@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,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, datePickerTriggerAttrs, dateRangeMachineProps, endRangeChoiceOnClose, focusOpeningDay, formatRange, keepCalendarFocus, keepDayFocused, keepRangePreview, rangeDayClick, rangeGridKeyDown, rangeMonthViews, rangeMonths, rangeSummary, readCssPx, shownRange, underlayLayerStyle } from "@xds/core";
8
9
  import { normalizeProps, useMachine } from "@zag-js/solid";
@@ -42,19 +43,24 @@ function DateRangePicker(props) {
42
43
  const id = createUniqueId();
43
44
  const ids = datePickerIds(id);
44
45
  const locale = () => datePickerLocale(props.locale);
46
+ const labels = useLabels();
45
47
  const [draft, setDraft] = createSignal(null);
46
48
  const [months, setMonths] = createSignal(1);
47
49
  const shown = createMemo(() => shownRange(props.value, draft()));
48
- const service = useMachine(datePicker.machine, () => dateRangeMachineProps(props, shown(), {
49
- id,
50
- locale: locale(),
51
- months: months(),
52
- onDraft: (next) => setDraft(() => next),
53
- onChange: (value) => props.onChange(value),
54
- gutter: readCssPx(null, "--xds-space-1", space[1])
50
+ const service = useMachine(datePicker.machine, () => ({
51
+ ...dateRangeMachineProps(props, shown(), {
52
+ id,
53
+ locale: locale(),
54
+ months: months(),
55
+ onDraft: (next) => setDraft(() => next),
56
+ onChange: (value) => props.onChange(value),
57
+ gutter: readCssPx(null, "--xds-space-1", space[1]),
58
+ labels: labels()
59
+ }),
60
+ ids: { root: props.id }
55
61
  }));
56
62
  const api = createMemo(() => datePicker.connect(service, normalizeProps));
57
- const root = withStyle(() => api().getRootProps(), () => props.style);
63
+ const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
58
64
  let positioner;
59
65
  let surface;
60
66
  modalPopover(() => api().open, () => positioner);
@@ -69,7 +75,7 @@ function DateRangePicker(props) {
69
75
  ], ([isOpen]) => keepDayFocused(isOpen, surface));
70
76
  createEffect(open, (isOpen) => endRangeChoiceOnClose(service, isOpen));
71
77
  createEffect(focused, () => keepRangePreview(service, shown(), open()));
72
- const summary = createMemo(() => rangeSummary(shown(), props, locale()));
78
+ const summary = createMemo(() => rangeSummary(shown(), props, locale(), labels()));
73
79
  const views = createMemo(() => rangeMonthViews(api(), months()));
74
80
  const invalid = () => props.error !== void 0;
75
81
  var _el$ = _tmpl$5();
@@ -1,6 +1,6 @@
1
1
  import { Portal as Portal$1 } from "./portal.js";
2
2
  import { createPresence } from "./presence.js";
3
- import { withStyle } from "./root.js";
3
+ import { rootAttributes, withStyle } from "./root.js";
4
4
  import { TriggerContext } from "./trigger.js";
5
5
  import { createComponent, insert, ref, spread, template } from "@solidjs/web";
6
6
  import { classes, leaveEscapeToFields } from "@xds/core";
@@ -29,6 +29,7 @@ function Dialog(props) {
29
29
  let content;
30
30
  const service = useMachine(dialog.machine, () => ({
31
31
  id,
32
+ ids: { content: props.id },
32
33
  open: props.open,
33
34
  onOpenChange: (details) => {
34
35
  if (!details.open) props.onClose();
@@ -39,7 +40,7 @@ function Dialog(props) {
39
40
  initialFocusEl: () => content ?? null
40
41
  }));
41
42
  const api = createMemo(() => dialog.connect(service, normalizeProps));
42
- const contentProps = withStyle(() => api().getContentProps(), () => props.style);
43
+ const contentProps = withStyle(() => api().getContentProps(), () => props.style, rootAttributes(props));
43
44
  const present = createPresence(() => api().open, () => [backdrop, positioner]);
44
45
  return createComponent(Show, {
45
46
  get when() {
@@ -1,4 +1,5 @@
1
- import { className, effect, readShallow, style, template } from "@solidjs/web";
1
+ import { rootAttributes } from "./root.js";
2
+ import { spread, template } from "@solidjs/web";
2
3
  import { classes, dividerClass, rootPart } from "@xds/core";
3
4
  // packages/ui-solid/src/Divider.tsx
4
5
  var _tmpl$ = /* @__PURE__ */ template(`<hr>`);
@@ -6,15 +7,16 @@ var ROOT = rootPart("Divider");
6
7
  /** A line between groups of content. Decorative lines use the low-contrast border color. */
7
8
  function Divider(props) {
8
9
  var _el$ = _tmpl$();
9
- effect(() => {
10
- return {
11
- e: readShallow(classes(ROOT, dividerClass, props.class)),
12
- t: readShallow(props.style)
13
- };
14
- }, ({ e, t }, _p$) => {
15
- className(_el$, e, _p$?.e);
16
- style(_el$, t, _p$?.t);
17
- });
10
+ spread(_el$, [() => {
11
+ return rootAttributes(props);
12
+ }, {
13
+ get "class"() {
14
+ return classes(ROOT, dividerClass, props.class);
15
+ },
16
+ get style() {
17
+ return props.style;
18
+ }
19
+ }], false);
18
20
  return _el$;
19
21
  }
20
22
  export { Divider };
@@ -1,5 +1,6 @@
1
1
  import { Icon } from "./Icon.js";
2
- import { className, createComponent, effect, insert, readShallow, style, template } from "@solidjs/web";
2
+ import { rootAttributes } from "./root.js";
3
+ import { className, createComponent, effect, insert, readShallow, spread, template } from "@solidjs/web";
3
4
  import { EMPTY_STATE_PARTS, classes, rootPart } from "@xds/core";
4
5
  import { Show } from "solid-js";
5
6
  // packages/ui-solid/src/EmptyState.tsx
@@ -16,6 +17,16 @@ function EmptyState(props) {
16
17
  var _el$2 = _el$.firstChild;
17
18
  var _el$3 = _el$2.nextSibling;
18
19
  var _el$4 = _el$3.nextSibling;
20
+ spread(_el$, [() => {
21
+ return rootAttributes(props);
22
+ }, {
23
+ get "class"() {
24
+ return classes(ROOT, EMPTY_STATE_PARTS.root, props.class);
25
+ },
26
+ get style() {
27
+ return props.style;
28
+ }
29
+ }], true);
19
30
  insert(_el$, createComponent(Icon, {
20
31
  get name() {
21
32
  return props.icon;
@@ -54,16 +65,8 @@ function EmptyState(props) {
54
65
  return _el$6;
55
66
  })()
56
67
  }), _el$4);
57
- effect(() => {
58
- return {
59
- e: readShallow(classes(ROOT, EMPTY_STATE_PARTS.root, props.class)),
60
- t: readShallow(props.style),
61
- a: readShallow(EMPTY_STATE_PARTS.title)
62
- };
63
- }, ({ e, t, a }, _p$) => {
64
- className(_el$, e, _p$?.e);
65
- style(_el$, t, _p$?.t);
66
- className(_el$2, a, _p$?.a);
68
+ effect(() => readShallow(EMPTY_STATE_PARTS.title), (_v$, _$p) => {
69
+ className(_el$2, _v$, _$p);
67
70
  });
68
71
  return _el$;
69
72
  }
package/dist/dom/Icon.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { useDefaults } from "./Defaults.js";
2
- import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
2
+ import { rootAttributes } from "./root.js";
3
+ import { createComponent, insert, setAttribute, spread, template } from "@solidjs/web";
3
4
  import { classes, iconClass, rootPart } from "@xds/core";
4
5
  import { For } from "solid-js";
5
6
  import { icons } from "@xds/tokens";
6
7
  // packages/ui-solid/src/Icon.tsx
7
- var _tmpl$ = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>`);
8
+ var _tmpl$ = /* @__PURE__ */ template(`<svg>`);
8
9
  var _tmpl$2 = /* @__PURE__ */ template(`<svg><path></svg>`, 2);
9
10
  var ROOT = rootPart("Icon");
10
11
  /**
@@ -14,6 +15,33 @@ var ROOT = rootPart("Icon");
14
15
  function Icon(props) {
15
16
  const defaults = useDefaults("Icon");
16
17
  var _el$ = _tmpl$();
18
+ spread(_el$, [() => {
19
+ return rootAttributes(props);
20
+ }, {
21
+ viewBox: "0 0 24 24",
22
+ get fill() {
23
+ return props.filled ? "currentColor" : "none";
24
+ },
25
+ stroke: "currentColor",
26
+ "stroke-width": "2",
27
+ "stroke-linecap": "round",
28
+ "stroke-linejoin": "round",
29
+ get "class"() {
30
+ return classes(ROOT, iconClass(props.size ?? defaults().size), props.class);
31
+ },
32
+ get style() {
33
+ return props.style;
34
+ },
35
+ get role() {
36
+ return props.label ? "img" : void 0;
37
+ },
38
+ get "aria-label"() {
39
+ return props.label || void 0;
40
+ },
41
+ get "aria-hidden"() {
42
+ return props.label ? void 0 : "true";
43
+ }
44
+ }], true);
17
45
  insert(_el$, createComponent(For, {
18
46
  get each() {
19
47
  return icons[props.name];
@@ -24,23 +52,6 @@ function Icon(props) {
24
52
  return _el$2;
25
53
  })()
26
54
  }));
27
- effect(() => {
28
- return {
29
- e: props.filled ? "currentColor" : "none",
30
- t: readShallow(classes(ROOT, iconClass(props.size ?? defaults().size), props.class)),
31
- a: readShallow(props.style),
32
- o: props.label ? "img" : void 0,
33
- i: props.label || void 0,
34
- n: props.label ? void 0 : "true"
35
- };
36
- }, ({ e, t, a, o, i, n }, _p$) => {
37
- e !== _p$?.e && setAttribute(_el$, "fill", e);
38
- className(_el$, t, _p$?.t);
39
- style(_el$, a, _p$?.a);
40
- o !== _p$?.o && setAttribute(_el$, "role", o);
41
- i !== _p$?.i && setAttribute(_el$, "aria-label", i);
42
- n !== _p$?.n && setAttribute(_el$, "aria-hidden", n);
43
- });
44
55
  return _el$;
45
56
  }
46
57
  export { Icon };
@@ -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, readShallow, spread, template } from "@solidjs/web";
6
+ import { className, createComponent, effect, insert, readShallow, ref, spread, template } from "@solidjs/web";
6
7
  import { ICON_BUTTON_BOX, buttonClass, classes, isHeld } from "@xds/core";
7
8
  import { Show, createMemo } from "solid-js";
8
9
  // packages/ui-solid/src/IconButton.tsx
@@ -33,10 +34,16 @@ function IconButton(props) {
33
34
  "aria-label": props.label,
34
35
  onClick: () => {
35
36
  if (!props.loading) props.onPress?.();
36
- }
37
- })), () => props.loading === true);
37
+ },
38
+ onFocus: (event) => props.onFocus?.(event),
39
+ onBlur: (event) => props.onBlur?.(event)
40
+ })), () => props.loading === true, rootAttributes(props));
38
41
  var _el$ = _tmpl$();
39
42
  spread(_el$, attributes, true);
43
+ var _ref$ = props.ref;
44
+ typeof _ref$ === "function" || Array.isArray(_ref$) ? ref(() => {
45
+ return _ref$;
46
+ }, _el$) : props.ref = _el$;
40
47
  insert(_el$, createComponent(Show, {
41
48
  get when() {
42
49
  return !props.loading;
@@ -0,0 +1,26 @@
1
+ import { createComponent } from "@solidjs/web";
2
+ import { DEFAULT_LABELS, mergeLabels } from "@xds/core";
3
+ import { createContext, createMemo, useContext } from "solid-js";
4
+ // packages/ui-solid/src/Labels.tsx
5
+ var LabelsContext = createContext(() => DEFAULT_LABELS);
6
+ /**
7
+ * Gives the components inside it the names of their own parts in the app's language: a banner's
8
+ * dismiss control, a search field's clear control, a calendar's month buttons. A label passed to
9
+ * a component wins. A Labels inside another keeps the outer one's labels and replaces those it
10
+ * names; a change of `value` reaches every component inside.
11
+ */
12
+ function Labels(props) {
13
+ const outer = useContext(LabelsContext);
14
+ const merged = createMemo(() => mergeLabels(outer(), props.value));
15
+ return createComponent(LabelsContext, {
16
+ value: merged,
17
+ get children() {
18
+ return props.children;
19
+ }
20
+ });
21
+ }
22
+ /** The labels the closest Labels gives, read where a label is read so that a change updates it. */
23
+ function useLabels() {
24
+ return useContext(LabelsContext);
25
+ }
26
+ export { Labels, useLabels };
@@ -1,11 +1,12 @@
1
1
  import { Icon } from "./Icon.js";
2
- import { className, createComponent, delegateEvents, effect, insert, memo, mergeProps, readShallow, setAttribute, style, template } from "@solidjs/web";
2
+ import { rootAttributes } from "./root.js";
3
+ import { className, createComponent, effect, insert, memo, mergeProps, readShallow, spread, template } from "@solidjs/web";
3
4
  import { LIST_ROW_PARTS, classes, listRowClass, listRowDescriptionClass, listRowTitleClass, rootPart } from "@xds/core";
4
5
  import { Show } from "solid-js";
5
6
  // packages/ui-solid/src/ListRow.tsx
6
7
  var _tmpl$ = /* @__PURE__ */ template(`<span><span>`);
7
8
  var _tmpl$2 = /* @__PURE__ */ template(`<span>`);
8
- var _tmpl$3 = /* @__PURE__ */ template(`<button type=button>`);
9
+ var _tmpl$3 = /* @__PURE__ */ template(`<button>`);
9
10
  var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
10
11
  var ROOT = rootPart("ListRow");
11
12
  /** One line of a list or a settings screen. Separate rows with a Divider. */
@@ -87,40 +88,45 @@ function PlaceRow(props) {
87
88
  },
88
89
  get fallback() {
89
90
  var _el$5 = _tmpl$4();
91
+ spread(_el$5, [() => {
92
+ return rootAttributes(props);
93
+ }, {
94
+ get "aria-current"() {
95
+ return current();
96
+ },
97
+ get "class"() {
98
+ return row();
99
+ },
100
+ get style() {
101
+ return props.style;
102
+ }
103
+ }], true);
90
104
  insert(_el$5, content);
91
- effect(() => {
92
- return {
93
- e: current(),
94
- t: readShallow(row()),
95
- a: readShallow(props.style)
96
- };
97
- }, ({ e, t, a }, _p$) => {
98
- e !== _p$?.e && setAttribute(_el$5, "aria-current", e);
99
- className(_el$5, t, _p$?.t);
100
- style(_el$5, a, _p$?.a);
101
- });
102
105
  return _el$5;
103
106
  },
104
107
  get children() {
105
108
  var _el$4 = _tmpl$3();
106
- _el$4._$$click = () => props.onPress?.();
109
+ spread(_el$4, [() => {
110
+ return rootAttributes(props);
111
+ }, {
112
+ get "aria-current"() {
113
+ return current();
114
+ },
115
+ type: "button",
116
+ get disabled() {
117
+ return props.disabled;
118
+ },
119
+ onClick: () => props.onPress?.(),
120
+ get "class"() {
121
+ return row();
122
+ },
123
+ get style() {
124
+ return props.style;
125
+ }
126
+ }], true);
107
127
  insert(_el$4, content);
108
- effect(() => {
109
- return {
110
- e: current(),
111
- t: props.disabled,
112
- a: readShallow(row()),
113
- o: readShallow(props.style)
114
- };
115
- }, ({ e, t, a, o }, _p$) => {
116
- e !== _p$?.e && setAttribute(_el$4, "aria-current", e);
117
- t !== _p$?.t && setAttribute(_el$4, "disabled", t);
118
- className(_el$4, a, _p$?.a);
119
- style(_el$4, o, _p$?.o);
120
- });
121
128
  return _el$4;
122
129
  }
123
130
  });
124
131
  }
125
- delegateEvents(["click"]);
126
132
  export { ListRow, PlaceRow };
@@ -1,6 +1,7 @@
1
1
  import { useDefaults } from "./Defaults.js";
2
+ import { rootAttributes } from "./root.js";
2
3
  import { Thumbnail } from "./Thumbnail.js";
3
- import { className, createComponent, delegateEvents, effect, insert, memo, readShallow, setAttribute, style, template } from "@solidjs/web";
4
+ import { className, createComponent, delegateEvents, effect, insert, memo, readShallow, setAttribute, spread, template } from "@solidjs/web";
4
5
  import { MEDIA_CARD_PARTS, classes, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, rootPart } from "@xds/core";
5
6
  import { For, Show, createMemo, createUniqueId } from "solid-js";
6
7
  // packages/ui-solid/src/MediaCard.tsx
@@ -8,7 +9,6 @@ var _tmpl$ = /* @__PURE__ */ template(`<div><span></span><div><span><span></span
8
9
  var _tmpl$2 = /* @__PURE__ */ template(`<span>`);
9
10
  var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
10
11
  var _tmpl$4 = /* @__PURE__ */ template(`<div><button type=button>`);
11
- var _tmpl$5 = /* @__PURE__ */ template(`<div role=group>`);
12
12
  var ROOT = rootPart("MediaCard");
13
13
  /**
14
14
  * A thumbnail with its title and details: a video in a feed, an article in a list.
@@ -137,38 +137,47 @@ function MediaCard(props) {
137
137
  return pressable();
138
138
  },
139
139
  get fallback() {
140
- var _el$12 = _tmpl$5();
140
+ var _el$12 = _tmpl$3();
141
+ spread(_el$12, [() => {
142
+ return rootAttributes(props);
143
+ }, {
144
+ role: "group",
145
+ get "aria-labelledby"() {
146
+ return ids().names;
147
+ },
148
+ get "class"() {
149
+ return classes(ROOT, MEDIA_CARD_PARTS.group, props.class);
150
+ },
151
+ get style() {
152
+ return props.style;
153
+ }
154
+ }], true);
141
155
  insert(_el$12, content);
142
- effect(() => {
143
- return {
144
- e: ids().names,
145
- t: readShallow(classes(ROOT, MEDIA_CARD_PARTS.group, props.class)),
146
- a: readShallow(props.style)
147
- };
148
- }, ({ e, t, a }, _p$) => {
149
- e !== _p$?.e && setAttribute(_el$12, "aria-labelledby", e);
150
- className(_el$12, t, _p$?.t);
151
- style(_el$12, a, _p$?.a);
152
- });
153
156
  return _el$12;
154
157
  },
155
158
  get children() {
156
159
  var _el$10 = _tmpl$4();
157
160
  var _el$11 = _el$10.firstChild;
161
+ spread(_el$10, [() => {
162
+ return rootAttributes(props);
163
+ }, {
164
+ get "class"() {
165
+ return classes(ROOT, MEDIA_CARD_PARTS.pressable, props.class);
166
+ },
167
+ get style() {
168
+ return props.style;
169
+ }
170
+ }], true);
158
171
  _el$11._$$click = () => props.onPress?.();
159
172
  insert(_el$10, content, null);
160
173
  effect(() => {
161
174
  return {
162
- e: readShallow(classes(ROOT, MEDIA_CARD_PARTS.pressable, props.class)),
163
- t: readShallow(props.style),
164
- a: ids().names,
165
- o: readShallow(MEDIA_CARD_PARTS.button)
175
+ e: ids().names,
176
+ t: readShallow(MEDIA_CARD_PARTS.button)
166
177
  };
167
- }, ({ e, t, a, o }, _p$) => {
168
- className(_el$10, e, _p$?.e);
169
- style(_el$10, t, _p$?.t);
170
- a !== _p$?.a && setAttribute(_el$11, "aria-labelledby", a);
171
- className(_el$11, o, _p$?.o);
178
+ }, ({ e, t }, _p$) => {
179
+ e !== _p$?.e && setAttribute(_el$11, "aria-labelledby", e);
180
+ className(_el$11, t, _p$?.t);
172
181
  });
173
182
  return _el$10;
174
183
  }
package/dist/dom/Menu.js CHANGED
@@ -2,6 +2,7 @@ import { Icon } from "./Icon.js";
2
2
  import { modalPopover } from "./modal-popover.js";
3
3
  import { Portal as Portal$1 } from "./portal.js";
4
4
  import { createPresence } from "./presence.js";
5
+ import { rootAttributes } from "./root.js";
5
6
  import { TriggerContext, provideTrigger } from "./trigger.js";
6
7
  import { createComponent, delegateEvents, effect, insert, readShallow, ref, spread, style, template } from "@solidjs/web";
7
8
  import { classes, firstMenuValue, keepListKeys, layoutRect, leaveEscapeToFields, menuItemClass, opensOnPress, readCssPx, underlayLayerStyle } from "@xds/core";
@@ -28,6 +29,7 @@ function Menu(props) {
28
29
  const id = createUniqueId();
29
30
  const service = useMachine(menu.machine, () => ({
30
31
  id,
32
+ ids: { content: props.id },
31
33
  "aria-label": props.label,
32
34
  positioning: {
33
35
  placement: `bottom-${props.align ?? "start"}`,
@@ -71,7 +73,7 @@ function Menu(props) {
71
73
  let surface;
72
74
  modalPopover(() => api().open, () => positioner);
73
75
  const present = createPresence(() => api().open, () => [surface]);
74
- const content = mergeProps$1(() => api().getContentProps(), {
76
+ const content = mergeProps$1(() => api().getContentProps(), rootAttributes(props), {
75
77
  onKeyDown: (event) => keepListKeys(event, surface, ".xds-menu__item:not([data-disabled])", (value) => api().setHighlightedValue(value)),
76
78
  get style() {
77
79
  return props.style;
@@ -1,7 +1,8 @@
1
- import { className, effect, readShallow, setAttribute, setStyleProperty, style, template } from "@solidjs/web";
1
+ import { rootAttributes } from "./root.js";
2
+ import { className, effect, readShallow, setStyleProperty, spread, template } from "@solidjs/web";
2
3
  import { classes, progressBarClass, progressBarFillClass, progressPercent, rootPart } from "@xds/core";
3
4
  // packages/ui-solid/src/ProgressBar.tsx
4
- var _tmpl$ = /* @__PURE__ */ template(`<div role=progressbar aria-valuemin=0 aria-valuemax=100><div>`);
5
+ var _tmpl$ = /* @__PURE__ */ template(`<div><div>`);
5
6
  var ROOT = rootPart("ProgressBar");
6
7
  /**
7
8
  * How far along something is, from 0 to 1. For work of unknown length use a Spinner.
@@ -11,22 +12,33 @@ function ProgressBar(props) {
11
12
  const percent = () => progressPercent(props.value);
12
13
  var _el$ = _tmpl$();
13
14
  var _el$2 = _el$.firstChild;
15
+ spread(_el$, [() => {
16
+ return rootAttributes(props);
17
+ }, {
18
+ role: "progressbar",
19
+ get "aria-label"() {
20
+ return props.label;
21
+ },
22
+ "aria-valuemin": 0,
23
+ "aria-valuemax": 100,
24
+ get "aria-valuenow"() {
25
+ return percent();
26
+ },
27
+ get "class"() {
28
+ return classes(ROOT, progressBarClass, props.class);
29
+ },
30
+ get style() {
31
+ return props.style;
32
+ }
33
+ }], true);
14
34
  effect(() => {
15
35
  return {
16
- e: props.label,
17
- t: percent(),
18
- a: readShallow(classes(ROOT, progressBarClass, props.class)),
19
- o: readShallow(props.style),
20
- i: readShallow(progressBarFillClass),
21
- n: `${percent()}%`
36
+ e: readShallow(progressBarFillClass),
37
+ t: `${percent()}%`
22
38
  };
23
- }, ({ e, t, a, o, i, n }, _p$) => {
24
- e !== _p$?.e && setAttribute(_el$, "aria-label", e);
25
- t !== _p$?.t && setAttribute(_el$, "aria-valuenow", t);
26
- className(_el$, a, _p$?.a);
27
- style(_el$, o, _p$?.o);
28
- className(_el$2, i, _p$?.i);
29
- n !== _p$?.n && setStyleProperty(_el$2, "width", n);
39
+ }, ({ e, t }, _p$) => {
40
+ className(_el$2, e, _p$?.e);
41
+ t !== _p$?.t && setStyleProperty(_el$2, "width", t);
30
42
  });
31
43
  return _el$;
32
44
  }
@@ -1,10 +1,12 @@
1
+ import { createControllable, resetWithForm } from "./controllable.js";
1
2
  import { keepChecked } from "./controlled.js";
2
- import { className, createComponent, effect, insert, readShallow, ref, setAttribute, setProperty, style, template } from "@solidjs/web";
3
- import { classes } from "@xds/core";
3
+ import { rootAttributes } from "./root.js";
4
+ import { createComponent, effect, insert, ref, setAttribute, setProperty, spread, template } from "@solidjs/web";
5
+ import { classes, isControlled } from "@xds/core";
4
6
  import { For, Show, createUniqueId } from "solid-js";
5
7
  // packages/ui-solid/src/RadioGroup.tsx
6
8
  var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-radio-group__error>`);
7
- var _tmpl$2 = /* @__PURE__ */ template(`<div role=radiogroup aria-orientation=vertical><span class=xds-radio-group__label></span><div class=xds-radio-group__options></div><div aria-live=polite>`);
9
+ var _tmpl$2 = /* @__PURE__ */ template(`<div><span class=xds-radio-group__label></span><div class=xds-radio-group__options></div><div aria-live=polite>`);
8
10
  var _tmpl$3 = /* @__PURE__ */ template(`<span class=xds-radio-group__description>`);
9
11
  var _tmpl$4 = /* @__PURE__ */ template(`<label class=xds-radio-group__option><input type=radio class="xds-radio-group__input sr-only"><span class=xds-radio-group__row><span class=xds-radio-group__circle-line><span class=xds-radio-group__circle><span class=xds-radio-group__dot></span></span></span><span class=xds-radio-group__words><span class=xds-radio-group__text>`);
10
12
  /**
@@ -14,6 +16,9 @@ var _tmpl$4 = /* @__PURE__ */ template(`<label class=xds-radio-group__option><in
14
16
  * The chosen option has a dot and a thicker ring, so the choice does not depend on color. The
15
17
  * options are native radio buttons, hidden and drawn beside, in a group named by the legend:
16
18
  * the arrow keys move between them, and the error is tied to the group and announced.
19
+ *
20
+ * Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
21
+ * `undefined`, it shows that.
17
22
  */
18
23
  function RadioGroup(props) {
19
24
  const id = createUniqueId();
@@ -21,11 +26,42 @@ function RadioGroup(props) {
21
26
  const errorId = `${id}-error`;
22
27
  const invalid = () => props.error !== void 0;
23
28
  let group;
29
+ const controlled = () => isControlled(props, "value");
30
+ const value = createControllable({
31
+ controlled,
32
+ value: () => props.value,
33
+ defaultValue: () => props.defaultValue,
34
+ onChange: (next) => {
35
+ if (next !== void 0) props.onChange?.(next);
36
+ }
37
+ });
38
+ resetWithForm(() => group, controlled, value.reset);
24
39
  var _el$ = _tmpl$2();
25
40
  var _el$2 = _el$.firstChild;
26
41
  var _el$3 = _el$2.nextSibling;
27
42
  var _el$4 = _el$3.nextSibling;
28
- setAttribute(_el$, "aria-labelledby", labelId);
43
+ spread(_el$, [() => {
44
+ return rootAttributes(props);
45
+ }, {
46
+ role: "radiogroup",
47
+ "aria-labelledby": labelId,
48
+ get "aria-describedby"() {
49
+ return invalid() ? errorId : void 0;
50
+ },
51
+ get "aria-invalid"() {
52
+ return invalid() ? "true" : void 0;
53
+ },
54
+ get "aria-disabled"() {
55
+ return props.disabled ? "true" : void 0;
56
+ },
57
+ "aria-orientation": "vertical",
58
+ get "class"() {
59
+ return classes("xds-radio-group", props.class);
60
+ },
61
+ get style() {
62
+ return props.style;
63
+ }
64
+ }], true);
29
65
  ref(() => {
30
66
  return (element) => group = element;
31
67
  }, _el$);
@@ -43,8 +79,8 @@ function RadioGroup(props) {
43
79
  var _el$10 = _el$7.nextSibling.firstChild.nextSibling;
44
80
  var _el$11 = _el$10.firstChild;
45
81
  _el$7.addEventListener("change", () => {
46
- props.onChange(option.value);
47
- for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === props.value);
82
+ value.set(option.value);
83
+ for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === value.value());
48
84
  });
49
85
  insert(_el$11, () => {
50
86
  return option.label;
@@ -68,8 +104,8 @@ function RadioGroup(props) {
68
104
  return {
69
105
  e: props.name ?? id,
70
106
  t: option.value,
71
- a: option.value === props.value,
72
- o: option.value === props.value,
107
+ a: option.value === value.value(),
108
+ o: option.value === (controlled() ? value.value() : props.defaultValue),
73
109
  i: props.disabled,
74
110
  n: `${id}-${index()}`,
75
111
  s: [option.description ? `${id}-${index()}-description` : void 0, invalid() ? errorId : void 0].filter(Boolean).join(" ") || void 0,
@@ -103,21 +139,6 @@ function RadioGroup(props) {
103
139
  return _el$5;
104
140
  }
105
141
  }));
106
- effect(() => {
107
- return {
108
- e: invalid() ? errorId : void 0,
109
- t: invalid() ? "true" : void 0,
110
- a: props.disabled ? "true" : void 0,
111
- o: readShallow(classes("xds-radio-group", props.class)),
112
- i: readShallow(props.style)
113
- };
114
- }, ({ e, t, a, o, i }, _p$) => {
115
- e !== _p$?.e && setAttribute(_el$, "aria-describedby", e);
116
- t !== _p$?.t && setAttribute(_el$, "aria-invalid", t);
117
- a !== _p$?.a && setAttribute(_el$, "aria-disabled", a);
118
- className(_el$, o, _p$?.o);
119
- style(_el$, i, _p$?.i);
120
- });
121
142
  return _el$;
122
143
  }
123
144
  export { RadioGroup };