@vonage/vivid 3.13.0 → 3.15.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 (134) hide show
  1. package/accordion/index.js +1 -0
  2. package/accordion-item/index.js +1 -0
  3. package/alert/index.js +1 -0
  4. package/avatar/index.js +1 -0
  5. package/badge/index.js +1 -0
  6. package/banner/index.js +1 -0
  7. package/breadcrumb-item/index.js +1 -0
  8. package/button/index.js +1 -0
  9. package/card/index.js +1 -0
  10. package/checkbox/index.js +4 -0
  11. package/combobox/index.js +1 -0
  12. package/custom-elements.json +1855 -117
  13. package/data-grid/index.js +4 -0
  14. package/dialog/index.js +1 -0
  15. package/empty-state/index.js +14 -0
  16. package/fab/index.js +2 -1
  17. package/header/index.js +1 -1
  18. package/icon/index.js +1 -0
  19. package/index.js +34 -30
  20. package/layout/index.js +1 -1
  21. package/lib/alert/alert.d.ts +4 -6
  22. package/lib/checkbox/checkbox.d.ts +6 -3
  23. package/lib/components.d.ts +2 -0
  24. package/lib/data-grid/data-grid-cell.d.ts +2 -0
  25. package/lib/data-grid/data-grid-row.d.ts +1 -0
  26. package/lib/data-grid/data-grid.d.ts +5 -0
  27. package/lib/empty-state/definition.d.ts +3 -0
  28. package/lib/empty-state/empty-state.d.ts +5 -0
  29. package/lib/empty-state/empty-state.template.d.ts +4 -0
  30. package/lib/empty-state/index.d.ts +1 -0
  31. package/lib/select/select.d.ts +3 -2
  32. package/listbox/index.js +2 -1
  33. package/menu/index.js +4 -3
  34. package/menu-item/index.js +4 -1
  35. package/nav/index.js +1 -1
  36. package/nav-disclosure/index.js +2 -1
  37. package/nav-item/index.js +2 -1
  38. package/note/index.js +2 -1
  39. package/number-field/index.js +2 -1
  40. package/option/index.js +1 -0
  41. package/package.json +1 -1
  42. package/pagination/index.js +15 -312
  43. package/popup/index.js +1 -0
  44. package/progress/index.js +1 -1
  45. package/radio/index.js +1 -1
  46. package/radio-group/index.js +1 -1
  47. package/select/index.js +2 -1
  48. package/shared/definition.js +1 -1
  49. package/shared/definition10.js +1 -1
  50. package/shared/definition11.js +1 -1
  51. package/shared/definition12.js +1 -1
  52. package/shared/definition14.js +1 -1
  53. package/shared/definition15.js +1 -1
  54. package/shared/definition16.js +2 -2
  55. package/shared/definition17.js +1 -1
  56. package/shared/definition18.js +23 -8
  57. package/shared/definition19.js +1 -1
  58. package/shared/definition2.js +1 -1
  59. package/shared/definition20.js +1 -1
  60. package/shared/definition21.js +1 -1
  61. package/shared/definition22.js +217 -11
  62. package/shared/definition23.js +2 -2
  63. package/shared/definition24.js +1 -1
  64. package/shared/definition25.js +39 -76
  65. package/shared/definition26.js +76 -47
  66. package/shared/definition27.js +46 -36
  67. package/shared/definition28.js +39 -49
  68. package/shared/definition29.js +48 -344
  69. package/shared/definition3.js +1 -1
  70. package/shared/definition30.js +273 -288
  71. package/shared/definition31.js +366 -14
  72. package/shared/definition32.js +13 -67
  73. package/shared/definition33.js +66 -21
  74. package/shared/definition34.js +21 -39
  75. package/shared/definition35.js +31 -432
  76. package/shared/definition36.js +432 -76
  77. package/shared/definition37.js +223 -34
  78. package/shared/definition38.js +82 -425
  79. package/shared/definition39.js +30 -628
  80. package/shared/definition4.js +1 -1
  81. package/shared/definition40.js +420 -73
  82. package/shared/definition41.js +530 -484
  83. package/shared/definition42.js +76 -133
  84. package/shared/definition43.js +577 -40
  85. package/shared/definition44.js +135 -20
  86. package/shared/definition45.js +42 -423
  87. package/shared/definition46.js +22 -112
  88. package/shared/definition47.js +440 -18
  89. package/shared/definition48.js +92 -247
  90. package/shared/definition49.js +20 -112
  91. package/shared/definition5.js +1 -1
  92. package/shared/definition50.js +259 -590
  93. package/shared/definition51.js +110 -91
  94. package/shared/definition52.js +602 -67
  95. package/shared/definition53.js +89 -294
  96. package/shared/definition54.js +80 -0
  97. package/shared/definition55.js +305 -0
  98. package/shared/definition6.js +52 -78
  99. package/shared/definition7.js +1 -1
  100. package/shared/definition8.js +1 -1
  101. package/shared/definition9.js +1 -1
  102. package/shared/engine-is-node.js +8 -0
  103. package/shared/es.object.assign.js +1 -1
  104. package/shared/es.regexp.to-string.js +1 -1
  105. package/shared/es.string.includes.js +83 -0
  106. package/shared/form-elements.js +2 -2
  107. package/shared/icon.js +13 -17
  108. package/shared/index.js +1 -1
  109. package/shared/patterns/form-elements/form-elements.d.ts +4 -4
  110. package/shared/string-trim.js +1 -1
  111. package/shared/text-field.js +1 -1
  112. package/shared/to-string.js +1 -1
  113. package/side-drawer/index.js +1 -1
  114. package/slider/index.js +1 -1
  115. package/styles/core/all.css +1 -1
  116. package/styles/core/theme.css +1 -1
  117. package/styles/core/typography.css +1 -1
  118. package/styles/fonts/spezia-variable.css +2 -2
  119. package/styles/tokens/theme-dark.css +4 -4
  120. package/styles/tokens/theme-light.css +4 -4
  121. package/switch/index.js +2 -1
  122. package/tab/index.js +2 -1
  123. package/tab-panel/index.js +1 -1
  124. package/tabs/index.js +4 -3
  125. package/tag/index.js +2 -1
  126. package/tag-group/index.js +1 -1
  127. package/text-anchor/index.js +1 -0
  128. package/text-area/index.js +2 -1
  129. package/text-field/index.js +2 -1
  130. package/toggletip/index.js +2 -1
  131. package/tooltip/index.js +2 -1
  132. package/tree-item/index.js +2 -1
  133. package/tree-view/index.js +1 -1
  134. package/vivid.api.json +210 -0
@@ -1,45 +1,234 @@
1
- import { h as html, r as registerFactory } from './index.js';
2
- import { f as focusRegistries } from './definition4.js';
3
- import { R as Radio } from './radio.js';
4
- import { f as focusTemplateFactory } from './focus2.js';
5
- import { w as when } from './when.js';
1
+ import { B as Button, b as buttonRegistries } from './definition7.js';
2
+ import { x as global$1, j as fails$1, i as functionUncurryThis, G as _export, F as FoundationElement, _ as __decorate, a as attr, b as __metadata, o as observable, W as volatile, h as html, r as registerFactory } from './index.js';
3
+ import { t as toString$1 } from './to-string.js';
4
+ import { w as whitespaces$1, s as stringTrim } from './string-trim.js';
5
+ import './es.regexp.to-string.js';
6
+ import './es.string.includes.js';
7
+ import { a as Size } from './enums.js';
8
+ import { e as elements } from './node-observation.js';
9
+ import { r as ref } from './ref.js';
10
+ import { r as repeat } from './repeat.js';
11
+ import { c as children } from './children.js';
6
12
  import { c as classNames } from './class-names.js';
13
+ import { w as when } from './when.js';
14
+
15
+ var css_248z = "/**\n * Do not edit directly\n * Generated on Tue, 06 Jun 2023 10:38:32 GMT\n */\n.control {\n display: inline-flex;\n justify-content: space-between;\n}\n\n.buttons-wrapper {\n display: flex;\n column-gap: 4px;\n}\n\n.dots {\n align-self: center;\n text-align: center;\n}\n.dots:not(.size-super-condensed) {\n font: var(--vvd-typography-base-bold);\n}\n.dots.size-super-condensed {\n font: var(--vvd-typography-base-condensed-bold);\n inline-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16));\n}\n.dots.size-condensed {\n inline-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8));\n}\n.dots.size-normal {\n inline-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n}";
16
+
17
+ var global = global$1;
18
+ var fails = fails$1;
19
+ var uncurryThis = functionUncurryThis;
20
+ var toString = toString$1;
21
+ var trim = stringTrim.trim;
22
+ var whitespaces = whitespaces$1;
7
23
 
8
- var css_248z = "/**\n * Do not edit directly\n * Generated on Wed, 17 May 2023 03:28:45 GMT\n */\n@supports selector(:focus-visible) {\n :host(:focus) {\n outline: none;\n }\n}\n.base {\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n gap: 8px;\n}\n.base {\n --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-firm: var(--vvd-color-canvas-text);\n --_connotation-color-faint: var(--vvd-color-neutral-50);\n --_connotation-color-soft: var(--vvd-color-neutral-100);\n}\n.base {\n --_appearance-color-text: var(--_connotation-color-firm);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-firm);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.base:where(:active, .active):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-firm);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.base:where(:checked, .checked):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: var(--_connotation-color-primary);\n}\n.base:where(:checked, .checked):where(:hover, .hover) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: var(--_connotation-color-primary);\n}\n.base:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-400);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: var(--vvd-color-neutral-400);\n}\n.base:where(.readonly):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--vvd-color-neutral-600);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: var(--vvd-color-neutral-400);\n}\n@supports (user-select: none) {\n .base {\n user-select: none;\n }\n}\n.base.disabled {\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.control {\n position: relative;\n flex-shrink: 0;\n background-color: var(--_appearance-color-fill);\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20));\n border-radius: 50%;\n box-shadow: inset 0 0 0 2px var(--_appearance-color-outline);\n inline-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20));\n}\n.control::after {\n position: absolute;\n background-color: var(--_appearance-color-text);\n border-radius: inherit;\n content: \"\";\n inset: 5px;\n}\n.base:not(.checked) .control::after {\n display: none;\n}\n\nlabel {\n color: var(--vvd-color-canvas-text);\n cursor: pointer;\n font: var(--vvd-typography-base);\n}\n\n.focus-indicator {\n --focus-inset: -3px;\n --focus-stroke-gap-color: transparent;\n border-radius: 50%;\n}\n:host(:not(:focus-visible)) .focus-indicator {\n display: none;\n}";
24
+ var $parseInt$1 = global.parseInt;
25
+ var Symbol = global.Symbol;
26
+ var ITERATOR = Symbol && Symbol.iterator;
27
+ var hex = /^[+-]?0x/i;
28
+ var exec = uncurryThis(hex.exec);
29
+ var FORCED = $parseInt$1(whitespaces + '08') !== 8 || $parseInt$1(whitespaces + '0x16') !== 22
30
+ // MS Edge 18- broken with boxed symbols
31
+ || (ITERATOR && !fails(function () { $parseInt$1(Object(ITERATOR)); }));
9
32
 
10
- let _ = t => t,
33
+ // `parseInt` method
34
+ // https://tc39.es/ecma262/#sec-parseint-string-radix
35
+ var numberParseInt = FORCED ? function parseInt(string, radix) {
36
+ var S = trim(toString(string));
37
+ return $parseInt$1(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
38
+ } : $parseInt$1;
39
+
40
+ var $ = _export;
41
+ var $parseInt = numberParseInt;
42
+
43
+ // `parseInt` method
44
+ // https://tc39.es/ecma262/#sec-parseint-string-radix
45
+ $({ global: true, forced: parseInt != $parseInt }, {
46
+ parseInt: $parseInt
47
+ });
48
+
49
+ const MAX_DIGITS_AND_PLACEHOLDERS = 7;
50
+ const totalConverter = {
51
+ fromView: value => parseInt(value, 10),
52
+ toView: value => value.toString()
53
+ };
54
+ class Pagination extends FoundationElement {
55
+ constructor() {
56
+ super();
57
+ this.navIcons = false;
58
+ this.total = 0;
59
+ this.selectedIndex = 0;
60
+ this.addEventListener('tabpressed', e => {
61
+ const {
62
+ value: currentLabel,
63
+ shiftKey
64
+ } = e.detail;
65
+ const index = this.paginationButtons.findIndex(button => Number(button.label) === currentLabel);
66
+ const focusDirection = shiftKey ? -1 : 1;
67
+ const newIndex = index + focusDirection;
68
+ if (newIndex < 0) {
69
+ return this.prevButton.focus();
70
+ }
71
+ if (newIndex > this.paginationButtons.length - 1) {
72
+ return this.nextButton.focus();
73
+ }
74
+ this.paginationButtons && this.paginationButtons[index + focusDirection].focus();
75
+ });
76
+ }
77
+ get pagesList() {
78
+ return new Array(this.total < MAX_DIGITS_AND_PLACEHOLDERS ? this.total : MAX_DIGITS_AND_PLACEHOLDERS).fill(0).map((_, i, arr) => {
79
+ if (i === 0) return 1;
80
+ if (i === arr.length - 1) return this.total;
81
+ if (this.selectedIndex !== undefined && this.total > MAX_DIGITS_AND_PLACEHOLDERS) {
82
+ if (this.selectedIndex < 4) {
83
+ if (i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return '...';
84
+ }
85
+ if (this.selectedIndex >= 4 && this.selectedIndex <= this.total - 5) {
86
+ if (i > 1 && i < MAX_DIGITS_AND_PLACEHOLDERS - 2) return this.selectedIndex + (i - 2);
87
+ if (i === 1 || i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return '...';
88
+ }
89
+ if (this.selectedIndex > this.total - 5) {
90
+ if (i > 1) return this.total - (6 - i);
91
+ if (i === 1) return '...';
92
+ }
93
+ }
94
+ return i + 1;
95
+ });
96
+ }
97
+ totalChanged(_, newValue) {
98
+ if (newValue < 0) {
99
+ this.total = 0;
100
+ }
101
+ this.selectedIndex = 0;
102
+ }
103
+ selectedIndexChanged(oldValue, newValue) {
104
+ if (oldValue === undefined) return;
105
+ this.$emit('pagination-change', {
106
+ selectedIndex: newValue,
107
+ total: this.total,
108
+ oldIndex: oldValue
109
+ });
110
+ }
111
+ paginationButtonsChanged(_, newValue) {
112
+ newValue.forEach(button => {
113
+ button.shadowRoot.querySelector('button').classList.add('icon-only');
114
+ });
115
+ }
116
+ }
117
+ __decorate([attr, __metadata("design:type", String)], Pagination.prototype, "size", void 0);
118
+ __decorate([observable, __metadata("design:type", Array)], Pagination.prototype, "paginationButtons", void 0);
119
+ __decorate([observable, __metadata("design:type", Function)], Pagination.prototype, "prevButton", void 0);
120
+ __decorate([observable, __metadata("design:type", Function)], Pagination.prototype, "nextButton", void 0);
121
+ __decorate([attr({
122
+ attribute: 'nav-icons',
123
+ mode: 'boolean'
124
+ }), __metadata("design:type", Object)], Pagination.prototype, "navIcons", void 0);
125
+ __decorate([volatile, __metadata("design:type", Object), __metadata("design:paramtypes", [])], Pagination.prototype, "pagesList", null);
126
+ __decorate([attr({
127
+ mode: 'reflect',
128
+ converter: totalConverter
129
+ }), __metadata("design:type", Number)], Pagination.prototype, "total", void 0);
130
+ __decorate([attr({
131
+ mode: 'reflect',
132
+ converter: totalConverter,
133
+ attribute: 'selected-index'
134
+ }), __metadata("design:type", Object)], Pagination.prototype, "selectedIndex", void 0);
135
+
136
+ let _2 = t => t,
11
137
  _t,
12
- _t2;
13
- const getClasses = ({
14
- checked,
15
- readOnly,
16
- disabled
17
- }) => classNames('base', ['checked', Boolean(checked)], ['readonly', Boolean(readOnly)], ['disabled', Boolean(disabled)]);
18
- const RadioTemplate = context => {
19
- const focusTemplate = focusTemplateFactory(context);
20
- return html(_t || (_t = _`
21
- <div class="${0}"
22
- role="radio"
23
- aria-checked="${0}"
24
- aria-required="${0}"
25
- aria-disabled="${0}"
26
- @keypress="${0}"
27
- @click="${0}"
28
- >
29
- <div class="control">
138
+ _t2,
139
+ _t3,
140
+ _t4;
141
+ const ALLOWED_SIZES = [Size.SuperCondensed, Size.Condensed, Size.Normal];
142
+ const handleSelection = (value, {
143
+ parent: x
144
+ }) => {
145
+ return x.selectedIndex = Number(value) - 1;
146
+ };
147
+ const handleKeyDown = (value, {
148
+ event,
149
+ parent
150
+ }) => {
151
+ if (event.key === ' ' || event.key === 'Enter') {
152
+ handleSelection(value, {
153
+ parent
154
+ });
155
+ }
156
+ if (event.key === 'Tab') {
157
+ event.target.dispatchEvent(new CustomEvent('tabpressed', {
158
+ detail: {
159
+ value,
160
+ shiftKey: event.shiftKey
161
+ },
162
+ bubbles: true,
163
+ composed: true
164
+ }));
165
+ }
166
+ };
167
+ const getClasses = _ => classNames('control');
168
+ function getButtonAppearance(value, {
169
+ parent
170
+ }) {
171
+ return parent.selectedIndex === Number(value) - 1 ? 'filled' : 'ghost';
172
+ }
173
+ const paginationButtonRenderer = buttonTag => html(_t || (_t = _2`
174
+ ${0}
175
+ ${0}`), when(value => value !== '...', html(_t2 || (_t2 = _2`
176
+ <${0} class="vwc-pagination-button"
177
+ label="${0}"
178
+ appearance="${0}"
179
+ size="${0}"
180
+ tabindex="0"
181
+ aria-pressed="${0}"
182
+ @click="${0}"
183
+ @keydown="${0}"
184
+ </${0}>
185
+ `), buttonTag, value => value, getButtonAppearance, (_, {
186
+ parent: x
187
+ }) => getPaginationSize(x), (value, {
188
+ parent
189
+ }) => parent.selectedIndex === Number(value) - 1, handleSelection, handleKeyDown, buttonTag)), when(value => value === '...', html(_t3 || (_t3 = _2`<div class="dots size-${0}">...</div>`), getPaginationSize)));
190
+ const getPaginationSize = x => {
191
+ if (!x.size || !ALLOWED_SIZES.includes(x.size)) {
192
+ return Size.SuperCondensed;
193
+ }
194
+ return x.size;
195
+ };
196
+ const PaginationTemplate = context => {
197
+ const buttonTag = context.tagFor(Button);
198
+ const paginationButtonTemplate = paginationButtonRenderer(buttonTag);
199
+ return html(_t4 || (_t4 = _2`
200
+ <div class="${0}">
201
+ <${0} class="prev-button" ${0}
202
+ label="${0}"
203
+ icon="${0}"
204
+ size="${0}"
205
+ ?disabled="${0}"
206
+ @click="${0}"
207
+ ></${0}>
208
+ <div id="buttons-wrapper" class="buttons-wrapper" ${0}>
30
209
  ${0}
31
210
  </div>
32
- ${0}
33
- </div>
34
- `), getClasses, x => x.checked, x => x.required, x => x.disabled, (x, c) => x.keypressHandler(c.event), (x, c) => x.clickHandler(c.event), () => focusTemplate, when(x => x.label, html(_t2 || (_t2 = _`<label class="label">${0}</label>`), x => x.label)));
211
+ <${0} class="next-button" ${0}
212
+ label="${0}"
213
+ icon="${0}"
214
+ size="${0}"
215
+ ?disabled="${0}"
216
+ @click="${0}"
217
+ ></${0}>
218
+ </div>`), getClasses, buttonTag, ref('prevButton'), x => !x.navIcons ? 'Previous' : null, x => x.navIcons ? 'chevron-left-line' : null, getPaginationSize, x => x.total === 0 || x.selectedIndex === 0, x => x.selectedIndex !== undefined && x.selectedIndex--, buttonTag, children({
219
+ property: 'paginationButtons',
220
+ filter: elements(buttonTag)
221
+ }), repeat(x => x.pagesList, paginationButtonTemplate, {
222
+ positioning: true
223
+ }), buttonTag, ref('nextButton'), x => !x.navIcons ? 'Next' : null, x => x.navIcons ? 'chevron-right-line' : null, getPaginationSize, x => x.total === 0 || x.selectedIndex === x.total - 1, x => x.selectedIndex !== undefined && x.selectedIndex++, buttonTag);
35
224
  };
36
225
 
37
- const radioDefinition = Radio.compose({
38
- baseName: 'radio',
39
- template: RadioTemplate,
226
+ const paginationDefinition = Pagination.compose({
227
+ baseName: 'pagination',
228
+ template: PaginationTemplate,
40
229
  styles: css_248z
41
230
  });
42
- const radioRegistries = [radioDefinition(), ...focusRegistries];
43
- const registerRadio = registerFactory(radioRegistries);
231
+ const paginationRegistries = [paginationDefinition(), buttonRegistries];
232
+ const registerPagination = registerFactory(paginationRegistries);
44
233
 
45
- export { radioDefinition as a, radioRegistries as b, registerRadio as r };
234
+ export { paginationRegistries as a, paginationDefinition as p, registerPagination as r };