@vonage/vivid 3.3.0 → 3.5.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 (130) hide show
  1. package/custom-elements.json +412 -1
  2. package/data-grid/index.js +7 -1047
  3. package/dialog/index.js +2 -1
  4. package/divider/index.js +1 -1
  5. package/fab/index.js +1 -1
  6. package/header/index.js +1 -1
  7. package/index.d.ts +1 -0
  8. package/index.js +32 -31
  9. package/layout/index.js +1 -1
  10. package/lib/accordion/definition.d.ts +1 -0
  11. package/lib/action-group/action-group.d.ts +1 -2
  12. package/lib/action-group/definition.d.ts +1 -0
  13. package/lib/avatar/avatar.d.ts +2 -3
  14. package/lib/avatar/definition.d.ts +1 -0
  15. package/lib/badge/badge.d.ts +3 -4
  16. package/lib/badge/definition.d.ts +1 -0
  17. package/lib/banner/definition.d.ts +1 -0
  18. package/lib/button/button.d.ts +3 -4
  19. package/lib/button/definition.d.ts +1 -0
  20. package/lib/calendar-event/calendar-event.d.ts +2 -3
  21. package/lib/calendar-event/definition.d.ts +1 -0
  22. package/lib/combobox/combobox.d.ts +1 -2
  23. package/lib/combobox/definition.d.ts +1 -0
  24. package/lib/components.d.ts +1 -0
  25. package/lib/data-grid/data-grid.d.ts +8 -0
  26. package/lib/dialog/definition.d.ts +1 -0
  27. package/lib/dialog/dialog.d.ts +3 -2
  28. package/lib/fab/definition.d.ts +1 -0
  29. package/lib/fab/fab.d.ts +1 -2
  30. package/lib/icon/definition.d.ts +1 -0
  31. package/lib/icon/icon.d.ts +1 -2
  32. package/lib/layout/definition.d.ts +1 -0
  33. package/lib/layout/layout.d.ts +3 -4
  34. package/lib/listbox/definition.d.ts +1 -0
  35. package/lib/menu/definition.d.ts +1 -0
  36. package/lib/menu/menu.d.ts +1 -0
  37. package/lib/note/definition.d.ts +1 -0
  38. package/lib/number-field/definition.d.ts +1 -0
  39. package/lib/number-field/number-field.d.ts +2 -3
  40. package/lib/popup/definition.d.ts +2 -0
  41. package/lib/progress/definition.d.ts +1 -0
  42. package/lib/progress-ring/definition.d.ts +1 -0
  43. package/lib/select/definition.d.ts +1 -0
  44. package/lib/select/select.d.ts +2 -3
  45. package/lib/switch/definition.d.ts +1 -0
  46. package/lib/text-area/definition.d.ts +1 -0
  47. package/lib/text-area/text-area.d.ts +1 -2
  48. package/lib/text-field/definition.d.ts +1 -0
  49. package/lib/text-field/text-field.d.ts +2 -3
  50. package/listbox/index.js +1 -1
  51. package/menu/index.js +2 -2
  52. package/menu-item/index.js +1 -1
  53. package/nav/index.js +1 -1
  54. package/nav-disclosure/index.js +1 -1
  55. package/nav-item/index.js +1 -1
  56. package/note/index.js +1 -1
  57. package/number-field/index.js +2 -2
  58. package/package.json +1 -1
  59. package/progress/index.js +1 -1
  60. package/progress-ring/index.js +1 -1
  61. package/radio/index.js +1 -1
  62. package/radio-group/index.js +1 -1
  63. package/select/index.js +1 -1
  64. package/shared/definition.js +1 -1
  65. package/shared/definition11.js +1 -1
  66. package/shared/definition12.js +1 -1
  67. package/shared/definition13.js +1 -1
  68. package/shared/definition14.js +1 -1
  69. package/shared/definition16.js +1 -1
  70. package/shared/definition17.js +1 -1
  71. package/shared/definition18.js +2 -2
  72. package/shared/definition19.js +1 -1
  73. package/shared/definition2.js +1 -1
  74. package/shared/definition20.js +1038 -203
  75. package/shared/definition21.js +226 -67
  76. package/shared/definition22.js +68 -77
  77. package/shared/definition23.js +76 -47
  78. package/shared/definition24.js +46 -32
  79. package/shared/definition25.js +35 -49
  80. package/shared/definition26.js +48 -338
  81. package/shared/definition27.js +273 -282
  82. package/shared/definition28.js +356 -14
  83. package/shared/definition29.js +13 -67
  84. package/shared/definition30.js +65 -21
  85. package/shared/definition31.js +21 -39
  86. package/shared/definition32.js +31 -432
  87. package/shared/definition33.js +432 -76
  88. package/shared/definition34.js +76 -59
  89. package/shared/definition35.js +67 -35
  90. package/shared/definition36.js +31 -422
  91. package/shared/definition37.js +357 -560
  92. package/shared/definition38.js +624 -74
  93. package/shared/definition39.js +70 -573
  94. package/shared/definition4.js +1 -1
  95. package/shared/definition40.js +527 -81
  96. package/shared/definition41.js +127 -47
  97. package/shared/definition42.js +51 -16
  98. package/shared/definition43.js +17 -425
  99. package/shared/definition44.js +367 -209
  100. package/shared/definition45.js +248 -85
  101. package/shared/definition46.js +110 -68
  102. package/shared/definition47.js +65 -67
  103. package/shared/definition48.js +69 -295
  104. package/shared/definition49.js +305 -0
  105. package/shared/definition5.js +1 -1
  106. package/shared/definition6.js +1 -1
  107. package/shared/definition7.js +1 -1
  108. package/shared/definition8.js +1 -1
  109. package/shared/definition9.js +1 -1
  110. package/shared/enums.js +1 -1
  111. package/shared/form-elements.js +1 -1
  112. package/shared/patterns/form-elements/form-elements.d.ts +2 -2
  113. package/shared/text-field.js +1 -1
  114. package/side-drawer/index.js +1 -1
  115. package/slider/index.js +1 -1
  116. package/styles/core/all.css +1 -1
  117. package/styles/core/theme.css +1 -1
  118. package/styles/core/typography.css +1 -1
  119. package/styles/tokens/theme-dark.css +4 -4
  120. package/styles/tokens/theme-light.css +4 -4
  121. package/switch/index.js +1 -1
  122. package/tab/index.js +1 -1
  123. package/tab-panel/index.js +1 -1
  124. package/tabs/index.js +3 -3
  125. package/text-area/index.js +1 -1
  126. package/text-field/index.js +1 -1
  127. package/tooltip/index.js +1 -1
  128. package/tree-item/index.js +1 -1
  129. package/tree-view/index.js +1 -1
  130. package/vivid.api.json +4526 -336
@@ -1,217 +1,1052 @@
1
- import { F as FoundationElement, U as __classPrivateFieldGet, _ as __decorate, a as attr, b as __metadata, a5 as __classPrivateFieldSet, h as html, r as registerFactory } from './index.js';
2
- import { i as iconRegistries } from './definition3.js';
3
- import { B as Button, b as buttonRegistries } from './definition9.js';
4
- import { E as Elevation, e as elevationRegistries } from './definition15.js';
5
- import { I as Icon } from './icon.js';
6
- import { w as when } from './when.js';
7
- import { c as classNames } from './class-names.js';
8
-
9
- var css_248z$1 = "dialog {\n position: absolute;\n left: 0; right: 0;\n width: -moz-fit-content;\n width: -webkit-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: -webkit-fit-content;\n height: fit-content;\n margin: auto;\n border: solid;\n padding: 1em;\n background: white;\n color: black;\n display: block;\n}\n\ndialog:not([open]) {\n display: none;\n}\n\ndialog + .backdrop {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n background: rgba(0,0,0,0.1);\n}\n\n._dialog_overlay {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n}\n\ndialog.fixed {\n position: fixed;\n top: 50%;\n transform: translate(0, -50%);\n}";
10
-
11
- var css_248z = "/**\n * Do not edit directly\n * Generated on Wed, 08 Mar 2023 09:27:51 GMT\n */\n.base {\n box-sizing: border-box;\n padding: 0;\n border: none;\n background: var(--_elevation-fill);\n border-radius: 6px;\n color: var(--vvd-color-canvas-text);\n max-block-size: var(--dialog-max-block-size, calc(100vh - 64px));\n max-inline-size: var(--dialog-max-inline-size, --_dialog-default-max-inline-size);\n min-inline-size: var(--dialog-min-inline-size, 280px);\n}\n@media not all and (min-width: 600px) {\n .base {\n --_dialog-default-max-inline-size: 90vw;\n }\n}\n@media (min-width: 600px) {\n .base {\n --_dialog-default-max-inline-size: 560px;\n }\n}\n.base:not(.modal) {\n z-index: var(--dialog-z-index, 1);\n}\n.base.modal::backdrop {\n background-color: var(--vvd-color-canvas-text, currentColor);\n opacity: 0.5;\n}\n\n.main-wrapper {\n display: flex;\n flex-direction: column;\n padding: 24px;\n gap: 12px;\n}\n\n.header {\n display: grid;\n align-items: flex-start;\n justify-content: space-between;\n inline-size: 100%;\n}\n.base:not(.icon-placement-side) .header {\n grid-template-columns: 1fr auto;\n grid-template-rows: auto auto auto;\n}\n.base:not(.icon-placement-side) .header .icon {\n font-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8));\n grid-column: 1/2;\n grid-row: 1/2;\n line-height: 1;\n margin-block-end: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 16));\n}\n.base.icon-placement-side .header {\n grid-template-columns: auto 1fr auto;\n grid-template-rows: auto auto;\n}\n.base.icon-placement-side .header .icon {\n font-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 12));\n}\n.base.icon-placement-side .header ::slotted(*),\n.base.icon-placement-side .header .icon {\n grid-column: 1/2;\n grid-row: 1/-1;\n margin-inline-end: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 8)) / 2);\n}\n\n.dismiss-button {\n flex-shrink: 0;\n grid-column: -2/-1;\n grid-row: 1/-1;\n margin-block-start: -8px;\n margin-inline-end: -8px;\n margin-inline-start: 4px;\n}\n\n.headline {\n font: var(--vvd-typography-heading-4);\n}\n\n.subtitle {\n font: var(--vvd-typography-base);\n}\n\nslot[name=main] {\n display: block;\n overflow: hidden auto;\n max-width: inherit;\n max-height: inherit;\n}";
12
-
13
- var _Dialog_instances, _Dialog_modal, _Dialog_dialogElement, _Dialog_dialog_get, _Dialog_handleScrimClick, _Dialog_handleInternalFormSubmit, _Dialog_handleModal;
14
- let dialogPolyfill;
15
- (async () => {
16
- if (!HTMLDialogElement || !HTMLDialogElement.prototype.showModal) {
17
- delete window.HTMLDialogElement;
18
- dialogPolyfill = await import('./dialog-polyfill.esm.js');
19
- }
20
- })();
21
- class Dialog extends FoundationElement {
22
- constructor() {
23
- super(...arguments);
24
- _Dialog_instances.add(this);
25
- this.open = false;
26
- this.ariaLabelledBy = null;
27
- this.ariaLabel = null;
28
- this.ariaDescribedBy = null;
29
- _Dialog_modal.set(this, false);
30
- _Dialog_dialogElement.set(this, void 0);
31
- _Dialog_handleScrimClick.set(this, event => {
32
- if (event.target !== __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get)) {
33
- return;
34
- }
35
- const rect = __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).getBoundingClientRect();
36
- const clickedInDialog = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
37
- this.open = clickedInDialog;
38
- });
39
- _Dialog_handleInternalFormSubmit.set(this, event => {
40
- if (event.target.method !== 'dialog') {
41
- return;
42
- }
43
- this.open = false;
44
- });
45
- }
46
- set returnValue(value) {
47
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).returnValue = value;
48
- }
49
- get returnValue() {
50
- var _a;
51
- return (_a = __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get)) === null || _a === void 0 ? void 0 : _a.returnValue;
52
- }
53
- get modal() {
54
- return __classPrivateFieldGet(this, _Dialog_modal, "f");
55
- }
56
- openChanged(oldValue, newValue) {
57
- if (oldValue === undefined) {
58
- return;
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';
6
+ import { f as focusTemplateFactory } from './focus2.js';
7
+
8
+ /**
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.
30
+ *
31
+ * @public
32
+ */
33
+ const DataGridCellTypes = {
34
+ default: "default",
35
+ columnHeader: "columnheader",
36
+ rowHeader: "rowheader",
37
+ };
38
+ /**
39
+ * Enumerates possible data grid row types
40
+ *
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.
51
+ *
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
+ * @public
55
+ */
56
+ class DataGridRow$1 extends FoundationElement {
57
+ constructor() {
58
+ super(...arguments);
59
+ /**
60
+ * The type of row
61
+ *
62
+ * @public
63
+ * @remarks
64
+ * HTML Attribute: row-type
65
+ */
66
+ this.rowType = DataGridRowTypes.default;
67
+ /**
68
+ * The base data for this row
69
+ *
70
+ * @public
71
+ */
72
+ this.rowData = null;
73
+ /**
74
+ * The column definitions of the row
75
+ *
76
+ * @public
77
+ */
78
+ this.columnDefinitions = null;
79
+ /**
80
+ * Whether focus is on/in a cell within this row.
81
+ *
82
+ * @internal
83
+ */
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
+ };
59
95
  }
60
- if (!newValue) {
61
- this.close();
62
- } else {
63
- if (__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get)) {
64
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).open = true;
65
- }
96
+ gridTemplateColumnsChanged() {
97
+ if (this.$fastController.isConnected) {
98
+ this.updateRowStyle();
99
+ }
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;
110
+ }
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]);
132
+ }
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
+ }
143
+ }
144
+ }
145
+ /**
146
+ * @internal
147
+ */
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) {
167
+ return;
168
+ }
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;
66
209
  }
67
- }
68
- close() {
69
- if (__classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).open) {
70
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).close();
71
- this.$emit('close', this.returnValue, {
72
- bubbles: false
73
- });
74
- }
75
- this.open = false;
76
- __classPrivateFieldGet(this, _Dialog_instances, "m", _Dialog_handleModal).call(this, false);
77
- }
78
- show() {
79
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).show();
80
- this.open = true;
81
- }
82
- showModal() {
83
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).showModal();
84
- this.open = true;
85
- __classPrivateFieldGet(this, _Dialog_instances, "m", _Dialog_handleModal).call(this, true);
86
- }
87
- connectedCallback() {
88
- super.connectedCallback();
89
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).addEventListener('click', __classPrivateFieldGet(this, _Dialog_handleScrimClick, "f"));
90
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).addEventListener('submit', __classPrivateFieldGet(this, _Dialog_handleInternalFormSubmit, "f"));
91
- }
92
- disconnectedCallback() {
93
- super.disconnectedCallback();
94
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).removeEventListener('click', __classPrivateFieldGet(this, _Dialog_handleScrimClick, "f"));
95
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).removeEventListener('submit', __classPrivateFieldGet(this, _Dialog_handleInternalFormSubmit, "f"));
96
- }
97
210
  }
98
- _Dialog_modal = new WeakMap(), _Dialog_dialogElement = new WeakMap(), _Dialog_handleScrimClick = new WeakMap(), _Dialog_handleInternalFormSubmit = new WeakMap(), _Dialog_instances = new WeakSet(), _Dialog_dialog_get = function _Dialog_dialog_get() {
99
- if (!__classPrivateFieldGet(this, _Dialog_dialogElement, "f")) {
100
- __classPrivateFieldSet(this, _Dialog_dialogElement, this.shadowRoot.querySelector('dialog'), "f");
101
- if (__classPrivateFieldGet(this, _Dialog_dialogElement, "f")) {
102
- __classPrivateFieldGet(this, _Dialog_dialogElement, "f").open = this.open;
103
- if (dialogPolyfill) {
104
- dialogPolyfill.registerDialog(__classPrivateFieldGet(this, _Dialog_dialogElement, "f"));
105
- }
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
+ };
106
375
  }
107
- }
108
- return __classPrivateFieldGet(this, _Dialog_dialogElement, "f");
109
- }, _Dialog_handleModal = function _Dialog_handleModal(show) {
110
- __classPrivateFieldSet(this, _Dialog_modal, show, "f");
111
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).toggleAttribute('aria-modal', show);
112
- __classPrivateFieldGet(this, _Dialog_instances, "a", _Dialog_dialog_get).classList.toggle('modal', show);
376
+ /**
377
+ * generates a gridTemplateColumns based on columndata array
378
+ */
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();
415
+ }
416
+ }
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;
432
+ }
433
+ }
434
+ }
435
+ focusRowIndexChanged() {
436
+ if (this.$fastController.isConnected) {
437
+ this.queueFocusUpdate();
438
+ }
439
+ }
440
+ focusColumnIndexChanged() {
441
+ if (this.$fastController.isConnected) {
442
+ this.queueFocusUpdate();
443
+ }
444
+ }
445
+ /**
446
+ * @internal
447
+ */
448
+ connectedCallback() {
449
+ super.connectedCallback();
450
+ if (this.rowItemTemplate === undefined) {
451
+ this.rowItemTemplate = this.defaultRowItemTemplate;
452
+ }
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");
468
+ }
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
+ }
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;
495
+ }
496
+ /**
497
+ * @internal
498
+ */
499
+ handleFocus(e) {
500
+ this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
501
+ }
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
+ }
509
+ }
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;
594
+ }
595
+ }
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
+ }
605
+ }
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
+ }
630
+ }
631
+ }
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
+ });
113
642
  };
114
- __decorate([attr({
115
- mode: 'boolean'
116
- }), __metadata("design:type", Object)], Dialog.prototype, "open", void 0);
117
- __decorate([attr, __metadata("design:type", String)], Dialog.prototype, "icon", void 0);
118
- __decorate([attr({
119
- attribute: 'icon-placement'
120
- }), __metadata("design:type", String)], Dialog.prototype, "iconPlacement", void 0);
121
- __decorate([attr, __metadata("design:type", String)], Dialog.prototype, "subtitle", void 0);
122
- __decorate([attr, __metadata("design:type", String)], Dialog.prototype, "headline", void 0);
123
- __decorate([attr({
124
- attribute: 'aria-labelledby'
125
- }), __metadata("design:type", Object)], Dialog.prototype, "ariaLabelledBy", void 0);
126
- __decorate([attr({
127
- attribute: 'aria-label'
128
- }), __metadata("design:type", Object)], Dialog.prototype, "ariaLabel", void 0);
129
- __decorate([attr({
130
- attribute: 'aria-describedby'
131
- }), __metadata("design:type", Object)], Dialog.prototype, "ariaDescribedBy", void 0);
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
+ __decorate([
653
+ observable
654
+ ], DataGrid$1.prototype, "rowsData", void 0);
655
+ __decorate([
656
+ observable
657
+ ], DataGrid$1.prototype, "columnDefinitions", void 0);
658
+ __decorate([
659
+ observable
660
+ ], DataGrid$1.prototype, "rowItemTemplate", void 0);
661
+ __decorate([
662
+ observable
663
+ ], DataGrid$1.prototype, "cellItemTemplate", void 0);
664
+ __decorate([
665
+ observable
666
+ ], DataGrid$1.prototype, "headerCellItemTemplate", void 0);
667
+ __decorate([
668
+ observable
669
+ ], DataGrid$1.prototype, "focusRowIndex", void 0);
670
+ __decorate([
671
+ observable
672
+ ], DataGrid$1.prototype, "focusColumnIndex", void 0);
673
+ __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);
132
682
 
133
- let _ = t => t,
134
- _t,
135
- _t2,
136
- _t3,
137
- _t4,
138
- _t5;
139
- const getClasses = ({
140
- iconPlacement
141
- }) => classNames('base', [`icon-placement-${iconPlacement}`, Boolean(iconPlacement)]);
142
- function icon(iconTag) {
143
- return html(_t || (_t = _`
144
- <${0} class="icon" name="${0}"></${0}>
145
- `), iconTag, x => x.icon, iconTag);
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
+ `;
701
+ /**
702
+ * A Data Grid Cell Custom HTML Element.
703
+ *
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
+ * @public
707
+ */
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
+ }
146
893
  }
147
- function headline() {
148
- return html(_t2 || (_t2 = _`
149
- <div class="headline">
150
- ${0}
151
- </div>
152
- `), x => x.headline);
894
+ __decorate([
895
+ attr({ attribute: "cell-type" })
896
+ ], DataGridCell$1.prototype, "cellType", void 0);
897
+ __decorate([
898
+ attr({ attribute: "grid-column" })
899
+ ], DataGridCell$1.prototype, "gridColumn", void 0);
900
+ __decorate([
901
+ observable
902
+ ], DataGridCell$1.prototype, "rowData", void 0);
903
+ __decorate([
904
+ 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, 27 Mar 2023 07:48:02 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, 27 Mar 2023 07:48:02 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}";
912
+
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);
153
932
  }
154
- function subtitle() {
155
- return html(_t3 || (_t3 = _`
156
- <div class="subtitle">
157
- ${0}
158
- </div>
159
- `), x => x.subtitle);
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');
956
+ }
957
+ handleFocusout(e) {
958
+ super.handleFocusout(e);
959
+ this.shadowRoot.getElementById('focus-wrapper').classList.remove('active');
960
+ }
160
961
  }
161
- function renderDismissButton(buttonTag) {
162
- return html(_t4 || (_t4 = _`
163
- <${0}
164
- size="condensed"
165
- class="dismiss-button"
166
- icon="close-line"
167
- @click="${0}">
168
- </${0}>`), buttonTag, x => {
169
- x.open = false;
170
- }, buttonTag);
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);
171
977
  }
172
- function handleEscapeKey(dialog, event) {
173
- if (event.key === 'Escape' && dialog.modal) {
174
- dialog.open = false;
175
- }
176
- return true;
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);
177
987
  }
178
- const DialogTemplate = context => {
179
- const elevationTag = context.tagFor(Elevation);
180
- const iconTag = context.tagFor(Icon);
181
- const buttonTag = context.tagFor(Button);
182
- return html(_t5 || (_t5 = _`
183
- <${0} dp="12">
184
- <dialog class="${0}"
185
- @keydown="${0}"
186
- returnValue="${0}"
187
- aria-labelledby="${0}"
188
- aria-label="${0}"
189
- aria-describedby="${0}"
190
- >
191
- <slot name="main">
192
- <div class="main-wrapper">
193
- <div class="header">
194
- <slot name="graphic">
195
- ${0}
196
- </slot>
197
- ${0}
198
- ${0}
199
- ${0}
200
- </div>
201
- <slot name="body"></slot>
202
- <slot name="footer"></slot>
203
- </div>
204
- </slot>
205
- </dialog>
206
- </${0}>`), elevationTag, getClasses, (x, c) => handleEscapeKey(x, c.event), x => x.returnValue, x => x.ariaLabelledBy, x => x.ariaLabel, x => x.ariaDescribedBy, when(x => x.icon, icon(iconTag)), when(x => x.headline, headline()), when(x => x.subtitle, subtitle()), renderDismissButton(buttonTag), elevationTag);
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'));
207
1005
  };
208
1006
 
209
- const dialogDefinition = Dialog.compose({
210
- baseName: 'dialog',
211
- template: DialogTemplate,
212
- styles: [css_248z, css_248z$1]
213
- });
214
- const dialogRegistries = [dialogDefinition(), ...iconRegistries, ...buttonRegistries, ...elevationRegistries];
215
- const registerDialog = registerFactory(dialogRegistries);
1007
+ const DataGridCellRole = {
1008
+ columnheader: 'columnheader',
1009
+ rowheader: 'rowheader',
1010
+ default: 'gridcell'
1011
+ };
1012
+
1013
+ let _ = t => t,
1014
+ _t;
1015
+ function DataGridCellTemplate(context) {
1016
+ const focusTemplate = focusTemplateFactory(context);
1017
+ 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>
1026
+
1027
+ </template>
1028
+ `), x => {
1029
+ var _a;
1030
+ return (_a = DataGridCellRole[x.cellType]) !== null && _a !== void 0 ? _a : DataGridCellRole.default;
1031
+ }, () => focusTemplate);
1032
+ }
1033
+
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,
1047
+ styles: css_248z
1048
+ })();
1049
+ const dataGridElements = [dataGridCell, dataGridRow, dataGrid];
1050
+ const registerDataGrid = registerFactory(dataGridElements);
216
1051
 
217
- export { dialogRegistries as a, dialogDefinition as d, registerDialog as r };
1052
+ export { dataGridRow as a, dataGridCell as b, dataGridElements as c, dataGrid as d, registerDataGrid as r };