winduum 0.8.0-next.3 → 0.8.0-next.5

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,10 +1,10 @@
1
1
  {
2
2
  "name": "winduum",
3
- "version": "0.8.0-next.3",
3
+ "version": "0.8.0-next.5",
4
4
  "type": "module",
5
5
  "types": "types/index.d.ts",
6
- "main": "plugin/tailwind.cjs",
7
- "module": "plugin/tailwind.js",
6
+ "main": "plugin/index.cjs",
7
+ "module": "plugin/index.js",
8
8
  "scripts": {
9
9
  "dev": "vite --host",
10
10
  "build": "vite build",
@@ -13,7 +13,8 @@
13
13
  "eslint-fix": "eslint 'src/**/*.js' --fix",
14
14
  "stylelint": "npx stylelint 'src/**/*.css'",
15
15
  "stylelint-fix": "npx stylelint 'src/**/*.css' --fix",
16
- "tailwind": "rollup plugin/tailwind.js --file plugin/tailwind.cjs -f cjs --exports named",
16
+ "plugin": "rollup plugin/index.js --file plugin/index.cjs -f cjs --exports named",
17
+ "dts": "node dts.js",
17
18
  "publish-next": "npm publish --tag next"
18
19
  },
19
20
  "devDependencies": {
@@ -35,7 +36,9 @@
35
36
  "tailwindcss-animate": "^1.0.7",
36
37
  "vite": "^5.0.12",
37
38
  "vue": "^3.4.15",
38
- "slide-element": "^2.3.1"
39
+ "slide-element": "^2.3.1",
40
+ "dts-buddy": "^0.4.4",
41
+ "typescript": "^5.3.3"
39
42
  },
40
43
  "files": [
41
44
  "index.js",
@@ -47,28 +50,49 @@
47
50
  ],
48
51
  "exports": {
49
52
  ".": {
50
- "default": "./plugin/tailwind.js",
51
- "require": "./plugin/tailwind.cjs",
52
- "import": "./plugin/tailwind.js"
53
+ "default": "./plugin/index.js",
54
+ "require": "./plugin/index.cjs",
55
+ "import": "./plugin/index.js",
56
+ "types": "./plugin/types.d.ts"
53
57
  },
54
58
  "./src/*": "./src/*",
55
59
  "./dist/*": "./dist/*",
56
60
  "./plugin/*": "./plugin/*",
57
- "./base/*": "./src/base/*",
58
- "./components/*": "./src/components/*",
59
- "./libraries/*": "./src/libraries/*",
60
- "./ui/*": "./src/ui/*",
61
+ "./src/components/compare": {
62
+ "default": "./src/components/compare/index.js",
63
+ "types": "./src/components/compare/index.d.ts"
64
+ },
65
+ "./src/components/details": {
66
+ "default": "./src/components/details/index.js",
67
+ "types": "./src/components/details/index.d.ts"
68
+ },
61
69
  "./src/components/dialog": {
62
70
  "default": "./src/components/dialog/index.js",
63
- "types": "./types/index.d.ts"
71
+ "types": "./src/components/dialog/index.d.ts"
64
72
  },
65
73
  "./src/components/form": {
66
74
  "default": "./src/components/form/index.js",
67
- "types": "./types/index.d.ts"
75
+ "types": "./src/components/form/index.d.ts"
76
+ },
77
+ "./src/components/toaster": {
78
+ "default": "./src/components/toaster/index.js",
79
+ "types": "./src/components/toaster/index.d.ts"
80
+ },
81
+ "./src/ui/range": {
82
+ "default": "./src/ui/range/index.js",
83
+ "types": "./src/ui/range/index.d.ts"
84
+ },
85
+ "./src/utilities/ripple": {
86
+ "default": "./src/utilities/ripple/index.js",
87
+ "types": "./src/utilities/ripple/index.d.ts"
88
+ },
89
+ "./src/utilities/swap": {
90
+ "default": "./src/utilities/ripple/index.js",
91
+ "types": "./src/utilities/ripple/index.d.ts"
68
92
  }
69
93
  },
70
94
  "engines": {
71
- "node": ">=18.0.0",
95
+ "node": ">=20.0.0",
72
96
  "npm": ">=9.0.0"
73
97
  },
74
98
  "repository": {
@@ -202,7 +202,7 @@ const tailwindAnimations = (values) => {
202
202
  };
203
203
 
204
204
  /**
205
- * @type {import('./tailwind').PluginOptions} options.
205
+ * @type {import('./').PluginOptions} options.
206
206
  */
207
207
  const defaultConfig = {
208
208
  colors: [
@@ -243,7 +243,7 @@ const defaultConfig = {
243
243
  };
244
244
 
245
245
  /**
246
- * @param {import('./tailwind').PluginOptions} userConfig
246
+ * @param {import('./').PluginOptions} userConfig
247
247
  */
248
248
  const createPlugin = (userConfig = {}) => {
249
249
  const settings = {
@@ -1,3 +1,5 @@
1
+ import { Plugin } from "tailwindcss/types/config";
2
+
1
3
  export interface PluginOptions {
2
4
  colors?: string[]
3
5
  fontFamily?: string[],
@@ -17,3 +19,7 @@ export interface PluginOptions {
17
19
  colorMix?: boolean
18
20
  }
19
21
  }
22
+
23
+ export const defaultConfig: PluginOptions
24
+
25
+ export default function createPlugin(userConfig: PluginOptions): Plugin
@@ -7,7 +7,7 @@ import { accentColor, textColor } from './utilities/color.js'
7
7
  import { tailwindAnimations, tailwindColors, tailwindPropertyUtilities, tailwindVariables, tailwindVariablesFont } from './utilities/common.js'
8
8
 
9
9
  /**
10
- * @type {import('./tailwind').PluginOptions} options.
10
+ * @type {import('./').PluginOptions} options.
11
11
  */
12
12
  export const defaultConfig = {
13
13
  colors: [
@@ -48,7 +48,7 @@ export const defaultConfig = {
48
48
  }
49
49
 
50
50
  /**
51
- * @param {import('./tailwind').PluginOptions} userConfig
51
+ * @param {import('./').PluginOptions} userConfig
52
52
  */
53
53
  export const createPlugin = (userConfig = {}) => {
54
54
  const settings = {
@@ -0,0 +1,2 @@
1
+ export function nextRepaint(): any;
2
+ export function animationsFinished(element: any): Promise<any>;
@@ -0,0 +1,8 @@
1
+ export interface SetPositionOptions {
2
+ selector?: string
3
+ positionProperty?: string
4
+ }
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
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @param {import("./types/index").Position} event
3
- * @param {import("./types/index").PositionOptions} options
2
+ * @param {Event} event
3
+ * @param {import("./").SetPositionOptions} options
4
4
  * @returns void
5
5
  */
6
6
  export const setPosition = ({ currentTarget }, options = {}) => {
@@ -14,27 +14,21 @@ export const setPosition = ({ currentTarget }, options = {}) => {
14
14
  }
15
15
 
16
16
  /**
17
- * @param {import("./types/index").KeyboardStep} event
18
- * @param {Number} step
17
+ * @param {KeyboardEvent & { currentTarget: HTMLInputElement | EventTarget }} event
18
+ * @param {string} step
19
19
  * @returns void
20
20
  */
21
- export const setKeyboardStep = ({ key, currentTarget }, step = 10) => {
21
+ export const setKeyboardStep = ({ key, currentTarget }, step = '10') => {
22
22
  if (key?.toLowerCase() !== 'arrowright' && key?.toLowerCase() !== 'arrowleft') return
23
23
 
24
24
  currentTarget.step = step
25
25
  }
26
26
 
27
27
  /**
28
- * @param {import("./types/index").MouseStep} event
29
- * @param {Number} step
28
+ * @param {MouseEvent & { currentTarget: HTMLInputElement | EventTarget }} event
29
+ * @param {string} step
30
30
  * @returns void
31
31
  */
32
- export const setMouseStep = ({ currentTarget }, step = 0.1) => {
32
+ export const setMouseStep = ({ currentTarget }, step = '0.1') => {
33
33
  currentTarget.step = step
34
34
  }
35
-
36
- export default {
37
- setPosition,
38
- setKeyboardStep,
39
- setMouseStep
40
- }
@@ -0,0 +1,9 @@
1
+ export interface DefaultOptions {
2
+ selector?: string
3
+ summarySelector?: string
4
+ }
5
+
6
+ export const defaultOptions: DefaultOptions
7
+ export function showDetails(selector: HTMLInputElement | HTMLElement, options?: DefaultOptions): Promise<void>
8
+ export function closeDetails(selector: HTMLInputElement | HTMLElement, options?: DefaultOptions): Promise<void>
9
+ export function toggleDetails(selector: HTMLInputElement | HTMLElement, options?: DefaultOptions): Promise<void>
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @type {import("./types/index").DefaultDetailsOptions}
2
+ * @type {import("./").DefaultOptions}
3
3
  */
4
4
  export const defaultOptions = {
5
5
  selector: 'details',
@@ -8,7 +8,7 @@ export const defaultOptions = {
8
8
 
9
9
  /**
10
10
  * @param {HTMLInputElement | HTMLElement} element
11
- * @param {import("./types/index").DefaultDetailsOptions} options
11
+ * @param {import("./").DefaultOptions} options
12
12
  * @returns Promise<void>
13
13
  */
14
14
  export const showDetails = async (element, options = {}) => {
@@ -31,7 +31,7 @@ export const showDetails = async (element, options = {}) => {
31
31
 
32
32
  /**
33
33
  * @param {HTMLInputElement | HTMLElement} element
34
- * @param {import("./types/index").DefaultDetailsOptions} options
34
+ * @param {import("./").DefaultOptions} options
35
35
  * @returns Promise<void>
36
36
  */
37
37
  export const closeDetails = async (element, options = {}) => {
@@ -56,7 +56,7 @@ export const closeDetails = async (element, options = {}) => {
56
56
 
57
57
  /**
58
58
  * @param {HTMLInputElement | HTMLElement} element
59
- * @param {import("./types/index").DefaultDetailsOptions} options
59
+ * @param {import("./").DefaultOptions} options
60
60
  * @returns Promise<void>
61
61
  */
62
62
  export const toggleDetails = async (element, options = {}) => {
@@ -75,9 +75,3 @@ export const toggleDetails = async (element, options = {}) => {
75
75
  await closeDetails(element, options)
76
76
  }
77
77
  }
78
-
79
- export default {
80
- showDetails,
81
- closeDetails,
82
- toggleDetails
83
- }
@@ -0,0 +1,30 @@
1
+ export interface DialogElement extends HTMLDialogElement {
2
+ _dialogHasEvents: boolean
3
+ }
4
+
5
+ export interface DefaultOptions {
6
+ remove?: boolean | null
7
+ closable?: boolean | null
8
+ openClass?: string
9
+ scrollbarWidthProperty?: string
10
+ }
11
+
12
+ export interface InsertDialogOptions {
13
+ selector?: string | null
14
+ class?: string | null
15
+ append?: boolean | null
16
+ show?: DefaultOptions
17
+ }
18
+
19
+ export interface FetchDialogOptions {
20
+ url: string
21
+ insert?: InsertDialogOptions
22
+ }
23
+
24
+ export const defaultOptions: DefaultOptions
25
+ export function dialogSelector(selector: string): HTMLDialogElement
26
+ export function dismissDialog(element: HTMLDialogElement, options?: DefaultOptions): Promise<void>
27
+ export function showDialog(element: DialogElement, options?: DefaultOptions): Promise<void>
28
+ export function closeDialog(element: HTMLDialogElement, options?: DefaultOptions): Promise<void>
29
+ export function insertDialog(content: string, options?: InsertDialogOptions): Promise<void>
30
+ export function fetchDialog({ url, insert }: FetchDialogOptions): Promise<void>
@@ -1,7 +1,7 @@
1
1
  import { animationsFinished } from '../../common.js'
2
2
 
3
3
  /**
4
- * @type {import("./types/index").DefaultOptions}
4
+ * @type {import("./").DefaultOptions}
5
5
  */
6
6
  export const defaultOptions = {
7
7
  openClass: 'visible',
@@ -11,22 +11,23 @@ export const defaultOptions = {
11
11
 
12
12
  /**
13
13
  * @param {string} selector.
14
+ * @return HTMLDialogElement
14
15
  */
15
16
  export const dialogSelector = selector => document.querySelectorAll(selector)[document.querySelectorAll(selector).length - 1]
16
17
 
17
18
  /**
18
19
  * Dismisses a dialog.
19
- * @param {HTMLDialogElement} selector - The dialog element to dismiss.
20
- * @param {import("./types/index").DefaultOptions} options - The options for closing the dialog.
20
+ * @param {HTMLDialogElement} element - The dialog element to dismiss.
21
+ * @param {import("./").DefaultOptions} options - The options for closing the dialog.
21
22
  * @returns Promise<void>
22
23
  */
23
- export const dismissDialog = async (selector, options = defaultOptions) => {
24
- await animationsFinished(selector)
25
- selector.inert = true
26
- selector.classList.remove(options.openClass)
27
- selector.dispatchEvent(new CustomEvent('c-dialog:dismiss'))
24
+ export const dismissDialog = async (element, options = defaultOptions) => {
25
+ await animationsFinished(element)
26
+ element.inert = true
27
+ element.classList.remove(options.openClass)
28
+ element.dispatchEvent(new CustomEvent('c-dialog:dismiss'))
28
29
 
29
- options.remove && selector.remove()
30
+ options.remove && element.remove()
30
31
 
31
32
  if (!document.querySelector('dialog[open]')) {
32
33
  document.documentElement.style.removeProperty(options.scrollbarWidthProperty)
@@ -35,11 +36,11 @@ export const dismissDialog = async (selector, options = defaultOptions) => {
35
36
 
36
37
  /**
37
38
  * Shows a dialog.
38
- * @param {import("./types/index").DialogElement} selector - The dialog element to show.
39
- * @param {import("./types/index").DefaultOptions} options - The options for showing the dialog.
39
+ * @param {HTMLDialogElement | import("./").DialogElement} element - The dialog element to show.
40
+ * @param {import("./").DefaultOptions} options - The options for showing the dialog.
40
41
  * @returns Promise<void>
41
42
  */
42
- export const showDialog = async (selector, options = {}) => {
43
+ export const showDialog = async (element, options = {}) => {
43
44
  options = {
44
45
  closable: true,
45
46
  ...defaultOptions,
@@ -48,54 +49,54 @@ export const showDialog = async (selector, options = {}) => {
48
49
 
49
50
  document.documentElement.style.setProperty(options.scrollbarWidthProperty, `${window.innerWidth - document.body.clientWidth}px`)
50
51
 
51
- if (!selector?._dialogHasEvents) {
52
- selector.addEventListener('keydown', (e) => {
52
+ if (!element?._dialogHasEvents) {
53
+ element.addEventListener('keydown', (e) => {
53
54
  if (e.key === 'Escape') {
54
55
  e.preventDefault()
55
- options.closable && closeDialog(selector, options)
56
+ options.closable && closeDialog(element, options)
56
57
  }
57
58
  })
58
59
 
59
- selector.addEventListener('click', ({ target }) => {
60
+ element.addEventListener('click', ({ target }) => {
60
61
  if (target.nodeName === 'DIALOG' && options.closable) {
61
- closeDialog(selector, options)
62
+ closeDialog(element, options)
62
63
  }
63
64
  })
64
65
 
65
- selector._dialogHasEvents = true
66
+ element._dialogHasEvents = true
66
67
  }
67
68
 
68
- selector.inert = false
69
- selector.classList.add(options.openClass)
69
+ element.inert = false
70
+ element.classList.add(options.openClass)
70
71
 
71
72
  window.HTMLDialogElement
72
- ? selector.showModal()
73
- : selector.setAttribute('open', '')
73
+ ? element.showModal()
74
+ : element.setAttribute('open', '')
74
75
  }
75
76
 
76
77
  /**
77
78
  * Closes and dismisses a dialog.
78
- * @param {HTMLDialogElement} selector - The dialog element to dismiss.
79
- * @param {import("./types/index").DefaultOptions} options - The options for closing the dialog.
79
+ * @param {HTMLDialogElement} element - The dialog element to dismiss.
80
+ * @param {import("./").DefaultOptions} options - The options for closing the dialog.
80
81
  * @returns Promise<void>
81
82
  */
82
- export const closeDialog = async (selector, options = {}) => {
83
+ export const closeDialog = async (element, options = {}) => {
83
84
  options = {
84
85
  ...defaultOptions,
85
86
  ...options
86
87
  }
87
88
 
88
89
  window.HTMLDialogElement
89
- ? selector.close()
90
- : selector.removeAttribute('open')
90
+ ? element.close()
91
+ : element.removeAttribute('open')
91
92
 
92
- await dismissDialog(selector, options)
93
+ await dismissDialog(element, options)
93
94
  }
94
95
 
95
96
  /**
96
97
  * Inserts a dialog into the DOM.
97
98
  * @param {string} content - The HTML content to insert into the dialog.
98
- * @param {import("./types/index").InsertOptions} options - The options for inserting the dialog.
99
+ * @param {import("./").InsertDialogOptions} options - The options for inserting the dialog.
99
100
  * @returns Promise<void>
100
101
  */
101
102
  export const insertDialog = async (content, options = {}) => {
@@ -109,7 +110,7 @@ export const insertDialog = async (content, options = {}) => {
109
110
  ...options
110
111
  }
111
112
 
112
- const dialog = new DOMParser().parseFromString(content, 'text/html').body.firstChild
113
+ const dialog = new DOMParser().parseFromString(content, 'text/html').body.firstElementChild
113
114
  dialog.classList.add(options.class)
114
115
 
115
116
  if (!dialogSelector(options.selector) || options.append) {
@@ -123,19 +124,10 @@ export const insertDialog = async (content, options = {}) => {
123
124
 
124
125
  /**
125
126
  * Fetches a dialog from a URL and inserts it into the DOM.
126
- * @param {import("./types/index").FetchOptions} options - The options for fetching and inserting the dialog.
127
+ * @param {import("./").FetchDialogOptions} options - The options for fetching and inserting the dialog.
127
128
  */
128
129
  export const fetchDialog = async ({ url, insert = {} }) => {
129
130
  await fetch(url, { headers: { 'X-Requested-With': 'XMLHttpRequest' } })
130
131
  .then(response => response.json())
131
132
  .then(async ({ content }) => await insertDialog(content, insert))
132
133
  }
133
-
134
- export default {
135
- defaultOptions,
136
- dismissDialog,
137
- showDialog,
138
- closeDialog,
139
- insertDialog,
140
- fetchDialog
141
- }
@@ -21,3 +21,6 @@ export interface ValidateFieldOptions {
21
21
  invalidIcon?: string
22
22
  activeClass?: string
23
23
  }
24
+
25
+ export function validateForm(event: Event | SubmitEvent, options?: ValidateFormOptions): void
26
+ export function validateField(element: HTMLElement | SubmitEvent, options?: ValidateFieldOptions): void
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @param {Event | SubmitEvent} event
3
- * @param {import("./types/index").ValidateFormOptions} options
3
+ * @param {import("./").ValidateFormOptions} options
4
4
  * @returns void
5
5
  */
6
6
  export const validateForm = (event, options = {}) => {
@@ -28,7 +28,7 @@ export const validateForm = (event, options = {}) => {
28
28
 
29
29
  /**
30
30
  * @param {HTMLElement} element
31
- * @param {import("./types/index").ValidateFieldOptions} options
31
+ * @param {import("./").ValidateFieldOptions} options
32
32
  * @returns void
33
33
  */
34
34
  export const validateField = (element, options = {}) => {
@@ -98,3 +98,8 @@ export const validateField = (element, options = {}) => {
98
98
  }
99
99
  }
100
100
  }
101
+
102
+ export default {
103
+ validateForm,
104
+ validateField
105
+ }
@@ -0,0 +1,30 @@
1
+ export interface ShowToastOptions {
2
+ visibleClass?: string
3
+ autoHide?: number | null
4
+ heightProperty?: string
5
+ close?: CloseToastOptions
6
+ }
7
+
8
+ export interface CloseToastOptions {
9
+ hiddenClass?: string
10
+ heightProperty?: string
11
+ }
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
+ export function closeToast(element: HTMLElement, options?: CloseToastOptions): Promise<void>
27
+ 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
+ export function closeToaster(element: HTMLElement, options?: CloseToastOptions): Promise<void>
@@ -2,7 +2,7 @@ import { animationsFinished, nextRepaint } from '../../common.js'
2
2
 
3
3
  /**
4
4
  * @param {HTMLElement} element
5
- * @param {import('./types/index').CloseToastOptions} options
5
+ * @param {import('./index').CloseToastOptions} options
6
6
  * @returns Promise<void>
7
7
  */
8
8
  export const closeToast = async (element, options = {}) => {
@@ -14,7 +14,7 @@ export const closeToast = async (element, options = {}) => {
14
14
 
15
15
  const toaster = element.parentElement
16
16
 
17
- element.style.setProperty(options.toastHeightProperty, `${element.offsetHeight}px`)
17
+ element.style.setProperty(options.heightProperty, `${element.offsetHeight}px`)
18
18
 
19
19
  await nextRepaint()
20
20
 
@@ -29,7 +29,7 @@ export const closeToast = async (element, options = {}) => {
29
29
 
30
30
  /**
31
31
  * @param {HTMLElement} element
32
- * @param {import('./types/index').ShowToastOptions} options
32
+ * @param {import('./').ShowToastOptions} options
33
33
  * @returns Promise<void>
34
34
  */
35
35
  export const showToast = async (element, options = {}) => {
@@ -56,7 +56,7 @@ export const showToast = async (element, options = {}) => {
56
56
 
57
57
  /**
58
58
  * @param {HTMLElement} element
59
- * @param {import('./types/index').InsertToasterOptions} options
59
+ * @param {import('./').InsertToasterOptions} options
60
60
  * @returns Promise<void>
61
61
  */
62
62
  export const insertToaster = async (element, options = {}) => {
@@ -72,7 +72,7 @@ export const insertToaster = async (element, options = {}) => {
72
72
 
73
73
  /**
74
74
  * @param {HTMLElement} element
75
- * @param {import('./types/index').InsertToastOptions} options
75
+ * @param {import('./').InsertToastOptions} options
76
76
  * @returns Promise<void>
77
77
  */
78
78
  export const insertToast = async (element, options = {}) => {
@@ -104,7 +104,7 @@ export const insertToast = async (element, options = {}) => {
104
104
 
105
105
  /**
106
106
  * @param {HTMLElement} element
107
- * @param {import('./types/index').CloseToastOptions} options
107
+ * @param {import('./').CloseToastOptions} options
108
108
  * @returns Promise<void>
109
109
  */
110
110
  export const closeToaster = (element, options = {}) => {
@@ -112,11 +112,3 @@ export const closeToaster = (element, options = {}) => {
112
112
  closeToast(toast, options)
113
113
  )
114
114
  }
115
-
116
- export default {
117
- closeToast,
118
- showToast,
119
- insertToast,
120
- insertToaster,
121
- closeToaster
122
- }
package/src/main.d.ts ADDED
File without changes
@@ -0,0 +1,19 @@
1
+ export interface SetTrackPropertyOptions {
2
+ element: HTMLElement | Element
3
+ value: string
4
+ max?: number
5
+ }
6
+
7
+ export interface SetValueOptions {
8
+ selector?: string
9
+ track?: 'start' | 'end'
10
+ }
11
+
12
+ export interface SetOutputOptions {
13
+ lang?: string
14
+ formatOptions?: Intl.NumberFormatOptions
15
+ }
16
+
17
+ export function setTrackProperty(options: SetTrackPropertyOptions, track: 'start' | 'end'): void
18
+ export function setValue(element: HTMLInputElement, options?: SetValueOptions): void
19
+ export function setOutputValue(element: HTMLInputElement, outputElement: HTMLOutputElement | Element, options?: SetOutputOptions): void
@@ -1,66 +1,59 @@
1
1
  /**
2
- * @type {import("./types/index").DefaultOptions}
3
- */
4
- export const defaultOptions = {
5
- selector: '.ui-range',
6
- track: 'start'
7
- }
8
-
9
- /**
10
- * @param {import("./types/index").TrackOptions} options
2
+ * @param {import("./").SetTrackPropertyOptions} options
11
3
  * @param {'start' | 'end'} track
12
4
  * @returns void
13
5
  */
14
- export const setTrackProperty = ({ element, value, max }, track = defaultOptions.track) => {
6
+ export const setTrackProperty = ({ element, value, max }, track = 'start') => {
15
7
  element.style.setProperty('--ui-range-track-' + track, `${(value / max * 100).toString()}%`)
16
8
  }
17
9
 
18
10
  /**
19
- * @param {HTMLInputElement} target
20
- * @param {import("./types/index").DefaultOptions} options
11
+ * @param {HTMLInputElement} element
12
+ * @param {import("./").SetValueOptions} options
21
13
  * @returns void
22
14
  */
23
- export const setValue = (target, options = {}) => {
15
+ export const setValue = (element, options = {}) => {
24
16
  const { selector, track } = {
25
- ...defaultOptions,
17
+ selector: '.ui-range',
18
+ track: 'start',
26
19
  ...options
27
20
  }
28
21
 
29
- const element = target.closest(selector)
22
+ const parentElement = element.closest(selector)
30
23
 
31
- if (!element._trackValues) {
32
- element._trackValues = {
24
+ if (!parentElement._trackValues) {
25
+ parentElement._trackValues = {
33
26
  start: 0,
34
27
  end: Infinity
35
28
  }
36
29
  }
37
30
 
38
- if (Object.keys(element._trackValues).length > 1) {
31
+ if (Object.keys(parentElement._trackValues).length > 1) {
39
32
  if (
40
- (track === 'start' && target.value < element._trackValues.end) ||
41
- (track === 'end' && element._trackValues.start < target.value)
33
+ (track === 'start' && element.value < parentElement._trackValues.end) ||
34
+ (track === 'end' && parentElement._trackValues.start < element.value)
42
35
  ) {
43
- element._trackValues[track] = Number(target.value)
36
+ parentElement._trackValues[track] = Number(element.value)
44
37
  }
45
38
 
46
- target.value = element._trackValues[track]
39
+ element.value = parentElement._trackValues[track]
47
40
  }
48
41
 
49
42
  setTrackProperty({
50
- element,
51
- value: target.value,
52
- max: target.max || 100
43
+ element: parentElement,
44
+ value: element.value,
45
+ max: Number(element.max) || 100
53
46
  }, track)
54
47
  }
55
48
 
56
49
  /**
57
- * @param {HTMLInputElement} target
58
- * @param {import("./types/index").OutputOptions} options
50
+ * @param {HTMLInputElement} element
51
+ * @param {HTMLOutputElement | Element} outputElement
52
+ * @param {import("./").SetOutputOptions} options
59
53
  * @returns void
60
54
  */
61
- export const setOutputValue = (target, options = {}) => {
62
- const { element, lang, formatOptions } = {
63
- element: null,
55
+ export const setOutputValue = (element, outputElement, options = {}) => {
56
+ options = {
64
57
  lang: document.documentElement.lang,
65
58
  formatOptions: {
66
59
  style: 'decimal',
@@ -70,12 +63,5 @@ export const setOutputValue = (target, options = {}) => {
70
63
  ...options
71
64
  }
72
65
 
73
- element.innerHTML = Number(target.value).toLocaleString(lang, formatOptions)
74
- }
75
-
76
- export default {
77
- defaultOptions,
78
- setTrackProperty,
79
- setValue,
80
- setOutputValue
66
+ outputElement.innerHTML = Number(element.value).toLocaleString(options.lang, options.formatOptions)
81
67
  }
@@ -0,0 +1 @@
1
+ export function showRipple(event: MouseEvent, element: HTMLElement): void
@@ -1,29 +1,25 @@
1
1
  /**
2
2
  * Shows a ripple effect.
3
3
  * @param {MouseEvent<HTMLElement>} event - The dialog element to dismiss.
4
- * @param {HTMLElement} selector - The options for closing the dialog.
4
+ * @param {HTMLElement} element - The options for closing the dialog.
5
5
  * @returns void
6
6
  */
7
- export const showRipple = ({ currentTarget, offsetX, offsetY }, selector = currentTarget.querySelector('.ripple')) => {
8
- if (!selector) {
7
+ export const showRipple = ({ currentTarget, offsetX, offsetY }, element = currentTarget.querySelector('.ripple')) => {
8
+ if (!element) {
9
9
  currentTarget.insertAdjacentHTML('beforeend', "<div class='ripple'></div>")
10
- selector = currentTarget.querySelector('.ripple')
10
+ element = currentTarget.querySelector('.ripple')
11
11
  }
12
12
 
13
- selector.classList.remove('animation-ripple')
13
+ element.classList.remove('animation-ripple')
14
14
 
15
- if (selector.clientWidth === 0 && selector.clientHeight === 0) {
15
+ if (element.clientWidth === 0 && element.clientHeight === 0) {
16
16
  const d = Math.max(currentTarget.offsetWidth, currentTarget.offsetHeight)
17
17
 
18
- selector.style.width = d + 'px'
19
- selector.style.height = d + 'px'
18
+ element.style.width = d + 'px'
19
+ element.style.height = d + 'px'
20
20
  }
21
21
 
22
- selector.style.top = offsetY - (selector.clientHeight / 2) + 'px'
23
- selector.style.left = offsetX - (selector.clientWidth / 2) + 'px'
24
- selector.classList.add('animation-ripple')
25
- }
26
-
27
- export default {
28
- showRipple
22
+ element.style.top = offsetY - (element.clientHeight / 2) + 'px'
23
+ element.style.left = offsetX - (element.clientWidth / 2) + 'px'
24
+ element.classList.add('animation-ripple')
29
25
  }
@@ -0,0 +1 @@
1
+ export function toggleSwap(element: HTMLElement): void
@@ -10,7 +10,3 @@ export const toggleSwap = (element) => {
10
10
  ariaVisible.ariaHidden = 'true'
11
11
  ariaHidden.ariaHidden = 'false'
12
12
  }
13
-
14
- export default {
15
- toggleSwap
16
- }
@@ -1,4 +1,4 @@
1
- import winduum from './plugin/tailwind.js'
1
+ import winduum from './plugin/index.js'
2
2
  import containerQueries from '@tailwindcss/container-queries'
3
3
  import animate from 'tailwindcss-animate'
4
4
 
package/types/index.d.ts CHANGED
@@ -1,20 +1,176 @@
1
+ declare module 'winduum' {
2
+ import type { Plugin } from 'tailwindcss/types/config';
3
+ export interface PluginOptions {
4
+ colors?: string[]
5
+ fontFamily?: string[],
6
+ fontWeight?: string[],
7
+ ease?: string[],
8
+ zIndex?: string[],
9
+ fontSize?: string[],
10
+ spacing?: string[],
11
+ borderRadius?: string[],
12
+ animations?: string[],
13
+ mask?: string[],
14
+ screens?: {
15
+ [key: string]: string
16
+ },
17
+ settings?: {
18
+ rgb?: boolean,
19
+ colorMix?: boolean
20
+ }
21
+ }
22
+
23
+ export const defaultConfig: PluginOptions
24
+
25
+ export default function createPlugin(userConfig: PluginOptions): Plugin
26
+ }
27
+
28
+ declare module 'winduum/src/components/compare' {
29
+ export interface SetPositionOptions {
30
+ selector?: string
31
+ positionProperty?: string
32
+ }
33
+
34
+ export function setPosition(event: Event, options?: SetPositionOptions): void
35
+ export function setKeyboardStep(event: KeyboardEvent, step?: string): void
36
+ export function setMouseStep(event: MouseEvent, step?: string): void
37
+ }
38
+
39
+ declare module 'winduum/src/components/details' {
40
+ export interface DefaultOptions {
41
+ selector?: string
42
+ summarySelector?: string
43
+ }
44
+
45
+ export const defaultOptions: DefaultOptions
46
+ export function showDetails(selector: HTMLInputElement | HTMLElement, options?: DefaultOptions): Promise<void>
47
+ export function closeDetails(selector: HTMLInputElement | HTMLElement, options?: DefaultOptions): Promise<void>
48
+ export function toggleDetails(selector: HTMLInputElement | HTMLElement, options?: DefaultOptions): Promise<void>
49
+ }
50
+
1
51
  declare module 'winduum/src/components/dialog' {
2
- export const defaultOptions: import('../src/components/dialog/types').DefaultOptions
3
- export function dialogSelector(selector: HTMLDialogElement): any;
4
- export function dismissDialog(selector: HTMLDialogElement, options?: import('../src/components/dialog/types').DefaultOptions): Promise<void>;
5
- export function showDialog(selector: any, options?: import('../src/components/dialog/types').DefaultOptions): Promise<void>;
6
- export function closeDialog(selector: HTMLDialogElement, options?: import('../src/components/dialog/types').DefaultOptions): Promise<void>;
7
- export function insertDialog(content: string, options?: import('../src/components/dialog/types').InsertOptions): Promise<void>;
8
- export function fetchDialog({ url, insert }: import('../src/components/dialog/types').FetchOptions): Promise<void>;
9
-
10
- namespace _default {
11
- export { defaultOptions };
12
- export { dismissDialog };
13
- export { showDialog };
14
- export { closeDialog };
15
- export { insertDialog };
16
- export { fetchDialog };
17
- }
18
-
19
- export default _default;
52
+ export interface DialogElement extends HTMLDialogElement {
53
+ _dialogHasEvents: boolean
54
+ }
55
+
56
+ export interface DefaultOptions {
57
+ remove?: boolean | null
58
+ closable?: boolean | null
59
+ openClass?: string
60
+ scrollbarWidthProperty?: string
61
+ }
62
+
63
+ export interface InsertDialogOptions {
64
+ selector?: string | null
65
+ class?: string | null
66
+ append?: boolean | null
67
+ show?: DefaultOptions
68
+ }
69
+
70
+ export interface FetchDialogOptions {
71
+ url: string
72
+ insert?: InsertDialogOptions
73
+ }
74
+
75
+ export const defaultOptions: DefaultOptions
76
+ export function dialogSelector(selector: string): HTMLDialogElement
77
+ export function dismissDialog(element: HTMLDialogElement, options?: DefaultOptions): Promise<void>
78
+ export function showDialog(element: DialogElement, options?: DefaultOptions): Promise<void>
79
+ export function closeDialog(element: HTMLDialogElement, options?: DefaultOptions): Promise<void>
80
+ export function insertDialog(content: string, options?: InsertDialogOptions): Promise<void>
81
+ export function fetchDialog({ url, insert }: FetchDialogOptions): Promise<void>
82
+ }
83
+
84
+ declare module 'winduum/src/components/form' {
85
+ export interface ValidateFormOptions {
86
+ validateSelectors?: string
87
+ validateOptions?: ValidateFieldOptions
88
+ submitterLoadingClass?: string
89
+ }
90
+
91
+ export interface ValidateFieldOptions {
92
+ validate?: boolean
93
+ selector?: string
94
+ ignoreMatch?: string
95
+ validitySelector?: string
96
+ infoParentSelector?: string
97
+ infoSelector?: string
98
+ infoContent?: string
99
+ endParentSelector?: string
100
+ endSelector?: string
101
+ endContent?: string
102
+ validClass?: string
103
+ validIcon?: string
104
+ invalidClass?: string
105
+ invalidIcon?: string
106
+ activeClass?: string
107
+ }
108
+
109
+ export function validateForm(event: Event | SubmitEvent, options?: ValidateFormOptions): void
110
+ export function validateField(element: HTMLElement | SubmitEvent, options?: ValidateFieldOptions): void
20
111
  }
112
+
113
+ declare module 'winduum/src/components/toaster' {
114
+ export interface ShowToastOptions {
115
+ visibleClass?: string
116
+ autoHide?: number | null
117
+ heightProperty?: string
118
+ close?: CloseToastOptions
119
+ }
120
+
121
+ export interface CloseToastOptions {
122
+ hiddenClass?: string
123
+ heightProperty?: string
124
+ }
125
+
126
+ export interface InsertToasterOptions {
127
+ classes?: string
128
+ }
129
+
130
+ export interface InsertToastOptions {
131
+ classes?: string
132
+ title?: string
133
+ text?: string
134
+ start?: string
135
+ end?: string
136
+ show?: ShowToastOptions
137
+ }
138
+
139
+ export function closeToast(element: HTMLElement, options?: CloseToastOptions): Promise<void>
140
+ export function showToast(element: HTMLElement, options?: ShowToastOptions): Promise<void>
141
+ export function insertToaster(element: HTMLElement, options?: InsertToasterOptions): Promise<void>
142
+ export function insertToast(element: HTMLElement, options?: InsertToastOptions): Promise<void>
143
+ export function closeToaster(element: HTMLElement, options?: CloseToastOptions): Promise<void>
144
+ }
145
+
146
+ declare module 'winduum/src/ui/range' {
147
+ export interface SetTrackPropertyOptions {
148
+ element: HTMLElement | Element
149
+ value: string
150
+ max?: number
151
+ }
152
+
153
+ export interface SetValueOptions {
154
+ selector?: string
155
+ track?: 'start' | 'end'
156
+ }
157
+
158
+ export interface SetOutputOptions {
159
+ lang?: string
160
+ formatOptions?: Intl.NumberFormatOptions
161
+ }
162
+
163
+ export function setTrackProperty(options: SetTrackPropertyOptions, track: 'start' | 'end'): void
164
+ export function setValue(element: HTMLInputElement, options?: SetValueOptions): void
165
+ export function setOutputValue(element: HTMLInputElement, outputElement: HTMLOutputElement | Element, options?: SetOutputOptions): void
166
+ }
167
+
168
+ declare module 'winduum/src/utilities/ripple' {
169
+ export function showRipple(event: MouseEvent, element: HTMLElement): void
170
+ }
171
+
172
+ declare module 'winduum/src/utilities/swap' {
173
+ export function toggleSwap(element: HTMLElement): void
174
+ }
175
+
176
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,70 @@
1
+ {
2
+ "version": 3,
3
+ "file": "index.d.ts",
4
+ "names": [
5
+ "PluginOptions",
6
+ "defaultConfig",
7
+ "SetPositionOptions",
8
+ "setPosition",
9
+ "setKeyboardStep",
10
+ "setMouseStep",
11
+ "DefaultOptions",
12
+ "defaultOptions",
13
+ "showDetails",
14
+ "closeDetails",
15
+ "toggleDetails",
16
+ "DialogElement",
17
+ "InsertDialogOptions",
18
+ "FetchDialogOptions",
19
+ "dialogSelector",
20
+ "dismissDialog",
21
+ "showDialog",
22
+ "closeDialog",
23
+ "insertDialog",
24
+ "fetchDialog",
25
+ "ValidateFormOptions",
26
+ "ValidateFieldOptions",
27
+ "validateForm",
28
+ "validateField",
29
+ "ShowToastOptions",
30
+ "CloseToastOptions",
31
+ "InsertToasterOptions",
32
+ "InsertToastOptions",
33
+ "closeToast",
34
+ "showToast",
35
+ "insertToaster",
36
+ "insertToast",
37
+ "closeToaster",
38
+ "SetTrackPropertyOptions",
39
+ "SetValueOptions",
40
+ "SetOutputOptions",
41
+ "setTrackProperty",
42
+ "setValue",
43
+ "setOutputValue",
44
+ "showRipple",
45
+ "toggleSwap"
46
+ ],
47
+ "sources": [
48
+ "../plugin/index.d.ts",
49
+ "../src/components/compare/index.d.ts",
50
+ "../src/components/details/index.d.ts",
51
+ "../src/components/dialog/index.d.ts",
52
+ "../src/components/form/index.d.ts",
53
+ "../src/components/toaster/index.d.ts",
54
+ "../src/ui/range/index.d.ts",
55
+ "../src/utilities/ripple/index.d.ts",
56
+ "../src/utilities/swap/index.d.ts"
57
+ ],
58
+ "sourcesContent": [
59
+ null,
60
+ null,
61
+ null,
62
+ null,
63
+ null,
64
+ null,
65
+ null,
66
+ null,
67
+ null
68
+ ],
69
+ "mappings": ";;kBAEiBA,aAAaA;;;;;;;;;;;;;;;;;;;;cAoBjBC,aAAaA;;;;;;kBCtBTC,kBAAkBA;;;;;iBAKnBC,WAAWA;iBACXC,eAAeA;iBACfC,YAAYA;;;;kBCPXC,cAAcA;;;;;cAKlBC,cAAcA;iBACXC,WAAWA;iBACXC,YAAYA;iBACZC,aAAaA;;;;kBCRZC,aAAaA;;;;kBAIbL,cAAcA;;;;;;;kBAOdM,mBAAmBA;;;;;;;kBAOnBC,kBAAkBA;;;;;cAKtBN,cAAcA;iBACXO,cAAcA;iBACdC,aAAaA;iBACbC,UAAUA;iBACVC,WAAWA;iBACXC,YAAYA;iBACZC,WAAWA;;;;kBC7BVC,mBAAmBA;;;;;;kBAMnBC,oBAAoBA;;;;;;;;;;;;;;;;;;iBAkBrBC,YAAYA;iBACZC,aAAaA;;;;kBCzBZC,gBAAgBA;;;;;;;kBAOhBC,iBAAiBA;;;;;kBAKjBC,oBAAoBA;;;;kBAIpBC,kBAAkBA;;;;;;;;;iBASnBC,UAAUA;iBACVC,SAASA;iBACTC,aAAaA;iBACbC,WAAWA;iBACXC,YAAYA;;;;kBC7BXC,uBAAuBA;;;;;;kBAMvBC,eAAeA;;;;;kBAKfC,gBAAgBA;;;;;iBAKjBC,gBAAgBA;iBAChBC,QAAQA;iBACRC,cAAcA;;;;iBClBdC,UAAUA;;;;iBCAVC,UAAUA"
70
+ }
@@ -1,17 +0,0 @@
1
- export interface Position {
2
- currentTarget: HTMLInputElement | EventTarget
3
- }
4
-
5
- export interface KeyboardStep {
6
- currentTarget: HTMLInputElement | EventTarget
7
- key: string
8
- }
9
-
10
- export interface MouseStep {
11
- currentTarget: HTMLInputElement | EventTarget
12
- }
13
-
14
- export interface PositionOptions {
15
- selector?: string
16
- positionProperty?: string
17
- }
@@ -1,4 +0,0 @@
1
- export interface DefaultDetailsOptions {
2
- selector?: string
3
- summarySelector?: string
4
- }
@@ -1,22 +0,0 @@
1
- export interface DialogElement extends HTMLDialogElement {
2
- _dialogHasEvents: boolean
3
- }
4
-
5
- export interface DefaultOptions {
6
- remove?: boolean | null
7
- closable?: boolean | null
8
- openClass?: string
9
- scrollbarWidthProperty?: string
10
- }
11
-
12
- export interface InsertOptions {
13
- selector?: string | null
14
- class?: string | null
15
- append?: boolean | null
16
- show?: DefaultOptions
17
- }
18
-
19
- export interface FetchOptions {
20
- url: string
21
- insert?: InsertOptions
22
- }
@@ -1,25 +0,0 @@
1
- export interface ShowToastOptions {
2
- visibleClass?: string
3
- autoHide?: number | null
4
- heightProperty?: string
5
- close?: CloseToastOptions
6
- }
7
-
8
- export interface CloseToastOptions {
9
- hiddenClass?: string
10
- heightProperty?: string
11
- }
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
-
@@ -1,16 +0,0 @@
1
- export interface DefaultOptions {
2
- selector?: string
3
- track?: 'start' | 'end'
4
- }
5
-
6
- export interface OutputOptions {
7
- element?: HTMLOutputElement
8
- lang?: string
9
- formatOptions?: Intl.NumberFormatOptions
10
- }
11
-
12
- export interface TrackOptions {
13
- element: HTMLElement | Element
14
- value: string
15
- max?: number
16
- }