fluid-primitives 0.17.2 → 0.18.0-next.8.a9be2d6
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 +2 -6
- package/dist/Client-C51NSHxg.js +248 -0
- package/dist/accordion.d.ts +3 -3
- package/dist/accordion.js +45 -1
- package/dist/checkbox-group.d.ts +99 -0
- package/dist/checkbox-group.js +117 -0
- package/dist/checkbox-group.registry-CGwuF7SF.js +112 -0
- package/dist/checkbox.d.ts +26 -3
- package/dist/checkbox.js +148 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +3 -1
- package/dist/clipboard.d.ts +3 -3
- package/dist/clipboard.js +32 -1
- package/dist/collapsible.d.ts +3 -3
- package/dist/collapsible.js +28 -1
- package/dist/dialog.d.ts +3 -3
- package/dist/dialog.js +34 -1
- package/dist/field.d.ts +2 -2
- package/dist/field.dom-CJQXpQbZ.js +11 -0
- package/dist/field.js +211 -1
- package/dist/form.d.ts +3 -3
- package/dist/form.js +432 -1
- package/dist/{form.registry-DdLr3dbX.d.ts → form.registry-Cb8Pvoe8.d.ts} +2 -2
- package/dist/form.registry-CmpTny_s.js +51 -0
- package/dist/{index-BpcuNDMI.d.ts → index-B8JCdyld.d.ts} +13 -1
- package/dist/navigation-menu.d.ts +15 -0
- package/dist/navigation-menu.js +71 -0
- package/dist/number-input.d.ts +3 -3
- package/dist/number-input.js +55 -1
- package/dist/popover.d.ts +3 -3
- package/dist/popover.js +42 -1
- package/dist/radio-group.d.ts +3 -3
- package/dist/radio-group.js +67 -1
- package/dist/scroll-area.d.ts +1 -1
- package/dist/scroll-area.js +32 -1
- package/dist/select.d.ts +5 -5
- package/dist/select.js +84 -1
- package/dist/switch.d.ts +16 -0
- package/dist/switch.js +61 -0
- package/dist/tabs.d.ts +3 -3
- package/dist/tabs.js +33 -1
- package/dist/tooltip.d.ts +3 -3
- package/dist/tooltip.js +36 -1
- package/package.json +44 -22
- package/dist/Client-CygooKu8.js +0 -1
- package/dist/field.dom-etI2JxSW.js +0 -1
- package/dist/form.registry-Bv4jZGjo.js +0 -1
package/dist/checkbox.d.ts
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Machine, d as FieldMachine, u as FieldAwareComponent } from "./index-B8JCdyld.js";
|
|
2
2
|
import * as checkbox from "@zag-js/checkbox";
|
|
3
|
-
import * as _zag_js_types0 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_types0.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{
|
|
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";
|
|
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 {
|
|
2
|
-
export { Component, ComponentHydrationData, ComponentHydrator, ComponentInterface, FieldAwareComponent, Machine, getHydrationData, mergeProps, mount, normalizeProps, spreadProps, uid };
|
|
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 };
|
package/dist/client.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{
|
|
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";
|
|
2
|
+
|
|
3
|
+
export { Component, ComponentHydrator, FieldAwareComponent, Machine, getHydrationData, mergeProps, mount, mountControlled, normalizeProps, spreadProps, uid };
|
package/dist/clipboard.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Machine, f as Component } from "./index-B8JCdyld.js";
|
|
2
2
|
import * as clipboard from "@zag-js/clipboard";
|
|
3
|
-
import * as
|
|
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<
|
|
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{
|
|
1
|
+
import { a as Machine, p as Component, r as normalizeProps } from "./Client-C51NSHxg.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 };
|
package/dist/collapsible.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Machine, f as Component } from "./index-B8JCdyld.js";
|
|
2
2
|
import * as collapsible from "@zag-js/collapsible";
|
|
3
|
-
import * as
|
|
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<
|
|
9
|
+
initApi(): collapsible.Api<_$_zag_js_types0.PropTypes<{
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
}>>;
|
|
12
12
|
render(): void;
|
package/dist/collapsible.js
CHANGED
|
@@ -1 +1,28 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { a as Machine, p as Component, r as normalizeProps } from "./Client-C51NSHxg.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 {
|
|
1
|
+
import { a as Machine, f as Component } from "./index-B8JCdyld.js";
|
|
2
2
|
import * as dialog from "@zag-js/dialog";
|
|
3
|
-
import * as
|
|
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<
|
|
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{
|
|
1
|
+
import { a as Machine, p as Component, r as normalizeProps } from "./Client-C51NSHxg.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 {
|
|
2
|
-
import { FormMachine } from "./form.registry-
|
|
1
|
+
import { a as Machine, f as Component } from "./index-B8JCdyld.js";
|
|
2
|
+
import { n as FormMachine } from "./form.registry-Cb8Pvoe8.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
|
|
1
|
+
import { a as Machine, f as registerFieldMachine, p as Component, r as normalizeProps } from "./Client-C51NSHxg.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 {
|
|
2
|
-
import {
|
|
1
|
+
import { a as Machine, f as Component } from "./index-B8JCdyld.js";
|
|
2
|
+
import { t as FieldMachine } from "./form.registry-Cb8Pvoe8.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 {
|