@itenthusiasm/custom-elements 0.0.1
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/Combobox/Combobox.css +100 -0
- package/Combobox/ComboboxField.d.ts +243 -0
- package/Combobox/ComboboxField.js +1182 -0
- package/Combobox/ComboboxListbox.d.ts +15 -0
- package/Combobox/ComboboxListbox.js +34 -0
- package/Combobox/ComboboxOption.d.ts +39 -0
- package/Combobox/ComboboxOption.js +144 -0
- package/Combobox/README.md +17 -0
- package/Combobox/SelectEnhancer.d.ts +27 -0
- package/Combobox/SelectEnhancer.js +185 -0
- package/Combobox/index.d.ts +4 -0
- package/Combobox/index.js +4 -0
- package/Combobox/types/dom.d.ts +10 -0
- package/Combobox/types/helpers.d.ts +7 -0
- package/Combobox/types/preact.d.ts +43 -0
- package/Combobox/types/react.d.ts +54 -0
- package/Combobox/types/solid.d.ts +45 -0
- package/Combobox/types/svelte.d.ts +43 -0
- package/Combobox/types/vue.d.ts +93 -0
- package/LICENSE +16 -0
- package/README.md +3 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +38 -0
- package/utils/dom.d.ts +10 -0
- package/utils/dom.js +13 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EventHandler } from "svelte/elements";
|
|
2
|
+
import type { SelectEnhancer, ComboboxField, ComboboxListbox, ComboboxOption } from "../index.js";
|
|
3
|
+
|
|
4
|
+
declare module "svelte/elements" {
|
|
5
|
+
interface SvelteHTMLElements {
|
|
6
|
+
"select-enhancer": HTMLSelectEnhancerAttributes;
|
|
7
|
+
"combobox-field": HTMLComboboxFieldAttributes<ComboboxField>;
|
|
8
|
+
"combobox-listbox": HTMLAttributes<ComboboxListbox>;
|
|
9
|
+
"combobox-option": HTMLComboboxOptionAttributes;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface HTMLSelectEnhancerAttributes extends HTMLAttributes<SelectEnhancer> {
|
|
13
|
+
comboboxtag?: SelectEnhancer["comboboxTag"] | null;
|
|
14
|
+
listboxtag?: SelectEnhancer["listboxTag"] | null;
|
|
15
|
+
optiontag?: SelectEnhancer["optionTag"] | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface HTMLComboboxFieldAttributes<T extends EventTarget> extends HTMLAttributes<T> {
|
|
19
|
+
disabled?: ComboboxField["disabled"] | null;
|
|
20
|
+
filter?: ComboboxField["filter"] | null;
|
|
21
|
+
filtermethod?: ComboboxField["filterMethod"] | null;
|
|
22
|
+
form?: string | null;
|
|
23
|
+
name?: ComboboxField["name"] | null;
|
|
24
|
+
nomatchesmessage?: ComboboxField["noMatchesMessage"] | null;
|
|
25
|
+
required?: ComboboxField["required"] | null;
|
|
26
|
+
valueis?: ComboboxField["valueIs"] | null;
|
|
27
|
+
valuemissingerror?: ComboboxField["valueMissingError"] | null;
|
|
28
|
+
|
|
29
|
+
"on:filterchange"?: EventHandler<Event, T> | null;
|
|
30
|
+
onfilterchange?: EventHandler<Event, T> | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- This is required to support ComboboxField attrs
|
|
34
|
+
interface HTMLSelectAttributes
|
|
35
|
+
extends Omit<HTMLComboboxFieldAttributes<HTMLSelectElement>, "onfilterchange" | "on:filterchange"> {}
|
|
36
|
+
|
|
37
|
+
interface HTMLComboboxOptionAttributes extends HTMLAttributes<ComboboxOption> {
|
|
38
|
+
defaultSelected?: ComboboxOption["defaultSelected"] | null;
|
|
39
|
+
disabled?: ComboboxOption["disabled"] | null;
|
|
40
|
+
selected?: ComboboxOption["selected"] | null;
|
|
41
|
+
value?: ComboboxOption["value"] | null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { HTMLAttributes, PublicProps, EmitFn } from "vue";
|
|
2
|
+
import type { SelectEnhancer, ComboboxField, ComboboxListbox, ComboboxOption } from "../index.js";
|
|
3
|
+
|
|
4
|
+
declare module "vue" {
|
|
5
|
+
// Helper Types
|
|
6
|
+
type Booleanish = boolean | "true" | "false";
|
|
7
|
+
type VueEmitMap<T extends GlobalEventHandlersEventMap> = EmitFn<{ [K in keyof T]: (event: T[K]) => void }>;
|
|
8
|
+
interface VueGlobalHTMLAttributes extends HTMLAttributes, Omit<PublicProps, "class" | "style"> {}
|
|
9
|
+
|
|
10
|
+
/* -------------------- Select Enhancer -------------------- */
|
|
11
|
+
interface SelectEnhancerHTMLAttributes extends VueGlobalHTMLAttributes {
|
|
12
|
+
comboboxtag?: SelectEnhancer["comboboxTag"];
|
|
13
|
+
listboxtag?: SelectEnhancer["listboxTag"];
|
|
14
|
+
optiontag?: SelectEnhancer["optionTag"];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface SelectEnhancerVueSFCType extends SelectEnhancer {
|
|
18
|
+
/** @deprecated Only for use by Vue's templating language */
|
|
19
|
+
$props: SelectEnhancerHTMLAttributes;
|
|
20
|
+
|
|
21
|
+
/** @deprecated Only for use by Vue's templating language */
|
|
22
|
+
$emit: VueEmitMap<HTMLElementEventMap>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* -------------------- Combobox Field -------------------- */
|
|
26
|
+
interface ComboboxFieldHTMLAttributes extends VueGlobalHTMLAttributes {
|
|
27
|
+
disabled?: Booleanish;
|
|
28
|
+
filter?: ComboboxField["filter"];
|
|
29
|
+
filtermethod?: ComboboxField["filterMethod"];
|
|
30
|
+
form?: string;
|
|
31
|
+
name?: ComboboxField["name"];
|
|
32
|
+
nomatchesmessage?: ComboboxField["noMatchesMessage"];
|
|
33
|
+
required?: Booleanish;
|
|
34
|
+
valueis?: ComboboxField["valueIs"];
|
|
35
|
+
valuemissingerror?: ComboboxField["valueMissingError"];
|
|
36
|
+
onFilterchange?: (payload: Event) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface ComboboxFieldVueSFCType extends ComboboxField {
|
|
40
|
+
/** @deprecated Only for use by Vue's templating language */
|
|
41
|
+
$props: ComboboxFieldHTMLAttributes;
|
|
42
|
+
|
|
43
|
+
/** @deprecated Only for use by Vue's templating language */
|
|
44
|
+
$emit: VueEmitMap<ComboboxFieldEvents>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ComboboxFieldEvents extends HTMLElementEventMap {
|
|
48
|
+
filterchange: Event;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- This is required to support ComboboxField attrs
|
|
52
|
+
interface SelectHTMLAttributes extends Omit<ComboboxFieldHTMLAttributes, "onFilterchange"> {}
|
|
53
|
+
|
|
54
|
+
/* -------------------- Combobox Listbox -------------------- */
|
|
55
|
+
interface ComboboxListboxVueSFCType extends ComboboxListbox {
|
|
56
|
+
/** @deprecated Only for use by Vue's templating language */
|
|
57
|
+
$props: VueGlobalHTMLAttributes;
|
|
58
|
+
|
|
59
|
+
/** @deprecated Only for use by Vue's templating language */
|
|
60
|
+
$emit: VueEmitMap<HTMLElementEventMap>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* -------------------- Combobox Option -------------------- */
|
|
64
|
+
interface ComboboxOptionHTMLAttributes extends VueGlobalHTMLAttributes {
|
|
65
|
+
defaultSelected?: ComboboxOption["defaultSelected"];
|
|
66
|
+
disabled?: ComboboxOption["disabled"];
|
|
67
|
+
selected?: ComboboxOption["selected"];
|
|
68
|
+
value?: ComboboxOption["value"];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface ComboboxOptionVueSFCType extends ComboboxOption {
|
|
72
|
+
/** @deprecated Only for use by Vue's templating language */
|
|
73
|
+
$props: ComboboxOptionHTMLAttributes;
|
|
74
|
+
|
|
75
|
+
/** @deprecated Only for use by Vue's templating language */
|
|
76
|
+
$emit: VueEmitMap<HTMLElementEventMap>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* -------------------- Register Elements -------------------- */
|
|
80
|
+
interface GlobalComponents {
|
|
81
|
+
"select-enhancer": new () => SelectEnhancerVueSFCType;
|
|
82
|
+
"combobox-field": new () => ComboboxFieldVueSFCType;
|
|
83
|
+
"combobox-listbox": new () => ComboboxListboxVueSFCType;
|
|
84
|
+
"combobox-option": new () => ComboboxOptionVueSFCType;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface IntrinsicElementAttributes {
|
|
88
|
+
"select-enhancer": SelectEnhancerHTMLAttributes;
|
|
89
|
+
"combobox-field": ComboboxFieldHTMLAttributes;
|
|
90
|
+
"combobox-listbox": VueGlobalHTMLAttributes;
|
|
91
|
+
"combobox-option": ComboboxOptionHTMLAttributes;
|
|
92
|
+
}
|
|
93
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright 2023 Isaiah Thomason
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
4
|
+
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
6
|
+
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
7
|
+
subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
10
|
+
portions of the Software.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
13
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
14
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
15
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
16
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Combobox/index.js";
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Combobox/index.js";
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@itenthusiasm/custom-elements",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"description": "Robust, accessible, and progressively-enhanceable Web Components for common developer needs",
|
|
8
|
+
"author": "Isaiah Thomason",
|
|
9
|
+
"homepage": "https://github.com/ITenthusiasm/custom-elements#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/ITenthusiasm/custom-elements.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/ITenthusiasm/custom-elements/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"itenthusiasm",
|
|
19
|
+
"web",
|
|
20
|
+
"components",
|
|
21
|
+
"custom",
|
|
22
|
+
"elements",
|
|
23
|
+
"ui",
|
|
24
|
+
"form",
|
|
25
|
+
"combobox",
|
|
26
|
+
"html",
|
|
27
|
+
"js",
|
|
28
|
+
"framework-agnostic",
|
|
29
|
+
"progressive-enhancement"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
"./*.js": "./*.js",
|
|
33
|
+
"./*.d.ts": {
|
|
34
|
+
"types": "./*.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./*": "./*/index.js"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/utils/dom.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the `attribute` of an `element` to the specified `value` _if_ the element's attribute
|
|
3
|
+
* did not already have that value. Used to avoid redundantly triggering `MutationObserver`s.
|
|
4
|
+
*
|
|
5
|
+
* @param {HTMLElement} element
|
|
6
|
+
* @param {string} attribute
|
|
7
|
+
* @param {string} value
|
|
8
|
+
* @returns {void}
|
|
9
|
+
*/
|
|
10
|
+
export function setAttributeFor(element: HTMLElement, attribute: string, value: string): void;
|
package/utils/dom.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the `attribute` of an `element` to the specified `value` _if_ the element's attribute
|
|
3
|
+
* did not already have that value. Used to avoid redundantly triggering `MutationObserver`s.
|
|
4
|
+
*
|
|
5
|
+
* @param {HTMLElement} element
|
|
6
|
+
* @param {string} attribute
|
|
7
|
+
* @param {string} value
|
|
8
|
+
* @returns {void}
|
|
9
|
+
*/
|
|
10
|
+
export function setAttributeFor(element, attribute, value) {
|
|
11
|
+
if (element.getAttribute(attribute) === value) return;
|
|
12
|
+
element.setAttribute(attribute, value);
|
|
13
|
+
}
|