@descope/web-components-ui 1.0.300 → 1.0.301

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.
Files changed (62) 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 +221 -138
  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-text-index-js.js +1 -0
  29. package/dist/umd/descope-user-attribute-index-js.js +1 -1
  30. package/dist/umd/descope-user-auth-method-index-js.js +1 -1
  31. package/dist/umd/index.js +1 -1
  32. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  33. package/dist/umd/mapping-fields-descope-saml-group-mappings-index-js.js +1 -1
  34. package/package.json +3 -3
  35. package/src/components/descope-divider/DividerClass.js +1 -1
  36. package/src/components/descope-divider/index.js +1 -1
  37. package/src/components/descope-enriched-text/EnrichedTextClass.js +163 -0
  38. package/src/components/descope-enriched-text/consts.js +74 -0
  39. package/src/components/descope-link/LinkClass.js +1 -1
  40. package/src/components/descope-link/index.js +1 -1
  41. package/src/components/descope-text/TextClass.js +64 -0
  42. package/src/components/descope-user-attribute/UserAttributeClass.js +1 -1
  43. package/src/components/descope-user-attribute/index.js +1 -1
  44. package/src/components/descope-user-auth-method/UserAuthMethodClass.js +1 -1
  45. package/src/components/descope-user-auth-method/index.js +1 -1
  46. package/src/components/mapping-fields/descope-mappings-field/MappingsFieldClass.js +1 -1
  47. package/src/components/mapping-fields/descope-mappings-field/index.js +1 -1
  48. package/src/index.cjs.js +2 -2
  49. package/src/index.d.ts +2 -2
  50. package/src/index.js +2 -2
  51. package/src/theme/components/enrichedText.js +4 -1
  52. package/src/theme/components/text.js +1 -1
  53. package/dist/umd/4569.js +0 -1
  54. package/dist/umd/text-components-descope-enriched-text-index-js.js +0 -1
  55. package/dist/umd/text-components-descope-text-index-js.js +0 -1
  56. package/src/components/text-components/createBaseTextClass.js +0 -26
  57. package/src/components/text-components/descope-enriched-text/EnrichedTextClass.js +0 -106
  58. package/src/components/text-components/descope-enriched-text/helpers.js +0 -41
  59. package/src/components/text-components/descope-text/TextClass.js +0 -34
  60. package/src/components/text-components/hideWhenEmptyMixin.js +0 -17
  61. /package/src/components/{text-components/descope-enriched-text → descope-enriched-text}/index.js +0 -0
  62. /package/src/components/{text-components/descope-text → descope-text}/index.js +0 -0
package/dist/index.d.ts CHANGED
@@ -24,8 +24,8 @@ export { NotpImageClass } from './components/descope-notp-image';
24
24
  export { NumberFieldClass } from './components/descope-number-field';
25
25
  export { PasscodeClass } from './components/descope-passcode';
26
26
  export { PasswordClass } from './components/descope-password';
27
- export { TextClass } from './components/text-components/descope-text';
28
- export { EnrichedTextClass } from './components/text-components/descope-enriched-text';
27
+ export { TextClass } from './components/descope-text';
28
+ export { EnrichedTextClass } from './components/descope-enriched-text';
29
29
  export { TextAreaClass } from './components/descope-text-area';
30
30
  export { TextFieldClass } from './components/descope-text-field';
31
31
  export { ImageClass } from './components/descope-image';
package/dist/index.esm.js CHANGED
@@ -5,7 +5,7 @@ import '@vaadin/text-field';
5
5
  import '@vaadin/email-field';
6
6
  import '@vaadin/number-field';
7
7
  import '@vaadin/password-field';
8
- import markdownit from 'markdown-it';
8
+ import { Remarkable } from 'remarkable';
9
9
  import '@vaadin/text-area';
10
10
  import '@vaadin/combo-box';
11
11
  import '@vaadin/grid';
@@ -2214,50 +2214,41 @@ const ContainerClass = compose(
2214
2214
 
2215
2215
  customElements.define(componentName$M, ContainerClass);
2216
2216
 
2217
- const hideWhenEmptyMixin = (superclass) =>
2218
- class HideWhenEmptyMixinClass extends superclass {
2219
- get hideWhenEmpty() {
2220
- return this.getAttribute('hide-when-empty') === 'true';
2221
- }
2222
-
2223
- init() {
2224
- super.init();
2225
-
2226
- observeChildren(this, () => {
2227
- const hasChildren = !!this.childNodes.length;
2228
- this.style.display = !hasChildren && this.hideWhenEmpty ? 'none' : '';
2229
- });
2230
- }
2231
- };
2217
+ const componentName$L = getComponentName('text');
2232
2218
 
2233
- const createBaseTextClass = (componentName) => {
2234
- class BaseText extends createBaseClass({ componentName, baseSelector: ':host > slot' }) {
2235
- constructor() {
2236
- super();
2219
+ class RawText extends createBaseClass({ componentName: componentName$L, baseSelector: ':host > slot' }) {
2220
+ constructor() {
2221
+ super();
2237
2222
 
2238
- this.attachShadow({ mode: 'open' }).innerHTML = `
2239
- <style>
2240
- :host {
2241
- display: inline-block;
2242
- }
2243
- :host > slot {
2244
- width: 100%;
2245
- display: inline-block;
2246
- }
2247
- </style>
2248
- <slot part="text-wrapper"></slot>
2249
- `;
2223
+ this.attachShadow({ mode: 'open' }).innerHTML = `
2224
+ <style>
2225
+ :host {
2226
+ display: inline-block;
2227
+ }
2228
+ :host > slot {
2229
+ width: 100%;
2230
+ display: inline-block;
2231
+ }
2232
+ </style>
2233
+ <slot part="text-wrapper"></slot>
2234
+ `;
2250
2235
 
2251
- this.textSlot = this.shadowRoot.querySelector('slot');
2252
- }
2236
+ this.textSlot = this.shadowRoot.querySelector('slot');
2253
2237
  }
2254
2238
 
2255
- return BaseText;
2256
- };
2239
+ get hideWhenEmpty() {
2240
+ return this.getAttribute('hide-when-empty') === 'true';
2241
+ }
2257
2242
 
2258
- const componentName$L = getComponentName('text');
2243
+ init() {
2244
+ super.init();
2259
2245
 
2260
- const BaseTextClass = createBaseTextClass(componentName$L);
2246
+ observeChildren(this, () => {
2247
+ const hasChildren = !!this.childNodes.length;
2248
+ this.style.display = !hasChildren && this.hideWhenEmpty ? 'none' : '';
2249
+ });
2250
+ }
2251
+ }
2261
2252
 
2262
2253
  const TextClass = compose(
2263
2254
  createStyleMixin({
@@ -2280,9 +2271,8 @@ const TextClass = compose(
2280
2271
  },
2281
2272
  }),
2282
2273
  draggableMixin,
2283
- componentNameValidationMixin,
2284
- hideWhenEmptyMixin
2285
- )(BaseTextClass);
2274
+ componentNameValidationMixin
2275
+ )(RawText);
2286
2276
 
2287
2277
  const componentName$K = getComponentName('divider');
2288
2278
  class RawDivider extends createBaseClass({ componentName: componentName$K, baseSelector: ':host > div' }) {
@@ -3343,115 +3333,218 @@ const PasswordClass = compose(
3343
3333
 
3344
3334
  customElements.define(componentName$A, PasswordClass);
3345
3335
 
3346
- const customEleMap = {
3347
- a: 'descope-link',
3336
+ const ruleSet = {
3337
+ custom: ['image'],
3338
+ core: [
3339
+ 'block',
3340
+ 'inline',
3341
+ 'abbr', // Parse abbreviation definitions, i.e. `*[abbr]: description`
3342
+ 'abbr2', // Enclose abbreviations in <abbr> tags
3343
+ 'references',
3344
+ 'footnote_tail',
3345
+ 'replacements', // Simple typographical replacements
3346
+ 'smartquotes', // Convert straight quotation marks to typographic ones
3347
+ ],
3348
+ inline: [
3349
+ 'text',
3350
+ 'newline', // Proceess '\n'
3351
+ 'backticks', // Parse backticks
3352
+ 'del', // Process ~~deleted text~~
3353
+ 'emphasis', // Process *this* and _that_
3354
+ 'sub', // Process ~subscript~
3355
+ 'sup', // Process ^superscript^
3356
+ 'links', // Process [links](<to> "stuff")
3357
+ 'escape', // Proceess escaped chars and hardbreaks
3358
+ 'ins', // Process ++inserted text++
3359
+ 'mark', // Process ==highlighted text==
3360
+ 'footnote_inline', // Process inline footnotes (^[...])
3361
+ 'footnote_ref', // Process footnote references ([^...])
3362
+ 'autolink', // Process autolinks '<protocol:...>'
3363
+ 'htmltag', // Process html tags
3364
+ 'entity', // Process html entity - &#123;, &#xAF;, &quot;, ...
3365
+ ],
3366
+ block: [
3367
+ 'code', // Code block (4 spaces padded)
3368
+ 'fences', // fences (``` lang, ~~~ lang)
3369
+ 'blockquote', // Block quotes
3370
+ 'list',
3371
+ 'heading', // heading (#, ##, ...)
3372
+ 'paragraph',
3373
+ 'hr', // Horizontal rule
3374
+ 'footnote', // Process footnote reference list
3375
+ 'lheading', // lheading (---, ===)
3376
+ 'htmlblock', // HTML block
3377
+ 'table', // GFM table, non-standard
3378
+ 'deflist', // Definition lists
3379
+ ],
3348
3380
  };
3349
3381
 
3350
- const getTokenTag = (token) => customEleMap[token.tag] || token.tag;
3382
+ const textRuleSet = {
3383
+ core: ['block', 'inline'],
3384
+ inline: [
3385
+ 'text',
3386
+ 'newline', // Proceess '\n'
3387
+ 'backticks', // Parse backticks
3388
+ 'del', // Process ~~deleted text~~
3389
+ 'emphasis', // Process *this* and _that_
3390
+ 'sub', // Process ~subscript~
3391
+ 'sup', // Process ^superscript^
3392
+ 'links', // Process [links](<to> "stuff")
3393
+ 'escape', // Proceess escaped chars and hardbreaks
3394
+ 'ins', // Process ++inserted text++
3395
+ 'footnote_inline', // Process inline footnotes (^[...])
3396
+ 'footnote_ref', // Process footnote references ([^...])
3397
+ 'autolink', // Process autolinks '<protocol:...>'
3398
+ ],
3399
+ block: [
3400
+ 'code', // Code block (4 spaces padded)
3401
+ 'fences', // fences (``` lang, ~~~ lang)
3402
+ 'blockquote', // Block quotes
3403
+ 'list',
3404
+ 'heading', // heading (#, ##, ...)
3405
+ 'paragraph',
3406
+ 'footnote', // Process footnote reference list
3407
+ 'htmlblock', // HTML block
3408
+ ],
3409
+ };
3351
3410
 
3352
- const isImageToken = (token) => token?.children?.[0].type === 'image';
3411
+ const componentName$z = getComponentName('enriched-text');
3353
3412
 
3354
- const enrichTokens = (tokens) =>
3355
- tokens.map((token) => {
3356
- const tag = getTokenTag(token);
3413
+ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName: componentName$z, baseSelector: ':host > div' }) {
3414
+ #origImageRenderer;
3357
3415
 
3358
- if (isImageToken(token)) {
3359
- token.children[0].attrs.push(['style', 'width:100%']);
3360
- return {
3361
- ...token,
3362
- tag,
3363
- };
3364
- }
3416
+ constructor() {
3417
+ super();
3365
3418
 
3366
- if (token?.children?.length > 0) {
3367
- return {
3368
- ...token,
3369
- tag,
3370
- children: enrichTokens(token.children),
3371
- };
3372
- }
3419
+ this.attachShadow({ mode: 'open' }).innerHTML = `
3420
+ <style>
3421
+ :host {
3422
+ display: inline-block;
3423
+ }
3424
+ :host > slot {
3425
+ width: 100%;
3426
+ display: inline-block;
3427
+ }
3428
+ *, *:last-child {
3429
+ margin: 0;
3430
+ }
3431
+ h1,
3432
+ h2,
3433
+ h3,
3434
+ h4,
3435
+ h5,
3436
+ h6,
3437
+ p {
3438
+ margin-bottom: 1em;
3439
+ }
3440
+ a {
3441
+ text-decoration: none;
3442
+ cursor: pointer;
3443
+ }
3444
+ a:hover {
3445
+ text-decoration: underline;
3446
+ }
3447
+ blockquote {
3448
+ padding: 0 2em;
3449
+ }
3450
+ </style>
3451
+ <slot part="text-wrapper" style="display:none"></slot>
3452
+ <div class="content"></div>
3453
+ `;
3373
3454
 
3374
- return {
3375
- ...token,
3376
- tag,
3377
- };
3378
- });
3455
+ this.textSlot = this.shadowRoot.querySelector('slot');
3379
3456
 
3380
- const onClipboardCopy = (e) => {
3381
- const selection = document.getSelection().toString();
3382
- const clipdata = e.clipboardData || window.clipboardData;
3383
- clipdata.setData('text/plain', selection);
3384
- clipdata.setData('text/html', selection);
3385
- e.preventDefault();
3386
- };
3457
+ this.#initProcessor();
3387
3458
 
3388
- const componentName$z = getComponentName('enriched-text');
3459
+ this.textSlot.addEventListener('slotchange', this.#parseChildren.bind(this));
3460
+ }
3461
+
3462
+ static get observedAttributes() {
3463
+ return ['readonly'];
3464
+ }
3389
3465
 
3390
- const BaseEnrichedTextClass = createBaseTextClass(componentName$z);
3466
+ attributeChangedCallback(attrName, oldValue, newValue) {
3467
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
3391
3468
 
3392
- const EnrichedTextMixin = (superclass) =>
3393
- class EnrichedTextMixinClass extends superclass {
3394
- static get observedAttributes() {
3395
- return ['disabled-rules', 'line-break', 'readonly'];
3469
+ if (newValue !== oldValue) {
3470
+ if (attrName === 'readonly') {
3471
+ this.onReadOnlyChange(newValue === 'true');
3472
+ }
3396
3473
  }
3474
+ }
3397
3475
 
3398
- get lineBreak() {
3399
- return this.getAttribute('line-break');
3476
+ #disableAllRules() {
3477
+ if (!this.processor) {
3478
+ return;
3400
3479
  }
3401
3480
 
3402
- get disabledRules() {
3403
- return (this.getAttribute('disabled-rules') || '').split(',').filter(Boolean);
3404
- }
3481
+ ruleSet?.core && this.processor.core.ruler.disable(ruleSet.core);
3482
+ ruleSet?.inline && this.processor.inline.ruler.disable(ruleSet.inline);
3483
+ ruleSet?.block && this.processor.block.ruler.disable(ruleSet.block);
3405
3484
 
3406
- init() {
3407
- super.init();
3408
- this.#initProcessor();
3409
- this.textSlot.addEventListener('slotchange', this.#parseChildren.bind(this));
3485
+ this.processor.renderer.rules.image = () => {
3486
+ return '';
3487
+ };
3488
+ }
3489
+
3490
+ #enableCustomRules() {
3491
+ if (!this.processor) {
3492
+ return;
3410
3493
  }
3411
3494
 
3412
- attributeChangedCallback(attrName, oldValue, newValue) {
3413
- super.attributeChangedCallback?.(attrName, oldValue, newValue);
3495
+ const customRuleSet = textRuleSet;
3414
3496
 
3415
- if (attrName === 'disabled-rules') {
3416
- if (newValue !== oldValue) {
3417
- this.#initProcessor(newValue);
3418
- this.#parseChildren();
3419
- }
3420
- }
3497
+ customRuleSet?.core && this.processor?.core.ruler.enable(customRuleSet?.core);
3498
+ customRuleSet?.inline && this.processor?.inline.ruler.enable(customRuleSet?.inline);
3499
+ customRuleSet?.block && this.processor?.block.ruler.enable(customRuleSet?.block);
3421
3500
 
3422
- if (attrName === 'readonly') {
3423
- this.onReadOnlyChange(newValue !== null);
3424
- }
3501
+ if (customRuleSet?.custom?.includes('image')) {
3502
+ this.processor.renderer.rules.image = this.#origImageRenderer;
3425
3503
  }
3504
+ }
3426
3505
 
3427
- #initProcessor() {
3428
- this.processor = markdownit({ breaks: this.lineBreak }).disable(this.disabledRules);
3429
- }
3506
+ #updateProcessorRules() {
3507
+ this.#disableAllRules();
3508
+ this.#enableCustomRules();
3509
+ }
3430
3510
 
3431
- #parseChildren() {
3432
- const node = this.textSlot.assignedNodes({ flatten: true })?.[0];
3511
+ #initProcessor() {
3512
+ this.processor = new Remarkable();
3513
+ this.#origImageRenderer = this.processor.renderer.rules.image;
3514
+ this.#updateProcessorRules();
3515
+ }
3433
3516
 
3434
- if (node && node.nodeType === Node.TEXT_NODE) {
3435
- const tokens = this.processor.parse(node.textContent, { references: undefined });
3436
- const result = this.processor.renderer.render(enrichTokens(tokens), {
3437
- breaks: this.lineBreak,
3438
- });
3517
+ get contentNode() {
3518
+ return this.shadowRoot.querySelector('.content');
3519
+ }
3439
3520
 
3440
- if (result !== node.textContent) {
3441
- const span = document.createElement('div');
3442
- span.classList.add('enriched-text');
3443
- // eslint-disable-next-line no-use-before-define
3444
- span.innerHTML = `${getStyleReset()}${result}`;
3445
- span.addEventListener('copy', onClipboardCopy);
3446
- node.parentNode.replaceChild(span, node);
3447
- }
3448
- }
3521
+ #parseChildren() {
3522
+ if (!this.processor) {
3523
+ return;
3449
3524
  }
3450
3525
 
3451
- onReadOnlyChange(val) {
3452
- this.setAttribute('inert', val);
3526
+ let html = this.textContent;
3527
+
3528
+ try {
3529
+ const tokens = this.processor.parse(this.textContent);
3530
+ html = this.processor.renderer.render(tokens, { breaks: true });
3531
+ this.contentNode.innerHTML = html;
3532
+ } catch (e) {
3533
+ // eslint-disable-next-line no-console
3534
+ console.warn('Not parsing invalid markdown token');
3453
3535
  }
3454
- };
3536
+
3537
+ this.contentNode.innerHTML = html;
3538
+ }
3539
+
3540
+ onReadOnlyChange(isReadOnly) {
3541
+ if (isReadOnly) {
3542
+ this.setAttribute('inert', isReadOnly);
3543
+ } else {
3544
+ this.removeAttribute('inert');
3545
+ }
3546
+ }
3547
+ };
3455
3548
 
3456
3549
  const EnrichedTextClass = compose(
3457
3550
  createStyleMixin({
@@ -3463,26 +3556,14 @@ const EnrichedTextClass = compose(
3463
3556
  fontWeight: {},
3464
3557
  textColor: { property: 'color' },
3465
3558
  textLineHeight: { property: 'line-height' },
3466
- marginReset: { selector: '*', property: 'margin' },
3467
3559
  textAlign: {},
3560
+ linkColor: { selector: 'a', property: 'color' },
3468
3561
  },
3469
3562
  }),
3563
+ createStyleMixin({ componentNameOverride: getComponentName('link') }),
3470
3564
  draggableMixin,
3471
- componentNameValidationMixin,
3472
- EnrichedTextMixin,
3473
- hideWhenEmptyMixin
3474
- )(BaseEnrichedTextClass);
3475
-
3476
- function getStyleReset() {
3477
- return `
3478
- <style>
3479
- .enriched-text > * { margin:0 }
3480
- .enriched-text > *:not(:only-child):not(:last-child) {
3481
- margin-bottom: var(${EnrichedTextClass.cssVarList.textLineHeight})
3482
- }
3483
- </style>
3484
- `;
3485
- }
3565
+ componentNameValidationMixin
3566
+ )(EnrichedText$2);
3486
3567
 
3487
3568
  customElements.define(componentName$z, EnrichedTextClass);
3488
3569
 
@@ -11562,6 +11643,8 @@ const EnrichedText = {
11562
11643
  [vars$q.textAlign]: 'left',
11563
11644
  [vars$q.textColor]: globalRefs$i.colors.surface.dark,
11564
11645
 
11646
+ [vars$q.linkColor]: `var(${LinkClass.cssVarList.textColor})`,
11647
+
11565
11648
  mode: {
11566
11649
  primary: {
11567
11650
  [vars$q.textColor]: globalRefs$i.colors.surface.contrast,