@vonage/vivid 3.0.0 → 3.1.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/README.md +176 -4
- package/accordion/index.js +22 -61
- package/accordion-item/index.js +16 -118
- package/action-group/index.js +5 -0
- package/avatar/index.js +11 -0
- package/badge/index.js +9 -53
- package/banner/index.js +20 -210
- package/breadcrumb/index.js +7 -96
- package/breadcrumb-item/index.js +15 -46
- package/button/index.js +19 -751
- package/calendar/index.js +6 -1520
- package/calendar-event/index.js +9 -0
- package/card/index.js +10 -133
- package/checkbox/index.js +16 -0
- package/combobox/index.js +35 -0
- package/custom-elements.json +6214 -0
- package/data-grid/index.js +1104 -0
- package/dialog/index.js +24 -0
- package/divider/index.js +6 -0
- package/elevation/index.js +4 -30
- package/fab/index.js +22 -0
- package/focus/index.js +4 -2
- package/header/index.js +6 -0
- package/icon/index.js +8 -36
- package/index.js +77 -26
- package/layout/index.js +4 -52
- package/lib/accordion/accordion.d.ts +3 -7
- package/lib/accordion/accordion.template.d.ts +1 -2
- package/lib/accordion/definition.d.ts +1 -0
- package/lib/accordion/index.d.ts +1 -2
- package/lib/accordion-item/accordion-item.d.ts +2 -6
- package/lib/accordion-item/accordion-item.template.d.ts +4 -4
- package/lib/accordion-item/definition.d.ts +1 -0
- package/lib/accordion-item/index.d.ts +1 -3
- package/lib/action-group/action-group.d.ts +10 -0
- package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
- package/lib/action-group/definition.d.ts +1 -0
- package/lib/action-group/index.d.ts +1 -0
- package/lib/avatar/avatar.d.ts +15 -0
- package/lib/avatar/avatar.template.d.ts +4 -0
- package/lib/avatar/definition.d.ts +1 -0
- package/lib/avatar/index.d.ts +1 -0
- package/lib/badge/badge.d.ts +2 -4
- package/lib/badge/definition.d.ts +3 -0
- package/lib/badge/index.d.ts +1 -3
- package/lib/banner/banner.d.ts +1 -1
- package/lib/banner/banner.template.d.ts +0 -2
- package/lib/banner/definition.d.ts +1 -0
- package/lib/banner/index.d.ts +1 -2
- package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
- package/lib/breadcrumb/definition.d.ts +1 -0
- package/lib/breadcrumb/index.d.ts +1 -2
- package/lib/breadcrumb-item/definition.d.ts +1 -0
- package/lib/breadcrumb-item/index.d.ts +1 -3
- package/lib/button/button.d.ts +3 -2
- package/lib/button/definition.d.ts +1 -0
- package/lib/button/index.d.ts +1 -21
- package/lib/calendar/calendar.d.ts +3 -1
- package/lib/calendar/definition.d.ts +1 -0
- package/lib/calendar/index.d.ts +1 -3
- package/lib/calendar-event/calendar-event.d.ts +14 -0
- package/lib/calendar-event/calendar-event.template.d.ts +4 -0
- package/lib/calendar-event/definition.d.ts +1 -0
- package/lib/calendar-event/index.d.ts +1 -0
- package/lib/card/card.d.ts +2 -2
- package/lib/card/definition.d.ts +1 -0
- package/lib/card/index.d.ts +1 -5
- package/lib/checkbox/checkbox.d.ts +5 -0
- package/lib/checkbox/checkbox.template.d.ts +4 -0
- package/lib/checkbox/definition.d.ts +1 -0
- package/lib/checkbox/index.d.ts +1 -0
- package/lib/combobox/combobox.d.ts +14 -0
- package/lib/combobox/combobox.template.d.ts +4 -0
- package/lib/combobox/definition.d.ts +3 -0
- package/lib/combobox/index.d.ts +1 -0
- package/lib/components.d.ts +44 -16
- package/lib/data-grid/data-grid-cell.d.ts +5 -0
- package/lib/data-grid/data-grid-cell.template.d.ts +4 -0
- package/lib/data-grid/data-grid-row.d.ts +3 -0
- package/lib/data-grid/data-grid-row.template.d.ts +3 -0
- package/lib/data-grid/data-grid.d.ts +3 -0
- package/lib/data-grid/data-grid.options.d.ts +31 -0
- package/lib/data-grid/data-grid.template.d.ts +3 -0
- package/lib/data-grid/definition.d.ts +6 -0
- package/lib/data-grid/index.d.ts +1 -0
- package/lib/dialog/definition.d.ts +1 -0
- package/lib/dialog/dialog.d.ts +23 -0
- package/lib/dialog/dialog.template.d.ts +4 -0
- package/lib/dialog/index.d.ts +1 -0
- package/lib/divider/definition.d.ts +1 -0
- package/lib/divider/divider.d.ts +3 -0
- package/lib/divider/divider.template.d.ts +4 -0
- package/lib/divider/index.d.ts +1 -0
- package/lib/elevation/definition.d.ts +1 -0
- package/lib/elevation/elevation.d.ts +1 -0
- package/lib/elevation/index.d.ts +1 -2
- package/lib/enums.d.ts +19 -6
- package/lib/fab/definition.d.ts +3 -0
- package/lib/fab/fab.d.ts +13 -0
- package/lib/fab/fab.template.d.ts +4 -0
- package/lib/fab/index.d.ts +1 -0
- package/lib/focus/definition.d.ts +3 -0
- package/lib/focus/index.d.ts +1 -2
- package/lib/{sidenav-item/index.d.ts → header/definition.d.ts} +2 -2
- package/lib/header/header.d.ts +5 -0
- package/lib/header/header.template.d.ts +4 -0
- package/lib/header/index.d.ts +1 -0
- package/lib/icon/definition.d.ts +3 -0
- package/lib/icon/icon.d.ts +5 -6
- package/lib/icon/index.d.ts +1 -2
- package/lib/layout/definition.d.ts +3 -0
- package/lib/layout/index.d.ts +1 -2
- package/lib/layout/layout.d.ts +4 -4
- package/lib/listbox/definition.d.ts +3 -0
- package/lib/listbox/index.d.ts +1 -0
- package/lib/listbox/listbox.d.ts +6 -0
- package/lib/listbox/listbox.template.d.ts +4 -0
- package/lib/menu/definition.d.ts +11 -0
- package/lib/menu/index.d.ts +1 -0
- package/lib/menu/menu.d.ts +10 -0
- package/lib/menu/menu.template.d.ts +3 -0
- package/lib/menu-item/definition.d.ts +3 -0
- package/lib/menu-item/index.d.ts +1 -0
- package/lib/menu-item/menu-item.d.ts +8 -0
- package/lib/menu-item/menu-item.template.d.ts +5 -0
- package/lib/nav/definition.d.ts +3 -0
- package/lib/nav/index.d.ts +1 -0
- package/lib/nav/nav.d.ts +3 -0
- package/lib/nav/nav.template.d.ts +4 -0
- package/lib/nav-disclosure/definition.d.ts +3 -0
- package/lib/nav-disclosure/index.d.ts +1 -0
- package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
- package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
- package/lib/nav-item/definition.d.ts +3 -0
- package/lib/nav-item/index.d.ts +1 -0
- package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
- package/lib/nav-item/nav-item.template.d.ts +4 -0
- package/lib/note/definition.d.ts +3 -0
- package/lib/note/index.d.ts +1 -0
- package/lib/note/note.d.ts +10 -0
- package/lib/{text/text.template.d.ts → note/note.template.d.ts} +2 -2
- package/lib/number-field/definition.d.ts +4 -0
- package/lib/number-field/index.d.ts +1 -0
- package/lib/number-field/number-field.d.ts +14 -0
- package/lib/number-field/number-field.template.d.ts +4 -0
- package/lib/option/definition.d.ts +3 -0
- package/lib/option/index.d.ts +1 -0
- package/lib/option/option.d.ts +9 -0
- package/lib/option/option.template.d.ts +4 -0
- package/lib/popup/definition.d.ts +3 -0
- package/lib/popup/index.d.ts +1 -4
- package/lib/popup/popup.d.ts +8 -4
- package/lib/progress/definition.d.ts +3 -0
- package/lib/progress/index.d.ts +1 -2
- package/lib/progress/progress.d.ts +1 -1
- package/lib/progress-ring/definition.d.ts +3 -0
- package/lib/progress-ring/index.d.ts +1 -2
- package/lib/progress-ring/progress-ring.d.ts +2 -1
- package/lib/radio/definition.d.ts +3 -0
- package/lib/radio/index.d.ts +1 -0
- package/lib/radio/radio.d.ts +4 -0
- package/lib/radio/radio.template.d.ts +4 -0
- package/lib/radio-group/definition.d.ts +11 -0
- package/lib/radio-group/index.d.ts +1 -0
- package/lib/radio-group/radio-group.d.ts +4 -0
- package/lib/radio-group/radio-group.template.d.ts +4 -0
- package/lib/select/definition.d.ts +3 -0
- package/lib/select/index.d.ts +1 -0
- package/lib/select/select.d.ts +17 -0
- package/lib/select/select.template.d.ts +4 -0
- package/lib/side-drawer/definition.d.ts +3 -0
- package/lib/side-drawer/index.d.ts +1 -2
- package/lib/side-drawer/side-drawer.d.ts +3 -2
- package/lib/slider/definition.d.ts +3 -0
- package/lib/slider/index.d.ts +1 -0
- package/lib/slider/slider.d.ts +4 -0
- package/lib/slider/slider.template.d.ts +4 -0
- package/lib/switch/definition.d.ts +3 -0
- package/lib/switch/index.d.ts +1 -0
- package/lib/switch/switch.d.ts +7 -0
- package/lib/switch/switch.template.d.ts +4 -0
- package/lib/tab/definition.d.ts +3 -0
- package/lib/tab/index.d.ts +1 -0
- package/lib/tab/tab.d.ts +9 -0
- package/lib/tab/tab.template.d.ts +3 -0
- package/lib/tab-panel/definition.d.ts +3 -0
- package/lib/tab-panel/index.d.ts +1 -0
- package/lib/tab-panel/tab-panel.d.ts +3 -0
- package/lib/tab-panel/tab-panel.template.d.ts +2 -0
- package/lib/tabs/definition.d.ts +3 -0
- package/lib/tabs/index.d.ts +1 -0
- package/lib/tabs/tabs.d.ts +10 -0
- package/lib/tabs/tabs.template.d.ts +2 -0
- package/lib/text-anchor/definition.d.ts +3 -0
- package/lib/text-anchor/index.d.ts +1 -2
- package/lib/text-area/definition.d.ts +3 -0
- package/lib/text-area/index.d.ts +1 -0
- package/lib/text-area/text-area.d.ts +9 -0
- package/lib/text-area/text-area.template.d.ts +4 -0
- package/lib/text-field/definition.d.ts +3 -0
- package/lib/text-field/index.d.ts +1 -0
- package/lib/text-field/text-field.d.ts +14 -0
- package/lib/text-field/text-field.template.d.ts +4 -0
- package/lib/tooltip/definition.d.ts +3 -0
- package/lib/tooltip/index.d.ts +1 -3
- package/lib/tooltip/tooltip.d.ts +6 -6
- package/listbox/index.js +27 -0
- package/menu/index.js +30 -0
- package/menu-item/index.js +20 -0
- package/nav/index.js +4 -0
- package/nav-disclosure/index.js +17 -0
- package/nav-item/index.js +22 -0
- package/note/index.js +15 -0
- package/number-field/index.js +459 -0
- package/option/index.js +21 -0
- package/package.json +21 -11
- package/popup/index.js +21 -2062
- package/progress/index.js +6 -98
- package/progress-ring/index.js +6 -75
- package/radio/index.js +12 -0
- package/radio-group/index.js +11 -0
- package/select/index.js +34 -0
- package/shared/affix.js +2 -8
- package/shared/anchor.js +10 -2
- package/shared/apply-mixins.js +5 -4
- package/shared/aria-global.js +2 -86
- package/shared/aria.js +9 -0
- package/shared/base-progress.js +5 -0
- package/shared/breadcrumb-item.js +1 -1
- package/shared/button.js +200 -0
- package/shared/calendar-event.js +19 -0
- package/shared/definition.js +225 -0
- package/shared/definition10.js +99 -0
- package/shared/definition11.js +48 -0
- package/shared/definition12.js +763 -0
- package/shared/definition13.js +111 -0
- package/shared/definition14.js +114 -0
- package/shared/definition15.js +32 -0
- package/shared/definition16.js +172 -0
- package/shared/definition17.js +727 -0
- package/shared/definition18.js +1531 -0
- package/shared/definition19.js +261 -0
- package/shared/definition2.js +150 -0
- package/shared/definition20.js +221 -0
- package/shared/definition21.js +78 -0
- package/shared/definition22.js +87 -0
- package/shared/definition23.js +58 -0
- package/shared/definition24.js +44 -0
- package/shared/definition25.js +58 -0
- package/shared/definition26.js +348 -0
- package/shared/definition27.js +363 -0
- package/shared/definition28.js +21 -0
- package/shared/definition29.js +75 -0
- package/shared/definition3.js +29 -0
- package/shared/definition30.js +31 -0
- package/shared/definition31.js +49 -0
- package/shared/definition32.js +94 -0
- package/shared/definition33.js +77 -0
- package/shared/definition34.js +45 -0
- package/shared/definition35.js +435 -0
- package/shared/definition36.js +634 -0
- package/shared/definition37.js +86 -0
- package/shared/definition38.js +592 -0
- package/shared/definition39.js +147 -0
- package/shared/definition4.js +19 -0
- package/shared/definition40.js +67 -0
- package/shared/definition41.js +32 -0
- package/shared/definition42.js +440 -0
- package/shared/definition43.js +282 -0
- package/shared/definition44.js +119 -0
- package/shared/definition45.js +77 -0
- package/shared/definition5.js +38 -0
- package/shared/definition6.js +60 -0
- package/shared/definition7.js +45 -0
- package/shared/definition8.js +113 -0
- package/shared/definition9.js +107 -0
- package/shared/design-system/index.d.ts +1 -1
- package/shared/dialog-polyfill.esm.js +858 -0
- package/shared/direction.js +20 -0
- package/shared/dom.js +8 -0
- package/shared/enums.js +70 -0
- package/shared/es.object.assign.js +2 -3
- package/shared/es.regexp.to-string.js +59 -0
- package/shared/focus.js +5 -0
- package/shared/focus2.js +11 -0
- package/shared/form-associated.js +466 -0
- package/shared/form-elements.js +127 -0
- package/shared/icon.js +538 -567
- package/shared/index.js +1664 -83
- package/shared/key-codes.js +100 -0
- package/shared/listbox.js +995 -0
- package/shared/numbers.js +34 -0
- package/shared/patterns/affix.d.ts +1 -1
- package/shared/patterns/focus.d.ts +3 -0
- package/shared/patterns/form-elements/form-elements.d.ts +43 -0
- package/shared/patterns/form-elements/index.d.ts +1 -0
- package/shared/patterns/index.d.ts +2 -0
- package/shared/radio.js +127 -0
- package/shared/ref.js +41 -0
- package/shared/repeat.js +764 -0
- package/shared/select.options.js +10 -0
- package/shared/slotted.js +1 -1
- package/shared/start-end.js +50 -0
- package/shared/string-trim.js +40 -0
- package/shared/strings.js +9 -0
- package/shared/text-anchor.js +0 -2
- package/shared/text-anchor.template.js +6 -5
- package/shared/text-field.js +3 -0
- package/shared/text-field2.js +225 -0
- package/shared/to-string.js +51 -0
- package/side-drawer/index.js +5 -81
- package/slider/index.js +17 -0
- package/styles/core/all.css +83 -0
- package/styles/core/theme.css +11 -0
- package/styles/core/typography.css +77 -0
- package/styles/tokens/theme-dark.css +228 -0
- package/styles/tokens/theme-light.css +228 -0
- package/switch/index.js +18 -0
- package/tab/index.js +16 -0
- package/tab-panel/index.js +4 -0
- package/tabs/index.js +24 -0
- package/text-anchor/index.js +11 -6
- package/text-area/index.js +23 -0
- package/text-field/index.js +24 -0
- package/tooltip/index.js +18 -55
- package/vivid.api.json +3695 -0
- package/lib/text/index.d.ts +0 -2
- package/lib/text/text.d.ts +0 -10
- package/shared/index2.js +0 -21
- package/shared/object-set-prototype-of.js +0 -1009
- package/shared/style-inject.es.js +0 -28
- package/shared/web.dom-collections.iterator.js +0 -473
- package/sidenav-item/index.js +0 -39
- package/styles/fonts/spezia.css +0 -23
- package/styles/themes/dark.css +0 -205
- package/styles/themes/light.css +0 -205
- package/text/index.js +0 -46
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { F as FoundationElement, U as __classPrivateFieldGet, _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { w as when } from './when.js';
|
|
3
|
+
import { c as classNames } from './class-names.js';
|
|
4
|
+
|
|
5
|
+
var _SideDrawer_instances, _SideDrawer_close, _SideDrawer_open;
|
|
6
|
+
class SideDrawer extends FoundationElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
_SideDrawer_instances.add(this);
|
|
10
|
+
this.alternate = false;
|
|
11
|
+
this.modal = false;
|
|
12
|
+
this.open = false;
|
|
13
|
+
this.trailing = false;
|
|
14
|
+
}
|
|
15
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
16
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
17
|
+
switch (name) {
|
|
18
|
+
case 'open':
|
|
19
|
+
{
|
|
20
|
+
this.open ? __classPrivateFieldGet(this, _SideDrawer_instances, "m", _SideDrawer_open).call(this) : __classPrivateFieldGet(this, _SideDrawer_instances, "m", _SideDrawer_close).call(this);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
_SideDrawer_instances = new WeakSet(), _SideDrawer_close = function _SideDrawer_close() {
|
|
26
|
+
this.$emit('close');
|
|
27
|
+
}, _SideDrawer_open = function _SideDrawer_open() {
|
|
28
|
+
this.$emit('open');
|
|
29
|
+
};
|
|
30
|
+
__decorate([attr({
|
|
31
|
+
mode: 'boolean'
|
|
32
|
+
}), __metadata("design:type", Object)], SideDrawer.prototype, "alternate", void 0);
|
|
33
|
+
__decorate([attr({
|
|
34
|
+
mode: 'boolean'
|
|
35
|
+
}), __metadata("design:type", Object)], SideDrawer.prototype, "modal", void 0);
|
|
36
|
+
__decorate([attr({
|
|
37
|
+
mode: 'boolean'
|
|
38
|
+
}), __metadata("design:type", Object)], SideDrawer.prototype, "open", void 0);
|
|
39
|
+
__decorate([attr({
|
|
40
|
+
mode: 'boolean'
|
|
41
|
+
}), __metadata("design:type", Object)], SideDrawer.prototype, "trailing", void 0);
|
|
42
|
+
|
|
43
|
+
var css_248z = "/**\n * Do not edit directly\n * Generated on Fri, 03 Feb 2023 15:57:56 GMT\n */\n.control {\n position: fixed;\n z-index: 1;\n background-color: var(--vvd-color-canvas);\n color: var(--vvd-color-canvas-text);\n inline-size: 280px;\n inset-block: 0;\n overflow-y: auto;\n}\n.control[part~=vvd-theme-alternate] {\n background-color: var(--vvd-color-canvas);\n color: var(--vvd-color-canvas-text);\n color-scheme: var(--vvd-color-scheme);\n}\n.control.trailing {\n inset-inline-end: 0;\n}\n.control:not(.open).trailing {\n transform: translateX(100%);\n}\n.control:not(.open):not(.trailing) {\n transform: translateX(-100%);\n}\n.control.open:not(.modal).trailing + .side-drawer-app-content {\n margin-inline-end: var(--side-drawer-app-content-offset, 280px);\n}\n.control.open:not(.modal):not(.trailing) + .side-drawer-app-content {\n margin-inline-start: var(--side-drawer-app-content-offset, 280px);\n}\n@media (prefers-reduced-motion: no-preference) {\n .control {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n }\n}\n\n.scrim {\n background-color: var(--vvd-color-canvas-text, currentColor);\n opacity: 0.5;\n position: fixed;\n inset: 0;\n}\n.scrim:not(.open) {\n display: none;\n}";
|
|
44
|
+
|
|
45
|
+
let _ = t => t,
|
|
46
|
+
_t,
|
|
47
|
+
_t2;
|
|
48
|
+
const getClasses = ({
|
|
49
|
+
modal,
|
|
50
|
+
open,
|
|
51
|
+
trailing
|
|
52
|
+
}) => classNames('control', ['modal', modal], ['open', open], ['trailing', trailing]);
|
|
53
|
+
const getScrimClasses = ({
|
|
54
|
+
open
|
|
55
|
+
}) => classNames('scrim', ['open', open]);
|
|
56
|
+
const sideDrawerTemplate = () => html(_t || (_t = _`
|
|
57
|
+
<aside class="${0}" part="base ${0}"
|
|
58
|
+
@keydown="${0}">
|
|
59
|
+
<slot></slot>
|
|
60
|
+
</aside>
|
|
61
|
+
|
|
62
|
+
<div class="side-drawer-app-content" ?inert="${0}">
|
|
63
|
+
<slot name="app-content"></slot>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
${0}
|
|
67
|
+
`), getClasses, x => x.alternate ? 'vvd-theme-alternate' : '', (x, c) => handleKeydown(x, c.event), x => x.open && x.modal, when(x => x.modal, html(_t2 || (_t2 = _`<div class="${0}" @click="${0}"></div>`), getScrimClasses, x => x.open = false)));
|
|
68
|
+
const handleKeydown = (x, {
|
|
69
|
+
key
|
|
70
|
+
}) => {
|
|
71
|
+
if (key === 'Escape') {
|
|
72
|
+
x.open = false;
|
|
73
|
+
} else {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const sideDrawerDefinition = SideDrawer.compose({
|
|
79
|
+
baseName: 'side-drawer',
|
|
80
|
+
template: sideDrawerTemplate,
|
|
81
|
+
styles: css_248z
|
|
82
|
+
});
|
|
83
|
+
const sideDrawerRegistries = [sideDrawerDefinition()];
|
|
84
|
+
const registerSideDrawer = registerFactory(sideDrawerRegistries);
|
|
85
|
+
|
|
86
|
+
export { sideDrawerRegistries as a, registerSideDrawer as r, sideDrawerDefinition as s };
|
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import { F as FoundationElement, _ as __decorate, a as attr, o as observable, n as nullableNumberConverter, g as global$1, l as fails$1, k as functionUncurryThis, G as _export, b as __metadata, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { f as focusRegistries } from './definition4.js';
|
|
3
|
+
import { t as toString$1 } from './to-string.js';
|
|
4
|
+
import { w as whitespaces$1, s as stringTrim } from './string-trim.js';
|
|
5
|
+
import './es.regexp.to-string.js';
|
|
6
|
+
import { D as Direction, g as getDirection } from './direction.js';
|
|
7
|
+
import { l as limit } from './numbers.js';
|
|
8
|
+
import { F as FormAssociated } from './form-associated.js';
|
|
9
|
+
import { O as Orientation } from './aria.js';
|
|
10
|
+
import { a as keyHome, k as keyEnd, b as keyArrowDown, i as keyArrowLeft, c as keyArrowUp, h as keyArrowRight } from './key-codes.js';
|
|
11
|
+
import { f as focusTemplateFactory } from './focus2.js';
|
|
12
|
+
import { r as ref } from './ref.js';
|
|
13
|
+
import { c as classNames } from './class-names.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Converts a pixel coordinate on the track to a percent of the track's range
|
|
17
|
+
*/
|
|
18
|
+
function convertPixelToPercent(pixelPos, minPosition, maxPosition, direction) {
|
|
19
|
+
let pct = limit(0, 1, (pixelPos - minPosition) / (maxPosition - minPosition));
|
|
20
|
+
if (direction === Direction.rtl) {
|
|
21
|
+
pct = 1 - pct;
|
|
22
|
+
}
|
|
23
|
+
return pct;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class _Slider extends FoundationElement {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A form-associated base class for the {@link @microsoft/fast-foundation#(Slider:class)} component.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
class FormAssociatedSlider extends FormAssociated(_Slider) {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.proxy = document.createElement("input");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The selection modes of a {@link @microsoft/fast-foundation#(Slider:class)}.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
const SliderMode = {
|
|
45
|
+
singleValue: "single-value",
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A Slider Custom HTML Element.
|
|
49
|
+
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#slider | ARIA slider }.
|
|
50
|
+
*
|
|
51
|
+
* @slot track - The track of the slider
|
|
52
|
+
* @slot track-start - The track-start visual indicator
|
|
53
|
+
* @slot thumb - The slider thumb
|
|
54
|
+
* @slot - The default slot for labels
|
|
55
|
+
* @csspart positioning-region - The region used to position the elements of the slider
|
|
56
|
+
* @csspart track-container - The region containing the track elements
|
|
57
|
+
* @csspart track-start - The element wrapping the track start slot
|
|
58
|
+
* @csspart thumb-container - The thumb container element which is programatically positioned
|
|
59
|
+
* @fires change - Fires a custom 'change' event when the slider value changes
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
class Slider$1 extends FormAssociatedSlider {
|
|
64
|
+
constructor() {
|
|
65
|
+
super(...arguments);
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
this.direction = Direction.ltr;
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
this.isDragging = false;
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
this.trackWidth = 0;
|
|
78
|
+
/**
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
this.trackMinWidth = 0;
|
|
82
|
+
/**
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
this.trackHeight = 0;
|
|
86
|
+
/**
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
this.trackLeft = 0;
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
this.trackMinHeight = 0;
|
|
94
|
+
/**
|
|
95
|
+
* Custom function that generates a string for the component's "aria-valuetext" attribute based on the current value.
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
this.valueTextFormatter = () => null;
|
|
100
|
+
/**
|
|
101
|
+
* The minimum allowed value.
|
|
102
|
+
*
|
|
103
|
+
* @defaultValue - 0
|
|
104
|
+
* @public
|
|
105
|
+
* @remarks
|
|
106
|
+
* HTML Attribute: min
|
|
107
|
+
*/
|
|
108
|
+
this.min = 0; // Map to proxy element.
|
|
109
|
+
/**
|
|
110
|
+
* The maximum allowed value.
|
|
111
|
+
*
|
|
112
|
+
* @defaultValue - 10
|
|
113
|
+
* @public
|
|
114
|
+
* @remarks
|
|
115
|
+
* HTML Attribute: max
|
|
116
|
+
*/
|
|
117
|
+
this.max = 10; // Map to proxy element.
|
|
118
|
+
/**
|
|
119
|
+
* Value to increment or decrement via arrow keys, mouse click or drag.
|
|
120
|
+
*
|
|
121
|
+
* @public
|
|
122
|
+
* @remarks
|
|
123
|
+
* HTML Attribute: step
|
|
124
|
+
*/
|
|
125
|
+
this.step = 1; // Map to proxy element.
|
|
126
|
+
/**
|
|
127
|
+
* The orientation of the slider.
|
|
128
|
+
*
|
|
129
|
+
* @public
|
|
130
|
+
* @remarks
|
|
131
|
+
* HTML Attribute: orientation
|
|
132
|
+
*/
|
|
133
|
+
this.orientation = Orientation.horizontal;
|
|
134
|
+
/**
|
|
135
|
+
* The selection mode.
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
* @remarks
|
|
139
|
+
* HTML Attribute: mode
|
|
140
|
+
*/
|
|
141
|
+
this.mode = SliderMode.singleValue;
|
|
142
|
+
this.keypressHandler = (e) => {
|
|
143
|
+
if (this.readOnly) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (e.key === keyHome) {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
this.value = `${this.min}`;
|
|
149
|
+
}
|
|
150
|
+
else if (e.key === keyEnd) {
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
this.value = `${this.max}`;
|
|
153
|
+
}
|
|
154
|
+
else if (!e.shiftKey) {
|
|
155
|
+
switch (e.key) {
|
|
156
|
+
case keyArrowRight:
|
|
157
|
+
case keyArrowUp:
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
this.increment();
|
|
160
|
+
break;
|
|
161
|
+
case keyArrowLeft:
|
|
162
|
+
case keyArrowDown:
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
this.decrement();
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
this.setupTrackConstraints = () => {
|
|
170
|
+
const clientRect = this.track.getBoundingClientRect();
|
|
171
|
+
this.trackWidth = this.track.clientWidth;
|
|
172
|
+
this.trackMinWidth = this.track.clientLeft;
|
|
173
|
+
this.trackHeight = clientRect.bottom;
|
|
174
|
+
this.trackMinHeight = clientRect.top;
|
|
175
|
+
this.trackLeft = this.getBoundingClientRect().left;
|
|
176
|
+
if (this.trackWidth === 0) {
|
|
177
|
+
this.trackWidth = 1;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
this.setupListeners = (remove = false) => {
|
|
181
|
+
const eventAction = `${remove ? "remove" : "add"}EventListener`;
|
|
182
|
+
this[eventAction]("keydown", this.keypressHandler);
|
|
183
|
+
this[eventAction]("mousedown", this.handleMouseDown);
|
|
184
|
+
this.thumb[eventAction]("mousedown", this.handleThumbMouseDown, {
|
|
185
|
+
passive: true,
|
|
186
|
+
});
|
|
187
|
+
this.thumb[eventAction]("touchstart", this.handleThumbMouseDown, {
|
|
188
|
+
passive: true,
|
|
189
|
+
});
|
|
190
|
+
// removes handlers attached by mousedown handlers
|
|
191
|
+
if (remove) {
|
|
192
|
+
this.handleMouseDown(null);
|
|
193
|
+
this.handleThumbMouseDown(null);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
this.initialValue = "";
|
|
200
|
+
/**
|
|
201
|
+
* Handle mouse moves during a thumb drag operation
|
|
202
|
+
* If the event handler is null it removes the events
|
|
203
|
+
*/
|
|
204
|
+
this.handleThumbMouseDown = (event) => {
|
|
205
|
+
if (event) {
|
|
206
|
+
if (this.readOnly || this.disabled || event.defaultPrevented) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
event.target.focus();
|
|
210
|
+
}
|
|
211
|
+
const eventAction = `${event !== null ? "add" : "remove"}EventListener`;
|
|
212
|
+
window[eventAction]("mouseup", this.handleWindowMouseUp);
|
|
213
|
+
window[eventAction]("mousemove", this.handleMouseMove, { passive: true });
|
|
214
|
+
window[eventAction]("touchmove", this.handleMouseMove, { passive: true });
|
|
215
|
+
window[eventAction]("touchend", this.handleWindowMouseUp);
|
|
216
|
+
this.isDragging = event !== null;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Handle mouse moves during a thumb drag operation
|
|
220
|
+
*/
|
|
221
|
+
this.handleMouseMove = (e) => {
|
|
222
|
+
if (this.readOnly || this.disabled || e.defaultPrevented) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
// update the value based on current position
|
|
226
|
+
const sourceEvent = window.TouchEvent && e instanceof TouchEvent
|
|
227
|
+
? e.touches[0]
|
|
228
|
+
: e;
|
|
229
|
+
const eventValue = this.orientation === Orientation.horizontal
|
|
230
|
+
? sourceEvent.pageX - document.documentElement.scrollLeft - this.trackLeft
|
|
231
|
+
: sourceEvent.pageY - document.documentElement.scrollTop;
|
|
232
|
+
this.value = `${this.calculateNewValue(eventValue)}`;
|
|
233
|
+
};
|
|
234
|
+
this.calculateNewValue = (rawValue) => {
|
|
235
|
+
// update the value based on current position
|
|
236
|
+
const newPosition = convertPixelToPercent(rawValue, this.orientation === Orientation.horizontal
|
|
237
|
+
? this.trackMinWidth
|
|
238
|
+
: this.trackMinHeight, this.orientation === Orientation.horizontal
|
|
239
|
+
? this.trackWidth
|
|
240
|
+
: this.trackHeight, this.direction);
|
|
241
|
+
const newValue = (this.max - this.min) * newPosition + this.min;
|
|
242
|
+
return this.convertToConstrainedValue(newValue);
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Handle a window mouse up during a drag operation
|
|
246
|
+
*/
|
|
247
|
+
this.handleWindowMouseUp = (event) => {
|
|
248
|
+
this.stopDragging();
|
|
249
|
+
};
|
|
250
|
+
this.stopDragging = () => {
|
|
251
|
+
this.isDragging = false;
|
|
252
|
+
this.handleMouseDown(null);
|
|
253
|
+
this.handleThumbMouseDown(null);
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
*
|
|
257
|
+
* @param e - MouseEvent or null. If there is no event handler it will remove the events
|
|
258
|
+
*/
|
|
259
|
+
this.handleMouseDown = (e) => {
|
|
260
|
+
const eventAction = `${e !== null ? "add" : "remove"}EventListener`;
|
|
261
|
+
if (e === null || (!this.disabled && !this.readOnly)) {
|
|
262
|
+
window[eventAction]("mouseup", this.handleWindowMouseUp);
|
|
263
|
+
window.document[eventAction]("mouseleave", this.handleWindowMouseUp);
|
|
264
|
+
window[eventAction]("mousemove", this.handleMouseMove);
|
|
265
|
+
if (e) {
|
|
266
|
+
e.preventDefault();
|
|
267
|
+
this.setupTrackConstraints();
|
|
268
|
+
e.target.focus();
|
|
269
|
+
const controlValue = this.orientation === Orientation.horizontal
|
|
270
|
+
? e.pageX - document.documentElement.scrollLeft - this.trackLeft
|
|
271
|
+
: e.pageY - document.documentElement.scrollTop;
|
|
272
|
+
this.value = `${this.calculateNewValue(controlValue)}`;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
this.convertToConstrainedValue = (value) => {
|
|
277
|
+
if (isNaN(value)) {
|
|
278
|
+
value = this.min;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The following logic intends to overcome the issue with math in JavaScript with regards to floating point numbers.
|
|
282
|
+
* This is needed as the `step` may be an integer but could also be a float. To accomplish this the step is assumed to be a float
|
|
283
|
+
* and is converted to an integer by determining the number of decimal places it represent, multiplying it until it is an
|
|
284
|
+
* integer and then dividing it to get back to the correct number.
|
|
285
|
+
*/
|
|
286
|
+
let constrainedValue = value - this.min;
|
|
287
|
+
const roundedConstrainedValue = Math.round(constrainedValue / this.step);
|
|
288
|
+
const remainderValue = constrainedValue -
|
|
289
|
+
(roundedConstrainedValue * (this.stepMultiplier * this.step)) /
|
|
290
|
+
this.stepMultiplier;
|
|
291
|
+
constrainedValue =
|
|
292
|
+
remainderValue >= Number(this.step) / 2
|
|
293
|
+
? constrainedValue - remainderValue + Number(this.step)
|
|
294
|
+
: constrainedValue - remainderValue;
|
|
295
|
+
return constrainedValue + this.min;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
readOnlyChanged() {
|
|
299
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
300
|
+
this.proxy.readOnly = this.readOnly;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The value property, typed as a number.
|
|
305
|
+
*
|
|
306
|
+
* @public
|
|
307
|
+
*/
|
|
308
|
+
get valueAsNumber() {
|
|
309
|
+
return parseFloat(super.value);
|
|
310
|
+
}
|
|
311
|
+
set valueAsNumber(next) {
|
|
312
|
+
this.value = next.toString();
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* @internal
|
|
316
|
+
*/
|
|
317
|
+
valueChanged(previous, next) {
|
|
318
|
+
super.valueChanged(previous, next);
|
|
319
|
+
if (this.$fastController.isConnected) {
|
|
320
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
321
|
+
}
|
|
322
|
+
this.$emit("change");
|
|
323
|
+
}
|
|
324
|
+
minChanged() {
|
|
325
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
326
|
+
this.proxy.min = `${this.min}`;
|
|
327
|
+
}
|
|
328
|
+
this.validate();
|
|
329
|
+
}
|
|
330
|
+
maxChanged() {
|
|
331
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
332
|
+
this.proxy.max = `${this.max}`;
|
|
333
|
+
}
|
|
334
|
+
this.validate();
|
|
335
|
+
}
|
|
336
|
+
stepChanged() {
|
|
337
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
338
|
+
this.proxy.step = `${this.step}`;
|
|
339
|
+
}
|
|
340
|
+
this.updateStepMultiplier();
|
|
341
|
+
this.validate();
|
|
342
|
+
}
|
|
343
|
+
orientationChanged() {
|
|
344
|
+
if (this.$fastController.isConnected) {
|
|
345
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* @internal
|
|
350
|
+
*/
|
|
351
|
+
connectedCallback() {
|
|
352
|
+
super.connectedCallback();
|
|
353
|
+
this.proxy.setAttribute("type", "range");
|
|
354
|
+
this.direction = getDirection(this);
|
|
355
|
+
this.updateStepMultiplier();
|
|
356
|
+
this.setupTrackConstraints();
|
|
357
|
+
this.setupListeners();
|
|
358
|
+
this.setupDefaultValue();
|
|
359
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* @internal
|
|
363
|
+
*/
|
|
364
|
+
disconnectedCallback() {
|
|
365
|
+
this.setupListeners(true);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Increment the value by the step
|
|
369
|
+
*
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
increment() {
|
|
373
|
+
const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical
|
|
374
|
+
? Number(this.value) + Number(this.step)
|
|
375
|
+
: Number(this.value) - Number(this.step);
|
|
376
|
+
const incrementedVal = this.convertToConstrainedValue(newVal);
|
|
377
|
+
const incrementedValString = incrementedVal < Number(this.max) ? `${incrementedVal}` : `${this.max}`;
|
|
378
|
+
this.value = incrementedValString;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Decrement the value by the step
|
|
382
|
+
*
|
|
383
|
+
* @public
|
|
384
|
+
*/
|
|
385
|
+
decrement() {
|
|
386
|
+
const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical
|
|
387
|
+
? Number(this.value) - Number(this.step)
|
|
388
|
+
: Number(this.value) + Number(this.step);
|
|
389
|
+
const decrementedVal = this.convertToConstrainedValue(newVal);
|
|
390
|
+
const decrementedValString = decrementedVal > Number(this.min) ? `${decrementedVal}` : `${this.min}`;
|
|
391
|
+
this.value = decrementedValString;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Places the thumb based on the current value
|
|
395
|
+
*
|
|
396
|
+
* @public
|
|
397
|
+
* @param direction - writing mode
|
|
398
|
+
*/
|
|
399
|
+
setThumbPositionForOrientation(direction) {
|
|
400
|
+
const newPct = convertPixelToPercent(Number(this.value), Number(this.min), Number(this.max), direction);
|
|
401
|
+
const percentage = (1 - newPct) * 100;
|
|
402
|
+
if (this.orientation === Orientation.horizontal) {
|
|
403
|
+
this.position = this.isDragging
|
|
404
|
+
? `right: ${percentage}%; transition: none;`
|
|
405
|
+
: `right: ${percentage}%; transition: all 0.2s ease;`;
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
this.position = this.isDragging
|
|
409
|
+
? `bottom: ${percentage}%; transition: none;`
|
|
410
|
+
: `bottom: ${percentage}%; transition: all 0.2s ease;`;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Update the step multiplier used to ensure rounding errors from steps that
|
|
415
|
+
* are not whole numbers
|
|
416
|
+
*/
|
|
417
|
+
updateStepMultiplier() {
|
|
418
|
+
const stepString = this.step + "";
|
|
419
|
+
const decimalPlacesOfStep = !!(this.step % 1)
|
|
420
|
+
? stepString.length - stepString.indexOf(".") - 1
|
|
421
|
+
: 0;
|
|
422
|
+
this.stepMultiplier = Math.pow(10, decimalPlacesOfStep);
|
|
423
|
+
}
|
|
424
|
+
get midpoint() {
|
|
425
|
+
return `${this.convertToConstrainedValue((this.max + this.min) / 2)}`;
|
|
426
|
+
}
|
|
427
|
+
setupDefaultValue() {
|
|
428
|
+
if (typeof this.value === "string") {
|
|
429
|
+
if (this.value.length === 0) {
|
|
430
|
+
this.initialValue = this.midpoint;
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
const value = parseFloat(this.value);
|
|
434
|
+
if (!Number.isNaN(value) && (value < this.min || value > this.max)) {
|
|
435
|
+
this.value = this.midpoint;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
__decorate([
|
|
442
|
+
attr({ attribute: "readonly", mode: "boolean" })
|
|
443
|
+
], Slider$1.prototype, "readOnly", void 0);
|
|
444
|
+
__decorate([
|
|
445
|
+
observable
|
|
446
|
+
], Slider$1.prototype, "direction", void 0);
|
|
447
|
+
__decorate([
|
|
448
|
+
observable
|
|
449
|
+
], Slider$1.prototype, "isDragging", void 0);
|
|
450
|
+
__decorate([
|
|
451
|
+
observable
|
|
452
|
+
], Slider$1.prototype, "position", void 0);
|
|
453
|
+
__decorate([
|
|
454
|
+
observable
|
|
455
|
+
], Slider$1.prototype, "trackWidth", void 0);
|
|
456
|
+
__decorate([
|
|
457
|
+
observable
|
|
458
|
+
], Slider$1.prototype, "trackMinWidth", void 0);
|
|
459
|
+
__decorate([
|
|
460
|
+
observable
|
|
461
|
+
], Slider$1.prototype, "trackHeight", void 0);
|
|
462
|
+
__decorate([
|
|
463
|
+
observable
|
|
464
|
+
], Slider$1.prototype, "trackLeft", void 0);
|
|
465
|
+
__decorate([
|
|
466
|
+
observable
|
|
467
|
+
], Slider$1.prototype, "trackMinHeight", void 0);
|
|
468
|
+
__decorate([
|
|
469
|
+
observable
|
|
470
|
+
], Slider$1.prototype, "valueTextFormatter", void 0);
|
|
471
|
+
__decorate([
|
|
472
|
+
attr({ converter: nullableNumberConverter })
|
|
473
|
+
], Slider$1.prototype, "min", void 0);
|
|
474
|
+
__decorate([
|
|
475
|
+
attr({ converter: nullableNumberConverter })
|
|
476
|
+
], Slider$1.prototype, "max", void 0);
|
|
477
|
+
__decorate([
|
|
478
|
+
attr({ converter: nullableNumberConverter })
|
|
479
|
+
], Slider$1.prototype, "step", void 0);
|
|
480
|
+
__decorate([
|
|
481
|
+
attr
|
|
482
|
+
], Slider$1.prototype, "orientation", void 0);
|
|
483
|
+
__decorate([
|
|
484
|
+
attr
|
|
485
|
+
], Slider$1.prototype, "mode", void 0);
|
|
486
|
+
|
|
487
|
+
var css_248z = ":host {\n display: inline-block;\n width: 100%;\n}\n\n:host([orientation=vertical]) {\n height: 100%;\n min-height: calc(var(--_thumb-interaction-indicator-size) * 5);\n}\n\n.control {\n --_thumb-size: 12px;\n --_thumb-interaction-indicator-size: 36px;\n height: var(--_thumb-interaction-indicator-size);\n cursor: pointer;\n outline: none;\n user-select: none;\n}\n@supports selector(:focus-visible) {\n .control:focus {\n outline: none;\n }\n}\n.control .positioning-region {\n position: relative;\n}\n.control .track {\n position: absolute;\n background: var(--_track-background-color);\n border-radius: 4px;\n}\n.control .track .track-start {\n position: absolute;\n left: 0;\n height: 100%;\n background: var(--_track-start-background-color);\n border-radius: 4px;\n}\n.control .thumb-container {\n position: absolute;\n width: var(--_thumb-interaction-indicator-size);\n height: var(--_thumb-interaction-indicator-size);\n cursor: inherit;\n touch-action: none;\n}\n.control .thumb-container::before {\n position: absolute;\n display: block;\n width: var(--_thumb-interaction-indicator-size);\n height: var(--_thumb-interaction-indicator-size);\n background-color: var(--_track-start-background-color);\n border-radius: 50%;\n content: \"\";\n opacity: var(--_thumb-interaction-indicator-alpha, 0);\n transition: opacity 0.2s ease-out 0s;\n}\n.control .thumb-container::after {\n position: absolute;\n display: block;\n width: var(--_thumb-size);\n height: var(--_thumb-size);\n background-color: var(--_track-start-background-color);\n border-radius: 50%;\n content: \"\";\n inset: calc((var(--_thumb-interaction-indicator-size) - var(--_thumb-size)) / 2);\n}\n.control[aria-orientation=horizontal] {\n width: calc(100% - var(--_thumb-size));\n min-width: var(--_thumb-size);\n margin-left: calc(var(--_thumb-size) / 2);\n}\n.control[aria-orientation=horizontal] .track {\n top: calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);\n right: 0;\n left: 0;\n height: 2px;\n}\n.control[aria-orientation=horizontal] .track .mark {\n width: 100%;\n height: 4px;\n}\n.control[aria-orientation=horizontal] .thumb-container {\n transform: translateX(calc(var(--_thumb-interaction-indicator-size) / 2));\n}\n.control[aria-orientation=vertical] {\n height: calc(100% - var(--_thumb-interaction-indicator-size));\n min-height: var(--_thumb-interaction-indicator-size);\n margin-top: calc(var(--_thumb-interaction-indicator-size) / 2);\n}\n.control[aria-orientation=vertical] .positioning-region {\n height: 100%;\n}\n.control[aria-orientation=vertical] .track {\n left: calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);\n width: 2px;\n height: 100%;\n}\n.control[aria-orientation=vertical] .track .mark {\n width: 4px;\n height: 100%;\n}\n.control[aria-orientation=vertical] .track-start {\n top: 0;\n width: 100%;\n height: auto;\n}\n.control[aria-orientation=vertical] .thumb-container {\n transform: translateY(calc(var(--_thumb-interaction-indicator-size) / 2));\n}\n.control.disabled {\n --_track-background-color: var(--vvd-color-neutral-100);\n --_track-start-background-color: var(--vvd-color-neutral-500);\n cursor: not-allowed;\n pointer-events: none;\n}\n.control:not(.disabled) {\n --_track-background-color: var(--vvd-color-neutral-300);\n --_track-start-background-color: var(--vvd-color-canvas-text);\n}\n.control:not(.disabled) .thumb-container:hover {\n --_thumb-interaction-indicator-alpha: 0.12;\n}\n.control:not(.disabled) .thumb-container:active {\n --_thumb-interaction-indicator-alpha: 0.25;\n}\n\n.focus-indicator {\n --focus-inset: -3px;\n --focus-stroke-gap-color: transparent;\n border-radius: 50%;\n}\n.control:not(:focus-visible) .focus-indicator {\n display: none;\n}";
|
|
488
|
+
|
|
489
|
+
var global = global$1;
|
|
490
|
+
var fails = fails$1;
|
|
491
|
+
var uncurryThis = functionUncurryThis;
|
|
492
|
+
var toString = toString$1;
|
|
493
|
+
var trim = stringTrim.trim;
|
|
494
|
+
var whitespaces = whitespaces$1;
|
|
495
|
+
|
|
496
|
+
var charAt = uncurryThis(''.charAt);
|
|
497
|
+
var $parseFloat$1 = global.parseFloat;
|
|
498
|
+
var Symbol = global.Symbol;
|
|
499
|
+
var ITERATOR = Symbol && Symbol.iterator;
|
|
500
|
+
var FORCED = 1 / $parseFloat$1(whitespaces + '-0') !== -Infinity
|
|
501
|
+
// MS Edge 18- broken with boxed symbols
|
|
502
|
+
|| (ITERATOR && !fails(function () { $parseFloat$1(Object(ITERATOR)); }));
|
|
503
|
+
|
|
504
|
+
// `parseFloat` method
|
|
505
|
+
// https://tc39.es/ecma262/#sec-parsefloat-string
|
|
506
|
+
var numberParseFloat = FORCED ? function parseFloat(string) {
|
|
507
|
+
var trimmedString = trim(toString(string));
|
|
508
|
+
var result = $parseFloat$1(trimmedString);
|
|
509
|
+
return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;
|
|
510
|
+
} : $parseFloat$1;
|
|
511
|
+
|
|
512
|
+
var $ = _export;
|
|
513
|
+
var $parseFloat = numberParseFloat;
|
|
514
|
+
|
|
515
|
+
// `parseFloat` method
|
|
516
|
+
// https://tc39.es/ecma262/#sec-parsefloat-string
|
|
517
|
+
$({ global: true, forced: parseFloat != $parseFloat }, {
|
|
518
|
+
parseFloat: $parseFloat
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
class Slider extends Slider$1 {
|
|
522
|
+
constructor() {
|
|
523
|
+
super(...arguments);
|
|
524
|
+
this.markers = false;
|
|
525
|
+
}
|
|
526
|
+
valueChanged(previous, next) {
|
|
527
|
+
if (this.$fastController.isConnected) {
|
|
528
|
+
const nextAsNumber = parseFloat(next);
|
|
529
|
+
const value = Math.min(Math.max(this['convertToConstrainedValue'](nextAsNumber), this.min), this.max).toString();
|
|
530
|
+
if (value !== next) {
|
|
531
|
+
this.value = value;
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
super.valueChanged(previous, next);
|
|
535
|
+
this['setThumbPositionForOrientation'](this.direction);
|
|
536
|
+
this.$emit('change');
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
__decorate([attr({
|
|
541
|
+
mode: 'boolean'
|
|
542
|
+
}), __metadata("design:type", Object)], Slider.prototype, "markers", void 0);
|
|
543
|
+
|
|
544
|
+
let _ = t => t,
|
|
545
|
+
_t,
|
|
546
|
+
_t2;
|
|
547
|
+
const getClasses = ({
|
|
548
|
+
disabled
|
|
549
|
+
}) => classNames('control', ['disabled', Boolean(disabled)]);
|
|
550
|
+
const getMarkersTemplate = (isHorizontal, numMarkers) => {
|
|
551
|
+
const placeholder = isHorizontal ? ['right', 'center', '', '100% repeat-x'] : ['bottom', 'top', '100%', 'repeat-y'];
|
|
552
|
+
return html(_t || (_t = _`
|
|
553
|
+
<div class="mark" style="
|
|
554
|
+
background: linear-gradient(to ${0}, currentcolor 3px, transparent 0px)
|
|
555
|
+
0px ${0} / ${0} calc((100% - 3px) / ${0}) ${0}
|
|
556
|
+
"></div>`), placeholder[0], placeholder[1], placeholder[2], numMarkers, placeholder[3]);
|
|
557
|
+
};
|
|
558
|
+
const SliderTemplate = context => {
|
|
559
|
+
const focusTemplate = focusTemplateFactory(context);
|
|
560
|
+
return html(_t2 || (_t2 = _`
|
|
561
|
+
<div
|
|
562
|
+
role="slider"
|
|
563
|
+
tabindex="${0}"
|
|
564
|
+
aria-valuetext="${0}"
|
|
565
|
+
aria-valuenow="${0}"
|
|
566
|
+
aria-valuemin="${0}"
|
|
567
|
+
aria-valuemax="${0}"
|
|
568
|
+
aria-disabled="${0}"
|
|
569
|
+
aria-orientation="${0}"
|
|
570
|
+
class="${0} ${0}"
|
|
571
|
+
>
|
|
572
|
+
<div class="positioning-region">
|
|
573
|
+
<div ${0} class="track">
|
|
574
|
+
<div class="track-start" style="${0}"></div>
|
|
575
|
+
${0}
|
|
576
|
+
</div>
|
|
577
|
+
<div ${0} class="thumb-container" style="${0}">
|
|
578
|
+
${0}
|
|
579
|
+
</div>
|
|
580
|
+
</div>
|
|
581
|
+
</div>`), x => x.disabled ? null : 0, x => x.valueTextFormatter(x.value), x => x.value, x => x.min, x => x.max, x => x.disabled ? true : void 0, x => x.orientation, getClasses, x => x.orientation, ref('track'), x => x.position, x => x.markers ? getMarkersTemplate(x.orientation === Orientation.horizontal, Math.floor((x.max - x.min) / x.step)) : void 0, ref('thumb'), x => x.position, () => focusTemplate);
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
const sliderDefinition = Slider.compose({
|
|
585
|
+
baseName: 'slider',
|
|
586
|
+
template: SliderTemplate,
|
|
587
|
+
styles: css_248z
|
|
588
|
+
});
|
|
589
|
+
const sliderRegistries = [sliderDefinition(), ...focusRegistries];
|
|
590
|
+
const registerSlider = registerFactory(sliderRegistries);
|
|
591
|
+
|
|
592
|
+
export { sliderRegistries as a, registerSlider as r, sliderDefinition as s };
|