fluid-primitives 0.19.1 → 1.0.0-beta.1
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/README.md +9 -0
- package/dist/Client-HrMIqv7d.js +1934 -0
- package/dist/accordion.d.ts +2 -2
- package/dist/accordion.js +25 -29
- package/dist/button.d.ts +52 -0
- package/dist/button.js +135 -0
- package/dist/checkbox-group.d.ts +6 -5
- package/dist/checkbox-group.js +36 -20
- package/dist/{checkbox-group.registry-CGwuF7SF.js → checkbox-group.registry-D8P8A4LY.js} +13 -8
- package/dist/checkbox.d.ts +18 -4
- package/dist/checkbox.js +30 -27
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -2
- package/dist/clipboard.d.ts +12 -5
- package/dist/clipboard.js +14 -16
- package/dist/collapsible.d.ts +3 -3
- package/dist/collapsible.js +13 -17
- package/dist/combobox.d.ts +37 -0
- package/dist/combobox.js +151 -0
- package/dist/date-picker.d.ts +67 -0
- package/dist/date-picker.js +289 -0
- package/dist/dialog.d.ts +3 -3
- package/dist/dialog.js +11 -12
- package/dist/field-array.d.ts +97 -0
- package/dist/field-array.js +223 -0
- package/dist/field.d.ts +30 -54
- package/dist/field.js +589 -175
- package/dist/fieldset.d.ts +15 -0
- package/dist/fieldset.js +27 -0
- package/dist/file-upload.d.ts +85 -0
- package/dist/file-upload.js +255 -0
- package/dist/form.d.ts +2 -83
- package/dist/form.fields-B58TZukv.js +329 -0
- package/dist/form.js +263 -276
- package/dist/index-B06gIN_k.d.ts +1358 -0
- package/dist/input.d.ts +96 -0
- package/dist/input.js +233 -0
- package/dist/menu.d.ts +55 -0
- package/dist/menu.js +144 -0
- package/dist/navigation-menu.d.ts +3 -3
- package/dist/navigation-menu.js +29 -43
- package/dist/number-input.d.ts +13 -4
- package/dist/number-input.js +30 -31
- package/dist/popover.d.ts +11 -3
- package/dist/popover.js +17 -18
- package/dist/radio-group.d.ts +4 -4
- package/dist/radio-group.js +35 -42
- package/dist/scroll-area.d.ts +3 -3
- package/dist/scroll-area.js +10 -9
- package/dist/select.d.ts +13 -51
- package/dist/select.js +62 -55
- package/dist/slider.d.ts +27 -0
- package/dist/slider.js +71 -0
- package/dist/switch.d.ts +4 -4
- package/dist/switch.js +24 -33
- package/dist/tabs.d.ts +3 -3
- package/dist/tabs.js +12 -15
- package/dist/textarea.d.ts +101 -0
- package/dist/textarea.js +231 -0
- package/dist/tooltip.d.ts +11 -3
- package/dist/tooltip.js +11 -10
- package/package.json +79 -24
- package/dist/Client-C51NSHxg.js +0 -248
- package/dist/field.dom-CJQXpQbZ.js +0 -11
- package/dist/form.registry-Cb8Pvoe8.d.ts +0 -7
- package/dist/form.registry-CmpTny_s.js +0 -51
- package/dist/index-B8JCdyld.d.ts +0 -118
package/dist/accordion.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as Machine, z as Component } from "./index-B06gIN_k.js";
|
|
2
2
|
import * as accordion from "@zag-js/accordion";
|
|
3
3
|
import * as _$_zag_js_types0 from "@zag-js/types";
|
|
4
4
|
|
|
5
5
|
//#region Resources/Private/Primitives/Accordion/Accordion.d.ts
|
|
6
6
|
declare class Accordion extends Component<accordion.Props, accordion.Api> {
|
|
7
|
-
static
|
|
7
|
+
static componentName: string;
|
|
8
8
|
initMachine(props: accordion.Props): Machine<any>;
|
|
9
9
|
initApi(): accordion.Api<_$_zag_js_types0.PropTypes<{
|
|
10
10
|
[x: string]: any;
|
package/dist/accordion.js
CHANGED
|
@@ -1,43 +1,39 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as normalizeProps, at as Machine, rt as Component } from "./Client-HrMIqv7d.js";
|
|
2
2
|
import * as accordion from "@zag-js/accordion";
|
|
3
3
|
|
|
4
4
|
//#region Resources/Private/Primitives/Accordion/Accordion.ts
|
|
5
5
|
var Accordion = class extends Component {
|
|
6
|
-
static
|
|
6
|
+
static componentName = "accordion";
|
|
7
7
|
initMachine(props) {
|
|
8
|
-
|
|
8
|
+
const [machineProps] = accordion.splitProps(props);
|
|
9
|
+
return new Machine(accordion.machine, machineProps);
|
|
9
10
|
}
|
|
10
11
|
initApi() {
|
|
11
12
|
return accordion.connect(this.machine.service, normalizeProps);
|
|
12
13
|
}
|
|
13
14
|
render() {
|
|
14
|
-
const rootEl = this.
|
|
15
|
+
const rootEl = this.hydrator.query("root");
|
|
15
16
|
if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
value: indicatorEl.getAttribute("data-value"),
|
|
37
|
-
disabled: indicatorEl.hasAttribute("data-disabled")
|
|
38
|
-
}));
|
|
39
|
-
});
|
|
40
|
-
this.getElements("item-header");
|
|
17
|
+
this.spreadPropsByValue("item", ({ el, value }) => this.api.getItemProps({
|
|
18
|
+
value,
|
|
19
|
+
disabled: el.hasAttribute("data-disabled")
|
|
20
|
+
}));
|
|
21
|
+
this.spreadPropsByValue("itemTrigger", ({ el, value }) => this.api.getItemTriggerProps({
|
|
22
|
+
value,
|
|
23
|
+
disabled: el.hasAttribute("data-disabled")
|
|
24
|
+
}));
|
|
25
|
+
this.spreadPropsByValue("itemContent", ({ el, value }) => this.api.getItemContentProps({
|
|
26
|
+
value,
|
|
27
|
+
disabled: el.hasAttribute("data-disabled")
|
|
28
|
+
}));
|
|
29
|
+
this.spreadPropsByValue("itemIndicator", ({ el, value }) => this.api.getItemIndicatorProps({
|
|
30
|
+
value,
|
|
31
|
+
disabled: el.hasAttribute("data-disabled")
|
|
32
|
+
}));
|
|
33
|
+
this.spreadPropsByValue("itemHeader", ({ el, value }) => this.api.getItemHeaderProps({
|
|
34
|
+
value,
|
|
35
|
+
disabled: el.hasAttribute("data-disabled")
|
|
36
|
+
}));
|
|
41
37
|
}
|
|
42
38
|
};
|
|
43
39
|
|
package/dist/button.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { c as Machine$1, z as Component } from "./index-B06gIN_k.js";
|
|
2
|
+
import { EventObject } from "@zag-js/core";
|
|
3
|
+
import { PropTypes } from "@zag-js/types";
|
|
4
|
+
|
|
5
|
+
//#region Resources/Private/Primitives/Button/src/button.types.d.ts
|
|
6
|
+
/** What the button is doing, and which indicators are shown. `loading` wins over `disabled`. */
|
|
7
|
+
type ButtonState = 'idle' | 'loading' | 'disabled';
|
|
8
|
+
interface ButtonProps {
|
|
9
|
+
/** The unique identifier of the button. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The ids of the parts other elements reference: `root`. */
|
|
12
|
+
ids?: Record<string, string>;
|
|
13
|
+
/** Whether the button is disabled. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Whether the button is loading. A loading button is disabled too. */
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Keeps a disabled button focusable. It then gets `aria-disabled` instead of the `disabled`
|
|
19
|
+
* attribute, and clicks and key presses are ignored.
|
|
20
|
+
*/
|
|
21
|
+
focusableWhenDisabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface ButtonIndicatorProps {
|
|
24
|
+
/** The state of the button the indicator is shown in. */
|
|
25
|
+
state: ButtonState;
|
|
26
|
+
}
|
|
27
|
+
interface ButtonApi {
|
|
28
|
+
/** The state of the button, which decides the indicators that are shown. */
|
|
29
|
+
state: ButtonState;
|
|
30
|
+
/** Whether the button is disabled, either on its own or because it is loading. */
|
|
31
|
+
disabled: boolean;
|
|
32
|
+
/** Whether the button is loading. */
|
|
33
|
+
loading: boolean;
|
|
34
|
+
/** Disables or enables the button. A loading button stays disabled. */
|
|
35
|
+
setDisabled(value: boolean): void;
|
|
36
|
+
/** Starts or stops loading. A loading button is disabled too. */
|
|
37
|
+
setLoading(value: boolean): void;
|
|
38
|
+
/** Adds an event listener to the button element, the same as `addEventListener` of the element. */
|
|
39
|
+
addEventListener(...args: Parameters<HTMLButtonElement['addEventListener']>): void;
|
|
40
|
+
getRootProps(): PropTypes['button'];
|
|
41
|
+
getIndicatorProps(props: ButtonIndicatorProps): PropTypes['element'];
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region Resources/Private/Primitives/Button/Button.d.ts
|
|
45
|
+
declare class Button extends Component<ButtonProps, ButtonApi> {
|
|
46
|
+
static componentName: string;
|
|
47
|
+
initMachine(props: ButtonProps): Machine$1<any>;
|
|
48
|
+
initApi(): ButtonApi;
|
|
49
|
+
render(): void;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { Button };
|
package/dist/button.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { a as normalizeProps, at as Machine$1, rt as Component } from "./Client-HrMIqv7d.js";
|
|
2
|
+
import { createSplitProps } from "@zag-js/utils";
|
|
3
|
+
import { createAnatomy } from "@zag-js/anatomy";
|
|
4
|
+
import { createMachine } from "@zag-js/core";
|
|
5
|
+
import { createProps } from "@zag-js/types";
|
|
6
|
+
|
|
7
|
+
//#region Resources/Private/Primitives/Button/src/button.anatomy.ts
|
|
8
|
+
const anatomy = createAnatomy("button").parts("root", "indicator");
|
|
9
|
+
const parts = anatomy.build();
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region Resources/Private/Primitives/Button/src/button.dom.ts
|
|
13
|
+
const getRootEl = (scope) => scope.query(scope.selector(parts.root));
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region Resources/Private/Primitives/Button/src/button.connect.ts
|
|
17
|
+
function connect(machine, normalize) {
|
|
18
|
+
const { scope, prop, computed } = machine;
|
|
19
|
+
const state = computed("state");
|
|
20
|
+
const disabled = computed("disabled");
|
|
21
|
+
const loading = state === "loading";
|
|
22
|
+
const focusableWhenDisabled = !!prop("focusableWhenDisabled");
|
|
23
|
+
return {
|
|
24
|
+
state,
|
|
25
|
+
disabled,
|
|
26
|
+
loading,
|
|
27
|
+
setDisabled(value) {
|
|
28
|
+
machine.updateProps({ disabled: value });
|
|
29
|
+
},
|
|
30
|
+
setLoading(value) {
|
|
31
|
+
machine.updateProps({ loading: value });
|
|
32
|
+
},
|
|
33
|
+
addEventListener(...args) {
|
|
34
|
+
getRootEl(scope)?.addEventListener(...args);
|
|
35
|
+
},
|
|
36
|
+
getRootProps() {
|
|
37
|
+
return normalize.button({
|
|
38
|
+
...parts.root.attrs(scope.id),
|
|
39
|
+
disabled: disabled && !focusableWhenDisabled ? true : void 0,
|
|
40
|
+
"aria-disabled": disabled && focusableWhenDisabled ? "true" : void 0,
|
|
41
|
+
"data-disabled": disabled ? "" : void 0,
|
|
42
|
+
/** Present while the button is loading. */
|
|
43
|
+
"data-loading": loading ? "" : void 0
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
getIndicatorProps({ state: indicatorState }) {
|
|
47
|
+
return normalize.element({
|
|
48
|
+
...parts.indicator.attrs(scope.id),
|
|
49
|
+
hidden: indicatorState === state ? void 0 : true
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region Resources/Private/Primitives/Button/src/button.machine.ts
|
|
57
|
+
const machine = createMachine({
|
|
58
|
+
initialState() {
|
|
59
|
+
return "idle";
|
|
60
|
+
},
|
|
61
|
+
computed: {
|
|
62
|
+
disabled({ prop }) {
|
|
63
|
+
return !!prop("disabled") || !!prop("loading");
|
|
64
|
+
},
|
|
65
|
+
state({ prop, computed }) {
|
|
66
|
+
if (prop("loading")) return "loading";
|
|
67
|
+
return computed("disabled") ? "disabled" : "idle";
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
watch({ track, computed, prop, scope }) {
|
|
71
|
+
track([() => computed("disabled")], () => {
|
|
72
|
+
if (!computed("disabled") || prop("focusableWhenDisabled")) return;
|
|
73
|
+
const buttonEl = getRootEl(scope);
|
|
74
|
+
if (buttonEl && scope.isActiveElement(buttonEl)) console.warn("[Button] A focused button was disabled, so it loses focus. Set `focusableWhenDisabled` to keep it.", buttonEl);
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
effects: ["ignoreInteractionWhenDisabled"],
|
|
78
|
+
states: { idle: {} },
|
|
79
|
+
implementations: { effects: { ignoreInteractionWhenDisabled({ scope, computed }) {
|
|
80
|
+
const buttonEl = getRootEl(scope);
|
|
81
|
+
if (!buttonEl) return void 0;
|
|
82
|
+
const ignore = (event) => {
|
|
83
|
+
if (!computed("disabled")) return;
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
event.stopImmediatePropagation();
|
|
86
|
+
};
|
|
87
|
+
const ignoreActivationKey = (event) => {
|
|
88
|
+
if (event.key === "Enter" || event.key === " ") ignore(event);
|
|
89
|
+
};
|
|
90
|
+
buttonEl.addEventListener("click", ignore, true);
|
|
91
|
+
buttonEl.addEventListener("pointerdown", ignore, true);
|
|
92
|
+
buttonEl.addEventListener("mousedown", ignore, true);
|
|
93
|
+
buttonEl.addEventListener("keydown", ignoreActivationKey, true);
|
|
94
|
+
buttonEl.addEventListener("keyup", ignoreActivationKey, true);
|
|
95
|
+
return () => {
|
|
96
|
+
buttonEl.removeEventListener("click", ignore, true);
|
|
97
|
+
buttonEl.removeEventListener("pointerdown", ignore, true);
|
|
98
|
+
buttonEl.removeEventListener("mousedown", ignore, true);
|
|
99
|
+
buttonEl.removeEventListener("keydown", ignoreActivationKey, true);
|
|
100
|
+
buttonEl.removeEventListener("keyup", ignoreActivationKey, true);
|
|
101
|
+
};
|
|
102
|
+
} } }
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region Resources/Private/Primitives/Button/src/button.props.ts
|
|
107
|
+
const props = createProps()([
|
|
108
|
+
"id",
|
|
109
|
+
"ids",
|
|
110
|
+
"disabled",
|
|
111
|
+
"loading",
|
|
112
|
+
"focusableWhenDisabled"
|
|
113
|
+
]);
|
|
114
|
+
const splitProps = createSplitProps(props);
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region Resources/Private/Primitives/Button/Button.ts
|
|
118
|
+
var Button = class extends Component {
|
|
119
|
+
static componentName = "button";
|
|
120
|
+
initMachine(props) {
|
|
121
|
+
const [machineProps] = splitProps(props);
|
|
122
|
+
return new Machine$1(machine, machineProps);
|
|
123
|
+
}
|
|
124
|
+
initApi() {
|
|
125
|
+
return connect(this.machine, normalizeProps);
|
|
126
|
+
}
|
|
127
|
+
render() {
|
|
128
|
+
const rootEl = this.hydrator.query("root");
|
|
129
|
+
if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
|
|
130
|
+
this.spreadPropsByValue("indicator", ({ value }) => this.api.getIndicatorProps({ state: value }));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { Button };
|
package/dist/checkbox-group.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as FieldMachine } from "./form.registry-Cb8Pvoe8.js";
|
|
1
|
+
import { b as FieldClientApi, c as Machine$1, y as FieldAwareComponent } from "./index-B06gIN_k.js";
|
|
3
2
|
import { EventObject } from "@zag-js/core";
|
|
4
3
|
import { PropTypes } from "@zag-js/types";
|
|
5
4
|
|
|
6
5
|
//#region Resources/Private/Primitives/CheckboxGroup/src/checkbox-group.types.d.ts
|
|
7
6
|
interface CheckboxGroupProps {
|
|
7
|
+
/** The unique identifier of the checkbox group. */
|
|
8
8
|
id: string;
|
|
9
|
+
/** The ids of the elements in the checkbox group. Useful for composition. */
|
|
9
10
|
ids?: Record<string, string>;
|
|
10
11
|
/** The initial value of the checkbox group (uncontrolled) */
|
|
11
12
|
defaultValue?: string[];
|
|
@@ -88,9 +89,9 @@ interface CheckboxGroupApi {
|
|
|
88
89
|
//#endregion
|
|
89
90
|
//#region Resources/Private/Primitives/CheckboxGroup/CheckboxGroup.d.ts
|
|
90
91
|
declare class CheckboxGroup extends FieldAwareComponent<CheckboxGroupProps, CheckboxGroupApi> {
|
|
91
|
-
static
|
|
92
|
-
propsWithField(props: CheckboxGroupProps,
|
|
93
|
-
initMachine(props: CheckboxGroupProps): Machine<CheckboxGroupSchema>;
|
|
92
|
+
static componentName: string;
|
|
93
|
+
propsWithField(props: CheckboxGroupProps, field: FieldClientApi): CheckboxGroupProps;
|
|
94
|
+
initMachine(props: CheckboxGroupProps): Machine$1<CheckboxGroupSchema>;
|
|
94
95
|
initApi(): CheckboxGroupApi;
|
|
95
96
|
render(): void;
|
|
96
97
|
destroy(): void;
|
package/dist/checkbox-group.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { i as connect, n as registerCheckboxGroup, r as unregisterCheckboxGroup } from "./checkbox-group.registry-
|
|
3
|
-
import {
|
|
1
|
+
import { a as normalizeProps, at as Machine$1, o as mergeProps, s as FieldAwareComponent } from "./Client-HrMIqv7d.js";
|
|
2
|
+
import { i as connect, n as registerCheckboxGroup, r as unregisterCheckboxGroup } from "./checkbox-group.registry-D8P8A4LY.js";
|
|
3
|
+
import { createSplitProps } from "@zag-js/utils";
|
|
4
4
|
import { createMachine } from "@zag-js/core";
|
|
5
|
+
import { createProps } from "@zag-js/types";
|
|
5
6
|
|
|
6
7
|
//#region Resources/Private/Primitives/CheckboxGroup/src/checkbox-group.machine.ts
|
|
7
8
|
const machine = createMachine({
|
|
@@ -70,28 +71,43 @@ const machine = createMachine({
|
|
|
70
71
|
} }
|
|
71
72
|
});
|
|
72
73
|
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region Resources/Private/Primitives/CheckboxGroup/src/checkbox-group.props.ts
|
|
76
|
+
const props = createProps()([
|
|
77
|
+
"id",
|
|
78
|
+
"ids",
|
|
79
|
+
"defaultValue",
|
|
80
|
+
"value",
|
|
81
|
+
"name",
|
|
82
|
+
"form",
|
|
83
|
+
"disabled",
|
|
84
|
+
"readOnly",
|
|
85
|
+
"required",
|
|
86
|
+
"invalid",
|
|
87
|
+
"maxSelectedValues",
|
|
88
|
+
"onValueChange"
|
|
89
|
+
]);
|
|
90
|
+
const splitProps = createSplitProps(props);
|
|
91
|
+
|
|
73
92
|
//#endregion
|
|
74
93
|
//#region Resources/Private/Primitives/CheckboxGroup/CheckboxGroup.ts
|
|
75
94
|
var CheckboxGroup = class extends FieldAwareComponent {
|
|
76
|
-
static
|
|
77
|
-
propsWithField(props,
|
|
95
|
+
static componentName = "checkboxGroup";
|
|
96
|
+
propsWithField(props, field) {
|
|
78
97
|
return {
|
|
79
98
|
...props,
|
|
80
|
-
disabled: props.disabled ??
|
|
81
|
-
readOnly: props.readOnly ??
|
|
82
|
-
required: props.required ??
|
|
83
|
-
invalid: props.invalid ??
|
|
84
|
-
name: props.name ??
|
|
85
|
-
ids: {
|
|
86
|
-
...props.ids,
|
|
87
|
-
label: getLabelId(fieldMachine.scope)
|
|
88
|
-
}
|
|
99
|
+
disabled: props.disabled ?? field.disabled,
|
|
100
|
+
readOnly: props.readOnly ?? field.readOnly,
|
|
101
|
+
required: props.required ?? field.required,
|
|
102
|
+
invalid: props.invalid ?? field.invalid,
|
|
103
|
+
name: props.name ?? field.name
|
|
89
104
|
};
|
|
90
105
|
}
|
|
91
106
|
initMachine(props) {
|
|
92
107
|
props = this.withFieldProps(props);
|
|
93
|
-
const
|
|
94
|
-
|
|
108
|
+
const [machineProps] = splitProps(props);
|
|
109
|
+
const createdMachine = new Machine$1(machine, machineProps);
|
|
110
|
+
registerCheckboxGroup(this.hydrator.query("root"), createdMachine);
|
|
95
111
|
return createdMachine;
|
|
96
112
|
}
|
|
97
113
|
initApi() {
|
|
@@ -99,16 +115,16 @@ var CheckboxGroup = class extends FieldAwareComponent {
|
|
|
99
115
|
}
|
|
100
116
|
render() {
|
|
101
117
|
this.subscribeToFieldService();
|
|
102
|
-
const rootEl = this.
|
|
118
|
+
const rootEl = this.hydrator.query("root");
|
|
103
119
|
if (rootEl) {
|
|
104
|
-
const mergedProps = mergeProps(this.api.getRootProps(), { "aria-describedby": this.
|
|
120
|
+
const mergedProps = mergeProps(this.api.getRootProps(), { "aria-describedby": this.field?.ariaDescribedby });
|
|
105
121
|
this.spreadProps(rootEl, mergedProps);
|
|
106
122
|
}
|
|
107
|
-
const labelEl = this.
|
|
123
|
+
const labelEl = this.hydrator.query("label");
|
|
108
124
|
if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
|
|
109
125
|
}
|
|
110
126
|
destroy() {
|
|
111
|
-
unregisterCheckboxGroup(this.
|
|
127
|
+
unregisterCheckboxGroup(this.hydrator.query("root"));
|
|
112
128
|
super.destroy();
|
|
113
129
|
}
|
|
114
130
|
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { createAnatomy } from "@zag-js/anatomy";
|
|
2
|
+
|
|
3
|
+
//#region Resources/Private/Primitives/CheckboxGroup/src/checkbox-group.anatomy.ts
|
|
4
|
+
const anatomy = createAnatomy("checkbox-group").parts("root", "label");
|
|
5
|
+
const parts = anatomy.build();
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
1
8
|
//#region Resources/Private/Primitives/CheckboxGroup/src/checkbox-group.dom.ts
|
|
2
|
-
const getRootId = (scope) => scope.ids?.root ?? `checkbox-group:${scope.id}:root`;
|
|
3
9
|
const getLabelId = (scope) => scope.ids?.label ?? `checkbox-group:${scope.id}:label`;
|
|
10
|
+
/** The group's own label part, or a surrounding Field's label carrying the mapped label id. */
|
|
11
|
+
const getLabelEl = (scope) => scope.query(scope.selector(parts.label)) ?? scope.getById(getLabelId(scope));
|
|
4
12
|
|
|
5
13
|
//#endregion
|
|
6
14
|
//#region Resources/Private/Primitives/CheckboxGroup/src/checkbox-group.connect.ts
|
|
@@ -63,14 +71,12 @@ function connect(service, normalize) {
|
|
|
63
71
|
},
|
|
64
72
|
getRootProps() {
|
|
65
73
|
return normalize.element({
|
|
66
|
-
|
|
74
|
+
...parts.root.attrs(scope.id),
|
|
67
75
|
role: "group",
|
|
68
|
-
"data-scope": "checkbox-group",
|
|
69
|
-
"data-part": "root",
|
|
70
76
|
"data-disabled": disabled ? "" : void 0,
|
|
71
77
|
"data-readonly": readOnly ? "" : void 0,
|
|
72
78
|
"data-invalid": invalid ? "" : void 0,
|
|
73
|
-
"aria-labelledby": getLabelId(scope),
|
|
79
|
+
"aria-labelledby": getLabelEl(scope) ? getLabelId(scope) : void 0,
|
|
74
80
|
"aria-disabled": disabled || void 0,
|
|
75
81
|
"aria-invalid": invalid || void 0,
|
|
76
82
|
"aria-required": required || void 0
|
|
@@ -78,9 +84,8 @@ function connect(service, normalize) {
|
|
|
78
84
|
},
|
|
79
85
|
getLabelProps() {
|
|
80
86
|
return normalize.element({
|
|
87
|
+
...parts.label.attrs(scope.id),
|
|
81
88
|
id: getLabelId(scope),
|
|
82
|
-
"data-scope": "checkbox-group",
|
|
83
|
-
"data-part": "label",
|
|
84
89
|
"data-disabled": disabled ? "" : void 0,
|
|
85
90
|
"data-readonly": readOnly ? "" : void 0,
|
|
86
91
|
"data-invalid": invalid ? "" : void 0
|
|
@@ -103,7 +108,7 @@ function unregisterCheckboxGroup(root) {
|
|
|
103
108
|
}
|
|
104
109
|
function getCheckboxGroupMachineFor(el) {
|
|
105
110
|
if (!el) return void 0;
|
|
106
|
-
const root = el.closest("[data-
|
|
111
|
+
const root = el.closest("[data-checkbox-group-root]");
|
|
107
112
|
if (!root) return void 0;
|
|
108
113
|
return registry.get(root);
|
|
109
114
|
}
|
package/dist/checkbox.d.ts
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as checkbox from "@zag-js/checkbox";
|
|
1
|
+
import { X as ConverterMachineProps, b as FieldClientApi, c as Machine, y as FieldAwareComponent } from "./index-B06gIN_k.js";
|
|
3
2
|
import * as _$_zag_js_types0 from "@zag-js/types";
|
|
3
|
+
import * as checkbox from "@zag-js/checkbox";
|
|
4
4
|
|
|
5
5
|
//#region Resources/Private/Primitives/Checkbox/Checkbox.d.ts
|
|
6
|
+
declare const checkboxPropConverters: {
|
|
7
|
+
defaultChecked: (defaultChecked: checkbox.Props["defaultChecked"]) => checkbox.CheckedState | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare module 'fluid-primitives' {
|
|
10
|
+
interface HydrationPropsOverrides {
|
|
11
|
+
checkbox: ConverterMachineProps<typeof checkboxPropConverters>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
6
14
|
declare class Checkbox extends FieldAwareComponent<checkbox.Props, checkbox.Api> {
|
|
7
|
-
static
|
|
15
|
+
static componentName: string;
|
|
8
16
|
private checkboxGroupMachine;
|
|
9
17
|
private checkboxGroupApi;
|
|
10
18
|
private groupUnsubscribe;
|
|
11
19
|
private subscribedToGroup;
|
|
12
20
|
private closestCheckboxGroup;
|
|
13
21
|
private syncingFromGroup;
|
|
14
|
-
propsWithField(props: checkbox.Props,
|
|
22
|
+
propsWithField(props: checkbox.Props, field: FieldClientApi): checkbox.Props;
|
|
23
|
+
/**
|
|
24
|
+
* A checkbox in a group takes its field state from the group, which carries it to its
|
|
25
|
+
* checkboxes: the Field's `required` would otherwise mean "every one of them has to be checked".
|
|
26
|
+
* Mirrors FieldContextVariableMerger's server-side rule.
|
|
27
|
+
*/
|
|
28
|
+
protected getClosestField(): HTMLElement | null;
|
|
15
29
|
private getClosestCheckboxGroup;
|
|
16
30
|
/**
|
|
17
31
|
* Build props merged with CheckboxGroup context.
|
package/dist/checkbox.js
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { i as connect, t as getCheckboxGroupMachineFor } from "./checkbox-group.registry-
|
|
3
|
-
import { a as getLabelId, t as getControlId } from "./field.dom-CJQXpQbZ.js";
|
|
1
|
+
import { K as registerClientPropConverters, a as normalizeProps, at as Machine, o as mergeProps, s as FieldAwareComponent } from "./Client-HrMIqv7d.js";
|
|
2
|
+
import { i as connect, t as getCheckboxGroupMachineFor } from "./checkbox-group.registry-D8P8A4LY.js";
|
|
4
3
|
import * as checkbox from "@zag-js/checkbox";
|
|
5
4
|
|
|
6
5
|
//#region Resources/Private/Primitives/Checkbox/Checkbox.ts
|
|
6
|
+
registerClientPropConverters("checkbox", { defaultChecked: (defaultChecked) => defaultChecked });
|
|
7
7
|
var Checkbox = class extends FieldAwareComponent {
|
|
8
|
-
static
|
|
8
|
+
static componentName = "checkbox";
|
|
9
9
|
checkboxGroupMachine;
|
|
10
10
|
checkboxGroupApi;
|
|
11
11
|
groupUnsubscribe;
|
|
12
12
|
subscribedToGroup = false;
|
|
13
13
|
closestCheckboxGroup = null;
|
|
14
14
|
syncingFromGroup = false;
|
|
15
|
-
propsWithField(props,
|
|
16
|
-
const isInGroup = !!this.getClosestCheckboxGroup();
|
|
15
|
+
propsWithField(props, field) {
|
|
17
16
|
return {
|
|
18
17
|
...props,
|
|
19
|
-
disabled: props.disabled ??
|
|
20
|
-
readOnly: props.readOnly ??
|
|
21
|
-
required: props.required ??
|
|
22
|
-
invalid: props.invalid ??
|
|
23
|
-
name: props.name ??
|
|
24
|
-
ids: {
|
|
25
|
-
...props.ids,
|
|
26
|
-
label: isInGroup ? void 0 : getLabelId(fieldMachine.scope),
|
|
27
|
-
hiddenInput: isInGroup ? void 0 : getControlId(fieldMachine.scope)
|
|
28
|
-
}
|
|
18
|
+
disabled: props.disabled ?? field.disabled,
|
|
19
|
+
readOnly: props.readOnly ?? field.readOnly,
|
|
20
|
+
required: props.required ?? field.required,
|
|
21
|
+
invalid: props.invalid ?? field.invalid,
|
|
22
|
+
name: props.name ?? field.name
|
|
29
23
|
};
|
|
30
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* A checkbox in a group takes its field state from the group, which carries it to its
|
|
27
|
+
* checkboxes: the Field's `required` would otherwise mean "every one of them has to be checked".
|
|
28
|
+
* Mirrors FieldContextVariableMerger's server-side rule.
|
|
29
|
+
*/
|
|
30
|
+
getClosestField() {
|
|
31
|
+
return this.getClosestCheckboxGroup() ? null : super.getClosestField();
|
|
32
|
+
}
|
|
31
33
|
getClosestCheckboxGroup() {
|
|
32
|
-
return this.closestCheckboxGroup || this.
|
|
34
|
+
return this.closestCheckboxGroup || this.hydrator.query("root")?.closest("[data-checkbox-group-root]");
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* Build props merged with CheckboxGroup context.
|
|
@@ -78,7 +80,8 @@ var Checkbox = class extends FieldAwareComponent {
|
|
|
78
80
|
initMachine(props) {
|
|
79
81
|
props = this.withFieldProps(props);
|
|
80
82
|
props = this.withGroupProps(props);
|
|
81
|
-
|
|
83
|
+
const [machineProps] = checkbox.splitProps(props);
|
|
84
|
+
return new Machine(checkbox.machine, machineProps);
|
|
82
85
|
}
|
|
83
86
|
initApi() {
|
|
84
87
|
return checkbox.connect(this.machine.service, normalizeProps);
|
|
@@ -86,17 +89,17 @@ var Checkbox = class extends FieldAwareComponent {
|
|
|
86
89
|
render() {
|
|
87
90
|
this.subscribeToFieldService();
|
|
88
91
|
this.subscribeToCheckboxGroup();
|
|
89
|
-
const rootEl = this.
|
|
92
|
+
const rootEl = this.hydrator.query("root");
|
|
90
93
|
if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
|
|
91
|
-
const labelEl = this.
|
|
94
|
+
const labelEl = this.hydrator.query("label");
|
|
92
95
|
if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
|
|
93
|
-
const controlEl = this.
|
|
96
|
+
const controlEl = this.hydrator.query("control");
|
|
94
97
|
if (controlEl) this.spreadProps(controlEl, this.api.getControlProps());
|
|
95
|
-
const indicatorEl = this.
|
|
98
|
+
const indicatorEl = this.hydrator.query("indicator");
|
|
96
99
|
if (indicatorEl) this.spreadProps(indicatorEl, this.api.getIndicatorProps());
|
|
97
|
-
const hiddenInputEl = this.
|
|
100
|
+
const hiddenInputEl = this.hydrator.query("hiddenInput");
|
|
98
101
|
if (hiddenInputEl) {
|
|
99
|
-
const mergedProps = mergeProps(this.api.getHiddenInputProps(), { "aria-describedby": this.
|
|
102
|
+
const mergedProps = mergeProps(this.api.getHiddenInputProps(), { "aria-describedby": this.field?.ariaDescribedby });
|
|
100
103
|
this.spreadProps(hiddenInputEl, mergedProps);
|
|
101
104
|
}
|
|
102
105
|
}
|
|
@@ -109,8 +112,8 @@ var Checkbox = class extends FieldAwareComponent {
|
|
|
109
112
|
this.closestCheckboxGroup = this.getClosestCheckboxGroup();
|
|
110
113
|
if (!this.closestCheckboxGroup) return;
|
|
111
114
|
if (!this.checkboxGroupMachine) this.checkboxGroupMachine = getCheckboxGroupMachineFor(this.closestCheckboxGroup);
|
|
112
|
-
if (this.checkboxGroupMachine && this.
|
|
113
|
-
const value = this.
|
|
115
|
+
if (this.checkboxGroupMachine && this.machine.prop("value")) {
|
|
116
|
+
const value = this.machine.prop("value");
|
|
114
117
|
this.groupUnsubscribe = this.checkboxGroupMachine.subscribe(() => {
|
|
115
118
|
queueMicrotask(() => {
|
|
116
119
|
this.checkboxGroupApi = connect(this.checkboxGroupMachine.service, normalizeProps);
|
|
@@ -124,7 +127,7 @@ var Checkbox = class extends FieldAwareComponent {
|
|
|
124
127
|
});
|
|
125
128
|
}
|
|
126
129
|
this.machine.updateProps({
|
|
127
|
-
disabled: this.
|
|
130
|
+
disabled: this.machine.prop("disabled") || groupItemProps.disabled,
|
|
128
131
|
invalid: groupItemProps.invalid
|
|
129
132
|
});
|
|
130
133
|
});
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { Component, ComponentHydrationData, ComponentHydrator, ComponentInterface, FieldAwareComponent, FluidPrimitivesGlobals, Machine, getHydrationData, mergeProps, mount,
|
|
1
|
+
import { $ as AsyncList, B as ComponentHydrationData, G as HydrationPropsRegistry, H as FluidPrimitivesGlobals, I as extbase, J as ClientPropConverter, K as KnownComponentName, L as DelayedIndicator, Q as registerClientPropConverters, R as DelayedIndicatorOptions, U as HydrationPropsFor, V as ComponentInterface, W as HydrationPropsOverrides, X as ConverterMachineProps, Y as ClientPropConverterMap, Z as applyClientPropConverters, _ as mountAll, a as spreadTextControlProps, c as Machine, d as getComponentInstance, et as AsyncListOptions, f as getGlobal, g as mount, i as spreadProps, l as ComponentHydrator, m as getHydrationData, n as Template, o as normalizeProps, p as getGlobals, q as NestedComponentEntry, r as TemplateOptions, s as mergeProps, t as uid, u as destroyComponentsWithin, v as toKebabCase, y as FieldAwareComponent, z as Component } from "./index-B06gIN_k.js";
|
|
2
|
+
export { AsyncList, AsyncListOptions, ClientPropConverter, ClientPropConverterMap, Component, ComponentHydrationData, ComponentHydrator, ComponentInterface, ConverterMachineProps, DelayedIndicator, DelayedIndicatorOptions, FieldAwareComponent, FluidPrimitivesGlobals, HydrationPropsFor, HydrationPropsOverrides, HydrationPropsRegistry, KnownComponentName, Machine, NestedComponentEntry, Template, TemplateOptions, applyClientPropConverters, destroyComponentsWithin, extbase, getComponentInstance, getGlobal, getGlobals, getHydrationData, mergeProps, mount, mountAll, normalizeProps, registerClientPropConverters, spreadProps, spreadTextControlProps, toKebabCase, uid };
|
package/dist/client.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as Machine,
|
|
1
|
+
import { G as applyClientPropConverters, J as destroyComponentsWithin, K as registerClientPropConverters, Q as getHydrationData, U as extbase, W as DelayedIndicator, X as getGlobal, Y as getComponentInstance, Z as getGlobals, a as normalizeProps, at as Machine, et as mount, i as spreadTextControlProps, it as AsyncList, n as Template, nt as toKebabCase, o as mergeProps, q as ComponentHydrator, r as spreadProps, rt as Component, s as FieldAwareComponent, t as uid, tt as mountAll } from "./Client-HrMIqv7d.js";
|
|
2
2
|
|
|
3
|
-
export { Component, ComponentHydrator, FieldAwareComponent, Machine, getHydrationData, mergeProps, mount,
|
|
3
|
+
export { AsyncList, Component, ComponentHydrator, DelayedIndicator, FieldAwareComponent, Machine, Template, applyClientPropConverters, destroyComponentsWithin, extbase, getComponentInstance, getGlobal, getGlobals, getHydrationData, mergeProps, mount, mountAll, normalizeProps, registerClientPropConverters, spreadProps, spreadTextControlProps, toKebabCase, uid };
|
package/dist/clipboard.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as clipboard from "@zag-js/clipboard";
|
|
1
|
+
import { c as Machine, z as Component } from "./index-B06gIN_k.js";
|
|
3
2
|
import * as _$_zag_js_types0 from "@zag-js/types";
|
|
3
|
+
import * as clipboard from "@zag-js/clipboard";
|
|
4
4
|
|
|
5
5
|
//#region Resources/Private/Primitives/Clipboard/Clipboard.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type ClipboardProps = Omit<clipboard.Props, 'translations'> & {
|
|
7
|
+
translations?: {
|
|
8
|
+
triggerLabelIdle?: string;
|
|
9
|
+
triggerLabelCopied?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare class Clipboard extends Component<ClipboardProps, clipboard.Api> {
|
|
13
|
+
static componentName: string;
|
|
14
|
+
private translations;
|
|
15
|
+
initMachine(props: ClipboardProps): Machine<any>;
|
|
9
16
|
initApi(): clipboard.Api<_$_zag_js_types0.PropTypes<{
|
|
10
17
|
[x: string]: any;
|
|
11
18
|
}>>;
|