q2-tecton-elements 1.12.0-alpha.0 → 1.12.2

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 +17 -5
  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 +28 -11
  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 +27 -4
  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 +2 -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 +44 -9
  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 +17 -5
  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 +28 -11
  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-06fff43d.entry.js → p-2afdc922.entry.js} +1 -1
  103. package/dist/q2-tecton-elements/{p-07a5d703.entry.js → p-30bf5f44.entry.js} +1 -1
  104. package/dist/q2-tecton-elements/{p-7e030e92.entry.js → p-34415315.entry.js} +1 -1
  105. package/dist/q2-tecton-elements/p-3c6f73cb.js +1 -0
  106. package/dist/q2-tecton-elements/p-54300d2f.entry.js +1 -0
  107. package/dist/q2-tecton-elements/p-54f0d64e.entry.js +1 -0
  108. package/dist/q2-tecton-elements/p-58d95376.entry.js +1 -0
  109. package/dist/q2-tecton-elements/p-5b906cf1.entry.js +1 -0
  110. package/dist/q2-tecton-elements/p-5effd81a.entry.js +1 -0
  111. package/dist/q2-tecton-elements/p-7ce98c1a.entry.js +1 -0
  112. package/dist/q2-tecton-elements/p-91dba21f.entry.js +1 -0
  113. package/dist/q2-tecton-elements/{p-a6f8d09a.entry.js → p-9a3c37ab.entry.js} +1 -1
  114. package/dist/q2-tecton-elements/{p-75e87cca.entry.js → p-a0248299.entry.js} +1 -1
  115. package/dist/q2-tecton-elements/p-aca8302b.entry.js +1 -0
  116. package/dist/q2-tecton-elements/{p-df182f61.entry.js → p-af202624.entry.js} +1 -1
  117. package/dist/q2-tecton-elements/{p-c5e55b9f.entry.js → p-b9c2c1d3.entry.js} +1 -1
  118. package/dist/q2-tecton-elements/p-c3d68d5c.js +1 -0
  119. package/dist/q2-tecton-elements/{p-bb2e110a.entry.js → p-c5199147.entry.js} +1 -1
  120. package/dist/q2-tecton-elements/{p-843b1ee9.entry.js → p-c5e6f7fa.entry.js} +1 -1
  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-production_release_1.12.x/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-production_release_1.12.x}/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,357 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-c2e53804.js');
6
+ const index$1 = require('./index-773c3eec.js');
7
+
8
+ 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}";
9
+
10
+ const Q2OptionList = class {
11
+ constructor(hostRef) {
12
+ index.registerInstance(this, hostRef);
13
+ this.change = index.createEvent(this, "change", 7);
14
+ this.optionListState = index.createEvent(this, "optionListState", 7);
15
+ this.role = 'listbox';
16
+ this.direction = 'down';
17
+ this.selectedOptions = [];
18
+ this.scheduledAfterRender = [];
19
+ /// Event Handlers ///
20
+ this.keydownHandler = (event, ignoreSelectionEvents) => {
21
+ event.stopPropagation();
22
+ const { activeIndex, customSearch, allOptions } = this;
23
+ const { key, shiftKey } = event;
24
+ let newOption;
25
+ switch (key) {
26
+ case ' ':
27
+ case 'Enter':
28
+ if (ignoreSelectionEvents) {
29
+ this.setDefaultActiveElement();
30
+ break;
31
+ }
32
+ event.preventDefault();
33
+ newOption = allOptions.find(element => element.active);
34
+ if (!newOption || newOption.disabled)
35
+ break;
36
+ this.selectOption(newOption.value);
37
+ break;
38
+ case 'ArrowUp':
39
+ event.preventDefault();
40
+ const isFirstOption = activeIndex === 0;
41
+ if (isFirstOption)
42
+ break;
43
+ if (activeIndex === undefined) {
44
+ this.setDefaultActiveElement();
45
+ }
46
+ else {
47
+ const nextIndex = this.getNextVisibleIndex(-1);
48
+ if (nextIndex === -1)
49
+ break;
50
+ this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
51
+ }
52
+ break;
53
+ case 'ArrowDown':
54
+ event.preventDefault();
55
+ const isLastOption = activeIndex === allOptions.length - 1;
56
+ if (isLastOption)
57
+ break;
58
+ if (activeIndex === undefined) {
59
+ this.setDefaultActiveElement();
60
+ }
61
+ else {
62
+ const nextIndex = this.getNextVisibleIndex(1);
63
+ if (nextIndex === -1)
64
+ break;
65
+ this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
66
+ }
67
+ break;
68
+ case 'Home':
69
+ event.preventDefault();
70
+ this.openDropdownWithActiveElement(0);
71
+ break;
72
+ case 'End':
73
+ event.preventDefault();
74
+ this.openDropdownWithActiveElement(allOptions.length - 1);
75
+ break;
76
+ case 'PageUp':
77
+ event.preventDefault();
78
+ this.openDropdownWithActiveElement(Math.max(activeIndex - 10, 0));
79
+ break;
80
+ case 'PageDown':
81
+ event.preventDefault();
82
+ this.openDropdownWithActiveElement(Math.min(activeIndex + 10, allOptions.length - 1));
83
+ break;
84
+ case 'Tab':
85
+ if (ignoreSelectionEvents)
86
+ break;
87
+ if (shiftKey)
88
+ break;
89
+ newOption = allOptions.find(element => element.active);
90
+ if (!newOption || newOption.disabled)
91
+ return;
92
+ this.selectOption(newOption.value);
93
+ break;
94
+ case 'Esc':
95
+ case 'Escape':
96
+ if (this.noSelect)
97
+ this.setActiveElement(null);
98
+ this.open = false;
99
+ break;
100
+ default:
101
+ if (customSearch)
102
+ break;
103
+ if (!key.match(/^[A-Za-z0-9]$/))
104
+ break;
105
+ // search in non-searchable select: alpha-numeric only
106
+ this.searchAndFocus(key);
107
+ break;
108
+ }
109
+ };
110
+ this.focusoutHandler = (event) => {
111
+ const { relatedTarget } = event;
112
+ const isInDropdown = this.allOptions.includes(relatedTarget);
113
+ const isInLightDom = !isInDropdown && this.hostElement.contains(relatedTarget);
114
+ if (isInDropdown || isInLightDom) {
115
+ event.stopPropagation();
116
+ }
117
+ };
118
+ this.clickHandler = (event) => {
119
+ const target = event.target;
120
+ if (target.localName !== 'q2-option' || target.disabled) {
121
+ return;
122
+ }
123
+ this.selectOption(target.value);
124
+ };
125
+ }
126
+ /// LifeCycle Hooks ///
127
+ componentWillLoad() {
128
+ this.hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
129
+ }
130
+ componentDidLoad() {
131
+ index$1.overrideFocus(this.hostElement);
132
+ this.checkOptions();
133
+ }
134
+ componentDidRender() {
135
+ this.scheduledAfterRender.forEach(fn => fn());
136
+ this.scheduledAfterRender = [];
137
+ }
138
+ /// Getters ///
139
+ get allOptions() {
140
+ return this.getRootSlot(this.hostElement);
141
+ }
142
+ /// Helpers ///
143
+ checkOptions() {
144
+ const { noSelect, type, allOptions } = this;
145
+ if (!noSelect && !type)
146
+ return;
147
+ const optionRole = type === 'menu' ? 'menuitem' : 'option';
148
+ allOptions.forEach(option => {
149
+ if (noSelect)
150
+ option.noSelect = true;
151
+ if (type)
152
+ option.role = optionRole;
153
+ });
154
+ }
155
+ getRootSlot(element) {
156
+ var _a;
157
+ const slot = element.querySelector('slot');
158
+ const assignedElements = (_a = slot === null || slot === void 0 ? void 0 : slot.assignedElements()) !== null && _a !== void 0 ? _a : Array.from(element.children);
159
+ const hasAnotherSlot = !!assignedElements.length && assignedElements[0].tagName === 'SLOT';
160
+ if (hasAnotherSlot) {
161
+ return this.getRootSlot(assignedElements[0]);
162
+ }
163
+ else {
164
+ return assignedElements;
165
+ }
166
+ }
167
+ scrollToActiveOption() {
168
+ const activeOption = this.allOptions[this.activeIndex];
169
+ activeOption === null || activeOption === void 0 ? void 0 : activeOption.scrollIntoView({ block: 'nearest' });
170
+ }
171
+ resizeIframe() {
172
+ var _a, _b;
173
+ return (_b = (_a = window.TectonElements) === null || _a === void 0 ? void 0 : _a.resizeIframe) === null || _b === void 0 ? void 0 : _b.call(_a);
174
+ }
175
+ openDropdownWithActiveElement(activeIndex) {
176
+ if (this.disabled)
177
+ return;
178
+ this.activeIndex = activeIndex;
179
+ this.open = true;
180
+ this.setActiveOption();
181
+ this.setFocusedOption();
182
+ this.scheduledAfterRender.push(() => {
183
+ this.scrollToActiveOption();
184
+ this.resizeIframe();
185
+ });
186
+ }
187
+ getDefaultActiveIndex() {
188
+ const { allOptions } = this;
189
+ const firstSelected = allOptions.findIndex(element => element.selected);
190
+ if (firstSelected > -1)
191
+ return firstSelected;
192
+ const firstEnabled = allOptions.findIndex(element => !element.hidden);
193
+ if (firstEnabled > -1)
194
+ return firstEnabled;
195
+ return 0;
196
+ }
197
+ updateSingleOptionAttrs() {
198
+ var _a, _b;
199
+ const { allOptions, selectedOptions } = this;
200
+ const singleValue = (_b = (_a = selectedOptions[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : undefined;
201
+ allOptions.forEach(element => {
202
+ element.selected = element.value === singleValue;
203
+ });
204
+ }
205
+ updateMultipleOptionAttrs() {
206
+ const { allOptions, selectedOptions } = this;
207
+ const selectedValues = selectedOptions.map(option => option.value);
208
+ allOptions.forEach(element => {
209
+ element.selected = selectedValues.includes(element.value);
210
+ });
211
+ }
212
+ setActiveOption() {
213
+ if (!this.open)
214
+ return;
215
+ const activeIndex = this.activeIndex;
216
+ this.allOptions.forEach((element, elementIndex) => {
217
+ element.active = activeIndex === elementIndex;
218
+ });
219
+ }
220
+ setFocusedOption() {
221
+ const option = this.allOptions[this.activeIndex];
222
+ if (!option)
223
+ return;
224
+ setTimeout(() => {
225
+ option.focus();
226
+ }, 25);
227
+ }
228
+ getNextVisibleIndex(direction) {
229
+ let index = this.activeIndex + direction;
230
+ while (index >= 0 && index <= this.allOptions.length - 1) {
231
+ const { display, visibility } = window.getComputedStyle(this.allOptions[index]);
232
+ if (display !== 'none' && visibility !== 'hidden') {
233
+ return index;
234
+ }
235
+ index = index + direction;
236
+ }
237
+ return -1;
238
+ }
239
+ selectOption(selectedValue) {
240
+ const option = this.allOptions.find(({ value }) => value === selectedValue);
241
+ const valueObject = {
242
+ value: selectedValue,
243
+ display: option.display || option.innerText.trim()
244
+ };
245
+ const { multiple, noSelect } = this;
246
+ let values;
247
+ if (multiple) {
248
+ const { selectedOptions = [] } = this;
249
+ const isAlreadySelected = !!selectedOptions.find(({ value }) => value === selectedValue);
250
+ if (isAlreadySelected) {
251
+ values = selectedOptions.filter(({ value }) => value !== selectedValue);
252
+ }
253
+ else {
254
+ values = [...selectedOptions, valueObject];
255
+ }
256
+ }
257
+ else {
258
+ values = [valueObject];
259
+ }
260
+ if (noSelect)
261
+ this.setActiveElement(null);
262
+ else
263
+ this.selectedOptions = values;
264
+ this.change.emit({ value: selectedValue, values });
265
+ if (multiple)
266
+ return;
267
+ this.open = false;
268
+ }
269
+ adjustActiveOptionAndScroll(numToAdd) {
270
+ this.activeIndex += numToAdd;
271
+ this.setActiveOption();
272
+ this.setFocusedOption();
273
+ this.scrollToActiveOption();
274
+ }
275
+ resetTimer() {
276
+ if (this.searchStringTimer) {
277
+ clearTimeout(this.searchStringTimer);
278
+ }
279
+ this.searchStringTimer = window.setTimeout(() => {
280
+ this.searchString = null;
281
+ }, 2000);
282
+ }
283
+ searchAndFocus(key) {
284
+ this.resetTimer();
285
+ let searchString = this.searchString ? `${this.searchString}${key}` : key;
286
+ searchString = searchString.replace(/[^0-9a-z]/gi, '');
287
+ this.searchString = searchString;
288
+ const searchRegEx = new RegExp(searchString, 'i');
289
+ const foundIndex = this.allOptions.findIndex(option => option.value === searchString || option.textContent.match(searchRegEx));
290
+ if (foundIndex === -1)
291
+ return;
292
+ this.setActiveElement(foundIndex);
293
+ }
294
+ /// Watchers ///
295
+ selectedOptionsUpdated() {
296
+ if (this.multiple) {
297
+ this.updateMultipleOptionAttrs();
298
+ }
299
+ else {
300
+ this.updateSingleOptionAttrs();
301
+ }
302
+ }
303
+ openChanged(newValue) {
304
+ this.optionListState.emit({ open: newValue });
305
+ }
306
+ /// Listeners ///
307
+ delegateFocus(event) {
308
+ if (!index$1.isEventFromElement(event, this.hostElement))
309
+ return;
310
+ this.open = true;
311
+ this.setDefaultActiveElement();
312
+ }
313
+ handleClick(event) {
314
+ event.stopPropagation();
315
+ }
316
+ /// Public Methods ///
317
+ toggle() {
318
+ const isOpen = !this.open;
319
+ this.open = isOpen;
320
+ }
321
+ setDefaultActiveElement() {
322
+ this.activeIndex = this.getDefaultActiveIndex();
323
+ this.setActiveOption();
324
+ this.setFocusedOption();
325
+ }
326
+ setActiveElement(index) {
327
+ this.activeIndex = index;
328
+ this.setActiveOption();
329
+ this.setFocusedOption();
330
+ }
331
+ handleExternalKeydown(event) {
332
+ const keysThatTriggerOpen = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp', 'Home', 'End'];
333
+ if (keysThatTriggerOpen.includes(event.key)) {
334
+ this.open = true;
335
+ }
336
+ const keysThatTriggerDefault = ['ArrowDown', 'ArrowUp'];
337
+ if (keysThatTriggerDefault.includes(event.key)) {
338
+ event.preventDefault();
339
+ this.setDefaultActiveElement();
340
+ }
341
+ else {
342
+ this.keydownHandler(event, true);
343
+ }
344
+ }
345
+ /// DOM ///
346
+ render() {
347
+ return (index.h(index.Host, null, index.h("div", { class: "content", ref: el => (this.contentElement = el), onFocusout: this.focusoutHandler }, index.h("div", { class: "options", role: this.type || 'listbox', onKeyDown: this.keydownHandler, onClick: this.clickHandler }, index.h("slot", null)))));
348
+ }
349
+ get hostElement() { return index.getElement(this); }
350
+ static get watchers() { return {
351
+ "selectedOptions": ["selectedOptionsUpdated"],
352
+ "open": ["openChanged"]
353
+ }; }
354
+ };
355
+ Q2OptionList.style = stylesCss;
356
+
357
+ exports.q2_option_list = Q2OptionList;
@@ -4,27 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-c2e53804.js');
6
6
 
7
- 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}";
7
+ 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}";
8
8
 
9
9
  const Q2Option = class {
10
10
  constructor(hostRef) {
11
11
  index.registerInstance(this, hostRef);
12
- this.click = index.createEvent(this, "click", 7);
13
12
  this.role = 'option';
14
13
  this.tabindex = '-1';
15
14
  this._multiSelectHidden = false;
16
- this.onClick = (event) => {
17
- event.stopImmediatePropagation();
18
- const { disabled, disabledGroup } = this;
19
- if (disabled || disabledGroup)
20
- return;
21
- this.click.emit();
22
- };
23
15
  }
24
16
  render() {
25
17
  const { disabled, disabledGroup, selected, _multiSelectHidden } = this;
26
18
  const isDisabled = disabled || disabledGroup;
27
- return (index.h(index.Host, { "aria-disabled": isDisabled ? 'true' : undefined, "aria-selected": selected ? 'true' : undefined, "aria-hidden": _multiSelectHidden ? 'true' : undefined }, this.selected && index.h("q2-icon", { type: "checkmark" }), index.h("div", { class: "content", onClick: this.onClick }, index.h("slot", null))));
19
+ return (index.h(index.Host, { "aria-disabled": isDisabled ? 'true' : undefined, "aria-selected": selected ? 'true' : undefined, "aria-hidden": _multiSelectHidden ? 'true' : undefined }, this.selected && index.h("q2-icon", { type: "checkmark" }), index.h("div", { class: "content" }, index.h("slot", null))));
28
20
  }
29
21
  get hostElement() { return index.getElement(this); }
30
22
  };
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-c2e53804.js');
6
+ const index$1 = require('./index-773c3eec.js');
7
+
8
+ 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}";
9
+
10
+ const Q2Pagination = class {
11
+ constructor(hostRef) {
12
+ index.registerInstance(this, hostRef);
13
+ this.change = index.createEvent(this, "change", 7);
14
+ this.handlePageChange = (page) => {
15
+ const { totalPages, inputField } = this;
16
+ if (page < 1) {
17
+ page = 1;
18
+ }
19
+ else if (page > totalPages) {
20
+ page = totalPages;
21
+ }
22
+ if (inputField.value !== `${page}`)
23
+ inputField.value = `${page}`;
24
+ if (!this.hostElement.onchange) {
25
+ this.page = page;
26
+ }
27
+ this.change.emit({ value: page });
28
+ };
29
+ }
30
+ ////////// LIFECYCLE HOOKS ////////
31
+ componentDidLoad() {
32
+ if (this.recordsOnly || this.pagesOnly)
33
+ return;
34
+ this.containerWidth = this.containerElement.clientWidth;
35
+ this.resizeObserver = new ResizeObserver(() => this.checkSize());
36
+ this.resizeObserver.observe(this.hostElement);
37
+ index$1.overrideFocus(this.hostElement);
38
+ }
39
+ disconnectedCallback() {
40
+ var _a;
41
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
42
+ }
43
+ onHostElementFocus(event) {
44
+ var _a;
45
+ if (!index$1.isEventFromElement(event, this.hostElement))
46
+ return;
47
+ const { isFullViewHidden, containerElement, inputField } = this;
48
+ if (isFullViewHidden) {
49
+ (_a = containerElement.querySelector('q2-btn:not([disabled])')) === null || _a === void 0 ? void 0 : _a.focus();
50
+ }
51
+ else {
52
+ inputField.focus();
53
+ }
54
+ }
55
+ get isFullViewHidden() {
56
+ return this.isSmall || this.recordsOnly || this.pagesOnly;
57
+ }
58
+ get pageWithDefault() {
59
+ return this.page || 1;
60
+ }
61
+ get perPageWithDefault() {
62
+ return this.perPage || 10;
63
+ }
64
+ get totalWithDefault() {
65
+ return this.total || 0;
66
+ }
67
+ get recordTypeWithDefault() {
68
+ return this.recordType || index$1.loc('tecton.element.pagination.defaultRecordType');
69
+ }
70
+ get currentRange() {
71
+ const { perPageWithDefault: perPage, totalWithDefault: total, pageWithDefault: page } = this;
72
+ const start = (page - 1) * perPage + 1;
73
+ const end = Math.min(page * perPage, total);
74
+ return `${start} - ${end}`;
75
+ }
76
+ get totalPages() {
77
+ const { pagesOnly, totalWithDefault: total, perPageWithDefault: perPage, pages } = this;
78
+ if (pagesOnly && pages && !isNaN(parseInt(`${pages}`)))
79
+ return pages;
80
+ return Math.ceil(total / perPage);
81
+ }
82
+ checkSize() {
83
+ const { hostElement, containerElement } = this;
84
+ const isOverflowing = this.containerWidth > hostElement.clientWidth;
85
+ this.isSmall = isOverflowing;
86
+ if (isOverflowing)
87
+ return;
88
+ index$1.nextPaint(() => {
89
+ const containerWidthHasNotChanged = this.containerWidth === containerElement.clientWidth;
90
+ if (containerWidthHasNotChanged)
91
+ return;
92
+ this.containerWidth = containerElement.clientWidth;
93
+ this.checkSize();
94
+ });
95
+ }
96
+ ////////// OBSERVERS //////////
97
+ render() {
98
+ const { pagesOnly, isFullViewHidden, recordTypeWithDefault: recordType, totalPages, totalWithDefault: total, pageWithDefault: page, currentRange } = this;
99
+ const onFirstPage = page === 1;
100
+ const onLastPage = page === totalPages;
101
+ return (index.h("nav", { class: "container", ref: el => (this.containerElement = el), "aria-label": index$1.loc('tecton.element.pagination.title') }, index.h("div", { class: "description", "test-id": "description" }, pagesOnly
102
+ ? index$1.loc('tecton.element.pagination.pages', {
103
+ current: page,
104
+ total: totalPages
105
+ })
106
+ : index$1.loc('tecton.element.pagination.description', {
107
+ range: currentRange,
108
+ recordType: recordType.toLowerCase(),
109
+ total: total.toLocaleString()
110
+ })), index.h("div", { class: "btn-group" }, index.h("q2-btn", { label: "tecton.element.pagination.goToFirstPage", disabled: onFirstPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(1), "test-id": "firstPageBtn", "hide-label": true }, index.h("q2-icon", { type: "chevron-double-left" })), index.h("q2-btn", { label: index$1.loc('tecton.element.pagination.goToPage', [page - 1]), disabled: onFirstPage, onClick: () => this.handlePageChange(page - 1), "test-id": "prevPageBtn", "hide-label": true }, index.h("q2-icon", { type: "chevron-left" }))), index.h("div", { class: "controls", hidden: isFullViewHidden, "test-id": "controls" }, index.h("span", { "aria-hidden": "true" }, index$1.loc('tecton.element.pagination.page')), index.h("div", { class: "input-wrapper", onClick: () => this.inputField.dispatchEvent(new FocusEvent('focus')) }, index.h("q2-input", { type: "number", value: `${page}`, min: 1, max: this.totalPages, hideLabel: true, optional: true, label: `${index$1.loc('tecton.element.pagination.page')} (${index$1.loc('tecton.element.pagination.ofPages', [
111
+ totalPages.toLocaleString()
112
+ ])})`, onChange: event => this.handlePageChange(event.detail.value), "test-id": "pageInput", current: "page", ref: el => (this.inputField = el) })), index.h("span", { "aria-hidden": "true" }, index$1.loc('tecton.element.pagination.ofPages', [totalPages.toLocaleString()]))), index.h("div", { class: "btn-group" }, index.h("q2-btn", { label: index$1.loc('tecton.element.pagination.goToPage', [page + 1]), disabled: onLastPage, onClick: () => this.handlePageChange(page + 1), "test-id": "nextPageBtn", "hide-label": true }, index.h("q2-icon", { type: "chevron-right" })), index.h("q2-btn", { label: "tecton.element.pagination.goToLastPage", disabled: onLastPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(totalPages), "test-id": "lastPageBtn", "hide-label": true }, index.h("q2-icon", { type: "chevron-double-right" })))));
113
+ }
114
+ get hostElement() { return index.getElement(this); }
115
+ };
116
+ Q2Pagination.style = stylesCss;
117
+
118
+ exports.q2_pagination = Q2Pagination;
@@ -0,0 +1,137 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-c2e53804.js');
6
+ const index$1 = require('./index-773c3eec.js');
7
+
8
+ 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))))}";
9
+
10
+ const Q2Pill = class {
11
+ constructor(hostRef) {
12
+ index.registerInstance(this, hostRef);
13
+ this.change = index.createEvent(this, "change", 7);
14
+ this.selectedOptions = [];
15
+ this.scheduledAfterRender = [];
16
+ /// Helpers
17
+ this.determineHasOptions = () => {
18
+ const hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
19
+ this.hasOptions = hasOptions;
20
+ };
21
+ this.clearSelectedOptions = () => {
22
+ this.selectedOptions = [];
23
+ this.active = false;
24
+ this.open = false;
25
+ this.primaryBtn.focus();
26
+ this.change.emit({ value: null, values: [], active: false });
27
+ };
28
+ /// Event Handlers ///
29
+ this.handleClick = (event) => {
30
+ event.stopPropagation();
31
+ if (this.disabled)
32
+ return;
33
+ if (this.hasOptions) {
34
+ this.optionList.toggle();
35
+ }
36
+ else {
37
+ const { value, label } = this;
38
+ const isActive = (this.active = !this.active);
39
+ const values = isActive ? [{ value, display: label }] : [];
40
+ this.selectedOptions = values;
41
+ this.change.emit({
42
+ value: value,
43
+ values,
44
+ active: isActive
45
+ });
46
+ }
47
+ };
48
+ this.handleKeydown = (event) => {
49
+ if (!this.hasOptions || this.disabled)
50
+ return;
51
+ this.optionList.handleExternalKeydown(event);
52
+ };
53
+ this.handleChange = event => {
54
+ if (!this.hasOptions)
55
+ return;
56
+ const { value, values } = event.detail;
57
+ const isActive = !!values.length;
58
+ if (!this.hostElement.onchange) {
59
+ this.selectedOptions = values;
60
+ this.active = isActive;
61
+ }
62
+ this.change.emit({ value: value, values, active: isActive });
63
+ };
64
+ this.handleFocusout = (event) => {
65
+ const relatedTarget = event.relatedTarget;
66
+ if (Array.from(this.hostElement.children).includes(relatedTarget))
67
+ return;
68
+ if (relatedTarget && !(event.relatedTarget instanceof HTMLElement))
69
+ return;
70
+ if (relatedTarget && relatedTarget.closest('.btn-height-wrapper'))
71
+ return;
72
+ this.optionList.open = false;
73
+ };
74
+ this.handleWrapperClick = () => {
75
+ this.primaryBtn.focus();
76
+ this.primaryBtn.click();
77
+ };
78
+ }
79
+ /// LifeCycle Hooks ///
80
+ componentWillLoad() {
81
+ const observer = new MutationObserver(this.determineHasOptions);
82
+ observer.observe(this.hostElement, { childList: true, attributes: true });
83
+ this.mutationObserver = observer;
84
+ }
85
+ componentDidLoad() {
86
+ index$1.overrideFocus(this.hostElement);
87
+ }
88
+ componentDidRender() {
89
+ this.scheduledAfterRender.forEach(fn => fn());
90
+ this.scheduledAfterRender = [];
91
+ }
92
+ disconnectedCallback() {
93
+ this.mutationObserver.disconnect();
94
+ this.mutationObserver = null;
95
+ }
96
+ /// Getters ///
97
+ get buttonContent() {
98
+ const { label, selectedOptions, hasOptions } = this;
99
+ if (!hasOptions || selectedOptions.length === 0)
100
+ return label;
101
+ else if (selectedOptions.length === 1)
102
+ return selectedOptions[0].display;
103
+ return index$1.loc('tecton.element.pill.activeCount', { count: selectedOptions.length });
104
+ }
105
+ /// Listeners ///
106
+ delegateFocus(event) {
107
+ if (!index$1.isEventFromElement(event, this.hostElement))
108
+ return;
109
+ this.primaryBtn.focus();
110
+ }
111
+ optionListStateEvent({ detail: { open } }) {
112
+ this.open = open;
113
+ if (!open)
114
+ this.primaryBtn.focus();
115
+ }
116
+ /// DOM ///
117
+ generateIcon() {
118
+ const { hasOptions, active } = this;
119
+ const isButton = hasOptions && active;
120
+ const TagName = isButton ? 'button' : 'div';
121
+ const iconName = isButton || !hasOptions ? 'close' : 'chevron-down';
122
+ return (index.h(TagName, { class: "btn-close", onClick: isButton && this.clearSelectedOptions, disabled: isButton && this.disabled, "aria-label": isButton && index$1.loc('tecton.element.pill.clearSelection'), type: isButton && 'button' }, index.h("q2-icon", { type: iconName })));
123
+ }
124
+ render() {
125
+ const { hasOptions, active, open } = this;
126
+ let wrapperClassNames = ['btn-wrapper'];
127
+ if (hasOptions || active)
128
+ wrapperClassNames.push('has-icon');
129
+ if (hasOptions)
130
+ wrapperClassNames.push('has-options');
131
+ return (index.h(index.Fragment, null, index.h("div", { class: wrapperClassNames.join(' ') }, index.h("div", { class: "btn-height-wrapper", onClick: this.handleWrapperClick, tabIndex: -1 }, index.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 && (index.h("span", { class: "sr" }, "(", index$1.loc('tecton.element.pill.active'), ")")))), this.generateIcon()), this.hasOptions && (index.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 }, index.h("slot", null)))));
132
+ }
133
+ get hostElement() { return index.getElement(this); }
134
+ };
135
+ Q2Pill.style = stylesCss;
136
+
137
+ exports.q2_pill = Q2Pill;