winduum 3.0.0-next.1 → 3.0.0-next.11

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.
Files changed (69) hide show
  1. package/dist/main.css +1 -1
  2. package/dist/tailwind.css +2 -1
  3. package/package.json +28 -19
  4. package/src/base/defaults.css +3 -0
  5. package/src/base/keyframes.css +32 -0
  6. package/src/common.d.ts +4 -0
  7. package/src/components/carousel/content.css +1 -0
  8. package/src/components/carousel/index.d.ts +14 -35
  9. package/src/components/carousel/index.js +131 -187
  10. package/src/components/check/props/default.css +1 -1
  11. package/src/components/control/props/select-picker.css +4 -4
  12. package/src/components/control/props/select.css +2 -2
  13. package/src/components/control/tel-country-code.css +24 -0
  14. package/src/components/details/index.d.ts +5 -0
  15. package/src/components/details/index.js +13 -0
  16. package/src/components/details/readme.md +2 -5
  17. package/src/components/dialog/content.css +0 -1
  18. package/src/components/dialog/drawer.css +20 -0
  19. package/src/components/dialog/index.css +1 -0
  20. package/src/components/dialog/index.js +4 -0
  21. package/src/components/drawer/content.css +2 -1
  22. package/src/components/drawer/default.css +13 -31
  23. package/src/components/drawer/index.css +3 -0
  24. package/src/components/drawer/index.d.ts +8 -15
  25. package/src/components/drawer/index.js +67 -50
  26. package/src/components/drawer/keyframes/default.css +9 -0
  27. package/src/components/drawer/noscript.css +32 -0
  28. package/src/components/drawer/nosnap.css +32 -0
  29. package/src/components/drawer/props/content.css +2 -2
  30. package/src/components/drawer/props/default.css +6 -0
  31. package/src/components/drawer/scroller.css +32 -0
  32. package/src/components/field/index.d.ts +13 -0
  33. package/src/components/field/index.js +48 -0
  34. package/src/components/form/index.d.ts +3 -21
  35. package/src/components/form/index.js +14 -93
  36. package/src/components/heading/lg.css +1 -1
  37. package/src/components/heading/props/default.css +1 -1
  38. package/src/components/heading/sm.css +1 -1
  39. package/src/components/label/props/default.css +3 -2
  40. package/src/components/popover/content.css +2 -0
  41. package/src/components/popover/default.css +1 -1
  42. package/src/components/popover/index.css +1 -0
  43. package/src/components/popover/tooltip.css +11 -0
  44. package/src/components/tabs/index.d.ts +2 -2
  45. package/src/components/text/content.css +241 -0
  46. package/src/components/text/default.css +0 -238
  47. package/src/components/text/index.css +2 -0
  48. package/src/components/text/props/content.css +9 -0
  49. package/src/components/text/props/default.css +1 -7
  50. package/src/components/toast/default.css +6 -0
  51. package/src/components/toast/index.js +2 -1
  52. package/src/components/toaster/index.d.ts +1 -0
  53. package/src/components/toaster/index.js +18 -0
  54. package/src/polyfill.js +13 -0
  55. package/src/polyfills/timelineTrigger.js +54 -0
  56. package/src/supports.js +24 -0
  57. package/src/utilities/container/props/default.css +3 -3
  58. package/tailwindcss/theme/config/radius.css +9 -1
  59. package/tailwindcss/utilities/animation-timeline.css +51 -0
  60. package/tailwindcss/utilities/animation-trigger-fallback.css +18 -0
  61. package/tailwindcss/utilities/animation-trigger.css +33 -0
  62. package/tailwindcss/utilities/animation.css +88 -0
  63. package/tailwindcss/utilities/grid-area.css +7 -0
  64. package/tailwindcss/utilities/index.css +3 -0
  65. package/tailwindcss/utilities/position.css +24 -0
  66. package/tailwindcss/variants/index.css +2 -1
  67. package/tailwindcss/variants/scroll-state.css +245 -0
  68. package/types/index.d.ts +62 -64
  69. package/types/index.d.ts.map +27 -22
@@ -1,40 +1,19 @@
1
- export interface ObserveCarouselOptions {
2
- visibleAttribute?: string
3
- observerOptions?: {
4
- rootMargin?: string
5
- threshold?: number | number[]
6
- }
7
- }
8
-
9
- export interface PaginationCarouselOptions {
10
- element?: HTMLElement | Element
11
- itemContent?: string
12
- activeAttribute?: string
13
- }
14
-
15
- export interface ScrollCarouselOptions {
16
- observe?: ObserveCarouselOptions
17
- pagination?: PaginationCarouselOptions
18
- progressElement?: HTMLProgressElement | Element
19
- counterMinElement?: HTMLElement | Element
20
- counterMaxElement?: HTMLElement | Element
21
- }
1
+ export type CarouselPlacement = 'left' | 'right' | 'top' | 'bottom'
22
2
 
23
- export interface AutoplayCarouselOptions {
24
- delay?: number
25
- pauseElements?: HTMLElement[] | Element[]
3
+ export interface ScrollByOptions {
4
+ direction?: number
5
+ vertical?: boolean
6
+ ratio?: number
26
7
  }
27
8
 
28
- export interface DragCarouselOptions {
29
- activeAttribute?: string
9
+ export interface ToggleScrollStateOptions {
10
+ prevElement?: HTMLButtonElement | null
11
+ nextElement?: HTMLButtonElement | null
12
+ vertical?: boolean
30
13
  }
31
14
 
32
- export function scrollPrev(element: HTMLElement | Element): void
33
- export function scrollNext(element: HTMLElement | Element): void
34
- export function scrollTo(element: HTMLElement | Element, selected?: number): void
35
- export function getItemCount(element: HTMLElement | Element, scrollWidth?: number, mathFloor?: boolean): number
36
- export function observeCarousel(element: HTMLElement | Element, options?: ObserveCarouselOptions): void
37
- export function scrollCarousel(element: HTMLElement | Element, options?: ScrollCarouselOptions): void
38
- export function paginationCarousel(element: HTMLElement | Element, options?: PaginationCarouselOptions): void
39
- export function autoplayCarousel(element: HTMLElement | Element, options?: AutoplayCarouselOptions): void
40
- export function dragCarousel(element: HTMLElement | Element, options?: DragCarouselOptions): void
15
+ export function scrollBy(element: HTMLElement, options?: ScrollByOptions): void
16
+ export function toggleScrollState(element: HTMLElement, options?: ToggleScrollStateOptions): void
17
+ export function setCurrentAttribute(element: HTMLElement, index: number, attributeName?: string): void
18
+ export function setSnappedAttribute(element: HTMLElement, target: HTMLElement, markerGroupElement?: HTMLElement | null): void
19
+ export function scrollToMarker(element: HTMLElement, target: HTMLElement, markerGroupElement: HTMLElement, scrollIntoViewOptions?: ScrollIntoViewOptions): void
@@ -1,227 +1,171 @@
1
1
  /**
2
- * @param {HTMLElement | Element} element
3
- * @param {number} index
4
- * @returns void
5
- */
6
- export const scrollTo = (element, index = 0) => {
7
- const scrollPaddingLeft = parseInt(getComputedStyle(element).scrollPaddingLeft)
8
-
9
- element.scroll({ left: element?.children[index]?.offsetLeft - (isNaN(scrollPaddingLeft) ? 0 : scrollPaddingLeft) })
10
- }
11
-
12
- /**
13
- * @param {HTMLElement | Element & { _activeIndex: number }} element
14
- * @returns void
2
+ * @param {HTMLElement} element
3
+ * @param {boolean} vertical
4
+ * @returns {{ position: number, always: boolean }[]}
15
5
  */
16
- export const scrollPrev = (element) => {
17
- scrollTo(element, element._activeIndex - 1)
6
+ const getSnapPositions = (element, vertical) => {
7
+ const elementRect = element.getBoundingClientRect()
8
+ const scrollPosition = vertical ? element.scrollTop : element.scrollLeft
9
+ const clientSize = vertical ? element.clientHeight : element.clientWidth
10
+ const maxScroll = (vertical ? element.scrollHeight : element.scrollWidth) - clientSize
11
+
12
+ return [...element.children]
13
+ .map((child) => {
14
+ const childRect = child.getBoundingClientRect()
15
+ const start = (vertical ? childRect.top - elementRect.top : childRect.left - elementRect.left) + scrollPosition
16
+ const size = vertical ? childRect.height : childRect.width
17
+ const { scrollSnapAlign, scrollSnapStop } = getComputedStyle(child)
18
+ const align = scrollSnapAlign.split(' ').at(vertical ? 0 : -1)
19
+
20
+ if (align === 'none') return null
21
+
22
+ const position = align === 'end'
23
+ ? start + size - clientSize
24
+ : align === 'center'
25
+ ? start + (size - clientSize) / 2
26
+ : start
27
+
28
+ return {
29
+ position: Math.max(0, Math.min(position, maxScroll)),
30
+ always: scrollSnapStop === 'always',
31
+ }
32
+ })
33
+ .filter(snapPosition => snapPosition !== null)
18
34
  }
19
35
 
20
36
  /**
21
- * @param {HTMLElement | Element & { _activeIndex: number }} element
37
+ * @param {HTMLElement} element
38
+ * @param {object} options
39
+ * @param {number} [options.direction=1]
40
+ * @param {boolean} [options.vertical=false]
41
+ * @param {number} [options.ratio=0.85]
22
42
  * @returns void
23
43
  */
24
- export const scrollNext = (element) => {
25
- scrollTo(element, element._activeIndex + 1)
26
- }
27
-
28
- /**
29
- * @param {HTMLElement | Element} element
30
- * @param {number} scrollWidth
31
- * @param {boolean} mathFloor
32
- * @returns number
33
- */
34
- export const getItemCount = (element, scrollWidth = element.scrollWidth - element.clientWidth, mathFloor = false) => {
35
- const gap = parseInt(getComputedStyle(element).rowGap)
36
- const mathRound = (value, floor) => floor ? Math.floor(value) : Math.ceil(value)
37
-
38
- return [...element.children].reduce((count, children) => {
39
- if (mathRound(scrollWidth / (children.offsetWidth + (isNaN(gap) ? 0 : gap)), mathFloor) > count) {
40
- return count + 1
44
+ export const scrollBy = (element, { direction = 1, vertical = false, ratio = 0.85 }) => {
45
+ const { distance, position } = vertical
46
+ ? {
47
+ distance: element.clientHeight * ratio,
48
+ position: 'top',
49
+ }
50
+ : {
51
+ distance: element.clientWidth * ratio,
52
+ position: 'left',
53
+ }
54
+
55
+ /* Safari does not snap after programmatic scrolls — browsers with native
56
+ scroll snap events are the ones that do, others get the exact snap offset */
57
+ if (!('onscrollsnapchanging' in window)) {
58
+ const scrollPosition = vertical ? element.scrollTop : element.scrollLeft
59
+ const targetPosition = scrollPosition + distance * direction
60
+ const passes = snapPosition => direction > 0 ? snapPosition.position > scrollPosition + 1 : snapPosition.position < scrollPosition - 1
61
+ const closer = (a, b) => direction > 0 ? a.position < b.position : a.position > b.position
62
+ const snapPositions = getSnapPositions(element, vertical).filter(passes)
63
+
64
+ if (snapPositions.length) {
65
+ let target = snapPositions.reduce((closest, current) =>
66
+ Math.abs(current.position - targetPosition) < Math.abs(closest.position - targetPosition) ? current : closest,
67
+ )
68
+
69
+ /* scroll-snap-stop: always must not be passed over */
70
+ const stop = snapPositions.reduce((first, current) =>
71
+ current.always && (!first || closer(current, first)) ? current : first, null)
72
+
73
+ if (stop && closer(stop, target)) target = stop
74
+
75
+ element.scrollTo({
76
+ [position]: target.position,
77
+ })
78
+
79
+ return
41
80
  }
42
- else {
43
- return count
44
- }
45
- }, 0) + 1
46
- }
47
-
48
- /**
49
- * @param {HTMLElement | Element} element
50
- * @param {import("./").ObserveCarouselOptions} options
51
- * @returns IntersectionObserver
52
- */
53
- export const observeCarousel = (element, options = {}) => {
54
- options = {
55
- visibleAttribute: 'data-visible',
56
- observerOptions: {},
57
- ...options,
58
81
  }
59
82
 
60
- element._observer = new IntersectionObserver((entries) => {
61
- entries.forEach((entry) => {
62
- entry.target.toggleAttribute(options.visibleAttribute, entry.isIntersecting)
63
- })
64
-
65
- const activeElement = [...element.children].find(children => children.hasAttribute(options.visibleAttribute))
66
-
67
- if (activeElement) {
68
- element._activeIndex = [...element.children].indexOf(activeElement)
69
- }
70
- }, {
71
- root: element,
72
- threshold: 0.75,
73
- ...options.observerOptions,
83
+ element.scrollBy({
84
+ [position]: distance * direction,
74
85
  })
75
-
76
- ;[...element.children].forEach(children => element._observer.observe(children))
77
-
78
- return element._observer
79
86
  }
80
87
 
81
88
  /**
82
- * @param {HTMLElement | Element} element
83
- * @param {import("./").ScrollCarouselOptions} options
89
+ * @param {HTMLElement} element
90
+ * @param {object} options
91
+ * @param {HTMLButtonElement | null} [options.prevElement]
92
+ * @param {HTMLButtonElement | null} [options.nextElement]
93
+ * @param {boolean} vertical
84
94
  * @returns void
85
95
  */
86
- export const scrollCarousel = (element, options = {}) => {
87
- options.pagination = {
88
- activeAttribute: 'data-active',
89
- ...options.pagination,
90
- }
91
-
92
- const activeItem = getItemCount(element, element.scrollLeft, element.scrollLeft < element._lastScrollLeft)
93
- const activeItemMax = getItemCount(element)
94
-
95
- if (options?.pagination?.element) {
96
- ;[...options.pagination.element.children].forEach(children => children.removeAttribute(options.pagination.activeAttribute))
97
-
98
- options.pagination.element.children[activeItem - 1]?.setAttribute(options.pagination.activeAttribute, '')
99
- }
100
-
101
- if (options.progressElement) {
102
- options.progressElement.value = activeItem / activeItemMax * 100
103
- }
104
-
105
- if (options.counterMinElement) {
106
- options.counterMinElement.innerHTML = `${activeItem}`
107
- }
108
-
109
- if (options.counterMaxElement) {
110
- options.counterMaxElement.innerHTML = `${activeItemMax}`
111
- }
112
-
113
- element._lastScrollLeft = element.scrollLeft <= 0 ? 0 : element.scrollLeft
96
+ export const toggleScrollState = (element, { prevElement, nextElement, vertical = false }) => {
97
+ const { scrollStart, scrollEnd, scrollNone } = vertical
98
+ ? {
99
+ scrollStart: element.scrollTop <= 0,
100
+ scrollEnd: element.scrollTop >= element.scrollHeight - element.clientHeight,
101
+ scrollNone: !(element.scrollHeight - element.clientHeight),
102
+ }
103
+ : {
104
+ scrollStart: element.scrollLeft <= 0,
105
+ scrollEnd: element.scrollLeft >= element.scrollWidth - element.clientWidth,
106
+ scrollNone: !(element.scrollWidth - element.clientWidth),
107
+ }
108
+
109
+ if (prevElement) prevElement.disabled = scrollStart
110
+ if (nextElement) nextElement.disabled = scrollEnd
111
+
112
+ element.toggleAttribute('data-scroll-start', scrollStart)
113
+ element.toggleAttribute('data-scroll-end', scrollEnd)
114
+ element.toggleAttribute('data-scroll-none', scrollNone)
114
115
  }
115
116
 
116
117
  /**
117
- * @param {HTMLElement | Element} element
118
- * @param {import("./").PaginationCarouselOptions} options
118
+ * @param {HTMLElement} element
119
+ * @param {number} index
120
+ * @param {string} [attributeName='data-current']
119
121
  * @returns void
120
122
  */
121
- export const paginationCarousel = (element, options = {}) => {
122
- options = {
123
- itemContent: '<div aria-hidden="true"></div>',
124
- activeAttribute: 'data-active',
125
- ...options,
126
- }
127
-
128
- if (!options.element) return
129
-
130
- options.element.insertAdjacentHTML('beforeend', [...Array(getItemCount(element))].map(
131
- () => options.itemContent,
132
- ).join(''))
133
-
134
- ;[...options.element.children].forEach((children, i) => {
135
- (i === 0) && children.setAttribute(options.activeAttribute, '')
136
- children.addEventListener('click', ({ currentTarget }) => {
137
- scrollTo(element, [...options.element.children].indexOf(currentTarget))
138
- })
139
- })
123
+ export const setCurrentAttribute = (element, index, attributeName = 'aria-current') => {
124
+ element.querySelector(`[${attributeName}]`)?.removeAttribute(attributeName)
125
+ element.children[index].setAttribute(attributeName, 'true')
140
126
  }
141
127
 
142
128
  /**
143
- * @param {HTMLElement | Element} element
144
- * @param {import("./").AutoplayCarouselOptions} options
129
+ * @param {HTMLElement & { _markerIndex?: number | null }} element
130
+ * @param {HTMLElement} target
131
+ * @param {HTMLElement | null} markerGroupElement
145
132
  * @returns void
146
133
  */
147
- export const autoplayCarousel = (element, options = {}) => {
148
- options = {
149
- delay: 4000,
150
- pauseElements: [],
151
- ...options,
152
- }
134
+ export const setSnappedAttribute = (element, target, markerGroupElement) => {
135
+ const snappedIndex = [...element.children].indexOf(target)
153
136
 
154
- let paused
137
+ setCurrentAttribute(element, snappedIndex, 'data-snapped')
155
138
 
156
- options.pauseElements.forEach((element) => {
157
- element?.addEventListener('mouseenter', () => (paused = true))
158
- element?.addEventListener('mouseleave', () => (paused = false))
159
- })
139
+ if (markerGroupElement) {
140
+ const markerTarget = markerGroupElement.querySelector(`[href="#${target.id}"]`)
141
+ const index = element._markerIndex ?? (markerTarget && [...markerGroupElement.children].indexOf(markerTarget)) ?? snappedIndex
160
142
 
161
- setInterval(() => {
162
- if (paused) return
143
+ setCurrentAttribute(markerGroupElement, index)
163
144
 
164
- if (element.scrollLeft < element.scrollWidth - element.clientWidth) {
165
- scrollNext(element)
166
- }
167
- else {
168
- scrollTo(element, 0)
169
- }
170
- }, options.delay)
145
+ element._markerIndex = null
146
+ }
171
147
  }
172
148
 
173
149
  /**
174
- * @param {HTMLElement | Element & { _activeIndex: number }} element
175
- * @param {import("./").DragCarouselOptions} options
150
+ * @param {HTMLElement & { _markerIndex?: number | null }} element
151
+ * @param {HTMLElement | HTMLLinkElement} target
152
+ * @param {HTMLElement} markerGroupElement
153
+ * @param {ScrollIntoViewOptions} scrollIntoViewOptions
176
154
  * @returns void
177
155
  */
178
- export const dragCarousel = (element, options = {}) => {
179
- options = {
180
- activeAttribute: 'data-grabbing',
181
- ...options,
182
- }
183
-
184
- if (!matchMedia('(hover: hover) and (pointer: fine)').matches) {
185
- return
186
- }
187
-
188
- let isDown
189
- let startX
190
- let scrollLeft
191
- let timeout
192
-
193
- const endGrabbing = () => {
194
- isDown = false
195
- element.removeAttribute(options.activeAttribute)
196
-
197
- scrollTo(element, element._activeIndex)
198
-
199
- clearTimeout(timeout)
200
-
201
- timeout = setTimeout(() => {
202
- element.style.scrollSnapType = ''
203
- }, 300)
204
- }
205
-
206
- element.addEventListener('mouseleave', endGrabbing)
207
-
208
- element.addEventListener('mouseup', endGrabbing)
209
-
210
- element.addEventListener('mousedown', ({ pageX }) => {
211
- isDown = true
212
- startX = pageX - element.offsetLeft
213
- scrollLeft = element.scrollLeft
214
- })
156
+ export const scrollToMarker = (element, target, markerGroupElement, scrollIntoViewOptions = {}) => {
157
+ const snappedTarget = document.getElementById(target.getAttribute('href').slice(1))
158
+ const markerTargetIndex = [...markerGroupElement.children].indexOf(target)
159
+ const index = snappedTarget ? [...element.children].indexOf(snappedTarget) : markerTargetIndex
215
160
 
216
- element.addEventListener('mousemove', (e) => {
217
- if (!isDown) return
218
- e.preventDefault()
161
+ element._markerIndex = markerTargetIndex
219
162
 
220
- const x = e.pageX - element.offsetLeft
163
+ setCurrentAttribute(markerGroupElement, markerTargetIndex)
221
164
 
222
- element.setAttribute(options.activeAttribute, '')
223
- element.style.scrollSnapType = 'unset'
224
- element.scroll({ left: scrollLeft - ((x - startX) * 1.25), behavior: 'instant' })
225
- element.ondragstart = e => e.preventDefault()
165
+ element.children[index]?.scrollIntoView({
166
+ inline: 'start',
167
+ block: 'nearest',
168
+ container: 'nearest',
169
+ ...scrollIntoViewOptions,
226
170
  })
227
171
  }
@@ -3,7 +3,7 @@
3
3
  --x-check-size: 1.25rem;
4
4
  --x-check-gap: calc(var(--spacing) * 3);
5
5
  --x-check-font-size: var(--text-sm);
6
- --x-check-line-height: calc(1em + 0.25rem);
6
+ --x-check-line-height: 1.25rem;
7
7
  --x-check-border-radius: var(--radius-md);
8
8
  --x-check-border-width: 1px;
9
9
  --x-check-background-color: currentcolor;
@@ -5,12 +5,12 @@
5
5
  --x-control-select-picker-border-color: currentcolor;
6
6
  --x-control-select-picker-background-color: var(--color-body-primary);
7
7
  --x-control-select-picker-margin-block: 0.375rem;
8
- --x-control-select-picker-padding-block: 0.375rem;
9
- --x-control-select-picker-padding-inline: 0.375rem;
8
+ --x-control-select-picker-padding-block: calc(var(--spacing) * 1);
9
+ --x-control-select-picker-padding-inline: calc(var(--spacing) * 1);
10
10
  --x-control-select-picker-gap: 0.25rem;
11
11
  --x-control-select-picker-scrollbar-color: currentcolor var(--color-body-primary);
12
- --x-control-select-option-padding-block: 0.75rem;
13
- --x-control-select-option-padding-inline: 0.75rem;
12
+ --x-control-select-option-padding-block: calc(var(--spacing) * 2.5);
13
+ --x-control-select-option-padding-inline: calc(var(--spacing) * 3);
14
14
  --x-control-select-option-border-radius: var(--radius-md);
15
15
  --x-control-select-option-hocus-background-color: var(--color-body-secondary);
16
16
  }
@@ -1,6 +1,6 @@
1
1
  :root,
2
2
  :host {
3
- --x-control-select-icon-size: 1.25rem;
4
- --x-control-select-icon-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" stroke="currentColor"><path d="M10.998 15.467c.491.71 1.513.71 2.004 0l3.767-5.453c.581-.843 0-2.013-1.002-2.014H8.234C7.232 8 6.65 9.17 7.231 10.014z" /></svg>');
3
+ --x-control-select-icon-size: 1rem;
4
+ --x-control-select-icon-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.75" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>');
5
5
  --x-control-select-icon-margin-inline-end: -0.25rem;
6
6
  }
@@ -0,0 +1,24 @@
1
+ .x-control {
2
+ &:has([autocomplete="tel-country-code"]) {
3
+ :where(select) {
4
+ @media not (scripting: none) {
5
+ font-size: 0;
6
+ }
7
+
8
+ + :where(span) {
9
+ pointer-events: none;
10
+
11
+ @media (scripting: none) {
12
+ display: none;
13
+ }
14
+ }
15
+
16
+ :where(option) {
17
+ &::before {
18
+ content: attr(data-icon);
19
+ margin-inline-end: 0.5ch;
20
+ }
21
+ }
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,5 @@
1
+ export interface ToggleDetailsOptions {
2
+ selector?: string
3
+ }
4
+
5
+ export function toggleDetails(element: HTMLInputElement, options?: ToggleDetailsOptions): void
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @param {HTMLInputElement} element
3
+ * @param {import("./").ToggleDetailsOptions} options
4
+ * @returns void
5
+ */
6
+ export const toggleDetails = (element, options = {}) => {
7
+ const { selector } = {
8
+ selector: 'details',
9
+ ...options,
10
+ }
11
+
12
+ element?.closest(selector)?.toggleAttribute('open', element.checked)
13
+ }
@@ -1,8 +1,5 @@
1
1
  # [Details](https://winduum.dev/docs/components/details.html)
2
2
 
3
- ## Dependencies
4
- * [slide-element](https://www.npmjs.com/package/slide-element)
5
-
6
3
  ## Installation
7
4
  ```shell
8
5
  npm i winduum
@@ -10,7 +7,7 @@ npm i winduum
10
7
  Learn more how to set up Winduum [here](https://winduum.dev/docs/).
11
8
 
12
9
  ```js
13
- import { showDetails } from 'winduum/src/components/details/index.js'
10
+ import { toggleDetails } from 'winduum/src/components/details/index.js'
14
11
  ```
15
12
 
16
13
  ### Local imports
@@ -18,7 +15,7 @@ By default, imports are directly from `npm` so you can leverage updates.
18
15
  You can also copy and paste the code from this directory to your project and remap the imports to local.
19
16
 
20
17
  ```js
21
- import { showDetails } from '@/components/details/assets/index.js'
18
+ import { toggleDetails } from '@/components/details/assets/index.js'
22
19
  ```
23
20
 
24
21
  ### Docs
@@ -6,7 +6,6 @@
6
6
  transition: var(--transition-transform), var(--transition-opacity) allow-discrete, var(--transition-display) allow-discrete;
7
7
  margin: auto;
8
8
  pointer-events: auto;
9
- height: 200vh;
10
9
 
11
10
  @starting-style {
12
11
  transform: translateY(-2rem);
@@ -0,0 +1,20 @@
1
+ .x-dialog {
2
+ &:is(.drawer) {
3
+ timeline-scope: --x-drawer-backdrop;
4
+ animation: x-drawer-backdrop-opacity linear both;
5
+ animation-timeline: --x-drawer-backdrop;
6
+
7
+ &::backdrop {
8
+ background-color:
9
+ color-mix(
10
+ in var(--x-drawer-background-color-space, srgb),
11
+ var(--color-dark) calc(var(--x-drawer-backdrop-opacity, 0) * var(--x-drawer-background-color-opacity)),
12
+ var(--x-drawer-background-color-mix, transparent)
13
+ );
14
+
15
+ @supports not (animation-timeline: --x) {
16
+ --x-drawer-backdrop-opacity: 1;
17
+ }
18
+ }
19
+ }
20
+ }
@@ -2,3 +2,4 @@
2
2
  @import "./props/content.css";
3
3
  @import "./default.css";
4
4
  @import "./content.css";
5
+ @import "./drawer.css";
@@ -5,3 +5,7 @@ document.documentElement.addEventListener('click', ({ target }) => {
5
5
  target?.close()
6
6
  }
7
7
  })
8
+
9
+ new ResizeObserver(() => {
10
+ document.documentElement.style.setProperty('--default-scrollbar-width', `${Math.max(0, window.innerWidth - document.body.clientWidth)}px`)
11
+ }).observe(document.body)
@@ -1,7 +1,8 @@
1
1
  .x-drawer-content {
2
+ background-color: var(--x-drawer-content-background-color);
3
+ padding: var(--x-drawer-content-padding-block) var(--x-drawer-content-padding-inline);
2
4
  inline-size: var(--x-drawer-content-inline-size);
3
5
  block-size: var(--x-drawer-content-block-size);
4
- background-color: var(--x-drawer-content-background-color);
5
6
  flex-shrink: 0;
6
7
  scroll-snap-align: end;
7
8
  }
@@ -1,40 +1,22 @@
1
1
  .x-drawer {
2
- z-index: var(--x-drawer-z-index, var(--z-index-30));
3
- background-color:
4
- color-mix(
5
- in var(--x-drawer-background-color-space, srgb),
6
- var(--color-dark) calc(var(--background-color-opacity, 0) * var(--x-drawer-background-color-opacity)),
7
- var(--x-drawer-background-color-mix, transparent)
8
- );
9
2
  position: fixed;
10
3
  inset: 0;
11
- display: flex;
12
- overflow: auto hidden;
13
- scrollbar-width: none;
14
- scroll-behavior: smooth;
15
- -webkit-overflow-scrolling: touch;
16
- overscroll-behavior: contain;
4
+ width: 100dvw;
5
+ height: 100dvh;
6
+ timeline-scope: --x-drawer-backdrop;
7
+ animation: x-drawer-backdrop-opacity linear both;
8
+ animation-timeline: --x-drawer-backdrop;
17
9
 
18
- &:not([open]),
19
10
  &::backdrop {
20
- display: none;
21
- }
22
-
23
- &::-webkit-scrollbar {
24
- display: none;
25
- }
26
-
27
- &::after {
28
- content: "";
29
- min-inline-size: 100vw;
30
- scroll-snap-align: end;
31
- }
32
-
33
- &.flex-col {
34
- overflow: hidden auto;
11
+ background-color:
12
+ color-mix(
13
+ in var(--x-drawer-background-color-space, srgb),
14
+ var(--color-dark) calc(var(--x-drawer-backdrop-opacity, 0) * var(--x-drawer-background-color-opacity)),
15
+ var(--x-drawer-background-color-mix, transparent)
16
+ );
35
17
 
36
- &::after {
37
- min-block-size: 100dvh;
18
+ @supports not (animation-timeline: --x) {
19
+ --x-drawer-backdrop-opacity: 1;
38
20
  }
39
21
  }
40
22
  }
@@ -1,4 +1,7 @@
1
1
  @import "./props/default.css";
2
2
  @import "./props/content.css";
3
+ @import "./keyframes/default.css";
3
4
  @import "./default.css";
4
5
  @import "./content.css";
6
+ @import "./scroller.css";
7
+ @import "./noscript.css";