@payfit/unity-components 0.0.0-alpha.12 → 0.0.0-alpha.13

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 (121) hide show
  1. package/dist/cjs/components/button/Button.d.cts +5 -2
  2. package/dist/cjs/components/checkbox/Checkbox.variants.cjs +1 -1
  3. package/dist/cjs/components/data-table/DataTable.cjs +1 -1
  4. package/dist/cjs/components/data-table/DataTable.d.cts +3 -6
  5. package/dist/cjs/components/date-calendar/DateCalendar.cjs +1 -0
  6. package/dist/cjs/components/date-calendar/DateCalendar.d.cts +23 -0
  7. package/dist/cjs/components/date-calendar/hooks/useMonthsList.d.cts +4 -0
  8. package/dist/cjs/components/date-calendar/hooks/useYearsList.d.cts +10 -0
  9. package/dist/cjs/components/date-picker/DatePicker.cjs +1 -1
  10. package/dist/cjs/components/date-picker/DatePicker.d.cts +3 -3
  11. package/dist/cjs/components/definition-tooltip/DefinitionTooltip.cjs +1 -0
  12. package/dist/cjs/components/definition-tooltip/DefinitionTooltip.d.cts +23 -0
  13. package/dist/cjs/components/dialog/parts/DialogActions/DialogButton.cjs +1 -1
  14. package/dist/cjs/components/dialog/parts/DialogActions/DialogButton.d.cts +2 -2
  15. package/dist/cjs/components/icon-button/CircularIconButton.cjs +1 -1
  16. package/dist/cjs/components/icon-button/CircularIconButton.d.cts +0 -21
  17. package/dist/cjs/components/icon-button/IconButton.d.cts +1 -1
  18. package/dist/cjs/components/number-field/NumberField.cjs +1 -0
  19. package/dist/cjs/components/number-field/NumberField.d.cts +47 -0
  20. package/dist/cjs/components/number-input/NumberInput.cjs +1 -0
  21. package/dist/cjs/components/number-input/NumberInput.d.cts +216 -0
  22. package/dist/cjs/components/pagination/Pagination.cjs +1 -1
  23. package/dist/cjs/components/pagination/hooks/use-pagination.cjs +1 -1
  24. package/dist/cjs/components/pagination/hooks/use-pagination.d.cts +2 -1
  25. package/dist/cjs/components/popover/Popover.cjs +1 -1
  26. package/dist/cjs/components/popover/parts/PopoverHeader.cjs +1 -1
  27. package/dist/cjs/components/radio-button-group/parts/RadioButton.cjs +1 -1
  28. package/dist/cjs/components/select-field/test-utils.cjs +1 -0
  29. package/dist/cjs/components/selectable-button-group/SelectableButtonGroup.cjs +1 -1
  30. package/dist/cjs/components/selectable-button-group/SelectableButtonGroup.context.d.cts +5 -1
  31. package/dist/cjs/components/selectable-button-group/SelectableButtonGroup.d.cts +7 -1
  32. package/dist/cjs/components/selectable-button-group/parts/SelectableButton.cjs +1 -1
  33. package/dist/cjs/components/selectable-button-group/parts/SelectableButton.d.cts +35 -0
  34. package/dist/cjs/components/selectable-button-group-field/SelectableButtonGroupField.cjs +1 -0
  35. package/dist/cjs/components/selectable-button-group-field/SelectableButtonGroupField.d.cts +59 -0
  36. package/dist/cjs/components/side-panel/SidePanel.cjs +1 -1
  37. package/dist/cjs/components/side-panel/SidePanel.d.cts +6 -0
  38. package/dist/cjs/components/table/Table.cjs +1 -1
  39. package/dist/cjs/components/table/Table.d.cts +4 -0
  40. package/dist/cjs/components/table/parts/TableCell.cjs +1 -1
  41. package/dist/cjs/components/tabs/parts/NavigationButton.cjs +1 -1
  42. package/dist/cjs/components/tabs/parts/TabList.cjs +1 -1
  43. package/dist/cjs/components/text/Text.cjs +1 -1
  44. package/dist/cjs/components/text/Text.d.cts +1 -1
  45. package/dist/cjs/components/text/Text.variants.cjs +1 -1
  46. package/dist/cjs/components/text/Text.variants.d.cts +7 -0
  47. package/dist/cjs/components/tooltip/Tooltip.cjs +1 -1
  48. package/dist/cjs/components/tooltip/Tooltip.d.cts +4 -3
  49. package/dist/cjs/index.cjs +1 -1
  50. package/dist/cjs/index.d.cts +5 -0
  51. package/dist/cjs/index.storybook-testing.d.cts +1 -0
  52. package/dist/cjs/storybook-testing.cjs +1 -1
  53. package/dist/esm/components/button/Button.d.ts +5 -2
  54. package/dist/esm/components/checkbox/Checkbox.variants.js +4 -4
  55. package/dist/esm/components/data-table/DataTable.d.ts +3 -6
  56. package/dist/esm/components/data-table/DataTable.js +61 -56
  57. package/dist/esm/components/date-calendar/DateCalendar.d.ts +23 -0
  58. package/dist/esm/components/{date-picker/parts → date-calendar}/DateCalendar.js +62 -60
  59. package/dist/esm/components/date-calendar/hooks/useMonthsList.d.ts +4 -0
  60. package/dist/esm/components/date-calendar/hooks/useYearsList.d.ts +10 -0
  61. package/dist/esm/components/date-picker/DatePicker.d.ts +3 -3
  62. package/dist/esm/components/date-picker/DatePicker.js +22 -22
  63. package/dist/esm/components/definition-tooltip/DefinitionTooltip.d.ts +23 -0
  64. package/dist/esm/components/definition-tooltip/DefinitionTooltip.js +29 -0
  65. package/dist/esm/components/dialog/parts/DialogActions/DialogButton.d.ts +2 -2
  66. package/dist/esm/components/dialog/parts/DialogActions/DialogButton.js +31 -27
  67. package/dist/esm/components/icon-button/CircularIconButton.d.ts +0 -21
  68. package/dist/esm/components/icon-button/CircularIconButton.js +23 -26
  69. package/dist/esm/components/icon-button/IconButton.d.ts +1 -1
  70. package/dist/esm/components/number-field/NumberField.d.ts +47 -0
  71. package/dist/esm/components/number-field/NumberField.js +71 -0
  72. package/dist/esm/components/number-input/NumberInput.d.ts +216 -0
  73. package/dist/esm/components/number-input/NumberInput.js +214 -0
  74. package/dist/esm/components/pagination/Pagination.js +17 -16
  75. package/dist/esm/components/pagination/hooks/use-pagination.d.ts +2 -1
  76. package/dist/esm/components/pagination/hooks/use-pagination.js +12 -11
  77. package/dist/esm/components/popover/Popover.js +25 -21
  78. package/dist/esm/components/popover/parts/PopoverHeader.js +17 -15
  79. package/dist/esm/components/radio-button-group/parts/RadioButton.js +1 -1
  80. package/dist/esm/components/select-field/test-utils.js +25 -0
  81. package/dist/esm/components/selectable-button-group/SelectableButtonGroup.context.d.ts +5 -1
  82. package/dist/esm/components/selectable-button-group/SelectableButtonGroup.d.ts +7 -1
  83. package/dist/esm/components/selectable-button-group/SelectableButtonGroup.js +23 -16
  84. package/dist/esm/components/selectable-button-group/parts/SelectableButton.d.ts +35 -0
  85. package/dist/esm/components/selectable-button-group/parts/SelectableButton.js +44 -36
  86. package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.d.ts +59 -0
  87. package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.js +45 -0
  88. package/dist/esm/components/side-panel/SidePanel.d.ts +6 -0
  89. package/dist/esm/components/side-panel/SidePanel.js +38 -35
  90. package/dist/esm/components/table/Table.d.ts +4 -0
  91. package/dist/esm/components/table/Table.js +96 -71
  92. package/dist/esm/components/table/parts/TableCell.js +5 -5
  93. package/dist/esm/components/tabs/parts/NavigationButton.js +4 -4
  94. package/dist/esm/components/tabs/parts/TabList.js +44 -35
  95. package/dist/esm/components/text/Text.d.ts +1 -1
  96. package/dist/esm/components/text/Text.js +6 -5
  97. package/dist/esm/components/text/Text.variants.d.ts +7 -0
  98. package/dist/esm/components/text/Text.variants.js +2 -1
  99. package/dist/esm/components/tooltip/Tooltip.d.ts +4 -3
  100. package/dist/esm/components/tooltip/Tooltip.js +13 -12
  101. package/dist/esm/index.d.ts +5 -0
  102. package/dist/esm/index.js +237 -225
  103. package/dist/esm/index.storybook-testing.d.ts +1 -0
  104. package/dist/esm/storybook-testing.js +3 -1
  105. package/i18n/en-GB.json +2 -0
  106. package/i18n/es-ES.json +2 -0
  107. package/i18n/fr-FR.json +2 -0
  108. package/package.json +7 -6
  109. package/dist/cjs/components/date-picker/parts/DateCalendar.cjs +0 -1
  110. package/dist/cjs/components/date-picker/parts/DateCalendar.d.cts +0 -9
  111. package/dist/cjs/components/popover/parts/PopoverContent.cjs +0 -1
  112. package/dist/esm/components/date-picker/parts/DateCalendar.d.ts +0 -9
  113. package/dist/esm/components/popover/parts/PopoverContent.js +0 -9
  114. /package/dist/cjs/components/{date-picker → date-calendar}/hooks/useMonthsList.cjs +0 -0
  115. /package/dist/cjs/components/{date-picker → date-calendar}/hooks/useYearsList.cjs +0 -0
  116. /package/dist/cjs/components/{date-picker → date-calendar}/parts/DateSegmentSelect.cjs +0 -0
  117. /package/dist/cjs/components/{date-picker → date-calendar}/parts/DateSegmentSelect.d.cts +0 -0
  118. /package/dist/esm/components/{date-picker → date-calendar}/hooks/useMonthsList.js +0 -0
  119. /package/dist/esm/components/{date-picker → date-calendar}/hooks/useYearsList.js +0 -0
  120. /package/dist/esm/components/{date-picker → date-calendar}/parts/DateSegmentSelect.d.ts +0 -0
  121. /package/dist/esm/components/{date-picker → date-calendar}/parts/DateSegmentSelect.js +0 -0
@@ -10,6 +10,11 @@ export declare const selectableButton: import('tailwind-variants').TVReturnType<
10
10
  base: string;
11
11
  };
12
12
  };
13
+ isInvalid: {
14
+ true: {
15
+ base: string;
16
+ };
17
+ };
13
18
  }, {
14
19
  base: string[];
15
20
  icon: string[];
@@ -23,6 +28,11 @@ export declare const selectableButton: import('tailwind-variants').TVReturnType<
23
28
  base: string;
24
29
  };
25
30
  };
31
+ isInvalid: {
32
+ true: {
33
+ base: string;
34
+ };
35
+ };
26
36
  }, {
27
37
  hasIcon: {
28
38
  true: {
@@ -32,6 +42,11 @@ export declare const selectableButton: import('tailwind-variants').TVReturnType<
32
42
  base: string;
33
43
  };
34
44
  };
45
+ isInvalid: {
46
+ true: {
47
+ base: string;
48
+ };
49
+ };
35
50
  }>, {
36
51
  hasIcon: {
37
52
  true: {
@@ -41,6 +56,11 @@ export declare const selectableButton: import('tailwind-variants').TVReturnType<
41
56
  base: string;
42
57
  };
43
58
  };
59
+ isInvalid: {
60
+ true: {
61
+ base: string;
62
+ };
63
+ };
44
64
  }, {
45
65
  base: string[];
46
66
  icon: string[];
@@ -54,6 +74,11 @@ export declare const selectableButton: import('tailwind-variants').TVReturnType<
54
74
  base: string;
55
75
  };
56
76
  };
77
+ isInvalid: {
78
+ true: {
79
+ base: string;
80
+ };
81
+ };
57
82
  }, {
58
83
  base: string[];
59
84
  icon: string[];
@@ -67,6 +92,11 @@ export declare const selectableButton: import('tailwind-variants').TVReturnType<
67
92
  base: string;
68
93
  };
69
94
  };
95
+ isInvalid: {
96
+ true: {
97
+ base: string;
98
+ };
99
+ };
70
100
  }, {
71
101
  hasIcon: {
72
102
  true: {
@@ -76,6 +106,11 @@ export declare const selectableButton: import('tailwind-variants').TVReturnType<
76
106
  base: string;
77
107
  };
78
108
  };
109
+ isInvalid: {
110
+ true: {
111
+ base: string;
112
+ };
113
+ };
79
114
  }>, unknown, unknown, undefined>>;
80
115
  type IconName<T extends string> = T extends `${infer Base}${'Filled' | 'Outlined'}` ? Base : T;
81
116
  export interface SelectableButtonProps extends Omit<AriaToggleButtonProps, 'id' | 'className' | 'style'> {
@@ -1,11 +1,11 @@
1
- import { jsxs as i, jsx as o, Fragment as g } from "react/jsx-runtime";
2
- import { forwardRef as v, useRef as h, useContext as x } from "react";
3
- import { useToggleButtonGroupItem as w, mergeProps as B } from "react-aria";
4
- import { tv as I } from "tailwind-variants";
5
- import { Icon as S } from "../../icon/Icon.js";
6
- import { Spinner as N } from "../../spinner/Spinner.js";
7
- import { SelectableButtonGroupContext as G } from "../SelectableButtonGroup.context.js";
8
- const P = I({
1
+ import { jsxs as n, jsx as o, Fragment as h } from "react/jsx-runtime";
2
+ import { forwardRef as x, useRef as I, useContext as w } from "react";
3
+ import { useToggleButtonGroupItem as B, mergeProps as S } from "react-aria";
4
+ import { tv as N } from "tailwind-variants";
5
+ import { Icon as G } from "../../icon/Icon.js";
6
+ import { Spinner as P } from "../../spinner/Spinner.js";
7
+ import { SelectableButtonGroupContext as R } from "../SelectableButtonGroup.context.js";
8
+ const j = N({
9
9
  // add the component styles
10
10
  slots: {
11
11
  base: [
@@ -37,63 +37,71 @@ const P = I({
37
37
  false: {
38
38
  base: "uy-px-200"
39
39
  }
40
+ },
41
+ isInvalid: {
42
+ true: {
43
+ base: "uy-bg-surface-form-error uy-border-border-form-error"
44
+ }
40
45
  }
41
46
  },
42
47
  defaultVariants: {
43
- hasIcon: !1
48
+ hasIcon: !1,
49
+ isInvalid: !1
44
50
  }
45
- }), R = v(
46
- (t, n) => {
47
- const s = h(null), a = x(G);
51
+ }), z = x(
52
+ (t, c) => {
53
+ const s = I(null), a = w(R);
48
54
  if (!a)
49
55
  throw new Error(
50
56
  "SelectableButton must be used within a ToggleButtonGroup component"
51
57
  );
52
- const { buttonProps: d, isPressed: c, isSelected: u } = w(
58
+ const { state: b, isInvalid: d } = a, { buttonProps: u, isPressed: f, isSelected: l } = B(
53
59
  { id: t.value, ...t },
54
- a,
60
+ b,
55
61
  s
56
- ), { ref: b } = B({ ref: s }, { ref: n }), {
57
- isDisabled: f = !1,
62
+ ), { ref: y } = S({ ref: s }, { ref: c }), {
63
+ isDisabled: m = !1,
58
64
  isLoading: e = !1,
59
65
  prefixIcon: r,
60
- children: l
61
- } = t, { base: y, icon: m, label: p } = P({
62
- hasIcon: !!r && !e
66
+ children: i
67
+ } = t, { base: p, icon: g, label: v } = j({
68
+ hasIcon: !!r && !e,
69
+ isInvalid: !!d
63
70
  });
64
- return /* @__PURE__ */ i(
71
+ return /* @__PURE__ */ n(
65
72
  "button",
66
73
  {
67
74
  "data-dd-privacy": "allow",
68
- ...d,
69
- ref: b,
70
- className: y(),
71
- disabled: d.disabled || f || e,
75
+ ...u,
76
+ ref: y,
77
+ className: p(),
78
+ disabled: u.disabled || m || e,
72
79
  "data-loading": e ? !0 : void 0,
73
- "data-pressed": c,
74
- "data-selected": u,
80
+ "data-pressed": f,
81
+ "data-selected": l,
82
+ "data-invalid": d,
75
83
  "aria-busy": e,
76
84
  children: [
77
85
  r && !e && /* @__PURE__ */ o(
78
- S,
86
+ G,
79
87
  {
80
- src: u ? `${r}Filled` : `${r}Outlined`,
88
+ src: l ? `${r}Filled` : `${r}Outlined`,
81
89
  role: "presentation",
82
- className: m(),
90
+ className: g(),
83
91
  size: 20
84
92
  }
85
93
  ),
86
- e ? /* @__PURE__ */ i(g, { children: [
87
- /* @__PURE__ */ o(N, { label: "Loading", size: "small", color: "inherit" }),
88
- /* @__PURE__ */ o("span", { className: "uy-sr-only", children: l })
89
- ] }) : /* @__PURE__ */ o("span", { className: p(), children: l })
94
+ e ? /* @__PURE__ */ n(h, { children: [
95
+ /* @__PURE__ */ o(P, { label: "Loading", size: "small", color: "inherit" }),
96
+ /* @__PURE__ */ o("span", { className: "uy-sr-only", children: i })
97
+ ] }) : /* @__PURE__ */ o("span", { className: v(), children: i })
90
98
  ]
91
99
  }
92
100
  );
93
101
  }
94
102
  );
95
- R.displayName = "SelectableButton";
103
+ z.displayName = "SelectableButton";
96
104
  export {
97
- R as SelectableButton,
98
- P as selectableButton
105
+ z as SelectableButton,
106
+ j as selectableButton
99
107
  };
@@ -0,0 +1,59 @@
1
+ import { ForwardedRef, JSX, ReactNode } from 'react';
2
+ import { FieldPath, FieldValues } from 'react-hook-form';
3
+ import { infer as ZodInfer } from 'zod';
4
+ import { Schema } from '../../hooks/use-form.types.js';
5
+ import { SelectableButtonGroupProps } from '../selectable-button-group/SelectableButtonGroup.js';
6
+ import { LabelProps } from '../label/Label.js';
7
+ interface FieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
8
+ /** The name of the field, which should match the form schema. */
9
+ name: TName;
10
+ /** The label for the field. */
11
+ label: string;
12
+ /** The required variant for the label. */
13
+ requiredVariant?: LabelProps['requiredVariant'];
14
+ /** Helper text to display below the field. */
15
+ helperText?: ReactNode;
16
+ /** A contextual link to display below the field. */
17
+ contextualLink?: ReactNode;
18
+ /** Whether the checkbox group is disabled. */
19
+ isDisabled?: boolean;
20
+ /** Whether the checkbox group is invalid. */
21
+ isInvalid?: boolean;
22
+ }
23
+ export type SelectableButtonGroupFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = FieldProps<TFieldValues, TName> & Omit<SelectableButtonGroupProps, 'isDisabled' | 'children'> & {
24
+ /** The options to render as SelectableButton children. */
25
+ children: ReactNode;
26
+ };
27
+ type SelectableButtonGroupFieldComponent = (<TSchema extends Schema>(props: SelectableButtonGroupFieldProps<ZodInfer<TSchema>> & {
28
+ ref?: ForwardedRef<HTMLInputElement | HTMLTextAreaElement>;
29
+ }) => JSX.Element) & {
30
+ displayName?: string;
31
+ };
32
+ /**
33
+ * The `SelectableButtonGroupField` component integrates the SelectableButtonGroup with Unity's form system, providing validation, accessibility, and helper/feedback text.
34
+ * @example
35
+ * ```tsx
36
+ * const schema = z.object({
37
+ * choice: z.string()
38
+ * })
39
+ *
40
+ * function MyForm() {
41
+ * const { Form } = useUnityForm(schema)
42
+ *
43
+ * return (
44
+ * <Form action={handleSubmit}>
45
+ * <SelectableButtonGroupField<typeof schema>
46
+ * name="choice"
47
+ * label="Choose an option"
48
+ * >
49
+ * <SelectableButton value="a">A</SelectableButton>
50
+ * <SelectableButton value="b">B</SelectableButton>
51
+ * </SelectableButtonGroupField>
52
+ * </Form>
53
+ * )
54
+ * }
55
+ * ```
56
+ * @note The schema type parameter is needed to ensure type safety with the form's schema. If you omit it, the `name` prop will not be type-safe.
57
+ */
58
+ declare const SelectableButtonGroupField: SelectableButtonGroupFieldComponent;
59
+ export { SelectableButtonGroupField };
@@ -0,0 +1,45 @@
1
+ import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as F } from "react";
3
+ import { useFormContext as s } from "react-hook-form";
4
+ import { FormField as b } from "../form-field/FormField.js";
5
+ import { FormControl as x } from "../form-field/parts/FormControl.js";
6
+ import { FormFeedbackText as B } from "../form-field/parts/FormFeedbackText.js";
7
+ import { FormHelperText as G } from "../form-field/parts/FormHelperText.js";
8
+ import { FormLabel as S } from "../form-field/parts/FormLabel.js";
9
+ import { SelectableButtonGroup as h } from "../selectable-button-group/SelectableButtonGroup.js";
10
+ function y({
11
+ name: t,
12
+ label: e,
13
+ helperText: r,
14
+ contextualLink: m,
15
+ isDisabled: l,
16
+ requiredVariant: i,
17
+ children: n,
18
+ ...c
19
+ }, p) {
20
+ const { control: u, watch: a } = s(), f = a(t);
21
+ return /* @__PURE__ */ d(b, { control: u, name: t, ref: p, children: [
22
+ /* @__PURE__ */ o(S, { requiredVariant: i, children: e }),
23
+ r && /* @__PURE__ */ o(G, { children: r }),
24
+ /* @__PURE__ */ o(x, { className: "uy-my-50", children: /* @__PURE__ */ o(
25
+ h,
26
+ {
27
+ value: f,
28
+ isDisabled: l,
29
+ ...c,
30
+ children: n
31
+ }
32
+ ) }),
33
+ /* @__PURE__ */ o(B, {}),
34
+ m
35
+ ] });
36
+ }
37
+ const j = F(
38
+ function(e, r) {
39
+ return y(e, r);
40
+ }
41
+ );
42
+ j.displayName = "SelectableButtonGroupField";
43
+ export {
44
+ j as SelectableButtonGroupField
45
+ };
@@ -80,6 +80,12 @@ export interface SidePanelProps extends PropsWithChildren<VariantProps<typeof si
80
80
  * Required when using controlled mode with `isOpen`.
81
81
  */
82
82
  onOpenChange?: (isOpen: boolean) => void;
83
+ /**
84
+ * If true, scroll locking will be disabled, allowing background scrolling while the panel is open.
85
+ * **Requires** controlled mode with `isOpen`/`onOpenChange`.
86
+ * @default false
87
+ */
88
+ disableScrollLocking?: boolean;
83
89
  }
84
90
  /**
85
91
  * The SidePanel component provides contextual space for supplementary content without fully
@@ -1,18 +1,18 @@
1
- import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
- import { forwardRef as f } from "react";
3
- import { ModalOverlay as c, Modal as g, Dialog as p } from "react-aria-components";
4
- import { tv as x } from "tailwind-variants";
5
- import { SidePanelDragIndicator as h } from "./parts/SidePanelDragIndicator.js";
6
- const v = x({
1
+ import { jsx as t, jsxs as s } from "react/jsx-runtime";
2
+ import { forwardRef as c, useEffect as g } from "react";
3
+ import { ModalOverlay as x, Modal as h, Dialog as v } from "react-aria-components";
4
+ import { tv as w } from "tailwind-variants";
5
+ import { SidePanelDragIndicator as p } from "./parts/SidePanelDragIndicator.js";
6
+ const N = w({
7
7
  slots: {
8
8
  overlay: [
9
9
  "md:uy-bg-gradient-to-r md:uy-from-grayscale-L12/0 md:uy-to-grayscale-L12/10 md:uy-from-70% md:uy-via-100%",
10
- "uy-fixed uy-inset-0 uy-isolate",
10
+ "uy-fixed uy-inset-0 uy-isolate uy-z-10",
11
11
  "data-[entering]:uy-animate-fade-in data-[exiting]:uy-animate-fade-out"
12
12
  ],
13
13
  wrapper: [
14
14
  "uy-w-full md:uy-w-[400px]",
15
- "uy-fixed uy-bottom-0 md:uy-inset-y-200 md:uy-right-200 uy-z-[100]",
15
+ "uy-fixed uy-bottom-0 md:uy-inset-y-200 md:uy-right-200",
16
16
  "uy-bg-surface-neutral uy-rounded-t-200 md:uy-rounded-200 uy-shadow-flying",
17
17
  "uy-flex uy-flex-col uy-h-[95svh] md:uy-max-h-[calc(100vh-2rem)]",
18
18
  "uy-overflow-hidden",
@@ -22,37 +22,40 @@ const v = x({
22
22
  "uy-flex uy-flex-col uy-h-full uy-overflow-hidden uy-outline-none"
23
23
  ]
24
24
  }
25
- }), w = f(
25
+ }), P = c(
26
26
  ({
27
- children: a,
28
- isOpen: d,
29
- onOpenChange: t,
30
- defaultOpen: i,
31
- isDismissable: u = !0,
32
- isKeyboardDismissDisabled: n = !1,
33
- ...r
34
- }, o) => {
35
- const { overlay: y, wrapper: l, content: m } = v();
36
- return /* @__PURE__ */ e(
37
- c,
27
+ children: o,
28
+ isOpen: e,
29
+ onOpenChange: u,
30
+ defaultOpen: a,
31
+ isDismissable: i = !0,
32
+ isKeyboardDismissDisabled: r = !1,
33
+ disableScrollLocking: d = !1,
34
+ ...y
35
+ }, n) => {
36
+ const { overlay: l, wrapper: m, content: f } = N();
37
+ return g(() => {
38
+ d && (e ?? a) && (document.documentElement.style.overflow = "", document.body.style.overflow = "");
39
+ }, [d, e, a]), /* @__PURE__ */ t(
40
+ x,
38
41
  {
39
- className: y(),
40
- isOpen: d,
41
- onOpenChange: t,
42
- defaultOpen: i,
43
- isDismissable: u,
44
- isKeyboardDismissDisabled: n,
42
+ className: l(),
43
+ isOpen: e,
44
+ onOpenChange: u,
45
+ defaultOpen: a,
46
+ isDismissable: i,
47
+ isKeyboardDismissDisabled: r,
45
48
  children: /* @__PURE__ */ s(
46
- g,
49
+ h,
47
50
  {
48
51
  "data-dd-privacy": "allow",
49
- ...r,
50
- ref: o,
51
- className: l(),
52
+ ...y,
53
+ ref: n,
54
+ className: m(),
52
55
  "data-unity-side-panel": !0,
53
56
  children: [
54
- /* @__PURE__ */ e(h, {}),
55
- /* @__PURE__ */ e(p, { className: m(), children: a })
57
+ /* @__PURE__ */ t(p, {}),
58
+ /* @__PURE__ */ t(v, { className: f(), children: o })
56
59
  ]
57
60
  }
58
61
  )
@@ -60,8 +63,8 @@ const v = x({
60
63
  );
61
64
  }
62
65
  );
63
- w.displayName = "SidePanel";
66
+ P.displayName = "SidePanel";
64
67
  export {
65
- w as SidePanel,
66
- v as sidePanel
68
+ P as SidePanel,
69
+ N as sidePanel
67
70
  };
@@ -44,6 +44,10 @@ export interface TableProps extends React.HTMLAttributes<HTMLTableElement> {
44
44
  * ```
45
45
  */
46
46
  description?: string;
47
+ /**
48
+ * Enables horizontal scrolling if the table overflows its container. Enabled by default.
49
+ */
50
+ isHorizontalScrollEnabled?: boolean;
47
51
  }
48
52
  export interface TableImperativeHandler {
49
53
  /**
@@ -1,9 +1,9 @@
1
- import { jsx as i, jsxs as T } from "react/jsx-runtime";
2
- import r, { forwardRef as R, useRef as k, useMemo as H, useImperativeHandle as V, useCallback as $ } from "react";
3
- import { tv as N } from "tailwind-variants";
4
- import { useResizeObserver as D } from "usehooks-ts";
5
- import { TableContextProvider as M, useTableContext as P } from "./Table.context.js";
6
- const j = N({
1
+ import { jsx as i, jsxs as R } from "react/jsx-runtime";
2
+ import r, { forwardRef as N, useRef as k, useMemo as z, useImperativeHandle as S, useCallback as V } from "react";
3
+ import { tv as E } from "tailwind-variants";
4
+ import { useResizeObserver as $ } from "usehooks-ts";
5
+ import { TableContextProvider as D, useTableContext as M } from "./Table.context.js";
6
+ const P = E({
7
7
  slots: {
8
8
  root: "uy-w-full uy-border uy-border-solid uy-border-border-neutral-enabled uy-rounded-100 uy-overflow-hidden",
9
9
  scroller: [
@@ -13,10 +13,10 @@ const j = N({
13
13
  // Ensure full width
14
14
  ]
15
15
  }
16
- }), A = R(
17
- ({ minRows: u = 10, maxRows: c = 50, children: e }, o) => {
18
- const { root: a, scroller: d } = j();
19
- return /* @__PURE__ */ i("div", { ref: o, className: a(), "data-unity-slot": "table-root", children: /* @__PURE__ */ i(
16
+ }), j = N(
17
+ ({ minRows: u = 10, maxRows: c = 50, children: e }, l) => {
18
+ const { root: t, scroller: d } = P();
19
+ return /* @__PURE__ */ i("div", { ref: l, className: t(), "data-unity-slot": "table-root", children: /* @__PURE__ */ i(
20
20
  "div",
21
21
  {
22
22
  className: d(),
@@ -30,107 +30,132 @@ const j = N({
30
30
  ) });
31
31
  }
32
32
  );
33
- A.displayName = "TableRoot";
34
- const K = N({
33
+ j.displayName = "TableRoot";
34
+ const A = E({
35
35
  slots: {
36
36
  wrapper: [
37
37
  "uy-flex-1 uy-h-full uy-bg-surface-neutral",
38
- "uy-overflow-auto",
38
+ "uy-overflow-y-auto",
39
+ // Always enable vertical scrolling
39
40
  "uy-w-full"
40
41
  ],
41
42
  table: [
42
43
  "uy-min-w-full",
43
- "uy-w-max",
44
44
  "uy-text-left uy-typography-body uy-text-content-neutral uy-border-collapse",
45
45
  "focus:uy-outline-2 focus:uy-outline-utility-focus-ring focus:uy-outline-offset-[-2px]"
46
46
  ]
47
+ },
48
+ variants: {
49
+ horizontalScroll: {
50
+ true: {
51
+ wrapper: "uy-overflow-x-auto",
52
+ table: "uy-w-max"
53
+ },
54
+ false: {
55
+ wrapper: "uy-overflow-x-hidden",
56
+ table: "uy-w-fit"
57
+ }
58
+ }
59
+ },
60
+ defaultVariants: {
61
+ horizontalScroll: !0
47
62
  }
48
- }), U = R((u, c) => {
49
- const { children: e, label: o, description: a, ...d } = u, n = k(null), { height: h = 0 } = D({
50
- ref: n,
63
+ }), K = N((u, c) => {
64
+ const {
65
+ children: e,
66
+ label: l,
67
+ description: t,
68
+ isHorizontalScrollEnabled: d = !0,
69
+ ...p
70
+ } = u, a = k(null), { height: n = 0 } = $({
71
+ ref: a,
51
72
  box: "border-box"
52
- }), { rowCount: l, columnCount: b } = H(() => {
53
- let y = 0, f = 0;
54
- return r.Children.forEach(e, (m) => {
55
- if (!r.isValidElement(m)) return;
73
+ }), { rowCount: b, columnCount: f } = z(() => {
74
+ let y = 0, m = 0;
75
+ return r.Children.forEach(e, (h) => {
76
+ if (!r.isValidElement(h)) return;
56
77
  const s = r.Children.toArray(
57
- m.props.children
58
- ).filter((t) => r.isValidElement(t));
59
- f += s.length, s.forEach((t) => {
60
- if (!r.isValidElement(t)) return;
61
- const p = r.Children.toArray(
62
- t.props.children
63
- ).filter((w) => r.isValidElement(w));
64
- y = Math.max(y, p.length);
78
+ h.props.children
79
+ ).filter((o) => r.isValidElement(o));
80
+ m += s.length, s.forEach((o) => {
81
+ if (!r.isValidElement(o)) return;
82
+ const w = r.Children.toArray(
83
+ o.props.children
84
+ ).filter((v) => r.isValidElement(v));
85
+ y = Math.max(y, w.length);
65
86
  });
66
- }), { rowCount: f, columnCount: y };
87
+ }), { rowCount: m, columnCount: y };
67
88
  }, [e]);
68
- return V(c, () => ({
89
+ return S(c, () => ({
69
90
  scrollToTop: () => {
70
- n.current && n.current.scrollTo({ top: 0, behavior: "smooth" });
91
+ a.current && a.current.scrollTo({ top: 0, behavior: "smooth" });
71
92
  }
72
- })), /* @__PURE__ */ i(M, { rowCount: l, columnCount: b, children: /* @__PURE__ */ i(
73
- E,
93
+ })), /* @__PURE__ */ i(D, { rowCount: b, columnCount: f, children: /* @__PURE__ */ i(
94
+ H,
74
95
  {
75
- scrollContainerRef: n,
76
- containerHeight: h,
77
- rowCount: l,
78
- columnCount: b,
79
- label: o,
80
- description: a,
81
- ...d,
96
+ scrollContainerRef: a,
97
+ containerHeight: n,
98
+ rowCount: b,
99
+ columnCount: f,
100
+ label: l,
101
+ description: t,
102
+ isHorizontalScrollEnabled: d,
103
+ ...p,
82
104
  children: e
83
105
  }
84
106
  ) });
85
107
  });
86
- U.displayName = "Table";
87
- const E = (u) => {
88
- var x, g, C;
108
+ K.displayName = "Table";
109
+ const H = (u) => {
110
+ var g, C, T;
89
111
  const {
90
112
  children: c,
91
113
  label: e,
92
- description: o,
93
- scrollContainerRef: a,
114
+ description: l,
115
+ scrollContainerRef: t,
94
116
  containerHeight: d,
95
- rowCount: n,
96
- columnCount: h,
97
- onKeyDown: l,
98
- ...b
99
- } = u, { wrapper: y, table: f } = K(), { keyboardNavigation: m } = P(), { tableRef: s, handleTableKeyDown: t } = m, p = $(
100
- (v) => {
101
- v.key !== "Tab" && (t(v), l == null || l(v));
117
+ rowCount: p,
118
+ columnCount: a,
119
+ onKeyDown: n,
120
+ isHorizontalScrollEnabled: b = !0,
121
+ ...f
122
+ } = u, { wrapper: y, table: m } = A({
123
+ horizontalScroll: b
124
+ }), { keyboardNavigation: h } = M(), { tableRef: s, handleTableKeyDown: o } = h, w = V(
125
+ (x) => {
126
+ x.key !== "Tab" && (o(x), n == null || n(x));
102
127
  },
103
- [t, l]
104
- ), w = (((x = a.current) == null ? void 0 : x.scrollHeight) ?? 0) > Math.floor(d);
105
- return /* @__PURE__ */ T(
128
+ [o, n]
129
+ ), v = (((g = t.current) == null ? void 0 : g.scrollHeight) ?? 0) > Math.floor(d);
130
+ return /* @__PURE__ */ R(
106
131
  "div",
107
132
  {
108
133
  className: y(),
109
- ref: a,
134
+ ref: t,
110
135
  style: {
111
- "--uy-table-is-scrollable": w ? "1" : "0"
136
+ "--uy-table-is-scrollable": v ? "1" : "0"
112
137
  },
113
138
  children: [
114
- /* @__PURE__ */ T(
139
+ /* @__PURE__ */ R(
115
140
  "table",
116
141
  {
117
142
  ref: s,
118
- className: f(),
143
+ className: m(),
119
144
  role: "grid",
120
- "aria-rowcount": n,
121
- "aria-colcount": h,
145
+ "aria-rowcount": p,
146
+ "aria-colcount": a,
122
147
  "aria-label": e,
123
- "aria-describedby": o ? `table-desc-${(g = s.current) == null ? void 0 : g.id}` : void 0,
124
- onKeyDown: p,
125
- ...b,
148
+ "aria-describedby": l ? `table-desc-${(C = s.current) == null ? void 0 : C.id}` : void 0,
149
+ onKeyDown: w,
150
+ ...f,
126
151
  children: [
127
152
  c,
128
- o && /* @__PURE__ */ i(
153
+ l && /* @__PURE__ */ i(
129
154
  "caption",
130
155
  {
131
- id: `table-desc-${(C = s.current) == null ? void 0 : C.id}`,
156
+ id: `table-desc-${(T = s.current) == null ? void 0 : T.id}`,
132
157
  className: "uy-sr-only",
133
- children: o
158
+ children: l
134
159
  }
135
160
  )
136
161
  ]
@@ -141,8 +166,8 @@ const E = (u) => {
141
166
  }
142
167
  );
143
168
  };
144
- E.displayName = "TableContent";
169
+ H.displayName = "TableContent";
145
170
  export {
146
- U as Table,
147
- A as TableRoot
171
+ K as Table,
172
+ j as TableRoot
148
173
  };