@deepfuture/dui-components 1.3.0 → 1.4.1
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/all.d.ts +7 -0
- package/all.js +6 -0
- package/package.json +10 -2
- package/splitter/index.d.ts +8 -0
- package/splitter/index.js +7 -0
- package/splitter/splitter-handle.d.ts +24 -0
- package/splitter/splitter-handle.js +113 -0
- package/splitter/splitter-panel.d.ts +11 -0
- package/splitter/splitter-panel.js +12 -0
- package/splitter/splitter.d.ts +11 -0
- package/splitter/splitter.js +12 -0
- package/toast/default-icons.d.ts +17 -0
- package/toast/default-icons.js +96 -0
- package/toast/index.d.ts +12 -0
- package/toast/index.js +11 -0
- package/toast/toast-action.d.ts +16 -0
- package/toast/toast-action.js +52 -0
- package/toast/toast-close.d.ts +16 -0
- package/toast/toast-close.js +52 -0
- package/toast/toast-region.d.ts +40 -0
- package/toast/toast-region.js +307 -0
- package/toast/toast.d.ts +52 -0
- package/toast/toast.js +448 -0
- package/tokens/tokens-raw.js +1 -1
- package/tokens/tokens.css +18 -0
- package/tokens/tokens.js +1 -1
package/all.d.ts
CHANGED
|
@@ -37,10 +37,12 @@ import "./sidebar/index.js";
|
|
|
37
37
|
import "./slider/index.js";
|
|
38
38
|
import "./spinner/index.js";
|
|
39
39
|
import "./split-button/index.js";
|
|
40
|
+
import "./splitter/index.js";
|
|
40
41
|
import "./stepper/index.js";
|
|
41
42
|
import "./switch/index.js";
|
|
42
43
|
import "./tabs/index.js";
|
|
43
44
|
import "./textarea/index.js";
|
|
45
|
+
import "./toast/index.js";
|
|
44
46
|
import "./toggle/index.js";
|
|
45
47
|
import "./toolbar/index.js";
|
|
46
48
|
import "./tooltip/index.js";
|
|
@@ -120,6 +122,9 @@ export { DuiSidebarTrigger } from "./sidebar/index.js";
|
|
|
120
122
|
export { DuiSlider } from "./slider/index.js";
|
|
121
123
|
export { DuiSpinner } from "./spinner/index.js";
|
|
122
124
|
export { DuiSplitButton } from "./split-button/index.js";
|
|
125
|
+
export { DuiSplitter } from "./splitter/index.js";
|
|
126
|
+
export { DuiSplitterHandle } from "./splitter/index.js";
|
|
127
|
+
export { DuiSplitterPanel } from "./splitter/index.js";
|
|
123
128
|
export { DuiStepper } from "./stepper/index.js";
|
|
124
129
|
export { DuiSwitch } from "./switch/index.js";
|
|
125
130
|
export { DuiTab } from "./tabs/index.js";
|
|
@@ -128,6 +133,7 @@ export { DuiTabsIndicator } from "./tabs/index.js";
|
|
|
128
133
|
export { DuiTabsList } from "./tabs/index.js";
|
|
129
134
|
export { DuiTabsPanel } from "./tabs/index.js";
|
|
130
135
|
export { DuiTextarea } from "./textarea/index.js";
|
|
136
|
+
export { DuiToast, DuiToastAction, DuiToastClose, DuiToastRegion, toast, } from "./toast/index.js";
|
|
131
137
|
export { DuiToggle } from "./toggle/index.js";
|
|
132
138
|
export { DuiToggleGroup } from "./toggle/index.js";
|
|
133
139
|
export { DuiToolbar } from "./toolbar/index.js";
|
|
@@ -157,6 +163,7 @@ export type { PreviewCardContext, PreviewCardSide } from "@deepfuture/dui-primit
|
|
|
157
163
|
export type { RadioGroupContext } from "@deepfuture/dui-primitives/radio";
|
|
158
164
|
export type { SidebarOpenChangeDetail } from "@deepfuture/dui-primitives/sidebar";
|
|
159
165
|
export type { SidebarContext } from "@deepfuture/dui-primitives/sidebar";
|
|
166
|
+
export type { SplitterContext, SplitterHandleAria, SplitterHandleMeta, SplitterPanelMeta } from "@deepfuture/dui-primitives/splitter";
|
|
160
167
|
export type { TabsContext } from "@deepfuture/dui-primitives/tabs";
|
|
161
168
|
export type { TextareaResize } from "@deepfuture/dui-primitives/textarea";
|
|
162
169
|
export type { ToggleGroupContext } from "@deepfuture/dui-primitives/toggle";
|
package/all.js
CHANGED
|
@@ -37,10 +37,12 @@ import "./sidebar/index.js";
|
|
|
37
37
|
import "./slider/index.js";
|
|
38
38
|
import "./spinner/index.js";
|
|
39
39
|
import "./split-button/index.js";
|
|
40
|
+
import "./splitter/index.js";
|
|
40
41
|
import "./stepper/index.js";
|
|
41
42
|
import "./switch/index.js";
|
|
42
43
|
import "./tabs/index.js";
|
|
43
44
|
import "./textarea/index.js";
|
|
45
|
+
import "./toast/index.js";
|
|
44
46
|
import "./toggle/index.js";
|
|
45
47
|
import "./toolbar/index.js";
|
|
46
48
|
import "./tooltip/index.js";
|
|
@@ -120,6 +122,9 @@ export { DuiSidebarTrigger } from "./sidebar/index.js";
|
|
|
120
122
|
export { DuiSlider } from "./slider/index.js";
|
|
121
123
|
export { DuiSpinner } from "./spinner/index.js";
|
|
122
124
|
export { DuiSplitButton } from "./split-button/index.js";
|
|
125
|
+
export { DuiSplitter } from "./splitter/index.js";
|
|
126
|
+
export { DuiSplitterHandle } from "./splitter/index.js";
|
|
127
|
+
export { DuiSplitterPanel } from "./splitter/index.js";
|
|
123
128
|
export { DuiStepper } from "./stepper/index.js";
|
|
124
129
|
export { DuiSwitch } from "./switch/index.js";
|
|
125
130
|
export { DuiTab } from "./tabs/index.js";
|
|
@@ -128,6 +133,7 @@ export { DuiTabsIndicator } from "./tabs/index.js";
|
|
|
128
133
|
export { DuiTabsList } from "./tabs/index.js";
|
|
129
134
|
export { DuiTabsPanel } from "./tabs/index.js";
|
|
130
135
|
export { DuiTextarea } from "./textarea/index.js";
|
|
136
|
+
export { DuiToast, DuiToastAction, DuiToastClose, DuiToastRegion, toast, } from "./toast/index.js";
|
|
131
137
|
export { DuiToggle } from "./toggle/index.js";
|
|
132
138
|
export { DuiToggleGroup } from "./toggle/index.js";
|
|
133
139
|
export { DuiToolbar } from "./toolbar/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepfuture/dui-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "DUI styled web components — extends dui-primitives with design tokens and variant CSS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -154,6 +154,10 @@
|
|
|
154
154
|
"import": "./split-button/index.js",
|
|
155
155
|
"types": "./split-button/index.d.ts"
|
|
156
156
|
},
|
|
157
|
+
"./splitter": {
|
|
158
|
+
"import": "./splitter/index.js",
|
|
159
|
+
"types": "./splitter/index.d.ts"
|
|
160
|
+
},
|
|
157
161
|
"./stepper": {
|
|
158
162
|
"import": "./stepper/index.js",
|
|
159
163
|
"types": "./stepper/index.d.ts"
|
|
@@ -174,6 +178,10 @@
|
|
|
174
178
|
"import": "./theme/index.js",
|
|
175
179
|
"types": "./theme/index.d.ts"
|
|
176
180
|
},
|
|
181
|
+
"./toast": {
|
|
182
|
+
"import": "./toast/index.js",
|
|
183
|
+
"types": "./toast/index.d.ts"
|
|
184
|
+
},
|
|
177
185
|
"./toggle": {
|
|
178
186
|
"import": "./toggle/index.js",
|
|
179
187
|
"types": "./toggle/index.d.ts"
|
|
@@ -214,7 +222,7 @@
|
|
|
214
222
|
"README.md"
|
|
215
223
|
],
|
|
216
224
|
"dependencies": {
|
|
217
|
-
"@deepfuture/dui-primitives": "1.
|
|
225
|
+
"@deepfuture/dui-primitives": "1.7.0",
|
|
218
226
|
"lit": "^3.3.2",
|
|
219
227
|
"@lit/context": "^1.1.3"
|
|
220
228
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "./splitter.js";
|
|
2
|
+
import "./splitter-panel.js";
|
|
3
|
+
import "./splitter-handle.js";
|
|
4
|
+
export { DuiSplitter } from "./splitter.js";
|
|
5
|
+
export { DuiSplitterPanel } from "./splitter-panel.js";
|
|
6
|
+
export { DuiSplitterHandle } from "./splitter-handle.js";
|
|
7
|
+
export type { SplitterContext, SplitterHandleAria, SplitterHandleMeta, SplitterPanelMeta, } from "@deepfuture/dui-primitives/splitter";
|
|
8
|
+
export { collapseChangeEvent, valueChangeEvent } from "@deepfuture/dui-primitives/splitter";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./splitter.js";
|
|
2
|
+
import "./splitter-panel.js";
|
|
3
|
+
import "./splitter-handle.js";
|
|
4
|
+
export { DuiSplitter } from "./splitter.js";
|
|
5
|
+
export { DuiSplitterPanel } from "./splitter-panel.js";
|
|
6
|
+
export { DuiSplitterHandle } from "./splitter-handle.js";
|
|
7
|
+
export { collapseChangeEvent, valueChangeEvent } from "@deepfuture/dui-primitives/splitter";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DuiSplitterHandlePrimitive } from "@deepfuture/dui-primitives/splitter";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
/**
|
|
4
|
+
* `<dui-splitter-handle>` — Styled draggable separator.
|
|
5
|
+
*
|
|
6
|
+
* Default appearance: 8px interaction target with a centered 1px line that
|
|
7
|
+
* brightens on hover and turns accent-colored when dragged or keyboard-focused.
|
|
8
|
+
*
|
|
9
|
+
* Customize via CSS vars on the handle, the splitter, or any ancestor:
|
|
10
|
+
*
|
|
11
|
+
* ```css
|
|
12
|
+
* .my-splitter {
|
|
13
|
+
* --splitter-handle-size: 12px; // interaction target thickness
|
|
14
|
+
* --splitter-handle-visible-size: 0; // invisible bar with a fat target
|
|
15
|
+
* --splitter-handle-color: var(--border);
|
|
16
|
+
* --splitter-handle-hover-color: var(--border-strong);
|
|
17
|
+
* --splitter-handle-active-color: var(--accent);
|
|
18
|
+
* --splitter-handle-radius: var(--radius-full);
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class DuiSplitterHandle extends DuiSplitterHandlePrimitive {
|
|
23
|
+
static styles: import("lit").CSSResult[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { DuiSplitterHandlePrimitive } from "@deepfuture/dui-primitives/splitter";
|
|
3
|
+
import "../_install.js";
|
|
4
|
+
/**
|
|
5
|
+
* Two-layer handle styling:
|
|
6
|
+
*
|
|
7
|
+
* • The host element is the **interaction target**. Its cross-axis size
|
|
8
|
+
* (--splitter-handle-size) defines how easy the handle is to grab.
|
|
9
|
+
* • A ::before pseudo on [part="root"] draws the **visible line**, centered
|
|
10
|
+
* in the target, with its own thickness (--splitter-handle-visible-size).
|
|
11
|
+
*
|
|
12
|
+
* This decouples hit area from drawn width — set the visible line to 1px
|
|
13
|
+
* (or 0 for an invisible-but-grabbable handle) while keeping a fat 8px+
|
|
14
|
+
* target.
|
|
15
|
+
*
|
|
16
|
+
* Defaults are applied via `var(name, fallback)` at every consumption site
|
|
17
|
+
* rather than via a `:host { --x: default }` declarations block. The latter
|
|
18
|
+
* sets the value *directly* on the host element, which silently overrides
|
|
19
|
+
* any value the consumer inherits down from an ancestor (e.g. a wrapper
|
|
20
|
+
* with `.fat-handles { --splitter-handle-size: 16px }`). The fallback
|
|
21
|
+
* pattern keeps every var overridable from anywhere in the cascade.
|
|
22
|
+
*/
|
|
23
|
+
const styles = css `
|
|
24
|
+
/* Host = interaction target. Cross-axis size depends on orientation. */
|
|
25
|
+
:host([data-orientation="horizontal"]) {
|
|
26
|
+
width: var(--splitter-handle-size, var(--space-2));
|
|
27
|
+
}
|
|
28
|
+
:host([data-orientation="vertical"]) {
|
|
29
|
+
height: var(--splitter-handle-size, var(--space-2));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[part="root"] {
|
|
33
|
+
position: relative;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Visible line — centered in the interaction target. */
|
|
40
|
+
[part="root"]::before {
|
|
41
|
+
content: "";
|
|
42
|
+
display: block;
|
|
43
|
+
background: var(--splitter-handle-color, var(--border));
|
|
44
|
+
border-radius: var(--splitter-handle-radius, var(--radius-full));
|
|
45
|
+
transition:
|
|
46
|
+
background-color var(--splitter-handle-transition-duration, var(--duration-fast)) ease,
|
|
47
|
+
width var(--splitter-handle-transition-duration, var(--duration-fast)) ease,
|
|
48
|
+
height var(--splitter-handle-transition-duration, var(--duration-fast)) ease;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host([data-orientation="horizontal"]) [part="root"]::before {
|
|
52
|
+
width: var(--splitter-handle-visible-size, var(--border-width-thin));
|
|
53
|
+
height: 100%;
|
|
54
|
+
}
|
|
55
|
+
:host([data-orientation="vertical"]) [part="root"]::before {
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: var(--splitter-handle-visible-size, var(--border-width-thin));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Hover — brighten the line. :where(:hover) keeps the specificity at
|
|
61
|
+
(0,1,0) so the dragging rule below can win the tie via source order;
|
|
62
|
+
otherwise hovering during a drag would override the active color. */
|
|
63
|
+
:host(:where(:hover):not([data-disabled])) [part="root"]::before {
|
|
64
|
+
background: var(--splitter-handle-hover-color, var(--border-strong));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Active states. The primitive defaultPrevents focus-on-mousedown so
|
|
68
|
+
pointer clicks no longer steal focus — [data-focused] reflects keyboard
|
|
69
|
+
focus only, matching :focus-visible semantics. */
|
|
70
|
+
:host([data-dragging]) [part="root"]::before,
|
|
71
|
+
:host([data-focused]) [part="root"]::before {
|
|
72
|
+
background: var(--splitter-handle-active-color, var(--accent));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Keyboard focus also fattens the line so the active state is unambiguous
|
|
76
|
+
even when --splitter-handle-visible-size is 0. The combined attribute
|
|
77
|
+
selector beats the orientation-specific size rule above on specificity. */
|
|
78
|
+
:host([data-orientation="horizontal"][data-focused]) [part="root"]::before {
|
|
79
|
+
width: var(--space-1);
|
|
80
|
+
}
|
|
81
|
+
:host([data-orientation="vertical"][data-focused]) [part="root"]::before {
|
|
82
|
+
height: var(--space-1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Disabled — mute the bar. */
|
|
86
|
+
:host([data-disabled]) [part="root"]::before {
|
|
87
|
+
background: var(--border);
|
|
88
|
+
opacity: 0.5;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
/**
|
|
92
|
+
* `<dui-splitter-handle>` — Styled draggable separator.
|
|
93
|
+
*
|
|
94
|
+
* Default appearance: 8px interaction target with a centered 1px line that
|
|
95
|
+
* brightens on hover and turns accent-colored when dragged or keyboard-focused.
|
|
96
|
+
*
|
|
97
|
+
* Customize via CSS vars on the handle, the splitter, or any ancestor:
|
|
98
|
+
*
|
|
99
|
+
* ```css
|
|
100
|
+
* .my-splitter {
|
|
101
|
+
* --splitter-handle-size: 12px; // interaction target thickness
|
|
102
|
+
* --splitter-handle-visible-size: 0; // invisible bar with a fat target
|
|
103
|
+
* --splitter-handle-color: var(--border);
|
|
104
|
+
* --splitter-handle-hover-color: var(--border-strong);
|
|
105
|
+
* --splitter-handle-active-color: var(--accent);
|
|
106
|
+
* --splitter-handle-radius: var(--radius-full);
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export class DuiSplitterHandle extends DuiSplitterHandlePrimitive {
|
|
111
|
+
static styles = [...DuiSplitterHandlePrimitive.styles, styles];
|
|
112
|
+
}
|
|
113
|
+
customElements.define(DuiSplitterHandle.tagName, DuiSplitterHandle);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DuiSplitterPanelPrimitive } from "@deepfuture/dui-primitives/splitter";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
/**
|
|
4
|
+
* `<dui-splitter-panel>` — A single resizable panel.
|
|
5
|
+
*
|
|
6
|
+
* The host owns `flex-basis` (set inline by the parent splitter); consumers
|
|
7
|
+
* paint content onto `::part(root)`. No default aesthetic styling — panels
|
|
8
|
+
* are content surfaces and should adopt the surrounding application's look.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DuiSplitterPanel extends DuiSplitterPanelPrimitive {
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DuiSplitterPanelPrimitive } from "@deepfuture/dui-primitives/splitter";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
/**
|
|
4
|
+
* `<dui-splitter-panel>` — A single resizable panel.
|
|
5
|
+
*
|
|
6
|
+
* The host owns `flex-basis` (set inline by the parent splitter); consumers
|
|
7
|
+
* paint content onto `::part(root)`. No default aesthetic styling — panels
|
|
8
|
+
* are content surfaces and should adopt the surrounding application's look.
|
|
9
|
+
*/
|
|
10
|
+
export class DuiSplitterPanel extends DuiSplitterPanelPrimitive {
|
|
11
|
+
}
|
|
12
|
+
customElements.define(DuiSplitterPanel.tagName, DuiSplitterPanel);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DuiSplitterPrimitive } from "@deepfuture/dui-primitives/splitter";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
/**
|
|
4
|
+
* `<dui-splitter>` — Resizable panel group.
|
|
5
|
+
*
|
|
6
|
+
* The root element is layout-only; all aesthetic styling lives on
|
|
7
|
+
* `<dui-splitter-handle>` and (optionally) on each `<dui-splitter-panel>`'s
|
|
8
|
+
* `::part(root)` content surface.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DuiSplitter extends DuiSplitterPrimitive {
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DuiSplitterPrimitive } from "@deepfuture/dui-primitives/splitter";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
/**
|
|
4
|
+
* `<dui-splitter>` — Resizable panel group.
|
|
5
|
+
*
|
|
6
|
+
* The root element is layout-only; all aesthetic styling lives on
|
|
7
|
+
* `<dui-splitter-handle>` and (optionally) on each `<dui-splitter-panel>`'s
|
|
8
|
+
* `::part(root)` content surface.
|
|
9
|
+
*/
|
|
10
|
+
export class DuiSplitter extends DuiSplitterPrimitive {
|
|
11
|
+
}
|
|
12
|
+
customElements.define(DuiSplitter.tagName, DuiSplitter);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default icon templates for `<dui-toast>`, keyed by `data-type`.
|
|
3
|
+
*
|
|
4
|
+
* SVGs are sized to 14×16 with `currentColor` so they inherit the toast's
|
|
5
|
+
* `--toast-icon-color` (which resolves per-type via `--toast-type-color`).
|
|
6
|
+
*
|
|
7
|
+
* The `loading` type uses `<dui-spinner>` instead of an inline SVG for
|
|
8
|
+
* consistency with the rest of `@dui/components` (and free reduced-motion
|
|
9
|
+
* handling).
|
|
10
|
+
*/
|
|
11
|
+
import { type TemplateResult } from "lit";
|
|
12
|
+
import type { ToastType } from "@deepfuture/dui-primitives/toast";
|
|
13
|
+
/**
|
|
14
|
+
* Returns the default icon template for a given toast type, or `null` if the
|
|
15
|
+
* type doesn't ship with a built-in icon (`default`, or any unknown value).
|
|
16
|
+
*/
|
|
17
|
+
export declare function defaultIconFor(type: ToastType): TemplateResult | null;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default icon templates for `<dui-toast>`, keyed by `data-type`.
|
|
3
|
+
*
|
|
4
|
+
* SVGs are sized to 14×16 with `currentColor` so they inherit the toast's
|
|
5
|
+
* `--toast-icon-color` (which resolves per-type via `--toast-type-color`).
|
|
6
|
+
*
|
|
7
|
+
* The `loading` type uses `<dui-spinner>` instead of an inline SVG for
|
|
8
|
+
* consistency with the rest of `@dui/components` (and free reduced-motion
|
|
9
|
+
* handling).
|
|
10
|
+
*/
|
|
11
|
+
import { html } from "lit";
|
|
12
|
+
const success = html `
|
|
13
|
+
<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">
|
|
14
|
+
<path
|
|
15
|
+
d="M3 8.5l3 3 6.5-7"
|
|
16
|
+
fill="none"
|
|
17
|
+
stroke="currentColor"
|
|
18
|
+
stroke-width="2"
|
|
19
|
+
stroke-linecap="round"
|
|
20
|
+
stroke-linejoin="round"
|
|
21
|
+
/>
|
|
22
|
+
</svg>
|
|
23
|
+
`;
|
|
24
|
+
const error = html `
|
|
25
|
+
<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">
|
|
26
|
+
<path
|
|
27
|
+
d="M4 4l8 8M12 4l-8 8"
|
|
28
|
+
fill="none"
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
stroke-width="2"
|
|
31
|
+
stroke-linecap="round"
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
`;
|
|
35
|
+
const warning = html `
|
|
36
|
+
<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">
|
|
37
|
+
<path
|
|
38
|
+
d="M8 1.5L14.5 13.5h-13z"
|
|
39
|
+
fill="none"
|
|
40
|
+
stroke="currentColor"
|
|
41
|
+
stroke-width="2"
|
|
42
|
+
stroke-linejoin="round"
|
|
43
|
+
/>
|
|
44
|
+
<path
|
|
45
|
+
d="M8 6v3.5"
|
|
46
|
+
fill="none"
|
|
47
|
+
stroke="currentColor"
|
|
48
|
+
stroke-width="2"
|
|
49
|
+
stroke-linecap="round"
|
|
50
|
+
/>
|
|
51
|
+
<circle cx="8" cy="11.5" r="0.9" fill="currentColor" />
|
|
52
|
+
</svg>
|
|
53
|
+
`;
|
|
54
|
+
const info = html `
|
|
55
|
+
<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">
|
|
56
|
+
<circle
|
|
57
|
+
cx="8"
|
|
58
|
+
cy="8"
|
|
59
|
+
r="6.5"
|
|
60
|
+
fill="none"
|
|
61
|
+
stroke="currentColor"
|
|
62
|
+
stroke-width="2"
|
|
63
|
+
/>
|
|
64
|
+
<path
|
|
65
|
+
d="M8 7.5v4"
|
|
66
|
+
fill="none"
|
|
67
|
+
stroke="currentColor"
|
|
68
|
+
stroke-width="2"
|
|
69
|
+
stroke-linecap="round"
|
|
70
|
+
/>
|
|
71
|
+
<circle cx="8" cy="4.7" r="0.9" fill="currentColor" />
|
|
72
|
+
</svg>
|
|
73
|
+
`;
|
|
74
|
+
const loading = html `
|
|
75
|
+
<dui-spinner part="spinner" aria-hidden="true"></dui-spinner>
|
|
76
|
+
`;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the default icon template for a given toast type, or `null` if the
|
|
79
|
+
* type doesn't ship with a built-in icon (`default`, or any unknown value).
|
|
80
|
+
*/
|
|
81
|
+
export function defaultIconFor(type) {
|
|
82
|
+
switch (type) {
|
|
83
|
+
case "success":
|
|
84
|
+
return success;
|
|
85
|
+
case "error":
|
|
86
|
+
return error;
|
|
87
|
+
case "warning":
|
|
88
|
+
return warning;
|
|
89
|
+
case "info":
|
|
90
|
+
return info;
|
|
91
|
+
case "loading":
|
|
92
|
+
return loading;
|
|
93
|
+
default:
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
package/toast/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "./toast-region.js";
|
|
2
|
+
import "./toast.js";
|
|
3
|
+
import "./toast-action.js";
|
|
4
|
+
import "./toast-close.js";
|
|
5
|
+
import { toast } from "@deepfuture/dui-primitives/toast";
|
|
6
|
+
export { DuiToastRegion } from "./toast-region.js";
|
|
7
|
+
export { DuiToast } from "./toast.js";
|
|
8
|
+
export { DuiToastAction } from "./toast-action.js";
|
|
9
|
+
export { DuiToastClose } from "./toast-close.js";
|
|
10
|
+
export { toast };
|
|
11
|
+
export type { PromiseMessages, ToastAction, ToastApi, ToastConfig, ToastDismissDetail, ToastDismissReason, ToastItemContext, ToastOpenChangeDetail, ToastOptions, ToastPosition, ToastPriority, ToastRegionContext, ToastType, } from "@deepfuture/dui-primitives/toast";
|
|
12
|
+
export { toastDismissEvent, toastOpenChangeEvent, toastRegionDismissEvent, } from "@deepfuture/dui-primitives/toast";
|
package/toast/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./toast-region.js";
|
|
2
|
+
import "./toast.js";
|
|
3
|
+
import "./toast-action.js";
|
|
4
|
+
import "./toast-close.js";
|
|
5
|
+
import { toast } from "@deepfuture/dui-primitives/toast";
|
|
6
|
+
export { DuiToastRegion } from "./toast-region.js";
|
|
7
|
+
export { DuiToast } from "./toast.js";
|
|
8
|
+
export { DuiToastAction } from "./toast-action.js";
|
|
9
|
+
export { DuiToastClose } from "./toast-close.js";
|
|
10
|
+
export { toast };
|
|
11
|
+
export { toastDismissEvent, toastOpenChangeEvent, toastRegionDismissEvent, } from "@deepfuture/dui-primitives/toast";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DuiToastActionPrimitive } from "@deepfuture/dui-primitives/toast";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
/**
|
|
4
|
+
* `<dui-toast-action>` — Styled action button wrapper.
|
|
5
|
+
*
|
|
6
|
+
* Wraps a slotted button (typically an auto-created `<button>` from the
|
|
7
|
+
* imperative `toast()` facade, or a consumer-provided `<button>` /
|
|
8
|
+
* `<dui-button>`). Clicking the slotted control dismisses the toast with
|
|
9
|
+
* reason `"action"` (handled by the primitive).
|
|
10
|
+
*
|
|
11
|
+
* Bare `<button>` children are styled as a small filled neutral button.
|
|
12
|
+
* Slotted `<dui-button>` retains its own styling.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DuiToastAction extends DuiToastActionPrimitive {
|
|
15
|
+
static styles: import("lit").CSSResult[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { DuiToastActionPrimitive } from "@deepfuture/dui-primitives/toast";
|
|
3
|
+
import "../_install.js";
|
|
4
|
+
const styles = css `
|
|
5
|
+
/* Style any slotted <button> uniformly — works for both the imperative
|
|
6
|
+
facade's auto-created <button>s and consumer-slotted ones. Native
|
|
7
|
+
::slotted() can't reach into shadow trees, but this targets light-DOM
|
|
8
|
+
children of <dui-toast-action>. */
|
|
9
|
+
::slotted(button) {
|
|
10
|
+
font-family: var(--font-sans);
|
|
11
|
+
font-size: var(--text-xs);
|
|
12
|
+
font-weight: var(--font-weight-medium);
|
|
13
|
+
line-height: 1;
|
|
14
|
+
padding: var(--space-1_5) var(--space-2_5);
|
|
15
|
+
border: var(--border-width-thin) solid transparent;
|
|
16
|
+
border-radius: var(--radius-sm);
|
|
17
|
+
background: var(--foreground);
|
|
18
|
+
color: var(--background);
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition:
|
|
21
|
+
background var(--duration-fast) var(--ease-out-3),
|
|
22
|
+
filter var(--duration-fast) var(--ease-out-3);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
::slotted(button:hover) {
|
|
26
|
+
filter: brightness(0.88);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
::slotted(button:active) {
|
|
30
|
+
filter: brightness(0.78);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
::slotted(button:focus-visible) {
|
|
34
|
+
outline: var(--focus-ring-width) solid var(--focus-ring-color);
|
|
35
|
+
outline-offset: var(--focus-ring-offset);
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
/**
|
|
39
|
+
* `<dui-toast-action>` — Styled action button wrapper.
|
|
40
|
+
*
|
|
41
|
+
* Wraps a slotted button (typically an auto-created `<button>` from the
|
|
42
|
+
* imperative `toast()` facade, or a consumer-provided `<button>` /
|
|
43
|
+
* `<dui-button>`). Clicking the slotted control dismisses the toast with
|
|
44
|
+
* reason `"action"` (handled by the primitive).
|
|
45
|
+
*
|
|
46
|
+
* Bare `<button>` children are styled as a small filled neutral button.
|
|
47
|
+
* Slotted `<dui-button>` retains its own styling.
|
|
48
|
+
*/
|
|
49
|
+
export class DuiToastAction extends DuiToastActionPrimitive {
|
|
50
|
+
static styles = [...DuiToastActionPrimitive.styles, styles];
|
|
51
|
+
}
|
|
52
|
+
customElements.define(DuiToastAction.tagName, DuiToastAction);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DuiToastClosePrimitive } from "@deepfuture/dui-primitives/toast";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
/**
|
|
4
|
+
* `<dui-toast-close>` — Styled close button wrapper.
|
|
5
|
+
*
|
|
6
|
+
* Wraps a slotted close control (typically an auto-created `<button>×</button>`
|
|
7
|
+
* from the imperative `toast()` facade, or a consumer-provided one). Clicking
|
|
8
|
+
* dismisses the toast with reason `"close"` (handled by the primitive).
|
|
9
|
+
*
|
|
10
|
+
* Bare `<button>` children are styled as a square ghost-icon button. The
|
|
11
|
+
* parent `<dui-toast>` controls visibility (hover-only on devices with
|
|
12
|
+
* hover, always visible on touch).
|
|
13
|
+
*/
|
|
14
|
+
export declare class DuiToastClose extends DuiToastClosePrimitive {
|
|
15
|
+
static styles: import("lit").CSSResult[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { DuiToastClosePrimitive } from "@deepfuture/dui-primitives/toast";
|
|
3
|
+
import "../_install.js";
|
|
4
|
+
const styles = css `
|
|
5
|
+
/* Style any slotted <button> as a small ghost-icon close affordance.
|
|
6
|
+
Hover-to-show behavior lives on the parent <dui-toast> (close-wrapper
|
|
7
|
+
part); this just renders the button itself. */
|
|
8
|
+
::slotted(button) {
|
|
9
|
+
font-family: var(--font-sans);
|
|
10
|
+
font-size: var(--text-xs);
|
|
11
|
+
line-height: 1;
|
|
12
|
+
width: var(--space-5);
|
|
13
|
+
height: var(--space-5);
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
padding: 0;
|
|
18
|
+
border: none;
|
|
19
|
+
border-radius: var(--radius-sm);
|
|
20
|
+
background: transparent;
|
|
21
|
+
color: var(--text-2);
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
transition:
|
|
24
|
+
background var(--duration-fast) var(--ease-out-3),
|
|
25
|
+
color var(--duration-fast) var(--ease-out-3);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
::slotted(button:hover) {
|
|
29
|
+
background: oklch(from var(--foreground) l c h / 0.08);
|
|
30
|
+
color: var(--text-1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
::slotted(button:focus-visible) {
|
|
34
|
+
outline: var(--focus-ring-width) solid var(--focus-ring-color);
|
|
35
|
+
outline-offset: var(--focus-ring-offset);
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
/**
|
|
39
|
+
* `<dui-toast-close>` — Styled close button wrapper.
|
|
40
|
+
*
|
|
41
|
+
* Wraps a slotted close control (typically an auto-created `<button>×</button>`
|
|
42
|
+
* from the imperative `toast()` facade, or a consumer-provided one). Clicking
|
|
43
|
+
* dismisses the toast with reason `"close"` (handled by the primitive).
|
|
44
|
+
*
|
|
45
|
+
* Bare `<button>` children are styled as a square ghost-icon button. The
|
|
46
|
+
* parent `<dui-toast>` controls visibility (hover-only on devices with
|
|
47
|
+
* hover, always visible on touch).
|
|
48
|
+
*/
|
|
49
|
+
export class DuiToastClose extends DuiToastClosePrimitive {
|
|
50
|
+
static styles = [...DuiToastClosePrimitive.styles, styles];
|
|
51
|
+
}
|
|
52
|
+
customElements.define(DuiToastClose.tagName, DuiToastClose);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type PropertyValues } from "lit";
|
|
2
|
+
import { DuiToastRegionPrimitive } from "@deepfuture/dui-primitives/toast";
|
|
3
|
+
import "../_install.js";
|
|
4
|
+
/**
|
|
5
|
+
* Theme override values for `<dui-toast-region theme="...">`.
|
|
6
|
+
*
|
|
7
|
+
* - `light` / `dark` — force a fixed palette regardless of page theme.
|
|
8
|
+
* - `inverted` — resolve at runtime to the opposite of the page theme.
|
|
9
|
+
*/
|
|
10
|
+
type RegionTheme = "light" | "dark" | "inverted" | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* `<dui-toast-region>` — Styled toast viewport.
|
|
13
|
+
*
|
|
14
|
+
* Extends the primitive with:
|
|
15
|
+
* - Sonner-style cascade-and-expand stacking (default-on)
|
|
16
|
+
* - Wider 24rem default width
|
|
17
|
+
* - Consumer-tunable stack visuals (`--toast-stack-peek`,
|
|
18
|
+
* `--toast-stack-scale-step`, `--toast-expanded-gap`)
|
|
19
|
+
* - Optional `theme="light|dark|inverted"` palette override
|
|
20
|
+
*
|
|
21
|
+
* Default position is the primitive's `bottom-right`; flip via the inherited
|
|
22
|
+
* `position` attribute. Imperative `toast()` calls land here automatically.
|
|
23
|
+
*
|
|
24
|
+
* @attr theme - `"light" | "dark" | "inverted"`. Unset = inherit page theme.
|
|
25
|
+
* `inverted` resolves at runtime to the opposite of the document's
|
|
26
|
+
* `<html data-theme>` attribute.
|
|
27
|
+
*/
|
|
28
|
+
export declare class DuiToastRegion extends DuiToastRegionPrimitive {
|
|
29
|
+
#private;
|
|
30
|
+
static styles: import("lit").CSSResult[];
|
|
31
|
+
/**
|
|
32
|
+
* Optional palette override. Unset = inherit page theme. `inverted`
|
|
33
|
+
* resolves at runtime to the opposite of `<html>`'s `data-theme`.
|
|
34
|
+
*/
|
|
35
|
+
accessor theme: RegionTheme;
|
|
36
|
+
connectedCallback(): void;
|
|
37
|
+
disconnectedCallback(): void;
|
|
38
|
+
willUpdate(changed: PropertyValues): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|