fluid-primitives 0.16.0 → 0.17.2-next.4.ea462ad

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 (47) hide show
  1. package/README.md +41 -3
  2. package/dist/Client-D-GbQqXf.js +240 -0
  3. package/dist/accordion.d.ts +3 -3
  4. package/dist/accordion.js +48 -1
  5. package/dist/checkbox-group.d.ts +99 -0
  6. package/dist/checkbox-group.js +117 -0
  7. package/dist/checkbox-group.registry-CGwuF7SF.js +112 -0
  8. package/dist/checkbox.d.ts +26 -3
  9. package/dist/checkbox.js +148 -1
  10. package/dist/client.d.ts +2 -2
  11. package/dist/client.js +3 -1
  12. package/dist/clipboard.d.ts +3 -3
  13. package/dist/clipboard.js +32 -1
  14. package/dist/collapsible.d.ts +3 -3
  15. package/dist/collapsible.js +28 -1
  16. package/dist/dialog.d.ts +3 -3
  17. package/dist/dialog.js +34 -1
  18. package/dist/field.d.ts +2 -2
  19. package/dist/field.dom-CJQXpQbZ.js +11 -0
  20. package/dist/field.js +211 -1
  21. package/dist/form.d.ts +3 -3
  22. package/dist/form.js +432 -1
  23. package/dist/form.registry-CmpTny_s.js +51 -0
  24. package/dist/{form.registry-DdLr3dbX.d.ts → form.registry-DjhMF6Ny.d.ts} +2 -2
  25. package/dist/{index-BpcuNDMI.d.ts → index-DxZhm-zT.d.ts} +10 -1
  26. package/dist/navigation-menu.d.ts +15 -0
  27. package/dist/navigation-menu.js +71 -0
  28. package/dist/number-input.d.ts +3 -3
  29. package/dist/number-input.js +55 -1
  30. package/dist/popover.d.ts +3 -3
  31. package/dist/popover.js +42 -1
  32. package/dist/radio-group.d.ts +3 -3
  33. package/dist/radio-group.js +67 -1
  34. package/dist/scroll-area.d.ts +1 -1
  35. package/dist/scroll-area.js +32 -1
  36. package/dist/select.d.ts +6 -5
  37. package/dist/select.js +84 -1
  38. package/dist/switch.d.ts +53 -0
  39. package/dist/switch.js +61 -0
  40. package/dist/tabs.d.ts +3 -3
  41. package/dist/tabs.js +33 -1
  42. package/dist/tooltip.d.ts +3 -3
  43. package/dist/tooltip.js +36 -1
  44. package/package.json +44 -22
  45. package/dist/Client-CygooKu8.js +0 -1
  46. package/dist/field.dom-etI2JxSW.js +0 -1
  47. package/dist/form.registry-Bv4jZGjo.js +0 -1
@@ -1,16 +1,39 @@
1
- import { FieldAwareComponent$1 as FieldAwareComponent, FieldMachine, Machine$1 as Machine } from "./index-BpcuNDMI.js";
1
+ import { a as Machine, l as FieldAwareComponent, u as FieldMachine } from "./index-DxZhm-zT.js";
2
2
  import * as checkbox from "@zag-js/checkbox";
3
- import * as _zag_js_types7 from "@zag-js/types";
3
+ import * as _$_zag_js_types0 from "@zag-js/types";
4
4
 
5
5
  //#region Resources/Private/Primitives/Checkbox/Checkbox.d.ts
6
6
  declare class Checkbox extends FieldAwareComponent<checkbox.Props, checkbox.Api> {
7
7
  static name: string;
8
+ private checkboxGroupMachine;
9
+ private checkboxGroupApi;
10
+ private groupUnsubscribe;
11
+ private subscribedToGroup;
12
+ private closestCheckboxGroup;
13
+ private syncingFromGroup;
8
14
  propsWithField(props: checkbox.Props, fieldMachine: FieldMachine): checkbox.Props;
15
+ private getClosestCheckboxGroup;
16
+ /**
17
+ * Build props merged with CheckboxGroup context.
18
+ * Called by withGroupProps and when group registers late.
19
+ */
20
+ private buildGroupProps;
21
+ /**
22
+ * Merge props from CheckboxGroup if this checkbox is inside one.
23
+ * Similar to withFieldProps - handles late registration via event listener.
24
+ */
25
+ private withGroupProps;
9
26
  initMachine(props: checkbox.Props): Machine<any>;
10
- initApi(): checkbox.Api<_zag_js_types7.PropTypes<{
27
+ initApi(): checkbox.Api<_$_zag_js_types0.PropTypes<{
11
28
  [x: string]: any;
12
29
  }>>;
13
30
  render(): void;
31
+ /**
32
+ * Subscribe to CheckboxGroup state changes to sync checked/disabled state.
33
+ * Similar to subscribeToFieldService.
34
+ */
35
+ private subscribeToCheckboxGroup;
36
+ destroy(): void;
14
37
  }
15
38
  //#endregion
16
39
  export { Checkbox };
package/dist/checkbox.js CHANGED
@@ -1 +1,148 @@
1
- import{FieldAwareComponent as e,Machine as t,mergeProps as n,normalizeProps as r}from"./Client-CygooKu8.js";import{getControlId as i,getLabelId as a}from"./field.dom-etI2JxSW.js";import*as o from"@zag-js/checkbox";var s=class extends e{static name=`checkbox`;propsWithField(e,t){return{value:`1`,...e,disabled:e.disabled??t.context.get(`disabled`),readOnly:e.readOnly??t.context.get(`readOnly`),required:e.required??t.context.get(`required`),invalid:e.invalid??t.context.get(`invalid`),name:e.name??t.prop(`name`),ids:{...e.ids,label:a(t.scope),hiddenInput:i(t.scope)}}}initMachine(e){return e=this.withFieldProps(e),new t(o.machine,e)}initApi(){return o.connect(this.machine.service,r)}render(){this.subscribeToFieldService();let e=this.getElement(`root`);e&&this.spreadProps(e,this.api.getRootProps());let t=this.getElement(`label`);t&&this.spreadProps(t,this.api.getLabelProps());let r=this.getElement(`control`);r&&this.spreadProps(r,this.api.getControlProps());let i=this.getElement(`indicator`);i&&this.spreadProps(i,this.api.getIndicatorProps());let a=this.getElement(`hidden-input`);if(a){let e=n(this.api.getHiddenInputProps(),{"aria-describedby":this.fieldMachine?.context.get(`describeIds`)||void 0});this.spreadProps(a,e)}}};export{s as Checkbox};
1
+ import { a as Machine, i as mergeProps, r as normalizeProps, u as FieldAwareComponent } from "./Client-D-GbQqXf.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";
4
+ import * as checkbox from "@zag-js/checkbox";
5
+
6
+ //#region Resources/Private/Primitives/Checkbox/Checkbox.ts
7
+ var Checkbox = class extends FieldAwareComponent {
8
+ static name = "checkbox";
9
+ checkboxGroupMachine;
10
+ checkboxGroupApi;
11
+ groupUnsubscribe;
12
+ subscribedToGroup = false;
13
+ closestCheckboxGroup = null;
14
+ syncingFromGroup = false;
15
+ propsWithField(props, fieldMachine) {
16
+ const isInGroup = !!this.getClosestCheckboxGroup();
17
+ return {
18
+ ...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
+ }
29
+ };
30
+ }
31
+ getClosestCheckboxGroup() {
32
+ return this.closestCheckboxGroup || this.getElement("root")?.closest("[data-scope=\"checkbox-group\"][data-part=\"root\"]");
33
+ }
34
+ /**
35
+ * Build props merged with CheckboxGroup context.
36
+ * Called by withGroupProps and when group registers late.
37
+ */
38
+ buildGroupProps(props) {
39
+ if (!this.checkboxGroupMachine || !props.value) return props;
40
+ this.checkboxGroupApi = connect(this.checkboxGroupMachine.service, normalizeProps);
41
+ const groupItemProps = this.checkboxGroupApi.getItemProps({ value: props.value });
42
+ return {
43
+ ...props,
44
+ defaultChecked: groupItemProps.checked,
45
+ disabled: props.disabled ?? groupItemProps.disabled,
46
+ readOnly: props.readOnly ?? groupItemProps.readOnly,
47
+ invalid: props.invalid ?? groupItemProps.invalid,
48
+ name: props.name ?? groupItemProps.name,
49
+ onCheckedChange: (details) => {
50
+ if (this.syncingFromGroup) {
51
+ props.onCheckedChange?.(details);
52
+ return;
53
+ }
54
+ groupItemProps.onCheckedChange();
55
+ props.onCheckedChange?.(details);
56
+ }
57
+ };
58
+ }
59
+ /**
60
+ * Merge props from CheckboxGroup if this checkbox is inside one.
61
+ * Similar to withFieldProps - handles late registration via event listener.
62
+ */
63
+ withGroupProps(props) {
64
+ this.closestCheckboxGroup = this.getClosestCheckboxGroup();
65
+ if (!this.closestCheckboxGroup || !props.value) return props;
66
+ this.checkboxGroupMachine = getCheckboxGroupMachineFor(this.closestCheckboxGroup);
67
+ if (this.checkboxGroupMachine) return this.buildGroupProps(props);
68
+ else {
69
+ const handler = () => {
70
+ this.checkboxGroupMachine = getCheckboxGroupMachineFor(this.getClosestCheckboxGroup());
71
+ if (this.checkboxGroupMachine) this.updateProps(this.buildGroupProps(this.userProps));
72
+ this.closestCheckboxGroup?.removeEventListener("fluid-primitives:checkbox-group:registered", handler);
73
+ };
74
+ this.closestCheckboxGroup.addEventListener("fluid-primitives:checkbox-group:registered", handler);
75
+ }
76
+ return props;
77
+ }
78
+ initMachine(props) {
79
+ props = this.withFieldProps(props);
80
+ props = this.withGroupProps(props);
81
+ return new Machine(checkbox.machine, props);
82
+ }
83
+ initApi() {
84
+ return checkbox.connect(this.machine.service, normalizeProps);
85
+ }
86
+ render() {
87
+ this.subscribeToFieldService();
88
+ this.subscribeToCheckboxGroup();
89
+ const rootEl = this.getElement("root");
90
+ if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
91
+ const labelEl = this.getElement("label");
92
+ if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
93
+ const controlEl = this.getElement("control");
94
+ if (controlEl) this.spreadProps(controlEl, this.api.getControlProps());
95
+ const indicatorEl = this.getElement("indicator");
96
+ if (indicatorEl) this.spreadProps(indicatorEl, this.api.getIndicatorProps());
97
+ const hiddenInputEl = this.getElement("hidden-input");
98
+ if (hiddenInputEl) {
99
+ const mergedProps = mergeProps(this.api.getHiddenInputProps(), { "aria-describedby": this.fieldMachine?.context.get("describeIds") || void 0 });
100
+ this.spreadProps(hiddenInputEl, mergedProps);
101
+ }
102
+ }
103
+ /**
104
+ * Subscribe to CheckboxGroup state changes to sync checked/disabled state.
105
+ * Similar to subscribeToFieldService.
106
+ */
107
+ subscribeToCheckboxGroup() {
108
+ if (this.subscribedToGroup) return;
109
+ this.closestCheckboxGroup = this.getClosestCheckboxGroup();
110
+ if (!this.closestCheckboxGroup) return;
111
+ if (!this.checkboxGroupMachine) this.checkboxGroupMachine = getCheckboxGroupMachineFor(this.closestCheckboxGroup);
112
+ if (this.checkboxGroupMachine && this.userProps?.value) {
113
+ const value = this.userProps.value;
114
+ this.groupUnsubscribe = this.checkboxGroupMachine.subscribe(() => {
115
+ queueMicrotask(() => {
116
+ this.checkboxGroupApi = connect(this.checkboxGroupMachine.service, normalizeProps);
117
+ const groupItemProps = this.checkboxGroupApi.getItemProps({ value });
118
+ const currentChecked = this.api.checked;
119
+ if (groupItemProps.checked !== currentChecked) {
120
+ this.syncingFromGroup = true;
121
+ this.api.setChecked(groupItemProps.checked);
122
+ queueMicrotask(() => {
123
+ this.syncingFromGroup = false;
124
+ });
125
+ }
126
+ this.machine.updateProps({
127
+ disabled: this.userProps?.disabled || groupItemProps.disabled,
128
+ invalid: groupItemProps.invalid
129
+ });
130
+ });
131
+ });
132
+ this.subscribedToGroup = true;
133
+ } else if (this.closestCheckboxGroup) {
134
+ const handler = () => {
135
+ this.subscribeToCheckboxGroup();
136
+ this.closestCheckboxGroup?.removeEventListener("fluid-primitives:checkbox-group:registered", handler);
137
+ };
138
+ this.closestCheckboxGroup.addEventListener("fluid-primitives:checkbox-group:registered", handler);
139
+ }
140
+ }
141
+ destroy() {
142
+ this.groupUnsubscribe?.();
143
+ super.destroy();
144
+ }
145
+ };
146
+
147
+ //#endregion
148
+ export { Checkbox };
package/dist/client.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Component$1 as Component, ComponentHydrationData, ComponentHydrator$1 as ComponentHydrator, ComponentInterface, FieldAwareComponent$1 as FieldAwareComponent, Machine$1 as Machine, getHydrationData$1 as getHydrationData, mergeProps$1 as mergeProps, mount$1 as mount, normalizeProps$1 as normalizeProps, spreadProps$1 as spreadProps, uid$1 as uid } from "./index-BpcuNDMI.js";
2
- export { Component, ComponentHydrationData, ComponentHydrator, ComponentInterface, FieldAwareComponent, Machine, getHydrationData, mergeProps, mount, normalizeProps, spreadProps, uid };
1
+ import { a as Machine, c as mount, d as Component, f as ComponentHydrationData, i as mergeProps, l as FieldAwareComponent, m as FluidPrimitivesGlobals, n as spreadProps, o as ComponentHydrator, p as ComponentInterface, r as normalizeProps, s as getHydrationData, t as uid } from "./index-DxZhm-zT.js";
2
+ export { Component, ComponentHydrationData, ComponentHydrator, ComponentInterface, FieldAwareComponent, FluidPrimitivesGlobals, Machine, getHydrationData, mergeProps, mount, normalizeProps, spreadProps, uid };
package/dist/client.js CHANGED
@@ -1 +1,3 @@
1
- import{Component as e,ComponentHydrator as t,FieldAwareComponent as n,Machine as r,getHydrationData as i,mergeProps as a,mount as o,normalizeProps as s,spreadProps as c,uid as l}from"./Client-CygooKu8.js";export{e as Component,t as ComponentHydrator,n as FieldAwareComponent,r as Machine,i as getHydrationData,a as mergeProps,o as mount,s as normalizeProps,c as spreadProps,l as uid};
1
+ import { a as Machine, f as Component, i as mergeProps, l as mount, n as spreadProps, o as ComponentHydrator, r as normalizeProps, s as getHydrationData, t as uid, u as FieldAwareComponent } from "./Client-D-GbQqXf.js";
2
+
3
+ export { Component, ComponentHydrator, FieldAwareComponent, Machine, getHydrationData, mergeProps, mount, normalizeProps, spreadProps, uid };
@@ -1,12 +1,12 @@
1
- import { Component$1 as Component, Machine$1 as Machine } from "./index-BpcuNDMI.js";
1
+ import { a as Machine, d as Component } from "./index-DxZhm-zT.js";
2
2
  import * as clipboard from "@zag-js/clipboard";
3
- import * as _zag_js_types4 from "@zag-js/types";
3
+ import * as _$_zag_js_types0 from "@zag-js/types";
4
4
 
5
5
  //#region Resources/Private/Primitives/Clipboard/Clipboard.d.ts
6
6
  declare class Clipboard extends Component<clipboard.Props, clipboard.Api> {
7
7
  static name: string;
8
8
  initMachine(props: clipboard.Props): Machine<any>;
9
- initApi(): clipboard.Api<_zag_js_types4.PropTypes<{
9
+ initApi(): clipboard.Api<_$_zag_js_types0.PropTypes<{
10
10
  [x: string]: any;
11
11
  }>>;
12
12
  render(): void;
package/dist/clipboard.js CHANGED
@@ -1 +1,32 @@
1
- import{Component as e,Machine as t,normalizeProps as n}from"./Client-CygooKu8.js";import*as r from"@zag-js/clipboard";var i=class extends e{static name=`clipboard`;initMachine(e){return new t(r.machine,e)}initApi(){return r.connect(this.machine.service,n)}render(){let e=this.getElement(`root`);e&&this.spreadProps(e,this.api.getRootProps());let t=this.getElement(`label`);t&&this.spreadProps(t,this.api.getLabelProps());let n=this.getElement(`control`);n&&this.spreadProps(n,this.api.getControlProps());let r=this.getElement(`input`);r&&this.spreadProps(r,this.api.getInputProps());let i=this.getElement(`indicator-copied`);i&&this.spreadProps(i,this.api.getIndicatorProps({copied:!0}));let a=this.getElement(`indicator-idle`);a&&this.spreadProps(a,this.api.getIndicatorProps({copied:!1}));let o=this.getElement(`trigger`);o&&this.spreadProps(o,this.api.getTriggerProps())}};export{i as Clipboard};
1
+ import { a as Machine, f as Component, r as normalizeProps } from "./Client-D-GbQqXf.js";
2
+ import * as clipboard from "@zag-js/clipboard";
3
+
4
+ //#region Resources/Private/Primitives/Clipboard/Clipboard.ts
5
+ var Clipboard = class extends Component {
6
+ static name = "clipboard";
7
+ initMachine(props) {
8
+ return new Machine(clipboard.machine, props);
9
+ }
10
+ initApi() {
11
+ return clipboard.connect(this.machine.service, normalizeProps);
12
+ }
13
+ render() {
14
+ const rootEl = this.getElement("root");
15
+ if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
16
+ const labelEl = this.getElement("label");
17
+ if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
18
+ const controlEl = this.getElement("control");
19
+ if (controlEl) this.spreadProps(controlEl, this.api.getControlProps());
20
+ const inputEl = this.getElement("input");
21
+ if (inputEl) this.spreadProps(inputEl, this.api.getInputProps());
22
+ const indicatorCopiedEl = this.getElement("indicator-copied");
23
+ if (indicatorCopiedEl) this.spreadProps(indicatorCopiedEl, this.api.getIndicatorProps({ copied: true }));
24
+ const indicatorIdleEl = this.getElement("indicator-idle");
25
+ if (indicatorIdleEl) this.spreadProps(indicatorIdleEl, this.api.getIndicatorProps({ copied: false }));
26
+ const triggerEl = this.getElement("trigger");
27
+ if (triggerEl) this.spreadProps(triggerEl, this.api.getTriggerProps());
28
+ }
29
+ };
30
+
31
+ //#endregion
32
+ export { Clipboard };
@@ -1,12 +1,12 @@
1
- import { Component$1 as Component, Machine$1 as Machine } from "./index-BpcuNDMI.js";
1
+ import { a as Machine, d as Component } from "./index-DxZhm-zT.js";
2
2
  import * as collapsible from "@zag-js/collapsible";
3
- import * as _zag_js_types5 from "@zag-js/types";
3
+ import * as _$_zag_js_types0 from "@zag-js/types";
4
4
 
5
5
  //#region Resources/Private/Primitives/Collapsible/Collapsible.d.ts
6
6
  declare class Collapsible extends Component<collapsible.Props, collapsible.Api> {
7
7
  static name: string;
8
8
  initMachine(props: collapsible.Props): Machine<any>;
9
- initApi(): collapsible.Api<_zag_js_types5.PropTypes<{
9
+ initApi(): collapsible.Api<_$_zag_js_types0.PropTypes<{
10
10
  [x: string]: any;
11
11
  }>>;
12
12
  render(): void;
@@ -1 +1,28 @@
1
- import{Component as e,Machine as t,normalizeProps as n}from"./Client-CygooKu8.js";import*as r from"@zag-js/collapsible";var i=class extends e{static name=`collapsible`;initMachine(e){return new t(r.machine,e)}initApi(){return r.connect(this.machine.service,n)}render(){let e=this.getElement(`root`);e&&this.spreadProps(e,this.api.getRootProps());let t=this.getElements(`trigger`);t.forEach(e=>{this.spreadProps(e,this.api.getTriggerProps())});let n=this.getElements(`trigger-text`);n.forEach(e=>{e&&e.dataset.openText&&e.dataset.closeText&&(e.textContent=this.api.open?e.dataset.closeText:e.dataset.openText)});let r=this.getElement(`content`);r&&this.spreadProps(r,this.api.getContentProps())}};export{i as Collapsible};
1
+ import { a as Machine, f as Component, r as normalizeProps } from "./Client-D-GbQqXf.js";
2
+ import * as collapsible from "@zag-js/collapsible";
3
+
4
+ //#region Resources/Private/Primitives/Collapsible/Collapsible.ts
5
+ var Collapsible = class extends Component {
6
+ static name = "collapsible";
7
+ initMachine(props) {
8
+ return new Machine(collapsible.machine, props);
9
+ }
10
+ initApi() {
11
+ return collapsible.connect(this.machine.service, normalizeProps);
12
+ }
13
+ render() {
14
+ const rootEl = this.getElement("root");
15
+ if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
16
+ this.getElements("trigger").forEach((triggerEl) => {
17
+ this.spreadProps(triggerEl, this.api.getTriggerProps());
18
+ });
19
+ this.getElements("trigger-text").forEach((triggerTextEl) => {
20
+ if (triggerTextEl && triggerTextEl.dataset.openText && triggerTextEl.dataset.closeText) triggerTextEl.textContent = this.api.open ? triggerTextEl.dataset.closeText : triggerTextEl.dataset.openText;
21
+ });
22
+ const contentEl = this.getElement("content");
23
+ if (contentEl) this.spreadProps(contentEl, this.api.getContentProps());
24
+ }
25
+ };
26
+
27
+ //#endregion
28
+ export { Collapsible };
package/dist/dialog.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { Component$1 as Component, Machine$1 as Machine } from "./index-BpcuNDMI.js";
1
+ import { a as Machine, d as Component } from "./index-DxZhm-zT.js";
2
2
  import * as dialog from "@zag-js/dialog";
3
- import * as _zag_js_types2 from "@zag-js/types";
3
+ import * as _$_zag_js_types0 from "@zag-js/types";
4
4
 
5
5
  //#region Resources/Private/Primitives/Dialog/Dialog.d.ts
6
6
  declare class Dialog extends Component<dialog.Props, dialog.Api> {
7
7
  static name: string;
8
8
  initMachine(props: dialog.Props): Machine<any>;
9
- initApi(): dialog.Api<_zag_js_types2.PropTypes<{
9
+ initApi(): dialog.Api<_$_zag_js_types0.PropTypes<{
10
10
  [x: string]: any;
11
11
  }>>;
12
12
  render(): void;
package/dist/dialog.js CHANGED
@@ -1 +1,34 @@
1
- import{Component as e,Machine as t,normalizeProps as n}from"./Client-CygooKu8.js";import*as r from"@zag-js/dialog";var i=class extends e{static name=`dialog`;initMachine(e){return new t(r.machine,e)}initApi(){return r.connect(this.machine.service,n)}render(){let e=this.getElements(`trigger`);e.forEach(e=>{this.spreadProps(e,this.api.getTriggerProps())});let t=this.getElement(`backdrop`);t&&this.spreadProps(t,this.api.getBackdropProps());let n=this.getElement(`positioner`);n&&this.spreadProps(n,this.api.getPositionerProps());let r=this.getElement(`content`);r&&this.spreadProps(r,this.api.getContentProps());let i=this.getElement(`title`);i&&this.spreadProps(i,this.api.getTitleProps());let a=this.getElement(`description`);a&&this.spreadProps(a,this.api.getDescriptionProps());let o=this.getElements(`close-trigger`);o.forEach(e=>{this.spreadProps(e,this.api.getCloseTriggerProps())})}};export{i as Dialog};
1
+ import { a as Machine, f as Component, r as normalizeProps } from "./Client-D-GbQqXf.js";
2
+ import * as dialog from "@zag-js/dialog";
3
+
4
+ //#region Resources/Private/Primitives/Dialog/Dialog.ts
5
+ var Dialog = class extends Component {
6
+ static name = "dialog";
7
+ initMachine(props) {
8
+ return new Machine(dialog.machine, props);
9
+ }
10
+ initApi() {
11
+ return dialog.connect(this.machine.service, normalizeProps);
12
+ }
13
+ render() {
14
+ this.getElements("trigger").forEach((trigger) => {
15
+ this.spreadProps(trigger, this.api.getTriggerProps());
16
+ });
17
+ const backdropEl = this.getElement("backdrop");
18
+ if (backdropEl) this.spreadProps(backdropEl, this.api.getBackdropProps());
19
+ const positionerEl = this.getElement("positioner");
20
+ if (positionerEl) this.spreadProps(positionerEl, this.api.getPositionerProps());
21
+ const contentEl = this.getElement("content");
22
+ if (contentEl) this.spreadProps(contentEl, this.api.getContentProps());
23
+ const titleEl = this.getElement("title");
24
+ if (titleEl) this.spreadProps(titleEl, this.api.getTitleProps());
25
+ const descriptionEl = this.getElement("description");
26
+ if (descriptionEl) this.spreadProps(descriptionEl, this.api.getDescriptionProps());
27
+ this.getElements("close-trigger").forEach((trigger) => {
28
+ this.spreadProps(trigger, this.api.getCloseTriggerProps());
29
+ });
30
+ }
31
+ };
32
+
33
+ //#endregion
34
+ export { Dialog };
package/dist/field.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Component$1 as Component, Machine$1 as Machine } from "./index-BpcuNDMI.js";
2
- import { FormMachine } from "./form.registry-DdLr3dbX.js";
1
+ import { a as Machine, d as Component } from "./index-DxZhm-zT.js";
2
+ import { n as FormMachine } from "./form.registry-DjhMF6Ny.js";
3
3
  import { EventObject } from "@zag-js/core";
4
4
  import { PropTypes } from "@zag-js/types";
5
5
 
@@ -0,0 +1,11 @@
1
+ //#region Resources/Private/Primitives/Field/src/field.dom.ts
2
+ const getRootId = (scope) => scope.ids?.root ?? `field:${scope.id}:root`;
3
+ const getLabelId = (scope) => scope.ids?.label ?? `field:${scope.id}:label`;
4
+ const getControlId = (scope) => scope.ids?.control ?? `field:${scope.id}:control`;
5
+ const getErrorId = (scope) => scope.ids?.error ?? `field:${scope.id}:error`;
6
+ const getDescriptionId = (scope) => scope.ids?.description ?? `field:${scope.id}:description`;
7
+ const getRootEl = (scope) => scope.getById(getRootId(scope));
8
+ const getDescriptionEl = (scope) => scope.getById(getDescriptionId(scope));
9
+
10
+ //#endregion
11
+ export { getLabelId as a, getErrorId as i, getDescriptionEl as n, getRootEl as o, getDescriptionId as r, getRootId as s, getControlId as t };
package/dist/field.js CHANGED
@@ -1 +1,211 @@
1
- import{Component as e,Machine as t,normalizeProps as n,registerFieldMachine as r}from"./Client-CygooKu8.js";import{getControlId as i,getDescriptionEl as a,getDescriptionId as o,getErrorId as s,getLabelId as c,getRootEl as l,getRootId as u}from"./field.dom-etI2JxSW.js";import{getFormMachineFor as d,registerFieldMachineForForm as f}from"./form.registry-Bv4jZGjo.js";import{createAnatomy as p}from"@zag-js/anatomy";import{createMachine as m}from"@zag-js/core";const h=p(`field`).parts(`root`,`label`,`control`,`error`,`description`),g=h.build();function _(e,t){let{scope:n,prop:r,context:a,computed:l}=e,d=a.get(`invalid`),f=a.get(`disabled`),p=a.get(`required`),m=a.get(`readOnly`),h=l(`errors`);return{getFormMachine:()=>a.get(`formMachine`),invalid:d,disabled:f,required:p,readOnly:m,errors:h,name:r(`name`),getErrorText(){return h.length>0?h.join(` `):null},getRootProps(){return t.element({...g.root.attrs,id:u(n),"data-invalid":d?``:void 0,"data-disabled":f?``:void 0,"data-readonly":m?``:void 0,"data-required":p?``:void 0,"data-name":r(`name`)})},getLabelProps(){return t.label({...g.label.attrs,id:c(n),htmlFor:i(n),"data-invalid":d?``:void 0,"data-disabled":f?``:void 0,"data-required":p?``:void 0})},getControlProps(){return t.element({...g.control.attrs,id:i(n),name:r(`name`),disabled:f||void 0,readOnly:m||void 0,required:p||void 0,"aria-invalid":d?`true`:void 0,"aria-describedby":a.get(`describeIds`)||void 0,"aria-required":p?`true`:void 0,"data-invalid":d?``:void 0,"data-disabled":f?``:void 0,"data-readonly":m?``:void 0})},getErrorProps(){return t.element({...g.error.attrs,id:s(n),hidden:!d})},getDescriptionProps(){return t.element({...g.description.attrs,id:o(n)})}}}const v=m({initialState(){return`ready`},context({bindable:e,prop:t}){return{invalid:e(()=>({defaultValue:t(`invalid`)??!1})),required:e(()=>({defaultValue:t(`required`)??!1})),disabled:e(()=>({defaultValue:t(`disabled`)??!1})),readOnly:e(()=>({defaultValue:t(`readOnly`)??!1})),formMachine:e(()=>({defaultValue:null,hash:e=>JSON.stringify({state:e?.state,errors:e?.context.get(`errors`)})})),describeIds:e(()=>({defaultValue:void 0})),hasDescription:e(()=>({defaultValue:!1}))}},entry:[`getFormMachine`,`checkForDescription`,`determineDescribeIds`,`updateInvalid`],states:{ready:{}},computed:{errors({context:e,prop:t}){let n=e.get(`formMachine`)?.context;if(!n)return[];let r=n.get(`errors`)?.[t(`name`)];return r?.messages??[]}},watch({track:e,context:t,computed:n,action:r}){e([()=>t.hash(`formMachine`),()=>n(`errors`).join(`|`)],()=>{r([`updateInvalid`])}),e([()=>t.get(`invalid`),()=>t.get(`hasDescription`)],()=>{r([`determineDescribeIds`])})},implementations:{actions:{getFormMachine({context:e,scope:t}){if(e.get(`formMachine`))return;let n=l(t);if(!n)return;let r=d(n)??null;if(r)e.set(`formMachine`,r);else{let t=n.closest(`form`);if(!t)return;let r=()=>{let i=d(n)??null;e.set(`formMachine`,i),t.removeEventListener(`fluid-primitives:form:registered`,r)};t.addEventListener(`fluid-primitives:form:registered`,r)}},checkForDescription({context:e,scope:t}){let n=a(t);e.set(`hasDescription`,!!n)},determineDescribeIds({context:e,scope:t}){let n=[];e.get(`hasDescription`)&&n.push(o(t)),e.get(`invalid`)&&n.push(s(t));let r=n.join(` `)||void 0;e.set(`describeIds`,r)},updateInvalid({context:e,prop:t}){let n=e.get(`formMachine`)?.context;if(!n){e.set(`invalid`,t(`invalid`)??!1);return}let r=n.get(`errors`)?.[t(`name`)],i=r?.messages??[];e.set(`invalid`,i.length>0)}}}});var y=class extends e{static name=`field`;subscribedToForm=!1;initMachine(e){let n=new t(v,e);return r(this.getElement(`root`),n),f(this.getElement(`root`),n),n}initApi(){return _(this.machine.service,n)}subscribeToFormMachine(){if(this.subscribedToForm)return;let e=this.api.getFormMachine();e&&(this.subscribedToForm=!0,e.subscribe(()=>{this.machine.notify()}))}render(){this.subscribeToFormMachine();let e=this.getElement(`root`);e&&this.spreadProps(e,this.api.getRootProps());let t=this.getElement(`label`);t&&this.spreadProps(t,this.api.getLabelProps());let n=this.getElement(`control`);n&&this.spreadProps(n,this.api.getControlProps());let r=this.getElement(`description`);r&&this.spreadProps(r,this.api.getDescriptionProps());let i=this.getElement(`error`);if(i){this.spreadProps(i,this.api.getErrorProps());let e=this.api.getErrorText();e&&(i.textContent=e)}}};export{y as Field};
1
+ import { a as Machine, d as registerFieldMachine, f as Component, r as normalizeProps } from "./Client-D-GbQqXf.js";
2
+ import { a as getLabelId, i as getErrorId, n as getDescriptionEl, o as getRootEl, r as getDescriptionId, s as getRootId, t as getControlId } from "./field.dom-CJQXpQbZ.js";
3
+ import { n as getFormMachineFor, r as registerFieldMachineForForm } from "./form.registry-CmpTny_s.js";
4
+ import { createMachine } from "@zag-js/core";
5
+ import { createAnatomy } from "@zag-js/anatomy";
6
+
7
+ //#region Resources/Private/Primitives/Field/src/field.anatomy.ts
8
+ const anatomy = createAnatomy("field").parts("root", "label", "control", "error", "description");
9
+ const parts = anatomy.build();
10
+
11
+ //#endregion
12
+ //#region Resources/Private/Primitives/Field/src/field.connect.ts
13
+ function connect(service, normalize) {
14
+ const { scope, prop, context, computed } = service;
15
+ const invalid = context.get("invalid");
16
+ const disabled = context.get("disabled");
17
+ const required = context.get("required");
18
+ const readOnly = context.get("readOnly");
19
+ const errors = computed("errors");
20
+ return {
21
+ getFormMachine: () => context.get("formMachine"),
22
+ invalid,
23
+ disabled,
24
+ required,
25
+ readOnly,
26
+ errors,
27
+ name: prop("name"),
28
+ getErrorText() {
29
+ return errors.length > 0 ? errors.join(" ") : null;
30
+ },
31
+ getRootProps() {
32
+ return normalize.element({
33
+ ...parts.root.attrs,
34
+ id: getRootId(scope),
35
+ "data-invalid": invalid ? "" : void 0,
36
+ "data-disabled": disabled ? "" : void 0,
37
+ "data-readonly": readOnly ? "" : void 0,
38
+ "data-required": required ? "" : void 0,
39
+ "data-name": prop("name")
40
+ });
41
+ },
42
+ getLabelProps() {
43
+ return normalize.label({
44
+ ...parts.label.attrs,
45
+ id: getLabelId(scope),
46
+ htmlFor: getControlId(scope),
47
+ "data-invalid": invalid ? "" : void 0,
48
+ "data-disabled": disabled ? "" : void 0,
49
+ "data-required": required ? "" : void 0
50
+ });
51
+ },
52
+ getControlProps() {
53
+ return normalize.element({
54
+ ...parts.control.attrs,
55
+ id: getControlId(scope),
56
+ name: prop("name"),
57
+ disabled: disabled || void 0,
58
+ readOnly: readOnly || void 0,
59
+ required: required || void 0,
60
+ "aria-invalid": invalid ? "true" : void 0,
61
+ "aria-describedby": context.get("describeIds") || void 0,
62
+ "aria-required": required ? "true" : void 0,
63
+ "data-invalid": invalid ? "" : void 0,
64
+ "data-disabled": disabled ? "" : void 0,
65
+ "data-readonly": readOnly ? "" : void 0
66
+ });
67
+ },
68
+ getErrorProps() {
69
+ return normalize.element({
70
+ ...parts.error.attrs,
71
+ id: getErrorId(scope),
72
+ hidden: !invalid
73
+ });
74
+ },
75
+ getDescriptionProps() {
76
+ return normalize.element({
77
+ ...parts.description.attrs,
78
+ id: getDescriptionId(scope)
79
+ });
80
+ }
81
+ };
82
+ }
83
+
84
+ //#endregion
85
+ //#region Resources/Private/Primitives/Field/src/field.machine.ts
86
+ const machine = createMachine({
87
+ initialState() {
88
+ return "ready";
89
+ },
90
+ context({ bindable, prop }) {
91
+ return {
92
+ invalid: bindable(() => ({ defaultValue: prop("invalid") ?? false })),
93
+ required: bindable(() => ({ defaultValue: prop("required") ?? false })),
94
+ disabled: bindable(() => ({ defaultValue: prop("disabled") ?? false })),
95
+ readOnly: bindable(() => ({ defaultValue: prop("readOnly") ?? false })),
96
+ formMachine: bindable(() => ({
97
+ defaultValue: null,
98
+ hash: (value) => JSON.stringify({
99
+ state: value?.state,
100
+ errors: value?.context.get("errors")
101
+ })
102
+ })),
103
+ describeIds: bindable(() => ({ defaultValue: void 0 })),
104
+ hasDescription: bindable(() => ({ defaultValue: false }))
105
+ };
106
+ },
107
+ entry: [
108
+ "getFormMachine",
109
+ "checkForDescription",
110
+ "determineDescribeIds",
111
+ "updateInvalid"
112
+ ],
113
+ states: { ready: {} },
114
+ computed: { errors({ context, prop }) {
115
+ const formMachineCtx = context.get("formMachine")?.context;
116
+ if (!formMachineCtx) return [];
117
+ return (formMachineCtx.get("errors")?.[prop("name")])?.messages ?? [];
118
+ } },
119
+ watch({ track, context, computed, action }) {
120
+ track([() => context.hash("formMachine"), () => computed("errors").join("|")], () => {
121
+ action(["updateInvalid"]);
122
+ });
123
+ track([() => context.get("invalid"), () => context.get("hasDescription")], () => {
124
+ action(["determineDescribeIds"]);
125
+ });
126
+ },
127
+ implementations: { actions: {
128
+ getFormMachine({ context, scope }) {
129
+ if (context.get("formMachine")) return;
130
+ const fieldRootEl = getRootEl(scope);
131
+ if (!fieldRootEl) return;
132
+ const formMachine = getFormMachineFor(fieldRootEl) ?? null;
133
+ if (formMachine) context.set("formMachine", formMachine);
134
+ else {
135
+ const closestForm = fieldRootEl.closest("form");
136
+ if (!closestForm) return;
137
+ const handler = () => {
138
+ const fs = getFormMachineFor(fieldRootEl) ?? null;
139
+ context.set("formMachine", fs);
140
+ closestForm.removeEventListener("fluid-primitives:form:registered", handler);
141
+ };
142
+ closestForm.addEventListener("fluid-primitives:form:registered", handler);
143
+ }
144
+ },
145
+ checkForDescription({ context, scope }) {
146
+ const descriptionEl = getDescriptionEl(scope);
147
+ context.set("hasDescription", !!descriptionEl);
148
+ },
149
+ determineDescribeIds({ context, scope }) {
150
+ const ids = [];
151
+ if (context.get("hasDescription")) ids.push(getDescriptionId(scope));
152
+ if (context.get("invalid")) ids.push(getErrorId(scope));
153
+ const idsStr = ids.join(" ") || void 0;
154
+ context.set("describeIds", idsStr);
155
+ },
156
+ updateInvalid({ context, prop }) {
157
+ const formMachineCtx = context.get("formMachine")?.context;
158
+ if (!formMachineCtx) {
159
+ context.set("invalid", prop("invalid") ?? false);
160
+ return;
161
+ }
162
+ const errs = (formMachineCtx.get("errors")?.[prop("name")])?.messages ?? [];
163
+ context.set("invalid", errs.length > 0);
164
+ }
165
+ } }
166
+ });
167
+
168
+ //#endregion
169
+ //#region Resources/Private/Primitives/Field/Field.ts
170
+ var Field = class extends Component {
171
+ static name = "field";
172
+ subscribedToForm = false;
173
+ initMachine(props) {
174
+ const createdMachine = new Machine(machine, props);
175
+ registerFieldMachine(this.getElement("root"), createdMachine);
176
+ registerFieldMachineForForm(this.getElement("root"), createdMachine);
177
+ return createdMachine;
178
+ }
179
+ initApi() {
180
+ return connect(this.machine.service, normalizeProps);
181
+ }
182
+ subscribeToFormMachine() {
183
+ if (this.subscribedToForm) return;
184
+ const formMachine = this.api.getFormMachine();
185
+ if (!formMachine) return;
186
+ this.subscribedToForm = true;
187
+ formMachine.subscribe(() => {
188
+ this.machine.notify();
189
+ });
190
+ }
191
+ render() {
192
+ this.subscribeToFormMachine();
193
+ const rootEl = this.getElement("root");
194
+ if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
195
+ const labelEl = this.getElement("label");
196
+ if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
197
+ const controlEl = this.getElement("control");
198
+ if (controlEl) this.spreadProps(controlEl, this.api.getControlProps());
199
+ const descriptionEl = this.getElement("description");
200
+ if (descriptionEl) this.spreadProps(descriptionEl, this.api.getDescriptionProps());
201
+ const errorEl = this.getElement("error");
202
+ if (errorEl) {
203
+ this.spreadProps(errorEl, this.api.getErrorProps());
204
+ const msg = this.api.getErrorText();
205
+ if (msg) errorEl.textContent = msg;
206
+ }
207
+ }
208
+ };
209
+
210
+ //#endregion
211
+ export { Field };
package/dist/form.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Component$1 as Component, Machine$1 as Machine } from "./index-BpcuNDMI.js";
2
- import { FieldMachine$1 as FieldMachine } from "./form.registry-DdLr3dbX.js";
1
+ import { a as Machine, d as Component } from "./index-DxZhm-zT.js";
2
+ import { t as FieldMachine } from "./form.registry-DjhMF6Ny.js";
3
3
  import { EventObject } from "@zag-js/core";
4
- import { JSX, PropTypes } from "@zag-js/types";
5
4
  import * as z from "zod";
5
+ import { JSX, PropTypes } from "@zag-js/types";
6
6
 
7
7
  //#region Resources/Private/Primitives/Form/src/form.types.d.ts
8
8
  interface FieldError {