@umbraco-ui/uui-color-picker 1.5.0-rc.0 → 1.5.0-rc.1
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/custom-elements.json +8 -8
- package/lib/index.js +50 -36
- package/lib/uui-color-picker.element.d.ts +5 -5
- package/package.json +3 -3
package/custom-elements.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "format",
|
|
16
|
-
"description": "The format to use for the display value. If opacity is enabled, these will translate to HEXA, RGBA, and
|
|
16
|
+
"description": "The format to use for the display value. If opacity is enabled, these will translate to HEXA, RGBA, HSLA, and HSVA\nrespectively. The color picker will always accept user input in any format (including CSS color names) and convert\nit to the desired format.",
|
|
17
17
|
"type": "UUIColorPickerFormat",
|
|
18
18
|
"default": "\"'hex'\""
|
|
19
19
|
},
|
|
@@ -66,11 +66,6 @@
|
|
|
66
66
|
}
|
|
67
67
|
],
|
|
68
68
|
"properties": [
|
|
69
|
-
{
|
|
70
|
-
"name": "styles",
|
|
71
|
-
"type": "CSSResult[]",
|
|
72
|
-
"default": "[null]"
|
|
73
|
-
},
|
|
74
69
|
{
|
|
75
70
|
"name": "value",
|
|
76
71
|
"attribute": "value",
|
|
@@ -81,7 +76,7 @@
|
|
|
81
76
|
{
|
|
82
77
|
"name": "format",
|
|
83
78
|
"attribute": "format",
|
|
84
|
-
"description": "The format to use for the display value. If opacity is enabled, these will translate to HEXA, RGBA, and
|
|
79
|
+
"description": "The format to use for the display value. If opacity is enabled, these will translate to HEXA, RGBA, HSLA, and HSVA\nrespectively. The color picker will always accept user input in any format (including CSS color names) and convert\nit to the desired format.",
|
|
85
80
|
"type": "UUIColorPickerFormat",
|
|
86
81
|
"default": "\"'hex'\""
|
|
87
82
|
},
|
|
@@ -136,10 +131,15 @@
|
|
|
136
131
|
},
|
|
137
132
|
{
|
|
138
133
|
"name": "swatches",
|
|
139
|
-
"description": "An array of predefined color swatches to display. Can include any format the color picker can parse, including\nHEX(A), RGB(A), HSL(A), and CSS color names.",
|
|
134
|
+
"description": "An array of predefined color swatches to display. Can include any format the color picker can parse, including\nHEX(A), RGB(A), HSL(A), HSV(A), and CSS color names.",
|
|
140
135
|
"type": "string[]",
|
|
141
136
|
"default": "[\"#d0021b\",\"#f5a623\",\"#f8e71c\",\"#8b572a\",\"#7ed321\",\"#417505\",\"#bd10e0\",\"#9013fe\",\"#4a90e2\",\"#50e3c2\",\"#b8e986\",\"#000\",\"#444\",\"#888\",\"#ccc\",\"#fff\"]"
|
|
142
137
|
},
|
|
138
|
+
{
|
|
139
|
+
"name": "styles",
|
|
140
|
+
"type": "CSSResult[]",
|
|
141
|
+
"default": "[null]"
|
|
142
|
+
},
|
|
143
143
|
{
|
|
144
144
|
"name": "label",
|
|
145
145
|
"attribute": "label",
|
package/lib/index.js
CHANGED
|
@@ -106,25 +106,29 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
106
106
|
/** Returns the current value as a string in the specified format. */
|
|
107
107
|
getFormattedValue(format) {
|
|
108
108
|
const formatToUse = this.opacity ? `${format}a` : format;
|
|
109
|
-
const
|
|
109
|
+
const hexa = this._colord.toHex();
|
|
110
|
+
const hex = hexa.length > 7 ? hexa.substring(0, hexa.length - 2) : hexa;
|
|
110
111
|
const { r, g, b } = this._colord.toRgb();
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
);
|
|
112
|
+
const { h, s, l } = this._colord.toHsl();
|
|
113
|
+
const { v } = this._colord.toHsv();
|
|
114
|
+
const a = this._colord.alpha();
|
|
115
115
|
switch (formatToUse) {
|
|
116
116
|
case "hex":
|
|
117
|
-
return hex;
|
|
117
|
+
return this.setLetterCase(hex);
|
|
118
118
|
case "hexa":
|
|
119
|
-
return hexa;
|
|
119
|
+
return this.setLetterCase(hexa);
|
|
120
120
|
case "rgb":
|
|
121
|
-
return `rgb(${r} ${g} ${b})
|
|
121
|
+
return this.setLetterCase(`rgb(${r}, ${g}, ${b})`);
|
|
122
122
|
case "rgba":
|
|
123
|
-
return this._colord.toRgbString();
|
|
123
|
+
return this.setLetterCase(this._colord.toRgbString());
|
|
124
124
|
case "hsl":
|
|
125
|
-
return `hsl(${h} ${s} ${l})
|
|
125
|
+
return this.setLetterCase(`hsl(${h}, ${s}%, ${l}%)`);
|
|
126
126
|
case "hsla":
|
|
127
|
-
return this._colord.toHslString();
|
|
127
|
+
return this.setLetterCase(this._colord.toHslString());
|
|
128
|
+
case "hsv":
|
|
129
|
+
return this.setLetterCase(`hsv(${h}, ${s}%, ${l}%)`);
|
|
130
|
+
case "hsva":
|
|
131
|
+
return this.setLetterCase(`hsva(${h}, ${s}%, ${v}%, ${a})`);
|
|
128
132
|
default:
|
|
129
133
|
return "";
|
|
130
134
|
}
|
|
@@ -140,7 +144,7 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
140
144
|
);
|
|
141
145
|
}
|
|
142
146
|
handleFormatToggle() {
|
|
143
|
-
const formats = ["hex", "rgb", "hsl"];
|
|
147
|
+
const formats = ["hex", "rgb", "hsl", "hsv"];
|
|
144
148
|
const nextIndex = (formats.indexOf(this.format) + 1) % formats.length;
|
|
145
149
|
this.format = formats[nextIndex];
|
|
146
150
|
this._syncValues();
|
|
@@ -231,13 +235,13 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
231
235
|
openColorPicker(event) {
|
|
232
236
|
event.stopImmediatePropagation();
|
|
233
237
|
const target = event.target;
|
|
234
|
-
const popover = target.
|
|
238
|
+
const popover = target.parentElement;
|
|
235
239
|
popover.open = !(popover == null ? void 0 : popover.open);
|
|
236
240
|
target.setAttribute("aria-expanded", popover.open.toString());
|
|
237
241
|
}
|
|
238
242
|
closeColorPicker(event) {
|
|
239
243
|
const target = event.target;
|
|
240
|
-
const trigger = target.
|
|
244
|
+
const trigger = target.querySelector("button[part=trigger]");
|
|
241
245
|
if (trigger) {
|
|
242
246
|
trigger.setAttribute("aria-expanded", "false");
|
|
243
247
|
}
|
|
@@ -282,7 +286,10 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
282
286
|
"color-picker--disabled": this.disabled
|
|
283
287
|
})}
|
|
284
288
|
aria-disabled=${this.disabled ? "true" : "false"}>
|
|
285
|
-
<uui-color-area
|
|
289
|
+
<uui-color-area
|
|
290
|
+
.value="${this.value}"
|
|
291
|
+
?disabled=${this.disabled}
|
|
292
|
+
@change=${this.handleGridChange}>
|
|
286
293
|
</uui-color-area>
|
|
287
294
|
<div class="color-picker__controls">
|
|
288
295
|
<div class="color-picker__sliders">
|
|
@@ -290,6 +297,7 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
290
297
|
label="hue"
|
|
291
298
|
class="hue-slider"
|
|
292
299
|
.value=${Math.round(this.hue)}
|
|
300
|
+
?disabled=${this.disabled}
|
|
293
301
|
@change=${this.handleHueChange}>
|
|
294
302
|
</uui-color-slider>
|
|
295
303
|
${this.opacity ? html`
|
|
@@ -299,6 +307,7 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
299
307
|
.value=${Math.round(this.alpha)}
|
|
300
308
|
type="opacity"
|
|
301
309
|
.color=${this.value}
|
|
310
|
+
?disabled=${this.disabled}
|
|
302
311
|
@change=${this.handleAlphaChange}>
|
|
303
312
|
</uui-color-slider>
|
|
304
313
|
` : ""}
|
|
@@ -329,19 +338,19 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
329
338
|
@change=${this.handleInputChange}>
|
|
330
339
|
</uui-input>
|
|
331
340
|
<uui-button-group>
|
|
332
|
-
${!this.noFormatToggle ? html
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
${hasEyeDropper ? html` <uui-button
|
|
341
|
+
${!this.noFormatToggle ? html`<uui-button
|
|
342
|
+
label="Toggle color format"
|
|
343
|
+
@click=${this.handleFormatToggle}
|
|
344
|
+
class="color-picker__toggle-format"
|
|
345
|
+
?disabled=${this.disabled}
|
|
346
|
+
compact>
|
|
347
|
+
<span>${this.format}</span>
|
|
348
|
+
</uui-button>` : ""}
|
|
349
|
+
${hasEyeDropper ? html`<uui-button
|
|
342
350
|
label="Select a color"
|
|
343
|
-
|
|
344
|
-
@click=${this.handleEyeDropper}
|
|
351
|
+
?disabled=${this.disabled}
|
|
352
|
+
@click=${this.handleEyeDropper}
|
|
353
|
+
compact>
|
|
345
354
|
<uui-icon-registry-essential>
|
|
346
355
|
<uui-icon name="colorpicker"></uui-icon>
|
|
347
356
|
</uui-icon-registry-essential>
|
|
@@ -358,17 +367,21 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
358
367
|
return html`<uui-color-swatches
|
|
359
368
|
id="swatches"
|
|
360
369
|
class="color-picker__swatches"
|
|
370
|
+
?disabled=${this.disabled}
|
|
361
371
|
@change=${this.handleColorSwatchChange}>
|
|
362
372
|
${this.swatches.map(
|
|
363
|
-
(swatch) => html`<uui-color-swatch
|
|
364
|
-
|
|
365
|
-
.value=${swatch}></uui-color-swatch>`
|
|
373
|
+
(swatch) => html`<uui-color-swatch label="${swatch}" .value=${swatch}>
|
|
374
|
+
</uui-color-swatch>`
|
|
366
375
|
)}
|
|
367
376
|
</uui-color-swatches>`;
|
|
368
377
|
}
|
|
369
378
|
_renderPreviewButton() {
|
|
370
|
-
return html`<
|
|
379
|
+
return html`<uui-popover
|
|
380
|
+
placement="bottom-start"
|
|
381
|
+
@close=${this.closeColorPicker}>
|
|
382
|
+
<button
|
|
371
383
|
type="button"
|
|
384
|
+
part="trigger"
|
|
372
385
|
slot="trigger"
|
|
373
386
|
aria-label="${this.label || "Open Color picker"}"
|
|
374
387
|
class=${classMap({
|
|
@@ -382,12 +395,12 @@ let UUIColorPickerElement = class extends LabelMixin("label", LitElement) {
|
|
|
382
395
|
style=${styleMap({
|
|
383
396
|
"--preview-color": `hsla(${this.hue}deg, ${this.saturation}%, ${this.lightness}%, ${this.alpha / 100})`
|
|
384
397
|
})}
|
|
398
|
+
?disabled=${this.disabled}
|
|
385
399
|
@click=${this.openColorPicker}
|
|
386
400
|
aria-haspopup="true"
|
|
387
401
|
aria-expanded="false"></button>
|
|
388
|
-
<
|
|
389
|
-
|
|
390
|
-
</uui-popover>`;
|
|
402
|
+
<div slot="popover">${this._renderColorPicker()}</div>
|
|
403
|
+
</uui-popover>`;
|
|
391
404
|
}
|
|
392
405
|
render() {
|
|
393
406
|
return this.inline ? this._renderColorPicker() : this._renderPreviewButton();
|
|
@@ -435,8 +448,9 @@ UUIColorPickerElement.styles = [
|
|
|
435
448
|
margin-left: 0.75rem;
|
|
436
449
|
border-radius: 50%;
|
|
437
450
|
}
|
|
438
|
-
color-picker__trigger {
|
|
439
|
-
cursor:
|
|
451
|
+
.color-picker__trigger[disabled] {
|
|
452
|
+
cursor: not-allowed;
|
|
453
|
+
opacity: 0.5;
|
|
440
454
|
}
|
|
441
455
|
.color-picker__preview::before,
|
|
442
456
|
.color-picker__trigger::before {
|
|
@@ -4,8 +4,8 @@ import { UUIColorAreaEvent } from '@umbraco-ui/uui-color-area/lib';
|
|
|
4
4
|
import { UUIColorSliderEvent } from '@umbraco-ui/uui-color-slider/lib';
|
|
5
5
|
import { UUIColorSwatchesElement, UUIColorSwatchesEvent } from '@umbraco-ui/uui-color-swatches/lib';
|
|
6
6
|
import { UUIInputElement } from '@umbraco-ui/uui-input/lib';
|
|
7
|
-
export type UUIColorPickerFormat = 'hex' | 'rgb' | 'hsl';
|
|
8
|
-
export type UUIColorPickerFormatWithAlpha = UUIColorPickerFormat | 'hexa' | 'rgba' | 'hsla';
|
|
7
|
+
export type UUIColorPickerFormat = 'hex' | 'rgb' | 'hsl' | 'hsv';
|
|
8
|
+
export type UUIColorPickerFormatWithAlpha = UUIColorPickerFormat | 'hexa' | 'rgba' | 'hsla' | 'hsva';
|
|
9
9
|
type UUIColorPickerSize = 'small' | 'medium' | 'large';
|
|
10
10
|
declare const UUIColorPickerElement_base: (new (...args: any[]) => import("@umbraco-ui/uui-base/lib/mixins").LabelMixinInterface) & typeof LitElement;
|
|
11
11
|
/**
|
|
@@ -15,7 +15,6 @@ declare const UUIColorPickerElement_base: (new (...args: any[]) => import("@umbr
|
|
|
15
15
|
* @fires {UUIColorPickerChangeEvent} change - Fired when the color changes
|
|
16
16
|
*/
|
|
17
17
|
export declare class UUIColorPickerElement extends UUIColorPickerElement_base {
|
|
18
|
-
static styles: import("lit").CSSResult[];
|
|
19
18
|
_input: UUIInputElement;
|
|
20
19
|
_previewButton: HTMLButtonElement;
|
|
21
20
|
_swatches: UUIColorSwatchesElement;
|
|
@@ -33,7 +32,7 @@ export declare class UUIColorPickerElement extends UUIColorPickerElement_base {
|
|
|
33
32
|
**/
|
|
34
33
|
value: string;
|
|
35
34
|
/**
|
|
36
|
-
* The format to use for the display value. If opacity is enabled, these will translate to HEXA, RGBA, and
|
|
35
|
+
* The format to use for the display value. If opacity is enabled, these will translate to HEXA, RGBA, HSLA, and HSVA
|
|
37
36
|
* respectively. The color picker will always accept user input in any format (including CSS color names) and convert
|
|
38
37
|
* it to the desired format.
|
|
39
38
|
* @attr
|
|
@@ -92,7 +91,7 @@ export declare class UUIColorPickerElement extends UUIColorPickerElement_base {
|
|
|
92
91
|
uppercase: boolean;
|
|
93
92
|
/**
|
|
94
93
|
* An array of predefined color swatches to display. Can include any format the color picker can parse, including
|
|
95
|
-
* HEX(A), RGB(A), HSL(A), and CSS color names.
|
|
94
|
+
* HEX(A), RGB(A), HSL(A), HSV(A), and CSS color names.
|
|
96
95
|
*/
|
|
97
96
|
swatches: string[];
|
|
98
97
|
connectedCallback(): void;
|
|
@@ -118,6 +117,7 @@ export declare class UUIColorPickerElement extends UUIColorPickerElement_base {
|
|
|
118
117
|
private _renderSwatches;
|
|
119
118
|
private _renderPreviewButton;
|
|
120
119
|
render(): import("lit-html").TemplateResult<1>;
|
|
120
|
+
static styles: import("lit").CSSResult[];
|
|
121
121
|
}
|
|
122
122
|
declare global {
|
|
123
123
|
interface HTMLElementTagNameMap {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-color-picker",
|
|
3
|
-
"version": "1.5.0-rc.
|
|
3
|
+
"version": "1.5.0-rc.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Umbraco",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"custom-elements.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@umbraco-ui/uui-base": "1.5.0-rc.
|
|
33
|
+
"@umbraco-ui/uui-base": "1.5.0-rc.1",
|
|
34
34
|
"colord": "^2.9.3"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://uui.umbraco.com/?path=/story/uui-color-picker",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "2ff35a098ed8a3feb8ebed1bf43b4fbb75950d65"
|
|
46
46
|
}
|