@vonage/vivid 5.3.0 → 5.5.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.
- package/accordion-item/definition.js +1 -1
- package/alert/definition.cjs +1 -1
- package/alert/definition.js +2 -2
- package/badge/definition.js +1 -1
- package/banner/definition.js +1 -1
- package/bundled/base-color-picker.cjs +18 -13
- package/bundled/base-color-picker.js +98 -81
- package/bundled/calendar-picker.template.cjs +7 -7
- package/bundled/calendar-picker.template.js +102 -102
- package/bundled/char-count.cjs +1 -1
- package/bundled/char-count.js +1 -1
- package/bundled/definition10.cjs +1 -1
- package/bundled/definition10.js +2 -2
- package/bundled/definition11.cjs +12 -19
- package/bundled/definition11.js +87 -66
- package/bundled/definition12.cjs +19 -10
- package/bundled/definition12.js +217 -36
- package/bundled/definition13.cjs +10 -1
- package/bundled/definition13.js +38 -14
- package/bundled/definition14.cjs +1 -5
- package/bundled/definition14.js +15 -24
- package/bundled/definition15.cjs +5 -30
- package/bundled/definition15.js +22 -73
- package/bundled/definition16.cjs +30 -19
- package/bundled/definition16.js +74 -97
- package/bundled/definition17.cjs +19 -13
- package/bundled/definition17.js +83 -117
- package/bundled/definition18.cjs +13 -12
- package/bundled/definition18.js +114 -71
- package/bundled/definition19.cjs +26 -27
- package/bundled/definition19.js +171 -180
- package/bundled/definition2.cjs +9 -9
- package/bundled/definition2.js +84 -129
- package/bundled/definition3.cjs +1 -1
- package/bundled/definition3.js +1 -1
- package/bundled/definition6.cjs +3 -3
- package/bundled/definition6.js +19 -19
- package/bundled/definition9.cjs +5 -5
- package/bundled/definition9.js +394 -392
- package/bundled/listbox.cjs +1 -1
- package/bundled/listbox.js +82 -102
- package/bundled/localized.cjs +1 -1
- package/bundled/localized.js +48 -31
- package/bundled/mixins.cjs +1 -1
- package/bundled/mixins.js +1 -1
- package/bundled/picker-field.template.cjs +14 -14
- package/bundled/picker-field.template.js +35 -56
- package/bundled/time-selection-picker.template.cjs +12 -12
- package/bundled/time-selection-picker.template.js +13 -12
- package/bundled/trapped-focus.cjs +1 -0
- package/bundled/trapped-focus.js +26 -0
- package/bundled/vivid-element.cjs +5 -1
- package/bundled/vivid-element.js +401 -358
- package/calendar/index.cjs +13 -13
- package/calendar/index.js +171 -143
- package/card/definition.cjs +1 -1
- package/card/definition.js +1 -1
- package/color-picker/definition.cjs +209 -113
- package/color-picker/definition.js +209 -113
- package/color-picker/index.cjs +104 -75
- package/color-picker/index.js +412 -326
- package/combobox/definition.cjs +7 -27
- package/combobox/definition.js +8 -28
- package/combobox/index.cjs +6 -6
- package/combobox/index.js +57 -71
- package/contextual-help/index.cjs +1 -1
- package/contextual-help/index.js +1 -1
- package/custom-elements.json +354 -2
- package/data-grid/index.cjs +1 -1
- package/data-grid/index.js +1 -1
- package/date-picker/definition.cjs +1 -1
- package/date-picker/definition.js +1 -1
- package/date-picker/index.cjs +1 -1
- package/date-picker/index.js +2 -2
- package/date-range-picker/definition.cjs +1 -1
- package/date-range-picker/definition.js +1 -1
- package/date-range-picker/index.cjs +1 -1
- package/date-range-picker/index.js +2 -2
- package/date-time-picker/definition.cjs +1 -1
- package/date-time-picker/definition.js +1 -1
- package/date-time-picker/index.cjs +1 -1
- package/date-time-picker/index.js +2 -2
- package/dial-pad/definition.cjs +139 -0
- package/dial-pad/definition.js +139 -0
- package/dial-pad/index.cjs +27 -20
- package/dial-pad/index.js +177 -100
- package/dialog/definition.cjs +2 -2
- package/dialog/definition.js +2 -2
- package/dialog/index.cjs +7 -7
- package/dialog/index.js +6 -6
- package/divider/index.cjs +1 -1
- package/divider/index.js +1 -1
- package/elevation/definition.cjs +1 -1
- package/elevation/definition.js +1 -1
- package/fab/definition.js +1 -1
- package/header/definition.cjs +1 -1
- package/header/definition.js +1 -1
- package/icon/definition.cjs +56 -22
- package/icon/definition.js +56 -22
- package/index.cjs +3 -4
- package/index.js +2 -3
- package/lib/accordion/accordion.d.ts +1 -1
- package/lib/accordion/definition.d.ts +1 -1
- package/lib/audio-player/audio-player.d.ts +1 -1
- package/lib/color-picker/color-picker.d.ts +390 -12
- package/lib/color-picker/locale.d.ts +4 -0
- package/lib/combobox/combobox.d.ts +1 -0
- package/lib/combobox/combobox.options.d.ts +1 -1
- package/lib/date-picker/date-picker.d.ts +38 -38
- package/lib/date-range-picker/date-range-picker.d.ts +20 -20
- package/lib/date-time-picker/date-time-picker.d.ts +40 -40
- package/lib/dial-pad/dial-pad.d.ts +1 -0
- package/lib/divider/divider.d.ts +1 -1
- package/lib/icon/icon.d.ts +1 -0
- package/lib/menu-item/menu-item-role.d.ts +1 -1
- package/lib/popup/popup.d.ts +1 -1
- package/lib/searchable-select/locale.d.ts +4 -0
- package/lib/searchable-select/searchable-select.d.ts +3 -0
- package/lib/select/select.d.ts +3 -1
- package/lib/simple-color-picker/simple-color-picker.d.ts +2 -1
- package/lib/slider/slider.d.ts +1 -1
- package/lib/tabs/tabs.d.ts +2 -2
- package/lib/text-area/text-area.d.ts +1 -1
- package/lib/text-field/text-field.d.ts +1 -1
- package/lib/time-picker/time-picker.d.ts +20 -20
- package/locales/de-DE.cjs +20 -3
- package/locales/de-DE.js +20 -3
- package/locales/en-GB.cjs +21 -4
- package/locales/en-GB.js +21 -4
- package/locales/en-US.cjs +21 -4
- package/locales/en-US.js +21 -4
- package/locales/ja-JP.cjs +20 -3
- package/locales/ja-JP.js +20 -3
- package/locales/zh-CN.cjs +19 -2
- package/locales/zh-CN.js +19 -2
- package/menu/definition.cjs +4 -4
- package/menu/definition.js +4 -4
- package/nav-disclosure/definition.js +1 -1
- package/nav-item/definition.js +1 -1
- package/note/definition.js +1 -1
- package/number-field/definition.js +1 -1
- package/number-field/index.cjs +1 -1
- package/number-field/index.js +3 -3
- package/option/definition.cjs +6 -77
- package/option/definition.js +3 -78
- package/option/index.cjs +1 -1
- package/option/index.js +1 -1
- package/package.json +31 -5
- package/popup/definition.cjs +2 -2
- package/popup/definition.js +2 -2
- package/progress-ring/index.cjs +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.cjs +1 -1
- package/radio/index.js +1 -1
- package/radio-group/index.cjs +1 -1
- package/radio-group/index.js +1 -1
- package/range-slider/definition.cjs +1 -1
- package/range-slider/definition.js +1 -1
- package/rich-text-editor/definition.cjs +2 -3
- package/rich-text-editor/definition.js +1 -2
- package/rich-text-editor/index.cjs +27 -27
- package/rich-text-editor/index.js +1209 -1199
- package/searchable-select/definition.cjs +103 -11
- package/searchable-select/definition.js +103 -11
- package/searchable-select/index.cjs +81 -69
- package/searchable-select/index.js +359 -273
- package/select/definition.cjs +30 -44
- package/select/definition.js +30 -44
- package/selectable-box/definition.cjs +1 -1
- package/selectable-box/definition.js +1 -1
- package/selectable-box/index.cjs +1 -1
- package/selectable-box/index.js +2 -2
- package/shared/aria/aria-mixin.d.ts +1 -1
- package/shared/color-picker/base-color-picker.d.ts +2 -1
- package/shared/foundation/listbox/listbox.d.ts +4 -0
- package/shared/picker-field/mixins/calendar-picker.d.ts +10 -10
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +10 -10
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +20 -20
- package/shared/picker-field/mixins/single-date-picker.d.ts +28 -28
- package/shared/picker-field/mixins/single-value-picker.d.ts +8 -8
- package/shared/picker-field/mixins/time-selection-picker.d.ts +20 -20
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +20 -20
- package/simple-color-picker/definition.cjs +9 -7
- package/simple-color-picker/definition.js +9 -7
- package/simple-color-picker/index.cjs +6 -6
- package/simple-color-picker/index.js +41 -39
- package/slider/definition.cjs +1 -1
- package/slider/definition.js +1 -1
- package/split-button/definition.js +1 -1
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/tab/definition.js +1 -1
- package/tag/definition.cjs +34 -14
- package/tag/definition.js +35 -15
- package/tag/index.cjs +25 -12
- package/tag/index.js +64 -47
- package/tag-group/definition.cjs +1 -2
- package/tag-group/definition.js +1 -2
- package/tag-group/index.cjs +1 -1
- package/tag-group/index.js +11 -12
- package/text-area/index.cjs +1 -1
- package/text-area/index.js +2 -2
- package/text-field/definition.js +1 -1
- package/time-picker/definition.cjs +1 -1
- package/time-picker/definition.js +1 -1
- package/time-picker/index.cjs +1 -1
- package/time-picker/index.js +1 -1
- package/toggletip/definition.cjs +1 -1
- package/toggletip/definition.js +1 -1
- package/toggletip/index.cjs +1 -1
- package/toggletip/index.js +1 -1
- package/tooltip/definition.cjs +3 -3
- package/tooltip/definition.js +3 -3
- package/tooltip/index.cjs +1 -1
- package/tooltip/index.js +1 -1
- package/tree-item/definition.cjs +1 -1
- package/tree-item/definition.js +1 -1
- package/tree-view/definition.cjs +1 -1
- package/tree-view/definition.js +1 -1
- package/unbundled/affix.js +1 -1
- package/unbundled/base-color-picker.cjs +36 -18
- package/unbundled/base-color-picker.js +36 -18
- package/unbundled/calendar-picker.template.cjs +2 -2
- package/unbundled/calendar-picker.template.js +2 -2
- package/unbundled/definition.js +1 -1
- package/unbundled/definition2.js +1 -1
- package/unbundled/definition3.cjs +222 -141
- package/unbundled/definition3.js +220 -139
- package/unbundled/definition4.cjs +145 -235
- package/unbundled/definition4.js +143 -233
- package/unbundled/definition5.cjs +269 -27
- package/unbundled/definition5.js +267 -26
- package/unbundled/definition6.cjs +56 -0
- package/unbundled/definition6.js +52 -0
- package/unbundled/listbox.cjs +41 -63
- package/unbundled/listbox.js +39 -61
- package/unbundled/picker-field.template.cjs +3 -36
- package/unbundled/picker-field.template.js +3 -35
- package/unbundled/slider.template.cjs +1 -1
- package/unbundled/slider.template.js +1 -1
- package/unbundled/time-selection-picker.template.cjs +2 -1
- package/unbundled/time-selection-picker.template.js +2 -1
- package/unbundled/trapped-focus.cjs +37 -0
- package/unbundled/trapped-focus.js +34 -0
- package/unbundled/vivid-element.cjs +1 -1
- package/unbundled/vivid-element.js +1 -1
- package/video-player/definition.cjs +56 -16
- package/video-player/definition.js +56 -16
- package/video-player/index.cjs +36 -36
- package/video-player/index.js +2461 -2445
- package/visually-hidden/index.cjs +1 -1
- package/visually-hidden/index.js +1 -1
- package/vivid.api.json +285 -38
- package/bundled/_has.cjs +0 -1
- package/bundled/_has.js +0 -34
- package/bundled/option.cjs +0 -1
- package/bundled/option.js +0 -158
- package/unbundled/option.cjs +0 -217
- package/unbundled/option.js +0 -214
|
@@ -3,20 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const vividElement = require('../unbundled/vivid-element.cjs');
|
|
6
|
-
const popup_definition = require('../unbundled/
|
|
6
|
+
const popup_definition = require('../unbundled/definition5.cjs');
|
|
7
7
|
const icon_definition = require('../icon/definition.cjs');
|
|
8
8
|
const mixins = require('../unbundled/mixins.cjs');
|
|
9
9
|
const fastElement = require('@microsoft/fast-element');
|
|
10
10
|
const delegatesAria = require('../unbundled/delegates-aria.cjs');
|
|
11
|
+
const index = require('../unbundled/index.cjs');
|
|
11
12
|
const withContextualHelp = require('../unbundled/with-contextual-help.cjs');
|
|
13
|
+
const trappedFocus = require('../unbundled/trapped-focus.cjs');
|
|
12
14
|
const baseColorPicker = require('../unbundled/base-color-picker.cjs');
|
|
13
15
|
const withErrorText = require('../unbundled/with-error-text.cjs');
|
|
14
16
|
const withSuccessText = require('../unbundled/with-success-text.cjs');
|
|
15
17
|
const fastWebUtilities = require('@microsoft/fast-web-utilities');
|
|
16
18
|
const textField_definition = require('../text-field/definition.cjs');
|
|
17
19
|
const button_definition = require('../unbundled/definition.cjs');
|
|
20
|
+
const tooltip_definition = require('../tooltip/definition.cjs');
|
|
18
21
|
|
|
19
|
-
const styles = ".palette{display:grid;grid-template-columns:repeat(var(--swatches-per-row, 7),var(--_color-swatch-size, 24px))}.swatch{position:relative;padding:0;border
|
|
22
|
+
const styles = ".palette{display:grid;grid-template-columns:repeat(var(--swatches-per-row, 7),var(--_color-swatch-size, 24px))}.swatch{position:relative;padding:0;border-radius:4px;background-color:var(--swatch-color);block-size:var(--_color-swatch-size, 24px);color:var(--vvd-color-canvas);cursor:pointer;inline-size:var(--_color-swatch-size, 24px)}.swatch:not(.contrast){border:none}.swatch.contrast{border:1px solid var(--vvd-color-neutral-400);color:var(--vvd-color-canvas-text)}.swatch:focus-visible{outline:none;box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent;--focus-inset: -3px}:host{display:inline-block;--_low-ink-color: var(--vvd-color-neutral-600)}.base{display:inline-block;min-inline-size:var(--_color-picker-min-inline-size, 280px)}.control{inline-size:100%}.button{display:inline-flex;box-sizing:border-box;align-items:center;border:0 none;border-radius:4px;margin:0;background-color:var(--button-color, var(--vvd-color-canvas-text));block-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2)));color:var(--vvd-color-canvas);inline-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-inline:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2))/4);text-decoration:none;vertical-align:middle}.button.contrast{color:var(--vvd-color-canvas-text)}.button:not(.disabled){cursor:pointer}.button.disabled{background-color:var(--vvd-color-neutral-300);color:var(--vvd-color-neutral-500);cursor:not-allowed}.button:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}.button [data-vvd-component=icon]{font-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2))/2);line-height:1}.dialog{display:flex;flex-direction:column;min-inline-size:var(--_color-picker-popup-min-inline-size, 264px)}.dialog .header{display:inline-flex;align-items:center;justify-content:space-between;padding-block:8px;padding-inline:16px}.dialog .header-title{font:var(--vvd-typography-base-extended-bold);margin-block:0}.dialog .body{display:flex;flex-direction:column;gap:16px;margin-block-end:16px;padding-inline:16px}.dialog .hex-input-wrapper{display:flex;align-items:stretch;gap:8px}.dialog .hex-input-wrapper [data-vvd-component=button]{flex:0 0 auto}.dialog .footer{padding:16px;border-top:1px solid var(--vvd-color-neutral-200)}.dialog .footer-header{margin-block-end:8px}.dialog .swatches-count{color:var(--_low-ink-color);font:var(--vvd-typography-base)}.dialog .palette{gap:var(--_color-swatches-gap, 8px)}vvd-hex-input{min-width:0;flex:1 1 auto}vvd-hex-input::part(input),vvd-hex-input>input{width:100%;height:100%;box-sizing:border-box;border:0 none;border-radius:8px;background-color:var(--vvd-color-canvas);box-shadow:inset 0 0 0 1px var(--vvd-color-neutral-500);font:var(--vvd-typography-base);outline:transparent;padding-inline:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2))*.4)}vvd-hex-input::part(input):focus-visible,vvd-hex-input>input:focus-visible{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent}vvd-hex-picker{width:auto;height:auto;gap:16px;inline-size:100%}vvd-hex-picker::part(saturation){border-radius:8px;block-size:120px}vvd-hex-picker::part(hue){flex:0 0 8px;border-radius:8px}vvd-hex-picker::part(hue-pointer){width:10px;height:10px}vvd-hex-picker::part(saturation-pointer){width:18px;height:18px}::part(popup-base){inline-size:max-content;min-block-size:var(--_color-picker-popup-min-inline-size, 264px);min-inline-size:var(--_color-picker-popup-min-inline-size, 264px)}.visually-hidden{position:absolute;overflow:hidden;width:1px;height:1px;padding:0;border:0;margin:-1px;clip:rect(0 0 0 0)}";
|
|
20
23
|
|
|
21
24
|
// Clamps a value between an upper and lower bound.
|
|
22
25
|
// We use ternary operators because it makes the minified code
|
|
@@ -606,7 +609,11 @@ const vcPickerTag = VC_HEX_PICKER_TAG;
|
|
|
606
609
|
const vcInputTag = VC_HEX_INPUT_TAG;
|
|
607
610
|
class ColorPicker extends withContextualHelp.WithContextualHelp(
|
|
608
611
|
mixins.WithFeedback(
|
|
609
|
-
withErrorText.WithErrorText(
|
|
612
|
+
withErrorText.WithErrorText(
|
|
613
|
+
withSuccessText.WithSuccessText(
|
|
614
|
+
delegatesAria.DelegatesAria(trappedFocus.TrappedFocus(baseColorPicker.BaseColorPicker(vividElement.VividElement)))
|
|
615
|
+
)
|
|
616
|
+
)
|
|
610
617
|
)
|
|
611
618
|
) {
|
|
612
619
|
constructor() {
|
|
@@ -614,20 +621,6 @@ class ColorPicker extends withContextualHelp.WithContextualHelp(
|
|
|
614
621
|
this.disableSavedColors = false;
|
|
615
622
|
this.savedColors = [];
|
|
616
623
|
this.maxSwatches = 6;
|
|
617
|
-
this.copyIconName = "copy-2-line";
|
|
618
|
-
this.#iconResetTimer = null;
|
|
619
|
-
/**
|
|
620
|
-
* @internal
|
|
621
|
-
*/
|
|
622
|
-
this._copyValueToClipboard = async (value) => {
|
|
623
|
-
try {
|
|
624
|
-
await navigator.clipboard.writeText(value);
|
|
625
|
-
this._setTemporaryCopyIcon("check-circle-line");
|
|
626
|
-
} catch {
|
|
627
|
-
alert(this.locale?.colorPicker?.copyErrorText);
|
|
628
|
-
this._setTemporaryCopyIcon("error-line");
|
|
629
|
-
}
|
|
630
|
-
};
|
|
631
624
|
/**
|
|
632
625
|
* @internal
|
|
633
626
|
*/
|
|
@@ -637,14 +630,23 @@ class ColorPicker extends withContextualHelp.WithContextualHelp(
|
|
|
637
630
|
}
|
|
638
631
|
this.open = false;
|
|
639
632
|
};
|
|
633
|
+
this.copyIconName = "copy-2-line";
|
|
634
|
+
this.#iconResetTimer = null;
|
|
640
635
|
/**
|
|
641
636
|
* @internal
|
|
642
637
|
*/
|
|
643
|
-
this
|
|
644
|
-
|
|
645
|
-
|
|
638
|
+
this._copyValueToClipboard = async (value) => {
|
|
639
|
+
try {
|
|
640
|
+
await navigator.clipboard.writeText(value);
|
|
641
|
+
this._setTemporaryCopyIcon("check-circle-line");
|
|
642
|
+
this._ariaLiveDescription = this.locale.colorPicker.copySuccessMessage(value);
|
|
643
|
+
} catch {
|
|
644
|
+
alert(this.locale.colorPicker.copyErrorText);
|
|
645
|
+
this._setTemporaryCopyIcon("error-line");
|
|
646
|
+
this._ariaLiveDescription = this.locale.colorPicker.copyErrorText;
|
|
646
647
|
}
|
|
647
648
|
};
|
|
649
|
+
this._ariaLiveDescription = "";
|
|
648
650
|
}
|
|
649
651
|
static {
|
|
650
652
|
/**
|
|
@@ -670,6 +672,16 @@ class ColorPicker extends withContextualHelp.WithContextualHelp(
|
|
|
670
672
|
handleChange() {
|
|
671
673
|
this.$emit("change");
|
|
672
674
|
}
|
|
675
|
+
/**
|
|
676
|
+
* @internal
|
|
677
|
+
*/
|
|
678
|
+
openChanged(_oldValue, newValue) {
|
|
679
|
+
if (newValue && this.isConnected) {
|
|
680
|
+
requestAnimationFrame(() => {
|
|
681
|
+
this._refreshCanvasColor();
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
}
|
|
673
685
|
/**
|
|
674
686
|
* @internal
|
|
675
687
|
*/
|
|
@@ -690,6 +702,71 @@ class ColorPicker extends withContextualHelp.WithContextualHelp(
|
|
|
690
702
|
_handleColorSaving() {
|
|
691
703
|
this._saveCurrentColor();
|
|
692
704
|
}
|
|
705
|
+
/**
|
|
706
|
+
* @internal
|
|
707
|
+
*/
|
|
708
|
+
_saveCurrentColor() {
|
|
709
|
+
const value = this.value;
|
|
710
|
+
if (typeof value !== "string" || !baseColorPicker.isValidHexColor(value)) return;
|
|
711
|
+
const swatches = Array.isArray(this.savedColors) ? [...this.savedColors] : [];
|
|
712
|
+
const idx = swatches.findIndex((s) => s?.value === value);
|
|
713
|
+
if (idx !== -1) swatches.splice(idx, 1);
|
|
714
|
+
swatches.unshift({ value });
|
|
715
|
+
this.savedColors = swatches.slice(0, this._maxSwatchesNormalized);
|
|
716
|
+
this._setSavedColors(this.savedColors);
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* @internal
|
|
720
|
+
*/
|
|
721
|
+
_loadSavedColors() {
|
|
722
|
+
try {
|
|
723
|
+
const savedColors = localStorage.getItem(this._savedColorsStorageKey);
|
|
724
|
+
if (!savedColors) return [];
|
|
725
|
+
const parsed = JSON.parse(savedColors);
|
|
726
|
+
if (!Array.isArray(parsed)) return [];
|
|
727
|
+
return parsed.filter(
|
|
728
|
+
(x) => x && typeof x.value === "string" && baseColorPicker.isValidHexColor(x.value)
|
|
729
|
+
).map((x) => ({
|
|
730
|
+
value: x.value,
|
|
731
|
+
label: typeof x.label === "string" ? x.label : void 0
|
|
732
|
+
}));
|
|
733
|
+
} catch {
|
|
734
|
+
return [];
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* @internal
|
|
739
|
+
*/
|
|
740
|
+
_setSavedColors(swatches) {
|
|
741
|
+
try {
|
|
742
|
+
localStorage.setItem(
|
|
743
|
+
this._savedColorsStorageKey,
|
|
744
|
+
JSON.stringify(swatches)
|
|
745
|
+
);
|
|
746
|
+
} catch {
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Get all color swatches combined, both from swatches property and saved colors
|
|
751
|
+
* @internal
|
|
752
|
+
*/
|
|
753
|
+
get allSwatches() {
|
|
754
|
+
const predefinedColors = Array.isArray(this.swatches) ? this.swatches : [];
|
|
755
|
+
const savedColors = Array.isArray(this.savedColors) ? this.savedColors : [];
|
|
756
|
+
const seen = /* @__PURE__ */ new Set();
|
|
757
|
+
const merged = [];
|
|
758
|
+
const appendIfUniqueAndValid = (swatch) => {
|
|
759
|
+
if (!swatch || typeof swatch.value !== "string") return;
|
|
760
|
+
if (!baseColorPicker.isValidHexColor(swatch.value) || seen.has(swatch.value)) return;
|
|
761
|
+
seen.add(swatch.value);
|
|
762
|
+
merged.push(swatch);
|
|
763
|
+
};
|
|
764
|
+
if (!this.disableSavedColors) {
|
|
765
|
+
savedColors.forEach(appendIfUniqueAndValid);
|
|
766
|
+
}
|
|
767
|
+
predefinedColors.forEach(appendIfUniqueAndValid);
|
|
768
|
+
return merged.slice(0, this._maxSwatchesNormalized);
|
|
769
|
+
}
|
|
693
770
|
/**
|
|
694
771
|
* @internal
|
|
695
772
|
*/
|
|
@@ -764,24 +841,11 @@ class ColorPicker extends withContextualHelp.WithContextualHelp(
|
|
|
764
841
|
const path = e.composedPath?.();
|
|
765
842
|
return !!(path && path.includes(el));
|
|
766
843
|
}
|
|
767
|
-
#
|
|
768
|
-
/**
|
|
769
|
-
* @internal
|
|
770
|
-
*/
|
|
771
|
-
_setTemporaryCopyIcon(name, ms = 2e3) {
|
|
772
|
-
this.copyIconName = name;
|
|
773
|
-
if (this.#iconResetTimer) clearTimeout(this.#iconResetTimer);
|
|
774
|
-
this.#iconResetTimer = setTimeout(() => {
|
|
775
|
-
this.copyIconName = "copy-2-line";
|
|
776
|
-
this.#iconResetTimer = null;
|
|
777
|
-
}, ms);
|
|
778
|
-
}
|
|
844
|
+
#closeOnPointerOutside;
|
|
779
845
|
connectedCallback() {
|
|
780
846
|
super.connectedCallback();
|
|
781
|
-
this._refreshCanvasColor();
|
|
782
847
|
this.savedColors = this._loadSavedColors();
|
|
783
848
|
document.addEventListener("mousedown", this.#closeOnPointerOutside, true);
|
|
784
|
-
document.addEventListener("keydown", this.#closeOnEscape);
|
|
785
849
|
}
|
|
786
850
|
disconnectedCallback() {
|
|
787
851
|
super.disconnectedCallback();
|
|
@@ -790,74 +854,66 @@ class ColorPicker extends withContextualHelp.WithContextualHelp(
|
|
|
790
854
|
this.#closeOnPointerOutside,
|
|
791
855
|
true
|
|
792
856
|
);
|
|
793
|
-
document.removeEventListener("keydown", this.#closeOnEscape);
|
|
794
857
|
}
|
|
795
|
-
#
|
|
796
|
-
#closeOnEscape;
|
|
858
|
+
#iconResetTimer;
|
|
797
859
|
/**
|
|
798
860
|
* @internal
|
|
799
861
|
*/
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
if (
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
this.savedColors = swatches.slice(0, this._maxSwatchesNormalized);
|
|
808
|
-
this._setSavedColors(this.savedColors);
|
|
862
|
+
_setTemporaryCopyIcon(name, ms = 2e3) {
|
|
863
|
+
this.copyIconName = name;
|
|
864
|
+
if (this.#iconResetTimer) clearTimeout(this.#iconResetTimer);
|
|
865
|
+
this.#iconResetTimer = setTimeout(() => {
|
|
866
|
+
this.copyIconName = "copy-2-line";
|
|
867
|
+
this.#iconResetTimer = null;
|
|
868
|
+
}, ms);
|
|
809
869
|
}
|
|
870
|
+
// --- Trapped focus ---
|
|
810
871
|
/**
|
|
811
872
|
* @internal
|
|
812
873
|
*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
const parsed = JSON.parse(savedColors);
|
|
818
|
-
if (!Array.isArray(parsed)) return [];
|
|
819
|
-
return parsed.filter(
|
|
820
|
-
(x) => x && typeof x.value === "string" && baseColorPicker.isValidHexColor(x.value)
|
|
821
|
-
).map((x) => ({
|
|
822
|
-
value: x.value,
|
|
823
|
-
label: typeof x.label === "string" ? x.label : void 0
|
|
824
|
-
}));
|
|
825
|
-
} catch {
|
|
826
|
-
return [];
|
|
874
|
+
_onBaseKeydown(event) {
|
|
875
|
+
if (this.open && index.handleEscapeKeyAndStopPropogation(event)) {
|
|
876
|
+
this.open = false;
|
|
877
|
+
return false;
|
|
827
878
|
}
|
|
879
|
+
if (this._trappedFocus(event, () => this._focusableElsWithinDialog())) {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
return true;
|
|
828
883
|
}
|
|
829
884
|
/**
|
|
830
885
|
* @internal
|
|
831
886
|
*/
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
887
|
+
_focusableElsWithinDialog() {
|
|
888
|
+
return this._popupEl.querySelectorAll(
|
|
889
|
+
'button:not([role="gridcell"]), [data-vvd-component="button"], vwc-button:not([role="gridcell"])'
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* @internal
|
|
894
|
+
*/
|
|
895
|
+
_handleCellKeydown(event, value, index, isSaveCell) {
|
|
896
|
+
if (event.key === "Tab") {
|
|
897
|
+
event.preventDefault();
|
|
898
|
+
const focusableEls = this._focusableElsWithinDialog();
|
|
899
|
+
const idx = Array.prototype.indexOf.call(
|
|
900
|
+
focusableEls,
|
|
901
|
+
event.currentTarget
|
|
837
902
|
);
|
|
838
|
-
|
|
903
|
+
const nextIdx = event.shiftKey ? (idx - 1 + focusableEls.length) % focusableEls.length : (idx + 1) % focusableEls.length;
|
|
904
|
+
focusableEls[nextIdx]?.focus();
|
|
905
|
+
return false;
|
|
839
906
|
}
|
|
907
|
+
return super._handleCellKeydown(event, value, index, isSaveCell);
|
|
840
908
|
}
|
|
841
909
|
/**
|
|
842
|
-
* Get all color swatches combined, both from swatches property and saved colors
|
|
843
910
|
* @internal
|
|
844
911
|
*/
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
const seen = /* @__PURE__ */ new Set();
|
|
849
|
-
const merged = [];
|
|
850
|
-
const appendIfUniqueAndValid = (swatch) => {
|
|
851
|
-
if (!swatch || typeof swatch.value !== "string") return;
|
|
852
|
-
if (!baseColorPicker.isValidHexColor(swatch.value) || seen.has(swatch.value)) return;
|
|
853
|
-
seen.add(swatch.value);
|
|
854
|
-
merged.push(swatch);
|
|
855
|
-
};
|
|
856
|
-
if (!this.disableSavedColors) {
|
|
857
|
-
savedColors.forEach(appendIfUniqueAndValid);
|
|
912
|
+
_handleSwatchSelection(value) {
|
|
913
|
+
if (this.value !== value) {
|
|
914
|
+
this._ariaLiveDescription = this.locale.colorPicker.selectionSuccessMessage(value);
|
|
858
915
|
}
|
|
859
|
-
|
|
860
|
-
return merged.slice(0, this._maxSwatchesNormalized);
|
|
916
|
+
super._handleSwatchSelection(value);
|
|
861
917
|
}
|
|
862
918
|
}
|
|
863
919
|
__decorateClass([
|
|
@@ -885,6 +941,9 @@ __decorateClass([
|
|
|
885
941
|
__decorateClass([
|
|
886
942
|
fastElement.observable
|
|
887
943
|
], ColorPicker.prototype, "copyIconName");
|
|
944
|
+
__decorateClass([
|
|
945
|
+
fastElement.observable
|
|
946
|
+
], ColorPicker.prototype, "_ariaLiveDescription");
|
|
888
947
|
|
|
889
948
|
function renderTextField(textFieldTag, iconTag) {
|
|
890
949
|
const getClasses = (_) => fastWebUtilities.classNames("control");
|
|
@@ -915,6 +974,8 @@ function renderTextField(textFieldTag, iconTag) {
|
|
|
915
974
|
>
|
|
916
975
|
<button
|
|
917
976
|
aria-label="${(x) => x.locale.colorPicker.pickerButtonLabel}"
|
|
977
|
+
aria-expanded="${(x) => x.open}"
|
|
978
|
+
aria-haspopup="dialog"
|
|
918
979
|
class="button ${(x) => fastWebUtilities.classNames(
|
|
919
980
|
x._applyContrastClass(x._buttonColor) ? "contrast" : "",
|
|
920
981
|
x.disabled ? "disabled" : ""
|
|
@@ -942,9 +1003,9 @@ function renderTextField(textFieldTag, iconTag) {
|
|
|
942
1003
|
function renderPopupHeader(buttonTag, iconTag) {
|
|
943
1004
|
return fastElement.html`
|
|
944
1005
|
<div class="header">
|
|
945
|
-
<
|
|
1006
|
+
<h2 class="header-title" id="color-picker-title">
|
|
946
1007
|
<slot name="popup-text">${(x) => x.locale.colorPicker.popupLabel}</slot>
|
|
947
|
-
</
|
|
1008
|
+
</h2>
|
|
948
1009
|
<${buttonTag} size="condensed"
|
|
949
1010
|
aria-label="${(x) => x.locale.colorPicker.closeButtonLabel}"
|
|
950
1011
|
@click="${(x) => x._handleCloseRequest()}">
|
|
@@ -953,7 +1014,7 @@ function renderPopupHeader(buttonTag, iconTag) {
|
|
|
953
1014
|
</div>
|
|
954
1015
|
`;
|
|
955
1016
|
}
|
|
956
|
-
function renderPopupBody(buttonTag, iconTag) {
|
|
1017
|
+
function renderPopupBody(buttonTag, iconTag, tooltipTag) {
|
|
957
1018
|
return fastElement.html`
|
|
958
1019
|
<div class="body">
|
|
959
1020
|
<${fastElement.html.partial(vcPickerTag)}
|
|
@@ -969,24 +1030,37 @@ function renderPopupBody(buttonTag, iconTag) {
|
|
|
969
1030
|
color="${(x) => x.value}"
|
|
970
1031
|
@color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
|
|
971
1032
|
${fastElement.ref("_vcHexInputEl")}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
</${
|
|
1033
|
+
>
|
|
1034
|
+
<input name="hex-code-input" aria-label="${(x) => x.locale.colorPicker.hexInputLabel}"
|
|
1035
|
+
placeholder="${(x) => x.placeholder}"
|
|
1036
|
+
@blur="${(x, c) => c.event.stopImmediatePropagation()}"
|
|
1037
|
+
part="input">
|
|
1038
|
+
</${fastElement.html.partial(vcInputTag)}>
|
|
1039
|
+
<${tooltipTag} placement="top"
|
|
1040
|
+
text="${(x) => x.locale.colorPicker.copyButtonLabel}"
|
|
1041
|
+
exportparts="vvd-theme-alternate">
|
|
1042
|
+
<${buttonTag}
|
|
1043
|
+
slot="anchor" size="normal"
|
|
1044
|
+
aria-label="${(x) => x.locale.colorPicker.copyButtonLabel}"
|
|
1045
|
+
@click="${(x) => x._copyValueToClipboard(x.value)}">
|
|
1046
|
+
<${iconTag} slot="icon" name="${(x) => x.copyIconName}"></${iconTag}>
|
|
1047
|
+
</${buttonTag}>
|
|
1048
|
+
</${tooltipTag}>
|
|
978
1049
|
</div>
|
|
979
1050
|
</div>
|
|
980
1051
|
`;
|
|
981
1052
|
}
|
|
982
|
-
function renderPopupFooter(buttonTag, iconTag) {
|
|
1053
|
+
function renderPopupFooter(buttonTag, iconTag, tooltipTag) {
|
|
983
1054
|
return fastElement.html`
|
|
984
1055
|
<div class="footer">
|
|
985
|
-
<
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1056
|
+
<div class="footer-header">
|
|
1057
|
+
<span class="footer-title" id="color-picker-footer-title"
|
|
1058
|
+
><slot name="swatches-text"
|
|
1059
|
+
>${(x) => x.locale.colorPicker.swatchesLabel}</slot
|
|
1060
|
+
></span
|
|
1061
|
+
>
|
|
1062
|
+
${fastElement.when((x) => !x.disableSavedColors, renderSwatchesCount())}
|
|
1063
|
+
</div>
|
|
990
1064
|
<div
|
|
991
1065
|
class="palette"
|
|
992
1066
|
role="grid"
|
|
@@ -997,41 +1071,62 @@ function renderPopupFooter(buttonTag, iconTag) {
|
|
|
997
1071
|
>
|
|
998
1072
|
${fastElement.repeat(
|
|
999
1073
|
(x) => x.allSwatches,
|
|
1000
|
-
(x) => x._renderColorSwatch(iconTag),
|
|
1074
|
+
(x) => x._renderColorSwatch(iconTag, tooltipTag),
|
|
1001
1075
|
{ positioning: true }
|
|
1002
1076
|
)}
|
|
1003
1077
|
${fastElement.when(
|
|
1004
1078
|
(x) => !x.disableSavedColors,
|
|
1005
1079
|
fastElement.html`
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1080
|
+
<${tooltipTag} placement="top"
|
|
1081
|
+
text="${(x) => x.locale.colorPicker.saveButtonLabel}"
|
|
1082
|
+
exportparts="vvd-theme-alternate">
|
|
1083
|
+
<${buttonTag}
|
|
1084
|
+
slot="anchor"
|
|
1085
|
+
appearance="outlined"
|
|
1086
|
+
size="super-condensed"
|
|
1087
|
+
role="gridcell"
|
|
1088
|
+
tabindex="${(x) => x.allSwatches.length ? "-1" : "0"}"
|
|
1089
|
+
aria-label="${(x) => x.locale.colorPicker.saveButtonLabel}"
|
|
1090
|
+
@click="${(x) => x._saveCurrentColor()}"
|
|
1091
|
+
@keydown="${(x, c) => x._handleCellKeydown(
|
|
1014
1092
|
c.event,
|
|
1015
1093
|
x.value,
|
|
1016
1094
|
x.allSwatches.length,
|
|
1017
1095
|
true
|
|
1018
1096
|
)}">
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1097
|
+
<${iconTag} slot="icon" name="plus-line"></${iconTag}>
|
|
1098
|
+
</${buttonTag}>
|
|
1099
|
+
</${tooltipTag}>
|
|
1100
|
+
`
|
|
1023
1101
|
)}
|
|
1024
1102
|
</div>
|
|
1025
1103
|
</div>
|
|
1026
1104
|
`;
|
|
1027
1105
|
}
|
|
1106
|
+
function renderSwatchesCount() {
|
|
1107
|
+
return fastElement.html`
|
|
1108
|
+
<span
|
|
1109
|
+
id="swatches-count"
|
|
1110
|
+
class="swatches-count"
|
|
1111
|
+
aria-label="${(x) => x.locale.colorPicker.maxSwatchesMessage(
|
|
1112
|
+
x.allSwatches.length,
|
|
1113
|
+
x.maxSwatches
|
|
1114
|
+
)}"
|
|
1115
|
+
>${(x) => `${x.allSwatches.length}/${x.maxSwatches}`}</span
|
|
1116
|
+
>
|
|
1117
|
+
`;
|
|
1118
|
+
}
|
|
1028
1119
|
const ColorPickerTemplate = (context) => {
|
|
1029
1120
|
const textFieldTag = context.tagFor(textField_definition.VwcTextFieldElement);
|
|
1030
1121
|
const iconTag = context.tagFor(icon_definition.VwcIconElement);
|
|
1031
1122
|
const popupTag = context.tagFor(popup_definition.Popup);
|
|
1032
1123
|
const buttonTag = context.tagFor(button_definition.Button);
|
|
1124
|
+
const tooltipTag = context.tagFor(tooltip_definition.VwcTooltipElement);
|
|
1033
1125
|
return fastElement.html`
|
|
1034
|
-
<div class="base">
|
|
1126
|
+
<div class="base" @keydown="${(x, { event }) => x._onBaseKeydown(event)}">
|
|
1127
|
+
<span aria-live="assertive" aria-relevant="text" class="visually-hidden">
|
|
1128
|
+
${(x) => x._ariaLiveDescription}
|
|
1129
|
+
</span>
|
|
1035
1130
|
${renderTextField(textFieldTag, iconTag)}
|
|
1036
1131
|
<${popupTag}
|
|
1037
1132
|
:open="${(x) => x.open}"
|
|
@@ -1044,10 +1139,10 @@ const ColorPickerTemplate = (context) => {
|
|
|
1044
1139
|
aria-modal="true"
|
|
1045
1140
|
aria-labelledby="color-picker-title">
|
|
1046
1141
|
${renderPopupHeader(buttonTag, iconTag)}
|
|
1047
|
-
${renderPopupBody(buttonTag, iconTag)}
|
|
1142
|
+
${renderPopupBody(buttonTag, iconTag, tooltipTag)}
|
|
1048
1143
|
${fastElement.when(
|
|
1049
1144
|
(x) => !x.disableSavedColors || x.allSwatches.length > 0,
|
|
1050
|
-
renderPopupFooter(buttonTag, iconTag)
|
|
1145
|
+
renderPopupFooter(buttonTag, iconTag, tooltipTag)
|
|
1051
1146
|
)}
|
|
1052
1147
|
</div>
|
|
1053
1148
|
</${popupTag}>
|
|
@@ -1064,6 +1159,7 @@ const colorPickerDefinition = vividElement.defineVividComponent(
|
|
|
1064
1159
|
icon_definition.iconDefinition,
|
|
1065
1160
|
textField_definition.textFieldDefinition,
|
|
1066
1161
|
button_definition.buttonDefinition,
|
|
1162
|
+
tooltip_definition.tooltipDefinition,
|
|
1067
1163
|
mixins.feedbackMessageDefinition
|
|
1068
1164
|
],
|
|
1069
1165
|
{
|