@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
@@ -0,0 +1,40 @@
1
+ export type { IconName, IconSize, TextTone, TextVariant } from "@xds/core";
2
+ export { Accordion, type AccordionItem, type AccordionProps } from "./Accordion.tsx";
3
+ export { Avatar, type AvatarProps, type AvatarSize } from "./Avatar.tsx";
4
+ export { AvatarStack, type AvatarStackProps } from "./AvatarStack.tsx";
5
+ export { Badge, type BadgeProps, type BadgeTone } from "./Badge.tsx";
6
+ export { Banner, type BannerProps, type BannerTone } from "./Banner.tsx";
7
+ export { Button, type ButtonProps, type ButtonVariant, type ControlSize } from "./Button.tsx";
8
+ export { Card, type CardProps } from "./Card.tsx";
9
+ export { Checkbox, type CheckboxProps } from "./Checkbox.tsx";
10
+ export { Chip, type ChipProps } from "./Chip.tsx";
11
+ export { ChipBar, type ChipBarProps } from "./ChipBar.tsx";
12
+ export { CountBadge, type CountBadgeProps } from "./CountBadge.tsx";
13
+ export { DatePicker, type DatePickerProps, type IsoDate } from "./DatePicker.tsx";
14
+ export { type DateRange, DateRangePicker, type DateRangePickerProps } from "./DateRangePicker.tsx";
15
+ export { type ComponentDefaults, Defaults, type DefaultsProps } from "./Defaults.tsx";
16
+ export { Dialog, type DialogProps } from "./Dialog.tsx";
17
+ export { Divider, type DividerProps } from "./Divider.tsx";
18
+ export { EmptyState, type EmptyStateProps } from "./EmptyState.tsx";
19
+ export { Icon, type IconProps } from "./Icon.tsx";
20
+ export { IconButton, type IconButtonProps } from "./IconButton.tsx";
21
+ export { ListRow, type ListRowProps } from "./ListRow.tsx";
22
+ export { MediaCard, type MediaCardProps } from "./MediaCard.tsx";
23
+ export { Menu, type MenuItem, type MenuProps } from "./Menu.tsx";
24
+ export { ProgressBar, type ProgressBarProps } from "./ProgressBar.tsx";
25
+ export { RadioGroup, type RadioGroupProps, type RadioOption } from "./RadioGroup.tsx";
26
+ export { SearchField, type SearchFieldProps } from "./SearchField.tsx";
27
+ export { SectionHeader, type SectionHeaderProps } from "./SectionHeader.tsx";
28
+ export { SegmentedControl, type SegmentedControlProps } from "./SegmentedControl.tsx";
29
+ export { Select, type SelectOption, type SelectProps } from "./Select.tsx";
30
+ export { Sidebar, type SidebarItem, type SidebarProps, type SidebarSection } from "./Sidebar.tsx";
31
+ export { Skeleton, type SkeletonProps } from "./Skeleton.tsx";
32
+ export { Slider, type SliderProps } from "./Slider.tsx";
33
+ export { Spinner, type SpinnerProps } from "./Spinner.tsx";
34
+ export { Switch, type SwitchProps } from "./Switch.tsx";
35
+ export { Tabs, type TabsProps } from "./Tabs.tsx";
36
+ export { Text, type TextProps } from "./Text.tsx";
37
+ export { TextField, type TextFieldProps } from "./TextField.tsx";
38
+ export { Thumbnail, type ThumbnailProps, type ThumbnailRatio } from "./Thumbnail.tsx";
39
+ export { Toast, type ToastProps } from "./Toast.tsx";
40
+ export { Tooltip, type TooltipProps } from "./Tooltip.tsx";
@@ -0,0 +1,39 @@
1
+ export { Accordion } from "./Accordion.jsx";
2
+ export { Avatar } from "./Avatar.jsx";
3
+ export { AvatarStack } from "./AvatarStack.jsx";
4
+ export { Badge } from "./Badge.jsx";
5
+ export { Banner } from "./Banner.jsx";
6
+ export { Button } from "./Button.jsx";
7
+ export { Card } from "./Card.jsx";
8
+ export { Checkbox } from "./Checkbox.jsx";
9
+ export { Chip } from "./Chip.jsx";
10
+ export { ChipBar } from "./ChipBar.jsx";
11
+ export { CountBadge } from "./CountBadge.jsx";
12
+ export { DatePicker } from "./DatePicker.jsx";
13
+ export { DateRangePicker } from "./DateRangePicker.jsx";
14
+ export { Defaults } from "./Defaults.jsx";
15
+ export { Dialog } from "./Dialog.jsx";
16
+ export { Divider } from "./Divider.jsx";
17
+ export { EmptyState } from "./EmptyState.jsx";
18
+ export { Icon } from "./Icon.jsx";
19
+ export { IconButton } from "./IconButton.jsx";
20
+ export { ListRow } from "./ListRow.jsx";
21
+ export { MediaCard } from "./MediaCard.jsx";
22
+ export { Menu } from "./Menu.jsx";
23
+ export { ProgressBar } from "./ProgressBar.jsx";
24
+ export { RadioGroup } from "./RadioGroup.jsx";
25
+ export { SearchField } from "./SearchField.jsx";
26
+ export { SectionHeader } from "./SectionHeader.jsx";
27
+ export { SegmentedControl } from "./SegmentedControl.jsx";
28
+ export { Select } from "./Select.jsx";
29
+ export { Sidebar } from "./Sidebar.jsx";
30
+ export { Skeleton } from "./Skeleton.jsx";
31
+ export { Slider } from "./Slider.jsx";
32
+ export { Spinner } from "./Spinner.jsx";
33
+ export { Switch } from "./Switch.jsx";
34
+ export { Tabs } from "./Tabs.jsx";
35
+ export { Text } from "./Text.jsx";
36
+ export { TextField } from "./TextField.jsx";
37
+ export { Thumbnail } from "./Thumbnail.jsx";
38
+ export { Toast } from "./Toast.jsx";
39
+ export { Tooltip } from "./Tooltip.jsx";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Makes an open Menu or Select list modal while `open()` is true: the rest of the page is
3
+ * hidden from assistive technology, so a screen reader's cursor stays in the popup, where the
4
+ * focus is held too, and the page does not scroll. The popup's underlay keeps the pointer off
5
+ * the page. Zag does all of this around a dialog, but not around a menu or a select.
6
+ */
7
+ export declare function modalPopover(open: () => boolean, popup: () => HTMLElement | undefined): void;
@@ -0,0 +1,15 @@
1
+ import { ariaHidden } from "@zag-js/aria-hidden";
2
+ import { preventBodyScroll } from "@zag-js/remove-scroll";
3
+ import { createEffect } from "solid-js";
4
+ export function modalPopover(open, popup) {
5
+ createEffect(open, (isOpen) => {
6
+ if (!isOpen)
7
+ return;
8
+ const unlock = preventBodyScroll(document);
9
+ const reveal = ariaHidden(() => [popup() ?? null], { defer: true });
10
+ return () => {
11
+ reveal();
12
+ unlock();
13
+ };
14
+ });
15
+ }
@@ -0,0 +1,20 @@
1
+ import { type Accessor } from "solid-js";
2
+ /**
3
+ * Follows the loading of the picture at `src()`. `loaded()` is undefined while it loads, then
4
+ * true or false. The result is remembered with the address it belongs to, so a new `src` starts
5
+ * over without an effect.
6
+ *
7
+ * A picture that is in the cache still reports its load in a later task, after the handlers
8
+ * are attached, so no check of `complete` is needed on a page rendered in the browser.
9
+ */
10
+ export declare function createPicture(src: Accessor<string | undefined>): {
11
+ loaded: () => boolean | undefined;
12
+ onLoad: (address: string) => {
13
+ src: string;
14
+ loaded: true;
15
+ };
16
+ onError: (address: string) => {
17
+ src: string;
18
+ loaded: false;
19
+ };
20
+ };
@@ -0,0 +1,13 @@
1
+ import { createSignal } from "solid-js";
2
+ export function createPicture(src) {
3
+ const [picture, setPicture] = createSignal();
4
+ const loaded = () => {
5
+ const current = picture();
6
+ return current !== undefined && current.src === src() ? current.loaded : undefined;
7
+ };
8
+ return {
9
+ loaded,
10
+ onLoad: (address) => setPicture({ src: address, loaded: true }),
11
+ onError: (address) => setPicture({ src: address, loaded: false }),
12
+ };
13
+ }
@@ -0,0 +1,7 @@
1
+ import { type Accessor } from "solid-js";
2
+ /**
3
+ * Whether an overlay is on the page: from when it opens until the exit animation that its
4
+ * stylesheet starts on `[data-state="closed"]` has finished. Zag hides a closed part at once.
5
+ * `parts` are the elements that animate.
6
+ */
7
+ export declare function createPresence(open: Accessor<boolean>, parts: () => readonly (Element | undefined)[]): Accessor<boolean>;
@@ -0,0 +1,13 @@
1
+ import { afterAnimations } from "@xds/core";
2
+ import { createEffect, createMemo, createSignal } from "solid-js";
3
+ export function createPresence(open, parts) {
4
+ const [exited, setExited] = createSignal(true);
5
+ createEffect(open, (isOpen) => {
6
+ if (isOpen) {
7
+ setExited(false);
8
+ return;
9
+ }
10
+ return afterAnimations(parts(), () => setExited(true));
11
+ });
12
+ return createMemo(() => open() || !exited());
13
+ }
@@ -0,0 +1,6 @@
1
+ import { type Screen } from "@xds/core/preview";
2
+ import { type Element } from "solid-js";
3
+ export { designPreview } from "@xds/core/preview";
4
+ export declare function Preview(props: {
5
+ screen: Screen;
6
+ }): Element;
@@ -0,0 +1,110 @@
1
+ import { isNode, isStatic, resolve, } from "@xds/core/preview";
2
+ import { dynamic, memo } from "@solidjs/web";
3
+ import { createComponent, createSignal, onSettled, Show, untrack, } from "solid-js";
4
+ import { Accordion, Avatar, AvatarStack, Badge, Banner, Button, Card, Checkbox, Chip, ChipBar, CountBadge, DatePicker, DateRangePicker, Defaults, Dialog, Divider, EmptyState, Icon, IconButton, ListRow, MediaCard, Menu, ProgressBar, RadioGroup, SearchField, SectionHeader, SegmentedControl, Select, Sidebar, Skeleton, Slider, Spinner, Switch, Tabs, Text, TextField, Thumbnail, Toast, Tooltip, } from "./index.js";
5
+ export { designPreview } from "@xds/core/preview";
6
+ const COMPONENTS = {
7
+ Accordion,
8
+ Avatar,
9
+ AvatarStack,
10
+ Badge,
11
+ Banner,
12
+ Button,
13
+ Card,
14
+ Checkbox,
15
+ Chip,
16
+ ChipBar,
17
+ CountBadge,
18
+ DatePicker,
19
+ DateRangePicker,
20
+ Defaults,
21
+ Dialog,
22
+ Divider,
23
+ EmptyState,
24
+ Icon,
25
+ IconButton,
26
+ ListRow,
27
+ MediaCard,
28
+ Menu,
29
+ ProgressBar,
30
+ RadioGroup,
31
+ SearchField,
32
+ SectionHeader,
33
+ SegmentedControl,
34
+ Select,
35
+ Sidebar,
36
+ Skeleton,
37
+ Slider,
38
+ Spinner,
39
+ Switch,
40
+ Tabs,
41
+ Text,
42
+ TextField,
43
+ Thumbnail,
44
+ Toast,
45
+ Tooltip,
46
+ };
47
+ const _lacking = {};
48
+ export function Preview(props) {
49
+ const screen = untrack(() => props.screen);
50
+ const state = {};
51
+ const writes = new Map();
52
+ for (const [key, first] of Object.entries(screen.state)) {
53
+ const [read, write] = createSignal(first, { name: key });
54
+ Object.defineProperty(state, key, { get: read, enumerable: true });
55
+ writes.set(key, (value) => write(() => value));
56
+ }
57
+ const host = {
58
+ state,
59
+ set: (patch) => {
60
+ for (const [key, value] of Object.entries(patch))
61
+ writes.get(key)?.(value);
62
+ },
63
+ draw: (slot) => {
64
+ if (Array.isArray(slot)) {
65
+ return slot.map((child) => typeof child === "function" ? memo(() => child(state)) : host.draw(child));
66
+ }
67
+ if (typeof slot === "function")
68
+ return slot(state);
69
+ if (!isNode(slot))
70
+ return slot;
71
+ if (slot.kind === "show") {
72
+ return createComponent(Show, {
73
+ get when() {
74
+ return slot.when(state);
75
+ },
76
+ get children() {
77
+ return host.draw(slot.children);
78
+ },
79
+ get fallback() {
80
+ return host.draw(slot.fallback);
81
+ },
82
+ });
83
+ }
84
+ const type = slot.kind === "element"
85
+ ? dynamic(() => slot.tag, { static: true })
86
+ : COMPONENTS[slot.name];
87
+ return createComponent(type, propsOf(slot));
88
+ },
89
+ };
90
+ const propsOf = ({ props: given, children }) => {
91
+ const props = {};
92
+ const read = (key, get) => Object.defineProperty(props, key, { get, enumerable: true });
93
+ for (const [key, value] of Object.entries(given)) {
94
+ if (isStatic(value, key))
95
+ props[key] = resolve(value, key, host);
96
+ else
97
+ read(key, () => resolve(value, key, host));
98
+ }
99
+ if (children.length === 0)
100
+ return props;
101
+ const content = children.length === 1 ? children[0] : children;
102
+ if (children.every((child) => isStatic(child)))
103
+ props.children = content;
104
+ else
105
+ read("children", () => host.draw(content));
106
+ return props;
107
+ };
108
+ onSettled(() => screen.mount?.());
109
+ return host.draw(screen.root);
110
+ }
@@ -0,0 +1,25 @@
1
+ import type { JSX } from "@solidjs/web";
2
+ /**
3
+ * What every component takes for its root element, beside its root part (`xds-<name>`): the
4
+ * app's own handle on it.
5
+ */
6
+ export type RootProps = {
7
+ /** Added to the classes of the component's root element. */
8
+ class?: string;
9
+ /** Inline style on the component's root element, laid over any it sets itself. */
10
+ style?: JSX.CSSProperties | string;
11
+ };
12
+ type Style = JSX.CSSProperties | string | undefined;
13
+ /**
14
+ * The style of a root element that sets one of its own: the app's comes after it, so that it
15
+ * wins property by property. A string cannot be merged into an object without parsing it, so a
16
+ * string on either side makes both into one declaration list.
17
+ */
18
+ export declare function layStyle(own: Style, app: Style): Style;
19
+ /**
20
+ * The props Zag gives a component's root element, with the app's style laid over the one Zag
21
+ * sets: Zag's mergeProps merges the two, where a `style` after the spread would replace Zag's.
22
+ * Spread the result on the element.
23
+ */
24
+ export declare function withStyle<T extends object>(zag: () => T, style: () => Style): T;
25
+ export {};
@@ -0,0 +1,19 @@
1
+ import { mergeProps } from "@zag-js/solid";
2
+ const css = (style) => typeof style === "string"
3
+ ? style
4
+ : Object.entries(style)
5
+ .filter(([, value]) => value !== undefined)
6
+ .map(([property, value]) => `${property}:${String(value)}`)
7
+ .join(";");
8
+ export function layStyle(own, app) {
9
+ if (app === undefined)
10
+ return own;
11
+ if (own === undefined)
12
+ return app;
13
+ if (typeof own === "string" || typeof app === "string")
14
+ return `${css(own)};${css(app)}`;
15
+ return { ...own, ...app };
16
+ }
17
+ export function withStyle(zag, style) {
18
+ return mergeProps(zag, () => ({ style: style() }));
19
+ }
@@ -0,0 +1,18 @@
1
+ import { type Accessor } from "solid-js";
2
+ /** The props an overlay's machine has for the control that opens it. */
3
+ export type TriggerProps = Record<string, unknown>;
4
+ /** Not exported from the package: only this package's controls and overlays use it. */
5
+ export declare const TriggerContext: import("solid-js").Context<Accessor<TriggerProps> | null>;
6
+ /**
7
+ * For an overlay: its trigger props, joined with those of any overlay around it, to provide
8
+ * as `<TriggerContext value={...}>` around the control. A Tooltip around a Menu's button gives
9
+ * the button both sets; the handlers of both run.
10
+ */
11
+ export declare function provideTrigger(own: Accessor<TriggerProps>): Accessor<TriggerProps>;
12
+ /**
13
+ * For a control that can open an overlay: its own props, after those of the overlays it opens.
14
+ * Its own attributes win, its own handlers run first, and its class is added to theirs, so the
15
+ * own class must be a string. While `inert` is true, as for a loading button, the overlays get
16
+ * none of its events and so do not open. Spread the result on the element.
17
+ */
18
+ export declare function withTrigger<T extends object>(own: Accessor<T>, inert?: Accessor<boolean>): T;
@@ -0,0 +1,18 @@
1
+ import { mergeProps } from "@zag-js/solid";
2
+ import { createContext, useContext } from "solid-js";
3
+ export const TriggerContext = createContext(null);
4
+ export function provideTrigger(own) {
5
+ const outer = useContext(TriggerContext);
6
+ const merged = mergeProps(() => outer?.() ?? {}, own);
7
+ return () => merged;
8
+ }
9
+ export function withTrigger(own, inert) {
10
+ const trigger = useContext(TriggerContext);
11
+ const overlays = () => {
12
+ const props = trigger?.() ?? {};
13
+ if (!inert?.())
14
+ return props;
15
+ return Object.fromEntries(Object.entries(props).filter(([key]) => !key.startsWith("on")));
16
+ };
17
+ return mergeProps(overlays, own);
18
+ }
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@xds/solid",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "The xds design system's components for Solid.",
5
+ "keywords": [
6
+ "design-system",
7
+ "design-tokens",
8
+ "components",
9
+ "solid"
10
+ ],
11
+ "license": "MIT",
12
+ "homepage": "https://github.com/kjmin-dev/xds/blob/main/docs/library.md",
13
+ "bugs": "https://github.com/kjmin-dev/xds/issues",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/kjmin-dev/xds.git",
17
+ "directory": "packages/ui-solid"
18
+ },
19
+ "type": "module",
20
+ "sideEffects": [
21
+ "*.css"
22
+ ],
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/source/index.d.ts",
26
+ "solid": "./dist/source/index.jsx",
27
+ "default": "./dist/dom/index.js"
28
+ },
29
+ "./preview": {
30
+ "types": "./dist/source/preview.d.ts",
31
+ "solid": "./dist/source/preview.jsx",
32
+ "default": "./dist/dom/preview.js"
33
+ },
34
+ "./styles.css": "./styles.css",
35
+ "./tailwind.css": "./tailwind.css",
36
+ "./page.css": "./page.css",
37
+ "./package.json": "./package.json"
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "styles.css",
42
+ "tailwind.css",
43
+ "page.css"
44
+ ],
45
+ "dependencies": {
46
+ "@xds/tokens": "0.1.0",
47
+ "@xds/core": "0.1.0",
48
+ "@internationalized/date": "3.12.4",
49
+ "@zag-js/accordion": "2.0.0-next.4",
50
+ "@zag-js/aria-hidden": "2.0.0-next.4",
51
+ "@zag-js/date-picker": "2.0.0-next.4",
52
+ "@zag-js/dialog": "2.0.0-next.4",
53
+ "@zag-js/menu": "2.0.0-next.4",
54
+ "@zag-js/remove-scroll": "2.0.0-next.4",
55
+ "@zag-js/select": "2.0.0-next.4",
56
+ "@zag-js/slider": "2.0.0-next.4",
57
+ "@zag-js/solid": "2.0.0-next.4",
58
+ "@zag-js/tabs": "2.0.0-next.4",
59
+ "@zag-js/tooltip": "2.0.0-next.4"
60
+ },
61
+ "peerDependencies": {
62
+ "@solidjs/web": "^2.0.0-rc.21",
63
+ "solid-js": "^2.0.0-rc.21"
64
+ }
65
+ }
package/page.css ADDED
@@ -0,0 +1,20 @@
1
+ /* The page itself: its font and how its text breaks, and the body's colors and text. An app
2
+ that takes the components as a library may leave these to its own page. */
3
+
4
+ @layer xds.base {
5
+ :root {
6
+ font-family: var(--xds-font-family-sans);
7
+ /* Korean breaks between words, not between syllables. */
8
+ word-break: keep-all;
9
+ /* Long unbroken strings (URLs, email addresses) still wrap instead of overflowing. */
10
+ overflow-wrap: anywhere;
11
+ }
12
+
13
+ body {
14
+ margin: 0;
15
+ background-color: var(--xds-color-background-base);
16
+ color: var(--xds-color-text-primary);
17
+ font-size: var(--xds-typography-body-size);
18
+ line-height: var(--xds-typography-body-line-height);
19
+ }
20
+ }