@xds/solid 1.0.1 → 1.2.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.
- package/dist/dom/Accordion.js +3 -2
- package/dist/dom/Avatar.js +17 -13
- package/dist/dom/AvatarStack.js +17 -13
- package/dist/dom/Badge.js +12 -10
- package/dist/dom/Banner.js +25 -15
- package/dist/dom/Breadcrumb.js +87 -0
- package/dist/dom/Button.js +10 -3
- package/dist/dom/Card.js +31 -26
- package/dist/dom/Checkbox.js +57 -26
- package/dist/dom/Chip.js +21 -17
- package/dist/dom/ChipBar.js +17 -13
- package/dist/dom/Combobox.js +295 -0
- package/dist/dom/CountBadge.js +28 -23
- package/dist/dom/DatePicker.js +13 -7
- package/dist/dom/DateRangePicker.js +16 -10
- package/dist/dom/Dialog.js +3 -2
- package/dist/dom/Divider.js +12 -10
- package/dist/dom/EmptyState.js +14 -11
- package/dist/dom/Icon.js +30 -19
- package/dist/dom/IconButton.js +10 -3
- package/dist/dom/Labels.js +26 -0
- package/dist/dom/Link.js +62 -0
- package/dist/dom/ListRow.js +34 -28
- package/dist/dom/MediaCard.js +32 -23
- package/dist/dom/Menu.js +18 -15
- package/dist/dom/Pagination.js +132 -0
- package/dist/dom/Popover.js +126 -0
- package/dist/dom/ProgressBar.js +27 -15
- package/dist/dom/RadioGroup.js +44 -23
- package/dist/dom/SearchField.js +58 -32
- package/dist/dom/SectionHeader.js +17 -10
- package/dist/dom/SegmentedControl.js +33 -19
- package/dist/dom/Select.js +91 -51
- package/dist/dom/Sidebar.js +17 -13
- package/dist/dom/Skeleton.js +15 -13
- package/dist/dom/Slider.js +15 -7
- package/dist/dom/Spinner.js +23 -17
- package/dist/dom/Switch.js +49 -24
- package/dist/dom/Table.js +150 -0
- package/dist/dom/Tabs.js +16 -6
- package/dist/dom/Text.js +6 -3
- package/dist/dom/TextField.js +37 -19
- package/dist/dom/Thumbnail.js +21 -14
- package/dist/dom/TimePicker.js +245 -0
- package/dist/dom/Toast.js +19 -20
- package/dist/dom/ToastQueue.js +59 -0
- package/dist/dom/Tooltip.js +10 -6
- package/dist/dom/base.js +16 -0
- package/dist/dom/controllable.js +44 -0
- package/dist/dom/index.js +10 -1
- package/dist/dom/modal-popover.js +2 -2
- package/dist/dom/presence.js +3 -2
- package/dist/dom/preview.js +20 -1
- package/dist/dom/root.js +16 -4
- package/dist/dom/rows.js +13 -0
- package/dist/dom/trigger.js +5 -3
- package/dist/source/Accordion.jsx +3 -2
- package/dist/source/Avatar.d.ts +1 -1
- package/dist/source/Avatar.jsx +2 -1
- package/dist/source/AvatarStack.d.ts +1 -1
- package/dist/source/AvatarStack.jsx +2 -1
- package/dist/source/Badge.d.ts +1 -1
- package/dist/source/Badge.jsx +2 -1
- package/dist/source/Banner.d.ts +1 -1
- package/dist/source/Banner.jsx +5 -2
- package/dist/source/Breadcrumb.d.ts +9 -0
- package/dist/source/Breadcrumb.jsx +26 -0
- package/dist/source/Button.d.ts +5 -1
- package/dist/source/Button.jsx +5 -2
- package/dist/source/Card.d.ts +1 -1
- package/dist/source/Card.jsx +3 -2
- package/dist/source/Checkbox.d.ts +10 -4
- package/dist/source/Checkbox.jsx +26 -8
- package/dist/source/Chip.d.ts +1 -1
- package/dist/source/Chip.jsx +2 -1
- package/dist/source/ChipBar.d.ts +1 -1
- package/dist/source/ChipBar.jsx +2 -1
- package/dist/source/Combobox.d.ts +16 -0
- package/dist/source/Combobox.jsx +137 -0
- package/dist/source/CountBadge.d.ts +1 -1
- package/dist/source/CountBadge.jsx +3 -2
- package/dist/source/DatePicker.jsx +13 -7
- package/dist/source/DateRangePicker.jsx +16 -10
- package/dist/source/Dialog.jsx +3 -2
- package/dist/source/Divider.d.ts +1 -1
- package/dist/source/Divider.jsx +2 -1
- package/dist/source/EmptyState.d.ts +1 -1
- package/dist/source/EmptyState.jsx +2 -1
- package/dist/source/Icon.d.ts +1 -1
- package/dist/source/Icon.jsx +2 -1
- package/dist/source/IconButton.d.ts +5 -1
- package/dist/source/IconButton.jsx +5 -2
- package/dist/source/Labels.d.ts +17 -0
- package/dist/source/Labels.jsx +11 -0
- package/dist/source/Link.d.ts +20 -0
- package/dist/source/Link.jsx +21 -0
- package/dist/source/ListRow.d.ts +1 -1
- package/dist/source/ListRow.jsx +3 -2
- package/dist/source/MediaCard.d.ts +1 -1
- package/dist/source/MediaCard.jsx +3 -2
- package/dist/source/Menu.d.ts +1 -1
- package/dist/source/Menu.jsx +11 -3
- package/dist/source/Pagination.d.ts +12 -0
- package/dist/source/Pagination.jsx +51 -0
- package/dist/source/Popover.d.ts +19 -0
- package/dist/source/Popover.jsx +65 -0
- package/dist/source/ProgressBar.d.ts +1 -1
- package/dist/source/ProgressBar.jsx +2 -1
- package/dist/source/RadioGroup.d.ts +5 -2
- package/dist/source/RadioGroup.jsx +18 -5
- package/dist/source/SearchField.d.ts +11 -3
- package/dist/source/SearchField.jsx +26 -12
- package/dist/source/SectionHeader.d.ts +1 -1
- package/dist/source/SectionHeader.jsx +2 -1
- package/dist/source/SegmentedControl.d.ts +4 -3
- package/dist/source/SegmentedControl.jsx +16 -5
- package/dist/source/Select.d.ts +10 -1
- package/dist/source/Select.jsx +46 -11
- package/dist/source/Sidebar.d.ts +1 -1
- package/dist/source/Sidebar.jsx +2 -1
- package/dist/source/Skeleton.jsx +2 -2
- package/dist/source/Slider.d.ts +2 -2
- package/dist/source/Slider.jsx +14 -6
- package/dist/source/Spinner.d.ts +1 -1
- package/dist/source/Spinner.jsx +2 -1
- package/dist/source/Switch.d.ts +10 -4
- package/dist/source/Switch.jsx +18 -6
- package/dist/source/Table.d.ts +17 -0
- package/dist/source/Table.jsx +46 -0
- package/dist/source/Tabs.d.ts +2 -2
- package/dist/source/Tabs.jsx +16 -5
- package/dist/source/Text.d.ts +1 -1
- package/dist/source/Text.jsx +2 -1
- package/dist/source/TextField.d.ts +12 -3
- package/dist/source/TextField.jsx +24 -9
- package/dist/source/Thumbnail.d.ts +1 -1
- package/dist/source/Thumbnail.jsx +2 -1
- package/dist/source/TimePicker.d.ts +19 -0
- package/dist/source/TimePicker.jsx +137 -0
- package/dist/source/Toast.d.ts +1 -1
- package/dist/source/Toast.jsx +2 -1
- package/dist/source/ToastQueue.d.ts +19 -0
- package/dist/source/ToastQueue.jsx +27 -0
- package/dist/source/Tooltip.jsx +4 -3
- package/dist/source/base.d.ts +15 -0
- package/dist/source/base.js +15 -0
- package/dist/source/controllable.d.ts +30 -0
- package/dist/source/controllable.js +30 -0
- package/dist/source/index.d.ts +10 -1
- package/dist/source/index.js +9 -0
- package/dist/source/modal-popover.js +2 -2
- package/dist/source/presence.js +3 -2
- package/dist/source/preview.d.ts +10 -2
- package/dist/source/preview.jsx +12 -2
- package/dist/source/root.d.ts +14 -4
- package/dist/source/root.js +7 -2
- package/dist/source/rows.d.ts +8 -0
- package/dist/source/rows.js +5 -0
- package/dist/source/trigger.d.ts +4 -2
- package/dist/source/trigger.js +2 -2
- package/eject/files/Accordion.tsx +138 -0
- package/eject/files/Avatar.tsx +48 -0
- package/eject/files/AvatarStack.tsx +51 -0
- package/eject/files/Badge.tsx +39 -0
- package/eject/files/Banner.tsx +80 -0
- package/eject/files/Breadcrumb.tsx +57 -0
- package/eject/files/Button.tsx +90 -0
- package/eject/files/Card.tsx +100 -0
- package/eject/files/Checkbox.tsx +100 -0
- package/eject/files/Chip.tsx +40 -0
- package/eject/files/ChipBar.tsx +34 -0
- package/eject/files/Combobox.tsx +200 -0
- package/eject/files/CountBadge.tsx +55 -0
- package/eject/files/DatePicker.tsx +225 -0
- package/eject/files/DateRangePicker.tsx +319 -0
- package/eject/files/Dialog.tsx +117 -0
- package/eject/files/Divider.tsx +21 -0
- package/eject/files/EmptyState.tsx +39 -0
- package/eject/files/Icon.tsx +37 -0
- package/eject/files/IconButton.tsx +76 -0
- package/eject/files/Link.tsx +61 -0
- package/eject/files/ListRow.tsx +94 -0
- package/eject/files/MediaCard.tsx +116 -0
- package/eject/files/Menu.tsx +190 -0
- package/eject/files/Pagination.tsx +109 -0
- package/eject/files/Popover.tsx +124 -0
- package/eject/files/ProgressBar.tsx +37 -0
- package/eject/files/RadioGroup.tsx +138 -0
- package/eject/files/SearchField.tsx +124 -0
- package/eject/files/SectionHeader.tsx +59 -0
- package/eject/files/SegmentedControl.tsx +79 -0
- package/eject/files/Select.tsx +290 -0
- package/eject/files/Sidebar.tsx +156 -0
- package/eject/files/Skeleton.tsx +33 -0
- package/eject/files/Slider.tsx +131 -0
- package/eject/files/Spinner.tsx +44 -0
- package/eject/files/Switch.tsx +88 -0
- package/eject/files/Table.tsx +98 -0
- package/eject/files/Tabs.tsx +87 -0
- package/eject/files/Text.tsx +38 -0
- package/eject/files/TextField.tsx +171 -0
- package/eject/files/Thumbnail.tsx +84 -0
- package/eject/files/TimePicker.tsx +237 -0
- package/eject/files/Toast.tsx +100 -0
- package/eject/files/ToastQueue.tsx +62 -0
- package/eject/files/Tooltip.tsx +135 -0
- package/eject/files/accordion.css +89 -0
- package/eject/files/accordion.ts +67 -0
- package/eject/files/avatar-stack.ts +57 -0
- package/eject/files/avatar.ts +42 -0
- package/eject/files/badge.ts +30 -0
- package/eject/files/banner.ts +71 -0
- package/eject/files/base.css +38 -0
- package/eject/files/breadcrumb.css +51 -0
- package/eject/files/breadcrumb.ts +42 -0
- package/eject/files/button.css +241 -0
- package/eject/files/button.ts +106 -0
- package/eject/files/card.ts +58 -0
- package/eject/files/checkbox.ts +52 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/combobox.css +269 -0
- package/eject/files/combobox.ts +85 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +375 -0
- package/eject/files/date-picker.ts +280 -0
- package/eject/files/date-range-picker.ts +338 -0
- package/eject/files/dialog.css +139 -0
- package/eject/files/dialog.ts +15 -0
- package/eject/files/divider.ts +5 -0
- package/eject/files/empty-state.ts +22 -0
- package/eject/files/icon.ts +36 -0
- package/eject/files/link.css +64 -0
- package/eject/files/link.ts +63 -0
- package/eject/files/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +192 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/overlay.css +40 -0
- package/eject/files/pagination.css +106 -0
- package/eject/files/pagination.ts +68 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/popover.css +101 -0
- package/eject/files/popover.ts +37 -0
- package/eject/files/progress-bar.ts +26 -0
- package/eject/files/radio-group.css +184 -0
- package/eject/files/radio-group.ts +30 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +33 -0
- package/eject/files/select.css +347 -0
- package/eject/files/select.ts +77 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +160 -0
- package/eject/files/slider.ts +80 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +45 -0
- package/eject/files/table.css +107 -0
- package/eject/files/table.ts +84 -0
- package/eject/files/tabs.css +120 -0
- package/eject/files/tabs.ts +37 -0
- package/eject/files/text-field.css +225 -0
- package/eject/files/text-field.ts +64 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/time-picker.ts +113 -0
- package/eject/files/toast-queue.ts +64 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +111 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +1027 -0
- package/package.json +12 -4
- package/styles.css +1066 -167
- package/tailwind.css +1295 -218
package/dist/source/Button.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type ButtonBaseProps } from "@xds/core";
|
|
2
2
|
import type { JSX } from "@solidjs/web";
|
|
3
3
|
import { type Element } from "solid-js";
|
|
4
|
-
import type
|
|
4
|
+
import { type RootProps } from "./root.ts";
|
|
5
5
|
export type { ButtonVariant, ControlSize } from "@xds/core";
|
|
6
6
|
export type ButtonProps = ButtonBaseProps & RootProps & {
|
|
7
7
|
onPress?: () => void;
|
|
8
|
+
onFocus?: JSX.FocusEventHandler<HTMLButtonElement, FocusEvent>;
|
|
9
|
+
onBlur?: JSX.FocusEventHandler<HTMLButtonElement, FocusEvent>;
|
|
10
|
+
/** The native button. */
|
|
11
|
+
ref?: JSX.Ref<HTMLButtonElement>;
|
|
8
12
|
/** Leave it out for a button that holds only an icon, and name that one with `aria-label`. */
|
|
9
13
|
children?: Element;
|
|
10
14
|
};
|
package/dist/source/Button.jsx
CHANGED
|
@@ -2,6 +2,7 @@ import { BUTTON_ICON, buttonClass, classes, isHeld } from "@xds/core";
|
|
|
2
2
|
import { children, createMemo, Show } from "solid-js";
|
|
3
3
|
import { useDefaults } from "./Defaults.jsx";
|
|
4
4
|
import { Icon } from "./Icon.jsx";
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
5
6
|
import { Spinner } from "./Spinner.jsx";
|
|
6
7
|
import { withTrigger } from "./trigger.js";
|
|
7
8
|
export function Button(props) {
|
|
@@ -32,8 +33,10 @@ export function Button(props) {
|
|
|
32
33
|
}
|
|
33
34
|
props.onPress?.();
|
|
34
35
|
},
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
onFocus: (event) => props.onFocus?.(event),
|
|
37
|
+
onBlur: (event) => props.onBlur?.(event),
|
|
38
|
+
})), () => props.loading === true, rootAttributes(props));
|
|
39
|
+
return (<button ref={props.ref} {...attributes}>
|
|
37
40
|
<Show when={props.loading}>
|
|
38
41
|
<Show when={props.iconStart} fallback={<Spinner size="sm"/>}>
|
|
39
42
|
|
package/dist/source/Card.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CardBaseProps } from "@xds/core";
|
|
2
2
|
import { type Element } from "solid-js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RootProps } from "./root.ts";
|
|
4
4
|
export type CardProps = CardBaseProps & RootProps & {
|
|
5
5
|
/** Sit across from the title. A pressable card takes none: it is one button already. */
|
|
6
6
|
actions?: Element;
|
package/dist/source/Card.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CARD_PARTS, cardClass, cardMediaClass, classes, rootPart, } from "@xds/core";
|
|
2
2
|
import { dynamic } from "@solidjs/web";
|
|
3
3
|
import { children, Show } from "solid-js";
|
|
4
|
+
import { rootAttributes } from "./root.js";
|
|
4
5
|
const ROOT = rootPart("Card");
|
|
5
6
|
export function Card(props) {
|
|
6
7
|
const media = children(() => props.media);
|
|
@@ -36,10 +37,10 @@ export function Card(props) {
|
|
|
36
37
|
const content = () => (<Show when={props.flush} fallback={parts()}>
|
|
37
38
|
<Box class={CARD_PARTS.flush}>{parts()}</Box>
|
|
38
39
|
</Show>);
|
|
39
|
-
return (<Show when={pressable()} fallback={<section aria-current={props.selected ? "true" : undefined} class={surface()} style={props.style}>
|
|
40
|
+
return (<Show when={pressable()} fallback={<section {...rootAttributes(props)} aria-current={props.selected ? "true" : undefined} class={surface()} style={props.style}>
|
|
40
41
|
{content()}
|
|
41
42
|
</section>}>
|
|
42
|
-
<button type="button" onClick={() => props.onPress?.()} aria-pressed={props.selected === undefined ? undefined : props.selected ? "true" : "false"} class={surface()} style={props.style}>
|
|
43
|
+
<button {...rootAttributes(props)} type="button" onClick={() => props.onPress?.()} aria-pressed={props.selected === undefined ? undefined : props.selected ? "true" : "false"} class={surface()} style={props.style}>
|
|
43
44
|
{content()}
|
|
44
45
|
</button>
|
|
45
46
|
</Show>);
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { type CheckboxBaseProps } from "@xds/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { JSX } from "@solidjs/web";
|
|
3
|
+
import { type RootProps } from "./root.ts";
|
|
3
4
|
export type CheckboxProps = CheckboxBaseProps & RootProps & {
|
|
4
|
-
onChange
|
|
5
|
+
onChange?: (checked: boolean) => void;
|
|
6
|
+
onFocus?: JSX.FocusEventHandler<HTMLInputElement, FocusEvent>;
|
|
7
|
+
onBlur?: JSX.FocusEventHandler<HTMLInputElement, FocusEvent>;
|
|
8
|
+
/** The native checkbox. */
|
|
9
|
+
ref?: JSX.Ref<HTMLInputElement>;
|
|
5
10
|
};
|
|
6
11
|
/**
|
|
7
12
|
* A choice that is applied later, with the form it belongs to. A native checkbox: the input is
|
|
8
|
-
* 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`. With `indeterminate` it shows a dash and is reported as mixed.
|
|
9
15
|
*/
|
|
10
|
-
export declare function Checkbox(props: CheckboxProps):
|
|
16
|
+
export declare function Checkbox(props: CheckboxProps): JSX.Element;
|
package/dist/source/Checkbox.jsx
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Show } from "solid-js";
|
|
1
|
+
import { checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMark, checkboxMarkClass, classes, isControlled, rootPart, } from "@xds/core";
|
|
2
|
+
import { createEffect, Show } from "solid-js";
|
|
3
|
+
import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
|
|
3
4
|
import { keepChecked } from "./controlled.js";
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
4
6
|
const ROOT = rootPart("Checkbox");
|
|
5
7
|
export function Checkbox(props) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const controlled = () => isControlled(props, "checked");
|
|
9
|
+
const defaultChecked = () => props.defaultChecked ?? false;
|
|
10
|
+
const checked = createControllable({
|
|
11
|
+
controlled,
|
|
12
|
+
value: () => props.checked ?? false,
|
|
13
|
+
defaultValue: defaultChecked,
|
|
14
|
+
onChange: (next) => props.onChange?.(next),
|
|
15
|
+
});
|
|
16
|
+
let input;
|
|
17
|
+
resetWithForm(() => input, controlled, checked.reset);
|
|
18
|
+
const indeterminate = () => props.indeterminate ?? false;
|
|
19
|
+
createEffect(indeterminate, (value) => {
|
|
20
|
+
if (input)
|
|
21
|
+
input.indeterminate = value;
|
|
22
|
+
});
|
|
23
|
+
return (<label {...rootAttributes(props)} class={classes(ROOT, checkboxClass, props.class)} style={props.style}>
|
|
24
|
+
<input ref={composeRefs((element) => (input = element), () => props.ref)} type="checkbox" aria-label={props["aria-label"]} class="peer sr-only" checked={checked.value()} defaultChecked={controlled() ? checked.value() : defaultChecked()} disabled={props.disabled} name={props.name || undefined} onChange={(event) => {
|
|
25
|
+
event.currentTarget.indeterminate = indeterminate();
|
|
26
|
+
checked.set(event.currentTarget.checked);
|
|
27
|
+
keepChecked(event.currentTarget, checked.value);
|
|
28
|
+
}} onFocus={(event) => props.onFocus?.(event)} onBlur={(event) => props.onBlur?.(event)}/>
|
|
11
29
|
<span class={checkboxBoxClass}>
|
|
12
30
|
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class={checkboxMarkClass}>
|
|
13
|
-
<path d={
|
|
31
|
+
<path d={checkboxMark(indeterminate())} stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
14
32
|
</svg>
|
|
15
33
|
</span>
|
|
16
34
|
<Show when={props.label}>
|
package/dist/source/Chip.d.ts
CHANGED
package/dist/source/Chip.jsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { chipClass, chipIcon, classes, rootPart } from "@xds/core";
|
|
2
2
|
import { Show } from "solid-js";
|
|
3
3
|
import { Icon } from "./Icon.jsx";
|
|
4
|
+
import { rootAttributes } from "./root.js";
|
|
4
5
|
const ROOT = rootPart("Chip");
|
|
5
6
|
export function Chip(props) {
|
|
6
|
-
return (<button type="button" aria-pressed={props.selected ? "true" : "false"} disabled={props.disabled} onClick={() => props.onPress?.()} class={classes(ROOT, chipClass(props.selected), props.class)} style={props.style}>
|
|
7
|
+
return (<button {...rootAttributes(props)} type="button" aria-pressed={props.selected ? "true" : "false"} disabled={props.disabled} onClick={() => props.onPress?.()} class={classes(ROOT, chipClass(props.selected), props.class)} style={props.style}>
|
|
7
8
|
<Show when={chipIcon({ selected: props.selected, iconStart: props.iconStart })}>
|
|
8
9
|
{(name) => <Icon name={name()} size="sm"/>}
|
|
9
10
|
</Show>
|
package/dist/source/ChipBar.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ChipBarBaseProps } from "@xds/core";
|
|
2
2
|
import type { Element } from "solid-js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RootProps } from "./root.ts";
|
|
4
4
|
export type ChipBarProps = ChipBarBaseProps & RootProps & {
|
|
5
5
|
/** The chips. Which of them are selected is the app's business: the bar holds no state. */
|
|
6
6
|
children: Element;
|
package/dist/source/ChipBar.jsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { chipBarClass, classes, rootPart } from "@xds/core";
|
|
2
|
+
import { rootAttributes } from "./root.js";
|
|
2
3
|
const ROOT = rootPart("ChipBar");
|
|
3
4
|
export function ChipBar(props) {
|
|
4
|
-
return (<div role="group" aria-label={props.label} class={classes(ROOT, chipBarClass, props.class)} style={props.style}>
|
|
5
|
+
return (<div {...rootAttributes(props)} role="group" aria-label={props.label} class={classes(ROOT, chipBarClass, props.class)} style={props.style}>
|
|
5
6
|
{props.children}
|
|
6
7
|
</div>);
|
|
7
8
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ComboboxBaseProps } from "@xds/core";
|
|
2
|
+
import { type RootProps } from "./root.ts";
|
|
3
|
+
export type ComboboxProps<Value extends string = string> = ComboboxBaseProps<Value> & RootProps & {
|
|
4
|
+
onChange?: (value: Value) => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A field for choosing one option from a list by typing part of its name. As the person types,
|
|
8
|
+
* the options whose label holds what was typed open under it, those that start with it first,
|
|
9
|
+
* and the first is highlighted, so Enter chooses it. Choosing an option calls `onChange`, puts
|
|
10
|
+
* its label in the field and closes the list. Text that names no option goes back to the chosen
|
|
11
|
+
* option's label when the field is left. When nothing matches, the list says so.
|
|
12
|
+
*
|
|
13
|
+
* Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
|
|
14
|
+
* `undefined`, it shows that.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Combobox<Value extends string = string>(props: ComboboxProps<Value>): import("@solidjs/web").JSX.Element;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { space } from "@xds/tokens";
|
|
2
|
+
import { COMBOBOX_PARTS as PARTS, classes, isControlled, matchOptions, readCssPx, selectOptionIds, } from "@xds/core";
|
|
3
|
+
import * as combobox from "@zag-js/combobox";
|
|
4
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/solid";
|
|
5
|
+
import { createMemo, createSignal, createUniqueId, For, Show } from "solid-js";
|
|
6
|
+
import { createControllable, resetWithForm } from "./controllable.js";
|
|
7
|
+
import { Icon } from "./Icon.jsx";
|
|
8
|
+
import { useLabels } from "./Labels.jsx";
|
|
9
|
+
import { Portal } from "./portal.jsx";
|
|
10
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
11
|
+
import { createItemProps } from "./rows.js";
|
|
12
|
+
export function Combobox(props) {
|
|
13
|
+
const id = createUniqueId();
|
|
14
|
+
const descriptionId = `${id}-description`;
|
|
15
|
+
const errorId = `${id}-error`;
|
|
16
|
+
const labels = useLabels();
|
|
17
|
+
const invalid = () => props.error !== undefined;
|
|
18
|
+
const controlled = () => isControlled(props, "value");
|
|
19
|
+
const value = createControllable({
|
|
20
|
+
controlled,
|
|
21
|
+
value: () => props.value,
|
|
22
|
+
defaultValue: () => props.defaultValue,
|
|
23
|
+
onChange: (next) => {
|
|
24
|
+
if (next !== undefined)
|
|
25
|
+
props.onChange?.(next);
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
let element;
|
|
29
|
+
resetWithForm(() => element, controlled, value.reset);
|
|
30
|
+
const [query, setQuery] = createSignal("");
|
|
31
|
+
const shown = createMemo(() => matchOptions(props.options, query()));
|
|
32
|
+
const collection = createMemo(() => combobox.collection({
|
|
33
|
+
items: shown(),
|
|
34
|
+
itemToValue: (option) => option.value,
|
|
35
|
+
itemToString: (option) => option.label,
|
|
36
|
+
}));
|
|
37
|
+
const service = useMachine(combobox.machine, () => ({
|
|
38
|
+
id,
|
|
39
|
+
ids: { root: props.id },
|
|
40
|
+
collection: collection(),
|
|
41
|
+
value: value.value() === undefined ? [] : [value.value()],
|
|
42
|
+
onValueChange: (details) => {
|
|
43
|
+
const next = details.value[0];
|
|
44
|
+
if (next !== undefined)
|
|
45
|
+
value.set(next);
|
|
46
|
+
},
|
|
47
|
+
onInputValueChange: (details) => {
|
|
48
|
+
if (details.reason === "input-change")
|
|
49
|
+
setQuery(details.inputValue);
|
|
50
|
+
},
|
|
51
|
+
onOpenChange: (details) => {
|
|
52
|
+
if (!details.open)
|
|
53
|
+
setQuery("");
|
|
54
|
+
},
|
|
55
|
+
inputBehavior: "autohighlight",
|
|
56
|
+
selectionBehavior: "replace",
|
|
57
|
+
openOnClick: true,
|
|
58
|
+
disabled: props.disabled,
|
|
59
|
+
invalid: invalid(),
|
|
60
|
+
placeholder: props.placeholder,
|
|
61
|
+
positioning: {
|
|
62
|
+
placement: "bottom-start",
|
|
63
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
64
|
+
sameWidth: true,
|
|
65
|
+
overflowPadding: readCssPx(null, "--xds-space-3", space[3]),
|
|
66
|
+
},
|
|
67
|
+
}));
|
|
68
|
+
const api = createMemo(() => combobox.connect(service, normalizeProps));
|
|
69
|
+
const input = mergeProps(() => api().getInputProps(), {
|
|
70
|
+
onBlur: () => {
|
|
71
|
+
const chosen = props.options.find((option) => option.value === value.value())?.label ?? "";
|
|
72
|
+
const now = combobox.connect(service, normalizeProps);
|
|
73
|
+
if (now.inputValue !== chosen)
|
|
74
|
+
now.setInputValue(chosen, "script");
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
78
|
+
return (<div {...root} ref={(node) => (element = node)} class={classes("xds-combobox", props.class)}>
|
|
79
|
+
<label {...api().getLabelProps()} class={PARTS.label}>
|
|
80
|
+
{props.label}
|
|
81
|
+
</label>
|
|
82
|
+
<div {...api().getControlProps()} class={PARTS.control}>
|
|
83
|
+
<input {...input} aria-describedby={invalid() ? errorId : props.description ? descriptionId : undefined} class={PARTS.input}/>
|
|
84
|
+
<Icon name="chevrons-up-down" size="sm" class={PARTS.icon}/>
|
|
85
|
+
</div>
|
|
86
|
+
<div class={PARTS.footer}>
|
|
87
|
+
<Show when={!invalid() && props.description}>
|
|
88
|
+
<span id={descriptionId} class={PARTS.description}>
|
|
89
|
+
{props.description}
|
|
90
|
+
</span>
|
|
91
|
+
</Show>
|
|
92
|
+
<span id={errorId} class={PARTS.error} aria-live="polite">
|
|
93
|
+
{props.error}
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<Show when={props.name !== undefined}>
|
|
98
|
+
<input type="hidden" name={props.name} value={value.value() ?? ""}/>
|
|
99
|
+
</Show>
|
|
100
|
+
<Portal>
|
|
101
|
+
<div {...api().getPositionerProps()} class={PARTS.positioner}>
|
|
102
|
+
|
|
103
|
+
<div {...api().getContentProps()} class={PARTS.content}>
|
|
104
|
+
<Show when={shown().length > 0} fallback={<div {...api().getEmptyProps()} class={PARTS.empty}>
|
|
105
|
+
{props.emptyLabel ?? labels().noMatches}
|
|
106
|
+
</div>}>
|
|
107
|
+
<div {...api().getListProps()} class={PARTS.list}>
|
|
108
|
+
<For each={shown()}>
|
|
109
|
+
{(option, index) => {
|
|
110
|
+
const ids = () => selectOptionIds(id, index());
|
|
111
|
+
const itemProps = createItemProps(() => api().getItemProps({ item: option }));
|
|
112
|
+
const textProps = createItemProps(() => api().getItemTextProps({ item: option }));
|
|
113
|
+
const selected = createMemo(() => api().getItemState({ item: option }).selected);
|
|
114
|
+
return (<div {...itemProps()} aria-labelledby={ids().label} aria-describedby={option.description ? ids().description : undefined} class={PARTS.item}>
|
|
115
|
+
<span class={PARTS.itemWords}>
|
|
116
|
+
<span {...textProps()} id={ids().label} class={PARTS.itemLabel}>
|
|
117
|
+
{option.label}
|
|
118
|
+
</span>
|
|
119
|
+
<Show when={option.description}>
|
|
120
|
+
<span id={ids().description} class={PARTS.itemDescription}>
|
|
121
|
+
{option.description}
|
|
122
|
+
</span>
|
|
123
|
+
</Show>
|
|
124
|
+
</span>
|
|
125
|
+
<Show when={selected()}>
|
|
126
|
+
<Icon name="check" size="sm"/>
|
|
127
|
+
</Show>
|
|
128
|
+
</div>);
|
|
129
|
+
}}
|
|
130
|
+
</For>
|
|
131
|
+
</div>
|
|
132
|
+
</Show>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</Portal>
|
|
136
|
+
</div>);
|
|
137
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CountBadgeBaseProps } from "@xds/core";
|
|
2
2
|
import { type Element } from "solid-js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RootProps } from "./root.ts";
|
|
4
4
|
export type CountBadgeProps = CountBadgeBaseProps & RootProps & {
|
|
5
5
|
/** What the count belongs to: an icon, an avatar, a button. The badge sits on its corner. */
|
|
6
6
|
children?: Element;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { countBadgeAnchorClass, countBadgeClass, countBadgeText, classes, rootPart, } from "@xds/core";
|
|
2
2
|
import { children, Show } from "solid-js";
|
|
3
|
+
import { rootAttributes } from "./root.js";
|
|
3
4
|
const ROOT = rootPart("CountBadge");
|
|
4
5
|
export function CountBadge(props) {
|
|
5
6
|
const child = children(() => props.children);
|
|
6
7
|
const badge = (onChild) => (<Show when={props.count > 0}>
|
|
7
|
-
<span role={props.label ? "img" : undefined} aria-label={props.label || undefined} class={classes(!onChild && ROOT, countBadgeClass(onChild), !onChild && props.class)} style={onChild ? undefined : props.style}>
|
|
8
|
+
<span {...(onChild ? {} : rootAttributes(props))} role={props.label ? "img" : undefined} aria-label={props.label || undefined} class={classes(!onChild && ROOT, countBadgeClass(onChild), !onChild && props.class)} style={onChild ? undefined : props.style}>
|
|
8
9
|
{countBadgeText(props.count, props.max)}
|
|
9
10
|
</span>
|
|
10
11
|
</Show>);
|
|
11
12
|
return (<Show when={child() != null} fallback={badge(false)}>
|
|
12
|
-
<span class={classes(ROOT, countBadgeAnchorClass, props.class)} style={props.style}>
|
|
13
|
+
<span {...rootAttributes(props)} class={classes(ROOT, countBadgeAnchorClass, props.class)} style={props.style}>
|
|
13
14
|
{child()}
|
|
14
15
|
{badge(true)}
|
|
15
16
|
</span>
|
|
@@ -4,22 +4,28 @@ import * as datePicker from "@zag-js/date-picker";
|
|
|
4
4
|
import { normalizeProps, useMachine } from "@zag-js/solid";
|
|
5
5
|
import { createEffect, createMemo, createUniqueId, For, Show } from "solid-js";
|
|
6
6
|
import { Icon } from "./Icon.jsx";
|
|
7
|
+
import { useLabels } from "./Labels.jsx";
|
|
7
8
|
import { modalPopover } from "./modal-popover.js";
|
|
8
9
|
import { Portal } from "./portal.jsx";
|
|
9
10
|
import { createPresence } from "./presence.js";
|
|
10
|
-
import { withStyle } from "./root.js";
|
|
11
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
11
12
|
export function DatePicker(props) {
|
|
12
13
|
const id = createUniqueId();
|
|
13
14
|
const ids = datePickerIds(id);
|
|
14
15
|
const locale = () => datePickerLocale(props.locale);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const labels = useLabels();
|
|
17
|
+
const service = useMachine(datePicker.machine, () => ({
|
|
18
|
+
...datePickerMachineProps(props, {
|
|
19
|
+
id,
|
|
20
|
+
locale: locale(),
|
|
21
|
+
onChange: (value) => props.onChange(value),
|
|
22
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
23
|
+
labels: labels(),
|
|
24
|
+
}),
|
|
25
|
+
ids: { root: props.id },
|
|
20
26
|
}));
|
|
21
27
|
const api = createMemo(() => datePicker.connect(service, normalizeProps));
|
|
22
|
-
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
28
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
23
29
|
let positioner;
|
|
24
30
|
let surface;
|
|
25
31
|
modalPopover(() => api().open, () => positioner);
|
|
@@ -4,27 +4,33 @@ import * as datePicker from "@zag-js/date-picker";
|
|
|
4
4
|
import { normalizeProps, useMachine } from "@zag-js/solid";
|
|
5
5
|
import { createEffect, createMemo, createSignal, createUniqueId, For, Show } from "solid-js";
|
|
6
6
|
import { Icon } from "./Icon.jsx";
|
|
7
|
+
import { useLabels } from "./Labels.jsx";
|
|
7
8
|
import { modalPopover } from "./modal-popover.js";
|
|
8
9
|
import { Portal } from "./portal.jsx";
|
|
9
10
|
import { createPresence } from "./presence.js";
|
|
10
|
-
import { withStyle } from "./root.js";
|
|
11
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
11
12
|
export function DateRangePicker(props) {
|
|
12
13
|
const id = createUniqueId();
|
|
13
14
|
const ids = datePickerIds(id);
|
|
14
15
|
const locale = () => datePickerLocale(props.locale);
|
|
16
|
+
const labels = useLabels();
|
|
15
17
|
const [draft, setDraft] = createSignal(null);
|
|
16
18
|
const [months, setMonths] = createSignal(1);
|
|
17
19
|
const shown = createMemo(() => shownRange(props.value, draft()));
|
|
18
|
-
const service = useMachine(datePicker.machine, () =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const service = useMachine(datePicker.machine, () => ({
|
|
21
|
+
...dateRangeMachineProps(props, shown(), {
|
|
22
|
+
id,
|
|
23
|
+
locale: locale(),
|
|
24
|
+
months: months(),
|
|
25
|
+
onDraft: (next) => setDraft(() => next),
|
|
26
|
+
onChange: (value) => props.onChange(value),
|
|
27
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
28
|
+
labels: labels(),
|
|
29
|
+
}),
|
|
30
|
+
ids: { root: props.id },
|
|
25
31
|
}));
|
|
26
32
|
const api = createMemo(() => datePicker.connect(service, normalizeProps));
|
|
27
|
-
const root = withStyle(() => api().getRootProps(), () => props.style);
|
|
33
|
+
const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
|
|
28
34
|
let positioner;
|
|
29
35
|
let surface;
|
|
30
36
|
modalPopover(() => api().open, () => positioner);
|
|
@@ -35,7 +41,7 @@ export function DateRangePicker(props) {
|
|
|
35
41
|
createEffect(() => [open(), focused(), month()], ([isOpen]) => keepDayFocused(isOpen, surface));
|
|
36
42
|
createEffect(open, (isOpen) => endRangeChoiceOnClose(service, isOpen));
|
|
37
43
|
createEffect(focused, () => keepRangePreview(service, shown(), open()));
|
|
38
|
-
const summary = createMemo(() => rangeSummary(shown(), props, locale()));
|
|
44
|
+
const summary = createMemo(() => rangeSummary(shown(), props, locale(), labels()));
|
|
39
45
|
const views = createMemo(() => rangeMonthViews(api(), months()));
|
|
40
46
|
const invalid = () => props.error !== undefined;
|
|
41
47
|
return (<div {...root} class={classes("xds-date-picker xds-date-range-picker", props.class)}>
|
package/dist/source/Dialog.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import { normalizeProps, useMachine } from "@zag-js/solid";
|
|
|
4
4
|
import { createMemo, createUniqueId, Show } from "solid-js";
|
|
5
5
|
import { Portal } from "./portal.jsx";
|
|
6
6
|
import { createPresence } from "./presence.js";
|
|
7
|
-
import { withStyle } from "./root.js";
|
|
7
|
+
import { rootAttributes, withStyle } from "./root.js";
|
|
8
8
|
import { TriggerContext } from "./trigger.js";
|
|
9
9
|
export function Dialog(props) {
|
|
10
10
|
const id = createUniqueId();
|
|
@@ -13,6 +13,7 @@ export function Dialog(props) {
|
|
|
13
13
|
let content;
|
|
14
14
|
const service = useMachine(dialog.machine, () => ({
|
|
15
15
|
id,
|
|
16
|
+
ids: { content: props.id },
|
|
16
17
|
open: props.open,
|
|
17
18
|
onOpenChange: (details) => {
|
|
18
19
|
if (!details.open)
|
|
@@ -24,7 +25,7 @@ export function Dialog(props) {
|
|
|
24
25
|
initialFocusEl: () => content ?? null,
|
|
25
26
|
}));
|
|
26
27
|
const api = createMemo(() => dialog.connect(service, normalizeProps));
|
|
27
|
-
const contentProps = withStyle(() => api().getContentProps(), () => props.style);
|
|
28
|
+
const contentProps = withStyle(() => api().getContentProps(), () => props.style, rootAttributes(props));
|
|
28
29
|
const present = createPresence(() => api().open, () => [backdrop, positioner]);
|
|
29
30
|
return (<Show when={present()}>
|
|
30
31
|
<Portal>
|
package/dist/source/Divider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RootProps } from "./root.ts";
|
|
2
2
|
export type DividerProps = RootProps;
|
|
3
3
|
/** A line between groups of content. Decorative lines use the low-contrast border color. */
|
|
4
4
|
export declare function Divider(props: DividerProps): import("@solidjs/web").JSX.Element;
|
package/dist/source/Divider.jsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { classes, dividerClass, rootPart } from "@xds/core";
|
|
2
|
+
import { rootAttributes } from "./root.js";
|
|
2
3
|
const ROOT = rootPart("Divider");
|
|
3
4
|
export function Divider(props) {
|
|
4
|
-
return <hr class={classes(ROOT, dividerClass, props.class)} style={props.style}
|
|
5
|
+
return (<hr {...rootAttributes(props)} class={classes(ROOT, dividerClass, props.class)} style={props.style}/>);
|
|
5
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EmptyStateBaseProps } from "@xds/core";
|
|
2
2
|
import { type Element } from "solid-js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RootProps } from "./root.ts";
|
|
4
4
|
export type EmptyStateProps = EmptyStateBaseProps & RootProps & {
|
|
5
5
|
/** The one thing to do about it, usually a Button. */
|
|
6
6
|
action?: Element;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { classes, EMPTY_STATE_PARTS, rootPart } from "@xds/core";
|
|
2
2
|
import { Show } from "solid-js";
|
|
3
3
|
import { Icon } from "./Icon.jsx";
|
|
4
|
+
import { rootAttributes } from "./root.js";
|
|
4
5
|
const ROOT = rootPart("EmptyState");
|
|
5
6
|
export function EmptyState(props) {
|
|
6
|
-
return (<div class={classes(ROOT, EMPTY_STATE_PARTS.root, props.class)} style={props.style}>
|
|
7
|
+
return (<div {...rootAttributes(props)} class={classes(ROOT, EMPTY_STATE_PARTS.root, props.class)} style={props.style}>
|
|
7
8
|
<Icon name={props.icon} size="xl" class={EMPTY_STATE_PARTS.icon}/>
|
|
8
9
|
<p class={EMPTY_STATE_PARTS.title}>{props.title}</p>
|
|
9
10
|
<Show when={props.description}>
|
package/dist/source/Icon.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type IconBaseProps } from "@xds/core";
|
|
2
|
-
import type
|
|
2
|
+
import { type RootProps } from "./root.ts";
|
|
3
3
|
export type IconProps = IconBaseProps & RootProps;
|
|
4
4
|
/**
|
|
5
5
|
* An icon from design/icons. It takes the color of the text around it. An arrow or a chevron
|
package/dist/source/Icon.jsx
CHANGED
|
@@ -2,10 +2,11 @@ import { icons } from "@xds/tokens";
|
|
|
2
2
|
import { classes, iconClass, rootPart } from "@xds/core";
|
|
3
3
|
import { For } from "solid-js";
|
|
4
4
|
import { useDefaults } from "./Defaults.jsx";
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
5
6
|
const ROOT = rootPart("Icon");
|
|
6
7
|
export function Icon(props) {
|
|
7
8
|
const defaults = useDefaults("Icon");
|
|
8
|
-
return (<svg viewBox="0 0 24 24" fill={props.filled ? "currentColor" : "none"} stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class={classes(ROOT, iconClass(props.size ?? defaults().size), props.class)} style={props.style} role={props.label ? "img" : undefined} aria-label={props.label || undefined} aria-hidden={props.label ? undefined : "true"}>
|
|
9
|
+
return (<svg {...rootAttributes(props)} viewBox="0 0 24 24" fill={props.filled ? "currentColor" : "none"} stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class={classes(ROOT, iconClass(props.size ?? defaults().size), props.class)} style={props.style} role={props.label ? "img" : undefined} aria-label={props.label || undefined} aria-hidden={props.label ? undefined : "true"}>
|
|
9
10
|
<For each={icons[props.name]}>{(path) => <path d={path}/>}</For>
|
|
10
11
|
</svg>);
|
|
11
12
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { type IconButtonBaseProps } from "@xds/core";
|
|
2
2
|
import type { JSX } from "@solidjs/web";
|
|
3
|
-
import type
|
|
3
|
+
import { type RootProps } from "./root.ts";
|
|
4
4
|
export type IconButtonProps = IconButtonBaseProps & RootProps & {
|
|
5
5
|
onPress?: () => void;
|
|
6
|
+
onFocus?: JSX.FocusEventHandler<HTMLButtonElement, FocusEvent>;
|
|
7
|
+
onBlur?: JSX.FocusEventHandler<HTMLButtonElement, FocusEvent>;
|
|
8
|
+
/** The native button. */
|
|
9
|
+
ref?: JSX.Ref<HTMLButtonElement>;
|
|
6
10
|
};
|
|
7
11
|
/**
|
|
8
12
|
* A button that holds only an icon, in Button's variants, sizes and states. It is a square as
|
|
@@ -2,6 +2,7 @@ import { buttonClass, classes, ICON_BUTTON_BOX, isHeld, } from "@xds/core";
|
|
|
2
2
|
import { createMemo, Show } from "solid-js";
|
|
3
3
|
import { useDefaults } from "./Defaults.jsx";
|
|
4
4
|
import { Icon } from "./Icon.jsx";
|
|
5
|
+
import { rootAttributes } from "./root.js";
|
|
5
6
|
import { Spinner } from "./Spinner.jsx";
|
|
6
7
|
import { withTrigger } from "./trigger.js";
|
|
7
8
|
export function IconButton(props) {
|
|
@@ -21,8 +22,10 @@ export function IconButton(props) {
|
|
|
21
22
|
if (!props.loading)
|
|
22
23
|
props.onPress?.();
|
|
23
24
|
},
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
onFocus: (event) => props.onFocus?.(event),
|
|
26
|
+
onBlur: (event) => props.onBlur?.(event),
|
|
27
|
+
})), () => props.loading === true, rootAttributes(props));
|
|
28
|
+
return (<button ref={props.ref} {...attributes}>
|
|
26
29
|
<Show when={!props.loading} fallback={<span class={ICON_BUTTON_BOX[size()]}>
|
|
27
30
|
<Spinner size="sm"/>
|
|
28
31
|
</span>}>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ComponentLabels } from "@xds/core";
|
|
2
|
+
import { type Accessor, type Element } from "solid-js";
|
|
3
|
+
export type { ComponentLabels } from "@xds/core";
|
|
4
|
+
export type LabelsProps = {
|
|
5
|
+
/** The labels the components give their own parts, by key: `{ dismiss: "닫기" }`. */
|
|
6
|
+
value: Partial<ComponentLabels>;
|
|
7
|
+
children: Element;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Gives the components inside it the names of their own parts in the app's language: a banner's
|
|
11
|
+
* dismiss control, a search field's clear control, a calendar's month buttons. A label passed to
|
|
12
|
+
* a component wins. A Labels inside another keeps the outer one's labels and replaces those it
|
|
13
|
+
* names; a change of `value` reaches every component inside.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Labels(props: LabelsProps): import("@solidjs/web").JSX.Element;
|
|
16
|
+
/** The labels the closest Labels gives, read where a label is read so that a change updates it. */
|
|
17
|
+
export declare function useLabels(): Accessor<ComponentLabels>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DEFAULT_LABELS, mergeLabels } from "@xds/core";
|
|
2
|
+
import { createContext, createMemo, useContext } from "solid-js";
|
|
3
|
+
const LabelsContext = createContext(() => DEFAULT_LABELS);
|
|
4
|
+
export function Labels(props) {
|
|
5
|
+
const outer = useContext(LabelsContext);
|
|
6
|
+
const merged = createMemo(() => mergeLabels(outer(), props.value));
|
|
7
|
+
return <LabelsContext value={merged}>{props.children}</LabelsContext>;
|
|
8
|
+
}
|
|
9
|
+
export function useLabels() {
|
|
10
|
+
return useContext(LabelsContext);
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type LinkBaseProps } from "@xds/core";
|
|
2
|
+
import { type JSX } from "@solidjs/web";
|
|
3
|
+
import { type Element } from "solid-js";
|
|
4
|
+
import { type RootProps } from "./root.ts";
|
|
5
|
+
export type LinkProps = LinkBaseProps & RootProps & {
|
|
6
|
+
/** Called on a press, before the browser follows `href`. A disabled link never calls it. */
|
|
7
|
+
onPress?: () => void;
|
|
8
|
+
onFocus?: JSX.FocusEventHandler<HTMLElement, FocusEvent>;
|
|
9
|
+
onBlur?: JSX.FocusEventHandler<HTMLElement, FocusEvent>;
|
|
10
|
+
/** The native element: an `<a>`, or a `<button>` for a link without `href`. */
|
|
11
|
+
ref?: JSX.Ref<HTMLElement>;
|
|
12
|
+
/** The text, which names the link. */
|
|
13
|
+
children: Element;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Text that takes the person somewhere, in the type of the text around it. It is underlined, so
|
|
17
|
+
* it does not depend on color. With `href` it is a native link; without one, a button that
|
|
18
|
+
* assistive technology hears as a link.
|
|
19
|
+
*/
|
|
20
|
+
export declare function Link(props: LinkProps): JSX.Element;
|