winduum 2.0.0-next.21 → 2.0.0-next.23

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "winduum",
3
- "version": "2.0.0-next.21",
3
+ "version": "2.0.0-next.23",
4
4
  "type": "module",
5
5
  "types": "types/index.d.ts",
6
6
  "main": "plugin/index.cjs",
@@ -1,8 +1,8 @@
1
- .x-button:has(.spinner) {
1
+ .x-button:has(.spinner-absolute) {
2
2
  pointer-events: none;
3
3
  color: transparent;
4
4
 
5
- .spinner {
5
+ .spinner-absolute {
6
6
  color: var(--x-button-color);
7
7
  position: absolute;
8
8
  }
@@ -41,13 +41,13 @@
41
41
  }
42
42
  }
43
43
 
44
- > :where(.x-button) {
44
+ > .x-button {
45
45
  inset-inline-start: var(--x-compare-position);
46
46
  margin-inline-start: calc(var(--x-button-inline-size) / 2 * -1);
47
47
  margin-block: auto;
48
48
  }
49
49
 
50
- > :where(.x-image) {
50
+ > .x-image {
51
51
  display: grid;
52
52
  z-index: 0;
53
53
 
@@ -3,6 +3,6 @@ export interface SetPositionOptions {
3
3
  positionProperty?: string
4
4
  }
5
5
 
6
- export function setPosition(event: Event, options?: SetPositionOptions): void
7
- export function setKeyboardStep(event: KeyboardEvent, step?: string): void
8
- export function setMouseStep(event: MouseEvent, step?: string): void
6
+ export function setPosition(element: HTMLInputElement, options?: SetPositionOptions): void
7
+ export function setKeyboardStep(element: HTMLInputElement, key: string, step?: string): void
8
+ export function setMouseStep(element: HTMLInputElement, step?: string): void
@@ -1,34 +1,35 @@
1
1
  /**
2
- * @param {Event & { currentTarget: HTMLElement | Element }} event
2
+ * @param {HTMLInputElement} element
3
3
  * @param {import("./").SetPositionOptions} options
4
4
  * @returns void
5
5
  */
6
- export const setPosition = ({ currentTarget }, options = {}) => {
6
+ export const setPosition = (element, options = {}) => {
7
7
  const { selector, positionProperty } = {
8
8
  selector: '.x-compare',
9
9
  positionProperty: '--x-compare-position',
10
10
  ...options
11
11
  }
12
12
 
13
- currentTarget?.closest(selector)?.style.setProperty(positionProperty, `${currentTarget.value}%`)
13
+ element?.closest(selector)?.style.setProperty(positionProperty, `${element.value}%`)
14
14
  }
15
15
 
16
16
  /**
17
- * @param {KeyboardEvent & { currentTarget: HTMLInputElement | EventTarget }} event
17
+ * @param {HTMLInputElement} element
18
+ * @param {string} key
18
19
  * @param {string} step
19
20
  * @returns void
20
21
  */
21
- export const setKeyboardStep = ({ key, currentTarget }, step = '10') => {
22
+ export const setKeyboardStep = (element, key, step = '10') => {
22
23
  if (key?.toLowerCase() !== 'arrowright' && key?.toLowerCase() !== 'arrowleft') return
23
24
 
24
- currentTarget.step = step
25
+ element.step = step
25
26
  }
26
27
 
27
28
  /**
28
- * @param {MouseEvent & { currentTarget: HTMLInputElement | EventTarget }} event
29
+ * @param {HTMLInputElement} element
29
30
  * @param {string} step
30
31
  * @returns void
31
32
  */
32
- export const setMouseStep = ({ currentTarget }, step = '0.1') => {
33
- currentTarget.step = step
33
+ export const setMouseStep = (element, step = '0.1') => {
34
+ element.step = step
34
35
  }
@@ -1,6 +1,7 @@
1
1
  export interface ValidateFormOptions {
2
2
  validateSelectors?: string
3
3
  validateOptions?: ValidateFieldOptions
4
+ scrollOptions?: ScrollIntoViewOptions
4
5
  submitterLoadingAttribute?: string
5
6
  }
6
7
 
@@ -8,6 +8,7 @@ export const validateForm = (event, options = {}) => {
8
8
  validateSelectors: '.x-control, .x-check, .x-switch, .x-rating, .x-color',
9
9
  validateOptions: {},
10
10
  submitterLoadingAttribute: 'data-loading',
11
+ scrollOptions: { behavior: 'smooth', block: 'center' },
11
12
  ...options
12
13
  }
13
14
 
@@ -15,7 +16,7 @@ export const validateForm = (event, options = {}) => {
15
16
  event.preventDefault()
16
17
  event.stopImmediatePropagation()
17
18
 
18
- event.target.querySelector(':invalid').scrollIntoView({ behavior: 'smooth', block: 'center' })
19
+ event.target.querySelector(':invalid').scrollIntoView(options.scrollOptions)
19
20
  event.target.querySelector(':invalid').focus()
20
21
  } else {
21
22
  event?.submitter?.setAttribute(options.submitterLoadingAttribute, '')
@@ -1,6 +1,7 @@
1
1
  import { FlipOptions, Middleware, OffsetOptions, Placement, ShiftOptions } from "@floating-ui/dom";
2
2
 
3
3
  export interface ShowPopoverOptions {
4
+ anchorSelector: string,
4
5
  openAttribute?: string
5
6
  compute?: boolean
6
7
  placement?: Placement
@@ -74,7 +74,7 @@ export const showPopover = async (element, options) => {
74
74
  popoverElement._cleanup = autoUpdate(
75
75
  element,
76
76
  popoverElement,
77
- async () => await computePopover(element, popoverElement, options)
77
+ async () => await computePopover(options.anchorSelector ? document.querySelector(options.anchorSelector) : element, popoverElement, options)
78
78
  )
79
79
  }
80
80
 
@@ -1 +1,7 @@
1
- export function showRipple(event: MouseEvent, element?: HTMLElement): void
1
+ export interface ShowRippleOptions {
2
+ element: HTMLElement | Element
3
+ x: number
4
+ y: number
5
+ }
6
+
7
+ export function showRipple(options: ShowRippleOptions, element?: HTMLElement): void
@@ -1,25 +1,25 @@
1
1
  /**
2
2
  * Shows a ripple effect.
3
- * @param {MouseEvent} event - The dialog element to dismiss.
4
- * @param {HTMLElement} element - The options for closing the dialog.
3
+ * @param {import("./").ShowRippleOptions} options
4
+ * @param {HTMLElement} rippleElement
5
5
  * @returns void
6
6
  */
7
- export const showRipple = ({ currentTarget, offsetX, offsetY }, element = currentTarget.querySelector('.ripple')) => {
8
- if (!element) {
9
- currentTarget.insertAdjacentHTML('beforeend', "<div class='ripple'></div>")
10
- element = currentTarget.querySelector('.ripple')
7
+ export const showRipple = ({ element, x, y }, rippleElement = element.querySelector('.ripple')) => {
8
+ if (!rippleElement) {
9
+ element.insertAdjacentHTML('beforeend', "<div class='ripple'></div>")
10
+ rippleElement = element.querySelector('.ripple')
11
11
  }
12
12
 
13
- element.classList.remove('animation-ripple')
13
+ rippleElement.classList.remove('animation-ripple')
14
14
 
15
- if (element.clientWidth === 0 && element.clientHeight === 0) {
16
- const d = Math.max(currentTarget.offsetWidth, currentTarget.offsetHeight)
15
+ if (rippleElement.clientWidth === 0 && rippleElement.clientHeight === 0) {
16
+ const d = Math.max(element.offsetWidth, element.offsetHeight)
17
17
 
18
- element.style.width = d + 'px'
19
- element.style.height = d + 'px'
18
+ rippleElement.style.width = d + 'px'
19
+ rippleElement.style.height = d + 'px'
20
20
  }
21
21
 
22
- element.style.top = offsetY - (element.clientHeight / 2) + 'px'
23
- element.style.left = offsetX - (element.clientWidth / 2) + 'px'
24
- element.classList.add('animation-ripple')
22
+ rippleElement.style.top = y - (rippleElement.clientHeight / 2) + 'px'
23
+ rippleElement.style.left = x - (rippleElement.clientWidth / 2) + 'px'
24
+ rippleElement.classList.add('animation-ripple')
25
25
  }