@vonage/vivid 3.9.0 → 3.11.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 (136) hide show
  1. package/accordion/index.js +1 -0
  2. package/alert/index.js +28 -0
  3. package/avatar/index.js +1 -1
  4. package/badge/index.js +1 -1
  5. package/banner/index.js +3 -3
  6. package/breadcrumb/index.js +2 -1
  7. package/breadcrumb-item/index.js +1 -1
  8. package/button/index.js +2 -2
  9. package/calendar/index.js +1 -1
  10. package/calendar-event/index.js +1 -1
  11. package/card/index.js +3 -2
  12. package/checkbox/index.js +1 -1
  13. package/combobox/index.js +7 -6
  14. package/custom-elements.json +589 -377
  15. package/data-grid/index.js +3 -2
  16. package/dialog/index.js +5 -4
  17. package/divider/index.js +1 -1
  18. package/elevation/index.js +1 -1
  19. package/fab/index.js +1 -1
  20. package/header/index.js +2 -2
  21. package/index.js +54 -52
  22. package/layout/index.js +1 -1
  23. package/lib/alert/alert.d.ts +24 -0
  24. package/lib/alert/alert.template.d.ts +4 -0
  25. package/lib/alert/definition.d.ts +2 -0
  26. package/lib/alert/index.d.ts +1 -0
  27. package/lib/components.d.ts +1 -0
  28. package/lib/enums.d.ts +10 -9
  29. package/lib/layout/layout.d.ts +2 -0
  30. package/lib/pagination/definition.d.ts +3 -0
  31. package/lib/pagination/index.d.ts +1 -0
  32. package/lib/pagination/pagination.d.ts +18 -0
  33. package/lib/pagination/pagination.template.d.ts +4 -0
  34. package/lib/popup/popup.d.ts +2 -2
  35. package/lib/text-area/text-area.d.ts +2 -1
  36. package/lib/tooltip/tooltip.d.ts +10 -4
  37. package/listbox/index.js +3 -2
  38. package/menu/index.js +7 -6
  39. package/menu-item/index.js +1 -1
  40. package/nav/index.js +1 -1
  41. package/nav-disclosure/index.js +1 -1
  42. package/nav-item/index.js +1 -1
  43. package/note/index.js +1 -1
  44. package/number-field/index.js +4 -4
  45. package/option/index.js +1 -1
  46. package/package.json +1 -1
  47. package/pagination/index.js +329 -0
  48. package/popup/index.js +4 -4
  49. package/progress/index.js +1 -1
  50. package/progress-ring/index.js +1 -1
  51. package/radio/index.js +1 -1
  52. package/radio-group/index.js +3 -2
  53. package/select/index.js +7 -6
  54. package/shared/children.js +1 -1
  55. package/shared/definition.js +3 -2
  56. package/shared/definition10.js +46 -63
  57. package/shared/definition11.js +38 -92
  58. package/shared/definition12.js +96 -31
  59. package/shared/definition13.js +85 -757
  60. package/shared/definition14.js +32 -95
  61. package/shared/definition15.js +758 -100
  62. package/shared/definition16.js +103 -24
  63. package/shared/definition17.js +96 -154
  64. package/shared/definition18.js +108 -663
  65. package/shared/definition19.js +667 -1532
  66. package/shared/definition2.js +1 -1
  67. package/shared/definition20.js +1532 -223
  68. package/shared/definition21.js +183 -964
  69. package/shared/definition22.js +1034 -218
  70. package/shared/definition23.js +226 -67
  71. package/shared/definition24.js +68 -77
  72. package/shared/definition25.js +76 -47
  73. package/shared/definition26.js +46 -32
  74. package/shared/definition27.js +39 -49
  75. package/shared/definition28.js +48 -344
  76. package/shared/definition29.js +273 -282
  77. package/shared/definition30.js +356 -14
  78. package/shared/definition31.js +13 -67
  79. package/shared/definition32.js +65 -21
  80. package/shared/definition33.js +21 -39
  81. package/shared/definition34.js +31 -432
  82. package/shared/definition35.js +432 -76
  83. package/shared/definition36.js +82 -33
  84. package/shared/definition37.js +31 -422
  85. package/shared/definition38.js +358 -564
  86. package/shared/definition39.js +628 -75
  87. package/shared/definition4.js +1 -1
  88. package/shared/definition40.js +70 -573
  89. package/shared/definition41.js +538 -81
  90. package/shared/definition42.js +127 -47
  91. package/shared/definition43.js +51 -16
  92. package/shared/definition44.js +17 -425
  93. package/shared/definition45.js +421 -103
  94. package/shared/definition46.js +114 -19
  95. package/shared/definition47.js +19 -269
  96. package/shared/definition48.js +244 -86
  97. package/shared/definition49.js +110 -70
  98. package/shared/definition5.js +1 -1
  99. package/shared/definition50.js +88 -67
  100. package/shared/definition51.js +69 -294
  101. package/shared/definition52.js +305 -0
  102. package/shared/definition6.js +142 -45
  103. package/shared/definition7.js +97 -24
  104. package/shared/definition8.js +22 -103
  105. package/shared/definition9.js +62 -102
  106. package/shared/enums.js +10 -9
  107. package/shared/es.object.assign.js +1 -1
  108. package/shared/form-associated.js +1 -1
  109. package/shared/form-elements.js +2 -2
  110. package/shared/index.js +1 -1
  111. package/shared/listbox.js +2 -2
  112. package/shared/node-observation.js +74 -0
  113. package/shared/patterns/form-elements/form-elements.d.ts +4 -4
  114. package/shared/repeat.js +1 -1
  115. package/shared/slotted.js +3 -73
  116. package/shared/text-field.js +1 -1
  117. package/shared/text-field2.js +1 -1
  118. package/side-drawer/index.js +1 -1
  119. package/slider/index.js +1 -1
  120. package/styles/core/all.css +1 -1
  121. package/styles/core/theme.css +1 -1
  122. package/styles/core/typography.css +1 -1
  123. package/styles/tokens/theme-dark.css +4 -4
  124. package/styles/tokens/theme-light.css +4 -4
  125. package/switch/index.js +1 -1
  126. package/tab/index.js +1 -1
  127. package/tab-panel/index.js +1 -1
  128. package/tabs/index.js +4 -3
  129. package/tag/index.js +1 -1
  130. package/tag-group/index.js +1 -1
  131. package/text-area/index.js +1 -1
  132. package/text-field/index.js +1 -1
  133. package/tooltip/index.js +5 -5
  134. package/tree-item/index.js +2 -1
  135. package/tree-view/index.js +2 -1
  136. package/vivid.api.json +128 -16
@@ -1,1052 +1,271 @@
1
- import { F as FoundationElement, _ as __decorate, a as attr, o as observable, W as DOM, h as html, b as __metadata, r as registerFactory } from './index.js';
2
- import { k as keyEnd, a as keyHome, h as keyArrowRight, i as keyArrowLeft, j as keyPageDown, l as keyPageUp, b as keyArrowDown, c as keyArrowUp, f as keyEscape, m as keyFunction2, d as keyEnter } from './key-codes.js';
3
- import { R as RepeatDirective } from './repeat.js';
4
- import { e as elements, s as slotted } from './slotted.js';
5
- import { c as children } from './children.js';
1
+ import { F as FoundationElement, O as Observable, _ as __decorate, o as observable, a as attr, b as __metadata, h as html, r as registerFactory } from './index.js';
2
+ import { i as iconRegistries } from './definition3.js';
3
+ import { f as focusRegistries } from './definition4.js';
4
+ import { A as AffixIconWithTrailing, a as affixIconTemplateFactory } from './affix.js';
5
+ import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
6
+ import { S as StartEnd } from './start-end.js';
7
+ import { a as applyMixins } from './apply-mixins.js';
8
+ import { i as isHTMLElement } from './dom.js';
6
9
  import { f as focusTemplateFactory } from './focus2.js';
10
+ import './form-elements.js';
11
+ import { w as when } from './when.js';
12
+ import { c as classNames } from './class-names.js';
7
13
 
8
14
  /**
9
- * This set of exported strings reference https://developer.mozilla.org/en-US/docs/Web/Events
10
- * and should include all non-deprecated and non-experimental Standard events
11
- */
12
- const eventFocus = "focus";
13
- const eventFocusIn = "focusin";
14
- const eventFocusOut = "focusout";
15
- const eventKeyDown = "keydown";
16
-
17
- /**
18
- * Enumerates the data grid auto generated header options
19
- * default option generates a non-sticky header row
20
- *
21
- * @public
22
- */
23
- const GenerateHeaderOptions = {
24
- none: "none",
25
- default: "default",
26
- sticky: "sticky",
27
- };
28
- /**
29
- * Enumerates possible data grid cell types.
15
+ * Determines if the element is a {@link (ListboxOption:class)}
30
16
  *
17
+ * @param element - the element to test.
31
18
  * @public
32
19
  */
33
- const DataGridCellTypes = {
34
- default: "default",
35
- columnHeader: "columnheader",
36
- rowHeader: "rowheader",
37
- };
20
+ function isListboxOption(el) {
21
+ return (isHTMLElement(el) &&
22
+ (el.getAttribute("role") === "option" ||
23
+ el instanceof HTMLOptionElement));
24
+ }
38
25
  /**
39
- * Enumerates possible data grid row types
26
+ * An Option Custom HTML Element.
27
+ * Implements {@link https://www.w3.org/TR/wai-aria-1.1/#option | ARIA option }.
40
28
  *
41
- * @public
42
- */
43
- const DataGridRowTypes = {
44
- default: "default",
45
- header: "header",
46
- stickyHeader: "sticky-header",
47
- };
48
-
49
- /**
50
- * A Data Grid Row Custom HTML Element.
29
+ * @slot start - Content which can be provided before the listbox option content
30
+ * @slot end - Content which can be provided after the listbox option content
31
+ * @slot - The default slot for listbox option content
32
+ * @csspart content - Wraps the listbox option content
51
33
  *
52
- * @fires row-focused - Fires a custom 'row-focused' event when focus is on an element (usually a cell or its contents) in the row
53
- * @slot - The default slot for custom cell elements
54
34
  * @public
55
35
  */
56
- class DataGridRow$1 extends FoundationElement {
57
- constructor() {
58
- super(...arguments);
36
+ class ListboxOption$1 extends FoundationElement {
37
+ constructor(text, value, defaultSelected, selected) {
38
+ super();
59
39
  /**
60
- * The type of row
61
- *
40
+ * The defaultSelected state of the option.
62
41
  * @public
63
- * @remarks
64
- * HTML Attribute: row-type
65
42
  */
66
- this.rowType = DataGridRowTypes.default;
43
+ this.defaultSelected = false;
67
44
  /**
68
- * The base data for this row
69
- *
70
- * @public
45
+ * Tracks whether the "selected" property has been changed.
46
+ * @internal
71
47
  */
72
- this.rowData = null;
48
+ this.dirtySelected = false;
73
49
  /**
74
- * The column definitions of the row
50
+ * The checked state of the control.
75
51
  *
76
52
  * @public
77
53
  */
78
- this.columnDefinitions = null;
54
+ this.selected = this.defaultSelected;
79
55
  /**
80
- * Whether focus is on/in a cell within this row.
81
- *
82
- * @internal
56
+ * Track whether the value has been changed from the initial value
83
57
  */
84
- this.isActiveRow = false;
85
- this.cellsRepeatBehavior = null;
86
- this.cellsPlaceholder = null;
87
- /**
88
- * @internal
89
- */
90
- this.focusColumnIndex = 0;
91
- this.refocusOnLoad = false;
92
- this.updateRowStyle = () => {
93
- this.style.gridTemplateColumns = this.gridTemplateColumns;
94
- };
95
- }
96
- gridTemplateColumnsChanged() {
97
- if (this.$fastController.isConnected) {
98
- this.updateRowStyle();
58
+ this.dirtyValue = false;
59
+ if (text) {
60
+ this.textContent = text;
99
61
  }
100
- }
101
- rowTypeChanged() {
102
- if (this.$fastController.isConnected) {
103
- this.updateItemTemplate();
104
- }
105
- }
106
- rowDataChanged() {
107
- if (this.rowData !== null && this.isActiveRow) {
108
- this.refocusOnLoad = true;
109
- return;
62
+ if (value) {
63
+ this.initialValue = value;
110
64
  }
111
- }
112
- cellItemTemplateChanged() {
113
- this.updateItemTemplate();
114
- }
115
- headerCellItemTemplateChanged() {
116
- this.updateItemTemplate();
117
- }
118
- /**
119
- * @internal
120
- */
121
- connectedCallback() {
122
- super.connectedCallback();
123
- // note that row elements can be reused with a different data object
124
- // as the parent grid's repeat behavior reacts to changes in the data set.
125
- if (this.cellsRepeatBehavior === null) {
126
- this.cellsPlaceholder = document.createComment("");
127
- this.appendChild(this.cellsPlaceholder);
128
- this.updateItemTemplate();
129
- this.cellsRepeatBehavior = new RepeatDirective(x => x.columnDefinitions, x => x.activeCellItemTemplate, { positioning: true }).createBehavior(this.cellsPlaceholder);
130
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
131
- this.$fastController.addBehaviors([this.cellsRepeatBehavior]);
65
+ if (defaultSelected) {
66
+ this.defaultSelected = defaultSelected;
132
67
  }
133
- this.addEventListener("cell-focused", this.handleCellFocus);
134
- this.addEventListener(eventFocusOut, this.handleFocusout);
135
- this.addEventListener(eventKeyDown, this.handleKeydown);
136
- this.updateRowStyle();
137
- if (this.refocusOnLoad) {
138
- // if focus was on the row when data changed try to refocus on same cell
139
- this.refocusOnLoad = false;
140
- if (this.cellElements.length > this.focusColumnIndex) {
141
- this.cellElements[this.focusColumnIndex].focus();
142
- }
68
+ if (selected) {
69
+ this.selected = selected;
143
70
  }
71
+ this.proxy = new Option(`${this.textContent}`, this.initialValue, this.defaultSelected, this.selected);
72
+ this.proxy.disabled = this.disabled;
144
73
  }
145
74
  /**
146
- * @internal
75
+ * Updates the ariaChecked property when the checked property changes.
76
+ *
77
+ * @param prev - the previous checked value
78
+ * @param next - the current checked value
79
+ *
80
+ * @public
147
81
  */
148
- disconnectedCallback() {
149
- super.disconnectedCallback();
150
- this.removeEventListener("cell-focused", this.handleCellFocus);
151
- this.removeEventListener(eventFocusOut, this.handleFocusout);
152
- this.removeEventListener(eventKeyDown, this.handleKeydown);
153
- }
154
- handleFocusout(e) {
155
- if (!this.contains(e.target)) {
156
- this.isActiveRow = false;
157
- this.focusColumnIndex = 0;
158
- }
159
- }
160
- handleCellFocus(e) {
161
- this.isActiveRow = true;
162
- this.focusColumnIndex = this.cellElements.indexOf(e.target);
163
- this.$emit("row-focused", this);
164
- }
165
- handleKeydown(e) {
166
- if (e.defaultPrevented) {
82
+ checkedChanged(prev, next) {
83
+ if (typeof next === "boolean") {
84
+ this.ariaChecked = next ? "true" : "false";
167
85
  return;
168
86
  }
169
- let newFocusColumnIndex = 0;
170
- switch (e.key) {
171
- case keyArrowLeft:
172
- // focus left one cell
173
- newFocusColumnIndex = Math.max(0, this.focusColumnIndex - 1);
174
- this.cellElements[newFocusColumnIndex].focus();
175
- e.preventDefault();
176
- break;
177
- case keyArrowRight:
178
- // focus right one cell
179
- newFocusColumnIndex = Math.min(this.cellElements.length - 1, this.focusColumnIndex + 1);
180
- this.cellElements[newFocusColumnIndex].focus();
181
- e.preventDefault();
182
- break;
183
- case keyHome:
184
- if (!e.ctrlKey) {
185
- this.cellElements[0].focus();
186
- e.preventDefault();
187
- }
188
- break;
189
- case keyEnd:
190
- if (!e.ctrlKey) {
191
- // focus last cell of the row
192
- this.cellElements[this.cellElements.length - 1].focus();
193
- e.preventDefault();
194
- }
195
- break;
196
- }
197
- }
198
- updateItemTemplate() {
199
- this.activeCellItemTemplate =
200
- this.rowType === DataGridRowTypes.default &&
201
- this.cellItemTemplate !== undefined
202
- ? this.cellItemTemplate
203
- : this.rowType === DataGridRowTypes.default &&
204
- this.cellItemTemplate === undefined
205
- ? this.defaultCellItemTemplate
206
- : this.headerCellItemTemplate !== undefined
207
- ? this.headerCellItemTemplate
208
- : this.defaultHeaderCellItemTemplate;
209
- }
210
- }
211
- __decorate([
212
- attr({ attribute: "grid-template-columns" })
213
- ], DataGridRow$1.prototype, "gridTemplateColumns", void 0);
214
- __decorate([
215
- attr({ attribute: "row-type" })
216
- ], DataGridRow$1.prototype, "rowType", void 0);
217
- __decorate([
218
- observable
219
- ], DataGridRow$1.prototype, "rowData", void 0);
220
- __decorate([
221
- observable
222
- ], DataGridRow$1.prototype, "columnDefinitions", void 0);
223
- __decorate([
224
- observable
225
- ], DataGridRow$1.prototype, "cellItemTemplate", void 0);
226
- __decorate([
227
- observable
228
- ], DataGridRow$1.prototype, "headerCellItemTemplate", void 0);
229
- __decorate([
230
- observable
231
- ], DataGridRow$1.prototype, "rowIndex", void 0);
232
- __decorate([
233
- observable
234
- ], DataGridRow$1.prototype, "isActiveRow", void 0);
235
- __decorate([
236
- observable
237
- ], DataGridRow$1.prototype, "activeCellItemTemplate", void 0);
238
- __decorate([
239
- observable
240
- ], DataGridRow$1.prototype, "defaultCellItemTemplate", void 0);
241
- __decorate([
242
- observable
243
- ], DataGridRow$1.prototype, "defaultHeaderCellItemTemplate", void 0);
244
- __decorate([
245
- observable
246
- ], DataGridRow$1.prototype, "cellElements", void 0);
247
-
248
- /**
249
- * A Data Grid Custom HTML Element.
250
- *
251
- * @slot - The default slot for custom row elements
252
- * @public
253
- */
254
- class DataGrid$1 extends FoundationElement {
255
- constructor() {
256
- super();
257
- /**
258
- * When true the component will not add itself to the tab queue.
259
- * Default is false.
260
- *
261
- * @public
262
- * @remarks
263
- * HTML Attribute: no-tabbing
264
- */
265
- this.noTabbing = false;
266
- /**
267
- * Whether the grid should automatically generate a header row and its type
268
- *
269
- * @public
270
- * @remarks
271
- * HTML Attribute: generate-header
272
- */
273
- this.generateHeader = GenerateHeaderOptions.default;
274
- /**
275
- * The data being displayed in the grid
276
- *
277
- * @public
278
- */
279
- this.rowsData = [];
280
- /**
281
- * The column definitions of the grid
282
- *
283
- * @public
284
- */
285
- this.columnDefinitions = null;
286
- /**
287
- * The index of the row that will receive focus the next time the
288
- * grid is focused. This value changes as focus moves to different
289
- * rows within the grid. Changing this value when focus is already
290
- * within the grid moves focus to the specified row.
291
- *
292
- * @public
293
- */
294
- this.focusRowIndex = 0;
295
- /**
296
- * The index of the column that will receive focus the next time the
297
- * grid is focused. This value changes as focus moves to different rows
298
- * within the grid. Changing this value when focus is already within
299
- * the grid moves focus to the specified column.
300
- *
301
- * @public
302
- */
303
- this.focusColumnIndex = 0;
304
- this.rowsPlaceholder = null;
305
- this.generatedHeader = null;
306
- this.isUpdatingFocus = false;
307
- this.pendingFocusUpdate = false;
308
- this.rowindexUpdateQueued = false;
309
- this.columnDefinitionsStale = true;
310
- this.generatedGridTemplateColumns = "";
311
- this.focusOnCell = (rowIndex, columnIndex, scrollIntoView) => {
312
- if (this.rowElements.length === 0) {
313
- this.focusRowIndex = 0;
314
- this.focusColumnIndex = 0;
315
- return;
316
- }
317
- const focusRowIndex = Math.max(0, Math.min(this.rowElements.length - 1, rowIndex));
318
- const focusRow = this.rowElements[focusRowIndex];
319
- const cells = focusRow.querySelectorAll('[role="cell"], [role="gridcell"], [role="columnheader"], [role="rowheader"]');
320
- const focusColumnIndex = Math.max(0, Math.min(cells.length - 1, columnIndex));
321
- const focusTarget = cells[focusColumnIndex];
322
- if (scrollIntoView &&
323
- this.scrollHeight !== this.clientHeight &&
324
- ((focusRowIndex < this.focusRowIndex && this.scrollTop > 0) ||
325
- (focusRowIndex > this.focusRowIndex &&
326
- this.scrollTop < this.scrollHeight - this.clientHeight))) {
327
- focusTarget.scrollIntoView({ block: "center", inline: "center" });
328
- }
329
- focusTarget.focus();
330
- };
331
- this.onChildListChange = (mutations,
332
- /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
333
- observer) => {
334
- if (mutations && mutations.length) {
335
- mutations.forEach((mutation) => {
336
- mutation.addedNodes.forEach((newNode) => {
337
- if (newNode.nodeType === 1 &&
338
- newNode.getAttribute("role") === "row") {
339
- newNode.columnDefinitions = this.columnDefinitions;
340
- }
341
- });
342
- });
343
- this.queueRowIndexUpdate();
344
- }
345
- };
346
- this.queueRowIndexUpdate = () => {
347
- if (!this.rowindexUpdateQueued) {
348
- this.rowindexUpdateQueued = true;
349
- DOM.queueUpdate(this.updateRowIndexes);
350
- }
351
- };
352
- this.updateRowIndexes = () => {
353
- let newGridTemplateColumns = this.gridTemplateColumns;
354
- if (newGridTemplateColumns === undefined) {
355
- // try to generate columns based on manual rows
356
- if (this.generatedGridTemplateColumns === "" && this.rowElements.length > 0) {
357
- const firstRow = this.rowElements[0];
358
- this.generatedGridTemplateColumns = new Array(firstRow.cellElements.length)
359
- .fill("1fr")
360
- .join(" ");
361
- }
362
- newGridTemplateColumns = this.generatedGridTemplateColumns;
363
- }
364
- this.rowElements.forEach((element, index) => {
365
- const thisRow = element;
366
- thisRow.rowIndex = index;
367
- thisRow.gridTemplateColumns = newGridTemplateColumns;
368
- if (this.columnDefinitionsStale) {
369
- thisRow.columnDefinitions = this.columnDefinitions;
370
- }
371
- });
372
- this.rowindexUpdateQueued = false;
373
- this.columnDefinitionsStale = false;
374
- };
87
+ this.ariaChecked = null;
375
88
  }
376
89
  /**
377
- * generates a gridTemplateColumns based on columndata array
90
+ * Updates the proxy's text content when the default slot changes.
91
+ * @param prev - the previous content value
92
+ * @param next - the current content value
93
+ *
94
+ * @internal
378
95
  */
379
- static generateTemplateColumns(columnDefinitions) {
380
- let templateColumns = "";
381
- columnDefinitions.forEach((column) => {
382
- templateColumns = `${templateColumns}${templateColumns === "" ? "" : " "}${"1fr"}`;
383
- });
384
- return templateColumns;
385
- }
386
- noTabbingChanged() {
387
- if (this.$fastController.isConnected) {
388
- if (this.noTabbing) {
389
- this.setAttribute("tabIndex", "-1");
390
- }
391
- else {
392
- this.setAttribute("tabIndex", this.contains(document.activeElement) ||
393
- this === document.activeElement
394
- ? "-1"
395
- : "0");
396
- }
397
- }
398
- }
399
- generateHeaderChanged() {
400
- if (this.$fastController.isConnected) {
401
- this.toggleGeneratedHeader();
402
- }
403
- }
404
- gridTemplateColumnsChanged() {
405
- if (this.$fastController.isConnected) {
406
- this.updateRowIndexes();
407
- }
408
- }
409
- rowsDataChanged() {
410
- if (this.columnDefinitions === null && this.rowsData.length > 0) {
411
- this.columnDefinitions = DataGrid$1.generateColumns(this.rowsData[0]);
412
- }
413
- if (this.$fastController.isConnected) {
414
- this.toggleGeneratedHeader();
96
+ contentChanged(prev, next) {
97
+ if (this.proxy instanceof HTMLOptionElement) {
98
+ this.proxy.textContent = this.textContent;
415
99
  }
100
+ this.$emit("contentchange", null, { bubbles: true });
416
101
  }
417
- columnDefinitionsChanged() {
418
- if (this.columnDefinitions === null) {
419
- this.generatedGridTemplateColumns = "";
420
- return;
421
- }
422
- this.generatedGridTemplateColumns = DataGrid$1.generateTemplateColumns(this.columnDefinitions);
423
- if (this.$fastController.isConnected) {
424
- this.columnDefinitionsStale = true;
425
- this.queueRowIndexUpdate();
426
- }
427
- }
428
- headerCellItemTemplateChanged() {
429
- if (this.$fastController.isConnected) {
430
- if (this.generatedHeader !== null) {
431
- this.generatedHeader.headerCellItemTemplate = this.headerCellItemTemplate;
102
+ defaultSelectedChanged() {
103
+ if (!this.dirtySelected) {
104
+ this.selected = this.defaultSelected;
105
+ if (this.proxy instanceof HTMLOptionElement) {
106
+ this.proxy.selected = this.defaultSelected;
432
107
  }
433
108
  }
434
109
  }
435
- focusRowIndexChanged() {
436
- if (this.$fastController.isConnected) {
437
- this.queueFocusUpdate();
110
+ disabledChanged(prev, next) {
111
+ this.ariaDisabled = this.disabled ? "true" : "false";
112
+ if (this.proxy instanceof HTMLOptionElement) {
113
+ this.proxy.disabled = this.disabled;
438
114
  }
439
115
  }
440
- focusColumnIndexChanged() {
441
- if (this.$fastController.isConnected) {
442
- this.queueFocusUpdate();
116
+ selectedAttributeChanged() {
117
+ this.defaultSelected = this.selectedAttribute;
118
+ if (this.proxy instanceof HTMLOptionElement) {
119
+ this.proxy.defaultSelected = this.defaultSelected;
443
120
  }
444
121
  }
445
- /**
446
- * @internal
447
- */
448
- connectedCallback() {
449
- super.connectedCallback();
450
- if (this.rowItemTemplate === undefined) {
451
- this.rowItemTemplate = this.defaultRowItemTemplate;
122
+ selectedChanged() {
123
+ this.ariaSelected = this.selected ? "true" : "false";
124
+ if (!this.dirtySelected) {
125
+ this.dirtySelected = true;
452
126
  }
453
- this.rowsPlaceholder = document.createComment("");
454
- this.appendChild(this.rowsPlaceholder);
455
- this.toggleGeneratedHeader();
456
- this.rowsRepeatBehavior = new RepeatDirective(x => x.rowsData, x => x.rowItemTemplate, { positioning: true }).createBehavior(this.rowsPlaceholder);
457
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
458
- this.$fastController.addBehaviors([this.rowsRepeatBehavior]);
459
- this.addEventListener("row-focused", this.handleRowFocus);
460
- this.addEventListener(eventFocus, this.handleFocus);
461
- this.addEventListener(eventKeyDown, this.handleKeydown);
462
- this.addEventListener(eventFocusOut, this.handleFocusOut);
463
- this.observer = new MutationObserver(this.onChildListChange);
464
- // only observe if nodes are added or removed
465
- this.observer.observe(this, { childList: true });
466
- if (this.noTabbing) {
467
- this.setAttribute("tabindex", "-1");
127
+ if (this.proxy instanceof HTMLOptionElement) {
128
+ this.proxy.selected = this.selected;
468
129
  }
469
- DOM.queueUpdate(this.queueRowIndexUpdate);
470
- }
471
- /**
472
- * @internal
473
- */
474
- disconnectedCallback() {
475
- super.disconnectedCallback();
476
- this.removeEventListener("row-focused", this.handleRowFocus);
477
- this.removeEventListener(eventFocus, this.handleFocus);
478
- this.removeEventListener(eventKeyDown, this.handleKeydown);
479
- this.removeEventListener(eventFocusOut, this.handleFocusOut);
480
- // disconnect observer
481
- this.observer.disconnect();
482
- this.rowsPlaceholder = null;
483
- this.generatedHeader = null;
484
130
  }
485
- /**
486
- * @internal
487
- */
488
- handleRowFocus(e) {
489
- this.isUpdatingFocus = true;
490
- const focusRow = e.target;
491
- this.focusRowIndex = this.rowElements.indexOf(focusRow);
492
- this.focusColumnIndex = focusRow.focusColumnIndex;
493
- this.setAttribute("tabIndex", "-1");
494
- this.isUpdatingFocus = false;
131
+ initialValueChanged(previous, next) {
132
+ // If the value is clean and the component is connected to the DOM
133
+ // then set value equal to the attribute value.
134
+ if (!this.dirtyValue) {
135
+ this.value = this.initialValue;
136
+ this.dirtyValue = false;
137
+ }
495
138
  }
496
- /**
497
- * @internal
498
- */
499
- handleFocus(e) {
500
- this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
139
+ get label() {
140
+ var _a;
141
+ return (_a = this.value) !== null && _a !== void 0 ? _a : this.text;
501
142
  }
502
- /**
503
- * @internal
504
- */
505
- handleFocusOut(e) {
506
- if (e.relatedTarget === null || !this.contains(e.relatedTarget)) {
507
- this.setAttribute("tabIndex", this.noTabbing ? "-1" : "0");
508
- }
143
+ get text() {
144
+ var _a, _b;
145
+ return (_b = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.replace(/\s+/g, " ").trim()) !== null && _b !== void 0 ? _b : "";
509
146
  }
510
- /**
511
- * @internal
512
- */
513
- handleKeydown(e) {
514
- if (e.defaultPrevented) {
515
- return;
516
- }
517
- let newFocusRowIndex;
518
- const maxIndex = this.rowElements.length - 1;
519
- const currentGridBottom = this.offsetHeight + this.scrollTop;
520
- const lastRow = this.rowElements[maxIndex];
521
- switch (e.key) {
522
- case keyArrowUp:
523
- e.preventDefault();
524
- // focus up one row
525
- this.focusOnCell(this.focusRowIndex - 1, this.focusColumnIndex, true);
526
- break;
527
- case keyArrowDown:
528
- e.preventDefault();
529
- // focus down one row
530
- this.focusOnCell(this.focusRowIndex + 1, this.focusColumnIndex, true);
531
- break;
532
- case keyPageUp:
533
- e.preventDefault();
534
- if (this.rowElements.length === 0) {
535
- this.focusOnCell(0, 0, false);
536
- break;
537
- }
538
- if (this.focusRowIndex === 0) {
539
- this.focusOnCell(0, this.focusColumnIndex, false);
540
- return;
541
- }
542
- newFocusRowIndex = this.focusRowIndex - 1;
543
- for (newFocusRowIndex; newFocusRowIndex >= 0; newFocusRowIndex--) {
544
- const thisRow = this.rowElements[newFocusRowIndex];
545
- if (thisRow.offsetTop < this.scrollTop) {
546
- this.scrollTop =
547
- thisRow.offsetTop + thisRow.clientHeight - this.clientHeight;
548
- break;
549
- }
550
- }
551
- this.focusOnCell(newFocusRowIndex, this.focusColumnIndex, false);
552
- break;
553
- case keyPageDown:
554
- e.preventDefault();
555
- if (this.rowElements.length === 0) {
556
- this.focusOnCell(0, 0, false);
557
- break;
558
- }
559
- // focus down one "page"
560
- if (this.focusRowIndex >= maxIndex ||
561
- lastRow.offsetTop + lastRow.offsetHeight <= currentGridBottom) {
562
- this.focusOnCell(maxIndex, this.focusColumnIndex, false);
563
- return;
564
- }
565
- newFocusRowIndex = this.focusRowIndex + 1;
566
- for (newFocusRowIndex; newFocusRowIndex <= maxIndex; newFocusRowIndex++) {
567
- const thisRow = this.rowElements[newFocusRowIndex];
568
- if (thisRow.offsetTop + thisRow.offsetHeight > currentGridBottom) {
569
- let stickyHeaderOffset = 0;
570
- if (this.generateHeader === GenerateHeaderOptions.sticky &&
571
- this.generatedHeader !== null) {
572
- stickyHeaderOffset = this.generatedHeader.clientHeight;
573
- }
574
- this.scrollTop = thisRow.offsetTop - stickyHeaderOffset;
575
- break;
576
- }
577
- }
578
- this.focusOnCell(newFocusRowIndex, this.focusColumnIndex, false);
579
- break;
580
- case keyHome:
581
- if (e.ctrlKey) {
582
- e.preventDefault();
583
- // focus first cell of first row
584
- this.focusOnCell(0, 0, true);
585
- }
586
- break;
587
- case keyEnd:
588
- if (e.ctrlKey && this.columnDefinitions !== null) {
589
- e.preventDefault();
590
- // focus last cell of last row
591
- this.focusOnCell(this.rowElements.length - 1, this.columnDefinitions.length - 1, true);
592
- }
593
- break;
147
+ set value(next) {
148
+ const newValue = `${next !== null && next !== void 0 ? next : ""}`;
149
+ this._value = newValue;
150
+ this.dirtyValue = true;
151
+ if (this.proxy instanceof HTMLOptionElement) {
152
+ this.proxy.value = newValue;
594
153
  }
154
+ Observable.notify(this, "value");
595
155
  }
596
- queueFocusUpdate() {
597
- if (this.isUpdatingFocus &&
598
- (this.contains(document.activeElement) || this === document.activeElement)) {
599
- return;
600
- }
601
- if (this.pendingFocusUpdate === false) {
602
- this.pendingFocusUpdate = true;
603
- DOM.queueUpdate(() => this.updateFocus());
604
- }
156
+ get value() {
157
+ var _a;
158
+ Observable.track(this, "value");
159
+ return (_a = this._value) !== null && _a !== void 0 ? _a : this.text;
605
160
  }
606
- updateFocus() {
607
- this.pendingFocusUpdate = false;
608
- this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
609
- }
610
- toggleGeneratedHeader() {
611
- if (this.generatedHeader !== null) {
612
- this.removeChild(this.generatedHeader);
613
- this.generatedHeader = null;
614
- }
615
- if (this.generateHeader !== GenerateHeaderOptions.none &&
616
- this.rowsData.length > 0) {
617
- const generatedHeaderElement = document.createElement(this.rowElementTag);
618
- this.generatedHeader = generatedHeaderElement;
619
- this.generatedHeader.columnDefinitions = this.columnDefinitions;
620
- this.generatedHeader.gridTemplateColumns = this.gridTemplateColumns;
621
- this.generatedHeader.rowType =
622
- this.generateHeader === GenerateHeaderOptions.sticky
623
- ? DataGridRowTypes.stickyHeader
624
- : DataGridRowTypes.header;
625
- if (this.firstChild !== null || this.rowsPlaceholder !== null) {
626
- this.insertBefore(generatedHeaderElement, this.firstChild !== null ? this.firstChild : this.rowsPlaceholder);
627
- }
628
- return;
629
- }
161
+ get form() {
162
+ return this.proxy ? this.proxy.form : null;
630
163
  }
631
164
  }
632
- /**
633
- * generates a basic column definition by examining sample row data
634
- */
635
- DataGrid$1.generateColumns = (row) => {
636
- return Object.getOwnPropertyNames(row).map((property, index) => {
637
- return {
638
- columnDataKey: property,
639
- gridColumn: `${index}`,
640
- };
641
- });
642
- };
643
- __decorate([
644
- attr({ attribute: "no-tabbing", mode: "boolean" })
645
- ], DataGrid$1.prototype, "noTabbing", void 0);
646
- __decorate([
647
- attr({ attribute: "generate-header" })
648
- ], DataGrid$1.prototype, "generateHeader", void 0);
649
- __decorate([
650
- attr({ attribute: "grid-template-columns" })
651
- ], DataGrid$1.prototype, "gridTemplateColumns", void 0);
652
165
  __decorate([
653
166
  observable
654
- ], DataGrid$1.prototype, "rowsData", void 0);
167
+ ], ListboxOption$1.prototype, "checked", void 0);
655
168
  __decorate([
656
169
  observable
657
- ], DataGrid$1.prototype, "columnDefinitions", void 0);
170
+ ], ListboxOption$1.prototype, "content", void 0);
658
171
  __decorate([
659
172
  observable
660
- ], DataGrid$1.prototype, "rowItemTemplate", void 0);
173
+ ], ListboxOption$1.prototype, "defaultSelected", void 0);
661
174
  __decorate([
662
- observable
663
- ], DataGrid$1.prototype, "cellItemTemplate", void 0);
664
- __decorate([
665
- observable
666
- ], DataGrid$1.prototype, "headerCellItemTemplate", void 0);
175
+ attr({ mode: "boolean" })
176
+ ], ListboxOption$1.prototype, "disabled", void 0);
667
177
  __decorate([
668
- observable
669
- ], DataGrid$1.prototype, "focusRowIndex", void 0);
178
+ attr({ attribute: "selected", mode: "boolean" })
179
+ ], ListboxOption$1.prototype, "selectedAttribute", void 0);
670
180
  __decorate([
671
181
  observable
672
- ], DataGrid$1.prototype, "focusColumnIndex", void 0);
182
+ ], ListboxOption$1.prototype, "selected", void 0);
673
183
  __decorate([
674
- observable
675
- ], DataGrid$1.prototype, "defaultRowItemTemplate", void 0);
676
- __decorate([
677
- observable
678
- ], DataGrid$1.prototype, "rowElementTag", void 0);
679
- __decorate([
680
- observable
681
- ], DataGrid$1.prototype, "rowElements", void 0);
682
-
683
- const defaultCellContentsTemplate = html `
684
- <template>
685
- ${x => x.rowData === null ||
686
- x.columnDefinition === null ||
687
- x.columnDefinition.columnDataKey === null
688
- ? null
689
- : x.rowData[x.columnDefinition.columnDataKey]}
690
- </template>
691
- `;
692
- const defaultHeaderCellContentsTemplate = html `
693
- <template>
694
- ${x => x.columnDefinition === null
695
- ? null
696
- : x.columnDefinition.title === undefined
697
- ? x.columnDefinition.columnDataKey
698
- : x.columnDefinition.title}
699
- </template>
700
- `;
184
+ attr({ attribute: "value", mode: "fromView" })
185
+ ], ListboxOption$1.prototype, "initialValue", void 0);
701
186
  /**
702
- * A Data Grid Cell Custom HTML Element.
187
+ * States and properties relating to the ARIA `option` role.
703
188
  *
704
- * @fires cell-focused - Fires a custom 'cell-focused' event when focus is on the cell or its contents
705
- * @slot - The default slot for cell contents. The "cell contents template" renders here.
706
189
  * @public
707
190
  */
708
- class DataGridCell$1 extends FoundationElement {
709
- constructor() {
710
- super(...arguments);
711
- /**
712
- * The type of cell
713
- *
714
- * @public
715
- * @remarks
716
- * HTML Attribute: cell-type
717
- */
718
- this.cellType = DataGridCellTypes.default;
719
- /**
720
- * The base data for the parent row
721
- *
722
- * @public
723
- */
724
- this.rowData = null;
725
- /**
726
- * The base data for the column
727
- *
728
- * @public
729
- */
730
- this.columnDefinition = null;
731
- this.isActiveCell = false;
732
- this.customCellView = null;
733
- this.updateCellStyle = () => {
734
- this.style.gridColumn = this.gridColumn;
735
- };
736
- }
737
- cellTypeChanged() {
738
- if (this.$fastController.isConnected) {
739
- this.updateCellView();
740
- }
741
- }
742
- gridColumnChanged() {
743
- if (this.$fastController.isConnected) {
744
- this.updateCellStyle();
745
- }
746
- }
747
- columnDefinitionChanged(oldValue, newValue) {
748
- if (this.$fastController.isConnected) {
749
- this.updateCellView();
750
- }
751
- }
752
- /**
753
- * @internal
754
- */
755
- connectedCallback() {
756
- var _a;
757
- super.connectedCallback();
758
- this.addEventListener(eventFocusIn, this.handleFocusin);
759
- this.addEventListener(eventFocusOut, this.handleFocusout);
760
- this.addEventListener(eventKeyDown, this.handleKeydown);
761
- this.style.gridColumn = `${((_a = this.columnDefinition) === null || _a === void 0 ? void 0 : _a.gridColumn) === undefined
762
- ? 0
763
- : this.columnDefinition.gridColumn}`;
764
- this.updateCellView();
765
- this.updateCellStyle();
766
- }
767
- /**
768
- * @internal
769
- */
770
- disconnectedCallback() {
771
- super.disconnectedCallback();
772
- this.removeEventListener(eventFocusIn, this.handleFocusin);
773
- this.removeEventListener(eventFocusOut, this.handleFocusout);
774
- this.removeEventListener(eventKeyDown, this.handleKeydown);
775
- this.disconnectCellView();
776
- }
777
- handleFocusin(e) {
778
- if (this.isActiveCell) {
779
- return;
780
- }
781
- this.isActiveCell = true;
782
- switch (this.cellType) {
783
- case DataGridCellTypes.columnHeader:
784
- if (this.columnDefinition !== null &&
785
- this.columnDefinition.headerCellInternalFocusQueue !== true &&
786
- typeof this.columnDefinition.headerCellFocusTargetCallback ===
787
- "function") {
788
- // move focus to the focus target
789
- const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
790
- if (focusTarget !== null) {
791
- focusTarget.focus();
792
- }
793
- }
794
- break;
795
- default:
796
- if (this.columnDefinition !== null &&
797
- this.columnDefinition.cellInternalFocusQueue !== true &&
798
- typeof this.columnDefinition.cellFocusTargetCallback === "function") {
799
- // move focus to the focus target
800
- const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
801
- if (focusTarget !== null) {
802
- focusTarget.focus();
803
- }
804
- }
805
- break;
806
- }
807
- this.$emit("cell-focused", this);
808
- }
809
- handleFocusout(e) {
810
- if (this !== document.activeElement && !this.contains(document.activeElement)) {
811
- this.isActiveCell = false;
812
- }
813
- }
814
- handleKeydown(e) {
815
- if (e.defaultPrevented ||
816
- this.columnDefinition === null ||
817
- (this.cellType === DataGridCellTypes.default &&
818
- this.columnDefinition.cellInternalFocusQueue !== true) ||
819
- (this.cellType === DataGridCellTypes.columnHeader &&
820
- this.columnDefinition.headerCellInternalFocusQueue !== true)) {
821
- return;
822
- }
823
- switch (e.key) {
824
- case keyEnter:
825
- case keyFunction2:
826
- if (this.contains(document.activeElement) &&
827
- document.activeElement !== this) {
828
- return;
829
- }
830
- switch (this.cellType) {
831
- case DataGridCellTypes.columnHeader:
832
- if (this.columnDefinition.headerCellFocusTargetCallback !==
833
- undefined) {
834
- const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
835
- if (focusTarget !== null) {
836
- focusTarget.focus();
837
- }
838
- e.preventDefault();
839
- }
840
- break;
841
- default:
842
- if (this.columnDefinition.cellFocusTargetCallback !== undefined) {
843
- const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
844
- if (focusTarget !== null) {
845
- focusTarget.focus();
846
- }
847
- e.preventDefault();
848
- }
849
- break;
850
- }
851
- break;
852
- case keyEscape:
853
- if (this.contains(document.activeElement) &&
854
- document.activeElement !== this) {
855
- this.focus();
856
- e.preventDefault();
857
- }
858
- break;
859
- }
860
- }
861
- updateCellView() {
862
- this.disconnectCellView();
863
- if (this.columnDefinition === null) {
864
- return;
865
- }
866
- switch (this.cellType) {
867
- case DataGridCellTypes.columnHeader:
868
- if (this.columnDefinition.headerCellTemplate !== undefined) {
869
- this.customCellView = this.columnDefinition.headerCellTemplate.render(this, this);
870
- }
871
- else {
872
- this.customCellView = defaultHeaderCellContentsTemplate.render(this, this);
873
- }
874
- break;
875
- case undefined:
876
- case DataGridCellTypes.rowHeader:
877
- case DataGridCellTypes.default:
878
- if (this.columnDefinition.cellTemplate !== undefined) {
879
- this.customCellView = this.columnDefinition.cellTemplate.render(this, this);
880
- }
881
- else {
882
- this.customCellView = defaultCellContentsTemplate.render(this, this);
883
- }
884
- break;
885
- }
886
- }
887
- disconnectCellView() {
888
- if (this.customCellView !== null) {
889
- this.customCellView.dispose();
890
- this.customCellView = null;
891
- }
892
- }
191
+ class DelegatesARIAListboxOption {
893
192
  }
894
193
  __decorate([
895
- attr({ attribute: "cell-type" })
896
- ], DataGridCell$1.prototype, "cellType", void 0);
194
+ observable
195
+ ], DelegatesARIAListboxOption.prototype, "ariaChecked", void 0);
897
196
  __decorate([
898
- attr({ attribute: "grid-column" })
899
- ], DataGridCell$1.prototype, "gridColumn", void 0);
197
+ observable
198
+ ], DelegatesARIAListboxOption.prototype, "ariaPosInSet", void 0);
900
199
  __decorate([
901
200
  observable
902
- ], DataGridCell$1.prototype, "rowData", void 0);
201
+ ], DelegatesARIAListboxOption.prototype, "ariaSelected", void 0);
903
202
  __decorate([
904
203
  observable
905
- ], DataGridCell$1.prototype, "columnDefinition", void 0);
906
-
907
- var css_248z$2 = ":host {\n position: relative;\n display: block;\n}\n\n:host([generate-header=sticky]) {\n max-height: var(--data-grid-max-height, 200px);\n overflow-y: auto;\n}";
908
-
909
- var css_248z$1 = "/**\n * Do not edit directly\n * Generated on Mon, 24 Apr 2023 10:27:51 GMT\n */\n:host {\n display: grid;\n width: 100%;\n box-sizing: border-box;\n color: var(--vvd-color-canvas-text);\n}\n\n:host([row-type=sticky-header]) {\n position: sticky;\n z-index: 999;\n top: 0;\n background: var(--vvd-color-canvas);\n}";
910
-
911
- var css_248z = "/**\n * Do not edit directly\n * Generated on Mon, 24 Apr 2023 10:27:51 GMT\n */\n:host {\n position: relative;\n display: flex;\n overflow: hidden;\n box-sizing: border-box;\n align-items: center;\n padding: 8px 12px;\n border-bottom: 1px solid var(--vvd-color-neutral-100);\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) + 8));\n color: var(--vvd-color-canvas-text);\n font: var(--vvd-typography-base);\n outline: none;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n:host([cell-type=columnheader]) {\n border-color: currentColor;\n font: var(--vvd-typography-base-bold);\n}\n\n.focus-indicator {\n --focus-stroke-gap-color: transparent;\n pointer-events: none;\n}\n#focus-wrapper:not(.active) > .focus-indicator {\n display: none;\n}";
204
+ ], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
205
+ applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
206
+ applyMixins(ListboxOption$1, StartEnd, DelegatesARIAListboxOption);
912
207
 
913
- class DataGrid extends DataGrid$1 {}
914
- __decorate([attr({
915
- attribute: 'selection-mode'
916
- }), __metadata("design:type", String)], DataGrid.prototype, "selectionMode", void 0);
917
-
918
- class DataGridRow extends DataGridRow$1 {}
919
-
920
- let _2$1 = t => t,
921
- _t$2,
922
- _t2$1;
923
- function createRowItemTemplate(context) {
924
- const rowTag = context.tagFor(DataGridRow);
925
- return html(_t$2 || (_t$2 = _2$1`
926
- <${0}
927
- :rowData="${0}"
928
- :cellItemTemplate="${0}"
929
- :headerCellItemTemplate="${0}"
930
- ></${0}>
931
- `), rowTag, x => x, (_, c) => c.parent.cellItemTemplate, (_, c) => c.parent.headerCellItemTemplate, rowTag);
932
- }
933
- const DataGridTemplate = context => {
934
- const rowItemTemplate = createRowItemTemplate(context);
935
- const rowTag = context.tagFor(DataGridRow);
936
- return html(_t2$1 || (_t2$1 = _2$1`
937
- <template
938
- role="grid"
939
- tabindex="0"
940
- :rowElementTag="${0}"
941
- :defaultRowItemTemplate="${0}"
942
- ${0}
943
- >
944
- <slot></slot>
945
- </template>
946
- `), () => rowTag, rowItemTemplate, children({
947
- property: 'rowElements',
948
- filter: elements('[role=row]')
949
- }));
950
- };
951
-
952
- class DataGridCell extends DataGridCell$1 {
953
- handleFocusin(e) {
954
- super.handleFocusin(e);
955
- this.shadowRoot.getElementById('focus-wrapper').classList.add('active');
208
+ class ListboxOption extends ListboxOption$1 {
209
+ set text(value) {
210
+ this._text = value;
956
211
  }
957
- handleFocusout(e) {
958
- super.handleFocusout(e);
959
- this.shadowRoot.getElementById('focus-wrapper').classList.remove('active');
212
+ get text() {
213
+ var _a;
214
+ return (_a = this._text) !== null && _a !== void 0 ? _a : '';
215
+ }
216
+ get label() {
217
+ var _a;
218
+ return (_a = this._label) !== null && _a !== void 0 ? _a : this.text;
219
+ }
220
+ set label(value) {
221
+ this._label = value;
960
222
  }
961
223
  }
962
-
963
- let _2 = t => t,
964
- _t$1,
965
- _t2,
966
- _t3;
967
- function createCellItemTemplate(context) {
968
- const cellTag = context.tagFor(DataGridCell);
969
- return html(_t$1 || (_t$1 = _2`
970
- <${0}
971
- cell-type="${0}"
972
- grid-column="${0}"
973
- :rowData="${0}"
974
- :columnDefinition="${0}"
975
- ></${0}>
976
- `), cellTag, x => x.isRowHeader ? 'rowheader' : undefined, (_, c) => c.index + 1, (_, c) => c.parent.rowData, x => x, cellTag);
977
- }
978
- function createHeaderCellItemTemplate(context) {
979
- const cellTag = context.tagFor(DataGridCell);
980
- return html(_t2 || (_t2 = _2`
981
- <${0}
982
- cell-type="columnheader"
983
- grid-column="${0}"
984
- :columnDefinition="${0}"
985
- ></${0}>
986
- `), cellTag, (_, c) => c.index + 1, x => x, cellTag);
987
- }
988
- const DataGridRowTemplate = context => {
989
- const cellItemTemplate = createCellItemTemplate(context);
990
- const headerCellItemTemplate = createHeaderCellItemTemplate(context);
991
- return html(_t3 || (_t3 = _2`
992
- <template
993
- role="row"
994
- class="${0}"
995
- :defaultCellItemTemplate="${0}"
996
- :defaultHeaderCellItemTemplate="${0}"
997
- ${0}
998
- >
999
- <slot ${0}></slot>
1000
- </template>
1001
- `), x => x.rowType !== 'default' ? x.rowType : '', cellItemTemplate, headerCellItemTemplate, children({
1002
- property: 'cellElements',
1003
- filter: elements('[role="cell"],[role="gridcell"],[role="columnheader"],[role="rowheader"]')
1004
- }), slotted('slottedCellElements'));
1005
- };
1006
-
1007
- const DataGridCellRole = {
1008
- columnheader: 'columnheader',
1009
- rowheader: 'rowheader',
1010
- default: 'gridcell'
1011
- };
224
+ __decorate([attr({
225
+ attribute: 'text'
226
+ }), __metadata("design:type", String)], ListboxOption.prototype, "_text", void 0);
227
+ __decorate([attr({
228
+ attribute: 'label'
229
+ }), __metadata("design:type", String)], ListboxOption.prototype, "_label", void 0);
230
+ applyMixins(ListboxOption, AffixIconWithTrailing);
1012
231
 
1013
232
  let _ = t => t,
1014
- _t;
1015
- function DataGridCellTemplate(context) {
233
+ _t,
234
+ _t2;
235
+ const getClasses = ({
236
+ icon,
237
+ disabled,
238
+ selected,
239
+ checked
240
+ }) => classNames('base', ['disabled', disabled], ['selected', Boolean(selected)], ['active', Boolean(checked)], ['icon', Boolean(icon)]);
241
+ const ListboxOptionTemplate = context => {
242
+ const affixIconTemplate = affixIconTemplateFactory(context);
1016
243
  const focusTemplate = focusTemplateFactory(context);
1017
244
  return html(_t || (_t = _`
1018
- <template
1019
- tabindex="-1"
1020
- role="${0}"
1021
- >
1022
- <div id="focus-wrapper">
1023
- <slot></slot>
1024
- ${0}
1025
- </div>
245
+ <template
246
+ aria-checked="${0}"
247
+ aria-disabled="${0}"
248
+ aria-posinset="${0}"
249
+ aria-selected="${0}"
250
+ aria-setsize="${0}"
251
+ role="option">
252
+ <div class="${0}">
253
+ ${0}
254
+ ${0}
255
+ ${0}
256
+ </div>
257
+ </template>
258
+ `), x => x.ariaChecked, x => x.ariaDisabled, x => x.ariaPosInSet, x => x.ariaSelected, x => x.ariaSetSize, getClasses, () => focusTemplate, x => affixIconTemplate(x.icon), when(x => x.text, html(_t2 || (_t2 = _`<div class="text">${0}</div>`), x => x.text)));
259
+ };
1026
260
 
1027
- </template>
1028
- `), x => {
1029
- var _a;
1030
- return (_a = DataGridCellRole[x.cellType]) !== null && _a !== void 0 ? _a : DataGridCellRole.default;
1031
- }, () => focusTemplate);
1032
- }
261
+ var css_248z = "/**\n * Do not edit directly\n * Generated on Mon, 08 May 2023 11:40:49 GMT\n */\n.base {\n position: relative; /* this is needed for the focus */\n display: flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n border-radius: 6px;\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n color: var(--_option-appearance-color-text, var(--_appearance-color-text));\n font: var(--vvd-typography-base);\n gap: 12px;\n hyphens: auto;\n inline-size: 100%;\n min-block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n padding-inline: 16px;\n vertical-align: middle;\n word-break: break-word;\n}\n.base {\n --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n --_connotation-color-primary-increment: var(--vvd-color-neutral-800);\n --_connotation-color-faint: var(--vvd-color-neutral-50);\n --_connotation-color-soft: var(--vvd-color-neutral-100);\n --_connotation-color-pale: var(--vvd-color-neutral-300);\n --_connotation-color-dim: var(--vvd-color-neutral-200);\n}\n.base {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: transparent;\n}\n.base:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-400);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:active, .active):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:not(:disabled, .disabled, :hover, .hover)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-dim);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:hover, .hover) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-pale);\n --_appearance-color-outline: transparent;\n}\n@supports (user-select: none) {\n .base {\n user-select: none;\n }\n}\n.base:not(.disabled) {\n cursor: pointer;\n}\n.base.disabled {\n cursor: not-allowed;\n pointer-events: none;\n}\n.base .text {\n font: var(--vvd-typography-base);\n}\n\n.icon {\n font-size: 20px;\n line-height: 1;\n}\n.base:not(.disabled, .selected) .icon {\n color: var(--vvd-color-neutral-600);\n}\n\n.focus-indicator {\n --focus-stroke-color: var(--vvd-color-neutral-500);\n --focus-stroke-gap-color: transparent;\n}\n:host(:not([aria-checked=true])) .focus-indicator {\n display: none;\n}";
1033
262
 
1034
- const dataGrid = DataGrid.compose({
1035
- baseName: 'data-grid',
1036
- template: DataGridTemplate,
1037
- styles: css_248z$2
1038
- })();
1039
- const dataGridRow = DataGridRow.compose({
1040
- baseName: 'data-grid-row',
1041
- template: DataGridRowTemplate,
1042
- styles: css_248z$1
1043
- })();
1044
- const dataGridCell = DataGridCell.compose({
1045
- baseName: 'data-grid-cell',
1046
- template: DataGridCellTemplate,
263
+ const listboxOptionDefinition = ListboxOption.compose({
264
+ baseName: 'option',
265
+ template: ListboxOptionTemplate,
1047
266
  styles: css_248z
1048
- })();
1049
- const dataGridElements = [dataGridCell, dataGridRow, dataGrid];
1050
- const registerDataGrid = registerFactory(dataGridElements);
267
+ });
268
+ const listboxOptionRegistries = [listboxOptionDefinition(), ...iconRegistries, ...focusRegistries];
269
+ const registerOption = registerFactory(listboxOptionRegistries);
1051
270
 
1052
- export { dataGridRow as a, dataGridCell as b, dataGridElements as c, dataGrid as d, registerDataGrid as r };
271
+ export { listboxOptionDefinition as a, isListboxOption as i, listboxOptionRegistries as l, registerOption as r };