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.
Files changed (67) hide show
  1. package/README.md +9 -0
  2. package/dist/Client-HrMIqv7d.js +1934 -0
  3. package/dist/accordion.d.ts +2 -2
  4. package/dist/accordion.js +25 -29
  5. package/dist/button.d.ts +52 -0
  6. package/dist/button.js +135 -0
  7. package/dist/checkbox-group.d.ts +6 -5
  8. package/dist/checkbox-group.js +36 -20
  9. package/dist/{checkbox-group.registry-CGwuF7SF.js → checkbox-group.registry-D8P8A4LY.js} +13 -8
  10. package/dist/checkbox.d.ts +18 -4
  11. package/dist/checkbox.js +30 -27
  12. package/dist/client.d.ts +2 -2
  13. package/dist/client.js +2 -2
  14. package/dist/clipboard.d.ts +12 -5
  15. package/dist/clipboard.js +14 -16
  16. package/dist/collapsible.d.ts +3 -3
  17. package/dist/collapsible.js +13 -17
  18. package/dist/combobox.d.ts +37 -0
  19. package/dist/combobox.js +151 -0
  20. package/dist/date-picker.d.ts +67 -0
  21. package/dist/date-picker.js +289 -0
  22. package/dist/dialog.d.ts +3 -3
  23. package/dist/dialog.js +11 -12
  24. package/dist/field-array.d.ts +97 -0
  25. package/dist/field-array.js +223 -0
  26. package/dist/field.d.ts +30 -54
  27. package/dist/field.js +589 -175
  28. package/dist/fieldset.d.ts +15 -0
  29. package/dist/fieldset.js +27 -0
  30. package/dist/file-upload.d.ts +85 -0
  31. package/dist/file-upload.js +255 -0
  32. package/dist/form.d.ts +2 -83
  33. package/dist/form.fields-B58TZukv.js +329 -0
  34. package/dist/form.js +263 -276
  35. package/dist/index-B06gIN_k.d.ts +1358 -0
  36. package/dist/input.d.ts +96 -0
  37. package/dist/input.js +233 -0
  38. package/dist/menu.d.ts +55 -0
  39. package/dist/menu.js +144 -0
  40. package/dist/navigation-menu.d.ts +3 -3
  41. package/dist/navigation-menu.js +29 -43
  42. package/dist/number-input.d.ts +13 -4
  43. package/dist/number-input.js +30 -31
  44. package/dist/popover.d.ts +11 -3
  45. package/dist/popover.js +17 -18
  46. package/dist/radio-group.d.ts +4 -4
  47. package/dist/radio-group.js +35 -42
  48. package/dist/scroll-area.d.ts +3 -3
  49. package/dist/scroll-area.js +10 -9
  50. package/dist/select.d.ts +13 -51
  51. package/dist/select.js +62 -55
  52. package/dist/slider.d.ts +27 -0
  53. package/dist/slider.js +71 -0
  54. package/dist/switch.d.ts +4 -4
  55. package/dist/switch.js +24 -33
  56. package/dist/tabs.d.ts +3 -3
  57. package/dist/tabs.js +12 -15
  58. package/dist/textarea.d.ts +101 -0
  59. package/dist/textarea.js +231 -0
  60. package/dist/tooltip.d.ts +11 -3
  61. package/dist/tooltip.js +11 -10
  62. package/package.json +79 -24
  63. package/dist/Client-C51NSHxg.js +0 -248
  64. package/dist/field.dom-CJQXpQbZ.js +0 -11
  65. package/dist/form.registry-Cb8Pvoe8.d.ts +0 -7
  66. package/dist/form.registry-CmpTny_s.js +0 -51
  67. package/dist/index-B8JCdyld.d.ts +0 -118
@@ -1,10 +1,10 @@
1
- import { a as Machine, f as Component } from "./index-B8JCdyld.js";
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 name: string;
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 Machine, p as Component, r as normalizeProps } from "./Client-C51NSHxg.js";
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 name = "accordion";
6
+ static componentName = "accordion";
7
7
  initMachine(props) {
8
- return new Machine(accordion.machine, { ...props });
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.getElement("root");
15
+ const rootEl = this.hydrator.query("root");
15
16
  if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
16
- this.getElements("item").forEach((itemEl) => {
17
- this.spreadProps(itemEl, this.api.getItemProps({
18
- value: itemEl.getAttribute("data-value"),
19
- disabled: itemEl.hasAttribute("data-disabled")
20
- }));
21
- });
22
- this.getElements("item-trigger").forEach((trigger) => {
23
- this.spreadProps(trigger, this.api.getItemTriggerProps({
24
- value: trigger.getAttribute("data-value"),
25
- disabled: trigger.hasAttribute("data-disabled")
26
- }));
27
- });
28
- this.getElements("item-content").forEach((contentEl) => {
29
- this.spreadProps(contentEl, this.api.getItemContentProps({
30
- value: contentEl.getAttribute("data-value"),
31
- disabled: contentEl.hasAttribute("data-disabled")
32
- }));
33
- });
34
- this.getElements("item-indicator").forEach((indicatorEl) => {
35
- this.spreadProps(indicatorEl, this.api.getItemIndicatorProps({
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
 
@@ -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 };
@@ -1,11 +1,12 @@
1
- import { a as Machine, u as FieldAwareComponent } from "./index-B8JCdyld.js";
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 name: string;
92
- propsWithField(props: CheckboxGroupProps, fieldMachine: FieldMachine): 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;
@@ -1,7 +1,8 @@
1
- import { a as Machine, d as FieldAwareComponent, i as mergeProps, r as normalizeProps } from "./Client-C51NSHxg.js";
2
- import { i as connect, n as registerCheckboxGroup, r as unregisterCheckboxGroup } from "./checkbox-group.registry-CGwuF7SF.js";
3
- import { a as getLabelId } from "./field.dom-CJQXpQbZ.js";
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 name = "checkbox-group";
77
- propsWithField(props, fieldMachine) {
95
+ static componentName = "checkboxGroup";
96
+ propsWithField(props, field) {
78
97
  return {
79
98
  ...props,
80
- disabled: props.disabled ?? fieldMachine.context.get("disabled"),
81
- readOnly: props.readOnly ?? fieldMachine.context.get("readOnly"),
82
- required: props.required ?? fieldMachine.context.get("required"),
83
- invalid: props.invalid ?? fieldMachine.context.get("invalid"),
84
- name: props.name ?? fieldMachine.prop("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 createdMachine = new Machine(machine, props);
94
- registerCheckboxGroup(this.getElement("root"), createdMachine);
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.getElement("root");
118
+ const rootEl = this.hydrator.query("root");
103
119
  if (rootEl) {
104
- const mergedProps = mergeProps(this.api.getRootProps(), { "aria-describedby": this.fieldMachine?.context.get("describeIds") || void 0 });
120
+ const mergedProps = mergeProps(this.api.getRootProps(), { "aria-describedby": this.field?.ariaDescribedby });
105
121
  this.spreadProps(rootEl, mergedProps);
106
122
  }
107
- const labelEl = this.getElement("label");
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.getElement("root"));
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
- id: getRootId(scope),
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-scope=\"checkbox-group\"][data-part=\"root\"]");
111
+ const root = el.closest("[data-checkbox-group-root]");
107
112
  if (!root) return void 0;
108
113
  return registry.get(root);
109
114
  }
@@ -1,17 +1,31 @@
1
- import { a as Machine, d as FieldMachine, u as FieldAwareComponent } from "./index-B8JCdyld.js";
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 name: string;
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, fieldMachine: FieldMachine): 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 Machine, d as FieldAwareComponent, i as mergeProps, r as normalizeProps } from "./Client-C51NSHxg.js";
2
- import { i as connect, t as getCheckboxGroupMachineFor } from "./checkbox-group.registry-CGwuF7SF.js";
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 name = "checkbox";
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, fieldMachine) {
16
- const isInGroup = !!this.getClosestCheckboxGroup();
15
+ propsWithField(props, field) {
17
16
  return {
18
17
  ...props,
19
- disabled: props.disabled ?? fieldMachine.context.get("disabled"),
20
- readOnly: props.readOnly ?? fieldMachine.context.get("readOnly"),
21
- required: props.required ?? fieldMachine.context.get("required"),
22
- invalid: props.invalid ?? fieldMachine.context.get("invalid"),
23
- name: props.name ?? fieldMachine.prop("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.getElement("root")?.closest("[data-scope=\"checkbox-group\"][data-part=\"root\"]");
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
- return new Machine(checkbox.machine, props);
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.getElement("root");
92
+ const rootEl = this.hydrator.query("root");
90
93
  if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
91
- const labelEl = this.getElement("label");
94
+ const labelEl = this.hydrator.query("label");
92
95
  if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
93
- const controlEl = this.getElement("control");
96
+ const controlEl = this.hydrator.query("control");
94
97
  if (controlEl) this.spreadProps(controlEl, this.api.getControlProps());
95
- const indicatorEl = this.getElement("indicator");
98
+ const indicatorEl = this.hydrator.query("indicator");
96
99
  if (indicatorEl) this.spreadProps(indicatorEl, this.api.getIndicatorProps());
97
- const hiddenInputEl = this.getElement("hidden-input");
100
+ const hiddenInputEl = this.hydrator.query("hiddenInput");
98
101
  if (hiddenInputEl) {
99
- const mergedProps = mergeProps(this.api.getHiddenInputProps(), { "aria-describedby": this.fieldMachine?.context.get("describeIds") || void 0 });
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.userProps?.value) {
113
- const value = this.userProps.value;
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.userProps?.disabled || groupItemProps.disabled,
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 Machine, c as mount, f as Component, h as FluidPrimitivesGlobals, i as mergeProps, l as mountControlled, m as ComponentInterface, n as spreadProps, o as ComponentHydrator, p as ComponentHydrationData, r as normalizeProps, s as getHydrationData, t as uid, u as FieldAwareComponent } from "./index-B8JCdyld.js";
2
- export { Component, ComponentHydrationData, ComponentHydrator, ComponentInterface, FieldAwareComponent, FluidPrimitivesGlobals, Machine, getHydrationData, mergeProps, mount, mountControlled, normalizeProps, spreadProps, uid };
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, d as FieldAwareComponent, i as mergeProps, l as mount, n as spreadProps, o as ComponentHydrator, p as Component, r as normalizeProps, s as getHydrationData, t as uid, u as mountControlled } from "./Client-C51NSHxg.js";
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, mountControlled, normalizeProps, spreadProps, uid };
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 };
@@ -1,11 +1,18 @@
1
- import { a as Machine, f as Component } from "./index-B8JCdyld.js";
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
- declare class Clipboard extends Component<clipboard.Props, clipboard.Api> {
7
- static name: string;
8
- initMachine(props: clipboard.Props): Machine<any>;
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
  }>>;