@xds/solid 0.0.0-stage → 0.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 (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -2
  3. package/dist/dom/Accordion.js +139 -0
  4. package/dist/dom/Avatar.js +59 -0
  5. package/dist/dom/AvatarStack.js +74 -0
  6. package/dist/dom/Badge.js +58 -0
  7. package/dist/dom/Banner.js +102 -0
  8. package/dist/dom/Button.js +107 -0
  9. package/dist/dom/Card.js +164 -0
  10. package/dist/dom/Checkbox.js +64 -0
  11. package/dist/dom/Chip.js +52 -0
  12. package/dist/dom/ChipBar.js +28 -0
  13. package/dist/dom/CountBadge.js +67 -0
  14. package/dist/dom/DatePicker.js +300 -0
  15. package/dist/dom/DateRangePicker.js +404 -0
  16. package/dist/dom/Defaults.js +29 -0
  17. package/dist/dom/Dialog.js +136 -0
  18. package/dist/dom/Divider.js +20 -0
  19. package/dist/dom/EmptyState.js +70 -0
  20. package/dist/dom/Icon.js +46 -0
  21. package/dist/dom/IconButton.js +72 -0
  22. package/dist/dom/ListRow.js +126 -0
  23. package/dist/dom/MediaCard.js +178 -0
  24. package/dist/dom/Menu.js +176 -0
  25. package/dist/dom/ProgressBar.js +33 -0
  26. package/dist/dom/RadioGroup.js +123 -0
  27. package/dist/dom/SearchField.js +94 -0
  28. package/dist/dom/SectionHeader.js +104 -0
  29. package/dist/dom/SegmentedControl.js +69 -0
  30. package/dist/dom/Select.js +271 -0
  31. package/dist/dom/Sidebar.js +233 -0
  32. package/dist/dom/Skeleton.js +34 -0
  33. package/dist/dom/Slider.js +115 -0
  34. package/dist/dom/Spinner.js +35 -0
  35. package/dist/dom/Switch.js +65 -0
  36. package/dist/dom/Tabs.js +80 -0
  37. package/dist/dom/Text.js +24 -0
  38. package/dist/dom/TextField.js +172 -0
  39. package/dist/dom/Thumbnail.js +119 -0
  40. package/dist/dom/Toast.js +99 -0
  41. package/dist/dom/Tooltip.js +128 -0
  42. package/dist/dom/controlled.js +13 -0
  43. package/dist/dom/index.js +40 -0
  44. package/dist/dom/modal-popover.js +22 -0
  45. package/dist/dom/picture.js +29 -0
  46. package/dist/dom/presence.js +20 -0
  47. package/dist/dom/preview.js +139 -0
  48. package/dist/dom/root.js +26 -0
  49. package/dist/dom/trigger.js +31 -0
  50. package/dist/source/Accordion.d.ts +21 -0
  51. package/dist/source/Accordion.jsx +57 -0
  52. package/dist/source/Avatar.d.ts +9 -0
  53. package/dist/source/Avatar.jsx +16 -0
  54. package/dist/source/AvatarStack.d.ts +8 -0
  55. package/dist/source/AvatarStack.jsx +22 -0
  56. package/dist/source/Badge.d.ts +13 -0
  57. package/dist/source/Badge.jsx +15 -0
  58. package/dist/source/Banner.d.ts +23 -0
  59. package/dist/source/Banner.jsx +32 -0
  60. package/dist/source/Button.d.ts +15 -0
  61. package/dist/source/Button.jsx +48 -0
  62. package/dist/source/Card.d.ts +18 -0
  63. package/dist/source/Card.jsx +46 -0
  64. package/dist/source/Checkbox.d.ts +10 -0
  65. package/dist/source/Checkbox.jsx +20 -0
  66. package/dist/source/Chip.d.ts +12 -0
  67. package/dist/source/Chip.jsx +12 -0
  68. package/dist/source/ChipBar.d.ts +12 -0
  69. package/dist/source/ChipBar.jsx +7 -0
  70. package/dist/source/CountBadge.d.ts +12 -0
  71. package/dist/source/CountBadge.jsx +17 -0
  72. package/dist/source/DatePicker.d.ts +20 -0
  73. package/dist/source/DatePicker.jsx +109 -0
  74. package/dist/source/DateRangePicker.d.ts +24 -0
  75. package/dist/source/DateRangePicker.jsx +150 -0
  76. package/dist/source/Defaults.d.ts +23 -0
  77. package/dist/source/Defaults.jsx +12 -0
  78. package/dist/source/Dialog.d.ts +21 -0
  79. package/dist/source/Dialog.jsx +58 -0
  80. package/dist/source/Divider.d.ts +4 -0
  81. package/dist/source/Divider.jsx +5 -0
  82. package/dist/source/EmptyState.d.ts +12 -0
  83. package/dist/source/EmptyState.jsx +16 -0
  84. package/dist/source/Icon.d.ts +8 -0
  85. package/dist/source/Icon.jsx +11 -0
  86. package/dist/source/IconButton.d.ts +13 -0
  87. package/dist/source/IconButton.jsx +36 -0
  88. package/dist/source/ListRow.d.ts +21 -0
  89. package/dist/source/ListRow.jsx +38 -0
  90. package/dist/source/MediaCard.d.ts +20 -0
  91. package/dist/source/MediaCard.jsx +47 -0
  92. package/dist/source/Menu.d.ts +19 -0
  93. package/dist/source/Menu.jsx +99 -0
  94. package/dist/source/ProgressBar.d.ts +8 -0
  95. package/dist/source/ProgressBar.jsx +8 -0
  96. package/dist/source/RadioGroup.d.ts +15 -0
  97. package/dist/source/RadioGroup.jsx +57 -0
  98. package/dist/source/SearchField.d.ts +15 -0
  99. package/dist/source/SearchField.jsx +39 -0
  100. package/dist/source/SectionHeader.d.ts +14 -0
  101. package/dist/source/SectionHeader.jsx +32 -0
  102. package/dist/source/SegmentedControl.d.ts +12 -0
  103. package/dist/source/SegmentedControl.jsx +21 -0
  104. package/dist/source/Select.d.ts +18 -0
  105. package/dist/source/Select.jsx +139 -0
  106. package/dist/source/Sidebar.d.ts +22 -0
  107. package/dist/source/Sidebar.jsx +65 -0
  108. package/dist/source/Skeleton.d.ts +11 -0
  109. package/dist/source/Skeleton.jsx +9 -0
  110. package/dist/source/Slider.d.ts +13 -0
  111. package/dist/source/Slider.jsx +69 -0
  112. package/dist/source/Spinner.d.ts +9 -0
  113. package/dist/source/Spinner.jsx +12 -0
  114. package/dist/source/Switch.d.ts +13 -0
  115. package/dist/source/Switch.jsx +18 -0
  116. package/dist/source/Tabs.d.ts +14 -0
  117. package/dist/source/Tabs.jsx +31 -0
  118. package/dist/source/Text.d.ts +10 -0
  119. package/dist/source/Text.jsx +14 -0
  120. package/dist/source/TextField.d.ts +22 -0
  121. package/dist/source/TextField.jsx +73 -0
  122. package/dist/source/Thumbnail.d.ts +9 -0
  123. package/dist/source/Thumbnail.jsx +34 -0
  124. package/dist/source/Toast.d.ts +16 -0
  125. package/dist/source/Toast.jsx +42 -0
  126. package/dist/source/Tooltip.d.ts +28 -0
  127. package/dist/source/Tooltip.jsx +52 -0
  128. package/dist/source/controlled.d.ts +4 -0
  129. package/dist/source/controlled.js +11 -0
  130. package/dist/source/index.d.ts +40 -0
  131. package/dist/source/index.js +39 -0
  132. package/dist/source/modal-popover.d.ts +7 -0
  133. package/dist/source/modal-popover.js +15 -0
  134. package/dist/source/picture.d.ts +20 -0
  135. package/dist/source/picture.js +13 -0
  136. package/dist/source/presence.d.ts +7 -0
  137. package/dist/source/presence.js +13 -0
  138. package/dist/source/preview.d.ts +6 -0
  139. package/dist/source/preview.jsx +110 -0
  140. package/dist/source/root.d.ts +25 -0
  141. package/dist/source/root.js +19 -0
  142. package/dist/source/trigger.d.ts +18 -0
  143. package/dist/source/trigger.js +18 -0
  144. package/package.json +63 -4
  145. package/page.css +20 -0
  146. package/styles.css +3353 -0
  147. package/tailwind.css +2665 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kjmin-dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,20 @@
1
- # Temporary Holding Version
1
+ # @xds/solid
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The components of the xds design system for Solid, with the look of an app made with `xds create`.
4
+
5
+ ```sh
6
+ npm install @xds/solid
7
+ ```
8
+
9
+ Import the stylesheet once, then use the components:
10
+
11
+ ```js
12
+ import "@xds/solid/styles.css";
13
+ import { Button } from "@xds/solid";
14
+ ```
15
+
16
+ `<Button>` and every other component take the app's class and style on their root element, which also carries a stable class such as `xds-button`. The `Defaults` component sets what the components inside it take when the app passes no variant, size or tone.
17
+
18
+ The stylesheet keeps to the `xds` cascade layer and to the library's own elements, so the app's styles win. `@xds/solid/page.css` gives the page the library's background, text color and font. An app with Tailwind CSS 4.1 or later can import `@xds/solid/tailwind.css` before Tailwind instead of `styles.css`.
19
+
20
+ This channel is a preview while its behavior library, Zag.js 2, is a prerelease. See [xds as a library](https://github.com/kjmin-dev/xds/blob/main/docs/library.md) for modes, themes and the rest of the customization.
@@ -0,0 +1,139 @@
1
+ import { Icon } from "./Icon.js";
2
+ import { withStyle } from "./root.js";
3
+ import { className, createComponent, effect, insert, readShallow, ref, spread, template } from "@solidjs/web";
4
+ import { ACCORDION_PARTS, classes, focusTitleOnClick, setPanelOpen } from "@xds/core";
5
+ import * as accordion from "@zag-js/accordion";
6
+ import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
7
+ import { For, Show, createEffect, createMemo, createUniqueId } from "solid-js";
8
+ // packages/ui-solid/src/Accordion.tsx
9
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
10
+ var _tmpl$2 = /* @__PURE__ */ template(`<div><h3><button><span><span>`);
11
+ var _tmpl$3 = /* @__PURE__ */ template(`<span>`);
12
+ var _tmpl$4 = /* @__PURE__ */ template(`<div><div class=xds-accordion__body>`);
13
+ /**
14
+ * Items whose bodies open and close under their titles, separated by hairlines. The chevron
15
+ * turns over when an item is open, so the state does not depend on color. Opening and closing
16
+ * animate the height, and do not for people who ask for less motion.
17
+ *
18
+ * Each title is a heading holding a button that says whether its body is expanded and which
19
+ * body it controls. A closed body is hidden, but the browser's find in page still opens it.
20
+ */
21
+ function Accordion(props) {
22
+ const id = createUniqueId();
23
+ const service = useMachine(accordion.machine, () => ({
24
+ id,
25
+ value: [...props.expanded],
26
+ onValueChange: (details) => props.onChange(details.value),
27
+ multiple: props.multiple ?? false,
28
+ collapsible: true,
29
+ hiddenUntilFound: true
30
+ }));
31
+ const api = createMemo(() => accordion.connect(service, normalizeProps));
32
+ const root = withStyle(() => api().getRootProps(), () => props.style);
33
+ const body = (value) => {
34
+ const { hidden: _hidden, ...attributes } = api().getItemContentProps({ value });
35
+ return attributes;
36
+ };
37
+ var _el$ = _tmpl$();
38
+ spread(_el$, [root, { get "class"() {
39
+ return classes("xds-accordion", props.class);
40
+ } }], true);
41
+ insert(_el$, createComponent(For, {
42
+ get each() {
43
+ return props.items;
44
+ },
45
+ children: (item) => (() => {
46
+ var _el$2 = _tmpl$2();
47
+ var _el$3 = _el$2.firstChild;
48
+ var _el$4 = _el$3.firstChild;
49
+ var _el$5 = _el$4.firstChild;
50
+ var _el$6 = _el$5.firstChild;
51
+ spread(_el$2, [() => {
52
+ return api().getItemProps({ value: item.value });
53
+ }, { class: "xds-accordion__item" }], true);
54
+ spread(_el$3, [() => {
55
+ return api().getItemHeaderProps({ value: item.value });
56
+ }, { class: "xds-accordion__heading" }], true);
57
+ spread(_el$4, [() => {
58
+ return mergeProps$1(() => api().getItemTriggerProps({ value: item.value }), { onClick: focusTitleOnClick });
59
+ }, { class: "xds-accordion__trigger group" }], true);
60
+ insert(_el$6, () => {
61
+ return item.title;
62
+ });
63
+ insert(_el$5, createComponent(Show, {
64
+ get when() {
65
+ return item.description;
66
+ },
67
+ children: (description) => (() => {
68
+ var _el$7 = _tmpl$3();
69
+ insert(_el$7, description);
70
+ effect(() => readShallow(ACCORDION_PARTS.description), (_v$, _$p) => {
71
+ className(_el$7, _v$, _$p);
72
+ });
73
+ return _el$7;
74
+ })()
75
+ }), null);
76
+ insert(_el$4, createComponent(Icon, {
77
+ name: "chevron-down",
78
+ size: "sm",
79
+ get "class"() {
80
+ return ACCORDION_PARTS.chevron;
81
+ }
82
+ }), null);
83
+ insert(_el$2, createComponent(Panel, {
84
+ get open() {
85
+ return api().value.includes(item.value);
86
+ },
87
+ get attributes() {
88
+ return body(item.value);
89
+ },
90
+ get children() {
91
+ return item.content;
92
+ }
93
+ }), null);
94
+ effect(() => {
95
+ return {
96
+ e: readShallow(ACCORDION_PARTS.text),
97
+ t: readShallow(ACCORDION_PARTS.title)
98
+ };
99
+ }, ({ e, t }, _p$) => {
100
+ className(_el$5, e, _p$?.e);
101
+ className(_el$6, t, _p$?.t);
102
+ });
103
+ return _el$2;
104
+ })()
105
+ }));
106
+ return _el$;
107
+ }
108
+ /**
109
+ * An item's body. Its height moves between zero and the height of what it holds, and it is
110
+ * hidden only once it has finished closing.
111
+ */
112
+ function Panel(props) {
113
+ let panel;
114
+ let rendered = false;
115
+ createEffect(() => props.open, (open) => {
116
+ const stop = setPanelOpen(panel, open, rendered);
117
+ rendered = true;
118
+ return stop;
119
+ });
120
+ var _el$8 = _tmpl$4();
121
+ var _el$9 = _el$8.firstChild;
122
+ spread(_el$8, [() => {
123
+ return props.attributes;
124
+ }, {
125
+ role: "group",
126
+ get "aria-hidden"() {
127
+ return props.open ? void 0 : "true";
128
+ },
129
+ class: "xds-accordion__panel"
130
+ }], true);
131
+ ref(() => {
132
+ return (element) => panel = element;
133
+ }, _el$8);
134
+ insert(_el$9, () => {
135
+ return props.children;
136
+ });
137
+ return _el$8;
138
+ }
139
+ export { Accordion };
@@ -0,0 +1,59 @@
1
+ import { useDefaults } from "./Defaults.js";
2
+ import { createPicture } from "./picture.js";
3
+ import { className, createComponent, effect, insert, memo, readShallow, setAttribute, style, template } from "@solidjs/web";
4
+ import { avatarClass, avatarInitials, classes, pictureClass, rootPart } from "@xds/core";
5
+ import { Show } from "solid-js";
6
+ // packages/ui-solid/src/Avatar.tsx
7
+ var _tmpl$ = /* @__PURE__ */ template(`<span role=img><!><!>`);
8
+ var _tmpl$2 = /* @__PURE__ */ template(`<img alt aria-hidden=true>`);
9
+ var ROOT = rootPart("Avatar");
10
+ /**
11
+ * Stands for a person or a team by a picture, or by their initials when there is none.
12
+ * Assistive technology gets the full name either way. The small size has room for one letter.
13
+ */
14
+ function Avatar(props) {
15
+ const defaults = useDefaults("Avatar");
16
+ const size = () => props.size ?? defaults().size;
17
+ const picture = createPicture(() => props.src);
18
+ var _el$ = _tmpl$();
19
+ var _el$2 = _el$.firstChild;
20
+ var _el$3 = _el$2.nextSibling;
21
+ insert(_el$, () => {
22
+ return avatarInitials(props.name, size());
23
+ }, _el$2);
24
+ insert(_el$, createComponent(Show, {
25
+ get when() {
26
+ return memo(() => {
27
+ return picture.loaded() !== false;
28
+ })() && props.src;
29
+ },
30
+ children: (src) => (() => {
31
+ var _el$4 = _tmpl$2();
32
+ _el$4.addEventListener("error", () => picture.onError(src()));
33
+ _el$4.addEventListener("load", () => picture.onLoad(src()));
34
+ effect(() => {
35
+ return {
36
+ e: src(),
37
+ t: readShallow(pictureClass(picture.loaded() === true))
38
+ };
39
+ }, ({ e, t }, _p$) => {
40
+ e !== _p$?.e && setAttribute(_el$4, "src", e);
41
+ className(_el$4, t, _p$?.t);
42
+ });
43
+ return _el$4;
44
+ })()
45
+ }), _el$3);
46
+ effect(() => {
47
+ return {
48
+ e: props.name,
49
+ t: readShallow(classes(ROOT, avatarClass(size()), props.class)),
50
+ a: readShallow(props.style)
51
+ };
52
+ }, ({ e, t, a }, _p$) => {
53
+ e !== _p$?.e && setAttribute(_el$, "aria-label", e);
54
+ className(_el$, t, _p$?.t);
55
+ style(_el$, a, _p$?.a);
56
+ });
57
+ return _el$;
58
+ }
59
+ export { Avatar };
@@ -0,0 +1,74 @@
1
+ import { Avatar } from "./Avatar.js";
2
+ import { useDefaults } from "./Defaults.js";
3
+ import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
4
+ import { avatarStack, avatarStackClass, avatarStackItemClass, avatarStackRestClass, classes, rootPart } from "@xds/core";
5
+ import { For, Show, createMemo } from "solid-js";
6
+ // packages/ui-solid/src/AvatarStack.tsx
7
+ var _tmpl$ = /* @__PURE__ */ template(`<span aria-hidden=true>+`);
8
+ var _tmpl$2 = /* @__PURE__ */ template(`<span role=img><!><!>`);
9
+ var _tmpl$3 = /* @__PURE__ */ template(`<span aria-hidden=true>`);
10
+ var ROOT = rootPart("AvatarStack");
11
+ /**
12
+ * Several people in the room of one. Assistive technology gets one image named after
13
+ * everyone in it, including those who did not fit.
14
+ */
15
+ function AvatarStack(props) {
16
+ const defaults = useDefaults("AvatarStack");
17
+ const size = () => props.size ?? defaults().size ?? "md";
18
+ const stack = createMemo(() => avatarStack(props.people, props.max, props.label));
19
+ var _el$ = _tmpl$2();
20
+ var _el$2 = _el$.firstChild;
21
+ var _el$5 = _el$2.nextSibling;
22
+ insert(_el$, createComponent(For, {
23
+ get each() {
24
+ return stack().shown;
25
+ },
26
+ children: (person) => (() => {
27
+ var _el$6 = _tmpl$3();
28
+ insert(_el$6, createComponent(Avatar, {
29
+ get name() {
30
+ return person.name;
31
+ },
32
+ get src() {
33
+ return person.src;
34
+ },
35
+ get size() {
36
+ return size();
37
+ }
38
+ }));
39
+ effect(() => readShallow(avatarStackItemClass(size())), (_v$, _$p) => {
40
+ className(_el$6, _v$, _$p);
41
+ });
42
+ return _el$6;
43
+ })()
44
+ }), _el$2);
45
+ insert(_el$, createComponent(Show, {
46
+ get when() {
47
+ return stack().rest > 0;
48
+ },
49
+ get children() {
50
+ var _el$3 = _tmpl$();
51
+ _el$3.firstChild;
52
+ insert(_el$3, () => {
53
+ return stack().rest;
54
+ }, null);
55
+ effect(() => readShallow(avatarStackRestClass(size())), (_v$, _$p) => {
56
+ className(_el$3, _v$, _$p);
57
+ });
58
+ return _el$3;
59
+ }
60
+ }), _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
+ return _el$;
73
+ }
74
+ export { AvatarStack };
@@ -0,0 +1,58 @@
1
+ import { useDefaults } from "./Defaults.js";
2
+ import { Icon } from "./Icon.js";
3
+ import { className, createComponent, effect, insert, readShallow, style, template } from "@solidjs/web";
4
+ import { badgeClass, badgeDotClass, classes, rootPart } from "@xds/core";
5
+ import { Show } from "solid-js";
6
+ // packages/ui-solid/src/Badge.tsx
7
+ var _tmpl$ = /* @__PURE__ */ template(`<span aria-hidden=true>`);
8
+ var _tmpl$2 = /* @__PURE__ */ template(`<span><!><!><!>`);
9
+ var ROOT = rootPart("Badge");
10
+ /**
11
+ * A short status or category. The words carry the meaning; the color only reinforces it, so a
12
+ * badge still reads for someone who cannot tell the tones apart. `dot` adds a small mark for
13
+ * live states such as "connected", and `icon` a drawing in front of the words.
14
+ */
15
+ function Badge(props) {
16
+ const defaults = useDefaults("Badge");
17
+ var _el$ = _tmpl$2();
18
+ var _el$3 = _el$.firstChild;
19
+ var _el$4 = _el$3.nextSibling;
20
+ var _el$5 = _el$4.nextSibling;
21
+ insert(_el$, createComponent(Show, {
22
+ get when() {
23
+ return props.dot;
24
+ },
25
+ get children() {
26
+ var _el$2 = _tmpl$();
27
+ effect(() => readShallow(badgeDotClass), (_v$, _$p) => {
28
+ className(_el$2, _v$, _$p);
29
+ });
30
+ return _el$2;
31
+ }
32
+ }), _el$3);
33
+ insert(_el$, createComponent(Show, {
34
+ get when() {
35
+ return props.icon;
36
+ },
37
+ children: (name) => createComponent(Icon, {
38
+ get name() {
39
+ return name();
40
+ },
41
+ size: "xs"
42
+ })
43
+ }), _el$4);
44
+ insert(_el$, () => {
45
+ return props.children;
46
+ }, _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
+ return _el$;
57
+ }
58
+ export { Badge };
@@ -0,0 +1,102 @@
1
+ import { Button } from "./Button.js";
2
+ import { useDefaults } from "./Defaults.js";
3
+ import { IconButton } from "./IconButton.js";
4
+ import { className, createComponent, effect, insert, readShallow, setAttribute, style, template } from "@solidjs/web";
5
+ import { BANNER_PARTS, bannerClass, bannerIconClass, bannerIconPath, bannerRole, classes, rootPart } from "@xds/core";
6
+ import { Show } from "solid-js";
7
+ // packages/ui-solid/src/Banner.tsx
8
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
9
+ var _tmpl$2 = /* @__PURE__ */ template(`<div><svg viewBox="0 0 24 24"aria-hidden=true><path fill=currentColor></path></svg><div><div></div><!>`);
10
+ var _tmpl$3 = /* @__PURE__ */ template(`<p>`);
11
+ var ROOT = rootPart("Banner");
12
+ /**
13
+ * A message about the whole view or a section of it. Each tone has its own icon shape, so the
14
+ * tone does not depend on color. Problems (`warning`, `danger`) interrupt a screen reader;
15
+ * `info` and `success` wait their turn.
16
+ */
17
+ function Banner(props) {
18
+ const defaults = useDefaults("Banner");
19
+ const tone = () => props.tone ?? defaults().tone;
20
+ var _el$ = _tmpl$2();
21
+ var _el$2 = _el$.firstChild;
22
+ var _el$3 = _el$2.firstChild;
23
+ var _el$4 = _el$2.nextSibling;
24
+ var _el$5 = _el$4.firstChild;
25
+ var _el$6 = _el$5.nextSibling;
26
+ insert(_el$4, createComponent(Show, {
27
+ get when() {
28
+ return props.title;
29
+ },
30
+ children: (title) => (() => {
31
+ var _el$8 = _tmpl$3();
32
+ insert(_el$8, title);
33
+ effect(() => readShallow(BANNER_PARTS.title), (_v$, _$p) => {
34
+ className(_el$8, _v$, _$p);
35
+ });
36
+ return _el$8;
37
+ })()
38
+ }), _el$5);
39
+ insert(_el$5, () => {
40
+ return props.children;
41
+ });
42
+ insert(_el$4, createComponent(Show, {
43
+ get when() {
44
+ return props.action;
45
+ },
46
+ children: (action) => (() => {
47
+ var _el$9 = _tmpl$();
48
+ insert(_el$9, createComponent(Button, {
49
+ variant: "secondary",
50
+ size: "sm",
51
+ onPress: () => action().onPress(),
52
+ get children() {
53
+ return action().label;
54
+ }
55
+ }));
56
+ effect(() => readShallow(BANNER_PARTS.action), (_v$, _$p) => {
57
+ className(_el$9, _v$, _$p);
58
+ });
59
+ return _el$9;
60
+ })()
61
+ }), _el$6);
62
+ insert(_el$, createComponent(Show, {
63
+ get when() {
64
+ return props.onDismiss;
65
+ },
66
+ get children() {
67
+ var _el$7 = _tmpl$();
68
+ insert(_el$7, createComponent(IconButton, {
69
+ icon: "x",
70
+ get label() {
71
+ return props.dismissLabel ?? "Dismiss";
72
+ },
73
+ variant: "ghost",
74
+ size: "sm",
75
+ onPress: () => props.onDismiss?.()
76
+ }));
77
+ effect(() => readShallow(BANNER_PARTS.dismiss), (_v$, _$p) => {
78
+ className(_el$7, _v$, _$p);
79
+ });
80
+ return _el$7;
81
+ }
82
+ }), null);
83
+ effect(() => {
84
+ 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)
91
+ };
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);
99
+ });
100
+ return _el$;
101
+ }
102
+ export { Banner };
@@ -0,0 +1,107 @@
1
+ import { useDefaults } from "./Defaults.js";
2
+ import { Icon } from "./Icon.js";
3
+ import { Spinner } from "./Spinner.js";
4
+ import { withTrigger } from "./trigger.js";
5
+ import { className, createComponent, effect, insert, memo, readShallow, spread, template } from "@solidjs/web";
6
+ import { BUTTON_ICON, buttonClass, classes, isHeld } from "@xds/core";
7
+ import { Show, children, createMemo } from "solid-js";
8
+ // packages/ui-solid/src/Button.tsx
9
+ var _tmpl$ = /* @__PURE__ */ template(`<span>`);
10
+ var _tmpl$2 = /* @__PURE__ */ template(`<button><!><!><!><!>`);
11
+ /**
12
+ * A native button. It also opens a Menu or a Tooltip it is the trigger of: their props reach
13
+ * it through context.
14
+ */
15
+ function Button(props) {
16
+ const label = children(() => props.children);
17
+ const defaults = useDefaults("Button");
18
+ const variant = () => props.variant ?? defaults().variant ?? "secondary";
19
+ const size = () => props.size ?? defaults().size ?? "md";
20
+ const icon = () => BUTTON_ICON[size()];
21
+ const held = () => isHeld({
22
+ variant: variant(),
23
+ selected: props.selected,
24
+ disabled: props.disabled
25
+ });
26
+ const attributes = withTrigger(createMemo(() => ({
27
+ type: props.type ?? "button",
28
+ class: classes(buttonClass({
29
+ variant: variant(),
30
+ size: size(),
31
+ iconOnly: label() == null && (props.iconStart !== void 0 || props.iconEnd !== void 0),
32
+ fullWidth: props.fullWidth ?? false
33
+ }), props.class),
34
+ style: props.style,
35
+ disabled: props.disabled,
36
+ "aria-disabled": props.loading ? "true" : void 0,
37
+ "data-pending": props.loading ? "" : void 0,
38
+ "aria-pressed": props.selected === void 0 ? void 0 : props.selected ? "true" : "false",
39
+ "aria-label": props["aria-label"],
40
+ onClick: () => {
41
+ if (!props.loading) props.onPress?.();
42
+ }
43
+ })), () => props.loading === true);
44
+ var _el$ = _tmpl$2();
45
+ var _el$3 = _el$.firstChild;
46
+ var _el$4 = _el$3.nextSibling;
47
+ var _el$5 = _el$4.nextSibling;
48
+ var _el$6 = _el$5.nextSibling;
49
+ spread(_el$, attributes, true);
50
+ insert(_el$, createComponent(Show, {
51
+ get when() {
52
+ return props.loading;
53
+ },
54
+ get children() {
55
+ return createComponent(Show, {
56
+ get when() {
57
+ return props.iconStart;
58
+ },
59
+ get fallback() {
60
+ return createComponent(Spinner, { size: "sm" });
61
+ },
62
+ get children() {
63
+ var _el$2 = _tmpl$();
64
+ insert(_el$2, createComponent(Spinner, { size: "sm" }));
65
+ effect(() => readShallow(icon().box), (_v$, _$p) => {
66
+ className(_el$2, _v$, _$p);
67
+ });
68
+ return _el$2;
69
+ }
70
+ });
71
+ }
72
+ }), _el$3);
73
+ insert(_el$, createComponent(Show, {
74
+ get when() {
75
+ return memo(() => {
76
+ return !props.loading;
77
+ })() && props.iconStart;
78
+ },
79
+ children: (name) => createComponent(Icon, {
80
+ get name() {
81
+ return name();
82
+ },
83
+ get size() {
84
+ return icon().size;
85
+ },
86
+ get filled() {
87
+ return held();
88
+ }
89
+ })
90
+ }), _el$4);
91
+ insert(_el$, label, _el$5);
92
+ insert(_el$, createComponent(Show, {
93
+ get when() {
94
+ return props.iconEnd;
95
+ },
96
+ children: (name) => createComponent(Icon, {
97
+ get name() {
98
+ return name();
99
+ },
100
+ get size() {
101
+ return icon().size;
102
+ }
103
+ })
104
+ }), _el$6);
105
+ return _el$;
106
+ }
107
+ export { Button };