@vonage/vivid 5.15.1 → 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/definition.cjs +7 -207
- package/accordion/definition.js +2 -199
- package/accordion/index.cjs +4 -4
- package/accordion/index.js +93 -127
- package/accordion-item/definition.cjs +6 -146
- package/accordion-item/definition.js +2 -139
- package/accordion-item/index.cjs +1 -1
- package/accordion-item/index.js +6 -2
- package/action-group/definition.cjs +5 -69
- package/action-group/definition.js +1 -62
- package/action-group/index.cjs +4 -4
- package/action-group/index.js +16 -46
- package/alert/definition.cjs +6 -201
- package/alert/definition.js +2 -194
- package/alert/index.cjs +15 -15
- package/alert/index.js +90 -136
- package/audio-player/definition.cjs +6 -459
- package/audio-player/definition.js +2 -452
- package/audio-player/index.cjs +49 -49
- package/audio-player/index.js +234 -302
- package/avatar/definition.cjs +6 -117
- package/avatar/definition.js +2 -110
- package/avatar/index.cjs +14 -14
- package/avatar/index.js +44 -84
- package/badge/definition.cjs +6 -85
- package/badge/definition.js +2 -78
- package/badge/index.cjs +4 -4
- package/badge/index.js +21 -65
- package/banner/definition.cjs +6 -160
- package/banner/definition.js +2 -153
- package/banner/index.cjs +13 -13
- package/banner/index.js +76 -109
- package/breadcrumb/definition.cjs +5 -97
- package/breadcrumb/definition.js +1 -90
- package/breadcrumb/index.cjs +4 -4
- package/breadcrumb/index.js +33 -59
- package/breadcrumb-item/definition.cjs +7 -47
- package/breadcrumb-item/definition.js +3 -40
- package/breadcrumb-item/index.cjs +5 -5
- package/breadcrumb-item/index.js +20 -32
- package/bundled/affix.cjs +10 -10
- package/bundled/affix.js +44 -57
- package/bundled/anchored.cjs +3 -3
- package/bundled/anchored.js +47 -65
- package/bundled/aria.cjs +1 -1
- package/bundled/aria.js +6 -6
- package/bundled/attribute-binding-behaviour.cjs +1 -1
- package/bundled/attribute-binding-behaviour.js +17 -28
- package/bundled/base-color-picker.cjs +10 -10
- package/bundled/base-color-picker.js +115 -197
- package/bundled/base-progress.cjs +1 -1
- package/bundled/base-progress.js +29 -56
- package/bundled/breadcrumb-item.cjs +1 -1
- package/bundled/breadcrumb-item.js +11 -20
- package/bundled/button.cjs +1 -1
- package/bundled/button.js +65 -100
- package/bundled/calendar-event.cjs +1 -1
- package/bundled/calendar-event.js +11 -34
- package/bundled/calendar-picker.template.cjs +77 -77
- package/bundled/calendar-picker.template.js +2883 -3347
- package/bundled/char-count.cjs +7 -7
- package/bundled/char-count.js +31 -46
- package/bundled/children.cjs +1 -1
- package/bundled/children.js +27 -45
- package/bundled/class-names.cjs +1 -1
- package/bundled/class-names.js +8 -8
- package/bundled/data-grid.options.cjs +1 -1
- package/bundled/data-grid.options.js +22 -26
- package/bundled/decorate.cjs +1 -0
- package/bundled/decorate.js +9 -0
- package/bundled/definition.cjs +1 -39
- package/bundled/definition.js +5 -122
- package/bundled/definition10.cjs +18 -72
- package/bundled/definition10.js +74 -355
- package/bundled/definition11.cjs +10 -12
- package/bundled/definition11.js +28 -92
- package/bundled/definition12.cjs +72 -18
- package/bundled/definition12.js +192 -222
- package/bundled/definition13.cjs +20 -10
- package/bundled/definition13.js +55 -41
- package/bundled/definition14.cjs +5 -1
- package/bundled/definition14.js +11 -20
- package/bundled/definition15.cjs +19 -5
- package/bundled/definition15.js +77 -28
- package/bundled/definition16.cjs +12 -29
- package/bundled/definition16.js +80 -78
- package/bundled/definition17.cjs +17 -17
- package/bundled/definition17.js +126 -98
- package/bundled/definition18.cjs +87 -13
- package/bundled/definition18.js +423 -134
- package/bundled/definition19.cjs +5 -87
- package/bundled/definition19.js +16 -742
- package/bundled/definition2.cjs +8 -8
- package/bundled/definition2.js +79 -122
- package/bundled/definition20.cjs +26 -16
- package/bundled/definition20.js +153 -98
- package/bundled/definition21.cjs +29 -5
- package/bundled/definition21.js +174 -18
- package/bundled/definition22.cjs +38 -23
- package/bundled/definition22.js +70 -149
- package/bundled/definition3.cjs +1 -29
- package/bundled/definition3.js +183 -194
- package/bundled/definition4.cjs +24 -6
- package/bundled/definition4.js +88 -40
- package/bundled/definition5.cjs +30 -1
- package/bundled/definition5.js +48 -346
- package/bundled/definition6.cjs +28 -30
- package/bundled/definition6.js +110 -264
- package/bundled/definition7.cjs +6 -30
- package/bundled/definition7.js +22 -288
- package/bundled/definition8.cjs +13 -18
- package/bundled/definition8.js +150 -132
- package/bundled/definition9.cjs +12 -14
- package/bundled/definition9.js +67 -235
- package/bundled/delegates-aria.cjs +1 -1
- package/bundled/delegates-aria.js +56 -88
- package/bundled/dialog.cjs +1 -0
- package/bundled/dialog.js +6 -0
- package/bundled/divider.cjs +1 -1
- package/bundled/divider.js +16 -33
- package/bundled/dom.cjs +1 -1
- package/bundled/dom.js +5 -5
- package/bundled/enums.cjs +1 -1
- package/bundled/enums.js +16 -9
- package/bundled/floating-ui.dom.cjs +1 -1
- package/bundled/floating-ui.dom.js +953 -1238
- package/bundled/form-associated.cjs +1 -1
- package/bundled/form-associated.js +165 -318
- package/bundled/form-element.cjs +1 -1
- package/bundled/form-element.js +33 -55
- package/bundled/host-semantics.cjs +1 -1
- package/bundled/host-semantics.js +46 -69
- package/bundled/key-codes.cjs +1 -1
- package/bundled/key-codes.js +4 -16
- package/bundled/linkable.cjs +6 -6
- package/bundled/linkable.js +25 -45
- package/bundled/listbox.cjs +1 -1
- package/bundled/listbox.js +176 -351
- package/bundled/localized.cjs +1 -1
- package/bundled/localized.js +451 -564
- package/bundled/mixins.cjs +20 -20
- package/bundled/mixins.js +162 -210
- package/bundled/normalize.cjs +1 -1
- package/bundled/normalize.js +6 -6
- package/bundled/numbers.cjs +1 -1
- package/bundled/numbers.js +9 -11
- package/bundled/picker-field.template.cjs +23 -23
- package/bundled/picker-field.template.js +108 -171
- package/bundled/playbackRates.cjs +1 -1
- package/bundled/playbackRates.js +10 -10
- package/bundled/ref.cjs +1 -1
- package/bundled/ref.js +10 -14
- package/bundled/repeat.cjs +1 -1
- package/bundled/repeat.js +421 -552
- package/bundled/scrollIntoView.cjs +1 -1
- package/bundled/scrollIntoView.js +26 -29
- package/bundled/single-date-picker.cjs +1 -1
- package/bundled/single-date-picker.js +23 -38
- package/bundled/single-value-picker.cjs +1 -1
- package/bundled/single-value-picker.js +58 -86
- package/bundled/slider.template.cjs +14 -14
- package/bundled/slider.template.js +67 -78
- package/bundled/slottable-request.cjs +4 -4
- package/bundled/slottable-request.js +1907 -2904
- package/bundled/slotted.cjs +1 -1
- package/bundled/slotted.js +47 -97
- package/bundled/strings.cjs +1 -1
- package/bundled/strings.js +6 -6
- package/bundled/text-field.cjs +1 -1
- package/bundled/text-field.js +4 -4
- package/bundled/time-selection-picker.template.cjs +26 -26
- package/bundled/time-selection-picker.template.js +355 -552
- package/bundled/trapped-focus.cjs +1 -1
- package/bundled/trapped-focus.js +18 -25
- package/bundled/vivid-element.cjs +4 -5
- package/bundled/vivid-element.js +1781 -2806
- package/bundled/when.cjs +1 -1
- package/bundled/when.js +10 -10
- package/bundled/with-contextual-help.cjs +1 -1
- package/bundled/with-contextual-help.js +15 -31
- package/bundled/with-error-text.cjs +1 -1
- package/bundled/with-error-text.js +25 -38
- package/bundled/with-success-text.cjs +1 -1
- package/bundled/with-success-text.js +8 -15
- package/button/definition.cjs +6 -14
- package/button/definition.js +3 -4
- package/button/index.cjs +1 -1
- package/button/index.js +6 -2
- package/calendar/definition.cjs +5 -358
- package/calendar/definition.js +1 -351
- package/calendar/index.cjs +20 -20
- package/calendar/index.js +165 -427
- package/calendar-event/definition.cjs +6 -58
- package/calendar-event/definition.js +2 -51
- package/calendar-event/index.cjs +7 -7
- package/calendar-event/index.js +25 -41
- package/card/definition.cjs +6 -194
- package/card/definition.js +2 -187
- package/card/index.cjs +37 -34
- package/card/index.js +83 -133
- package/checkbox/definition.cjs +6 -209
- package/checkbox/definition.js +2 -202
- package/checkbox/index.cjs +1 -1
- package/checkbox/index.js +6 -2
- package/color-picker/definition.cjs +6 -1175
- package/color-picker/definition.js +2 -1168
- package/color-picker/index.cjs +94 -94
- package/color-picker/index.js +605 -737
- package/combobox/definition.cjs +6 -647
- package/combobox/definition.js +2 -640
- package/combobox/index.cjs +38 -37
- package/combobox/index.js +258 -458
- package/contextual-help/definition.cjs +6 -63
- package/contextual-help/definition.js +2 -56
- package/contextual-help/index.cjs +1 -1
- package/contextual-help/index.js +6 -2
- package/country/definition.cjs +6 -340
- package/country/definition.js +2 -333
- package/country/index.cjs +6 -6
- package/country/index.js +1209 -308
- package/custom-elements.json +1247 -1173
- package/data-grid/definition.cjs +10 -2350
- package/data-grid/definition.js +2 -2339
- package/data-grid/index.cjs +65 -65
- package/data-grid/index.js +644 -997
- package/date-picker/definition.cjs +6 -152
- package/date-picker/definition.js +2 -145
- package/date-picker/index.cjs +1 -1
- package/date-picker/index.js +66 -114
- package/date-range-picker/definition.cjs +6 -467
- package/date-range-picker/definition.js +2 -460
- package/date-range-picker/index.cjs +1 -1
- package/date-range-picker/index.js +218 -334
- package/date-time-picker/definition.cjs +6 -285
- package/date-time-picker/definition.js +2 -278
- package/date-time-picker/index.cjs +4 -4
- package/date-time-picker/index.js +116 -211
- package/dial-pad/definition.cjs +6 -460
- package/dial-pad/definition.js +2 -453
- package/dial-pad/index.cjs +44 -43
- package/dial-pad/index.js +197 -288
- package/dialog/definition.cjs +6 -349
- package/dialog/definition.js +2 -342
- package/dialog/index.cjs +28 -28
- package/dialog/index.js +148 -229
- package/divider/definition.cjs +6 -42
- package/divider/definition.js +2 -35
- package/divider/index.cjs +1 -1
- package/divider/index.js +5 -2
- package/elevation/definition.cjs +4 -11
- package/elevation/definition.js +2 -2
- package/elevation/index.cjs +1 -1
- package/elevation/index.js +5 -2
- package/empty-state/definition.cjs +6 -86
- package/empty-state/definition.js +2 -79
- package/empty-state/index.cjs +9 -9
- package/empty-state/index.js +28 -60
- package/fab/definition.cjs +6 -105
- package/fab/definition.js +2 -98
- package/fab/index.cjs +17 -17
- package/fab/index.js +46 -81
- package/file-picker/definition.cjs +6 -523
- package/file-picker/definition.js +2 -516
- package/file-picker/index.cjs +32 -29
- package/file-picker/index.js +254 -356
- package/header/definition.cjs +5 -78
- package/header/definition.js +1 -71
- package/header/index.cjs +6 -6
- package/header/index.js +28 -42
- package/icon/definition.cjs +5 -202
- package/icon/definition.js +1 -195
- package/icon/index.cjs +1 -1
- package/icon/index.js +5 -2
- package/index.cjs +353 -356
- package/index.js +79 -78
- package/layout/definition.cjs +5 -72
- package/layout/definition.js +1 -65
- package/layout/index.cjs +2 -2
- package/layout/index.js +10 -51
- package/lib/alert/alert.d.ts +0 -1
- package/lib/audio-player/audio-player.d.ts +0 -1
- package/lib/banner/banner.d.ts +0 -2
- package/lib/button/button.d.ts +0 -1
- package/lib/calendar/calendar.d.ts +0 -1
- package/lib/combobox/combobox.d.ts +0 -3
- package/lib/data-grid/data-grid-cell.d.ts +0 -3
- package/lib/data-grid/data-grid-row.d.ts +0 -3
- package/lib/data-grid/data-grid.d.ts +0 -1
- 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/fab/fab.d.ts +0 -1
- package/lib/file-picker/file-picker.d.ts +1 -1
- package/lib/icon/icon.d.ts +0 -1
- package/lib/menu/menu.d.ts +0 -1
- package/lib/option/option.d.ts +4 -1
- package/lib/pagination/pagination.d.ts +0 -4
- package/lib/popover/popover.d.ts +0 -5
- 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/split-button/split-button.d.ts +0 -2
- package/lib/tab/tab.d.ts +0 -2
- 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/lib/tag/tag.d.ts +0 -2
- package/lib/toggletip/toggletip.d.ts +0 -1
- package/lib/tree-item/tree-item.d.ts +0 -2
- package/lib/tree-view/tree-view.d.ts +0 -1
- package/locales/de-DE.cjs +266 -550
- package/locales/de-DE.js +264 -548
- package/locales/en-GB.cjs +266 -382
- package/locales/en-GB.js +264 -380
- package/locales/en-US.cjs +266 -550
- package/locales/en-US.js +264 -548
- package/locales/ja-JP.cjs +266 -549
- package/locales/ja-JP.js +264 -547
- package/locales/zh-CN.cjs +266 -551
- package/locales/zh-CN.js +264 -549
- package/menu/definition.cjs +6 -393
- package/menu/definition.js +2 -386
- package/menu/index.cjs +1 -1
- package/menu/index.js +6 -2
- package/menu-item/definition.cjs +7 -14
- package/menu-item/definition.js +3 -3
- package/menu-item/index.cjs +1 -1
- package/menu-item/index.js +6 -2
- package/nav/definition.cjs +5 -27
- package/nav/definition.js +1 -20
- package/nav/index.cjs +3 -3
- package/nav/index.js +7 -10
- package/nav-disclosure/definition.cjs +6 -122
- package/nav-disclosure/definition.js +2 -115
- package/nav-disclosure/index.cjs +8 -8
- package/nav-disclosure/index.js +49 -86
- package/nav-item/definition.cjs +6 -79
- package/nav-item/definition.js +2 -72
- package/nav-item/index.cjs +2 -2
- package/nav-item/index.js +33 -58
- package/note/definition.cjs +6 -61
- package/note/definition.js +2 -54
- package/note/index.cjs +5 -5
- package/note/index.js +24 -38
- package/number-field/definition.cjs +6 -440
- package/number-field/definition.js +2 -433
- package/number-field/index.cjs +31 -31
- package/number-field/index.js +160 -328
- package/option/definition.cjs +6 -13
- package/option/definition.js +3 -3
- package/option/index.cjs +1 -1
- package/option/index.js +6 -2
- package/package.json +15 -17
- package/pagination/definition.cjs +6 -254
- package/pagination/definition.js +2 -247
- package/pagination/index.cjs +37 -37
- package/pagination/index.js +148 -186
- package/popover/definition.cjs +6 -356
- package/popover/definition.js +2 -349
- package/popover/index.cjs +16 -16
- package/popover/index.js +161 -239
- package/popup/definition.cjs +5 -13
- package/popup/definition.js +3 -4
- package/popup/index.cjs +1 -1
- package/popup/index.js +6 -2
- package/progress/definition.cjs +5 -87
- package/progress/definition.js +1 -80
- package/progress/index.cjs +9 -9
- package/progress/index.js +33 -55
- package/progress-ring/definition.cjs +5 -95
- package/progress-ring/definition.js +1 -88
- package/progress-ring/index.cjs +1 -1
- package/progress-ring/index.js +5 -2
- package/radio/definition.cjs +5 -227
- package/radio/definition.js +1 -220
- package/radio/index.cjs +1 -1
- package/radio/index.js +5 -2
- package/radio-group/definition.cjs +6 -361
- package/radio-group/definition.js +2 -354
- package/radio-group/index.cjs +10 -10
- package/radio-group/index.js +160 -242
- package/range-slider/definition.cjs +6 -632
- package/range-slider/definition.js +2 -625
- package/range-slider/index.cjs +41 -41
- package/range-slider/index.js +259 -429
- package/rich-text-editor/definition.cjs +33 -15694
- package/rich-text-editor/definition.js +3 -15662
- package/rich-text-editor/index.cjs +18 -18
- package/rich-text-editor/index.js +9129 -11475
- package/rich-text-view/definition.cjs +5 -171
- package/rich-text-view/definition.js +1 -164
- package/rich-text-view/index.cjs +1 -1
- package/rich-text-view/index.js +68 -102
- package/searchable-select/definition.cjs +5 -1401
- package/searchable-select/definition.js +2 -1395
- package/searchable-select/index.cjs +94 -94
- package/searchable-select/index.js +600 -1015
- package/select/definition.cjs +6 -1002
- package/select/definition.js +2 -995
- package/select/index.cjs +1 -1
- package/select/index.js +6 -2
- package/selectable-box/definition.cjs +6 -174
- package/selectable-box/definition.js +2 -167
- package/selectable-box/index.cjs +18 -18
- package/selectable-box/index.js +66 -127
- package/shared/foundation/test-utilities/fixture.d.ts +1 -1
- package/shared/patterns/linkable.d.ts +1 -1
- package/side-drawer/definition.cjs +5 -130
- package/side-drawer/definition.js +1 -123
- package/side-drawer/index.cjs +7 -7
- package/side-drawer/index.js +47 -89
- package/simple-color-picker/definition.cjs +6 -225
- package/simple-color-picker/definition.js +2 -218
- package/simple-color-picker/index.cjs +15 -15
- package/simple-color-picker/index.js +98 -135
- package/slider/definition.cjs +6 -499
- package/slider/definition.js +2 -492
- package/slider/index.cjs +1 -1
- package/slider/index.js +6 -2
- package/split-button/definition.cjs +6 -176
- package/split-button/definition.js +2 -169
- package/split-button/index.cjs +15 -15
- package/split-button/index.js +74 -135
- package/status/definition.cjs +6 -82
- package/status/definition.js +2 -75
- package/status/index.cjs +7 -7
- package/status/index.js +35 -52
- package/switch/definition.cjs +6 -148
- package/switch/definition.js +2 -141
- package/switch/index.cjs +8 -8
- package/switch/index.js +48 -92
- package/tab/definition.cjs +6 -127
- package/tab/definition.js +2 -120
- package/tab/index.cjs +1 -1
- package/tab/index.js +6 -2
- package/tab-panel/definition.cjs +5 -29
- package/tab-panel/definition.js +1 -22
- package/tab-panel/index.cjs +1 -1
- package/tab-panel/index.js +5 -2
- package/table/definition.cjs +18 -174
- package/table/definition.js +3 -158
- package/table/index.cjs +19 -10
- package/table/index.js +74 -82
- package/tabs/definition.cjs +7 -467
- package/tabs/definition.js +2 -459
- package/tabs/index.cjs +11 -11
- package/tabs/index.js +169 -296
- package/tag/definition.cjs +6 -176
- package/tag/definition.js +2 -169
- package/tag/index.cjs +26 -26
- package/tag/index.js +64 -125
- package/tag-group/definition.cjs +5 -40
- package/tag-group/definition.js +1 -33
- package/tag-group/index.cjs +4 -4
- package/tag-group/index.js +10 -21
- package/text-area/definition.cjs +6 -355
- package/text-area/definition.js +2 -348
- package/text-area/index.cjs +11 -11
- package/text-area/index.js +153 -260
- package/text-field/definition.cjs +6 -423
- package/text-field/definition.js +2 -416
- package/text-field/index.cjs +1 -1
- package/text-field/index.js +6 -2
- package/time-picker/definition.cjs +7 -43
- package/time-picker/definition.js +3 -36
- package/time-picker/index.cjs +1 -1
- package/time-picker/index.js +24 -29
- package/toggletip/definition.cjs +6 -159
- package/toggletip/definition.js +2 -152
- package/toggletip/index.cjs +1 -1
- package/toggletip/index.js +6 -2
- package/tooltip/definition.cjs +6 -139
- package/tooltip/definition.js +2 -132
- package/tooltip/index.cjs +1 -1
- package/tooltip/index.js +6 -2
- package/tree-item/definition.cjs +6 -13
- package/tree-item/definition.js +3 -3
- package/tree-item/index.cjs +1 -1
- package/tree-item/index.js +6 -2
- package/tree-view/definition.cjs +6 -302
- package/tree-view/definition.js +2 -295
- package/tree-view/index.cjs +11 -11
- package/tree-view/index.js +145 -174
- package/unbundled/affix.cjs +89 -62
- package/unbundled/affix.js +58 -55
- package/unbundled/anchored.cjs +87 -94
- package/unbundled/anchored.js +74 -90
- package/unbundled/attribute-binding-behaviour.cjs +37 -42
- package/unbundled/attribute-binding-behaviour.js +31 -40
- package/unbundled/base-color-picker.cjs +226 -275
- package/unbundled/base-color-picker.js +214 -272
- package/unbundled/base-progress.cjs +63 -78
- package/unbundled/base-progress.js +57 -76
- package/unbundled/breadcrumb-item.cjs +24 -28
- package/unbundled/breadcrumb-item.js +18 -26
- package/unbundled/button.cjs +115 -166
- package/unbundled/button.js +109 -164
- package/unbundled/calendar-event.cjs +28 -41
- package/unbundled/calendar-event.js +22 -39
- package/unbundled/calendar-picker.template.cjs +4967 -792
- package/unbundled/calendar-picker.template.js +4907 -781
- package/unbundled/char-count.cjs +50 -80
- package/unbundled/char-count.js +44 -78
- package/unbundled/chunk.cjs +28 -0
- package/unbundled/data-grid.options.cjs +80 -29
- package/unbundled/data-grid.options.js +51 -23
- package/unbundled/decorate.cjs +14 -0
- package/unbundled/decorate.js +9 -0
- package/unbundled/definition.cjs +42 -405
- package/unbundled/definition.js +24 -399
- package/unbundled/definition10.cjs +253 -0
- package/unbundled/definition10.js +229 -0
- package/unbundled/definition11.cjs +397 -0
- package/unbundled/definition11.js +379 -0
- package/unbundled/definition12.cjs +317 -0
- package/unbundled/definition12.js +287 -0
- package/unbundled/definition13.cjs +321 -0
- package/unbundled/definition13.js +303 -0
- package/unbundled/definition14.cjs +406 -0
- package/unbundled/definition14.js +388 -0
- package/unbundled/definition15.cjs +107 -0
- package/unbundled/definition15.js +89 -0
- package/unbundled/definition16.cjs +63 -0
- package/unbundled/definition16.js +45 -0
- package/unbundled/definition17.cjs +151 -0
- package/unbundled/definition17.js +133 -0
- package/unbundled/definition18.cjs +47 -0
- package/unbundled/definition18.js +35 -0
- package/unbundled/definition19.cjs +98 -0
- package/unbundled/definition19.js +80 -0
- package/unbundled/definition2.cjs +180 -220
- package/unbundled/definition2.js +162 -215
- package/unbundled/definition20.cjs +56 -0
- package/unbundled/definition20.js +43 -0
- package/unbundled/definition21.cjs +304 -0
- package/unbundled/definition21.js +285 -0
- package/unbundled/definition22.cjs +179 -0
- package/unbundled/definition22.js +161 -0
- package/unbundled/definition23.cjs +161 -0
- package/unbundled/definition23.js +143 -0
- package/unbundled/definition24.cjs +157 -0
- package/unbundled/definition24.js +139 -0
- package/unbundled/definition25.cjs +75 -0
- package/unbundled/definition25.js +57 -0
- package/unbundled/definition26.cjs +363 -0
- package/unbundled/definition26.js +345 -0
- package/unbundled/definition27.cjs +137 -0
- package/unbundled/definition27.js +119 -0
- package/unbundled/definition28.cjs +538 -0
- package/unbundled/definition28.js +520 -0
- package/unbundled/definition29.cjs +236 -0
- package/unbundled/definition29.js +212 -0
- package/unbundled/definition3.cjs +131 -284
- package/unbundled/definition3.js +113 -279
- package/unbundled/definition30.cjs +559 -0
- package/unbundled/definition30.js +541 -0
- package/unbundled/definition31.cjs +1265 -0
- package/unbundled/definition31.js +1247 -0
- package/unbundled/definition32.cjs +1908 -0
- package/unbundled/definition32.js +1866 -0
- package/unbundled/definition33.cjs +346 -0
- package/unbundled/definition33.js +256 -0
- package/unbundled/definition34.cjs +46 -0
- package/unbundled/definition34.js +33 -0
- package/unbundled/definition35.cjs +152 -0
- package/unbundled/definition35.js +134 -0
- package/unbundled/definition36.cjs +426 -0
- package/unbundled/definition36.js +408 -0
- package/unbundled/definition37.cjs +247 -0
- package/unbundled/definition37.js +229 -0
- package/unbundled/definition38.cjs +411 -0
- package/unbundled/definition38.js +393 -0
- package/unbundled/definition39.cjs +299 -0
- package/unbundled/definition39.js +281 -0
- package/unbundled/definition4.cjs +186 -205
- package/unbundled/definition4.js +162 -200
- package/unbundled/definition40.cjs +81 -0
- package/unbundled/definition40.js +63 -0
- package/unbundled/definition41.cjs +100 -0
- package/unbundled/definition41.js +82 -0
- package/unbundled/definition42.cjs +468 -0
- package/unbundled/definition42.js +450 -0
- package/unbundled/definition43.cjs +86 -0
- package/unbundled/definition43.js +68 -0
- package/unbundled/definition44.cjs +60 -0
- package/unbundled/definition44.js +41 -0
- package/unbundled/definition45.cjs +124 -0
- package/unbundled/definition45.js +106 -0
- package/unbundled/definition46.cjs +85 -0
- package/unbundled/definition46.js +67 -0
- package/unbundled/definition47.cjs +52 -0
- package/unbundled/definition47.js +31 -0
- package/unbundled/definition48.cjs +69 -0
- package/unbundled/definition48.js +51 -0
- package/unbundled/definition49.cjs +377 -0
- package/unbundled/definition49.js +359 -0
- package/unbundled/definition5.cjs +69 -298
- package/unbundled/definition5.js +44 -293
- package/unbundled/definition50.cjs +246 -0
- package/unbundled/definition50.js +228 -0
- package/unbundled/definition51.cjs +337 -0
- package/unbundled/definition51.js +319 -0
- package/unbundled/definition52.cjs +86 -0
- package/unbundled/definition52.js +67 -0
- package/unbundled/definition53.cjs +193 -0
- package/unbundled/definition53.js +174 -0
- package/unbundled/definition54.cjs +297 -0
- package/unbundled/definition54.js +279 -0
- package/unbundled/definition55.cjs +510 -0
- package/unbundled/definition55.js +492 -0
- package/unbundled/definition56.cjs +3659 -0
- package/unbundled/definition56.js +3478 -0
- package/unbundled/definition57.cjs +837 -0
- package/unbundled/definition57.js +819 -0
- package/unbundled/definition58.cjs +147 -0
- package/unbundled/definition58.js +129 -0
- package/unbundled/definition59.cjs +1081 -0
- package/unbundled/definition59.js +1063 -0
- package/unbundled/definition6.cjs +88 -56
- package/unbundled/definition6.js +69 -52
- package/unbundled/definition60.cjs +149 -0
- package/unbundled/definition60.js +131 -0
- package/unbundled/definition61.cjs +116 -0
- package/unbundled/definition61.js +97 -0
- package/unbundled/definition62.cjs +213 -0
- package/unbundled/definition62.js +195 -0
- package/unbundled/definition63.cjs +159 -0
- package/unbundled/definition63.js +141 -0
- package/unbundled/definition64.cjs +86 -0
- package/unbundled/definition64.js +68 -0
- package/unbundled/definition65.cjs +126 -0
- package/unbundled/definition65.js +107 -0
- package/unbundled/definition66.cjs +49 -0
- package/unbundled/definition66.js +28 -0
- package/unbundled/definition67.cjs +119 -0
- package/unbundled/definition67.js +101 -0
- package/unbundled/definition68.cjs +374 -0
- package/unbundled/definition68.js +349 -0
- package/unbundled/definition69.cjs +57 -0
- package/unbundled/definition69.js +38 -0
- package/unbundled/definition7.cjs +190 -0
- package/unbundled/definition7.js +166 -0
- package/unbundled/definition70.cjs +155 -0
- package/unbundled/definition70.js +137 -0
- package/unbundled/definition71.cjs +302 -0
- package/unbundled/definition71.js +284 -0
- package/unbundled/definition72.cjs +48 -0
- package/unbundled/definition72.js +37 -0
- package/unbundled/definition73.cjs +171 -0
- package/unbundled/definition73.js +147 -0
- package/unbundled/definition74.cjs +232 -0
- package/unbundled/definition74.js +213 -0
- package/unbundled/definition75.cjs +533 -0
- package/unbundled/definition75.js +513 -0
- package/unbundled/definition8.cjs +63 -0
- package/unbundled/definition8.js +44 -0
- package/unbundled/definition9.cjs +183 -0
- package/unbundled/definition9.js +165 -0
- package/unbundled/delegates-aria.cjs +90 -131
- package/unbundled/delegates-aria.js +77 -127
- package/unbundled/dialog.cjs +15 -0
- package/unbundled/dialog.js +10 -0
- package/unbundled/divider.cjs +42 -50
- package/unbundled/divider.js +30 -47
- package/unbundled/enums.cjs +166 -107
- package/unbundled/enums.js +95 -94
- package/unbundled/form-associated.cjs +408 -463
- package/unbundled/form-associated.js +396 -460
- package/unbundled/form-element.cjs +74 -83
- package/unbundled/form-element.js +68 -81
- package/unbundled/host-semantics.cjs +70 -89
- package/unbundled/host-semantics.js +57 -85
- package/unbundled/key-codes.cjs +16 -10
- package/unbundled/key-codes.js +5 -7
- package/unbundled/linkable.cjs +35 -56
- package/unbundled/linkable.js +27 -52
- package/unbundled/listbox.cjs +363 -465
- package/unbundled/listbox.js +357 -463
- package/unbundled/localized.cjs +79 -74
- package/unbundled/localized.js +61 -70
- package/unbundled/mixins.cjs +222 -223
- package/unbundled/mixins.js +186 -211
- package/unbundled/picker-field.template.cjs +188 -217
- package/unbundled/picker-field.template.js +165 -208
- package/unbundled/playbackRates.cjs +18 -11
- package/unbundled/playbackRates.js +13 -9
- package/unbundled/scrollIntoView.cjs +38 -43
- package/unbundled/scrollIntoView.js +33 -41
- package/unbundled/single-date-picker.cjs +48 -45
- package/unbundled/single-date-picker.js +43 -43
- package/unbundled/single-value-picker.cjs +106 -114
- package/unbundled/single-value-picker.js +101 -112
- package/unbundled/slider.template.cjs +107 -73
- package/unbundled/slider.template.js +67 -62
- package/unbundled/slottable-request.cjs +145 -3700
- package/unbundled/slottable-request.js +98 -3681
- package/unbundled/text-field.cjs +9 -5
- package/unbundled/text-field.js +4 -3
- package/unbundled/time-selection-picker.template.cjs +611 -755
- package/unbundled/time-selection-picker.template.js +554 -742
- package/unbundled/trapped-focus.cjs +45 -35
- package/unbundled/trapped-focus.js +34 -32
- package/unbundled/vivid-element.cjs +281 -274
- package/unbundled/vivid-element.js +239 -266
- package/unbundled/with-contextual-help.cjs +35 -39
- package/unbundled/with-contextual-help.js +29 -37
- package/unbundled/with-error-text.cjs +45 -55
- package/unbundled/with-error-text.js +39 -53
- package/unbundled/with-success-text.cjs +18 -22
- package/unbundled/with-success-text.js +12 -20
- package/video-player/definition.cjs +5 -69835
- package/video-player/definition.js +1 -69828
- package/video-player/index.cjs +44 -39
- package/video-player/index.js +23517 -35507
- package/visually-hidden/definition.cjs +5 -30
- package/visually-hidden/definition.js +1 -23
- package/visually-hidden/index.cjs +1 -1
- package/visually-hidden/index.js +5 -2
- package/vivid.api.json +331 -1874
- package/bundled/index.cjs +0 -1
- package/bundled/index.js +0 -6
- package/unbundled/_commonjsHelpers.cjs +0 -40
- package/unbundled/_commonjsHelpers.js +0 -36
- package/unbundled/index.cjs +0 -11
- package/unbundled/index.js +0 -9
|
@@ -1,1175 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const icon_definition = require('../icon/definition.cjs');
|
|
8
|
-
const mixins = require('../unbundled/mixins.cjs');
|
|
9
|
-
const fastElement = require('@microsoft/fast-element');
|
|
10
|
-
const delegatesAria = require('../unbundled/delegates-aria.cjs');
|
|
11
|
-
const index = require('../unbundled/index.cjs');
|
|
12
|
-
const withContextualHelp = require('../unbundled/with-contextual-help.cjs');
|
|
13
|
-
const trappedFocus = require('../unbundled/trapped-focus.cjs');
|
|
14
|
-
const baseColorPicker = require('../unbundled/base-color-picker.cjs');
|
|
15
|
-
const withErrorText = require('../unbundled/with-error-text.cjs');
|
|
16
|
-
const withSuccessText = require('../unbundled/with-success-text.cjs');
|
|
17
|
-
const fastWebUtilities = require('@microsoft/fast-web-utilities');
|
|
18
|
-
const textField_definition = require('../text-field/definition.cjs');
|
|
19
|
-
const button_definition = require('../unbundled/definition2.cjs');
|
|
20
|
-
const tooltip_definition = require('../tooltip/definition.cjs');
|
|
21
|
-
|
|
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(--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;--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(--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(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(--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){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)}";
|
|
23
|
-
|
|
24
|
-
// Clamps a value between an upper and lower bound.
|
|
25
|
-
// We use ternary operators because it makes the minified code
|
|
26
|
-
// 2 times shorter then `Math.min(Math.max(a,b),c)`
|
|
27
|
-
const clamp = (number, min = 0, max = 1) => {
|
|
28
|
-
return number > max ? max : number < min ? min : number;
|
|
29
|
-
};
|
|
30
|
-
const round = (number, digits = 0, base = Math.pow(10, digits)) => {
|
|
31
|
-
return Math.round(base * number) / base;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const hexToHsva = (hex) => rgbaToHsva(hexToRgba(hex));
|
|
35
|
-
const hexToRgba = (hex) => {
|
|
36
|
-
if (hex[0] === '#')
|
|
37
|
-
hex = hex.substring(1);
|
|
38
|
-
if (hex.length < 6) {
|
|
39
|
-
return {
|
|
40
|
-
r: parseInt(hex[0] + hex[0], 16),
|
|
41
|
-
g: parseInt(hex[1] + hex[1], 16),
|
|
42
|
-
b: parseInt(hex[2] + hex[2], 16),
|
|
43
|
-
a: hex.length === 4 ? round(parseInt(hex[3] + hex[3], 16) / 255, 2) : 1
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
r: parseInt(hex.substring(0, 2), 16),
|
|
48
|
-
g: parseInt(hex.substring(2, 4), 16),
|
|
49
|
-
b: parseInt(hex.substring(4, 6), 16),
|
|
50
|
-
a: hex.length === 8 ? round(parseInt(hex.substring(6, 8), 16) / 255, 2) : 1
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
const hsvaToHex = (hsva) => rgbaToHex(hsvaToRgba(hsva));
|
|
54
|
-
const hsvaToHsla = ({ h, s, v, a }) => {
|
|
55
|
-
const hh = ((200 - s) * v) / 100;
|
|
56
|
-
return {
|
|
57
|
-
h: round(h),
|
|
58
|
-
s: round(hh > 0 && hh < 200 ? ((s * v) / 100 / (hh <= 100 ? hh : 200 - hh)) * 100 : 0),
|
|
59
|
-
l: round(hh / 2),
|
|
60
|
-
a: round(a, 2)
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const hsvaToHslString = (hsva) => {
|
|
64
|
-
const { h, s, l } = hsvaToHsla(hsva);
|
|
65
|
-
return `hsl(${h}, ${s}%, ${l}%)`;
|
|
66
|
-
};
|
|
67
|
-
const hsvaToRgba = ({ h, s, v, a }) => {
|
|
68
|
-
h = (h / 360) * 6;
|
|
69
|
-
s = s / 100;
|
|
70
|
-
v = v / 100;
|
|
71
|
-
const hh = Math.floor(h), b = v * (1 - s), c = v * (1 - (h - hh) * s), d = v * (1 - (1 - h + hh) * s), module = hh % 6;
|
|
72
|
-
return {
|
|
73
|
-
r: round([v, c, b, b, d, v][module] * 255),
|
|
74
|
-
g: round([d, v, v, c, b, b][module] * 255),
|
|
75
|
-
b: round([b, b, d, v, v, c][module] * 255),
|
|
76
|
-
a: round(a, 2)
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
const format = (number) => {
|
|
80
|
-
const hex = number.toString(16);
|
|
81
|
-
return hex.length < 2 ? '0' + hex : hex;
|
|
82
|
-
};
|
|
83
|
-
const rgbaToHex = ({ r, g, b, a }) => {
|
|
84
|
-
const alphaHex = a < 1 ? format(round(a * 255)) : '';
|
|
85
|
-
return '#' + format(r) + format(g) + format(b) + alphaHex;
|
|
86
|
-
};
|
|
87
|
-
const rgbaToHsva = ({ r, g, b, a }) => {
|
|
88
|
-
const max = Math.max(r, g, b);
|
|
89
|
-
const delta = max - Math.min(r, g, b);
|
|
90
|
-
// prettier-ignore
|
|
91
|
-
const hh = delta
|
|
92
|
-
? max === r
|
|
93
|
-
? (g - b) / delta
|
|
94
|
-
: max === g
|
|
95
|
-
? 2 + (b - r) / delta
|
|
96
|
-
: 4 + (r - g) / delta
|
|
97
|
-
: 0;
|
|
98
|
-
return {
|
|
99
|
-
h: round(60 * (hh < 0 ? hh + 6 : hh)),
|
|
100
|
-
s: round(max ? (delta / max) * 100 : 0),
|
|
101
|
-
v: round((max / 255) * 100),
|
|
102
|
-
a
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const equalColorObjects = (first, second) => {
|
|
107
|
-
if (first === second)
|
|
108
|
-
return true;
|
|
109
|
-
for (const prop in first) {
|
|
110
|
-
// The following allows for a type-safe calling of this function (first & second have to be HSL, HSV, or RGB)
|
|
111
|
-
// with type-unsafe iterating over object keys. TS does not allow this without an index (`[key: string]: number`)
|
|
112
|
-
// on an object to define how iteration is normally done. To ensure extra keys are not allowed on our types,
|
|
113
|
-
// we must cast our object to unknown (as RGB demands `r` be a key, while `Record<string, x>` does not care if
|
|
114
|
-
// there is or not), and then as a type TS can iterate over.
|
|
115
|
-
if (first[prop] !==
|
|
116
|
-
second[prop])
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
};
|
|
121
|
-
const equalHex = (first, second) => {
|
|
122
|
-
if (first.toLowerCase() === second.toLowerCase())
|
|
123
|
-
return true;
|
|
124
|
-
// To compare colors like `#FFF` and `ffffff` we convert them into RGB objects
|
|
125
|
-
return equalColorObjects(hexToRgba(first), hexToRgba(second));
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const cache = {};
|
|
129
|
-
const tpl = (html) => {
|
|
130
|
-
let template = cache[html];
|
|
131
|
-
if (!template) {
|
|
132
|
-
template = document.createElement('template');
|
|
133
|
-
template.innerHTML = html;
|
|
134
|
-
cache[html] = template;
|
|
135
|
-
}
|
|
136
|
-
return template;
|
|
137
|
-
};
|
|
138
|
-
const fire = (target, type, detail) => {
|
|
139
|
-
target.dispatchEvent(new CustomEvent(type, {
|
|
140
|
-
bubbles: true,
|
|
141
|
-
detail
|
|
142
|
-
}));
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
let hasTouched = false;
|
|
146
|
-
// Check if an event was triggered by touch
|
|
147
|
-
const isTouch = (e) => 'touches' in e;
|
|
148
|
-
// Prevent mobile browsers from handling mouse events (conflicting with touch ones).
|
|
149
|
-
// If we detected a touch interaction before, we prefer reacting to touch events only.
|
|
150
|
-
const isValid = (event) => {
|
|
151
|
-
if (hasTouched && !isTouch(event))
|
|
152
|
-
return false;
|
|
153
|
-
if (!hasTouched)
|
|
154
|
-
hasTouched = isTouch(event);
|
|
155
|
-
return true;
|
|
156
|
-
};
|
|
157
|
-
const pointerMove = (target, event) => {
|
|
158
|
-
const pointer = isTouch(event) ? event.touches[0] : event;
|
|
159
|
-
const rect = target.el.getBoundingClientRect();
|
|
160
|
-
fire(target.el, 'move', target.getMove({
|
|
161
|
-
x: clamp((pointer.pageX - (rect.left + window.pageXOffset)) / rect.width),
|
|
162
|
-
y: clamp((pointer.pageY - (rect.top + window.pageYOffset)) / rect.height)
|
|
163
|
-
}));
|
|
164
|
-
};
|
|
165
|
-
const keyMove = (target, event) => {
|
|
166
|
-
// We use `keyCode` instead of `key` to reduce the size of the library.
|
|
167
|
-
const keyCode = event.keyCode;
|
|
168
|
-
// Ignore all keys except arrow ones, Page Up, Page Down, Home and End.
|
|
169
|
-
if (keyCode > 40 || (target.xy && keyCode < 37) || keyCode < 33)
|
|
170
|
-
return;
|
|
171
|
-
// Do not scroll page by keys when color picker element has focus.
|
|
172
|
-
event.preventDefault();
|
|
173
|
-
// Send relative offset to the parent component.
|
|
174
|
-
fire(target.el, 'move', target.getMove({
|
|
175
|
-
x: keyCode === 39 // Arrow Right
|
|
176
|
-
? 0.01
|
|
177
|
-
: keyCode === 37 // Arrow Left
|
|
178
|
-
? -0.01
|
|
179
|
-
: keyCode === 34 // Page Down
|
|
180
|
-
? 0.05
|
|
181
|
-
: keyCode === 33 // Page Up
|
|
182
|
-
? -0.05
|
|
183
|
-
: keyCode === 35 // End
|
|
184
|
-
? 1
|
|
185
|
-
: keyCode === 36 // Home
|
|
186
|
-
? -1
|
|
187
|
-
: 0,
|
|
188
|
-
y: keyCode === 40 // Arrow down
|
|
189
|
-
? 0.01
|
|
190
|
-
: keyCode === 38 // Arrow Up
|
|
191
|
-
? -0.01
|
|
192
|
-
: 0
|
|
193
|
-
}, true));
|
|
194
|
-
};
|
|
195
|
-
class Slider {
|
|
196
|
-
constructor(root, part, aria, xy) {
|
|
197
|
-
const template = tpl(`<div role="slider" tabindex="0" part="${part}" ${aria}><div part="${part}-pointer"></div></div>`);
|
|
198
|
-
root.appendChild(template.content.cloneNode(true));
|
|
199
|
-
const el = root.querySelector(`[part=${part}]`);
|
|
200
|
-
el.addEventListener('mousedown', this);
|
|
201
|
-
el.addEventListener('touchstart', this);
|
|
202
|
-
el.addEventListener('keydown', this);
|
|
203
|
-
this.el = el;
|
|
204
|
-
this.xy = xy;
|
|
205
|
-
this.nodes = [el.firstChild, el];
|
|
206
|
-
}
|
|
207
|
-
set dragging(state) {
|
|
208
|
-
const toggleEvent = state ? document.addEventListener : document.removeEventListener;
|
|
209
|
-
toggleEvent(hasTouched ? 'touchmove' : 'mousemove', this);
|
|
210
|
-
toggleEvent(hasTouched ? 'touchend' : 'mouseup', this);
|
|
211
|
-
}
|
|
212
|
-
handleEvent(event) {
|
|
213
|
-
switch (event.type) {
|
|
214
|
-
case 'mousedown':
|
|
215
|
-
case 'touchstart':
|
|
216
|
-
event.preventDefault();
|
|
217
|
-
// event.button is 0 in mousedown for left button activation
|
|
218
|
-
if (!isValid(event) || (!hasTouched && event.button != 0))
|
|
219
|
-
return;
|
|
220
|
-
this.el.focus();
|
|
221
|
-
pointerMove(this, event);
|
|
222
|
-
this.dragging = true;
|
|
223
|
-
break;
|
|
224
|
-
case 'mousemove':
|
|
225
|
-
case 'touchmove':
|
|
226
|
-
event.preventDefault();
|
|
227
|
-
pointerMove(this, event);
|
|
228
|
-
break;
|
|
229
|
-
case 'mouseup':
|
|
230
|
-
case 'touchend':
|
|
231
|
-
this.dragging = false;
|
|
232
|
-
break;
|
|
233
|
-
case 'keydown':
|
|
234
|
-
keyMove(this, event);
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
style(styles) {
|
|
239
|
-
styles.forEach((style, i) => {
|
|
240
|
-
for (const p in style) {
|
|
241
|
-
this.nodes[i].style.setProperty(p, style[p]);
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
class Hue extends Slider {
|
|
248
|
-
constructor(root) {
|
|
249
|
-
super(root, 'hue', 'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"', false);
|
|
250
|
-
}
|
|
251
|
-
update({ h }) {
|
|
252
|
-
this.h = h;
|
|
253
|
-
this.style([
|
|
254
|
-
{
|
|
255
|
-
left: `${(h / 360) * 100}%`,
|
|
256
|
-
color: hsvaToHslString({ h, s: 100, v: 100, a: 1 })
|
|
257
|
-
}
|
|
258
|
-
]);
|
|
259
|
-
this.el.setAttribute('aria-valuenow', `${round(h)}`);
|
|
260
|
-
}
|
|
261
|
-
getMove(offset, key) {
|
|
262
|
-
// Hue measured in degrees of the color circle ranging from 0 to 360
|
|
263
|
-
return { h: key ? clamp(this.h + offset.x * 360, 0, 360) : 360 * offset.x };
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
class Saturation extends Slider {
|
|
268
|
-
constructor(root) {
|
|
269
|
-
super(root, 'saturation', 'aria-label="Color"', true);
|
|
270
|
-
}
|
|
271
|
-
update(hsva) {
|
|
272
|
-
this.hsva = hsva;
|
|
273
|
-
this.style([
|
|
274
|
-
{
|
|
275
|
-
top: `${100 - hsva.v}%`,
|
|
276
|
-
left: `${hsva.s}%`,
|
|
277
|
-
color: hsvaToHslString(hsva)
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
'background-color': hsvaToHslString({ h: hsva.h, s: 100, v: 100, a: 1 })
|
|
281
|
-
}
|
|
282
|
-
]);
|
|
283
|
-
this.el.setAttribute('aria-valuetext', `Saturation ${round(hsva.s)}%, Brightness ${round(hsva.v)}%`);
|
|
284
|
-
}
|
|
285
|
-
getMove(offset, key) {
|
|
286
|
-
// Saturation and brightness always fit into [0, 100] range
|
|
287
|
-
return {
|
|
288
|
-
s: key ? clamp(this.hsva.s + offset.x * 100, 0, 100) : offset.x * 100,
|
|
289
|
-
v: key ? clamp(this.hsva.v - offset.y * 100, 0, 100) : Math.round(100 - offset.y * 100)
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const css = `:host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}`;
|
|
295
|
-
|
|
296
|
-
const hueCss = `[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}`;
|
|
297
|
-
|
|
298
|
-
const saturationCss = `[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}`;
|
|
299
|
-
|
|
300
|
-
const $isSame = Symbol('same');
|
|
301
|
-
const $color$1 = Symbol('color');
|
|
302
|
-
const $hsva = Symbol('hsva');
|
|
303
|
-
const $update$1 = Symbol('update');
|
|
304
|
-
const $parts = Symbol('parts');
|
|
305
|
-
const $css = Symbol('css');
|
|
306
|
-
const $sliders = Symbol('sliders');
|
|
307
|
-
let ColorPicker$1 = class ColorPicker extends HTMLElement {
|
|
308
|
-
static get observedAttributes() {
|
|
309
|
-
return ['color'];
|
|
310
|
-
}
|
|
311
|
-
get [$css]() {
|
|
312
|
-
return [css, hueCss, saturationCss];
|
|
313
|
-
}
|
|
314
|
-
get [$sliders]() {
|
|
315
|
-
return [Saturation, Hue];
|
|
316
|
-
}
|
|
317
|
-
get color() {
|
|
318
|
-
return this[$color$1];
|
|
319
|
-
}
|
|
320
|
-
set color(newColor) {
|
|
321
|
-
if (!this[$isSame](newColor)) {
|
|
322
|
-
const newHsva = this.colorModel.toHsva(newColor);
|
|
323
|
-
this[$update$1](newHsva);
|
|
324
|
-
this[$color$1] = newColor;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
constructor() {
|
|
328
|
-
super();
|
|
329
|
-
const template = tpl(`<style>${this[$css].join('')}</style>`);
|
|
330
|
-
const root = this.attachShadow({ mode: 'open' });
|
|
331
|
-
root.appendChild(template.content.cloneNode(true));
|
|
332
|
-
root.addEventListener('move', this);
|
|
333
|
-
this[$parts] = this[$sliders].map((slider) => new slider(root));
|
|
334
|
-
}
|
|
335
|
-
connectedCallback() {
|
|
336
|
-
// A user may set a property on an _instance_ of an element,
|
|
337
|
-
// before its prototype has been connected to this class.
|
|
338
|
-
// If so, we need to run it through the proper class setter.
|
|
339
|
-
if (this.hasOwnProperty('color')) {
|
|
340
|
-
const value = this.color;
|
|
341
|
-
delete this['color'];
|
|
342
|
-
this.color = value;
|
|
343
|
-
}
|
|
344
|
-
else if (!this.color) {
|
|
345
|
-
this.color = this.colorModel.defaultColor;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
attributeChangedCallback(_attr, _oldVal, newVal) {
|
|
349
|
-
const color = this.colorModel.fromAttr(newVal);
|
|
350
|
-
if (!this[$isSame](color)) {
|
|
351
|
-
this.color = color;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
handleEvent(event) {
|
|
355
|
-
// Merge the current HSV color object with updated params.
|
|
356
|
-
const oldHsva = this[$hsva];
|
|
357
|
-
const newHsva = { ...oldHsva, ...event.detail };
|
|
358
|
-
this[$update$1](newHsva);
|
|
359
|
-
let newColor;
|
|
360
|
-
if (!equalColorObjects(newHsva, oldHsva) &&
|
|
361
|
-
!this[$isSame]((newColor = this.colorModel.fromHsva(newHsva)))) {
|
|
362
|
-
this[$color$1] = newColor;
|
|
363
|
-
fire(this, 'color-changed', { value: newColor });
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
[$isSame](color) {
|
|
367
|
-
return this.color && this.colorModel.equal(color, this.color);
|
|
368
|
-
}
|
|
369
|
-
[$update$1](hsva) {
|
|
370
|
-
this[$hsva] = hsva;
|
|
371
|
-
this[$parts].forEach((part) => part.update(hsva));
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
const colorModel = {
|
|
376
|
-
defaultColor: '#000',
|
|
377
|
-
toHsva: hexToHsva,
|
|
378
|
-
fromHsva: ({ h, s, v }) => hsvaToHex({ h, s, v, a: 1 }),
|
|
379
|
-
equal: equalHex,
|
|
380
|
-
fromAttr: (color) => color
|
|
381
|
-
};
|
|
382
|
-
class HexBase extends ColorPicker$1 {
|
|
383
|
-
get colorModel() {
|
|
384
|
-
return colorModel;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* A color picker custom element that uses HEX format.
|
|
390
|
-
*
|
|
391
|
-
* @element hex-color-picker
|
|
392
|
-
*
|
|
393
|
-
* @prop {string} color - Selected color in HEX format.
|
|
394
|
-
* @attr {string} color - Selected color in HEX format.
|
|
395
|
-
*
|
|
396
|
-
* @fires color-changed - Event fired when color property changes.
|
|
397
|
-
*
|
|
398
|
-
* @csspart hue - A hue selector container.
|
|
399
|
-
* @csspart saturation - A saturation selector container
|
|
400
|
-
* @csspart hue-pointer - A hue pointer element.
|
|
401
|
-
* @csspart saturation-pointer - A saturation pointer element.
|
|
402
|
-
*/
|
|
403
|
-
class HexColorPicker extends HexBase {
|
|
404
|
-
}
|
|
405
|
-
customElements.define('hex-color-picker', HexColorPicker);
|
|
406
|
-
|
|
407
|
-
const matcher = /^#?([0-9A-F]{3,8})$/i;
|
|
408
|
-
const validHex = (value, alpha) => {
|
|
409
|
-
const match = matcher.exec(value);
|
|
410
|
-
const length = match ? match[1].length : 0;
|
|
411
|
-
return (length === 3 || // '#rgb' format
|
|
412
|
-
length === 6 || // '#rrggbb' format
|
|
413
|
-
(!!alpha && length === 4) || // '#rgba' format
|
|
414
|
-
(!!alpha && length === 8) // '#rrggbbaa' format
|
|
415
|
-
);
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
const template = tpl('<slot><input part="input" spellcheck="false"></slot>');
|
|
419
|
-
// Escapes all non-hexadecimal characters including "#"
|
|
420
|
-
const escape = (hex, alpha) => hex.replace(/([^0-9A-F]+)/gi, '').substring(0, alpha ? 8 : 6);
|
|
421
|
-
const $alpha = Symbol('alpha');
|
|
422
|
-
const $color = Symbol('color');
|
|
423
|
-
const $saved = Symbol('saved');
|
|
424
|
-
const $input = Symbol('input');
|
|
425
|
-
const $init = Symbol('init');
|
|
426
|
-
const $prefix = Symbol('prefix');
|
|
427
|
-
const $update = Symbol('update');
|
|
428
|
-
class HexInputBase extends HTMLElement {
|
|
429
|
-
static get observedAttributes() {
|
|
430
|
-
return ['alpha', 'color', 'prefixed'];
|
|
431
|
-
}
|
|
432
|
-
get color() {
|
|
433
|
-
return this[$color];
|
|
434
|
-
}
|
|
435
|
-
set color(hex) {
|
|
436
|
-
this[$color] = hex;
|
|
437
|
-
this[$update](hex);
|
|
438
|
-
}
|
|
439
|
-
get alpha() {
|
|
440
|
-
return this[$alpha];
|
|
441
|
-
}
|
|
442
|
-
set alpha(alpha) {
|
|
443
|
-
this[$alpha] = alpha;
|
|
444
|
-
this.toggleAttribute('alpha', alpha);
|
|
445
|
-
// When alpha set to false, update color
|
|
446
|
-
const color = this.color;
|
|
447
|
-
if (color && !validHex(color, alpha)) {
|
|
448
|
-
this.color = color.startsWith('#')
|
|
449
|
-
? color.substring(0, color.length === 5 ? 4 : 7)
|
|
450
|
-
: color.substring(0, color.length === 4 ? 3 : 6);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
get prefixed() {
|
|
454
|
-
return this[$prefix];
|
|
455
|
-
}
|
|
456
|
-
set prefixed(prefixed) {
|
|
457
|
-
this[$prefix] = prefixed;
|
|
458
|
-
this.toggleAttribute('prefixed', prefixed);
|
|
459
|
-
this[$update](this.color);
|
|
460
|
-
}
|
|
461
|
-
constructor() {
|
|
462
|
-
super();
|
|
463
|
-
const root = this.attachShadow({ mode: 'open' });
|
|
464
|
-
root.appendChild(template.content.cloneNode(true));
|
|
465
|
-
const slot = root.firstElementChild;
|
|
466
|
-
slot.addEventListener('slotchange', () => this[$init](root));
|
|
467
|
-
}
|
|
468
|
-
connectedCallback() {
|
|
469
|
-
this[$init](this.shadowRoot);
|
|
470
|
-
// A user may set a property on an _instance_ of an element,
|
|
471
|
-
// before its prototype has been connected to this class.
|
|
472
|
-
// If so, we need to run it through the proper class setter.
|
|
473
|
-
if (this.hasOwnProperty('alpha')) {
|
|
474
|
-
const value = this.alpha;
|
|
475
|
-
delete this['alpha'];
|
|
476
|
-
this.alpha = value;
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
this.alpha = this.hasAttribute('alpha');
|
|
480
|
-
}
|
|
481
|
-
if (this.hasOwnProperty('prefixed')) {
|
|
482
|
-
const value = this.prefixed;
|
|
483
|
-
delete this['prefixed'];
|
|
484
|
-
this.prefixed = value;
|
|
485
|
-
}
|
|
486
|
-
else {
|
|
487
|
-
this.prefixed = this.hasAttribute('prefixed');
|
|
488
|
-
}
|
|
489
|
-
if (this.hasOwnProperty('color')) {
|
|
490
|
-
const value = this.color;
|
|
491
|
-
delete this['color'];
|
|
492
|
-
this.color = value;
|
|
493
|
-
}
|
|
494
|
-
else if (this.color == null) {
|
|
495
|
-
this.color = this.getAttribute('color') || '';
|
|
496
|
-
}
|
|
497
|
-
else if (this[$color]) {
|
|
498
|
-
this[$update](this[$color]);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
handleEvent(event) {
|
|
502
|
-
const target = event.target;
|
|
503
|
-
const { value } = target;
|
|
504
|
-
switch (event.type) {
|
|
505
|
-
case 'input':
|
|
506
|
-
const hex = escape(value, this.alpha);
|
|
507
|
-
this[$saved] = this.color;
|
|
508
|
-
if (validHex(hex, this.alpha) || value === '') {
|
|
509
|
-
this.color = hex;
|
|
510
|
-
this.dispatchEvent(new CustomEvent('color-changed', {
|
|
511
|
-
bubbles: true,
|
|
512
|
-
detail: { value: hex ? '#' + hex : '' }
|
|
513
|
-
}));
|
|
514
|
-
}
|
|
515
|
-
break;
|
|
516
|
-
case 'blur':
|
|
517
|
-
if (value && !validHex(value, this.alpha)) {
|
|
518
|
-
this.color = this[$saved];
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
attributeChangedCallback(attr, _oldVal, newVal) {
|
|
523
|
-
if (attr === 'color' && this.color !== newVal) {
|
|
524
|
-
this.color = newVal;
|
|
525
|
-
}
|
|
526
|
-
const hasBooleanAttr = newVal != null;
|
|
527
|
-
if (attr === 'alpha') {
|
|
528
|
-
if (this.alpha !== hasBooleanAttr) {
|
|
529
|
-
this.alpha = hasBooleanAttr;
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
if (attr === 'prefixed') {
|
|
533
|
-
if (this.prefixed !== hasBooleanAttr) {
|
|
534
|
-
this.prefixed = hasBooleanAttr;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
[$init](root) {
|
|
539
|
-
let input = this.querySelector('input');
|
|
540
|
-
if (!input) {
|
|
541
|
-
// remove all child node if no input found
|
|
542
|
-
let c;
|
|
543
|
-
while ((c = this.firstChild)) {
|
|
544
|
-
c.remove();
|
|
545
|
-
}
|
|
546
|
-
input = root.querySelector('input');
|
|
547
|
-
}
|
|
548
|
-
input.addEventListener('input', this);
|
|
549
|
-
input.addEventListener('blur', this);
|
|
550
|
-
this[$input] = input;
|
|
551
|
-
this[$update](this.color);
|
|
552
|
-
}
|
|
553
|
-
[$update](hex) {
|
|
554
|
-
if (this[$input]) {
|
|
555
|
-
this[$input].value =
|
|
556
|
-
hex == null || hex == '' ? '' : (this.prefixed ? '#' : '') + escape(hex, this.alpha);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* A custom element for entering color in HEX format.
|
|
563
|
-
*
|
|
564
|
-
* @element hex-input
|
|
565
|
-
*
|
|
566
|
-
* @prop {string} color - Color in HEX format.
|
|
567
|
-
* @attr {string} color - Selected color in HEX format.
|
|
568
|
-
* @prop {boolean} alpha - When true, `#rgba` and `#rrggbbaa` color formats are allowed.
|
|
569
|
-
* @attr {boolean} alpha - Allows `#rgba` and `#rrggbbaa` color formats.
|
|
570
|
-
* @prop {boolean} prefixed - When true, `#` prefix is displayed in the input.
|
|
571
|
-
* @attr {boolean} prefixed - Enables `#` prefix displaying.
|
|
572
|
-
*
|
|
573
|
-
* @fires color-changed - Event fired when color is changed.
|
|
574
|
-
*
|
|
575
|
-
* @csspart input - A native input element.
|
|
576
|
-
*/
|
|
577
|
-
class HexInput extends HexInputBase {
|
|
578
|
-
}
|
|
579
|
-
customElements.define('hex-input', HexInput);
|
|
580
|
-
|
|
581
|
-
var __defProp = Object.defineProperty;
|
|
582
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
583
|
-
var result = void 0 ;
|
|
584
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
585
|
-
if (decorator = decorators[i])
|
|
586
|
-
result = (decorator(target, key, result) ) || result;
|
|
587
|
-
if (result) __defProp(target, key, result);
|
|
588
|
-
return result;
|
|
589
|
-
};
|
|
590
|
-
const VC_HEX_PICKER_TAG = "vvd-hex-picker";
|
|
591
|
-
const VC_HEX_INPUT_TAG = "vvd-hex-input";
|
|
592
|
-
class VvdHexPicker extends HexColorPicker {
|
|
593
|
-
static {
|
|
594
|
-
this.displayName = "VvdHexPicker";
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
class VvdHexInput extends HexInput {
|
|
598
|
-
static {
|
|
599
|
-
this.displayName = "VvdHexInput";
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
if (!customElements.get(VC_HEX_PICKER_TAG)) {
|
|
603
|
-
customElements.define(VC_HEX_PICKER_TAG, VvdHexPicker);
|
|
604
|
-
}
|
|
605
|
-
if (!customElements.get(VC_HEX_INPUT_TAG)) {
|
|
606
|
-
customElements.define(VC_HEX_INPUT_TAG, VvdHexInput);
|
|
607
|
-
}
|
|
608
|
-
const vcPickerTag = VC_HEX_PICKER_TAG;
|
|
609
|
-
const vcInputTag = VC_HEX_INPUT_TAG;
|
|
610
|
-
class ColorPicker extends withContextualHelp.WithContextualHelp(
|
|
611
|
-
mixins.WithFeedback(
|
|
612
|
-
withErrorText.WithErrorText(
|
|
613
|
-
withSuccessText.WithSuccessText(
|
|
614
|
-
delegatesAria.DelegatesAria(trappedFocus.TrappedFocus(baseColorPicker.BaseColorPicker(vividElement.VividElement)))
|
|
615
|
-
)
|
|
616
|
-
)
|
|
617
|
-
)
|
|
618
|
-
) {
|
|
619
|
-
constructor() {
|
|
620
|
-
super(...arguments);
|
|
621
|
-
this.disableSavedColors = false;
|
|
622
|
-
this.savedColors = [];
|
|
623
|
-
this.maxSwatches = 6;
|
|
624
|
-
/**
|
|
625
|
-
* @internal
|
|
626
|
-
*/
|
|
627
|
-
this.#closeOnPointerOutside = (e) => {
|
|
628
|
-
if (this._isInPath(e, this._buttonEl) || this._isInPath(e, this._popupEl)) {
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
this.open = false;
|
|
632
|
-
};
|
|
633
|
-
this.copyIconName = "copy-2-line";
|
|
634
|
-
this.#iconResetTimer = null;
|
|
635
|
-
/**
|
|
636
|
-
* @internal
|
|
637
|
-
*/
|
|
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;
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
this._ariaLiveDescription = "";
|
|
650
|
-
}
|
|
651
|
-
static {
|
|
652
|
-
/**
|
|
653
|
-
* Regular expression pattern for valid hex colors (with # prefix)
|
|
654
|
-
* Matches both 3-digit (#abc) and 6-digit (#aabbcc) hex colors
|
|
655
|
-
* @internal
|
|
656
|
-
*/
|
|
657
|
-
this.HEX_COLOR_PATTERN = /^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$/;
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* @internal
|
|
661
|
-
*/
|
|
662
|
-
placeholderChanged() {
|
|
663
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
664
|
-
this.proxy.placeholder = this.placeholder;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Change event handler for inner control.
|
|
669
|
-
* @remarks
|
|
670
|
-
* @internal
|
|
671
|
-
*/
|
|
672
|
-
handleChange() {
|
|
673
|
-
this.$emit("change");
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* @internal
|
|
677
|
-
*/
|
|
678
|
-
openChanged(_oldValue, newValue) {
|
|
679
|
-
if (newValue && this.isConnected) {
|
|
680
|
-
requestAnimationFrame(() => {
|
|
681
|
-
this._refreshCanvasColor();
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* @internal
|
|
687
|
-
*/
|
|
688
|
-
savedColorsKeyChanged() {
|
|
689
|
-
this.savedColors = this._loadSavedColors();
|
|
690
|
-
}
|
|
691
|
-
/**
|
|
692
|
-
* @internal
|
|
693
|
-
*/
|
|
694
|
-
get _savedColorsStorageKey() {
|
|
695
|
-
if (this.savedColorsKey) return this.savedColorsKey;
|
|
696
|
-
const tag = this.tagName.toLowerCase();
|
|
697
|
-
return `vvd-saved-colors:${tag}`;
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* @internal
|
|
701
|
-
*/
|
|
702
|
-
_handleColorSaving() {
|
|
703
|
-
this._saveCurrentColor();
|
|
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
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* @internal
|
|
772
|
-
*/
|
|
773
|
-
get _maxSwatchesNormalized() {
|
|
774
|
-
return Number.isFinite(this.maxSwatches) ? Math.max(0, Math.floor(this.maxSwatches)) : 0;
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* @internal
|
|
778
|
-
*/
|
|
779
|
-
maxSwatchesChanged() {
|
|
780
|
-
const maxCount = this._maxSwatchesNormalized;
|
|
781
|
-
if (this.savedColors?.length > maxCount) {
|
|
782
|
-
this.savedColors = this.savedColors.slice(0, maxCount);
|
|
783
|
-
this._setSavedColors(this.savedColors);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
/**
|
|
787
|
-
* @internal
|
|
788
|
-
*/
|
|
789
|
-
_onPickerColorChanged(e) {
|
|
790
|
-
if (typeof e.detail?.value === "string") {
|
|
791
|
-
this.value = e.detail?.value;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* @internal
|
|
796
|
-
*/
|
|
797
|
-
valueChanged(_oldVal, newVal) {
|
|
798
|
-
if (this._vcHexPickerEl && typeof newVal === "string") {
|
|
799
|
-
this._vcHexPickerEl.color = newVal;
|
|
800
|
-
}
|
|
801
|
-
if (this._vcHexInputEl && typeof newVal === "string") {
|
|
802
|
-
this._vcHexInputEl.color = newVal;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* @internal
|
|
807
|
-
*/
|
|
808
|
-
_onTextFieldInput(event) {
|
|
809
|
-
const textField = event.currentTarget;
|
|
810
|
-
this.value = textField.value;
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* @internal
|
|
814
|
-
*/
|
|
815
|
-
get _buttonColor() {
|
|
816
|
-
if (!this._canvasColor) {
|
|
817
|
-
this._refreshCanvasColor();
|
|
818
|
-
}
|
|
819
|
-
if (this.value && baseColorPicker.isValidHexColor(this.value)) {
|
|
820
|
-
return this.value;
|
|
821
|
-
}
|
|
822
|
-
return "var(--vvd-color-canvas-text)";
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* @internal
|
|
826
|
-
*/
|
|
827
|
-
_onButtonClick() {
|
|
828
|
-
this.open = !this.open;
|
|
829
|
-
}
|
|
830
|
-
/**
|
|
831
|
-
* @internal
|
|
832
|
-
*/
|
|
833
|
-
_handleCloseRequest() {
|
|
834
|
-
this.open = false;
|
|
835
|
-
}
|
|
836
|
-
/**
|
|
837
|
-
* @internal
|
|
838
|
-
*/
|
|
839
|
-
_isInPath(e, el) {
|
|
840
|
-
if (!el) return false;
|
|
841
|
-
const path = e.composedPath?.();
|
|
842
|
-
return !!(path && path.includes(el));
|
|
843
|
-
}
|
|
844
|
-
#closeOnPointerOutside;
|
|
845
|
-
connectedCallback() {
|
|
846
|
-
super.connectedCallback();
|
|
847
|
-
this.savedColors = this._loadSavedColors();
|
|
848
|
-
document.addEventListener("mousedown", this.#closeOnPointerOutside, true);
|
|
849
|
-
}
|
|
850
|
-
disconnectedCallback() {
|
|
851
|
-
super.disconnectedCallback();
|
|
852
|
-
document.removeEventListener(
|
|
853
|
-
"mousedown",
|
|
854
|
-
this.#closeOnPointerOutside,
|
|
855
|
-
true
|
|
856
|
-
);
|
|
857
|
-
}
|
|
858
|
-
#iconResetTimer;
|
|
859
|
-
/**
|
|
860
|
-
* @internal
|
|
861
|
-
*/
|
|
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);
|
|
869
|
-
}
|
|
870
|
-
// --- Trapped focus ---
|
|
871
|
-
/**
|
|
872
|
-
* @internal
|
|
873
|
-
*/
|
|
874
|
-
_onBaseKeydown(event) {
|
|
875
|
-
if (this.open && index.handleEscapeKeyAndStopPropogation(event)) {
|
|
876
|
-
this.open = false;
|
|
877
|
-
return false;
|
|
878
|
-
}
|
|
879
|
-
if (this._trappedFocus(event, () => this._focusableElsWithinDialog())) {
|
|
880
|
-
return false;
|
|
881
|
-
}
|
|
882
|
-
return true;
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* @internal
|
|
886
|
-
*/
|
|
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
|
|
902
|
-
);
|
|
903
|
-
const nextIdx = event.shiftKey ? (idx - 1 + focusableEls.length) % focusableEls.length : (idx + 1) % focusableEls.length;
|
|
904
|
-
focusableEls[nextIdx]?.focus();
|
|
905
|
-
return false;
|
|
906
|
-
}
|
|
907
|
-
return super._handleCellKeydown(event, value, index, isSaveCell);
|
|
908
|
-
}
|
|
909
|
-
/**
|
|
910
|
-
* @internal
|
|
911
|
-
*/
|
|
912
|
-
_handleSwatchSelection(value) {
|
|
913
|
-
if (this.value !== value) {
|
|
914
|
-
this._ariaLiveDescription = this.locale.colorPicker.selectionSuccessMessage(value);
|
|
915
|
-
}
|
|
916
|
-
super._handleSwatchSelection(value);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
__decorateClass([
|
|
920
|
-
fastElement.attr
|
|
921
|
-
], ColorPicker.prototype, "placeholder");
|
|
922
|
-
__decorateClass([
|
|
923
|
-
fastElement.attr({ attribute: "saved-colors-key" })
|
|
924
|
-
], ColorPicker.prototype, "savedColorsKey");
|
|
925
|
-
__decorateClass([
|
|
926
|
-
fastElement.attr({
|
|
927
|
-
mode: "boolean",
|
|
928
|
-
attribute: "disable-saved-colors"
|
|
929
|
-
})
|
|
930
|
-
], ColorPicker.prototype, "disableSavedColors");
|
|
931
|
-
__decorateClass([
|
|
932
|
-
fastElement.observable
|
|
933
|
-
], ColorPicker.prototype, "savedColors");
|
|
934
|
-
__decorateClass([
|
|
935
|
-
fastElement.attr({
|
|
936
|
-
attribute: "max-swatches",
|
|
937
|
-
mode: "fromView",
|
|
938
|
-
converter: fastElement.nullableNumberConverter
|
|
939
|
-
})
|
|
940
|
-
], ColorPicker.prototype, "maxSwatches");
|
|
941
|
-
__decorateClass([
|
|
942
|
-
fastElement.observable
|
|
943
|
-
], ColorPicker.prototype, "copyIconName");
|
|
944
|
-
__decorateClass([
|
|
945
|
-
fastElement.observable
|
|
946
|
-
], ColorPicker.prototype, "_ariaLiveDescription");
|
|
947
|
-
|
|
948
|
-
function renderTextField(textFieldTag, iconTag) {
|
|
949
|
-
const getClasses = (_) => fastWebUtilities.classNames("control");
|
|
950
|
-
return fastElement.html`
|
|
951
|
-
<${textFieldTag}
|
|
952
|
-
id="text-field"
|
|
953
|
-
class="${getClasses}"
|
|
954
|
-
pattern="${ColorPicker.HEX_COLOR_PATTERN.source}"
|
|
955
|
-
maxlength="7"
|
|
956
|
-
label="${(x) => x.label}"
|
|
957
|
-
:value="${(x) => x.value}"
|
|
958
|
-
placeholder="${(x) => x.placeholder}"
|
|
959
|
-
helper-text="${(x) => x.helperText}"
|
|
960
|
-
error-text="${(x) => x.errorValidationMessage}"
|
|
961
|
-
success-text="${(x) => x.successText}"
|
|
962
|
-
?disabled="${(x) => x.disabled}"
|
|
963
|
-
?required="${(x) => x.required}"
|
|
964
|
-
@input='${(x, c) => x._onTextFieldInput(c.event)}'
|
|
965
|
-
@change="${(x) => x.handleChange()}"
|
|
966
|
-
@blur="${(x) => {
|
|
967
|
-
x.$emit("blur", void 0, { bubbles: false });
|
|
968
|
-
}}"
|
|
969
|
-
@focus="${(x) => {
|
|
970
|
-
x.$emit("focus", void 0, { bubbles: false });
|
|
971
|
-
}}"
|
|
972
|
-
${delegatesAria.delegateAria()}
|
|
973
|
-
${fastElement.ref("_textFieldEl")}
|
|
974
|
-
>
|
|
975
|
-
<button
|
|
976
|
-
aria-label="${(x) => x.locale.colorPicker.pickerButtonLabel}"
|
|
977
|
-
aria-expanded="${(x) => x.open}"
|
|
978
|
-
aria-haspopup="dialog"
|
|
979
|
-
class="button ${(x) => fastWebUtilities.classNames(
|
|
980
|
-
x._applyContrastClass(x._buttonColor) ? "contrast" : "",
|
|
981
|
-
x.disabled ? "disabled" : ""
|
|
982
|
-
)}"
|
|
983
|
-
style="--button-color: ${(x) => x._buttonColor};"
|
|
984
|
-
?disabled="${(x) => x.disabled}"
|
|
985
|
-
@click="${(x) => x._onButtonClick()}"
|
|
986
|
-
slot="action-items"
|
|
987
|
-
${fastElement.ref("_buttonEl")}>
|
|
988
|
-
<${iconTag} name="edit-line"></${iconTag}>
|
|
989
|
-
</button>
|
|
990
|
-
<slot
|
|
991
|
-
slot="${(x) => x._helperTextSlottedContent?.length ? "helper-text" : void 0}"
|
|
992
|
-
name="helper-text"
|
|
993
|
-
${fastElement.slotted("_helperTextSlottedContent")}
|
|
994
|
-
></slot>
|
|
995
|
-
<slot
|
|
996
|
-
slot='${(x) => x._contextualHelpSlottedContent?.length ? "contextual-help" : void 0}'
|
|
997
|
-
name='contextual-help'
|
|
998
|
-
${fastElement.slotted("_contextualHelpSlottedContent")}
|
|
999
|
-
></slot>
|
|
1000
|
-
</${textFieldTag}>
|
|
1001
|
-
`;
|
|
1002
|
-
}
|
|
1003
|
-
function renderPopupHeader(buttonTag, iconTag) {
|
|
1004
|
-
return fastElement.html`
|
|
1005
|
-
<div class="header">
|
|
1006
|
-
<h2 class="header-title" id="color-picker-title">
|
|
1007
|
-
<slot name="popup-text">${(x) => x.locale.colorPicker.popupLabel}</slot>
|
|
1008
|
-
</h2>
|
|
1009
|
-
<${buttonTag} size="condensed"
|
|
1010
|
-
aria-label="${(x) => x.locale.colorPicker.closeButtonLabel}"
|
|
1011
|
-
@click="${(x) => x._handleCloseRequest()}">
|
|
1012
|
-
<${iconTag} slot="icon" name="close-line"></${iconTag}>
|
|
1013
|
-
</${buttonTag}>
|
|
1014
|
-
</div>
|
|
1015
|
-
`;
|
|
1016
|
-
}
|
|
1017
|
-
function renderPopupBody(buttonTag, iconTag, tooltipTag) {
|
|
1018
|
-
return fastElement.html`
|
|
1019
|
-
<div class="body">
|
|
1020
|
-
<${fastElement.html.partial(vcPickerTag)}
|
|
1021
|
-
part="hex-picker"
|
|
1022
|
-
color="${(x) => x.value}"
|
|
1023
|
-
@color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
|
|
1024
|
-
${fastElement.ref("_vcHexPickerEl")}
|
|
1025
|
-
></${fastElement.html.partial(vcPickerTag)}>
|
|
1026
|
-
<div class="hex-input-wrapper">
|
|
1027
|
-
<${fastElement.html.partial(vcInputTag)}
|
|
1028
|
-
part="hex-input"
|
|
1029
|
-
prefixed
|
|
1030
|
-
color="${(x) => x.value}"
|
|
1031
|
-
@color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
|
|
1032
|
-
${fastElement.ref("_vcHexInputEl")}
|
|
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}>
|
|
1049
|
-
</div>
|
|
1050
|
-
</div>
|
|
1051
|
-
`;
|
|
1052
|
-
}
|
|
1053
|
-
function renderPopupFooter(buttonTag, iconTag, tooltipTag) {
|
|
1054
|
-
return fastElement.html`
|
|
1055
|
-
<div class="footer">
|
|
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>
|
|
1064
|
-
<div
|
|
1065
|
-
class="palette"
|
|
1066
|
-
role="grid"
|
|
1067
|
-
aria-rowcount="${(x) => Math.ceil(x.allSwatches.length / x._getRowLength())}"
|
|
1068
|
-
aria-colcount="${(x) => x._getRowLength()}"
|
|
1069
|
-
style="--swatches-per-row: ${(x) => x._getRowLength()};"
|
|
1070
|
-
aria-labelledby="color-picker-footer-title"
|
|
1071
|
-
>
|
|
1072
|
-
${fastElement.repeat(
|
|
1073
|
-
(x) => x.allSwatches,
|
|
1074
|
-
(x) => x._renderColorSwatch(iconTag, tooltipTag),
|
|
1075
|
-
{ positioning: true }
|
|
1076
|
-
)}
|
|
1077
|
-
${fastElement.when(
|
|
1078
|
-
(x) => !x.disableSavedColors,
|
|
1079
|
-
fastElement.html`
|
|
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(
|
|
1092
|
-
c.event,
|
|
1093
|
-
x.value,
|
|
1094
|
-
x.allSwatches.length,
|
|
1095
|
-
true
|
|
1096
|
-
)}">
|
|
1097
|
-
<${iconTag} slot="icon" name="plus-line"></${iconTag}>
|
|
1098
|
-
</${buttonTag}>
|
|
1099
|
-
</${tooltipTag}>
|
|
1100
|
-
`
|
|
1101
|
-
)}
|
|
1102
|
-
</div>
|
|
1103
|
-
</div>
|
|
1104
|
-
`;
|
|
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
|
-
}
|
|
1119
|
-
const ColorPickerTemplate = (context) => {
|
|
1120
|
-
const textFieldTag = context.tagFor(textField_definition.VwcTextFieldElement);
|
|
1121
|
-
const iconTag = context.tagFor(icon_definition.VwcIconElement);
|
|
1122
|
-
const popupTag = context.tagFor(popup_definition.Popup);
|
|
1123
|
-
const buttonTag = context.tagFor(button_definition.Button);
|
|
1124
|
-
const tooltipTag = context.tagFor(tooltip_definition.VwcTooltipElement);
|
|
1125
|
-
return fastElement.html`
|
|
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>
|
|
1130
|
-
${renderTextField(textFieldTag, iconTag)}
|
|
1131
|
-
<${popupTag}
|
|
1132
|
-
:open="${(x) => x.open}"
|
|
1133
|
-
:anchor="${(x) => x._buttonEl}"
|
|
1134
|
-
placement="top"
|
|
1135
|
-
offset="10"
|
|
1136
|
-
${fastElement.ref("_popupEl")}>
|
|
1137
|
-
<div class="dialog"
|
|
1138
|
-
role="dialog"
|
|
1139
|
-
aria-modal="true"
|
|
1140
|
-
aria-labelledby="color-picker-title">
|
|
1141
|
-
${renderPopupHeader(buttonTag, iconTag)}
|
|
1142
|
-
${renderPopupBody(buttonTag, iconTag, tooltipTag)}
|
|
1143
|
-
${fastElement.when(
|
|
1144
|
-
(x) => !x.disableSavedColors || x.allSwatches.length > 0,
|
|
1145
|
-
renderPopupFooter(buttonTag, iconTag, tooltipTag)
|
|
1146
|
-
)}
|
|
1147
|
-
</div>
|
|
1148
|
-
</${popupTag}>
|
|
1149
|
-
</div>
|
|
1150
|
-
`;
|
|
1151
|
-
};
|
|
1152
|
-
|
|
1153
|
-
const colorPickerDefinition = vividElement.defineVividComponent(
|
|
1154
|
-
"color-picker",
|
|
1155
|
-
ColorPicker,
|
|
1156
|
-
ColorPickerTemplate,
|
|
1157
|
-
[
|
|
1158
|
-
popup_definition.popupDefinition,
|
|
1159
|
-
icon_definition.iconDefinition,
|
|
1160
|
-
textField_definition.textFieldDefinition,
|
|
1161
|
-
button_definition.buttonDefinition,
|
|
1162
|
-
tooltip_definition.tooltipDefinition,
|
|
1163
|
-
mixins.feedbackMessageDefinition
|
|
1164
|
-
],
|
|
1165
|
-
{
|
|
1166
|
-
styles
|
|
1167
|
-
}
|
|
1168
|
-
);
|
|
1169
|
-
const registerColorPicker = vividElement.createRegisterFunction(
|
|
1170
|
-
colorPickerDefinition
|
|
1171
|
-
);
|
|
1172
|
-
|
|
1173
|
-
exports.VwcColorPickerElement = ColorPicker;
|
|
1174
|
-
exports.colorPickerDefinition = colorPickerDefinition;
|
|
1175
|
-
exports.registerColorPicker = registerColorPicker;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../unbundled/definition2.cjs");
|
|
3
|
+
const require_definition$1 = require("../unbundled/definition28.cjs");
|
|
4
|
+
exports.VwcColorPickerElement = require_definition$1.ColorPicker;
|
|
5
|
+
exports.colorPickerDefinition = require_definition$1.colorPickerDefinition;
|
|
6
|
+
exports.registerColorPicker = require_definition$1.registerColorPicker;
|