@zazz-ui/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +61 -0
- package/dist/sri.json +75 -0
- package/dist/zazz.css +1 -0
- package/dist/zazz.js +1 -0
- package/examples/about.html +590 -0
- package/examples/components.html +1040 -0
- package/examples/forms.html +511 -0
- package/examples/index.html +268 -0
- package/examples/layout.html +320 -0
- package/examples/products.html +846 -0
- package/examples/responsive.html +339 -0
- package/package.json +85 -0
- package/src/base/_layers.css +12 -0
- package/src/base/_layout.css +568 -0
- package/src/base/_reset.css +515 -0
- package/src/base/_typography.css +495 -0
- package/src/base/_utilities.css +6628 -0
- package/src/base/_variables.css +682 -0
- package/src/base/_view-transitions.css +103 -0
- package/src/base/command-score.d.ts +12 -0
- package/src/base/command-score.d.ts.map +1 -0
- package/src/base/command-score.js +151 -0
- package/src/base/command-score.ts +192 -0
- package/src/base/dialog-lifecycle.d.ts +11 -0
- package/src/base/dialog-lifecycle.d.ts.map +1 -0
- package/src/base/dialog-lifecycle.js +65 -0
- package/src/base/dialog-lifecycle.ts +80 -0
- package/src/base/embla.d.ts +90 -0
- package/src/base/embla.d.ts.map +1 -0
- package/src/base/embla.js +643 -0
- package/src/base/embla.ts +791 -0
- package/src/base/hotkeys.d.ts +82 -0
- package/src/base/hotkeys.d.ts.map +1 -0
- package/src/base/hotkeys.js +141 -0
- package/src/base/hotkeys.ts +195 -0
- package/src/base/navigation.d.ts +2 -0
- package/src/base/navigation.d.ts.map +1 -0
- package/src/base/navigation.js +136 -0
- package/src/base/navigation.ts +151 -0
- package/src/base/reveal.d.ts +80 -0
- package/src/base/reveal.d.ts.map +1 -0
- package/src/base/reveal.js +305 -0
- package/src/base/reveal.ts +379 -0
- package/src/base/signals.d.ts +89 -0
- package/src/base/signals.d.ts.map +1 -0
- package/src/base/signals.js +134 -0
- package/src/base/signals.ts +164 -0
- package/src/base/typeahead.d.ts +105 -0
- package/src/base/typeahead.d.ts.map +1 -0
- package/src/base/typeahead.js +411 -0
- package/src/base/typeahead.ts +500 -0
- package/src/base/utils.d.ts +56 -0
- package/src/base/utils.d.ts.map +1 -0
- package/src/base/utils.js +88 -0
- package/src/base/utils.ts +98 -0
- package/src/base/zazz-element.d.ts +44 -0
- package/src/base/zazz-element.d.ts.map +1 -0
- package/src/base/zazz-element.js +59 -0
- package/src/base/zazz-element.ts +73 -0
- package/src/globals.d.ts +148 -0
- package/src/head.d.ts +95 -0
- package/src/head.d.ts.map +1 -0
- package/src/head.js +311 -0
- package/src/head.ts +433 -0
- package/src/index.css +71 -0
- package/src/index.d.ts +36 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +35 -0
- package/src/index.ts +36 -0
- package/src/manifest.d.ts +90 -0
- package/src/manifest.d.ts.map +1 -0
- package/src/manifest.js +614 -0
- package/src/manifest.ts +667 -0
- package/src/primitives/accordion/accordion.css +104 -0
- package/src/primitives/accordion/accordion.html +69 -0
- package/src/primitives/alert-dialog/alert-dialog.css +38 -0
- package/src/primitives/alert-dialog/alert-dialog.html +53 -0
- package/src/primitives/autocomplete/autocomplete-groups.html +77 -0
- package/src/primitives/autocomplete/autocomplete.css +114 -0
- package/src/primitives/autocomplete/autocomplete.d.ts +30 -0
- package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -0
- package/src/primitives/autocomplete/autocomplete.html +66 -0
- package/src/primitives/autocomplete/autocomplete.js +41 -0
- package/src/primitives/autocomplete/autocomplete.ts +46 -0
- package/src/primitives/avatar/avatar.html +44 -0
- package/src/primitives/badge/badge-icon.html +36 -0
- package/src/primitives/badge/badge.css +251 -0
- package/src/primitives/badge/badge.html +7 -0
- package/src/primitives/breadcrumbs/breadcrumbs.html +9 -0
- package/src/primitives/button/button-icon-only.html +84 -0
- package/src/primitives/button/button-icon.html +82 -0
- package/src/primitives/button/button.css +319 -0
- package/src/primitives/button/button.html +8 -0
- package/src/primitives/button-group/button-group-vertical.html +6 -0
- package/src/primitives/button-group/button-group.css +94 -0
- package/src/primitives/button-group/button-group.html +64 -0
- package/src/primitives/card/card-subgrid.html +118 -0
- package/src/primitives/card/card.html +53 -0
- package/src/primitives/carousel/carousel.css +61 -0
- package/src/primitives/carousel/carousel.d.ts +16 -0
- package/src/primitives/carousel/carousel.d.ts.map +1 -0
- package/src/primitives/carousel/carousel.html +315 -0
- package/src/primitives/carousel/carousel.js +73 -0
- package/src/primitives/carousel/carousel.ts +84 -0
- package/src/primitives/checkbox/checkbox-tasklist.html +71 -0
- package/src/primitives/checkbox/checkbox.css +82 -0
- package/src/primitives/checkbox/checkbox.d.ts +21 -0
- package/src/primitives/checkbox/checkbox.d.ts.map +1 -0
- package/src/primitives/checkbox/checkbox.html +17 -0
- package/src/primitives/checkbox/checkbox.js +190 -0
- package/src/primitives/checkbox/checkbox.ts +219 -0
- package/src/primitives/combobox/combobox-multiselect.html +91 -0
- package/src/primitives/combobox/combobox.css +307 -0
- package/src/primitives/combobox/combobox.d.ts +100 -0
- package/src/primitives/combobox/combobox.d.ts.map +1 -0
- package/src/primitives/combobox/combobox.html +73 -0
- package/src/primitives/combobox/combobox.js +503 -0
- package/src/primitives/combobox/combobox.ts +559 -0
- package/src/primitives/command/command-actions.d.ts +31 -0
- package/src/primitives/command/command-actions.d.ts.map +1 -0
- package/src/primitives/command/command-actions.html +89 -0
- package/src/primitives/command/command-actions.js +70 -0
- package/src/primitives/command/command-actions.ts +77 -0
- package/src/primitives/command/command-dialog.html +77 -0
- package/src/primitives/command/command.css +151 -0
- package/src/primitives/command/command.d.ts +52 -0
- package/src/primitives/command/command.d.ts.map +1 -0
- package/src/primitives/command/command.html +119 -0
- package/src/primitives/command/command.js +146 -0
- package/src/primitives/command/command.ts +157 -0
- package/src/primitives/dialog/dialog-with-form.html +200 -0
- package/src/primitives/dialog/dialog.css +229 -0
- package/src/primitives/dialog/dialog.html +90 -0
- package/src/primitives/fields/fields.css +278 -0
- package/src/primitives/input/input-icon-leading.html +19 -0
- package/src/primitives/input/input-icon-trailing.html +18 -0
- package/src/primitives/input/input.css +114 -0
- package/src/primitives/input/input.html +61 -0
- package/src/primitives/input-group/input-group-password-group.html +108 -0
- package/src/primitives/input-group/input-group.css +215 -0
- package/src/primitives/input-group/input-group.html +132 -0
- package/src/primitives/kbd/kbd-group.html +18 -0
- package/src/primitives/kbd/kbd.css +87 -0
- package/src/primitives/kbd/kbd.html +7 -0
- package/src/primitives/lightbox/lightbox.css +459 -0
- package/src/primitives/lightbox/lightbox.d.ts +7 -0
- package/src/primitives/lightbox/lightbox.d.ts.map +1 -0
- package/src/primitives/lightbox/lightbox.html +665 -0
- package/src/primitives/lightbox/lightbox.js +96 -0
- package/src/primitives/lightbox/lightbox.ts +113 -0
- package/src/primitives/menu/menu-interest.html +52 -0
- package/src/primitives/menu/menu.css +55 -0
- package/src/primitives/menu/menu.d.ts +38 -0
- package/src/primitives/menu/menu.d.ts.map +1 -0
- package/src/primitives/menu/menu.html +70 -0
- package/src/primitives/menu/menu.js +117 -0
- package/src/primitives/menu/menu.ts +131 -0
- package/src/primitives/menubar/menubar-help-search.html +103 -0
- package/src/primitives/menubar/menubar.html +166 -0
- package/src/primitives/meter/meter.css +178 -0
- package/src/primitives/meter/meter.html +38 -0
- package/src/primitives/mobile-menu/mobile-menu.css +145 -0
- package/src/primitives/mobile-menu/mobile-menu.html +614 -0
- package/src/primitives/navigation-menu/navigation-menu-featured.html +76 -0
- package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +158 -0
- package/src/primitives/navigation-menu/navigation-menu-interest.html +103 -0
- package/src/primitives/navigation-menu/navigation-menu-megamenu.html +141 -0
- package/src/primitives/navigation-menu/navigation-menu-simple.html +96 -0
- package/src/primitives/navigation-menu/navigation-menu.css +295 -0
- package/src/primitives/navigation-menu/navigation-menu.html +576 -0
- package/src/primitives/otp/otp.css +126 -0
- package/src/primitives/otp/otp.d.ts +89 -0
- package/src/primitives/otp/otp.d.ts.map +1 -0
- package/src/primitives/otp/otp.html +22 -0
- package/src/primitives/otp/otp.js +226 -0
- package/src/primitives/otp/otp.ts +279 -0
- package/src/primitives/password-group/password-group.css +238 -0
- package/src/primitives/password-group/password-group.d.ts +25 -0
- package/src/primitives/password-group/password-group.d.ts.map +1 -0
- package/src/primitives/password-group/password-group.html +109 -0
- package/src/primitives/password-group/password-group.js +76 -0
- package/src/primitives/password-group/password-group.ts +95 -0
- package/src/primitives/popover/popover.css +233 -0
- package/src/primitives/progress/progress-indeterminate.html +1 -0
- package/src/primitives/progress/progress.css +105 -0
- package/src/primitives/progress/progress.html +7 -0
- package/src/primitives/prose/prose.html +65 -0
- package/src/primitives/radio/radio.css +84 -0
- package/src/primitives/radio/radio.html +17 -0
- package/src/primitives/reveal/reveal.css +167 -0
- package/src/primitives/select/multiselect.d.ts +43 -0
- package/src/primitives/select/multiselect.d.ts.map +1 -0
- package/src/primitives/select/multiselect.js +147 -0
- package/src/primitives/select/multiselect.ts +188 -0
- package/src/primitives/select/select-align.html +49 -0
- package/src/primitives/select/select-multiple.html +12 -0
- package/src/primitives/select/select-sides.html +65 -0
- package/src/primitives/select/select.css +481 -0
- package/src/primitives/select/select.html +16 -0
- package/src/primitives/separator/separator.css +49 -0
- package/src/primitives/separator/separator.html +16 -0
- package/src/primitives/slider/slider.css +122 -0
- package/src/primitives/slider/slider.html +1 -0
- package/src/primitives/switch/switch.css +126 -0
- package/src/primitives/switch/switch.html +13 -0
- package/src/primitives/table/table-alternating.html +36 -0
- package/src/primitives/table/table-grid.html +30 -0
- package/src/primitives/table/table-size-sm.html +26 -0
- package/src/primitives/table/table.css +158 -0
- package/src/primitives/table/table.html +45 -0
- package/src/primitives/tabs/tabs.css +328 -0
- package/src/primitives/tabs/tabs.d.ts +35 -0
- package/src/primitives/tabs/tabs.d.ts.map +1 -0
- package/src/primitives/tabs/tabs.html +75 -0
- package/src/primitives/tabs/tabs.js +84 -0
- package/src/primitives/tabs/tabs.ts +93 -0
- package/src/primitives/textarea/textarea.css +78 -0
- package/src/primitives/textarea/textarea.html +10 -0
- package/src/primitives/toaster/toaster.css +309 -0
- package/src/primitives/toaster/toaster.d.ts +138 -0
- package/src/primitives/toaster/toaster.d.ts.map +1 -0
- package/src/primitives/toaster/toaster.html +77 -0
- package/src/primitives/toaster/toaster.js +736 -0
- package/src/primitives/toaster/toaster.ts +823 -0
- package/src/primitives/toggle/toggle.css +295 -0
- package/src/primitives/toggle/toggle.html +68 -0
- package/src/primitives/toggle-group/toggle-group-multiple.html +14 -0
- package/src/primitives/toggle-group/toggle-group-vertical.html +14 -0
- package/src/primitives/toggle-group/toggle-group.css +73 -0
- package/src/primitives/toggle-group/toggle-group.html +53 -0
- package/src/primitives/toolbar/toolbar.html +45 -0
- package/src/primitives/tooltip/tooltip-disabled.html +19 -0
- package/src/primitives/tooltip/tooltip-sides.html +57 -0
- package/src/primitives/tooltip/tooltip-with-kbd.html +31 -0
- package/src/primitives/tooltip/tooltip.css +235 -0
- package/src/primitives/tooltip/tooltip.html +12 -0
- package/src/primitives/utilities/aspect-ratio.html +17 -0
- package/src/primitives/utilities/basis.html +27 -0
- package/src/primitives/utilities/col-span.html +23 -0
- package/src/primitives/utilities/compose.html +19 -0
- package/src/primitives/utilities/flex-align.html +26 -0
- package/src/primitives/utilities/flex-direction.html +36 -0
- package/src/primitives/utilities/flex-grow.html +17 -0
- package/src/primitives/utilities/gap.html +62 -0
- package/src/primitives/utilities/grid-cols.html +20 -0
- package/src/primitives/utilities/grid-pile.html +5 -0
- package/src/primitives/utilities/grid-responsive.html +31 -0
- package/src/primitives/utilities/margin-auto.html +13 -0
- package/src/primitives/utilities/object-fit.html +41 -0
- package/src/primitives/utilities/order.html +17 -0
- package/src/primitives/utilities/overflow.html +26 -0
- package/src/primitives/utilities/padding-compose.html +23 -0
- package/src/primitives/utilities/padding.html +30 -0
- package/src/primitives/utilities/position.html +13 -0
- package/src/primitives/utilities/responsive-flex.html +22 -0
- package/src/primitives/utilities/responsive-grid.html +31 -0
- package/src/primitives/utilities/size.html +22 -0
- package/src/primitives/utilities/width.html +22 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* textarea.css — Textarea (.ui-textarea)
|
|
3
|
+
*
|
|
4
|
+
* @layer variables, components
|
|
5
|
+
* @requires layers.css, _variables.css, fields.css
|
|
6
|
+
* @uses field-sizing: content — auto-grow with text (modern browsers;
|
|
7
|
+
* falls back to fixed min/max block-size where unsupported)
|
|
8
|
+
* @tokens --ui-textarea-* (@layer variables)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
@layer variables {
|
|
12
|
+
:root {
|
|
13
|
+
--ui-textarea-inline-size: 100%;
|
|
14
|
+
--ui-textarea-min-inline-size: 0;
|
|
15
|
+
--ui-textarea-min-block-size: 5lh;
|
|
16
|
+
--ui-textarea-max-block-size: 12lh;
|
|
17
|
+
--ui-textarea-padding: var(--ui-field-padding);
|
|
18
|
+
--ui-textarea-font-size: var(--font-size-sm);
|
|
19
|
+
--ui-textarea-line-height: var(--leading-sm);
|
|
20
|
+
--ui-textarea-border: 1px solid var(--ui-field-border);
|
|
21
|
+
--ui-textarea-border-radius: var(--ui-field-radius);
|
|
22
|
+
--ui-textarea-resize: vertical;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@layer zazz.components {
|
|
27
|
+
/* ===========================================================================
|
|
28
|
+
TEXTAREA — .ui-textarea (auto-sizing)
|
|
29
|
+
- field-sizing: content grows the box with the text; height clamps between
|
|
30
|
+
min/max block-size, then scrolls.
|
|
31
|
+
- Shares the --ui-field-* tokens defined in fields.css so it matches .ui-input /
|
|
32
|
+
.ui-select / .ui-button.
|
|
33
|
+
=========================================================================== */
|
|
34
|
+
|
|
35
|
+
.ui-textarea {
|
|
36
|
+
field-sizing: content;
|
|
37
|
+
inline-size: var(--ui-textarea-inline-size);
|
|
38
|
+
min-inline-size: var(--ui-textarea-min-inline-size);
|
|
39
|
+
min-block-size: var(--ui-textarea-min-block-size);
|
|
40
|
+
max-block-size: var(--ui-textarea-max-block-size);
|
|
41
|
+
padding: var(--ui-textarea-padding);
|
|
42
|
+
|
|
43
|
+
font-size: var(--ui-textarea-font-size);
|
|
44
|
+
line-height: var(--ui-textarea-line-height);
|
|
45
|
+
color: var(--ui-field-foreground);
|
|
46
|
+
background-color: var(--ui-field-background);
|
|
47
|
+
|
|
48
|
+
border: var(--ui-textarea-border);
|
|
49
|
+
border-radius: var(--ui-textarea-border-radius);
|
|
50
|
+
resize: var(--ui-textarea-resize);
|
|
51
|
+
|
|
52
|
+
/* ring renders as box-shadow; transparent outline twin keeps focus visible
|
|
53
|
+
in forced-colors / high-contrast modes */
|
|
54
|
+
--_ring-offset-width: 0px;
|
|
55
|
+
--_ring-width: 0px;
|
|
56
|
+
--_ring: color-mix(in oklch, var(--ui-field-ring-color) var(--ring-opacity), transparent);
|
|
57
|
+
box-shadow:
|
|
58
|
+
0 0 0 var(--_ring-offset-width) var(--ring-offset-color),
|
|
59
|
+
0 0 0 calc(var(--_ring-offset-width) + var(--_ring-width)) var(--_ring, var(--ring));
|
|
60
|
+
outline: var(--outline-width) var(--outline-style) transparent;
|
|
61
|
+
outline-offset: var(--outline-offset);
|
|
62
|
+
|
|
63
|
+
transition: var(--default-transition);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ui-textarea:hover {
|
|
67
|
+
border-color: var(--ui-field-border--hover);
|
|
68
|
+
background-color: var(--ui-field-background--hover);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ui-textarea:focus-visible {
|
|
72
|
+
background-color: var(--ui-field-background--focus);
|
|
73
|
+
border-color: var(--ui-field-border--focus);
|
|
74
|
+
--_ring-offset-width: var(--ring-offset-width);
|
|
75
|
+
--_ring-width: var(--ring-width);
|
|
76
|
+
outline-color: transparent;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toaster.css: Toaster (ui-toaster | .ui-toaster, [data-slot~="toaster-toast"])
|
|
3
|
+
*
|
|
4
|
+
* Stacked toast notifications. Collapsed-stack presentation (newest toast in
|
|
5
|
+
* front, older toasts peeking behind, expand on hover) adapted from Sonner by
|
|
6
|
+
* Emil Kowalski: https://sonner.emilkowal.ski (MIT).
|
|
7
|
+
*
|
|
8
|
+
* @layer variables, components
|
|
9
|
+
* @requires layers.css, _variables.css, popover.css, button.css
|
|
10
|
+
* @uses popover="manual" + showPopover()/hidePopover(): top-layer region,
|
|
11
|
+
* driven by zazz/scripts/toaster.js (no light dismiss)
|
|
12
|
+
* @uses @starting-style: enter motion for toasts inserted into the open region
|
|
13
|
+
* @uses view-transition-name: toaster: own snapshot group, frozen in
|
|
14
|
+
* _view-transitions.css so page transitions never repaint the stack
|
|
15
|
+
* @uses JS-maintained props (--toasts-before, --offset, --initial-height,
|
|
16
|
+
* --front-toast-height + inline z-index): stack math from toaster.js
|
|
17
|
+
* @tokens --ui-toaster-* (@layer variables)
|
|
18
|
+
* @see /docs/components/toaster
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
@layer variables {
|
|
22
|
+
:root {
|
|
23
|
+
/* surface */
|
|
24
|
+
--ui-toaster-background: var(--popover);
|
|
25
|
+
--ui-toaster-foreground: var(--popover-foreground);
|
|
26
|
+
--ui-toaster-border: var(--border);
|
|
27
|
+
--ui-toaster-radius: var(--radius-md);
|
|
28
|
+
--ui-toaster-shadow: var(--shadow-md);
|
|
29
|
+
/* status accent: icon color; variants reassign */
|
|
30
|
+
--ui-toaster-accent: var(--popover-foreground);
|
|
31
|
+
|
|
32
|
+
/* metrics: mobile full width falls out of the min(); no media query */
|
|
33
|
+
--ui-toaster-width: min(356px, calc(100vi - var(--gutters) * 2));
|
|
34
|
+
--ui-toaster-inset: var(--gutters);
|
|
35
|
+
--ui-toaster-gap: var(--step-3_5);
|
|
36
|
+
--ui-toaster-padding: var(--step-4);
|
|
37
|
+
--ui-toaster-icon-size: var(--step-5);
|
|
38
|
+
|
|
39
|
+
/* type */
|
|
40
|
+
--ui-toaster-title-font-size: var(--font-size-sm);
|
|
41
|
+
--ui-toaster-title-font-weight: var(--font-weight-strong);
|
|
42
|
+
--ui-toaster-description-font-size: var(--font-size-sm);
|
|
43
|
+
--ui-toaster-description-color: var(--muted-foreground);
|
|
44
|
+
|
|
45
|
+
/* stack: per-depth shrink of collapsed toasts */
|
|
46
|
+
--ui-toaster-scale-step: 0.05;
|
|
47
|
+
|
|
48
|
+
/* motion */
|
|
49
|
+
--ui-toaster-transition-duration: calc(var(--default-transition-duration) * 1.5);
|
|
50
|
+
--ui-toaster-transition-timing-function: var(--default-transition-timing-function);
|
|
51
|
+
--ui-toaster-opacity--start: 0;
|
|
52
|
+
--ui-toaster-opacity--end: 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@layer zazz.components {
|
|
57
|
+
/* ===========================================================================
|
|
58
|
+
TOASTER REGION: popover="manual" host (<ui-toaster class="toaster">)
|
|
59
|
+
- Sits in the top layer while any toast is visible; toaster.js calls
|
|
60
|
+
showPopover()/hidePopover(). It is a positioning shell, not a surface, so
|
|
61
|
+
the shared [popover] chrome from popover.css (reset + components layers)
|
|
62
|
+
is neutralized here. The region does not animate: JS hides it only after
|
|
63
|
+
the last toast's exit transition finishes.
|
|
64
|
+
- --_lift is an inherited coordination var (like --_gap in _utilities.css):
|
|
65
|
+
set per data-position on the region, read by every toast for the stack
|
|
66
|
+
direction (-1 = toasts travel up from the bottom edge, 1 = down from top).
|
|
67
|
+
=========================================================================== */
|
|
68
|
+
|
|
69
|
+
:where(ui-toaster, .ui-toaster) {
|
|
70
|
+
/* neutralize shared [popover] chrome + UA popover styles */
|
|
71
|
+
background: none;
|
|
72
|
+
border: none;
|
|
73
|
+
box-shadow: none;
|
|
74
|
+
padding: 0;
|
|
75
|
+
margin: 0;
|
|
76
|
+
min-inline-size: unset;
|
|
77
|
+
max-inline-size: unset;
|
|
78
|
+
backdrop-filter: none;
|
|
79
|
+
opacity: 1;
|
|
80
|
+
transform: none;
|
|
81
|
+
transition: none;
|
|
82
|
+
overflow: visible;
|
|
83
|
+
position-area: none;
|
|
84
|
+
|
|
85
|
+
position: fixed;
|
|
86
|
+
inset: auto;
|
|
87
|
+
inset-block-end: var(--ui-toaster-inset);
|
|
88
|
+
inset-inline-end: var(--ui-toaster-inset);
|
|
89
|
+
inline-size: var(--ui-toaster-width);
|
|
90
|
+
--_lift: -1;
|
|
91
|
+
|
|
92
|
+
/* Own snapshot group for page view transitions: frozen (never animated)
|
|
93
|
+
in _view-transitions.css, so navigations cannot cross-fade or repaint an
|
|
94
|
+
active stack. One region per page: duplicate view-transition-names
|
|
95
|
+
would make the browser skip the whole transition. */
|
|
96
|
+
view-transition-name: toaster;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:where(ui-toaster, .ui-toaster):where(:popover-open, .\:popover-open) {
|
|
100
|
+
display: block;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Positions: logical, so RTL flips for free. Default is bottom-end. */
|
|
104
|
+
|
|
105
|
+
:where(ui-toaster, .ui-toaster)[data-position^="top"] {
|
|
106
|
+
inset-block-start: var(--ui-toaster-inset);
|
|
107
|
+
inset-block-end: auto;
|
|
108
|
+
--_lift: 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:where(ui-toaster, .ui-toaster)[data-position$="start"] {
|
|
112
|
+
inset-inline-start: var(--ui-toaster-inset);
|
|
113
|
+
inset-inline-end: auto;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:where(ui-toaster, .ui-toaster)[data-position$="center"] {
|
|
117
|
+
inset-inline-start: calc(50vi - var(--ui-toaster-width) / 2);
|
|
118
|
+
inset-inline-end: auto;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
[data-slot~="toaster-list"] {
|
|
122
|
+
list-style: none;
|
|
123
|
+
margin: 0;
|
|
124
|
+
padding: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* ===========================================================================
|
|
128
|
+
TOAST: absolutely positioned against the region's edge; all placement is
|
|
129
|
+
transform-based so enter/exit/stack shifts share one transition.
|
|
130
|
+
toaster.js maintains --toasts-before, --offset (cumulative expanded offset),
|
|
131
|
+
--initial-height, data-front, data-visible, data-removed, and inline z-index.
|
|
132
|
+
=========================================================================== */
|
|
133
|
+
|
|
134
|
+
[data-slot~="toaster-toast"] {
|
|
135
|
+
position: absolute;
|
|
136
|
+
inset-inline: 0;
|
|
137
|
+
inset-block-end: 0;
|
|
138
|
+
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
gap: var(--step-2);
|
|
142
|
+
inline-size: 100%;
|
|
143
|
+
padding: var(--ui-toaster-padding);
|
|
144
|
+
|
|
145
|
+
color: var(--ui-toaster-foreground);
|
|
146
|
+
background-color: var(--ui-toaster-background);
|
|
147
|
+
border: 1px solid var(--ui-toaster-border);
|
|
148
|
+
border-radius: var(--ui-toaster-radius);
|
|
149
|
+
box-shadow: var(--ui-toaster-shadow);
|
|
150
|
+
overflow-wrap: anywhere;
|
|
151
|
+
|
|
152
|
+
--_y: translateY(calc(var(--_lift) * var(--offset, 0px)));
|
|
153
|
+
transform: var(--_y);
|
|
154
|
+
opacity: var(--ui-toaster-opacity--end);
|
|
155
|
+
transition:
|
|
156
|
+
transform var(--ui-toaster-transition-duration) var(--ui-toaster-transition-timing-function),
|
|
157
|
+
opacity var(--ui-toaster-transition-duration) var(--ui-toaster-transition-timing-function),
|
|
158
|
+
block-size var(--ui-toaster-transition-duration) var(--ui-toaster-transition-timing-function);
|
|
159
|
+
|
|
160
|
+
/* Newly inserted toasts slide in from the region's edge (the region is
|
|
161
|
+
already :popover-open; JS shows it before appending). */
|
|
162
|
+
@starting-style {
|
|
163
|
+
opacity: var(--ui-toaster-opacity--start);
|
|
164
|
+
transform: translateY(calc(var(--_lift) * -100%));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
:where(ui-toaster, .ui-toaster)[data-position^="top"] [data-slot~="toaster-toast"] {
|
|
169
|
+
inset-block-end: auto;
|
|
170
|
+
inset-block-start: 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* Content crossfades when the stack collapses/expands. */
|
|
174
|
+
[data-slot~="toaster-toast"] > * {
|
|
175
|
+
transition: opacity var(--ui-toaster-transition-duration)
|
|
176
|
+
var(--ui-toaster-transition-timing-function);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* ===========================================================================
|
|
180
|
+
COLLAPSED STACK: behind toasts tuck under the front one: shifted by one
|
|
181
|
+
gap per depth, scaled down, clamped to the front toast's height so only
|
|
182
|
+
their edges peek, content hidden.
|
|
183
|
+
=========================================================================== */
|
|
184
|
+
|
|
185
|
+
:where(ui-toaster, .ui-toaster):not([data-expanded="true"])
|
|
186
|
+
[data-slot~="toaster-toast"]:not([data-front="true"], [data-removed="true"]) {
|
|
187
|
+
--_y: translateY(calc(var(--_lift) * var(--ui-toaster-gap) * var(--toasts-before, 0)))
|
|
188
|
+
scale(calc(1 - var(--ui-toaster-scale-step) * var(--toasts-before, 0)));
|
|
189
|
+
block-size: var(--front-toast-height);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
:where(ui-toaster, .ui-toaster):not([data-expanded="true"])
|
|
193
|
+
[data-slot~="toaster-toast"]:not([data-front="true"], [data-removed="true"])
|
|
194
|
+
> * {
|
|
195
|
+
opacity: 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* ===========================================================================
|
|
199
|
+
EXPANDED: real cumulative offsets and natural heights. The ::after bridge
|
|
200
|
+
spans the gap toward the next toast so the pointer never leaves the stack
|
|
201
|
+
while moving between toasts (which would collapse it).
|
|
202
|
+
=========================================================================== */
|
|
203
|
+
|
|
204
|
+
:where(ui-toaster, .ui-toaster)[data-expanded="true"] [data-slot~="toaster-toast"] {
|
|
205
|
+
block-size: var(--initial-height, auto);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
:where(ui-toaster, .ui-toaster)[data-expanded="true"] [data-slot~="toaster-toast"]::after {
|
|
209
|
+
content: "";
|
|
210
|
+
position: absolute;
|
|
211
|
+
inset-inline: 0;
|
|
212
|
+
inset-block-end: 100%;
|
|
213
|
+
block-size: calc(var(--ui-toaster-gap) + 1px);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
:where(ui-toaster, .ui-toaster)[data-position^="top"][data-expanded="true"]
|
|
217
|
+
[data-slot~="toaster-toast"]::after {
|
|
218
|
+
inset-block-end: auto;
|
|
219
|
+
inset-block-start: 100%;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* Beyond the visible limit: kept in the DOM until dismissed, but hidden. */
|
|
223
|
+
[data-slot~="toaster-toast"][data-visible="false"] {
|
|
224
|
+
opacity: 0;
|
|
225
|
+
pointer-events: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* ===========================================================================
|
|
229
|
+
EXIT: transition back toward the region's edge; toaster.js removes the
|
|
230
|
+
node on transitionend. Collapsed behind toasts keep their tucked transform
|
|
231
|
+
and simply fade, so removal doesn't jump the stack.
|
|
232
|
+
=========================================================================== */
|
|
233
|
+
|
|
234
|
+
/* Keep the dying toast pointer-active: hiding it from hit-testing would fire
|
|
235
|
+
mouseleave on the region and collapse an expanded stack mid-dismiss.
|
|
236
|
+
toaster.js already ignores interactions with removed toasts. */
|
|
237
|
+
[data-slot~="toaster-toast"][data-removed="true"] {
|
|
238
|
+
opacity: var(--ui-toaster-opacity--start);
|
|
239
|
+
--_y: translateY(calc(var(--_lift) * var(--offset, 0px) + var(--_lift) * -100%));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
:where(ui-toaster, .ui-toaster):not([data-expanded="true"])
|
|
243
|
+
[data-slot~="toaster-toast"][data-removed="true"]:not([data-front="true"]) {
|
|
244
|
+
--_y: translateY(calc(var(--_lift) * var(--ui-toaster-gap) * var(--toasts-before, 0)))
|
|
245
|
+
scale(calc(1 - var(--ui-toaster-scale-step) * var(--toasts-before, 0)));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* ===========================================================================
|
|
249
|
+
TOAST PARTS
|
|
250
|
+
=========================================================================== */
|
|
251
|
+
|
|
252
|
+
[data-slot~="toaster-icon"] {
|
|
253
|
+
flex-shrink: 0;
|
|
254
|
+
inline-size: var(--ui-toaster-icon-size);
|
|
255
|
+
block-size: var(--ui-toaster-icon-size);
|
|
256
|
+
color: var(--ui-toaster-accent);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
[data-slot~="toaster-icon"] > svg {
|
|
260
|
+
display: block;
|
|
261
|
+
inline-size: 100%;
|
|
262
|
+
block-size: 100%;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
[data-slot~="toaster-content"] {
|
|
266
|
+
flex: 1;
|
|
267
|
+
min-inline-size: 0;
|
|
268
|
+
display: flex;
|
|
269
|
+
flex-direction: column;
|
|
270
|
+
gap: var(--step-1);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
[data-slot~="toaster-title"] {
|
|
274
|
+
font-size: var(--ui-toaster-title-font-size);
|
|
275
|
+
font-weight: var(--ui-toaster-title-font-weight);
|
|
276
|
+
line-height: var(--leading-sm);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
[data-slot~="toaster-description"] {
|
|
280
|
+
font-size: var(--ui-toaster-description-font-size);
|
|
281
|
+
line-height: var(--leading-sm);
|
|
282
|
+
color: var(--ui-toaster-description-color);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
[data-slot~="toaster-action"],
|
|
286
|
+
[data-slot~="toaster-close"] {
|
|
287
|
+
flex-shrink: 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* ===========================================================================
|
|
291
|
+
VARIANTS: reassign the accent token only
|
|
292
|
+
=========================================================================== */
|
|
293
|
+
|
|
294
|
+
[data-slot~="toaster-toast"][data-variant="success"] {
|
|
295
|
+
--ui-toaster-accent: var(--success);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
[data-slot~="toaster-toast"][data-variant="info"] {
|
|
299
|
+
--ui-toaster-accent: var(--info);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
[data-slot~="toaster-toast"][data-variant="warning"] {
|
|
303
|
+
--ui-toaster-accent: var(--warning);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
[data-slot~="toaster-toast"][data-variant="destructive"] {
|
|
307
|
+
--ui-toaster-accent: var(--destructive);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { ZazzElement } from "../../base/zazz-element.ts";
|
|
2
|
+
interface ToastAction {
|
|
3
|
+
/** Button label. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Click handler. Call `event.preventDefault()` to keep the toast open. */
|
|
6
|
+
onClick?: (event: MouseEvent) => void;
|
|
7
|
+
}
|
|
8
|
+
interface ToastOptions {
|
|
9
|
+
/** Toast heading. */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Supporting copy under the title. */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Status accent + icon. */
|
|
14
|
+
variant?: "success" | "info" | "warning" | "destructive";
|
|
15
|
+
/** Lifetime in ms; `Infinity` persists until dismissed. Default `4000`. */
|
|
16
|
+
duration?: number;
|
|
17
|
+
/** Optional action button. */
|
|
18
|
+
action?: ToastAction;
|
|
19
|
+
/** Render the explicit close button. Default `true`. */
|
|
20
|
+
closeButton?: boolean;
|
|
21
|
+
/** Target region id or element (default: first `<ui-toaster>`). */
|
|
22
|
+
region?: string | Element;
|
|
23
|
+
}
|
|
24
|
+
/** Computed placement for one toast (same index as the heights input). */
|
|
25
|
+
interface ToastStackLayout {
|
|
26
|
+
/** 0 = front (newest); grows toward the back of the stack. */
|
|
27
|
+
stackIndex: number;
|
|
28
|
+
/** Sum of the heights of the toasts stacked in front, in px. */
|
|
29
|
+
offsetPx: number;
|
|
30
|
+
/** Paint order: front toast highest. */
|
|
31
|
+
zIndex: number;
|
|
32
|
+
/** Whether this is the front (newest) toast. */
|
|
33
|
+
front: boolean;
|
|
34
|
+
/** Whether the toast is within the visible collapsed stack. */
|
|
35
|
+
visible: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @description Computes the collapsed-stack placement for every toast from the
|
|
39
|
+
* measured heights alone (oldest first, matching DOM order). Pure: the
|
|
40
|
+
* measure step feeds it and an effect writes the results to the DOM, so this
|
|
41
|
+
* is the unit-testable core of the stacking model.
|
|
42
|
+
*
|
|
43
|
+
* @param heights - Natural toast heights in px, oldest first.
|
|
44
|
+
* @returns Per-toast layout (same order) and the front toast's height.
|
|
45
|
+
*/
|
|
46
|
+
declare function computeStackLayout(heights: number[]): {
|
|
47
|
+
toasts: ToastStackLayout[];
|
|
48
|
+
frontToastHeightPx: number | null;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @class
|
|
52
|
+
* @description Hosts the toast stack: builds toast markup, maintains the
|
|
53
|
+
* collapsed-stack CSS custom properties, runs auto-dismiss timers, and shows or
|
|
54
|
+
* hides the `popover="manual"` region as toasts come and go.
|
|
55
|
+
*/
|
|
56
|
+
declare class UiToaster extends ZazzElement {
|
|
57
|
+
#private;
|
|
58
|
+
protected setup(signal: AbortSignal): void;
|
|
59
|
+
protected teardown(): void;
|
|
60
|
+
/**
|
|
61
|
+
* @description Adds a toast to this region and shows the region if needed.
|
|
62
|
+
*
|
|
63
|
+
* @param options - Toast content and behavior.
|
|
64
|
+
* @returns The toast id (usable with `dismiss()`).
|
|
65
|
+
*/
|
|
66
|
+
addToast(options?: ToastOptions): string;
|
|
67
|
+
/**
|
|
68
|
+
* @description Dismisses one toast by id, or every toast when omitted.
|
|
69
|
+
*
|
|
70
|
+
* @param id - Toast id returned by `addToast()`.
|
|
71
|
+
*/
|
|
72
|
+
dismiss(id?: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* @description Dismisses every toast in this region.
|
|
75
|
+
*/
|
|
76
|
+
dismissAll(): void;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @namespace Toaster
|
|
80
|
+
* @description Imperative toast API. Requires a `<ui-toaster>` in the page:
|
|
81
|
+
* the region is never auto-created (HTML-first, like every Zazz component).
|
|
82
|
+
*
|
|
83
|
+
* @property toast - Shows a toast; returns its id.
|
|
84
|
+
* @property success - Success shorthand.
|
|
85
|
+
* @property info - Info shorthand.
|
|
86
|
+
* @property warning - Warning shorthand.
|
|
87
|
+
* @property error - Destructive shorthand.
|
|
88
|
+
* @property dismiss - Dismisses one toast, or all when omitted.
|
|
89
|
+
*/
|
|
90
|
+
declare const Toaster: {
|
|
91
|
+
/**
|
|
92
|
+
* @description Shows a toast in the target (or first) region.
|
|
93
|
+
*
|
|
94
|
+
* @param options - Options object or title string.
|
|
95
|
+
* @returns The toast id, or `null` when no region exists.
|
|
96
|
+
*/
|
|
97
|
+
toast(options?: ToastOptions | string): string | null;
|
|
98
|
+
/**
|
|
99
|
+
* @description Shows a success toast.
|
|
100
|
+
*
|
|
101
|
+
* @param message - Toast title.
|
|
102
|
+
* @param options - Additional options.
|
|
103
|
+
* @returns The toast id, or `null` when no region exists.
|
|
104
|
+
*/
|
|
105
|
+
success(message: string, options?: ToastOptions): string | null;
|
|
106
|
+
/**
|
|
107
|
+
* @description Shows an info toast.
|
|
108
|
+
*
|
|
109
|
+
* @param message - Toast title.
|
|
110
|
+
* @param options - Additional options.
|
|
111
|
+
* @returns The toast id, or `null` when no region exists.
|
|
112
|
+
*/
|
|
113
|
+
info(message: string, options?: ToastOptions): string | null;
|
|
114
|
+
/**
|
|
115
|
+
* @description Shows a warning toast.
|
|
116
|
+
*
|
|
117
|
+
* @param message - Toast title.
|
|
118
|
+
* @param options - Additional options.
|
|
119
|
+
* @returns The toast id, or `null` when no region exists.
|
|
120
|
+
*/
|
|
121
|
+
warning(message: string, options?: ToastOptions): string | null;
|
|
122
|
+
/**
|
|
123
|
+
* @description Shows a destructive/error toast.
|
|
124
|
+
*
|
|
125
|
+
* @param message - Toast title.
|
|
126
|
+
* @param options - Additional options.
|
|
127
|
+
* @returns The toast id, or `null` when no region exists.
|
|
128
|
+
*/
|
|
129
|
+
error(message: string, options?: ToastOptions): string | null;
|
|
130
|
+
/**
|
|
131
|
+
* @description Dismisses a toast by id in any region, or every toast everywhere.
|
|
132
|
+
*
|
|
133
|
+
* @param id - Toast id returned by `toast()`.
|
|
134
|
+
*/
|
|
135
|
+
dismiss(id?: string): void;
|
|
136
|
+
};
|
|
137
|
+
export { Toaster, UiToaster, computeStackLayout };
|
|
138
|
+
//# sourceMappingURL=toaster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toaster.d.ts","sourceRoot":"","sources":["toaster.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAC;AAoC5E,UAAU,WAAW;IACnB,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC;AAED,UAAU,YAAY;IACpB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,aAAa,CAAC;IACzD,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,wDAAwD;IACxD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAmBD,0EAA0E;AAC1E,UAAU,gBAAgB;IACxB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,KAAK,EAAE,OAAO,CAAC;IACf,+DAA+D;IAC/D,OAAO,EAAE,OAAO,CAAC;CAClB;AAyBD;;;;;;;;GAQG;AACH,iBAAS,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG;IAC9C,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC,CAkBA;AAID;;;;;GAKG;AACH,cAAM,SAAU,SAAQ,WAAW;;IA4BjC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAwFzC;IAED,SAAS,CAAC,QAAQ,IAAI,IAAI,CAKzB;IAID;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,GAAE,YAAiB,GAAG,MAAM,CAa3C;IAED;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAiCzB;IAED;;OAEG;IACH,UAAU,IAAI,IAAI,CAKjB;CAkTF;AAuCD;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,OAAO;IACX;;;;;OAKG;IACH,KAAK,WAAW,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI;IAMrD;;;;;;OAMG;IACH,OAAO,UAAU,MAAM,YAAY,YAAY,GAAG,MAAM,GAAG,IAAI;IAI/D;;;;;;OAMG;IACH,IAAI,UAAU,MAAM,YAAY,YAAY,GAAG,MAAM,GAAG,IAAI;IAI5D;;;;;;OAMG;IACH,OAAO,UAAU,MAAM,YAAY,YAAY,GAAG,MAAM,GAAG,IAAI;IAI/D;;;;;;OAMG;IACH,KAAK,UAAU,MAAM,YAAY,YAAY,GAAG,MAAM,GAAG,IAAI;IAI7D;;;;OAIG;IACH,OAAO,MAAM,MAAM,GAAG,IAAI;CAK3B,CAAC;AAYF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<div class="flex flex-wrap items-center gap-sm">
|
|
2
|
+
<button
|
|
3
|
+
class="ui-button"
|
|
4
|
+
type="button"
|
|
5
|
+
commandfor="toaster-example"
|
|
6
|
+
command="--toast"
|
|
7
|
+
data-title="Event created"
|
|
8
|
+
data-description="Monday, July 13 at 9:00 AM"
|
|
9
|
+
>
|
|
10
|
+
Show toast
|
|
11
|
+
</button>
|
|
12
|
+
<button
|
|
13
|
+
class="ui-button"
|
|
14
|
+
type="button"
|
|
15
|
+
commandfor="toaster-example"
|
|
16
|
+
command="--toast-success"
|
|
17
|
+
data-title="Changes saved"
|
|
18
|
+
>
|
|
19
|
+
Success
|
|
20
|
+
</button>
|
|
21
|
+
<button
|
|
22
|
+
class="ui-button"
|
|
23
|
+
type="button"
|
|
24
|
+
commandfor="toaster-example"
|
|
25
|
+
command="--toast-info"
|
|
26
|
+
data-title="Update available"
|
|
27
|
+
>
|
|
28
|
+
Info
|
|
29
|
+
</button>
|
|
30
|
+
<button
|
|
31
|
+
class="ui-button"
|
|
32
|
+
type="button"
|
|
33
|
+
commandfor="toaster-example"
|
|
34
|
+
command="--toast-warning"
|
|
35
|
+
data-title="Storage almost full"
|
|
36
|
+
>
|
|
37
|
+
Warning
|
|
38
|
+
</button>
|
|
39
|
+
<button
|
|
40
|
+
class="ui-button"
|
|
41
|
+
type="button"
|
|
42
|
+
commandfor="toaster-example"
|
|
43
|
+
command="--toast-destructive"
|
|
44
|
+
data-title="Something went wrong"
|
|
45
|
+
data-description="The request could not be completed."
|
|
46
|
+
>
|
|
47
|
+
Error
|
|
48
|
+
</button>
|
|
49
|
+
<button class="ui-button" data-variant="primary" type="button" id="toaster-action-example">
|
|
50
|
+
With action
|
|
51
|
+
</button>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<ui-toaster id="toaster-example" popover="manual"></ui-toaster>
|
|
55
|
+
|
|
56
|
+
<script type="module">
|
|
57
|
+
// Toasts with an action button need the imperative API (a callback can't live
|
|
58
|
+
// in a data attribute). Everything else above is wired declaratively.
|
|
59
|
+
await customElements.whenDefined("ui-toaster");
|
|
60
|
+
|
|
61
|
+
const toastTrigger = document.getElementById("toaster-action-example");
|
|
62
|
+
const handler = () => {
|
|
63
|
+
window.Toaster.toast({
|
|
64
|
+
title: "Email archived",
|
|
65
|
+
description: "The conversation was moved to the archive.",
|
|
66
|
+
action: { label: "Undo", onClick: () => window.Toaster.success("Email restored") },
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
toastTrigger.addEventListener("click", handler);
|
|
71
|
+
|
|
72
|
+
// Optional: If you need to clean up immediately after the event or on some app shutdown:
|
|
73
|
+
// Example cleanup on page unload for demo purposes:
|
|
74
|
+
window.addEventListener("unload", () => {
|
|
75
|
+
toastTrigger.removeEventListener("click", handler);
|
|
76
|
+
});
|
|
77
|
+
</script>
|