winduum 1.2.0-next.4 → 1.2.0-next.6

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": "1.2.0-next.4",
3
+ "version": "1.2.0-next.6",
4
4
  "type": "module",
5
5
  "types": "types/index.d.ts",
6
6
  "main": "plugin/index.cjs",
@@ -0,0 +1,15 @@
1
+ import { FlipOptions, Middleware, OffsetOptions, Placement, ShiftOptions } from "@floating-ui/dom";
2
+
3
+ export interface ShowPopoverOptions {
4
+ visibleClass?: string
5
+ compute?: boolean
6
+ placement?: Placement
7
+ middleware?: Array<Middleware | null | undefined | false>
8
+ offset?: OffsetOptions
9
+ flip?: FlipOptions
10
+ shift?: ShiftOptions
11
+ }
12
+
13
+ export function showPopover(element: HTMLElement | Element, options?: ShowPopoverOptions): Promise<void>
14
+ export function hidePopover(element: HTMLElement | Element): Promise<void>
15
+ export function togglePopover(element: HTMLElement | Element, options?: ShowPopoverOptions): Promise<void>
@@ -1,36 +1,51 @@
1
1
  import { animationsFinished } from '../../common.js'
2
2
 
3
- export const computePopover = async (element, popover, options) => {
3
+ /**
4
+ * @param {HTMLElement | Element} element
5
+ * @param {HTMLElement | Element} popoverElement
6
+ * @param {import("./").ShowPopoverOptions} options
7
+ * @returns Promise<void>
8
+ */
9
+ export const computePopover = async (element, popoverElement, options) => {
4
10
  const { computePosition, flip, shift, offset } = await import('@floating-ui/dom')
5
11
 
6
- popover.classList.remove(popover._placement)
12
+ popoverElement.classList.remove(popoverElement._placement)
7
13
 
8
- popover.style.minWidth = `${element.offsetWidth / 16}rem`
14
+ popoverElement.style.minWidth = `${element.offsetWidth / 16}rem`
9
15
 
10
- await computePosition(element, popover, {
16
+ await computePosition(element, popoverElement, {
11
17
  placement: options?.placement,
12
- middleware: options?.middleware ?? [offset(12 ?? options?.offset), flip(), shift({ padding: 8, ...options?.shift })]
18
+ middleware: options?.middleware ?? [offset(12 ?? options?.offset), flip(options?.flip), shift({ padding: 8, ...options?.shift })]
13
19
  }).then(({ x, y, placement }) => {
14
- Object.assign(popover.style, {
20
+ Object.assign(popoverElement.style, {
15
21
  inset: `${y}px auto auto ${x}px`
16
22
  })
17
23
 
18
- popover._placement = placement
19
- popover.classList.add(popover._placement, options?.visibleClass ?? 'in')
24
+ popoverElement._placement = placement
25
+ popoverElement.classList.add(popoverElement._placement, options?.visibleClass ?? 'in')
20
26
  })
21
27
  }
22
28
 
23
- export const closePopover = async (element) => {
29
+ /**
30
+ * @param {HTMLElement | Element} element - The HTML content to insert into the dialog.
31
+ * @returns Promise<void>
32
+ */
33
+ export const hidePopover = async (element) => {
24
34
  const popoverElement = document.getElementById(element.getAttribute('popovertarget'))
25
35
 
26
36
  popoverElement.classList.remove('in')
27
37
  await animationsFinished(popoverElement)
28
- popoverElement?._cleanup()
38
+ popoverElement._cleanup && popoverElement._cleanup()
29
39
  popoverElement.hidePopover && popoverElement.hidePopover()
30
40
 
31
- element.ariaExpanded = false
41
+ element.ariaExpanded = 'false'
32
42
  }
33
43
 
44
+ /**
45
+ * @param {HTMLElement | Element} element
46
+ * @param {import("./").ShowPopoverOptions} options
47
+ * @returns Promise<void>
48
+ */
34
49
  export const showPopover = async (element, options) => {
35
50
  options = {
36
51
  visibleClass: 'in',
@@ -42,7 +57,7 @@ export const showPopover = async (element, options) => {
42
57
 
43
58
  const popoverElement = document.getElementById(element.getAttribute('popovertarget'))
44
59
 
45
- element.ariaExpanded = true
60
+ element.ariaExpanded = 'true'
46
61
 
47
62
  if (!element.ariaHasPopup) (element.ariaHasPopup = 'dialog')
48
63
  if (!popoverElement.role) (popoverElement.role = element.ariaHasPopup)
@@ -61,10 +76,15 @@ export const showPopover = async (element, options) => {
61
76
  )
62
77
  }
63
78
 
79
+ /**
80
+ * @param {HTMLElement | Element} element
81
+ * @param {import("./").ShowPopoverOptions} options
82
+ * @returns Promise<void>
83
+ */
64
84
  export const togglePopover = async (element, options) => {
65
85
  if (element.ariaExpanded !== 'true') {
66
86
  await showPopover(element, options)
67
87
  } else {
68
- await closePopover(element)
88
+ await hidePopover(element)
69
89
  }
70
90
  }
package/types/index.d.ts CHANGED
@@ -22,7 +22,7 @@ declare module 'winduum' {
22
22
 
23
23
  export const defaultConfig: PluginOptions
24
24
 
25
- export default function createPlugin(userConfig: PluginOptions): Plugin
25
+ export default function createPlugin(userConfig?: PluginOptions): Plugin
26
26
  }
27
27
 
28
28
  declare module 'winduum/src/components/carousel' {
@@ -92,10 +92,6 @@ declare module 'winduum/src/components/details' {
92
92
  }
93
93
 
94
94
  declare module 'winduum/src/components/dialog' {
95
- export interface DialogElement extends HTMLDialogElement {
96
- _dialogHasEvents: boolean
97
- }
98
-
99
95
  export interface DefaultOptions {
100
96
  remove?: boolean | null
101
97
  closable?: boolean | null
@@ -118,7 +114,7 @@ declare module 'winduum/src/components/dialog' {
118
114
  export const defaultOptions: DefaultOptions
119
115
  export function dialogSelector(selector: string): HTMLDialogElement
120
116
  export function dismissDialog(element: HTMLDialogElement, options?: DefaultOptions): Promise<void>
121
- export function showDialog(element: DialogElement, options?: DefaultOptions): Promise<void>
117
+ export function showDialog(element: HTMLDialogElement, options?: DefaultOptions): Promise<void>
122
118
  export function closeDialog(element: HTMLDialogElement, options?: DefaultOptions): Promise<void>
123
119
  export function insertDialog(content: string, options?: InsertDialogOptions): Promise<void>
124
120
  export function fetchDialog({ url, insert }: FetchDialogOptions): Promise<void>
@@ -211,6 +207,23 @@ declare module 'winduum/src/components/toaster' {
211
207
  export function closeToaster(element: HTMLElement, options?: CloseToastOptions): Promise<void>
212
208
  }
213
209
 
210
+ declare module 'winduum/src/components/popover' {
211
+ import type { FlipOptions, Middleware, OffsetOptions, Placement, ShiftOptions } from '@floating-ui/dom';
212
+ export interface ShowPopoverOptions {
213
+ visibleClass?: string
214
+ compute?: boolean
215
+ placement?: Placement
216
+ middleware?: Array<Middleware | null | undefined | false>
217
+ offset?: OffsetOptions
218
+ flip?: FlipOptions
219
+ shift?: ShiftOptions
220
+ }
221
+
222
+ export function showPopover(element: HTMLElement | Element, options?: ShowPopoverOptions): Promise<void>
223
+ export function hidePopover(element: HTMLElement | Element): Promise<void>
224
+ export function togglePopover(element: HTMLElement | Element, options?: ShowPopoverOptions): Promise<void>
225
+ }
226
+
214
227
  declare module 'winduum/src/ui/range' {
215
228
  export interface SetTrackPropertyOptions {
216
229
  element: HTMLElement | Element
@@ -27,7 +27,6 @@
27
27
  "showDetails",
28
28
  "closeDetails",
29
29
  "toggleDetails",
30
- "DialogElement",
31
30
  "InsertDialogOptions",
32
31
  "FetchDialogOptions",
33
32
  "dialogSelector",
@@ -54,6 +53,10 @@
54
53
  "insertToaster",
55
54
  "insertToast",
56
55
  "closeToaster",
56
+ "ShowPopoverOptions",
57
+ "showPopover",
58
+ "hidePopover",
59
+ "togglePopover",
57
60
  "SetTrackPropertyOptions",
58
61
  "SetValueOptions",
59
62
  "SetOutputOptions",
@@ -73,6 +76,7 @@
73
76
  "../src/components/form/index.d.ts",
74
77
  "../src/components/tabs/index.d.ts",
75
78
  "../src/components/toaster/index.d.ts",
79
+ "../src/components/popover/index.d.ts",
76
80
  "../src/ui/range/index.d.ts",
77
81
  "../src/utilities/ripple/index.d.ts",
78
82
  "../src/utilities/swap/index.d.ts"
@@ -89,7 +93,8 @@
89
93
  null,
90
94
  null,
91
95
  null,
96
+ null,
92
97
  null
93
98
  ],
94
- "mappings": ";;kBAEiBA,aAAaA;;;;;;;;;;;;;;;;;;;;cAoBjBC,aAAaA;;;;;;kBCtBTC,sBAAsBA;;;;;;;;kBAQtBC,yBAAyBA;;;;;;kBAMzBC,qBAAqBA;;;;;;;;kBAQrBC,uBAAuBA;;;;;kBAKvBC,mBAAmBA;;;;iBAIpBC,UAAUA;iBACVC,UAAUA;iBACVC,QAAQA;iBACRC,YAAYA;iBACZC,eAAeA;iBACfC,cAAcA;iBACdC,kBAAkBA;iBAClBC,gBAAgBA;iBA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