@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.
Files changed (182) hide show
  1. package/accordion/index.cjs +21 -0
  2. package/accordion-item/index.cjs +18 -0
  3. package/action-group/index.cjs +7 -0
  4. package/alert/index.cjs +30 -0
  5. package/appearance-ui/index.cjs +96 -0
  6. package/audio-player/index.cjs +34 -0
  7. package/avatar/index.cjs +11 -0
  8. package/badge/index.cjs +14 -0
  9. package/banner/index.cjs +29 -0
  10. package/breadcrumb/index.cjs +13 -0
  11. package/breadcrumb-item/index.cjs +22 -0
  12. package/button/index.cjs +25 -0
  13. package/calendar/index.cjs +9 -0
  14. package/calendar-event/index.cjs +9 -0
  15. package/card/index.cjs +14 -0
  16. package/checkbox/index.cjs +21 -0
  17. package/combobox/index.cjs +39 -0
  18. package/data-grid/index.cjs +18 -0
  19. package/date-picker/index.cjs +40 -0
  20. package/date-range-picker/index.cjs +40 -0
  21. package/dialog/index.cjs +31 -0
  22. package/divider/index.cjs +8 -0
  23. package/elevation/index.cjs +7 -0
  24. package/empty-state/index.cjs +12 -0
  25. package/fab/index.cjs +22 -0
  26. package/file-picker/index.cjs +30 -0
  27. package/focus/index.cjs +7 -0
  28. package/header/index.cjs +8 -0
  29. package/icon/index.cjs +10 -0
  30. package/index.cjs +296 -0
  31. package/layout/index.cjs +7 -0
  32. package/listbox/index.cjs +77 -0
  33. package/locales/en-GB.cjs +106 -0
  34. package/locales/en-US.cjs +106 -0
  35. package/locales/ja-JP.cjs +106 -0
  36. package/locales/zh-CN.cjs +106 -0
  37. package/menu/index.cjs +32 -0
  38. package/menu-item/index.cjs +22 -0
  39. package/nav/index.cjs +6 -0
  40. package/nav-disclosure/index.cjs +17 -0
  41. package/nav-item/index.cjs +22 -0
  42. package/note/index.cjs +16 -0
  43. package/number-field/index.cjs +33 -0
  44. package/option/index.cjs +23 -0
  45. package/package.json +20 -2
  46. package/pagination/index.cjs +28 -0
  47. package/popup/index.cjs +27 -0
  48. package/progress/index.cjs +9 -0
  49. package/progress-ring/index.cjs +9 -0
  50. package/radio/index.cjs +14 -0
  51. package/radio-group/index.cjs +14 -0
  52. package/select/index.cjs +38 -0
  53. package/selectable-box/index.cjs +25 -0
  54. package/shared/Reflector.cjs +67 -0
  55. package/shared/_has.cjs +62 -0
  56. package/shared/affix.cjs +64 -0
  57. package/shared/affix.js +8 -4
  58. package/shared/anchor.cjs +90 -0
  59. package/shared/anchored.cjs +78 -0
  60. package/shared/apply-mixins.cjs +25 -0
  61. package/shared/aria-global.cjs +74 -0
  62. package/shared/aria.cjs +11 -0
  63. package/shared/aria2.cjs +11 -0
  64. package/shared/base-progress.cjs +72 -0
  65. package/shared/breadcrumb-item.cjs +27 -0
  66. package/shared/button.cjs +202 -0
  67. package/shared/calendar-event.cjs +41 -0
  68. package/shared/children.cjs +61 -0
  69. package/shared/class-names.cjs +17 -0
  70. package/shared/definition.cjs +165 -0
  71. package/shared/definition10.cjs +102 -0
  72. package/shared/definition11.cjs +164 -0
  73. package/shared/definition11.js +38 -36
  74. package/shared/definition12.cjs +50 -0
  75. package/shared/definition13.cjs +779 -0
  76. package/shared/definition14.cjs +157 -0
  77. package/shared/definition15.cjs +249 -0
  78. package/shared/definition16.cjs +746 -0
  79. package/shared/definition17.cjs +1372 -0
  80. package/shared/definition18.cjs +175 -0
  81. package/shared/definition19.cjs +416 -0
  82. package/shared/definition2.cjs +232 -0
  83. package/shared/definition20.cjs +278 -0
  84. package/shared/definition21.cjs +83 -0
  85. package/shared/definition22.cjs +74 -0
  86. package/shared/definition23.cjs +106 -0
  87. package/shared/definition24.cjs +2392 -0
  88. package/shared/definition25.cjs +75 -0
  89. package/shared/definition26.cjs +39 -0
  90. package/shared/definition27.cjs +66 -0
  91. package/shared/definition28.cjs +849 -0
  92. package/shared/definition29.cjs +72 -0
  93. package/shared/definition3.cjs +72 -0
  94. package/shared/definition30.cjs +98 -0
  95. package/shared/definition31.cjs +37 -0
  96. package/shared/definition32.cjs +24 -0
  97. package/shared/definition33.cjs +64 -0
  98. package/shared/definition34.cjs +533 -0
  99. package/shared/definition35.cjs +295 -0
  100. package/shared/definition36.cjs +219 -0
  101. package/shared/definition37.cjs +109 -0
  102. package/shared/definition38.cjs +92 -0
  103. package/shared/definition39.cjs +448 -0
  104. package/shared/definition4.cjs +198 -0
  105. package/shared/definition40.cjs +49 -0
  106. package/shared/definition41.cjs +694 -0
  107. package/shared/definition42.cjs +152 -0
  108. package/shared/definition43.cjs +113 -0
  109. package/shared/definition44.cjs +607 -0
  110. package/shared/definition45.cjs +152 -0
  111. package/shared/definition46.cjs +166 -0
  112. package/shared/definition47.cjs +35 -0
  113. package/shared/definition48.cjs +98 -0
  114. package/shared/definition49.cjs +543 -0
  115. package/shared/definition5.cjs +199 -0
  116. package/shared/definition50.cjs +52 -0
  117. package/shared/definition51.cjs +150 -0
  118. package/shared/definition52.cjs +304 -0
  119. package/shared/definition53.cjs +309 -0
  120. package/shared/definition54.cjs +146 -0
  121. package/shared/definition55.cjs +128 -0
  122. package/shared/definition56.cjs +99 -0
  123. package/shared/definition57.cjs +310 -0
  124. package/shared/definition58.cjs +20 -0
  125. package/shared/definition59.cjs +51 -0
  126. package/shared/definition6.cjs +83 -0
  127. package/shared/definition60.cjs +1810 -0
  128. package/shared/definition7.cjs +72 -0
  129. package/shared/definition8.cjs +152 -0
  130. package/shared/definition9.cjs +69 -0
  131. package/shared/dialog-polyfill.esm.cjs +862 -0
  132. package/shared/direction.cjs +22 -0
  133. package/shared/dom.cjs +23 -0
  134. package/shared/enums.cjs +87 -0
  135. package/shared/focus.cjs +8 -0
  136. package/shared/focus2.cjs +11 -0
  137. package/shared/form-associated.cjs +470 -0
  138. package/shared/icon.cjs +237 -0
  139. package/shared/index.cjs +5061 -0
  140. package/shared/index2.cjs +231 -0
  141. package/shared/key-codes.cjs +115 -0
  142. package/shared/key-codes2.cjs +14 -0
  143. package/shared/listbox.cjs +1072 -0
  144. package/shared/localized.cjs +11 -0
  145. package/shared/numbers.cjs +38 -0
  146. package/shared/patterns/affix.d.ts +5 -1
  147. package/shared/presentationDate.cjs +6192 -0
  148. package/shared/radio.cjs +153 -0
  149. package/shared/ref.cjs +43 -0
  150. package/shared/repeat.cjs +767 -0
  151. package/shared/select.options.cjs +12 -0
  152. package/shared/slotted.cjs +123 -0
  153. package/shared/start-end.cjs +52 -0
  154. package/shared/strings.cjs +11 -0
  155. package/shared/text-anchor.cjs +33 -0
  156. package/shared/text-anchor.template.cjs +48 -0
  157. package/shared/text-field.cjs +5 -0
  158. package/shared/text-field2.cjs +228 -0
  159. package/shared/tree-item.cjs +154 -0
  160. package/shared/when.cjs +31 -0
  161. package/side-drawer/index.cjs +8 -0
  162. package/slider/index.cjs +16 -0
  163. package/split-button/index.cjs +20 -0
  164. package/styles/core/all.css +1 -1
  165. package/styles/core/theme.css +1 -1
  166. package/styles/core/typography.css +1 -1
  167. package/styles/tokens/theme-dark.css +4 -4
  168. package/styles/tokens/theme-light.css +4 -4
  169. package/styles/tokens/vivid-2-compat.css +1 -1
  170. package/switch/index.cjs +15 -0
  171. package/tab/index.cjs +17 -0
  172. package/tab-panel/index.cjs +6 -0
  173. package/tabs/index.cjs +24 -0
  174. package/tag/index.cjs +17 -0
  175. package/tag-group/index.cjs +7 -0
  176. package/text-anchor/index.cjs +24 -0
  177. package/text-area/index.cjs +25 -0
  178. package/text-field/index.cjs +27 -0
  179. package/toggletip/index.cjs +29 -0
  180. package/tooltip/index.cjs +29 -0
  181. package/tree-item/index.cjs +22 -0
  182. package/tree-view/index.cjs +14 -0
@@ -0,0 +1,295 @@
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 ariaGlobal = require('./aria-global.cjs');
8
+ const startEnd = require('./start-end.cjs');
9
+ const applyMixins = require('./apply-mixins.cjs');
10
+ const dom = require('./dom.cjs');
11
+ const focus = require('./focus2.cjs');
12
+ require('./index2.cjs');
13
+ const when = require('./when.cjs');
14
+ const classNames = require('./class-names.cjs');
15
+
16
+ /**
17
+ * Determines if the element is a {@link (ListboxOption:class)}
18
+ *
19
+ * @param element - the element to test.
20
+ * @public
21
+ */
22
+ function isListboxOption(el) {
23
+ return (dom.isHTMLElement(el) &&
24
+ (el.getAttribute("role") === "option" ||
25
+ el instanceof HTMLOptionElement));
26
+ }
27
+ /**
28
+ * An Option Custom HTML Element.
29
+ * Implements {@link https://www.w3.org/TR/wai-aria-1.1/#option | ARIA option }.
30
+ *
31
+ * @slot start - Content which can be provided before the listbox option content
32
+ * @slot end - Content which can be provided after the listbox option content
33
+ * @slot - The default slot for listbox option content
34
+ * @csspart content - Wraps the listbox option content
35
+ *
36
+ * @public
37
+ */
38
+ let ListboxOption$1 = class ListboxOption extends index.FoundationElement {
39
+ constructor(text, value, defaultSelected, selected) {
40
+ super();
41
+ /**
42
+ * The defaultSelected state of the option.
43
+ * @public
44
+ */
45
+ this.defaultSelected = false;
46
+ /**
47
+ * Tracks whether the "selected" property has been changed.
48
+ * @internal
49
+ */
50
+ this.dirtySelected = false;
51
+ /**
52
+ * The checked state of the control.
53
+ *
54
+ * @public
55
+ */
56
+ this.selected = this.defaultSelected;
57
+ /**
58
+ * Track whether the value has been changed from the initial value
59
+ */
60
+ this.dirtyValue = false;
61
+ if (text) {
62
+ this.textContent = text;
63
+ }
64
+ if (value) {
65
+ this.initialValue = value;
66
+ }
67
+ if (defaultSelected) {
68
+ this.defaultSelected = defaultSelected;
69
+ }
70
+ if (selected) {
71
+ this.selected = selected;
72
+ }
73
+ this.proxy = new Option(`${this.textContent}`, this.initialValue, this.defaultSelected, this.selected);
74
+ this.proxy.disabled = this.disabled;
75
+ }
76
+ /**
77
+ * Updates the ariaChecked property when the checked property changes.
78
+ *
79
+ * @param prev - the previous checked value
80
+ * @param next - the current checked value
81
+ *
82
+ * @public
83
+ */
84
+ checkedChanged(prev, next) {
85
+ if (typeof next === "boolean") {
86
+ this.ariaChecked = next ? "true" : "false";
87
+ return;
88
+ }
89
+ this.ariaChecked = null;
90
+ }
91
+ /**
92
+ * Updates the proxy's text content when the default slot changes.
93
+ * @param prev - the previous content value
94
+ * @param next - the current content value
95
+ *
96
+ * @internal
97
+ */
98
+ contentChanged(prev, next) {
99
+ if (this.proxy instanceof HTMLOptionElement) {
100
+ this.proxy.textContent = this.textContent;
101
+ }
102
+ this.$emit("contentchange", null, { bubbles: true });
103
+ }
104
+ defaultSelectedChanged() {
105
+ if (!this.dirtySelected) {
106
+ this.selected = this.defaultSelected;
107
+ if (this.proxy instanceof HTMLOptionElement) {
108
+ this.proxy.selected = this.defaultSelected;
109
+ }
110
+ }
111
+ }
112
+ disabledChanged(prev, next) {
113
+ this.ariaDisabled = this.disabled ? "true" : "false";
114
+ if (this.proxy instanceof HTMLOptionElement) {
115
+ this.proxy.disabled = this.disabled;
116
+ }
117
+ }
118
+ selectedAttributeChanged() {
119
+ this.defaultSelected = this.selectedAttribute;
120
+ if (this.proxy instanceof HTMLOptionElement) {
121
+ this.proxy.defaultSelected = this.defaultSelected;
122
+ }
123
+ }
124
+ selectedChanged() {
125
+ this.ariaSelected = this.selected ? "true" : "false";
126
+ if (!this.dirtySelected) {
127
+ this.dirtySelected = true;
128
+ }
129
+ if (this.proxy instanceof HTMLOptionElement) {
130
+ this.proxy.selected = this.selected;
131
+ }
132
+ }
133
+ initialValueChanged(previous, next) {
134
+ // If the value is clean and the component is connected to the DOM
135
+ // then set value equal to the attribute value.
136
+ if (!this.dirtyValue) {
137
+ this.value = this.initialValue;
138
+ this.dirtyValue = false;
139
+ }
140
+ }
141
+ get label() {
142
+ var _a;
143
+ return (_a = this.value) !== null && _a !== void 0 ? _a : this.text;
144
+ }
145
+ get text() {
146
+ var _a, _b;
147
+ return (_b = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.replace(/\s+/g, " ").trim()) !== null && _b !== void 0 ? _b : "";
148
+ }
149
+ set value(next) {
150
+ const newValue = `${next !== null && next !== void 0 ? next : ""}`;
151
+ this._value = newValue;
152
+ this.dirtyValue = true;
153
+ if (this.proxy instanceof HTMLOptionElement) {
154
+ this.proxy.value = newValue;
155
+ }
156
+ index.Observable.notify(this, "value");
157
+ }
158
+ get value() {
159
+ var _a;
160
+ index.Observable.track(this, "value");
161
+ return (_a = this._value) !== null && _a !== void 0 ? _a : this.text;
162
+ }
163
+ get form() {
164
+ return this.proxy ? this.proxy.form : null;
165
+ }
166
+ };
167
+ index.__decorate([
168
+ index.observable
169
+ ], ListboxOption$1.prototype, "checked", void 0);
170
+ index.__decorate([
171
+ index.observable
172
+ ], ListboxOption$1.prototype, "content", void 0);
173
+ index.__decorate([
174
+ index.observable
175
+ ], ListboxOption$1.prototype, "defaultSelected", void 0);
176
+ index.__decorate([
177
+ index.attr({ mode: "boolean" })
178
+ ], ListboxOption$1.prototype, "disabled", void 0);
179
+ index.__decorate([
180
+ index.attr({ attribute: "selected", mode: "boolean" })
181
+ ], ListboxOption$1.prototype, "selectedAttribute", void 0);
182
+ index.__decorate([
183
+ index.observable
184
+ ], ListboxOption$1.prototype, "selected", void 0);
185
+ index.__decorate([
186
+ index.attr({ attribute: "value", mode: "fromView" })
187
+ ], ListboxOption$1.prototype, "initialValue", void 0);
188
+ /**
189
+ * States and properties relating to the ARIA `option` role.
190
+ *
191
+ * @public
192
+ */
193
+ class DelegatesARIAListboxOption {
194
+ }
195
+ index.__decorate([
196
+ index.observable
197
+ ], DelegatesARIAListboxOption.prototype, "ariaChecked", void 0);
198
+ index.__decorate([
199
+ index.observable
200
+ ], DelegatesARIAListboxOption.prototype, "ariaPosInSet", void 0);
201
+ index.__decorate([
202
+ index.observable
203
+ ], DelegatesARIAListboxOption.prototype, "ariaSelected", void 0);
204
+ index.__decorate([
205
+ index.observable
206
+ ], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
207
+ applyMixins.applyMixins(DelegatesARIAListboxOption, ariaGlobal.ARIAGlobalStatesAndProperties);
208
+ applyMixins.applyMixins(ListboxOption$1, startEnd.StartEnd, DelegatesARIAListboxOption);
209
+
210
+ var __defProp = Object.defineProperty;
211
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
212
+ var __decorateClass = (decorators, target, key, kind) => {
213
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
214
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
215
+ if (decorator = decorators[i])
216
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
217
+ if (kind && result)
218
+ __defProp(target, key, result);
219
+ return result;
220
+ };
221
+ class ListboxOption extends ListboxOption$1 {
222
+ // #region overrides base class accessor
223
+ set text(value) {
224
+ this._text = value;
225
+ }
226
+ get text() {
227
+ return this._text ?? "";
228
+ }
229
+ get label() {
230
+ return this._label ?? this.text;
231
+ }
232
+ set label(value) {
233
+ this._label = value;
234
+ }
235
+ // #endregion overrides
236
+ }
237
+ __decorateClass([
238
+ index.attr({
239
+ attribute: "text"
240
+ })
241
+ ], ListboxOption.prototype, "_text", 2);
242
+ __decorateClass([
243
+ index.attr({
244
+ attribute: "label"
245
+ })
246
+ ], ListboxOption.prototype, "_label", 2);
247
+ applyMixins.applyMixins(ListboxOption, affix.AffixIconWithTrailing);
248
+
249
+ const getClasses = ({
250
+ icon,
251
+ disabled,
252
+ selected,
253
+ checked
254
+ }) => classNames.classNames(
255
+ "base",
256
+ ["disabled", disabled],
257
+ ["selected", Boolean(selected)],
258
+ ["active", Boolean(checked)],
259
+ ["icon", Boolean(icon)]
260
+ );
261
+ const ListboxOptionTemplate = (context) => {
262
+ const affixIconTemplate = affix.affixIconTemplateFactory(context);
263
+ const focusTemplate = focus.focusTemplateFactory(context);
264
+ return index.html`
265
+ <template
266
+ aria-checked="${(x) => x.ariaChecked}"
267
+ aria-disabled="${(x) => x.ariaDisabled}"
268
+ aria-posinset="${(x) => x.ariaPosInSet}"
269
+ aria-selected="${(x) => x.ariaSelected}"
270
+ aria-setsize="${(x) => x.ariaSetSize}"
271
+ role="option">
272
+ <div class="${getClasses}">
273
+ ${() => focusTemplate}
274
+ ${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)}
275
+ ${when.when((x) => x.text, index.html`<div class="text">${(x) => x.text}</div>`)}
276
+ </div>
277
+ </template>
278
+ `;
279
+ };
280
+
281
+ const styles = ":host([disabled]){cursor:not-allowed}.base{position:relative;display:flex;box-sizing:border-box;align-items:center;background-color:var(--_appearance-color-fill);border-radius:8px;box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_option-appearance-color-text, var(--_appearance-color-text));font:var(--vvd-typography-base);gap:12px;hyphens:auto;inline-size:100%;min-block-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-inline:16px;vertical-align:middle;word-break:break-word}.base{--_connotation-color-primary: var(--vvd-option-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-option-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-option-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-faint: var(--vvd-option-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-option-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-option-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-dim: var(--vvd-option-accent-dim, var(--vvd-color-neutral-200))}.base{--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.base:where(:disabled,.disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(:active,.active):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.selected,[aria-current]):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.base:where(.selected,[aria-current]):where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-pale);--_appearance-color-outline: transparent}@supports (user-select: none){.base{user-select:none}}.base:not(.disabled){cursor:pointer}.base.disabled{pointer-events:none}.base .text{font:var(--vvd-typography-base)}slot[name=icon]{font-size:20px;line-height:1}.base:not(.disabled,.selected) slot[name=icon]{color:var(--vvd-color-neutral-600)}.focus-indicator{--focus-stroke-color: var(--vvd-color-neutral-500);--focus-stroke-gap-color: transparent}:host(:not([aria-checked=true])) .focus-indicator{display:none}\n";
282
+
283
+ const listboxOptionDefinition = ListboxOption.compose({
284
+ baseName: "option",
285
+ template: ListboxOptionTemplate,
286
+ styles
287
+ });
288
+ const listboxOptionRegistries = [listboxOptionDefinition(), ...definition.iconRegistries, ...definition$1.focusRegistries];
289
+ const registerOption = index.registerFactory(listboxOptionRegistries);
290
+
291
+ exports.ListboxOption = ListboxOption;
292
+ exports.isListboxOption = isListboxOption;
293
+ exports.listboxOptionDefinition = listboxOptionDefinition;
294
+ exports.listboxOptionRegistries = listboxOptionRegistries;
295
+ exports.registerOption = registerOption;
@@ -0,0 +1,219 @@
1
+ 'use strict';
2
+
3
+ const definition = require('./definition11.cjs');
4
+ const index = require('./index.cjs');
5
+ const enums = require('./enums.cjs');
6
+ const slotted = require('./slotted.cjs');
7
+ const ref = require('./ref.cjs');
8
+ const children = require('./children.cjs');
9
+ const repeat = require('./repeat.cjs');
10
+ const classNames = require('./class-names.cjs');
11
+ const when = require('./when.cjs');
12
+
13
+ const styles = ".control{display:inline-flex;justify-content:space-between}.control:not(.shape-pill){border-radius:4px}.control.shape-pill{border-radius:14px}.buttons-wrapper{display:flex;column-gap:4px}.vwc-pagination-button[size=super-condensed]{--base-size:calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.vwc-pagination-button[size=condensed]{--base-size:calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.vwc-pagination-button[size=normal]{--base-size:calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.vwc-pagination-button::part(button){padding-inline:0}.dots{align-self:center;text-align:center}.dots:not(.size-super-condensed){font:var(--vvd-typography-base-bold)}.dots.size-super-condensed{font:var(--vvd-typography-base-condensed-bold);inline-size:calc(1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}.dots.size-condensed{inline-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}.dots.size-normal{inline-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}\n";
14
+
15
+ var __defProp = Object.defineProperty;
16
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17
+ var __decorateClass = (decorators, target, key, kind) => {
18
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
19
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
20
+ if (decorator = decorators[i])
21
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
22
+ if (kind && result)
23
+ __defProp(target, key, result);
24
+ return result;
25
+ };
26
+ const MAX_DIGITS_AND_PLACEHOLDERS = 7;
27
+ const totalConverter = {
28
+ fromView: (value) => parseInt(value, 10),
29
+ toView: (value) => value.toString()
30
+ };
31
+ class Pagination extends index.FoundationElement {
32
+ constructor() {
33
+ super();
34
+ this.navIcons = false;
35
+ this.total = 0;
36
+ this.selectedIndex = 0;
37
+ this.addEventListener("tabpressed", (e) => {
38
+ const { value: currentLabel, shiftKey } = e.detail;
39
+ const index = this.paginationButtons.findIndex((button) => Number(button.label) === currentLabel);
40
+ const focusDirection = shiftKey ? -1 : 1;
41
+ const newIndex = index + focusDirection;
42
+ if (newIndex < 0) {
43
+ return this.prevButton.focus();
44
+ }
45
+ if (newIndex > this.paginationButtons.length - 1) {
46
+ return this.nextButton.focus();
47
+ }
48
+ this.paginationButtons && this.paginationButtons[index + focusDirection].focus();
49
+ });
50
+ }
51
+ get pagesList() {
52
+ return new Array(this.total < MAX_DIGITS_AND_PLACEHOLDERS ? this.total : MAX_DIGITS_AND_PLACEHOLDERS).fill(0).map((_, i, arr) => {
53
+ if (i === 0)
54
+ return 1;
55
+ if (i === arr.length - 1)
56
+ return this.total;
57
+ if (this.selectedIndex !== void 0 && this.total > MAX_DIGITS_AND_PLACEHOLDERS) {
58
+ if (this.selectedIndex < 4) {
59
+ if (i === MAX_DIGITS_AND_PLACEHOLDERS - 2)
60
+ return "...";
61
+ }
62
+ if (this.selectedIndex >= 4 && this.selectedIndex <= this.total - 5) {
63
+ if (i > 1 && i < MAX_DIGITS_AND_PLACEHOLDERS - 2)
64
+ return this.selectedIndex + (i - 2);
65
+ if (i === 1 || i === MAX_DIGITS_AND_PLACEHOLDERS - 2)
66
+ return "...";
67
+ }
68
+ if (this.selectedIndex > this.total - 5) {
69
+ if (i > 1)
70
+ return this.total - (6 - i);
71
+ if (i === 1)
72
+ return "...";
73
+ }
74
+ }
75
+ return i + 1;
76
+ });
77
+ }
78
+ totalChanged(_, newValue) {
79
+ if (newValue < 0) {
80
+ this.total = 0;
81
+ }
82
+ this.selectedIndex = 0;
83
+ }
84
+ selectedIndexChanged(oldValue, newValue) {
85
+ if (oldValue === void 0)
86
+ return;
87
+ this.$emit("pagination-change", { selectedIndex: newValue, total: this.total, oldIndex: oldValue });
88
+ }
89
+ paginationButtonsChanged(_, newValue) {
90
+ newValue.forEach((button) => {
91
+ button.shadowRoot.querySelector("button").setAttribute("part", "button");
92
+ });
93
+ }
94
+ }
95
+ __decorateClass([
96
+ index.attr
97
+ ], Pagination.prototype, "size", 2);
98
+ __decorateClass([
99
+ index.attr
100
+ ], Pagination.prototype, "shape", 2);
101
+ __decorateClass([
102
+ index.observable
103
+ ], Pagination.prototype, "paginationButtons", 2);
104
+ __decorateClass([
105
+ index.observable
106
+ ], Pagination.prototype, "prevButton", 2);
107
+ __decorateClass([
108
+ index.observable
109
+ ], Pagination.prototype, "nextButton", 2);
110
+ __decorateClass([
111
+ index.attr({ attribute: "nav-icons", mode: "boolean" })
112
+ ], Pagination.prototype, "navIcons", 2);
113
+ __decorateClass([
114
+ index.volatile
115
+ ], Pagination.prototype, "pagesList", 1);
116
+ __decorateClass([
117
+ index.attr({ mode: "reflect", converter: totalConverter })
118
+ ], Pagination.prototype, "total", 2);
119
+ __decorateClass([
120
+ index.attr({ mode: "reflect", converter: totalConverter, attribute: "selected-index" })
121
+ ], Pagination.prototype, "selectedIndex", 2);
122
+
123
+ const ALLOWED_SIZES = [enums.Size.SuperCondensed, enums.Size.Condensed, enums.Size.Normal];
124
+ const ALLOWED_SHAPES = [enums.Shape.Rounded, enums.Shape.Pill];
125
+ const handleSelection = (value, { parent: x }) => {
126
+ return x.selectedIndex = Number(value) - 1;
127
+ };
128
+ const handleKeyDown = (value, { event, parent }) => {
129
+ if (event.key === " " || event.key === "Enter") {
130
+ handleSelection(value, { parent });
131
+ }
132
+ if (event.key === "Tab") {
133
+ event.target.dispatchEvent(
134
+ new CustomEvent("tabpressed", { detail: { value, shiftKey: event.shiftKey }, bubbles: true, composed: true })
135
+ );
136
+ }
137
+ };
138
+ const getClasses = (_) => classNames.classNames("control");
139
+ function getButtonAppearance(value, { parent }) {
140
+ return parent.selectedIndex === Number(value) - 1 ? "filled" : "ghost";
141
+ }
142
+ const paginationButtonRenderer = (buttonTag) => index.html`
143
+ ${when.when(
144
+ (value) => value !== "...",
145
+ index.html`
146
+ <${buttonTag} class="vwc-pagination-button"
147
+ label="${(value) => value}"
148
+ appearance="${getButtonAppearance}"
149
+ size="${(_, { parent: x }) => getPaginationSize(x)}"
150
+ shape="${(_, { parent: x }) => getPaginationShape(x)}"
151
+ style="inline-size: ${(value) => getPaginationButtonWidth(value)};"
152
+ tabindex="0"
153
+ aria-current="${(value, { parent }) => parent.selectedIndex === Number(value) - 1}"
154
+ @click="${handleSelection}"
155
+ @keydown="${handleKeyDown}">
156
+ </${buttonTag}>
157
+ `
158
+ )}
159
+ ${when.when(
160
+ (value) => value === "...",
161
+ index.html`
162
+ <div
163
+ class="dots size-${(_, { parent: x }) => getPaginationSize(x)}">
164
+ ...
165
+ </div>`
166
+ )}`;
167
+ const getPaginationSize = (x) => {
168
+ if (!x.size || !ALLOWED_SIZES.includes(x.size)) {
169
+ return enums.Size.SuperCondensed;
170
+ }
171
+ return x.size;
172
+ };
173
+ const getPaginationShape = (x) => {
174
+ if (!x.shape || !ALLOWED_SHAPES.includes(x.shape)) {
175
+ return enums.Shape.Rounded;
176
+ }
177
+ return x.shape;
178
+ };
179
+ const getPaginationButtonWidth = (value) => {
180
+ return `calc(var(--base-size) + ${String(value).length - 1}ch)`;
181
+ };
182
+ const PaginationTemplate = (context) => {
183
+ const buttonTag = context.tagFor(definition.Button);
184
+ const paginationButtonTemplate = paginationButtonRenderer(buttonTag);
185
+ return index.html`
186
+ <div class="${getClasses}">
187
+ <${buttonTag} class="prev-button" ${ref.ref("prevButton")}
188
+ label="${(x) => !x.navIcons ? "Previous" : null}"
189
+ icon="${(x) => x.navIcons ? "chevron-left-line" : null}"
190
+ size="${getPaginationSize}"
191
+ shape="${getPaginationShape}"
192
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === 0}"
193
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex--}"
194
+ ></${buttonTag}>
195
+ <div id="buttons-wrapper" class="buttons-wrapper" ${children.children({ property: "paginationButtons", filter: slotted.elements(buttonTag) })}>
196
+ ${repeat.repeat((x) => x.pagesList, paginationButtonTemplate, { positioning: true })}
197
+ </div>
198
+ <${buttonTag} class="next-button" ${ref.ref("nextButton")}
199
+ label="${(x) => !x.navIcons ? "Next" : null}"
200
+ icon="${(x) => x.navIcons ? "chevron-right-line" : null}"
201
+ size="${getPaginationSize}"
202
+ shape="${getPaginationShape}"
203
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === x.total - 1}"
204
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex++}"
205
+ ></${buttonTag}>
206
+ </div>`;
207
+ };
208
+
209
+ const paginationDefinition = Pagination.compose({
210
+ baseName: "pagination",
211
+ template: PaginationTemplate,
212
+ styles
213
+ });
214
+ const paginationRegistries = [paginationDefinition(), definition.buttonRegistries];
215
+ const registerPagination = index.registerFactory(paginationRegistries);
216
+
217
+ exports.paginationDefinition = paginationDefinition;
218
+ exports.paginationRegistries = paginationRegistries;
219
+ exports.registerPagination = registerPagination;
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index.cjs');
4
+ const baseProgress = require('./base-progress.cjs');
5
+ const when = require('./when.cjs');
6
+ const classNames = require('./class-names.cjs');
7
+
8
+ const styles = ".base{align-items:center;block-size:var(--_size);color:var(--_appearance-color-text);inline-size:var(--_size);outline:none}.base.connotation-cta{--_connotation-color-primary: var(--vvd-progress-ring-cta-primary, var(--vvd-color-cta-500))}.base.connotation-alert{--_connotation-color-primary: var(--vvd-progress-ring-alert-primary, var(--vvd-color-alert-500))}.base.connotation-success{--_connotation-color-primary: var(--vvd-progress-ring-success-primary, var(--vvd-color-success-500))}.base:not(.connotation-cta,.connotation-alert,.connotation-success){--_connotation-color-primary: var(--vvd-progress-ring-accent-primary, var(--vvd-color-canvas-text))}.base{--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(:disabled,.disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base.size--6{--_size:calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2)) - (1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))))}.base.size--5{--_size:calc(1px*(20 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size--4{--_size:calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size--3{--_size:calc(1px*(28 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size--2{--_size:calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size--1{--_size:calc(1px*(36 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size-1{--_size:calc(1px*(44 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size-2{--_size:calc(1px*(48 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size-3{--_size:calc(1px*(52 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size-4{--_size:calc(1px*(56 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base.size-5{--_size:calc(1px*(60 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.base:not(.size--6,.size--5,.size--4,.size--3,.size--2,.size--1,.size-1,.size-2,.size-3,.size-4,.size-5){--_size:calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.progress{width:100%;height:100%}.background{fill:none;stroke:transparent;stroke-width:1px}.determinate{fill:none;stroke:currentColor;stroke-linecap:round;stroke-width:1px;transform:rotate(-90deg);transform-origin:50% 50%;transition:all .2s ease-in-out}.indeterminate-indicator-1{animation:spin-infinite 2s linear infinite;fill:none;stroke:currentColor;stroke-linecap:round;stroke-width:1px;transform:rotate(-90deg);transform-origin:50% 50%;transition:all .2s ease-in-out}.base.paused .indeterminate-indicator-1{animation-play-state:paused}@keyframes spin-infinite{0%{stroke-dasharray:.01px 43.97px;transform:rotate(0)}50%{stroke-dasharray:21.99px 21.99px;transform:rotate(450deg)}to{stroke-dasharray:.01px 43.97px;transform:rotate(1080deg)}}\n";
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __decorateClass = (decorators, target, key, kind) => {
13
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
14
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
15
+ if (decorator = decorators[i])
16
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
17
+ if (kind && result)
18
+ __defProp(target, key, result);
19
+ return result;
20
+ };
21
+ class ProgressRing extends baseProgress.BaseProgress {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.ariaLabel = null;
25
+ }
26
+ }
27
+ __decorateClass([
28
+ index.attr({ attribute: "aria-label" })
29
+ ], ProgressRing.prototype, "ariaLabel", 2);
30
+ __decorateClass([
31
+ index.attr
32
+ ], ProgressRing.prototype, "connotation", 2);
33
+ __decorateClass([
34
+ index.attr
35
+ ], ProgressRing.prototype, "size", 2);
36
+
37
+ const getClasses = ({ connotation, size, paused }) => classNames.classNames(
38
+ "base",
39
+ ["disabled", !!paused],
40
+ [`connotation-${connotation}`, !!connotation],
41
+ [`size-${size}`, !!size]
42
+ );
43
+ const progressSegments = 44;
44
+ const ProgressRingTemplate = (_) => index.html`<template role="${(x) => x.ariaLabel ? "presentation" : null}">
45
+ <div
46
+ role="progressbar"
47
+ aria-label="${(x) => x.ariaLabel}"
48
+ aria-valuenow="${(x) => x.value}"
49
+ aria-valuemin="${(x) => x.min}"
50
+ aria-valuemax="${(x) => x.max}"
51
+ class="${(x) => x.paused ? "paused" : ""} ${getClasses}"
52
+ >
53
+ ${when.when(
54
+ (x) => typeof x.value === "number",
55
+ index.html`
56
+ <svg
57
+ class="progress"
58
+ viewBox="0 0 16 16"
59
+ >
60
+ <circle
61
+ class="background"
62
+ cx="8px"
63
+ cy="8px"
64
+ r="7px"
65
+ ></circle>
66
+ <circle
67
+ class="determinate"
68
+ style="stroke-dasharray: ${(x) => progressSegments * x.percentComplete / 100}px ${progressSegments}px"
69
+ cx="8px"
70
+ cy="8px"
71
+ r="7px"
72
+ ></circle>
73
+ </svg>
74
+ `
75
+ )}
76
+ ${when.when(
77
+ (x) => typeof x.value !== "number",
78
+ index.html`
79
+ <svg class="progress" viewBox="0 0 16 16">
80
+ <circle
81
+ class="background"
82
+ cx="8px"
83
+ cy="8px"
84
+ r="7px"
85
+ ></circle>
86
+ <circle
87
+ class="indeterminate-indicator-1"
88
+ cx="8px"
89
+ cy="8px"
90
+ r="7px"
91
+ ></circle>
92
+ </svg>
93
+ `
94
+ )}
95
+ </div>
96
+ </template>`;
97
+
98
+ const progressRingDefinition = ProgressRing.compose({
99
+ baseName: "progress-ring",
100
+ template: ProgressRingTemplate,
101
+ styles
102
+ });
103
+ const progressRingRegistries = [progressRingDefinition()];
104
+ const registerProgressRing = index.registerFactory(progressRingRegistries);
105
+
106
+ exports.ProgressRing = ProgressRing;
107
+ exports.progressRingDefinition = progressRingDefinition;
108
+ exports.progressRingRegistries = progressRingRegistries;
109
+ exports.registerProgressRing = registerProgressRing;