@descope/web-components-ui 1.0.299 → 1.0.301

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/dist/cjs/index.cjs.js +287 -204
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.esm.js +230 -143
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/umd/1612.js +1 -1
  7. package/dist/umd/1621.js +2 -2
  8. package/dist/umd/3951.js +1 -1
  9. package/dist/umd/4024.js +1 -1
  10. package/dist/umd/4052.js +1 -1
  11. package/dist/umd/4746.js +1 -1
  12. package/dist/umd/5806.js +1 -1
  13. package/dist/umd/6770.js +1 -1
  14. package/dist/umd/7056.js +1 -1
  15. package/dist/umd/7531.js +1 -1
  16. package/dist/umd/7911.js +1 -1
  17. package/dist/umd/9092.js +2 -2
  18. package/dist/umd/9314.js +1 -1
  19. package/dist/umd/9423.js +2 -2
  20. package/dist/umd/9562.js +1 -1
  21. package/dist/umd/9927.js +1 -0
  22. package/dist/umd/DescopeDev.js +1 -1
  23. package/dist/umd/descope-button-index-js.js +1 -1
  24. package/dist/umd/descope-divider-index-js.js +1 -1
  25. package/dist/umd/descope-email-field-index-js.js +1 -1
  26. package/dist/umd/descope-enriched-text-index-js.js +1 -0
  27. package/dist/umd/descope-link-index-js.js +1 -1
  28. package/dist/umd/descope-new-password-descope-new-password-internal-index-js.js +1 -1
  29. package/dist/umd/descope-new-password-index-js.js +1 -1
  30. package/dist/umd/descope-text-index-js.js +1 -0
  31. package/dist/umd/descope-user-attribute-index-js.js +1 -1
  32. package/dist/umd/descope-user-auth-method-index-js.js +1 -1
  33. package/dist/umd/index.js +1 -1
  34. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  35. package/dist/umd/mapping-fields-descope-saml-group-mappings-index-js.js +1 -1
  36. package/package.json +3 -3
  37. package/src/components/descope-divider/DividerClass.js +1 -1
  38. package/src/components/descope-divider/index.js +1 -1
  39. package/src/components/descope-enriched-text/EnrichedTextClass.js +163 -0
  40. package/src/components/descope-enriched-text/consts.js +74 -0
  41. package/src/components/descope-link/LinkClass.js +1 -1
  42. package/src/components/descope-link/index.js +1 -1
  43. package/src/components/descope-new-password/descope-new-password-internal/NewPasswordInternal.js +9 -5
  44. package/src/components/descope-text/TextClass.js +64 -0
  45. package/src/components/descope-user-attribute/UserAttributeClass.js +1 -1
  46. package/src/components/descope-user-attribute/index.js +1 -1
  47. package/src/components/descope-user-auth-method/UserAuthMethodClass.js +1 -1
  48. package/src/components/descope-user-auth-method/index.js +1 -1
  49. package/src/components/mapping-fields/descope-mappings-field/MappingsFieldClass.js +1 -1
  50. package/src/components/mapping-fields/descope-mappings-field/index.js +1 -1
  51. package/src/index.cjs.js +2 -2
  52. package/src/index.d.ts +2 -2
  53. package/src/index.js +2 -2
  54. package/src/theme/components/enrichedText.js +4 -1
  55. package/src/theme/components/text.js +1 -1
  56. package/dist/umd/4569.js +0 -1
  57. package/dist/umd/text-components-descope-enriched-text-index-js.js +0 -1
  58. package/dist/umd/text-components-descope-text-index-js.js +0 -1
  59. package/src/components/text-components/createBaseTextClass.js +0 -26
  60. package/src/components/text-components/descope-enriched-text/EnrichedTextClass.js +0 -106
  61. package/src/components/text-components/descope-enriched-text/helpers.js +0 -41
  62. package/src/components/text-components/descope-text/TextClass.js +0 -34
  63. package/src/components/text-components/hideWhenEmptyMixin.js +0 -17
  64. /package/src/components/{text-components/descope-enriched-text → descope-enriched-text}/index.js +0 -0
  65. /package/src/components/{text-components/descope-text → descope-text}/index.js +0 -0
@@ -1 +0,0 @@
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":""}))}}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[7433],{2663:(t,e,o)=>{o.d(e,{T:()=>n});var s=o(3346);const n=t=>{class e extends((0,s.s)({componentName:t,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 e}},1611:(t,e,o)=>{o.d(e,{f:()=>l,k:()=>c});var s=o(4978),n=o(2061),r=o(4567),i=o(5753),h=o(2663);const l=(0,r.iY)("text"),p=(0,h.T)(l),c=(0,n.qC)((0,s.yk)({mappings:{hostWidth:{selector:()=>":host",property:"width"},hostDirection:{selector:()=>":host",property:"direction"},fontSize:{},textColor:{property:"color"},textLineHeight:{property:"line-height"},textLetterSpacing:{property:"letter-spacing"},textShadow:{},textAlign:{},textTransform:{},fontFamily:{},fontStyle:{},fontWeight:{},borderWidth:{},borderStyle:{},borderColor:{}}}),s.e4,s.Ae,i.y)(p)},4803:(t,e,o)=>{o.r(e),o.d(e,{TextClass:()=>s.k});var s=o(1611);customElements.define(s.f,s.k)},5753:(t,e,o)=>{o.d(e,{y:()=>n});var s=o(4567);const n=t=>class extends t{get hideWhenEmpty(){return"true"===this.getAttribute("hide-when-empty")}init(){super.init(),(0,s.P$)(this,(()=>{const t=!!this.childNodes.length;this.style.display=!t&&this.hideWhenEmpty?"none":""}))}}}}]);
@@ -1,26 +0,0 @@
1
- import { createBaseClass } from '../../baseClasses/createBaseClass';
2
-
3
- export const createBaseTextClass = (componentName) => {
4
- class BaseText extends createBaseClass({ componentName, baseSelector: ':host > slot' }) {
5
- constructor() {
6
- super();
7
-
8
- this.attachShadow({ mode: 'open' }).innerHTML = `
9
- <style>
10
- :host {
11
- display: inline-block;
12
- }
13
- :host > slot {
14
- width: 100%;
15
- display: inline-block;
16
- }
17
- </style>
18
- <slot part="text-wrapper"></slot>
19
- `;
20
-
21
- this.textSlot = this.shadowRoot.querySelector('slot');
22
- }
23
- }
24
-
25
- return BaseText;
26
- };
@@ -1,106 +0,0 @@
1
- import markdownit from 'markdown-it';
2
- import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../../mixins';
3
- import { compose } from '../../../helpers';
4
- import { getComponentName } from '../../../helpers/componentHelpers';
5
- import { hideWhenEmptyMixin } from '../hideWhenEmptyMixin';
6
- import { createBaseTextClass } from '../createBaseTextClass';
7
- import { enrichTokens, onClipboardCopy } from './helpers';
8
-
9
- export const componentName = getComponentName('enriched-text');
10
-
11
- const BaseEnrichedTextClass = createBaseTextClass(componentName);
12
-
13
- const EnrichedTextMixin = (superclass) =>
14
- class EnrichedTextMixinClass extends superclass {
15
- static get observedAttributes() {
16
- return ['disabled-rules', 'line-break', 'readonly'];
17
- }
18
-
19
- get lineBreak() {
20
- return this.getAttribute('line-break');
21
- }
22
-
23
- get disabledRules() {
24
- return (this.getAttribute('disabled-rules') || '').split(',').filter(Boolean);
25
- }
26
-
27
- init() {
28
- super.init();
29
- this.#initProcessor();
30
- this.textSlot.addEventListener('slotchange', this.#parseChildren.bind(this));
31
- }
32
-
33
- attributeChangedCallback(attrName, oldValue, newValue) {
34
- super.attributeChangedCallback?.(attrName, oldValue, newValue);
35
-
36
- if (attrName === 'disabled-rules') {
37
- if (newValue !== oldValue) {
38
- this.#initProcessor(newValue);
39
- this.#parseChildren();
40
- }
41
- }
42
-
43
- if (attrName === 'readonly') {
44
- this.onReadOnlyChange(newValue !== null);
45
- }
46
- }
47
-
48
- #initProcessor() {
49
- this.processor = markdownit({ breaks: this.lineBreak }).disable(this.disabledRules);
50
- }
51
-
52
- #parseChildren() {
53
- const node = this.textSlot.assignedNodes({ flatten: true })?.[0];
54
-
55
- if (node && node.nodeType === Node.TEXT_NODE) {
56
- const tokens = this.processor.parse(node.textContent, { references: undefined });
57
- const result = this.processor.renderer.render(enrichTokens(tokens), {
58
- breaks: this.lineBreak,
59
- });
60
-
61
- if (result !== node.textContent) {
62
- const span = document.createElement('div');
63
- span.classList.add('enriched-text');
64
- // eslint-disable-next-line no-use-before-define
65
- span.innerHTML = `${getStyleReset()}${result}`;
66
- span.addEventListener('copy', onClipboardCopy);
67
- node.parentNode.replaceChild(span, node);
68
- }
69
- }
70
- }
71
-
72
- onReadOnlyChange(val) {
73
- this.setAttribute('inert', val);
74
- }
75
- };
76
-
77
- export const EnrichedTextClass = compose(
78
- createStyleMixin({
79
- mappings: {
80
- hostWidth: { selector: () => ':host', property: 'width' },
81
- hostDirection: { selector: () => ':host', property: 'direction' },
82
- fontSize: {},
83
- fontFamily: {},
84
- fontWeight: {},
85
- textColor: { property: 'color' },
86
- textLineHeight: { property: 'line-height' },
87
- marginReset: { selector: '*', property: 'margin' },
88
- textAlign: {},
89
- },
90
- }),
91
- draggableMixin,
92
- componentNameValidationMixin,
93
- EnrichedTextMixin,
94
- hideWhenEmptyMixin
95
- )(BaseEnrichedTextClass);
96
-
97
- function getStyleReset() {
98
- return `
99
- <style>
100
- .enriched-text > * { margin:0 }
101
- .enriched-text > *:not(:only-child):not(:last-child) {
102
- margin-bottom: var(${EnrichedTextClass.cssVarList.textLineHeight})
103
- }
104
- </style>
105
- `;
106
- }
@@ -1,41 +0,0 @@
1
- const customEleMap = {
2
- a: 'descope-link',
3
- };
4
-
5
- const getTokenTag = (token) => customEleMap[token.tag] || token.tag;
6
-
7
- const isImageToken = (token) => token?.children?.[0].type === 'image';
8
-
9
- export const enrichTokens = (tokens) =>
10
- tokens.map((token) => {
11
- const tag = getTokenTag(token);
12
-
13
- if (isImageToken(token)) {
14
- token.children[0].attrs.push(['style', 'width:100%']);
15
- return {
16
- ...token,
17
- tag,
18
- };
19
- }
20
-
21
- if (token?.children?.length > 0) {
22
- return {
23
- ...token,
24
- tag,
25
- children: enrichTokens(token.children),
26
- };
27
- }
28
-
29
- return {
30
- ...token,
31
- tag,
32
- };
33
- });
34
-
35
- export const onClipboardCopy = (e) => {
36
- const selection = document.getSelection().toString();
37
- const clipdata = e.clipboardData || window.clipboardData;
38
- clipdata.setData('text/plain', selection);
39
- clipdata.setData('text/html', selection);
40
- e.preventDefault();
41
- };
@@ -1,34 +0,0 @@
1
- import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../../mixins';
2
- import { compose } from '../../../helpers';
3
- import { getComponentName } from '../../../helpers/componentHelpers';
4
- import { hideWhenEmptyMixin } from '../hideWhenEmptyMixin';
5
- import { createBaseTextClass } from '../createBaseTextClass';
6
-
7
- export const componentName = getComponentName('text');
8
-
9
- const BaseTextClass = createBaseTextClass(componentName);
10
-
11
- export const TextClass = compose(
12
- createStyleMixin({
13
- mappings: {
14
- hostWidth: { selector: () => ':host', property: 'width' },
15
- hostDirection: { selector: () => ':host', property: 'direction' },
16
- fontSize: {},
17
- textColor: { property: 'color' },
18
- textLineHeight: { property: 'line-height' },
19
- textLetterSpacing: { property: 'letter-spacing' },
20
- textShadow: {},
21
- textAlign: {},
22
- textTransform: {},
23
- fontFamily: {},
24
- fontStyle: {},
25
- fontWeight: {},
26
- borderWidth: {},
27
- borderStyle: {},
28
- borderColor: {},
29
- },
30
- }),
31
- draggableMixin,
32
- componentNameValidationMixin,
33
- hideWhenEmptyMixin
34
- )(BaseTextClass);
@@ -1,17 +0,0 @@
1
- import { observeChildren } from '../../helpers/componentHelpers';
2
-
3
- export const hideWhenEmptyMixin = (superclass) =>
4
- class HideWhenEmptyMixinClass extends superclass {
5
- get hideWhenEmpty() {
6
- return this.getAttribute('hide-when-empty') === 'true';
7
- }
8
-
9
- init() {
10
- super.init();
11
-
12
- observeChildren(this, () => {
13
- const hasChildren = !!this.childNodes.length;
14
- this.style.display = !hasChildren && this.hideWhenEmpty ? 'none' : '';
15
- });
16
- }
17
- };