@umbraco-ui/uui-color-swatches 1.10.0 → 1.12.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.
@@ -4,7 +4,7 @@
4
4
  {
5
5
  "name": "uui-color-swatches",
6
6
  "path": "./lib/uui-color-swatches.element.ts",
7
- "description": "Put uui-stacked-color-swatch elements inside this element to create a color swatch selector.",
7
+ "description": "Put uui-color-swatch elements inside this element to create a color swatch selector.",
8
8
  "attributes": [
9
9
  {
10
10
  "name": "value",
@@ -14,7 +14,13 @@
14
14
  },
15
15
  {
16
16
  "name": "disabled",
17
- "description": "Disables the color swatches.",
17
+ "description": "Sets the swatches to disabled.",
18
+ "type": "boolean",
19
+ "default": "\"false\""
20
+ },
21
+ {
22
+ "name": "readonly",
23
+ "description": "Sets the swatches to readonly mode.",
18
24
  "type": "boolean",
19
25
  "default": "\"false\""
20
26
  },
@@ -35,13 +41,16 @@
35
41
  {
36
42
  "name": "disabled",
37
43
  "attribute": "disabled",
38
- "description": "Disables the color swatches.",
44
+ "description": "Sets the swatches to disabled.",
39
45
  "type": "boolean",
40
46
  "default": "\"false\""
41
47
  },
42
48
  {
43
- "name": "swatches",
44
- "type": "UUIColorSwatchElement[]"
49
+ "name": "readonly",
50
+ "attribute": "readonly",
51
+ "description": "Sets the swatches to readonly mode.",
52
+ "type": "boolean",
53
+ "default": "\"false\""
45
54
  },
46
55
  {
47
56
  "name": "styles",
package/lib/index.js CHANGED
@@ -29,9 +29,10 @@ let UUIColorSwatchesElement = class extends LabelMixin("label", LitElement) {
29
29
  super();
30
30
  this.value = "";
31
31
  this.disabled = false;
32
+ this.readonly = false;
32
33
  this._onSelected = (event) => {
33
34
  const target = event.target;
34
- if (!this.swatches.includes(target)) return;
35
+ if (!this._swatches.includes(target)) return;
35
36
  if (this._selectedElement) {
36
37
  this._selectedElement.selected = false;
37
38
  this._selectedElement.active = false;
@@ -44,7 +45,7 @@ let UUIColorSwatchesElement = class extends LabelMixin("label", LitElement) {
44
45
  };
45
46
  this._onDeselected = (event) => {
46
47
  const target = event.target;
47
- if (!this.swatches.includes(target)) return;
48
+ if (!this._swatches.includes(target)) return;
48
49
  if (this._activeElement === target) {
49
50
  this._activeElement = void 0;
50
51
  }
@@ -84,8 +85,8 @@ let UUIColorSwatchesElement = class extends LabelMixin("label", LitElement) {
84
85
  }
85
86
  }
86
87
  _handleSlotChange() {
87
- if (!this.swatches || this.swatches.length === 0) return;
88
- this.swatches.forEach((swatch) => {
88
+ if (!this._swatches || this._swatches.length === 0) return;
89
+ this._swatches.forEach((swatch) => {
89
90
  swatch.setAttribute("aria-checked", "false");
90
91
  swatch.setAttribute("role", "radio");
91
92
  if (this.disabled) {
@@ -93,6 +94,9 @@ let UUIColorSwatchesElement = class extends LabelMixin("label", LitElement) {
93
94
  } else {
94
95
  swatch.setAttribute("selectable", "selectable");
95
96
  }
97
+ if (this.readonly) {
98
+ swatch.setAttribute("readonly", "");
99
+ }
96
100
  if (this.value !== "" && swatch.value === this.value) {
97
101
  swatch.selected = true;
98
102
  swatch.setAttribute("aria-checked", "true");
@@ -107,7 +111,7 @@ let UUIColorSwatchesElement = class extends LabelMixin("label", LitElement) {
107
111
  * @memberof UUIColorSwatchesElement
108
112
  */
109
113
  resetSelection() {
110
- this.swatches.forEach((swatch) => {
114
+ this._swatches.forEach((swatch) => {
111
115
  swatch.selected = false;
112
116
  swatch.active = false;
113
117
  swatch.selectable = !swatch.disabled;
@@ -135,9 +139,12 @@ __decorateClass([
135
139
  __decorateClass([
136
140
  property({ type: Boolean, reflect: true })
137
141
  ], UUIColorSwatchesElement.prototype, "disabled", 2);
142
+ __decorateClass([
143
+ property({ type: Boolean, reflect: true })
144
+ ], UUIColorSwatchesElement.prototype, "readonly", 2);
138
145
  __decorateClass([
139
146
  queryAssignedElements({ selector: "uui-color-swatch" })
140
- ], UUIColorSwatchesElement.prototype, "swatches", 2);
147
+ ], UUIColorSwatchesElement.prototype, "_swatches", 2);
141
148
  UUIColorSwatchesElement = __decorateClass([
142
149
  defineElement("uui-color-swatches")
143
150
  ], UUIColorSwatchesElement);
@@ -1,8 +1,7 @@
1
- import type { UUIColorSwatchElement } from '@umbraco-ui/uui-color-swatch/lib';
2
1
  import { LitElement, PropertyValueMap } from 'lit';
3
2
  declare const UUIColorSwatchesElement_base: (new (...args: any[]) => import("@umbraco-ui/uui-base/lib/mixins").LabelMixinInterface) & typeof LitElement;
4
3
  /**
5
- * Put uui-stacked-color-swatch elements inside this element to create a color swatch selector.
4
+ * Put uui-color-swatch elements inside this element to create a color swatch selector.
6
5
  * @element uui-color-swatches
7
6
  * @slot - Default slot for content.
8
7
  * @fires {UUIColorSwatchesEvent} change - Fires when a color swatch is selected.
@@ -15,13 +14,20 @@ export declare class UUIColorSwatchesElement extends UUIColorSwatchesElement_bas
15
14
  */
16
15
  value: string;
17
16
  /**
18
- * Disables the color swatches.
17
+ * Sets the swatches to disabled.
19
18
  * @type {boolean}
20
19
  * @attr
21
20
  * @default false
22
21
  **/
23
22
  disabled: boolean;
24
- swatches: Array<UUIColorSwatchElement>;
23
+ /**
24
+ * Sets the swatches to readonly mode.
25
+ * @type {boolean}
26
+ * @attr
27
+ * @default false
28
+ */
29
+ readonly: boolean;
30
+ private readonly _swatches;
25
31
  private __activeElement;
26
32
  private get _activeElement();
27
33
  private set _activeElement(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-ui/uui-color-swatches",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Umbraco",
@@ -30,8 +30,8 @@
30
30
  "custom-elements.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@umbraco-ui/uui-base": "1.10.0",
34
- "@umbraco-ui/uui-color-swatch": "1.10.0"
33
+ "@umbraco-ui/uui-base": "1.12.0",
34
+ "@umbraco-ui/uui-color-swatch": "1.12.0"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "npm run analyze && tsc --build && rollup -c rollup.config.js",
@@ -42,5 +42,5 @@
42
42
  "access": "public"
43
43
  },
44
44
  "homepage": "https://uui.umbraco.com/?path=/story/uui-color-swatches",
45
- "gitHead": "fc19b5d3cd80cf4205ec56d14403ae0e926d6aed"
45
+ "gitHead": "0ac5219b2765bf6c90fe4943a6620b46a7fced4e"
46
46
  }