@descope/flow-components 3.1.5 → 3.1.6

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.
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.1.5",
8
+ "buildVersion": "3.1.6",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.1.5",
8
+ "buildVersion": "3.1.6",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
package/dist/index.cjs.js CHANGED
@@ -97282,7 +97282,7 @@ descope-enriched-text {
97282
97282
  };
97283
97283
 
97284
97284
  const renderCodeSnippet = (value, lang) =>
97285
- `<descope-code-snippet lang="${lang}" class="row-details__value code">${escapeXML(value)}</descope-code-snippet>`;
97285
+ `<descope-code-snippet copy-button="true" lang="${lang}" class="row-details__value code">${escapeXML(value)}</descope-code-snippet>`;
97286
97286
 
97287
97287
  const renderText = (text) =>
97288
97288
  `<div class="row-details__value text" title="${text}">${escapeXML(text)}</div>`;
@@ -97310,16 +97310,31 @@ descope-enriched-text {
97310
97310
  return renderText(value);
97311
97311
  };
97312
97312
 
97313
+ const isCodeSnippetValue = (value) => {
97314
+ const type = getValueType(value);
97315
+ return (
97316
+ type === 'object' ||
97317
+ type === 'xml' ||
97318
+ (type === 'array' && value.some((v) => getValueType(v) === 'object'))
97319
+ );
97320
+ };
97321
+
97313
97322
  const defaultRowDetailsRenderer = (item, itemLabelsMapping) => `
97314
97323
  <div class="row-details">
97315
97324
  ${Object.entries(item)
97316
- .map(
97317
- ([key, value]) =>
97318
- `<div class="row-details__item" >
97319
- <div class="row-details__label">${itemLabelsMapping[key] || toTitle(key)}</div>
97325
+ .map(([key, value]) => {
97326
+ const label = itemLabelsMapping[key] || toTitle(key);
97327
+ if (isCodeSnippetValue(value)) {
97328
+ return `<details class="row-details__item">
97329
+ <summary class="row-details__label">${label}</summary>
97320
97330
  ${defaultRowDetailsValueRenderer(value)}
97321
- </div>`
97322
- )
97331
+ </details>`;
97332
+ }
97333
+ return `<div class="row-details__item">
97334
+ <div class="row-details__label">${label}</div>
97335
+ ${defaultRowDetailsValueRenderer(value)}
97336
+ </div>`;
97337
+ })
97323
97338
  .join('\n')}
97324
97339
  </div>
97325
97340
  `;
@@ -97347,6 +97362,18 @@ descope-enriched-text {
97347
97362
  };
97348
97363
 
97349
97364
  this.baseElement.rowDetailsRenderer = this.#rowDetailsRenderer.bind(this);
97365
+
97366
+ // Stop wheel events from propagating to vaadin-grid when scrolling
97367
+ // inside code snippets, so touchpad horizontal scroll works
97368
+ this.baseElement.addEventListener(
97369
+ 'wheel',
97370
+ (e) => {
97371
+ if (e.target.closest('descope-code-snippet')) {
97372
+ e.stopPropagation();
97373
+ }
97374
+ },
97375
+ true
97376
+ );
97350
97377
  }
97351
97378
 
97352
97379
  // this renders the details panel content
@@ -97657,6 +97684,14 @@ descope-enriched-text {
97657
97684
  grid-column: 1 / -1;
97658
97685
  order: 2;
97659
97686
  }
97687
+ vaadin-grid details.row-details__item {
97688
+ padding: 0;
97689
+ }
97690
+ vaadin-grid details.row-details__item > summary.row-details__label {
97691
+ cursor: pointer;
97692
+ list-style: revert;
97693
+ display: revert;
97694
+ }
97660
97695
  vaadin-grid .row-details__value.text {
97661
97696
  overflow: hidden;
97662
97697
  text-overflow: ellipsis;
@@ -97664,8 +97699,7 @@ descope-enriched-text {
97664
97699
  }
97665
97700
  vaadin-grid .row-details__value.code {
97666
97701
  margin-top: 5px;
97667
- max-height: 120px;
97668
- overflow: scroll;
97702
+ overflow-x: auto;
97669
97703
  font-size: 0.85em;
97670
97704
  }
97671
97705
  vaadin-grid vaadin-icon.toggle-details-button {
@@ -99596,18 +99630,24 @@ descope-enriched-text {
99596
99630
 
99597
99631
  const tpl = (input, inline) => (inline ? input : `<pre>${input}</pre>`);
99598
99632
 
99633
+ var copyIconSrc = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPgogIDxyZWN0IHg9IjkiIHk9IjkiIHdpZHRoPSIxMyIgaGVpZ2h0PSIxMyIgcng9IjIiIHJ5PSIyIj48L3JlY3Q+CiAgPHBhdGggZD0iTTUgMTVINGEyIDIgMCAwIDEtMi0yVjRhMiAyIDAgMCAxIDItMmg5YTIgMiAwIDAgMSAyIDJ2MSI+PC9wYXRoPgo8L3N2Zz4K";
99634
+
99635
+ var checkIconSrc = "data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iY2hlY2staWNvbiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj4KICA8cG9seWxpbmUgcG9pbnRzPSIyMCA2IDkgMTcgNCAxMiI+PC9wb2x5bGluZT4KPC9zdmc+Cg==";
99636
+
99599
99637
  const componentName$e = getComponentName$1('code-snippet');
99600
99638
 
99601
- let CodeSnippet$1 = class CodeSnippet extends createBaseClass({ componentName: componentName$e, baseSelector: ':host > code' }) {
99639
+ let CodeSnippet$1 = class CodeSnippet extends createBaseClass({ componentName: componentName$e, baseSelector: ':host > .wrapper' }) {
99602
99640
  static get observedAttributes() {
99603
- return ['lang', 'inline'];
99641
+ return ['lang', 'inline', 'copy-button'];
99604
99642
  }
99605
99643
 
99606
99644
  constructor() {
99607
99645
  super();
99608
99646
 
99609
99647
  this.attachShadow({ mode: 'open' }).innerHTML = `
99610
- <code class="hljs"></code>
99648
+ <div class="wrapper">
99649
+ <code class="hljs"></code>
99650
+ </div>
99611
99651
  `;
99612
99652
 
99613
99653
  injectStyle(
@@ -99616,6 +99656,10 @@ descope-enriched-text {
99616
99656
  display: inline-block;
99617
99657
  width: 100%;
99618
99658
  }
99659
+ .wrapper {
99660
+ position: relative;
99661
+ width: 100%;
99662
+ }
99619
99663
  code {
99620
99664
  display: block;
99621
99665
  width: 100%;
@@ -99626,6 +99670,38 @@ descope-enriched-text {
99626
99670
  pre {
99627
99671
  margin: 0;
99628
99672
  }
99673
+ .copy-btn {
99674
+ position: absolute;
99675
+ top: 8px;
99676
+ right: 8px;
99677
+ display: flex;
99678
+ align-items: center;
99679
+ justify-content: center;
99680
+ padding: 0;
99681
+ border-style: solid;
99682
+ cursor: pointer;
99683
+ opacity: 0;
99684
+ transition: opacity 150ms ease, background 150ms ease;
99685
+ }
99686
+ .wrapper:hover .copy-btn,
99687
+ .copy-btn:focus-visible {
99688
+ opacity: 1;
99689
+ }
99690
+ .copy-btn descope-icon {
99691
+ width: 16px;
99692
+ height: 16px;
99693
+ pointer-events: none;
99694
+ flex-shrink: 0;
99695
+ }
99696
+ .copy-btn .check-icon {
99697
+ display: none;
99698
+ }
99699
+ .copy-btn.copied .check-icon {
99700
+ display: block;
99701
+ }
99702
+ .copy-btn.copied descope-icon:not(.check-icon) {
99703
+ display: none;
99704
+ }
99629
99705
  `,
99630
99706
  this
99631
99707
  );
@@ -99637,11 +99713,15 @@ descope-enriched-text {
99637
99713
  this.lang = this.getAttribute('lang');
99638
99714
  this.isInline = this.getAttribute('inline') === 'true';
99639
99715
 
99716
+ if (this.getAttribute('copy-button') === 'true') {
99717
+ this.#initCopyButton();
99718
+ }
99719
+
99640
99720
  observeChildren$1(this, this.#renderSnippet.bind(this));
99641
99721
  }
99642
99722
 
99643
99723
  get contentNode() {
99644
- return this.shadowRoot.querySelector(this.baseSelector);
99724
+ return this.shadowRoot.querySelector('code');
99645
99725
  }
99646
99726
 
99647
99727
  attributeChangedCallback(attrName, oldValue, newValue) {
@@ -99656,10 +99736,58 @@ descope-enriched-text {
99656
99736
  this.lang = newValue;
99657
99737
  }
99658
99738
 
99739
+ if (attrName === 'copy-button') {
99740
+ if (newValue === 'true') {
99741
+ this.#initCopyButton();
99742
+ } else {
99743
+ this.#destroyCopyButton();
99744
+ }
99745
+ }
99746
+
99659
99747
  this.#renderSnippet();
99660
99748
  }
99661
99749
  }
99662
99750
 
99751
+ // ── Copy button ────────────────────────────────────────────────────────────
99752
+
99753
+ #initCopyButton() {
99754
+ if (this.shadowRoot.querySelector('.copy-btn')) return;
99755
+
99756
+ const btn = document.createElement('button');
99757
+ btn.className = 'copy-btn';
99758
+ btn.type = 'button';
99759
+ btn.setAttribute('aria-label', 'Copy code');
99760
+ const copyIcon = document.createElement('descope-icon');
99761
+ copyIcon.setAttribute('src', copyIconSrc);
99762
+
99763
+ const checkIcon = document.createElement('descope-icon');
99764
+ checkIcon.setAttribute('src', checkIconSrc);
99765
+ checkIcon.classList.add('check-icon');
99766
+
99767
+ btn.appendChild(copyIcon);
99768
+ btn.appendChild(checkIcon);
99769
+ btn.addEventListener('click', () => this.#handleCopyClick());
99770
+
99771
+ this.shadowRoot.querySelector('.wrapper').appendChild(btn);
99772
+ }
99773
+
99774
+ #destroyCopyButton() {
99775
+ this.shadowRoot.querySelector('.copy-btn')?.remove();
99776
+ }
99777
+
99778
+ #handleCopyClick() {
99779
+ const btn = this.shadowRoot.querySelector('.copy-btn');
99780
+ navigator.clipboard
99781
+ .writeText(decode(this.textContent))
99782
+ .then(() => {
99783
+ btn.classList.add('copied');
99784
+ setTimeout(() => btn.classList.remove('copied'), 2000);
99785
+ })
99786
+ .catch(() => {});
99787
+ }
99788
+
99789
+ // ── Snippet rendering ──────────────────────────────────────────────────────
99790
+
99663
99791
  #renderSnippet() {
99664
99792
  const sanitized = decode(this.textContent);
99665
99793
  const language = this.lang;
@@ -99675,6 +99803,8 @@ descope-enriched-text {
99675
99803
  }
99676
99804
  };
99677
99805
 
99806
+ const copyBtn = { selector: () => '.copy-btn' };
99807
+
99678
99808
  const {
99679
99809
  root,
99680
99810
  docTag,
@@ -99826,6 +99956,16 @@ descope-enriched-text {
99826
99956
  propertyTextColor: { ...property, property: 'color' },
99827
99957
  punctuationTextColor: { ...punctuation, property: 'color' },
99828
99958
  tagTextColor: { ...tag, property: 'color' },
99959
+ copyButtonSize: [
99960
+ { ...copyBtn, property: 'width' },
99961
+ { ...copyBtn, property: 'height' },
99962
+ ],
99963
+ copyButtonBorderRadius: { ...copyBtn, property: 'border-radius' },
99964
+ copyButtonBorderWidth: { ...copyBtn, property: 'border-width' },
99965
+ copyButtonBorderColor: { ...copyBtn, property: 'border-color' },
99966
+ copyButtonBgColor: { ...copyBtn, property: 'background-color' },
99967
+ copyButtonHoverBgColor: { selector: () => '.copy-btn:hover', property: 'background-color' },
99968
+ copyButtonColor: { ...copyBtn, property: 'color' },
99829
99969
  },
99830
99970
  }),
99831
99971
  draggableMixin,
@@ -99863,6 +100003,13 @@ descope-enriched-text {
99863
100003
  };
99864
100004
 
99865
100005
  const CodeSnippet = {
100006
+ [vars$c.copyButtonSize]: '32px',
100007
+ [vars$c.copyButtonBorderRadius]: globalRefs$6.radius.xs,
100008
+ [vars$c.copyButtonBorderWidth]: globalRefs$6.border.xs,
100009
+ [vars$c.copyButtonBorderColor]: globalRefs$6.colors.surface.light,
100010
+ [vars$c.copyButtonBgColor]: globalRefs$6.colors.surface.highlight,
100011
+ [vars$c.copyButtonHoverBgColor]: globalRefs$6.colors.surface.light,
100012
+ [vars$c.copyButtonColor]: globalRefs$6.colors.surface.contrast,
99866
100013
  [vars$c.rootBgColor]: globalRefs$6.colors.surface.main,
99867
100014
  [vars$c.rootTextColor]: globalRefs$6.colors.surface.contrast,
99868
100015
  [vars$c.docTagTextColor]: light.color2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -97,7 +97,7 @@
97
97
  "webpack-subresource-integrity": "5.2.0-rc.1"
98
98
  },
99
99
  "dependencies": {
100
- "@descope/web-components-ui": "3.1.5"
100
+ "@descope/web-components-ui": "3.1.6"
101
101
  },
102
102
  "peerDependencies": {
103
103
  "react": ">= 18"