q2-tecton-elements 1.17.0 → 1.18.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 (138) hide show
  1. package/dist/cjs/{index-afc50fbb.js → index-eccd5617.js} +8 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/q2-badge_2.cjs.entry.js +1 -1
  4. package/dist/cjs/q2-btn_2.cjs.entry.js +3 -2
  5. package/dist/cjs/q2-calendar.cjs.entry.js +1 -1
  6. package/dist/cjs/q2-card.cjs.entry.js +1 -1
  7. package/dist/cjs/q2-carousel-pane.cjs.entry.js +1 -1
  8. package/dist/cjs/q2-carousel.cjs.entry.js +1 -1
  9. package/dist/cjs/q2-chart-donut.cjs.entry.js +1 -1
  10. package/dist/cjs/q2-checkbox-group.cjs.entry.js +1 -1
  11. package/dist/cjs/q2-checkbox.cjs.entry.js +1 -1
  12. package/dist/cjs/q2-dropdown-item.cjs.entry.js +1 -1
  13. package/dist/cjs/q2-dropdown.cjs.entry.js +1 -1
  14. package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
  15. package/dist/cjs/q2-icon.cjs.entry.js +1 -1
  16. package/dist/cjs/q2-loc.cjs.entry.js +1 -1
  17. package/dist/cjs/q2-message.cjs.entry.js +1 -1
  18. package/dist/cjs/q2-month-picker.cjs.entry.js +147 -0
  19. package/dist/cjs/q2-optgroup.cjs.entry.js +1 -1
  20. package/dist/cjs/{q2-option-list.cjs.entry.js → q2-option-list_2.cjs.entry.js} +102 -19
  21. package/dist/cjs/q2-pagination.cjs.entry.js +8 -2
  22. package/dist/cjs/q2-pill.cjs.entry.js +20 -18
  23. package/dist/cjs/q2-radio-group.cjs.entry.js +1 -1
  24. package/dist/cjs/q2-radio.cjs.entry.js +1 -1
  25. package/dist/cjs/q2-section.cjs.entry.js +1 -1
  26. package/dist/cjs/q2-select.cjs.entry.js +3 -5
  27. package/dist/cjs/q2-stepper-pane.cjs.entry.js +1 -1
  28. package/dist/cjs/q2-stepper-vertical.cjs.entry.js +1 -1
  29. package/dist/cjs/q2-stepper.cjs.entry.js +1 -1
  30. package/dist/cjs/q2-tab-container.cjs.entry.js +1 -1
  31. package/dist/cjs/q2-tag.cjs.entry.js +17 -15
  32. package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
  33. package/dist/cjs/q2-textarea.cjs.entry.js +1 -1
  34. package/dist/cjs/q2-tooltip.cjs.entry.js +63 -13
  35. package/dist/collection/collection-manifest.json +2 -0
  36. package/dist/collection/components/q2-btn/index.js +19 -1
  37. package/dist/collection/components/q2-btn/styles.css +1 -0
  38. package/dist/collection/components/q2-calendar/q2-month-picker.css +130 -0
  39. package/dist/collection/components/q2-calendar/q2-month-picker.js +246 -0
  40. package/dist/collection/components/q2-option-list/index.js +7 -52
  41. package/dist/collection/components/q2-option-list/styles.css +1 -49
  42. package/dist/collection/components/q2-pagination/index.js +9 -3
  43. package/dist/collection/components/q2-pill/index.js +27 -24
  44. package/dist/collection/components/q2-pill/styles.css +11 -6
  45. package/dist/collection/components/q2-popover/index.js +245 -0
  46. package/dist/collection/components/q2-popover/styles.css +205 -0
  47. package/dist/collection/components/q2-select/index.js +2 -4
  48. package/dist/collection/components/q2-tag/index.js +21 -18
  49. package/dist/collection/components/q2-tag/styles.css +1 -5
  50. package/dist/collection/components/q2-tooltip/index.js +102 -13
  51. package/dist/collection/components/q2-tooltip/styles.css +62 -82
  52. package/dist/collection/utils/index.js +7 -0
  53. package/dist/esm/{index-2ca8c93c.js → index-eac6b89e.js} +8 -1
  54. package/dist/esm/loader.js +1 -1
  55. package/dist/esm/q2-badge_2.entry.js +1 -1
  56. package/dist/esm/q2-btn_2.entry.js +3 -2
  57. package/dist/esm/q2-calendar.entry.js +1 -1
  58. package/dist/esm/q2-card.entry.js +1 -1
  59. package/dist/esm/q2-carousel-pane.entry.js +1 -1
  60. package/dist/esm/q2-carousel.entry.js +1 -1
  61. package/dist/esm/q2-chart-donut.entry.js +1 -1
  62. package/dist/esm/q2-checkbox-group.entry.js +1 -1
  63. package/dist/esm/q2-checkbox.entry.js +1 -1
  64. package/dist/esm/q2-dropdown-item.entry.js +1 -1
  65. package/dist/esm/q2-dropdown.entry.js +1 -1
  66. package/dist/esm/q2-editable-field.entry.js +1 -1
  67. package/dist/esm/q2-icon.entry.js +1 -1
  68. package/dist/esm/q2-loc.entry.js +1 -1
  69. package/dist/esm/q2-message.entry.js +1 -1
  70. package/dist/esm/q2-month-picker.entry.js +143 -0
  71. package/dist/esm/q2-optgroup.entry.js +1 -1
  72. package/dist/esm/{q2-option-list.entry.js → q2-option-list_2.entry.js} +102 -20
  73. package/dist/esm/q2-pagination.entry.js +8 -2
  74. package/dist/esm/q2-pill.entry.js +21 -19
  75. package/dist/esm/q2-radio-group.entry.js +1 -1
  76. package/dist/esm/q2-radio.entry.js +1 -1
  77. package/dist/esm/q2-section.entry.js +1 -1
  78. package/dist/esm/q2-select.entry.js +3 -5
  79. package/dist/esm/q2-stepper-pane.entry.js +1 -1
  80. package/dist/esm/q2-stepper-vertical.entry.js +1 -1
  81. package/dist/esm/q2-stepper.entry.js +1 -1
  82. package/dist/esm/q2-tab-container.entry.js +1 -1
  83. package/dist/esm/q2-tag.entry.js +18 -16
  84. package/dist/esm/q2-tecton-elements.js +1 -1
  85. package/dist/esm/q2-textarea.entry.js +1 -1
  86. package/dist/esm/q2-tooltip.entry.js +63 -13
  87. package/dist/q2-tecton-elements/{p-d781e2d9.entry.js → p-02c1b7fd.entry.js} +1 -1
  88. package/dist/q2-tecton-elements/{p-2faed36b.entry.js → p-04c743f2.entry.js} +1 -1
  89. package/dist/q2-tecton-elements/{p-5acb7ec6.entry.js → p-07dc509c.entry.js} +1 -1
  90. package/dist/q2-tecton-elements/{p-d8d9e8eb.entry.js → p-12caa479.entry.js} +1 -1
  91. package/dist/q2-tecton-elements/{p-d3e4cc5d.entry.js → p-160dd1c2.entry.js} +1 -1
  92. package/dist/q2-tecton-elements/{p-31070ab8.entry.js → p-1a3de749.entry.js} +1 -1
  93. package/dist/q2-tecton-elements/{p-0d849ed4.entry.js → p-2061c3fd.entry.js} +1 -1
  94. package/dist/q2-tecton-elements/{p-64605d17.entry.js → p-2e54f9a0.entry.js} +1 -1
  95. package/dist/q2-tecton-elements/{p-a45c6b65.entry.js → p-375569ff.entry.js} +1 -1
  96. package/dist/q2-tecton-elements/p-3766cc6c.entry.js +1 -0
  97. package/dist/q2-tecton-elements/{p-732dafd0.entry.js → p-3eda2714.entry.js} +1 -1
  98. package/dist/q2-tecton-elements/{p-cde0cdff.entry.js → p-421af42d.entry.js} +1 -1
  99. package/dist/q2-tecton-elements/{p-44bdaf52.entry.js → p-4fd405f5.entry.js} +1 -1
  100. package/dist/q2-tecton-elements/p-509c8924.entry.js +1 -0
  101. package/dist/q2-tecton-elements/{p-445e7c45.entry.js → p-55dc3dc1.entry.js} +1 -1
  102. package/dist/q2-tecton-elements/p-5fffb28a.entry.js +1 -0
  103. package/dist/q2-tecton-elements/p-612e9974.entry.js +1 -0
  104. package/dist/q2-tecton-elements/{p-815c8a7d.entry.js → p-796c2bb5.entry.js} +1 -1
  105. package/dist/q2-tecton-elements/{p-41fcf343.js → p-80014da0.js} +1 -1
  106. package/dist/q2-tecton-elements/{p-8543a0e1.entry.js → p-86887866.entry.js} +1 -1
  107. package/dist/q2-tecton-elements/p-9204c34d.entry.js +1 -0
  108. package/dist/q2-tecton-elements/{p-b4b8f85c.entry.js → p-a0fa416d.entry.js} +1 -1
  109. package/dist/q2-tecton-elements/p-bd83e8e2.entry.js +1 -0
  110. package/dist/q2-tecton-elements/{p-fbf23146.entry.js → p-be0f2539.entry.js} +1 -1
  111. package/dist/q2-tecton-elements/p-c05b0b55.entry.js +1 -0
  112. package/dist/q2-tecton-elements/{p-318758d4.entry.js → p-c608e3c9.entry.js} +1 -1
  113. package/dist/q2-tecton-elements/{p-824a1d7c.entry.js → p-d826d7ad.entry.js} +1 -1
  114. package/dist/q2-tecton-elements/{p-06865cf5.entry.js → p-d9e9340c.entry.js} +1 -1
  115. package/dist/q2-tecton-elements/{p-4da9b6b6.entry.js → p-e5757895.entry.js} +1 -1
  116. package/dist/q2-tecton-elements/p-e68c9ef0.entry.js +1 -0
  117. package/dist/q2-tecton-elements/{p-30f81b22.entry.js → p-eb33bda4.entry.js} +1 -1
  118. package/dist/q2-tecton-elements/{p-661c2092.entry.js → p-f319549d.entry.js} +1 -1
  119. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
  120. package/dist/types/components/q2-btn/index.d.ts +1 -0
  121. package/dist/types/components/q2-calendar/q2-month-picker.d.ts +24 -0
  122. package/dist/types/components/q2-option-list/index.d.ts +1 -4
  123. package/dist/types/components/q2-pill/index.d.ts +7 -3
  124. package/dist/types/components/q2-popover/index.d.ts +26 -0
  125. package/dist/types/components/q2-tag/index.d.ts +5 -2
  126. package/dist/types/components/q2-tooltip/index.d.ts +12 -0
  127. package/dist/types/components.d.ts +53 -4
  128. package/dist/types/utils/index.d.ts +1 -0
  129. package/package.json +2 -2
  130. package/dist/q2-tecton-elements/p-30a4fdfb.entry.js +0 -1
  131. package/dist/q2-tecton-elements/p-41c22a16.entry.js +0 -1
  132. package/dist/q2-tecton-elements/p-654fcd6b.entry.js +0 -1
  133. package/dist/q2-tecton-elements/p-916fd90b.entry.js +0 -1
  134. package/dist/q2-tecton-elements/p-94b3c534.entry.js +0 -1
  135. package/dist/q2-tecton-elements/p-a659d112.entry.js +0 -1
  136. package/dist/q2-tecton-elements/p-b595b415.entry.js +0 -1
  137. package/dist/test/elements/q2-tag-test.js +0 -151
  138. package/dist/types/workspace/workspace/Tecton_tecton-production_master/packages/q2-tecton-elements/.stencil/test/elements/q2-tag-test.d.ts +0 -1
@@ -0,0 +1,246 @@
1
+ import { Component, Prop, Element, h, State, Event } from '@stencil/core';
2
+ import { loc, overrideFocus } from 'src/utils';
3
+ export class Q2MonthPicker {
4
+ constructor() {
5
+ this.year = Number(new Date().toLocaleString('en-US', { year: 'numeric' }));
6
+ this.selectedIndex = 0;
7
+ this.focusedIndex = 0;
8
+ this.showYearLayer = false;
9
+ this.scheduledAfterRender = [];
10
+ this.monthGrid = [
11
+ [0, 1, 2],
12
+ [3, 4, 5],
13
+ [6, 7, 8],
14
+ [9, 10, 11],
15
+ ];
16
+ this.months = [
17
+ 'January',
18
+ 'February',
19
+ 'March',
20
+ 'April',
21
+ 'May',
22
+ 'June',
23
+ 'July',
24
+ 'August',
25
+ 'September',
26
+ 'October',
27
+ 'November',
28
+ 'December',
29
+ ].map(mon => ({
30
+ label: loc(`tecton.element.calendar.months.${mon}`),
31
+ abbr: loc(`tecton.element.calendar.months.abbr.${mon}`),
32
+ }));
33
+ this.onMonthSelection = (event) => {
34
+ var _a, _b;
35
+ const targetElement = event.target.closest('.month-button');
36
+ if ((_a = targetElement === null || targetElement === void 0 ? void 0 : targetElement.dataset) === null || _a === void 0 ? void 0 : _a.index) {
37
+ this.selectMonth(Number((_b = targetElement === null || targetElement === void 0 ? void 0 : targetElement.dataset) === null || _b === void 0 ? void 0 : _b.index));
38
+ }
39
+ };
40
+ this.onMonthKeydown = (event) => {
41
+ if (event.key === 'Escape' || event.key === 'Esc') {
42
+ this.toggleChange.emit({ close: true });
43
+ return;
44
+ }
45
+ const monthIndex = event.target.dataset.index;
46
+ if (!monthIndex)
47
+ return;
48
+ if (event.key === 'Enter' || event.key === ' ') {
49
+ event.preventDefault();
50
+ event.stopPropagation();
51
+ this.selectMonth(Number(monthIndex));
52
+ }
53
+ else {
54
+ const nextMonthIndex = this.moveMonth(this.monthGrid, Number(monthIndex), event);
55
+ this.focusMonth(nextMonthIndex);
56
+ }
57
+ };
58
+ this.moveMonth = (grid, index, event) => {
59
+ const rows = grid.length;
60
+ const cols = grid[0].length;
61
+ const row = Math.floor(index / cols);
62
+ const col = index % cols;
63
+ const current = [row, col];
64
+ if (event.key === 'ArrowUp') {
65
+ event.stopPropagation();
66
+ event.preventDefault();
67
+ return grid[Math.max(0, current[0] - 1)][current[1]];
68
+ }
69
+ else if (event.key === 'ArrowDown') {
70
+ event.stopPropagation();
71
+ event.preventDefault();
72
+ return grid[Math.min(rows - 1, current[0] + 1)][current[1]];
73
+ }
74
+ else if (event.key === 'ArrowLeft') {
75
+ event.stopPropagation();
76
+ event.preventDefault();
77
+ return Math.max(0, index - 1);
78
+ }
79
+ else if (event.key === 'ArrowRight') {
80
+ event.stopPropagation();
81
+ event.preventDefault();
82
+ return Math.min(this.months.length - 1, index + 1);
83
+ }
84
+ else {
85
+ return grid[current[0]][current[1]];
86
+ }
87
+ };
88
+ this.focusMonth = (index) => {
89
+ const nextMonth = this.hostElement.shadowRoot.querySelector(`.month-button[data-index="${index}"]`);
90
+ if (nextMonth) {
91
+ this.focusedIndex = index;
92
+ nextMonth.focus();
93
+ }
94
+ };
95
+ this.selectMonth = (index) => {
96
+ var _a, _b, _c;
97
+ this.selectedIndex = index;
98
+ this.focusedIndex = index;
99
+ const nextMonth = this.hostElement.shadowRoot.querySelector(`.month-button[data-index="${index}"]`);
100
+ (_a = this.hostElement.shadowRoot
101
+ .querySelectorAll(`.month-button`)) === null || _a === void 0 ? void 0 : _a.forEach(el => el.classList.remove('active'));
102
+ nextMonth === null || nextMonth === void 0 ? void 0 : nextMonth.classList.add('active');
103
+ nextMonth === null || nextMonth === void 0 ? void 0 : nextMonth.focus();
104
+ const value = {
105
+ view: 'day',
106
+ monthIndex: index,
107
+ selectedYear: this.year,
108
+ };
109
+ (_c = (_b = this.hostElement).onchange) === null || _c === void 0 ? void 0 : _c.call(_b, new CustomEvent('click', {
110
+ bubbles: true,
111
+ detail: value,
112
+ }));
113
+ this.viewChange.emit(value);
114
+ };
115
+ this.selectYear = (year) => {
116
+ this.year = Math.max(1970, year);
117
+ };
118
+ }
119
+ componentDidRender() {
120
+ var _a;
121
+ (_a = this.scheduledAfterRender) === null || _a === void 0 ? void 0 : _a.forEach(fn => fn());
122
+ this.scheduledAfterRender = [];
123
+ }
124
+ componentDidLoad() {
125
+ overrideFocus(this.hostElement);
126
+ }
127
+ render() {
128
+ return (h("div", { class: "month-container", onKeyDown: this.onMonthKeydown },
129
+ h("div", { class: "navigation" },
130
+ h("q2-btn", { class: "year-btn", onClick: () => this.viewChange.emit({
131
+ view: 'year',
132
+ selectedYear: this.year,
133
+ }) },
134
+ h("span", { class: "year" }, this.year),
135
+ h("q2-icon", { class: "year-icon off", type: "chevron-down" })),
136
+ h("div", { class: "month-controller" },
137
+ h("div", { class: "cal-year-prev-next" },
138
+ h("q2-btn", { label: loc('tecton.element.calendar.previousYear'), "hide-label": true, class: "cal-nav-btn prev-year", "test-id": "previousYearButton", onClick: () => this.selectYear(this.year - 1) },
139
+ h("q2-icon", { type: "arrow-left" })),
140
+ h("q2-btn", { label: loc('tecton.element.calendar.nextYear'), "hide-label": true, class: "cal-nav-btn next-year", "test-id": "nextYearButton", onClick: () => this.selectYear(this.year + 1) },
141
+ h("q2-icon", { type: "arrow-right" }))))),
142
+ h("div", { class: "month-list", onClick: this.onMonthSelection }, this.months.map((month, index) => (h("div", { class: "month" },
143
+ h("span", { role: "button", class: "month-button", "data-index": index, "aria-label": month.label, tabindex: index === this.focusedIndex ? 0 : -1 }, month.abbr))))),
144
+ this.today && (h("div", { class: "today-label" },
145
+ loc('tecton.element.calendar.today'),
146
+ ": ",
147
+ this.today))));
148
+ }
149
+ static get is() { return "q2-month-picker"; }
150
+ static get encapsulation() { return "shadow"; }
151
+ static get originalStyleUrls() { return {
152
+ "$": ["q2-month-picker.scss"]
153
+ }; }
154
+ static get styleUrls() { return {
155
+ "$": ["q2-month-picker.css"]
156
+ }; }
157
+ static get properties() { return {
158
+ "year": {
159
+ "type": "number",
160
+ "mutable": true,
161
+ "complexType": {
162
+ "original": "number",
163
+ "resolved": "number",
164
+ "references": {}
165
+ },
166
+ "required": false,
167
+ "optional": false,
168
+ "docs": {
169
+ "tags": [],
170
+ "text": ""
171
+ },
172
+ "attribute": "year",
173
+ "reflect": true,
174
+ "defaultValue": "Number(\n new Date().toLocaleString('en-US', { year: 'numeric' })\n )"
175
+ },
176
+ "disabledMonths": {
177
+ "type": "unknown",
178
+ "mutable": false,
179
+ "complexType": {
180
+ "original": "string[]",
181
+ "resolved": "string[]",
182
+ "references": {}
183
+ },
184
+ "required": false,
185
+ "optional": false,
186
+ "docs": {
187
+ "tags": [],
188
+ "text": ""
189
+ }
190
+ },
191
+ "today": {
192
+ "type": "string",
193
+ "mutable": false,
194
+ "complexType": {
195
+ "original": "string",
196
+ "resolved": "string",
197
+ "references": {}
198
+ },
199
+ "required": false,
200
+ "optional": false,
201
+ "docs": {
202
+ "tags": [],
203
+ "text": ""
204
+ },
205
+ "attribute": "today",
206
+ "reflect": false
207
+ }
208
+ }; }
209
+ static get states() { return {
210
+ "selectedIndex": {},
211
+ "focusedIndex": {},
212
+ "showYearLayer": {}
213
+ }; }
214
+ static get events() { return [{
215
+ "method": "viewChange",
216
+ "name": "viewChange",
217
+ "bubbles": true,
218
+ "cancelable": true,
219
+ "composed": true,
220
+ "docs": {
221
+ "tags": [],
222
+ "text": ""
223
+ },
224
+ "complexType": {
225
+ "original": "any",
226
+ "resolved": "any",
227
+ "references": {}
228
+ }
229
+ }, {
230
+ "method": "toggleChange",
231
+ "name": "toggleChange",
232
+ "bubbles": true,
233
+ "cancelable": true,
234
+ "composed": true,
235
+ "docs": {
236
+ "tags": [],
237
+ "text": ""
238
+ },
239
+ "complexType": {
240
+ "original": "any",
241
+ "resolved": "any",
242
+ "references": {}
243
+ }
244
+ }]; }
245
+ static get elementRef() { return "hostElement"; }
246
+ }
@@ -86,7 +86,7 @@ export class Q2OptionList {
86
86
  case 'Escape':
87
87
  if (this.noSelect)
88
88
  this.setActiveElement(null);
89
- this.open = false;
89
+ this.popoverState.emit({ open: false });
90
90
  break;
91
91
  default:
92
92
  if (customSearch)
@@ -168,7 +168,7 @@ export class Q2OptionList {
168
168
  if (this.disabled)
169
169
  return;
170
170
  this.activeIndex = activeIndex;
171
- this.open = true;
171
+ this.popoverState.emit({ open: true });
172
172
  this.setActiveOption();
173
173
  this.setFocusedOption();
174
174
  this.scheduledAfterRender.push(() => {
@@ -202,8 +202,6 @@ export class Q2OptionList {
202
202
  });
203
203
  }
204
204
  setActiveOption() {
205
- if (!this.open)
206
- return;
207
205
  const activeIndex = this.activeIndex;
208
206
  this.allOptions.forEach((element, elementIndex) => {
209
207
  element.active = activeIndex === elementIndex;
@@ -256,7 +254,7 @@ export class Q2OptionList {
256
254
  this.change.emit({ value: selectedValue, values });
257
255
  if (multiple)
258
256
  return;
259
- this.open = false;
257
+ this.popoverState.emit({ open: false });
260
258
  }
261
259
  adjustActiveOptionAndScroll(numToAdd) {
262
260
  this.activeIndex += numToAdd;
@@ -292,24 +290,17 @@ export class Q2OptionList {
292
290
  this.updateSingleOptionAttrs();
293
291
  }
294
292
  }
295
- openChanged(newValue) {
296
- this.optionListState.emit({ open: newValue });
297
- }
298
293
  /// Listeners ///
299
294
  delegateFocus(event) {
300
295
  if (!isEventFromElement(event, this.hostElement))
301
296
  return;
302
- this.open = true;
297
+ this.popoverState.emit({ open: true });
303
298
  this.setDefaultActiveElement();
304
299
  }
305
300
  handleClick(event) {
306
301
  event.stopPropagation();
307
302
  }
308
303
  /// Public Methods ///
309
- async toggle() {
310
- const isOpen = !this.open;
311
- this.open = isOpen;
312
- }
313
304
  async setDefaultActiveElement() {
314
305
  this.activeIndex = this.getDefaultActiveIndex();
315
306
  this.setActiveOption();
@@ -323,7 +314,7 @@ export class Q2OptionList {
323
314
  async handleExternalKeydown(event) {
324
315
  const keysThatTriggerOpen = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp', 'Home', 'End'];
325
316
  if (keysThatTriggerOpen.includes(event.key)) {
326
- this.open = true;
317
+ this.popoverState.emit({ open: true });
327
318
  }
328
319
  const keysThatTriggerDefault = ['ArrowDown', 'ArrowUp'];
329
320
  if (keysThatTriggerDefault.includes(event.key)) {
@@ -386,23 +377,6 @@ export class Q2OptionList {
386
377
  "reflect": true,
387
378
  "defaultValue": "'down'"
388
379
  },
389
- "open": {
390
- "type": "boolean",
391
- "mutable": true,
392
- "complexType": {
393
- "original": "boolean",
394
- "resolved": "boolean",
395
- "references": {}
396
- },
397
- "required": false,
398
- "optional": false,
399
- "docs": {
400
- "tags": [],
401
- "text": ""
402
- },
403
- "attribute": "open",
404
- "reflect": true
405
- },
406
380
  "customSearch": {
407
381
  "type": "boolean",
408
382
  "mutable": false,
@@ -549,8 +523,8 @@ export class Q2OptionList {
549
523
  }
550
524
  }
551
525
  }, {
552
- "method": "optionListState",
553
- "name": "optionListState",
526
+ "method": "popoverState",
527
+ "name": "popoverState",
554
528
  "bubbles": true,
555
529
  "cancelable": true,
556
530
  "composed": true,
@@ -565,22 +539,6 @@ export class Q2OptionList {
565
539
  }
566
540
  }]; }
567
541
  static get methods() { return {
568
- "toggle": {
569
- "complexType": {
570
- "signature": "() => Promise<void>",
571
- "parameters": [],
572
- "references": {
573
- "Promise": {
574
- "location": "global"
575
- }
576
- },
577
- "return": "Promise<void>"
578
- },
579
- "docs": {
580
- "text": "",
581
- "tags": []
582
- }
583
- },
584
542
  "setDefaultActiveElement": {
585
543
  "complexType": {
586
544
  "signature": "() => Promise<void>",
@@ -643,9 +601,6 @@ export class Q2OptionList {
643
601
  static get watchers() { return [{
644
602
  "propName": "selectedOptions",
645
603
  "methodName": "selectedOptionsUpdated"
646
- }, {
647
- "propName": "open",
648
- "methodName": "openChanged"
649
604
  }]; }
650
605
  static get listeners() { return [{
651
606
  "name": "focus",
@@ -69,61 +69,13 @@ button {
69
69
  position: relative;
70
70
  width: 100%;
71
71
  display: block;
72
+ line-height: var(--tct-option-list-line-height, var(--t-option-list-line-height, var(--app-line-height, 1.428571429em)));
72
73
  }
73
74
 
74
75
  .content {
75
- margin-top: var(--tct-option-list-margin, var(--t-option-list-margin, var(--app-scale-1x, 5px)));
76
- position: absolute;
77
- height: 0;
78
- opacity: 0;
79
- visibility: hidden;
80
- background-color: var(--app-white, #ffffff);
81
- color: var(--t-text, #4d4d4d);
82
- z-index: 100;
83
- width: max-content;
84
- min-width: var(--tct-option-list-min-width, var(--t-option-list-min-width, 135px));
85
- box-shadow: var(--app-shadow-1, 0 2px 4px rgba(0, 0, 0, 0.3));
86
- overflow: hidden;
87
76
  text-align: start;
88
- transition: opacity var(--app-tween-1, 0.2s ease);
89
- border-radius: var(--tct-option-list-border-radius, var(--t-option-list-border-radius, 0));
90
- --comp-scrollbar-size: var(--tct-scrollbar-size, var(--t-scrollbar-size, var(--app-scale-1x, 5px)));
91
- --comp-scrollbar-border-radius: var(--tct-scrollbar-border-radius, var(--t-scrollbar-border-radius, var(--app-border-radius-1, 3px)));
92
- --comp-scrollbar-color: var(--tct-scrollbar-color, var(--t-scrollbar-color, var(--t-a11y-gray-color, #747474)));
93
- scrollbar-width: thin;
94
- scrollbar-color: var(--comp-scrollbar-color) transparent;
95
- }
96
- .content::-webkit-scrollbar {
97
- width: var(--comp-scrollbar-size);
98
- height: var(--comp-scrollbar-size);
99
- margin: 5px;
100
- }
101
- .content::-webkit-scrollbar-thumb {
102
- background: var(--comp-scrollbar-color);
103
- border-radius: var(--comp-scrollbar-border-radius);
104
- }
105
- .content::-webkit-scrollbar-track {
106
- background: transparent;
107
- border-radius: var(--comp-scrollbar-border-radius);
108
- }
109
- :host(:not([align=right])) .content {
110
- left: 0;
111
- }
112
- :host([align=right]) .content {
113
- right: 0;
114
- }
115
- :host([open]) .content {
116
- display: block;
117
- height: auto;
118
- overflow: auto;
119
- opacity: 1;
120
- visibility: visible;
121
77
  }
122
78
  :host([is-sizeable]) .content {
123
79
  display: block;
124
80
  height: auto;
125
- }
126
- :host([alignment=right]) .content {
127
- left: unset;
128
- right: 0;
129
81
  }
@@ -101,9 +101,12 @@ export class Q2Pagination {
101
101
  total: total.toLocaleString(),
102
102
  })),
103
103
  h("div", { class: "btn-group" },
104
- h("q2-btn", { label: "tecton.element.pagination.goToFirstPage", disabled: onFirstPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(1), "test-id": "firstPageBtn", "hide-label": true },
104
+ h("q2-btn", { label: loc('tecton.element.pagination.goToFirstPage'), disabled: onFirstPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(1), "test-id": "firstPageBtn", "hide-label": true },
105
105
  h("q2-icon", { type: "chevron-double-left" })),
106
- h("q2-btn", { label: loc('tecton.element.pagination.goToPage', [page - 1]), disabled: onFirstPage, onClick: () => this.handlePageChange(page - 1), "test-id": "prevPageBtn", "hide-label": true },
106
+ h("q2-btn", { label: loc('tecton.element.pagination.goToPages', {
107
+ next: page - 1,
108
+ total: totalPages,
109
+ }), disabled: onFirstPage, onClick: () => this.handlePageChange(page - 1), "test-id": "prevPageBtn", "hide-label": true },
107
110
  h("q2-icon", { type: "chevron-left" }))),
108
111
  h("div", { class: "controls", hidden: isFullViewHidden, "test-id": "controls" },
109
112
  h("span", { "aria-hidden": "true" }, loc('tecton.element.pagination.page')),
@@ -111,7 +114,10 @@ export class Q2Pagination {
111
114
  h("q2-input", { type: "number", value: `${page}`, min: 1, max: this.totalPages, hideLabel: true, optional: true, label: `${loc('tecton.element.pagination.page')} (${loc('tecton.element.pagination.ofPages', [totalPages.toLocaleString()])})`, onChange: event => this.handlePageChange(event.detail.value), "test-id": "pageInput", current: "page", ref: el => (this.inputField = el) })),
112
115
  h("span", { "aria-hidden": "true" }, loc('tecton.element.pagination.ofPages', [totalPages.toLocaleString()]))),
113
116
  h("div", { class: "btn-group" },
114
- h("q2-btn", { label: loc('tecton.element.pagination.goToPage', [page + 1]), disabled: onLastPage, onClick: () => this.handlePageChange(page + 1), "test-id": "nextPageBtn", "hide-label": true },
117
+ h("q2-btn", { label: loc('tecton.element.pagination.goToPages', {
118
+ next: page + 1,
119
+ total: totalPages,
120
+ }), disabled: onLastPage, onClick: () => this.handlePageChange(page + 1), "test-id": "nextPageBtn", "hide-label": true },
115
121
  h("q2-icon", { type: "chevron-right" })),
116
122
  h("q2-btn", { label: "tecton.element.pagination.goToLastPage", disabled: onLastPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(totalPages), "test-id": "lastPageBtn", "hide-label": true },
117
123
  h("q2-icon", { type: "chevron-double-right" })))));
@@ -1,5 +1,5 @@
1
- import { Component, State, Prop, h, Listen, Element, Fragment, Event, } from '@stencil/core';
2
- import { isEventFromElement, loc, overrideFocus } from 'src/utils';
1
+ import { Component, State, Prop, h, Listen, Element, Event } from '@stencil/core';
2
+ import { isEventFromElement, loc, overrideFocus, resizeIframe } from 'src/utils';
3
3
  export class Q2Pill {
4
4
  constructor() {
5
5
  this.selectedOptions = [];
@@ -15,14 +15,15 @@ export class Q2Pill {
15
15
  this.open = false;
16
16
  this.primaryBtn.focus();
17
17
  this.change.emit({ value: null, values: [], active: false });
18
+ this.scheduledAfterRender.push(resizeIframe);
18
19
  };
19
20
  /// Event Handlers ///
20
- this.handleClick = (event) => {
21
+ this.handleClick = async (event) => {
21
22
  event.stopPropagation();
22
23
  if (this.disabled)
23
24
  return;
24
25
  if (this.hasOptions) {
25
- this.optionList.toggle();
26
+ await this.popoverElement.toggle();
26
27
  }
27
28
  else {
28
29
  const { value, label } = this;
@@ -42,6 +43,7 @@ export class Q2Pill {
42
43
  this.optionList.handleExternalKeydown(event);
43
44
  };
44
45
  this.handleChange = event => {
46
+ event.stopPropagation();
45
47
  if (!this.hasOptions)
46
48
  return;
47
49
  const { value, values } = event.detail;
@@ -52,20 +54,17 @@ export class Q2Pill {
52
54
  }
53
55
  this.change.emit({ value, values, active: isActive });
54
56
  };
55
- this.handleFocusout = (event) => {
56
- const relatedTarget = event.relatedTarget;
57
- if (Array.from(this.hostElement.children).includes(relatedTarget))
58
- return;
59
- if (relatedTarget && !(event.relatedTarget instanceof HTMLElement))
60
- return;
61
- if (relatedTarget && relatedTarget.closest('.btn-height-wrapper'))
62
- return;
63
- this.optionList.open = false;
64
- };
65
57
  this.handleWrapperClick = () => {
66
58
  this.primaryBtn.focus();
67
59
  this.primaryBtn.click();
68
60
  };
61
+ this.onClickElsewhere = (event) => {
62
+ const target = event.target;
63
+ if (target.localName === 'click-elsewhere') {
64
+ event.stopPropagation();
65
+ this.popoverElement.open = false;
66
+ }
67
+ };
69
68
  }
70
69
  /// LifeCycle Hooks ///
71
70
  componentWillLoad() {
@@ -106,9 +105,12 @@ export class Q2Pill {
106
105
  return;
107
106
  this.primaryBtn.focus();
108
107
  }
109
- optionListStateEvent({ detail: { open } }) {
110
- this.open = open;
111
- if (!open)
108
+ popoverStateHandler({ detail: { open } }) {
109
+ if (this.open !== open)
110
+ this.open = open;
111
+ if (open)
112
+ this.optionList.focus();
113
+ else
112
114
  this.primaryBtn.focus();
113
115
  }
114
116
  /// DOM ///
@@ -127,18 +129,19 @@ export class Q2Pill {
127
129
  wrapperClassNames.push('has-icon');
128
130
  if (hasOptions)
129
131
  wrapperClassNames.push('has-options');
130
- return (h(Fragment, null,
132
+ return (h("click-elsewhere", { onChange: this.onClickElsewhere },
131
133
  h("div", { class: wrapperClassNames.join(' ') },
132
- h("div", { class: "btn-height-wrapper", onClick: this.handleWrapperClick, tabIndex: -1 },
133
- h("button", { class: "btn-primary", type: "button", "test-id": "btn-control", ref: el => (this.primaryBtn = el), onClick: this.handleClick, onKeyDown: this.handleKeydown, disabled: this.disabled, onFocusout: this.handleFocusout, "aria-selected": !hasOptions && active ? 'true' : 'false', "aria-roledescription": !hasOptions && 'filter', "aria-controls": hasOptions && 'option-list', "aria-haspopup": hasOptions && 'true', "aria-expanded": (hasOptions && `${!!open}`) || undefined, "aria-label": this.maxLength && this.buttonContent },
134
+ h("div", { class: "btn-height-wrapper", ref: el => (this.primaryBtnWrapper = el), onClick: this.handleWrapperClick, tabIndex: -1 },
135
+ h("button", { class: "btn-primary", "test-id": "btn-control", type: "button", ref: el => (this.primaryBtn = el), onClick: this.handleClick, onKeyDown: this.handleKeydown, disabled: this.disabled, "aria-selected": !hasOptions && active ? 'true' : 'false', "aria-roledescription": !hasOptions && 'filter', "aria-controls": hasOptions && 'option-list', "aria-haspopup": hasOptions && 'true', "aria-expanded": (hasOptions && `${!!open}`) || undefined, "aria-label": this.maxLength && this.buttonContent },
134
136
  this.truncatedButtonContent,
135
137
  !hasOptions && active && h("span", { class: "sr" },
136
138
  "(",
137
139
  loc('tecton.element.pill.active'),
138
140
  ")"))),
139
141
  this.generateIcon()),
140
- this.hasOptions && (h("q2-option-list", { id: "option-list", ref: el => (this.optionList = el), open: this.open, onChange: this.handleChange, multiple: this.multiple, onFocusout: this.handleFocusout, selectedOptions: this.selectedOptions },
141
- h("slot", null)))));
142
+ this.hasOptions && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.primaryBtnWrapper, open: this.open },
143
+ h("q2-option-list", { ref: el => (this.optionList = el), id: "option-list", onChange: this.handleChange, multiple: this.multiple, selectedOptions: this.selectedOptions },
144
+ h("slot", null))))));
142
145
  }
143
146
  static get is() { return "q2-pill"; }
144
147
  static get encapsulation() { return "shadow"; }
@@ -339,8 +342,8 @@ export class Q2Pill {
339
342
  "capture": false,
340
343
  "passive": false
341
344
  }, {
342
- "name": "optionListState",
343
- "method": "optionListStateEvent",
345
+ "name": "popoverStateChanged",
346
+ "method": "popoverStateHandler",
344
347
  "target": undefined,
345
348
  "capture": false,
346
349
  "passive": false
@@ -68,16 +68,21 @@ button {
68
68
  :host {
69
69
  display: inline-block;
70
70
  position: relative;
71
+ line-height: 0;
71
72
  }
72
73
 
73
74
  :host(:not(:last-child)) {
74
75
  margin-inline-end: var(--tct-pill-margin, var(--t-pill-margin, var(--app-scale-2x, 10px)));
75
76
  }
76
77
 
78
+ q2-popover,
77
79
  .btn-wrapper {
78
80
  --comp-pill-min-height: var(--tct-pill-min-height, var(--t-pill-min-height, 44px));
79
- --comp-pill-btn-border-width: var(--tct-pill-btn-border-width, var(--t-pill-btn-border-width, 2px));
80
81
  --comp-pill-btn-height: var(--tct-pill-btn-height, var(--t-pill-btn-height, 30px));
82
+ }
83
+
84
+ .btn-wrapper {
85
+ --comp-pill-btn-border-width: var(--tct-pill-btn-border-width, var(--t-pill-btn-border-width, 2px));
81
86
  --comp-close-size: 0px;
82
87
  --comp-btn-background: var(--tct-pill-btn-background, var(--t-pill-btn-background, var(--t-base, #ffffff)));
83
88
  --compt-hover-btn-background: var(--tct-pill-hover-btn-background, var(--t-pill-hover-btn-background, var(--t-gray-13, #e6e6e6)));
@@ -118,11 +123,6 @@ button {
118
123
  --comp-hover-active-btn-border-color: var(--t-tertiary-l3, #eff8fd);
119
124
  }
120
125
 
121
- q2-option-list {
122
- position: absolute;
123
- left: 0;
124
- }
125
-
126
126
  .btn-height-wrapper {
127
127
  height: var(--comp-pill-min-height);
128
128
  display: flex;
@@ -228,4 +228,9 @@ div.btn-close {
228
228
  :host([active]) button.btn-close:focus, :host([active]) button.btn-close:hover {
229
229
  background: var(--tct-pill-hover-close-btn-background, var(--t-pill-hover-close-btn-background, var(--t-top-a1, rgba(13, 13, 13, 0.35))));
230
230
  border-color: var(--tct-pill-hover-close-btn-border-color, var(--t-pill-hover-close-btn-border-color, var(--t-top-a1, rgba(13, 13, 13, 0.35))));
231
+ }
232
+
233
+ q2-popover {
234
+ position: relative;
235
+ top: calc((var(--comp-pill-min-height) - var(--comp-pill-btn-height)) / 2 * -1);
231
236
  }