@yahoo/uds 3.161.0 → 3.162.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/components/client/Checkbox/Checkbox.cjs +118 -0
  2. package/dist/components/client/{Checkbox.d.cts → Checkbox/Checkbox.d.cts} +5 -18
  3. package/dist/components/client/{Checkbox.d.ts → Checkbox/Checkbox.d.ts} +5 -18
  4. package/dist/components/client/Checkbox/Checkbox.js +113 -0
  5. package/dist/components/client/Checkbox/CheckboxBase.cjs +141 -0
  6. package/dist/components/client/Checkbox/CheckboxBase.d.cts +48 -0
  7. package/dist/components/client/Checkbox/CheckboxBase.d.ts +49 -0
  8. package/dist/components/client/Checkbox/CheckboxBase.js +138 -0
  9. package/dist/components/client/Checkbox/checkboxConstants.cjs +23 -0
  10. package/dist/components/client/Checkbox/checkboxConstants.d.cts +25 -0
  11. package/dist/components/client/Checkbox/checkboxConstants.d.ts +26 -0
  12. package/dist/components/client/Checkbox/checkboxConstants.js +17 -0
  13. package/dist/components/client/Checkbox/index.cjs +10 -0
  14. package/dist/components/client/Checkbox/index.d.cts +6 -0
  15. package/dist/components/client/Checkbox/index.d.ts +7 -0
  16. package/dist/components/client/Checkbox/index.js +6 -0
  17. package/dist/components/client/Checkbox/types.cjs +2 -0
  18. package/dist/components/client/Checkbox/types.d.cts +22 -0
  19. package/dist/components/client/Checkbox/types.d.ts +23 -0
  20. package/dist/components/client/Checkbox/types.js +2 -0
  21. package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
  22. package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
  23. package/dist/components/client/Popover/UDSPopoverConfigProvider.d.cts +1 -1
  24. package/dist/components/client/Popover/UDSPopoverConfigProvider.d.ts +1 -1
  25. package/dist/components/client/Radio/Radio.cjs +67 -164
  26. package/dist/components/client/Radio/Radio.d.cts +4 -17
  27. package/dist/components/client/Radio/Radio.d.ts +4 -17
  28. package/dist/components/client/Radio/Radio.js +66 -163
  29. package/dist/components/client/Radio/RadioBase.cjs +133 -0
  30. package/dist/components/client/Radio/RadioBase.d.cts +45 -0
  31. package/dist/components/client/Radio/RadioBase.d.ts +46 -0
  32. package/dist/components/client/Radio/RadioBase.js +130 -0
  33. package/dist/components/client/Radio/radioConstants.cjs +14 -0
  34. package/dist/components/client/Radio/radioConstants.d.cts +8 -0
  35. package/dist/components/client/Radio/radioConstants.d.ts +9 -0
  36. package/dist/components/client/Radio/radioConstants.js +11 -0
  37. package/dist/components/client/Radio/types.cjs +2 -0
  38. package/dist/components/client/Radio/types.d.cts +20 -0
  39. package/dist/components/client/Radio/types.d.ts +21 -0
  40. package/dist/components/client/Radio/types.js +2 -0
  41. package/dist/components/client/Toast/UDSToastConfigProvider.d.cts +1 -1
  42. package/dist/components/client/Toast/UDSToastConfigProvider.d.ts +1 -1
  43. package/dist/components/client/index.cjs +2 -2
  44. package/dist/components/client/index.d.cts +1 -1
  45. package/dist/components/client/index.d.ts +1 -1
  46. package/dist/components/client/index.js +1 -1
  47. package/dist/components/index.cjs +2 -2
  48. package/dist/components/index.d.cts +1 -1
  49. package/dist/components/index.d.ts +1 -1
  50. package/dist/components/index.js +1 -1
  51. package/dist/css-animation/Checkbox/Checkbox.cjs +75 -0
  52. package/dist/css-animation/Checkbox/Checkbox.d.cts +22 -0
  53. package/dist/css-animation/Checkbox/Checkbox.d.ts +23 -0
  54. package/dist/css-animation/Checkbox/Checkbox.js +72 -0
  55. package/dist/css-animation/Checkbox/index.cjs +5 -0
  56. package/dist/css-animation/Checkbox/index.d.cts +3 -0
  57. package/dist/css-animation/Checkbox/index.d.ts +4 -0
  58. package/dist/css-animation/Checkbox/index.js +4 -0
  59. package/dist/css-animation/Radio/Radio.cjs +92 -0
  60. package/dist/css-animation/Radio/Radio.d.cts +22 -0
  61. package/dist/css-animation/Radio/Radio.d.ts +23 -0
  62. package/dist/css-animation/Radio/Radio.js +89 -0
  63. package/dist/css-animation/Radio/index.cjs +5 -0
  64. package/dist/css-animation/Radio/index.d.cts +3 -0
  65. package/dist/css-animation/Radio/index.d.ts +4 -0
  66. package/dist/css-animation/Radio/index.js +4 -0
  67. package/dist/css-animation/index.cjs +4 -0
  68. package/dist/css-animation/index.d.cts +3 -1
  69. package/dist/css-animation/index.d.ts +3 -1
  70. package/dist/css-animation/index.js +3 -1
  71. package/dist/index.cjs +2 -2
  72. package/dist/index.d.cts +1 -1
  73. package/dist/index.d.ts +1 -1
  74. package/dist/index.js +1 -1
  75. package/dist/styles/styler.d.cts +43 -43
  76. package/dist/styles/styler.d.ts +43 -43
  77. package/dist/uds/generated/componentData.cjs +2501 -2451
  78. package/dist/uds/generated/componentData.js +2501 -2451
  79. package/dist/uds/generated/tailwindPurge.cjs +12 -12
  80. package/dist/uds/generated/tailwindPurge.js +12 -12
  81. package/generated/componentData.json +3275 -3186
  82. package/generated/tailwindPurge.ts +2 -2
  83. package/package.json +1 -1
  84. package/dist/components/client/Checkbox.cjs +0 -224
  85. package/dist/components/client/Checkbox.js +0 -219
@@ -2,21 +2,16 @@
2
2
  "use client";
3
3
  import { cx, getStyles } from "../../../styles/styler.js";
4
4
  import { Box } from "../../Box.js";
5
- import { FormLabel } from "../../FormLabel.js";
6
5
  import { usePrefersReducedMotion } from "../../../hooks/usePrefersReducedMotion.js";
7
6
  import { SpringMotionConfig } from "../SpringMotionConfig.js";
8
- import { useRadioGroup } from "./useRadioGroup.js";
9
- import { forwardRef, useCallback, useId, useMemo, useRef, useState } from "react";
7
+ import { RADIO_SIZES, RADIO_VARIANTS } from "./radioConstants.js";
8
+ import { RadioBase } from "./RadioBase.js";
9
+ import { forwardRef } from "react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
11
  import { m } from "motion/react";
12
12
  //#region src/components/client/Radio/Radio.tsx
13
- const RADIO_VARIANTS = ["primary", "secondary"];
14
- const RADIO_SIZES = ["sm", "md"];
15
- const VARIANT_ERROR_MAP = {
16
- primary: "alert",
17
- secondary: "alert-secondary"
18
- };
19
13
  const MotionBox = m.create(Box);
14
+ MotionBox.displayName = "RadioMotionBox";
20
15
  const hoverTransition = {
21
16
  layoutVariant: "smooth",
22
17
  layoutSpeed: "3"
@@ -49,175 +44,83 @@ const pressTransition = {
49
44
  *
50
45
  * @related [Radio](https://uds.build/docs/components/Radio).
51
46
  **/
52
- const Radio = forwardRef(function Radio({ id, name: nameProp, label, labelPosition = "start", variant: variantProp = "primary", size = "md", reduceMotion: forceReduceMotion, value: valueProp = "", checked: checkedProp, defaultChecked, disabled, hasError, onChange, onFocus, onBlur, className, style, slotProps, ...radioProps }, parentRef) {
53
- const generatedId = useId();
54
- const uid = id ?? `uds-radio-${generatedId}`;
55
- const rootSlotProps = slotProps?.root ?? {};
56
- const radioSlotProps = slotProps?.radio ?? {};
57
- const radioIconSlotProps = slotProps?.radioIcon ?? {};
58
- const labelSlotProps = slotProps?.label ?? {};
59
- const innerRef = useRef(null);
60
- /**
61
- * State
62
- */
63
- const { name, isControlled, checked, setGroupValue } = useRadioGroup({
64
- name: nameProp,
65
- value: valueProp,
66
- checked: checkedProp,
67
- defaultChecked
68
- });
69
- const [isHovered, setIsHovered] = useState(false);
70
- const [isPressed, setIsPressed] = useState(false);
71
- /**
72
- * Derived values
73
- */
74
- const variant = useMemo(() => hasError ? VARIANT_ERROR_MAP[variantProp] : variantProp, [hasError, variantProp]);
75
- const showHoverEffect = useMemo(() => !disabled && isHovered, [disabled, isHovered]);
76
- const showPressedEffect = useMemo(() => !disabled && !checked && isPressed, [
77
- checked,
78
- disabled,
79
- isPressed
80
- ]);
81
- const scale = useMemo(() => showPressedEffect ? .9 : showHoverEffect ? 1.1 : 1, [showHoverEffect, showPressedEffect]);
82
- const checkOpacity = useMemo(() => checked ? showPressedEffect ? "opacity-55" : "opacity-100" : "opacity-0", [checked, showPressedEffect]);
83
- const showShadow = useMemo(() => {
84
- return !disabled && (showPressedEffect && !checked || showHoverEffect && checked);
85
- }, [
86
- checked,
87
- disabled,
88
- showHoverEffect,
89
- showPressedEffect
90
- ]);
91
- const motionAnimate = useMemo(() => ({ scale }), [scale]);
92
- const motionTransition = useMemo(() => isPressed ? pressTransition : hoverTransition, [isPressed]);
93
- /**
94
- * Handlers
95
- */
96
- const handleOnChange = useCallback((e) => {
97
- setGroupValue(e.target.value);
98
- onChange?.(e);
99
- }, [onChange, setGroupValue]);
100
- const handleFocus = useCallback((e) => {
101
- onFocus?.(e);
102
- }, [onFocus]);
103
- const handleBlur = useCallback((e) => {
104
- onBlur?.(e);
105
- }, [onBlur]);
106
- const handleHoverStart = useCallback(() => {
107
- setIsHovered(true);
108
- }, []);
109
- const handleHoverEnd = useCallback(() => {
110
- setIsHovered(false);
111
- }, []);
112
- const handleTapStart = useCallback(() => {
113
- setIsPressed(true);
114
- }, []);
115
- const handleTapEnd = useCallback(() => {
116
- setIsPressed(false);
117
- }, []);
47
+ const Radio = forwardRef(function Radio({ reduceMotion: forceReduceMotion, ...props }, parentRef) {
118
48
  const prefersReducedMotion = usePrefersReducedMotion();
119
49
  const reduceMotion = forceReduceMotion ? "always" : "user";
120
50
  const cssAnimationDuration = prefersReducedMotion || forceReduceMotion ? "duration-0" : "duration-120";
121
- const classNames = {
122
- root: getStyles({
123
- radioSizeRoot: size,
124
- radioVariantValueRoot: checked ? "checked" : "unchecked",
125
- radioVariantRoot: variant,
126
- display: "flex",
127
- flexDirection: labelPosition === "start" ? "row" : "row-reverse",
128
- alignItems: "center",
129
- className: cx([{
130
- "cursor-pointer": !disabled,
131
- "cursor-default": disabled,
132
- "opacity-50": disabled
133
- }, className])
134
- }),
135
- radio: getStyles({
136
- radioSizeRadio: size,
137
- radioVariantRadio: variant,
138
- radioVariantValueRadio: checked ? "checked" : "unchecked",
139
- className: cx([
140
- "border",
141
- "uds-ring",
142
- "uds-ring-within",
143
- cssAnimationDuration,
144
- "transition-[background-color,border-color]",
145
- "transition-shadow"
146
- ])
147
- }),
148
- radioCircle: getStyles({
149
- radioVariantRadioCircle: variant,
150
- radioVariantValueRadioCircle: checked ? "checked" : "unchecked",
151
- className: cx([
152
- "pointer-events-none",
153
- "w-[8px]",
154
- "h-[8px]",
155
- checkOpacity,
156
- cssAnimationDuration,
157
- "transition-opacity"
158
- ])
159
- }),
160
- htmlRadio: cx("cursor-[inherit]", "absolute", "opacity-0", "top-1/2", "left-1/2", "w-[calc(100%+2px)]", "h-[calc(100%+2px)]", "transform", "translate-x-[-50%]", "translate-y-[-50%]"),
161
- label: cx(labelPosition === "start" ? "text-start" : "text-end")
162
- };
163
- const RootElement = label ? m.label : m.div;
164
- return /* @__PURE__ */ jsx(SpringMotionConfig, {
165
- reducedMotion: reduceMotion,
166
- ...motionTransition,
167
- children: /* @__PURE__ */ jsxs(RootElement, {
168
- className: classNames.root,
169
- "data-testid": "container",
170
- style,
171
- onHoverStart: handleHoverStart,
172
- onHoverEnd: handleHoverEnd,
173
- onTapStart: handleTapStart,
174
- onTap: handleTapEnd,
175
- onTapCancel: handleTapEnd,
176
- tabIndex: -1,
177
- ...rootSlotProps,
178
- children: [/* @__PURE__ */ jsxs(MotionBox, {
51
+ return /* @__PURE__ */ jsx(RadioBase, {
52
+ ...props,
53
+ ref: parentRef,
54
+ cssAnimationDuration,
55
+ enableInteractionTracking: true,
56
+ renderRoot: ({ className, style, rootSlotProps, hasLabel, isPressed, onHoverStart, onHoverEnd, onTapStart, onTapEnd, children }) => {
57
+ const RootElement = hasLabel ? m.label : m.div;
58
+ return /* @__PURE__ */ jsx(SpringMotionConfig, {
59
+ reducedMotion: reduceMotion,
60
+ ...isPressed ? pressTransition : hoverTransition,
61
+ children: /* @__PURE__ */ jsx(RootElement, {
62
+ className,
63
+ "data-testid": "container",
64
+ style,
65
+ onHoverStart,
66
+ onHoverEnd,
67
+ onTapStart,
68
+ onTap: onTapEnd,
69
+ onTapCancel: onTapEnd,
70
+ tabIndex: -1,
71
+ ...rootSlotProps,
72
+ children
73
+ })
74
+ });
75
+ },
76
+ renderIndicator: ({ size, variant, checked, disabled, showHoverEffect, showPressedEffect, cssAnimationDuration, radioSlotProps, radioIconSlotProps, children }) => {
77
+ const scale = showPressedEffect ? .9 : showHoverEffect ? 1.1 : 1;
78
+ const checkOpacity = checked ? showPressedEffect ? cx("opacity-55") : cx("opacity-100") : cx("opacity-0");
79
+ const showShadow = !disabled && (showPressedEffect && !checked || showHoverEffect && checked);
80
+ const classNames = {
81
+ radio: getStyles({
82
+ radioSizeRadio: size,
83
+ radioVariantRadio: variant,
84
+ radioVariantValueRadio: checked ? "checked" : "unchecked",
85
+ className: cx([
86
+ "border",
87
+ "uds-ring",
88
+ "uds-ring-within",
89
+ cssAnimationDuration,
90
+ "transition-[background-color,border-color]",
91
+ "transition-shadow"
92
+ ])
93
+ }),
94
+ radioCircle: getStyles({
95
+ radioVariantRadioCircle: variant,
96
+ radioVariantValueRadioCircle: checked ? "checked" : "unchecked",
97
+ className: cx([
98
+ "pointer-events-none",
99
+ "w-[8px]",
100
+ "h-[8px]",
101
+ checkOpacity,
102
+ cssAnimationDuration,
103
+ "transition-opacity"
104
+ ])
105
+ })
106
+ };
107
+ return /* @__PURE__ */ jsxs(MotionBox, {
179
108
  position: "relative",
180
109
  borderRadius: "full",
181
110
  alignItems: "center",
182
111
  justifyContent: "center",
183
112
  flex: "none",
184
113
  className: classNames.radio,
185
- animate: motionAnimate,
114
+ animate: { scale },
186
115
  insetShadow: showShadow ? "lg-invert" : "none",
187
116
  ...radioSlotProps,
188
- children: [/* @__PURE__ */ jsx("input", {
189
- type: "radio",
190
- tabIndex: 0,
191
- ...radioProps,
192
- ref: (ref) => {
193
- innerRef.current = ref;
194
- if (typeof parentRef === "function") parentRef(ref);
195
- else if (parentRef !== null) parentRef.current = ref;
196
- },
197
- onFocus: handleFocus,
198
- onBlur: handleBlur,
199
- id: uid,
200
- name,
201
- value: valueProp,
202
- disabled,
203
- "aria-invalid": hasError,
204
- onChange: handleOnChange,
205
- ...isControlled ? { checked } : { defaultChecked },
206
- className: classNames.htmlRadio
207
- }), /* @__PURE__ */ jsx(Box, {
117
+ children: [children, /* @__PURE__ */ jsx(Box, {
208
118
  borderRadius: "full",
209
119
  className: classNames.radioCircle,
210
120
  ...radioIconSlotProps
211
121
  })]
212
- }), label && /* @__PURE__ */ jsx(FormLabel, {
213
- as: "div",
214
- variant: "inherit",
215
- color: "inherit",
216
- label,
217
- className: classNames.label,
218
- ...labelSlotProps
219
- })]
220
- })
122
+ });
123
+ }
221
124
  });
222
125
  });
223
126
  Radio.displayName = "Radio";
@@ -0,0 +1,133 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
5
+ const require_styles_styler = require("../../../styles/styler.cjs");
6
+ const require_components_FormLabel = require("../../FormLabel.cjs");
7
+ const require_components_client_Radio_radioConstants = require("./radioConstants.cjs");
8
+ const require_components_client_Radio_useRadioGroup = require("./useRadioGroup.cjs");
9
+ let react = require("react");
10
+ react = require_runtime.__toESM(react);
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ //#region src/components/client/Radio/RadioBase.tsx
13
+ const RadioBase = (0, react.forwardRef)(function RadioBase({ id, name: nameProp, label, labelPosition = "start", variant: variantProp = "primary", size = "md", reduceMotion: _reduceMotion, value: valueProp = "", checked: checkedProp, defaultChecked, disabled, hasError, onChange, onFocus, onBlur, className, style, slotProps, cssAnimationDuration, enableInteractionTracking = false, renderRoot, renderIndicator, ...radioProps }, parentRef) {
14
+ const generatedId = (0, react.useId)();
15
+ const uid = id ?? `uds-radio-${generatedId}`;
16
+ const rootSlotProps = slotProps?.root ?? {};
17
+ const radioSlotProps = slotProps?.radio ?? {};
18
+ const radioIconSlotProps = slotProps?.radioIcon ?? {};
19
+ const labelSlotProps = slotProps?.label ?? {};
20
+ const innerRef = (0, react.useRef)(null);
21
+ /**
22
+ * State
23
+ */
24
+ const { name, isControlled, checked, setGroupValue } = require_components_client_Radio_useRadioGroup.useRadioGroup({
25
+ name: nameProp,
26
+ value: valueProp,
27
+ checked: checkedProp,
28
+ defaultChecked
29
+ });
30
+ const [isHovered, setIsHovered] = (0, react.useState)(false);
31
+ const [isPressed, setIsPressed] = (0, react.useState)(false);
32
+ /**
33
+ * Derived values
34
+ */
35
+ const variant = (0, react.useMemo)(() => hasError ? require_components_client_Radio_radioConstants.VARIANT_ERROR_MAP[variantProp] : variantProp, [hasError, variantProp]);
36
+ const showHoverEffect = enableInteractionTracking && !disabled && isHovered;
37
+ const showPressedEffect = enableInteractionTracking && !disabled && !checked && isPressed;
38
+ /**
39
+ * Handlers
40
+ */
41
+ const handleOnChange = (0, react.useCallback)((e) => {
42
+ setGroupValue(e.target.value);
43
+ onChange?.(e);
44
+ }, [onChange, setGroupValue]);
45
+ const handleFocus = (0, react.useCallback)((e) => {
46
+ onFocus?.(e);
47
+ }, [onFocus]);
48
+ const handleBlur = (0, react.useCallback)((e) => {
49
+ onBlur?.(e);
50
+ }, [onBlur]);
51
+ const handleHoverStart = (0, react.useCallback)(() => {
52
+ if (enableInteractionTracking) setIsHovered(true);
53
+ }, [enableInteractionTracking]);
54
+ const handleHoverEnd = (0, react.useCallback)(() => {
55
+ if (enableInteractionTracking) setIsHovered(false);
56
+ }, [enableInteractionTracking]);
57
+ const handleTapStart = (0, react.useCallback)(() => {
58
+ if (enableInteractionTracking) setIsPressed(true);
59
+ }, [enableInteractionTracking]);
60
+ const handleTapEnd = (0, react.useCallback)(() => {
61
+ if (enableInteractionTracking) setIsPressed(false);
62
+ }, [enableInteractionTracking]);
63
+ const classNames = {
64
+ root: require_styles_styler.getStyles({
65
+ radioSizeRoot: size,
66
+ radioVariantValueRoot: checked ? "checked" : "unchecked",
67
+ radioVariantRoot: variant,
68
+ display: "flex",
69
+ flexDirection: labelPosition === "start" ? "row" : "row-reverse",
70
+ alignItems: "center",
71
+ className: require_styles_styler.cx([{
72
+ "cursor-pointer": !disabled,
73
+ "cursor-default": disabled,
74
+ "opacity-50": disabled
75
+ }, className])
76
+ }),
77
+ htmlRadio: require_styles_styler.cx("cursor-[inherit]", "absolute", "opacity-0", "top-1/2", "left-1/2", "w-[calc(100%+2px)]", "h-[calc(100%+2px)]", "transform", "translate-x-[-50%]", "translate-y-[-50%]"),
78
+ label: require_styles_styler.cx(labelPosition === "start" ? "text-start" : "text-end")
79
+ };
80
+ const input = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
81
+ type: "radio",
82
+ tabIndex: 0,
83
+ ...radioProps,
84
+ ref: (ref) => {
85
+ innerRef.current = ref;
86
+ if (typeof parentRef === "function") parentRef(ref);
87
+ else if (parentRef !== null) parentRef.current = ref;
88
+ },
89
+ onFocus: handleFocus,
90
+ onBlur: handleBlur,
91
+ id: uid,
92
+ name,
93
+ value: valueProp,
94
+ disabled,
95
+ "aria-invalid": hasError,
96
+ onChange: handleOnChange,
97
+ ...isControlled ? { checked } : { defaultChecked },
98
+ className: classNames.htmlRadio
99
+ });
100
+ return renderRoot({
101
+ className: classNames.root,
102
+ style,
103
+ rootSlotProps,
104
+ hasLabel: Boolean(label),
105
+ isPressed,
106
+ onHoverStart: handleHoverStart,
107
+ onHoverEnd: handleHoverEnd,
108
+ onTapStart: handleTapStart,
109
+ onTapEnd: handleTapEnd,
110
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderIndicator({
111
+ size,
112
+ variant,
113
+ checked: Boolean(checked),
114
+ disabled,
115
+ showHoverEffect,
116
+ showPressedEffect,
117
+ cssAnimationDuration,
118
+ radioSlotProps,
119
+ radioIconSlotProps,
120
+ children: input
121
+ }), label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_FormLabel.FormLabel, {
122
+ as: "div",
123
+ variant: "inherit",
124
+ color: "inherit",
125
+ label,
126
+ className: classNames.label,
127
+ ...labelSlotProps
128
+ })] })
129
+ });
130
+ });
131
+ RadioBase.displayName = "RadioBase";
132
+ //#endregion
133
+ exports.RadioBase = RadioBase;
@@ -0,0 +1,45 @@
1
+
2
+ import { RadioVariant } from "../../../types/dist/index.cjs";
3
+ import { DataAttributes, RadioProps } from "./types.cjs";
4
+ import React, { CSSProperties, ReactNode } from "react";
5
+
6
+ //#region src/components/client/Radio/RadioBase.d.ts
7
+ type ResolvedRadioVariant = RadioVariant | 'alert' | 'alert-secondary';
8
+ type RenderRootArgs = {
9
+ className: string;
10
+ style?: CSSProperties;
11
+ rootSlotProps: DataAttributes;
12
+ hasLabel: boolean;
13
+ isPressed: boolean;
14
+ onHoverStart: () => void;
15
+ onHoverEnd: () => void;
16
+ onTapStart: () => void;
17
+ onTapEnd: () => void;
18
+ children: ReactNode;
19
+ };
20
+ type RenderIndicatorArgs = {
21
+ size: NonNullable<RadioProps['size']>;
22
+ variant: ResolvedRadioVariant;
23
+ checked: boolean;
24
+ disabled?: boolean;
25
+ showHoverEffect: boolean;
26
+ showPressedEffect: boolean;
27
+ cssAnimationDuration: string;
28
+ radioSlotProps: DataAttributes;
29
+ radioIconSlotProps: DataAttributes;
30
+ children: ReactNode;
31
+ };
32
+ type RadioBaseProps = RadioProps & {
33
+ cssAnimationDuration: string;
34
+ enableInteractionTracking?: boolean;
35
+ renderRoot: (args: RenderRootArgs) => ReactNode;
36
+ renderIndicator: (args: RenderIndicatorArgs) => ReactNode;
37
+ };
38
+ declare const RadioBase: React.ForwardRefExoticComponent<RadioProps & {
39
+ cssAnimationDuration: string;
40
+ enableInteractionTracking?: boolean;
41
+ renderRoot: (args: RenderRootArgs) => ReactNode;
42
+ renderIndicator: (args: RenderIndicatorArgs) => ReactNode;
43
+ } & React.RefAttributes<HTMLInputElement>>;
44
+ //#endregion
45
+ export { RadioBase, type RadioBaseProps, type RenderIndicatorArgs, type RenderRootArgs, type ResolvedRadioVariant };
@@ -0,0 +1,46 @@
1
+
2
+ "use client";
3
+ import { RadioVariant } from "../../../types/dist/index.js";
4
+ import { DataAttributes, RadioProps } from "./types.js";
5
+ import React, { CSSProperties, ReactNode } from "react";
6
+
7
+ //#region src/components/client/Radio/RadioBase.d.ts
8
+ type ResolvedRadioVariant = RadioVariant | 'alert' | 'alert-secondary';
9
+ type RenderRootArgs = {
10
+ className: string;
11
+ style?: CSSProperties;
12
+ rootSlotProps: DataAttributes;
13
+ hasLabel: boolean;
14
+ isPressed: boolean;
15
+ onHoverStart: () => void;
16
+ onHoverEnd: () => void;
17
+ onTapStart: () => void;
18
+ onTapEnd: () => void;
19
+ children: ReactNode;
20
+ };
21
+ type RenderIndicatorArgs = {
22
+ size: NonNullable<RadioProps['size']>;
23
+ variant: ResolvedRadioVariant;
24
+ checked: boolean;
25
+ disabled?: boolean;
26
+ showHoverEffect: boolean;
27
+ showPressedEffect: boolean;
28
+ cssAnimationDuration: string;
29
+ radioSlotProps: DataAttributes;
30
+ radioIconSlotProps: DataAttributes;
31
+ children: ReactNode;
32
+ };
33
+ type RadioBaseProps = RadioProps & {
34
+ cssAnimationDuration: string;
35
+ enableInteractionTracking?: boolean;
36
+ renderRoot: (args: RenderRootArgs) => ReactNode;
37
+ renderIndicator: (args: RenderIndicatorArgs) => ReactNode;
38
+ };
39
+ declare const RadioBase: React.ForwardRefExoticComponent<RadioProps & {
40
+ cssAnimationDuration: string;
41
+ enableInteractionTracking?: boolean;
42
+ renderRoot: (args: RenderRootArgs) => ReactNode;
43
+ renderIndicator: (args: RenderIndicatorArgs) => ReactNode;
44
+ } & React.RefAttributes<HTMLInputElement>>;
45
+ //#endregion
46
+ export { RadioBase, type RadioBaseProps, type RenderIndicatorArgs, type RenderRootArgs, type ResolvedRadioVariant };
@@ -0,0 +1,130 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ import { cx, getStyles } from "../../../styles/styler.js";
4
+ import { FormLabel } from "../../FormLabel.js";
5
+ import { VARIANT_ERROR_MAP } from "./radioConstants.js";
6
+ import { useRadioGroup } from "./useRadioGroup.js";
7
+ import { forwardRef, useCallback, useId, useMemo, useRef, useState } from "react";
8
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
+ //#region src/components/client/Radio/RadioBase.tsx
10
+ const RadioBase = forwardRef(function RadioBase({ id, name: nameProp, label, labelPosition = "start", variant: variantProp = "primary", size = "md", reduceMotion: _reduceMotion, value: valueProp = "", checked: checkedProp, defaultChecked, disabled, hasError, onChange, onFocus, onBlur, className, style, slotProps, cssAnimationDuration, enableInteractionTracking = false, renderRoot, renderIndicator, ...radioProps }, parentRef) {
11
+ const generatedId = useId();
12
+ const uid = id ?? `uds-radio-${generatedId}`;
13
+ const rootSlotProps = slotProps?.root ?? {};
14
+ const radioSlotProps = slotProps?.radio ?? {};
15
+ const radioIconSlotProps = slotProps?.radioIcon ?? {};
16
+ const labelSlotProps = slotProps?.label ?? {};
17
+ const innerRef = useRef(null);
18
+ /**
19
+ * State
20
+ */
21
+ const { name, isControlled, checked, setGroupValue } = useRadioGroup({
22
+ name: nameProp,
23
+ value: valueProp,
24
+ checked: checkedProp,
25
+ defaultChecked
26
+ });
27
+ const [isHovered, setIsHovered] = useState(false);
28
+ const [isPressed, setIsPressed] = useState(false);
29
+ /**
30
+ * Derived values
31
+ */
32
+ const variant = useMemo(() => hasError ? VARIANT_ERROR_MAP[variantProp] : variantProp, [hasError, variantProp]);
33
+ const showHoverEffect = enableInteractionTracking && !disabled && isHovered;
34
+ const showPressedEffect = enableInteractionTracking && !disabled && !checked && isPressed;
35
+ /**
36
+ * Handlers
37
+ */
38
+ const handleOnChange = useCallback((e) => {
39
+ setGroupValue(e.target.value);
40
+ onChange?.(e);
41
+ }, [onChange, setGroupValue]);
42
+ const handleFocus = useCallback((e) => {
43
+ onFocus?.(e);
44
+ }, [onFocus]);
45
+ const handleBlur = useCallback((e) => {
46
+ onBlur?.(e);
47
+ }, [onBlur]);
48
+ const handleHoverStart = useCallback(() => {
49
+ if (enableInteractionTracking) setIsHovered(true);
50
+ }, [enableInteractionTracking]);
51
+ const handleHoverEnd = useCallback(() => {
52
+ if (enableInteractionTracking) setIsHovered(false);
53
+ }, [enableInteractionTracking]);
54
+ const handleTapStart = useCallback(() => {
55
+ if (enableInteractionTracking) setIsPressed(true);
56
+ }, [enableInteractionTracking]);
57
+ const handleTapEnd = useCallback(() => {
58
+ if (enableInteractionTracking) setIsPressed(false);
59
+ }, [enableInteractionTracking]);
60
+ const classNames = {
61
+ root: getStyles({
62
+ radioSizeRoot: size,
63
+ radioVariantValueRoot: checked ? "checked" : "unchecked",
64
+ radioVariantRoot: variant,
65
+ display: "flex",
66
+ flexDirection: labelPosition === "start" ? "row" : "row-reverse",
67
+ alignItems: "center",
68
+ className: cx([{
69
+ "cursor-pointer": !disabled,
70
+ "cursor-default": disabled,
71
+ "opacity-50": disabled
72
+ }, className])
73
+ }),
74
+ htmlRadio: cx("cursor-[inherit]", "absolute", "opacity-0", "top-1/2", "left-1/2", "w-[calc(100%+2px)]", "h-[calc(100%+2px)]", "transform", "translate-x-[-50%]", "translate-y-[-50%]"),
75
+ label: cx(labelPosition === "start" ? "text-start" : "text-end")
76
+ };
77
+ const input = /* @__PURE__ */ jsx("input", {
78
+ type: "radio",
79
+ tabIndex: 0,
80
+ ...radioProps,
81
+ ref: (ref) => {
82
+ innerRef.current = ref;
83
+ if (typeof parentRef === "function") parentRef(ref);
84
+ else if (parentRef !== null) parentRef.current = ref;
85
+ },
86
+ onFocus: handleFocus,
87
+ onBlur: handleBlur,
88
+ id: uid,
89
+ name,
90
+ value: valueProp,
91
+ disabled,
92
+ "aria-invalid": hasError,
93
+ onChange: handleOnChange,
94
+ ...isControlled ? { checked } : { defaultChecked },
95
+ className: classNames.htmlRadio
96
+ });
97
+ return renderRoot({
98
+ className: classNames.root,
99
+ style,
100
+ rootSlotProps,
101
+ hasLabel: Boolean(label),
102
+ isPressed,
103
+ onHoverStart: handleHoverStart,
104
+ onHoverEnd: handleHoverEnd,
105
+ onTapStart: handleTapStart,
106
+ onTapEnd: handleTapEnd,
107
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [renderIndicator({
108
+ size,
109
+ variant,
110
+ checked: Boolean(checked),
111
+ disabled,
112
+ showHoverEffect,
113
+ showPressedEffect,
114
+ cssAnimationDuration,
115
+ radioSlotProps,
116
+ radioIconSlotProps,
117
+ children: input
118
+ }), label && /* @__PURE__ */ jsx(FormLabel, {
119
+ as: "div",
120
+ variant: "inherit",
121
+ color: "inherit",
122
+ label,
123
+ className: classNames.label,
124
+ ...labelSlotProps
125
+ })] })
126
+ });
127
+ });
128
+ RadioBase.displayName = "RadioBase";
129
+ //#endregion
130
+ export { RadioBase };
@@ -0,0 +1,14 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ //#region src/components/client/Radio/radioConstants.ts
5
+ const RADIO_VARIANTS = ["primary", "secondary"];
6
+ const RADIO_SIZES = ["sm", "md"];
7
+ const VARIANT_ERROR_MAP = {
8
+ primary: "alert",
9
+ secondary: "alert-secondary"
10
+ };
11
+ //#endregion
12
+ exports.RADIO_SIZES = RADIO_SIZES;
13
+ exports.RADIO_VARIANTS = RADIO_VARIANTS;
14
+ exports.VARIANT_ERROR_MAP = VARIANT_ERROR_MAP;
@@ -0,0 +1,8 @@
1
+
2
+ import { RadioSize, RadioVariant } from "../../../types/dist/index.cjs";
3
+ //#region src/components/client/Radio/radioConstants.d.ts
4
+ declare const RADIO_VARIANTS: RadioVariant[];
5
+ declare const RADIO_SIZES: RadioSize[];
6
+ declare const VARIANT_ERROR_MAP: Record<RadioVariant, 'alert' | 'alert-secondary'>;
7
+ //#endregion
8
+ export { RADIO_SIZES, RADIO_VARIANTS, VARIANT_ERROR_MAP };
@@ -0,0 +1,9 @@
1
+
2
+ "use client";
3
+ import { RadioSize, RadioVariant } from "../../../types/dist/index.js";
4
+ //#region src/components/client/Radio/radioConstants.d.ts
5
+ declare const RADIO_VARIANTS: RadioVariant[];
6
+ declare const RADIO_SIZES: RadioSize[];
7
+ declare const VARIANT_ERROR_MAP: Record<RadioVariant, 'alert' | 'alert-secondary'>;
8
+ //#endregion
9
+ export { RADIO_SIZES, RADIO_VARIANTS, VARIANT_ERROR_MAP };
@@ -0,0 +1,11 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ //#region src/components/client/Radio/radioConstants.ts
4
+ const RADIO_VARIANTS = ["primary", "secondary"];
5
+ const RADIO_SIZES = ["sm", "md"];
6
+ const VARIANT_ERROR_MAP = {
7
+ primary: "alert",
8
+ secondary: "alert-secondary"
9
+ };
10
+ //#endregion
11
+ export { RADIO_SIZES, RADIO_VARIANTS, VARIANT_ERROR_MAP };
@@ -0,0 +1,2 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";