@umbraco-ui/uui-ref-node 1.8.0 → 1.9.0-rc.0

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.
@@ -29,6 +29,18 @@
29
29
  "type": "string",
30
30
  "default": "\"undefined\""
31
31
  },
32
+ {
33
+ "name": "rel",
34
+ "description": "Set the rel attribute for an anchor tag, only used when using href.",
35
+ "type": "string",
36
+ "default": "\"undefined\""
37
+ },
38
+ {
39
+ "name": "readonly",
40
+ "description": "Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.",
41
+ "type": "boolean",
42
+ "default": "\"false\""
43
+ },
32
44
  {
33
45
  "name": "disabled",
34
46
  "description": "Set tot true to disable",
@@ -93,6 +105,20 @@
93
105
  "type": "string",
94
106
  "default": "\"undefined\""
95
107
  },
108
+ {
109
+ "name": "rel",
110
+ "attribute": "rel",
111
+ "description": "Set the rel attribute for an anchor tag, only used when using href.",
112
+ "type": "string",
113
+ "default": "\"undefined\""
114
+ },
115
+ {
116
+ "name": "readonly",
117
+ "attribute": "readonly",
118
+ "description": "Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.",
119
+ "type": "boolean",
120
+ "default": "\"false\""
121
+ },
96
122
  {
97
123
  "name": "styles",
98
124
  "type": "CSSResult[]",
package/lib/index.js CHANGED
@@ -7,37 +7,25 @@ import { property, state } from 'lit/decorators.js';
7
7
 
8
8
  var __defProp = Object.defineProperty;
9
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __typeError = (msg) => {
11
+ throw TypeError(msg);
12
+ };
10
13
  var __decorateClass = (decorators, target, key, kind) => {
11
14
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
12
15
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
16
  if (decorator = decorators[i])
14
17
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
15
- if (kind && result)
16
- __defProp(target, key, result);
18
+ if (kind && result) __defProp(target, key, result);
17
19
  return result;
18
20
  };
19
- var __accessCheck = (obj, member, msg) => {
20
- if (!member.has(obj))
21
- throw TypeError("Cannot " + msg);
22
- };
23
- var __privateAdd = (obj, member, value) => {
24
- if (member.has(obj))
25
- throw TypeError("Cannot add the same private member more than once");
26
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
27
- };
28
- var __privateMethod = (obj, member, method) => {
29
- __accessCheck(obj, member, "access private method");
30
- return method;
31
- };
32
- var _onSlotIconChange, onSlotIconChange_fn, _renderFallbackIcon, renderFallbackIcon_fn, _renderContent, renderContent_fn, _renderLink, renderLink_fn, _renderButton, renderButton_fn;
21
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
22
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
23
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
24
+ var _UUIRefNodeElement_instances, onSlotIconChange_fn, renderFallbackIcon_fn, renderContent_fn, renderLink_fn, renderButton_fn, renderSomething_fn;
33
25
  let UUIRefNodeElement = class extends UUIRefElement {
34
26
  constructor() {
35
27
  super(...arguments);
36
- __privateAdd(this, _onSlotIconChange);
37
- __privateAdd(this, _renderFallbackIcon);
38
- __privateAdd(this, _renderContent);
39
- __privateAdd(this, _renderLink);
40
- __privateAdd(this, _renderButton);
28
+ __privateAdd(this, _UUIRefNodeElement_instances);
41
29
  this.name = "";
42
30
  this.detail = "";
43
31
  this._iconSlotHasContent = false;
@@ -54,7 +42,7 @@ let UUIRefNodeElement = class extends UUIRefElement {
54
42
  }
55
43
  render() {
56
44
  return html`
57
- ${this.href ? __privateMethod(this, _renderLink, renderLink_fn).call(this) : __privateMethod(this, _renderButton, renderButton_fn).call(this)}
45
+ ${__privateMethod(this, _UUIRefNodeElement_instances, renderSomething_fn).call(this)}
58
46
  <!-- Select border must be right after #open-part -->
59
47
  <div id="select-border"></div>
60
48
 
@@ -64,28 +52,27 @@ let UUIRefNodeElement = class extends UUIRefElement {
64
52
  `;
65
53
  }
66
54
  };
67
- _onSlotIconChange = new WeakSet();
55
+ _UUIRefNodeElement_instances = new WeakSet();
68
56
  onSlotIconChange_fn = function(event) {
69
57
  this._iconSlotHasContent = event.target.assignedNodes({ flatten: true }).length > 0;
70
58
  };
71
- _renderFallbackIcon = new WeakSet();
72
59
  renderFallbackIcon_fn = function() {
73
60
  return html`<uui-icon .svg="${this.fallbackIcon}"></uui-icon>`;
74
61
  };
75
- _renderContent = new WeakSet();
76
62
  renderContent_fn = function() {
77
63
  return html`
78
- <span id="icon">
79
- <slot name="icon" @slotchange=${__privateMethod(this, _onSlotIconChange, onSlotIconChange_fn)}></slot>
80
- ${this._iconSlotHasContent === false ? __privateMethod(this, _renderFallbackIcon, renderFallbackIcon_fn).call(this) : ""}
64
+ <span id="content">
65
+ <span id="icon">
66
+ <slot name="icon" @slotchange=${__privateMethod(this, _UUIRefNodeElement_instances, onSlotIconChange_fn)}></slot>
67
+ ${this._iconSlotHasContent === false ? __privateMethod(this, _UUIRefNodeElement_instances, renderFallbackIcon_fn).call(this) : ""}
68
+ </span>
69
+ <div id="info">
70
+ <div id="name">${this.name}</div>
71
+ ${this.renderDetail()}
72
+ </div>
81
73
  </span>
82
- <div id="info">
83
- <div id="name">${this.name}</div>
84
- ${this.renderDetail()}
85
- </div>
86
74
  `;
87
75
  };
88
- _renderLink = new WeakSet();
89
76
  renderLink_fn = function() {
90
77
  return html`<a
91
78
  id="open-part"
@@ -93,12 +80,13 @@ renderLink_fn = function() {
93
80
  href=${ifDefined(!this.disabled ? this.href : void 0)}
94
81
  target=${ifDefined(this.target || void 0)}
95
82
  rel=${ifDefined(
96
- this.target === "_blank" ? "noopener noreferrer" : void 0
83
+ this.rel || ifDefined(
84
+ this.target === "_blank" ? "noopener noreferrer" : void 0
85
+ )
97
86
  )}>
98
- ${__privateMethod(this, _renderContent, renderContent_fn).call(this)}
87
+ ${__privateMethod(this, _UUIRefNodeElement_instances, renderContent_fn).call(this)}
99
88
  </a>`;
100
89
  };
101
- _renderButton = new WeakSet();
102
90
  renderButton_fn = function() {
103
91
  return html`
104
92
  <button
@@ -108,10 +96,17 @@ renderButton_fn = function() {
108
96
  @click=${this.handleOpenClick}
109
97
  @keydown=${this.handleOpenKeydown}
110
98
  ?disabled=${this.disabled}>
111
- ${__privateMethod(this, _renderContent, renderContent_fn).call(this)}
99
+ ${__privateMethod(this, _UUIRefNodeElement_instances, renderContent_fn).call(this)}
112
100
  </button>
113
101
  `;
114
102
  };
103
+ renderSomething_fn = function() {
104
+ if (this.readonly) {
105
+ return html`${__privateMethod(this, _UUIRefNodeElement_instances, renderContent_fn).call(this)}`;
106
+ } else {
107
+ return this.href ? __privateMethod(this, _UUIRefNodeElement_instances, renderLink_fn).call(this) : __privateMethod(this, _UUIRefNodeElement_instances, renderButton_fn).call(this);
108
+ }
109
+ };
115
110
  UUIRefNodeElement.styles = [
116
111
  ...UUIRefElement.styles,
117
112
  css`
@@ -120,15 +115,17 @@ UUIRefNodeElement.styles = [
120
115
  padding: calc(var(--uui-size-2,6px) + 1px);
121
116
  }
122
117
 
123
- #open-part {
124
- text-decoration: none;
125
- color: inherit;
118
+ #content {
126
119
  align-self: stretch;
127
120
  line-height: normal;
128
-
129
121
  display: flex;
130
122
  position: relative;
131
123
  align-items: center;
124
+ }
125
+
126
+ #open-part {
127
+ color: inherit;
128
+ text-decoration: none;
132
129
  cursor: pointer;
133
130
  }
134
131
 
@@ -190,6 +187,9 @@ __decorateClass([
190
187
  __decorateClass([
191
188
  property({ type: String })
192
189
  ], UUIRefNodeElement.prototype, "target", 2);
190
+ __decorateClass([
191
+ property({ type: String })
192
+ ], UUIRefNodeElement.prototype, "rel", 2);
193
193
  __decorateClass([
194
194
  state()
195
195
  ], UUIRefNodeElement.prototype, "_iconSlotHasContent", 2);
@@ -40,6 +40,13 @@ export declare class UUIRefNodeElement extends UUIRefElement {
40
40
  * @default undefined
41
41
  */
42
42
  target?: '_blank' | '_parent' | '_self' | '_top';
43
+ /**
44
+ * Set the rel attribute for an anchor tag, only used when using href.
45
+ * @type {string}
46
+ * @attr
47
+ * @default undefined
48
+ */
49
+ rel?: string;
43
50
  private _iconSlotHasContent;
44
51
  protected fallbackIcon: string;
45
52
  connectedCallback(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-ui/uui-ref-node",
3
- "version": "1.8.0",
3
+ "version": "1.9.0-rc.0",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Umbraco",
@@ -30,9 +30,9 @@
30
30
  "custom-elements.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@umbraco-ui/uui-base": "1.8.0",
34
- "@umbraco-ui/uui-icon": "1.8.0",
35
- "@umbraco-ui/uui-ref": "1.8.0"
33
+ "@umbraco-ui/uui-base": "1.9.0-rc.0",
34
+ "@umbraco-ui/uui-icon": "1.9.0-rc.0",
35
+ "@umbraco-ui/uui-ref": "1.9.0-rc.0"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "npm run analyze && tsc --build && rollup -c rollup.config.js",
@@ -43,5 +43,5 @@
43
43
  "access": "public"
44
44
  },
45
45
  "homepage": "https://uui.umbraco.com/?path=/story/uui-ref-node",
46
- "gitHead": "53021762a52dc54a46f0c5ef829c1cbaabde1160"
46
+ "gitHead": "e3e398e07b6ff9874aa0656cb7767df42f58a4ce"
47
47
  }