@vonage/vivid 3.14.0 → 3.16.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 (105) hide show
  1. package/checkbox/index.js +3 -0
  2. package/custom-elements.json +250 -27
  3. package/empty-state/index.js +14 -0
  4. package/fab/index.js +1 -1
  5. package/header/index.js +1 -1
  6. package/index.js +31 -29
  7. package/layout/index.js +1 -1
  8. package/lib/checkbox/checkbox.d.ts +6 -3
  9. package/lib/components.d.ts +2 -0
  10. package/lib/data-grid/data-grid-cell.d.ts +2 -0
  11. package/lib/data-grid/data-grid-row.d.ts +1 -0
  12. package/lib/data-grid/data-grid.d.ts +1 -1
  13. package/lib/empty-state/definition.d.ts +3 -0
  14. package/lib/empty-state/empty-state.d.ts +5 -0
  15. package/lib/empty-state/empty-state.template.d.ts +4 -0
  16. package/lib/empty-state/index.d.ts +1 -0
  17. package/listbox/index.js +1 -1
  18. package/menu/index.js +2 -2
  19. package/menu-item/index.js +1 -1
  20. package/nav/index.js +1 -1
  21. package/nav-disclosure/index.js +1 -1
  22. package/nav-item/index.js +1 -1
  23. package/note/index.js +1 -1
  24. package/number-field/index.js +1 -1
  25. package/package.json +1 -1
  26. package/pagination/index.js +14 -232
  27. package/progress/index.js +1 -1
  28. package/radio/index.js +1 -1
  29. package/radio-group/index.js +1 -1
  30. package/select/index.js +1 -1
  31. package/shared/definition.js +1 -1
  32. package/shared/definition10.js +1 -1
  33. package/shared/definition11.js +1 -1
  34. package/shared/definition12.js +1 -1
  35. package/shared/definition14.js +1 -1
  36. package/shared/definition15.js +1 -1
  37. package/shared/definition16.js +1 -1
  38. package/shared/definition17.js +1 -1
  39. package/shared/definition18.js +23 -8
  40. package/shared/definition19.js +1 -1
  41. package/shared/definition2.js +1 -1
  42. package/shared/definition21.js +1 -1
  43. package/shared/definition22.js +114 -40
  44. package/shared/definition23.js +1 -1
  45. package/shared/definition24.js +1 -1
  46. package/shared/definition25.js +39 -76
  47. package/shared/definition26.js +76 -47
  48. package/shared/definition27.js +46 -36
  49. package/shared/definition28.js +39 -49
  50. package/shared/definition29.js +48 -344
  51. package/shared/definition30.js +272 -291
  52. package/shared/definition31.js +366 -14
  53. package/shared/definition32.js +13 -67
  54. package/shared/definition33.js +66 -21
  55. package/shared/definition34.js +21 -39
  56. package/shared/definition35.js +31 -432
  57. package/shared/definition36.js +432 -76
  58. package/shared/definition37.js +223 -34
  59. package/shared/definition38.js +82 -425
  60. package/shared/definition39.js +30 -635
  61. package/shared/definition4.js +1 -1
  62. package/shared/definition40.js +420 -73
  63. package/shared/definition41.js +530 -484
  64. package/shared/definition42.js +76 -133
  65. package/shared/definition43.js +577 -40
  66. package/shared/definition44.js +135 -20
  67. package/shared/definition45.js +42 -423
  68. package/shared/definition46.js +22 -112
  69. package/shared/definition47.js +440 -18
  70. package/shared/definition48.js +92 -247
  71. package/shared/definition49.js +20 -112
  72. package/shared/definition5.js +1 -1
  73. package/shared/definition50.js +259 -590
  74. package/shared/definition51.js +110 -91
  75. package/shared/definition52.js +626 -67
  76. package/shared/definition53.js +111 -292
  77. package/shared/definition54.js +80 -0
  78. package/shared/definition55.js +305 -0
  79. package/shared/definition6.js +1 -1
  80. package/shared/definition7.js +1 -1
  81. package/shared/definition9.js +1 -1
  82. package/shared/form-elements.js +1 -1
  83. package/shared/icon.js +1 -1
  84. package/shared/patterns/form-elements/form-elements.d.ts +4 -4
  85. package/shared/text-field.js +1 -1
  86. package/side-drawer/index.js +1 -1
  87. package/slider/index.js +1 -1
  88. package/styles/core/all.css +1 -1
  89. package/styles/core/theme.css +1 -1
  90. package/styles/core/typography.css +1 -1
  91. package/styles/tokens/theme-dark.css +4 -4
  92. package/styles/tokens/theme-light.css +4 -4
  93. package/switch/index.js +1 -1
  94. package/tab/index.js +1 -1
  95. package/tab-panel/index.js +1 -1
  96. package/tabs/index.js +3 -3
  97. package/tag/index.js +1 -1
  98. package/tag-group/index.js +1 -1
  99. package/text-area/index.js +1 -1
  100. package/text-field/index.js +1 -1
  101. package/toggletip/index.js +1 -1
  102. package/tooltip/index.js +1 -1
  103. package/tree-item/index.js +1 -1
  104. package/tree-view/index.js +1 -1
  105. 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 Wed, 07 Jun 2023 09:55:04 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 Tue, 30 May 2023 12:49:14 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 /* @cssprop [--vvd-radio-accent-primary=var(--vvd-color-canvas-text)] */\n --_connotation-color-primary: var(--vvd-radio-accent-primary, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-radio-accent-firm=var(--vvd-color-canvas-text)] */\n --_connotation-color-firm: var(--vvd-radio-accent-firm, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-radio-accent-faint=var(--vvd-color-neutral-50)] */\n --_connotation-color-faint: var(--vvd-radio-accent-faint, var(--vvd-color-neutral-50));\n /* @cssprop [--vvd-radio-accent-soft=var(--vvd-color-neutral-100)] */\n --_connotation-color-soft: var(--vvd-radio-accent-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 };