@xds/solid 1.0.1 → 1.1.0

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 (128) hide show
  1. package/dist/dom/Accordion.js +3 -2
  2. package/dist/dom/Avatar.js +17 -13
  3. package/dist/dom/AvatarStack.js +17 -13
  4. package/dist/dom/Badge.js +12 -10
  5. package/dist/dom/Banner.js +25 -15
  6. package/dist/dom/Button.js +10 -3
  7. package/dist/dom/Card.js +31 -26
  8. package/dist/dom/Checkbox.js +49 -24
  9. package/dist/dom/Chip.js +21 -17
  10. package/dist/dom/ChipBar.js +17 -13
  11. package/dist/dom/CountBadge.js +28 -23
  12. package/dist/dom/DatePicker.js +13 -7
  13. package/dist/dom/DateRangePicker.js +16 -10
  14. package/dist/dom/Dialog.js +3 -2
  15. package/dist/dom/Divider.js +12 -10
  16. package/dist/dom/EmptyState.js +14 -11
  17. package/dist/dom/Icon.js +30 -19
  18. package/dist/dom/IconButton.js +10 -3
  19. package/dist/dom/Labels.js +26 -0
  20. package/dist/dom/ListRow.js +34 -28
  21. package/dist/dom/MediaCard.js +32 -23
  22. package/dist/dom/Menu.js +3 -1
  23. package/dist/dom/ProgressBar.js +27 -15
  24. package/dist/dom/RadioGroup.js +44 -23
  25. package/dist/dom/SearchField.js +58 -32
  26. package/dist/dom/SectionHeader.js +17 -10
  27. package/dist/dom/SegmentedControl.js +33 -19
  28. package/dist/dom/Select.js +18 -5
  29. package/dist/dom/Sidebar.js +17 -13
  30. package/dist/dom/Skeleton.js +15 -13
  31. package/dist/dom/Slider.js +15 -7
  32. package/dist/dom/Spinner.js +23 -17
  33. package/dist/dom/Switch.js +49 -24
  34. package/dist/dom/Tabs.js +16 -6
  35. package/dist/dom/Text.js +6 -3
  36. package/dist/dom/TextField.js +37 -19
  37. package/dist/dom/Thumbnail.js +21 -14
  38. package/dist/dom/Toast.js +19 -20
  39. package/dist/dom/Tooltip.js +10 -6
  40. package/dist/dom/controllable.js +44 -0
  41. package/dist/dom/index.js +2 -1
  42. package/dist/dom/preview.js +2 -0
  43. package/dist/dom/root.js +16 -4
  44. package/dist/dom/trigger.js +5 -3
  45. package/dist/source/Accordion.jsx +3 -2
  46. package/dist/source/Avatar.d.ts +1 -1
  47. package/dist/source/Avatar.jsx +2 -1
  48. package/dist/source/AvatarStack.d.ts +1 -1
  49. package/dist/source/AvatarStack.jsx +2 -1
  50. package/dist/source/Badge.d.ts +1 -1
  51. package/dist/source/Badge.jsx +2 -1
  52. package/dist/source/Banner.d.ts +1 -1
  53. package/dist/source/Banner.jsx +5 -2
  54. package/dist/source/Button.d.ts +5 -1
  55. package/dist/source/Button.jsx +5 -2
  56. package/dist/source/Card.d.ts +1 -1
  57. package/dist/source/Card.jsx +3 -2
  58. package/dist/source/Checkbox.d.ts +10 -4
  59. package/dist/source/Checkbox.jsx +18 -6
  60. package/dist/source/Chip.d.ts +1 -1
  61. package/dist/source/Chip.jsx +2 -1
  62. package/dist/source/ChipBar.d.ts +1 -1
  63. package/dist/source/ChipBar.jsx +2 -1
  64. package/dist/source/CountBadge.d.ts +1 -1
  65. package/dist/source/CountBadge.jsx +3 -2
  66. package/dist/source/DatePicker.jsx +13 -7
  67. package/dist/source/DateRangePicker.jsx +16 -10
  68. package/dist/source/Dialog.jsx +3 -2
  69. package/dist/source/Divider.d.ts +1 -1
  70. package/dist/source/Divider.jsx +2 -1
  71. package/dist/source/EmptyState.d.ts +1 -1
  72. package/dist/source/EmptyState.jsx +2 -1
  73. package/dist/source/Icon.d.ts +1 -1
  74. package/dist/source/Icon.jsx +2 -1
  75. package/dist/source/IconButton.d.ts +5 -1
  76. package/dist/source/IconButton.jsx +5 -2
  77. package/dist/source/Labels.d.ts +17 -0
  78. package/dist/source/Labels.jsx +11 -0
  79. package/dist/source/ListRow.d.ts +1 -1
  80. package/dist/source/ListRow.jsx +3 -2
  81. package/dist/source/MediaCard.d.ts +1 -1
  82. package/dist/source/MediaCard.jsx +3 -2
  83. package/dist/source/Menu.d.ts +1 -1
  84. package/dist/source/Menu.jsx +3 -1
  85. package/dist/source/ProgressBar.d.ts +1 -1
  86. package/dist/source/ProgressBar.jsx +2 -1
  87. package/dist/source/RadioGroup.d.ts +5 -2
  88. package/dist/source/RadioGroup.jsx +18 -5
  89. package/dist/source/SearchField.d.ts +11 -3
  90. package/dist/source/SearchField.jsx +26 -12
  91. package/dist/source/SectionHeader.d.ts +1 -1
  92. package/dist/source/SectionHeader.jsx +2 -1
  93. package/dist/source/SegmentedControl.d.ts +4 -3
  94. package/dist/source/SegmentedControl.jsx +16 -5
  95. package/dist/source/Select.d.ts +4 -1
  96. package/dist/source/Select.jsx +16 -5
  97. package/dist/source/Sidebar.d.ts +1 -1
  98. package/dist/source/Sidebar.jsx +2 -1
  99. package/dist/source/Skeleton.jsx +2 -2
  100. package/dist/source/Slider.d.ts +2 -2
  101. package/dist/source/Slider.jsx +14 -6
  102. package/dist/source/Spinner.d.ts +1 -1
  103. package/dist/source/Spinner.jsx +2 -1
  104. package/dist/source/Switch.d.ts +10 -4
  105. package/dist/source/Switch.jsx +18 -6
  106. package/dist/source/Tabs.d.ts +2 -2
  107. package/dist/source/Tabs.jsx +16 -5
  108. package/dist/source/Text.d.ts +1 -1
  109. package/dist/source/Text.jsx +2 -1
  110. package/dist/source/TextField.d.ts +12 -3
  111. package/dist/source/TextField.jsx +24 -9
  112. package/dist/source/Thumbnail.d.ts +1 -1
  113. package/dist/source/Thumbnail.jsx +2 -1
  114. package/dist/source/Toast.d.ts +1 -1
  115. package/dist/source/Toast.jsx +2 -1
  116. package/dist/source/Tooltip.jsx +4 -3
  117. package/dist/source/controllable.d.ts +30 -0
  118. package/dist/source/controllable.js +30 -0
  119. package/dist/source/index.d.ts +1 -0
  120. package/dist/source/index.js +1 -0
  121. package/dist/source/preview.jsx +2 -1
  122. package/dist/source/root.d.ts +14 -4
  123. package/dist/source/root.js +7 -2
  124. package/dist/source/trigger.d.ts +4 -2
  125. package/dist/source/trigger.js +2 -2
  126. package/package.json +3 -3
  127. package/styles.css +4 -0
  128. package/tailwind.css +1 -1
@@ -1,5 +1,5 @@
1
1
  import { Icon } from "./Icon.js";
2
- import { withStyle } from "./root.js";
2
+ import { rootAttributes, withStyle } from "./root.js";
3
3
  import { className, createComponent, effect, insert, readShallow, ref, spread, template } from "@solidjs/web";
4
4
  import { ACCORDION_PARTS, classes, focusTitleOnClick, setPanelOpen } from "@xds/core";
5
5
  import * as accordion from "@zag-js/accordion";
@@ -22,6 +22,7 @@ function Accordion(props) {
22
22
  const id = createUniqueId();
23
23
  const service = useMachine(accordion.machine, () => ({
24
24
  id,
25
+ ids: { root: props.id },
25
26
  value: [...props.expanded],
26
27
  onValueChange: (details) => props.onChange(details.value),
27
28
  multiple: props.multiple ?? false,
@@ -29,7 +30,7 @@ function Accordion(props) {
29
30
  hiddenUntilFound: true
30
31
  }));
31
32
  const api = createMemo(() => accordion.connect(service, normalizeProps));
32
- const root = withStyle(() => api().getRootProps(), () => props.style);
33
+ const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
33
34
  const body = (value) => {
34
35
  const { hidden: _hidden, ...attributes } = api().getItemContentProps({ value });
35
36
  return attributes;
@@ -1,10 +1,11 @@
1
1
  import { useDefaults } from "./Defaults.js";
2
2
  import { createPicture } from "./picture.js";
3
- import { className, createComponent, effect, insert, memo, readShallow, ref, setAttribute, style, template } from "@solidjs/web";
3
+ import { rootAttributes } from "./root.js";
4
+ import { className, createComponent, effect, insert, memo, readShallow, ref, setAttribute, spread, template } from "@solidjs/web";
4
5
  import { avatarClass, avatarInitials, classes, pictureClass, rootPart } from "@xds/core";
5
6
  import { Show } from "solid-js";
6
7
  // packages/ui-solid/src/Avatar.tsx
7
- var _tmpl$ = /* @__PURE__ */ template(`<span role=img><!><!>`);
8
+ var _tmpl$ = /* @__PURE__ */ template(`<span><!><!>`);
8
9
  var _tmpl$2 = /* @__PURE__ */ template(`<img alt aria-hidden=true>`);
9
10
  var ROOT = rootPart("Avatar");
10
11
  /**
@@ -18,6 +19,20 @@ function Avatar(props) {
18
19
  var _el$ = _tmpl$();
19
20
  var _el$2 = _el$.firstChild;
20
21
  var _el$3 = _el$2.nextSibling;
22
+ spread(_el$, [() => {
23
+ return rootAttributes(props);
24
+ }, {
25
+ role: "img",
26
+ get "aria-label"() {
27
+ return props.name;
28
+ },
29
+ get "class"() {
30
+ return classes(ROOT, avatarClass(size()), props.class);
31
+ },
32
+ get style() {
33
+ return props.style;
34
+ }
35
+ }], true);
21
36
  insert(_el$, () => {
22
37
  return avatarInitials(props.name, size());
23
38
  }, _el$2);
@@ -46,17 +61,6 @@ function Avatar(props) {
46
61
  return _el$4;
47
62
  })()
48
63
  }), _el$3);
49
- effect(() => {
50
- return {
51
- e: props.name,
52
- t: readShallow(classes(ROOT, avatarClass(size()), props.class)),
53
- a: readShallow(props.style)
54
- };
55
- }, ({ e, t, a }, _p$) => {
56
- e !== _p$?.e && setAttribute(_el$, "aria-label", e);
57
- className(_el$, t, _p$?.t);
58
- style(_el$, a, _p$?.a);
59
- });
60
64
  return _el$;
61
65
  }
62
66
  export { Avatar };
@@ -1,11 +1,12 @@
1
1
  import { Avatar } from "./Avatar.js";
2
2
  import { useDefaults } from "./Defaults.js";
3
- import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
3
+ import { rootAttributes } from "./root.js";
4
+ import { className, createComponent, effect, insert, readShallow, spread, template } from "@solidjs/web";
4
5
  import { avatarStack, avatarStackClass, avatarStackItemClass, avatarStackRestClass, classes, rootPart } from "@xds/core";
5
6
  import { For, Show, createMemo } from "solid-js";
6
7
  // packages/ui-solid/src/AvatarStack.tsx
7
8
  var _tmpl$ = /* @__PURE__ */ template(`<span aria-hidden=true>+`);
8
- var _tmpl$2 = /* @__PURE__ */ template(`<span role=img><!><!>`);
9
+ var _tmpl$2 = /* @__PURE__ */ template(`<span><!><!>`);
9
10
  var _tmpl$3 = /* @__PURE__ */ template(`<span aria-hidden=true>`);
10
11
  var ROOT = rootPart("AvatarStack");
11
12
  /**
@@ -19,6 +20,20 @@ function AvatarStack(props) {
19
20
  var _el$ = _tmpl$2();
20
21
  var _el$2 = _el$.firstChild;
21
22
  var _el$5 = _el$2.nextSibling;
23
+ spread(_el$, [() => {
24
+ return rootAttributes(props);
25
+ }, {
26
+ role: "img",
27
+ get "aria-label"() {
28
+ return stack().name;
29
+ },
30
+ get "class"() {
31
+ return classes(ROOT, avatarStackClass, props.class);
32
+ },
33
+ get style() {
34
+ return props.style;
35
+ }
36
+ }], true);
22
37
  insert(_el$, createComponent(For, {
23
38
  get each() {
24
39
  return stack().shown;
@@ -58,17 +73,6 @@ function AvatarStack(props) {
58
73
  return _el$3;
59
74
  }
60
75
  }), _el$5);
61
- effect(() => {
62
- return {
63
- e: stack().name,
64
- t: readShallow(classes(ROOT, avatarStackClass, props.class)),
65
- a: readShallow(props.style)
66
- };
67
- }, ({ e, t, a }, _p$) => {
68
- e !== _p$?.e && setAttribute(_el$, "aria-label", e);
69
- className(_el$, t, _p$?.t);
70
- style(_el$, a, _p$?.a);
71
- });
72
76
  return _el$;
73
77
  }
74
78
  export { AvatarStack };
package/dist/dom/Badge.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { useDefaults } from "./Defaults.js";
2
2
  import { Icon } from "./Icon.js";
3
- import { className, createComponent, effect, insert, readShallow, style, template } from "@solidjs/web";
3
+ import { rootAttributes } from "./root.js";
4
+ import { className, createComponent, effect, insert, readShallow, spread, template } from "@solidjs/web";
4
5
  import { badgeClass, badgeDotClass, classes, rootPart } from "@xds/core";
5
6
  import { Show } from "solid-js";
6
7
  // packages/ui-solid/src/Badge.tsx
@@ -18,6 +19,16 @@ function Badge(props) {
18
19
  var _el$3 = _el$.firstChild;
19
20
  var _el$4 = _el$3.nextSibling;
20
21
  var _el$5 = _el$4.nextSibling;
22
+ spread(_el$, [() => {
23
+ return rootAttributes(props);
24
+ }, {
25
+ get "class"() {
26
+ return classes(ROOT, badgeClass(props.tone ?? defaults().tone), props.class);
27
+ },
28
+ get style() {
29
+ return props.style;
30
+ }
31
+ }], true);
21
32
  insert(_el$, createComponent(Show, {
22
33
  get when() {
23
34
  return props.dot;
@@ -44,15 +55,6 @@ function Badge(props) {
44
55
  insert(_el$, () => {
45
56
  return props.children;
46
57
  }, _el$5);
47
- effect(() => {
48
- return {
49
- e: readShallow(classes(ROOT, badgeClass(props.tone ?? defaults().tone), props.class)),
50
- t: readShallow(props.style)
51
- };
52
- }, ({ e, t }, _p$) => {
53
- className(_el$, e, _p$?.e);
54
- style(_el$, t, _p$?.t);
55
- });
56
58
  return _el$;
57
59
  }
58
60
  export { Badge };
@@ -1,7 +1,9 @@
1
1
  import { Button } from "./Button.js";
2
2
  import { useDefaults } from "./Defaults.js";
3
3
  import { IconButton } from "./IconButton.js";
4
- import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
4
+ import { useLabels } from "./Labels.js";
5
+ import { rootAttributes } from "./root.js";
6
+ import { className, createComponent, effect, insert, readShallow, setAttribute, spread, template } from "@solidjs/web";
5
7
  import { BANNER_PARTS, bannerClass, bannerIconClass, bannerIconPath, bannerRole, classes, rootPart } from "@xds/core";
6
8
  import { Show } from "solid-js";
7
9
  // packages/ui-solid/src/Banner.tsx
@@ -16,6 +18,7 @@ var ROOT = rootPart("Banner");
16
18
  */
17
19
  function Banner(props) {
18
20
  const defaults = useDefaults("Banner");
21
+ const labels = useLabels();
19
22
  const tone = () => props.tone ?? defaults().tone;
20
23
  var _el$ = _tmpl$2();
21
24
  var _el$2 = _el$.firstChild;
@@ -23,6 +26,19 @@ function Banner(props) {
23
26
  var _el$4 = _el$2.nextSibling;
24
27
  var _el$5 = _el$4.firstChild;
25
28
  var _el$6 = _el$5.nextSibling;
29
+ spread(_el$, [() => {
30
+ return rootAttributes(props);
31
+ }, {
32
+ get role() {
33
+ return bannerRole(tone());
34
+ },
35
+ get "class"() {
36
+ return classes(ROOT, bannerClass(tone()), props.class);
37
+ },
38
+ get style() {
39
+ return props.style;
40
+ }
41
+ }], true);
26
42
  insert(_el$4, createComponent(Show, {
27
43
  get when() {
28
44
  return props.title;
@@ -68,7 +84,7 @@ function Banner(props) {
68
84
  insert(_el$7, createComponent(IconButton, {
69
85
  icon: "x",
70
86
  get label() {
71
- return props.dismissLabel ?? "Dismiss";
87
+ return props.dismissLabel ?? labels().dismiss;
72
88
  },
73
89
  variant: "ghost",
74
90
  size: "sm",
@@ -82,20 +98,14 @@ function Banner(props) {
82
98
  }), null);
83
99
  effect(() => {
84
100
  return {
85
- e: bannerRole(tone()),
86
- t: readShallow(classes(ROOT, bannerClass(tone()), props.class)),
87
- a: readShallow(props.style),
88
- o: readShallow(bannerIconClass(tone())),
89
- i: bannerIconPath(tone()),
90
- n: readShallow(BANNER_PARTS.body)
101
+ e: readShallow(bannerIconClass(tone())),
102
+ t: bannerIconPath(tone()),
103
+ a: readShallow(BANNER_PARTS.body)
91
104
  };
92
- }, ({ e, t, a, o, i, n }, _p$) => {
93
- e !== _p$?.e && setAttribute(_el$, "role", e);
94
- className(_el$, t, _p$?.t);
95
- style(_el$, a, _p$?.a);
96
- className(_el$2, o, _p$?.o);
97
- i !== _p$?.i && setAttribute(_el$3, "d", i);
98
- className(_el$4, n, _p$?.n);
105
+ }, ({ e, t, a }, _p$) => {
106
+ className(_el$2, e, _p$?.e);
107
+ t !== _p$?.t && setAttribute(_el$3, "d", t);
108
+ className(_el$4, a, _p$?.a);
99
109
  });
100
110
  return _el$;
101
111
  }
@@ -1,8 +1,9 @@
1
1
  import { useDefaults } from "./Defaults.js";
2
2
  import { Icon } from "./Icon.js";
3
+ import { rootAttributes } from "./root.js";
3
4
  import { Spinner } from "./Spinner.js";
4
5
  import { withTrigger } from "./trigger.js";
5
- import { className, createComponent, effect, insert, memo, readShallow, spread, template } from "@solidjs/web";
6
+ import { className, createComponent, effect, insert, memo, readShallow, ref, spread, template } from "@solidjs/web";
6
7
  import { BUTTON_ICON, buttonClass, classes, isHeld } from "@xds/core";
7
8
  import { Show, children, createMemo } from "solid-js";
8
9
  // packages/ui-solid/src/Button.tsx
@@ -43,14 +44,20 @@ function Button(props) {
43
44
  return;
44
45
  }
45
46
  props.onPress?.();
46
- }
47
- })), () => props.loading === true);
47
+ },
48
+ onFocus: (event) => props.onFocus?.(event),
49
+ onBlur: (event) => props.onBlur?.(event)
50
+ })), () => props.loading === true, rootAttributes(props));
48
51
  var _el$ = _tmpl$2();
49
52
  var _el$3 = _el$.firstChild;
50
53
  var _el$4 = _el$3.nextSibling;
51
54
  var _el$5 = _el$4.nextSibling;
52
55
  var _el$6 = _el$5.nextSibling;
53
56
  spread(_el$, attributes, true);
57
+ var _ref$ = props.ref;
58
+ typeof _ref$ === "function" || Array.isArray(_ref$) ? ref(() => {
59
+ return _ref$;
60
+ }, _el$) : props.ref = _el$;
54
61
  insert(_el$, createComponent(Show, {
55
62
  get when() {
56
63
  return props.loading;
package/dist/dom/Card.js CHANGED
@@ -1,9 +1,10 @@
1
- import { className, createComponent, delegateEvents, dynamic, effect, insert, memo, readShallow, setAttribute, style, template } from "@solidjs/web";
1
+ import { rootAttributes } from "./root.js";
2
+ import { className, createComponent, dynamic, effect, insert, memo, readShallow, spread, template } from "@solidjs/web";
2
3
  import { CARD_PARTS, cardClass, cardMediaClass, classes, rootPart } from "@xds/core";
3
4
  import { Show, children } from "solid-js";
4
5
  // packages/ui-solid/src/Card.tsx
5
6
  var _tmpl$ = /* @__PURE__ */ template(`<div>`);
6
- var _tmpl$2 = /* @__PURE__ */ template(`<button type=button>`);
7
+ var _tmpl$2 = /* @__PURE__ */ template(`<button>`);
7
8
  var _tmpl$3 = /* @__PURE__ */ template(`<section>`);
8
9
  var ROOT = rootPart("Card");
9
10
  /**
@@ -127,38 +128,42 @@ function Card(props) {
127
128
  },
128
129
  get fallback() {
129
130
  var _el$3 = _tmpl$3();
131
+ spread(_el$3, [() => {
132
+ return rootAttributes(props);
133
+ }, {
134
+ get "aria-current"() {
135
+ return props.selected ? "true" : void 0;
136
+ },
137
+ get "class"() {
138
+ return surface();
139
+ },
140
+ get style() {
141
+ return props.style;
142
+ }
143
+ }], true);
130
144
  insert(_el$3, content);
131
- effect(() => {
132
- return {
133
- e: props.selected ? "true" : void 0,
134
- t: readShallow(surface()),
135
- a: readShallow(props.style)
136
- };
137
- }, ({ e, t, a }, _p$) => {
138
- e !== _p$?.e && setAttribute(_el$3, "aria-current", e);
139
- className(_el$3, t, _p$?.t);
140
- style(_el$3, a, _p$?.a);
141
- });
142
145
  return _el$3;
143
146
  },
144
147
  get children() {
145
148
  var _el$2 = _tmpl$2();
146
- _el$2._$$click = () => props.onPress?.();
149
+ spread(_el$2, [() => {
150
+ return rootAttributes(props);
151
+ }, {
152
+ type: "button",
153
+ onClick: () => props.onPress?.(),
154
+ get "aria-pressed"() {
155
+ return props.selected === void 0 ? void 0 : props.selected ? "true" : "false";
156
+ },
157
+ get "class"() {
158
+ return surface();
159
+ },
160
+ get style() {
161
+ return props.style;
162
+ }
163
+ }], true);
147
164
  insert(_el$2, content);
148
- effect(() => {
149
- return {
150
- e: props.selected === void 0 ? void 0 : props.selected ? "true" : "false",
151
- t: readShallow(surface()),
152
- a: readShallow(props.style)
153
- };
154
- }, ({ e, t, a }, _p$) => {
155
- e !== _p$?.e && setAttribute(_el$2, "aria-pressed", e);
156
- className(_el$2, t, _p$?.t);
157
- style(_el$2, a, _p$?.a);
158
- });
159
165
  return _el$2;
160
166
  }
161
167
  });
162
168
  }
163
- delegateEvents(["click"]);
164
169
  export { Card };
@@ -1,6 +1,8 @@
1
+ import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
1
2
  import { keepChecked } from "./controlled.js";
2
- import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
3
- import { CHECKBOX_MARK, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMarkClass, classes, rootPart } from "@xds/core";
3
+ import { rootAttributes } from "./root.js";
4
+ import { className, createComponent, effect, insert, readShallow, ref, setAttribute, spread, template } from "@solidjs/web";
5
+ import { CHECKBOX_MARK, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMarkClass, classes, isControlled, rootPart } from "@xds/core";
4
6
  import { Show } from "solid-js";
5
7
  // packages/ui-solid/src/Checkbox.tsx
6
8
  var _tmpl$ = /* @__PURE__ */ template(`<span>`);
@@ -8,18 +10,45 @@ var _tmpl$2 = /* @__PURE__ */ template(`<label><input type=checkbox class="peer
8
10
  var ROOT = rootPart("Checkbox");
9
11
  /**
10
12
  * A choice that is applied later, with the form it belongs to. A native checkbox: the input is
11
- * hidden and the box is drawn beside it.
13
+ * hidden and the box is drawn beside it. Without `checked` it keeps its own state, from
14
+ * `defaultChecked`.
12
15
  */
13
16
  function Checkbox(props) {
17
+ const controlled = () => isControlled(props, "checked");
18
+ const defaultChecked = () => props.defaultChecked ?? false;
19
+ const checked = createControllable({
20
+ controlled,
21
+ value: () => props.checked ?? false,
22
+ defaultValue: defaultChecked,
23
+ onChange: (next) => props.onChange?.(next)
24
+ });
25
+ let input;
26
+ resetWithForm(() => input, controlled, checked.reset);
14
27
  var _el$ = _tmpl$2();
15
28
  var _el$2 = _el$.firstChild;
16
29
  var _el$3 = _el$2.nextSibling;
17
30
  var _el$4 = _el$3.firstChild;
18
31
  var _el$5 = _el$4.firstChild;
32
+ spread(_el$, [() => {
33
+ return rootAttributes(props);
34
+ }, {
35
+ get "class"() {
36
+ return classes(ROOT, checkboxClass, props.class);
37
+ },
38
+ get style() {
39
+ return props.style;
40
+ }
41
+ }], true);
42
+ _el$2.addEventListener("blur", (event) => props.onBlur?.(event));
43
+ _el$2.addEventListener("focus", (event) => props.onFocus?.(event));
19
44
  _el$2.addEventListener("change", (event) => {
20
- props.onChange(event.currentTarget.checked);
21
- keepChecked(event.currentTarget, () => props.checked);
45
+ checked.set(event.currentTarget.checked);
46
+ keepChecked(event.currentTarget, checked.value);
22
47
  });
48
+ var _ref$ = composeRefs((element) => input = element, () => props.ref);
49
+ (typeof _ref$ === "function" || Array.isArray(_ref$)) && ref(() => {
50
+ return _ref$;
51
+ }, _el$2);
23
52
  setAttribute(_el$5, "d", CHECKBOX_MARK);
24
53
  insert(_el$, createComponent(Show, {
25
54
  get when() {
@@ -38,26 +67,22 @@ function Checkbox(props) {
38
67
  }), null);
39
68
  effect(() => {
40
69
  return {
41
- e: readShallow(classes(ROOT, checkboxClass, props.class)),
42
- t: readShallow(props.style),
43
- a: props["aria-label"],
44
- o: props.checked,
45
- i: props.checked,
46
- n: props.disabled,
47
- s: props.name || void 0,
48
- h: readShallow(checkboxBoxClass),
49
- r: readShallow(checkboxMarkClass)
70
+ e: props["aria-label"],
71
+ t: checked.value(),
72
+ a: controlled() ? checked.value() : defaultChecked(),
73
+ o: props.disabled,
74
+ i: props.name || void 0,
75
+ n: readShallow(checkboxBoxClass),
76
+ s: readShallow(checkboxMarkClass)
50
77
  };
51
- }, ({ e, t, a, o, i, n, s, h, r }, _p$) => {
52
- className(_el$, e, _p$?.e);
53
- style(_el$, t, _p$?.t);
54
- a !== _p$?.a && setAttribute(_el$2, "aria-label", a);
55
- _el$2.checked = o;
56
- i !== _p$?.i && (_el$2.defaultChecked = i);
57
- n !== _p$?.n && setAttribute(_el$2, "disabled", n);
58
- s !== _p$?.s && setAttribute(_el$2, "name", s);
59
- className(_el$3, h, _p$?.h);
60
- className(_el$4, r, _p$?.r);
78
+ }, ({ e, t, a, o, i, n, s }, _p$) => {
79
+ e !== _p$?.e && setAttribute(_el$2, "aria-label", e);
80
+ _el$2.checked = t;
81
+ a !== _p$?.a && (_el$2.defaultChecked = a);
82
+ o !== _p$?.o && setAttribute(_el$2, "disabled", o);
83
+ i !== _p$?.i && setAttribute(_el$2, "name", i);
84
+ className(_el$3, n, _p$?.n);
85
+ className(_el$4, s, _p$?.s);
61
86
  });
62
87
  return _el$;
63
88
  }
package/dist/dom/Chip.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Icon } from "./Icon.js";
2
- import { className, createComponent, delegateEvents, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
2
+ import { rootAttributes } from "./root.js";
3
+ import { createComponent, insert, spread, template } from "@solidjs/web";
3
4
  import { chipClass, chipIcon, classes, rootPart } from "@xds/core";
4
5
  import { Show } from "solid-js";
5
6
  // packages/ui-solid/src/Chip.tsx
6
- var _tmpl$ = /* @__PURE__ */ template(`<button type=button><!><!>`);
7
+ var _tmpl$ = /* @__PURE__ */ template(`<button><!><!>`);
7
8
  var ROOT = rootPart("Chip");
8
9
  /**
9
10
  * A choice that filters what is shown. Unlike a Badge it is pressed. A selected chip is tinted,
@@ -15,7 +16,24 @@ function Chip(props) {
15
16
  var _el$ = _tmpl$();
16
17
  var _el$2 = _el$.firstChild;
17
18
  var _el$3 = _el$2.nextSibling;
18
- _el$._$$click = () => props.onPress?.();
19
+ spread(_el$, [() => {
20
+ return rootAttributes(props);
21
+ }, {
22
+ type: "button",
23
+ get "aria-pressed"() {
24
+ return props.selected ? "true" : "false";
25
+ },
26
+ get disabled() {
27
+ return props.disabled;
28
+ },
29
+ onClick: () => props.onPress?.(),
30
+ get "class"() {
31
+ return classes(ROOT, chipClass(props.selected), props.class);
32
+ },
33
+ get style() {
34
+ return props.style;
35
+ }
36
+ }], true);
19
37
  insert(_el$, createComponent(Show, {
20
38
  get when() {
21
39
  return chipIcon({
@@ -33,20 +51,6 @@ function Chip(props) {
33
51
  insert(_el$, () => {
34
52
  return props.label;
35
53
  }, _el$3);
36
- effect(() => {
37
- return {
38
- e: props.selected ? "true" : "false",
39
- t: props.disabled,
40
- a: readShallow(classes(ROOT, chipClass(props.selected), props.class)),
41
- o: readShallow(props.style)
42
- };
43
- }, ({ e, t, a, o }, _p$) => {
44
- e !== _p$?.e && setAttribute(_el$, "aria-pressed", e);
45
- t !== _p$?.t && setAttribute(_el$, "disabled", t);
46
- className(_el$, a, _p$?.a);
47
- style(_el$, o, _p$?.o);
48
- });
49
54
  return _el$;
50
55
  }
51
- delegateEvents(["click"]);
52
56
  export { Chip };
@@ -1,7 +1,8 @@
1
- import { className, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
1
+ import { rootAttributes } from "./root.js";
2
+ import { insert, spread, template } from "@solidjs/web";
2
3
  import { chipBarClass, classes, rootPart } from "@xds/core";
3
4
  // packages/ui-solid/src/ChipBar.tsx
4
- var _tmpl$ = /* @__PURE__ */ template(`<div role=group>`);
5
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
5
6
  var ROOT = rootPart("ChipBar");
6
7
  /**
7
8
  * One row of chips. It scrolls sideways when the chips do not fit and never wraps, so the
@@ -9,20 +10,23 @@ var ROOT = rootPart("ChipBar");
9
10
  */
10
11
  function ChipBar(props) {
11
12
  var _el$ = _tmpl$();
13
+ spread(_el$, [() => {
14
+ return rootAttributes(props);
15
+ }, {
16
+ role: "group",
17
+ get "aria-label"() {
18
+ return props.label;
19
+ },
20
+ get "class"() {
21
+ return classes(ROOT, chipBarClass, props.class);
22
+ },
23
+ get style() {
24
+ return props.style;
25
+ }
26
+ }], true);
12
27
  insert(_el$, () => {
13
28
  return props.children;
14
29
  });
15
- effect(() => {
16
- return {
17
- e: props.label,
18
- t: readShallow(classes(ROOT, chipBarClass, props.class)),
19
- a: readShallow(props.style)
20
- };
21
- }, ({ e, t, a }, _p$) => {
22
- e !== _p$?.e && setAttribute(_el$, "aria-label", e);
23
- className(_el$, t, _p$?.t);
24
- style(_el$, a, _p$?.a);
25
- });
26
30
  return _el$;
27
31
  }
28
32
  export { ChipBar };
@@ -1,4 +1,5 @@
1
- import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
1
+ import { rootAttributes } from "./root.js";
2
+ import { createComponent, insert, spread, template } from "@solidjs/web";
2
3
  import { classes, countBadgeAnchorClass, countBadgeClass, countBadgeText, rootPart } from "@xds/core";
3
4
  import { Show, children } from "solid-js";
4
5
  // packages/ui-solid/src/CountBadge.tsx
@@ -17,22 +18,25 @@ function CountBadge(props) {
17
18
  },
18
19
  get children() {
19
20
  var _el$ = _tmpl$();
21
+ spread(_el$, [() => {
22
+ return onChild ? {} : rootAttributes(props);
23
+ }, {
24
+ get role() {
25
+ return props.label ? "img" : void 0;
26
+ },
27
+ get "aria-label"() {
28
+ return props.label || void 0;
29
+ },
30
+ get "class"() {
31
+ return classes(!onChild && ROOT, countBadgeClass(onChild), !onChild && props.class);
32
+ },
33
+ get style() {
34
+ return onChild ? void 0 : props.style;
35
+ }
36
+ }], true);
20
37
  insert(_el$, () => {
21
38
  return countBadgeText(props.count, props.max);
22
39
  });
23
- effect(() => {
24
- return {
25
- e: props.label ? "img" : void 0,
26
- t: props.label || void 0,
27
- a: readShallow(classes(!onChild && ROOT, countBadgeClass(onChild), !onChild && props.class)),
28
- o: readShallow(onChild ? void 0 : props.style)
29
- };
30
- }, ({ e, t, a, o }, _p$) => {
31
- e !== _p$?.e && setAttribute(_el$, "role", e);
32
- t !== _p$?.t && setAttribute(_el$, "aria-label", t);
33
- className(_el$, a, _p$?.a);
34
- style(_el$, o, _p$?.o);
35
- });
36
40
  return _el$;
37
41
  }
38
42
  });
@@ -47,19 +51,20 @@ function CountBadge(props) {
47
51
  var _el$2 = _tmpl$2();
48
52
  var _el$3 = _el$2.firstChild;
49
53
  var _el$4 = _el$3.nextSibling;
54
+ spread(_el$2, [() => {
55
+ return rootAttributes(props);
56
+ }, {
57
+ get "class"() {
58
+ return classes(ROOT, countBadgeAnchorClass, props.class);
59
+ },
60
+ get style() {
61
+ return props.style;
62
+ }
63
+ }], true);
50
64
  insert(_el$2, child, _el$3);
51
65
  insert(_el$2, () => {
52
66
  return badge(true);
53
67
  }, _el$4);
54
- effect(() => {
55
- return {
56
- e: readShallow(classes(ROOT, countBadgeAnchorClass, props.class)),
57
- t: readShallow(props.style)
58
- };
59
- }, ({ e, t }, _p$) => {
60
- className(_el$2, e, _p$?.e);
61
- style(_el$2, t, _p$?.t);
62
- });
63
68
  return _el$2;
64
69
  }
65
70
  });
@@ -1,8 +1,9 @@
1
1
  import { Icon } from "./Icon.js";
2
+ import { useLabels } from "./Labels.js";
2
3
  import { modalPopover } from "./modal-popover.js";
3
4
  import { Portal as Portal$1 } from "./portal.js";
4
5
  import { createPresence } from "./presence.js";
5
- import { withStyle } from "./root.js";
6
+ import { rootAttributes, withStyle } from "./root.js";
6
7
  import { createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, spread, style, template } from "@solidjs/web";
7
8
  import { DATE_PICKER_NAV_CLASS, classes, datePickerContentAttrs, datePickerIds, datePickerLocale, datePickerMachineProps, datePickerTriggerAttrs, focusOpeningDay, formatDay, keepCalendarFocus, keepDayFocused, readCssPx, underlayLayerStyle } from "@xds/core";
8
9
  import { normalizeProps, useMachine } from "@zag-js/solid";
@@ -35,14 +36,19 @@ function DatePicker(props) {
35
36
  const id = createUniqueId();
36
37
  const ids = datePickerIds(id);
37
38
  const locale = () => datePickerLocale(props.locale);
38
- const service = useMachine(datePicker.machine, () => datePickerMachineProps(props, {
39
- id,
40
- locale: locale(),
41
- onChange: (value) => props.onChange(value),
42
- gutter: readCssPx(null, "--xds-space-1", space[1])
39
+ const labels = useLabels();
40
+ const service = useMachine(datePicker.machine, () => ({
41
+ ...datePickerMachineProps(props, {
42
+ id,
43
+ locale: locale(),
44
+ onChange: (value) => props.onChange(value),
45
+ gutter: readCssPx(null, "--xds-space-1", space[1]),
46
+ labels: labels()
47
+ }),
48
+ ids: { root: props.id }
43
49
  }));
44
50
  const api = createMemo(() => datePicker.connect(service, normalizeProps));
45
- const root = withStyle(() => api().getRootProps(), () => props.style);
51
+ const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
46
52
  let positioner;
47
53
  let surface;
48
54
  modalPopover(() => api().open, () => positioner);