@descope/web-components-ui 1.0.61 → 1.0.63
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.cjs.js +95 -21
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +967 -784
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/447.js +1 -1
- package/dist/umd/666.js +37 -0
- package/dist/umd/725.js +1 -37
- package/dist/umd/descope-button-index-js.js +1 -1
- package/dist/umd/descope-checkbox-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-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/BaseInputClass.js +3 -0
- package/src/components/descope-button/Button.js +14 -10
- package/src/components/descope-checkbox/Checkbox.js +10 -7
- package/src/components/descope-container/Container.js +12 -7
- package/src/components/descope-date-picker/index.js +3 -3
- package/src/components/descope-divider/Divider.js +35 -30
- package/src/components/descope-email-field/EmailField.js +5 -5
- package/src/components/descope-link/Link.js +19 -27
- package/src/components/descope-loader-linear/LoaderLinear.js +12 -7
- package/src/components/descope-loader-radial/LoaderRadial.js +5 -5
- package/src/components/descope-logo/Logo.js +4 -4
- package/src/components/descope-number-field/NumberField.js +5 -5
- package/src/components/descope-passcode/Passcode.js +52 -71
- package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +43 -71
- package/src/components/descope-password-field/PasswordField.js +5 -5
- package/src/components/descope-switch-toggle/SwitchToggle.js +10 -7
- package/src/components/descope-text/Text.js +18 -9
- package/src/components/descope-text-area/TextArea.js +9 -8
- package/src/components/descope-text-field/TextField.js +5 -5
- package/src/components/descope-text-field/textFieldMappings.js +3 -5
- package/src/constants.js +1 -0
- package/src/dev/index.js +2 -2
- package/src/{componentsHelpers/createProxy/helpers.js → helpers/componentHelpers.js} +13 -5
- package/src/{helpers.js → helpers/index.js} +5 -2
- package/src/helpers/themeHelpers/componentsThemeManager.js +40 -0
- package/src/{themeHelpers → helpers/themeHelpers}/index.js +56 -21
- package/src/index.cjs.js +1 -1
- package/src/index.js +5 -5
- package/src/index.umd.js +4 -0
- package/src/{componentsHelpers/createProxy/index.js → mixins/createProxy.js} +4 -4
- package/src/{componentsHelpers → mixins}/createStyleMixin/helpers.js +14 -15
- package/src/mixins/createStyleMixin/index.js +109 -0
- package/src/mixins/index.js +7 -0
- package/src/mixins/inputMixin.js +173 -0
- package/src/mixins/proxyInputMixin.js +152 -0
- package/src/theme/components/button.js +2 -2
- package/src/theme/components/checkbox.js +2 -1
- package/src/theme/components/container.js +2 -2
- package/src/theme/components/divider.js +17 -9
- package/src/theme/components/link.js +1 -1
- package/src/theme/components/loader/loaderLinear.js +1 -1
- package/src/theme/components/loader/loaderRadial.js +1 -1
- package/src/theme/components/text.js +1 -1
- package/src/theme/components/textArea.js +2 -1
- package/src/theme/components/textField.js +2 -2
- package/src/theme/globals.js +3 -3
- package/dist/umd/832.js +0 -1
- package/dist/umd/942.js +0 -1
- package/dist/umd/descope-combo-index-js.js +0 -1
- package/src/components/descope-combo/index.js +0 -27
- package/src/componentsHelpers/createStyleMixin/index.js +0 -114
- package/src/componentsHelpers/enforceNestingElementsStylesMixin.js +0 -95
- package/src/componentsHelpers/index.js +0 -15
- package/src/componentsHelpers/inputMixin.js +0 -94
- /package/dist/umd/{725.js.LICENSE.txt → 666.js.LICENSE.txt} +0 -0
- /package/src/{themeHelpers/processColors.js → helpers/themeHelpers/colorsHelpers.js} +0 -0
- /package/src/{componentsHelpers → mixins}/componentNameValidationMixin.js +0 -0
- /package/src/{componentsHelpers → mixins}/draggableMixin.js +0 -0
- /package/src/{componentsHelpers → mixins}/hoverableMixin.js +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
import globals from '../globals';
|
2
|
-
import { getThemeRefs } from '../../themeHelpers';
|
2
|
+
import { getThemeRefs } from '../../helpers/themeHelpers';
|
3
3
|
import TextField from '../../components/descope-text-field/TextField';
|
4
4
|
|
5
5
|
const globalRefs = getThemeRefs(globals);
|
@@ -63,7 +63,7 @@ export const textField = (vars) => ({
|
|
63
63
|
[vars.borderColor]: globalRefs.colors.surface.main
|
64
64
|
},
|
65
65
|
|
66
|
-
|
66
|
+
_invalid: {
|
67
67
|
[vars.borderColor]: globalRefs.colors.error.main,
|
68
68
|
[vars.color]: globalRefs.colors.error.main,
|
69
69
|
[vars.placeholderColor]: globalRefs.colors.error.light
|
package/src/theme/globals.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import { getThemeRefs } from '../themeHelpers';
|
2
|
-
import { genColors } from '../themeHelpers/
|
1
|
+
import { getThemeRefs } from '../helpers/themeHelpers';
|
2
|
+
import { genColors } from '../helpers/themeHelpers/colorsHelpers';
|
3
3
|
|
4
4
|
export const colors = genColors({
|
5
5
|
surface: {
|
6
6
|
main: 'lightgray',
|
7
7
|
light: '#fff',
|
8
|
-
dark: '#000'
|
8
|
+
dark: '#000',
|
9
9
|
},
|
10
10
|
primary: '#0082B5',
|
11
11
|
secondary: '#7D14EB',
|
package/dist/umd/832.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[832],{9989:(t,e,s)=>{s.d(e,{V:()=>n});class n extends HTMLElement{}},9201:(t,e,s)=>{s.d(e,{Db:()=>a,oP:()=>i,tg:()=>r});const n=(t,e,{excludeAttrs:s=[],includeAttrs:n=[]})=>{e(...Array.from(t.attributes).filter((t=>!s.includes(t.name)&&(!n.length||n.includes(t.name)))).map((t=>t.name))),new MutationObserver((t=>{for(const o of t)"attributes"!==o.type||s.includes(o.attributeName)||n.length&&!n.includes(o.attributeName)||e([o.attributeName])})).observe(t,{attributes:!0})},o=(t,e,s={})=>(...n)=>{n.forEach((n=>{const o=s[n]||n,r=t.getAttribute(n);null!==r?e.getAttribute(o)!==r&&e.setAttribute(o,r):e.removeAttribute(o)}))},r=(t,e,s)=>{n(t,o(t,e),s),n(e,o(e,t),s)},i=(t,e,s={})=>{n(t,o(t,e,s.mapAttrs),s)},a=(t,e,s=[])=>{if(!s.length)return;const n=s.reduce(((t,s)=>Object.assign(t,{[s]:{get:()=>e[s],set(t){e[s]=t}}})),{});Object.defineProperties(t,n)}},3535:(t,e,s)=>{s.d(e,{SP:()=>a,wj:()=>i,zy:()=>l});var n=s(6225);const o=(t,...e)=>`var(${t}${e.length?` , ${o(...e)}`:""})`;class r{constructor(){this.styleMap=new Map}add(t,e,s){this.styleMap.has(t)||this.styleMap.set(t,[]),this.styleMap.set(t,[...this.styleMap.get(t),{property:e,value:s}])}toString(){return Array.from(this.styleMap.entries()).reduce(((t,[e,s])=>t+`${e} { \n${s.map((({property:t,value:e})=>`${t}: ${e}`)).join(";\n")} \n}\n\n`),"")}}const i=(t,e,s)=>{const i=new r;return Object.keys(s).forEach((r=>{const a=((t,e)=>{const s={selector:"",property:(0,n.GL)(t)};return e&&Object.keys(e).length?Array.isArray(e)?e.map((t=>Object.assign({},s,t))):[Object.assign({},s,e)]:[s]})(r,s[r]),l=(0,n.Tk)(t,r);a.forEach((({selector:t,property:s})=>{i.add(((t="",e="")=>"function"==typeof e?e(t):`${t}${/^[A-Za-z]/.test(e)?` ${e}`:e}`)(e,t),s,o(l))}))})),i.toString()},a=(t,e)=>Object.keys(e).reduce(((e,s)=>Object.assign(e,{[s]:(0,n.Tk)(t,s)})),{}),l=(t={})=>[t,{...t,selector:()=>`:host${t.selector||""}`}]},893:(t,e,s)=>{s.d(e,{_:()=>n});const n=(t="")=>e=>class extends e{connectedCallback(){super.connectedCallback?.(),this.shadowRoot.querySelector(this.baseSelector+t).addEventListener("mouseover",(t=>{this.shadowRoot.host.setAttribute("hover","true"),t.target.addEventListener("mouseleave",(()=>this.shadowRoot.host.removeAttribute("hover")),{once:!0})}))}}},832:(t,e,s)=>{s.d(e,{Ae:()=>m,qC:()=>y,DM:()=>h,yk:()=>r,e4:()=>i,iY:()=>p,y7:()=>u});var n=s(6225),o=s(3535);const r=({mappings:t={},nestedMappings:e={}})=>s=>{const r=Object.keys(t).map((t=>(0,n.E3)("st",t)));return class extends s{static get observedAttributes(){return[...s.observedAttributes||[],...r]}static get cssVarList(){return(0,o.SP)(s.componentName,{...t,...e})}#t=null;constructor(){super(),this.#e(),this.#s()}#s(){this.#t=document.createElement("style"),this.#t.id="style-mixin-overrides",this.#t.innerText="* {}",this.shadowRoot.prepend(this.#t)}#n(t,e){const o=this.#t.sheet?.cssRules[0].style,r=(0,n.Tk)(s.componentName,t.replace(/^st-/,""));e?o?.setProperty(r,e):o?.removeProperty(r)}#e(){const e=document.createElement("style");e.id="style-mixin-component",e.innerHTML=(0,o.wj)(s.componentName,this.baseSelector,t),this.shadowRoot.prepend(e)}#o(){const t=this.shadowRoot.host.getRootNode(),n=`${s.componentName}-style-mixin-component`,r=s.componentName;if(this.shadowRoot.host.classList.add(r),t.querySelector(`style#${n}`))return;const i=document.createElement("style");i.id=n,i.innerHTML=(0,o.wj)(s.componentName,`${s.componentName}${Array(3).fill(`.${r}`).join("")}`,e),"#document"===t.nodeName?t.head.append(i):t.append(i)}attributeChangedCallback(t,e,s){super.attributeChangedCallback?.(t,e,s),r.includes(t)&&this.#n(t,s)}connectedCallback(){super.connectedCallback?.(),this.shadowRoot.isConnected&&(this.#o(),Array.from(this.attributes).forEach((t=>{r.includes(t.nodeName)&&this.#n(t.nodeName,t.value)})))}}},i=t=>class extends t{#t=null;static get observedAttributes(){return[...t.observedAttributes||[],"draggable"]}constructor(){super(),this.#t=document.createElement("style"),this.#t.innerText=`${this.baseSelector} { cursor: inherit }`}#r(t){t?this.shadowRoot.appendChild(this.#t):this.#t.remove()}attributeChangedCallback(t,e,s){super.attributeChangedCallback?.(t,e,s),"draggable"===t&&this.#r("true"===s)}};var a=s(9989),l=s(893),c=s(9201);const h=({componentName:t,wrappedEleName:e,slots:s=[],style:n,excludeAttrsSync:o=[],includeAttrsSync:r=[],includeForwardProps:i=[]})=>{const h=`\n\t\t<style id="create-proxy"></style>\n\t\t<${e}>\n\t\t<slot></slot>\n\t\t${s.map((t=>`<slot name="${t}" slot="${t}"></slot>`)).join("")}\n\t\t</${e}>\n\t`;class d extends a.V{static get componentName(){return t}constructor(){super().attachShadow({mode:"open"}).innerHTML=h,this.hostElement=this.shadowRoot.host,this.baseSelector=e,this.shadowRoot.getElementById("create-proxy").innerHTML="function"==typeof n?n():n}connectedCallback(){this.shadowRoot.isConnected&&(this.proxyElement=this.shadowRoot.querySelector(e),(0,c.Db)(this.hostElement,this.proxyElement,i),this.setAttribute("tabindex","0"),this.addEventListener("focus",(()=>{this.proxyElement.focus()})),this.proxyElement.onkeydown=t=>{t.shiftKey&&9===t.keyCode&&(this.removeAttribute("tabindex"),setTimeout((()=>this.setAttribute("tabindex","0")),0))},this.addEventListener=(...t)=>this.proxyElement.addEventListener(...t),(0,c.tg)(this.proxyElement,this.hostElement,{excludeAttrs:o,includeAttrs:r}))}disconnectedCallback(){this.proxyElement.removeEventListener("mouseover",this.mouseoverCbRef)}attributeChangedCallback(){this.proxyElement}}return y((0,l._)())(d)},d=["invalid","has-error-message"],u=t=>class extends t{static get formAssociated(){return!0}#i;constructor(){super(),this.#i=this.attachInternals()}formAssociatedCallback(){this.setValidity?.()}setValidationAttribute(t){const e=this.getAttribute(t);e&&this.proxyElement.setAttribute("error-message",e),d.forEach((t=>this.proxyElement.setAttribute(t,"true")))}validate(){const{valueMissing:t,patternMismatch:e,typeMismatch:s}=this.validity;t?this.setValidationAttribute("data-errormessage-value-missing"):(s||e)&&this.setValidationAttribute("data-errormessage-pattern-mismatch")}connectedCallback(){if(super.connectedCallback?.(),this.baseEle=this.shadowRoot.querySelector(this.baseSelector),this.hasAttribute("tabindex")||this.setAttribute("tabindex",0),this.inputElement??=this.baseEle.shadowRoot.querySelector('slot[name="input"]')?.assignedElements()[0]||this.baseEle.shadowRoot.querySelector('slot[name="textarea"]')?.assignedElements()[0],!this.inputElement)throw Error("no input was found");var t,e;t=this.inputElement,e="value",Object.defineProperty(this,e,{set:function(s){return t[e]=s},get:function(){return t[e]},configurable:!0}),this.setSelectionRange=this.inputElement.setSelectionRange?.bind(this.inputElement),this.validity=this.inputElement.validity,this.setValidity=()=>{this.#i.setValidity(this.inputElement.validity,this.inputElement.validationMessage)},this.inputElement.oninput=()=>{this.value=this.inputElement.value,this.setValidity()},this.onfocus=()=>{setTimeout((()=>this.inputElement.reportValidity()),0),this.validate()},this.inputElement.oninvalid=()=>{this.validate()}}},m=t=>class extends t{#a(){const e=this.shadowRoot.host.tagName.toLowerCase();if(!t.componentName)throw Error('component name is not defined on super class, make sure you have a static get for "componentName"');if(e!==t.componentName)throw Error(`component name mismatch, expected "${t.componentName}", current "${e}"`)}connectedCallback(){super.connectedCallback?.(),this.shadowRoot.isConnected&&this.#a()}},p=t=>(0,n.E3)("descope",t),y=(...t)=>e=>t.reduceRight(((t,e)=>e(t)),e)},6225:(t,e,s)=>{s.d(e,{E3:()=>o,GL:()=>n,Tk:()=>r});const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase(),o=(...t)=>n(t.join("-")),r=(...t)=>`--${o(...t.filter((t=>!!t)))}`}}]);
|
package/dist/umd/942.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[942],{4942:(o,t,s)=>{s.d(t,{s:()=>c});var e=s(9201);const h=(o,t)=>{t.append(...o.childNodes),o.appendChild(t)},c=({nestingElementTagName:o,nestingElementDestSlotName:t,forwardAttrOptions:s})=>c=>{const d=()=>Object.assign(document.createElement(o),{slot:t});let i;const a=()=>i;return class extends c{constructor(){var t;super(),t=()=>{a().disconnect(this.shadowRoot.host);const t=this.shadowRoot.host.querySelector(o),c=this.shadowRoot.host.childNodes.length>0;!t&&c?h(this.shadowRoot.host,d()):t&&c?(this.shadowRoot.host.querySelector(child).remove(),h(this.shadowRoot.host,d())):t&&!c&&this.shadowRoot.host.querySelector(child).remove(),this.shadowRoot.host.querySelector(o)&&(0,e.oP)(this.shadowRoot.host,this.shadowRoot.host.querySelector(o),s),a().observe(this.shadowRoot.host,{childList:!0})},i=new MutationObserver((o=>{for(const s of o)"childList"===s.type&&t()}))}connectedCallback(){super.connectedCallback?.(),this.shadowRoot.host.childNodes.length>0&&(h(this.shadowRoot.host,d()),(0,e.oP)(this.shadowRoot.host,this.shadowRoot.host.querySelector(o),s)),a().observe(this.shadowRoot.host,{childList:!0})}}}}}]);
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[247],{2798:(e,t,o)=>{o.r(t),o.d(t,{Combo:()=>p});var n=o(9989),c=o(832);o(3029),o(9357);const s=document.createElement("template"),d=(0,c.iY)("combo");s.innerHTML="\n <descope-button></descope-button>\n <descope-text-field></descope-text-field>\n";class p extends n.V{constructor(){super(),this.attachShadow({mode:"open"}).appendChild(s.content.cloneNode(!0))}}customElements.define(d,p)}}]);
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { DescopeBaseClass } from '../../baseClasses/DescopeBaseClass';
|
2
|
-
import { getComponentName } from '../../componentsHelpers';
|
3
|
-
import '../descope-button';
|
4
|
-
import '../descope-text-field';
|
5
|
-
|
6
|
-
const template = document.createElement('template');
|
7
|
-
|
8
|
-
const componentName = getComponentName('combo');
|
9
|
-
|
10
|
-
template.innerHTML = `
|
11
|
-
<descope-button></descope-button>
|
12
|
-
<descope-text-field></descope-text-field>
|
13
|
-
`;
|
14
|
-
|
15
|
-
class Combo extends DescopeBaseClass {
|
16
|
-
constructor() {
|
17
|
-
super();
|
18
|
-
|
19
|
-
this.attachShadow({ mode: 'open' }).appendChild(
|
20
|
-
template.content.cloneNode(true)
|
21
|
-
);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
customElements.define(componentName, Combo);
|
26
|
-
|
27
|
-
export { Combo };
|
@@ -1,114 +0,0 @@
|
|
1
|
-
import { getCssVarName, kebabCaseJoin } from '../../helpers';
|
2
|
-
import { createStyle, createCssVarsList } from './helpers';
|
3
|
-
|
4
|
-
export const createStyleMixin =
|
5
|
-
({ mappings = {}, nestedMappings = {} }) =>
|
6
|
-
(superclass) => {
|
7
|
-
const styleAttributes = Object.keys(mappings).map((key) =>
|
8
|
-
kebabCaseJoin('st', key)
|
9
|
-
);
|
10
|
-
return class CustomStyleMixinClass extends superclass {
|
11
|
-
static get observedAttributes() {
|
12
|
-
const superAttrs = superclass.observedAttributes || [];
|
13
|
-
return [...superAttrs, ...styleAttributes];
|
14
|
-
}
|
15
|
-
|
16
|
-
static get cssVarList() {
|
17
|
-
return createCssVarsList(superclass.componentName, {
|
18
|
-
...mappings,
|
19
|
-
...nestedMappings
|
20
|
-
});
|
21
|
-
}
|
22
|
-
|
23
|
-
#styleEle = null;
|
24
|
-
|
25
|
-
constructor() {
|
26
|
-
super();
|
27
|
-
|
28
|
-
this.#createComponentStyle();
|
29
|
-
this.#createAttrOverrideStyle();
|
30
|
-
}
|
31
|
-
|
32
|
-
#createAttrOverrideStyle() {
|
33
|
-
this.#styleEle = document.createElement('style');
|
34
|
-
this.#styleEle.id = 'style-mixin-overrides';
|
35
|
-
|
36
|
-
this.#styleEle.innerText = '* {}';
|
37
|
-
this.shadowRoot.prepend(this.#styleEle);
|
38
|
-
}
|
39
|
-
|
40
|
-
#updateAttrOverrideStyle(attrName, value) {
|
41
|
-
const style = this.#styleEle.sheet?.cssRules[0].style;
|
42
|
-
const varName = getCssVarName(
|
43
|
-
superclass.componentName,
|
44
|
-
attrName.replace(/^st-/, '')
|
45
|
-
);
|
46
|
-
|
47
|
-
if (value) style?.setProperty(varName, value);
|
48
|
-
else style?.removeProperty(varName);
|
49
|
-
}
|
50
|
-
|
51
|
-
#createComponentStyle() {
|
52
|
-
const themeStyle = document.createElement('style');
|
53
|
-
themeStyle.id = 'style-mixin-component';
|
54
|
-
themeStyle.innerHTML = createStyle(
|
55
|
-
superclass.componentName,
|
56
|
-
this.baseSelector,
|
57
|
-
mappings
|
58
|
-
);
|
59
|
-
this.shadowRoot.prepend(themeStyle);
|
60
|
-
}
|
61
|
-
|
62
|
-
#createComponentNestingStyle() {
|
63
|
-
// we need these selectors to be more specific from the theme selectors
|
64
|
-
// in order to do it, we are repeating the class name for specificity
|
65
|
-
const numOfClassNameSpecifier = 3;
|
66
|
-
|
67
|
-
const rootNode = this.shadowRoot.host.getRootNode();
|
68
|
-
const styleId = `${superclass.componentName}-style-mixin-component`;
|
69
|
-
|
70
|
-
const className = superclass.componentName;
|
71
|
-
this.shadowRoot.host.classList.add(className);
|
72
|
-
|
73
|
-
if (rootNode.querySelector(`style#${styleId}`)) return;
|
74
|
-
|
75
|
-
const themeStyle = document.createElement('style');
|
76
|
-
themeStyle.id = styleId;
|
77
|
-
themeStyle.innerHTML = createStyle(
|
78
|
-
superclass.componentName,
|
79
|
-
`${superclass.componentName}${Array(numOfClassNameSpecifier)
|
80
|
-
.fill(`.${className}`)
|
81
|
-
.join('')}`,
|
82
|
-
nestedMappings
|
83
|
-
);
|
84
|
-
|
85
|
-
// rootNode can be either a shadow DOM or a light DOM
|
86
|
-
if (rootNode.nodeName === '#document') {
|
87
|
-
rootNode.head.append(themeStyle);
|
88
|
-
} else {
|
89
|
-
rootNode.append(themeStyle);
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
attributeChangedCallback(attrName, oldValue, newValue) {
|
94
|
-
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
95
|
-
|
96
|
-
if (styleAttributes.includes(attrName)) {
|
97
|
-
this.#updateAttrOverrideStyle(attrName, newValue);
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
connectedCallback() {
|
102
|
-
super.connectedCallback?.();
|
103
|
-
if (this.shadowRoot.isConnected) {
|
104
|
-
this.#createComponentNestingStyle();
|
105
|
-
|
106
|
-
Array.from(this.attributes).forEach((attr) => {
|
107
|
-
if (styleAttributes.includes(attr.nodeName)) {
|
108
|
-
this.#updateAttrOverrideStyle(attr.nodeName, attr.value);
|
109
|
-
}
|
110
|
-
});
|
111
|
-
}
|
112
|
-
}
|
113
|
-
};
|
114
|
-
};
|
@@ -1,95 +0,0 @@
|
|
1
|
-
import { forwardAttrs } from '../componentsHelpers/createProxy/helpers';
|
2
|
-
|
3
|
-
const getChildObserver = (callback) => {
|
4
|
-
return new MutationObserver((mutationsList) => {
|
5
|
-
for (const mutation of mutationsList) {
|
6
|
-
if (mutation.type === 'childList') {
|
7
|
-
callback(mutation);
|
8
|
-
}
|
9
|
-
}
|
10
|
-
});
|
11
|
-
};
|
12
|
-
|
13
|
-
const insertNestingLevel = (srcEle, nestingEle) => {
|
14
|
-
nestingEle.append(...srcEle.childNodes);
|
15
|
-
srcEle.appendChild(nestingEle);
|
16
|
-
};
|
17
|
-
|
18
|
-
// adds a nesting element to the component, and move all existing children
|
19
|
-
// to be under the nesting element
|
20
|
-
export const enforceNestingElementsStylesMixin =
|
21
|
-
({ nestingElementTagName, nestingElementDestSlotName, forwardAttrOptions }) =>
|
22
|
-
(superclass) => {
|
23
|
-
const getChildNodeEle = () =>
|
24
|
-
Object.assign(document.createElement(nestingElementTagName), {
|
25
|
-
slot: nestingElementDestSlotName
|
26
|
-
});
|
27
|
-
|
28
|
-
let childObserver;
|
29
|
-
|
30
|
-
const getObserver = () => childObserver;
|
31
|
-
|
32
|
-
return class EnforceNestingElementsStylesMixinClass extends superclass {
|
33
|
-
constructor() {
|
34
|
-
super();
|
35
|
-
|
36
|
-
const childObserverCallback = () => {
|
37
|
-
// we are going to change the DOM, so we need to disconnect the observer before
|
38
|
-
// and reconnect it after the child component is added
|
39
|
-
getObserver().disconnect(this.shadowRoot.host);
|
40
|
-
|
41
|
-
const isNestingElementExist = this.shadowRoot.host.querySelector(nestingElementTagName);
|
42
|
-
const hasNewChildren = this.shadowRoot.host.childNodes.length > 0;
|
43
|
-
|
44
|
-
if (!isNestingElementExist && hasNewChildren) {
|
45
|
-
// if before there were no children and now there are children - insert
|
46
|
-
insertNestingLevel(this.shadowRoot.host, getChildNodeEle());
|
47
|
-
} else if (isNestingElementExist && hasNewChildren) {
|
48
|
-
// if children existed, and they changed -
|
49
|
-
// we need to update (move) the new children into
|
50
|
-
// descope-text and remove previous children
|
51
|
-
this.shadowRoot.host.querySelector(child).remove();
|
52
|
-
insertNestingLevel(this.shadowRoot.host, getChildNodeEle());
|
53
|
-
}
|
54
|
-
else if (isNestingElementExist && !hasNewChildren) {
|
55
|
-
// if children existed and now there are none -
|
56
|
-
// we need to remove descope-text completely
|
57
|
-
this.shadowRoot.host.querySelector(child).remove();
|
58
|
-
}
|
59
|
-
|
60
|
-
// we need a new observer, because we remove the nesting element
|
61
|
-
this.shadowRoot.host.querySelector(nestingElementTagName) &&
|
62
|
-
forwardAttrs(
|
63
|
-
this.shadowRoot.host,
|
64
|
-
this.shadowRoot.host.querySelector(nestingElementTagName),
|
65
|
-
forwardAttrOptions
|
66
|
-
);
|
67
|
-
|
68
|
-
getObserver().observe(this.shadowRoot.host, {
|
69
|
-
childList: true
|
70
|
-
});
|
71
|
-
};
|
72
|
-
|
73
|
-
childObserver = getChildObserver(childObserverCallback);
|
74
|
-
}
|
75
|
-
|
76
|
-
connectedCallback() {
|
77
|
-
super.connectedCallback?.();
|
78
|
-
|
79
|
-
if (this.shadowRoot.host.childNodes.length > 0) {
|
80
|
-
// on the first render - we want to move all component's children to be under descope-text
|
81
|
-
insertNestingLevel(this.shadowRoot.host, getChildNodeEle());
|
82
|
-
|
83
|
-
forwardAttrs(
|
84
|
-
this.shadowRoot.host,
|
85
|
-
this.shadowRoot.host.querySelector(nestingElementTagName),
|
86
|
-
forwardAttrOptions
|
87
|
-
);
|
88
|
-
}
|
89
|
-
|
90
|
-
getObserver().observe(this.shadowRoot.host, {
|
91
|
-
childList: true
|
92
|
-
});
|
93
|
-
}
|
94
|
-
};
|
95
|
-
};
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { DESCOPE_PREFIX } from '../constants';
|
2
|
-
import { kebabCaseJoin } from '../helpers';
|
3
|
-
|
4
|
-
export const getComponentName = (name) => kebabCaseJoin(DESCOPE_PREFIX, name);
|
5
|
-
|
6
|
-
export const compose =
|
7
|
-
(...fns) =>
|
8
|
-
(val) =>
|
9
|
-
fns.reduceRight((res, fn) => fn(res), val);
|
10
|
-
|
11
|
-
export { createStyleMixin } from './createStyleMixin';
|
12
|
-
export { draggableMixin } from './draggableMixin';
|
13
|
-
export { createProxy } from './createProxy';
|
14
|
-
export { inputMixin } from './inputMixin';
|
15
|
-
export { componentNameValidationMixin } from './componentNameValidationMixin';
|
@@ -1,94 +0,0 @@
|
|
1
|
-
const attrs = {
|
2
|
-
valueMissing: 'data-errormessage-value-missing',
|
3
|
-
patternMismatch: 'data-errormessage-pattern-mismatch'
|
4
|
-
};
|
5
|
-
|
6
|
-
const errorAttrs = ['invalid', 'has-error-message'];
|
7
|
-
|
8
|
-
const propertyObserver = (src, target, property) => {
|
9
|
-
Object.defineProperty(src, property, {
|
10
|
-
set: function (v) {
|
11
|
-
return (target[property] = v);
|
12
|
-
},
|
13
|
-
get: function () {
|
14
|
-
return target[property];
|
15
|
-
},
|
16
|
-
configurable: true
|
17
|
-
});
|
18
|
-
};
|
19
|
-
|
20
|
-
export const inputMixin = (superclass) =>
|
21
|
-
class InputMixinClass extends superclass {
|
22
|
-
static get formAssociated() {
|
23
|
-
return true;
|
24
|
-
}
|
25
|
-
|
26
|
-
#internals;
|
27
|
-
|
28
|
-
constructor() {
|
29
|
-
super();
|
30
|
-
|
31
|
-
this.#internals = this.attachInternals();
|
32
|
-
}
|
33
|
-
|
34
|
-
formAssociatedCallback() {
|
35
|
-
this.setValidity?.();
|
36
|
-
}
|
37
|
-
|
38
|
-
setValidationAttribute(attr) {
|
39
|
-
const validationAttr = this.getAttribute(attr);
|
40
|
-
if (validationAttr) {
|
41
|
-
this.proxyElement.setAttribute('error-message', validationAttr);
|
42
|
-
}
|
43
|
-
// normalize vaadin error attributes to have a boolean value
|
44
|
-
errorAttrs.forEach((att) => this.proxyElement.setAttribute(att, 'true'));
|
45
|
-
}
|
46
|
-
|
47
|
-
validate() {
|
48
|
-
const { valueMissing, patternMismatch, typeMismatch } = this.validity;
|
49
|
-
if (valueMissing) {
|
50
|
-
this.setValidationAttribute(attrs.valueMissing);
|
51
|
-
} else if (typeMismatch || patternMismatch) {
|
52
|
-
this.setValidationAttribute(attrs.patternMismatch);
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
connectedCallback() {
|
57
|
-
super.connectedCallback?.();
|
58
|
-
|
59
|
-
this.baseEle = this.shadowRoot.querySelector(this.baseSelector);
|
60
|
-
|
61
|
-
// this is needed in order to make sure the form input validation is working
|
62
|
-
if (!this.hasAttribute('tabindex')) {
|
63
|
-
this.setAttribute('tabindex', 0);
|
64
|
-
}
|
65
|
-
|
66
|
-
this.inputElement ??= this.baseEle.shadowRoot.querySelector('slot[name="input"]')?.assignedElements()[0] ||
|
67
|
-
this.baseEle.shadowRoot.querySelector('slot[name="textarea"]')?.assignedElements()[0]
|
68
|
-
if (!this.inputElement) throw Error('no input was found');
|
69
|
-
|
70
|
-
// sync properties
|
71
|
-
propertyObserver(this, this.inputElement, 'value');
|
72
|
-
this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
|
73
|
-
|
74
|
-
this.validity = this.inputElement.validity;
|
75
|
-
|
76
|
-
this.setValidity = () => {
|
77
|
-
this.#internals.setValidity(this.inputElement.validity, this.inputElement.validationMessage);
|
78
|
-
};
|
79
|
-
|
80
|
-
this.inputElement.oninput = () => {
|
81
|
-
this.value = this.inputElement.value;
|
82
|
-
this.setValidity();
|
83
|
-
};
|
84
|
-
|
85
|
-
this.onfocus = () => {
|
86
|
-
setTimeout(() => this.inputElement.reportValidity(), 0);
|
87
|
-
this.validate();
|
88
|
-
};
|
89
|
-
|
90
|
-
this.inputElement.oninvalid = () => {
|
91
|
-
this.validate();
|
92
|
-
};
|
93
|
-
}
|
94
|
-
};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|