@payfit/unity-components 0.0.0-alpha.11 → 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.
- package/dist/cjs/components/button/Button.d.cts +5 -2
- package/dist/cjs/components/checkbox/Checkbox.cjs +1 -1
- package/dist/cjs/components/checkbox/Checkbox.variants.cjs +1 -1
- package/dist/cjs/components/checkbox/parts/CheckboxIndicator.cjs +1 -1
- package/dist/cjs/components/data-table/DataTable.cjs +1 -1
- package/dist/cjs/components/data-table/DataTable.d.cts +3 -6
- package/dist/cjs/components/date-calendar/DateCalendar.cjs +1 -0
- package/dist/cjs/components/date-calendar/DateCalendar.d.cts +23 -0
- package/dist/cjs/components/date-calendar/hooks/useMonthsList.d.cts +4 -0
- package/dist/cjs/components/date-calendar/hooks/useYearsList.d.cts +10 -0
- package/dist/cjs/components/date-picker/DatePicker.cjs +1 -1
- package/dist/cjs/components/date-picker/DatePicker.d.cts +3 -3
- package/dist/cjs/components/date-picker-field/test-utils.cjs +1 -0
- package/dist/cjs/components/date-picker-field/test-utils.d.cts +12 -0
- package/dist/cjs/components/definition-tooltip/DefinitionTooltip.cjs +1 -0
- package/dist/cjs/components/definition-tooltip/DefinitionTooltip.d.cts +23 -0
- package/dist/cjs/components/dialog/parts/DialogActions/DialogButton.cjs +1 -1
- package/dist/cjs/components/dialog/parts/DialogActions/DialogButton.d.cts +2 -2
- package/dist/cjs/components/icon-button/CircularIconButton.cjs +1 -1
- package/dist/cjs/components/icon-button/CircularIconButton.d.cts +0 -21
- package/dist/cjs/components/icon-button/IconButton.d.cts +1 -1
- package/dist/cjs/components/number-field/NumberField.cjs +1 -0
- package/dist/cjs/components/number-field/NumberField.d.cts +47 -0
- package/dist/cjs/components/number-input/NumberInput.cjs +1 -0
- package/dist/cjs/components/number-input/NumberInput.d.cts +216 -0
- package/dist/cjs/components/pagination/Pagination.cjs +1 -1
- package/dist/cjs/components/pagination/hooks/use-pagination.cjs +1 -1
- package/dist/cjs/components/pagination/hooks/use-pagination.d.cts +2 -1
- package/dist/cjs/components/popover/Popover.cjs +1 -1
- package/dist/cjs/components/popover/parts/PopoverHeader.cjs +1 -1
- package/dist/cjs/components/radio-button-group/parts/RadioButton.cjs +1 -1
- package/dist/cjs/components/select-field/test-utils.cjs +1 -0
- package/dist/cjs/components/select-field/test-utils.d.cts +11 -0
- package/dist/cjs/components/selectable-button-group/SelectableButtonGroup.cjs +1 -1
- package/dist/cjs/components/selectable-button-group/SelectableButtonGroup.context.d.cts +5 -1
- package/dist/cjs/components/selectable-button-group/SelectableButtonGroup.d.cts +7 -1
- package/dist/cjs/components/selectable-button-group/parts/SelectableButton.cjs +1 -1
- package/dist/cjs/components/selectable-button-group/parts/SelectableButton.d.cts +35 -0
- package/dist/cjs/components/selectable-button-group-field/SelectableButtonGroupField.cjs +1 -0
- package/dist/cjs/components/selectable-button-group-field/SelectableButtonGroupField.d.cts +59 -0
- package/dist/cjs/components/side-panel/SidePanel.cjs +1 -1
- package/dist/cjs/components/side-panel/SidePanel.d.cts +6 -0
- package/dist/cjs/components/table/Table.cjs +1 -1
- package/dist/cjs/components/table/Table.d.cts +4 -0
- package/dist/cjs/components/table/parts/TableCell.cjs +1 -1
- package/dist/cjs/components/tabs/parts/NavigationButton.cjs +1 -1
- package/dist/cjs/components/tabs/parts/TabList.cjs +1 -1
- package/dist/cjs/components/text/Text.cjs +1 -1
- package/dist/cjs/components/text/Text.d.cts +1 -1
- package/dist/cjs/components/text/Text.variants.cjs +1 -1
- package/dist/cjs/components/text/Text.variants.d.cts +7 -0
- package/dist/cjs/components/toggle-switch/ToggleSwitch.cjs +1 -1
- package/dist/cjs/components/toggle-switch/ToggleSwitch.d.cts +71 -49
- package/dist/cjs/components/toggle-switch-field/ToggleSwitchField.cjs +1 -1
- package/dist/cjs/components/toggle-switch-field/ToggleSwitchField.d.cts +2 -7
- package/dist/cjs/components/tooltip/Tooltip.cjs +1 -1
- package/dist/cjs/components/tooltip/Tooltip.d.cts +4 -3
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.d.cts +5 -0
- package/dist/cjs/index.storybook-testing.d.cts +2 -0
- package/dist/cjs/storybook-testing.cjs +1 -0
- package/dist/cjs/storybook-utilities/breadcrumbs/transform.d.cts +2 -0
- package/dist/cjs/storybook-utilities/previewTransform.d.cts +1 -0
- package/dist/cjs/types/testing.d.cts +2 -0
- package/dist/esm/components/button/Button.d.ts +5 -2
- package/dist/esm/components/checkbox/Checkbox.js +21 -29
- package/dist/esm/components/checkbox/Checkbox.variants.js +4 -4
- package/dist/esm/components/checkbox/parts/CheckboxIndicator.js +1 -1
- package/dist/esm/components/data-table/DataTable.d.ts +3 -6
- package/dist/esm/components/data-table/DataTable.js +61 -56
- package/dist/esm/components/date-calendar/DateCalendar.d.ts +23 -0
- package/dist/esm/components/{date-picker/parts → date-calendar}/DateCalendar.js +62 -60
- package/dist/esm/components/date-calendar/hooks/useMonthsList.d.ts +4 -0
- package/dist/esm/components/date-calendar/hooks/useYearsList.d.ts +10 -0
- package/dist/esm/components/date-picker/DatePicker.d.ts +3 -3
- package/dist/esm/components/date-picker/DatePicker.js +22 -22
- package/dist/esm/components/date-picker-field/test-utils.d.ts +12 -0
- package/dist/esm/components/date-picker-field/test-utils.js +35 -0
- package/dist/esm/components/definition-tooltip/DefinitionTooltip.d.ts +23 -0
- package/dist/esm/components/definition-tooltip/DefinitionTooltip.js +29 -0
- package/dist/esm/components/dialog/parts/DialogActions/DialogButton.d.ts +2 -2
- package/dist/esm/components/dialog/parts/DialogActions/DialogButton.js +31 -27
- package/dist/esm/components/icon-button/CircularIconButton.d.ts +0 -21
- package/dist/esm/components/icon-button/CircularIconButton.js +23 -26
- package/dist/esm/components/icon-button/IconButton.d.ts +1 -1
- package/dist/esm/components/number-field/NumberField.d.ts +47 -0
- package/dist/esm/components/number-field/NumberField.js +71 -0
- package/dist/esm/components/number-input/NumberInput.d.ts +216 -0
- package/dist/esm/components/number-input/NumberInput.js +214 -0
- package/dist/esm/components/pagination/Pagination.js +17 -16
- package/dist/esm/components/pagination/hooks/use-pagination.d.ts +2 -1
- package/dist/esm/components/pagination/hooks/use-pagination.js +12 -11
- package/dist/esm/components/popover/Popover.js +25 -21
- package/dist/esm/components/popover/parts/PopoverHeader.js +17 -15
- package/dist/esm/components/radio-button-group/parts/RadioButton.js +1 -1
- package/dist/esm/components/select-field/test-utils.d.ts +11 -0
- package/dist/esm/components/select-field/test-utils.js +25 -0
- package/dist/esm/components/selectable-button-group/SelectableButtonGroup.context.d.ts +5 -1
- package/dist/esm/components/selectable-button-group/SelectableButtonGroup.d.ts +7 -1
- package/dist/esm/components/selectable-button-group/SelectableButtonGroup.js +23 -16
- package/dist/esm/components/selectable-button-group/parts/SelectableButton.d.ts +35 -0
- package/dist/esm/components/selectable-button-group/parts/SelectableButton.js +44 -36
- package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.d.ts +59 -0
- package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.js +45 -0
- package/dist/esm/components/side-panel/SidePanel.d.ts +6 -0
- package/dist/esm/components/side-panel/SidePanel.js +38 -35
- package/dist/esm/components/table/Table.d.ts +4 -0
- package/dist/esm/components/table/Table.js +96 -71
- package/dist/esm/components/table/parts/TableCell.js +5 -5
- package/dist/esm/components/tabs/parts/NavigationButton.js +4 -4
- package/dist/esm/components/tabs/parts/TabList.js +44 -35
- package/dist/esm/components/text/Text.d.ts +1 -1
- package/dist/esm/components/text/Text.js +6 -5
- package/dist/esm/components/text/Text.variants.d.ts +7 -0
- package/dist/esm/components/text/Text.variants.js +2 -1
- package/dist/esm/components/toggle-switch/ToggleSwitch.d.ts +71 -49
- package/dist/esm/components/toggle-switch/ToggleSwitch.js +50 -29
- package/dist/esm/components/toggle-switch-field/ToggleSwitchField.d.ts +2 -7
- package/dist/esm/components/toggle-switch-field/ToggleSwitchField.js +41 -55
- package/dist/esm/components/tooltip/Tooltip.d.ts +4 -3
- package/dist/esm/components/tooltip/Tooltip.js +13 -12
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +237 -225
- package/dist/esm/index.storybook-testing.d.ts +2 -0
- package/dist/esm/storybook-testing.js +6 -0
- package/dist/esm/storybook-utilities/breadcrumbs/transform.d.ts +2 -0
- package/dist/esm/storybook-utilities/previewTransform.d.ts +1 -0
- package/dist/esm/types/testing.d.ts +2 -0
- package/i18n/en-GB.json +2 -0
- package/i18n/es-ES.json +2 -0
- package/i18n/fr-FR.json +2 -0
- package/package.json +44 -20
- package/dist/cjs/components/date-picker/parts/DateCalendar.cjs +0 -1
- package/dist/cjs/components/date-picker/parts/DateCalendar.d.cts +0 -9
- package/dist/cjs/components/popover/parts/PopoverContent.cjs +0 -1
- package/dist/esm/components/date-picker/parts/DateCalendar.d.ts +0 -9
- package/dist/esm/components/popover/parts/PopoverContent.js +0 -9
- /package/dist/cjs/components/{date-picker → date-calendar}/hooks/useMonthsList.cjs +0 -0
- /package/dist/cjs/components/{date-picker → date-calendar}/hooks/useYearsList.cjs +0 -0
- /package/dist/cjs/components/{date-picker → date-calendar}/parts/DateSegmentSelect.cjs +0 -0
- /package/dist/cjs/components/{date-picker → date-calendar}/parts/DateSegmentSelect.d.cts +0 -0
- /package/dist/esm/components/{date-picker → date-calendar}/hooks/useMonthsList.js +0 -0
- /package/dist/esm/components/{date-picker → date-calendar}/hooks/useYearsList.js +0 -0
- /package/dist/esm/components/{date-picker → date-calendar}/parts/DateSegmentSelect.d.ts +0 -0
- /package/dist/esm/components/{date-picker → date-calendar}/parts/DateSegmentSelect.js +0 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { NumberFieldProps } from 'react-aria-components';
|
|
3
|
+
import { VariantProps } from 'tailwind-variants';
|
|
4
|
+
export declare const numberInput: import('tailwind-variants').TVReturnType<{
|
|
5
|
+
isReadOnly: {
|
|
6
|
+
true: {
|
|
7
|
+
base: string[];
|
|
8
|
+
prefix: string[];
|
|
9
|
+
wrapper: string[];
|
|
10
|
+
input: string[];
|
|
11
|
+
suffix: string[];
|
|
12
|
+
};
|
|
13
|
+
false: {
|
|
14
|
+
base: string[];
|
|
15
|
+
prefix: string[];
|
|
16
|
+
suffix: string[];
|
|
17
|
+
wrapper: string[];
|
|
18
|
+
input: string[];
|
|
19
|
+
state: string[];
|
|
20
|
+
button: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
base: string[];
|
|
25
|
+
wrapper: string[];
|
|
26
|
+
input: string[];
|
|
27
|
+
prefix: string[];
|
|
28
|
+
suffix: string[];
|
|
29
|
+
state: string[];
|
|
30
|
+
controls: string[];
|
|
31
|
+
}, undefined, import('tailwind-variants/dist/config.js').TVConfig<{
|
|
32
|
+
isReadOnly: {
|
|
33
|
+
true: {
|
|
34
|
+
base: string[];
|
|
35
|
+
prefix: string[];
|
|
36
|
+
wrapper: string[];
|
|
37
|
+
input: string[];
|
|
38
|
+
suffix: string[];
|
|
39
|
+
};
|
|
40
|
+
false: {
|
|
41
|
+
base: string[];
|
|
42
|
+
prefix: string[];
|
|
43
|
+
suffix: string[];
|
|
44
|
+
wrapper: string[];
|
|
45
|
+
input: string[];
|
|
46
|
+
state: string[];
|
|
47
|
+
button: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}, {
|
|
51
|
+
isReadOnly: {
|
|
52
|
+
true: {
|
|
53
|
+
base: string[];
|
|
54
|
+
prefix: string[];
|
|
55
|
+
wrapper: string[];
|
|
56
|
+
input: string[];
|
|
57
|
+
suffix: string[];
|
|
58
|
+
};
|
|
59
|
+
false: {
|
|
60
|
+
base: string[];
|
|
61
|
+
prefix: string[];
|
|
62
|
+
suffix: string[];
|
|
63
|
+
wrapper: string[];
|
|
64
|
+
input: string[];
|
|
65
|
+
state: string[];
|
|
66
|
+
button: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
}>, {
|
|
70
|
+
isReadOnly: {
|
|
71
|
+
true: {
|
|
72
|
+
base: string[];
|
|
73
|
+
prefix: string[];
|
|
74
|
+
wrapper: string[];
|
|
75
|
+
input: string[];
|
|
76
|
+
suffix: string[];
|
|
77
|
+
};
|
|
78
|
+
false: {
|
|
79
|
+
base: string[];
|
|
80
|
+
prefix: string[];
|
|
81
|
+
suffix: string[];
|
|
82
|
+
wrapper: string[];
|
|
83
|
+
input: string[];
|
|
84
|
+
state: string[];
|
|
85
|
+
button: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
}, {
|
|
89
|
+
base: string[];
|
|
90
|
+
wrapper: string[];
|
|
91
|
+
input: string[];
|
|
92
|
+
prefix: string[];
|
|
93
|
+
suffix: string[];
|
|
94
|
+
state: string[];
|
|
95
|
+
controls: string[];
|
|
96
|
+
}, import('tailwind-variants').TVReturnType<{
|
|
97
|
+
isReadOnly: {
|
|
98
|
+
true: {
|
|
99
|
+
base: string[];
|
|
100
|
+
prefix: string[];
|
|
101
|
+
wrapper: string[];
|
|
102
|
+
input: string[];
|
|
103
|
+
suffix: string[];
|
|
104
|
+
};
|
|
105
|
+
false: {
|
|
106
|
+
base: string[];
|
|
107
|
+
prefix: string[];
|
|
108
|
+
suffix: string[];
|
|
109
|
+
wrapper: string[];
|
|
110
|
+
input: string[];
|
|
111
|
+
state: string[];
|
|
112
|
+
button: string;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
}, {
|
|
116
|
+
base: string[];
|
|
117
|
+
wrapper: string[];
|
|
118
|
+
input: string[];
|
|
119
|
+
prefix: string[];
|
|
120
|
+
suffix: string[];
|
|
121
|
+
state: string[];
|
|
122
|
+
controls: string[];
|
|
123
|
+
}, undefined, import('tailwind-variants/dist/config.js').TVConfig<{
|
|
124
|
+
isReadOnly: {
|
|
125
|
+
true: {
|
|
126
|
+
base: string[];
|
|
127
|
+
prefix: string[];
|
|
128
|
+
wrapper: string[];
|
|
129
|
+
input: string[];
|
|
130
|
+
suffix: string[];
|
|
131
|
+
};
|
|
132
|
+
false: {
|
|
133
|
+
base: string[];
|
|
134
|
+
prefix: string[];
|
|
135
|
+
suffix: string[];
|
|
136
|
+
wrapper: string[];
|
|
137
|
+
input: string[];
|
|
138
|
+
state: string[];
|
|
139
|
+
button: string;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
}, {
|
|
143
|
+
isReadOnly: {
|
|
144
|
+
true: {
|
|
145
|
+
base: string[];
|
|
146
|
+
prefix: string[];
|
|
147
|
+
wrapper: string[];
|
|
148
|
+
input: string[];
|
|
149
|
+
suffix: string[];
|
|
150
|
+
};
|
|
151
|
+
false: {
|
|
152
|
+
base: string[];
|
|
153
|
+
prefix: string[];
|
|
154
|
+
suffix: string[];
|
|
155
|
+
wrapper: string[];
|
|
156
|
+
input: string[];
|
|
157
|
+
state: string[];
|
|
158
|
+
button: string;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
}>, unknown, unknown, undefined>>;
|
|
162
|
+
type StyleWithoutCurrency = Exclude<Intl.NumberFormatOptions['style'], 'currency'>;
|
|
163
|
+
interface FormatOptions extends Omit<Intl.NumberFormatOptions, 'currency' | 'style'> {
|
|
164
|
+
style?: StyleWithoutCurrency;
|
|
165
|
+
}
|
|
166
|
+
export interface NumberProps extends VariantProps<typeof numberInput>, Omit<NumberFieldProps, 'className' | 'style' | 'formatOptions' | 'children'> {
|
|
167
|
+
withControls?: boolean;
|
|
168
|
+
/** Element to display before the input field */
|
|
169
|
+
prefix?: ReactElement;
|
|
170
|
+
/** Element to display after the input field */
|
|
171
|
+
suffix?: ReactElement;
|
|
172
|
+
/** Whether the field is in a loading state */
|
|
173
|
+
isLoading?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Clear button click handler
|
|
176
|
+
*/
|
|
177
|
+
onClearButtonPress?: () => void;
|
|
178
|
+
/** Format options for the number input */
|
|
179
|
+
formatOptions?: FormatOptions;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The `NumberInput` component renders an input field specifically designed for numeric values. It provides features like
|
|
183
|
+
* increment/decrement controls, formatting options, and various states including loading, invalid, disabled, and read-only.
|
|
184
|
+
* The component supports prefix and suffix elements, clear button functionality, and can be integrated with form validation.
|
|
185
|
+
* @param {NumberProps} props - The props for the `NumberInput` component
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* import { NumberInput } from '@payfit/unity-components'
|
|
189
|
+
*
|
|
190
|
+
* // Basic usage
|
|
191
|
+
* <NumberInput aria-label="Amount" />
|
|
192
|
+
*
|
|
193
|
+
* // With controls and formatting
|
|
194
|
+
* <NumberInput
|
|
195
|
+
* withControls
|
|
196
|
+
* minValue={0}
|
|
197
|
+
* maxValue={1000}
|
|
198
|
+
* step={10}
|
|
199
|
+
* formatOptions={{
|
|
200
|
+
* minimumFractionDigits: 2,
|
|
201
|
+
* maximumFractionDigits: 2
|
|
202
|
+
* }}
|
|
203
|
+
* aria-label="Amount"
|
|
204
|
+
* />
|
|
205
|
+
*
|
|
206
|
+
* // With prefix
|
|
207
|
+
* <NumberInput
|
|
208
|
+
* prefix={<Icon src="CurrencyEuroOutlined" size={20} />}
|
|
209
|
+
* aria-label="Amount"
|
|
210
|
+
* />
|
|
211
|
+
* ```
|
|
212
|
+
* @see {@link NumberProps} for all available props
|
|
213
|
+
* @remarks {@link https://www.payfit.design/24f360409/p/545bd2-number-field|Design docs}
|
|
214
|
+
*/
|
|
215
|
+
declare const NumberInput: import('react').ForwardRefExoticComponent<NumberProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
216
|
+
export { NumberInput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),d=require("react"),P=require("react-aria"),N=require("react-intl"),R=require("react-stately"),S=require("tailwind-variants"),T=require("./hooks/use-pagination.cjs"),E=require("./parts/PaginationEllipsis.cjs"),W=require("./parts/PaginationJumpDialog.cjs"),J=require("./parts/PaginationLink.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),d=require("react"),P=require("react-aria"),N=require("react-intl"),R=require("react-stately"),S=require("tailwind-variants"),T=require("./hooks/use-pagination.cjs"),E=require("./parts/PaginationEllipsis.cjs"),W=require("./parts/PaginationJumpDialog.cjs"),J=require("./parts/PaginationLink.cjs"),D=require("./parts/PaginationNavButton.cjs"),O=require("./utils/pagination-window.cjs"),A=S.tv({slots:{base:"uy-flex uy-gap-100 uy-relative",pagesList:"uy-flex uy-gap-100 uy-list-none uy-m-0 uy-p-0"}}),$=7,L=d.forwardRef(({pageCount:i,defaultPage:f,currentPage:v,onPageHover:l,onPageChange:y,onNextPress:c,onPreviousPress:u,...j},h)=>{const p=P.useId(),m=N.useIntl(),b=v!==void 0&&y!==void 0&&f===void 0,{currentPage:r,goToPage:s}=T.usePagination({pageCount:i,initialPage:b?v:f,onPageChange:y,isControlled:b}),g=R.useOverlayTriggerState({}),o=d.useRef(new Map),k=d.useMemo(()=>O.generatePaginationWithWindow(i,r,$),[i,r]),x=new Intl.NumberFormat(m.locale,{notation:"standard"}),I=a=>{s(a),g.close(),requestAnimationFrame(()=>{const t=o.current.get(a);t&&t.focus()})},q=(a,t)=>{switch(a.key){case"ArrowLeft":case"ArrowUp":a.preventDefault(),t>1&&(s(t-1),requestAnimationFrame(()=>{var e;(e=o.current.get(t-1))==null||e.focus()}));break;case"ArrowRight":case"ArrowDown":a.preventDefault(),t<i&&(s(t+1),requestAnimationFrame(()=>{var e;(e=o.current.get(t+1))==null||e.focus()}));break;case"Home":a.preventDefault(),s(1),requestAnimationFrame(()=>{var e;(e=o.current.get(1))==null||e.focus()});break;case"End":a.preventDefault(),s(i),requestAnimationFrame(()=>{var e;(e=o.current.get(i))==null||e.focus()});break}},w={paginationLabel:m.formatMessage({id:"unity:component:pagination:label",defaultMessage:"Pagination"}),pageListLabel:m.formatMessage({id:"unity:component:pagination:page-list:label",defaultMessage:"Page {current} of {total}"},{current:r,total:i})},{base:F,pagesList:M}=A();return n.jsxs("nav",{"data-dd-privacy":"allow",...j,ref:h,className:F(),"aria-labelledby":w.paginationLabel,children:[n.jsx(W.PaginationJumpDialog,{pageCount:i,onJumpToPage:I,state:g}),n.jsx(D.PaginationNavButton,{variant:"previous",isDisabled:r===1,onClick:()=>{s("previous"),u==null||u()}}),n.jsx("ul",{className:M(),"aria-label":w.pageListLabel,children:k.map((a,t)=>a.type==="page"?n.jsx("li",{"aria-setsize":i,"aria-posinset":a.value,children:n.jsx(J.PaginationLink,{ref:e=>{e?o.current.set(a.value,e):o.current.delete(a.value)},onPress:()=>{s(a.value)},onHoverChange:e=>{e&&(l==null||l(a.value))},onKeyDown:e=>{q(e,a.value)},isActive:a.value===r,value:a.value,children:x.format(a.value)})},`uy-pagination-${p}-item-${t}`):n.jsx("li",{children:n.jsx(E.PaginationEllipsis,{value:a.value,onKeyDown:e=>{q(e,-1)},onPress:()=>{g.open()}})},`uy-pagination-${p}-item-${t}`))}),n.jsx(D.PaginationNavButton,{variant:"next",isDisabled:r===i,onClick:()=>{s("next"),c==null||c()}})]})});L.displayName="Pagination";exports.Pagination=L;exports.pagination=A;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react");function b({isControlled:c=!1,pageCount:o,initialPage:r=1,onPageChange:n}){const[i,u]=a.useState(r),e=c?r:i,l=e-1,P=e+1,s=a.useCallback(t=>{n&&n(t,e,Math.sign(t-e)),u(Math.max(1,Math.min(o,t)))},[e,o,n]),f=a.useCallback(t=>{s(t==="previous"?e-1:t==="next"?e+1:t)},[e,s]);return{currentPage:e,previousPage:l,nextPage:P,goToPage:f}}exports.usePagination=b;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export interface PaginationOptions {
|
|
2
2
|
pageCount: number;
|
|
3
3
|
initialPage?: number;
|
|
4
|
+
isControlled?: boolean;
|
|
4
5
|
onPageChange?: (page: number, previous: number, direction: -1 | 1) => void;
|
|
5
6
|
}
|
|
6
|
-
export declare function usePagination({ pageCount, initialPage, onPageChange, }: PaginationOptions): {
|
|
7
|
+
export declare function usePagination({ isControlled, pageCount, initialPage, onPageChange, }: PaginationOptions): {
|
|
7
8
|
currentPage: number;
|
|
8
9
|
previousPage: number;
|
|
9
10
|
nextPage: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),c=require("react"),e=require("react-aria-components"),g=require("tailwind-variants"),p=require("./parts/PopoverHeader.cjs"),m=g.tv({slots:{base:["uy-border uy-border-solid uy-border-border-neutral uy-bg-surface-neutral uy-rounded-200 uy-p-200 uy-shadow-floating uy-min-w-[320px] uy-max-w-[800px] uy-overflow-auto","uy-transition-all uy-duration-200 uy-linear data-[entering]:uy-opacity-100 data-[exiting]:uy-opacity-0",'data-[entering]:data-[placement="bottom"]:-uy-translate-y-100 data-[entering]:data-[placement="bottom"]:uy-translate-x-0 data-[exiting]:data-[placement="bottom"]:uy-translate-y-0','data-[entering]:data-[placement="top"]:uy-translate-y-100 data-[entering]:data-[placement="top"]:uy-translate-x-0 data-[exiting]:data-[placement="top"]:uy-translate-y-0','data-[entering]:data-[placement="left"]:uy-translate-x-100 data-[entering]:data-[placement="left"]:uy-translate-y-0 data-[exiting]:data-[placement="bottom"]:uy-translate-x-0','data-[entering]:data-[placement="right"]:-uy-translate-x-100 data-[entering]:data-[placement="right"]:uy-translate-y-0 data-[exiting]:data-[placement="right"]:uy-translate-y-0'],dialog:["uy-flex uy-flex-col","focus:uy-outline-2 focus:uy-outline-offset-2"]}}),a=c.forwardRef((r,n)=>{const{children:o,title:i,isTitleSrOnly:l,displayCloseButton:u,...s}=r,{base:d,dialog:y}=m();return t.jsx(e.Popover,{ref:n,className:d(),offset:8,...s,children:t.jsxs(e.Dialog,{className:y(),role:"dialog",children:[t.jsx(p.PopoverHeader,{title:i,isTitleSrOnly:l,displayCloseButton:u}),o]})})});a.displayName="Popover";e.DialogTrigger.displayName="PopoverTrigger";Object.defineProperty(exports,"PopoverTrigger",{enumerable:!0,get:()=>e.DialogTrigger});exports.Popover=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("react"),o=require("react-aria-components"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("react"),o=require("react-aria-components"),g=require("react-intl"),m=require("tailwind-variants"),p=require("../../icon-button/IconButton.cjs"),v=m.tv({slots:{base:"uy-flex uy-justify-between",heading:"uy-content-center",iconButton:"uy-ml-200"},variants:{isTitleSrOnly:{true:{heading:"uy-sr-only"},false:{base:"uy-mb-150",heading:"uy-typography-h2 uy-min-h-500 uy-align-center"}}}}),a=n.forwardRef(({title:s,isTitleSrOnly:r,displayCloseButton:i},l)=>{const e=n.useContext(o.OverlayTriggerStateContext),c=g.useIntl(),{base:u,heading:d,iconButton:y}=v({isTitleSrOnly:r});return t.jsxs("div",{className:u(),children:[t.jsx(o.Heading,{ref:l,slot:"title",className:d(),"data-dd-privacy":"allow",children:s}),i&&t.jsx(p.IconButton,{variant:"ghost",color:"neutral",className:y(),label:c.formatMessage({id:"unity:component:common:close:label",defaultMessage:"Close"}),icon:"CloseOutlined",onClick:()=>e==null?void 0:e.close()})]})});a.displayName="PopoverTitle";exports.PopoverHeader=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),t=require("react"),d=require("react-aria-components"),m=require("tailwind-variants"),x=require("../../flex/Flex.cjs"),p=require("../../text/Text.cjs"),v=require("./radio-input-selected.svg.cjs"),R=require("./radio-input-unselected.svg.cjs"),j=require("./RadioButtonHelper.cjs"),n=m.tv({slots:{base:["uy-group uy-flex uy-gap-100 uy-rounded-50 uy-items-center","data-[disabled]:uy-cursor-not-allowed","data-[readonly]:uy-cursor-not-allowed"],radio:["uy-border-border-form-enabled uy-border-solid uy-bg-surface-form-enabled","group-data-[disabled]:uy-border-border-form-disabled"],label:["uy-text-content-neutral","group-data-[disabled]:uy-text-content-neutral-disabled","group-data-[readonly]:uy-text-content-neutral group-data-[readonly]:uy-cursor-text"]},variants:{isFocusVisible:{true:"uy-outline-none uy-ring-2 uy-ring-offset-2 uy-ring-utility-focus-ring"}}}),u=t.forwardRef(({children:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),t=require("react"),d=require("react-aria-components"),m=require("tailwind-variants"),x=require("../../flex/Flex.cjs"),p=require("../../text/Text.cjs"),v=require("./radio-input-selected.svg.cjs"),R=require("./radio-input-unselected.svg.cjs"),j=require("./RadioButtonHelper.cjs"),n=m.tv({slots:{base:["uy-group uy-flex uy-gap-100 uy-rounded-50 uy-items-center uy-cursor-pointer","data-[disabled]:uy-cursor-not-allowed","data-[readonly]:uy-cursor-not-allowed"],radio:["uy-border-border-form-enabled uy-border-solid uy-bg-surface-form-enabled","group-data-[disabled]:uy-border-border-form-disabled"],label:["uy-text-content-neutral","group-data-[disabled]:uy-text-content-neutral-disabled","group-data-[readonly]:uy-text-content-neutral group-data-[readonly]:uy-cursor-text"]},variants:{isFocusVisible:{true:"uy-outline-none uy-ring-2 uy-ring-offset-2 uy-ring-utility-focus-ring"}}}),u=t.forwardRef(({children:i,value:l,isDisabled:s,helperText:a,...c},y)=>{const{base:b,label:g}=n(),r=t.useContext(d.RadioGroupStateContext),f=t.useMemo(()=>r!=null&&r.isReadOnly?{"--radio-fill-color":"rgb(var(--uy-colors-border-form-read-only))","--radio-border-color":"rgb(var(--uy-colors-border-form-disabled))"}:{"--radio-fill-color":"rgb(var(--uy-colors-surface-primary-active))","--radio-border-color":"rgb(var(--uy-colors-border-form-active))"},[r==null?void 0:r.isReadOnly]);return o.jsxs(x.Flex,{direction:"col",gap:"50",children:[o.jsx(d.Radio,{...c,value:l,isDisabled:s,className:({isFocusVisible:e})=>b({isFocusVisible:e}),ref:y,children:({isSelected:e})=>o.jsxs(o.Fragment,{children:[e?o.jsx(v,{style:f}):o.jsx(R,{style:r!=null&&r.isReadOnly?{"--radio-border-color":"rgb(var(--uy-colors-border-form-disabled))"}:{"--radio-border-color":"rgb(var(--uy-colors-border-form-enabled))"}}),o.jsx(p.Text,{variant:"body",className:g(),children:i})]})}),a?o.jsx(j.RadioButtonHelper,{children:a}):null]})});u.displayName="RadioButton";exports.RadioButton=u;exports.radioButton=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("storybook/test"),i=n=>({selectOption:async({labelText:t,optionName:s})=>{await n.step(`Select option "${s}" in "${t}"`,async()=>{const c=e.within(n.canvasElement).getByLabelText(t,{exact:!1});if(!c)throw new Error(`Select not found for label ${t}`);await e.userEvent.click(c,{delay:100}),await e.userEvent.click(e.screen.getByRole("option",{name:s}),{delay:100}),await e.userEvent.tab({delay:100})})}});exports.getTestingUtilsSelect=i;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PlayCtx } from '../../types/testing.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* Factory to get select testing utils
|
|
4
|
+
* @param context the story context
|
|
5
|
+
*/
|
|
6
|
+
export declare const getTestingUtilsSelect: (context: PlayCtx) => {
|
|
7
|
+
selectOption: ({ labelText, optionName, }: {
|
|
8
|
+
labelText: string;
|
|
9
|
+
optionName: string;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),r=require("react"),u=require("react-aria"),v=require("react-stately"),S=require("tailwind-variants"),b=require("./SelectableButtonGroup.context.cjs"),c=S.tv({base:"uy-flex uy-gap-100"}),o=r.forwardRef((e,i)=>{const t=r.useRef(null),a=v.useToggleGroupState({...e,selectedKeys:e.value,defaultSelectedKeys:e.defaultValue,onSelectionChange:g=>{var l;(l=e.onChange)==null||l.call(e,Array.from(g))}}),{groupProps:s}=u.useToggleButtonGroup(e,a,t),d=c({className:e.className}),{ref:f}=u.mergeProps({ref:t},{ref:i});return n.jsx("div",{...s,className:d,ref:f,"data-dd-privacy":"allow","aria-invalid":e.isInvalid,children:n.jsx(b.SelectableButtonGroupContext.Provider,{value:{state:a,isInvalid:e.isInvalid},children:e.children})})});o.displayName="SelectableButtonGroup";exports.SelectableButtonGroup=o;exports.selectableButtonGroup=c;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { ToggleGroupState } from 'react-stately';
|
|
2
|
-
export
|
|
2
|
+
export interface SelectableButtonGroupContextValue {
|
|
3
|
+
state: ToggleGroupState;
|
|
4
|
+
isInvalid?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const SelectableButtonGroupContext: import('react').Context<SelectableButtonGroupContextValue | null>;
|
|
@@ -2,7 +2,7 @@ import { AriaToggleButtonGroupProps } from 'react-aria';
|
|
|
2
2
|
import { Key } from 'react-stately';
|
|
3
3
|
import { VariantProps } from 'tailwind-variants';
|
|
4
4
|
export declare const selectableButtonGroup: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, "uy-flex uy-gap-100", import('tailwind-variants/dist/config.js').TVConfig<unknown, {} | {}>, {} | {}, undefined, import('tailwind-variants').TVReturnType<unknown, undefined, "uy-flex uy-gap-100", import('tailwind-variants/dist/config.js').TVConfig<unknown, {} | {}>, unknown, unknown, undefined>>;
|
|
5
|
-
export interface SelectableButtonGroupProps extends VariantProps<typeof selectableButtonGroup>, Omit<AriaToggleButtonGroupProps, 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | '
|
|
5
|
+
export interface SelectableButtonGroupProps extends VariantProps<typeof selectableButtonGroup>, Omit<AriaToggleButtonGroupProps, 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'style'> {
|
|
6
6
|
/**
|
|
7
7
|
* The SelectableButton components to render within the group.
|
|
8
8
|
* Each child must be a SelectableButton component with a unique value prop.
|
|
@@ -26,6 +26,12 @@ export interface SelectableButtonGroupProps extends VariantProps<typeof selectab
|
|
|
26
26
|
* Required when using the component in controlled mode.
|
|
27
27
|
*/
|
|
28
28
|
onChange?: (keys: Key[]) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Marks the group and all contained buttons as invalid, applying error styles.
|
|
31
|
+
* Use this to indicate a validation error for the group.
|
|
32
|
+
*/
|
|
33
|
+
isInvalid?: boolean;
|
|
34
|
+
className?: string;
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
31
37
|
* A group component that manages the selection state of multiple SelectableButton components.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),c=require("react-aria"),S=require("tailwind-variants"),B=require("../../icon/Icon.cjs"),j=require("../../spinner/Spinner.cjs"),w=require("../SelectableButtonGroup.context.cjs"),b=S.tv({slots:{base:["uy-group uy-border uy-border-solid uy-rounded-75 uy-py-100 uy-flex uy-gap-50 uy-items-center","uy-border-border-form-enabled uy-bg-surface-form-enabled","hover:uy-bg-surface-form-hover hover:uy-border-border-form-hover","active:uy-bg-surface-form-pressed active:uy-border-border-form-pressed","focus-visible:uy-bg-surface-form-focus focus-visible:uy-border-border-form-focus","focus-visible:uy-outline-2 focus-visible:uy-outline focus-visible:uy-outline-offset-2 focus-visible:uy-outline-utility-focus-ring","data-[pressed=true]:uy-bg-surface-form-pressed data-[pressed=true]:uy-border-border-form-pressed data-[pressed=true]:uy-text-content-form-pressed","data-[selected=true]:uy-bg-surface-form-selected data-[selected=true]:uy-border-border-form-selected data-[selected=true]:uy-text-content-form-selected","disabled:uy-bg-surface-form-disabled disabled:uy-border-border-form-disabled disabled:uy-text-content-form-disabled disabled:uy-cursor-not-allowed","data-[loading=true]:uy-bg-surface-form-disabled data-[loading=true]:uy-border-border-form-disabled data-[loading=true]:uy-text-content-form-disabled data-[loading=true]:uy-cursor-wait"],icon:["uy-p-25","data-[loading=true]:uy-hidden"],label:["uy-typography-action"]},variants:{hasIcon:{true:{base:"uy-pl-100 uy-pr-200"},false:{base:"uy-px-200"}},isInvalid:{true:{base:"uy-bg-surface-form-error uy-border-border-form-error"}}},defaultVariants:{hasIcon:!1,isInvalid:!1}}),f=o.forwardRef((s,y)=>{const a=o.useRef(null),u=o.useContext(w.SelectableButtonGroupContext);if(!u)throw new Error("SelectableButton must be used within a ToggleButtonGroup component");const{state:m,isInvalid:d}=u,{buttonProps:l,isPressed:p,isSelected:n}=c.useToggleButtonGroupItem({id:s.value,...s},m,a),{ref:g}=c.mergeProps({ref:a},{ref:y}),{isDisabled:v=!1,isLoading:r=!1,prefixIcon:t,children:i}=s,{base:x,icon:h,label:I}=b({hasIcon:!!t&&!r,isInvalid:!!d});return e.jsxs("button",{"data-dd-privacy":"allow",...l,ref:g,className:x(),disabled:l.disabled||v||r,"data-loading":r?!0:void 0,"data-pressed":p,"data-selected":n,"data-invalid":d,"aria-busy":r,children:[t&&!r&&e.jsx(B.Icon,{src:n?`${t}Filled`:`${t}Outlined`,role:"presentation",className:h(),size:20}),r?e.jsxs(e.Fragment,{children:[e.jsx(j.Spinner,{label:"Loading",size:"small",color:"inherit"}),e.jsx("span",{className:"uy-sr-only",children:i})]}):e.jsx("span",{className:I(),children:i})]})});f.displayName="SelectableButton";exports.SelectableButton=f;exports.selectableButton=b;
|
|
@@ -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'> {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("react"),p=require("react-hook-form"),x=require("../form-field/FormField.cjs"),q=require("../form-field/parts/FormControl.cjs"),S=require("../form-field/parts/FormFeedbackText.cjs"),j=require("../form-field/parts/FormHelperText.cjs"),B=require("../form-field/parts/FormLabel.cjs"),G=require("../selectable-button-group/SelectableButtonGroup.cjs");function y({name:t,label:o,helperText:r,contextualLink:n,isDisabled:c,requiredVariant:u,children:i,...s},a){const{control:F,watch:d}=p.useFormContext(),m=d(t);return e.jsxs(x.FormField,{control:F,name:t,ref:a,children:[e.jsx(B.FormLabel,{requiredVariant:u,children:o}),r&&e.jsx(j.FormHelperText,{children:r}),e.jsx(q.FormControl,{className:"uy-my-50",children:e.jsx(G.SelectableButtonGroup,{value:m,isDisabled:c,...s,children:i})}),e.jsx(S.FormFeedbackText,{}),n]})}const l=b.forwardRef(function(o,r){return y(o,r)});l.displayName="SelectableButtonGroupField";exports.SelectableButtonGroupField=l;
|
|
@@ -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.cjs';
|
|
5
|
+
import { SelectableButtonGroupProps } from '../selectable-button-group/SelectableButtonGroup.cjs';
|
|
6
|
+
import { LabelProps } from '../label/Label.cjs';
|
|
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 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),d=require("react-aria-components"),h=require("tailwind-variants"),v=require("./parts/SidePanelDragIndicator.cjs"),u=h.tv({slots:{overlay:["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%","uy-fixed uy-inset-0 uy-isolate uy-z-10","data-[entering]:uy-animate-fade-in data-[exiting]:uy-animate-fade-out"],wrapper:["uy-w-full md:uy-w-[400px]","uy-fixed uy-bottom-0 md:uy-inset-y-200 md:uy-right-200","uy-bg-surface-neutral uy-rounded-t-200 md:uy-rounded-200 uy-shadow-flying","uy-flex uy-flex-col uy-h-[95svh] md:uy-max-h-[calc(100vh-2rem)]","uy-overflow-hidden","data-[entering]:uy-animate-slide-up-fade-in data-[exiting]:uy-animate-slide-down-fade-out md:data-[entering]:uy-animate-slide-right-fade-in md:data-[exiting]:uy-animate-slide-right-fade-out"],content:["uy-flex uy-flex-col uy-h-full uy-overflow-hidden uy-outline-none"]}}),r=i.forwardRef(({children:o,isOpen:a,onOpenChange:l,defaultOpen:t,isDismissable:y=!0,isKeyboardDismissDisabled:s=!1,disableScrollLocking:n=!1,...m},c)=>{const{overlay:f,wrapper:g,content:x}=u();return i.useEffect(()=>{n&&(a??t)&&(document.documentElement.style.overflow="",document.body.style.overflow="")},[n,a,t]),e.jsx(d.ModalOverlay,{className:f(),isOpen:a,onOpenChange:l,defaultOpen:t,isDismissable:y,isKeyboardDismissDisabled:s,children:e.jsxs(d.Modal,{"data-dd-privacy":"allow",...m,ref:c,className:g(),"data-unity-side-panel":!0,children:[e.jsx(v.SidePanelDragIndicator,{}),e.jsx(d.Dialog,{className:x(),children:o})]})})});r.displayName="SidePanel";exports.SidePanel=r;exports.sidePanel=u;
|
|
@@ -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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("react"),j=require("tailwind-variants"),H=require("usehooks-ts"),N=require("./Table.context.cjs"),V=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},a=V(n),z=j.tv({slots:{root:"uy-w-full uy-border uy-border-solid uy-border-border-neutral-enabled uy-rounded-100 uy-overflow-hidden",scroller:["uy-relative uy-flex uy-flex-col","uy-min-h-[var(--uy-table-min-rows)] uy-max-h-[var(--uy-table-max-rows)]","uy-w-full"]}}),E=n.forwardRef(({minRows:e=10,maxRows:d=50,children:l},o)=>{const{root:s,scroller:y}=z();return t.jsx("div",{ref:o,className:s(),"data-unity-slot":"table-root",children:t.jsx("div",{className:y(),"data-unity-slot":"table-scroller",style:{"--uy-table-min-rows":`calc(var(--uy-spacing-600) * ${e})`,"--uy-table-max-rows":`calc(var(--uy-spacing-600) * ${d})`},children:l})})});E.displayName="TableRoot";const q=j.tv({slots:{wrapper:["uy-flex-1 uy-h-full uy-bg-surface-neutral","uy-overflow-y-auto","uy-w-full"],table:["uy-min-w-full","uy-text-left uy-typography-body uy-text-content-neutral uy-border-collapse","focus:uy-outline-2 focus:uy-outline-utility-focus-ring focus:uy-outline-offset-[-2px]"]},variants:{horizontalScroll:{true:{wrapper:"uy-overflow-x-auto",table:"uy-w-max"},false:{wrapper:"uy-overflow-x-hidden",table:"uy-w-fit"}}},defaultVariants:{horizontalScroll:!0}}),S=n.forwardRef((e,d)=>{const{children:l,label:o,description:s,isHorizontalScrollEnabled:y=!0,...p}=e,u=n.useRef(null),{height:i=0}=H.useResizeObserver({ref:u,box:"border-box"}),{rowCount:f,columnCount:h}=n.useMemo(()=>{let b=0,m=0;return a.default.Children.forEach(l,w=>{if(!a.default.isValidElement(w))return;const c=a.default.Children.toArray(w.props.children).filter(r=>a.default.isValidElement(r));m+=c.length,c.forEach(r=>{if(!a.default.isValidElement(r))return;const x=a.default.Children.toArray(r.props.children).filter(v=>a.default.isValidElement(v));b=Math.max(b,x.length)})}),{rowCount:m,columnCount:b}},[l]);return n.useImperativeHandle(d,()=>({scrollToTop:()=>{u.current&&u.current.scrollTo({top:0,behavior:"smooth"})}})),t.jsx(N.TableContextProvider,{rowCount:f,columnCount:h,children:t.jsx(k,{scrollContainerRef:u,containerHeight:i,rowCount:f,columnCount:h,label:o,description:s,isHorizontalScrollEnabled:y,...p,children:l})})});S.displayName="Table";const k=e=>{var g,C,R;const{children:d,label:l,description:o,scrollContainerRef:s,containerHeight:y,rowCount:p,columnCount:u,onKeyDown:i,isHorizontalScrollEnabled:f=!0,...h}=e,{wrapper:b,table:m}=q({horizontalScroll:f}),{keyboardNavigation:w}=N.useTableContext(),{tableRef:c,handleTableKeyDown:r}=w,x=n.useCallback(T=>{T.key!=="Tab"&&(r(T),i==null||i(T))},[r,i]),v=(((g=s.current)==null?void 0:g.scrollHeight)??0)>Math.floor(y);return t.jsxs("div",{className:b(),ref:s,style:{"--uy-table-is-scrollable":v?"1":"0"},children:[t.jsxs("table",{ref:c,className:m(),role:"grid","aria-rowcount":p,"aria-colcount":u,"aria-label":l,"aria-describedby":o?`table-desc-${(C=c.current)==null?void 0:C.id}`:void 0,onKeyDown:x,...h,children:[d,o&&t.jsx("caption",{id:`table-desc-${(R=c.current)==null?void 0:R.id}`,className:"uy-sr-only",children:o})]}),t.jsx("div",{className:"uy-sr-only","aria-live":"polite",children:"Table navigation: Use arrow keys to move between cells. Tab key exits the table. Home and End keys navigate to the first and last cell in a row. Page Up and Page Down move between rows."})]})};k.displayName="TableContent";exports.Table=S;exports.TableRoot=E;
|
|
@@ -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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),p=require("react"),m=require("tailwind-variants"),q=require("../Table.context.cjs"),r=m.tv({base:["uy-px-200 uy-py-150 uy-text-content-neutral uy-typography-body","focus-visible:uy-outline-2 focus-visible:-uy-outline-offset-2 focus-visible:uy-outline-utility-focus-ring"],variants:{align:{left:"uy-text-left",center:"uy-text-center",right:"uy-text-right"}}}),s=p.forwardRef(({children:n,colIndex:a=0,rowIndex:u=0,align:o,onKeyDown:t,onFocus:l,className:c,isRowHeader:i=!1,...b},y)=>{const{keyboardNavigation:d}=q.useTableContext(),{isCellFocused:f,handleCellKeyDown:x,handleCellFocus:g}=d,h=f(u,a),C=e=>{e.key!=="Tab"&&(x(e),t==null||t(e))},v=i?"th":"td";return T.jsx(v,{ref:y,role:i?"rowheader":"gridcell","aria-colindex":a+1,tabIndex:h?0:-1,className:r({align:o,className:c}),onKeyDown:C,onFocus:e=>{g(e),l==null||l(e)},"data-dd-privacy":"mask",...b,children:n})});s.displayName="TableCell";exports.TableCell=s;exports.tableCell=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react-aria-components"),s=require("tailwind-variants"),a=require("../../icon/Icon.cjs"),l=s.tv({slots:{base:"uy-absolute uy-pt-150 uy-pb-150",button:"uy-rounded-circle hover:uy-text-content-neutral-hover focus-visible:uy-outline-2 focus-visible:uy-outline-offset-2 focus-visible:uy-outline-utility-focus-ring",icon:"uy-text-content-neutral-enabled"},variants:{direction:{left:{base:"uy-top-0 uy-left-0 uy-z-10 uy-bg-gradient-to-r uy-from-surface-inverted/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react-aria-components"),s=require("tailwind-variants"),a=require("../../icon/Icon.cjs"),l=s.tv({slots:{base:"uy-absolute uy-pt-150 uy-pb-150",button:"uy-rounded-circle hover:uy-text-content-neutral-hover focus-visible:uy-outline-2 focus-visible:uy-outline-offset-2 focus-visible:uy-outline-utility-focus-ring",icon:"uy-text-content-neutral-enabled"},variants:{direction:{left:{base:"uy-top-0 uy-left-0 uy-z-10 uy-bg-gradient-to-r uy-from-surface-inverted/100 uy-to-surface-inverted/0 uy-pl-50 uy-pr-200"},right:{base:"uy-right-0 uy-top-0 uy-z-10 uy-bg-gradient-to-l uy-from-surface-inverted/100 uy-to-surface-inverted/0 uy-pl-200 uy-pr-50"}}}}),c=({direction:t,onPress:u})=>{const{base:n,button:o,icon:r}=l({direction:t});return e.jsx("div",{className:n(),children:e.jsx(i.Button,{id:`scroll-${t}`,className:o(),"aria-label":`Scroll ${t}`,onPress:u,children:e.jsx(a.Icon,{className:r(),"aria-labelledby":`scroll-${t}`,src:t==="left"?"CaretLeftOutlined":"CaretRightOutlined"})})})};exports.NavigationButton=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),l=require("react"),y=require("react-aria-components"),p=require("usehooks-ts"),A=require("../Tabs.context.cjs"),B=require("../Tabs.variant.cjs"),S=require("./NavigationButton.cjs"),v=l.forwardRef(({children:f},b)=>{const e=l.useRef(null),[m,x]=l.useState(!1),[R,T]=l.useState(!1),{variant:q,scrollable:d}=A.useTabsContext(),{tabList:h}=B.tabsVariant({variant:q,scrollable:d}),L=l.useCallback(()=>{if(!e.current)return;const{scrollLeft:t,scrollWidth:n,clientWidth:r}=e.current;x(t>0),T(t+r<n)},[]);p.useResizeObserver({ref:e,onResize:L});const j=t=>{L()},N=()=>{var a;const t=(a=e.current)==null?void 0:a.querySelectorAll("[role=tab]");if(!e.current||!t)return 0;const{scrollLeft:n}=e.current,r=Array.from(t);for(let s=r.length-1;s>=0;s--){const c=r[s];if(c.offsetLeft<n)return-c.offsetWidth}return 0},W=()=>{var c;const t=(c=e.current)==null?void 0:c.querySelectorAll("[role=tab]");if(!e.current||!t)return 0;const{scrollLeft:n,clientWidth:r}=e.current,a=Array.from(t),s=n+r;for(let i=0;i<a.length-1;i++){const u=a[i],g=u.offsetLeft+u.offsetWidth;if(g>s||g<s)return u.offsetWidth}return 0};return d?o.jsxs("div",{className:"uy-relative",children:[m&&o.jsx(S.NavigationButton,{direction:"left",onPress:()=>{var t;(t=e.current)==null||t.scrollBy({behavior:"smooth",left:N()})}}),o.jsx("div",{ref:e,"data-testid":"scrollable-tab-list",className:"uy-overflow-x-auto uy-overflow-y-hidden uy-border-b-[1.25px] uy-border-solid uy-border-b-border-form-enabled",onScroll:j,children:o.jsx(y.TabList,{ref:b,className:h(),children:f})}),R&&o.jsx(S.NavigationButton,{direction:"right",onPress:()=>{var t;(t=e.current)==null||t.scrollBy({behavior:"smooth",left:W()})}})]}):o.jsx(y.TabList,{ref:b,className:h(),children:f})});v.displayName="TabList";exports.TabList=v;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),g=require("react"),u=require("./Text.variants.cjs"),b={inherit:"span",h1:"h1",h2:"h2",h3:"h3",h4:"h4",overline:"h6",subtitle:"h5",displayTitle:"h1",displayBody:"p",body:"p",bodyStrong:"strong",bodySmall:"small",bodySmallStrong:"strong",bodyLarge:"p",bodyLargeStrong:"strong",action:"span",actionLarge:"span",actionSmall:"span"},s=g.forwardRef(({children:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),g=require("react"),u=require("./Text.variants.cjs"),b={inherit:"span",h1:"h1",h2:"h2",h3:"h3",h4:"h4",overline:"h6",subtitle:"h5",displayTitle:"h1",displayBody:"p",body:"p",bodyStrong:"strong",bodySmall:"small",bodySmallStrong:"strong",bodyLarge:"p",bodyLargeStrong:"strong",action:"span",actionLarge:"span",actionSmall:"span",actionInfo:"span"},s=g.forwardRef(({children:n,variant:e,color:o,isTruncated:a,lineClamp:t,asElement:r,className:i,...l},c)=>{const d=t!==void 0,m=u.text({variant:e,color:o,isTruncated:a,isLineClamped:d,className:i}),p=b[e??"inherit"],y=r??p;return h.jsx(y,{"data-dd-privacy":"mask",...l,ref:c,className:m,style:{"--uy-text-line-clamp":t},children:n})});s.displayName="Text";exports.Text=s;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
2
|
import { VariantProps } from 'tailwind-variants';
|
|
3
3
|
import { text } from './Text.variants.cjs';
|
|
4
|
-
type ValidTextElements = 'p' | 'span' | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'em' | 'strong' | 'small';
|
|
4
|
+
export type ValidTextElements = 'p' | 'span' | 'div' | 'abbr' | 'dfn' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'em' | 'strong' | 'small';
|
|
5
5
|
export type TextProps = PropsWithChildren<HTMLAttributes<HTMLSpanElement> & {
|
|
6
6
|
/**
|
|
7
7
|
* The HTML element to render the text as. Defaults to a recommended element based on the variant.
|