@descope/web-components-ui 1.0.70 → 1.0.72
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/dist/index.esm.js +420 -464
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/809.js +1 -0
- package/dist/umd/descope-button-index-js.js +1 -1
- package/dist/umd/descope-checkbox-index-js.js +1 -1
- package/dist/umd/descope-combo-box-index-js.js +1 -1
- package/dist/umd/descope-container-index-js.js +1 -1
- package/dist/umd/descope-date-picker-index-js.js +1 -1
- package/dist/umd/descope-divider-index-js.js +1 -1
- package/dist/umd/descope-email-field-index-js.js +1 -1
- package/dist/umd/descope-image-index-js.js +1 -0
- package/dist/umd/descope-link-index-js.js +1 -1
- package/dist/umd/descope-loader-linear-index-js.js +1 -1
- package/dist/umd/descope-loader-radial-index-js.js +1 -1
- package/dist/umd/descope-logo-index-js.js +1 -1
- package/dist/umd/descope-number-field-index-js.js +1 -1
- package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +1 -1
- package/dist/umd/descope-passcode-index-js.js +1 -1
- package/dist/umd/descope-password-field-index-js.js +1 -1
- package/dist/umd/descope-switch-toggle-index-js.js +1 -1
- package/dist/umd/descope-text-area-index-js.js +1 -1
- package/dist/umd/descope-text-field-index-js.js +1 -1
- package/dist/umd/descope-text-index-js.js +1 -1
- package/dist/umd/index.js +1 -1
- package/package.json +1 -1
- package/src/baseClasses/createBaseClass.js +29 -3
- package/src/baseClasses/createBaseInputClass.js +9 -0
- package/src/components/descope-image/Image.js +53 -0
- package/src/components/descope-image/index.js +5 -0
- package/src/components/descope-passcode/Passcode.js +1 -1
- package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +67 -51
- package/src/helpers/mixinsHelpers.js +26 -9
- package/src/index.js +1 -0
- package/src/mixins/changeMixin.js +13 -39
- package/src/mixins/componentNameValidationMixin.js +2 -4
- package/src/mixins/createProxy.js +45 -53
- package/src/mixins/createStyleMixin/index.js +2 -0
- package/src/mixins/focusMixin.js +20 -125
- package/src/mixins/hoverableMixin.js +10 -16
- package/src/mixins/index.js +1 -0
- package/src/mixins/inputValidationMixin.js +10 -30
- package/src/mixins/normalizeBooleanAttributesMixin.js +11 -0
- package/src/mixins/proxyInputMixin.js +51 -58
- package/src/theme/components/container.js +1 -1
- package/src/theme/components/image.js +7 -0
- package/src/theme/components/index.js +3 -1
- package/dist/umd/775.js +0 -1
- package/src/baseClasses/BaseInputClass.js +0 -4
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { createEventListener } from "../helpers/mixinsHelpers";
|
2
2
|
|
3
3
|
const observedAttributes = [
|
4
4
|
'required',
|
@@ -21,19 +21,12 @@ export const inputValidationMixin = (superclass) => class InputValidationMixinCl
|
|
21
21
|
return true;
|
22
22
|
}
|
23
23
|
|
24
|
-
#dispatchValid = createDispatchEvent.bind(this, 'valid')
|
25
|
-
#dispatchInvalid = createDispatchEvent.bind(this, 'invalid')
|
26
|
-
|
27
24
|
#internals
|
28
25
|
|
29
|
-
#boundedHandleInput
|
30
|
-
|
31
26
|
constructor() {
|
32
27
|
super();
|
33
28
|
|
34
29
|
this.#internals = this.attachInternals();
|
35
|
-
|
36
|
-
this.#boundedHandleInput = this.#handleInput.bind(this);
|
37
30
|
}
|
38
31
|
|
39
32
|
get defaultErrorMsgValueMissing() {
|
@@ -59,7 +52,7 @@ export const inputValidationMixin = (superclass) => class InputValidationMixinCl
|
|
59
52
|
}
|
60
53
|
}
|
61
54
|
|
62
|
-
setValidity() {
|
55
|
+
#setValidity() {
|
63
56
|
const validity = this.getValidity()
|
64
57
|
this.#internals.setValidity(validity, this.getErrorMessage(validity))
|
65
58
|
}
|
@@ -89,7 +82,7 @@ export const inputValidationMixin = (superclass) => class InputValidationMixinCl
|
|
89
82
|
this.#internals.setValidity({ customError: true }, errorMessage)
|
90
83
|
} else {
|
91
84
|
this.#internals.setValidity({})
|
92
|
-
this
|
85
|
+
this.#setValidity()
|
93
86
|
}
|
94
87
|
}
|
95
88
|
|
@@ -101,37 +94,24 @@ export const inputValidationMixin = (superclass) => class InputValidationMixinCl
|
|
101
94
|
return this.getAttribute('pattern')
|
102
95
|
}
|
103
96
|
|
104
|
-
|
105
|
-
this.
|
106
|
-
this.handleDispatchValidationEvents()
|
97
|
+
get form() {
|
98
|
+
return this.#internals.form
|
107
99
|
}
|
108
100
|
|
109
101
|
attributeChangedCallback(attrName, oldValue, newValue) {
|
110
102
|
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
111
103
|
|
112
104
|
if (observedAttributes.includes(attrName)) {
|
113
|
-
this
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
handleDispatchValidationEvents() {
|
118
|
-
if (this.checkValidity()) {
|
119
|
-
this.#dispatchValid()
|
120
|
-
} else {
|
121
|
-
this.#dispatchInvalid()
|
105
|
+
this.#setValidity();
|
122
106
|
}
|
123
107
|
}
|
124
108
|
|
125
109
|
connectedCallback() {
|
126
110
|
super.connectedCallback?.();
|
111
|
+
createEventListener.call(this, 'change', this.#setValidity)
|
112
|
+
createEventListener.call(this, 'invalid', (e) => e.stopPropagation())
|
113
|
+
createEventListener.call(this, 'input', this.#setValidity)
|
127
114
|
|
128
|
-
this
|
129
|
-
|
130
|
-
this.setValidity();
|
131
|
-
this.handleDispatchValidationEvents();
|
132
|
-
}
|
133
|
-
|
134
|
-
disconnectedCallback() {
|
135
|
-
this.removeEventListener('input', this.#boundedHandleInput)
|
115
|
+
this.#setValidity();
|
136
116
|
}
|
137
117
|
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// we want all the valueless attributes to have "true" value
|
2
|
+
export const normalizeBooleanAttributesMixin = (superclass) => class NormalizeBooleanAttributesMixinClass extends superclass {
|
3
|
+
attributeChangedCallback(attrName, oldValue, newValue) {
|
4
|
+
if (newValue === '') {
|
5
|
+
this.setAttribute(attrName, 'true')
|
6
|
+
newValue = 'true'
|
7
|
+
}
|
8
|
+
|
9
|
+
super.attributeChangedCallback?.(attrName, oldValue, newValue)
|
10
|
+
}
|
11
|
+
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { createDispatchEvent, createEventListener } from "../helpers/mixinsHelpers";
|
1
2
|
import { inputValidationMixin } from "./inputValidationMixin";
|
2
3
|
|
3
4
|
const errorAttrs = ['invalid', 'has-error-message'];
|
@@ -36,26 +37,17 @@ export const proxyInputMixin = (superclass) =>
|
|
36
37
|
|
37
38
|
#inputElement
|
38
39
|
|
39
|
-
#
|
40
|
-
#boundHandleInvalid
|
41
|
-
#boundHandleValid
|
40
|
+
#dispatchChange = createDispatchEvent.bind(this, 'change')
|
42
41
|
|
43
42
|
constructor() {
|
44
43
|
super();
|
45
44
|
|
46
45
|
this.#inputElement = super.inputElement
|
47
|
-
|
48
|
-
this.#boundHandleFocus = this.#handleFocus.bind(this);
|
49
|
-
this.#boundHandleInvalid = this.#handleInvalid.bind(this);
|
50
|
-
this.#boundHandleValid = this.#handleValid.bind(this);
|
51
|
-
|
52
|
-
this.baseEle = this.shadowRoot.querySelector(this.baseSelector);
|
53
|
-
|
54
46
|
}
|
55
47
|
|
56
48
|
get inputElement() {
|
57
|
-
const inputSlot = this.
|
58
|
-
const textAreaSlot = this.
|
49
|
+
const inputSlot = this.baseElement.shadowRoot.querySelector('slot[name="input"]')
|
50
|
+
const textAreaSlot = this.baseElement.shadowRoot.querySelector('slot[name="textarea"]')
|
59
51
|
|
60
52
|
this.#inputElement ??= getNestedInput(inputSlot) || getNestedInput(textAreaSlot)
|
61
53
|
|
@@ -74,7 +66,6 @@ export const proxyInputMixin = (superclass) =>
|
|
74
66
|
|
75
67
|
reportValidityOnInternalInput() {
|
76
68
|
setTimeout(() => {
|
77
|
-
this.baseEle.focus() //TODO: check if this is needed
|
78
69
|
this.inputElement.reportValidity()
|
79
70
|
})
|
80
71
|
}
|
@@ -87,72 +78,74 @@ export const proxyInputMixin = (superclass) =>
|
|
87
78
|
}
|
88
79
|
}
|
89
80
|
|
90
|
-
|
91
|
-
if (!this.checkValidity()) {
|
81
|
+
handleInternalInputErrorMessage() {
|
82
|
+
if (!this.inputElement.checkValidity()) {
|
92
83
|
this.inputElement.setCustomValidity(this.validationMessage)
|
93
84
|
}
|
94
85
|
}
|
95
86
|
|
96
|
-
|
97
|
-
|
98
|
-
#handleFocus(e) {
|
99
|
-
if (e.relatedTarget?.form) {
|
100
|
-
if (!this.checkValidity()) {
|
101
|
-
this.setAttribute('invalid', 'true');
|
102
|
-
}
|
103
|
-
|
104
|
-
if (this.hasAttribute('invalid')) {
|
105
|
-
this.reportValidityOnInternalInput()
|
106
|
-
}
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
#handleInvalid() {
|
111
|
-
this.setInternalInputErrorMessage()
|
87
|
+
#handleErrorMessage() {
|
88
|
+
this.handleInternalInputErrorMessage()
|
112
89
|
this.setAttribute('error-message', this.validationMessage)
|
113
90
|
}
|
114
91
|
|
115
|
-
#handleValid() {
|
116
|
-
this.removeAttribute('invalid')
|
117
|
-
}
|
118
|
-
|
119
92
|
connectedCallback() {
|
120
93
|
super.connectedCallback?.();
|
121
94
|
|
122
|
-
|
123
|
-
|
124
|
-
|
95
|
+
createEventListener.call(this, 'input', (e) => {
|
96
|
+
if (!this.inputElement.checkValidity()) {
|
97
|
+
this.inputElement.setCustomValidity('')
|
98
|
+
// after updating the input validity we want to trigger set validity on the wrapping element
|
99
|
+
// so we will get the updated validity
|
100
|
+
this.setCustomValidity('')
|
101
|
+
|
102
|
+
// Vaadin is getting the input event before us,
|
103
|
+
// so in order to make sure they use the updated validity
|
104
|
+
// we calling their fn after updating the input validity
|
105
|
+
this.baseElement.__onInput(e)
|
106
|
+
|
107
|
+
this.#handleErrorMessage()
|
108
|
+
}
|
109
|
+
}, { element: this.inputElement })
|
125
110
|
|
126
|
-
|
127
|
-
|
111
|
+
createEventListener.call(this, 'change', () => {
|
112
|
+
this.#dispatchChange()
|
113
|
+
}, { element: this.baseElement })
|
128
114
|
|
129
|
-
|
130
|
-
this.
|
131
|
-
|
132
|
-
this
|
115
|
+
createEventListener.call(this, 'blur', () => {
|
116
|
+
if (!this.checkValidity()) {
|
117
|
+
this.setAttribute('invalid', 'true')
|
118
|
+
this.#handleErrorMessage()
|
119
|
+
}
|
133
120
|
})
|
134
121
|
|
122
|
+
createEventListener.call(this, 'focus', (e) => {
|
123
|
+
// when clicking on the form submit button and the input is invalid
|
124
|
+
// we want it to appear as invalid
|
125
|
+
if (e.relatedTarget?.form === this.form) {
|
126
|
+
if (!this.checkValidity()) {
|
127
|
+
this.setAttribute('invalid', 'true');
|
128
|
+
}
|
129
|
+
|
130
|
+
if (this.hasAttribute('invalid')) {
|
131
|
+
this.reportValidityOnInternalInput()
|
132
|
+
}
|
133
|
+
}
|
134
|
+
})
|
135
|
+
|
136
|
+
createEventListener.call(this, 'invalid', this.#handleErrorMessage)
|
137
|
+
|
138
|
+
this.handleInternalInputErrorMessage()
|
139
|
+
|
135
140
|
// this is needed in order to make sure the form input validation is working
|
141
|
+
// we do not want it to happen when the component is nested
|
136
142
|
if (!this.hasAttribute('tabindex') && this.getRootNode() === document) {
|
137
143
|
this.setAttribute('tabindex', 0);
|
138
144
|
}
|
139
145
|
|
140
146
|
// sync properties
|
141
147
|
propertyObserver(this, this.inputElement, 'value');
|
148
|
+
propertyObserver(this, this.inputElement, 'selectionStart');
|
142
149
|
this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
|
143
150
|
}
|
144
|
-
|
145
|
-
disconnectedCallback() {
|
146
|
-
this.removeEventListener('focus', this.#boundHandleFocus)
|
147
|
-
this.removeEventListener('invalid', this.#boundHandleInvalid)
|
148
|
-
this.removeEventListener('valid', this.#boundHandleValid)
|
149
|
-
}
|
150
|
-
|
151
|
-
attributeChangedCallback(attrName, oldValue, newValue) {
|
152
|
-
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
153
|
-
|
154
|
-
if (attrName === 'invalid' && newValue === '') {
|
155
|
-
this.setAttribute('invalid', 'true')
|
156
|
-
}
|
157
|
-
}
|
158
151
|
};
|
@@ -23,7 +23,7 @@ const [helperTheme, helperRefs, helperVars] =
|
|
23
23
|
verticalAlignment,
|
24
24
|
horizontalAlignment,
|
25
25
|
shadowColor: '#00000020' //if we want to support transparency vars, we should use different color format
|
26
|
-
},
|
26
|
+
}, Container.componentName)
|
27
27
|
|
28
28
|
const container = {
|
29
29
|
...helperTheme,
|
@@ -14,6 +14,7 @@ import divider from './divider';
|
|
14
14
|
import passcode from './passcode';
|
15
15
|
import { loaderRadial, loaderLinear } from './loader';
|
16
16
|
import comboBox from './comboBox';
|
17
|
+
import image from './image';
|
17
18
|
|
18
19
|
export default {
|
19
20
|
button,
|
@@ -32,5 +33,6 @@ export default {
|
|
32
33
|
passcode,
|
33
34
|
loaderRadial,
|
34
35
|
loaderLinear,
|
35
|
-
comboBox
|
36
|
+
comboBox,
|
37
|
+
image
|
36
38
|
};
|
package/dist/umd/775.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[775],{693:(e,t,s)=>{s.d(t,{s:()=>r});var n=s(2061),i=s(357);const o=e=>class extends e{#e=this.#t.bind(this);#t(e){this.setAttribute("hover","true"),e.target.addEventListener("mouseleave",(()=>this.shadowRoot.host.removeAttribute("hover")),{once:!0})}connectedCallback(){super.connectedCallback?.(),this.shadowRoot.querySelector(this.baseSelector).addEventListener("mouseover",this.#e)}},r=({componentName:e,baseSelector:t=""})=>{class s extends HTMLElement{static get componentName(){return e}#s;get baseSelector(){return t}get baseElement(){return this.#s??=this.baseSelector?this.rootElement.querySelector(this.baseSelector):this,this.#s}get rootElement(){return this.shadowRoot||this}}return(0,n.qC)(i.A,o)(s)}},5279:(e,t,s)=>{s.d(t,{gh:()=>n,k4:()=>i,qM:()=>r,qg:()=>o});const n="descope",i=3,o="host",r="@"},4567:(e,t,s)=>{s.d(t,{Db:()=>u,FX:()=>o,P$:()=>r,Tk:()=>h,iY:()=>d,oP:()=>c,tg:()=>l});var n=s(2061),i=s(5279);const o=(e,t,{excludeAttrs:s=[],includeAttrs:n=[]})=>{const i=Array.from(e.attributes).filter((e=>!s.includes(e.name)&&(!n.length||n.includes(e.name)))).map((e=>e.name));t(i),new MutationObserver((e=>{for(const i of e)"attributes"!==i.type||s.includes(i.attributeName)||n.length&&!n.includes(i.attributeName)||t([i.attributeName])})).observe(e,{attributes:!0})},r=(e,t)=>{t({addedNodes:Array.from(e.children),removedNodes:[]}),new MutationObserver((e=>{for(const s of e)"childList"===s.type&&t(s)})).observe(e,{childList:!0})},a=(e,t,s={})=>n=>{n.forEach((n=>{const i=s[n]||n,o=e.getAttribute(n);null!==o?t.getAttribute(i)!==o&&t.setAttribute(i,o):t.removeAttribute(i)}))},l=(e,t,s)=>{o(e,a(e,t),s),o(t,a(t,e),s)},d=e=>(0,n.E3)(i.gh,e),h=(...e)=>`--${(0,n.E3)(...e)}`,c=(e,t,s={})=>{o(e,a(e,t,s.mapAttrs),s)},u=(e,t,s=[])=>{if(!s.length)return;const n=s.reduce(((e,s)=>Object.assign(e,{[s]:{get:()=>t[s],set(e){t[s]=e}}})),{});Object.defineProperties(e,n)}},2061:(e,t,s)=>{s.d(t,{E3:()=>i,GL:()=>n,jC:()=>r,mf:()=>a,qC:()=>o});const n=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase(),i=(...e)=>n(e.filter((e=>!!e)).join("-")),o=(...e)=>t=>e.reduceRight(((e,t)=>t(e)),t),r=e=>e.charAt(0).toUpperCase()+e.slice(1),a=e=>"function"==typeof e},357:(e,t,s)=>{s.d(t,{A:()=>n});const n=e=>class extends e{#n(){const t=this.shadowRoot.host.tagName.toLowerCase();if(!e.componentName)throw Error('component name is not defined on super class, make sure you have a static get for "componentName"');if(t!==e.componentName)throw Error(`component name mismatch, expected "${e.componentName}", current "${t}"`)}connectedCallback(){super.connectedCallback?.(),this.shadowRoot.isConnected&&this.#n()}}},775:(e,t,s)=>{s.d(t,{li:()=>k,Ae:()=>f.A,DM:()=>m,yk:()=>h,e4:()=>c,pY:()=>A,wX:()=>g,Iw:()=>S,dj:()=>y});var n=s(5279),i=s(2061),o=s(4567),r=s(5561);const a=(e,...t)=>`var(${e}${t.length?` , ${a(...t)}`:""})`;class l{constructor(){this.styleMap=new Map}add(e,t,s){this.styleMap.has(e)||this.styleMap.set(e,[]),this.styleMap.set(e,[...this.styleMap.get(e),{property:t,value:s}])}toString(){return Array.from(this.styleMap.entries()).reduce(((e,[t,s])=>e+`${t} { \n${s.map((({property:e,value:t})=>`${e}: ${t}`)).join(";\n")} \n}\n\n`),"")}}const d=(e,t)=>Object.keys(t).reduce(((t,s)=>Object.assign(t,{[s]:(0,o.Tk)(e,s)})),{}),h=({mappings:e={}})=>t=>class extends t{static get cssVarList(){return{...t.cssVarList,...d(t.componentName,{...e})}}#i;#o;#r;#a;#l;#d;#h;#c;constructor({getRootElement:t,componentNameSuffix:s="",themeSection:o=n.qg,baseSelector:r}={}){super(),this.#a=s,this.#l=o,this.#d=t?.(this)||this.shadowRoot,this.#h=r??this.baseSelector,this.#c=Object.keys(e).map((e=>(0,i.E3)("st",s,e)))}get componentTheme(){return r.componentsThemeManager.currentTheme?.[t.componentName]||""}#u(){this.#o.innerHTML=this.componentTheme[this.#l]}#m(){this.#o=document.createElement("style"),this.#o.id="style-mixin-theme",this.#d.prepend(this.#o),this.#r=r.componentsThemeManager.onCurrentThemeChange(this.#u.bind(this)),this.#u()}#p(){this.#i=document.createElement("style"),this.#i.id="style-mixin-overrides";const e=(s=t.componentName,i=n.k4,Array(i).fill(`.${s}`).join(""));var s,i;this.#i.innerText=`:host(${e}) {}`,this.#d.append(this.#i)}#b(e,s){const n=this.#i?.sheet?.cssRules[0].style;if(!n)return;const i=(0,o.Tk)(t.componentName,e.replace(new RegExp("^st-"),""));s?n?.setProperty(i,s):n?.removeProperty(i)}#g(e=[]){for(const t of e)this.#c.includes(t)&&this.#b(t,this.getAttribute(t));this.#i.innerHTML=this.#i?.sheet?.cssRules[0].cssText}#v(){const s=document.createElement("style");s.id="style-mixin-mappings",s.innerHTML=((e,t,s)=>{const n=new l;return Object.keys(s).forEach((r=>{const l=((e,t)=>{const s={selector:"",property:(0,i.GL)(e)};return t&&Object.keys(t).length?Array.isArray(t)?t.map((e=>Object.assign({},s,e))):[Object.assign({},s,t)]:[s]})(r,s[r]),d=(0,o.Tk)(e,r);l.forEach((({selector:e,property:s})=>{n.add(((e="",t="")=>(0,i.mf)(t)?t(e):`${e}${/^[A-Za-z]/.test(t)?` ${t}`:t}`)(t,e),(0,i.mf)(s)?s():s,a(d))}))})),n.toString()})((0,i.E3)(t.componentName,this.#a),this.#h,e),this.#d.prepend(s)}#E(e){(this.#d.classList||this.#d.host.classList).add(e)}connectedCallback(){super.connectedCallback?.(),this.shadowRoot.isConnected&&(this.#E(t.componentName),this.#v(),this.#m(),this.#p(),(0,o.FX)(this,this.#g.bind(this),{}))}disconnectedCallback(){this.#r?.()}},c=e=>class extends e{#y=null;static get observedAttributes(){return[...e.observedAttributes||[],"draggable"]}constructor(){super(),this.#y=document.createElement("style"),this.#y.innerText="* { cursor: inherit!important }"}#f(e){e?this.shadowRoot.appendChild(this.#y):this.#y.remove()}attributeChangedCallback(e,t,s){super.attributeChangedCallback?.(e,t,s),"draggable"===e&&this.#f("true"===s)}};var u=s(693);const m=({componentName:e,wrappedEleName:t,slots:s=[],style:n,excludeAttrsSync:r=[],includeAttrsSync:a=[],includeForwardProps:l=[]})=>{const d=`\n\t\t<style id="create-proxy"></style>\n\t\t<${t}>\n\t\t<slot></slot>\n\t\t${s.map((e=>`<slot name="${e}" slot="${e}"></slot>`)).join("")}\n\t\t</${t}>\n\t`;class h extends((0,u.s)({componentName:e,baseSelector:t})){constructor(){super().attachShadow({mode:"open"}).innerHTML=d,this.hostElement=this.shadowRoot.host,this.shadowRoot.getElementById("create-proxy").innerHTML=(0,i.mf)(n)?n():n}#C=this.#A.bind(this);#A(){this.proxyElement.focus()}focus=this.#A;connectedCallback(){this.shadowRoot.isConnected&&(this.proxyElement=this.shadowRoot.querySelector(t),this.addEventListener("focus",this.#C),(0,o.Db)(this.hostElement,this.proxyElement,l),this.proxyElement.onkeydown=e=>{e.shiftKey&&9===e.keyCode&&this.getRootNode()===document&&(this.removeAttribute("tabindex"),setTimeout((()=>this.setAttribute("tabindex","0")),0))},(0,o.tg)(this.proxyElement,this.hostElement,{excludeAttrs:r,includeAttrs:a}))}attributeChangedCallback(){this.proxyElement}disconnectedCallback(){super.disconnectedCallback?.(),this.removeEventListener("focus",this.#C)}}return h};function p(e){this[`on${e}`]?.(),this.dispatchEvent(new Event(e))}const b=["required","pattern"],g=e=>class extends e{static get observedAttributes(){return[...e.observedAttributes||[],...b]}static get formAssociated(){return!0}#S=p.bind(this,"valid");#k=p.bind(this,"invalid");#M;#F;constructor(){super(),this.#M=this.attachInternals(),this.#F=this.#H.bind(this)}get defaultErrorMsgValueMissing(){return"Please fill out this field."}get defaultErrorMsgPatternMismatch(){return"Please match the requested format."}getErrorMessage(e){switch(!0){case e.valueMissing:return this.getAttribute("data-errormessage-value-missing")||this.defaultErrorMsgValueMissing;case e.patternMismatch||e.typeMismatch:return this.getAttribute("data-errormessage-pattern-mismatch")||this.defaultErrorMsgPatternMismatch;case e.customError:return this.validationMessage;default:return""}}setValidity(){const e=this.getValidity();this.#M.setValidity(e,this.getErrorMessage(e))}get validationMessage(){return this.#M.validationMessage}getValidity(){console.warn("getValidity","is not implemented")}checkValidity(){return this.#M.validity.valid}reportValidity(){return this.#M.reportValidity()}get validity(){return this.#M.validity}setCustomValidity(e){e?this.#M.setValidity({customError:!0},e):(this.#M.setValidity({}),this.setValidity())}get isRequired(){return this.hasAttribute("required")&&"false"!==this.getAttribute("required")}get pattern(){return this.getAttribute("pattern")}#H(){this.setValidity(),this.handleDispatchValidationEvents()}attributeChangedCallback(e,t,s){super.attributeChangedCallback?.(e,t,s),b.includes(e)&&this.setValidity()}handleDispatchValidationEvents(){this.checkValidity()?this.#S():this.#k()}connectedCallback(){super.connectedCallback?.(),this.addEventListener("input",this.#F),this.setValidity(),this.handleDispatchValidationEvents()}disconnectedCallback(){this.removeEventListener("input",this.#F)}},v=["invalid","has-error-message"],E=e=>{if(!e)return;let t=e;for(let e=0;e<10;e++)if(t=t.assignedElements()[0],"slot"!==t.localName)return t},y=e=>class extends(g(e)){static get observedAttributes(){return[...e.observedAttributes||[],...v]}#L;#V;#w;#x;constructor(){super(),this.#L=super.inputElement,this.#V=this.#I.bind(this),this.#w=this.#T.bind(this),this.#x=this.#O.bind(this),this.baseEle=this.shadowRoot.querySelector(this.baseSelector)}get inputElement(){const e=this.baseEle.shadowRoot.querySelector('slot[name="input"]'),t=this.baseEle.shadowRoot.querySelector('slot[name="textarea"]');if(this.#L??=E(e)||E(t),!this.#L)throw Error("no input was found");return this.#L}set inputElement(e){this.#L=e}getValidity(){return this.inputElement.validity}reportValidityOnInternalInput(){setTimeout((()=>{this.baseEle.focus(),this.inputElement.reportValidity()}))}reportValidity(){isValid||(this.setAttribute("invalid","true"),this.reportValidityOnInternalInput())}setInternalInputErrorMessage(){this.checkValidity()||this.inputElement.setCustomValidity(this.validationMessage)}#I(e){e.relatedTarget?.form&&(this.checkValidity()||this.setAttribute("invalid","true"),this.hasAttribute("invalid")&&this.reportValidityOnInternalInput())}#T(){this.setInternalInputErrorMessage(),this.setAttribute("error-message",this.validationMessage)}#O(){this.removeAttribute("invalid")}connectedCallback(){var e,t;super.connectedCallback?.(),this.addEventListener("focus",this.#V),this.addEventListener("invalid",this.#w),this.addEventListener("valid",this.#x),this.addEventListener("input",(()=>{this.inputElement.setCustomValidity(""),this.inputElement.checkValidity()||this.setInternalInputErrorMessage()})),this.hasAttribute("tabindex")||this.getRootNode()!==document||this.setAttribute("tabindex",0),e=this.inputElement,t="value",Object.defineProperty(this,t,{set:function(s){return e[t]=s},get:function(){return e[t]},configurable:!0}),this.setSelectionRange=this.inputElement.setSelectionRange?.bind(this.inputElement)}disconnectedCallback(){this.removeEventListener("focus",this.#V),this.removeEventListener("invalid",this.#w),this.removeEventListener("valid",this.#x)}attributeChangedCallback(e,t,s){super.attributeChangedCallback?.(e,t,s),"invalid"===e&&""===s&&this.setAttribute("invalid","true")}};var f=s(357);const C=["blur","focus","focusin","focusout"],A=e=>class extends e{#N=!1;#R;#$;#q;#P;#j;constructor(){super();for(const e of C)this[`dispatch${(0,i.jC)(e)}`]=function(){this.dispatchInputEvent(e)};this.#$=this.#I.bind(this),this.#q=this.#B.bind(this),this.#P=this.#D.bind(this),this.#j=this.#U.bind(this)}#I(e){this.isReadOnly?e.stopPropagation():e.isTrusted&&(e.stopPropagation(),this.setFocus(!0),e.target===this&&this.onFocus(e))}#U(e){e.isTrusted&&e.stopPropagation()}#D(e){e.isTrusted&&e.stopPropagation()}#B(e){e.isTrusted&&(e.stopPropagation(),this.setFocus(!1))}get isReadOnly(){return this.hasAttribute("readonly")&&"false"!==this.getAttribute("readonly")}setFocus(e){clearTimeout(this.#R),this.#R=setTimeout((()=>{this.#N!==e&&(this.#N=e,e?(this.dispatchFocus(),this.dispatchFocusin()):(this.dispatchBlur(),this.dispatchFocusout()))}))}onFocus(){console.warn("onFocus","is not implemented")}dispatchInputEvent(e){this[`on${e}`]?.(),this.dispatchEvent(new InputEvent(e))}connectedCallback(){super.connectedCallback?.(),this.addEventListener("focus",this.#$,!0),this.addEventListener("blur",this.#q,!0),this.addEventListener("focusin",this.#P),this.addEventListener("focusout",this.#j)}disconnectedCallback(){this.removeEventListener("focus",this.#$),this.removeEventListener("blur",this.#q),this.removeEventListener("focusin",this.#P),this.removeEventListener("focusout",this.#j)}},S=({name:e,selector:t,mappings:s={}})=>r=>{const a=e||(e=>e.replace(/[^\w\s]/gi,""))(t),l=h({mappings:s})(r);return class extends l{static get cssVarList(){return{...l.cssVarList,[a]:d((0,i.E3)(r.componentName,"_"+a),s)}}#X;constructor(){const e=e=>{const s=e.shadowRoot.querySelector(e.baseSelector),n=t?s.shadowRoot.querySelector(t):s;return n.shadowRoot||n};var s;super({getRootElement:e,componentNameSuffix:"_"+a,themeSection:n.qM+a,baseSelector:":host"}),this.#X=(s=e(this)).host||s}#_(){this.#X.onmouseenter=e=>{e.target.setAttribute("hover","true")},this.#X.onmouseleave=e=>{e.target.removeAttribute("hover")}}connectedCallback(){super.connectedCallback?.(),(0,o.oP)(this,this.#X,{excludeAttrs:["hover"]}),this.#_()}}},k=e=>class extends e{#z;#q;#G;#Y;#Z=p.bind(this,"change");constructor(){super(),this.#z=this.#K.bind(this),this.#q=this.#B.bind(this)}#K(e){e.isTrusted&&e.stopPropagation()}#B(){this.#Z()}connectedCallback(){super.connectedCallback?.(),this.#G=addEventListener.bind(),this.addEventListener("change",this.#z,!0),this.addEventListener("blur",this.#q)}disconnectedCallback(){this.removeEventListener("change",this.#z),this.removeEventListener("blur",this.#q)}}}}]);
|