@vonage/vivid 4.5.0 → 4.7.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/custom-elements.json +947 -79
- package/elevation/index.cjs +1 -1
- package/elevation/index.js +1 -1
- package/index.cjs +62 -56
- package/index.js +20 -19
- package/lib/components.d.ts +1 -0
- package/lib/dialog/dialog.d.ts +0 -1
- package/lib/menu/menu.d.ts +2 -1
- package/lib/number-field/number-field.d.ts +3 -1
- package/lib/searchable-select/definition.d.ts +4 -0
- package/lib/searchable-select/locale.d.ts +9 -0
- package/lib/searchable-select/option-tag.d.ts +14 -0
- package/lib/searchable-select/option-tag.template.d.ts +4 -0
- package/lib/searchable-select/searchable-select.d.ts +29 -0
- package/lib/searchable-select/searchable-select.form-associated.d.ts +10 -0
- package/lib/searchable-select/searchable-select.template.d.ts +4 -0
- package/lib/select/select.d.ts +3 -1
- package/lib/tab/locale.d.ts +3 -0
- package/lib/tab/tab.d.ts +5 -1
- package/lib/tag/definition.d.ts +1 -0
- package/lib/text-field/text-field.d.ts +3 -1
- package/locales/de-DE.cjs +24 -0
- package/locales/de-DE.js +24 -0
- package/locales/en-GB.cjs +24 -0
- package/locales/en-GB.js +24 -0
- package/locales/en-US.cjs +24 -0
- package/locales/en-US.js +24 -0
- package/locales/ja-JP.cjs +24 -0
- package/locales/ja-JP.js +24 -0
- package/locales/zh-CN.cjs +24 -0
- package/locales/zh-CN.js +24 -0
- package/package.json +1 -1
- package/popup/index.cjs +1 -1
- package/popup/index.js +1 -1
- package/searchable-select/index.cjs +5 -0
- package/searchable-select/index.js +3 -0
- package/select/index.cjs +1 -1
- package/select/index.js +1 -1
- package/selectable-box/index.cjs +1 -1
- package/selectable-box/index.js +1 -1
- package/shared/definition11.cjs +1 -1
- package/shared/definition11.js +1 -1
- package/shared/definition14.cjs +1 -1
- package/shared/definition14.js +1 -1
- package/shared/definition16.cjs +1 -1
- package/shared/definition16.js +1 -1
- package/shared/definition18.cjs +2 -2
- package/shared/definition18.js +2 -2
- package/shared/definition19.cjs +2 -2
- package/shared/definition19.js +2 -2
- package/shared/definition20.cjs +14 -34
- package/shared/definition20.js +14 -34
- package/shared/definition21.cjs +2 -19
- package/shared/definition21.js +2 -19
- package/shared/definition26.cjs +1 -1
- package/shared/definition26.js +1 -1
- package/shared/definition29.cjs +4 -0
- package/shared/definition29.js +4 -0
- package/shared/definition30.cjs +2 -1
- package/shared/definition30.js +2 -1
- package/shared/definition35.cjs +12 -7
- package/shared/definition35.js +12 -7
- package/shared/definition36.cjs +50 -207
- package/shared/definition36.js +51 -207
- package/shared/definition4.cjs +1 -1
- package/shared/definition4.js +1 -1
- package/shared/definition42.cjs +1 -1
- package/shared/definition42.js +1 -1
- package/shared/definition43.cjs +1018 -647
- package/shared/definition43.js +1014 -644
- package/shared/definition44.cjs +723 -112
- package/shared/definition44.js +722 -111
- package/shared/definition45.cjs +121 -80
- package/shared/definition45.js +119 -78
- package/shared/definition46.cjs +81 -614
- package/shared/definition46.js +80 -612
- package/shared/definition47.cjs +608 -114
- package/shared/definition47.js +606 -113
- package/shared/definition48.cjs +116 -134
- package/shared/definition48.js +115 -133
- package/shared/definition49.cjs +149 -19
- package/shared/definition49.js +148 -18
- package/shared/definition5.cjs +1 -1
- package/shared/definition5.js +1 -1
- package/shared/definition50.cjs +21 -82
- package/shared/definition50.js +20 -81
- package/shared/definition51.cjs +77 -539
- package/shared/definition51.js +76 -538
- package/shared/definition52.cjs +568 -28
- package/shared/definition52.js +567 -27
- package/shared/definition53.cjs +28 -123
- package/shared/definition53.js +26 -122
- package/shared/definition54.cjs +115 -295
- package/shared/definition54.js +114 -294
- package/shared/definition55.cjs +251 -311
- package/shared/definition55.js +251 -311
- package/shared/definition56.cjs +299 -780
- package/shared/definition56.js +298 -779
- package/shared/definition57.cjs +800 -102
- package/shared/definition57.js +799 -101
- package/shared/definition58.cjs +92 -63
- package/shared/definition58.js +91 -62
- package/shared/definition59.cjs +117 -75
- package/shared/definition59.js +116 -74
- package/shared/definition60.cjs +70 -285
- package/shared/definition60.js +71 -286
- package/shared/definition61.cjs +274 -66146
- package/shared/definition61.js +273 -66145
- package/shared/definition62.cjs +66160 -27
- package/shared/definition62.js +66158 -25
- package/shared/definition63.cjs +24 -1952
- package/shared/definition63.js +23 -1950
- package/shared/definition64.cjs +1976 -0
- package/shared/definition64.js +1971 -0
- package/shared/listbox-option.cjs +204 -0
- package/shared/listbox-option.js +201 -0
- package/shared/listbox.cjs +3 -3
- package/shared/listbox.js +1 -1
- package/shared/localization/Locale.d.ts +4 -0
- package/shared/presentationDate.cjs +2 -2
- package/shared/presentationDate.js +2 -2
- package/shared/scrollIntoView.cjs +51 -0
- package/shared/scrollIntoView.js +49 -0
- package/shared/slider.template.cjs +1 -1
- package/shared/slider.template.js +1 -1
- package/shared/text-field.cjs +1 -1
- package/shared/text-field.js +1 -1
- package/shared/utils/scrollIntoView.d.ts +1 -0
- package/side-drawer/index.cjs +1 -1
- package/side-drawer/index.js +1 -1
- package/slider/index.cjs +1 -1
- package/slider/index.js +1 -1
- package/split-button/index.cjs +1 -1
- package/split-button/index.js +1 -1
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/switch/index.cjs +1 -1
- package/switch/index.js +1 -1
- package/tab/index.cjs +1 -1
- package/tab/index.js +1 -1
- package/tab-panel/index.cjs +1 -1
- package/tab-panel/index.js +1 -1
- package/tabs/index.cjs +1 -1
- package/tabs/index.js +1 -1
- package/tag/index.cjs +1 -1
- package/tag/index.js +1 -1
- package/tag-group/index.cjs +1 -1
- package/tag-group/index.js +1 -1
- package/text-area/index.cjs +1 -1
- package/text-area/index.js +1 -1
- package/text-field/index.cjs +1 -1
- package/text-field/index.js +1 -1
- package/time-picker/index.cjs +1 -1
- package/time-picker/index.js +1 -1
- package/toggletip/index.cjs +1 -1
- package/toggletip/index.js +1 -1
- package/tooltip/index.cjs +1 -1
- package/tooltip/index.js +1 -1
- package/tree-item/index.cjs +1 -1
- package/tree-item/index.js +1 -1
- package/tree-view/index.cjs +1 -1
- package/tree-view/index.js +1 -1
- package/video-player/index.cjs +1 -1
- package/video-player/index.js +1 -1
- package/vivid.api.json +295 -0
- package/api-extractor.json +0 -25
- package/shared/dialog-polyfill.esm.cjs +0 -862
- package/shared/dialog-polyfill.esm.js +0 -858
- package/tsdoc-metadata.json +0 -11
package/shared/definition45.cjs
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const index = require('./index.cjs');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const definition = require('./definition15.cjs');
|
|
5
|
+
const definition$1 = require('./definition41.cjs');
|
|
6
|
+
const enums = require('./enums.cjs');
|
|
7
|
+
const radio$1 = require('./radio.cjs');
|
|
6
8
|
const classNames = require('./class-names.cjs');
|
|
9
|
+
const when = require('./when.cjs');
|
|
10
|
+
|
|
11
|
+
const styles = ":host{display:flex}.base.connotation-cta{--_connotation-color-firm-all: var(--vvd-selectable-box-cta-firm-all, var(--vvd-color-cta-600));--_connotation-color-pale: var(--vvd-selectable-box-cta-pale, var(--vvd-color-cta-300));--_connotation-color-fierce: var(--vvd-selectable-box-cta-fierce, var(--vvd-color-cta-700));--_connotation-color-faint: var(--vvd-selectable-box-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-selectable-box-cta-soft, var(--vvd-color-cta-100))}.base:not(.connotation-cta){--_connotation-color-firm-all: var(--vvd-selectable-box-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-pale: var(--vvd-selectable-box-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-selectable-box-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-faint: var(--vvd-selectable-box-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-selectable-box-accent-soft, var(--vvd-color-neutral-100))}.base{--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-firm-all)}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: var(--_connotation-color-firm-all)}.base{position:relative;padding:var(--selectable-box-spacing, 16px);border:1px solid var(--_appearance-color-outline);border-radius:8px;background-color:var(--_appearance-color-fill);inline-size:100%;padding-block-start:calc(var(--selectable-box-spacing, 16px) + 36px);text-align:start}.base:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}.base.tight{overflow:hidden;min-height:calc(var(--selectable-box-spacing, 16px) * 2 + 22px);padding:0}.base.clickable{cursor:pointer}.control{position:absolute;inset-block-start:var(--selectable-box-spacing, 16px);inset-inline-end:var(--selectable-box-spacing, 16px)}";
|
|
7
12
|
|
|
8
13
|
var __defProp = Object.defineProperty;
|
|
9
14
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -14,97 +19,133 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
14
19
|
if (result) __defProp(target, key, result);
|
|
15
20
|
return result;
|
|
16
21
|
};
|
|
17
|
-
class
|
|
22
|
+
class SelectableBox extends index.FoundationElement {
|
|
18
23
|
constructor() {
|
|
19
24
|
super(...arguments);
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
25
|
+
this.ariaLabel = null;
|
|
26
|
+
this.checked = false;
|
|
27
|
+
this.clickable = false;
|
|
28
|
+
this.clickableBox = false;
|
|
29
|
+
this.tight = false;
|
|
24
30
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
_handleCheckedChange() {
|
|
35
|
+
if (this.controlType === "radio" && this.checked) return;
|
|
36
|
+
this.checked = !this.checked;
|
|
37
|
+
if (this.clickableBox || this.clickable) this.$emit("change");
|
|
32
38
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
_handleKeydown(event) {
|
|
43
|
+
if ((event.code === "Space" || event.code === "Enter") && (this.clickableBox || this.clickable))
|
|
44
|
+
return this._handleCheckedChange();
|
|
45
|
+
return true;
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
__decorateClass([
|
|
41
|
-
index.attr({
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
], SideDrawer.prototype, "alternate");
|
|
49
|
+
index.attr({ attribute: "aria-label" })
|
|
50
|
+
], SelectableBox.prototype, "ariaLabel");
|
|
45
51
|
__decorateClass([
|
|
46
|
-
index.attr({
|
|
47
|
-
|
|
48
|
-
})
|
|
49
|
-
], SideDrawer.prototype, "modal");
|
|
52
|
+
index.attr({ mode: "boolean" })
|
|
53
|
+
], SelectableBox.prototype, "checked");
|
|
50
54
|
__decorateClass([
|
|
51
|
-
index.attr({
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
], SideDrawer.prototype, "open");
|
|
55
|
+
index.attr({ mode: "boolean" })
|
|
56
|
+
], SelectableBox.prototype, "clickable");
|
|
55
57
|
__decorateClass([
|
|
56
|
-
index.attr({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
index.attr({ attribute: "clickable-box", mode: "boolean" })
|
|
59
|
+
], SelectableBox.prototype, "clickableBox");
|
|
60
|
+
__decorateClass([
|
|
61
|
+
index.attr
|
|
62
|
+
], SelectableBox.prototype, "connotation");
|
|
63
|
+
__decorateClass([
|
|
64
|
+
index.attr({ attribute: "control-type" })
|
|
65
|
+
], SelectableBox.prototype, "controlType");
|
|
66
|
+
__decorateClass([
|
|
67
|
+
index.attr({ mode: "boolean" })
|
|
68
|
+
], SelectableBox.prototype, "tight");
|
|
62
69
|
|
|
63
|
-
const getClasses = ({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
const getClasses = ({
|
|
71
|
+
connotation,
|
|
72
|
+
tight,
|
|
73
|
+
checked,
|
|
74
|
+
clickableBox,
|
|
75
|
+
clickable
|
|
76
|
+
}) => classNames.classNames(
|
|
77
|
+
"base",
|
|
78
|
+
[`connotation-${connotation}`, Boolean(connotation)],
|
|
79
|
+
["tight", tight],
|
|
80
|
+
["selected", checked],
|
|
81
|
+
["clickable", clickableBox || clickable],
|
|
82
|
+
["readonly", !clickableBox && !clickable]
|
|
68
83
|
);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
function handleControlChange(x) {
|
|
85
|
+
if (!x.clickableBox) x._handleCheckedChange();
|
|
86
|
+
}
|
|
87
|
+
function checkbox(context) {
|
|
88
|
+
const checkboxTag = context.tagFor(definition.Checkbox);
|
|
89
|
+
return index.html`${when.when(
|
|
90
|
+
(x) => x.controlType !== "radio",
|
|
91
|
+
index.html`
|
|
92
|
+
<${checkboxTag}
|
|
93
|
+
aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
|
|
94
|
+
@change="${(x) => handleControlChange(x)}"
|
|
95
|
+
class="control checkbox"
|
|
96
|
+
connotation="${(x) => x.connotation === "cta" ? enums.Connotation.CTA : enums.Connotation.Accent}"
|
|
97
|
+
:checked="${(x) => x.checked}"
|
|
98
|
+
inert="${(x) => x.clickableBox || x.clickable ? true : null}"
|
|
99
|
+
></${checkboxTag}>`
|
|
100
|
+
)} `;
|
|
101
|
+
}
|
|
102
|
+
function radio(context) {
|
|
103
|
+
const radioTag = context.tagFor(radio$1.Radio);
|
|
104
|
+
return index.html`${when.when(
|
|
105
|
+
(x) => x.controlType === "radio",
|
|
106
|
+
index.html`
|
|
107
|
+
<${radioTag}
|
|
108
|
+
aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
|
|
109
|
+
@change="${(x) => handleControlChange(x)}"
|
|
110
|
+
class="control radio"
|
|
111
|
+
connotation="${(x) => x.connotation === "cta" ? enums.Connotation.CTA : enums.Connotation.Accent}"
|
|
112
|
+
:checked="${(x) => x.checked}"
|
|
113
|
+
inert="${(x) => x.clickableBox || x.clickable ? true : null}"
|
|
114
|
+
></${radioTag}>`
|
|
115
|
+
)} `;
|
|
116
|
+
}
|
|
117
|
+
const SelectableBoxTemplate = (context) => {
|
|
118
|
+
return index.html`<template role="presentation">
|
|
119
|
+
<div
|
|
120
|
+
class="${getClasses}"
|
|
121
|
+
tabindex="${(x) => x.clickableBox || x.clickable ? "0" : null}"
|
|
122
|
+
role="${(x) => x.clickableBox || x.clickable ? "button" : null}"
|
|
123
|
+
aria-pressed="${(x) => x.clickableBox || x.clickable ? x.checked ? "true" : "false" : null}"
|
|
124
|
+
aria-label="${(x) => x.clickableBox || x.clickable ? x.ariaLabel : null}"
|
|
125
|
+
@keydown="${(x, c) => x._handleKeydown(c.event)}"
|
|
126
|
+
@click="${(x) => x.clickableBox || x.clickable ? x._handleCheckedChange() : null}"
|
|
127
|
+
>
|
|
128
|
+
${checkbox(context)} ${radio(context)}
|
|
129
|
+
<slot></slot>
|
|
130
|
+
</div>
|
|
131
|
+
</template>`;
|
|
98
132
|
};
|
|
99
133
|
|
|
100
|
-
const
|
|
101
|
-
baseName: "
|
|
102
|
-
template:
|
|
103
|
-
styles
|
|
134
|
+
const selectableBoxDefinition = SelectableBox.compose({
|
|
135
|
+
baseName: "selectable-box",
|
|
136
|
+
template: SelectableBoxTemplate,
|
|
137
|
+
styles,
|
|
138
|
+
shadowOptions: {
|
|
139
|
+
delegatesFocus: true
|
|
140
|
+
}
|
|
104
141
|
});
|
|
105
|
-
const
|
|
106
|
-
|
|
142
|
+
const selectableBoxRegistries = [
|
|
143
|
+
selectableBoxDefinition(),
|
|
144
|
+
...definition.checkboxRegistries,
|
|
145
|
+
...definition$1.radioRegistries
|
|
146
|
+
];
|
|
147
|
+
const registerSelectableBox = index.registerFactory(selectableBoxRegistries);
|
|
107
148
|
|
|
108
|
-
exports.
|
|
109
|
-
exports.
|
|
110
|
-
exports.
|
|
149
|
+
exports.registerSelectableBox = registerSelectableBox;
|
|
150
|
+
exports.selectableBoxDefinition = selectableBoxDefinition;
|
|
151
|
+
exports.selectableBoxRegistries = selectableBoxRegistries;
|
package/shared/definition45.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { F as FoundationElement, a as attr, h as html, r as registerFactory } from './index.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { C as Checkbox, a as checkboxRegistries } from './definition15.js';
|
|
3
|
+
import { a as radioRegistries } from './definition41.js';
|
|
4
|
+
import { C as Connotation } from './enums.js';
|
|
5
|
+
import { R as Radio } from './radio.js';
|
|
4
6
|
import { c as classNames } from './class-names.js';
|
|
7
|
+
import { w as when } from './when.js';
|
|
8
|
+
|
|
9
|
+
const styles = ":host{display:flex}.base.connotation-cta{--_connotation-color-firm-all: var(--vvd-selectable-box-cta-firm-all, var(--vvd-color-cta-600));--_connotation-color-pale: var(--vvd-selectable-box-cta-pale, var(--vvd-color-cta-300));--_connotation-color-fierce: var(--vvd-selectable-box-cta-fierce, var(--vvd-color-cta-700));--_connotation-color-faint: var(--vvd-selectable-box-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-selectable-box-cta-soft, var(--vvd-color-cta-100))}.base:not(.connotation-cta){--_connotation-color-firm-all: var(--vvd-selectable-box-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-pale: var(--vvd-selectable-box-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-selectable-box-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-faint: var(--vvd-selectable-box-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-selectable-box-accent-soft, var(--vvd-color-neutral-100))}.base{--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-firm-all)}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: var(--_connotation-color-firm-all)}.base{position:relative;padding:var(--selectable-box-spacing, 16px);border:1px solid var(--_appearance-color-outline);border-radius:8px;background-color:var(--_appearance-color-fill);inline-size:100%;padding-block-start:calc(var(--selectable-box-spacing, 16px) + 36px);text-align:start}.base:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}.base.tight{overflow:hidden;min-height:calc(var(--selectable-box-spacing, 16px) * 2 + 22px);padding:0}.base.clickable{cursor:pointer}.control{position:absolute;inset-block-start:var(--selectable-box-spacing, 16px);inset-inline-end:var(--selectable-box-spacing, 16px)}";
|
|
5
10
|
|
|
6
11
|
var __defProp = Object.defineProperty;
|
|
7
12
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -12,95 +17,131 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
12
17
|
if (result) __defProp(target, key, result);
|
|
13
18
|
return result;
|
|
14
19
|
};
|
|
15
|
-
class
|
|
20
|
+
class SelectableBox extends FoundationElement {
|
|
16
21
|
constructor() {
|
|
17
22
|
super(...arguments);
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
23
|
+
this.ariaLabel = null;
|
|
24
|
+
this.checked = false;
|
|
25
|
+
this.clickable = false;
|
|
26
|
+
this.clickableBox = false;
|
|
27
|
+
this.tight = false;
|
|
22
28
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
_handleCheckedChange() {
|
|
33
|
+
if (this.controlType === "radio" && this.checked) return;
|
|
34
|
+
this.checked = !this.checked;
|
|
35
|
+
if (this.clickableBox || this.clickable) this.$emit("change");
|
|
30
36
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
_handleKeydown(event) {
|
|
41
|
+
if ((event.code === "Space" || event.code === "Enter") && (this.clickableBox || this.clickable))
|
|
42
|
+
return this._handleCheckedChange();
|
|
43
|
+
return true;
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
__decorateClass([
|
|
39
|
-
attr({
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
], SideDrawer.prototype, "alternate");
|
|
47
|
+
attr({ attribute: "aria-label" })
|
|
48
|
+
], SelectableBox.prototype, "ariaLabel");
|
|
43
49
|
__decorateClass([
|
|
44
|
-
attr({
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
-
], SideDrawer.prototype, "modal");
|
|
50
|
+
attr({ mode: "boolean" })
|
|
51
|
+
], SelectableBox.prototype, "checked");
|
|
48
52
|
__decorateClass([
|
|
49
|
-
attr({
|
|
50
|
-
|
|
51
|
-
})
|
|
52
|
-
], SideDrawer.prototype, "open");
|
|
53
|
+
attr({ mode: "boolean" })
|
|
54
|
+
], SelectableBox.prototype, "clickable");
|
|
53
55
|
__decorateClass([
|
|
54
|
-
attr({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
attr({ attribute: "clickable-box", mode: "boolean" })
|
|
57
|
+
], SelectableBox.prototype, "clickableBox");
|
|
58
|
+
__decorateClass([
|
|
59
|
+
attr
|
|
60
|
+
], SelectableBox.prototype, "connotation");
|
|
61
|
+
__decorateClass([
|
|
62
|
+
attr({ attribute: "control-type" })
|
|
63
|
+
], SelectableBox.prototype, "controlType");
|
|
64
|
+
__decorateClass([
|
|
65
|
+
attr({ mode: "boolean" })
|
|
66
|
+
], SelectableBox.prototype, "tight");
|
|
60
67
|
|
|
61
|
-
const getClasses = ({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
const getClasses = ({
|
|
69
|
+
connotation,
|
|
70
|
+
tight,
|
|
71
|
+
checked,
|
|
72
|
+
clickableBox,
|
|
73
|
+
clickable
|
|
74
|
+
}) => classNames(
|
|
75
|
+
"base",
|
|
76
|
+
[`connotation-${connotation}`, Boolean(connotation)],
|
|
77
|
+
["tight", tight],
|
|
78
|
+
["selected", checked],
|
|
79
|
+
["clickable", clickableBox || clickable],
|
|
80
|
+
["readonly", !clickableBox && !clickable]
|
|
66
81
|
);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
function handleControlChange(x) {
|
|
83
|
+
if (!x.clickableBox) x._handleCheckedChange();
|
|
84
|
+
}
|
|
85
|
+
function checkbox(context) {
|
|
86
|
+
const checkboxTag = context.tagFor(Checkbox);
|
|
87
|
+
return html`${when(
|
|
88
|
+
(x) => x.controlType !== "radio",
|
|
89
|
+
html`
|
|
90
|
+
<${checkboxTag}
|
|
91
|
+
aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
|
|
92
|
+
@change="${(x) => handleControlChange(x)}"
|
|
93
|
+
class="control checkbox"
|
|
94
|
+
connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
|
|
95
|
+
:checked="${(x) => x.checked}"
|
|
96
|
+
inert="${(x) => x.clickableBox || x.clickable ? true : null}"
|
|
97
|
+
></${checkboxTag}>`
|
|
98
|
+
)} `;
|
|
99
|
+
}
|
|
100
|
+
function radio(context) {
|
|
101
|
+
const radioTag = context.tagFor(Radio);
|
|
102
|
+
return html`${when(
|
|
103
|
+
(x) => x.controlType === "radio",
|
|
104
|
+
html`
|
|
105
|
+
<${radioTag}
|
|
106
|
+
aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
|
|
107
|
+
@change="${(x) => handleControlChange(x)}"
|
|
108
|
+
class="control radio"
|
|
109
|
+
connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
|
|
110
|
+
:checked="${(x) => x.checked}"
|
|
111
|
+
inert="${(x) => x.clickableBox || x.clickable ? true : null}"
|
|
112
|
+
></${radioTag}>`
|
|
113
|
+
)} `;
|
|
114
|
+
}
|
|
115
|
+
const SelectableBoxTemplate = (context) => {
|
|
116
|
+
return html`<template role="presentation">
|
|
117
|
+
<div
|
|
118
|
+
class="${getClasses}"
|
|
119
|
+
tabindex="${(x) => x.clickableBox || x.clickable ? "0" : null}"
|
|
120
|
+
role="${(x) => x.clickableBox || x.clickable ? "button" : null}"
|
|
121
|
+
aria-pressed="${(x) => x.clickableBox || x.clickable ? x.checked ? "true" : "false" : null}"
|
|
122
|
+
aria-label="${(x) => x.clickableBox || x.clickable ? x.ariaLabel : null}"
|
|
123
|
+
@keydown="${(x, c) => x._handleKeydown(c.event)}"
|
|
124
|
+
@click="${(x) => x.clickableBox || x.clickable ? x._handleCheckedChange() : null}"
|
|
125
|
+
>
|
|
126
|
+
${checkbox(context)} ${radio(context)}
|
|
127
|
+
<slot></slot>
|
|
128
|
+
</div>
|
|
129
|
+
</template>`;
|
|
96
130
|
};
|
|
97
131
|
|
|
98
|
-
const
|
|
99
|
-
baseName: "
|
|
100
|
-
template:
|
|
101
|
-
styles
|
|
132
|
+
const selectableBoxDefinition = SelectableBox.compose({
|
|
133
|
+
baseName: "selectable-box",
|
|
134
|
+
template: SelectableBoxTemplate,
|
|
135
|
+
styles,
|
|
136
|
+
shadowOptions: {
|
|
137
|
+
delegatesFocus: true
|
|
138
|
+
}
|
|
102
139
|
});
|
|
103
|
-
const
|
|
104
|
-
|
|
140
|
+
const selectableBoxRegistries = [
|
|
141
|
+
selectableBoxDefinition(),
|
|
142
|
+
...checkboxRegistries,
|
|
143
|
+
...radioRegistries
|
|
144
|
+
];
|
|
145
|
+
const registerSelectableBox = registerFactory(selectableBoxRegistries);
|
|
105
146
|
|
|
106
|
-
export {
|
|
147
|
+
export { selectableBoxRegistries as a, registerSelectableBox as r, selectableBoxDefinition as s };
|