winduum 2.0.0-next.2 → 2.0.0-next.20
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/main.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/test.css +1 -0
- package/package.json +15 -15
- package/plugin/index.cjs +81 -43
- package/plugin/utilities/common.js +2 -2
- package/plugin/utilities/dot.js +3 -3
- package/src/base/breakpoints-tw.css +12 -0
- package/src/base/config/transition.css +5 -1
- package/src/base/config/tw.css +30 -0
- package/src/base/defaults-tw.css +9 -0
- package/src/base/defaults.css +1 -11
- package/src/base/index.css +2 -0
- package/src/base/reset.css +0 -1
- package/src/base/theme/default-tw.css +26 -0
- package/src/base/transitions.css +11 -0
- package/src/components/badge/circle.css +1 -1
- package/src/components/badge/default.css +2 -2
- package/src/components/badge/lg.css +1 -1
- package/src/components/badge/props/default.css +1 -1
- package/src/components/badge/sm.css +1 -1
- package/src/components/badge/square.css +1 -1
- package/src/components/breadcrumb/default.css +1 -1
- package/src/components/button/bordered.css +1 -1
- package/src/components/button/circle.css +1 -1
- package/src/components/button/default.css +2 -2
- package/src/components/button/interactive.css +13 -11
- package/src/components/button/lg.css +1 -1
- package/src/components/button/props/default.css +1 -1
- package/src/components/button/sm.css +1 -1
- package/src/components/button/square.css +1 -1
- package/src/components/carousel/index.d.ts +3 -3
- package/src/components/carousel/index.js +13 -11
- package/src/components/check/default.css +2 -2
- package/src/components/check/invalid.css +1 -1
- package/src/components/color/interactive.css +1 -1
- package/src/components/color/props/default.css +0 -1
- package/src/components/compare/default.css +1 -1
- package/src/components/control/color.css +5 -5
- package/src/components/control/default.css +3 -3
- package/src/components/control/file.css +1 -1
- package/src/components/control/invalid.css +1 -1
- package/src/components/control/props/color.css +2 -2
- package/src/components/control/props/default.css +3 -3
- package/src/components/control/select-multiple.css +1 -1
- package/src/components/details/index.js +2 -2
- package/src/components/dialog/content.css +1 -1
- package/src/components/dialog/default.css +2 -2
- package/src/components/dialog/index.d.ts +3 -2
- package/src/components/dialog/index.js +15 -14
- package/src/components/drawer/default.css +6 -5
- package/src/components/drawer/index.d.ts +2 -1
- package/src/components/drawer/index.js +15 -1
- package/src/components/drawer/props/content.css +1 -1
- package/src/components/field/default.css +1 -1
- package/src/components/form/index.d.ts +4 -4
- package/src/components/form/index.js +11 -10
- package/src/components/group/default.css +1 -1
- package/src/components/image/default.css +1 -1
- package/src/components/popover/content.css +2 -2
- package/src/components/popover/index.d.ts +5 -1
- package/src/components/popover/index.js +11 -9
- package/src/components/range/default.css +4 -4
- package/src/components/rating/default.css +8 -0
- package/src/components/rating/invalid.css +1 -1
- package/src/components/rating/props/default.css +0 -1
- package/src/components/switch/invalid.css +1 -1
- package/src/components/tabs/index.css +1 -1
- package/src/components/tabs/list.css +8 -0
- package/src/components/tabs/readme.md +1 -1
- package/src/components/text/default.css +2 -2
- package/src/components/toast/content.css +0 -5
- package/src/components/toast/default.css +3 -3
- package/src/components/toaster/default.css +4 -0
- package/src/components/toaster/index.d.ts +2 -17
- package/src/components/toaster/index.js +4 -56
- package/src/tailwind.css +4 -1
- package/src/test.css +7 -0
- package/src/utilities/animation.css +4 -0
- package/src/utilities/dot.css +10 -0
- package/src/utilities/view-transition.css +3 -0
- package/tailwind.config.js +4 -1
- package/types/index.d.ts +45 -28
- package/types/index.d.ts.map +3 -5
- package/src/base/tailwind.css +0 -3
- package/src/components/tabs/default.css +0 -8
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { nextRepaint } from '../../common.js'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @param {HTMLElement | Element} element
|
|
3
5
|
* @param {number} distance
|
|
4
6
|
* @param {'top' | 'left'} direction
|
|
5
7
|
* @returns void
|
|
6
8
|
*/
|
|
7
|
-
export const showDrawer = (element, distance = 0, direction = 'left') => {
|
|
9
|
+
export const showDrawer = async (element, distance = 0, direction = 'left') => {
|
|
8
10
|
element.scroll({ [direction]: distance })
|
|
9
11
|
}
|
|
10
12
|
|
|
@@ -20,6 +22,17 @@ export const closeDrawer = (element, distance = element.scrollWidth, direction =
|
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* @param {HTMLElement | Element} element
|
|
25
|
+
* @param {number} distance
|
|
26
|
+
* @param {'top' | 'left'} direction
|
|
27
|
+
* @returns void
|
|
28
|
+
*/
|
|
29
|
+
export const scrollInitDrawer = async (element, distance = element.scrollWidth, direction = 'left') => {
|
|
30
|
+
element.scroll({ [direction]: distance, behavior: 'instant' })
|
|
31
|
+
await nextRepaint()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {HTMLDialogElement | Element} element
|
|
23
36
|
* @param {import("./").ScrollDrawerOptions} options
|
|
24
37
|
* @returns void
|
|
25
38
|
*/
|
|
@@ -49,6 +62,7 @@ export const scrollDrawer = (element, options = {}) => {
|
|
|
49
62
|
if ((options.scrollDirection === options.scrollClose) && !element.inert) {
|
|
50
63
|
element.classList.remove(...options.snapClass.split(/\s/))
|
|
51
64
|
element.inert = true
|
|
65
|
+
element.close && element.close()
|
|
52
66
|
element.dispatchEvent(new CustomEvent('x-drawer:close'))
|
|
53
67
|
}
|
|
54
68
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
--x-drawer-content-background-color: var(--color-body-primary);
|
|
3
3
|
--x-drawer-content-padding-block: 2rem;
|
|
4
4
|
--x-drawer-content-padding-inline: 1.5rem;
|
|
5
|
-
--x-drawer-content-inline-size:
|
|
5
|
+
--x-drawer-content-inline-size: 100%;
|
|
6
6
|
--x-drawer-content-block-size: 100%;
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface ValidateFormOptions {
|
|
2
2
|
validateSelectors?: string
|
|
3
3
|
validateOptions?: ValidateFieldOptions
|
|
4
|
-
|
|
4
|
+
submitterLoadingAttribute?: string
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export interface ValidateFieldOptions {
|
|
@@ -15,11 +15,11 @@ export interface ValidateFieldOptions {
|
|
|
15
15
|
endParentSelector?: string
|
|
16
16
|
endSelector?: string
|
|
17
17
|
endContent?: string
|
|
18
|
-
|
|
18
|
+
validAttribute?: string
|
|
19
19
|
validIcon?: string | null
|
|
20
|
-
|
|
20
|
+
invalidAttribute?: string
|
|
21
21
|
invalidIcon?: string
|
|
22
|
-
|
|
22
|
+
activeAttribute?: string
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function validateForm(event: Event | SubmitEvent, options?: ValidateFormOptions): void
|
|
@@ -7,7 +7,7 @@ export const validateForm = (event, options = {}) => {
|
|
|
7
7
|
options = {
|
|
8
8
|
validateSelectors: '.x-control, .x-check, .x-switch, .x-rating, .x-color',
|
|
9
9
|
validateOptions: {},
|
|
10
|
-
|
|
10
|
+
submitterLoadingAttribute: 'data-loading',
|
|
11
11
|
...options
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -18,7 +18,7 @@ export const validateForm = (event, options = {}) => {
|
|
|
18
18
|
event.target.querySelector(':invalid').scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
19
19
|
event.target.querySelector(':invalid').focus()
|
|
20
20
|
} else {
|
|
21
|
-
event?.submitter?.
|
|
21
|
+
event?.submitter?.setAttribute(options.submitterLoadingAttribute, '')
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
event.target.querySelectorAll(options.validateSelectors).forEach(element => {
|
|
@@ -43,11 +43,11 @@ export const validateField = (element, options = {}) => {
|
|
|
43
43
|
endParentSelector: '.x-control',
|
|
44
44
|
endSelector: '.ms-auto',
|
|
45
45
|
endContent: '<div class="ms-auto"></div>',
|
|
46
|
-
|
|
46
|
+
validAttribute: 'data-valid',
|
|
47
47
|
validIcon: null,
|
|
48
|
-
|
|
48
|
+
invalidAttribute: 'data-invalid',
|
|
49
49
|
invalidIcon: '<svg class="text-error validity" aria-hidden="true"><use href="#icon-exclamation-circle"></use></svg>',
|
|
50
|
-
|
|
50
|
+
activeAttribute: 'data-active',
|
|
51
51
|
...options
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -71,23 +71,24 @@ export const validateField = (element, options = {}) => {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
if (validationElement.value !== '') {
|
|
74
|
-
element.
|
|
74
|
+
element.setAttribute(options.activeAttribute, '')
|
|
75
75
|
} else {
|
|
76
|
-
element.
|
|
76
|
+
element.removeAttribute(options.activeAttribute)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if (!validationElement.outerHTML.match(options.ignoreMatch) && options.validate) {
|
|
80
|
-
element?.
|
|
80
|
+
element?.removeAttribute(options.validAttribute)
|
|
81
|
+
element?.removeAttribute(options.invalidAttribute)
|
|
81
82
|
|
|
82
83
|
infoParentElement?.querySelector(infoSelector)?.remove()
|
|
83
84
|
endParentElement?.querySelector(endSelector)?.remove()
|
|
84
85
|
|
|
85
86
|
if (validationElement.checkValidity()) {
|
|
86
|
-
element.
|
|
87
|
+
element.setAttribute(options.validAttribute, '')
|
|
87
88
|
|
|
88
89
|
insertIcon(options.validIcon)
|
|
89
90
|
} else {
|
|
90
|
-
element.
|
|
91
|
+
element.setAttribute(options.invalidAttribute, '')
|
|
91
92
|
|
|
92
93
|
insertIcon(options.invalidIcon)
|
|
93
94
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
translate(var(--tw-translate-x), var(--tw-translate-y))
|
|
11
11
|
scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
12
12
|
will-change: transform;
|
|
13
|
-
|
|
13
|
+
inline-size: max-content;
|
|
14
14
|
position: absolute;
|
|
15
15
|
|
|
16
16
|
&:where(.bottom), & {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
inset-block-start: 50%;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
&[popover]:not(
|
|
89
|
+
&[popover]:not([data-open]) {
|
|
90
90
|
--tw-scale-x: var(--x-popover-content-scale-x);
|
|
91
91
|
--tw-scale-y: var(--x-popover-content-scale-y);
|
|
92
92
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FlipOptions, Middleware, OffsetOptions, Placement, ShiftOptions } from "@floating-ui/dom";
|
|
2
2
|
|
|
3
3
|
export interface ShowPopoverOptions {
|
|
4
|
-
|
|
4
|
+
openAttribute?: string
|
|
5
5
|
compute?: boolean
|
|
6
6
|
placement?: Placement
|
|
7
7
|
middleware?: Array<Middleware | null | undefined | false>
|
|
@@ -10,6 +10,10 @@ export interface ShowPopoverOptions {
|
|
|
10
10
|
shift?: ShiftOptions
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface HidePopoverOptions {
|
|
14
|
+
openAttribute?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
export function showPopover(element: HTMLElement | Element, options?: ShowPopoverOptions): Promise<void>
|
|
14
18
|
export function hidePopover(element: HTMLElement | Element): Promise<void>
|
|
15
19
|
export function togglePopover(element: HTMLElement | Element, options?: ShowPopoverOptions): Promise<void>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { animationsFinished } from '../../common.js'
|
|
1
|
+
import { animationsFinished, nextRepaint } from '../../common.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {HTMLElement | Element} element
|
|
@@ -6,13 +6,11 @@ import { animationsFinished } from '../../common.js'
|
|
|
6
6
|
* @param {import("./").ShowPopoverOptions} options
|
|
7
7
|
* @returns Promise<void>
|
|
8
8
|
*/
|
|
9
|
-
export const computePopover = async (element, popoverElement, options) => {
|
|
9
|
+
export const computePopover = async (element, popoverElement, options = {}) => {
|
|
10
10
|
const { computePosition, flip, shift, offset } = await import('@floating-ui/dom')
|
|
11
11
|
|
|
12
12
|
popoverElement.classList.remove(popoverElement._placement)
|
|
13
13
|
|
|
14
|
-
popoverElement.style.minWidth = `${element.offsetWidth / 16}rem`
|
|
15
|
-
|
|
16
14
|
await computePosition(element, popoverElement, {
|
|
17
15
|
placement: options?.placement,
|
|
18
16
|
middleware: options?.middleware ?? [offset(12 ?? options?.offset), flip(options?.flip), shift({ padding: 8, ...options?.shift })]
|
|
@@ -22,18 +20,19 @@ export const computePopover = async (element, popoverElement, options) => {
|
|
|
22
20
|
})
|
|
23
21
|
|
|
24
22
|
popoverElement._placement = placement
|
|
25
|
-
popoverElement.classList.add(popoverElement._placement
|
|
23
|
+
popoverElement.classList.add(popoverElement._placement)
|
|
26
24
|
})
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* @param {HTMLElement | Element} element - The HTML content to insert into the dialog.
|
|
29
|
+
* @param {import("./").HidePopoverOptions} options
|
|
31
30
|
* @returns Promise<void>
|
|
32
31
|
*/
|
|
33
|
-
export const hidePopover = async (element) => {
|
|
32
|
+
export const hidePopover = async (element, options = { openAttribute: 'data-open' }) => {
|
|
34
33
|
const popoverElement = document.getElementById(element.getAttribute('popovertarget'))
|
|
35
34
|
|
|
36
|
-
popoverElement.
|
|
35
|
+
popoverElement.removeAttribute(options?.openAttribute)
|
|
37
36
|
await animationsFinished(popoverElement)
|
|
38
37
|
popoverElement._cleanup && popoverElement._cleanup()
|
|
39
38
|
popoverElement.hidePopover && popoverElement.hidePopover()
|
|
@@ -48,7 +47,7 @@ export const hidePopover = async (element) => {
|
|
|
48
47
|
*/
|
|
49
48
|
export const showPopover = async (element, options) => {
|
|
50
49
|
options = {
|
|
51
|
-
|
|
50
|
+
openAttribute: 'data-open',
|
|
52
51
|
compute: true,
|
|
53
52
|
...options
|
|
54
53
|
}
|
|
@@ -64,8 +63,11 @@ export const showPopover = async (element, options) => {
|
|
|
64
63
|
|
|
65
64
|
popoverElement.showPopover && popoverElement.showPopover()
|
|
66
65
|
|
|
66
|
+
await nextRepaint()
|
|
67
|
+
|
|
68
|
+
popoverElement.setAttribute(options?.openAttribute, '')
|
|
69
|
+
|
|
67
70
|
if (!options.compute) {
|
|
68
|
-
popoverElement.classList.add(options.visibleClass)
|
|
69
71
|
return
|
|
70
72
|
}
|
|
71
73
|
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&::-webkit-slider-thumb {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
inline-size: var(--x-range-thumb-size);
|
|
42
|
+
block-size: var(--x-range-thumb-size);
|
|
43
43
|
background-color: var(--x-range-thumb-background-color);
|
|
44
44
|
border-radius: var(--radius-full);
|
|
45
45
|
border: var(--x-range-thumb-border-width) solid var(--x-range-thumb-border-color);
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
&::-moz-range-thumb {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
inline-size: var(--x-range-thumb-size);
|
|
67
|
+
block-size: var(--x-range-thumb-size);
|
|
68
68
|
background-color: var(--x-range-thumb-background-color);
|
|
69
69
|
border-radius: var(--radius-full);
|
|
70
70
|
border: var(--x-range-thumb-border-width) solid var(--x-range-thumb-border-color);
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
.x-rating {
|
|
2
|
+
--x-rating-color: var(--color-accent);
|
|
3
|
+
|
|
2
4
|
display: flex;
|
|
3
5
|
align-items: center;
|
|
6
|
+
border-radius: var(--radius-full);
|
|
7
|
+
|
|
8
|
+
&:focus-within {
|
|
9
|
+
outline: 2px dotted var(--color-accent);
|
|
10
|
+
outline-offset: 3px;
|
|
11
|
+
}
|
|
4
12
|
|
|
5
13
|
:where(input) {
|
|
6
14
|
inline-size: var(--x-rating-inline-size);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@import "
|
|
1
|
+
@import "list.css";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
.x-tabs-list {
|
|
2
|
+
background-color: var(--x-tabs-list-background-color, var(--color-body-secondary));
|
|
3
|
+
gap: var(--x-tabs-list-gap, var(--spacing-xs));
|
|
4
|
+
padding: var(--x-tabs-list-padding, var(--spacing-xs));
|
|
5
|
+
border-radius: var(--x-tabs-list-border-radius, var(--radius));
|
|
6
|
+
display: flex;
|
|
7
|
+
inline-size: max-content;
|
|
8
|
+
}
|
|
@@ -14,7 +14,7 @@ Include CSS either globally or to your component _([you can't use TailwindCSS la
|
|
|
14
14
|
or modular (you can use your own props or CSS)
|
|
15
15
|
|
|
16
16
|
```css
|
|
17
|
-
@import "winduum/src/components/tabs/
|
|
17
|
+
@import "winduum/src/components/tabs/list.css" layer(components);
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
|
|
@@ -170,8 +170,8 @@
|
|
|
170
170
|
list-style-type: "";
|
|
171
171
|
|
|
172
172
|
&::before {
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
inline-size: var(--x-text-list-marker-size);
|
|
174
|
+
block-size: var(--x-text-list-marker-size);
|
|
175
175
|
inset-inline-start: var(--x-text-list-marker-inset-inline-start, -0.75em);
|
|
176
176
|
inset-block-start: var(--x-text-list-marker-inset-block-start, 0.5lh);
|
|
177
177
|
border:
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
justify-content: flex-end;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
&[data-open] {
|
|
17
17
|
margin-block: var(--x-toaster-margin-block);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
&[data-open]:where(:nth-last-child(-n+3)) {
|
|
21
21
|
visibility: visible;
|
|
22
22
|
opacity: 100%;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
&[data-closed] {
|
|
26
26
|
visibility: hidden;
|
|
27
27
|
opacity: 0%;
|
|
28
28
|
height: 0;
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
export interface ShowToastOptions {
|
|
2
|
-
|
|
2
|
+
openAttribute?: string
|
|
3
3
|
autoHide?: number | null
|
|
4
4
|
heightProperty?: string
|
|
5
5
|
close?: CloseToastOptions
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface CloseToastOptions {
|
|
9
|
-
|
|
9
|
+
closedAttribute?: string
|
|
10
10
|
heightProperty?: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export interface InsertToasterOptions {
|
|
14
|
-
classes?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface InsertToastOptions {
|
|
18
|
-
classes?: string
|
|
19
|
-
title?: string
|
|
20
|
-
text?: string
|
|
21
|
-
start?: string
|
|
22
|
-
end?: string
|
|
23
|
-
show?: ShowToastOptions
|
|
24
|
-
}
|
|
25
|
-
|
|
26
13
|
export function closeToast(element: HTMLElement, options?: CloseToastOptions): Promise<void>
|
|
27
14
|
export function showToast(element: HTMLElement, options?: ShowToastOptions): Promise<void>
|
|
28
|
-
export function insertToaster(element: HTMLElement, options?: InsertToasterOptions): Promise<void>
|
|
29
|
-
export function insertToast(element: HTMLElement, options?: InsertToastOptions): Promise<void>
|
|
30
15
|
export function closeToaster(element: HTMLElement, options?: CloseToastOptions): Promise<void>
|
|
@@ -7,24 +7,20 @@ import { animationsFinished, nextRepaint } from '../../common.js'
|
|
|
7
7
|
*/
|
|
8
8
|
export const closeToast = async (element, options = {}) => {
|
|
9
9
|
options = {
|
|
10
|
-
|
|
10
|
+
closedAttribute: 'data-closed',
|
|
11
11
|
heightProperty: '--x-toast-block-size',
|
|
12
12
|
...options
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const toaster = element.parentElement
|
|
16
|
-
|
|
17
15
|
element.style.setProperty(options.heightProperty, `${element.offsetHeight}px`)
|
|
18
16
|
|
|
19
17
|
await nextRepaint()
|
|
20
18
|
|
|
21
|
-
element.
|
|
19
|
+
element.setAttribute(options.closedAttribute, '')
|
|
22
20
|
|
|
23
21
|
await animationsFinished(element)
|
|
24
22
|
|
|
25
23
|
element.remove()
|
|
26
|
-
|
|
27
|
-
if (toaster.children.length < 1) toaster.remove()
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
/**
|
|
@@ -34,7 +30,7 @@ export const closeToast = async (element, options = {}) => {
|
|
|
34
30
|
*/
|
|
35
31
|
export const showToast = async (element, options = {}) => {
|
|
36
32
|
options = {
|
|
37
|
-
|
|
33
|
+
openAttribute: 'data-open',
|
|
38
34
|
autoHide: null,
|
|
39
35
|
heightProperty: '--x-toast-block-size',
|
|
40
36
|
close: {},
|
|
@@ -47,61 +43,13 @@ export const showToast = async (element, options = {}) => {
|
|
|
47
43
|
await animationsFinished(element)
|
|
48
44
|
|
|
49
45
|
element.style.height = ''
|
|
50
|
-
element.
|
|
46
|
+
element.setAttribute(options.openAttribute, '')
|
|
51
47
|
|
|
52
48
|
if (options.autoHide) {
|
|
53
49
|
setTimeout(() => closeToast(element, options.close), options.autoHide * ((element.parentElement.children.length + 1) / 2))
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
/**
|
|
58
|
-
* @param {HTMLElement} element
|
|
59
|
-
* @param {import('./').InsertToasterOptions} options
|
|
60
|
-
* @returns Promise<void>
|
|
61
|
-
*/
|
|
62
|
-
export const insertToaster = async (element, options = {}) => {
|
|
63
|
-
options = {
|
|
64
|
-
classes: '',
|
|
65
|
-
...options
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!document.querySelector('.x-toaster')) {
|
|
69
|
-
element.insertAdjacentHTML('beforeend', `<ol class="x-toaster ${options.classes}"></ol>`)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @param {HTMLElement} element
|
|
75
|
-
* @param {import('./').InsertToastOptions} options
|
|
76
|
-
* @returns Promise<void>
|
|
77
|
-
*/
|
|
78
|
-
export const insertToast = async (element, options = {}) => {
|
|
79
|
-
options = {
|
|
80
|
-
classes: '',
|
|
81
|
-
title: '',
|
|
82
|
-
text: '',
|
|
83
|
-
start: '',
|
|
84
|
-
end: '',
|
|
85
|
-
show: {},
|
|
86
|
-
...options
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
element.insertAdjacentHTML('beforeend', `
|
|
90
|
-
<li class="x-toast ${options.classes}" role="status" aria-live="assertive" aria-atomic="true">
|
|
91
|
-
<div class="x-toast-content">
|
|
92
|
-
${options.start}
|
|
93
|
-
<div class="flex-col">
|
|
94
|
-
<div class="x-title">${options.title}</div>
|
|
95
|
-
<div class="x-text">${options.text}</div>
|
|
96
|
-
</div>
|
|
97
|
-
${options.end}
|
|
98
|
-
</div>
|
|
99
|
-
</li>
|
|
100
|
-
`)
|
|
101
|
-
|
|
102
|
-
await showToast(element.children[element.children.length - 1], options.show)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
53
|
/**
|
|
106
54
|
* @param {HTMLElement} element
|
|
107
55
|
* @param {import('./').CloseToastOptions} options
|
package/src/tailwind.css
CHANGED
package/src/test.css
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@import "base/index.css";
|
|
2
|
+
@import "components/index.css" layer(components);
|
|
3
|
+
@import "utilities/index.css" layer(components);
|
|
4
|
+
@import "tailwindcss/base.css";
|
|
5
|
+
@import "tailwindcss/components.css";
|
|
6
|
+
@import "tailwindcss/utilities.css";
|
|
7
|
+
@import "tailwindcss/variants.css";
|