@lanfermann/ui 0.5.0 → 0.7.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/components/accordion/accordion.d.ts +11 -3
- package/dist/components/accordion/accordion.js +15 -10
- package/dist/components/action-bar/action-bar.d.ts +60 -0
- package/dist/components/action-bar/action-bar.js +117 -0
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +3 -17
- package/dist/components/alert-dialog/alert-dialog.d.ts +1 -1
- package/dist/components/app-shell/app-shell.d.ts +33 -0
- package/dist/components/app-shell/app-shell.js +93 -0
- package/dist/components/attachment/attachment.d.ts +51 -0
- package/dist/components/attachment/attachment.js +255 -0
- package/dist/components/attachment/kinds.d.ts +7 -0
- package/dist/components/attachment/kinds.js +142 -0
- package/dist/components/avatar/avatar.d.ts +14 -4
- package/dist/components/avatar/avatar.js +57 -13
- package/dist/components/avatar-group/avatar-group.d.ts +33 -0
- package/dist/components/avatar-group/avatar-group.js +110 -0
- package/dist/components/avatar-group/people.d.ts +12 -0
- package/dist/components/avatar-group/people.js +24 -0
- package/dist/components/badge/badge.d.ts +9 -3
- package/dist/components/badge/badge.js +21 -6
- package/dist/components/banner/banner.d.ts +39 -0
- package/dist/components/banner/banner.js +149 -0
- package/dist/components/button-group/button-group-variants.d.ts +4 -3
- package/dist/components/button-group/button-group-variants.js +13 -12
- package/dist/components/button-group/button-group.d.ts +3 -3
- package/dist/components/button-group/button-group.js +3 -3
- package/dist/components/card/card.d.ts +20 -4
- package/dist/components/card/card.js +32 -6
- package/dist/components/checkbox-card/checkbox-card.d.ts +21 -0
- package/dist/components/checkbox-card/checkbox-card.js +50 -0
- package/dist/components/chip/chip-group.d.ts +15 -0
- package/dist/components/chip/chip-group.js +44 -0
- package/dist/components/chip/chip-variants.d.ts +6 -0
- package/dist/components/chip/chip-variants.js +28 -0
- package/dist/components/chip/chip.d.ts +39 -0
- package/dist/components/chip/chip.js +71 -0
- package/dist/components/code-block/code-copy.d.ts +3 -11
- package/dist/components/code-block/code-copy.js +15 -62
- package/dist/components/code-block/code-keys.js +10 -22
- package/dist/components/collapsible/collapsible.js +7 -3
- package/dist/components/combobox/combobox.d.ts +53 -3
- package/dist/components/combobox/combobox.js +204 -20
- package/dist/components/command/command.d.ts +131 -0
- package/dist/components/command/command.js +335 -0
- package/dist/components/consent/consent-card.js +365 -0
- package/dist/components/consent/consent-embed.d.ts +21 -0
- package/dist/components/consent/consent-embed.js +111 -0
- package/dist/components/consent/consent-labels.d.ts +70 -0
- package/dist/components/consent/consent-labels.js +61 -0
- package/dist/components/consent/consent-record.d.ts +95 -0
- package/dist/components/consent/consent-record.js +112 -0
- package/dist/components/consent/consent-store.d.ts +26 -0
- package/dist/components/consent/consent-store.js +240 -0
- package/dist/components/consent/consent.d.ts +86 -0
- package/dist/components/consent/consent.js +306 -0
- package/dist/components/container/container.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +23 -0
- package/dist/components/context-menu/context-menu.js +50 -0
- package/dist/components/conversation/conversation.d.ts +45 -0
- package/dist/components/conversation/conversation.js +295 -0
- package/dist/components/conversation/stick.js +23 -0
- package/dist/components/copy-button/copy-button.d.ts +50 -0
- package/dist/components/copy-button/copy-button.js +65 -0
- package/dist/components/copy-page/copy-page.d.ts +4 -4
- package/dist/components/copy-page/copy-page.js +16 -36
- package/dist/components/copy-pill/copy-pill.js +1 -1
- package/dist/components/description-list/description-list.d.ts +32 -0
- package/dist/components/description-list/description-list.js +51 -0
- package/dist/components/empty/empty.d.ts +38 -0
- package/dist/components/empty/empty.js +57 -0
- package/dist/components/field/field.js +1 -1
- package/dist/components/file-upload/file-upload.d.ts +96 -0
- package/dist/components/file-upload/file-upload.js +347 -0
- package/dist/components/file-upload/files.d.ts +39 -0
- package/dist/components/file-upload/files.js +74 -0
- package/dist/components/grow/grow.d.ts +15 -3
- package/dist/components/grow/grow.js +24 -9
- package/dist/components/heading/heading.d.ts +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/menu/menu.d.ts +20 -8
- package/dist/components/menu/menu.js +51 -29
- package/dist/components/message/message.d.ts +81 -0
- package/dist/components/message/message.js +208 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +7 -1
- package/dist/components/navigation-menu/navigation-menu.js +11 -4
- package/dist/components/otp-field/otp-field.d.ts +37 -0
- package/dist/components/otp-field/otp-field.js +161 -0
- package/dist/components/pagination/pagination.d.ts +50 -0
- package/dist/components/pagination/pagination.js +188 -0
- package/dist/components/prompt-input/keys.js +15 -0
- package/dist/components/prompt-input/prompt-input.d.ts +89 -0
- package/dist/components/prompt-input/prompt-input.js +331 -0
- package/dist/components/radio-card/radio-card.d.ts +23 -0
- package/dist/components/radio-card/radio-card.js +49 -0
- package/dist/components/rolling-number/rolling-number.d.ts +30 -0
- package/dist/components/rolling-number/rolling-number.js +149 -0
- package/dist/components/seam/seam.d.ts +1 -1
- package/dist/components/secret-field/secret-field.d.ts +53 -0
- package/dist/components/secret-field/secret-field.js +121 -0
- package/dist/components/section/section.d.ts +1 -1
- package/dist/components/segmented-control/segmented-control.js +29 -16
- package/dist/components/select/select.d.ts +5 -4
- package/dist/components/select/select.js +16 -11
- package/dist/components/shortcut/shortcut.d.ts +46 -0
- package/dist/components/shortcut/shortcut.js +87 -0
- package/dist/components/sidebar/sidebar-context.js +16 -0
- package/dist/components/sidebar/sidebar.d.ts +161 -0
- package/dist/components/sidebar/sidebar.js +588 -0
- package/dist/components/site-header/site-header.js +1 -1
- package/dist/components/skeleton/loaded.d.ts +21 -0
- package/dist/components/skeleton/loaded.js +57 -0
- package/dist/components/skeleton/skeleton.d.ts +43 -0
- package/dist/components/skeleton/skeleton.js +48 -0
- package/dist/components/sources/source-list.d.ts +17 -0
- package/dist/components/sources/source-list.js +26 -0
- package/dist/components/sources/sources.d.ts +45 -0
- package/dist/components/sources/sources.js +167 -0
- package/dist/components/stat/stat.d.ts +59 -0
- package/dist/components/stat/stat.js +112 -0
- package/dist/components/steps/steps.d.ts +57 -0
- package/dist/components/steps/steps.js +134 -0
- package/dist/components/table/table.d.ts +18 -9
- package/dist/components/table/table.js +21 -13
- package/dist/components/text/text.d.ts +1 -1
- package/dist/components/theme-switch/theme-switch.js +1 -1
- package/dist/components/time-field/time-field.js +7 -6
- package/dist/components/timeline/timeline.d.ts +45 -0
- package/dist/components/timeline/timeline.js +86 -0
- package/dist/components/toast/toast.js +10 -26
- package/dist/components/toggle/toggle.d.ts +27 -0
- package/dist/components/toggle/toggle.js +61 -0
- package/dist/components/toggle-group/toggle-group.d.ts +27 -0
- package/dist/components/toggle-group/toggle-group.js +38 -0
- package/dist/components/toolbar/toolbar-context.js +12 -0
- package/dist/components/toolbar/toolbar.d.ts +52 -0
- package/dist/components/toolbar/toolbar.js +105 -0
- package/dist/components/trace/trace.d.ts +2 -1
- package/dist/components/trace/trace.js +15 -27
- package/dist/index.d.ts +46 -3
- package/dist/index.js +44 -3
- package/dist/internal/arriving-pieces.js +56 -0
- package/dist/internal/arriving.js +171 -0
- package/dist/internal/avatar-cut.d.ts +15 -0
- package/dist/internal/avatar-cut.js +83 -0
- package/dist/internal/choice-card.d.ts +15 -0
- package/dist/internal/choice-card.js +81 -0
- package/dist/internal/clipboard.js +37 -0
- package/dist/internal/copy.js +58 -0
- package/dist/internal/disclosure.js +15 -3
- package/dist/internal/field.js +24 -4
- package/dist/internal/glyphs.js +26 -1
- package/dist/internal/key-tip.js +18 -0
- package/dist/internal/list-mark.js +39 -0
- package/dist/internal/live-list.js +41 -0
- package/dist/internal/number-places.js +157 -0
- package/dist/internal/picker-sheet.js +1 -1
- package/dist/internal/presence-dot.js +24 -0
- package/dist/internal/presence.js +104 -0
- package/dist/internal/rail-mark.d.ts +3 -0
- package/dist/internal/rail-mark.js +33 -0
- package/dist/internal/rule.js +2 -1
- package/dist/internal/status-icon.js +22 -0
- package/dist/internal/tile.js +23 -0
- package/dist/internal/travelling-mark.js +204 -0
- package/dist/lib/cn.js +10 -0
- package/dist/lib/shortcut.d.ts +11 -0
- package/dist/lib/shortcut.js +165 -0
- package/package.json +1 -1
- package/src/styles/accordion.css +176 -0
- package/src/styles/action-bar.css +28 -0
- package/src/styles/assistant.css +83 -0
- package/src/styles/avatar.css +24 -0
- package/src/styles/consent.css +65 -0
- package/src/styles/copy.css +12 -11
- package/src/styles/depth.css +120 -4
- package/src/styles/marks.css +20 -2
- package/src/styles/motion.css +3 -0
- package/src/styles/rail.css +49 -0
- package/src/styles/rolling-number.css +94 -0
- package/src/styles/segmented.css +14 -7
- package/src/styles/steps.css +98 -0
- package/src/styles/timeline.css +48 -0
- package/src/styles/travel.css +36 -0
- package/src/styles.css +10 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { linkVariants } from "../link/link-variants.js";
|
|
2
|
+
import { TickGlyph } from "../../internal/glyphs.js";
|
|
3
|
+
import { renderAs } from "../../internal/render-as.js";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/steps/steps.tsx
|
|
7
|
+
const statusWords = {
|
|
8
|
+
done: "Erledigt",
|
|
9
|
+
current: "Aktueller Schritt",
|
|
10
|
+
upcoming: "Steht aus"
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Where one stands in a set-up of a few steps: an order, an onboarding, a form in parts. Its
|
|
14
|
+
* marks are a checkbox's: an empty socket with the step's number is ahead, the socket with the
|
|
15
|
+
* accent ring is where one stands, and a finished step is the accent plug with its tick. A line
|
|
16
|
+
* with round ends joins them, filled in the text colour behind a finished step.
|
|
17
|
+
*
|
|
18
|
+
* Going on is one movement along the way: the plug seats and its tick draws, the line draws on
|
|
19
|
+
* to the next mark, and that mark takes the ring as the line arrives. Going back runs it in
|
|
20
|
+
* reverse. Where the steps first show, the finished ones draw themselves in (`steps.css`).
|
|
21
|
+
*
|
|
22
|
+
* Put `Step`s inside, each with its `status`; exactly one is `current`. Name the list
|
|
23
|
+
* (`aria-label`: "Einrichtung"). It shows the way and does not walk it: the buttons that go on
|
|
24
|
+
* and back belong to the form below. Three to five steps; a longer way is better told as
|
|
25
|
+
* "Schritt 4 von 9" in words.
|
|
26
|
+
*/
|
|
27
|
+
function Steps({ orientation = "horizontal", marks = "numbers", className, ...props }) {
|
|
28
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
29
|
+
"data-slot": "steps",
|
|
30
|
+
"data-orientation": orientation,
|
|
31
|
+
"data-marks": marks,
|
|
32
|
+
className: cn("group/steps relative flex [counter-reset:step] data-[orientation=horizontal]:@container/steps data-[orientation=horizontal]:w-full data-[orientation=vertical]:flex-col", "[--line-gap:1.125rem] data-[marks=dots]:[--line-gap:0.75rem]", className),
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The order of a step that changes. A transition takes the delay of the state it goes to, so
|
|
38
|
+
* going on and going back are both one movement along the line: a mark that becomes current
|
|
39
|
+
* waits until the line has reached it (or, going back, has left the mark after it), and a line
|
|
40
|
+
* fills once the plug behind it has seated.
|
|
41
|
+
*/
|
|
42
|
+
const timing = "[--mark-delay:0ms] [--line-delay:0ms] data-[status=current]:[--mark-delay:350ms] data-[status=done]:[--line-delay:100ms]";
|
|
43
|
+
/**
|
|
44
|
+
* The piece of line from this mark to the next: a trough 2px high with round ends, and in it a
|
|
45
|
+
* fill as long as the trough that is pushed out of it at the start (`translate`), so both ends
|
|
46
|
+
* stay round while it draws and nothing is laid out. In a row it lies between the middles of
|
|
47
|
+
* two marks, 8px clear of each.
|
|
48
|
+
*/
|
|
49
|
+
const line = ["absolute start-[calc(50%+var(--line-gap))] top-[calc(50%-1px)] h-0.5 w-[calc(100%-2*var(--line-gap))] overflow-hidden rounded-full bg-hairline group-last/step:hidden forced-colors:bg-[GrayText]", "group-data-[orientation=vertical]/steps:static group-data-[orientation=vertical]/steps:my-1.5 group-data-[orientation=vertical]/steps:h-auto group-data-[orientation=vertical]/steps:min-h-3 group-data-[orientation=vertical]/steps:w-0.5 group-data-[orientation=vertical]/steps:flex-1"].join(" ");
|
|
50
|
+
const fill = [
|
|
51
|
+
"block size-full rounded-full bg-fg forced-colors:bg-[CanvasText]",
|
|
52
|
+
"translate-x-[calc((var(--fill)-1)*(100%+2px))] rtl:translate-x-[calc((1-var(--fill))*(100%+2px))]",
|
|
53
|
+
"group-data-[orientation=vertical]/steps:translate-x-0 group-data-[orientation=vertical]/steps:translate-y-[calc((var(--fill)-1)*(100%+2px))]",
|
|
54
|
+
"transition-[translate] spring-glide delay-(--line-delay) motion-reduce:transition-none"
|
|
55
|
+
].join(" ");
|
|
56
|
+
/** The system's mark: ring ahead, the heavier ring in the accent now, the disc when done. */
|
|
57
|
+
const dot = ["mark hidden delay-(--mark-delay) group-data-[marks=dots]/steps:block", "group-data-[status=current]/step:mark-now group-data-[status=done]/step:mark-on"].join(" ");
|
|
58
|
+
/**
|
|
59
|
+
* The step's number in a checkbox's socket (checkbox.tsx), so the three states are one part:
|
|
60
|
+
* ahead it is the empty socket, where one stands its rim is the accent, and done the accent plug
|
|
61
|
+
* seats into it with the tick.
|
|
62
|
+
*/
|
|
63
|
+
const number = [
|
|
64
|
+
"relative hidden size-5 items-center justify-center rounded-full bg-surface text-xs font-medium text-fg-muted tabular-nums depth-socket group-data-[marks=numbers]/steps:flex",
|
|
65
|
+
"transition-[background-color,box-shadow,color,outline-color] spring-settle delay-(--mark-delay)",
|
|
66
|
+
"before:translate-y-px before:transition-opacity before:duration-150 before:ease-out before:delay-(--mark-delay) before:content-[counter(step)]",
|
|
67
|
+
"outline-2 -outline-offset-1 outline-transparent",
|
|
68
|
+
"group-data-[status=current]/step:text-fg group-data-[status=current]/step:outline-accent",
|
|
69
|
+
"group-data-[status=done]/step:bg-accent group-data-[status=done]/step:text-on-accent group-data-[status=done]/step:depth-plug group-data-[status=done]/step:depth-tone-accent group-data-[status=done]/step:before:opacity-0",
|
|
70
|
+
"forced-colors:outline-1 forced-colors:outline-offset-0 forced-colors:outline-[CanvasText] forced-colors:group-data-[status=current]/step:outline-2"
|
|
71
|
+
].join(" ");
|
|
72
|
+
/**
|
|
73
|
+
* One step. Its mark stands on the line and its name is centred under it (beside it when the
|
|
74
|
+
* steps stand one under the other). The current step says so to assistive tech
|
|
75
|
+
* (`aria-current="step"`) and has its name in the strong text colour.
|
|
76
|
+
*/
|
|
77
|
+
function Step({ status = "upcoming", title, description, href, render, statusLabel = statusWords[status], className, ...props }) {
|
|
78
|
+
const linked = href !== void 0 || render !== void 0;
|
|
79
|
+
const name = /* @__PURE__ */ jsxs(Fragment, { children: [status !== "current" && /* @__PURE__ */ jsxs("span", {
|
|
80
|
+
className: "sr-only",
|
|
81
|
+
children: [statusLabel, ": "]
|
|
82
|
+
}), title] });
|
|
83
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
84
|
+
"data-slot": "step",
|
|
85
|
+
"data-status": status,
|
|
86
|
+
"aria-current": status === "current" ? "step" : void 0,
|
|
87
|
+
className: cn("group/step relative flex min-w-0 flex-1 basis-0 flex-col items-center gap-2 [--fill:0] [counter-increment:step] data-[status=done]:[--fill:1]", timing, "group-data-[orientation=vertical]/steps:flex-none group-data-[orientation=vertical]/steps:basis-auto group-data-[orientation=vertical]/steps:flex-row group-data-[orientation=vertical]/steps:items-stretch group-data-[orientation=vertical]/steps:gap-3", "[--name-room:200%] first:[--name-room:100%] last:[--name-room:100%] group-data-[orientation=horizontal]/steps:@max-md/steps:pb-8", className),
|
|
88
|
+
...props,
|
|
89
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
90
|
+
"aria-hidden": true,
|
|
91
|
+
"data-slot": "step-rail",
|
|
92
|
+
className: "relative flex h-5 w-full items-center justify-center group-data-[orientation=vertical]/steps:h-auto group-data-[orientation=vertical]/steps:w-5 group-data-[orientation=vertical]/steps:flex-col group-data-[orientation=vertical]/steps:justify-start",
|
|
93
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
94
|
+
"data-slot": "step-mark",
|
|
95
|
+
className: "flex size-5 shrink-0 items-center justify-center group-data-[marks=dots]/steps:w-2 group-data-[orientation=vertical]/steps:group-data-[marks=dots]/steps:w-5",
|
|
96
|
+
children: [/* @__PURE__ */ jsx("span", { className: dot }), /* @__PURE__ */ jsx("span", {
|
|
97
|
+
className: number,
|
|
98
|
+
children: /* @__PURE__ */ jsx(TickGlyph, {
|
|
99
|
+
"data-slot": "step-tick",
|
|
100
|
+
className: "absolute -translate-y-[0.5px] opacity-0 transition-[stroke-dashoffset,opacity] delay-[calc(var(--mark-delay)+60ms)] duration-150 ease-out [stroke-dasharray:1] [stroke-dashoffset:1] group-data-[status=done]/step:opacity-100 group-data-[status=done]/step:[stroke-dashoffset:0]"
|
|
101
|
+
})
|
|
102
|
+
})]
|
|
103
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
104
|
+
"data-slot": "step-line",
|
|
105
|
+
className: line,
|
|
106
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
107
|
+
"data-slot": "step-fill",
|
|
108
|
+
className: fill
|
|
109
|
+
})
|
|
110
|
+
})]
|
|
111
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
112
|
+
"data-slot": "step-text",
|
|
113
|
+
className: cn("flex max-w-full min-w-0 flex-col items-center gap-0.5 px-2 text-center", "group-data-[orientation=vertical]/steps:items-start group-data-[orientation=vertical]/steps:px-0 group-data-[orientation=vertical]/steps:pb-5 group-data-[orientation=vertical]/steps:text-start group-data-[orientation=vertical]/steps:group-last/step:pb-0", "group-data-[orientation=horizontal]/steps:@max-md/steps:group-data-[status=done]/step:sr-only group-data-[orientation=horizontal]/steps:@max-md/steps:group-data-[status=upcoming]/step:sr-only", "group-data-[orientation=horizontal]/steps:@max-md/steps:group-data-[status=current]/step:absolute group-data-[orientation=horizontal]/steps:@max-md/steps:group-data-[status=current]/step:top-7 group-data-[orientation=horizontal]/steps:@max-md/steps:group-data-[status=current]/step:left-1/2 group-data-[orientation=horizontal]/steps:@max-md/steps:group-data-[status=current]/step:-translate-x-1/2", "group-data-[orientation=horizontal]/steps:@max-md/steps:group-data-[status=current]/step:w-max group-data-[orientation=horizontal]/steps:@max-md/steps:group-data-[status=current]/step:max-w-(--name-room)"),
|
|
114
|
+
children: [linked ? renderAs("a", render, {
|
|
115
|
+
href,
|
|
116
|
+
"data-slot": "step-title",
|
|
117
|
+
className: cn(linkVariants({ variant: "quiet" }), "w-fit max-w-full min-w-0 text-control leading-5 text-fg-body"),
|
|
118
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
119
|
+
className: "block overflow-x-clip text-ellipsis whitespace-nowrap",
|
|
120
|
+
children: name
|
|
121
|
+
})
|
|
122
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
123
|
+
"data-slot": "step-title",
|
|
124
|
+
className: cn("max-w-full truncate text-control leading-5 text-fg-muted", "[transition:color_150ms_ease-out_var(--mark-delay),font-weight_0s_linear_var(--mark-delay)]", "group-data-[status=current]/step:font-medium group-data-[status=current]/step:text-fg group-data-[status=done]/step:text-fg-body"),
|
|
125
|
+
children: name
|
|
126
|
+
}), description !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
127
|
+
"data-slot": "step-description",
|
|
128
|
+
className: "text-sm text-pretty text-fg-muted",
|
|
129
|
+
children: description
|
|
130
|
+
})]
|
|
131
|
+
})]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export { Step, Steps };
|
|
@@ -4,16 +4,17 @@ type Named = {
|
|
|
4
4
|
"aria-label": string;
|
|
5
5
|
"aria-labelledby"?: undefined;
|
|
6
6
|
} | {
|
|
7
|
-
"aria-labelledby": string;
|
|
8
7
|
"aria-label"?: undefined;
|
|
8
|
+
"aria-labelledby": string;
|
|
9
9
|
};
|
|
10
10
|
export type TableProps = Omit<ComponentProps<"table">, "aria-label" | "aria-labelledby"> & Named & {
|
|
11
11
|
/** Classes for the box around the table (its rule and the scrolling region): its place. */
|
|
12
12
|
containerClassName?: string;
|
|
13
13
|
/**
|
|
14
|
-
* What the cells hold. `data` (the default): short values, centred on the
|
|
15
|
-
* `text`: sentences, as in a reference or the docs
|
|
16
|
-
* long cell does not push the short ones beside it down to its
|
|
14
|
+
* What the cells hold. `data` (the default): short values on a close rhythm, centred on the
|
|
15
|
+
* row's line. `text`: sentences, as in a reference or the docs, on a looser one. Cells then
|
|
16
|
+
* start at the row's top, so a long cell does not push the short ones beside it down to its
|
|
17
|
+
* middle.
|
|
17
18
|
*/
|
|
18
19
|
content?: "data" | "text";
|
|
19
20
|
/**
|
|
@@ -26,13 +27,21 @@ export type TableProps = Omit<ComponentProps<"table">, "aria-label" | "aria-labe
|
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* Rows of the same kind of thing, compared column by column: quotes, invoice lines, members.
|
|
29
|
-
* Real `<table>` markup, structured by line
|
|
30
|
-
*
|
|
30
|
+
* Real `<table>` markup, structured by line: hairlines divide the rows, no stripes.
|
|
31
|
+
*
|
|
32
|
+
* In an app a table stands in a `Card`, under a `CardBar` that names it: put it straight in the
|
|
33
|
+
* card, not in a `CardContent`. There the card's edge holds it: the column names stand on the
|
|
34
|
+
* well, the outer cells keep the card's 20px, and the last row has no line under it. Elsewhere
|
|
35
|
+
* (a reference, the docs) a 2px rule with round ends opens it.
|
|
36
|
+
*
|
|
37
|
+
* Rows of data are set close: 15px text (it follows the density) with 8px above and below, a row
|
|
38
|
+
* at least a large control high, and what stands inline in a cell (a badge, avatars, a checkbox)
|
|
39
|
+
* centred on the text. Rows selected one after another are one wash.
|
|
31
40
|
*
|
|
32
41
|
* On a narrow screen the table keeps its columns and scrolls sideways inside its own region,
|
|
33
|
-
* which is focusable so the keyboard can scroll it too. Its edges fade where more columns wait
|
|
34
|
-
*
|
|
35
|
-
*
|
|
42
|
+
* which is focusable so the keyboard can scroll it too. Its edges fade where more columns wait.
|
|
43
|
+
* Name it with `aria-label` (or `aria-labelledby`, pointing at a heading or the
|
|
44
|
+
* `TableCaption`). Give the table a `min-w-*` if its columns must not squeeze.
|
|
36
45
|
*
|
|
37
46
|
* Sorting, filtering and paging are the caller's state; the table only provides the slots.
|
|
38
47
|
*/
|
|
@@ -6,20 +6,28 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
// src/components/table/table.tsx
|
|
7
7
|
/**
|
|
8
8
|
* Rows of the same kind of thing, compared column by column: quotes, invoice lines, members.
|
|
9
|
-
* Real `<table>` markup, structured by line
|
|
10
|
-
*
|
|
9
|
+
* Real `<table>` markup, structured by line: hairlines divide the rows, no stripes.
|
|
10
|
+
*
|
|
11
|
+
* In an app a table stands in a `Card`, under a `CardBar` that names it: put it straight in the
|
|
12
|
+
* card, not in a `CardContent`. There the card's edge holds it: the column names stand on the
|
|
13
|
+
* well, the outer cells keep the card's 20px, and the last row has no line under it. Elsewhere
|
|
14
|
+
* (a reference, the docs) a 2px rule with round ends opens it.
|
|
15
|
+
*
|
|
16
|
+
* Rows of data are set close: 15px text (it follows the density) with 8px above and below, a row
|
|
17
|
+
* at least a large control high, and what stands inline in a cell (a badge, avatars, a checkbox)
|
|
18
|
+
* centred on the text. Rows selected one after another are one wash.
|
|
11
19
|
*
|
|
12
20
|
* On a narrow screen the table keeps its columns and scrolls sideways inside its own region,
|
|
13
|
-
* which is focusable so the keyboard can scroll it too. Its edges fade where more columns wait
|
|
14
|
-
*
|
|
15
|
-
*
|
|
21
|
+
* which is focusable so the keyboard can scroll it too. Its edges fade where more columns wait.
|
|
22
|
+
* Name it with `aria-label` (or `aria-labelledby`, pointing at a heading or the
|
|
23
|
+
* `TableCaption`). Give the table a `min-w-*` if its columns must not squeeze.
|
|
16
24
|
*
|
|
17
25
|
* Sorting, filtering and paging are the caller's state; the table only provides the slots.
|
|
18
26
|
*/
|
|
19
27
|
function Table({ className, containerClassName, content = "data", stack = false, "aria-label": label, "aria-labelledby": labelledBy, ...props }) {
|
|
20
28
|
return /* @__PURE__ */ jsx("div", {
|
|
21
29
|
"data-slot": "table-container",
|
|
22
|
-
className: cn(ruleTop, "rounded-xs", "has-[[data-slot=table-scroll]:focus-visible]:outline-2", "has-[[data-slot=table-scroll]:focus-visible]:outline-offset-2", "has-[[data-slot=table-scroll]:focus-visible]:outline-accent", containerClassName),
|
|
30
|
+
className: cn(ruleTop, "rounded-xs", "has-[[data-slot=table-scroll]:focus-visible]:outline-2", "has-[[data-slot=table-scroll]:focus-visible]:outline-offset-2", "has-[[data-slot=table-scroll]:focus-visible]:outline-accent", "in-data-[slot=card]:border-t-0 in-data-[slot=card]:before:hidden", "in-data-[slot=card]:overflow-clip in-data-[slot=card]:rounded-none", "in-data-[slot=card]:first:rounded-t-xl in-data-[slot=card]:last:rounded-b-xl", "in-data-[slot=card]:has-[[data-slot=table-scroll]:focus-visible]:-outline-offset-2", containerClassName),
|
|
23
31
|
children: /* @__PURE__ */ jsx(ScrollFade, {
|
|
24
32
|
axis: "x",
|
|
25
33
|
"data-slot": "table-scroll",
|
|
@@ -33,7 +41,7 @@ function Table({ className, containerClassName, content = "data", stack = false,
|
|
|
33
41
|
"data-content": content,
|
|
34
42
|
"data-stack": stack ? "" : void 0,
|
|
35
43
|
role: "table",
|
|
36
|
-
className: cn("w-full caption-bottom border-collapse text-left text-
|
|
44
|
+
className: cn("w-full caption-bottom border-collapse text-left text-fg-body", content === "data" ? "text-control" : "text-base", "data-stack:max-sm:block", className),
|
|
37
45
|
...props
|
|
38
46
|
})
|
|
39
47
|
})
|
|
@@ -50,7 +58,7 @@ const stackedCell = [
|
|
|
50
58
|
function TableCaption({ className, ...props }) {
|
|
51
59
|
return /* @__PURE__ */ jsx("caption", {
|
|
52
60
|
"data-slot": "table-caption",
|
|
53
|
-
className: cn("pt-3 text-left text-sm text-fg-muted", className),
|
|
61
|
+
className: cn("pt-3 text-left text-sm text-fg-muted", "in-data-[slot=card]:px-5 in-data-[slot=card]:pb-3", className),
|
|
54
62
|
...props
|
|
55
63
|
});
|
|
56
64
|
}
|
|
@@ -66,7 +74,7 @@ function TableBody({ className, ...props }) {
|
|
|
66
74
|
return /* @__PURE__ */ jsx("tbody", {
|
|
67
75
|
"data-slot": "table-body",
|
|
68
76
|
role: "rowgroup",
|
|
69
|
-
className: cn(stackedGroup, className),
|
|
77
|
+
className: cn(stackedGroup, "in-data-[slot=card]:[&>tr:last-child]:border-b-0", className),
|
|
70
78
|
...props
|
|
71
79
|
});
|
|
72
80
|
}
|
|
@@ -86,11 +94,11 @@ function TableRow({ className, interactive, selected, ...props }) {
|
|
|
86
94
|
"data-interactive": interactive ? "" : void 0,
|
|
87
95
|
"data-selected": selected ? "" : void 0,
|
|
88
96
|
"aria-selected": selected,
|
|
89
|
-
className: cn("border-b border-hairline", "data-interactive:hover:bg-hover data-selected:bg-tint data-selected:text-fg", stackedRow, className),
|
|
97
|
+
className: cn("group/row border-b border-hairline", "data-interactive:hover:bg-hover data-selected:bg-tint data-selected:text-fg", "data-selected:has-[+[data-selected]]:border-b-tint", stackedRow, className),
|
|
90
98
|
...props
|
|
91
99
|
});
|
|
92
100
|
}
|
|
93
|
-
const cell = "px-3 text-left align-middle in-data-[content=text]:align-top";
|
|
101
|
+
const cell = ["px-3 text-left align-middle in-data-[content=text]:align-top", "in-data-[slot=card]:first:pl-5 in-data-[slot=card]:last:pr-5"].join(" ");
|
|
94
102
|
const numeric = "text-right tabular-nums whitespace-nowrap";
|
|
95
103
|
/** A column heading: small and muted, so the rows are what is read. */
|
|
96
104
|
function TableHead({ className, numeric: isNumeric, sort, ...props }) {
|
|
@@ -99,7 +107,7 @@ function TableHead({ className, numeric: isNumeric, sort, ...props }) {
|
|
|
99
107
|
scope: "col",
|
|
100
108
|
role: "columnheader",
|
|
101
109
|
"aria-sort": sort,
|
|
102
|
-
className: cn(cell, "h-(--control-lg) text-sm font-normal whitespace-nowrap text-fg-muted", "in-data-[content=text]:pb-2 in-data-[content=text]:align-bottom", isNumeric && "text-right", className),
|
|
110
|
+
className: cn(cell, "h-(--control-lg) text-sm font-normal whitespace-nowrap text-fg-muted", "in-data-[content=data]:h-(--control-md) in-data-[slot=card]:bg-well", "in-data-[content=text]:pb-2 in-data-[content=text]:align-bottom", isNumeric && "text-right", className),
|
|
103
111
|
...props
|
|
104
112
|
});
|
|
105
113
|
}
|
|
@@ -108,7 +116,7 @@ function TableCell({ className, numeric: isNumeric, label, nowrap = false, ...pr
|
|
|
108
116
|
"data-slot": "table-cell",
|
|
109
117
|
role: "cell",
|
|
110
118
|
"data-label": label,
|
|
111
|
-
className: cn(cell, "py-3 in-data-[content=text]:[text-wrap-style:pretty]", isNumeric && numeric, nowrap && "whitespace-nowrap", stackedCell, className),
|
|
119
|
+
className: cn(cell, "py-3 in-data-[content=text]:[text-wrap-style:pretty]", "in-data-[content=data]:h-(--control-lg) in-data-[content=data]:py-2 in-data-[content=data]:*:align-middle", isNumeric && numeric, isNumeric && "in-data-[content=data]:text-fg", nowrap && "whitespace-nowrap", stackedCell, className),
|
|
112
120
|
...props
|
|
113
121
|
});
|
|
114
122
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { VariantProps } from "class-variance-authority";
|
|
2
1
|
import { ComponentProps } from "react";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const textVariants: (props?: ({
|
|
4
4
|
size?: "sm" | "lg" | "base" | "xs" | null | undefined;
|
|
5
5
|
tone?: "success" | "warning" | "danger" | "body" | "strong" | "muted" | null | undefined;
|
|
@@ -4,8 +4,8 @@ import { Segment, SegmentedControl } from "../segmented-control/segmented-contro
|
|
|
4
4
|
import { Select, SelectContent, SelectItem, SelectTrigger } from "../select/select.js";
|
|
5
5
|
import { cn } from "../../lib/cn.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { ComputerIcon, Moon02Icon, Sun03Icon } from "@hugeicons/core-free-icons";
|
|
8
7
|
import { useMemo } from "react";
|
|
8
|
+
import { ComputerIcon, Moon02Icon, Sun03Icon } from "@hugeicons/core-free-icons";
|
|
9
9
|
// src/components/theme-switch/theme-switch.tsx
|
|
10
10
|
const themes = [
|
|
11
11
|
{
|
|
@@ -5,12 +5,13 @@ import { InputGroupAddon } from "../input-group/input-group.js";
|
|
|
5
5
|
import { fieldShell, fieldShellSize, focusFieldControl } from "../../internal/field.js";
|
|
6
6
|
import { FieldShellContext } from "../../internal/field-context.js";
|
|
7
7
|
import { formatTime, parseGermanTime, timeMatches, timesOfDay } from "../../internal/iso-date.js";
|
|
8
|
+
import { ListMark } from "../../internal/list-mark.js";
|
|
8
9
|
import { listItem, listSheet, popupMotion } from "../../internal/popup.js";
|
|
9
10
|
import { TypedInput, useTypedValue } from "../../internal/typed-input.js";
|
|
10
11
|
import { cn } from "../../lib/cn.js";
|
|
11
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { Clock01Icon } from "@hugeicons/core-free-icons";
|
|
13
13
|
import { useRef } from "react";
|
|
14
|
+
import { Clock01Icon } from "@hugeicons/core-free-icons";
|
|
14
15
|
import { Autocomplete } from "@base-ui/react/autocomplete";
|
|
15
16
|
// src/components/time-field/time-field.tsx
|
|
16
17
|
/**
|
|
@@ -109,11 +110,11 @@ function TimeField({ value, defaultValue, onValueChange, min, max, step = 15, ho
|
|
|
109
110
|
value: time,
|
|
110
111
|
"data-slot": "time-field-option",
|
|
111
112
|
"data-time": time,
|
|
112
|
-
className: cn(listItem, "tabular-nums"),
|
|
113
|
-
children: [/* @__PURE__ */ jsx(
|
|
114
|
-
|
|
115
|
-
className:
|
|
116
|
-
})
|
|
113
|
+
className: cn("group", listItem, "tabular-nums"),
|
|
114
|
+
children: [written(time), /* @__PURE__ */ jsx(ListMark, {
|
|
115
|
+
on: time === typed.value,
|
|
116
|
+
className: "ml-auto"
|
|
117
|
+
})]
|
|
117
118
|
}, time)
|
|
118
119
|
})
|
|
119
120
|
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IconSvgElement } from "../icon/icon.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* What happened lately: quotes sent and accepted, people invited, a payment that failed. A flat
|
|
5
|
+
* list on a hairline rail, newest first, each entry a sentence and its time, drawn the way a
|
|
6
|
+
* `Trace` is (`rail.css`). Entries group under their day with a `TimelineGroup`.
|
|
7
|
+
*
|
|
8
|
+
* Each entry is led by what it is: the avatar of the person who acted, the symbol of an event the
|
|
9
|
+
* system did (a mail sent, an invoice made), the danger mark for a failure, and the plain mark for
|
|
10
|
+
* anything else. Mix them freely in one list; the rail runs straight through all of them.
|
|
11
|
+
*
|
|
12
|
+
* An entry that joins a list already on screen opens its room and fades in; what is there when
|
|
13
|
+
* the list first shows does not move (`timeline.css`). Server-safe: the list is markup, and the
|
|
14
|
+
* one frame of script that tells load from later comes with it (`LiveList`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function Timeline({ className, ...props }: ComponentProps<"ol">): import("react").JSX.Element;
|
|
17
|
+
export type TimelineGroupProps = Omit<ComponentProps<"li">, "children"> & {
|
|
18
|
+
/** The day, as people say it: „Heute“, „Gestern“, „Montag, 17. November“. */
|
|
19
|
+
label: ReactNode;
|
|
20
|
+
/** The day as a machine reads it (`2026-11-17`), for the `<time>` around the label. */
|
|
21
|
+
dateTime?: string;
|
|
22
|
+
/** Its `TimelineItem`s, newest first. */
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
};
|
|
25
|
+
/** The entries of one day, under the day's name. */
|
|
26
|
+
export declare function TimelineGroup({ label, dateTime, className, children, ...props }: TimelineGroupProps): import("react").JSX.Element;
|
|
27
|
+
export type TimelineItemProps = Omit<ComponentProps<"li">, "children"> & {
|
|
28
|
+
/**
|
|
29
|
+
* What happened, as a sentence with the names in `<strong>`: „<strong>Anna Weber</strong> hat
|
|
30
|
+
* das Angebot A-2026-0418 angenommen.“
|
|
31
|
+
*/
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
/** When, as people read it: „14:32“ within a day, a date after a week. */
|
|
34
|
+
time?: ReactNode;
|
|
35
|
+
/** The moment as a machine reads it (`2026-11-19T14:32`), for the `<time>`. */
|
|
36
|
+
dateTime?: string;
|
|
37
|
+
/** The person who did it: an `Avatar size="sm"`. Without one, the system's mark stands there. */
|
|
38
|
+
avatar?: ReactNode;
|
|
39
|
+
/** A symbol for the kind of event, in place of the disc: a mail, an invoice. */
|
|
40
|
+
icon?: IconSvgElement;
|
|
41
|
+
/** A failure carries the danger symbol in place of the disc. Say it in the sentence as well. */
|
|
42
|
+
tone?: "neutral" | "danger";
|
|
43
|
+
};
|
|
44
|
+
/** One event: what happened, and when. */
|
|
45
|
+
export declare function TimelineItem({ avatar, icon, tone, time, dateTime, className, children, ...props }: TimelineItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { LiveList } from "../../internal/live-list.js";
|
|
2
|
+
import { RailMark } from "../../internal/rail-mark.js";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/timeline/timeline.tsx
|
|
6
|
+
/**
|
|
7
|
+
* What happened lately: quotes sent and accepted, people invited, a payment that failed. A flat
|
|
8
|
+
* list on a hairline rail, newest first, each entry a sentence and its time, drawn the way a
|
|
9
|
+
* `Trace` is (`rail.css`). Entries group under their day with a `TimelineGroup`.
|
|
10
|
+
*
|
|
11
|
+
* Each entry is led by what it is: the avatar of the person who acted, the symbol of an event the
|
|
12
|
+
* system did (a mail sent, an invoice made), the danger mark for a failure, and the plain mark for
|
|
13
|
+
* anything else. Mix them freely in one list; the rail runs straight through all of them.
|
|
14
|
+
*
|
|
15
|
+
* An entry that joins a list already on screen opens its room and fades in; what is there when
|
|
16
|
+
* the list first shows does not move (`timeline.css`). Server-safe: the list is markup, and the
|
|
17
|
+
* one frame of script that tells load from later comes with it (`LiveList`).
|
|
18
|
+
*/
|
|
19
|
+
function Timeline({ className, ...props }) {
|
|
20
|
+
return /* @__PURE__ */ jsx(LiveList, {
|
|
21
|
+
"data-slot": "timeline",
|
|
22
|
+
className: cn("flex flex-col [--rail-clear:0.25rem] [--rail-lead:1.5rem] [--rail-line:1.75rem]", className),
|
|
23
|
+
...props
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** The entries of one day, under the day's name. */
|
|
27
|
+
function TimelineGroup({ label, dateTime, className, children, ...props }) {
|
|
28
|
+
return /* @__PURE__ */ jsx("li", {
|
|
29
|
+
"data-slot": "timeline-group",
|
|
30
|
+
className: cn("not-first:mt-4", className),
|
|
31
|
+
...props,
|
|
32
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
33
|
+
"data-slot": "timeline-day",
|
|
34
|
+
className: "flex flex-col gap-1.5",
|
|
35
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
36
|
+
"data-slot": "timeline-group-label",
|
|
37
|
+
className: "text-sm font-medium text-fg-muted",
|
|
38
|
+
children: dateTime ? /* @__PURE__ */ jsx("time", {
|
|
39
|
+
dateTime,
|
|
40
|
+
children: label
|
|
41
|
+
}) : label
|
|
42
|
+
}), /* @__PURE__ */ jsx("ol", {
|
|
43
|
+
className: "flex flex-col",
|
|
44
|
+
children
|
|
45
|
+
})]
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** One event: what happened, and when. */
|
|
50
|
+
function TimelineItem({ avatar, icon, tone = "neutral", time, dateTime, className, children, ...props }) {
|
|
51
|
+
const lead = avatar ? "avatar" : "mark";
|
|
52
|
+
return /* @__PURE__ */ jsx("li", {
|
|
53
|
+
"data-slot": "timeline-item",
|
|
54
|
+
"data-lead": lead,
|
|
55
|
+
"data-tone": tone,
|
|
56
|
+
className: cn("rail-item", lead === "avatar" && "[--rail-mark:1.5rem]", className),
|
|
57
|
+
...props,
|
|
58
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
59
|
+
"data-slot": "timeline-entry",
|
|
60
|
+
className: "grid grid-cols-[var(--rail-lead)_minmax(0,1fr)_auto] gap-x-3 pb-3",
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsx("span", {
|
|
63
|
+
"data-slot": "timeline-lead",
|
|
64
|
+
className: "flex h-(--rail-line) items-center justify-center",
|
|
65
|
+
children: avatar ?? /* @__PURE__ */ jsx(RailMark, {
|
|
66
|
+
slot: "timeline-mark",
|
|
67
|
+
status: tone === "danger" ? "error" : "done",
|
|
68
|
+
icon
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ jsx("p", {
|
|
72
|
+
"data-slot": "timeline-text",
|
|
73
|
+
className: "py-[calc((var(--rail-line)-1lh)/2)] text-control text-pretty text-fg-body [&_strong]:font-medium [&_strong]:text-fg",
|
|
74
|
+
children
|
|
75
|
+
}),
|
|
76
|
+
time !== void 0 && /* @__PURE__ */ jsx("time", {
|
|
77
|
+
"data-slot": "timeline-time",
|
|
78
|
+
dateTime,
|
|
79
|
+
className: "py-[calc((var(--rail-line)-1lh)/2)] text-sm whitespace-nowrap text-fg-muted tabular-nums",
|
|
80
|
+
children: time
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export { Timeline, TimelineGroup, TimelineItem };
|
|
@@ -3,8 +3,9 @@ import { Button } from "../button/button.js";
|
|
|
3
3
|
import { Icon } from "../icon/icon.js";
|
|
4
4
|
import { Spinner } from "../spinner/spinner.js";
|
|
5
5
|
import { CloseGlyph } from "../../internal/glyphs.js";
|
|
6
|
+
import { statusIconTone, statusIcons } from "../../internal/status-icon.js";
|
|
7
|
+
import { cn } from "../../lib/cn.js";
|
|
6
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { Alert02Icon, AlertCircleIcon, CheckmarkCircle02Icon, InformationCircleIcon } from "@hugeicons/core-free-icons";
|
|
8
9
|
import { Toast } from "@base-ui/react/toast";
|
|
9
10
|
// src/components/toast/toast.tsx
|
|
10
11
|
/** The one stack of the app. `toast()` adds to it from anywhere, also from outside React. */
|
|
@@ -41,31 +42,14 @@ const toast = Object.assign(show, {
|
|
|
41
42
|
promise: toastManager.promise
|
|
42
43
|
});
|
|
43
44
|
function ToneIcon({ type }) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
icon: Alert02Icon,
|
|
53
|
-
size: 18,
|
|
54
|
-
className: "mt-0.5 text-warning"
|
|
55
|
-
});
|
|
56
|
-
case "danger":
|
|
57
|
-
case "error": return /* @__PURE__ */ jsx(Icon, {
|
|
58
|
-
icon: AlertCircleIcon,
|
|
59
|
-
size: 18,
|
|
60
|
-
className: "mt-0.5 text-danger"
|
|
61
|
-
});
|
|
62
|
-
case "info": return /* @__PURE__ */ jsx(Icon, {
|
|
63
|
-
icon: InformationCircleIcon,
|
|
64
|
-
size: 18,
|
|
65
|
-
className: "mt-0.5 text-fg"
|
|
66
|
-
});
|
|
67
|
-
default: return null;
|
|
68
|
-
}
|
|
45
|
+
if (type === "loading") return /* @__PURE__ */ jsx(Spinner, { className: "mt-[3px] text-fg-muted" });
|
|
46
|
+
const tone = type === "error" ? "danger" : type === "neutral" ? void 0 : type;
|
|
47
|
+
if (!tone || !(tone in statusIcons)) return null;
|
|
48
|
+
return /* @__PURE__ */ jsx(Icon, {
|
|
49
|
+
icon: statusIcons[tone],
|
|
50
|
+
size: 18,
|
|
51
|
+
className: cn("mt-0.5", statusIconTone[tone])
|
|
52
|
+
});
|
|
69
53
|
}
|
|
70
54
|
function ToastList({ closeLabel }) {
|
|
71
55
|
const { toasts } = Toast.useToastManager();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ButtonProps } from "../button/button.js";
|
|
2
|
+
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
3
|
+
export type ToggleProps<Value extends string = string> = Omit<Toggle$1.Props<Value>, "className" | "render"> & Pick<ButtonProps, "size"> & {
|
|
4
|
+
/** `secondary` (the default): a raised key. `quiet`: no face, for a toolbar. */
|
|
5
|
+
variant?: "secondary" | "quiet";
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Its keyboard shortcut (`mod+b`), said after its name in a toolbar's tooltip. */
|
|
8
|
+
shortcut?: string;
|
|
9
|
+
} & ({
|
|
10
|
+
/** A square key for a single symbol. It has no visible label, so it needs a name. */
|
|
11
|
+
iconOnly: true;
|
|
12
|
+
"aria-label": string;
|
|
13
|
+
} | {
|
|
14
|
+
iconOnly?: false;
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* A key that stays down: bold, a pinned row, a filter that is on. It is a button with two
|
|
18
|
+
* states and says which one it is in (`aria-pressed`). Pressed, it stays down; pressed again,
|
|
19
|
+
* it seats back.
|
|
20
|
+
*
|
|
21
|
+
* Its name does not change with its state: "Fett", not "Fett ausschalten". For a setting with
|
|
22
|
+
* a label beside it, a `Switch` reads better; for one choice out of a few views, a
|
|
23
|
+
* `SegmentedControl`. Several toggles that belong together go into a `ToggleGroup`, where each
|
|
24
|
+
* needs a `value`. In a `Toolbar` it joins the bar's one tab stop by itself, and a toggle with
|
|
25
|
+
* only a symbol says its name (and its `shortcut`) in a tooltip there.
|
|
26
|
+
*/
|
|
27
|
+
export declare function Toggle<Value extends string = string>({ variant, size, iconOnly, className, shortcut, children, ...props }: ToggleProps<Value>): import("react").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { useButtonGroup } from "../button-group/button-group-context.js";
|
|
4
|
+
import { useInToolbar } from "../toolbar/toolbar-context.js";
|
|
5
|
+
import { KeyTip } from "../../internal/key-tip.js";
|
|
6
|
+
import { cn } from "../../lib/cn.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Toolbar } from "@base-ui/react/toolbar";
|
|
9
|
+
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
10
|
+
// src/components/toggle/toggle.tsx
|
|
11
|
+
/**
|
|
12
|
+
* How a key shows that it is on. A key of a group keeps the pressed colour and the inner shade of
|
|
13
|
+
* a press, without its scale. A raised key on its own stays down: the pressed recipe without
|
|
14
|
+
* the scale, since it has come to rest. A quiet key keeps the wash it has under the pointer and
|
|
15
|
+
* its symbol stays dark; off, the symbol is muted and only darkens under the pointer.
|
|
16
|
+
*/
|
|
17
|
+
const pressedLook = {
|
|
18
|
+
key: "data-pressed:bg-(--key-pressed) data-pressed:inset-shadow-pressed",
|
|
19
|
+
secondary: ["data-pressed:bg-raised-pressed data-pressed:depth-pressed data-pressed:hover:depth-pressed", "data-disabled:data-pressed:bg-disabled data-disabled:data-pressed:depth-flat data-disabled:data-pressed:inset-shadow-pressed"].join(" "),
|
|
20
|
+
quiet: "text-fg-muted hover:text-fg data-pressed:bg-hover data-pressed:text-fg"
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A key that stays down: bold, a pinned row, a filter that is on. It is a button with two
|
|
24
|
+
* states and says which one it is in (`aria-pressed`). Pressed, it stays down; pressed again,
|
|
25
|
+
* it seats back.
|
|
26
|
+
*
|
|
27
|
+
* Its name does not change with its state: "Fett", not "Fett ausschalten". For a setting with
|
|
28
|
+
* a label beside it, a `Switch` reads better; for one choice out of a few views, a
|
|
29
|
+
* `SegmentedControl`. Several toggles that belong together go into a `ToggleGroup`, where each
|
|
30
|
+
* needs a `value`. In a `Toolbar` it joins the bar's one tab stop by itself, and a toggle with
|
|
31
|
+
* only a symbol says its name (and its `shortcut`) in a tooltip there.
|
|
32
|
+
*/
|
|
33
|
+
function Toggle({ variant = "secondary", size, iconOnly, className, shortcut, children, ...props }) {
|
|
34
|
+
const group = useButtonGroup();
|
|
35
|
+
const inToolbar = useInToolbar();
|
|
36
|
+
const look = cn(group ? pressedLook.key : pressedLook[variant], className);
|
|
37
|
+
const key = iconOnly ? /* @__PURE__ */ jsx(Button, {
|
|
38
|
+
iconOnly: true,
|
|
39
|
+
"aria-label": props["aria-label"] ?? "",
|
|
40
|
+
variant,
|
|
41
|
+
size,
|
|
42
|
+
className: look
|
|
43
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
44
|
+
variant,
|
|
45
|
+
size,
|
|
46
|
+
className: look
|
|
47
|
+
});
|
|
48
|
+
const toggle = /* @__PURE__ */ jsx(Toggle$1, {
|
|
49
|
+
"data-slot": "toggle",
|
|
50
|
+
...props,
|
|
51
|
+
render: inToolbar ? /* @__PURE__ */ jsx(Toolbar.Button, { render: key }) : key,
|
|
52
|
+
children
|
|
53
|
+
});
|
|
54
|
+
const label = inToolbar && iconOnly ? props["aria-label"] : void 0;
|
|
55
|
+
return label ? /* @__PURE__ */ jsx(KeyTip, {
|
|
56
|
+
label,
|
|
57
|
+
shortcut,
|
|
58
|
+
trigger: toggle
|
|
59
|
+
}) : toggle;
|
|
60
|
+
}
|
|
61
|
+
export { Toggle };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ToggleGroup as ToggleGroup$1 } from "@base-ui/react/toggle-group";
|
|
2
|
+
/** A group is a set of keys, and a set needs a name. */
|
|
3
|
+
type Named = {
|
|
4
|
+
"aria-label": string;
|
|
5
|
+
"aria-labelledby"?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
"aria-labelledby": string;
|
|
8
|
+
"aria-label"?: undefined;
|
|
9
|
+
};
|
|
10
|
+
export type ToggleGroupProps<Value extends string = string> = Omit<ToggleGroup$1.Props<Value>, "aria-label" | "aria-labelledby"> & Named & {
|
|
11
|
+
/** The size of every key in it. */
|
|
12
|
+
size?: "sm" | "md" | "lg";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Keys that stay down, as one fitting: bold, italic and underlined, or the alignment of a
|
|
16
|
+
* paragraph. It is drawn like a `ButtonGroup` (one face, one edge, one shadow, a seam between
|
|
17
|
+
* two keys), and every key that is on keeps the inner shade of a press.
|
|
18
|
+
*
|
|
19
|
+
* With `multiple` any number of keys may be down at once, each on its own. Without it one key
|
|
20
|
+
* at most is down, and pressing it again lets it up: for a choice that may also be none. A
|
|
21
|
+
* choice between views, where one is always selected, is a `SegmentedControl`.
|
|
22
|
+
*
|
|
23
|
+
* Put `Toggle`s inside, each with a `value`. The value of the group is always a list. Name the
|
|
24
|
+
* group (`aria-label`): Tab reaches it once, and the arrow keys move between its keys.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ToggleGroup<Value extends string = string>({ size, disabled, className, ...props }: ToggleGroupProps<Value>): import("react").JSX.Element;
|
|
27
|
+
export {};
|