@vonage/vivid 3.48.0 → 3.49.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.cjs +21 -0
- package/accordion-item/index.cjs +18 -0
- package/action-group/index.cjs +7 -0
- package/alert/index.cjs +30 -0
- package/appearance-ui/index.cjs +96 -0
- package/audio-player/index.cjs +34 -0
- package/avatar/index.cjs +11 -0
- package/badge/index.cjs +14 -0
- package/banner/index.cjs +29 -0
- package/breadcrumb/index.cjs +13 -0
- package/breadcrumb-item/index.cjs +22 -0
- package/button/index.cjs +25 -0
- package/calendar/index.cjs +9 -0
- package/calendar-event/index.cjs +9 -0
- package/card/index.cjs +14 -0
- package/checkbox/index.cjs +21 -0
- package/combobox/index.cjs +39 -0
- package/data-grid/index.cjs +18 -0
- package/date-picker/index.cjs +40 -0
- package/date-range-picker/index.cjs +40 -0
- package/dialog/index.cjs +31 -0
- package/divider/index.cjs +8 -0
- package/elevation/index.cjs +7 -0
- package/empty-state/index.cjs +12 -0
- package/fab/index.cjs +22 -0
- package/file-picker/index.cjs +30 -0
- package/focus/index.cjs +7 -0
- package/header/index.cjs +8 -0
- package/icon/index.cjs +10 -0
- package/index.cjs +296 -0
- package/layout/index.cjs +7 -0
- package/listbox/index.cjs +77 -0
- package/locales/en-GB.cjs +106 -0
- package/locales/en-US.cjs +106 -0
- package/locales/ja-JP.cjs +106 -0
- package/locales/zh-CN.cjs +106 -0
- package/menu/index.cjs +32 -0
- package/menu-item/index.cjs +22 -0
- package/nav/index.cjs +6 -0
- package/nav-disclosure/index.cjs +17 -0
- package/nav-item/index.cjs +22 -0
- package/note/index.cjs +16 -0
- package/number-field/index.cjs +33 -0
- package/option/index.cjs +23 -0
- package/package.json +20 -2
- package/pagination/index.cjs +28 -0
- package/popup/index.cjs +27 -0
- package/progress/index.cjs +9 -0
- package/progress-ring/index.cjs +9 -0
- package/radio/index.cjs +14 -0
- package/radio-group/index.cjs +14 -0
- package/select/index.cjs +38 -0
- package/selectable-box/index.cjs +25 -0
- package/shared/Reflector.cjs +67 -0
- package/shared/_has.cjs +62 -0
- package/shared/affix.cjs +64 -0
- package/shared/affix.js +8 -4
- package/shared/anchor.cjs +90 -0
- package/shared/anchored.cjs +78 -0
- package/shared/apply-mixins.cjs +25 -0
- package/shared/aria-global.cjs +74 -0
- package/shared/aria.cjs +11 -0
- package/shared/aria2.cjs +11 -0
- package/shared/base-progress.cjs +72 -0
- package/shared/breadcrumb-item.cjs +27 -0
- package/shared/button.cjs +202 -0
- package/shared/calendar-event.cjs +41 -0
- package/shared/children.cjs +61 -0
- package/shared/class-names.cjs +17 -0
- package/shared/definition.cjs +165 -0
- package/shared/definition10.cjs +102 -0
- package/shared/definition11.cjs +164 -0
- package/shared/definition11.js +38 -36
- package/shared/definition12.cjs +50 -0
- package/shared/definition13.cjs +779 -0
- package/shared/definition14.cjs +157 -0
- package/shared/definition15.cjs +249 -0
- package/shared/definition16.cjs +746 -0
- package/shared/definition17.cjs +1372 -0
- package/shared/definition18.cjs +175 -0
- package/shared/definition19.cjs +416 -0
- package/shared/definition2.cjs +232 -0
- package/shared/definition20.cjs +278 -0
- package/shared/definition21.cjs +83 -0
- package/shared/definition22.cjs +74 -0
- package/shared/definition23.cjs +106 -0
- package/shared/definition24.cjs +2392 -0
- package/shared/definition25.cjs +75 -0
- package/shared/definition26.cjs +39 -0
- package/shared/definition27.cjs +66 -0
- package/shared/definition28.cjs +849 -0
- package/shared/definition29.cjs +72 -0
- package/shared/definition3.cjs +72 -0
- package/shared/definition30.cjs +98 -0
- package/shared/definition31.cjs +37 -0
- package/shared/definition32.cjs +24 -0
- package/shared/definition33.cjs +64 -0
- package/shared/definition34.cjs +533 -0
- package/shared/definition35.cjs +295 -0
- package/shared/definition36.cjs +219 -0
- package/shared/definition37.cjs +109 -0
- package/shared/definition38.cjs +92 -0
- package/shared/definition39.cjs +448 -0
- package/shared/definition4.cjs +198 -0
- package/shared/definition40.cjs +49 -0
- package/shared/definition41.cjs +694 -0
- package/shared/definition42.cjs +152 -0
- package/shared/definition43.cjs +113 -0
- package/shared/definition44.cjs +607 -0
- package/shared/definition45.cjs +152 -0
- package/shared/definition46.cjs +166 -0
- package/shared/definition47.cjs +35 -0
- package/shared/definition48.cjs +98 -0
- package/shared/definition49.cjs +543 -0
- package/shared/definition5.cjs +199 -0
- package/shared/definition50.cjs +52 -0
- package/shared/definition51.cjs +150 -0
- package/shared/definition52.cjs +304 -0
- package/shared/definition53.cjs +309 -0
- package/shared/definition54.cjs +146 -0
- package/shared/definition55.cjs +128 -0
- package/shared/definition56.cjs +99 -0
- package/shared/definition57.cjs +310 -0
- package/shared/definition58.cjs +20 -0
- package/shared/definition59.cjs +51 -0
- package/shared/definition6.cjs +83 -0
- package/shared/definition60.cjs +1810 -0
- package/shared/definition7.cjs +72 -0
- package/shared/definition8.cjs +152 -0
- package/shared/definition9.cjs +69 -0
- package/shared/dialog-polyfill.esm.cjs +862 -0
- package/shared/direction.cjs +22 -0
- package/shared/dom.cjs +23 -0
- package/shared/enums.cjs +87 -0
- package/shared/focus.cjs +8 -0
- package/shared/focus2.cjs +11 -0
- package/shared/form-associated.cjs +470 -0
- package/shared/icon.cjs +237 -0
- package/shared/index.cjs +5061 -0
- package/shared/index2.cjs +231 -0
- package/shared/key-codes.cjs +115 -0
- package/shared/key-codes2.cjs +14 -0
- package/shared/listbox.cjs +1072 -0
- package/shared/localized.cjs +11 -0
- package/shared/numbers.cjs +38 -0
- package/shared/patterns/affix.d.ts +5 -1
- package/shared/presentationDate.cjs +6192 -0
- package/shared/radio.cjs +153 -0
- package/shared/ref.cjs +43 -0
- package/shared/repeat.cjs +767 -0
- package/shared/select.options.cjs +12 -0
- package/shared/slotted.cjs +123 -0
- package/shared/start-end.cjs +52 -0
- package/shared/strings.cjs +11 -0
- package/shared/text-anchor.cjs +33 -0
- package/shared/text-anchor.template.cjs +48 -0
- package/shared/text-field.cjs +5 -0
- package/shared/text-field2.cjs +228 -0
- package/shared/tree-item.cjs +154 -0
- package/shared/when.cjs +31 -0
- package/side-drawer/index.cjs +8 -0
- package/slider/index.cjs +16 -0
- package/split-button/index.cjs +20 -0
- 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 +15 -0
- package/tab/index.cjs +17 -0
- package/tab-panel/index.cjs +6 -0
- package/tabs/index.cjs +24 -0
- package/tag/index.cjs +17 -0
- package/tag-group/index.cjs +7 -0
- package/text-anchor/index.cjs +24 -0
- package/text-area/index.cjs +25 -0
- package/text-field/index.cjs +27 -0
- package/toggletip/index.cjs +29 -0
- package/tooltip/index.cjs +29 -0
- package/tree-item/index.cjs +22 -0
- package/tree-view/index.cjs +14 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const definition = require('./definition11.cjs');
|
|
5
|
+
const definition$1 = require('./definition44.cjs');
|
|
6
|
+
const definition$2 = require('./definition58.cjs');
|
|
7
|
+
require('./affix.cjs');
|
|
8
|
+
require('./index2.cjs');
|
|
9
|
+
const localized = require('./localized.cjs');
|
|
10
|
+
const applyMixins = require('./apply-mixins.cjs');
|
|
11
|
+
const when = require('./when.cjs');
|
|
12
|
+
const ref = require('./ref.cjs');
|
|
13
|
+
const classNames = require('./class-names.cjs');
|
|
14
|
+
|
|
15
|
+
const styles = ".base{display:inline-flex;align-items:center;padding:8px;color:var(--vvd-color-canvas-text);user-select:none}.base .slider{min-inline-size:var(--audio-player-min-inline-size, 200px)}.base .controls{display:flex;align-items:center;gap:16px}.base .time-stamp{display:inline-flex}.base .time-stamp .current-time,.base .time-stamp .total-time{margin-inline:6px;min-inline-size:32px}\n";
|
|
16
|
+
|
|
17
|
+
var __defProp = Object.defineProperty;
|
|
18
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
19
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
+
if (decorator = decorators[i])
|
|
23
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
+
if (kind && result)
|
|
25
|
+
__defProp(target, key, result);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
class AudioPlayer extends index.FoundationElement {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.playButtonAriaLabel = null;
|
|
32
|
+
this.pauseButtonAriaLabel = null;
|
|
33
|
+
this.sliderAriaLabel = null;
|
|
34
|
+
this.disabled = false;
|
|
35
|
+
this.notime = false;
|
|
36
|
+
this.paused = true;
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
this._rewind = () => {
|
|
41
|
+
this.paused = true;
|
|
42
|
+
if (this._playerEl) {
|
|
43
|
+
this._playerEl.pause();
|
|
44
|
+
this._playerEl.currentTime = this._playerEl.duration * (Number(this._sliderEl.value) / 100);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
super.connectedCallback();
|
|
50
|
+
this.addEventListener("keydown", this._rewind);
|
|
51
|
+
this.addEventListener("mousedown", this._rewind);
|
|
52
|
+
this.addEventListener("keyup", this._rewind);
|
|
53
|
+
document.addEventListener("mouseup", this._rewind);
|
|
54
|
+
}
|
|
55
|
+
disconnectedCallback() {
|
|
56
|
+
super.disconnectedCallback();
|
|
57
|
+
this.removeEventListener("keydown", this._rewind);
|
|
58
|
+
this.removeEventListener("mousedown", this._rewind);
|
|
59
|
+
this.removeEventListener("keyup", this._rewind);
|
|
60
|
+
document.removeEventListener("mouseup", this._rewind);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
_togglePlay() {
|
|
66
|
+
if (this.paused) {
|
|
67
|
+
this._updateProgress();
|
|
68
|
+
this._playerEl.play();
|
|
69
|
+
} else {
|
|
70
|
+
this._playerEl.pause();
|
|
71
|
+
}
|
|
72
|
+
this.paused = !this.paused;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
_updateProgress() {
|
|
78
|
+
let currentTime;
|
|
79
|
+
const current = this._playerEl.currentTime;
|
|
80
|
+
const percent = current / this._playerEl.duration * 100;
|
|
81
|
+
if (this._sliderEl) {
|
|
82
|
+
this._sliderEl.value = percent.toString();
|
|
83
|
+
this._sliderEl.ariaValuetext = this._formatTime(current);
|
|
84
|
+
}
|
|
85
|
+
if (percent === 100) {
|
|
86
|
+
this.paused = true;
|
|
87
|
+
}
|
|
88
|
+
if (this._timeStampEl) {
|
|
89
|
+
currentTime = this._timeStampEl.querySelector(".current-time");
|
|
90
|
+
if (currentTime)
|
|
91
|
+
currentTime.textContent = this._formatTime(current);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
_updateTotalTime() {
|
|
98
|
+
let totalTime;
|
|
99
|
+
if (this._playerEl)
|
|
100
|
+
this.duration = this._playerEl.duration;
|
|
101
|
+
if (this._timeStampEl) {
|
|
102
|
+
totalTime = this._timeStampEl.querySelector(".total-time");
|
|
103
|
+
if (totalTime)
|
|
104
|
+
totalTime.textContent = this._formatTime(this._playerEl.duration);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
_formatTime(time) {
|
|
111
|
+
const min = Math.floor(time / 60);
|
|
112
|
+
const sec = Math.floor(time % 60);
|
|
113
|
+
return min + ":" + (sec < 10 ? "0" + sec : sec);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
__decorateClass([
|
|
117
|
+
index.attr({ attribute: "play-button-aria-label" })
|
|
118
|
+
], AudioPlayer.prototype, "playButtonAriaLabel", 2);
|
|
119
|
+
__decorateClass([
|
|
120
|
+
index.attr({ attribute: "pause-button-aria-label" })
|
|
121
|
+
], AudioPlayer.prototype, "pauseButtonAriaLabel", 2);
|
|
122
|
+
__decorateClass([
|
|
123
|
+
index.attr({ attribute: "slider-aria-label" })
|
|
124
|
+
], AudioPlayer.prototype, "sliderAriaLabel", 2);
|
|
125
|
+
__decorateClass([
|
|
126
|
+
index.attr
|
|
127
|
+
], AudioPlayer.prototype, "connotation", 2);
|
|
128
|
+
__decorateClass([
|
|
129
|
+
index.attr
|
|
130
|
+
], AudioPlayer.prototype, "src", 2);
|
|
131
|
+
__decorateClass([
|
|
132
|
+
index.attr({ mode: "boolean" })
|
|
133
|
+
], AudioPlayer.prototype, "disabled", 2);
|
|
134
|
+
__decorateClass([
|
|
135
|
+
index.attr({ mode: "boolean" })
|
|
136
|
+
], AudioPlayer.prototype, "notime", 2);
|
|
137
|
+
__decorateClass([
|
|
138
|
+
index.observable
|
|
139
|
+
], AudioPlayer.prototype, "paused", 2);
|
|
140
|
+
__decorateClass([
|
|
141
|
+
index.observable
|
|
142
|
+
], AudioPlayer.prototype, "duration", 2);
|
|
143
|
+
applyMixins.applyMixins(AudioPlayer, localized.Localized);
|
|
144
|
+
|
|
145
|
+
const getClasses = ({ disabled, duration }) => classNames.classNames(
|
|
146
|
+
["disabled", Boolean(disabled) || !Boolean(duration)]
|
|
147
|
+
);
|
|
148
|
+
function renderButton(context) {
|
|
149
|
+
const buttonTag = context.tagFor(definition.Button);
|
|
150
|
+
return index.html`<${buttonTag} class="pause" @click="${(x) => x._togglePlay()}"
|
|
151
|
+
icon="${(x) => x.paused ? "play-solid" : "pause-solid"}"
|
|
152
|
+
aria-label="${(x) => x.paused ? x.playButtonAriaLabel || x.locale.audioPlayer.playButtonLabel : x.pauseButtonAriaLabel || x.locale.audioPlayer.playButtonLabel}"
|
|
153
|
+
size='condensed'
|
|
154
|
+
connotation="${(x) => x.connotation}"
|
|
155
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
156
|
+
></${buttonTag}>`;
|
|
157
|
+
}
|
|
158
|
+
function renderSlider(context) {
|
|
159
|
+
const sliderTag = context.tagFor(definition$1.Slider);
|
|
160
|
+
return index.html`<${sliderTag}
|
|
161
|
+
${ref.ref("_sliderEl")} class="slider"
|
|
162
|
+
aria-label="${(x) => x.sliderAriaLabel || x.locale.audioPlayer.sliderLabel}"
|
|
163
|
+
value="0" max="100"
|
|
164
|
+
connotation="${(x) => x.connotation}"
|
|
165
|
+
?disabled="${(x) => x.disabled || !x.duration}">
|
|
166
|
+
</${sliderTag}>`;
|
|
167
|
+
}
|
|
168
|
+
function renderTimestamp() {
|
|
169
|
+
return index.html`
|
|
170
|
+
<div class="time-stamp" ${ref.ref("_timeStampEl")}>
|
|
171
|
+
<span class="current-time">0:00</span>
|
|
172
|
+
<span>/</span>
|
|
173
|
+
<span class="total-time">0:00</span>
|
|
174
|
+
</div>`;
|
|
175
|
+
}
|
|
176
|
+
const AudioPlayerTemplate = (context) => {
|
|
177
|
+
return index.html`
|
|
178
|
+
<div class="base ${getClasses}">
|
|
179
|
+
<div class="controls">
|
|
180
|
+
${renderButton(context)}
|
|
181
|
+
${when.when((x) => !x.notime, renderTimestamp())}
|
|
182
|
+
${renderSlider(context)}
|
|
183
|
+
</div>
|
|
184
|
+
<audio ${ref.ref("_playerEl")} src="${(x) => x.src}"
|
|
185
|
+
@timeupdate="${(x) => x._updateProgress()}" @loadedmetadata="${(x) => x._updateTotalTime()}"></audio>
|
|
186
|
+
</div>`;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const audioPlayerDefinition = AudioPlayer.compose({
|
|
190
|
+
baseName: "audio-player",
|
|
191
|
+
template: AudioPlayerTemplate,
|
|
192
|
+
styles
|
|
193
|
+
});
|
|
194
|
+
const audioPlayerRegistries = [audioPlayerDefinition(), ...definition.buttonRegistries, ...definition$1.sliderRegistries, ...definition$2.focusRegistries];
|
|
195
|
+
const registerAudioPlayer = index.registerFactory(audioPlayerRegistries);
|
|
196
|
+
|
|
197
|
+
exports.audioPlayerDefinition = audioPlayerDefinition;
|
|
198
|
+
exports.audioPlayerRegistries = audioPlayerRegistries;
|
|
199
|
+
exports.registerAudioPlayer = registerAudioPlayer;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const classNames = require('./class-names.cjs');
|
|
5
|
+
|
|
6
|
+
const styles = ".base{display:flex;flex-wrap:wrap;gap:8px}\n";
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
12
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
|
+
if (decorator = decorators[i])
|
|
14
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
15
|
+
if (kind && result)
|
|
16
|
+
__defProp(target, key, result);
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
class TagGroup extends index.FoundationElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.ariaLabel = null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
__decorateClass([
|
|
26
|
+
index.attr({ attribute: "aria-label" })
|
|
27
|
+
], TagGroup.prototype, "ariaLabel", 2);
|
|
28
|
+
|
|
29
|
+
const getClasses = (_) => classNames.classNames(
|
|
30
|
+
"base"
|
|
31
|
+
);
|
|
32
|
+
const TagGroupTemplate = () => {
|
|
33
|
+
return index.html`
|
|
34
|
+
<div class="${getClasses}" role="listbox" aria-orientation="horizontal" aria-label="${(x) => x.ariaLabel}">
|
|
35
|
+
<slot></slot>
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const tagGroupDefinition = TagGroup.compose(
|
|
41
|
+
{
|
|
42
|
+
baseName: "tag-group",
|
|
43
|
+
template: TagGroupTemplate,
|
|
44
|
+
styles
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
const tagGroupRegistries = [tagGroupDefinition()];
|
|
48
|
+
const registerTagGroup = index.registerFactory(tagGroupRegistries);
|
|
49
|
+
|
|
50
|
+
exports.registerTagGroup = registerTagGroup;
|
|
51
|
+
exports.tagGroupDefinition = tagGroupDefinition;
|
|
52
|
+
exports.tagGroupRegistries = tagGroupRegistries;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const definition = require('./definition26.cjs');
|
|
5
|
+
const definition$1 = require('./definition58.cjs');
|
|
6
|
+
const affix = require('./affix.cjs');
|
|
7
|
+
const applyMixins = require('./apply-mixins.cjs');
|
|
8
|
+
const focus = require('./focus2.cjs');
|
|
9
|
+
const icon = require('./icon.cjs');
|
|
10
|
+
const when = require('./when.cjs');
|
|
11
|
+
const classNames = require('./class-names.cjs');
|
|
12
|
+
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
16
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
17
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
18
|
+
if (decorator = decorators[i])
|
|
19
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
20
|
+
if (kind && result)
|
|
21
|
+
__defProp(target, key, result);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
class Tag extends index.FoundationElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.removable = false;
|
|
28
|
+
this.disabled = false;
|
|
29
|
+
this.selectable = false;
|
|
30
|
+
this.selected = false;
|
|
31
|
+
this.#select = () => {
|
|
32
|
+
if (!this.selectable || this.disabled) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.selected = !this.selected;
|
|
36
|
+
this.$emit("selected-change");
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
remove() {
|
|
40
|
+
if (!this.removable || this.selectable) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.$emit("removed");
|
|
44
|
+
this.parentElement && this.parentElement.removeChild(this);
|
|
45
|
+
}
|
|
46
|
+
#select;
|
|
47
|
+
handleKeydown(e) {
|
|
48
|
+
if (e.key === "Enter") {
|
|
49
|
+
this.#select();
|
|
50
|
+
}
|
|
51
|
+
if (e.key === "Delete" || e.key === "Backspace") {
|
|
52
|
+
this.remove();
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
handleClick() {
|
|
57
|
+
this.#select();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
__decorateClass([
|
|
61
|
+
index.attr
|
|
62
|
+
], Tag.prototype, "connotation", 2);
|
|
63
|
+
__decorateClass([
|
|
64
|
+
index.attr
|
|
65
|
+
], Tag.prototype, "shape", 2);
|
|
66
|
+
__decorateClass([
|
|
67
|
+
index.attr
|
|
68
|
+
], Tag.prototype, "appearance", 2);
|
|
69
|
+
__decorateClass([
|
|
70
|
+
index.attr
|
|
71
|
+
], Tag.prototype, "label", 2);
|
|
72
|
+
__decorateClass([
|
|
73
|
+
index.attr({ mode: "boolean" })
|
|
74
|
+
], Tag.prototype, "removable", 2);
|
|
75
|
+
__decorateClass([
|
|
76
|
+
index.attr({ mode: "boolean" })
|
|
77
|
+
], Tag.prototype, "disabled", 2);
|
|
78
|
+
__decorateClass([
|
|
79
|
+
index.attr({ mode: "boolean" })
|
|
80
|
+
], Tag.prototype, "selectable", 2);
|
|
81
|
+
__decorateClass([
|
|
82
|
+
index.attr({ mode: "boolean" })
|
|
83
|
+
], Tag.prototype, "selected", 2);
|
|
84
|
+
applyMixins.applyMixins(Tag, affix.AffixIcon);
|
|
85
|
+
|
|
86
|
+
const styles = ".base{--tag-block-size:calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2)));position:relative;display:inline-flex;box-sizing:border-box;align-items:center;background-color:var(--_appearance-color-fill);block-size:var(--tag-block-size);box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);column-gap:8px;font:var(--vvd-typography-base-bold);max-inline-size:100%;padding-inline:8px;vertical-align:middle}.base.connotation-cta{--_connotation-color-contrast: var(--vvd-tag-cta-contrast, var(--vvd-color-cta-800));--_connotation-color-soft: var(--vvd-tag-cta-soft, var(--vvd-color-cta-100));--_connotation-color-pale: var(--vvd-tag-cta-pale, var(--vvd-color-cta-300));--_connotation-color-fierce: var(--vvd-tag-cta-fierce, var(--vvd-color-cta-700));--_connotation-color-firm: var(--vvd-tag-cta-firm, var(--vvd-color-cta-600));--_connotation-color-faint: var(--vvd-tag-cta-faint, var(--vvd-color-cta-50));--_connotation-color-dim: var(--vvd-tag-cta-dim, var(--vvd-color-cta-200))}.base:not(.connotation-cta){--_connotation-color-contrast: var(--vvd-tag-accent-contrast, var(--vvd-color-neutral-800));--_connotation-color-soft: var(--vvd-tag-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-tag-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-tag-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-firm: var(--vvd-tag-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-tag-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-dim: var(--vvd-tag-accent-dim, var(--vvd-color-neutral-200))}.base{--_appearance-color-text: var(--_connotation-color-contrast);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base.appearance-duotone{--_appearance-color-text: var(--_connotation-color-firm);--_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-contrast);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.base:where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)).appearance-duotone{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-firm)}.base:where(:active,.active):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-contrast);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.base:where(:active,.active):where(:not(:disabled,.disabled)).appearance-duotone{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(:disabled,.disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: transparent}.base:where(:disabled,.disabled).appearance-duotone{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--vvd-color-neutral-100)}.base:where(.selected,[aria-current]):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-contrast);--_appearance-color-fill: var(--_connotation-color-pale);--_appearance-color-outline: transparent}.base:where(.selected,[aria-current]):where(:not(:disabled,.disabled)).appearance-duotone{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: var(--_connotation-color-pale)}.base:not(.shape-pill){border-radius:4px}.base.shape-pill{border-radius:14px}@supports selector(:focus-visible){.base:focus-visible{outline:none}}@supports (user-select: none){.base{user-select:none}}.base:not(.disabled){cursor:pointer}.base.disabled{cursor:not-allowed;pointer-events:none}.base.removable{cursor:auto}.label{overflow:hidden;max-inline-size:100%;text-overflow:ellipsis;white-space:nowrap}slot[name=icon]{font-size:calc(var(--tag-block-size) / 1.5);line-height:1}.dismiss-button{display:flex;align-items:center;background-color:var(--_appearance-color-fill);border-radius:inherit;cursor:pointer}.focus-indicator{--focus-stroke-gap-color: transparent}.base:not(:focus-visible) .focus-indicator{display:none}\n";
|
|
87
|
+
|
|
88
|
+
const getClasses = ({
|
|
89
|
+
connotation,
|
|
90
|
+
appearance,
|
|
91
|
+
shape,
|
|
92
|
+
disabled,
|
|
93
|
+
selectable,
|
|
94
|
+
removable,
|
|
95
|
+
selected
|
|
96
|
+
}) => classNames.classNames(
|
|
97
|
+
"base",
|
|
98
|
+
["disabled", disabled],
|
|
99
|
+
["selectable", selectable],
|
|
100
|
+
["selected", selectable && selected],
|
|
101
|
+
["removable", removable && !selectable],
|
|
102
|
+
[`connotation-${connotation}`, Boolean(connotation)],
|
|
103
|
+
[`appearance-${appearance}`, Boolean(appearance)],
|
|
104
|
+
[`shape-${shape}`, Boolean(shape)]
|
|
105
|
+
);
|
|
106
|
+
function renderDismissButton(iconTag) {
|
|
107
|
+
return index.html`
|
|
108
|
+
<span
|
|
109
|
+
aria-hidden="true"
|
|
110
|
+
class="dismiss-button"
|
|
111
|
+
@click="${(x) => x.remove()}">
|
|
112
|
+
<${iconTag} name="close-line"></${iconTag}>
|
|
113
|
+
</span>`;
|
|
114
|
+
}
|
|
115
|
+
const tagTemplate = (context) => {
|
|
116
|
+
const affixIconTemplate = affix.affixIconTemplateFactory(context);
|
|
117
|
+
const iconTag = context.tagFor(icon.Icon);
|
|
118
|
+
const focusTemplate = focus.focusTemplateFactory(context);
|
|
119
|
+
return index.html`
|
|
120
|
+
<span class="${getClasses}"
|
|
121
|
+
role="option"
|
|
122
|
+
aria-disabled="${(x) => x.disabled}"
|
|
123
|
+
aria-selected="${(x) => x.selectable}"
|
|
124
|
+
tabindex="${(x) => x.disabled ? null : 0}"
|
|
125
|
+
@keydown="${(x, c) => x.handleKeydown(c.event)}"
|
|
126
|
+
@click="${(x) => x.handleClick()}">
|
|
127
|
+
${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)}
|
|
128
|
+
${when.when((x) => x.label, (x) => index.html`<span class="label">${x.label}</span>`)}
|
|
129
|
+
${when.when((x) => x.removable && !x.selectable, renderDismissButton(iconTag))}
|
|
130
|
+
${when.when(
|
|
131
|
+
(x) => x.selectable && x.selected,
|
|
132
|
+
index.html`<${iconTag} class="selectable-icon" name="check-circle-solid"></${iconTag}>`
|
|
133
|
+
)}
|
|
134
|
+
${() => focusTemplate}
|
|
135
|
+
</span>`;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const tagDefinition = Tag.compose({
|
|
139
|
+
baseName: "tag",
|
|
140
|
+
template: tagTemplate,
|
|
141
|
+
styles,
|
|
142
|
+
shadowOptions: {
|
|
143
|
+
delegatesFocus: true
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
const tagRegistries = [tagDefinition(), ...definition.iconRegistries, ...definition$1.focusRegistries];
|
|
147
|
+
const registerTag = index.registerFactory(tagRegistries);
|
|
148
|
+
|
|
149
|
+
exports.registerTag = registerTag;
|
|
150
|
+
exports.tagDefinition = tagDefinition;
|