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,58 +1,57 @@
1
- import { a as Machine, d as FieldAwareComponent, i as mergeProps, r as normalizeProps } from "./Client-C51NSHxg.js";
2
- 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";
3
2
  import * as numberInput from "@zag-js/number-input";
4
3
 
5
4
  //#region Resources/Private/Primitives/NumberInput/NumberInput.ts
5
+ registerClientPropConverters("numberInput", { formatOptions: (formatOptions) => formatOptions });
6
6
  var NumberInput = class extends FieldAwareComponent {
7
- static name = "number-input";
8
- propsWithField(props, fieldMachine) {
7
+ static componentName = "numberInput";
8
+ propsWithField(props, field) {
9
9
  return {
10
10
  ...props,
11
- disabled: props.disabled ?? fieldMachine.context.get("disabled"),
12
- readOnly: props.readOnly ?? fieldMachine.context.get("readOnly"),
13
- required: props.required ?? fieldMachine.context.get("required"),
14
- invalid: props.invalid ?? fieldMachine.context.get("invalid"),
15
- name: props.name ?? fieldMachine.prop("name"),
16
- ids: {
17
- ...props.ids,
18
- label: getLabelId(fieldMachine.scope),
19
- input: getControlId(fieldMachine.scope)
11
+ disabled: props.disabled ?? field.disabled,
12
+ readOnly: props.readOnly ?? field.readOnly,
13
+ required: props.required ?? field.required,
14
+ invalid: props.invalid ?? field.invalid,
15
+ name: props.name ?? field.name
16
+ };
17
+ }
18
+ transformProps(props) {
19
+ return {
20
+ ...props,
21
+ onValueChange: (details) => {
22
+ this.hydrator.query("input")?.dispatchEvent(new Event("input", { bubbles: true }));
23
+ props?.onValueChange?.(details);
20
24
  }
21
25
  };
22
26
  }
23
27
  initMachine(props) {
24
28
  props = this.withFieldProps(props);
25
- return new Machine(numberInput.machine, props);
29
+ const [machineProps] = numberInput.splitProps(props);
30
+ return new Machine(numberInput.machine, machineProps);
26
31
  }
27
32
  initApi() {
28
33
  return numberInput.connect(this.machine.service, normalizeProps);
29
34
  }
30
35
  render() {
31
36
  this.subscribeToFieldService();
32
- const rootEl = this.getElement("root");
37
+ const rootEl = this.hydrator.query("root");
33
38
  if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
34
- const labelEl = this.getElement("label");
39
+ const labelEl = this.hydrator.query("label");
35
40
  if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
36
- const controlEl = this.getElement("control");
41
+ const controlEl = this.hydrator.query("control");
37
42
  if (controlEl) this.spreadProps(controlEl, this.api.getControlProps());
38
- const inputEl = this.getElement("input");
43
+ const inputEl = this.hydrator.query("input");
39
44
  if (inputEl) {
40
- const mergedProps = mergeProps(this.api.getInputProps(), { "aria-describedby": this.fieldMachine?.context.get("describeIds") || void 0 });
45
+ const mergedProps = mergeProps(this.api.getInputProps(), { "aria-describedby": this.field?.ariaDescribedby });
41
46
  this.spreadProps(inputEl, mergedProps);
42
47
  }
43
- const incrementTriggerEl = this.getElement("increment-trigger");
44
- if (incrementTriggerEl) {
45
- const triggerProps = mergeProps(this.api.getIncrementTriggerProps(), { "aria-label": this.userProps?.translations?.incrementLabel || null });
46
- this.spreadProps(incrementTriggerEl, triggerProps);
47
- }
48
- const decrementTriggerEl = this.getElement("decrement-trigger");
49
- if (decrementTriggerEl) {
50
- const triggerProps = mergeProps(this.api.getDecrementTriggerProps(), { "aria-label": this.userProps?.translations?.decrementLabel || null });
51
- this.spreadProps(decrementTriggerEl, triggerProps);
52
- }
53
- const valueTextEl = this.getElement("value-text");
48
+ const incrementTriggerEl = this.hydrator.query("incrementTrigger");
49
+ if (incrementTriggerEl) this.spreadProps(incrementTriggerEl, this.api.getIncrementTriggerProps());
50
+ const decrementTriggerEl = this.hydrator.query("decrementTrigger");
51
+ if (decrementTriggerEl) this.spreadProps(decrementTriggerEl, this.api.getDecrementTriggerProps());
52
+ const valueTextEl = this.hydrator.query("valueText");
54
53
  if (valueTextEl) this.spreadProps(valueTextEl, this.api.getValueTextProps());
55
- const scrubberEl = this.getElement("scrubber");
54
+ const scrubberEl = this.hydrator.query("scrubber");
56
55
  if (scrubberEl) this.spreadProps(scrubberEl, this.api.getScrubberProps());
57
56
  }
58
57
  };
package/dist/popover.d.ts CHANGED
@@ -1,10 +1,18 @@
1
- import { a as Machine, f as Component } from "./index-B8JCdyld.js";
2
- import * as popover from "@zag-js/popover";
1
+ import { X as ConverterMachineProps, 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 popover from "@zag-js/popover";
4
4
 
5
5
  //#region Resources/Private/Primitives/Popover/Popover.d.ts
6
+ declare const popoverPropConverters: {
7
+ positioning: (positioning: popover.Props["positioning"]) => popover.PositioningOptions | undefined;
8
+ };
9
+ declare module 'fluid-primitives' {
10
+ interface HydrationPropsOverrides {
11
+ popover: ConverterMachineProps<typeof popoverPropConverters>;
12
+ }
13
+ }
6
14
  declare class Popover extends Component<popover.Props, popover.Api> {
7
- static name: string;
15
+ static componentName: string;
8
16
  initMachine(props: popover.Props): Machine<any>;
9
17
  initApi(): popover.Api<_$_zag_js_types0.PropTypes<{
10
18
  [x: string]: any;
package/dist/popover.js CHANGED
@@ -1,15 +1,17 @@
1
- import { a as Machine, i as mergeProps, p as Component, r as normalizeProps } from "./Client-C51NSHxg.js";
1
+ import { K as registerClientPropConverters, a as normalizeProps, at as Machine, rt as Component } from "./Client-HrMIqv7d.js";
2
2
  import * as popover from "@zag-js/popover";
3
3
 
4
4
  //#region Resources/Private/Primitives/Popover/Popover.ts
5
+ registerClientPropConverters("popover", { positioning: (positioning) => positioning });
5
6
  var Popover = class extends Component {
6
- static name = "popover";
7
+ static componentName = "popover";
7
8
  initMachine(props) {
9
+ const [machineProps] = popover.splitProps(props);
8
10
  return new Machine(popover.machine, {
9
- ...props,
11
+ ...machineProps,
10
12
  positioning: {
11
13
  gutter: 6,
12
- ...props.positioning
14
+ ...machineProps.positioning
13
15
  }
14
16
  });
15
17
  }
@@ -17,26 +19,23 @@ var Popover = class extends Component {
17
19
  return popover.connect(this.machine.service, normalizeProps);
18
20
  }
19
21
  render() {
20
- const triggerEl = this.getElement("trigger");
21
- if (triggerEl) this.spreadProps(triggerEl, this.api.getTriggerProps());
22
- const positionerEl = this.getElement("positioner");
22
+ this.spreadPropsByOptionalValue("trigger", ({ value }) => this.api.getTriggerProps({ value }));
23
+ const positionerEl = this.hydrator.query("positioner");
23
24
  if (positionerEl) this.spreadProps(positionerEl, this.api.getPositionerProps());
24
- const arrowEl = this.getElement("arrow");
25
+ const arrowEl = this.hydrator.query("arrow");
25
26
  if (arrowEl) this.spreadProps(arrowEl, this.api.getArrowProps());
26
- const arrowTipEl = this.getElement("arrow-tip");
27
+ const arrowTipEl = this.hydrator.query("arrowTip");
27
28
  if (arrowTipEl) this.spreadProps(arrowTipEl, this.api.getArrowTipProps());
28
- const contentEl = this.getElement("content");
29
+ const contentEl = this.hydrator.query("content");
29
30
  if (contentEl) this.spreadProps(contentEl, this.api.getContentProps());
30
- const titleEl = this.getElement("title");
31
+ const titleEl = this.hydrator.query("title");
31
32
  if (titleEl) this.spreadProps(titleEl, this.api.getTitleProps());
32
- const descriptionEl = this.getElement("description");
33
+ const descriptionEl = this.hydrator.query("description");
33
34
  if (descriptionEl) this.spreadProps(descriptionEl, this.api.getDescriptionProps());
34
- const closeTriggerEl = this.getElement("close-trigger");
35
- if (closeTriggerEl) {
36
- const closeTriggerProps = mergeProps(this.api.getCloseTriggerProps(), { "aria-label": this.userProps?.translations?.closeTriggerLabel || null });
37
- this.spreadProps(closeTriggerEl, closeTriggerProps);
38
- }
39
- const indicatorEl = this.getElement("indicator");
35
+ this.hydrator.queryAll("closeTrigger").forEach((closeTriggerEl) => {
36
+ this.spreadProps(closeTriggerEl, this.api.getCloseTriggerProps());
37
+ });
38
+ const indicatorEl = this.hydrator.query("indicator");
40
39
  if (indicatorEl) this.spreadProps(indicatorEl, this.api.getIndicatorProps());
41
40
  }
42
41
  };
@@ -1,11 +1,11 @@
1
- import { a as Machine, d as FieldMachine, u as FieldAwareComponent } from "./index-B8JCdyld.js";
2
- import * as radioGroup from "@zag-js/radio-group";
1
+ import { 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 radioGroup from "@zag-js/radio-group";
4
4
 
5
5
  //#region Resources/Private/Primitives/RadioGroup/RadioGroup.d.ts
6
6
  declare class RadioGroup extends FieldAwareComponent<radioGroup.Props, radioGroup.Api> {
7
- static name: string;
8
- propsWithField(props: radioGroup.Props, fieldMachine: FieldMachine): radioGroup.Props;
7
+ static componentName: string;
8
+ propsWithField(props: radioGroup.Props, field: FieldClientApi): radioGroup.Props;
9
9
  initMachine(props: radioGroup.Props): Machine<any>;
10
10
  initApi(): radioGroup.Api<_$_zag_js_types0.PropTypes<{
11
11
  [x: string]: any;
@@ -1,64 +1,57 @@
1
- import { a as Machine, d as FieldAwareComponent, i as mergeProps, r as normalizeProps } from "./Client-C51NSHxg.js";
1
+ import { a as normalizeProps, at as Machine, o as mergeProps, s as FieldAwareComponent } from "./Client-HrMIqv7d.js";
2
2
  import * as radioGroup from "@zag-js/radio-group";
3
3
 
4
4
  //#region Resources/Private/Primitives/RadioGroup/RadioGroup.ts
5
5
  var RadioGroup = class extends FieldAwareComponent {
6
- static name = "radio-group";
7
- propsWithField(props, fieldMachine) {
6
+ static componentName = "radioGroup";
7
+ propsWithField(props, field) {
8
8
  return {
9
9
  ...props,
10
- disabled: props.disabled ?? fieldMachine.context.get("disabled"),
11
- readOnly: props.readOnly ?? fieldMachine.context.get("readOnly"),
12
- required: props.required ?? fieldMachine.context.get("required"),
13
- invalid: props.invalid ?? fieldMachine.context.get("invalid"),
14
- name: props.name ?? fieldMachine.prop("name")
10
+ disabled: props.disabled ?? field.disabled,
11
+ readOnly: props.readOnly ?? field.readOnly,
12
+ required: props.required ?? field.required,
13
+ invalid: props.invalid ?? field.invalid,
14
+ name: props.name ?? field.name
15
15
  };
16
16
  }
17
17
  initMachine(props) {
18
18
  props = this.withFieldProps(props);
19
- return new Machine(radioGroup.machine, props);
19
+ const [machineProps] = radioGroup.splitProps(props);
20
+ return new Machine(radioGroup.machine, machineProps);
20
21
  }
21
22
  initApi() {
22
23
  return radioGroup.connect(this.machine.service, normalizeProps);
23
24
  }
24
25
  render() {
25
26
  this.subscribeToFieldService();
26
- const rootEl = this.getElement("root");
27
+ const rootEl = this.hydrator.query("root");
27
28
  if (rootEl) this.spreadProps(rootEl, mergeProps(this.api.getRootProps(), {
28
- "aria-invalid": this.fieldMachine?.context.get("invalid") || void 0,
29
- "aria-describedby": this.fieldMachine?.context.get("describeIds") || void 0
29
+ "aria-invalid": this.field?.invalid || void 0,
30
+ "aria-describedby": this.field?.ariaDescribedby
30
31
  }));
31
- const labelEl = this.getElement("label");
32
+ const labelEl = this.hydrator.query("label");
32
33
  if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
33
- this.getElements("item").forEach((itemEl) => {
34
- this.spreadProps(itemEl, this.api.getItemProps({
35
- value: itemEl.dataset.value,
36
- disabled: itemEl.getAttribute("data-disabled") === "true",
37
- invalid: itemEl.getAttribute("data-invalid") === "true"
38
- }));
39
- });
40
- this.getElements("item-text").forEach((itemTextEl) => {
41
- this.spreadProps(itemTextEl, this.api.getItemTextProps({
42
- value: itemTextEl.dataset.value,
43
- disabled: itemTextEl.getAttribute("data-disabled") === "true",
44
- invalid: itemTextEl.getAttribute("data-invalid") === "true"
45
- }));
46
- });
47
- this.getElements("item-control").forEach((itemControlEl) => {
48
- this.spreadProps(itemControlEl, this.api.getItemControlProps({
49
- value: itemControlEl.dataset.value,
50
- disabled: itemControlEl.getAttribute("data-disabled") === "true",
51
- invalid: itemControlEl.getAttribute("data-invalid") === "true"
52
- }));
53
- });
54
- this.getElements("item-hidden-input").forEach((itemHiddenInputEl) => {
55
- this.spreadProps(itemHiddenInputEl, this.api.getItemHiddenInputProps({
56
- value: itemHiddenInputEl.dataset.value,
57
- disabled: itemHiddenInputEl.getAttribute("data-disabled") === "true",
58
- invalid: itemHiddenInputEl.getAttribute("data-invalid") === "true"
59
- }));
60
- });
61
- const indicatorEl = this.getElement("indicator");
34
+ this.spreadPropsByValue("item", ({ el, value }) => this.api.getItemProps({
35
+ value,
36
+ disabled: el.hasAttribute("data-disabled"),
37
+ invalid: el.hasAttribute("data-invalid")
38
+ }));
39
+ this.spreadPropsByValue("itemText", ({ el, value }) => this.api.getItemTextProps({
40
+ value,
41
+ disabled: el.hasAttribute("data-disabled"),
42
+ invalid: el.hasAttribute("data-invalid")
43
+ }));
44
+ this.spreadPropsByValue("itemControl", ({ el, value }) => this.api.getItemControlProps({
45
+ value,
46
+ disabled: el.hasAttribute("data-disabled"),
47
+ invalid: el.hasAttribute("data-invalid")
48
+ }));
49
+ this.spreadPropsByValue("itemHiddenInput", ({ el, value }) => this.api.getItemHiddenInputProps({
50
+ value,
51
+ disabled: el.hasAttribute("data-disabled"),
52
+ invalid: el.hasAttribute("data-invalid")
53
+ }));
54
+ const indicatorEl = this.hydrator.query("indicator");
62
55
  if (indicatorEl) this.spreadProps(indicatorEl, this.api.getIndicatorProps());
63
56
  }
64
57
  };
@@ -1,10 +1,10 @@
1
- import { a as Machine, f as Component } from "./index-B8JCdyld.js";
2
- import * as scrollArea from "@zag-js/scroll-area";
1
+ import { c as Machine, z as Component } from "./index-B06gIN_k.js";
3
2
  import { PropTypes } from "@zag-js/types";
3
+ import * as scrollArea from "@zag-js/scroll-area";
4
4
 
5
5
  //#region Resources/Private/Primitives/ScrollArea/ScrollArea.d.ts
6
6
  declare class ScrollArea extends Component<scrollArea.Props, scrollArea.Api<PropTypes>> {
7
- static name: string;
7
+ static componentName: string;
8
8
  initMachine(props: scrollArea.Props): Machine<any>;
9
9
  initApi(): scrollArea.Api<PropTypes<{
10
10
  [x: string]: any;
@@ -1,28 +1,29 @@
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 scrollArea from "@zag-js/scroll-area";
3
3
 
4
4
  //#region Resources/Private/Primitives/ScrollArea/ScrollArea.ts
5
5
  var ScrollArea = class extends Component {
6
- static name = "scroll-area";
6
+ static componentName = "scrollArea";
7
7
  initMachine(props) {
8
- return new Machine(scrollArea.machine, props);
8
+ const [machineProps] = scrollArea.splitProps(props);
9
+ return new Machine(scrollArea.machine, machineProps);
9
10
  }
10
11
  initApi() {
11
12
  return scrollArea.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
- const viewportEl = this.getElement("viewport");
17
+ const viewportEl = this.hydrator.query("viewport");
17
18
  if (viewportEl) this.spreadProps(viewportEl, this.api.getViewportProps());
18
- const contentEl = this.getElement("content");
19
+ const contentEl = this.hydrator.query("content");
19
20
  if (contentEl) this.spreadProps(contentEl, this.api.getContentProps());
20
- this.getElements("scrollbar").forEach((scrollbarEl) => {
21
+ this.hydrator.queryAll("scrollbar").forEach((scrollbarEl) => {
21
22
  this.spreadProps(scrollbarEl, this.api.getScrollbarProps({ orientation: scrollbarEl.getAttribute("data-orientation") }));
22
23
  });
23
- const cornerEl = this.getElement("corner");
24
+ const cornerEl = this.hydrator.query("corner");
24
25
  if (cornerEl) this.spreadProps(cornerEl, this.api.getCornerProps());
25
- this.getElements("thumb").forEach((thumbEl) => {
26
+ this.hydrator.queryAll("thumb").forEach((thumbEl) => {
26
27
  this.spreadProps(thumbEl, this.api.getThumbProps({ orientation: thumbEl.getAttribute("data-orientation") }));
27
28
  });
28
29
  }
package/dist/select.d.ts CHANGED
@@ -1,59 +1,21 @@
1
- import { a as Machine, d as FieldMachine, u as FieldAwareComponent } from "./index-B8JCdyld.js";
1
+ import { X as ConverterMachineProps, b as FieldClientApi, c as Machine, h as getListCollectionFromHydrationData, y as FieldAwareComponent } from "./index-B06gIN_k.js";
2
2
  import * as _$_zag_js_collection0 from "@zag-js/collection";
3
- import * as select from "@zag-js/select";
4
3
  import * as _$_zag_js_types0 from "@zag-js/types";
4
+ import * as select from "@zag-js/select";
5
5
 
6
6
  //#region Resources/Private/Primitives/Select/Select.d.ts
7
+ declare const selectPropConverters: {
8
+ collection: (collection: Parameters<typeof getListCollectionFromHydrationData>[0]) => _$_zag_js_collection0.ListCollection<unknown>;
9
+ positioning: (positioning: select.Props["positioning"]) => select.PositioningOptions | undefined;
10
+ };
11
+ declare module 'fluid-primitives' {
12
+ interface HydrationPropsOverrides {
13
+ select: ConverterMachineProps<typeof selectPropConverters>;
14
+ }
15
+ }
7
16
  declare class Select extends FieldAwareComponent<select.Props, select.Api> {
8
- static name: string;
9
- propsWithField(props: select.Props, fieldMachine: FieldMachine): select.Props;
10
- transformProps(props: select.Props): {
11
- collection: _$_zag_js_collection0.ListCollection<any>;
12
- translations?: select.IntlTranslations | undefined;
13
- ids?: Partial<{
14
- root: string;
15
- content: string;
16
- control: string;
17
- trigger: string;
18
- clearTrigger: string;
19
- label: string;
20
- hiddenSelect: string;
21
- positioner: string;
22
- item: (id: string | number) => string;
23
- itemGroup: (id: string | number) => string;
24
- itemGroupLabel: (id: string | number) => string;
25
- }> | undefined;
26
- name?: string | undefined;
27
- form?: string | undefined;
28
- autoComplete?: string | undefined;
29
- disabled?: boolean | undefined;
30
- invalid?: boolean | undefined;
31
- readOnly?: boolean | undefined;
32
- required?: boolean | undefined;
33
- closeOnSelect?: boolean | undefined;
34
- onSelect?: ((details: select.SelectionDetails) => void) | undefined;
35
- onHighlightChange?: ((details: select.HighlightChangeDetails<any>) => void) | undefined;
36
- onValueChange?: ((details: select.ValueChangeDetails<any>) => void) | undefined;
37
- onOpenChange?: ((details: select.OpenChangeDetails) => void) | undefined;
38
- positioning?: select.PositioningOptions | undefined;
39
- value?: string[] | undefined;
40
- defaultValue?: string[] | undefined;
41
- highlightedValue?: string | null | undefined;
42
- defaultHighlightedValue?: string | null | undefined;
43
- loopFocus?: boolean | undefined;
44
- multiple?: boolean | undefined;
45
- open?: boolean | undefined;
46
- defaultOpen?: boolean | undefined;
47
- scrollToIndexFn?: ((details: select.ScrollToIndexDetails) => void) | undefined;
48
- composite?: boolean | undefined;
49
- deselectable?: boolean | undefined;
50
- dir?: "ltr" | "rtl" | undefined;
51
- id: string;
52
- getRootNode?: (() => ShadowRoot | Document | Node) | undefined;
53
- onPointerDownOutside?: ((event: select.PointerDownOutsideEvent) => void) | undefined;
54
- onFocusOutside?: ((event: select.FocusOutsideEvent) => void) | undefined;
55
- onInteractOutside?: ((event: select.InteractOutsideEvent) => void) | undefined;
56
- };
17
+ static componentName: string;
18
+ propsWithField(props: select.Props, field: FieldClientApi): select.Props;
57
19
  initMachine(props: select.Props): Machine<any>;
58
20
  initApi(): select.Api<_$_zag_js_types0.PropTypes<{
59
21
  [x: string]: any;
package/dist/select.js CHANGED
@@ -1,84 +1,91 @@
1
- import { a as Machine, c as getListCollectionFromHydrationData, d as FieldAwareComponent, i as mergeProps, r as normalizeProps } from "./Client-C51NSHxg.js";
2
- import { a as getLabelId, t as getControlId } from "./field.dom-CJQXpQbZ.js";
1
+ import { $ as getListCollectionFromHydrationData, K as registerClientPropConverters, a as normalizeProps, at as Machine, o as mergeProps, s as FieldAwareComponent } from "./Client-HrMIqv7d.js";
3
2
  import * as select from "@zag-js/select";
4
3
 
5
4
  //#region Resources/Private/Primitives/Select/Select.ts
5
+ registerClientPropConverters("select", {
6
+ collection: (collection) => getListCollectionFromHydrationData(collection),
7
+ positioning: (positioning) => positioning
8
+ });
6
9
  var Select = class extends FieldAwareComponent {
7
- static name = "select";
8
- propsWithField(props, fieldMachine) {
10
+ static componentName = "select";
11
+ propsWithField(props, field) {
9
12
  return {
10
13
  ...props,
11
- disabled: props.disabled ?? fieldMachine.context.get("disabled"),
12
- readOnly: props.readOnly ?? fieldMachine.context.get("readOnly"),
13
- required: props.required ?? fieldMachine.context.get("required"),
14
- invalid: props.invalid ?? fieldMachine.context.get("invalid"),
15
- name: props.name ?? fieldMachine.prop("name"),
16
- ids: {
17
- ...props.ids,
18
- label: getLabelId(fieldMachine.scope),
19
- hiddenSelect: getControlId(fieldMachine.scope)
20
- }
21
- };
22
- }
23
- transformProps(props) {
24
- return {
25
- ...props,
26
- get collection() {
27
- return getListCollectionFromHydrationData(props.collection);
28
- }
14
+ disabled: props.disabled ?? field.disabled,
15
+ readOnly: props.readOnly ?? field.readOnly,
16
+ required: props.required ?? field.required,
17
+ invalid: props.invalid ?? field.invalid,
18
+ name: props.name ?? field.name
29
19
  };
30
20
  }
31
21
  initMachine(props) {
32
- props = this.withFieldProps(props);
33
- return new Machine(select.machine, this.transformProps(props));
22
+ const [machineProps] = select.splitProps(this.withFieldProps(props));
23
+ return new Machine(select.machine, machineProps);
34
24
  }
35
25
  initApi() {
36
26
  return select.connect(this.machine.service, normalizeProps);
37
27
  }
38
28
  render = () => {
39
29
  this.subscribeToFieldService();
40
- const rootEl = this.getElement("root");
30
+ const rootEl = this.hydrator.query("root");
41
31
  if (rootEl) this.spreadProps(rootEl, this.api.getRootProps());
42
- const controlEl = this.getElement("control");
32
+ const controlEl = this.hydrator.query("control");
43
33
  if (controlEl) this.spreadProps(controlEl, this.api.getControlProps());
44
- const hiddenSelectEl = this.getElement("hidden-select");
34
+ const hiddenSelectEl = this.hydrator.query("hiddenSelect");
45
35
  if (hiddenSelectEl) {
46
- const mergedProps = mergeProps(this.api.getHiddenSelectProps(), { "aria-describedby": this.fieldMachine?.context.get("describeIds") || void 0 });
47
- this.spreadProps(hiddenSelectEl, mergedProps);
36
+ this.spreadProps(hiddenSelectEl, this.api.getHiddenSelectProps());
37
+ const isValueEmpty = this.api.value.length === 0;
38
+ const defaultOption = hiddenSelectEl.querySelector("option");
39
+ if (defaultOption) defaultOption.selected = isValueEmpty;
48
40
  }
49
- const labelEl = this.getElement("label");
41
+ const labelEl = this.hydrator.query("label");
50
42
  if (labelEl) this.spreadProps(labelEl, this.api.getLabelProps());
51
- const triggerEl = this.getElement("trigger");
52
- if (triggerEl) this.spreadProps(triggerEl, this.api.getTriggerProps());
53
- const positionerEl = this.getElement("positioner");
43
+ const triggerEl = this.hydrator.query("trigger");
44
+ if (triggerEl) {
45
+ const mergedProps = mergeProps(this.api.getTriggerProps(), { "aria-describedby": this.field?.ariaDescribedby });
46
+ this.spreadProps(triggerEl, mergedProps);
47
+ }
48
+ const positionerEl = this.hydrator.query("positioner");
54
49
  if (positionerEl) this.spreadProps(positionerEl, this.api.getPositionerProps());
55
- const contentEl = this.getElement("content");
50
+ const contentEl = this.hydrator.query("content");
56
51
  if (contentEl) this.spreadProps(contentEl, this.api.getContentProps());
57
- const valueTextEl = this.getElement("value-text");
58
- if (valueTextEl) this.spreadProps(valueTextEl, mergeProps(this.api.getValueTextProps(), { children: this.api.valueAsString || valueTextEl.dataset.placeholder }));
59
- this.getElements("item-group").forEach((itemGroupEl) => {
60
- this.spreadProps(itemGroupEl, this.api.getItemGroupProps({ id: itemGroupEl.dataset.id }));
61
- const itemGroupLabelEl = this.getElement("item-group-label", itemGroupEl);
62
- if (itemGroupLabelEl) this.spreadProps(itemGroupLabelEl, this.api.getItemGroupLabelProps({ htmlFor: itemGroupEl.dataset.id }));
52
+ const listEl = this.hydrator.query("list");
53
+ if (listEl) this.spreadProps(listEl, this.api.getListProps());
54
+ const valueTextEl = this.hydrator.query("valueText");
55
+ if (valueTextEl) {
56
+ const currentText = valueTextEl.textContent || valueTextEl.dataset.placeholder || "";
57
+ const nextValue = this.api.valueAsString || valueTextEl.dataset.placeholder || "";
58
+ this.spreadProps(valueTextEl, mergeProps(this.api.getValueTextProps(), { children: nextValue }));
59
+ if (nextValue !== currentText) queueMicrotask(() => {
60
+ const el = this.hydrator.query("valueText");
61
+ if (el?.isConnected) {
62
+ const next = el.cloneNode(true);
63
+ el.replaceWith(next);
64
+ next.replaceWith(el);
65
+ }
66
+ });
67
+ }
68
+ this.spreadPropsByValue("itemGroup", ({ value }) => {
69
+ return this.api.getItemGroupProps({ id: value });
63
70
  });
64
- this.getElements("item").forEach((itemEl) => {
65
- const item = this.api.collection.find(itemEl.dataset.value);
66
- if (item) this.spreadProps(itemEl, this.api.getItemProps({ item }));
71
+ this.spreadPropsByValue("itemGroupLabel", ({ value }) => {
72
+ return this.api.getItemGroupLabelProps({ htmlFor: value });
67
73
  });
68
- this.getElements("item-text").forEach((itemTextEl) => {
69
- const item = this.api.collection.find(itemTextEl.dataset.value);
70
- if (item) this.spreadProps(itemTextEl, this.api.getItemTextProps({ item }));
74
+ this.spreadPropsByValue("item", ({ value }) => {
75
+ const item = this.api.collection.find(value);
76
+ return item ? this.api.getItemProps({ item }) : null;
71
77
  });
72
- this.getElements("item-indicator").forEach((itemIndicatorEl) => {
73
- const item = this.api.collection.find(itemIndicatorEl.dataset.value);
74
- if (item) this.spreadProps(itemIndicatorEl, this.api.getItemIndicatorProps({ item }));
78
+ this.spreadPropsByValue("itemText", ({ value }) => {
79
+ const item = this.api.collection.find(value);
80
+ return item ? this.api.getItemTextProps({ item }) : null;
75
81
  });
76
- const clearTriggerEl = this.getElement("clear-trigger");
77
- if (clearTriggerEl) {
78
- const clearTriggerProps = mergeProps(this.api.getClearTriggerProps(), { "aria-label": this.userProps?.translations?.clearTriggerLabel || null });
79
- this.spreadProps(clearTriggerEl, clearTriggerProps);
80
- }
81
- const indicatorEl = this.getElement("indicator");
82
+ this.spreadPropsByValue("itemIndicator", ({ value }) => {
83
+ const item = this.api.collection.find(value);
84
+ return item ? this.api.getItemIndicatorProps({ item }) : null;
85
+ });
86
+ const clearTriggerEl = this.hydrator.query("clearTrigger");
87
+ if (clearTriggerEl) this.spreadProps(clearTriggerEl, this.api.getClearTriggerProps());
88
+ const indicatorEl = this.hydrator.query("indicator");
82
89
  if (indicatorEl) this.spreadProps(indicatorEl, this.api.getIndicatorProps());
83
90
  };
84
91
  };
@@ -0,0 +1,27 @@
1
+ import { X as ConverterMachineProps, b as FieldClientApi, c as Machine, y as FieldAwareComponent } from "./index-B06gIN_k.js";
2
+ import * as _$_zag_js_types0 from "@zag-js/types";
3
+ import * as slider from "@zag-js/slider";
4
+
5
+ //#region Resources/Private/Primitives/Slider/Slider.d.ts
6
+ declare const sliderPropConverters: {
7
+ thumbSize: (thumbSize: slider.Props["thumbSize"]) => {
8
+ width: number;
9
+ height: number;
10
+ } | undefined;
11
+ };
12
+ declare module 'fluid-primitives' {
13
+ interface HydrationPropsOverrides {
14
+ slider: ConverterMachineProps<typeof sliderPropConverters>;
15
+ }
16
+ }
17
+ declare class Slider extends FieldAwareComponent<slider.Props, slider.Api> {
18
+ static componentName: string;
19
+ propsWithField(props: slider.Props, field: FieldClientApi): slider.Props;
20
+ initMachine(props: slider.Props): Machine<any>;
21
+ initApi(): slider.Api<_$_zag_js_types0.PropTypes<{
22
+ [x: string]: any;
23
+ }>>;
24
+ render(): void;
25
+ }
26
+ //#endregion
27
+ export { Slider };