@vonage/vivid 5.16.0 → 5.17.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/index.cjs +1 -1
- package/accordion/index.js +1 -1
- package/accordion-item/index.cjs +1 -1
- package/accordion-item/index.js +1 -1
- package/action-group/index.cjs +3 -3
- package/action-group/index.js +5 -5
- package/alert/index.cjs +3 -3
- package/alert/index.js +17 -17
- package/audio-player/index.cjs +16 -16
- package/audio-player/index.js +27 -27
- package/avatar/index.cjs +2 -2
- package/avatar/index.js +6 -6
- package/badge/index.cjs +2 -2
- package/badge/index.js +6 -6
- package/banner/index.cjs +3 -3
- package/banner/index.js +15 -15
- package/bundled/base-color-picker.cjs +2 -2
- package/bundled/base-color-picker.js +5 -5
- package/bundled/button.cjs +1 -1
- package/bundled/button.js +2 -2
- package/bundled/calendar-picker.template.cjs +2 -2
- package/bundled/calendar-picker.template.js +498 -498
- package/bundled/definition10.cjs +18 -30
- package/bundled/definition10.js +53 -155
- package/bundled/definition11.cjs +10 -19
- package/bundled/definition11.js +25 -74
- package/bundled/definition12.cjs +72 -18
- package/bundled/definition12.js +171 -107
- package/bundled/definition13.cjs +18 -17
- package/bundled/definition13.js +45 -65
- package/bundled/definition14.cjs +5 -10
- package/bundled/definition14.js +9 -27
- package/bundled/definition15.cjs +17 -71
- package/bundled/definition15.js +64 -181
- package/bundled/definition16.cjs +12 -4
- package/bundled/definition16.js +79 -14
- package/bundled/definition17.cjs +19 -13
- package/bundled/definition17.js +119 -70
- package/bundled/definition18.cjs +87 -12
- package/bundled/definition18.js +409 -52
- package/bundled/definition19.cjs +5 -87
- package/bundled/definition19.js +14 -422
- package/bundled/definition2.cjs +3 -3
- package/bundled/definition2.js +27 -27
- package/bundled/definition20.cjs +30 -5
- package/bundled/definition20.js +159 -9
- package/bundled/definition21.cjs +28 -19
- package/bundled/definition21.js +164 -47
- package/bundled/definition22.cjs +38 -23
- package/bundled/definition22.js +64 -82
- package/bundled/definition3.cjs +1 -1
- package/bundled/definition3.js +15 -15
- package/bundled/definition4.cjs +23 -38
- package/bundled/definition4.js +82 -64
- package/bundled/definition5.cjs +2 -2
- package/bundled/definition5.js +5 -5
- package/bundled/definition6.cjs +2 -2
- package/bundled/definition6.js +24 -24
- package/bundled/definition9.cjs +12 -30
- package/bundled/definition9.js +55 -148
- package/bundled/divider.cjs +1 -1
- package/bundled/divider.js +5 -5
- package/bundled/listbox.cjs +1 -1
- package/bundled/listbox.js +1 -1
- package/bundled/mixins.cjs +4 -4
- package/bundled/mixins.js +43 -43
- package/bundled/picker-field.template.cjs +7 -7
- package/bundled/picker-field.template.js +14 -14
- package/bundled/slider.template.cjs +7 -7
- package/bundled/slider.template.js +12 -12
- package/bundled/slottable-request.cjs +1 -1
- package/bundled/slottable-request.js +8 -38
- package/bundled/time-selection-picker.template.cjs +4 -4
- package/bundled/time-selection-picker.template.js +35 -35
- package/bundled/vivid-element.cjs +1 -1
- package/bundled/vivid-element.js +1 -1
- package/calendar/index.cjs +11 -11
- package/calendar/index.js +30 -237
- package/calendar-event/index.cjs +3 -3
- package/calendar-event/index.js +4 -4
- package/card/index.cjs +14 -11
- package/card/index.js +16 -13
- package/checkbox/index.cjs +1 -1
- package/checkbox/index.js +1 -1
- package/color-picker/definition.cjs +1 -1
- package/color-picker/definition.js +1 -1
- package/color-picker/index.cjs +6 -6
- package/color-picker/index.js +24 -24
- package/combobox/definition.cjs +1 -1
- package/combobox/definition.js +1 -1
- package/combobox/index.cjs +9 -8
- package/combobox/index.js +32 -28
- package/contextual-help/definition.cjs +1 -1
- package/contextual-help/definition.js +1 -1
- package/contextual-help/index.cjs +1 -1
- package/contextual-help/index.js +1 -1
- package/custom-elements.json +1027 -615
- package/data-grid/definition.js +1 -1
- package/data-grid/index.cjs +17 -17
- package/data-grid/index.js +261 -264
- package/date-picker/index.cjs +1 -1
- package/date-picker/index.js +12 -12
- package/date-range-picker/index.cjs +1 -1
- package/date-range-picker/index.js +7 -7
- package/date-time-picker/index.cjs +4 -4
- package/date-time-picker/index.js +24 -24
- package/dial-pad/index.cjs +3 -2
- package/dial-pad/index.js +6 -5
- package/dialog/index.cjs +4 -4
- package/dialog/index.js +5 -5
- package/divider/index.cjs +1 -1
- package/divider/index.js +1 -1
- package/fab/index.cjs +3 -3
- package/fab/index.js +8 -8
- package/file-picker/index.cjs +16 -13
- package/file-picker/index.js +31 -28
- package/header/index.cjs +4 -4
- package/header/index.js +5 -5
- package/index.cjs +24 -21
- package/index.js +11 -11
- package/lib/combobox/combobox.d.ts +0 -3
- package/lib/date-time-picker/date-time-picker.d.ts +0 -4
- package/lib/dial-pad/dial-pad.d.ts +6 -2
- package/lib/dialog/dialog.d.ts +0 -1
- package/lib/menu/menu.d.ts +0 -1
- package/lib/option/option.d.ts +0 -1
- package/lib/rich-text-editor/rte/exports.d.ts +1 -0
- package/lib/rich-text-editor/rte/features/alignment.d.ts +1 -1
- package/lib/rich-text-editor/rte/features/character-count.d.ts +21 -0
- package/lib/rich-text-editor/rte/features/font-size-picker.d.ts +1 -1
- package/lib/rich-text-editor/rte/features/internal/basic-text-blocks.d.ts +1 -1
- package/lib/rich-text-editor/rte/features/keyboard-shortcuts.d.ts +1 -1
- package/lib/rich-text-editor/rte/features/text-color-picker.d.ts +1 -1
- package/lib/rich-text-editor/rte/public-interface.d.ts +6 -0
- package/lib/searchable-select/option-tag.d.ts +0 -1
- package/lib/table/definition.d.ts +2 -1
- package/lib/table/table-header-cell.d.ts +3 -0
- package/lib/table/table-sorting-button.d.ts +415 -0
- package/lib/table/table-sorting-button.template.d.ts +3 -0
- package/locales/de-DE.cjs +4 -178
- package/locales/de-DE.js +2 -179
- package/locales/en-GB.cjs +4 -9
- package/locales/en-GB.js +2 -10
- package/locales/en-US.cjs +268 -2
- package/locales/en-US.js +265 -1
- package/locales/ja-JP.cjs +4 -171
- package/locales/ja-JP.js +2 -172
- package/locales/zh-CN.cjs +4 -172
- package/locales/zh-CN.js +2 -173
- package/menu/index.cjs +1 -1
- package/menu/index.js +1 -1
- package/menu-item/index.cjs +1 -1
- package/menu-item/index.js +1 -1
- package/nav-disclosure/index.cjs +3 -3
- package/nav-disclosure/index.js +8 -8
- package/nav-item/index.cjs +1 -1
- package/nav-item/index.js +7 -7
- package/note/index.cjs +2 -2
- package/note/index.js +6 -6
- package/number-field/index.cjs +4 -4
- package/number-field/index.js +31 -31
- package/option/definition.cjs +1 -1
- package/option/definition.js +1 -1
- package/option/index.cjs +1 -1
- package/option/index.js +1 -1
- package/package.json +7 -8
- package/pagination/index.cjs +3 -3
- package/pagination/index.js +15 -15
- package/popover/index.cjs +4 -4
- package/popover/index.js +5 -5
- package/progress/index.cjs +2 -2
- package/progress/index.js +5 -5
- package/radio/index.cjs +1 -1
- package/radio/index.js +1 -1
- package/radio-group/index.cjs +4 -4
- package/radio-group/index.js +10 -10
- package/range-slider/index.cjs +4 -4
- package/range-slider/index.js +17 -17
- package/rich-text-editor/definition.cjs +1 -0
- package/rich-text-editor/definition.js +2 -2
- package/rich-text-editor/index.cjs +13 -13
- package/rich-text-editor/index.js +1886 -1829
- package/rich-text-view/index.cjs +1 -1
- package/rich-text-view/index.js +8 -8
- package/searchable-select/index.cjs +12 -12
- package/searchable-select/index.js +25 -25
- package/select/index.cjs +1 -1
- package/select/index.js +1 -1
- package/selectable-box/index.cjs +7 -7
- package/selectable-box/index.js +11 -11
- package/shared/foundation/test-utilities/fixture.d.ts +1 -1
- package/shared/patterns/linkable.d.ts +1 -1
- package/simple-color-picker/index.cjs +3 -3
- package/simple-color-picker/index.js +10 -10
- package/split-button/index.cjs +5 -5
- package/split-button/index.js +10 -10
- package/status/index.cjs +2 -2
- package/status/index.js +12 -12
- package/switch/index.cjs +3 -3
- package/switch/index.js +5 -5
- package/tab/index.cjs +1 -1
- package/tab/index.js +1 -1
- package/tab-panel/index.cjs +1 -1
- package/tab-panel/index.js +1 -1
- package/table/definition.cjs +17 -14
- package/table/definition.js +3 -2
- package/table/index.cjs +19 -10
- package/table/index.js +69 -21
- package/tabs/index.cjs +2 -2
- package/tabs/index.js +4 -4
- package/tag/index.cjs +7 -7
- package/tag/index.js +9 -9
- package/tag-group/index.cjs +3 -3
- package/tag-group/index.js +5 -5
- package/text-area/index.cjs +2 -2
- package/text-area/index.js +12 -12
- package/text-field/definition.cjs +1 -1
- package/text-field/definition.js +1 -1
- package/text-field/index.cjs +1 -1
- package/text-field/index.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 +1 -1
- package/tooltip/definition.js +1 -1
- package/tooltip/index.cjs +1 -1
- package/tooltip/index.js +1 -1
- package/tree-item/index.cjs +1 -1
- package/tree-item/index.js +1 -1
- package/tree-view/index.cjs +3 -3
- package/tree-view/index.js +17 -17
- package/unbundled/button.cjs +2 -2
- package/unbundled/button.js +2 -2
- package/unbundled/calendar-picker.template.cjs +4347 -9
- package/unbundled/calendar-picker.template.js +4345 -7
- package/unbundled/chunk.cjs +0 -22
- package/unbundled/definition13.cjs +1 -8
- package/unbundled/definition13.js +1 -8
- package/unbundled/definition14.cjs +2 -2
- package/unbundled/definition14.js +2 -2
- package/unbundled/definition2.cjs +1 -1
- package/unbundled/definition2.js +1 -1
- package/unbundled/definition21.cjs +1 -2
- package/unbundled/definition21.js +1 -2
- package/unbundled/definition22.cjs +7 -2
- package/unbundled/definition22.js +7 -2
- package/unbundled/definition24.cjs +98 -979
- package/unbundled/definition24.js +93 -974
- package/unbundled/definition25.cjs +37 -322
- package/unbundled/definition25.js +33 -318
- package/unbundled/definition26.cjs +317 -91
- package/unbundled/definition26.js +313 -87
- package/unbundled/definition27.cjs +94 -192
- package/unbundled/definition27.js +91 -183
- package/unbundled/definition28.cjs +387 -395
- package/unbundled/definition28.js +387 -395
- package/unbundled/definition29.cjs +189 -110
- package/unbundled/definition29.js +180 -107
- package/unbundled/definition30.cjs +520 -36
- package/unbundled/definition30.js +519 -35
- package/unbundled/definition32.cjs +477 -477
- package/unbundled/definition32.js +475 -475
- package/unbundled/definition33.cjs +87 -2
- package/unbundled/definition33.js +77 -4
- package/unbundled/definition35.cjs +2 -2
- package/unbundled/definition35.js +2 -2
- package/unbundled/definition36.cjs +1 -1
- package/unbundled/definition36.js +1 -1
- package/unbundled/definition37.cjs +6 -2
- package/unbundled/definition37.js +6 -2
- package/unbundled/definition38.cjs +7 -5
- package/unbundled/definition38.js +7 -5
- package/unbundled/definition39.cjs +1 -0
- package/unbundled/definition39.js +1 -0
- package/unbundled/definition42.cjs +22 -11
- package/unbundled/definition42.js +22 -11
- package/unbundled/definition49.cjs +3 -3
- package/unbundled/definition49.js +3 -3
- package/unbundled/definition56.cjs +437 -9506
- package/unbundled/definition56.js +340 -9415
- package/unbundled/definition57.cjs +5 -5
- package/unbundled/definition57.js +5 -5
- package/unbundled/definition58.cjs +4 -3
- package/unbundled/definition58.js +2 -1
- package/unbundled/definition59.cjs +4 -3
- package/unbundled/definition59.js +4 -3
- package/unbundled/definition62.cjs +2 -2
- package/unbundled/definition62.js +2 -2
- package/unbundled/definition64.cjs +1 -1
- package/unbundled/definition64.js +1 -1
- package/unbundled/definition71.cjs +2 -2
- package/unbundled/definition71.js +2 -2
- package/unbundled/definition72.cjs +1 -2
- package/unbundled/definition72.js +1 -2
- package/unbundled/definition75.cjs +3 -51711
- package/unbundled/definition75.js +1 -51711
- package/unbundled/listbox.cjs +1 -1
- package/unbundled/listbox.js +1 -1
- package/unbundled/localized.cjs +2 -2
- package/unbundled/localized.js +1 -1
- package/unbundled/picker-field.template.cjs +1 -1
- package/unbundled/picker-field.template.js +1 -1
- package/unbundled/slottable-request.cjs +2 -3168
- package/unbundled/slottable-request.js +3 -3097
- package/unbundled/time-selection-picker.template.cjs +1 -1
- package/unbundled/time-selection-picker.template.js +1 -1
- package/unbundled/vivid-element.cjs +1 -1
- package/unbundled/vivid-element.js +1 -1
- package/video-player/index.cjs +3 -3
- package/video-player/index.js +9 -9
- package/vivid.api.json +220 -282
- package/unbundled/chunk.js +0 -33
- package/unbundled/en-US.cjs +0 -447
- package/unbundled/en-US.js +0 -443
|
@@ -1,528 +1,520 @@
|
|
|
1
|
-
import { o as defineVividComponent, s as createRegisterFunction } from "./vivid-element.js";
|
|
2
|
-
import { t as iconDefinition } from "./definition2.js";
|
|
1
|
+
import { o as defineVividComponent, s as createRegisterFunction, t as VividElement } from "./vivid-element.js";
|
|
2
|
+
import { r as Icon, t as iconDefinition } from "./definition2.js";
|
|
3
3
|
import { t as __decorate } from "./decorate.js";
|
|
4
|
-
import {
|
|
5
|
-
import { n as FormAssociated } from "./form-associated.js";
|
|
6
|
-
import { t as FormElement } from "./form-element.js";
|
|
4
|
+
import { n as delegateAria, t as DelegatesAria } from "./delegates-aria.js";
|
|
7
5
|
import { t as WithSuccessText } from "./with-success-text.js";
|
|
8
6
|
import { t as WithErrorText } from "./with-error-text.js";
|
|
9
7
|
import { t as WithContextualHelp } from "./with-contextual-help.js";
|
|
10
|
-
import {
|
|
8
|
+
import { t as TrappedFocus } from "./trapped-focus.js";
|
|
9
|
+
import { i as Button, t as buttonDefinition } from "./definition7.js";
|
|
11
10
|
import { t as handleEscapeKeyAndStopPropogation } from "./dialog.js";
|
|
12
11
|
import { i as Popup, t as popupDefinition } from "./definition10.js";
|
|
13
12
|
import { a as feedbackMessageDefinition, t as WithFeedback } from "./mixins.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { t as
|
|
17
|
-
import {
|
|
18
|
-
import { classNames
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
import { n as textFieldDefinition, r as TextField } from "./definition26.js";
|
|
14
|
+
import { n as tooltipDefinition, r as Tooltip } from "./definition27.js";
|
|
15
|
+
import { n as isValidHexColor, t as BaseColorPicker } from "./base-color-picker.js";
|
|
16
|
+
import { attr, html, nullableNumberConverter, observable, ref, repeat, slotted, when } from "@microsoft/fast-element";
|
|
17
|
+
import { classNames } from "@microsoft/fast-web-utilities";
|
|
18
|
+
import { HexColorPicker } from "vanilla-colorful/hex-color-picker.js";
|
|
19
|
+
import { HexInput } from "vanilla-colorful/hex-input.js";
|
|
20
|
+
//#region src/lib/color-picker/color-picker.scss?inline
|
|
21
|
+
var color_picker_default = ".palette{grid-template-columns:repeat(var(--swatches-per-row,7), var(--_color-swatch-size,24px));display:grid}.swatch{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);border-radius:4px;padding:0;position:relative}.swatch:not(.contrast){border:none}.swatch.contrast{border:1px solid var(--vvd-color-neutral-400);color:var(--vvd-color-canvas-text)}.swatch:focus-visible{box-shadow:0 0 0 4px color-mix(in srgb, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:none;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{--_low-ink-color:var(--vvd-color-neutral-600);display:inline-block}.base{min-inline-size:var(--_color-picker-min-inline-size,280px);display:inline-block}.control{inline-size:100%}.button{box-sizing:border-box;background-color:var(--button-color,var(--vvd-color-canvas-text));block-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8));color:var(--vvd-color-canvas);inline-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8));padding-inline:calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8)) / 4);vertical-align:middle;border:0;border-radius:4px;align-items:center;margin:0;text-decoration:none;display:inline-flex}.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(--focus-stroke-color,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(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8)) / 2);line-height:1}.dialog{min-inline-size:var(--_color-picker-popup-min-inline-size,264px);flex-direction:column;display:flex}.dialog .header{justify-content:space-between;align-items:center;padding-block:8px;padding-inline:16px;display:inline-flex}.dialog .header-title{font:var(--vvd-typography-base-extended-bold);margin-block:0}.dialog .body{flex-direction:column;gap:16px;margin-block-end:16px;padding-inline:16px;display:flex}.dialog .hex-input-wrapper{align-items:stretch;gap:8px;display:flex}.dialog .hex-input-wrapper [data-vvd-component=button]{flex:none}.dialog .footer{border-top:1px solid var(--vvd-color-neutral-200);padding:16px}.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{flex:auto;min-width:0}vvd-hex-input::part(input),vvd-hex-input>input{box-sizing:border-box;background-color:var(--vvd-color-canvas);width:100%;height:100%;box-shadow:inset 0 0 0 1px var(--vvd-color-neutral-500);font:var(--vvd-typography-base);padding-inline:calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2))) / 2.5);border:0;border-radius:8px;outline:#0000}vvd-hex-input::part(input):focus-visible,vvd-hex-input>input:focus-visible{box-shadow:0 0 0 4px color-mix(in srgb, var(--focus-stroke-color,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){border-radius:8px;flex:0 0 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{clip:rect(0 0 0 0);border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}";
|
|
21
22
|
//#endregion
|
|
22
|
-
//#region src/lib/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
list: "list",
|
|
30
|
-
both: "both",
|
|
31
|
-
none: "none"
|
|
23
|
+
//#region src/lib/color-picker/color-picker.ts
|
|
24
|
+
var VC_HEX_PICKER_TAG = "vvd-hex-picker";
|
|
25
|
+
var VC_HEX_INPUT_TAG = "vvd-hex-input";
|
|
26
|
+
var VvdHexPicker = class extends HexColorPicker {
|
|
27
|
+
static {
|
|
28
|
+
this.displayName = "VvdHexPicker";
|
|
29
|
+
}
|
|
32
30
|
};
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
var VvdHexInput = class extends HexInput {
|
|
32
|
+
static {
|
|
33
|
+
this.displayName = "VvdHexInput";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/* v8 ignore if -- @preserve */
|
|
37
|
+
if (!customElements.get(VC_HEX_PICKER_TAG)) customElements.define(VC_HEX_PICKER_TAG, VvdHexPicker);
|
|
38
|
+
/* v8 ignore if -- @preserve */
|
|
39
|
+
if (!customElements.get(VC_HEX_INPUT_TAG)) customElements.define(VC_HEX_INPUT_TAG, VvdHexInput);
|
|
40
|
+
var vcPickerTag = VC_HEX_PICKER_TAG;
|
|
41
|
+
var vcInputTag = VC_HEX_INPUT_TAG;
|
|
35
42
|
/**
|
|
36
43
|
* @public
|
|
37
|
-
* @component
|
|
38
|
-
* @slot -
|
|
39
|
-
* @slot
|
|
40
|
-
* @slot
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
43
|
-
* @vueModel modelValue value change `event.currentTarget.value`
|
|
44
|
-
* @testAction fill comboboxFill
|
|
45
|
-
* @testAction clear comboboxClear
|
|
46
|
-
* @testAction selectOptionByText selectOptionByText
|
|
47
|
-
* @testAction selectOptionByValue selectOptionByValue
|
|
48
|
-
* @testRef control shadow input.control
|
|
44
|
+
* @component color-picker
|
|
45
|
+
* @slot helper-text - Describes how to use the text-field. Alternative to the `helper-text` attribute.
|
|
46
|
+
* @slot popup-text - Overrides the default "Color Picker" title of the Popup window.
|
|
47
|
+
* @slot swatches-text - Overrides the default "Saved colors:" text above color swatches.
|
|
48
|
+
* @event {CustomEvent<undefined>} change - Fires when the value changes
|
|
49
|
+
* @vueModel modelValue value input,@lazy:change `event.currentTarget.value`
|
|
49
50
|
*/
|
|
50
|
-
var
|
|
51
|
+
var ColorPicker = class extends WithContextualHelp(WithFeedback(WithErrorText(WithSuccessText(DelegatesAria(TrappedFocus(BaseColorPicker(VividElement))))))) {
|
|
51
52
|
constructor(..._args) {
|
|
52
53
|
super(..._args);
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
this.disableSavedColors = false;
|
|
55
|
+
this.savedColors = [];
|
|
56
|
+
this.maxSwatches = 6;
|
|
57
|
+
this.copyIconName = "copy-2-line";
|
|
58
|
+
this._copyValueToClipboard = async (value) => {
|
|
59
|
+
try {
|
|
60
|
+
await navigator.clipboard.writeText(value);
|
|
61
|
+
this._setTemporaryCopyIcon("check-circle-line");
|
|
62
|
+
this._ariaLiveDescription = this.locale.colorPicker.copySuccessMessage(value);
|
|
63
|
+
} catch {
|
|
64
|
+
alert(this.locale.colorPicker.copyErrorText);
|
|
65
|
+
this._setTemporaryCopyIcon("error-line");
|
|
66
|
+
this._ariaLiveDescription = this.locale.colorPicker.copyErrorText;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
this._ariaLiveDescription = "";
|
|
70
|
+
}
|
|
71
|
+
static {
|
|
72
|
+
this.HEX_COLOR_PATTERN = /^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$/;
|
|
60
73
|
}
|
|
61
74
|
/**
|
|
62
75
|
* @internal
|
|
63
76
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.
|
|
67
|
-
this.value = this.firstSelectedOption?.text || "";
|
|
68
|
-
}
|
|
69
|
-
/** {@inheritDoc (FormAssociated:interface).validate} */
|
|
70
|
-
validate() {
|
|
71
|
-
super.validate(this.control);
|
|
72
|
-
}
|
|
73
|
-
get isAutocompleteInline() {
|
|
74
|
-
return this.autocomplete === ComboboxAutocomplete.inline || this.isAutocompleteBoth;
|
|
75
|
-
}
|
|
76
|
-
get isAutocompleteList() {
|
|
77
|
-
return this.autocomplete === ComboboxAutocomplete.list || this.isAutocompleteBoth;
|
|
77
|
+
placeholderChanged() {
|
|
78
|
+
/* v8 ignore if -- @preserve */
|
|
79
|
+
if (this.proxy instanceof HTMLInputElement) this.proxy.placeholder = this.placeholder;
|
|
78
80
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Change event handler for inner control.
|
|
83
|
+
* @remarks
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
handleChange() {
|
|
87
|
+
this.$emit("change");
|
|
81
88
|
}
|
|
82
89
|
/**
|
|
83
90
|
* @internal
|
|
84
91
|
*/
|
|
85
|
-
openChanged() {
|
|
86
|
-
if (this.
|
|
92
|
+
openChanged(_oldValue, newValue) {
|
|
93
|
+
if (newValue && this.isConnected) requestAnimationFrame(() => {
|
|
94
|
+
this._refreshCanvasColor();
|
|
95
|
+
});
|
|
87
96
|
}
|
|
88
97
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @public
|
|
92
|
-
* @remarks
|
|
93
|
-
* Overrides `Listbox.options`.
|
|
98
|
+
* @internal
|
|
94
99
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return this.filteredOptions.length ? this.filteredOptions : this._options;
|
|
100
|
+
savedColorsKeyChanged() {
|
|
101
|
+
this.savedColors = this._loadSavedColors();
|
|
98
102
|
}
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
get _savedColorsStorageKey() {
|
|
107
|
+
if (this.savedColorsKey) return this.savedColorsKey;
|
|
108
|
+
return `vvd-saved-colors:${this.tagName.toLowerCase()}`;
|
|
101
109
|
}
|
|
102
110
|
/**
|
|
103
|
-
* Updates the placeholder on the proxy element.
|
|
104
111
|
* @internal
|
|
105
112
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (this.proxy instanceof HTMLInputElement) this.proxy.placeholder = this.placeholder;
|
|
113
|
+
_handleColorSaving() {
|
|
114
|
+
this._saveCurrentColor();
|
|
109
115
|
}
|
|
110
116
|
/**
|
|
111
117
|
* @internal
|
|
112
118
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
_saveCurrentColor() {
|
|
120
|
+
const value = this.value;
|
|
121
|
+
if (typeof value !== "string" || !isValidHexColor(value)) return;
|
|
122
|
+
const swatches = Array.isArray(this.savedColors) ? [...this.savedColors] : [];
|
|
123
|
+
const idx = swatches.findIndex((s) => s?.value === value);
|
|
124
|
+
if (idx !== -1) swatches.splice(idx, 1);
|
|
125
|
+
swatches.unshift({ value });
|
|
126
|
+
this.savedColors = swatches.slice(0, this._maxSwatchesNormalized);
|
|
127
|
+
this._setSavedColors(this.savedColors);
|
|
119
128
|
}
|
|
120
129
|
/**
|
|
121
|
-
* Handle opening and closing the listbox when the combobox is clicked.
|
|
122
|
-
*
|
|
123
|
-
* @param e - the mouse event
|
|
124
130
|
* @internal
|
|
125
131
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
_loadSavedColors() {
|
|
133
|
+
try {
|
|
134
|
+
const savedColors = localStorage.getItem(this._savedColorsStorageKey);
|
|
135
|
+
if (!savedColors) return [];
|
|
136
|
+
const parsed = JSON.parse(savedColors);
|
|
137
|
+
if (!Array.isArray(parsed)) return [];
|
|
138
|
+
return parsed.filter((x) => x && typeof x.value === "string" && isValidHexColor(x.value)).map((x) => ({
|
|
139
|
+
value: x.value,
|
|
140
|
+
label: typeof x.label === "string" ? x.label : void 0
|
|
141
|
+
}));
|
|
142
|
+
} catch {
|
|
143
|
+
return [];
|
|
135
144
|
}
|
|
136
|
-
this.open = !this.open;
|
|
137
|
-
if (this.open) this.control.focus();
|
|
138
|
-
return true;
|
|
139
145
|
}
|
|
140
146
|
/**
|
|
141
|
-
* Handle closing the listbox when the combobox is open and the chevron icon is clicked.
|
|
142
|
-
*
|
|
143
|
-
* @param e - the mouse event
|
|
144
147
|
* @internal
|
|
145
148
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
_setSavedColors(swatches) {
|
|
150
|
+
try {
|
|
151
|
+
localStorage.setItem(this._savedColorsStorageKey, JSON.stringify(swatches));
|
|
152
|
+
} catch {}
|
|
150
153
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Get all color swatches combined, both from swatches property and saved colors
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
get allSwatches() {
|
|
159
|
+
const predefinedColors = Array.isArray(this.swatches) ? this.swatches : [];
|
|
160
|
+
const savedColors = Array.isArray(this.savedColors) ? this.savedColors : [];
|
|
161
|
+
const seen = /* @__PURE__ */ new Set();
|
|
162
|
+
const merged = [];
|
|
163
|
+
const appendIfUniqueAndValid = (swatch) => {
|
|
164
|
+
if (!swatch || typeof swatch.value !== "string") return;
|
|
165
|
+
if (!isValidHexColor(swatch.value) || seen.has(swatch.value)) return;
|
|
166
|
+
seen.add(swatch.value);
|
|
167
|
+
merged.push(swatch);
|
|
168
|
+
};
|
|
169
|
+
if (!this.disableSavedColors) savedColors.forEach(appendIfUniqueAndValid);
|
|
170
|
+
predefinedColors.forEach(appendIfUniqueAndValid);
|
|
171
|
+
return merged.slice(0, this._maxSwatchesNormalized);
|
|
155
172
|
}
|
|
156
173
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* @public
|
|
174
|
+
* @internal
|
|
160
175
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.filteredOptions = this._options.filter((o) => o.text.toLowerCase().startsWith(this.filter.toLowerCase()));
|
|
164
|
-
if (this.isAutocompleteList) this._options.forEach((o) => {
|
|
165
|
-
o.hidden = !this.filteredOptions.includes(o);
|
|
166
|
-
});
|
|
176
|
+
get _maxSwatchesNormalized() {
|
|
177
|
+
return Number.isFinite(this.maxSwatches) ? Math.max(0, Math.floor(this.maxSwatches)) : 0;
|
|
167
178
|
}
|
|
168
179
|
/**
|
|
169
|
-
* Focus the control and scroll the first selected option into view.
|
|
170
|
-
*
|
|
171
180
|
* @internal
|
|
172
|
-
* @remarks
|
|
173
|
-
* Overrides: `Listbox.focusAndScrollOptionIntoView`
|
|
174
181
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
this.
|
|
182
|
+
maxSwatchesChanged() {
|
|
183
|
+
const maxCount = this._maxSwatchesNormalized;
|
|
184
|
+
if (this.savedColors?.length > maxCount) {
|
|
185
|
+
this.savedColors = this.savedColors.slice(0, maxCount);
|
|
186
|
+
this._setSavedColors(this.savedColors);
|
|
179
187
|
}
|
|
180
188
|
}
|
|
181
189
|
/**
|
|
182
190
|
* @internal
|
|
183
191
|
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
/* v8 ignore else -- @preserve */
|
|
187
|
-
if (firstSelectedOption) requestAnimationFrame(() => {
|
|
188
|
-
firstSelectedOption.scrollIntoView({ block: "nearest" });
|
|
189
|
-
});
|
|
192
|
+
_onPickerColorChanged(e) {
|
|
193
|
+
if (typeof e.detail?.value === "string") this.value = e.detail?.value;
|
|
190
194
|
}
|
|
191
195
|
/**
|
|
192
|
-
* Handle focus state when the element or its children lose focus.
|
|
193
|
-
*
|
|
194
|
-
* @param e - The focus event
|
|
195
196
|
* @internal
|
|
196
197
|
*/
|
|
197
|
-
|
|
198
|
-
this.
|
|
199
|
-
if (
|
|
200
|
-
const focusTarget = e.relatedTarget;
|
|
201
|
-
if (this.isSameNode(focusTarget)) {
|
|
202
|
-
this.focus();
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
this.open = false;
|
|
198
|
+
valueChanged(_oldVal, newVal) {
|
|
199
|
+
if (this._vcHexPickerEl && typeof newVal === "string") this._vcHexPickerEl.color = newVal;
|
|
200
|
+
if (this._vcHexInputEl && typeof newVal === "string") this._vcHexInputEl.color = newVal;
|
|
206
201
|
}
|
|
207
202
|
/**
|
|
208
|
-
* Handle content changes on the control input.
|
|
209
|
-
*
|
|
210
|
-
* @param e - the input event
|
|
211
203
|
* @internal
|
|
212
204
|
*/
|
|
213
|
-
|
|
214
|
-
this.
|
|
215
|
-
this.filterOptions();
|
|
216
|
-
if (!this.isAutocompleteInline) this.selectedIndex = this.options.map((option) => option.text).indexOf(this.control.value);
|
|
217
|
-
if (e.inputType.includes("deleteContent") || !this.filter.length) return true;
|
|
218
|
-
if (this.isAutocompleteList && !this.open) this.open = true;
|
|
219
|
-
if (this.isAutocompleteInline) if (this.filteredOptions.length) {
|
|
220
|
-
this.selectedOptions = [this.filteredOptions[0]];
|
|
221
|
-
this.selectedIndex = this.options.indexOf(this.firstSelectedOption);
|
|
222
|
-
this.setInlineSelection();
|
|
223
|
-
} else this.selectedIndex = -1;
|
|
205
|
+
_onTextFieldInput(event) {
|
|
206
|
+
this.value = event.currentTarget.value;
|
|
224
207
|
}
|
|
225
208
|
/**
|
|
226
|
-
* Handle keydown actions for listbox navigation.
|
|
227
|
-
*
|
|
228
|
-
* @param e - the keyboard event
|
|
229
209
|
* @internal
|
|
230
210
|
*/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
this.syncValue();
|
|
237
|
-
/* v8 ignore else -- @preserve */
|
|
238
|
-
if (this.isAutocompleteInline) this.filter = this.value;
|
|
239
|
-
this.open = false;
|
|
240
|
-
this.clearSelectionRange();
|
|
241
|
-
break;
|
|
242
|
-
case "Escape":
|
|
243
|
-
/* v8 ignore else -- @preserve */
|
|
244
|
-
if (!this.isAutocompleteInline) this.selectedIndex = -1;
|
|
245
|
-
if (this.open) {
|
|
246
|
-
this.open = false;
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
this.value = "";
|
|
250
|
-
this.control.value = "";
|
|
251
|
-
this.filter = "";
|
|
252
|
-
this.filterOptions();
|
|
253
|
-
break;
|
|
254
|
-
case "Tab":
|
|
255
|
-
this.setInputToSelection();
|
|
256
|
-
if (!this.open) return true;
|
|
257
|
-
e.preventDefault();
|
|
258
|
-
this.open = false;
|
|
259
|
-
break;
|
|
260
|
-
case "ArrowUp":
|
|
261
|
-
case "ArrowDown":
|
|
262
|
-
this.filterOptions();
|
|
263
|
-
if (!this.open) {
|
|
264
|
-
this.open = true;
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
/* v8 ignore else -- @preserve */
|
|
268
|
-
if (this.filteredOptions.length > 0) super.keydownHandler(e);
|
|
269
|
-
if (this.isAutocompleteInline) this.setInlineSelection();
|
|
270
|
-
break;
|
|
271
|
-
default: return true;
|
|
272
|
-
}
|
|
211
|
+
get _buttonColor() {
|
|
212
|
+
/* v8 ignore else -- @preserve */
|
|
213
|
+
if (!this._canvasColor) this._refreshCanvasColor();
|
|
214
|
+
if (this.value && isValidHexColor(this.value)) return this.value;
|
|
215
|
+
return "var(--vvd-color-canvas-text)";
|
|
273
216
|
}
|
|
274
217
|
/**
|
|
275
|
-
* Ensure that the selectedIndex is within the current allowable filtered range.
|
|
276
|
-
*
|
|
277
|
-
* @param prev - the previous selected index value
|
|
278
|
-
* @param next - the current selected index value
|
|
279
|
-
*
|
|
280
218
|
* @internal
|
|
281
219
|
*/
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
next = limit(-1, this.options.length - 1, next);
|
|
285
|
-
if (next !== this.selectedIndex) {
|
|
286
|
-
this.selectedIndex = next;
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
super.selectedIndexChanged(prev, next);
|
|
290
|
-
}
|
|
220
|
+
_onButtonClick() {
|
|
221
|
+
this.open = !this.open;
|
|
291
222
|
}
|
|
292
223
|
/**
|
|
293
|
-
* Move focus to the previous selectable option.
|
|
294
|
-
*
|
|
295
224
|
* @internal
|
|
296
|
-
* @remarks
|
|
297
|
-
* Overrides `Listbox.selectPreviousOption`
|
|
298
225
|
*/
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
_isDefaultSelected(option) {
|
|
303
|
-
return super._isDefaultSelected(option) || option.text !== "" && option.text === this.initialValue;
|
|
226
|
+
_handleCloseRequest() {
|
|
227
|
+
this.open = false;
|
|
304
228
|
}
|
|
305
229
|
/**
|
|
306
|
-
* Focus and set the content of the control based on the first selected option.
|
|
307
|
-
*
|
|
308
230
|
* @internal
|
|
309
231
|
*/
|
|
310
|
-
|
|
311
|
-
if (
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
232
|
+
_isInPath(e, el) {
|
|
233
|
+
if (!el) return false;
|
|
234
|
+
const path = e.composedPath?.();
|
|
235
|
+
return !!(path && path.includes(el));
|
|
315
236
|
}
|
|
316
237
|
/**
|
|
317
|
-
* Focus, set and select the content of the control based on the first selected option.
|
|
318
|
-
*
|
|
319
238
|
* @internal
|
|
320
239
|
*/
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
240
|
+
#closeOnPointerOutside = (e) => {
|
|
241
|
+
if (this._isInPath(e, this._buttonEl) || this._isInPath(e, this._popupEl)) return;
|
|
242
|
+
this.open = false;
|
|
243
|
+
};
|
|
244
|
+
connectedCallback() {
|
|
245
|
+
super.connectedCallback();
|
|
246
|
+
this.savedColors = this._loadSavedColors();
|
|
247
|
+
document.addEventListener("mousedown", this.#closeOnPointerOutside, true);
|
|
327
248
|
}
|
|
249
|
+
disconnectedCallback() {
|
|
250
|
+
super.disconnectedCallback();
|
|
251
|
+
document.removeEventListener("mousedown", this.#closeOnPointerOutside, true);
|
|
252
|
+
}
|
|
253
|
+
#iconResetTimer = null;
|
|
328
254
|
/**
|
|
329
|
-
* Determines if a value update should involve emitting a change event, then updates the value.
|
|
330
|
-
*
|
|
331
255
|
* @internal
|
|
332
256
|
*/
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
this
|
|
257
|
+
_setTemporaryCopyIcon(name, ms = 2e3) {
|
|
258
|
+
this.copyIconName = name;
|
|
259
|
+
if (this.#iconResetTimer) clearTimeout(this.#iconResetTimer);
|
|
260
|
+
this.#iconResetTimer = setTimeout(() => {
|
|
261
|
+
this.copyIconName = "copy-2-line";
|
|
262
|
+
this.#iconResetTimer = null;
|
|
263
|
+
}, ms);
|
|
336
264
|
}
|
|
337
265
|
/**
|
|
338
|
-
* Ensure that the entire list of options is used when setting the selected property.
|
|
339
|
-
*
|
|
340
|
-
* @param prev - the previous list of selected options
|
|
341
|
-
* @param next - the current list of selected options
|
|
342
|
-
*
|
|
343
266
|
* @internal
|
|
344
|
-
* @remarks
|
|
345
|
-
* Overrides: `Listbox.selectedOptionsChanged`
|
|
346
267
|
*/
|
|
347
|
-
|
|
348
|
-
if (this
|
|
349
|
-
|
|
350
|
-
|
|
268
|
+
_onBaseKeydown(event) {
|
|
269
|
+
if (this.open && handleEscapeKeyAndStopPropogation(event)) {
|
|
270
|
+
this.open = false;
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (this._trappedFocus(event, () => this._focusableElsWithinDialog())) return false;
|
|
274
|
+
return true;
|
|
351
275
|
}
|
|
352
276
|
/**
|
|
353
|
-
* Synchronize the form-associated proxy and update the value property of the element.
|
|
354
|
-
*
|
|
355
|
-
* @param prev - the previous collection of slotted option elements
|
|
356
|
-
* @param next - the next collection of slotted option elements
|
|
357
|
-
*
|
|
358
277
|
* @internal
|
|
359
278
|
*/
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
this.updateValue();
|
|
363
|
-
const scale = this.getAttribute("scale") || this.scale;
|
|
364
|
-
next.forEach((element) => {
|
|
365
|
-
if (scale) {
|
|
366
|
-
element.setAttribute("scale", scale);
|
|
367
|
-
element.scale = scale;
|
|
368
|
-
}
|
|
369
|
-
});
|
|
279
|
+
_focusableElsWithinDialog() {
|
|
280
|
+
return this._popupEl.querySelectorAll("button:not([role=\"gridcell\"]), [data-vvd-component=\"button\"], vwc-button:not([role=\"gridcell\"])");
|
|
370
281
|
}
|
|
371
282
|
/**
|
|
372
|
-
* Sets the value and to match the first selected option.
|
|
373
|
-
*
|
|
374
|
-
* @param shouldEmit - if true, the change event will be emitted
|
|
375
|
-
*
|
|
376
283
|
* @internal
|
|
377
284
|
*/
|
|
378
|
-
|
|
379
|
-
if (
|
|
380
|
-
|
|
285
|
+
_handleCellKeydown(event, value, index, isSaveCell) {
|
|
286
|
+
if (event.key === "Tab") {
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
const focusableEls = this._focusableElsWithinDialog();
|
|
289
|
+
const idx = Array.prototype.indexOf.call(focusableEls, event.currentTarget);
|
|
290
|
+
focusableEls[event.shiftKey ? (idx - 1 + focusableEls.length) % focusableEls.length : (idx + 1) % focusableEls.length]?.focus();
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
return super._handleCellKeydown(event, value, index, isSaveCell);
|
|
381
294
|
}
|
|
382
295
|
/**
|
|
383
296
|
* @internal
|
|
384
297
|
*/
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
this.
|
|
298
|
+
_handleSwatchSelection(value) {
|
|
299
|
+
/* v8 ignore else -- @preserve */
|
|
300
|
+
if (this.value !== value) this._ariaLiveDescription = this.locale.colorPicker.selectionSuccessMessage(value);
|
|
301
|
+
super._handleSwatchSelection(value);
|
|
388
302
|
}
|
|
389
303
|
};
|
|
390
|
-
__decorate([attr
|
|
391
|
-
|
|
392
|
-
mode: "fromView"
|
|
393
|
-
})], Combobox.prototype, "autocomplete", void 0);
|
|
394
|
-
__decorate([attr], Combobox.prototype, "appearance", void 0);
|
|
395
|
-
__decorate([attr], Combobox.prototype, "shape", void 0);
|
|
396
|
-
__decorate([attr()], Combobox.prototype, "scale", void 0);
|
|
397
|
-
__decorate([attr], Combobox.prototype, "placement", void 0);
|
|
304
|
+
__decorate([attr], ColorPicker.prototype, "placeholder", void 0);
|
|
305
|
+
__decorate([attr({ attribute: "saved-colors-key" })], ColorPicker.prototype, "savedColorsKey", void 0);
|
|
398
306
|
__decorate([attr({
|
|
399
307
|
mode: "boolean",
|
|
400
|
-
attribute: "
|
|
401
|
-
})],
|
|
402
|
-
__decorate([observable],
|
|
403
|
-
__decorate([observable], Combobox.prototype, "maxHeight", void 0);
|
|
308
|
+
attribute: "disable-saved-colors"
|
|
309
|
+
})], ColorPicker.prototype, "disableSavedColors", void 0);
|
|
310
|
+
__decorate([observable], ColorPicker.prototype, "savedColors", void 0);
|
|
404
311
|
__decorate([attr({
|
|
405
|
-
attribute: "
|
|
406
|
-
mode: "
|
|
407
|
-
|
|
408
|
-
|
|
312
|
+
attribute: "max-swatches",
|
|
313
|
+
mode: "fromView",
|
|
314
|
+
converter: nullableNumberConverter
|
|
315
|
+
})], ColorPicker.prototype, "maxSwatches", void 0);
|
|
316
|
+
__decorate([observable], ColorPicker.prototype, "copyIconName", void 0);
|
|
317
|
+
__decorate([observable], ColorPicker.prototype, "_ariaLiveDescription", void 0);
|
|
409
318
|
//#endregion
|
|
410
|
-
//#region src/lib/
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return html`
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
?
|
|
319
|
+
//#region src/lib/color-picker/color-picker.template.ts
|
|
320
|
+
function renderTextField(textFieldTag, iconTag) {
|
|
321
|
+
const getClasses = (_) => classNames("control");
|
|
322
|
+
return html`
|
|
323
|
+
<${textFieldTag}
|
|
324
|
+
id="text-field"
|
|
325
|
+
class="${getClasses}"
|
|
326
|
+
pattern="${ColorPicker.HEX_COLOR_PATTERN.source}"
|
|
327
|
+
maxlength="7"
|
|
328
|
+
label="${(x) => x.label}"
|
|
329
|
+
:value="${(x) => x.value}"
|
|
330
|
+
placeholder="${(x) => x.placeholder}"
|
|
331
|
+
helper-text="${(x) => x.helperText}"
|
|
332
|
+
error-text="${(x) => x.errorValidationMessage}"
|
|
333
|
+
success-text="${(x) => x.successText}"
|
|
334
|
+
?disabled="${(x) => x.disabled}"
|
|
335
|
+
?required="${(x) => x.required}"
|
|
336
|
+
@input='${(x, c) => x._onTextFieldInput(c.event)}'
|
|
337
|
+
@change="${(x) => x.handleChange()}"
|
|
338
|
+
@blur="${(x) => {
|
|
339
|
+
x.$emit("blur", void 0, { bubbles: false });
|
|
340
|
+
}}"
|
|
341
|
+
@focus="${(x) => {
|
|
342
|
+
x.$emit("focus", void 0, { bubbles: false });
|
|
343
|
+
}}"
|
|
344
|
+
${delegateAria()}
|
|
345
|
+
${ref("_textFieldEl")}
|
|
427
346
|
>
|
|
428
|
-
|
|
347
|
+
<button
|
|
348
|
+
aria-label="${(x) => x.locale.colorPicker.pickerButtonLabel}"
|
|
349
|
+
aria-expanded="${(x) => x.open}"
|
|
350
|
+
aria-haspopup="dialog"
|
|
351
|
+
class="button ${(x) => classNames(x._applyContrastClass(x._buttonColor) ? "contrast" : "", x.disabled ? "disabled" : "")}"
|
|
352
|
+
style="--button-color: ${(x) => x._buttonColor};"
|
|
353
|
+
?disabled="${(x) => x.disabled}"
|
|
354
|
+
@click="${(x) => x._onButtonClick()}"
|
|
355
|
+
slot="action-items"
|
|
356
|
+
${ref("_buttonEl")}>
|
|
357
|
+
<${iconTag} name="edit-line"></${iconTag}>
|
|
358
|
+
</button>
|
|
359
|
+
<slot
|
|
360
|
+
slot="${(x) => x._helperTextSlottedContent?.length ? "helper-text" : void 0}"
|
|
361
|
+
name="helper-text"
|
|
362
|
+
${slotted("_helperTextSlottedContent")}
|
|
363
|
+
></slot>
|
|
429
364
|
<slot
|
|
430
|
-
|
|
365
|
+
slot='${(x) => x._contextualHelpSlottedContent?.length ? "contextual-help" : void 0}'
|
|
366
|
+
name='contextual-help'
|
|
431
367
|
${slotted("_contextualHelpSlottedContent")}
|
|
432
368
|
></slot>
|
|
369
|
+
</${textFieldTag}>
|
|
370
|
+
`;
|
|
371
|
+
}
|
|
372
|
+
function renderPopupHeader(buttonTag, iconTag) {
|
|
373
|
+
return html`
|
|
374
|
+
<div class="header">
|
|
375
|
+
<h2 class="header-title" id="color-picker-title">
|
|
376
|
+
<slot name="popup-text">${(x) => x.locale.colorPicker.popupLabel}</slot>
|
|
377
|
+
</h2>
|
|
378
|
+
<${buttonTag} size="condensed"
|
|
379
|
+
aria-label="${(x) => x.locale.colorPicker.closeButtonLabel}"
|
|
380
|
+
@click="${(x) => x._handleCloseRequest()}">
|
|
381
|
+
<${iconTag} slot="icon" name="close-line"></${iconTag}>
|
|
382
|
+
</${buttonTag}>
|
|
433
383
|
</div>
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
@input="${(x, c) => x.inputHandler(c.event)}"
|
|
453
|
-
${ref("control")}
|
|
454
|
-
/>
|
|
455
|
-
</div>
|
|
456
|
-
<div class="leading-items-wrapper">
|
|
457
|
-
<slot name="meta" ${slotted("metaSlottedContent")}></slot>
|
|
458
|
-
<div
|
|
459
|
-
@click="${(x, c) => x._chevronIconClickHandler(c.event)}"
|
|
384
|
+
`;
|
|
385
|
+
}
|
|
386
|
+
function renderPopupBody(buttonTag, iconTag, tooltipTag) {
|
|
387
|
+
return html`
|
|
388
|
+
<div class="body">
|
|
389
|
+
<${html.partial(vcPickerTag)}
|
|
390
|
+
part="hex-picker"
|
|
391
|
+
color="${(x) => x.value}"
|
|
392
|
+
@color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
|
|
393
|
+
${ref("_vcHexPickerEl")}
|
|
394
|
+
></${html.partial(vcPickerTag)}>
|
|
395
|
+
<div class="hex-input-wrapper">
|
|
396
|
+
<${html.partial(vcInputTag)}
|
|
397
|
+
part="hex-input"
|
|
398
|
+
prefixed
|
|
399
|
+
color="${(x) => x.value}"
|
|
400
|
+
@color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
|
|
401
|
+
${ref("_vcHexInputEl")}
|
|
460
402
|
>
|
|
461
|
-
${
|
|
462
|
-
|
|
403
|
+
<input name="hex-code-input" aria-label="${(x) => x.locale.colorPicker.hexInputLabel}"
|
|
404
|
+
placeholder="${(x) => x.placeholder}"
|
|
405
|
+
@blur="${(x, c) => c.event.stopImmediatePropagation()}"
|
|
406
|
+
part="input">
|
|
407
|
+
</${html.partial(vcInputTag)}>
|
|
408
|
+
<${tooltipTag} placement="top"
|
|
409
|
+
text="${(x) => x.locale.colorPicker.copyButtonLabel}"
|
|
410
|
+
exportparts="vvd-theme-alternate">
|
|
411
|
+
<${buttonTag}
|
|
412
|
+
slot="anchor" size="normal"
|
|
413
|
+
aria-label="${(x) => x.locale.colorPicker.copyButtonLabel}"
|
|
414
|
+
@click="${(x) => x._copyValueToClipboard(x.value)}">
|
|
415
|
+
<${iconTag} slot="icon" name="${(x) => x.copyIconName}"></${iconTag}>
|
|
416
|
+
</${buttonTag}>
|
|
417
|
+
</${tooltipTag}>
|
|
463
418
|
</div>
|
|
464
419
|
</div>
|
|
465
|
-
|
|
420
|
+
`;
|
|
466
421
|
}
|
|
467
|
-
|
|
468
|
-
const popupTag = context.tagFor(Popup);
|
|
422
|
+
function renderPopupFooter(buttonTag, iconTag, tooltipTag) {
|
|
469
423
|
return html`
|
|
470
|
-
<
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
>
|
|
479
|
-
<div class="control-wrapper">
|
|
480
|
-
${() => renderInput(context)}
|
|
481
|
-
<${popupTag} class="popup"
|
|
482
|
-
style="${setFixedDropdownVarWidth}"
|
|
483
|
-
?open="${(x) => x.open}"
|
|
484
|
-
placement="${(x) => x.placement ?? "bottom-start"}"
|
|
485
|
-
strategy="${(x) => x.fixedDropdown ? "fixed" : "absolute"}"
|
|
486
|
-
${ref("_popup")}>
|
|
487
|
-
<div id="${(x) => x.listboxId}"
|
|
488
|
-
class="listbox"
|
|
489
|
-
role="listbox"
|
|
490
|
-
?disabled="${(x) => x.disabled}"
|
|
491
|
-
${ref("listbox")}>
|
|
492
|
-
<slot ${slotted({
|
|
493
|
-
filter: Listbox.slottedOptionFilter,
|
|
494
|
-
flatten: true,
|
|
495
|
-
property: "slottedOptions"
|
|
496
|
-
})}>
|
|
497
|
-
</slot>
|
|
498
|
-
</div>
|
|
499
|
-
</${popupTag}>
|
|
424
|
+
<div class="footer">
|
|
425
|
+
<div class="footer-header">
|
|
426
|
+
<span class="footer-title" id="color-picker-footer-title"
|
|
427
|
+
><slot name="swatches-text"
|
|
428
|
+
>${(x) => x.locale.colorPicker.swatchesLabel}</slot
|
|
429
|
+
></span
|
|
430
|
+
>
|
|
431
|
+
${when((x) => !x.disableSavedColors, renderSwatchesCount())}
|
|
500
432
|
</div>
|
|
501
|
-
<div
|
|
502
|
-
|
|
433
|
+
<div
|
|
434
|
+
class="palette"
|
|
435
|
+
role="grid"
|
|
436
|
+
aria-rowcount="${(x) => Math.ceil(x.allSwatches.length / x._getRowLength())}"
|
|
437
|
+
aria-colcount="${(x) => x._getRowLength()}"
|
|
438
|
+
style="--swatches-per-row: ${(x) => x._getRowLength()};"
|
|
439
|
+
aria-labelledby="color-picker-footer-title"
|
|
440
|
+
>
|
|
441
|
+
${repeat((x) => x.allSwatches, (x) => x._renderColorSwatch(iconTag, tooltipTag), { positioning: true })}
|
|
442
|
+
${when((x) => !x.disableSavedColors, html`
|
|
443
|
+
<${tooltipTag} placement="top"
|
|
444
|
+
text="${(x) => x.locale.colorPicker.saveButtonLabel}"
|
|
445
|
+
exportparts="vvd-theme-alternate">
|
|
446
|
+
<${buttonTag}
|
|
447
|
+
slot="anchor"
|
|
448
|
+
appearance="outlined"
|
|
449
|
+
size="super-condensed"
|
|
450
|
+
role="gridcell"
|
|
451
|
+
tabindex="${(x) => x.allSwatches.length ? "-1" : "0"}"
|
|
452
|
+
aria-label="${(x) => x.locale.colorPicker.saveButtonLabel}"
|
|
453
|
+
@click="${(x) => x._saveCurrentColor()}"
|
|
454
|
+
@keydown="${(x, c) => x._handleCellKeydown(c.event, x.value, x.allSwatches.length, true)}">
|
|
455
|
+
<${iconTag} slot="icon" name="plus-line"></${iconTag}>
|
|
456
|
+
</${buttonTag}>
|
|
457
|
+
</${tooltipTag}>
|
|
458
|
+
`)}
|
|
503
459
|
</div>
|
|
504
|
-
|
|
460
|
+
</div>
|
|
461
|
+
`;
|
|
462
|
+
}
|
|
463
|
+
function renderSwatchesCount() {
|
|
464
|
+
return html`
|
|
465
|
+
<span
|
|
466
|
+
id="swatches-count"
|
|
467
|
+
class="swatches-count"
|
|
468
|
+
aria-label="${(x) => x.locale.colorPicker.maxSwatchesMessage(x.allSwatches.length, x.maxSwatches)}"
|
|
469
|
+
>${(x) => `${x.allSwatches.length}/${x.maxSwatches}`}</span
|
|
470
|
+
>
|
|
471
|
+
`;
|
|
472
|
+
}
|
|
473
|
+
var ColorPickerTemplate = (context) => {
|
|
474
|
+
const textFieldTag = context.tagFor(TextField);
|
|
475
|
+
const iconTag = context.tagFor(Icon);
|
|
476
|
+
const popupTag = context.tagFor(Popup);
|
|
477
|
+
const buttonTag = context.tagFor(Button);
|
|
478
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
479
|
+
return html`
|
|
480
|
+
<div class="base" @keydown="${(x, { event }) => x._onBaseKeydown(event)}">
|
|
481
|
+
<span aria-live="assertive" aria-relevant="text" class="visually-hidden">
|
|
482
|
+
${(x) => x._ariaLiveDescription}
|
|
483
|
+
</span>
|
|
484
|
+
${renderTextField(textFieldTag, iconTag)}
|
|
485
|
+
<${popupTag}
|
|
486
|
+
:open="${(x) => x.open}"
|
|
487
|
+
:anchor="${(x) => x._buttonEl}"
|
|
488
|
+
placement="top"
|
|
489
|
+
offset="10"
|
|
490
|
+
${ref("_popupEl")}>
|
|
491
|
+
<div class="dialog"
|
|
492
|
+
role="dialog"
|
|
493
|
+
aria-modal="true"
|
|
494
|
+
aria-labelledby="color-picker-title">
|
|
495
|
+
${renderPopupHeader(buttonTag, iconTag)}
|
|
496
|
+
${renderPopupBody(buttonTag, iconTag, tooltipTag)}
|
|
497
|
+
${when((x) => !x.disableSavedColors || x.allSwatches.length > 0, renderPopupFooter(buttonTag, iconTag, tooltipTag))}
|
|
498
|
+
</div>
|
|
499
|
+
</${popupTag}>
|
|
500
|
+
</div>
|
|
505
501
|
`;
|
|
506
502
|
};
|
|
507
503
|
//#endregion
|
|
508
|
-
//#region src/lib/
|
|
509
|
-
|
|
510
|
-
* @internal
|
|
511
|
-
*/
|
|
512
|
-
var comboboxDefinition = defineVividComponent("combobox", Combobox, comboboxTemplate, [
|
|
513
|
-
iconDefinition,
|
|
504
|
+
//#region src/lib/color-picker/definition.ts
|
|
505
|
+
var colorPickerDefinition = defineVividComponent("color-picker", ColorPicker, ColorPickerTemplate, [
|
|
514
506
|
popupDefinition,
|
|
515
|
-
|
|
507
|
+
iconDefinition,
|
|
508
|
+
textFieldDefinition,
|
|
509
|
+
buttonDefinition,
|
|
510
|
+
tooltipDefinition,
|
|
516
511
|
feedbackMessageDefinition
|
|
517
|
-
], {
|
|
518
|
-
styles: [text_field_default, combobox_default],
|
|
519
|
-
shadowOptions: { delegatesFocus: true }
|
|
520
|
-
});
|
|
512
|
+
], { styles: color_picker_default });
|
|
521
513
|
/**
|
|
522
|
-
* Registers the
|
|
514
|
+
* Registers the color-picker element with the design system.
|
|
523
515
|
*
|
|
524
516
|
* @param prefix - the prefix to use for the component name
|
|
525
517
|
*/
|
|
526
|
-
var
|
|
518
|
+
var registerColorPicker = createRegisterFunction(colorPickerDefinition);
|
|
527
519
|
//#endregion
|
|
528
|
-
export {
|
|
520
|
+
export { registerColorPicker as n, ColorPicker as r, colorPickerDefinition as t };
|