winduum 2.2.28 → 3.0.0-next.10
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/package.json +19 -12
- package/src/base/defaults.css +3 -0
- package/src/base/reset.css +4 -0
- package/src/common.d.ts +4 -0
- package/src/common.js +9 -1
- package/src/components/carousel/content.css +1 -0
- package/src/components/carousel/index.d.ts +14 -35
- package/src/components/carousel/index.js +75 -194
- package/src/components/check/props/default.css +1 -1
- package/src/components/control/props/select-picker.css +4 -4
- package/src/components/control/props/select.css +2 -2
- package/src/components/control/tel-country-code.css +24 -0
- package/src/components/details/default.css +14 -0
- package/src/components/details/index.css +1 -0
- package/src/components/details/index.d.ts +2 -6
- package/src/components/details/index.js +7 -72
- package/src/components/details/readme.md +2 -5
- package/src/components/dialog/content.css +8 -2
- package/src/components/dialog/default.css +16 -2
- package/src/components/dialog/drawer.css +20 -0
- package/src/components/dialog/index.css +1 -0
- package/src/components/dialog/index.js +8 -79
- package/src/components/dialog/readme.md +1 -5
- package/src/components/drawer/content.css +2 -1
- package/src/components/drawer/default.css +13 -31
- package/src/components/drawer/index.css +3 -0
- package/src/components/drawer/index.d.ts +8 -15
- package/src/components/drawer/index.js +67 -50
- package/src/components/drawer/keyframes/default.css +9 -0
- package/src/components/drawer/noscript.css +32 -0
- package/src/components/drawer/nosnap.css +32 -0
- package/src/components/drawer/props/content.css +2 -2
- package/src/components/drawer/props/default.css +6 -0
- package/src/components/drawer/scroller.css +32 -0
- package/src/components/form/index.d.ts +5 -12
- package/src/components/form/index.js +35 -70
- package/src/components/heading/lg.css +1 -1
- package/src/components/heading/props/default.css +1 -1
- package/src/components/heading/sm.css +1 -1
- package/src/components/index.css +1 -0
- package/src/components/label/props/default.css +3 -2
- package/src/components/popover/content.css +7 -94
- package/src/components/popover/default.css +16 -3
- package/src/components/popover/index.css +2 -0
- package/src/components/popover/index.d.ts +14 -18
- package/src/components/popover/index.js +40 -80
- package/src/components/popover/props/content.css +1 -2
- package/src/components/popover/props/default.css +4 -0
- package/src/components/popover/readme.md +1 -2
- package/src/components/popover/tooltip.css +11 -0
- package/src/components/tabs/index.d.ts +2 -2
- package/src/components/text/content.css +241 -0
- package/src/components/text/default.css +0 -238
- package/src/components/text/index.css +2 -0
- package/src/components/text/props/content.css +9 -0
- package/src/components/text/props/default.css +1 -7
- package/src/components/toast/default.css +6 -0
- package/src/components/toast/index.js +2 -1
- package/src/components/toaster/index.d.ts +1 -0
- package/src/components/toaster/index.js +18 -0
- package/src/components/tooltip/default.css +8 -8
- package/src/polyfill.js +13 -0
- package/src/supports.js +15 -0
- package/src/utilities/container/props/default.css +3 -3
- package/tailwindcss/utilities/animation-trigger-fallback.css +18 -0
- package/tailwindcss/utilities/index.css +1 -0
- package/tailwindcss/utilities/position.css +203 -0
- package/types/index.d.ts +20 -58
- package/src/components/dialog/index.d.ts +0 -13
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.x-drawer-scroller {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: inherit;
|
|
4
|
+
height: inherit;
|
|
5
|
+
overflow: auto clip;
|
|
6
|
+
scrollbar-width: none;
|
|
7
|
+
scroll-behavior: smooth;
|
|
8
|
+
-webkit-overflow-scrolling: touch;
|
|
9
|
+
overscroll-behavior: none;
|
|
10
|
+
scroll-snap-type: x mandatory;
|
|
11
|
+
scroll-timeline: --x-drawer-backdrop x;
|
|
12
|
+
|
|
13
|
+
&::-webkit-scrollbar {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&::after {
|
|
18
|
+
content: "";
|
|
19
|
+
min-inline-size: 100dvw;
|
|
20
|
+
scroll-snap-align: end;
|
|
21
|
+
scroll-initial-target: nearest;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:where(.snap-y) {
|
|
25
|
+
overflow: clip auto;
|
|
26
|
+
scroll-timeline: --x-drawer-backdrop y;
|
|
27
|
+
|
|
28
|
+
&::after {
|
|
29
|
+
min-block-size: 100dvh;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface ValidateFormOptions {
|
|
2
|
-
|
|
2
|
+
validateSelector?: string
|
|
3
3
|
validateOptions?: ValidateFieldOptions
|
|
4
4
|
validateField?: typeof validateField
|
|
5
5
|
scrollOptions?: ScrollIntoViewOptions
|
|
@@ -7,23 +7,16 @@ export interface ValidateFormOptions {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface ValidateFieldOptions {
|
|
10
|
-
validate?: boolean
|
|
11
10
|
validationMessage?: string
|
|
12
11
|
selector?: string
|
|
13
|
-
ignoreMatch?: RegExp
|
|
14
12
|
validitySelector?: string
|
|
15
|
-
infoParentSelector?: string
|
|
16
|
-
infoSelector?: string
|
|
17
13
|
infoContent?: string
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
validAttribute?: string
|
|
14
|
+
iconParentSelector?: string
|
|
15
|
+
iconSelector?: string
|
|
16
|
+
iconContent?: string
|
|
22
17
|
validIcon?: string | null
|
|
23
|
-
invalidAttribute?: string
|
|
24
18
|
invalidIcon?: string
|
|
25
|
-
activeAttribute?: string
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
export function validateForm(event: Event | SubmitEvent, options?: ValidateFormOptions): void
|
|
29
|
-
export function validateField(element: HTMLElement
|
|
22
|
+
export function validateField(element: HTMLElement, options?: ValidateFieldOptions): void
|
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {
|
|
2
|
+
* @param {SubmitEvent & { target: HTMLFormElement }} event
|
|
3
3
|
* @param {import("./").ValidateFormOptions} options
|
|
4
4
|
* @returns void
|
|
5
5
|
*/
|
|
6
6
|
export const validateForm = (event, options = {}) => {
|
|
7
7
|
options = {
|
|
8
|
-
|
|
9
|
-
validateOptions: {
|
|
10
|
-
validate: true,
|
|
11
|
-
},
|
|
8
|
+
validateSelector: '.x-field',
|
|
9
|
+
validateOptions: {},
|
|
12
10
|
validateField,
|
|
13
11
|
submitterLoadingAttribute: 'data-loading',
|
|
14
12
|
scrollOptions: { behavior: 'smooth', block: 'center' },
|
|
15
13
|
...options,
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
event.stopImmediatePropagation()
|
|
16
|
+
if (!event.target.checkValidity()) {
|
|
17
|
+
event.preventDefault()
|
|
18
|
+
event.stopImmediatePropagation()
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
20
|
+
event.target.querySelector(':invalid').scrollIntoView(options.scrollOptions)
|
|
21
|
+
event.target.querySelector(':invalid').focus()
|
|
22
|
+
}
|
|
23
|
+
else if (options.submitterLoadingAttribute) {
|
|
24
|
+
event?.submitter?.setAttribute(options.submitterLoadingAttribute, '')
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
event.target.querySelectorAll(options.
|
|
27
|
+
event.target.querySelectorAll(options.validateSelector).forEach((element) => {
|
|
32
28
|
options.validateField(element, options.validateOptions)
|
|
33
29
|
})
|
|
34
30
|
}
|
|
@@ -40,73 +36,42 @@ export const validateForm = (event, options = {}) => {
|
|
|
40
36
|
*/
|
|
41
37
|
export const validateField = (element, options = {}) => {
|
|
42
38
|
options = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
infoContent: '<div class="x-info text-error validity"></div>',
|
|
50
|
-
endParentSelector: '.x-control',
|
|
51
|
-
endSelector: '.ms-auto',
|
|
52
|
-
endContent: '<div class="ms-auto"></div>',
|
|
53
|
-
validAttribute: 'data-valid',
|
|
39
|
+
selector: ':is(input:not([type="hidden"]), textarea, select):not([readonly], [data-novalidate])',
|
|
40
|
+
validitySelector: '[data-validity]',
|
|
41
|
+
infoContent: '<div class="x-info text-error" data-validity></div>',
|
|
42
|
+
iconParentSelector: '.x-control',
|
|
43
|
+
iconSelector: '.ms-auto',
|
|
44
|
+
iconContent: '<div class="ms-auto"></div>',
|
|
54
45
|
validIcon: null,
|
|
55
|
-
|
|
56
|
-
invalidIcon: '<svg class="text-error validity" aria-hidden="true"><use href="#icon-exclamation-circle"></use></svg>',
|
|
57
|
-
activeAttribute: 'data-active',
|
|
46
|
+
invalidIcon: '<svg class="text-error" data-validity aria-hidden="true"><use href="#heroicons-outline/exclamation-circle"></use></svg>',
|
|
58
47
|
...options,
|
|
59
48
|
}
|
|
60
49
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const validationElement = element.querySelector(options.selector)
|
|
64
|
-
const validationMessage = options.validationMessage ?? validationElement.dataset.validationMessage ?? validationElement.validationMessage
|
|
65
|
-
const infoParentElement = validationElement?.closest(options.infoParentSelector)
|
|
66
|
-
const endParentElement = validationElement.closest(options.endParentSelector)
|
|
67
|
-
const infoSelector = options.infoSelector + options.validitySelector
|
|
68
|
-
const endSelector = `${options.endSelector} ${options.validitySelector}`
|
|
69
|
-
|
|
70
|
-
const insertIcon = (icon) => {
|
|
71
|
-
if (!endParentElement || !icon) return
|
|
72
|
-
|
|
73
|
-
if (!element?.querySelector(options.endSelector)) {
|
|
74
|
-
element?.insertAdjacentHTML('beforeend', options.endContent)
|
|
75
|
-
}
|
|
50
|
+
const validationElements = [...element.querySelectorAll(options.selector)]
|
|
76
51
|
|
|
77
|
-
|
|
78
|
-
}
|
|
52
|
+
if (!validationElements.length) return
|
|
79
53
|
|
|
80
|
-
|
|
81
|
-
element.setAttribute(options.activeAttribute, '')
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
element.removeAttribute(options.activeAttribute)
|
|
85
|
-
}
|
|
54
|
+
element.querySelectorAll(options.validitySelector).forEach(el => el.remove())
|
|
86
55
|
|
|
87
|
-
|
|
88
|
-
element?.removeAttribute(options.validAttribute)
|
|
89
|
-
element?.removeAttribute(options.invalidAttribute)
|
|
56
|
+
const invalidElements = validationElements.filter(validationElement => !validationElement.checkValidity())
|
|
90
57
|
|
|
91
|
-
|
|
92
|
-
|
|
58
|
+
validationElements.forEach((validationElement) => {
|
|
59
|
+
const icon = invalidElements.includes(validationElement) ? options.invalidIcon : options.validIcon
|
|
60
|
+
const iconParentElement = validationElement.closest(options.iconParentSelector)
|
|
93
61
|
|
|
94
|
-
if (
|
|
95
|
-
element.setAttribute(options.validAttribute, '')
|
|
62
|
+
if (!iconParentElement || !icon) return
|
|
96
63
|
|
|
97
|
-
|
|
64
|
+
if (!iconParentElement.querySelector(options.iconSelector)) {
|
|
65
|
+
iconParentElement.insertAdjacentHTML('beforeend', options.iconContent)
|
|
98
66
|
}
|
|
99
|
-
else {
|
|
100
|
-
element.setAttribute(options.invalidAttribute, '')
|
|
101
67
|
|
|
102
|
-
|
|
68
|
+
iconParentElement.querySelector(options.iconSelector).insertAdjacentHTML('afterbegin', icon)
|
|
69
|
+
})
|
|
103
70
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
}
|
|
71
|
+
if (!invalidElements.length) return
|
|
72
|
+
|
|
73
|
+
element.insertAdjacentHTML('beforeend', options.infoContent)
|
|
74
|
+
element.lastElementChild.textContent = options.validationMessage ?? invalidElements[0].dataset.validationMessage ?? invalidElements[0].validationMessage
|
|
110
75
|
}
|
|
111
76
|
|
|
112
77
|
export default {
|
package/src/components/index.css
CHANGED
|
@@ -2,103 +2,16 @@
|
|
|
2
2
|
background-color: var(--x-popover-content-background-color);
|
|
3
3
|
border-radius: var(--x-popover-content-border-radius);
|
|
4
4
|
padding: var(--x-popover-content-padding-block) var(--x-popover-content-padding-inline);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
transition
|
|
8
|
-
transition-duration: var(--default-transition-duration);
|
|
9
|
-
transform:
|
|
10
|
-
translate(var(--tw-translate-x, 0), var(--tw-translate-y, 0))
|
|
11
|
-
scaleX(var(--tw-scale-x, 1)) scaleY(var(--tw-scale-y, 1));
|
|
5
|
+
color: var(--x-popover-content-color);
|
|
6
|
+
font-size: var(--x-popover-font-size);
|
|
7
|
+
transition: inherit;
|
|
12
8
|
will-change: transform;
|
|
13
|
-
inline-size: max-content;
|
|
14
|
-
position: absolute;
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
transform-origin: top;
|
|
10
|
+
@starting-style {
|
|
11
|
+
scale: var(--x-popover-content-starting-scale);
|
|
19
12
|
}
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&:where(.bottom-end) {
|
|
26
|
-
inset-inline-end: 0;
|
|
27
|
-
transform-origin: top right;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&:where(.right) {
|
|
31
|
-
inset-block-start: 0;
|
|
32
|
-
inset-inline-start: 100%;
|
|
33
|
-
transform-origin: left;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&:where(.right-start) {
|
|
37
|
-
transform-origin: left top;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&:where(.right-end) {
|
|
41
|
-
inset-block: auto 0;
|
|
42
|
-
transform-origin: left bottom;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&:where(.left) {
|
|
46
|
-
inset-block-start: 0;
|
|
47
|
-
inset-inline-end: 100%;
|
|
48
|
-
transform-origin: right;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&:where(.left-start) {
|
|
52
|
-
transform-origin: right top;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
&:where(.left-end) {
|
|
56
|
-
inset-block: auto 0;
|
|
57
|
-
transform-origin: right bottom;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
&:where(.top) {
|
|
61
|
-
inset-block-end: 100%;
|
|
62
|
-
transform-origin: bottom;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
&:where(.top-start) {
|
|
66
|
-
transform-origin: bottom left;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&:where(.top-end) {
|
|
70
|
-
inset-inline-end: 0;
|
|
71
|
-
transform-origin: bottom right;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&:where(.inline-center) {
|
|
75
|
-
--tw-translate-x: -50%;
|
|
76
|
-
|
|
77
|
-
inset-inline-start: 50%;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
&:where(.block-center) {
|
|
81
|
-
--tw-translate-y: -50%;
|
|
82
|
-
|
|
83
|
-
inset-block-start: 50%;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&[popover]:not([data-open]) {
|
|
87
|
-
--tw-scale-x: var(--x-popover-content-scale-x);
|
|
88
|
-
--tw-scale-y: var(--x-popover-content-scale-y);
|
|
89
|
-
|
|
90
|
-
opacity: 0%;
|
|
91
|
-
pointer-events: none;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&:not([popover]) {
|
|
95
|
-
.trigger-focus:not(:focus, :focus-within) > &,
|
|
96
|
-
.trigger-hover:not(:hover) > & {
|
|
97
|
-
--tw-scale-x: var(--x-popover-content-scale-x);
|
|
98
|
-
--tw-scale-y: var(--x-popover-content-scale-y);
|
|
99
|
-
|
|
100
|
-
opacity: 0%;
|
|
101
|
-
visibility: hidden;
|
|
102
|
-
}
|
|
14
|
+
:where(.x-popover:not(:popover-open)) > & {
|
|
15
|
+
scale: var(--x-popover-content-starting-scale);
|
|
103
16
|
}
|
|
104
17
|
}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
.x-popover {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
transition-property: var(--default-transition-property);
|
|
3
|
+
transition-timing-function: var(--ease-in-out);
|
|
4
|
+
transition-duration: var(--default-transition-duration);
|
|
5
|
+
transition-behavior: allow-discrete;
|
|
6
|
+
position: fixed;
|
|
7
|
+
inset: auto;
|
|
8
|
+
container-type: anchored;
|
|
9
|
+
|
|
10
|
+
@starting-style {
|
|
11
|
+
opacity: var(--x-popover-starting-opacity);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&:not(:popover-open) {
|
|
15
|
+
opacity: var(--x-popover-starting-opacity);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ComputePositionConfig } from '@floating-ui/dom'
|
|
2
|
+
import type { Placement } from '@floating-ui/utils'
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
offset?: OffsetOptions
|
|
10
|
-
flip?: FlipOptions
|
|
11
|
-
shift?: ShiftOptions
|
|
12
|
-
}
|
|
4
|
+
export declare function computePositionPopover(
|
|
5
|
+
referenceElement: HTMLElement,
|
|
6
|
+
floatingElement: HTMLElement & { $currentPlacement?: string },
|
|
7
|
+
placement: Placement,
|
|
8
|
+
options?: ComputePositionConfig | boolean
|
|
9
|
+
): Promise<void>
|
|
13
10
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export function togglePopover(element: HTMLElement | Element, options?: ShowPopoverOptions): Promise<void>
|
|
11
|
+
export declare function autoUpdatePopover(
|
|
12
|
+
referenceElement: HTMLElement,
|
|
13
|
+
floatingElement: HTMLElement,
|
|
14
|
+
placement: Placement,
|
|
15
|
+
options?: ComputePositionConfig | boolean
|
|
16
|
+
): Promise<() => void>
|
|
@@ -1,93 +1,53 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { supportsAnchor } from '../../common.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param {HTMLElement
|
|
5
|
-
* @param {HTMLElement
|
|
6
|
-
* @param {import(
|
|
7
|
-
* @
|
|
4
|
+
* @param {HTMLElement} referenceElement
|
|
5
|
+
* @param {HTMLElement & { _currentPlacement?: import('@floating-ui/utils').Placement }} floatingElement
|
|
6
|
+
* @param {import('@floating-ui/utils').Placement} placement
|
|
7
|
+
* @param {import('@floating-ui/dom').ComputePositionConfig | boolean} [options={}]
|
|
8
|
+
* @returns {Promise<void>}
|
|
8
9
|
*/
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
export const computePositionPopover = async (
|
|
11
|
+
referenceElement,
|
|
12
|
+
floatingElement,
|
|
13
|
+
placement,
|
|
14
|
+
options = {},
|
|
15
|
+
) => {
|
|
16
|
+
const { computePosition, flip } = await import('@floating-ui/dom')
|
|
17
|
+
|
|
18
|
+
const autoUpdate = options === true
|
|
19
|
+
const middleware = autoUpdate ? [flip()] : []
|
|
20
|
+
|
|
21
|
+
floatingElement.classList.remove(floatingElement._currentPlacement ?? placement)
|
|
22
|
+
floatingElement.style.setProperty('--anchor-size', !supportsAnchor ? `${referenceElement.offsetWidth}px` : '')
|
|
23
|
+
|
|
24
|
+
await computePosition(referenceElement, floatingElement, {
|
|
25
|
+
middleware,
|
|
26
|
+
placement,
|
|
27
|
+
...(autoUpdate ? {} : options),
|
|
17
28
|
}).then(({ x, y, placement }) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
popoverElement._placement = placement
|
|
23
|
-
popoverElement.classList.add(popoverElement._placement)
|
|
29
|
+
floatingElement.style.inset = !supportsAnchor ? `${y}px auto auto ${x}px` : ''
|
|
30
|
+
floatingElement.classList.add(placement)
|
|
31
|
+
floatingElement._currentPlacement = placement
|
|
24
32
|
})
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
/**
|
|
28
|
-
* @param {HTMLElement
|
|
29
|
-
* @param {
|
|
30
|
-
* @
|
|
36
|
+
* @param {HTMLElement} referenceElement
|
|
37
|
+
* @param {HTMLElement} floatingElement
|
|
38
|
+
* @param {import('@floating-ui/utils').Placement} placement
|
|
39
|
+
* @param {import('@floating-ui/dom').ComputePositionConfig | boolean} [options={}]
|
|
40
|
+
* @returns {Promise<() => void>}
|
|
31
41
|
*/
|
|
32
|
-
export const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
popoverElement.hidePopover && popoverElement.hidePopover()
|
|
39
|
-
|
|
40
|
-
element.ariaExpanded = 'false'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @param {HTMLElement | Element} element
|
|
45
|
-
* @param {import("./").ShowPopoverOptions} options
|
|
46
|
-
* @returns Promise<void>
|
|
47
|
-
*/
|
|
48
|
-
export const showPopover = async (element, options) => {
|
|
49
|
-
options = {
|
|
50
|
-
openAttribute: 'data-open',
|
|
51
|
-
compute: true,
|
|
52
|
-
...options,
|
|
53
|
-
}
|
|
54
|
-
|
|
42
|
+
export const autoUpdatePopover = async (
|
|
43
|
+
referenceElement,
|
|
44
|
+
floatingElement,
|
|
45
|
+
placement,
|
|
46
|
+
options = {},
|
|
47
|
+
) => {
|
|
55
48
|
const { autoUpdate } = await import('@floating-ui/dom')
|
|
56
49
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
element.ariaExpanded = 'true'
|
|
60
|
-
|
|
61
|
-
if (!element.ariaHasPopup) (element.ariaHasPopup = 'dialog')
|
|
62
|
-
if (!popoverElement.role) (popoverElement.role = element.ariaHasPopup)
|
|
63
|
-
|
|
64
|
-
popoverElement.showPopover && popoverElement.showPopover()
|
|
65
|
-
|
|
66
|
-
await nextRepaint()
|
|
67
|
-
|
|
68
|
-
popoverElement.setAttribute(options?.openAttribute, '')
|
|
69
|
-
|
|
70
|
-
if (!options.compute) {
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
popoverElement._cleanup = autoUpdate(
|
|
75
|
-
element,
|
|
76
|
-
popoverElement,
|
|
77
|
-
async () => await computePopover(options.anchorSelector ? document.querySelector(options.anchorSelector) : element, popoverElement, options),
|
|
50
|
+
return autoUpdate(referenceElement, floatingElement, () =>
|
|
51
|
+
computePositionPopover(referenceElement, floatingElement, placement, options),
|
|
78
52
|
)
|
|
79
53
|
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @param {HTMLElement | Element} element
|
|
83
|
-
* @param {import("./").ShowPopoverOptions} options
|
|
84
|
-
* @returns Promise<void>
|
|
85
|
-
*/
|
|
86
|
-
export const togglePopover = async (element, options) => {
|
|
87
|
-
if (element.ariaExpanded !== 'true') {
|
|
88
|
-
await showPopover(element, options)
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
await hidePopover(element)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -4,6 +4,5 @@
|
|
|
4
4
|
--x-popover-content-border-radius: var(--radius-xl);
|
|
5
5
|
--x-popover-content-padding-block: calc(var(--spacing) * 2);
|
|
6
6
|
--x-popover-content-padding-inline: calc(var(--spacing) * 2);
|
|
7
|
-
--x-popover-content-scale
|
|
8
|
-
--x-popover-content-scale-x: 0.75;
|
|
7
|
+
--x-popover-content-starting-scale: 0.75;
|
|
9
8
|
}
|
|
@@ -14,9 +14,8 @@ 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/popover/props/
|
|
17
|
+
@import "winduum/src/components/popover/props/default.css" layer(components);
|
|
18
18
|
@import "winduum/src/components/popover/default.css" layer(components);
|
|
19
|
-
@import "winduum/src/components/popover/content.css" layer(components);
|
|
20
19
|
```
|
|
21
20
|
|
|
22
21
|
### Local imports
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.x-popover {
|
|
2
|
+
&:is(.tooltip) {
|
|
3
|
+
--x-popover-content-background-color: var(--color-main);
|
|
4
|
+
--x-popover-content-color: var(--color-main-foreground);
|
|
5
|
+
--x-popover-content-border-radius: var(--radius-md);
|
|
6
|
+
--x-popover-content-padding-block: calc(var(--spacing) * 1);
|
|
7
|
+
--x-popover-content-padding-inline: calc(var(--spacing) * 2);
|
|
8
|
+
--x-popover-font-size: var(--text-sm);
|
|
9
|
+
--x-popover-content-starting-scale: 0.75;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
interface ToggleTabOptions {
|
|
2
|
-
tabElements?: NodeListOf<Element>
|
|
3
|
-
tabPanelElements?: NodeListOf<Element>
|
|
2
|
+
tabElements?: NodeListOf<Element> | Element[]
|
|
3
|
+
tabPanelElements?: NodeListOf<Element> | Element[]
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export function toggleTab(element: HTMLElement | Element, options?: ToggleTabOptions): void
|