@descope-ui/descope-link 3.3.2 → 3.3.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [3.3.3](https://github.com/descope/web-components-ui/compare/web-components-ui-3.3.2...web-components-ui-3.3.3) (2026-05-03)
6
+
7
+
8
+ ### Features
9
+
10
+ * **descope-link:** add readonly property ([#1010](https://github.com/descope/web-components-ui/issues/1010)) ([3f6613e](https://github.com/descope/web-components-ui/commit/3f6613eaa260207f36f94d16009c82f6a5763001))
11
+
5
12
  ## [3.3.2](https://github.com/descope/web-components-ui/compare/web-components-ui-3.3.1...web-components-ui-3.3.2) (2026-04-26)
6
13
 
7
14
  ## [3.3.1](https://github.com/descope/web-components-ui/compare/web-components-ui-3.3.0...web-components-ui-3.3.1) (2026-04-23)
@@ -10,6 +10,7 @@ const componentAttributes = {
10
10
  tooltip: 'Tooltip',
11
11
  'text-align': ['left', 'center', 'right'],
12
12
  'full-width': ['true', 'false'],
13
+ readonly: ['true', 'false'],
13
14
  };
14
15
 
15
16
  const storyName = 'descope-link';
@@ -58,4 +59,22 @@ test.describe('logic', () => {
58
59
 
59
60
  expect(newPage.url()).toBe(MOCK_URL);
60
61
  });
62
+
63
+ test('readonly prevents navigation', async ({ page }) => {
64
+ await page.goto(getStoryUrl(storyName, { href: MOCK_URL, readonly: 'true' }), {
65
+ waitUntil: 'networkidle',
66
+ });
67
+ const urlBefore = page.url();
68
+ await page.locator(componentName).click();
69
+ await page.waitForTimeout(300);
70
+ expect(page.url()).toBe(urlBefore);
71
+ });
72
+
73
+ test('readonly=false allows navigation', async ({ page }) => {
74
+ await page.goto(getStoryUrl(storyName, { href: MOCK_URL, readonly: 'false' }), {
75
+ waitUntil: 'networkidle',
76
+ });
77
+ await page.locator(componentName).click();
78
+ await page.waitForURL(MOCK_URL);
79
+ });
61
80
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope-ui/descope-link",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./src/component/index.js"
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "devDependencies": {
16
16
  "@playwright/test": "1.58.2",
17
- "e2e-utils": "3.3.2",
18
- "@descope-ui/descope-text": "3.3.2"
17
+ "e2e-utils": "3.3.3",
18
+ "@descope-ui/descope-text": "3.3.3"
19
19
  },
20
20
  "dependencies": {
21
- "@descope-ui/common": "3.3.2",
22
- "@descope-ui/theme-globals": "3.3.2"
21
+ "@descope-ui/common": "3.3.3",
22
+ "@descope-ui/theme-globals": "3.3.3"
23
23
  },
24
24
  "publishConfig": {
25
25
  "link-workspace-packages": false
@@ -14,7 +14,16 @@ import { TextClass } from '@descope-ui/descope-text/class';
14
14
 
15
15
  export const componentName = getComponentName('link');
16
16
 
17
- class RawLink extends createBaseClass({ componentName, baseSelector: ':host a' }) {
17
+ const observedAttrs = ['href', 'readonly'];
18
+
19
+ class RawLink extends createBaseClass({
20
+ componentName,
21
+ baseSelector: ':host a',
22
+ }) {
23
+ static get observedAttributes() {
24
+ return observedAttrs.concat(super.observedAttributes || []);
25
+ }
26
+
18
27
  constructor() {
19
28
  super();
20
29
 
@@ -47,10 +56,12 @@ class RawLink extends createBaseClass({ componentName, baseSelector: ':host a' }
47
56
  white-space: nowrap;
48
57
  }
49
58
  `,
50
- this
59
+ this,
51
60
  );
52
61
 
53
- forwardAttrs(this, this.shadowRoot.querySelector('a'), {
62
+ this.anchor = this.shadowRoot.querySelector('a');
63
+
64
+ forwardAttrs(this, this.anchor, {
54
65
  includeAttrs: ['href', 'target', 'tooltip'],
55
66
  mapAttrs: {
56
67
  tooltip: 'title',
@@ -60,6 +71,16 @@ class RawLink extends createBaseClass({ componentName, baseSelector: ':host a' }
60
71
  forwardAttrs(this, this.shadowRoot.querySelector('descope-text'), {
61
72
  includeAttrs: ['mode', 'variant'],
62
73
  });
74
+
75
+ this.anchor.addEventListener('click', (e) => {
76
+ if (this.readOnly) {
77
+ e.preventDefault();
78
+ }
79
+ });
80
+ }
81
+
82
+ get readOnly() {
83
+ return this.getAttribute('readonly') === 'true';
63
84
  }
64
85
  }
65
86
 
@@ -79,7 +100,11 @@ export const LinkClass = compose(
79
100
  hostWidth: { ...host, property: 'width' },
80
101
  hostDirection: { ...text, property: 'direction' },
81
102
  textAlign: wrapper,
82
- textDecoration: { ...link, property: 'text-decoration', fallback: 'none' },
103
+ textDecoration: {
104
+ ...link,
105
+ property: 'text-decoration',
106
+ fallback: 'none',
107
+ },
83
108
  textColor: [
84
109
  { ...anchor, property: 'color' },
85
110
  { ...text, property: TextClass.cssVarList.textColor },
@@ -88,5 +113,5 @@ export const LinkClass = compose(
88
113
  },
89
114
  }),
90
115
  draggableMixin,
91
- componentNameValidationMixin
116
+ componentNameValidationMixin,
92
117
  )(RawLink);
@@ -5,6 +5,7 @@ import {
5
5
  modeControl,
6
6
  fullWidthControl,
7
7
  directionControl,
8
+ readOnlyControl,
8
9
  } from '@descope-ui/common/sb-controls';
9
10
 
10
11
  const Template = ({
@@ -16,6 +17,7 @@ const Template = ({
16
17
  'full-width': fullWidth,
17
18
  text,
18
19
  direction,
20
+ readonly,
19
21
  }) => `
20
22
  <descope-link
21
23
  mode="${mode}"
@@ -25,6 +27,7 @@ const Template = ({
25
27
  text-align="${textAlign || ''}"
26
28
  full-width="${fullWidth || false}"
27
29
  st-host-direction="${direction ?? ''}"
30
+ readonly="${readonly || false}"
28
31
  >
29
32
  ${text}
30
33
  </descope-link>
@@ -43,6 +46,7 @@ export default {
43
46
  ...textAlignControl,
44
47
  ...fullWidthControl,
45
48
  ...directionControl,
49
+ ...readOnlyControl,
46
50
  variant: {
47
51
  name: 'Variant',
48
52
  options: ['h1', 'h2', 'h3', 'subtitle1', 'subtitle2', 'body1', 'body2'],
@@ -67,4 +71,12 @@ Default.args = {
67
71
  variant: 'h1',
68
72
  mode: 'primary',
69
73
  href: 'https://descope.com',
74
+ readonly: false,
75
+ };
76
+
77
+ export const ReadOnly = Template.bind({});
78
+
79
+ ReadOnly.args = {
80
+ ...Default.args,
81
+ readonly: true,
70
82
  };