q2-tecton-elements 1.12.0-alpha.0 → 1.12.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 (162) hide show
  1. package/dist/cjs/{icons-4595ee47.js → icons-9bd0febe.js} +10 -0
  2. package/dist/cjs/{index-a55d3c34.js → index-773c3eec.js} +25 -12
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/q2-avatar.cjs.entry.js +1 -1
  5. package/dist/cjs/q2-btn_2.cjs.entry.js +3 -3
  6. package/dist/cjs/q2-calendar.cjs.entry.js +15 -4
  7. package/dist/cjs/q2-card.cjs.entry.js +89 -0
  8. package/dist/cjs/q2-carousel-pane.cjs.entry.js +1 -1
  9. package/dist/cjs/q2-carousel.cjs.entry.js +1 -1
  10. package/dist/cjs/q2-checkbox-group.cjs.entry.js +4 -1
  11. package/dist/cjs/q2-checkbox.cjs.entry.js +17 -6
  12. package/dist/cjs/q2-dropdown-item.cjs.entry.js +1 -1
  13. package/dist/cjs/q2-dropdown.cjs.entry.js +2 -2
  14. package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
  15. package/dist/cjs/q2-icon.cjs.entry.js +2 -2
  16. package/dist/cjs/q2-input.cjs.entry.js +12 -7
  17. package/dist/cjs/q2-loc.cjs.entry.js +1 -1
  18. package/dist/cjs/q2-message.cjs.entry.js +1 -1
  19. package/dist/cjs/q2-optgroup.cjs.entry.js +1 -1
  20. package/dist/cjs/q2-option-list.cjs.entry.js +357 -0
  21. package/dist/cjs/q2-option.cjs.entry.js +2 -10
  22. package/dist/cjs/q2-pagination.cjs.entry.js +118 -0
  23. package/dist/cjs/q2-pill.cjs.entry.js +137 -0
  24. package/dist/cjs/q2-radio-group.cjs.entry.js +40 -12
  25. package/dist/cjs/q2-radio.cjs.entry.js +20 -3
  26. package/dist/cjs/q2-section.cjs.entry.js +1 -1
  27. package/dist/cjs/q2-select.cjs.entry.js +14 -6
  28. package/dist/cjs/q2-stepper-pane.cjs.entry.js +1 -1
  29. package/dist/cjs/q2-stepper.cjs.entry.js +2 -2
  30. package/dist/cjs/q2-tab-container.cjs.entry.js +5 -1
  31. package/dist/cjs/q2-tag.cjs.entry.js +94 -0
  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/collection/collection-manifest.json +5 -0
  35. package/dist/collection/components/q2-btn/styles.css +1 -1
  36. package/dist/collection/components/q2-calendar/helpers.js +6 -0
  37. package/dist/collection/components/q2-calendar/index.js +25 -3
  38. package/dist/collection/components/q2-calendar/styles.css +1 -1
  39. package/dist/collection/components/q2-card/index.js +290 -0
  40. package/dist/collection/components/q2-card/styles.css +161 -0
  41. package/dist/collection/components/q2-checkbox/index.js +32 -4
  42. package/dist/collection/components/q2-checkbox/styles.css +1 -1
  43. package/dist/collection/components/q2-checkbox-group/index.js +21 -0
  44. package/dist/collection/components/q2-dropdown/styles.css +3 -3
  45. package/dist/collection/components/q2-icon/icons.js +10 -0
  46. package/dist/collection/components/q2-input/index.js +63 -6
  47. package/dist/collection/components/q2-input/styles.css +25 -33
  48. package/dist/collection/components/q2-loading/styles.css +1 -1
  49. package/dist/collection/components/q2-option/index.js +19 -25
  50. package/dist/collection/components/q2-option/styles.css +5 -0
  51. package/dist/collection/components/q2-option-list/index.js +646 -0
  52. package/dist/collection/components/q2-option-list/styles.css +128 -0
  53. package/dist/collection/components/q2-pagination/index.js +277 -0
  54. package/dist/collection/components/q2-pagination/styles.css +120 -0
  55. package/dist/collection/components/q2-pill/index.js +324 -0
  56. package/dist/collection/components/q2-pill/styles.css +227 -0
  57. package/dist/collection/components/q2-radio/index.js +38 -1
  58. package/dist/collection/components/q2-radio-group/index.js +64 -19
  59. package/dist/collection/components/q2-select/index.js +30 -4
  60. package/dist/collection/components/q2-select/styles.css +4 -4
  61. package/dist/collection/components/q2-stepper/styles.css +8 -8
  62. package/dist/collection/components/q2-tab-container/index.js +4 -0
  63. package/dist/collection/components/q2-tag/index.js +200 -0
  64. package/dist/collection/components/q2-tag/styles.css +141 -0
  65. package/dist/collection/utils/index.js +24 -12
  66. package/dist/esm/{icons-3ee662ea.js → icons-6a143c2f.js} +10 -0
  67. package/dist/esm/{index-ec6660af.js → index-fa32f694.js} +25 -13
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/q2-avatar.entry.js +1 -1
  70. package/dist/esm/q2-btn_2.entry.js +3 -3
  71. package/dist/esm/q2-calendar.entry.js +15 -4
  72. package/dist/esm/q2-card.entry.js +85 -0
  73. package/dist/esm/q2-carousel-pane.entry.js +1 -1
  74. package/dist/esm/q2-carousel.entry.js +1 -1
  75. package/dist/esm/q2-checkbox-group.entry.js +4 -1
  76. package/dist/esm/q2-checkbox.entry.js +17 -6
  77. package/dist/esm/q2-dropdown-item.entry.js +1 -1
  78. package/dist/esm/q2-dropdown.entry.js +2 -2
  79. package/dist/esm/q2-editable-field.entry.js +1 -1
  80. package/dist/esm/q2-icon.entry.js +2 -2
  81. package/dist/esm/q2-input.entry.js +12 -7
  82. package/dist/esm/q2-loc.entry.js +1 -1
  83. package/dist/esm/q2-message.entry.js +1 -1
  84. package/dist/esm/q2-optgroup.entry.js +1 -1
  85. package/dist/esm/q2-option-list.entry.js +353 -0
  86. package/dist/esm/q2-option.entry.js +3 -11
  87. package/dist/esm/q2-pagination.entry.js +114 -0
  88. package/dist/esm/q2-pill.entry.js +133 -0
  89. package/dist/esm/q2-radio-group.entry.js +41 -13
  90. package/dist/esm/q2-radio.entry.js +20 -3
  91. package/dist/esm/q2-section.entry.js +1 -1
  92. package/dist/esm/q2-select.entry.js +14 -6
  93. package/dist/esm/q2-stepper-pane.entry.js +1 -1
  94. package/dist/esm/q2-stepper.entry.js +2 -2
  95. package/dist/esm/q2-tab-container.entry.js +5 -1
  96. package/dist/esm/q2-tag.entry.js +90 -0
  97. package/dist/esm/q2-tecton-elements.js +1 -1
  98. package/dist/esm/q2-textarea.entry.js +1 -1
  99. package/dist/q2-tecton-elements/p-08668234.entry.js +1 -0
  100. package/dist/q2-tecton-elements/{p-fbf7c5e6.entry.js → p-0a7cff38.entry.js} +1 -1
  101. package/dist/q2-tecton-elements/p-167a19fd.entry.js +1 -0
  102. package/dist/q2-tecton-elements/{p-07a5d703.entry.js → p-30bf5f44.entry.js} +1 -1
  103. package/dist/q2-tecton-elements/{p-7e030e92.entry.js → p-34415315.entry.js} +1 -1
  104. package/dist/q2-tecton-elements/p-3c6f73cb.js +1 -0
  105. package/dist/q2-tecton-elements/p-54300d2f.entry.js +1 -0
  106. package/dist/q2-tecton-elements/p-54f0d64e.entry.js +1 -0
  107. package/dist/q2-tecton-elements/p-5b906cf1.entry.js +1 -0
  108. package/dist/q2-tecton-elements/{p-06fff43d.entry.js → p-650d7497.entry.js} +1 -1
  109. package/dist/q2-tecton-elements/p-7ce98c1a.entry.js +1 -0
  110. package/dist/q2-tecton-elements/p-8c22e6b4.entry.js +1 -0
  111. package/dist/q2-tecton-elements/p-91dba21f.entry.js +1 -0
  112. package/dist/q2-tecton-elements/{p-a6f8d09a.entry.js → p-9a3c37ab.entry.js} +1 -1
  113. package/dist/q2-tecton-elements/{p-75e87cca.entry.js → p-a0248299.entry.js} +1 -1
  114. package/dist/q2-tecton-elements/p-aca8302b.entry.js +1 -0
  115. package/dist/q2-tecton-elements/{p-df182f61.entry.js → p-af202624.entry.js} +1 -1
  116. package/dist/q2-tecton-elements/{p-c5e55b9f.entry.js → p-b9c2c1d3.entry.js} +1 -1
  117. package/dist/q2-tecton-elements/p-c3d68d5c.js +1 -0
  118. package/dist/q2-tecton-elements/{p-bb2e110a.entry.js → p-c5199147.entry.js} +1 -1
  119. package/dist/q2-tecton-elements/{p-843b1ee9.entry.js → p-c5e6f7fa.entry.js} +1 -1
  120. package/dist/q2-tecton-elements/p-ce44ee47.entry.js +1 -0
  121. package/dist/q2-tecton-elements/{p-50967020.entry.js → p-d3058002.entry.js} +1 -1
  122. package/dist/q2-tecton-elements/p-d65aaed2.entry.js +1 -0
  123. package/dist/q2-tecton-elements/{p-9b50c3c3.entry.js → p-d9bc6494.entry.js} +1 -1
  124. package/dist/q2-tecton-elements/p-df86f160.entry.js +1 -0
  125. package/dist/q2-tecton-elements/{p-9a977ee6.entry.js → p-e38080d2.entry.js} +1 -1
  126. package/dist/q2-tecton-elements/p-e9d69ba8.entry.js +1 -0
  127. package/dist/q2-tecton-elements/p-f98dc161.entry.js +1 -0
  128. package/dist/q2-tecton-elements/{p-7e6fc65d.entry.js → p-fa9e3825.entry.js} +1 -1
  129. package/dist/q2-tecton-elements/{p-b281c349.entry.js → p-fe6407a4.entry.js} +1 -1
  130. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
  131. package/dist/test/elements/q2-tag-test.js +151 -0
  132. package/dist/test/helpers.js +14 -3
  133. package/dist/types/components/q2-calendar/helpers.d.ts +1 -0
  134. package/dist/types/components/q2-calendar/index.d.ts +1 -0
  135. package/dist/types/components/q2-card/index.d.ts +31 -0
  136. package/dist/types/components/q2-checkbox/index.d.ts +3 -1
  137. package/dist/types/components/q2-checkbox-group/index.d.ts +1 -0
  138. package/dist/types/components/q2-input/index.d.ts +3 -0
  139. package/dist/types/components/q2-option/index.d.ts +2 -3
  140. package/dist/types/components/q2-option-list/index.d.ts +62 -0
  141. package/dist/types/components/q2-pagination/index.d.ts +30 -0
  142. package/dist/types/components/q2-pill/index.d.ts +39 -0
  143. package/dist/types/components/q2-radio/index.d.ts +4 -1
  144. package/dist/types/components/q2-radio-group/index.d.ts +5 -1
  145. package/dist/types/components/q2-select/index.d.ts +1 -0
  146. package/dist/types/components/q2-tag/index.d.ts +28 -0
  147. package/dist/types/components.d.ts +175 -1
  148. package/dist/types/utils/index.d.ts +1 -0
  149. package/dist/types/workspace/workspace/Tecton_tecton-production_master/packages/q2-tecton-elements/.stencil/test/elements/q2-tag-test.d.ts +1 -0
  150. package/dist/types/workspace/workspace/{_production_release_1.11.0-alpha → Tecton_tecton-production_master}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +4 -1
  151. package/package.json +2 -2
  152. package/dist/q2-tecton-elements/p-29a37091.entry.js +0 -1
  153. package/dist/q2-tecton-elements/p-37aba2a4.js +0 -1
  154. package/dist/q2-tecton-elements/p-4cd00f1a.js +0 -1
  155. package/dist/q2-tecton-elements/p-6702eb4d.entry.js +0 -1
  156. package/dist/q2-tecton-elements/p-768e3a5d.entry.js +0 -1
  157. package/dist/q2-tecton-elements/p-943c7745.entry.js +0 -1
  158. package/dist/q2-tecton-elements/p-95a73559.entry.js +0 -1
  159. package/dist/q2-tecton-elements/p-ac859fcc.entry.js +0 -1
  160. package/dist/q2-tecton-elements/p-ccbe9158.entry.js +0 -1
  161. package/dist/q2-tecton-elements/p-db6f90ac.entry.js +0 -1
  162. package/dist/q2-tecton-elements/p-fa6eea5c.entry.js +0 -1
@@ -0,0 +1,353 @@
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-be8376c0.js';
2
+ import { o as overrideFocus, i as isEventFromElement } from './index-fa32f694.js';
3
+
4
+ const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}:host{position:relative;width:100%;display:block}.content{margin-top:var(--tct-option-list-margin, var(--t-option-list-margin, var(--app-scale-1x, 5px)));position:absolute;height:0;opacity:0;visibility:hidden;background-color:var(--app-white);color:var(--t-font-color);z-index:100;width:max-content;min-width:var(--tct-option-list-min-width, var(--t-option-list-min-width, 135px));box-shadow:var(--app-shadow-1);overflow:hidden;text-align:start;transition:opacity var(--app-tween-1);border-radius:var(--tct-option-list-border-radius, var(--t-option-list-border-radius, 0));--comp-scrollbar-size:var(--tct-scrollbar-size, var(--t-scrollbar-size, var(--app-scale-1x, 5px)));--comp-scrollbar-border-radius:var(--tct-scrollbar-border-radius, var(--t-scrollbar-border-radius, var(--app-border-radius-1, 3px)));--comp-scrollbar-color:var(--tct-scrollbar-color, var(--t-scrollbar-color, var(--t-a11y-gray-color, #747474)));scrollbar-width:thin;scrollbar-color:var(--comp-scrollbar-color) transparent}.content::-webkit-scrollbar{width:var(--comp-scrollbar-size);height:var(--comp-scrollbar-size);margin:5px}.content::-webkit-scrollbar-thumb{background:var(--comp-scrollbar-color);border-radius:var(--comp-scrollbar-border-radius)}.content::-webkit-scrollbar-track{background:transparent;border-radius:var(--comp-scrollbar-border-radius)}:host(:not([align=right])) .content{left:0}:host([align=right]) .content{right:0}:host([open]) .content{display:block;height:auto;overflow:auto;opacity:1;visibility:visible}:host([is-sizeable]) .content{display:block;height:auto}:host([alignment=right]) .content{left:unset;right:0}";
5
+
6
+ const Q2OptionList = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.change = createEvent(this, "change", 7);
10
+ this.optionListState = createEvent(this, "optionListState", 7);
11
+ this.role = 'listbox';
12
+ this.direction = 'down';
13
+ this.selectedOptions = [];
14
+ this.scheduledAfterRender = [];
15
+ /// Event Handlers ///
16
+ this.keydownHandler = (event, ignoreSelectionEvents) => {
17
+ event.stopPropagation();
18
+ const { activeIndex, customSearch, allOptions } = this;
19
+ const { key, shiftKey } = event;
20
+ let newOption;
21
+ switch (key) {
22
+ case ' ':
23
+ case 'Enter':
24
+ if (ignoreSelectionEvents) {
25
+ this.setDefaultActiveElement();
26
+ break;
27
+ }
28
+ event.preventDefault();
29
+ newOption = allOptions.find(element => element.active);
30
+ if (!newOption || newOption.disabled)
31
+ break;
32
+ this.selectOption(newOption.value);
33
+ break;
34
+ case 'ArrowUp':
35
+ event.preventDefault();
36
+ const isFirstOption = activeIndex === 0;
37
+ if (isFirstOption)
38
+ break;
39
+ if (activeIndex === undefined) {
40
+ this.setDefaultActiveElement();
41
+ }
42
+ else {
43
+ const nextIndex = this.getNextVisibleIndex(-1);
44
+ if (nextIndex === -1)
45
+ break;
46
+ this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
47
+ }
48
+ break;
49
+ case 'ArrowDown':
50
+ event.preventDefault();
51
+ const isLastOption = activeIndex === allOptions.length - 1;
52
+ if (isLastOption)
53
+ break;
54
+ if (activeIndex === undefined) {
55
+ this.setDefaultActiveElement();
56
+ }
57
+ else {
58
+ const nextIndex = this.getNextVisibleIndex(1);
59
+ if (nextIndex === -1)
60
+ break;
61
+ this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
62
+ }
63
+ break;
64
+ case 'Home':
65
+ event.preventDefault();
66
+ this.openDropdownWithActiveElement(0);
67
+ break;
68
+ case 'End':
69
+ event.preventDefault();
70
+ this.openDropdownWithActiveElement(allOptions.length - 1);
71
+ break;
72
+ case 'PageUp':
73
+ event.preventDefault();
74
+ this.openDropdownWithActiveElement(Math.max(activeIndex - 10, 0));
75
+ break;
76
+ case 'PageDown':
77
+ event.preventDefault();
78
+ this.openDropdownWithActiveElement(Math.min(activeIndex + 10, allOptions.length - 1));
79
+ break;
80
+ case 'Tab':
81
+ if (ignoreSelectionEvents)
82
+ break;
83
+ if (shiftKey)
84
+ break;
85
+ newOption = allOptions.find(element => element.active);
86
+ if (!newOption || newOption.disabled)
87
+ return;
88
+ this.selectOption(newOption.value);
89
+ break;
90
+ case 'Esc':
91
+ case 'Escape':
92
+ if (this.noSelect)
93
+ this.setActiveElement(null);
94
+ this.open = false;
95
+ break;
96
+ default:
97
+ if (customSearch)
98
+ break;
99
+ if (!key.match(/^[A-Za-z0-9]$/))
100
+ break;
101
+ // search in non-searchable select: alpha-numeric only
102
+ this.searchAndFocus(key);
103
+ break;
104
+ }
105
+ };
106
+ this.focusoutHandler = (event) => {
107
+ const { relatedTarget } = event;
108
+ const isInDropdown = this.allOptions.includes(relatedTarget);
109
+ const isInLightDom = !isInDropdown && this.hostElement.contains(relatedTarget);
110
+ if (isInDropdown || isInLightDom) {
111
+ event.stopPropagation();
112
+ }
113
+ };
114
+ this.clickHandler = (event) => {
115
+ const target = event.target;
116
+ if (target.localName !== 'q2-option' || target.disabled) {
117
+ return;
118
+ }
119
+ this.selectOption(target.value);
120
+ };
121
+ }
122
+ /// LifeCycle Hooks ///
123
+ componentWillLoad() {
124
+ this.hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
125
+ }
126
+ componentDidLoad() {
127
+ overrideFocus(this.hostElement);
128
+ this.checkOptions();
129
+ }
130
+ componentDidRender() {
131
+ this.scheduledAfterRender.forEach(fn => fn());
132
+ this.scheduledAfterRender = [];
133
+ }
134
+ /// Getters ///
135
+ get allOptions() {
136
+ return this.getRootSlot(this.hostElement);
137
+ }
138
+ /// Helpers ///
139
+ checkOptions() {
140
+ const { noSelect, type, allOptions } = this;
141
+ if (!noSelect && !type)
142
+ return;
143
+ const optionRole = type === 'menu' ? 'menuitem' : 'option';
144
+ allOptions.forEach(option => {
145
+ if (noSelect)
146
+ option.noSelect = true;
147
+ if (type)
148
+ option.role = optionRole;
149
+ });
150
+ }
151
+ getRootSlot(element) {
152
+ var _a;
153
+ const slot = element.querySelector('slot');
154
+ const assignedElements = (_a = slot === null || slot === void 0 ? void 0 : slot.assignedElements()) !== null && _a !== void 0 ? _a : Array.from(element.children);
155
+ const hasAnotherSlot = !!assignedElements.length && assignedElements[0].tagName === 'SLOT';
156
+ if (hasAnotherSlot) {
157
+ return this.getRootSlot(assignedElements[0]);
158
+ }
159
+ else {
160
+ return assignedElements;
161
+ }
162
+ }
163
+ scrollToActiveOption() {
164
+ const activeOption = this.allOptions[this.activeIndex];
165
+ activeOption === null || activeOption === void 0 ? void 0 : activeOption.scrollIntoView({ block: 'nearest' });
166
+ }
167
+ resizeIframe() {
168
+ var _a, _b;
169
+ return (_b = (_a = window.TectonElements) === null || _a === void 0 ? void 0 : _a.resizeIframe) === null || _b === void 0 ? void 0 : _b.call(_a);
170
+ }
171
+ openDropdownWithActiveElement(activeIndex) {
172
+ if (this.disabled)
173
+ return;
174
+ this.activeIndex = activeIndex;
175
+ this.open = true;
176
+ this.setActiveOption();
177
+ this.setFocusedOption();
178
+ this.scheduledAfterRender.push(() => {
179
+ this.scrollToActiveOption();
180
+ this.resizeIframe();
181
+ });
182
+ }
183
+ getDefaultActiveIndex() {
184
+ const { allOptions } = this;
185
+ const firstSelected = allOptions.findIndex(element => element.selected);
186
+ if (firstSelected > -1)
187
+ return firstSelected;
188
+ const firstEnabled = allOptions.findIndex(element => !element.hidden);
189
+ if (firstEnabled > -1)
190
+ return firstEnabled;
191
+ return 0;
192
+ }
193
+ updateSingleOptionAttrs() {
194
+ var _a, _b;
195
+ const { allOptions, selectedOptions } = this;
196
+ const singleValue = (_b = (_a = selectedOptions[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : undefined;
197
+ allOptions.forEach(element => {
198
+ element.selected = element.value === singleValue;
199
+ });
200
+ }
201
+ updateMultipleOptionAttrs() {
202
+ const { allOptions, selectedOptions } = this;
203
+ const selectedValues = selectedOptions.map(option => option.value);
204
+ allOptions.forEach(element => {
205
+ element.selected = selectedValues.includes(element.value);
206
+ });
207
+ }
208
+ setActiveOption() {
209
+ if (!this.open)
210
+ return;
211
+ const activeIndex = this.activeIndex;
212
+ this.allOptions.forEach((element, elementIndex) => {
213
+ element.active = activeIndex === elementIndex;
214
+ });
215
+ }
216
+ setFocusedOption() {
217
+ const option = this.allOptions[this.activeIndex];
218
+ if (!option)
219
+ return;
220
+ setTimeout(() => {
221
+ option.focus();
222
+ }, 25);
223
+ }
224
+ getNextVisibleIndex(direction) {
225
+ let index = this.activeIndex + direction;
226
+ while (index >= 0 && index <= this.allOptions.length - 1) {
227
+ const { display, visibility } = window.getComputedStyle(this.allOptions[index]);
228
+ if (display !== 'none' && visibility !== 'hidden') {
229
+ return index;
230
+ }
231
+ index = index + direction;
232
+ }
233
+ return -1;
234
+ }
235
+ selectOption(selectedValue) {
236
+ const option = this.allOptions.find(({ value }) => value === selectedValue);
237
+ const valueObject = {
238
+ value: selectedValue,
239
+ display: option.display || option.innerText.trim()
240
+ };
241
+ const { multiple, noSelect } = this;
242
+ let values;
243
+ if (multiple) {
244
+ const { selectedOptions = [] } = this;
245
+ const isAlreadySelected = !!selectedOptions.find(({ value }) => value === selectedValue);
246
+ if (isAlreadySelected) {
247
+ values = selectedOptions.filter(({ value }) => value !== selectedValue);
248
+ }
249
+ else {
250
+ values = [...selectedOptions, valueObject];
251
+ }
252
+ }
253
+ else {
254
+ values = [valueObject];
255
+ }
256
+ if (noSelect)
257
+ this.setActiveElement(null);
258
+ else
259
+ this.selectedOptions = values;
260
+ this.change.emit({ value: selectedValue, values });
261
+ if (multiple)
262
+ return;
263
+ this.open = false;
264
+ }
265
+ adjustActiveOptionAndScroll(numToAdd) {
266
+ this.activeIndex += numToAdd;
267
+ this.setActiveOption();
268
+ this.setFocusedOption();
269
+ this.scrollToActiveOption();
270
+ }
271
+ resetTimer() {
272
+ if (this.searchStringTimer) {
273
+ clearTimeout(this.searchStringTimer);
274
+ }
275
+ this.searchStringTimer = window.setTimeout(() => {
276
+ this.searchString = null;
277
+ }, 2000);
278
+ }
279
+ searchAndFocus(key) {
280
+ this.resetTimer();
281
+ let searchString = this.searchString ? `${this.searchString}${key}` : key;
282
+ searchString = searchString.replace(/[^0-9a-z]/gi, '');
283
+ this.searchString = searchString;
284
+ const searchRegEx = new RegExp(searchString, 'i');
285
+ const foundIndex = this.allOptions.findIndex(option => option.value === searchString || option.textContent.match(searchRegEx));
286
+ if (foundIndex === -1)
287
+ return;
288
+ this.setActiveElement(foundIndex);
289
+ }
290
+ /// Watchers ///
291
+ selectedOptionsUpdated() {
292
+ if (this.multiple) {
293
+ this.updateMultipleOptionAttrs();
294
+ }
295
+ else {
296
+ this.updateSingleOptionAttrs();
297
+ }
298
+ }
299
+ openChanged(newValue) {
300
+ this.optionListState.emit({ open: newValue });
301
+ }
302
+ /// Listeners ///
303
+ delegateFocus(event) {
304
+ if (!isEventFromElement(event, this.hostElement))
305
+ return;
306
+ this.open = true;
307
+ this.setDefaultActiveElement();
308
+ }
309
+ handleClick(event) {
310
+ event.stopPropagation();
311
+ }
312
+ /// Public Methods ///
313
+ toggle() {
314
+ const isOpen = !this.open;
315
+ this.open = isOpen;
316
+ }
317
+ setDefaultActiveElement() {
318
+ this.activeIndex = this.getDefaultActiveIndex();
319
+ this.setActiveOption();
320
+ this.setFocusedOption();
321
+ }
322
+ setActiveElement(index) {
323
+ this.activeIndex = index;
324
+ this.setActiveOption();
325
+ this.setFocusedOption();
326
+ }
327
+ handleExternalKeydown(event) {
328
+ const keysThatTriggerOpen = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp', 'Home', 'End'];
329
+ if (keysThatTriggerOpen.includes(event.key)) {
330
+ this.open = true;
331
+ }
332
+ const keysThatTriggerDefault = ['ArrowDown', 'ArrowUp'];
333
+ if (keysThatTriggerDefault.includes(event.key)) {
334
+ event.preventDefault();
335
+ this.setDefaultActiveElement();
336
+ }
337
+ else {
338
+ this.keydownHandler(event, true);
339
+ }
340
+ }
341
+ /// DOM ///
342
+ render() {
343
+ return (h(Host, null, h("div", { class: "content", ref: el => (this.contentElement = el), onFocusout: this.focusoutHandler }, h("div", { class: "options", role: this.type || 'listbox', onKeyDown: this.keydownHandler, onClick: this.clickHandler }, h("slot", null)))));
344
+ }
345
+ get hostElement() { return getElement(this); }
346
+ static get watchers() { return {
347
+ "selectedOptions": ["selectedOptionsUpdated"],
348
+ "open": ["openChanged"]
349
+ }; }
350
+ };
351
+ Q2OptionList.style = stylesCss;
352
+
353
+ export { Q2OptionList as q2_option_list };
@@ -1,26 +1,18 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-be8376c0.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-be8376c0.js';
2
2
 
3
- const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}:host{padding:0 var(--tct-scale-2, var(--app-scale-2, 10px));min-height:44px;align-items:center;cursor:pointer;grid-template-columns:var(--tct-option-selected-icon-size, var(--tct-scale-3, var(--app-scale-3, 15px))) 1fr;align-items:center;grid-template-areas:\"icon content\";gap:var(--tct-scale-1, var(--app-scale-1, 5px))}:host([aria-disabled]){cursor:not-allowed;opacity:var(--tct-disabled-opacity, var(--app-disabled-opacity, 0.4));pointer-events:none}:host([aria-hidden]){display:none}:host(:not([hidden]):not([aria-hidden])){display:grid}:host(:not([aria-disabled]):hover),:host([active]),:host(:focus){background-color:var(--tct-option-active-bg, var(--tct-gray-14, var(--t-gray-14, var(--tct-gray-l3, var(--app-gray-l3, #f2f2f2)))))}q2-icon{grid-area:icon;--tct-icon-size:var(--tct-option-selected-icon-size, var(--tct-scale-3, var(--app-scale-3, 15px)))}.content{display:block;grid-area:content}:host(:not([multiline])) .content{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";
3
+ const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}:host{padding:0 var(--tct-scale-2, var(--app-scale-2, 10px));min-height:44px;align-items:center;cursor:pointer;grid-template-columns:var(--tct-option-selected-icon-size, var(--tct-scale-3, var(--app-scale-3, 15px))) 1fr;align-items:center;grid-template-areas:\"icon content\";gap:var(--tct-scale-1, var(--app-scale-1, 5px))}:host([_no-select]){grid-template-columns:1fr;grid-template-areas:\"content\"}:host([aria-disabled]){cursor:not-allowed;opacity:var(--tct-disabled-opacity, var(--app-disabled-opacity, 0.4));pointer-events:none}:host([aria-hidden]){display:none}:host(:not([hidden]):not([aria-hidden])){display:grid}:host(:not([aria-disabled]):hover),:host([active]),:host(:focus){background-color:var(--tct-option-active-bg, var(--tct-gray-14, var(--t-gray-14, var(--tct-gray-l3, var(--app-gray-l3, #f2f2f2)))))}q2-icon{grid-area:icon;--tct-icon-size:var(--tct-option-selected-icon-size, var(--tct-scale-3, var(--app-scale-3, 15px)))}.content{display:block;grid-area:content}:host(:not([multiline])) .content{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";
4
4
 
5
5
  const Q2Option = class {
6
6
  constructor(hostRef) {
7
7
  registerInstance(this, hostRef);
8
- this.click = createEvent(this, "click", 7);
9
8
  this.role = 'option';
10
9
  this.tabindex = '-1';
11
10
  this._multiSelectHidden = false;
12
- this.onClick = (event) => {
13
- event.stopImmediatePropagation();
14
- const { disabled, disabledGroup } = this;
15
- if (disabled || disabledGroup)
16
- return;
17
- this.click.emit();
18
- };
19
11
  }
20
12
  render() {
21
13
  const { disabled, disabledGroup, selected, _multiSelectHidden } = this;
22
14
  const isDisabled = disabled || disabledGroup;
23
- return (h(Host, { "aria-disabled": isDisabled ? 'true' : undefined, "aria-selected": selected ? 'true' : undefined, "aria-hidden": _multiSelectHidden ? 'true' : undefined }, this.selected && h("q2-icon", { type: "checkmark" }), h("div", { class: "content", onClick: this.onClick }, h("slot", null))));
15
+ return (h(Host, { "aria-disabled": isDisabled ? 'true' : undefined, "aria-selected": selected ? 'true' : undefined, "aria-hidden": _multiSelectHidden ? 'true' : undefined }, this.selected && h("q2-icon", { type: "checkmark" }), h("div", { class: "content" }, h("slot", null))));
24
16
  }
25
17
  get hostElement() { return getElement(this); }
26
18
  };
@@ -0,0 +1,114 @@
1
+ import { r as registerInstance, c as createEvent, h, g as getElement } from './index-be8376c0.js';
2
+ import { o as overrideFocus, i as isEventFromElement, l as loc, n as nextPaint } from './index-fa32f694.js';
3
+
4
+ const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}:host{text-align:right;display:block}:host([hidden]){display:none}.container{display:inline-flex;column-gap:var(--tct-pagination-column-gap, var(--t-pagination-column-gap, var(--app-scale-2x, 10px)));align-items:center;height:var(--tct-pagination-height, var(--t-pagination-height, 44px))}.btn-group{display:flex;gap:var(--tct-pagination-btn-gap, var(--t-pagination-btn-gap, 0))}.description,.controls{white-space:nowrap}.controls{display:grid;grid-template-columns:auto 50px auto;align-items:center;gap:var(--tct-pagination-controls-gap, var(--t-pagination-controls-gap, var(--app-scale-1x, 5px)))}.controls[hidden]{display:none}.input-wrapper{height:var(--tct-pagination-height, var(--t-pagination-height, 44px));display:flex;align-items:center}q2-icon{--tct-icon-size:var(--tct-pagination-icon-size, var(--t-pagination-icon-size, 12px));color:var(--tct-pagination-icon-color, var(--t-pagination-icon-color, var(--t-text, #4d4d4d)))}q2-input{--tct-input-margin-top:0;--tct-input-margin-bottom:0;--tct-input-height:var(--tct-pagination-input-height, var(--t-pagination-input-height, 30px));--tct-input-min-height:var(--tct-input-height);--tct-input-align:center}";
5
+
6
+ const Q2Pagination = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.change = createEvent(this, "change", 7);
10
+ this.handlePageChange = (page) => {
11
+ const { totalPages, inputField } = this;
12
+ if (page < 1) {
13
+ page = 1;
14
+ }
15
+ else if (page > totalPages) {
16
+ page = totalPages;
17
+ }
18
+ if (inputField.value !== `${page}`)
19
+ inputField.value = `${page}`;
20
+ if (!this.hostElement.onchange) {
21
+ this.page = page;
22
+ }
23
+ this.change.emit({ value: page });
24
+ };
25
+ }
26
+ ////////// LIFECYCLE HOOKS ////////
27
+ componentDidLoad() {
28
+ if (this.recordsOnly || this.pagesOnly)
29
+ return;
30
+ this.containerWidth = this.containerElement.clientWidth;
31
+ this.resizeObserver = new ResizeObserver(() => this.checkSize());
32
+ this.resizeObserver.observe(this.hostElement);
33
+ overrideFocus(this.hostElement);
34
+ }
35
+ disconnectedCallback() {
36
+ var _a;
37
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
38
+ }
39
+ onHostElementFocus(event) {
40
+ var _a;
41
+ if (!isEventFromElement(event, this.hostElement))
42
+ return;
43
+ const { isFullViewHidden, containerElement, inputField } = this;
44
+ if (isFullViewHidden) {
45
+ (_a = containerElement.querySelector('q2-btn:not([disabled])')) === null || _a === void 0 ? void 0 : _a.focus();
46
+ }
47
+ else {
48
+ inputField.focus();
49
+ }
50
+ }
51
+ get isFullViewHidden() {
52
+ return this.isSmall || this.recordsOnly || this.pagesOnly;
53
+ }
54
+ get pageWithDefault() {
55
+ return this.page || 1;
56
+ }
57
+ get perPageWithDefault() {
58
+ return this.perPage || 10;
59
+ }
60
+ get totalWithDefault() {
61
+ return this.total || 0;
62
+ }
63
+ get recordTypeWithDefault() {
64
+ return this.recordType || loc('tecton.element.pagination.defaultRecordType');
65
+ }
66
+ get currentRange() {
67
+ const { perPageWithDefault: perPage, totalWithDefault: total, pageWithDefault: page } = this;
68
+ const start = (page - 1) * perPage + 1;
69
+ const end = Math.min(page * perPage, total);
70
+ return `${start} - ${end}`;
71
+ }
72
+ get totalPages() {
73
+ const { pagesOnly, totalWithDefault: total, perPageWithDefault: perPage, pages } = this;
74
+ if (pagesOnly && pages && !isNaN(parseInt(`${pages}`)))
75
+ return pages;
76
+ return Math.ceil(total / perPage);
77
+ }
78
+ checkSize() {
79
+ const { hostElement, containerElement } = this;
80
+ const isOverflowing = this.containerWidth > hostElement.clientWidth;
81
+ this.isSmall = isOverflowing;
82
+ if (isOverflowing)
83
+ return;
84
+ nextPaint(() => {
85
+ const containerWidthHasNotChanged = this.containerWidth === containerElement.clientWidth;
86
+ if (containerWidthHasNotChanged)
87
+ return;
88
+ this.containerWidth = containerElement.clientWidth;
89
+ this.checkSize();
90
+ });
91
+ }
92
+ ////////// OBSERVERS //////////
93
+ render() {
94
+ const { pagesOnly, isFullViewHidden, recordTypeWithDefault: recordType, totalPages, totalWithDefault: total, pageWithDefault: page, currentRange } = this;
95
+ const onFirstPage = page === 1;
96
+ const onLastPage = page === totalPages;
97
+ return (h("nav", { class: "container", ref: el => (this.containerElement = el), "aria-label": loc('tecton.element.pagination.title') }, h("div", { class: "description", "test-id": "description" }, pagesOnly
98
+ ? loc('tecton.element.pagination.pages', {
99
+ current: page,
100
+ total: totalPages
101
+ })
102
+ : loc('tecton.element.pagination.description', {
103
+ range: currentRange,
104
+ recordType: recordType.toLowerCase(),
105
+ total: total.toLocaleString()
106
+ })), h("div", { class: "btn-group" }, h("q2-btn", { label: "tecton.element.pagination.goToFirstPage", disabled: onFirstPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(1), "test-id": "firstPageBtn", "hide-label": true }, h("q2-icon", { type: "chevron-double-left" })), h("q2-btn", { label: loc('tecton.element.pagination.goToPage', [page - 1]), disabled: onFirstPage, onClick: () => this.handlePageChange(page - 1), "test-id": "prevPageBtn", "hide-label": true }, h("q2-icon", { type: "chevron-left" }))), h("div", { class: "controls", hidden: isFullViewHidden, "test-id": "controls" }, h("span", { "aria-hidden": "true" }, loc('tecton.element.pagination.page')), h("div", { class: "input-wrapper", onClick: () => this.inputField.dispatchEvent(new FocusEvent('focus')) }, 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', [
107
+ totalPages.toLocaleString()
108
+ ])})`, onChange: event => this.handlePageChange(event.detail.value), "test-id": "pageInput", current: "page", ref: el => (this.inputField = el) })), h("span", { "aria-hidden": "true" }, loc('tecton.element.pagination.ofPages', [totalPages.toLocaleString()]))), h("div", { class: "btn-group" }, h("q2-btn", { label: loc('tecton.element.pagination.goToPage', [page + 1]), disabled: onLastPage, onClick: () => this.handlePageChange(page + 1), "test-id": "nextPageBtn", "hide-label": true }, h("q2-icon", { type: "chevron-right" })), h("q2-btn", { label: "tecton.element.pagination.goToLastPage", disabled: onLastPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(totalPages), "test-id": "lastPageBtn", "hide-label": true }, h("q2-icon", { type: "chevron-double-right" })))));
109
+ }
110
+ get hostElement() { return getElement(this); }
111
+ };
112
+ Q2Pagination.style = stylesCss;
113
+
114
+ export { Q2Pagination as q2_pagination };
@@ -0,0 +1,133 @@
1
+ import { r as registerInstance, c as createEvent, h, F as Fragment, g as getElement } from './index-be8376c0.js';
2
+ import { o as overrideFocus, l as loc, i as isEventFromElement } from './index-fa32f694.js';
3
+
4
+ const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}:host{display:inline-block;position:relative}:host(:not(:last-child)){margin-inline-end:var(--tct-pill-margin, var(--t-pill-margin, var(--app-scale-2x, 10px)))}.btn-wrapper{--comp-pill-min-height:var(--tct-pill-min-height, var(--t-pill-min-height, 44px));--comp-pill-btn-border-width:var(--tct-pill-btn-border-width, var(--t-pill-btn-border-width, 2px));--comp-pill-btn-height:var(--tct-pill-btn-height, var(--t-pill-btn-height, 30px));--comp-close-size:0px;--comp-btn-background:var(--tct-pill-btn-background, var(--t-pill-btn-background, var(--t-base, #ffffff)));--compt-hover-btn-background:var(--tct-pill-hover-btn-background, var(--t-pill-hover-btn-background, var(--t-gray-13, #e6e6e6)));--comp-btn-padding:var(--tct-pill-btn-padding-inline, var(--t-pill-btn-padding-inline, var(--app-scale-3x, 15px)));--comp-btn-color:var(--tct-pill-btn-color, var(--t-pill-btn-color, var(--t-gray-3, #262626)));--comp-active-btn-background:var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-7, #666666)));--comp-active-btn-border-color:var(--tct-pill-active-btn-border-color, var(--t-pill-active-btn-border-color, var(--t-gray-7, #666666)));--comp-hover-active-btn-background:var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-6, #4d4d4d)));--comp-hover-active-btn-border-color:var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-6, #4d4d4d)));position:relative}:host(:not(:empty)) .btn-wrapper,.btn-wrapper.has-icon{--comp-close-size:var(--comp-pill-btn-height)}:host([active]) .btn-wrapper{--comp-btn-color:var(--tct-pill-active-btn-color, var(--t-pill-active-btn-color, var(--t-base, #ffffff)))}:host([theme=primary]) .btn-wrapper{--comp-active-btn-background:var(--t-primary-l5, #61c4ff);--comp-btn-color:var(--t-primary-text, #ffffff);--comp-active-btn-border-color:var(--t-primary-l5, #61c4ff);--comp-hover-active-btn-background:var(--t-primary-l3, #21acff);--comp-hover-active-btn-border-color:var(--t-primary-l3, #21acff)}:host([theme=secondary]) .btn-wrapper{--comp-active-btn-background:var(--t-secondary-l5, #61c4ff);--comp-btn-color:var(--t-secondary-text, #000000);--comp-active-btn-border-color:var(--t-secondary-l5, #61c4ff);--comp-hover-active-btn-background:var(--t-secondary-l3, #21acff);--comp-hover-active-btn-border-color:var(--t-secondary-l3, #21acff)}:host([theme=tertiary]) .btn-wrapper{--comp-active-btn-background:var(--t-tertiary-l5, #61c4ff);--comp-btn-color:var(--t-tertiary-text, #000000);--comp-active-btn-border-color:var(--t-tertiary-l5, #61c4ff);--comp-hover-active-btn-background:var(--t-tertiary-l3, #21acff);--comp-hover-active-btn-border-color:var(--t-tertiary-l3, #21acff)}q2-option-list{position:absolute;left:0}.btn-height-wrapper{height:var(--comp-pill-min-height);display:flex;align-items:center;cursor:pointer}.btn-height-wrapper:focus{box-shadow:none}:host([disabled]) .btn-height-wrapper{cursor:not-allowed}.btn-close,.btn-primary{cursor:pointer;height:var(--comp-pill-btn-height);border-style:solid;border-radius:var(--tct-pill-btn-border-radius, var(--t-pill-btn-border-radius, 30px));transition-property:background, color, padding, width, opacity;transition:var(--tct-pill-btn-tween, var(--t-pill-btn-tween, var(--app-tween-1, 0.2s ease)))}:host([disabled]) .btn-close,:host([disabled]) .btn-primary,:host([disabled]) q2-icon{opacity:var(--tct-pill-disabled-opacity, var(--t-pill-disabled-opacity, var(--tct-disabled-opacity, var(--app-disabled-opacity, 0.4))));cursor:not-allowed}.btn-primary{background:var(--comp-btn-background);border-width:var(--comp-pill-btn-border-width);border-color:var(--tct-pill-btn-border-color, var(--t-pill-btn-border-color, var(--t-gray-9, #999999)));padding-inline:var(--comp-btn-padding);padding-right:calc(var(--comp-btn-padding) + var(--comp-close-size));font-size:var(--tct-pill-btn-font-size, var(--t-pill-btn-font-size, var(--app-font-size, 14px)));color:var(--comp-btn-color);display:block;width:100%;text-align:start}.btn-primary:focus,.btn-primary:hover{background:var(--comp-hover-btn-background)}:host(:not(:empty)) .btn-primary,.has-icon .btn-primary{padding-right:calc( var(--tct-pill-icon-gap, var(--t-pill-icon-gap, var(--app-size-1x, 5px))) + var(--comp-close-size) )}.has-options .btn-primary{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:var(--tct-pill-max-width, var(--t-pill-max-width, 200px))}:host([active]) .btn-primary{background:var(--comp-active-btn-background);border-color:var(--comp-active-btn-border-color)}:host([active]) .btn-primary:focus,:host([active]) .btn-primary:hover{background:var(--comp-hover-active-btn-background);border-color:var(--comp-hover-active-btn-border-color)}.btn-close{background:transparent;border-color:transparent;border-width:var(--comp-pill-btn-border-width);width:var(--comp-close-size);height:var(--comp-close-size);padding:0;border:0;display:inline-flex;justify-content:center;align-items:center;position:absolute;right:0;top:50%;transform:translateY(-50%);opacity:0;stroke:var(--comp-btn-color);--tct-icon-stroke-primary:var(--comp-btn-color)}:host(:not(:empty)) .btn-close,.has-icon .btn-close{opacity:1}q2-icon{width:var(--tct-pill-icon-size, var(--t-pill-icon-size, 14px));height:var(--tct-pill-icon-size, var(--t-pill-icon-size, 14px));transition-property:transform;transition:var(--tct-pill-btn-tween, var(--t-pill-btn-tween, var(--app-tween-1, 0.2s ease)))}div.btn-close{pointer-events:none}:host([open]) div.btn-close q2-icon{transform:rotate(180deg)}:host([active]) button.btn-close:focus,:host([active]) button.btn-close:hover{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))));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))))}";
5
+
6
+ const Q2Pill = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.change = createEvent(this, "change", 7);
10
+ this.selectedOptions = [];
11
+ this.scheduledAfterRender = [];
12
+ /// Helpers
13
+ this.determineHasOptions = () => {
14
+ const hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
15
+ this.hasOptions = hasOptions;
16
+ };
17
+ this.clearSelectedOptions = () => {
18
+ this.selectedOptions = [];
19
+ this.active = false;
20
+ this.open = false;
21
+ this.primaryBtn.focus();
22
+ this.change.emit({ value: null, values: [], active: false });
23
+ };
24
+ /// Event Handlers ///
25
+ this.handleClick = (event) => {
26
+ event.stopPropagation();
27
+ if (this.disabled)
28
+ return;
29
+ if (this.hasOptions) {
30
+ this.optionList.toggle();
31
+ }
32
+ else {
33
+ const { value, label } = this;
34
+ const isActive = (this.active = !this.active);
35
+ const values = isActive ? [{ value, display: label }] : [];
36
+ this.selectedOptions = values;
37
+ this.change.emit({
38
+ value: value,
39
+ values,
40
+ active: isActive
41
+ });
42
+ }
43
+ };
44
+ this.handleKeydown = (event) => {
45
+ if (!this.hasOptions || this.disabled)
46
+ return;
47
+ this.optionList.handleExternalKeydown(event);
48
+ };
49
+ this.handleChange = event => {
50
+ if (!this.hasOptions)
51
+ return;
52
+ const { value, values } = event.detail;
53
+ const isActive = !!values.length;
54
+ if (!this.hostElement.onchange) {
55
+ this.selectedOptions = values;
56
+ this.active = isActive;
57
+ }
58
+ this.change.emit({ value: value, values, active: isActive });
59
+ };
60
+ this.handleFocusout = (event) => {
61
+ const relatedTarget = event.relatedTarget;
62
+ if (Array.from(this.hostElement.children).includes(relatedTarget))
63
+ return;
64
+ if (relatedTarget && !(event.relatedTarget instanceof HTMLElement))
65
+ return;
66
+ if (relatedTarget && relatedTarget.closest('.btn-height-wrapper'))
67
+ return;
68
+ this.optionList.open = false;
69
+ };
70
+ this.handleWrapperClick = () => {
71
+ this.primaryBtn.focus();
72
+ this.primaryBtn.click();
73
+ };
74
+ }
75
+ /// LifeCycle Hooks ///
76
+ componentWillLoad() {
77
+ const observer = new MutationObserver(this.determineHasOptions);
78
+ observer.observe(this.hostElement, { childList: true, attributes: true });
79
+ this.mutationObserver = observer;
80
+ }
81
+ componentDidLoad() {
82
+ overrideFocus(this.hostElement);
83
+ }
84
+ componentDidRender() {
85
+ this.scheduledAfterRender.forEach(fn => fn());
86
+ this.scheduledAfterRender = [];
87
+ }
88
+ disconnectedCallback() {
89
+ this.mutationObserver.disconnect();
90
+ this.mutationObserver = null;
91
+ }
92
+ /// Getters ///
93
+ get buttonContent() {
94
+ const { label, selectedOptions, hasOptions } = this;
95
+ if (!hasOptions || selectedOptions.length === 0)
96
+ return label;
97
+ else if (selectedOptions.length === 1)
98
+ return selectedOptions[0].display;
99
+ return loc('tecton.element.pill.activeCount', { count: selectedOptions.length });
100
+ }
101
+ /// Listeners ///
102
+ delegateFocus(event) {
103
+ if (!isEventFromElement(event, this.hostElement))
104
+ return;
105
+ this.primaryBtn.focus();
106
+ }
107
+ optionListStateEvent({ detail: { open } }) {
108
+ this.open = open;
109
+ if (!open)
110
+ this.primaryBtn.focus();
111
+ }
112
+ /// DOM ///
113
+ generateIcon() {
114
+ const { hasOptions, active } = this;
115
+ const isButton = hasOptions && active;
116
+ const TagName = isButton ? 'button' : 'div';
117
+ const iconName = isButton || !hasOptions ? 'close' : 'chevron-down';
118
+ return (h(TagName, { class: "btn-close", onClick: isButton && this.clearSelectedOptions, disabled: isButton && this.disabled, "aria-label": isButton && loc('tecton.element.pill.clearSelection'), type: isButton && 'button' }, h("q2-icon", { type: iconName })));
119
+ }
120
+ render() {
121
+ const { hasOptions, active, open } = this;
122
+ let wrapperClassNames = ['btn-wrapper'];
123
+ if (hasOptions || active)
124
+ wrapperClassNames.push('has-icon');
125
+ if (hasOptions)
126
+ wrapperClassNames.push('has-options');
127
+ return (h(Fragment, null, h("div", { class: wrapperClassNames.join(' ') }, h("div", { class: "btn-height-wrapper", onClick: this.handleWrapperClick, tabIndex: -1 }, 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 ? 'true' : 'false' }, this.buttonContent, !hasOptions && active && (h("span", { class: "sr" }, "(", loc('tecton.element.pill.active'), ")")))), this.generateIcon()), 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 }, h("slot", null)))));
128
+ }
129
+ get hostElement() { return getElement(this); }
130
+ };
131
+ Q2Pill.style = stylesCss;
132
+
133
+ export { Q2Pill as q2_pill };