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