@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
@@ -0,0 +1,118 @@
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_Icon = require("../../Icon.cjs");
7
+ const require_components_Box = require("../../Box.cjs");
8
+ const require_hooks_usePrefersReducedMotion = require("../../../hooks/usePrefersReducedMotion.cjs");
9
+ const require_components_client_SpringMotionConfig = require("../SpringMotionConfig.cjs");
10
+ const require_components_client_Checkbox_checkboxConstants = require("./checkboxConstants.cjs");
11
+ const require_components_client_Checkbox_CheckboxBase = require("./CheckboxBase.cjs");
12
+ let react = require("react");
13
+ react = require_runtime.__toESM(react);
14
+ let react_jsx_runtime = require("react/jsx-runtime");
15
+ let motion_react = require("motion/react");
16
+ //#region src/components/client/Checkbox/Checkbox.tsx
17
+ const MotionBox = motion_react.m.create(require_components_Box.Box);
18
+ MotionBox.displayName = "CheckboxMotionBox";
19
+ const hoverTransition = {
20
+ layoutVariant: "smooth",
21
+ layoutSpeed: "3"
22
+ };
23
+ const pressTransition = {
24
+ layoutVariant: "veryBouncy",
25
+ layoutSpeed: "4"
26
+ };
27
+ /**
28
+ * **⚙️️ An checkbox.
29
+ *
30
+ * @componentType Client component
31
+ *
32
+ * @description
33
+ * A checkbox component allows users to select one or multiple options from a set. It represents a binary state, typically as checked or unchecked, and optionally includes a third "indeterminate" state to indicate partial selection.
34
+ *
35
+ * @see
36
+ * Check out the {@link https://uds.build/docs/components/checkbox Checkbox Docs} for more info
37
+ *
38
+ * @usage
39
+ * - Forms: checkbox
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * 'use client';
44
+ * import { Checkbox } from "@yahoo/uds";
45
+ *
46
+ * <Checkbox label="Name" required />
47
+ *```
48
+ *
49
+ * @related [Radio](https://uds.build/docs/components/radio), [Switch](https://uds.build/docs/components/switch), [Input](https://uds.build/docs/components/input).
50
+ **/
51
+ const Checkbox = (0, react.forwardRef)(function Checkbox({ reduceMotion: forceReduceMotion, ...props }, parentRef) {
52
+ const prefersReducedMotion = require_hooks_usePrefersReducedMotion.usePrefersReducedMotion();
53
+ const reduceMotion = forceReduceMotion ? "always" : "user";
54
+ const cssAnimationDuration = prefersReducedMotion || forceReduceMotion ? "duration-0" : "duration-120";
55
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_Checkbox_CheckboxBase.CheckboxBase, {
56
+ ...props,
57
+ ref: parentRef,
58
+ cssAnimationDuration,
59
+ enableInteractionTracking: true,
60
+ renderRoot: ({ className, style, rootSlotProps, hasLabel, isPressed, onHoverStart, onHoverEnd, onTapStart, onTapEnd, children }) => {
61
+ const RootElement = hasLabel ? motion_react.m.label : motion_react.m.div;
62
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
63
+ reducedMotion: reduceMotion,
64
+ ...isPressed ? pressTransition : hoverTransition,
65
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RootElement, {
66
+ className,
67
+ "data-testid": "container",
68
+ style,
69
+ onHoverStart,
70
+ onHoverEnd,
71
+ onTapStart,
72
+ onTap: onTapEnd,
73
+ onTapCancel: onTapEnd,
74
+ tabIndex: -1,
75
+ ...rootSlotProps,
76
+ children
77
+ })
78
+ });
79
+ },
80
+ renderIndicator: ({ size, variant, valueState, checked, showHoverEffect, showPressedEffect, cssAnimationDuration, checkIcon, checkboxSlotProps, iconSlotProps, children }) => {
81
+ const scale = showPressedEffect ? .9 : showHoverEffect ? 1.1 : 1;
82
+ const checkOpacity = !checked ? require_styles_styler.cx("opacity-0") : showPressedEffect ? require_styles_styler.cx("opacity-55") : require_styles_styler.cx("opacity-100");
83
+ const classNames = {
84
+ checkbox: require_styles_styler.getStyles({
85
+ checkboxSizeCheckbox: size,
86
+ checkboxVariantCheckbox: variant,
87
+ checkboxVariantValueCheckbox: valueState,
88
+ className: require_styles_styler.cx("uds-ring", "uds-ring-within", cssAnimationDuration, "transition-[background-color,border-color,box-shadow]")
89
+ }),
90
+ check: require_styles_styler.getStyles({
91
+ checkboxVariantCheckboxIcon: variant,
92
+ checkboxVariantValueCheckboxIcon: valueState,
93
+ className: require_styles_styler.cx("pointer-events-none", checkOpacity, cssAnimationDuration, "transition-opacity")
94
+ })
95
+ };
96
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(MotionBox, {
97
+ position: "relative",
98
+ className: classNames.checkbox,
99
+ alignItems: "center",
100
+ justifyContent: "center",
101
+ flex: "none",
102
+ animate: { scale },
103
+ ...checkboxSlotProps,
104
+ children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
105
+ name: checkIcon,
106
+ size: "sm",
107
+ className: classNames.check,
108
+ ...iconSlotProps
109
+ })]
110
+ });
111
+ }
112
+ });
113
+ });
114
+ Checkbox.displayName = "Checkbox";
115
+ //#endregion
116
+ exports.Checkbox = Checkbox;
117
+ exports.SIZES = require_components_client_Checkbox_checkboxConstants.SIZES;
118
+ exports.VARIANTS = require_components_client_Checkbox_checkboxConstants.VARIANTS;
@@ -1,23 +1,10 @@
1
1
 
2
- import { UniversalCheckboxProps } from "../../types/dist/index.cjs";
2
+ import { SIZES, VARIANTS } from "./checkboxConstants.cjs";
3
+ import { CheckboxProps as CheckboxProps$1 } from "./types.cjs";
3
4
  import React from "react";
4
5
 
5
- //#region src/components/client/Checkbox.d.ts
6
- type NativeInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'size' | 'height' | 'width' | 'color'>;
7
- type DataAttributes = {
8
- [name: `data-${string}`]: string;
9
- };
10
- interface CheckboxProps extends NativeInputProps, UniversalCheckboxProps {
11
- /** Props to be passed into various slots within the component. */
12
- slotProps?: {
13
- root?: DataAttributes;
14
- checkbox?: DataAttributes;
15
- icon?: DataAttributes;
16
- label?: DataAttributes;
17
- };
18
- }
19
- declare const VARIANTS: ("primary" | "secondary")[];
20
- declare const SIZES: ("sm" | "md")[];
6
+ //#region src/components/client/Checkbox/Checkbox.d.ts
7
+ type CheckboxProps = CheckboxProps$1;
21
8
  /**
22
9
  * **⚙️️ An checkbox.
23
10
  *
@@ -42,6 +29,6 @@ declare const SIZES: ("sm" | "md")[];
42
29
  *
43
30
  * @related [Radio](https://uds.build/docs/components/radio), [Switch](https://uds.build/docs/components/switch), [Input](https://uds.build/docs/components/input).
44
31
  **/
45
- declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
32
+ declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps$1 & React.RefAttributes<HTMLInputElement>>;
46
33
  //#endregion
47
34
  export { Checkbox, type CheckboxProps, SIZES, VARIANTS };
@@ -1,24 +1,11 @@
1
1
 
2
2
  "use client";
3
- import { UniversalCheckboxProps } from "../../types/dist/index.js";
3
+ import { SIZES, VARIANTS } from "./checkboxConstants.js";
4
+ import { CheckboxProps as CheckboxProps$1 } from "./types.js";
4
5
  import React from "react";
5
6
 
6
- //#region src/components/client/Checkbox.d.ts
7
- type NativeInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'size' | 'height' | 'width' | 'color'>;
8
- type DataAttributes = {
9
- [name: `data-${string}`]: string;
10
- };
11
- interface CheckboxProps extends NativeInputProps, UniversalCheckboxProps {
12
- /** Props to be passed into various slots within the component. */
13
- slotProps?: {
14
- root?: DataAttributes;
15
- checkbox?: DataAttributes;
16
- icon?: DataAttributes;
17
- label?: DataAttributes;
18
- };
19
- }
20
- declare const VARIANTS: ("primary" | "secondary")[];
21
- declare const SIZES: ("sm" | "md")[];
7
+ //#region src/components/client/Checkbox/Checkbox.d.ts
8
+ type CheckboxProps = CheckboxProps$1;
22
9
  /**
23
10
  * **⚙️️ An checkbox.
24
11
  *
@@ -43,6 +30,6 @@ declare const SIZES: ("sm" | "md")[];
43
30
  *
44
31
  * @related [Radio](https://uds.build/docs/components/radio), [Switch](https://uds.build/docs/components/switch), [Input](https://uds.build/docs/components/input).
45
32
  **/
46
- declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
33
+ declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps$1 & React.RefAttributes<HTMLInputElement>>;
47
34
  //#endregion
48
35
  export { Checkbox, type CheckboxProps, SIZES, VARIANTS };
@@ -0,0 +1,113 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ import { cx, getStyles } from "../../../styles/styler.js";
4
+ import { Icon } from "../../Icon.js";
5
+ import { Box } from "../../Box.js";
6
+ import { usePrefersReducedMotion } from "../../../hooks/usePrefersReducedMotion.js";
7
+ import { SpringMotionConfig } from "../SpringMotionConfig.js";
8
+ import { SIZES, VARIANTS } from "./checkboxConstants.js";
9
+ import { CheckboxBase } from "./CheckboxBase.js";
10
+ import { forwardRef } from "react";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ import { m } from "motion/react";
13
+ //#region src/components/client/Checkbox/Checkbox.tsx
14
+ const MotionBox = m.create(Box);
15
+ MotionBox.displayName = "CheckboxMotionBox";
16
+ const hoverTransition = {
17
+ layoutVariant: "smooth",
18
+ layoutSpeed: "3"
19
+ };
20
+ const pressTransition = {
21
+ layoutVariant: "veryBouncy",
22
+ layoutSpeed: "4"
23
+ };
24
+ /**
25
+ * **⚙️️ An checkbox.
26
+ *
27
+ * @componentType Client component
28
+ *
29
+ * @description
30
+ * A checkbox component allows users to select one or multiple options from a set. It represents a binary state, typically as checked or unchecked, and optionally includes a third "indeterminate" state to indicate partial selection.
31
+ *
32
+ * @see
33
+ * Check out the {@link https://uds.build/docs/components/checkbox Checkbox Docs} for more info
34
+ *
35
+ * @usage
36
+ * - Forms: checkbox
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * 'use client';
41
+ * import { Checkbox } from "@yahoo/uds";
42
+ *
43
+ * <Checkbox label="Name" required />
44
+ *```
45
+ *
46
+ * @related [Radio](https://uds.build/docs/components/radio), [Switch](https://uds.build/docs/components/switch), [Input](https://uds.build/docs/components/input).
47
+ **/
48
+ const Checkbox = forwardRef(function Checkbox({ reduceMotion: forceReduceMotion, ...props }, parentRef) {
49
+ const prefersReducedMotion = usePrefersReducedMotion();
50
+ const reduceMotion = forceReduceMotion ? "always" : "user";
51
+ const cssAnimationDuration = prefersReducedMotion || forceReduceMotion ? "duration-0" : "duration-120";
52
+ return /* @__PURE__ */ jsx(CheckboxBase, {
53
+ ...props,
54
+ ref: parentRef,
55
+ cssAnimationDuration,
56
+ enableInteractionTracking: true,
57
+ renderRoot: ({ className, style, rootSlotProps, hasLabel, isPressed, onHoverStart, onHoverEnd, onTapStart, onTapEnd, children }) => {
58
+ const RootElement = hasLabel ? m.label : m.div;
59
+ return /* @__PURE__ */ jsx(SpringMotionConfig, {
60
+ reducedMotion: reduceMotion,
61
+ ...isPressed ? pressTransition : hoverTransition,
62
+ children: /* @__PURE__ */ jsx(RootElement, {
63
+ className,
64
+ "data-testid": "container",
65
+ style,
66
+ onHoverStart,
67
+ onHoverEnd,
68
+ onTapStart,
69
+ onTap: onTapEnd,
70
+ onTapCancel: onTapEnd,
71
+ tabIndex: -1,
72
+ ...rootSlotProps,
73
+ children
74
+ })
75
+ });
76
+ },
77
+ renderIndicator: ({ size, variant, valueState, checked, showHoverEffect, showPressedEffect, cssAnimationDuration, checkIcon, checkboxSlotProps, iconSlotProps, children }) => {
78
+ const scale = showPressedEffect ? .9 : showHoverEffect ? 1.1 : 1;
79
+ const checkOpacity = !checked ? cx("opacity-0") : showPressedEffect ? cx("opacity-55") : cx("opacity-100");
80
+ const classNames = {
81
+ checkbox: getStyles({
82
+ checkboxSizeCheckbox: size,
83
+ checkboxVariantCheckbox: variant,
84
+ checkboxVariantValueCheckbox: valueState,
85
+ className: cx("uds-ring", "uds-ring-within", cssAnimationDuration, "transition-[background-color,border-color,box-shadow]")
86
+ }),
87
+ check: getStyles({
88
+ checkboxVariantCheckboxIcon: variant,
89
+ checkboxVariantValueCheckboxIcon: valueState,
90
+ className: cx("pointer-events-none", checkOpacity, cssAnimationDuration, "transition-opacity")
91
+ })
92
+ };
93
+ return /* @__PURE__ */ jsxs(MotionBox, {
94
+ position: "relative",
95
+ className: classNames.checkbox,
96
+ alignItems: "center",
97
+ justifyContent: "center",
98
+ flex: "none",
99
+ animate: { scale },
100
+ ...checkboxSlotProps,
101
+ children: [children, /* @__PURE__ */ jsx(Icon, {
102
+ name: checkIcon,
103
+ size: "sm",
104
+ className: classNames.check,
105
+ ...iconSlotProps
106
+ })]
107
+ });
108
+ }
109
+ });
110
+ });
111
+ Checkbox.displayName = "Checkbox";
112
+ //#endregion
113
+ export { Checkbox, SIZES, VARIANTS };
@@ -0,0 +1,141 @@
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_Checkbox_checkboxConstants = require("./checkboxConstants.cjs");
8
+ let react = require("react");
9
+ react = require_runtime.__toESM(react);
10
+ let react_jsx_runtime = require("react/jsx-runtime");
11
+ //#region src/components/client/Checkbox/CheckboxBase.tsx
12
+ const CheckboxBase = (0, react.forwardRef)(function CheckboxBase({ id, checked: checkedProp, defaultChecked, onChange, label, labelPosition = "start", variant: variantProp = "primary", size = "md", reduceMotion: _reduceMotion, disabled, required, hasError, className, style, slotProps, cssAnimationDuration, enableInteractionTracking = false, renderRoot, renderIndicator, ...checkboxProps }, parentRef) {
13
+ const generatedId = (0, react.useId)();
14
+ const uid = id ?? `uds-input-${generatedId}`;
15
+ const rootSlotProps = slotProps?.root ?? {};
16
+ const checkboxSlotProps = slotProps?.checkbox ?? {};
17
+ const iconSlotProps = slotProps?.icon ?? {};
18
+ const labelSlotProps = slotProps?.label ?? {};
19
+ const innerRef = (0, react.useRef)(null);
20
+ /**
21
+ * State
22
+ */
23
+ const isControlled = checkedProp !== void 0;
24
+ const [checked, setChecked] = (0, react.useState)(isControlled ? checkedProp : defaultChecked);
25
+ const [isHovered, setIsHovered] = (0, react.useState)(false);
26
+ const [isPressed, setIsPressed] = (0, react.useState)(false);
27
+ /**
28
+ * Derived values
29
+ */
30
+ const variant = (0, react.useMemo)(() => hasError ? require_components_client_Checkbox_checkboxConstants.VARIANT_ERROR_MAP[variantProp] : variantProp, [hasError, variantProp]);
31
+ const showHoverEffect = enableInteractionTracking && !disabled && isHovered;
32
+ const showPressedEffect = enableInteractionTracking && !disabled && isPressed;
33
+ /**
34
+ * Handlers
35
+ */
36
+ const handleChange = (0, react.useCallback)((e) => {
37
+ onChange?.(e);
38
+ if (!isControlled) setChecked(e.target.checked);
39
+ }, [isControlled, onChange]);
40
+ const handleHoverStart = (0, react.useCallback)(() => {
41
+ if (enableInteractionTracking) setIsHovered(true);
42
+ }, [enableInteractionTracking]);
43
+ const handleHoverEnd = (0, react.useCallback)(() => {
44
+ if (enableInteractionTracking) setIsHovered(false);
45
+ }, [enableInteractionTracking]);
46
+ const handleTapStart = (0, react.useCallback)(() => {
47
+ if (enableInteractionTracking) setIsPressed(true);
48
+ }, [enableInteractionTracking]);
49
+ const handleTapEnd = (0, react.useCallback)(() => {
50
+ if (enableInteractionTracking) setIsPressed(false);
51
+ }, [enableInteractionTracking]);
52
+ /**
53
+ * Helpers
54
+ */
55
+ const setDOMIndeterminate = (checked_) => {
56
+ if (!innerRef.current) return;
57
+ innerRef.current.indeterminate = require_components_client_Checkbox_checkboxConstants.isIndeterminate(checked_);
58
+ };
59
+ /**
60
+ * Effects
61
+ */
62
+ (0, react.useEffect)(() => {
63
+ if (isControlled) setChecked(checkedProp);
64
+ }, [checkedProp, isControlled]);
65
+ (0, react.useEffect)(() => {
66
+ setDOMIndeterminate(checked);
67
+ }, [checked]);
68
+ const valueState = require_components_client_Checkbox_checkboxConstants.isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
69
+ const classNames = {
70
+ root: require_styles_styler.getStyles({
71
+ checkboxSizeRoot: size,
72
+ checkboxVariantRoot: variant,
73
+ checkboxVariantValueRoot: valueState,
74
+ display: "flex",
75
+ flexDirection: labelPosition === "start" ? "row" : "row-reverse",
76
+ alignItems: "center",
77
+ className: require_styles_styler.cx({
78
+ "cursor-pointer": !disabled,
79
+ "cursor-default": disabled,
80
+ "opacity-50": disabled
81
+ }, className)
82
+ }),
83
+ htmlCheckbox: 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%]"),
84
+ label: require_styles_styler.cx(labelPosition === "start" ? "text-start" : "text-end")
85
+ };
86
+ const input = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
87
+ type: "checkbox",
88
+ tabIndex: 0,
89
+ ...checkboxProps,
90
+ ref: (ref) => {
91
+ innerRef.current = ref;
92
+ setDOMIndeterminate(checked);
93
+ if (typeof parentRef === "function") parentRef(ref);
94
+ else if (parentRef !== null) parentRef.current = ref;
95
+ },
96
+ id: uid,
97
+ disabled,
98
+ required,
99
+ "aria-invalid": hasError,
100
+ checked: isControlled ? require_components_client_Checkbox_checkboxConstants.isIndeterminate(checked) ? false : checked : void 0,
101
+ defaultChecked: isControlled ? void 0 : defaultChecked,
102
+ onChange: handleChange,
103
+ className: classNames.htmlCheckbox
104
+ });
105
+ return renderRoot({
106
+ className: classNames.root,
107
+ style,
108
+ rootSlotProps,
109
+ hasLabel: Boolean(label),
110
+ isPressed,
111
+ onHoverStart: handleHoverStart,
112
+ onHoverEnd: handleHoverEnd,
113
+ onTapStart: handleTapStart,
114
+ onTapEnd: handleTapEnd,
115
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderIndicator({
116
+ size,
117
+ variant,
118
+ valueState,
119
+ checked,
120
+ disabled,
121
+ showHoverEffect,
122
+ showPressedEffect,
123
+ cssAnimationDuration,
124
+ checkIcon: require_components_client_Checkbox_checkboxConstants.getIcon(checked),
125
+ checkboxSlotProps,
126
+ iconSlotProps,
127
+ children: input
128
+ }), label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_FormLabel.FormLabel, {
129
+ as: "div",
130
+ variant: "inherit",
131
+ color: "inherit",
132
+ required,
133
+ label,
134
+ className: classNames.label,
135
+ ...labelSlotProps
136
+ })] })
137
+ });
138
+ });
139
+ CheckboxBase.displayName = "CheckboxBase";
140
+ //#endregion
141
+ exports.CheckboxBase = CheckboxBase;
@@ -0,0 +1,48 @@
1
+
2
+ import { CheckboxVariant } from "../../../types/dist/index.cjs";
3
+ import { getIcon } from "./checkboxConstants.cjs";
4
+ import { CheckboxProps, CheckboxValueState, DataAttributes } from "./types.cjs";
5
+ import React, { CSSProperties, ReactNode } from "react";
6
+
7
+ //#region src/components/client/Checkbox/CheckboxBase.d.ts
8
+ type ResolvedCheckboxVariant = CheckboxVariant | '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<CheckboxProps['size']>;
23
+ variant: ResolvedCheckboxVariant;
24
+ valueState: CheckboxValueState;
25
+ checked: CheckboxProps['checked'];
26
+ disabled?: boolean;
27
+ showHoverEffect: boolean;
28
+ showPressedEffect: boolean;
29
+ cssAnimationDuration: string;
30
+ checkIcon: ReturnType<typeof getIcon>;
31
+ checkboxSlotProps: DataAttributes;
32
+ iconSlotProps: DataAttributes;
33
+ children: ReactNode;
34
+ };
35
+ type CheckboxBaseProps = CheckboxProps & {
36
+ cssAnimationDuration: string;
37
+ enableInteractionTracking?: boolean;
38
+ renderRoot: (args: RenderRootArgs) => ReactNode;
39
+ renderIndicator: (args: RenderIndicatorArgs) => ReactNode;
40
+ };
41
+ declare const CheckboxBase: React.ForwardRefExoticComponent<CheckboxProps & {
42
+ cssAnimationDuration: string;
43
+ enableInteractionTracking?: boolean;
44
+ renderRoot: (args: RenderRootArgs) => ReactNode;
45
+ renderIndicator: (args: RenderIndicatorArgs) => ReactNode;
46
+ } & React.RefAttributes<HTMLInputElement>>;
47
+ //#endregion
48
+ export { CheckboxBase, type CheckboxBaseProps, type RenderIndicatorArgs, type RenderRootArgs, type ResolvedCheckboxVariant };
@@ -0,0 +1,49 @@
1
+
2
+ "use client";
3
+ import { CheckboxVariant } from "../../../types/dist/index.js";
4
+ import { getIcon } from "./checkboxConstants.js";
5
+ import { CheckboxProps, CheckboxValueState, DataAttributes } from "./types.js";
6
+ import React, { CSSProperties, ReactNode } from "react";
7
+
8
+ //#region src/components/client/Checkbox/CheckboxBase.d.ts
9
+ type ResolvedCheckboxVariant = CheckboxVariant | 'alert' | 'alert-secondary';
10
+ type RenderRootArgs = {
11
+ className: string;
12
+ style?: CSSProperties;
13
+ rootSlotProps: DataAttributes;
14
+ hasLabel: boolean;
15
+ isPressed: boolean;
16
+ onHoverStart: () => void;
17
+ onHoverEnd: () => void;
18
+ onTapStart: () => void;
19
+ onTapEnd: () => void;
20
+ children: ReactNode;
21
+ };
22
+ type RenderIndicatorArgs = {
23
+ size: NonNullable<CheckboxProps['size']>;
24
+ variant: ResolvedCheckboxVariant;
25
+ valueState: CheckboxValueState;
26
+ checked: CheckboxProps['checked'];
27
+ disabled?: boolean;
28
+ showHoverEffect: boolean;
29
+ showPressedEffect: boolean;
30
+ cssAnimationDuration: string;
31
+ checkIcon: ReturnType<typeof getIcon>;
32
+ checkboxSlotProps: DataAttributes;
33
+ iconSlotProps: DataAttributes;
34
+ children: ReactNode;
35
+ };
36
+ type CheckboxBaseProps = CheckboxProps & {
37
+ cssAnimationDuration: string;
38
+ enableInteractionTracking?: boolean;
39
+ renderRoot: (args: RenderRootArgs) => ReactNode;
40
+ renderIndicator: (args: RenderIndicatorArgs) => ReactNode;
41
+ };
42
+ declare const CheckboxBase: React.ForwardRefExoticComponent<CheckboxProps & {
43
+ cssAnimationDuration: string;
44
+ enableInteractionTracking?: boolean;
45
+ renderRoot: (args: RenderRootArgs) => ReactNode;
46
+ renderIndicator: (args: RenderIndicatorArgs) => ReactNode;
47
+ } & React.RefAttributes<HTMLInputElement>>;
48
+ //#endregion
49
+ export { CheckboxBase, type CheckboxBaseProps, type RenderIndicatorArgs, type RenderRootArgs, type ResolvedCheckboxVariant };
@@ -0,0 +1,138 @@
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, getIcon, isIndeterminate } from "./checkboxConstants.js";
6
+ import { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/components/client/Checkbox/CheckboxBase.tsx
9
+ const CheckboxBase = forwardRef(function CheckboxBase({ id, checked: checkedProp, defaultChecked, onChange, label, labelPosition = "start", variant: variantProp = "primary", size = "md", reduceMotion: _reduceMotion, disabled, required, hasError, className, style, slotProps, cssAnimationDuration, enableInteractionTracking = false, renderRoot, renderIndicator, ...checkboxProps }, parentRef) {
10
+ const generatedId = useId();
11
+ const uid = id ?? `uds-input-${generatedId}`;
12
+ const rootSlotProps = slotProps?.root ?? {};
13
+ const checkboxSlotProps = slotProps?.checkbox ?? {};
14
+ const iconSlotProps = slotProps?.icon ?? {};
15
+ const labelSlotProps = slotProps?.label ?? {};
16
+ const innerRef = useRef(null);
17
+ /**
18
+ * State
19
+ */
20
+ const isControlled = checkedProp !== void 0;
21
+ const [checked, setChecked] = useState(isControlled ? checkedProp : defaultChecked);
22
+ const [isHovered, setIsHovered] = useState(false);
23
+ const [isPressed, setIsPressed] = useState(false);
24
+ /**
25
+ * Derived values
26
+ */
27
+ const variant = useMemo(() => hasError ? VARIANT_ERROR_MAP[variantProp] : variantProp, [hasError, variantProp]);
28
+ const showHoverEffect = enableInteractionTracking && !disabled && isHovered;
29
+ const showPressedEffect = enableInteractionTracking && !disabled && isPressed;
30
+ /**
31
+ * Handlers
32
+ */
33
+ const handleChange = useCallback((e) => {
34
+ onChange?.(e);
35
+ if (!isControlled) setChecked(e.target.checked);
36
+ }, [isControlled, onChange]);
37
+ const handleHoverStart = useCallback(() => {
38
+ if (enableInteractionTracking) setIsHovered(true);
39
+ }, [enableInteractionTracking]);
40
+ const handleHoverEnd = useCallback(() => {
41
+ if (enableInteractionTracking) setIsHovered(false);
42
+ }, [enableInteractionTracking]);
43
+ const handleTapStart = useCallback(() => {
44
+ if (enableInteractionTracking) setIsPressed(true);
45
+ }, [enableInteractionTracking]);
46
+ const handleTapEnd = useCallback(() => {
47
+ if (enableInteractionTracking) setIsPressed(false);
48
+ }, [enableInteractionTracking]);
49
+ /**
50
+ * Helpers
51
+ */
52
+ const setDOMIndeterminate = (checked_) => {
53
+ if (!innerRef.current) return;
54
+ innerRef.current.indeterminate = isIndeterminate(checked_);
55
+ };
56
+ /**
57
+ * Effects
58
+ */
59
+ useEffect(() => {
60
+ if (isControlled) setChecked(checkedProp);
61
+ }, [checkedProp, isControlled]);
62
+ useEffect(() => {
63
+ setDOMIndeterminate(checked);
64
+ }, [checked]);
65
+ const valueState = isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
66
+ const classNames = {
67
+ root: getStyles({
68
+ checkboxSizeRoot: size,
69
+ checkboxVariantRoot: variant,
70
+ checkboxVariantValueRoot: valueState,
71
+ display: "flex",
72
+ flexDirection: labelPosition === "start" ? "row" : "row-reverse",
73
+ alignItems: "center",
74
+ className: cx({
75
+ "cursor-pointer": !disabled,
76
+ "cursor-default": disabled,
77
+ "opacity-50": disabled
78
+ }, className)
79
+ }),
80
+ htmlCheckbox: 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%]"),
81
+ label: cx(labelPosition === "start" ? "text-start" : "text-end")
82
+ };
83
+ const input = /* @__PURE__ */ jsx("input", {
84
+ type: "checkbox",
85
+ tabIndex: 0,
86
+ ...checkboxProps,
87
+ ref: (ref) => {
88
+ innerRef.current = ref;
89
+ setDOMIndeterminate(checked);
90
+ if (typeof parentRef === "function") parentRef(ref);
91
+ else if (parentRef !== null) parentRef.current = ref;
92
+ },
93
+ id: uid,
94
+ disabled,
95
+ required,
96
+ "aria-invalid": hasError,
97
+ checked: isControlled ? isIndeterminate(checked) ? false : checked : void 0,
98
+ defaultChecked: isControlled ? void 0 : defaultChecked,
99
+ onChange: handleChange,
100
+ className: classNames.htmlCheckbox
101
+ });
102
+ return renderRoot({
103
+ className: classNames.root,
104
+ style,
105
+ rootSlotProps,
106
+ hasLabel: Boolean(label),
107
+ isPressed,
108
+ onHoverStart: handleHoverStart,
109
+ onHoverEnd: handleHoverEnd,
110
+ onTapStart: handleTapStart,
111
+ onTapEnd: handleTapEnd,
112
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [renderIndicator({
113
+ size,
114
+ variant,
115
+ valueState,
116
+ checked,
117
+ disabled,
118
+ showHoverEffect,
119
+ showPressedEffect,
120
+ cssAnimationDuration,
121
+ checkIcon: getIcon(checked),
122
+ checkboxSlotProps,
123
+ iconSlotProps,
124
+ children: input
125
+ }), label && /* @__PURE__ */ jsx(FormLabel, {
126
+ as: "div",
127
+ variant: "inherit",
128
+ color: "inherit",
129
+ required,
130
+ label,
131
+ className: classNames.label,
132
+ ...labelSlotProps
133
+ })] })
134
+ });
135
+ });
136
+ CheckboxBase.displayName = "CheckboxBase";
137
+ //#endregion
138
+ export { CheckboxBase };