@wix/site-ui 1.30.0 → 1.32.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.
- package/dist/1268.js +99 -0
- package/dist/1279.js +7 -0
- package/dist/1457.js +10 -0
- package/dist/1477.js +106 -0
- package/dist/1500.js +111 -0
- package/dist/167.js +6 -0
- package/dist/2274.js +34 -0
- package/dist/2287.js +17 -0
- package/dist/2418.js +31 -0
- package/dist/2801.js +20 -0
- package/dist/285.js +86 -0
- package/dist/2861.js +6 -0
- package/dist/3020.js +7 -0
- package/dist/3021.js +72 -0
- package/dist/3056.js +229 -0
- package/dist/3140.js +4 -0
- package/dist/3248.js +307 -0
- package/dist/3296.js +4 -0
- package/dist/3319.js +400 -0
- package/dist/3395.js +4 -0
- package/dist/3485.js +854 -0
- package/dist/353.js +14 -0
- package/dist/3670.js +418 -0
- package/dist/3829.js +113 -0
- package/dist/4026.js +12 -0
- package/dist/4143.js +46 -0
- package/dist/42.js +32 -0
- package/dist/4281.js +30 -0
- package/dist/4346.js +2 -0
- package/dist/4388.js +418 -0
- package/dist/4490.js +32 -0
- package/dist/4495.js +9 -0
- package/dist/4549.js +24 -0
- package/dist/4586.js +41 -0
- package/dist/4586.js.LICENSE.txt +19 -0
- package/dist/4707.js +19 -0
- package/dist/4723.js +7 -0
- package/dist/4745.js +7 -0
- package/dist/4768.js +35 -0
- package/dist/4922.js +15 -0
- package/dist/5036.js +17 -0
- package/dist/5085.js +20 -0
- package/dist/5299.js +597 -0
- package/dist/5659.js +4 -0
- package/dist/5778.js +10 -0
- package/dist/5864.js +86 -0
- package/dist/5992.js +913 -0
- package/dist/5992.js.LICENSE.txt +19 -0
- package/dist/6003.js +10 -0
- package/dist/6046.js +29 -0
- package/dist/6089.js +2355 -0
- package/dist/6107.js +10 -0
- package/dist/6247.js +20 -0
- package/dist/6270.js +487 -0
- package/dist/6329.js +32 -0
- package/dist/6330.js +30 -0
- package/dist/6499.js +7 -0
- package/dist/6535.js +71 -0
- package/dist/6588.js +382 -0
- package/dist/6706.js +16 -0
- package/dist/6825.js +7 -0
- package/dist/6882.js +1562 -0
- package/dist/6914.js +30 -0
- package/dist/7021.js +13 -0
- package/dist/7366.js +83 -0
- package/dist/7373.js +25 -0
- package/dist/7541.js +25 -0
- package/dist/7564.js +10 -0
- package/dist/7642.js +20 -0
- package/dist/7725.js +10 -0
- package/dist/7871.js +38 -0
- package/dist/8052.js +352 -0
- package/dist/8106.js +238 -0
- package/dist/8171.js +346 -0
- package/dist/8225.js +21 -0
- package/dist/8272.js +333 -0
- package/dist/8527.js +58 -0
- package/dist/8724.js +10 -0
- package/dist/8750.js +1920 -0
- package/dist/8758.js +43 -0
- package/dist/880.js +149 -0
- package/dist/8935.js +8 -0
- package/dist/8960.js +22 -0
- package/dist/8971.js +40 -0
- package/dist/8979.js +10 -0
- package/dist/8996.js +71 -0
- package/dist/904.js +121 -0
- package/dist/9048.js +52 -0
- package/dist/9087.js +256 -0
- package/dist/9189.js +158 -0
- package/dist/9255.js +136 -0
- package/dist/9352.js +148 -0
- package/dist/951.js +22 -0
- package/dist/9635.js +22 -0
- package/dist/9829.js +4 -0
- package/dist/9863.js +8 -0
- package/dist/Accordion/index.d.ts +569 -12
- package/dist/Accordion/index.js +423 -8
- package/dist/AlertDialog/index.d.ts +1417 -18
- package/dist/AlertDialog/index.js +34 -14
- package/dist/Autocomplete/index.d.ts +1861 -38
- package/dist/Autocomplete/index.js +98 -24
- package/dist/Avatar/index.d.ts +129 -7
- package/dist/Avatar/index.js +149 -6
- package/dist/Breadcrumbs/index.d.ts +960 -7
- package/dist/Breadcrumbs/index.js +5 -5
- package/dist/Button/index.d.ts +88 -6
- package/dist/Button/index.js +27 -3
- package/dist/Checkbox/index.d.ts +425 -5
- package/dist/Checkbox/index.js +45 -5
- package/dist/CheckboxGroup/index.d.ts +318 -3
- package/dist/CheckboxGroup/index.js +166 -3
- package/dist/Collapsible/index.d.ts +377 -7
- package/dist/Collapsible/index.js +160 -6
- package/dist/Combobox/index.d.ts +1984 -48
- package/dist/Combobox/index.js +352 -29
- package/dist/ContextMenu/index.d.ts +2340 -36
- package/dist/ContextMenu/index.js +197 -22
- package/dist/Dialog/index.d.ts +1355 -18
- package/dist/Dialog/index.js +16 -14
- package/dist/Drawer/index.d.ts +1653 -18
- package/dist/Drawer/index.js +2797 -20
- package/dist/Field/index.d.ts +655 -15
- package/dist/Field/index.js +677 -10
- package/dist/Fieldset/index.d.ts +94 -5
- package/dist/Fieldset/index.js +68 -5
- package/dist/Form/index.d.ts +331 -2
- package/dist/Form/index.js +106 -3
- package/dist/Input/index.d.ts +692 -3
- package/dist/Input/index.js +10 -3
- package/dist/Menu/index.d.ts +2301 -36
- package/dist/Menu/index.js +365 -26
- package/dist/Menubar/index.d.ts +2301 -3
- package/dist/Menubar/index.js +105 -3
- package/dist/Meter/index.d.ts +175 -11
- package/dist/Meter/index.js +129 -9
- package/dist/NavigationMenu/index.d.ts +978 -28
- package/dist/NavigationMenu/index.js +1034 -17
- package/dist/NumberField/index.d.ts +612 -15
- package/dist/NumberField/index.js +1409 -11
- package/dist/Popover/index.d.ts +1655 -20
- package/dist/Popover/index.js +792 -17
- package/dist/PreviewCard/index.d.ts +1523 -14
- package/dist/PreviewCard/index.js +679 -14
- package/dist/Progress/index.d.ts +183 -11
- package/dist/Progress/index.js +181 -9
- package/dist/Radio/index.d.ts +185 -6
- package/dist/Radio/index.js +253 -6
- package/dist/RadioGroup/index.d.ts +341 -2
- package/dist/RadioGroup/index.js +154 -3
- package/dist/ScrollArea/index.d.ts +265 -13
- package/dist/ScrollArea/index.js +892 -10
- package/dist/Select/index.d.ts +1493 -38
- package/dist/Select/index.js +1824 -23
- package/dist/Separator/index.d.ts +80 -6
- package/dist/Separator/index.js +3 -3
- package/dist/Slider/index.d.ts +678 -16
- package/dist/Slider/index.js +1199 -11
- package/dist/Switch/index.d.ts +393 -5
- package/dist/Switch/index.js +208 -6
- package/dist/Tabs/index.d.ts +523 -12
- package/dist/Tabs/index.js +685 -9
- package/dist/Toggle/index.d.ts +305 -2
- package/dist/Toggle/index.js +76 -3
- package/dist/ToggleGroup/index.d.ts +316 -2
- package/dist/ToggleGroup/index.js +102 -3
- package/dist/Toolbar/index.d.ts +282 -13
- package/dist/Toolbar/index.js +230 -9
- package/dist/Tooltip/index.d.ts +1572 -14
- package/dist/Tooltip/index.js +965 -14
- package/dist/index.d.ts +12749 -652
- package/dist/rslib-runtime.js +18 -0
- package/package.json +3 -3
package/dist/Checkbox/index.js
CHANGED
|
@@ -1,7 +1,47 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Checkbox } from "@base-ui/react/checkbox";
|
|
3
2
|
import clsx from "clsx";
|
|
3
|
+
import { CheckboxRoot_CheckboxRoot, useCheckboxRootContext, useStateAttributesMapping } from "../3248.js";
|
|
4
|
+
import { useOpenChangeComplete, transitionStatusMapping, useTransitionStatus } from "../880.js";
|
|
5
|
+
import { fieldValidityMapping } from "../1477.js";
|
|
6
|
+
import { useRenderElement } from "../8272.js";
|
|
4
7
|
import * as __rspack_external_react from "react";
|
|
8
|
+
const CheckboxIndicator_CheckboxIndicator = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
9
|
+
const { render, className, style, keepMounted = false, ...elementProps } = componentProps;
|
|
10
|
+
const rootState = useCheckboxRootContext();
|
|
11
|
+
const rendered = rootState.checked || rootState.indeterminate;
|
|
12
|
+
const { mounted, transitionStatus, setMounted } = useTransitionStatus(rendered);
|
|
13
|
+
const indicatorRef = __rspack_external_react.useRef(null);
|
|
14
|
+
const state = {
|
|
15
|
+
...rootState,
|
|
16
|
+
transitionStatus
|
|
17
|
+
};
|
|
18
|
+
useOpenChangeComplete({
|
|
19
|
+
open: rendered,
|
|
20
|
+
ref: indicatorRef,
|
|
21
|
+
onComplete () {
|
|
22
|
+
if (!rendered) setMounted(false);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const baseStateAttributesMapping = useStateAttributesMapping(rootState);
|
|
26
|
+
const stateAttributesMapping = {
|
|
27
|
+
...baseStateAttributesMapping,
|
|
28
|
+
...transitionStatusMapping,
|
|
29
|
+
...fieldValidityMapping
|
|
30
|
+
};
|
|
31
|
+
const shouldRender = keepMounted || mounted;
|
|
32
|
+
const element = useRenderElement('span', componentProps, {
|
|
33
|
+
ref: [
|
|
34
|
+
forwardedRef,
|
|
35
|
+
indicatorRef
|
|
36
|
+
],
|
|
37
|
+
state,
|
|
38
|
+
stateAttributesMapping,
|
|
39
|
+
props: elementProps
|
|
40
|
+
});
|
|
41
|
+
if (!shouldRender) return null;
|
|
42
|
+
return element;
|
|
43
|
+
});
|
|
44
|
+
if ("production" !== process.env.NODE_ENV) CheckboxIndicator_CheckboxIndicator.displayName = "CheckboxIndicator";
|
|
5
45
|
const Checkbox_module = {
|
|
6
46
|
root: "root-OrOWpu",
|
|
7
47
|
indicator: "indicator-g_8JYy"
|
|
@@ -11,7 +51,7 @@ const CheckboxSize = {
|
|
|
11
51
|
medium: 16,
|
|
12
52
|
large: 20
|
|
13
53
|
};
|
|
14
|
-
const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, size = CheckboxSize.medium, style, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
54
|
+
const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, size = CheckboxSize.medium, style, ...props }, ref)=>/*#__PURE__*/ jsx(CheckboxRoot_CheckboxRoot, {
|
|
15
55
|
ref: ref,
|
|
16
56
|
className: clsx(Checkbox_module.root, className),
|
|
17
57
|
style: {
|
|
@@ -20,13 +60,13 @@ const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, size
|
|
|
20
60
|
},
|
|
21
61
|
...props
|
|
22
62
|
}));
|
|
23
|
-
const Indicator = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
63
|
+
const Indicator = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(CheckboxIndicator_CheckboxIndicator, {
|
|
24
64
|
ref: ref,
|
|
25
65
|
className: clsx(Checkbox_module.indicator, className),
|
|
26
66
|
...props
|
|
27
67
|
}));
|
|
28
|
-
const
|
|
68
|
+
const Checkbox = {
|
|
29
69
|
Root: Root,
|
|
30
70
|
Indicator: Indicator
|
|
31
71
|
};
|
|
32
|
-
export {
|
|
72
|
+
export { Checkbox, CheckboxSize };
|
|
@@ -1,11 +1,326 @@
|
|
|
1
|
-
import { CheckboxGroupProps } from '@base-ui/react/checkbox-group';
|
|
1
|
+
import { CheckboxGroupProps as CheckboxGroupProps_2 } from '@base-ui/react/checkbox-group';
|
|
2
2
|
import * as React_2 from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
declare type BaseUIChangeEventDetail<Reason extends string, CustomProperties extends object> = {
|
|
5
|
+
/**
|
|
6
|
+
* The reason for the event.
|
|
7
|
+
*/
|
|
8
|
+
reason: Reason;
|
|
9
|
+
/**
|
|
10
|
+
* The native event associated with the custom event.
|
|
11
|
+
*/
|
|
12
|
+
event: ReasonToEvent<Reason>;
|
|
13
|
+
/**
|
|
14
|
+
* Cancels Base UI from handling the event.
|
|
15
|
+
*/
|
|
16
|
+
cancel: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Allows the event to propagate in cases where Base UI will stop the propagation.
|
|
19
|
+
*/
|
|
20
|
+
allowPropagation: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Indicates whether the event has been canceled.
|
|
23
|
+
*/
|
|
24
|
+
isCanceled: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Indicates whether the event is allowed to propagate.
|
|
27
|
+
*/
|
|
28
|
+
isPropagationAllowed: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The element that triggered the event, if applicable.
|
|
31
|
+
*/
|
|
32
|
+
trigger: Element | undefined;
|
|
33
|
+
} & CustomProperties;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Details of custom change events emitted by Base UI components.
|
|
37
|
+
*/
|
|
38
|
+
declare type BaseUIChangeEventDetails<Reason extends string, CustomProperties extends object = {}> = Reason extends string ? BaseUIChangeEventDetail<Reason, CustomProperties> & {} : never;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Props shared by all Base UI components.
|
|
42
|
+
* Contains `className` (string or callback taking the component's state as an argument) and `render` (function to customize rendering).
|
|
43
|
+
*/
|
|
44
|
+
declare type BaseUIComponentProps<ElementType extends React_2.ElementType, State, RenderFunctionProps = HTMLProps> = Omit<WithBaseUIEvent<React_2.ComponentPropsWithRef<ElementType>>, 'className' | 'color' | 'defaultValue' | 'defaultChecked' | 'style'> & {
|
|
45
|
+
/**
|
|
46
|
+
* CSS class applied to the element, or a function that
|
|
47
|
+
* returns a class based on the component's state.
|
|
48
|
+
*/
|
|
49
|
+
className?: string | ((state: State) => string | undefined) | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Allows you to replace the component's HTML element
|
|
52
|
+
* with a different tag, or compose it with another component.
|
|
53
|
+
*
|
|
54
|
+
* Accepts a `ReactElement` or a function that returns the element to render.
|
|
55
|
+
*/
|
|
56
|
+
render?: React_2.ReactElement | ComponentRenderFn<RenderFunctionProps, State> | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Style applied to the element, or a function that
|
|
59
|
+
* returns a style object based on the component's state.
|
|
60
|
+
*/
|
|
61
|
+
style?: React_2.CSSProperties | ((state: State) => React_2.CSSProperties | undefined) | undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
declare type BaseUIEvent<E extends React_2.SyntheticEvent<Element, Event>> = E & {
|
|
65
|
+
preventBaseUIHandler: () => void;
|
|
66
|
+
readonly baseUIHandlerPrevented?: boolean | undefined;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
declare const cancelOpen: "cancel-open";
|
|
70
|
+
|
|
71
|
+
export declare const CheckboxGroup: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<CheckboxGroupProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>, "ref">, "className"> & {
|
|
5
72
|
className?: string | undefined;
|
|
6
73
|
} & React_2.RefAttributes<HTMLDivElement>>;
|
|
7
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Provides a shared state to a series of checkboxes.
|
|
77
|
+
*
|
|
78
|
+
* Documentation: [Base UI Checkbox Group](https://base-ui.com/react/components/checkbox-group)
|
|
79
|
+
*/
|
|
80
|
+
declare const CheckboxGroup_2: React_2.ForwardRefExoticComponent<Omit<CheckboxGroupProps, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
81
|
+
|
|
82
|
+
declare namespace CheckboxGroup_2 {
|
|
83
|
+
type State = CheckboxGroupState;
|
|
84
|
+
type Props = CheckboxGroupProps;
|
|
85
|
+
type ChangeEventReason = CheckboxGroupChangeEventReason;
|
|
86
|
+
type ChangeEventDetails = CheckboxGroupChangeEventDetails;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export declare type CheckboxGroupChangeEventDetails = BaseUIChangeEventDetails<CheckboxGroup_2.ChangeEventReason>;
|
|
90
|
+
|
|
91
|
+
export declare type CheckboxGroupChangeEventReason = typeof REASONS.none;
|
|
92
|
+
|
|
93
|
+
export declare interface CheckboxGroupProps extends BaseUIComponentProps<'div', CheckboxGroupState> {
|
|
94
|
+
/**
|
|
95
|
+
* Names of the checkboxes in the group that should be ticked.
|
|
96
|
+
*
|
|
97
|
+
* To render an uncontrolled checkbox group, use the `defaultValue` prop instead.
|
|
98
|
+
*/
|
|
99
|
+
value?: string[] | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Names of the checkboxes in the group that should be initially ticked.
|
|
102
|
+
*
|
|
103
|
+
* To render a controlled checkbox group, use the `value` prop instead.
|
|
104
|
+
*/
|
|
105
|
+
defaultValue?: string[] | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Event handler called when a checkbox in the group is ticked or unticked.
|
|
108
|
+
* Provides the new value as an argument.
|
|
109
|
+
*/
|
|
110
|
+
onValueChange?: ((value: string[], eventDetails: CheckboxGroupChangeEventDetails) => void) | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Names of all checkboxes in the group. Use this when creating a parent checkbox.
|
|
113
|
+
*/
|
|
114
|
+
allValues?: string[] | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Whether the component should ignore user interaction.
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
disabled?: boolean | undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export declare interface CheckboxGroupState extends FieldRootState {
|
|
123
|
+
/**
|
|
124
|
+
* Whether the component should ignore user interaction.
|
|
125
|
+
*/
|
|
126
|
+
disabled: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare const chipRemovePress: "chip-remove-press";
|
|
130
|
+
|
|
131
|
+
declare const clearPress: "clear-press";
|
|
132
|
+
|
|
133
|
+
declare const closePress: "close-press";
|
|
134
|
+
|
|
135
|
+
declare const closeWatcher: "close-watcher";
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Shape of the render prop: a function that takes props to be spread on the element and component's state and returns a React element.
|
|
139
|
+
*
|
|
140
|
+
* @template Props Props to be spread on the rendered element.
|
|
141
|
+
* @template State Component's internal state.
|
|
142
|
+
*/
|
|
143
|
+
declare type ComponentRenderFn<Props, State> = (props: Props, state: State) => React_2.ReactElement<unknown>;
|
|
144
|
+
|
|
145
|
+
declare const decrementPress: "decrement-press";
|
|
146
|
+
|
|
147
|
+
declare const disabled: "disabled";
|
|
148
|
+
|
|
149
|
+
declare const drag: "drag";
|
|
150
|
+
|
|
151
|
+
declare const escapeKey: "escape-key";
|
|
152
|
+
|
|
153
|
+
declare interface FieldRootState {
|
|
154
|
+
/**
|
|
155
|
+
* Whether the component should ignore user interaction.
|
|
156
|
+
*/
|
|
157
|
+
disabled: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Whether the field has been touched.
|
|
160
|
+
*/
|
|
161
|
+
touched: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Whether the field value has changed from its initial value.
|
|
164
|
+
*/
|
|
165
|
+
dirty: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Whether the field is valid.
|
|
168
|
+
*/
|
|
169
|
+
valid: boolean | null;
|
|
170
|
+
/**
|
|
171
|
+
* Whether the field has a value.
|
|
172
|
+
*/
|
|
173
|
+
filled: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Whether the field is focused.
|
|
176
|
+
*/
|
|
177
|
+
focused: boolean;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare const focusOut: "focus-out";
|
|
181
|
+
|
|
182
|
+
declare type HTMLProps<T = any> = React_2.HTMLAttributes<T> & {
|
|
183
|
+
ref?: React_2.Ref<T> | undefined;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
declare const imperativeAction: "imperative-action";
|
|
187
|
+
|
|
188
|
+
declare const incrementPress: "increment-press";
|
|
189
|
+
|
|
190
|
+
declare const initial: "initial";
|
|
191
|
+
|
|
192
|
+
declare const inputBlur: "input-blur";
|
|
193
|
+
|
|
194
|
+
declare const inputChange: "input-change";
|
|
195
|
+
|
|
196
|
+
declare const inputClear: "input-clear";
|
|
197
|
+
|
|
198
|
+
declare const inputPaste: "input-paste";
|
|
199
|
+
|
|
200
|
+
declare const inputPress: "input-press";
|
|
201
|
+
|
|
202
|
+
declare const itemPress: "item-press";
|
|
203
|
+
|
|
204
|
+
declare const keyboard: "keyboard";
|
|
205
|
+
|
|
206
|
+
declare const linkPress: "link-press";
|
|
207
|
+
|
|
208
|
+
declare const listNavigation: "list-navigation";
|
|
209
|
+
|
|
210
|
+
declare const missing: "missing";
|
|
211
|
+
|
|
212
|
+
declare const none: "none";
|
|
213
|
+
|
|
214
|
+
declare const outsidePress: "outside-press";
|
|
215
|
+
|
|
216
|
+
declare const pointer: "pointer";
|
|
217
|
+
|
|
218
|
+
declare namespace REASONS {
|
|
219
|
+
export {
|
|
220
|
+
none,
|
|
221
|
+
triggerPress,
|
|
222
|
+
triggerHover,
|
|
223
|
+
triggerFocus,
|
|
224
|
+
outsidePress,
|
|
225
|
+
itemPress,
|
|
226
|
+
closePress,
|
|
227
|
+
linkPress,
|
|
228
|
+
clearPress,
|
|
229
|
+
chipRemovePress,
|
|
230
|
+
trackPress,
|
|
231
|
+
incrementPress,
|
|
232
|
+
decrementPress,
|
|
233
|
+
inputChange,
|
|
234
|
+
inputClear,
|
|
235
|
+
inputBlur,
|
|
236
|
+
inputPaste,
|
|
237
|
+
inputPress,
|
|
238
|
+
focusOut,
|
|
239
|
+
escapeKey,
|
|
240
|
+
closeWatcher,
|
|
241
|
+
listNavigation,
|
|
242
|
+
keyboard,
|
|
243
|
+
pointer,
|
|
244
|
+
drag,
|
|
245
|
+
wheel,
|
|
246
|
+
scrub,
|
|
247
|
+
cancelOpen,
|
|
248
|
+
siblingOpen,
|
|
249
|
+
disabled,
|
|
250
|
+
missing,
|
|
251
|
+
initial,
|
|
252
|
+
imperativeAction,
|
|
253
|
+
swipe,
|
|
254
|
+
windowResize
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Maps a change `reason` string to the corresponding native event type.
|
|
260
|
+
*/
|
|
261
|
+
declare type ReasonToEvent<Reason extends string> = Reason extends keyof ReasonToEventMap ? ReasonToEventMap[Reason] : Event;
|
|
262
|
+
|
|
263
|
+
declare interface ReasonToEventMap {
|
|
264
|
+
[REASONS.none]: Event;
|
|
265
|
+
[REASONS.triggerPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
|
|
266
|
+
[REASONS.triggerHover]: MouseEvent;
|
|
267
|
+
[REASONS.triggerFocus]: FocusEvent;
|
|
268
|
+
[REASONS.outsidePress]: MouseEvent | PointerEvent | TouchEvent;
|
|
269
|
+
[REASONS.itemPress]: MouseEvent | KeyboardEvent | PointerEvent;
|
|
270
|
+
[REASONS.closePress]: MouseEvent | KeyboardEvent | PointerEvent;
|
|
271
|
+
[REASONS.linkPress]: MouseEvent | PointerEvent;
|
|
272
|
+
[REASONS.clearPress]: PointerEvent | MouseEvent | KeyboardEvent;
|
|
273
|
+
[REASONS.chipRemovePress]: PointerEvent | MouseEvent | KeyboardEvent;
|
|
274
|
+
[REASONS.trackPress]: PointerEvent | MouseEvent | TouchEvent;
|
|
275
|
+
[REASONS.incrementPress]: PointerEvent | MouseEvent | TouchEvent;
|
|
276
|
+
[REASONS.decrementPress]: PointerEvent | MouseEvent | TouchEvent;
|
|
277
|
+
[REASONS.inputChange]: InputEvent | Event;
|
|
278
|
+
[REASONS.inputClear]: InputEvent | FocusEvent | Event;
|
|
279
|
+
[REASONS.inputBlur]: FocusEvent;
|
|
280
|
+
[REASONS.inputPaste]: ClipboardEvent;
|
|
281
|
+
[REASONS.inputPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
|
|
282
|
+
[REASONS.focusOut]: FocusEvent | KeyboardEvent;
|
|
283
|
+
[REASONS.escapeKey]: KeyboardEvent;
|
|
284
|
+
[REASONS.closeWatcher]: Event;
|
|
285
|
+
[REASONS.listNavigation]: KeyboardEvent;
|
|
286
|
+
[REASONS.keyboard]: KeyboardEvent;
|
|
287
|
+
[REASONS.pointer]: PointerEvent;
|
|
288
|
+
[REASONS.drag]: PointerEvent | TouchEvent;
|
|
289
|
+
[REASONS.swipe]: PointerEvent | TouchEvent;
|
|
290
|
+
[REASONS.wheel]: WheelEvent;
|
|
291
|
+
[REASONS.scrub]: PointerEvent;
|
|
292
|
+
[REASONS.cancelOpen]: MouseEvent;
|
|
293
|
+
[REASONS.siblingOpen]: Event;
|
|
294
|
+
[REASONS.disabled]: Event;
|
|
295
|
+
[REASONS.missing]: Event;
|
|
296
|
+
[REASONS.initial]: Event;
|
|
297
|
+
[REASONS.imperativeAction]: Event;
|
|
298
|
+
[REASONS.windowResize]: UIEvent;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
declare const scrub: "scrub";
|
|
302
|
+
|
|
303
|
+
declare const siblingOpen: "sibling-open";
|
|
304
|
+
|
|
305
|
+
declare const swipe: "swipe";
|
|
306
|
+
|
|
307
|
+
declare const trackPress: "track-press";
|
|
308
|
+
|
|
309
|
+
declare const triggerFocus: "trigger-focus";
|
|
310
|
+
|
|
311
|
+
declare const triggerHover: "trigger-hover";
|
|
312
|
+
|
|
313
|
+
declare const triggerPress: "trigger-press";
|
|
314
|
+
|
|
315
|
+
declare const wheel: "wheel";
|
|
316
|
+
|
|
317
|
+
declare const windowResize: "window-resize";
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Adds a `preventBaseUIHandler` method to all event handlers.
|
|
321
|
+
*/
|
|
322
|
+
declare type WithBaseUIEvent<T> = { [K in keyof T]: WithPreventBaseUIHandler<T[K]> };
|
|
8
323
|
|
|
9
|
-
|
|
324
|
+
declare type WithPreventBaseUIHandler<T> = T extends ((event: infer E) => any) ? E extends React_2.SyntheticEvent<Element, Event> ? (event: BaseUIEvent<E>) => ReturnType<T> : T : T extends undefined ? undefined : T;
|
|
10
325
|
|
|
11
326
|
export { }
|
|
@@ -1,13 +1,176 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { CheckboxGroup } from "@base-ui/react/checkbox-group";
|
|
3
2
|
import clsx from "clsx";
|
|
3
|
+
import { useBaseUiId } from "../6046.js";
|
|
4
|
+
import { useStableCallback } from "../7541.js";
|
|
5
|
+
import { useLabelableContext, useFieldRootContext, fieldValidityMapping } from "../1477.js";
|
|
6
|
+
import { useFormContext } from "../5085.js";
|
|
7
|
+
import { useControlled } from "../8527.js";
|
|
8
|
+
import { PARENT_CHECKBOX } from "../3248.js";
|
|
9
|
+
import { useRegisterFieldControl } from "../4281.js";
|
|
10
|
+
import { EMPTY_ARRAY, useRenderElement } from "../8272.js";
|
|
11
|
+
import { useValueChanged } from "../2801.js";
|
|
12
|
+
import { areArraysEqual } from "../5659.js";
|
|
13
|
+
import { CheckboxGroupContext } from "../8979.js";
|
|
4
14
|
import * as __rspack_external_react from "react";
|
|
15
|
+
const EMPTY = [];
|
|
16
|
+
function useCheckboxGroupParent(params) {
|
|
17
|
+
const { allValues = EMPTY, value = EMPTY, onValueChange: onValueChangeProp } = params;
|
|
18
|
+
const uncontrolledStateRef = __rspack_external_react.useRef(value);
|
|
19
|
+
const disabledStatesRef = __rspack_external_react.useRef(new Map());
|
|
20
|
+
const [status, setStatus] = __rspack_external_react.useState('mixed');
|
|
21
|
+
const id = useBaseUiId();
|
|
22
|
+
const checked = value.length === allValues.length;
|
|
23
|
+
const indeterminate = value.length !== allValues.length && value.length > 0;
|
|
24
|
+
const onValueChange = useStableCallback(onValueChangeProp);
|
|
25
|
+
const getParentProps = __rspack_external_react.useCallback(()=>({
|
|
26
|
+
id,
|
|
27
|
+
indeterminate,
|
|
28
|
+
checked,
|
|
29
|
+
'aria-controls': allValues.map((v)=>`${id}-${v}`).join(' '),
|
|
30
|
+
onCheckedChange (_, eventDetails) {
|
|
31
|
+
const uncontrolledState = uncontrolledStateRef.current;
|
|
32
|
+
const none = allValues.filter((v)=>disabledStatesRef.current.get(v) && uncontrolledState.includes(v));
|
|
33
|
+
const all = allValues.filter((v)=>!disabledStatesRef.current.get(v) || disabledStatesRef.current.get(v) && uncontrolledState.includes(v));
|
|
34
|
+
const allOnOrOff = uncontrolledState.length === all.length || 0 === uncontrolledState.length;
|
|
35
|
+
if (allOnOrOff) return void (value.length === all.length ? onValueChange(none, eventDetails) : onValueChange(all, eventDetails));
|
|
36
|
+
if ('mixed' === status) {
|
|
37
|
+
onValueChange(all, eventDetails);
|
|
38
|
+
setStatus('on');
|
|
39
|
+
} else if ('on' === status) {
|
|
40
|
+
onValueChange(none, eventDetails);
|
|
41
|
+
setStatus('off');
|
|
42
|
+
} else if ('off' === status) {
|
|
43
|
+
onValueChange(uncontrolledState, eventDetails);
|
|
44
|
+
setStatus('mixed');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}), [
|
|
48
|
+
allValues,
|
|
49
|
+
checked,
|
|
50
|
+
id,
|
|
51
|
+
indeterminate,
|
|
52
|
+
onValueChange,
|
|
53
|
+
status,
|
|
54
|
+
value.length
|
|
55
|
+
]);
|
|
56
|
+
const getChildProps = __rspack_external_react.useCallback((childValue)=>({
|
|
57
|
+
checked: value.includes(childValue),
|
|
58
|
+
onCheckedChange (nextChecked, eventDetails) {
|
|
59
|
+
const newValue = value.slice();
|
|
60
|
+
if (nextChecked) newValue.push(childValue);
|
|
61
|
+
else newValue.splice(newValue.indexOf(childValue), 1);
|
|
62
|
+
uncontrolledStateRef.current = newValue;
|
|
63
|
+
onValueChange(newValue, eventDetails);
|
|
64
|
+
setStatus('mixed');
|
|
65
|
+
}
|
|
66
|
+
}), [
|
|
67
|
+
onValueChange,
|
|
68
|
+
value
|
|
69
|
+
]);
|
|
70
|
+
return __rspack_external_react.useMemo(()=>({
|
|
71
|
+
id,
|
|
72
|
+
indeterminate,
|
|
73
|
+
getParentProps,
|
|
74
|
+
getChildProps,
|
|
75
|
+
disabledStatesRef
|
|
76
|
+
}), [
|
|
77
|
+
id,
|
|
78
|
+
indeterminate,
|
|
79
|
+
getParentProps,
|
|
80
|
+
getChildProps
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
const CheckboxGroup_CheckboxGroup = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
84
|
+
const { allValues, className, defaultValue: defaultValueProp, disabled: disabledProp = false, id: idProp, onValueChange, render, value: externalValue, style, ...elementProps } = componentProps;
|
|
85
|
+
const { disabled: fieldDisabled, name: fieldName, state: fieldState, validation, setFilled, setDirty, shouldValidateOnChange, validityData } = useFieldRootContext();
|
|
86
|
+
const { labelId, getDescriptionProps } = useLabelableContext();
|
|
87
|
+
const { clearErrors } = useFormContext();
|
|
88
|
+
const disabled = fieldDisabled || disabledProp;
|
|
89
|
+
const defaultValue = __rspack_external_react.useMemo(()=>{
|
|
90
|
+
if (void 0 === externalValue) return defaultValueProp ?? [];
|
|
91
|
+
}, [
|
|
92
|
+
externalValue,
|
|
93
|
+
defaultValueProp
|
|
94
|
+
]);
|
|
95
|
+
const [value, setValueUnwrapped] = useControlled({
|
|
96
|
+
controlled: externalValue,
|
|
97
|
+
default: defaultValue,
|
|
98
|
+
name: 'CheckboxGroup',
|
|
99
|
+
state: 'value'
|
|
100
|
+
});
|
|
101
|
+
const setValue = useStableCallback((v, eventDetails)=>{
|
|
102
|
+
onValueChange?.(v, eventDetails);
|
|
103
|
+
if (eventDetails.isCanceled) return;
|
|
104
|
+
setValueUnwrapped(v);
|
|
105
|
+
});
|
|
106
|
+
const parent = useCheckboxGroupParent({
|
|
107
|
+
allValues,
|
|
108
|
+
value,
|
|
109
|
+
onValueChange: setValue
|
|
110
|
+
});
|
|
111
|
+
const id = useBaseUiId(idProp);
|
|
112
|
+
const controlRef = __rspack_external_react.useRef(null);
|
|
113
|
+
const registerControlRef = __rspack_external_react.useCallback((element)=>{
|
|
114
|
+
if (null == controlRef.current && null != element && !element.hasAttribute(PARENT_CHECKBOX)) controlRef.current = element;
|
|
115
|
+
}, []);
|
|
116
|
+
useRegisterFieldControl(controlRef, id, value, void 0, !!fieldName);
|
|
117
|
+
const resolvedValue = value ?? EMPTY_ARRAY;
|
|
118
|
+
useValueChanged(resolvedValue, ()=>{
|
|
119
|
+
if (fieldName) clearErrors(fieldName);
|
|
120
|
+
const initialValue = Array.isArray(validityData.initialValue) ? validityData.initialValue : EMPTY_ARRAY;
|
|
121
|
+
setFilled(resolvedValue.length > 0);
|
|
122
|
+
setDirty(!areArraysEqual(resolvedValue, initialValue));
|
|
123
|
+
if (shouldValidateOnChange()) validation.commit(resolvedValue);
|
|
124
|
+
else validation.commit(resolvedValue, true);
|
|
125
|
+
});
|
|
126
|
+
const state = {
|
|
127
|
+
...fieldState,
|
|
128
|
+
disabled
|
|
129
|
+
};
|
|
130
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
131
|
+
allValues,
|
|
132
|
+
value,
|
|
133
|
+
defaultValue,
|
|
134
|
+
setValue,
|
|
135
|
+
parent,
|
|
136
|
+
disabled,
|
|
137
|
+
validation,
|
|
138
|
+
registerControlRef
|
|
139
|
+
}), [
|
|
140
|
+
allValues,
|
|
141
|
+
value,
|
|
142
|
+
defaultValue,
|
|
143
|
+
setValue,
|
|
144
|
+
parent,
|
|
145
|
+
disabled,
|
|
146
|
+
validation,
|
|
147
|
+
registerControlRef
|
|
148
|
+
]);
|
|
149
|
+
const element = useRenderElement('div', componentProps, {
|
|
150
|
+
state,
|
|
151
|
+
ref: forwardedRef,
|
|
152
|
+
props: [
|
|
153
|
+
{
|
|
154
|
+
role: 'group',
|
|
155
|
+
'aria-labelledby': labelId
|
|
156
|
+
},
|
|
157
|
+
getDescriptionProps,
|
|
158
|
+
elementProps
|
|
159
|
+
],
|
|
160
|
+
stateAttributesMapping: fieldValidityMapping
|
|
161
|
+
});
|
|
162
|
+
return /*#__PURE__*/ jsx(CheckboxGroupContext.Provider, {
|
|
163
|
+
value: contextValue,
|
|
164
|
+
children: element
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
if ("production" !== process.env.NODE_ENV) CheckboxGroup_CheckboxGroup.displayName = "CheckboxGroup";
|
|
5
168
|
const CheckboxGroup_module = {
|
|
6
169
|
root: "root-ZCRH6j"
|
|
7
170
|
};
|
|
8
|
-
const
|
|
171
|
+
const CheckboxGroup_CheckboxGroup_CheckboxGroup = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(CheckboxGroup_CheckboxGroup, {
|
|
9
172
|
ref: ref,
|
|
10
173
|
className: clsx(CheckboxGroup_module.root, className),
|
|
11
174
|
...props
|
|
12
175
|
}));
|
|
13
|
-
export {
|
|
176
|
+
export { CheckboxGroup_CheckboxGroup_CheckboxGroup as CheckboxGroup };
|