@aquera/nile-elements 0.1.59-beta-1.1 → 0.1.59
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/README.md +2 -6
- package/demo/index.html +33 -150
- package/dist/index.js +4 -5
- package/dist/internal/form.cjs.js +1 -1
- package/dist/internal/form.cjs.js.map +1 -1
- package/dist/internal/form.esm.js +1 -1
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.cjs.js +1 -1
- package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.esm.js +1 -1
- package/dist/nile-option/nile-option.esm.js +2 -2
- package/dist/nile-virtual-select/renderer.cjs.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
- package/dist/nile-virtual-select/renderer.esm.js +0 -1
- package/dist/src/internal/form.js +2 -2
- package/dist/src/internal/form.js.map +1 -1
- package/dist/src/nile-option/nile-option.css.js +1 -1
- package/dist/src/nile-option/nile-option.css.js.map +1 -1
- package/dist/src/nile-option/nile-option.d.ts +0 -3
- package/dist/src/nile-option/nile-option.js +0 -14
- package/dist/src/nile-option/nile-option.js.map +1 -1
- package/dist/src/nile-virtual-select/renderer.js +0 -1
- package/dist/src/nile-virtual-select/renderer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/internal/form.ts +2 -2
- package/src/nile-option/nile-option.css.ts +1 -1
- package/src/nile-option/nile-option.ts +0 -12
- package/src/nile-virtual-select/renderer.ts +0 -1
- package/vscode-html-custom-data.json +1 -6
package/README.md
CHANGED
@@ -79,8 +79,8 @@ To run a local development server that serves the basic demo located in `demo/in
|
|
79
79
|
|
80
80
|
In this section, you can find the updates for each release of `nile-elements`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
|
81
81
|
|
82
|
-
#### Version 0.1.59
|
83
|
-
- Nile
|
82
|
+
#### Version 0.1.59
|
83
|
+
- Nile Select: Virtual scroll feature added [UIF-734]
|
84
84
|
|
85
85
|
#### Version 0.1.58
|
86
86
|
- Nile Table: Column resize feature added [UIF-889]
|
@@ -103,10 +103,6 @@ In this section, you can find the updates for each release of `nile-elements`. I
|
|
103
103
|
#### Version 0.1.53
|
104
104
|
- Nile Code Editor: Tab Completion, Custom Icon Support, and Suggestion Styling [UIF-887]
|
105
105
|
|
106
|
-
#### Version 0.1.52-beta-1.2
|
107
|
-
- Nile virtual Select: Virtual select feature added
|
108
|
-
- Dependency Nile 0.3.71-beta-1.2
|
109
|
-
|
110
106
|
#### Version 0.1.51
|
111
107
|
- Icon Addition: column-add icon is added [UIF-874]
|
112
108
|
|
package/demo/index.html
CHANGED
@@ -1,156 +1,39 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html lang="en-GB">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<link rel="stylesheet" href="variables_v2.css" id="stylesheet" />
|
6
|
-
<link rel="stylesheet" href="index.css" />
|
7
|
-
<script type="module" src="index.js"></script>
|
8
|
-
</head>
|
9
|
-
<style>
|
10
|
-
.component-viewer {
|
11
|
-
margin: 200px;
|
12
|
-
}
|
13
|
-
</style>
|
14
3
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
>
|
42
|
-
</nile-select>
|
43
|
-
|
44
|
-
<br />
|
45
|
-
<nile-divider></nile-divider>
|
46
|
-
<br />
|
47
|
-
|
48
|
-
<div>Virtual Select - Enhanced (renderItemConfig)</div>
|
49
|
-
<nile-select
|
50
|
-
class="virtual-scroll-enhanced"
|
51
|
-
placeholder="Please Select"
|
52
|
-
searchEnabled="true"
|
53
|
-
enableVirtualScroll="true"
|
54
|
-
>
|
55
|
-
</nile-select>
|
56
|
-
<br />
|
57
|
-
<nile-select
|
58
|
-
multiple
|
59
|
-
class="virtual-scroll-enhanced-multiple"
|
60
|
-
placeholder="Please Select"
|
61
|
-
searchEnabled="true"
|
62
|
-
enableVirtualScroll="true"
|
63
|
-
>
|
64
|
-
</nile-select>
|
65
|
-
|
66
|
-
<br />
|
67
|
-
<nile-divider></nile-divider>
|
68
|
-
<br />
|
69
|
-
|
70
|
-
<div>Virtual Select - Complex Data Structure</div>
|
71
|
-
<nile-select
|
72
|
-
class="virtual-scroll-complex"
|
73
|
-
placeholder="Please Select"
|
74
|
-
searchEnabled="true"
|
75
|
-
enableVirtualScroll="true"
|
76
|
-
>
|
77
|
-
</nile-select>
|
4
|
+
<head>
|
5
|
+
<meta charset="utf-8" />
|
6
|
+
<link rel="stylesheet" href="variables_v2.css" id="stylesheet" />
|
7
|
+
<link rel="stylesheet" href="index.css" />
|
8
|
+
<script type="module" src="index.js"></script>
|
9
|
+
</head>
|
10
|
+
<style>
|
11
|
+
.flex-container {
|
12
|
+
display: flex;
|
13
|
+
flex-wrap: wrap;
|
14
|
+
gap: 30px;
|
15
|
+
padding: 0;
|
16
|
+
margin: 0;
|
17
|
+
border: 1px solid silver;
|
18
|
+
height: 900px;
|
19
|
+
}
|
20
|
+
|
21
|
+
nile-button {
|
22
|
+
flex: 0 0 auto;
|
23
|
+
height: 38px;
|
24
|
+
}
|
25
|
+
</style>
|
26
|
+
|
27
|
+
<body>
|
28
|
+
<div style="padding: 30px;">
|
29
|
+
<nile-progress-bar value="80"></nile-progress-bar>
|
78
30
|
</div>
|
79
|
-
<
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
// Basic data structure
|
88
|
-
const options = Array.from({ length: 1000 }, (_, i) => ({
|
89
|
-
value: `option-${i + 1}`,
|
90
|
-
label: `Option ${i + 1}`,
|
91
|
-
}));
|
92
|
-
|
93
|
-
|
94
|
-
// Enhanced data structure with more fields
|
95
|
-
const enhancedOptions = Array.from({ length: 1000 }, (_, i) => ({
|
96
|
-
id: i + 1,
|
97
|
-
firstName: `User${i + 1}`,
|
98
|
-
lastName: `Name${i + 1}`,
|
99
|
-
email: `user${i + 1}@example.com`,
|
100
|
-
department: `Dept${Math.floor(i / 100) + 1}`,
|
101
|
-
displayName: `User${i + 1} Name${i + 1}`,
|
102
|
-
value: `user-${i + 1}`
|
103
|
-
}));
|
104
|
-
|
105
|
-
// Complex data structure
|
106
|
-
const complexOptions = Array.from({ length: 1000 }, (_, i) => ({
|
107
|
-
code: `CODE-${String(i + 1).padStart(3, '0')}`,
|
108
|
-
name: `Product ${i + 1}`,
|
109
|
-
category: `Category ${Math.floor(i / 50) + 1}`,
|
110
|
-
description: `This is a detailed description for product ${i + 1}`,
|
111
|
-
price: Math.floor(Math.random() * 1000) + 100,
|
112
|
-
value: `product-${i + 1}`
|
113
|
-
}));
|
114
|
-
|
115
|
-
// Basic example
|
116
|
-
const e = document.querySelector('nile-select.virtual-scroll');
|
117
|
-
e.data = options;
|
118
|
-
|
119
|
-
const me = document.querySelector('nile-select.virtual-scroll-multiple');
|
120
|
-
me.renderItemConfig = {
|
121
|
-
getDisplayText: (item) => item.label
|
122
|
-
};
|
123
|
-
me.data = options;
|
124
|
-
me.value = ['option-2', 'option-4'];
|
125
|
-
|
126
|
-
// Enhanced examples using renderItemConfig (new way)
|
127
|
-
const enhanced = document.querySelector('nile-select.virtual-scroll-enhanced');
|
128
|
-
enhanced.renderItemConfig = {
|
129
|
-
getDisplayText: (item) => `${item.firstName} ${item.lastName}`,
|
130
|
-
getValue: (item) => item.value,
|
131
|
-
getSearchText: (item) => `${item.firstName} ${item.lastName} ${item.email} ${item.department}`
|
132
|
-
};
|
133
|
-
enhanced.data = enhancedOptions;
|
134
|
-
|
135
|
-
const enhancedMultiple = document.querySelector('nile-select.virtual-scroll-enhanced-multiple');
|
136
|
-
enhancedMultiple.renderItemConfig = {
|
137
|
-
getDisplayText: (item) => `${item.firstName} ${item.lastName}`,
|
138
|
-
getValue: (item) => item.value,
|
139
|
-
getSearchText: (item) => `${item.firstName} ${item.lastName} ${item.email} ${item.department}`
|
140
|
-
};
|
141
|
-
enhancedMultiple.data = enhancedOptions;
|
142
|
-
enhancedMultiple.value = ['user-2', 'user-4', 'user-6'];
|
31
|
+
<div style="padding: 30px;">
|
32
|
+
<nile-circular-progressbar content="text"></nile-circular-progressbar>
|
33
|
+
<nile-circular-progressbar value="80" size="60"></nile-circular-progressbar>
|
34
|
+
<nile-circular-progressbar></nile-circular-progressbar>
|
35
|
+
<nile-circular-progressbar value="30" content=" "></nile-circular-progressbar>
|
36
|
+
</div>
|
37
|
+
</body>
|
143
38
|
|
144
|
-
|
145
|
-
// Complex example with different display, value, and search text
|
146
|
-
const complex = document.querySelector('nile-select.virtual-scroll-complex');
|
147
|
-
complex.renderItemConfig = {
|
148
|
-
getDisplayText: (item) => `${item.name} (${item.code}) - $${item.price}`,
|
149
|
-
getValue: (item) => item.value,
|
150
|
-
getSearchText: (item) => `${item.name} ${item.category} ${item.description}`
|
151
|
-
};
|
152
|
-
complex.data = complexOptions;
|
153
|
-
|
154
|
-
</script>
|
155
|
-
</body>
|
156
39
|
</html>
|
package/dist/index.js
CHANGED
@@ -110,7 +110,7 @@ const Te=1,Oe=2,ye=3,de=4,he=e=>(...t)=>({_$litDirective$:e,values:t});let Ae=cl
|
|
110
110
|
.nds-icon--push {
|
111
111
|
margin-right: 12px;
|
112
112
|
}
|
113
|
-
`,e([ge({type:String,reflect:!0})],we.prototype,"set",void 0),e([ge({type:String,reflect:!0})],we.prototype,"name",void 0),e([ge({type:String,reflect:!0})],we.prototype,"description",void 0),e([ge({type:String,reflect:!0})],we.prototype,"method",void 0),e([ge({type:String})],we.prototype,"customSvgPath",void 0),e([ge({type:String,reflect:!0})],we.prototype,"size",void 0),e([je()],we.prototype,"_svg",void 0),e([ge({type:String})],we.prototype,"title",void 0),e([ge({reflect:!0})],we.prototype,"color",void 0),e([ge({type:Boolean})],we.prototype,"push",void 0),e([ge({reflect:!0})],we.prototype,"frame",void 0),we=e([ae("nile-icon")],we);const me=new WeakMap,Ue=new WeakMap,Ce=new WeakSet,be=new WeakMap;class fe{constructor(e,t){(this.host=e).addController(this),this.options={form:e=>{if(e.hasAttribute("form")&&""!==e.getAttribute("form")){const t=e.getRootNode(),M=e.getAttribute("form");if(M)return t.getElementById(M)}return e.closest("form")},name:e=>e.name,value:e=>e.value,defaultValue:e=>e.defaultValue,disabled:e=>e.disabled??!1,reportValidity:e=>"function"!=typeof e.reportValidity||e.reportValidity(),setValue:(e,t)=>e.value=t,assumeInteractionOn:["nile-input"],...t},this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this)}hostConnected(){const e=this.options
|
113
|
+
`,e([ge({type:String,reflect:!0})],we.prototype,"set",void 0),e([ge({type:String,reflect:!0})],we.prototype,"name",void 0),e([ge({type:String,reflect:!0})],we.prototype,"description",void 0),e([ge({type:String,reflect:!0})],we.prototype,"method",void 0),e([ge({type:String})],we.prototype,"customSvgPath",void 0),e([ge({type:String,reflect:!0})],we.prototype,"size",void 0),e([je()],we.prototype,"_svg",void 0),e([ge({type:String})],we.prototype,"title",void 0),e([ge({reflect:!0})],we.prototype,"color",void 0),e([ge({type:Boolean})],we.prototype,"push",void 0),e([ge({reflect:!0})],we.prototype,"frame",void 0),we=e([ae("nile-icon")],we);const me=new WeakMap,Ue=new WeakMap,Ce=new WeakSet,be=new WeakMap;class fe{constructor(e,t){(this.host=e).addController(this),this.options={form:e=>{if(e.hasAttribute("form")&&""!==e.getAttribute("form")){const t=e.getRootNode(),M=e.getAttribute("form");if(M)return t.getElementById(M)}return e.closest("form")},name:e=>e.name,value:e=>e.value,defaultValue:e=>e.defaultValue,disabled:e=>e.disabled??!1,reportValidity:e=>"function"!=typeof e.reportValidity||e.reportValidity(),setValue:(e,t)=>e.value=t,assumeInteractionOn:["nile-input"],...t},this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this)}hostConnected(){const e=this.options.form(this.host);e&&this.attachForm(e),be.set(this.host,[]),this.options.assumeInteractionOn.forEach((e=>{this.host.addEventListener(e,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),be.delete(this.host),this.options.assumeInteractionOn.forEach((e=>{this.host.removeEventListener(e,this.handleInteraction)}))}hostUpdated(){const e=this.options.form(this.host);e||this.detachForm(),e&&this.form!==e&&(this.detachForm(),this.attachForm(e)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(e){e?(this.form=e,me.has(this.form)?me.get(this.form).add(this.host):me.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),Ue.has(this.form)||(Ue.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity())):this.form=void 0}detachForm(){this.form&&(me.get(this.form)?.delete(this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),Ue.has(this.form)&&(this.form.reportValidity=Ue.get(this.form),Ue.delete(this.form))),this.form=void 0}handleFormData(e){const t=this.options.disabled(this.host),M=this.options.name(this.host),i=this.options.value(this.host),N="nile-button"===this.host.tagName.toLowerCase();!t&&!N&&"string"==typeof M&&M.length>0&&void 0!==i&&(Array.isArray(i)?i.forEach((t=>{e.formData.append(M,t.toString())})):e.formData.append(M,i.toString()))}handleFormSubmit(e){const t=this.options.disabled(this.host),M=this.options.reportValidity;this.form&&!this.form.noValidate&&me.get(this.form)?.forEach((e=>{this.setUserInteracted(e,!0)})),!this.form||this.form.noValidate||t||M(this.host)||(e.preventDefault(),e.stopImmediatePropagation())}handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),be.set(this.host,[])}handleInteraction(e){const t=be.get(this.host);t.includes(e.type)||t.push(e.type),t.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)}reportFormValidity(){if(this.form&&!this.form.noValidate){const e=this.form.querySelectorAll("*");for(const t of e)if("function"==typeof t.reportValidity&&!t.reportValidity())return!1}return!0}setUserInteracted(e,t){t?Ce.add(e):Ce.delete(e),e.requestUpdate()}doAction(e,t){if(this.form){const M=document.createElement("button");M.type=e,M.style.position="absolute",M.style.width="0",M.style.height="0",M.style.clipPath="inset(50%)",M.style.overflow="hidden",M.style.whiteSpace="nowrap",t&&(M.name=t.name,M.value=t.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach((e=>{t.hasAttribute(e)&&M.setAttribute(e,t.getAttribute(e))}))),this.form.append(M),M.click(),M.remove()}}getForm(){return this.form??null}reset(e){this.doAction("reset",e)}submit(e){this.doAction("submit",e)}setValidity(e){const t=this.host,M=Boolean(Ce.has(t)),i=Boolean(t.required);t.toggleAttribute("data-required",i),t.toggleAttribute("data-optional",!i),t.toggleAttribute("data-invalid",!e),t.toggleAttribute("data-valid",e),t.toggleAttribute("data-user-invalid",!e&&M),t.toggleAttribute("data-user-valid",e&&M)}updateValidity(){const e=this.host;this.setValidity(e.validity.valid)}emitInvalidEvent(e){const t=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});e||t.preventDefault(),this.host.dispatchEvent(t)||e?.preventDefault()}}const Ye=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1});Object.freeze({...Ye,valid:!1,valueMissing:!0}),Object.freeze({...Ye,valid:!1,customError:!0});let ve=class{constructor(e,...t){this.slotNames=[],(this.host=e).addController(this),this.slotNames=t,this.handleSlotChange=this.handleSlotChange.bind(this)}hasDefaultSlot(){return[...this.host.childNodes].some((e=>{if(e.nodeType===e.TEXT_NODE&&""!==e.textContent.trim())return!0;if(e.nodeType===e.ELEMENT_NODE){const t=e;if("nile-visually-hidden"===t.tagName.toLowerCase())return!1;if(!t.hasAttribute("slot"))return!0}return!1}))}hasNamedSlot(e){return null!==this.host.querySelector(`:scope > [slot="${e}"]`)}test(e){return"[default]"===e?this.hasDefaultSlot():this.hasNamedSlot(e)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}handleSlotChange(e){const t=e.target;(this.slotNames.includes("[default]")&&!t.name||t.name&&this.slotNames.includes(t.name))&&this.host.requestUpdate()}};
|
114
114
|
/**
|
115
115
|
* @license
|
116
116
|
* Copyright 2018 Google LLC
|
@@ -4342,7 +4342,6 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
4342
4342
|
<nile-option
|
4343
4343
|
value=${r}
|
4344
4344
|
.selected=${l}
|
4345
|
-
.multiple=${i}
|
4346
4345
|
.disabled=${a}
|
4347
4346
|
.showCheckbox=${i}
|
4348
4347
|
>
|
@@ -4861,7 +4860,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
4861
4860
|
}
|
4862
4861
|
|
4863
4862
|
.option--single-select {
|
4864
|
-
padding:
|
4863
|
+
padding: 9px 12px;
|
4865
4864
|
}
|
4866
4865
|
|
4867
4866
|
.option--hover:not(.option--current):not(.option--disabled) {
|
@@ -4930,7 +4929,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
4930
4929
|
outline-offset: -1px;
|
4931
4930
|
}
|
4932
4931
|
}
|
4933
|
-
`;let uN=class extends Pe{constructor(){super(...arguments),this.current=!1,this.hasHover=!1,this.hidden=!1,this.isMultipleSelect=!1,this.value="",this.showCheckbox=!1,this.disabled=!1,this.
|
4932
|
+
`;let uN=class extends Pe{constructor(){super(...arguments),this.current=!1,this.hasHover=!1,this.hidden=!1,this.isMultipleSelect=!1,this.value="",this.showCheckbox=!1,this.disabled=!1,this.selected=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","option"),this.setAttribute("aria-selected","false");const e=this.closest("nile-select")||this.closest("nile-virtual-select");if(e&&e.hasAttribute("multiple")){let t=e.getAttribute("multiple");"false"!==t&&(""===t&&(t="true"),this.isMultipleSelect=Boolean(t))}}updated(e){e.has("showCheckbox")&&(this.isMultipleSelect=this.showCheckbox)}handleDefaultSlotChange(){const e=this.getTextLabel();void 0!==this.cachedTextLabel?e!==this.cachedTextLabel&&(this.cachedTextLabel=e,this.emit("slotchange")):this.cachedTextLabel=e}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}handleSelectedChange(){this.setAttribute("aria-selected",this.selected?"true":"false")}handleValueChange(){"string"!=typeof this.value&&(this.value=String(this.value))}getTextLabel(){const e=this.querySelector("label");return e?e.textContent?.trim()??"":(this.textContent??"").trim()}render(){return R`
|
4934
4933
|
${this.hidden?"":R` <div
|
4935
4934
|
part="base"
|
4936
4935
|
class=${Le({option:!0,"option--single-select":!this.isMultipleSelect,"option--current":this.selected&&!this.isMultipleSelect,"option--disabled":this.disabled,"option--selected":this.selected&&!this.isMultipleSelect,"option--hover":this.hasHover})}
|
@@ -4948,7 +4947,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
4948
4947
|
></slot>
|
4949
4948
|
<slot part="suffix" name="suffix" class="option__suffix"></slot>
|
4950
4949
|
</div>`}
|
4951
|
-
`}};uN.styles=lN,e([ze(".option__label")],uN.prototype,"defaultSlot",void 0),e([je()],uN.prototype,"current",void 0),e([je()],uN.prototype,"hasHover",void 0),e([je()],uN.prototype,"hidden",void 0),e([je()],uN.prototype,"isMultipleSelect",void 0),e([ge({reflect:!0})],uN.prototype,"value",void 0),e([ge({type:Boolean})],uN.prototype,"showCheckbox",void 0),e([ge({type:Boolean,reflect:!0})],uN.prototype,"disabled",void 0),e([ge({type:Boolean,reflect:!0})],uN.prototype,"
|
4950
|
+
`}};uN.styles=lN,e([ze(".option__label")],uN.prototype,"defaultSlot",void 0),e([je()],uN.prototype,"current",void 0),e([je()],uN.prototype,"hasHover",void 0),e([je()],uN.prototype,"hidden",void 0),e([je()],uN.prototype,"isMultipleSelect",void 0),e([ge({reflect:!0})],uN.prototype,"value",void 0),e([ge({type:Boolean})],uN.prototype,"showCheckbox",void 0),e([ge({type:Boolean,reflect:!0})],uN.prototype,"disabled",void 0),e([ge({type:Boolean,reflect:!0})],uN.prototype,"selected",void 0),e([Ve("disabled")],uN.prototype,"handleDisabledChange",null),e([Ve("selected")],uN.prototype,"handleSelectedChange",null),e([Ve("value")],uN.prototype,"handleValueChange",null),uN=e([ae("nile-option")],uN);const gN=s`
|
4952
4951
|
:host {
|
4953
4952
|
box-sizing: border-box;
|
4954
4953
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
System.register([],function(_export,_context){"use strict";var t,i,s,h,e,o;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[],execute:function execute(){t=new WeakMap(),i=new WeakMap(),s=new WeakSet(),h=new WeakMap();_export("F",e=/*#__PURE__*/function(){function e(t,i){_classCallCheck(this,e);(this.host=t).addController(this),this.options=_objectSpread({form:function form(t){if(t.hasAttribute("form")&&""!==t.getAttribute("form")){var _i=t.getRootNode(),_s=t.getAttribute("form");if(_s)return _i.getElementById(_s);}return t.closest("form");},name:function name(t){return t.name;},value:function value(t){return t.value;},defaultValue:function defaultValue(t){return t.defaultValue;},disabled:function disabled(t){var _t$disabled;return(_t$disabled=t.disabled)!==null&&_t$disabled!==void 0?_t$disabled:!1;},reportValidity:function reportValidity(t){return"function"!=typeof t.reportValidity||t.reportValidity();},setValue:function setValue(t,i){return t.value=i;},assumeInteractionOn:["nile-input"]},i),this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this);}return _createClass(e,[{key:"hostConnected",value:function hostConnected(){var _this
|
1
|
+
System.register([],function(_export,_context){"use strict";var t,i,s,h,e,o;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]};},e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[],execute:function execute(){t=new WeakMap(),i=new WeakMap(),s=new WeakSet(),h=new WeakMap();_export("F",e=/*#__PURE__*/function(){function e(t,i){_classCallCheck(this,e);(this.host=t).addController(this),this.options=_objectSpread({form:function form(t){if(t.hasAttribute("form")&&""!==t.getAttribute("form")){var _i=t.getRootNode(),_s=t.getAttribute("form");if(_s)return _i.getElementById(_s);}return t.closest("form");},name:function name(t){return t.name;},value:function value(t){return t.value;},defaultValue:function defaultValue(t){return t.defaultValue;},disabled:function disabled(t){var _t$disabled;return(_t$disabled=t.disabled)!==null&&_t$disabled!==void 0?_t$disabled:!1;},reportValidity:function reportValidity(t){return"function"!=typeof t.reportValidity||t.reportValidity();},setValue:function setValue(t,i){return t.value=i;},assumeInteractionOn:["nile-input"]},i),this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this);}return _createClass(e,[{key:"hostConnected",value:function hostConnected(){var _this=this;var t=this.options.form(this.host);t&&this.attachForm(t),h.set(this.host,[]),this.options.assumeInteractionOn.forEach(function(t){_this.host.addEventListener(t,_this.handleInteraction);});}},{key:"hostDisconnected",value:function hostDisconnected(){var _this2=this;this.detachForm(),h["delete"](this.host),this.options.assumeInteractionOn.forEach(function(t){_this2.host.removeEventListener(t,_this2.handleInteraction);});}},{key:"hostUpdated",value:function hostUpdated(){var t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid);}},{key:"attachForm",value:function attachForm(s){var _this3=this;s?(this.form=s,t.has(this.form)?t.get(this.form).add(this.host):t.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),i.has(this.form)||(i.set(this.form,this.form.reportValidity),this.form.reportValidity=function(){return _this3.reportFormValidity();})):this.form=void 0;}},{key:"detachForm",value:function detachForm(){var _t$get;this.form&&((_t$get=t.get(this.form))!==null&&_t$get!==void 0&&_t$get["delete"](this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),i.has(this.form)&&(this.form.reportValidity=i.get(this.form),i["delete"](this.form))),this.form=void 0;}},{key:"handleFormData",value:function handleFormData(t){var i=this.options.disabled(this.host),s=this.options.name(this.host),h=this.options.value(this.host),_e="nile-button"===this.host.tagName.toLowerCase();!i&&!_e&&"string"==typeof s&&s.length>0&&void 0!==h&&(Array.isArray(h)?h.forEach(function(i){t.formData.append(s,i.toString());}):t.formData.append(s,h.toString()));}},{key:"handleFormSubmit",value:function handleFormSubmit(i){var _t$get2,_this4=this;var s=this.options.disabled(this.host),h=this.options.reportValidity;this.form&&!this.form.noValidate&&(_t$get2=t.get(this.form))!==null&&_t$get2!==void 0&&_t$get2.forEach(function(t){_this4.setUserInteracted(t,!0);}),!this.form||this.form.noValidate||s||h(this.host)||(i.preventDefault(),i.stopImmediatePropagation());}},{key:"handleFormReset",value:function handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),h.set(this.host,[]);}},{key:"handleInteraction",value:function handleInteraction(t){var i=h.get(this.host);i.includes(t.type)||i.push(t.type),i.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0);}},{key:"reportFormValidity",value:function reportFormValidity(){if(this.form&&!this.form.noValidate){var _t=this.form.querySelectorAll("*");var _iterator=_createForOfIteratorHelper(_t),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _i2=_step.value;if("function"==typeof _i2.reportValidity&&!_i2.reportValidity())return!1;}}catch(err){_iterator.e(err);}finally{_iterator.f();}}return!0;}},{key:"setUserInteracted",value:function setUserInteracted(t,i){i?s.add(t):s["delete"](t),t.requestUpdate();}},{key:"doAction",value:function doAction(t,i){if(this.form){var _s2=document.createElement("button");_s2.type=t,_s2.style.position="absolute",_s2.style.width="0",_s2.style.height="0",_s2.style.clipPath="inset(50%)",_s2.style.overflow="hidden",_s2.style.whiteSpace="nowrap",i&&(_s2.name=i.name,_s2.value=i.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach(function(t){i.hasAttribute(t)&&_s2.setAttribute(t,i.getAttribute(t));})),this.form.append(_s2),_s2.click(),_s2.remove();}}},{key:"getForm",value:function getForm(){var _this$form;return(_this$form=this.form)!==null&&_this$form!==void 0?_this$form:null;}},{key:"reset",value:function reset(t){this.doAction("reset",t);}},{key:"submit",value:function submit(t){this.doAction("submit",t);}},{key:"setValidity",value:function setValidity(t){var i=this.host,h=Boolean(s.has(i)),_e2=Boolean(i.required);i.toggleAttribute("data-required",_e2),i.toggleAttribute("data-optional",!_e2),i.toggleAttribute("data-invalid",!t),i.toggleAttribute("data-valid",t),i.toggleAttribute("data-user-invalid",!t&&h),i.toggleAttribute("data-user-valid",t&&h);}},{key:"updateValidity",value:function updateValidity(){var t=this.host;this.setValidity(t.validity.valid);}},{key:"emitInvalidEvent",value:function emitInvalidEvent(t){var i=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||i.preventDefault(),this.host.dispatchEvent(i)||(t===null||t===void 0?void 0:t.preventDefault());}}]);}());_export("v",o=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}));Object.freeze(_objectSpread(_objectSpread({},o),{},{valid:!1,valueMissing:!0})),Object.freeze(_objectSpread(_objectSpread({},o),{},{valid:!1,customError:!0}));}};});
|
2
2
|
//# sourceMappingURL=form.cjs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"form.cjs.js","sources":["../../../src/internal/form.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport type { NileFormControl } from '../internal/nile-element';\nimport type { NileButton } from '../nile-button';\n\n//\n// We store a WeakMap of forms + controls so we can keep references to all Nile controls within a given form. As\n// elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is\n// added and removed from the form's set, respectively.\n//\nexport const formCollections: WeakMap<HTMLFormElement, Set<NileFormControl>> = new WeakMap();\n\n//\n// We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and\n// restore the original behavior when they disconnect.\n//\nconst reportValidityOverloads: WeakMap<HTMLFormElement, () => boolean> = new WeakMap();\n\n//\n// We store a Set of controls that users have interacted with. This allows us to determine the interaction state\n// without littering the DOM with additional data attributes.\n//\nconst userInteractedControls: WeakSet<NileFormControl> = new WeakSet();\n\n//\n// We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.\n//\nconst interactions = new WeakMap<NileFormControl, string[]>();\n\nexport interface FormControlControllerOptions {\n /** A function that returns the form containing the form control. */\n form: (input: NileFormControl) => HTMLFormElement | null;\n /** A function that returns the form control's name, which will be submitted with the form data. */\n name: (input: NileFormControl) => string;\n /** A function that returns the form control's current value. */\n value: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's default value. */\n defaultValue: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */\n disabled: (input: NileFormControl) => boolean;\n /**\n * A function that maps to the form control's reportValidity() function. When the control is invalid, this will\n * prevent submission and trigger the browser's constraint violation warning.\n */\n reportValidity: (input: NileFormControl) => boolean;\n /** A function that sets the form control's value */\n setValue: (input: NileFormControl, value: unknown) => void;\n /**\n * An array of event names to listen to. When all events in the list are emitted, the control will receive validity\n * states such as user-valid and user-invalid.user interacted validity states. */\n assumeInteractionOn: string[];\n}\n\n/** A reactive controller to allow form controls to participate in form submission, validation, etc. */\nexport class FormControlController implements ReactiveController {\n host: NileFormControl & ReactiveControllerHost;\n form?: HTMLFormElement | null;\n options: FormControlControllerOptions;\n\n constructor(host: ReactiveControllerHost & NileFormControl, options?: Partial<FormControlControllerOptions>) {\n (this.host = host).addController(this);\n this.options = {\n form: input => {\n // If there's a form attribute, use it to find the target form by id\n if (input.hasAttribute('form') && input.getAttribute('form') !== '') {\n const root = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute('form');\n\n if (formId) {\n return root.getElementById(formId) as HTMLFormElement;\n }\n }\n\n return input.closest('form');\n },\n name: input => input.name,\n value: input => input.value,\n defaultValue: input => input.defaultValue,\n disabled: input => input.disabled ?? false,\n reportValidity: input => (typeof input.reportValidity === 'function' ? input.reportValidity() : true),\n setValue: (input, value: string) => (input.value = value),\n assumeInteractionOn: ['nile-input'],\n ...options\n };\n this.handleFormData = this.handleFormData.bind(this);\n this.handleFormSubmit = this.handleFormSubmit.bind(this);\n this.handleFormReset = this.handleFormReset.bind(this);\n this.reportFormValidity = this.reportFormValidity.bind(this);\n this.handleInteraction = this.handleInteraction.bind(this);\n }\n\n hostConnected() {\n const form = this.options?.form(this.host);\n\n if (form) {\n this.attachForm(form);\n }\n\n // Listen for interactions\n interactions.set(this.host, []);\n this.options?.assumeInteractionOn.forEach(event => {\n this.host.addEventListener(event, this.handleInteraction);\n });\n }\n\n hostDisconnected() {\n this.detachForm();\n\n // Clean up interactions\n interactions.delete(this.host);\n this.options.assumeInteractionOn.forEach(event => {\n this.host.removeEventListener(event, this.handleInteraction);\n });\n }\n\n hostUpdated() {\n const form = this.options.form(this.host);\n\n // Detach if the form no longer exists\n if (!form) {\n this.detachForm();\n }\n\n // If the form has changed, reattach it\n if (form && this.form !== form) {\n this.detachForm();\n this.attachForm(form);\n }\n\n if (this.host.hasUpdated) {\n this.setValidity(this.host.validity.valid);\n }\n }\n\n private attachForm(form?: HTMLFormElement) {\n if (form) {\n this.form = form;\n\n // Add this element to the form's collection\n if (formCollections.has(this.form)) {\n formCollections.get(this.form)!.add(this.host);\n } else {\n formCollections.set(this.form, new Set<NileFormControl>([this.host]));\n }\n\n this.form.addEventListener('formdata', this.handleFormData);\n this.form.addEventListener('submit', this.handleFormSubmit);\n this.form.addEventListener('reset', this.handleFormReset);\n\n // Overload the form's reportValidity() method so it looks at nile form controls\n if (!reportValidityOverloads.has(this.form)) {\n reportValidityOverloads.set(this.form, this.form.reportValidity);\n this.form.reportValidity = () => this.reportFormValidity();\n }\n } else {\n this.form = undefined;\n }\n }\n\n private detachForm() {\n if (this.form) {\n // Remove this element from the form's collection\n formCollections.get(this.form)?.delete(this.host);\n\n this.form.removeEventListener('formdata', this.handleFormData);\n this.form.removeEventListener('submit', this.handleFormSubmit);\n this.form.removeEventListener('reset', this.handleFormReset);\n\n // Remove the overload and restore the original method\n if (reportValidityOverloads.has(this.form)) {\n this.form.reportValidity = reportValidityOverloads.get(this.form)!;\n reportValidityOverloads.delete(this.form);\n }\n }\n\n this.form = undefined;\n }\n\n private handleFormData(event: FormDataEvent) {\n const disabled = this.options.disabled(this.host);\n const name = this.options.name(this.host);\n const value = this.options.value(this.host);\n\n // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by\n // injecting the name/value on a temporary button, so we can just skip them here.\n const isButton = this.host.tagName.toLowerCase() === 'nile-button';\n\n if (!disabled && !isButton && typeof name === 'string' && name.length > 0 && typeof value !== 'undefined') {\n if (Array.isArray(value)) {\n (value as unknown[]).forEach(val => {\n event.formData.append(name, (val as string | number | boolean).toString());\n });\n } else {\n event.formData.append(name, (value as string | number | boolean).toString());\n }\n }\n }\n\n private handleFormSubmit(event: Event) {\n const disabled = this.options.disabled(this.host);\n const reportValidity = this.options.reportValidity;\n\n // Update the interacted state for all controls when the form is submitted\n if (this.form && !this.form.noValidate) {\n formCollections.get(this.form)?.forEach(control => {\n this.setUserInteracted(control, true);\n });\n }\n\n if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleFormReset() {\n this.options.setValue(this.host, this.options.defaultValue(this.host));\n this.setUserInteracted(this.host, false);\n interactions.set(this.host, []);\n }\n\n private handleInteraction(event: Event) {\n const emittedEvents = interactions.get(this.host)!;\n\n if (!emittedEvents.includes(event.type)) {\n emittedEvents.push(event.type);\n }\n\n // Mark it as user-interacted as soon as all associated events have been emitted\n if (emittedEvents.length === this.options.assumeInteractionOn.length) {\n this.setUserInteracted(this.host, true);\n }\n }\n\n private reportFormValidity() {\n //\n // Nile form controls work hard to act like regular form controls. They support the Constraint Validation API\n // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also\n // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using\n // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.\n //\n // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger\n // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't\n // be necessary once we can use ElementInternals.\n //\n // Note that we're also honoring the form's novalidate attribute.\n //\n if (this.form && !this.form.noValidate) {\n // This seems sloppy, but checking all elements will cover native inputs, Nile inputs, and other custom\n // elements that support the constraint validation API.\n const elements = this.form.querySelectorAll<HTMLInputElement>('*');\n\n for (const element of elements) {\n if (typeof element.reportValidity === 'function') {\n if (!element.reportValidity()) {\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n private setUserInteracted(el: NileFormControl, hasInteracted: boolean) {\n if (hasInteracted) {\n userInteractedControls.add(el);\n } else {\n userInteractedControls.delete(el);\n }\n\n el.requestUpdate();\n }\n\n private doAction(type: 'submit' | 'reset', submitter?: HTMLInputElement | NileButton) {\n if (this.form) {\n const button = document.createElement('button');\n button.type = type;\n button.style.position = 'absolute';\n button.style.width = '0';\n button.style.height = '0';\n button.style.clipPath = 'inset(50%)';\n button.style.overflow = 'hidden';\n button.style.whiteSpace = 'nowrap';\n\n // Pass name, value, and form attributes through to the temporary button\n if (submitter) {\n button.name = submitter.name;\n button.value = submitter.value;\n\n ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {\n if (submitter.hasAttribute(attr)) {\n button.setAttribute(attr, submitter.getAttribute(attr)!);\n }\n });\n }\n\n this.form.append(button);\n button.click();\n button.remove();\n }\n }\n\n /** Returns the associated `<form>` element, if one exists. */\n getForm() {\n return this.form ?? null;\n }\n\n /** Resets the form, restoring all the control to their default value */\n reset(submitter?: HTMLInputElement | NileButton) {\n this.doAction('reset', submitter);\n }\n\n /** Submits the form, triggering validation and form data injection. */\n submit(submitter?: HTMLInputElement | NileButton) {\n // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a\n // native submit button into the form, \"click\" it, then remove it to simulate a standard form submission.\n this.doAction('submit', submitter);\n }\n\n /**\n * Synchronously sets the form control's validity. Call this when you know the future validity but need to update\n * the host element immediately, i.e. before Lit updates the component in the next update.\n */\n setValidity(isValid: boolean) {\n const host = this.host;\n const hasInteracted = Boolean(userInteractedControls.has(host));\n const required = Boolean(host.required);\n\n //\n // We're mapping the following \"states\" to data attributes. In the future, we can use ElementInternals.states to\n // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.\n //\n //\n host.toggleAttribute('data-required', required);\n host.toggleAttribute('data-optional', !required);\n host.toggleAttribute('data-invalid', !isValid);\n host.toggleAttribute('data-valid', isValid);\n host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);\n host.toggleAttribute('data-user-valid', isValid && hasInteracted);\n }\n\n /**\n * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything\n * that affects constraint validation changes so the component receives the correct validity states.\n */\n updateValidity() {\n const host = this.host;\n this.setValidity(host.validity.valid);\n }\n\n /**\n * Dispatches a non-bubbling, cancelable custom event of type `nile-invalid`.\n * If the `nile-invalid` event will be cancelled then the original `invalid`\n * event (which may have been passed as argument) will also be cancelled.\n * If no original `invalid` event has been passed then the `nile-invalid`\n * event will be cancelled before being dispatched.\n */\n emitInvalidEvent(originalInvalidEvent?: Event) {\n const slInvalidEvent = new CustomEvent<Record<PropertyKey, never>>('nile-invalid', {\n bubbles: false,\n composed: false,\n cancelable: true,\n detail: {}\n });\n\n if (!originalInvalidEvent) {\n slInvalidEvent.preventDefault();\n }\n\n if (!this.host.dispatchEvent(slInvalidEvent)) {\n originalInvalidEvent?.preventDefault();\n }\n }\n}\n\n/*\n * Predefined common validity states.\n * All of them are read-only.\n */\n\n// A validity state object that represents `valid`\nexport const validValidityState: ValidityState = Object.freeze({\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valid: true,\n valueMissing: false\n});\n\n// A validity state object that represents `value missing`\nexport const valueMissingValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n valueMissing: true\n});\n\n// A validity state object that represents a custom error\nexport const customErrorValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n customError: true\n});\n"],"names":["formCollections","WeakMap","reportValidityOverloads","userInteractedControls","WeakSet","interactions","FormControlController","e","host","options","this","addController","_objectSpread","form","input","hasAttribute","getAttribute","root","getRootNode","formId","getElementById","closest","name","value","defaultValue","disabled","reportValidity","setValue","assumeInteractionOn","handleFormData","bind","handleFormSubmit","handleFormReset","reportFormValidity","handleInteraction","_createClass","key","hostConnected","_this$options","_this$options2","_this","attachForm","set","forEach","event","addEventListener","hostDisconnected","detachForm","removeEventListener","hostUpdated","hasUpdated","setValidity","validity","valid","has","get","add","Set","undefined","isButton","tagName","toLowerCase","length","Array","isArray","val","formData","append","toString","noValidate","control","setUserInteracted","preventDefault","stopImmediatePropagation","emittedEvents","includes","type","push","elements","querySelectorAll","_iterator","_createForOfIteratorHelper","s","_step","n","done","element","err","f","el","hasInteracted","delete","requestUpdate","doAction","submitter","button","document","createElement","style","position","width","height","clipPath","overflow","whiteSpace","attr","setAttribute","click","remove","getForm","_this$form","reset","submit","isValid","Boolean","required","toggleAttribute","updateValidity","emitInvalidEvent","originalInvalidEvent","slInvalidEvent","CustomEvent","bubbles","composed","cancelable","detail","dispatchEvent","_export","validValidityState","Object","freeze","badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],"mappings":"wmGASaA,EAAkE,GAAIC,CAAAA,OAAAA,CAAAA,CAAAA,CAM7EC,EAAmE,GAAID,CAAAA,OAAAA,CAAAA,CAAAA,CAMvEE,EAAmD,GAAIC,CAAAA,OAAAA,CAAAA,CAAAA,CAKvDC,EAAe,GAAIJ,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,OAAAA,KA2BZK,CAKX,yBAAA,SAAAC,EAAYC,CAAgDC,CAAAA,CAAAA,CAAAA,CAAAA,eAAAA,MAAAA,CAAAA,EAAAA,CACzDC,KAAKF,IAAOA,CAAAA,CAAAA,EAAMG,aAAcD,CAAAA,IAAAA,CAAAA,CACjCA,KAAKD,OAAU,CAAAG,aAAA,EACbC,KAAMC,QAAND,CAAAA,KAAMC,CAEJ,CAAA,CAAA,GAAIA,EAAMC,YAAa,CAAA,MAAA,CAAA,EAA0C,KAA/BD,CAAME,CAAAA,YAAAA,CAAa,QAAgB,CACnE,GAAMC,CAAAA,GAAOH,CAAMI,CAAAA,WAAAA,CAAAA,CAAAA,CACbC,GAASL,CAAME,CAAAA,YAAAA,CAAa,MAElC,CAAA,CAAA,GAAIG,GACF,MAAOF,CAAAA,EAAAA,CAAKG,eAAeD,EAE9B,CAAA,EAED,MAAOL,CAAAA,CAAMO,CAAAA,OAAAA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,CAAA,CAAE,IAGPN,CACHC,EAAAA,CAAAA,CAAehD,iBAGZ9D,IAAKF,CAAAA,IAAAA,CAAKsH,cAAcN,CAC3BD,CAAAA,GAAAA,CAAAA,SAAAA,CAAAA,iBAAAA,CAAAA,CAAsB/C,cAEzB,CAAA,CAAA,GAAA,SAAAuD,OAAA,KASUC,CAAoCC,CAAAA,MAAAA,CAAOC,OAAO,CAC7DC,QAAAA,CAAAA,CAAU,EACVC,WAAa,CAAA,CAAA,CAAA,CACbC,iBAAiB,CACjBC,CAAAA,aAAAA,CAAAA,CAAe,EACfC,cAAgB,CAAA,CAAA,CAAA,CAChBC,cAAc,CACdC,CAAAA,OAAAA,CAAAA,CAAS,EACTC,QAAU,CAAA,CAAA,CAAA,CACVC,cAAc,CACdtF,CAAAA,KAAAA,CAAAA,CAAO,EACPuF,YAAc,CAAA,CAAA,CAAA,CAAA,CAAA,EAIwCX,OAAOC,MAAO,CAAAtH,aAAA,CAAAA,aAAA,IACjEoH,OACH3E,KAAO,CAAA,CAAA,CAAA,CACPuF,cAAc,CAIuCX,EAAAA,CAAAA,CAAAA,MAAAA,CAAOC,sCACzDF,CAAAA,MACH3E,OAAO,CACP+E,CAAAA,WAAAA,CAAAA,CAAa"}
|
1
|
+
{"version":3,"file":"form.cjs.js","sources":["../../../src/internal/form.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport type { NileFormControl } from '../internal/nile-element';\nimport type { NileButton } from '../nile-button';\n\n//\n// We store a WeakMap of forms + controls so we can keep references to all Nile controls within a given form. As\n// elements connect and disconnect to/from the DOM, their containing form is used as the key and the form control is\n// added and removed from the form's set, respectively.\n//\nexport const formCollections: WeakMap<HTMLFormElement, Set<NileFormControl>> = new WeakMap();\n\n//\n// We store a WeakMap of reportValidity() overloads so we can override it when form controls connect to the DOM and\n// restore the original behavior when they disconnect.\n//\nconst reportValidityOverloads: WeakMap<HTMLFormElement, () => boolean> = new WeakMap();\n\n//\n// We store a Set of controls that users have interacted with. This allows us to determine the interaction state\n// without littering the DOM with additional data attributes.\n//\nconst userInteractedControls: WeakSet<NileFormControl> = new WeakSet();\n\n//\n// We store a WeakMap of interactions for each form control so we can track when all conditions are met for validation.\n//\nconst interactions = new WeakMap<NileFormControl, string[]>();\n\nexport interface FormControlControllerOptions {\n /** A function that returns the form containing the form control. */\n form: (input: NileFormControl) => HTMLFormElement | null;\n /** A function that returns the form control's name, which will be submitted with the form data. */\n name: (input: NileFormControl) => string;\n /** A function that returns the form control's current value. */\n value: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's default value. */\n defaultValue: (input: NileFormControl) => unknown | unknown[];\n /** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */\n disabled: (input: NileFormControl) => boolean;\n /**\n * A function that maps to the form control's reportValidity() function. When the control is invalid, this will\n * prevent submission and trigger the browser's constraint violation warning.\n */\n reportValidity: (input: NileFormControl) => boolean;\n /** A function that sets the form control's value */\n setValue: (input: NileFormControl, value: unknown) => void;\n /**\n * An array of event names to listen to. When all events in the list are emitted, the control will receive validity\n * states such as user-valid and user-invalid.user interacted validity states. */\n assumeInteractionOn: string[];\n}\n\n/** A reactive controller to allow form controls to participate in form submission, validation, etc. */\nexport class FormControlController implements ReactiveController {\n host: NileFormControl & ReactiveControllerHost;\n form?: HTMLFormElement | null;\n options: FormControlControllerOptions;\n\n constructor(host: ReactiveControllerHost & NileFormControl, options?: Partial<FormControlControllerOptions>) {\n (this.host = host).addController(this);\n this.options = {\n form: input => {\n // If there's a form attribute, use it to find the target form by id\n if (input.hasAttribute('form') && input.getAttribute('form') !== '') {\n const root = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute('form');\n\n if (formId) {\n return root.getElementById(formId) as HTMLFormElement;\n }\n }\n\n return input.closest('form');\n },\n name: input => input.name,\n value: input => input.value,\n defaultValue: input => input.defaultValue,\n disabled: input => input.disabled ?? false,\n reportValidity: input => (typeof input.reportValidity === 'function' ? input.reportValidity() : true),\n setValue: (input, value: string) => (input.value = value),\n assumeInteractionOn: ['nile-input'],\n ...options\n };\n this.handleFormData = this.handleFormData.bind(this);\n this.handleFormSubmit = this.handleFormSubmit.bind(this);\n this.handleFormReset = this.handleFormReset.bind(this);\n this.reportFormValidity = this.reportFormValidity.bind(this);\n this.handleInteraction = this.handleInteraction.bind(this);\n }\n\n hostConnected() {\n const form = this.options.form(this.host);\n\n if (form) {\n this.attachForm(form);\n }\n\n // Listen for interactions\n interactions.set(this.host, []);\n this.options.assumeInteractionOn.forEach(event => {\n this.host.addEventListener(event, this.handleInteraction);\n });\n }\n\n hostDisconnected() {\n this.detachForm();\n\n // Clean up interactions\n interactions.delete(this.host);\n this.options.assumeInteractionOn.forEach(event => {\n this.host.removeEventListener(event, this.handleInteraction);\n });\n }\n\n hostUpdated() {\n const form = this.options.form(this.host);\n\n // Detach if the form no longer exists\n if (!form) {\n this.detachForm();\n }\n\n // If the form has changed, reattach it\n if (form && this.form !== form) {\n this.detachForm();\n this.attachForm(form);\n }\n\n if (this.host.hasUpdated) {\n this.setValidity(this.host.validity.valid);\n }\n }\n\n private attachForm(form?: HTMLFormElement) {\n if (form) {\n this.form = form;\n\n // Add this element to the form's collection\n if (formCollections.has(this.form)) {\n formCollections.get(this.form)!.add(this.host);\n } else {\n formCollections.set(this.form, new Set<NileFormControl>([this.host]));\n }\n\n this.form.addEventListener('formdata', this.handleFormData);\n this.form.addEventListener('submit', this.handleFormSubmit);\n this.form.addEventListener('reset', this.handleFormReset);\n\n // Overload the form's reportValidity() method so it looks at nile form controls\n if (!reportValidityOverloads.has(this.form)) {\n reportValidityOverloads.set(this.form, this.form.reportValidity);\n this.form.reportValidity = () => this.reportFormValidity();\n }\n } else {\n this.form = undefined;\n }\n }\n\n private detachForm() {\n if (this.form) {\n // Remove this element from the form's collection\n formCollections.get(this.form)?.delete(this.host);\n\n this.form.removeEventListener('formdata', this.handleFormData);\n this.form.removeEventListener('submit', this.handleFormSubmit);\n this.form.removeEventListener('reset', this.handleFormReset);\n\n // Remove the overload and restore the original method\n if (reportValidityOverloads.has(this.form)) {\n this.form.reportValidity = reportValidityOverloads.get(this.form)!;\n reportValidityOverloads.delete(this.form);\n }\n }\n\n this.form = undefined;\n }\n\n private handleFormData(event: FormDataEvent) {\n const disabled = this.options.disabled(this.host);\n const name = this.options.name(this.host);\n const value = this.options.value(this.host);\n\n // For buttons, we only submit the value if they were the submitter. This is currently done in doAction() by\n // injecting the name/value on a temporary button, so we can just skip them here.\n const isButton = this.host.tagName.toLowerCase() === 'nile-button';\n\n if (!disabled && !isButton && typeof name === 'string' && name.length > 0 && typeof value !== 'undefined') {\n if (Array.isArray(value)) {\n (value as unknown[]).forEach(val => {\n event.formData.append(name, (val as string | number | boolean).toString());\n });\n } else {\n event.formData.append(name, (value as string | number | boolean).toString());\n }\n }\n }\n\n private handleFormSubmit(event: Event) {\n const disabled = this.options.disabled(this.host);\n const reportValidity = this.options.reportValidity;\n\n // Update the interacted state for all controls when the form is submitted\n if (this.form && !this.form.noValidate) {\n formCollections.get(this.form)?.forEach(control => {\n this.setUserInteracted(control, true);\n });\n }\n\n if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleFormReset() {\n this.options.setValue(this.host, this.options.defaultValue(this.host));\n this.setUserInteracted(this.host, false);\n interactions.set(this.host, []);\n }\n\n private handleInteraction(event: Event) {\n const emittedEvents = interactions.get(this.host)!;\n\n if (!emittedEvents.includes(event.type)) {\n emittedEvents.push(event.type);\n }\n\n // Mark it as user-interacted as soon as all associated events have been emitted\n if (emittedEvents.length === this.options.assumeInteractionOn.length) {\n this.setUserInteracted(this.host, true);\n }\n }\n\n private reportFormValidity() {\n //\n // Nile form controls work hard to act like regular form controls. They support the Constraint Validation API\n // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also\n // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using\n // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.\n //\n // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger\n // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't\n // be necessary once we can use ElementInternals.\n //\n // Note that we're also honoring the form's novalidate attribute.\n //\n if (this.form && !this.form.noValidate) {\n // This seems sloppy, but checking all elements will cover native inputs, Nile inputs, and other custom\n // elements that support the constraint validation API.\n const elements = this.form.querySelectorAll<HTMLInputElement>('*');\n\n for (const element of elements) {\n if (typeof element.reportValidity === 'function') {\n if (!element.reportValidity()) {\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n private setUserInteracted(el: NileFormControl, hasInteracted: boolean) {\n if (hasInteracted) {\n userInteractedControls.add(el);\n } else {\n userInteractedControls.delete(el);\n }\n\n el.requestUpdate();\n }\n\n private doAction(type: 'submit' | 'reset', submitter?: HTMLInputElement | NileButton) {\n if (this.form) {\n const button = document.createElement('button');\n button.type = type;\n button.style.position = 'absolute';\n button.style.width = '0';\n button.style.height = '0';\n button.style.clipPath = 'inset(50%)';\n button.style.overflow = 'hidden';\n button.style.whiteSpace = 'nowrap';\n\n // Pass name, value, and form attributes through to the temporary button\n if (submitter) {\n button.name = submitter.name;\n button.value = submitter.value;\n\n ['formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'].forEach(attr => {\n if (submitter.hasAttribute(attr)) {\n button.setAttribute(attr, submitter.getAttribute(attr)!);\n }\n });\n }\n\n this.form.append(button);\n button.click();\n button.remove();\n }\n }\n\n /** Returns the associated `<form>` element, if one exists. */\n getForm() {\n return this.form ?? null;\n }\n\n /** Resets the form, restoring all the control to their default value */\n reset(submitter?: HTMLInputElement | NileButton) {\n this.doAction('reset', submitter);\n }\n\n /** Submits the form, triggering validation and form data injection. */\n submit(submitter?: HTMLInputElement | NileButton) {\n // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a\n // native submit button into the form, \"click\" it, then remove it to simulate a standard form submission.\n this.doAction('submit', submitter);\n }\n\n /**\n * Synchronously sets the form control's validity. Call this when you know the future validity but need to update\n * the host element immediately, i.e. before Lit updates the component in the next update.\n */\n setValidity(isValid: boolean) {\n const host = this.host;\n const hasInteracted = Boolean(userInteractedControls.has(host));\n const required = Boolean(host.required);\n\n //\n // We're mapping the following \"states\" to data attributes. In the future, we can use ElementInternals.states to\n // create a similar mapping, but instead of [data-invalid] it will look like :--invalid.\n //\n //\n host.toggleAttribute('data-required', required);\n host.toggleAttribute('data-optional', !required);\n host.toggleAttribute('data-invalid', !isValid);\n host.toggleAttribute('data-valid', isValid);\n host.toggleAttribute('data-user-invalid', !isValid && hasInteracted);\n host.toggleAttribute('data-user-valid', isValid && hasInteracted);\n }\n\n /**\n * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything\n * that affects constraint validation changes so the component receives the correct validity states.\n */\n updateValidity() {\n const host = this.host;\n this.setValidity(host.validity.valid);\n }\n\n /**\n * Dispatches a non-bubbling, cancelable custom event of type `nile-invalid`.\n * If the `nile-invalid` event will be cancelled then the original `invalid`\n * event (which may have been passed as argument) will also be cancelled.\n * If no original `invalid` event has been passed then the `nile-invalid`\n * event will be cancelled before being dispatched.\n */\n emitInvalidEvent(originalInvalidEvent?: Event) {\n const slInvalidEvent = new CustomEvent<Record<PropertyKey, never>>('nile-invalid', {\n bubbles: false,\n composed: false,\n cancelable: true,\n detail: {}\n });\n\n if (!originalInvalidEvent) {\n slInvalidEvent.preventDefault();\n }\n\n if (!this.host.dispatchEvent(slInvalidEvent)) {\n originalInvalidEvent?.preventDefault();\n }\n }\n}\n\n/*\n * Predefined common validity states.\n * All of them are read-only.\n */\n\n// A validity state object that represents `valid`\nexport const validValidityState: ValidityState = Object.freeze({\n badInput: false,\n customError: false,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n typeMismatch: false,\n valid: true,\n valueMissing: false\n});\n\n// A validity state object that represents `value missing`\nexport const valueMissingValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n valueMissing: true\n});\n\n// A validity state object that represents a custom error\nexport const customErrorValidityState: ValidityState = Object.freeze({\n ...validValidityState,\n valid: false,\n customError: true\n});\n"],"names":["formCollections","WeakMap","reportValidityOverloads","userInteractedControls","WeakSet","interactions","FormControlController","e","host","options","this","addController","_objectSpread","form","input","hasAttribute","getAttribute","root","getRootNode","formId","getElementById","closest","name","value","defaultValue","disabled","reportValidity","setValue","assumeInteractionOn","handleFormData","bind","handleFormSubmit","handleFormReset","reportFormValidity","handleInteraction","_createClass","key","hostConnected","_this","attachForm","set","forEach","event","addEventListener","hostDisconnected","detachForm","removeEventListener","hostUpdated","hasUpdated","setValidity","validity","valid","has","get","add","Set","undefined","isButton","tagName","toLowerCase","length","Array","isArray","val","formData","append","toString","noValidate","control","setUserInteracted","preventDefault","stopImmediatePropagation","emittedEvents","includes","type","push","elements","querySelectorAll","_iterator","_createForOfIteratorHelper","s","_step","n","done","element","err","f","el","hasInteracted","delete","requestUpdate","doAction","submitter","button","document","createElement","style","position","width","height","clipPath","overflow","whiteSpace","attr","setAttribute","click","remove","getForm","_this$form","reset","submit","isValid","Boolean","required","toggleAttribute","updateValidity","emitInvalidEvent","originalInvalidEvent","slInvalidEvent","CustomEvent","bubbles","composed","cancelable","detail","dispatchEvent","_export","validValidityState","Object","freeze","badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],"mappings":"wmGASaA,EAAkE,GAAIC,CAAAA,OAAAA,CAAAA,CAAAA,CAM7EC,EAAmE,GAAID,CAAAA,OAAAA,CAAAA,CAAAA,CAMvEE,EAAmD,GAAIC,CAAAA,OAAAA,CAAAA,CAAAA,CAKvDC,EAAe,GAAIJ,CAAAA,OAAAA,CAAAA,CAAAA,CAAAA,OAAAA,KA2BZK,CAKX,yBAAA,SAAAC,EAAYC,CAAgDC,CAAAA,CAAAA,CAAAA,CAAAA,eAAAA,MAAAA,CAAAA,EAAAA,CACzDC,KAAKF,IAA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t=>{if(t.hasAttribute("form")&&""!==t.getAttribute("form")){const i=t.getRootNode(),s=t.getAttribute("form");if(s)return i.getElementById(s)}return t.closest("form")},name:t=>t.name,value:t=>t.value,defaultValue:t=>t.defaultValue,disabled:t=>t.disabled??!1,reportValidity:t=>"function"!=typeof t.reportValidity||t.reportValidity(),setValue:(t,i)=>t.value=i,assumeInteractionOn:["nile-input"],...i},this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this)}hostConnected(){const t=this.options
|
1
|
+
const t=new WeakMap,i=new WeakMap,s=new WeakSet,h=new WeakMap;class e{constructor(t,i){(this.host=t).addController(this),this.options={form:t=>{if(t.hasAttribute("form")&&""!==t.getAttribute("form")){const i=t.getRootNode(),s=t.getAttribute("form");if(s)return i.getElementById(s)}return t.closest("form")},name:t=>t.name,value:t=>t.value,defaultValue:t=>t.defaultValue,disabled:t=>t.disabled??!1,reportValidity:t=>"function"!=typeof t.reportValidity||t.reportValidity(),setValue:(t,i)=>t.value=i,assumeInteractionOn:["nile-input"],...i},this.handleFormData=this.handleFormData.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFormReset=this.handleFormReset.bind(this),this.reportFormValidity=this.reportFormValidity.bind(this),this.handleInteraction=this.handleInteraction.bind(this)}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),h.set(this.host,[]),this.options.assumeInteractionOn.forEach((t=>{this.host.addEventListener(t,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),h.delete(this.host),this.options.assumeInteractionOn.forEach((t=>{this.host.removeEventListener(t,this.handleInteraction)}))}hostUpdated(){const t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(s){s?(this.form=s,t.has(this.form)?t.get(this.form).add(this.host):t.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),i.has(this.form)||(i.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity())):this.form=void 0}detachForm(){this.form&&(t.get(this.form)?.delete(this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),i.has(this.form)&&(this.form.reportValidity=i.get(this.form),i.delete(this.form))),this.form=void 0}handleFormData(t){const i=this.options.disabled(this.host),s=this.options.name(this.host),h=this.options.value(this.host),e="nile-button"===this.host.tagName.toLowerCase();!i&&!e&&"string"==typeof s&&s.length>0&&void 0!==h&&(Array.isArray(h)?h.forEach((i=>{t.formData.append(s,i.toString())})):t.formData.append(s,h.toString()))}handleFormSubmit(i){const s=this.options.disabled(this.host),h=this.options.reportValidity;this.form&&!this.form.noValidate&&t.get(this.form)?.forEach((t=>{this.setUserInteracted(t,!0)})),!this.form||this.form.noValidate||s||h(this.host)||(i.preventDefault(),i.stopImmediatePropagation())}handleFormReset(){this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),h.set(this.host,[])}handleInteraction(t){const i=h.get(this.host);i.includes(t.type)||i.push(t.type),i.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const i of t)if("function"==typeof i.reportValidity&&!i.reportValidity())return!1}return!0}setUserInteracted(t,i){i?s.add(t):s.delete(t),t.requestUpdate()}doAction(t,i){if(this.form){const s=document.createElement("button");s.type=t,s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.clipPath="inset(50%)",s.style.overflow="hidden",s.style.whiteSpace="nowrap",i&&(s.name=i.name,s.value=i.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach((t=>{i.hasAttribute(t)&&s.setAttribute(t,i.getAttribute(t))}))),this.form.append(s),s.click(),s.remove()}}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){const i=this.host,h=Boolean(s.has(i)),e=Boolean(i.required);i.toggleAttribute("data-required",e),i.toggleAttribute("data-optional",!e),i.toggleAttribute("data-invalid",!t),i.toggleAttribute("data-valid",t),i.toggleAttribute("data-user-invalid",!t&&h),i.toggleAttribute("data-user-valid",t&&h)}updateValidity(){const t=this.host;this.setValidity(t.validity.valid)}emitInvalidEvent(t){const i=new CustomEvent("nile-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||i.preventDefault(),this.host.dispatchEvent(i)||t?.preventDefault()}}const o=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1});Object.freeze({...o,valid:!1,valueMissing:!0}),Object.freeze({...o,valid:!1,customError:!0});export{e as F,o as v};
|