@descope/web-components-ui 1.0.298 → 1.0.299
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/cjs/index.cjs.js +9 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/text-components-descope-enriched-text-index-js.js +1 -1
- package/package.json +1 -1
- package/src/components/text-components/descope-enriched-text/EnrichedTextClass.js +9 -1
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[657],{2663:(e,t,
|
1
|
+
"use strict";(self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[657],{2663:(e,t,n)=>{n.d(t,{T:()=>i});var s=n(3346);const i=e=>{class t extends((0,s.s)({componentName:e,baseSelector:":host > slot"})){constructor(){super(),this.attachShadow({mode:"open"}).innerHTML='\n <style>\n :host {\n display: inline-block;\n }\n :host > slot {\n width: 100%;\n display: inline-block;\n }\n </style>\n <slot part="text-wrapper"></slot>\n ',this.textSlot=this.shadowRoot.querySelector("slot")}}return t}},1655:(e,t,n)=>{n.r(t),n.d(t,{EnrichedTextClass:()=>g});var s=n(4569),i=n(4978),r=n(2061),o=n(4567),l=n(5753),a=n(2663);const d={a:"descope-link"},h=e=>e.map((e=>{const t=(e=>d[e.tag]||e.tag)(e);return(e=>"image"===e?.children?.[0].type)(e)?(e.children[0].attrs.push(["style","width:100%"]),{...e,tag:t}):e?.children?.length>0?{...e,tag:t,children:h(e.children)}:{...e,tag:t}})),c=e=>{const t=document.getSelection().toString(),n=e.clipboardData||window.clipboardData;n.setData("text/plain",t),n.setData("text/html",t),e.preventDefault()},p=(0,o.iY)("enriched-text"),u=(0,a.T)(p),g=(0,r.qC)((0,i.yk)({mappings:{hostWidth:{selector:()=>":host",property:"width"},hostDirection:{selector:()=>":host",property:"direction"},fontSize:{},fontFamily:{},fontWeight:{},textColor:{property:"color"},textLineHeight:{property:"line-height"},marginReset:{selector:"*",property:"margin"},textAlign:{}}}),i.e4,i.Ae,(e=>class extends e{static get observedAttributes(){return["disabled-rules","line-break","readonly"]}get lineBreak(){return this.getAttribute("line-break")}get disabledRules(){return(this.getAttribute("disabled-rules")||"").split(",").filter(Boolean)}init(){super.init(),this.#e(),this.textSlot.addEventListener("slotchange",this.#t.bind(this))}attributeChangedCallback(e,t,n){super.attributeChangedCallback?.(e,t,n),"disabled-rules"===e&&n!==t&&(this.#e(n),this.#t()),"readonly"===e&&this.onReadOnlyChange(null!==n)}#e(){this.processor=(0,s.Z)({breaks:this.lineBreak}).disable(this.disabledRules)}#t(){const e=this.textSlot.assignedNodes({flatten:!0})?.[0];if(e&&e.nodeType===Node.TEXT_NODE){const t=this.processor.parse(e.textContent,{references:void 0}),n=this.processor.renderer.render(h(t),{breaks:this.lineBreak});if(n!==e.textContent){const t=document.createElement("div");t.classList.add("enriched-text"),t.innerHTML=`\n <style>\n .enriched-text > * { margin:0 }\n .enriched-text > *:not(:only-child):not(:last-child) {\n margin-bottom: var(${g.cssVarList.textLineHeight})\n }\n </style>\n ${n}`,t.addEventListener("copy",c),e.parentNode.replaceChild(t,e)}}}onReadOnlyChange(e){this.setAttribute("inert",e)}}),l.y)(u);customElements.define(p,g)},5753:(e,t,n)=>{n.d(t,{y:()=>i});var s=n(4567);const i=e=>class extends e{get hideWhenEmpty(){return"true"===this.getAttribute("hide-when-empty")}init(){super.init(),(0,s.P$)(this,(()=>{const e=!!this.childNodes.length;this.style.display=!e&&this.hideWhenEmpty?"none":""}))}}}}]);
|
package/package.json
CHANGED
@@ -13,7 +13,7 @@ const BaseEnrichedTextClass = createBaseTextClass(componentName);
|
|
13
13
|
const EnrichedTextMixin = (superclass) =>
|
14
14
|
class EnrichedTextMixinClass extends superclass {
|
15
15
|
static get observedAttributes() {
|
16
|
-
return ['disabled-rules', 'line-break'];
|
16
|
+
return ['disabled-rules', 'line-break', 'readonly'];
|
17
17
|
}
|
18
18
|
|
19
19
|
get lineBreak() {
|
@@ -39,6 +39,10 @@ const EnrichedTextMixin = (superclass) =>
|
|
39
39
|
this.#parseChildren();
|
40
40
|
}
|
41
41
|
}
|
42
|
+
|
43
|
+
if (attrName === 'readonly') {
|
44
|
+
this.onReadOnlyChange(newValue !== null);
|
45
|
+
}
|
42
46
|
}
|
43
47
|
|
44
48
|
#initProcessor() {
|
@@ -64,6 +68,10 @@ const EnrichedTextMixin = (superclass) =>
|
|
64
68
|
}
|
65
69
|
}
|
66
70
|
}
|
71
|
+
|
72
|
+
onReadOnlyChange(val) {
|
73
|
+
this.setAttribute('inert', val);
|
74
|
+
}
|
67
75
|
};
|
68
76
|
|
69
77
|
export const EnrichedTextClass = compose(
|