q2-tecton-elements 1.26.0 → 1.27.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 (188) hide show
  1. package/dist/cjs/{index-d62f5a7e.js → index-ffd19146.js} +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/q2-action-sheet.cjs.entry.js +1 -1
  4. package/dist/cjs/q2-avatar.cjs.entry.js +1 -1
  5. package/dist/cjs/q2-badge_2.cjs.entry.js +4 -4
  6. package/dist/cjs/q2-btn_2.cjs.entry.js +7 -5
  7. package/dist/cjs/q2-calendar.cjs.entry.js +3 -3
  8. package/dist/cjs/q2-card.cjs.entry.js +1 -1
  9. package/dist/cjs/q2-carousel-pane.cjs.entry.js +1 -1
  10. package/dist/cjs/q2-carousel.cjs.entry.js +1 -1
  11. package/dist/cjs/q2-chart-area.cjs.entry.js +1 -1
  12. package/dist/cjs/q2-chart-bar.cjs.entry.js +1 -1
  13. package/dist/cjs/q2-chart-donut.cjs.entry.js +1 -1
  14. package/dist/cjs/q2-checkbox-group.cjs.entry.js +6 -5
  15. package/dist/cjs/q2-checkbox.cjs.entry.js +3 -3
  16. package/dist/cjs/q2-dropdown-item.cjs.entry.js +1 -1
  17. package/dist/cjs/q2-dropdown.cjs.entry.js +2 -2
  18. package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
  19. package/dist/cjs/q2-icon.cjs.entry.js +1 -1
  20. package/dist/cjs/q2-loc.cjs.entry.js +1 -1
  21. package/dist/cjs/q2-message.cjs.entry.js +2 -2
  22. package/dist/cjs/q2-month-picker.cjs.entry.js +1 -1
  23. package/dist/cjs/q2-optgroup_2.cjs.entry.js +2 -2
  24. package/dist/cjs/q2-option-list_2.cjs.entry.js +66 -25
  25. package/dist/cjs/q2-pagination.cjs.entry.js +18 -16
  26. package/dist/cjs/q2-pill.cjs.entry.js +82 -14
  27. package/dist/cjs/q2-radio-group.cjs.entry.js +1 -1
  28. package/dist/cjs/q2-radio.cjs.entry.js +2 -2
  29. package/dist/cjs/q2-section.cjs.entry.js +1 -1
  30. package/dist/cjs/q2-select.cjs.entry.js +24 -19
  31. package/dist/cjs/q2-stepper-pane.cjs.entry.js +1 -1
  32. package/dist/cjs/q2-stepper-vertical.cjs.entry.js +1 -1
  33. package/dist/cjs/q2-stepper.cjs.entry.js +1 -1
  34. package/dist/cjs/q2-tab-container.cjs.entry.js +1 -1
  35. package/dist/cjs/q2-tag.cjs.entry.js +11 -4
  36. package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
  37. package/dist/cjs/q2-textarea.cjs.entry.js +1 -1
  38. package/dist/cjs/q2-tooltip.cjs.entry.js +1 -1
  39. package/dist/collection/components/q2-avatar/styles.css +22 -14
  40. package/dist/collection/components/q2-btn/index.js +22 -3
  41. package/dist/collection/components/q2-btn/styles.css +26 -11
  42. package/dist/collection/components/q2-calendar/index.js +1 -1
  43. package/dist/collection/components/q2-calendar/styles.css +7 -1
  44. package/dist/collection/components/q2-carousel-pane/index.js +15 -6
  45. package/dist/collection/components/q2-checkbox/index.js +6 -3
  46. package/dist/collection/components/q2-checkbox/styles.css +1 -0
  47. package/dist/collection/components/q2-checkbox-group/index.js +5 -4
  48. package/dist/collection/components/q2-dropdown/index.js +1 -1
  49. package/dist/collection/components/q2-input/index.js +6 -6
  50. package/dist/collection/components/q2-input/styles.css +4 -0
  51. package/dist/collection/components/q2-message/index.js +1 -1
  52. package/dist/collection/components/q2-option/index.js +21 -9
  53. package/dist/collection/components/q2-option-list/index.js +55 -14
  54. package/dist/collection/components/q2-pagination/index.js +16 -14
  55. package/dist/collection/components/q2-pagination/styles.css +5 -0
  56. package/dist/collection/components/q2-pill/index.js +84 -14
  57. package/dist/collection/components/q2-popover/index.js +10 -10
  58. package/dist/collection/components/q2-radio/index.js +20 -8
  59. package/dist/collection/components/q2-radio/styles.css +2 -0
  60. package/dist/collection/components/q2-select/index.js +40 -17
  61. package/dist/collection/components/q2-select/styles.css +41 -3
  62. package/dist/collection/components/q2-stepper/index.js +5 -2
  63. package/dist/collection/components/q2-stepper-pane/index.js +5 -2
  64. package/dist/collection/components/q2-tab-pane/index.js +20 -8
  65. package/dist/collection/components/q2-tag/index.js +10 -3
  66. package/dist/collection/utils/index.js +1 -1
  67. package/dist/components/index10.js +1 -1
  68. package/dist/components/index12.js +1 -1
  69. package/dist/components/index13.js +55 -14
  70. package/dist/components/index14.js +10 -10
  71. package/dist/components/index15.js +2 -2
  72. package/dist/components/index3.js +1 -1
  73. package/dist/components/index5.js +7 -4
  74. package/dist/components/index8.js +4 -4
  75. package/dist/components/q2-calendar.js +2 -2
  76. package/dist/components/q2-checkbox-group.js +5 -4
  77. package/dist/components/q2-checkbox.js +2 -2
  78. package/dist/components/q2-dropdown.js +1 -1
  79. package/dist/components/q2-pagination.js +18 -16
  80. package/dist/components/q2-pill.js +82 -14
  81. package/dist/components/q2-radio.js +1 -1
  82. package/dist/components/q2-select.js +25 -19
  83. package/dist/components/q2-tag.js +10 -3
  84. package/dist/docs.json +145 -46
  85. package/dist/esm/{index-5040cd84.js → index-a0cc60e3.js} +2 -2
  86. package/dist/esm/loader.js +1 -1
  87. package/dist/esm/q2-action-sheet.entry.js +1 -1
  88. package/dist/esm/q2-avatar.entry.js +1 -1
  89. package/dist/esm/q2-badge_2.entry.js +4 -4
  90. package/dist/esm/q2-btn_2.entry.js +7 -5
  91. package/dist/esm/q2-calendar.entry.js +3 -3
  92. package/dist/esm/q2-card.entry.js +1 -1
  93. package/dist/esm/q2-carousel-pane.entry.js +1 -1
  94. package/dist/esm/q2-carousel.entry.js +1 -1
  95. package/dist/esm/q2-chart-area.entry.js +1 -1
  96. package/dist/esm/q2-chart-bar.entry.js +1 -1
  97. package/dist/esm/q2-chart-donut.entry.js +1 -1
  98. package/dist/esm/q2-checkbox-group.entry.js +6 -5
  99. package/dist/esm/q2-checkbox.entry.js +3 -3
  100. package/dist/esm/q2-dropdown-item.entry.js +1 -1
  101. package/dist/esm/q2-dropdown.entry.js +2 -2
  102. package/dist/esm/q2-editable-field.entry.js +1 -1
  103. package/dist/esm/q2-icon.entry.js +1 -1
  104. package/dist/esm/q2-loc.entry.js +1 -1
  105. package/dist/esm/q2-message.entry.js +2 -2
  106. package/dist/esm/q2-month-picker.entry.js +1 -1
  107. package/dist/esm/q2-optgroup_2.entry.js +2 -2
  108. package/dist/esm/q2-option-list_2.entry.js +66 -25
  109. package/dist/esm/q2-pagination.entry.js +18 -16
  110. package/dist/esm/q2-pill.entry.js +82 -14
  111. package/dist/esm/q2-radio-group.entry.js +1 -1
  112. package/dist/esm/q2-radio.entry.js +2 -2
  113. package/dist/esm/q2-section.entry.js +1 -1
  114. package/dist/esm/q2-select.entry.js +24 -19
  115. package/dist/esm/q2-stepper-pane.entry.js +1 -1
  116. package/dist/esm/q2-stepper-vertical.entry.js +1 -1
  117. package/dist/esm/q2-stepper.entry.js +1 -1
  118. package/dist/esm/q2-tab-container.entry.js +1 -1
  119. package/dist/esm/q2-tag.entry.js +11 -4
  120. package/dist/esm/q2-tecton-elements.js +1 -1
  121. package/dist/esm/q2-textarea.entry.js +1 -1
  122. package/dist/esm/q2-tooltip.entry.js +1 -1
  123. package/dist/q2-tecton-elements/p-04b9a7ee.entry.js +1 -0
  124. package/dist/q2-tecton-elements/{p-c506314d.entry.js → p-05bdc0aa.entry.js} +1 -1
  125. package/dist/q2-tecton-elements/{p-f5c9ef75.entry.js → p-0b8943da.entry.js} +1 -1
  126. package/dist/q2-tecton-elements/{p-ece7a1ca.entry.js → p-12e65423.entry.js} +1 -1
  127. package/dist/q2-tecton-elements/{p-f3096cce.entry.js → p-1d28c600.entry.js} +1 -1
  128. package/dist/q2-tecton-elements/{p-839ef27d.js → p-2453cd92.js} +1 -1
  129. package/dist/q2-tecton-elements/{p-a1f91d8c.entry.js → p-256e5161.entry.js} +1 -1
  130. package/dist/q2-tecton-elements/{p-5878b8bd.entry.js → p-25ea01d3.entry.js} +1 -1
  131. package/dist/q2-tecton-elements/p-2b8a8981.entry.js +1 -0
  132. package/dist/q2-tecton-elements/p-396fd275.entry.js +1 -0
  133. package/dist/q2-tecton-elements/p-3dca7465.entry.js +1 -0
  134. package/dist/q2-tecton-elements/p-414ca427.entry.js +1 -0
  135. package/dist/q2-tecton-elements/p-521c9085.entry.js +1 -0
  136. package/dist/q2-tecton-elements/{p-bfaff58b.entry.js → p-5a670d93.entry.js} +1 -1
  137. package/dist/q2-tecton-elements/p-72374b8e.entry.js +1 -0
  138. package/dist/q2-tecton-elements/p-8545c3cb.entry.js +1 -0
  139. package/dist/q2-tecton-elements/p-85e780b2.entry.js +1 -0
  140. package/dist/q2-tecton-elements/{p-18808c27.entry.js → p-869e899c.entry.js} +1 -1
  141. package/dist/q2-tecton-elements/p-8e652d59.entry.js +1 -0
  142. package/dist/q2-tecton-elements/{p-74ac19cd.entry.js → p-9292bd80.entry.js} +1 -1
  143. package/dist/q2-tecton-elements/{p-fbe8b4c0.entry.js → p-9367dc29.entry.js} +1 -1
  144. package/dist/q2-tecton-elements/{p-bc8a507b.entry.js → p-949fa312.entry.js} +1 -1
  145. package/dist/q2-tecton-elements/{p-a8258fb1.entry.js → p-a298cbfb.entry.js} +1 -1
  146. package/dist/q2-tecton-elements/p-aae8b9fc.entry.js +1 -0
  147. package/dist/q2-tecton-elements/{p-bea1fda1.entry.js → p-ac6dd5b1.entry.js} +1 -1
  148. package/dist/q2-tecton-elements/{p-8b5639a1.entry.js → p-bafb5e70.entry.js} +1 -1
  149. package/dist/q2-tecton-elements/{p-a411f2f3.entry.js → p-be0d3bfe.entry.js} +1 -1
  150. package/dist/q2-tecton-elements/{p-a7679912.entry.js → p-ce67d77a.entry.js} +1 -1
  151. package/dist/q2-tecton-elements/{p-1cc42a02.entry.js → p-d06d752f.entry.js} +1 -1
  152. package/dist/q2-tecton-elements/{p-7b124d8c.entry.js → p-d69cb7d1.entry.js} +1 -1
  153. package/dist/q2-tecton-elements/{p-bda877fe.entry.js → p-edcf49fd.entry.js} +1 -1
  154. package/dist/q2-tecton-elements/{p-8954cc63.entry.js → p-ef657f8f.entry.js} +1 -1
  155. package/dist/q2-tecton-elements/{p-0cbad3bc.entry.js → p-f3e4bb52.entry.js} +1 -1
  156. package/dist/q2-tecton-elements/{p-7d35c1a1.entry.js → p-fb768d19.entry.js} +1 -1
  157. package/dist/q2-tecton-elements/{p-87cecc80.entry.js → p-fcad1609.entry.js} +1 -1
  158. package/dist/q2-tecton-elements/{p-7eca74d4.entry.js → p-fe3625ad.entry.js} +1 -1
  159. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
  160. package/dist/test/helpers.js +1 -1
  161. package/dist/types/components/q2-btn/index.d.ts +2 -0
  162. package/dist/types/components/q2-carousel-pane/index.d.ts +12 -0
  163. package/dist/types/components/q2-checkbox/index.d.ts +4 -0
  164. package/dist/types/components/q2-checkbox-group/index.d.ts +1 -1
  165. package/dist/types/components/q2-input/index.d.ts +1 -1
  166. package/dist/types/components/q2-option/index.d.ts +16 -0
  167. package/dist/types/components/q2-option-list/index.d.ts +6 -0
  168. package/dist/types/components/q2-pagination/index.d.ts +1 -1
  169. package/dist/types/components/q2-pill/index.d.ts +6 -2
  170. package/dist/types/components/q2-radio/index.d.ts +16 -0
  171. package/dist/types/components/q2-select/index.d.ts +3 -2
  172. package/dist/types/components/q2-stepper/index.d.ts +4 -0
  173. package/dist/types/components/q2-stepper-pane/index.d.ts +4 -0
  174. package/dist/types/components/q2-tab-pane/index.d.ts +16 -0
  175. package/dist/types/components/q2-tag/index.d.ts +1 -1
  176. package/dist/types/components.d.ts +148 -0
  177. package/package.json +3 -3
  178. package/dist/q2-tecton-elements/p-09639e95.entry.js +0 -1
  179. package/dist/q2-tecton-elements/p-0b82891e.entry.js +0 -1
  180. package/dist/q2-tecton-elements/p-224d3c31.entry.js +0 -1
  181. package/dist/q2-tecton-elements/p-4734a577.entry.js +0 -1
  182. package/dist/q2-tecton-elements/p-55d192b3.entry.js +0 -1
  183. package/dist/q2-tecton-elements/p-721d0aee.entry.js +0 -1
  184. package/dist/q2-tecton-elements/p-73643653.entry.js +0 -1
  185. package/dist/q2-tecton-elements/p-8d703466.entry.js +0 -1
  186. package/dist/q2-tecton-elements/p-aafb9537.entry.js +0 -1
  187. package/dist/q2-tecton-elements/p-b8420bfe.entry.js +0 -1
  188. package/dist/q2-tecton-elements/p-e4aa271e.entry.js +0 -1
@@ -196,8 +196,12 @@ label {
196
196
  white-space: nowrap;
197
197
  overflow: hidden;
198
198
  text-overflow: ellipsis;
199
+ display: block;
199
200
  }
200
201
 
202
+ .custom-display-container {
203
+ max-width: 100%;
204
+ }
201
205
  .has-custom-display .custom-display-container {
202
206
  --comp-default-padding: var(--app-scale-2x, 10px) var(--app-scale-2x, 10px) var(--app-scale-3x, 15px);
203
207
  padding: var(--tct-input-padding, var(--t-input-padding, var(--comp-default-padding)));
@@ -32,7 +32,7 @@ export class Q2Message {
32
32
  const addAriaHiddenForAriaLive = isFirefox && this.presentToggle;
33
33
  const addDivForAriaLive = !isFirefox && this.presentToggle;
34
34
  const { description } = this;
35
- return (h("div", { tabindex: "-1", class: "message", role: description ? undefined : 'alert', "aria-live": description ? undefined : 'assertive', "aria-atomic": description ? undefined : 'true', "aria-relevant": description ? undefined : 'all' }, this.appearance === 'standard' ? generateIcon(this.type) : '', addDivForAriaLive && h("div", { class: "sr" }), h("div", { class: "message-content", "aria-hidden": addAriaHiddenForAriaLive ? 'true' : undefined }, h("slot", null))));
35
+ return (h("div", { tabindex: "-1", class: "message", role: description ? undefined : 'alert', "aria-live": description ? undefined : 'assertive', "aria-atomic": description ? undefined : 'true', "aria-relevant": description ? undefined : 'all', "test-id": "messageContainer" }, this.appearance === 'standard' ? generateIcon(this.type) : '', addDivForAriaLive && h("div", { class: "sr" }), h("div", { class: "message-content", "aria-hidden": addAriaHiddenForAriaLive ? 'true' : undefined }, h("slot", null))));
36
36
  }
37
37
  static get is() { return "q2-message"; }
38
38
  static get encapsulation() { return "shadow"; }
@@ -23,7 +23,7 @@ export class Q2Option {
23
23
  render() {
24
24
  const { disabled, disabledGroup, selected, _multiSelectHidden } = this;
25
25
  const isDisabled = disabled || disabledGroup;
26
- return (h(Host, { tabindex: "-1", "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))));
26
+ return (h(Host, { tabindex: "-1", "aria-disabled": isDisabled ? 'true' : undefined, "aria-selected": `${!!selected}`, "aria-hidden": _multiSelectHidden ? 'true' : undefined }, this.selected && h("q2-icon", { type: "checkmark" }), h("div", { class: "content" }, h("slot", null))));
27
27
  }
28
28
  static get is() { return "q2-option"; }
29
29
  static get encapsulation() { return "shadow"; }
@@ -50,8 +50,11 @@ export class Q2Option {
50
50
  "required": false,
51
51
  "optional": false,
52
52
  "docs": {
53
- "tags": [],
54
- "text": ""
53
+ "tags": [{
54
+ "name": "private",
55
+ "text": undefined
56
+ }],
57
+ "text": "Used by q2-option-list to set a role on the option"
55
58
  },
56
59
  "attribute": "role",
57
60
  "reflect": true,
@@ -119,8 +122,11 @@ export class Q2Option {
119
122
  "required": false,
120
123
  "optional": false,
121
124
  "docs": {
122
- "tags": [],
123
- "text": ""
125
+ "tags": [{
126
+ "name": "private",
127
+ "text": undefined
128
+ }],
129
+ "text": "Used by q2-radio-group to disable all options in the group"
124
130
  },
125
131
  "attribute": "disabled-group",
126
132
  "reflect": true
@@ -136,8 +142,11 @@ export class Q2Option {
136
142
  "required": false,
137
143
  "optional": false,
138
144
  "docs": {
139
- "tags": [],
140
- "text": ""
145
+ "tags": [{
146
+ "name": "private",
147
+ "text": undefined
148
+ }],
149
+ "text": "Used by q2-option-list to indicate the option is selected"
141
150
  },
142
151
  "attribute": "selected",
143
152
  "reflect": true
@@ -187,8 +196,11 @@ export class Q2Option {
187
196
  "required": false,
188
197
  "optional": false,
189
198
  "docs": {
190
- "tags": [],
191
- "text": ""
199
+ "tags": [{
200
+ "name": "private",
201
+ "text": undefined
202
+ }],
203
+ "text": "Used by q2-option-list to indicate the option is active"
192
204
  },
193
205
  "attribute": "active",
194
206
  "reflect": true
@@ -3,6 +3,56 @@ import { isEventFromElement, nextPaint, overrideFocus, waitForNextPaint } from '
3
3
  export class Q2OptionList {
4
4
  constructor() {
5
5
  this.scheduledAfterRender = [];
6
+ this.keyStore = {
7
+ queue: [],
8
+ lastPressedAt: new Date(),
9
+ };
10
+ this.searchAndFocus = (keyValue, shouldSelect) => {
11
+ // pseudo search in non-searchable select
12
+ const reorder = () => {
13
+ this.pivotIndex = this.pivotIndex === undefined ? 0 : (this.activeIndex || 0) + 1;
14
+ const list = this.allOptions.map((element, index) => ({ element, index }));
15
+ return [...list.slice(this.pivotIndex), ...list.slice(0, this.pivotIndex)];
16
+ };
17
+ const buildQueue = () => {
18
+ const now = new Date();
19
+ if (now.getTime() - this.keyStore.lastPressedAt.getTime() > 1000) {
20
+ // empty stored keys if delay > 1s
21
+ this.keyStore.queue.length = 0;
22
+ }
23
+ if (this.keyStore.queue.length !== 1 || this.keyStore.queue[0] !== keyValue) {
24
+ this.keyStore.queue.push(keyValue);
25
+ }
26
+ this.keyStore.lastPressedAt = now;
27
+ };
28
+ const searchIndex = (list) => {
29
+ const keyStr = this.keyStore.queue.join('');
30
+ return list.find(v => {
31
+ return (!v.element.disabled &&
32
+ v.element.display &&
33
+ (v.element.display.match(new RegExp(`^${keyStr}`, 'i')) ||
34
+ v.element.display.replace(/\s/g, '').match(new RegExp(`^${keyStr}`, 'i'))));
35
+ });
36
+ };
37
+ const setFocus = ({ index }) => {
38
+ if (this.multiple) {
39
+ // multiple: should open to make sure that which options are selected
40
+ this.openDropdownWithActiveElement(index);
41
+ }
42
+ else {
43
+ this.activeIndex = index;
44
+ if (shouldSelect)
45
+ this.selectOption(this.allOptions[index]);
46
+ else
47
+ this.setActiveElement(index);
48
+ }
49
+ };
50
+ buildQueue();
51
+ const matched = searchIndex(reorder());
52
+ if (matched) {
53
+ setFocus(matched);
54
+ }
55
+ };
6
56
  /// Event Handlers ///
7
57
  /* tslint:disable:cyclomatic-complexity */
8
58
  this.externalKeydownHandler = (event) => {
@@ -92,7 +142,7 @@ export class Q2OptionList {
92
142
  let newOption;
93
143
  switch (key) {
94
144
  case ' ':
95
- if (this.searchString) {
145
+ if (this.searchString && !this.multiple) {
96
146
  if (customSearch)
97
147
  break;
98
148
  this.searchOptions(key, false);
@@ -162,6 +212,8 @@ export class Q2OptionList {
162
212
  case 'Tab':
163
213
  if (shiftKey)
164
214
  break;
215
+ if (this.multiple && this.role === 'listbox')
216
+ break;
165
217
  newOption = allOptions.find(element => element.active);
166
218
  if (!newOption || newOption.disabled)
167
219
  return;
@@ -408,19 +460,8 @@ export class Q2OptionList {
408
460
  }, 2000);
409
461
  }
410
462
  searchOptions(key, shouldSelect) {
411
- this.resetTimer();
412
- let searchString = this.searchString ? `${this.searchString}${key}` : key;
413
- searchString = searchString.replace(/[^\w\s]/gi, '');
414
- this.searchString = searchString;
415
- const searchRegEx = new RegExp(`^${searchString}`, 'i');
416
- const { allOptions } = this;
417
- const foundIndex = allOptions.findIndex(option => option.value === searchString || option.textContent.trim().match(searchRegEx));
418
- if (foundIndex === -1)
419
- return;
420
- if (shouldSelect)
421
- this.selectOption(this.allOptions[foundIndex]);
422
- else
423
- this.setActiveElement(foundIndex);
463
+ this.searchString = key;
464
+ this.searchAndFocus(key, shouldSelect);
424
465
  }
425
466
  /// Watchers ///
426
467
  showSelectedUpdated(showSelected) {
@@ -17,6 +17,20 @@ export class Q2Pagination {
17
17
  }
18
18
  this.change.emit({ page });
19
19
  };
20
+ this.checkSize = () => {
21
+ const { hostElement, containerElement } = this;
22
+ const isOverflowing = this.containerWidth > hostElement.clientWidth;
23
+ this.isSmall = isOverflowing;
24
+ if (isOverflowing)
25
+ return;
26
+ nextPaint(() => {
27
+ const containerWidthHasNotChanged = this.containerWidth === containerElement.clientWidth;
28
+ if (containerWidthHasNotChanged)
29
+ return;
30
+ this.containerWidth = containerElement.clientWidth;
31
+ this.checkSize();
32
+ });
33
+ };
20
34
  this.recordType = undefined;
21
35
  this.perPage = undefined;
22
36
  this.total = undefined;
@@ -32,12 +46,14 @@ export class Q2Pagination {
32
46
  return;
33
47
  this.containerWidth = this.containerElement.clientWidth;
34
48
  this.resizeObserver = new ResizeObserver(() => this.checkSize());
49
+ window.addEventListener('resize', this.checkSize);
35
50
  this.resizeObserver.observe(this.hostElement);
36
51
  overrideFocus(this.hostElement);
37
52
  }
38
53
  disconnectedCallback() {
39
54
  var _a;
40
55
  (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
56
+ window.removeEventListener('resize', this.checkSize);
41
57
  }
42
58
  onHostElementFocus(event) {
43
59
  var _a;
@@ -78,20 +94,6 @@ export class Q2Pagination {
78
94
  return pages;
79
95
  return Math.ceil(total / perPage);
80
96
  }
81
- checkSize() {
82
- const { hostElement, containerElement } = this;
83
- const isOverflowing = this.containerWidth > hostElement.clientWidth;
84
- this.isSmall = isOverflowing;
85
- if (isOverflowing)
86
- return;
87
- nextPaint(() => {
88
- const containerWidthHasNotChanged = this.containerWidth === containerElement.clientWidth;
89
- if (containerWidthHasNotChanged)
90
- return;
91
- this.containerWidth = containerElement.clientWidth;
92
- this.checkSize();
93
- });
94
- }
95
97
  ////////// OBSERVERS //////////
96
98
  render() {
97
99
  const { pagesOnly, isFullViewHidden, recordTypeWithDefault: recordType, totalPages, totalWithDefault: total, pageWithDefault: page, currentRange, } = this;
@@ -107,6 +107,11 @@ button {
107
107
  align-items: center;
108
108
  }
109
109
 
110
+ q2-btn {
111
+ --tct-btn-border-radius: var(--tct-pagination-btn-border-radius, var(--t-pagination-btn-border-radius));
112
+ --tct-btn-border: var(--tct-pagination-btn-border, var(--t-pagination-btn-border));
113
+ }
114
+
110
115
  q2-icon {
111
116
  --tct-icon-size: var(--tct-pagination-icon-size, var(--t-pagination-icon-size, 12px));
112
117
  color: var(--tct-pagination-icon-color, var(--t-pagination-icon-color, var(--t-text, #4d4d4d)));
@@ -6,12 +6,30 @@ export class Q2Pill {
6
6
  var _a;
7
7
  this.scheduledAfterRender = [];
8
8
  /// Helpers ///
9
+ this.syncValueProperties = () => {
10
+ const { value, selectedOptions } = this;
11
+ if (!!(selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length))
12
+ this.selectedOptionsChanged(selectedOptions);
13
+ else if (value)
14
+ this.valueChanged(value);
15
+ };
16
+ this.getOption = async (value) => {
17
+ if (this.optionList) {
18
+ const options = await this.optionList.getOptions();
19
+ return options.find(option => option.value === value);
20
+ }
21
+ else {
22
+ return this.hostElement.querySelector(`q2-option[value="${value}"]`);
23
+ }
24
+ };
9
25
  this.updateSelectedOptionElements = async () => {
10
26
  var _a;
11
27
  const { selectedOptions } = this;
12
28
  const selectedValues = selectedOptions.map(option => option.value);
13
29
  const options = await ((_a = this.optionList) === null || _a === void 0 ? void 0 : _a.getOptions());
14
- this.selectedOptionElements = options === null || options === void 0 ? void 0 : options.filter(option => selectedValues.includes(option.value));
30
+ if (this.hasOptions)
31
+ this.active = !!selectedValues.length;
32
+ this.selectedOptionElements = (options === null || options === void 0 ? void 0 : options.filter(option => selectedValues.includes(option.value))) || [];
15
33
  };
16
34
  this.determineHasOptions = () => {
17
35
  const hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
@@ -19,6 +37,7 @@ export class Q2Pill {
19
37
  };
20
38
  this.clearSelectedOptions = () => {
21
39
  this.selectedOptions = [];
40
+ this.value = null;
22
41
  this.active = false;
23
42
  this.open = false;
24
43
  this.primaryBtn.focus();
@@ -51,9 +70,10 @@ export class Q2Pill {
51
70
  }
52
71
  };
53
72
  this.handleKeydown = async (event) => {
54
- event.preventDefault();
55
- if (!this.hasOptions || this.disabled)
73
+ const isTabMetaOrCtrl = event.metaKey || event.ctrlKey || event.key === 'Tab';
74
+ if (!this.hasOptions || this.disabled || isTabMetaOrCtrl)
56
75
  return;
76
+ event.preventDefault();
57
77
  if (shouldShowActionSheet(this, event)) {
58
78
  this.executeActionSheet(event);
59
79
  }
@@ -61,6 +81,13 @@ export class Q2Pill {
61
81
  this.optionList.handleExternalKeydown(event);
62
82
  }
63
83
  };
84
+ this.handleButtonFocusout = async (event) => {
85
+ var _a;
86
+ const relatedTarget = event.relatedTarget;
87
+ if ((_a = (relatedTarget === null || relatedTarget === void 0 ? void 0 : relatedTarget.tagName) === 'Q2-OPTION') !== null && _a !== void 0 ? _a : false)
88
+ return;
89
+ this.open = false;
90
+ };
64
91
  this.handleChange = event => {
65
92
  event.stopPropagation();
66
93
  if (!this.hasOptions)
@@ -75,7 +102,10 @@ export class Q2Pill {
75
102
  const target = event.target;
76
103
  if (target.localName === 'click-elsewhere') {
77
104
  event.stopPropagation();
78
- this.popoverElement.open = false;
105
+ const { popoverElement } = this;
106
+ if (!popoverElement)
107
+ return;
108
+ popoverElement.open = false;
79
109
  }
80
110
  };
81
111
  this.hoist = !!((_a = window.Tecton) === null || _a === void 0 ? void 0 : _a.useActionSheets);
@@ -101,6 +131,7 @@ export class Q2Pill {
101
131
  }
102
132
  componentDidLoad() {
103
133
  overrideFocus(this.hostElement);
134
+ this.syncValueProperties();
104
135
  }
105
136
  componentDidRender() {
106
137
  this.scheduledAfterRender.forEach(fn => fn());
@@ -130,12 +161,22 @@ export class Q2Pill {
130
161
  const result = await showActionSheetList(this, event);
131
162
  this.handleSelectionChanges(result);
132
163
  }
133
- handleSelectionChanges(changeDetails) {
164
+ async handleSelectionChanges(changeDetails) {
165
+ const { multiple } = this;
134
166
  const { value = '', values = [] } = changeDetails;
135
- const isActive = !!values.length;
167
+ const isActive = multiple ? !!values.length : !!value;
136
168
  if (!this.hostElement.onchange) {
137
- this.selectedOptions = values;
138
- this.active = isActive;
169
+ if (multiple) {
170
+ this.selectedOptions = values;
171
+ this.value = undefined;
172
+ }
173
+ else {
174
+ const selectedOption = await this.getOption(value);
175
+ this.selectedOptions = selectedOption
176
+ ? [{ value: selectedOption.value, display: selectedOption.display }]
177
+ : undefined;
178
+ this.value = selectedOption.value || undefined;
179
+ }
139
180
  }
140
181
  this.change.emit({
141
182
  value,
@@ -144,8 +185,35 @@ export class Q2Pill {
144
185
  });
145
186
  }
146
187
  /// Watchers ///
147
- selectedOptionsWatcher() {
148
- this.updateSelectedOptionElements();
188
+ async valueChanged(newValue) {
189
+ var _a, _b;
190
+ const { multiple, selectedOptions } = this;
191
+ const firstValue = (_b = (_a = selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null;
192
+ if (multiple)
193
+ return;
194
+ if (newValue === firstValue)
195
+ this.updateSelectedOptionElements();
196
+ else {
197
+ const selectedOption = await this.getOption(newValue);
198
+ const { value, display } = selectedOption || { value: newValue, display: null };
199
+ this.selectedOptions = [{ value, display }];
200
+ }
201
+ }
202
+ selectedOptionsChanged(newValue) {
203
+ var _a, _b;
204
+ const { multiple } = this;
205
+ const firstValue = (_b = (_a = newValue === null || newValue === void 0 ? void 0 : newValue[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null;
206
+ if (multiple) {
207
+ if (this.value)
208
+ this.value = null;
209
+ this.updateSelectedOptionElements();
210
+ }
211
+ else if (this.value === firstValue) {
212
+ this.updateSelectedOptionElements();
213
+ }
214
+ else {
215
+ this.value = firstValue;
216
+ }
149
217
  }
150
218
  /// Listeners ///
151
219
  delegateFocus(event) {
@@ -159,7 +227,6 @@ export class Q2Pill {
159
227
  if (open)
160
228
  return;
161
229
  this.optionList.setActiveElement(null);
162
- this.primaryBtn.focus();
163
230
  }
164
231
  /// DOM ///
165
232
  generateIcon() {
@@ -176,7 +243,7 @@ export class Q2Pill {
176
243
  wrapperClassNames.push('has-icon');
177
244
  if (hasOptions)
178
245
  wrapperClassNames.push('has-options');
179
- return (h("click-elsewhere", { onChange: this.onClickElsewhere }, h("div", { class: wrapperClassNames.join(' ') }, h("div", { class: "btn-height-wrapper", ref: el => (this.primaryBtnWrapper = el), onClick: this.handleWrapperClick, tabIndex: -1 }, h("button", { class: "btn-primary", "test-id": "btn-control", type: "button", ref: el => (this.primaryBtn = el), onClick: this.handleClick, onKeyDown: this.handleKeydown, disabled: this.disabled, "aria-selected": !hasOptions && active ? 'true' : 'false', "aria-roledescription": !hasOptions && 'filter', "aria-controls": hasOptions && 'option-list', "aria-haspopup": hasOptions && 'true', "aria-expanded": (hasOptions && `${!!open}`) || undefined, "aria-label": this.maxLength && this.buttonContent }, this.truncatedButtonContent, !hasOptions && active && h("span", { class: "sr" }, "(", loc('tecton.element.pill.active'), ")"))), this.generateIcon()), this.hasOptions && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.primaryBtn, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection, align: "right" }, h("q2-option-list", { role: "menu", ref: el => (this.optionList = el), id: "option-list", onChange: this.handleChange, multiple: this.multiple, selectedOptions: this.selectedOptions, onReady: () => this.updateSelectedOptionElements() }, h("slot", null))))));
246
+ return (h("click-elsewhere", { onChange: this.onClickElsewhere }, h("div", { class: wrapperClassNames.join(' ') }, h("div", { class: "btn-height-wrapper", ref: el => (this.primaryBtnWrapper = el), onClick: this.handleWrapperClick, tabIndex: -1 }, h("button", { class: "btn-primary", "test-id": "btn-control", type: "button", ref: el => (this.primaryBtn = el), onClick: this.handleClick, onKeyDown: this.handleKeydown, onFocusout: this.handleButtonFocusout, disabled: this.disabled, "aria-selected": !hasOptions && active ? 'true' : 'false', "aria-roledescription": !hasOptions && 'filter', "aria-controls": hasOptions && 'option-list', "aria-haspopup": hasOptions && 'true', "aria-expanded": (hasOptions && `${!!open}`) || undefined, "aria-label": this.maxLength && this.buttonContent }, this.truncatedButtonContent, !hasOptions && active && h("span", { class: "sr" }, "(", loc('tecton.element.pill.active'), ")"))), this.generateIcon()), this.hasOptions && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.primaryBtn, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection, align: "right" }, h("q2-option-list", { role: "menu", ref: el => (this.optionList = el), id: "option-list", onChange: this.handleChange, multiple: this.multiple, selectedOptions: this.selectedOptions, onReady: () => this.updateSelectedOptionElements() }, h("slot", null))))));
180
247
  }
181
248
  static get is() { return "q2-pill"; }
182
249
  static get encapsulation() { return "shadow"; }
@@ -314,7 +381,7 @@ export class Q2Pill {
314
381
  },
315
382
  "value": {
316
383
  "type": "string",
317
- "mutable": false,
384
+ "mutable": true,
318
385
  "complexType": {
319
386
  "original": "string",
320
387
  "resolved": "string",
@@ -436,8 +503,11 @@ export class Q2Pill {
436
503
  static get elementRef() { return "hostElement"; }
437
504
  static get watchers() {
438
505
  return [{
506
+ "propName": "value",
507
+ "methodName": "valueChanged"
508
+ }, {
439
509
  "propName": "selectedOptions",
440
- "methodName": "selectedOptionsWatcher"
510
+ "methodName": "selectedOptionsChanged"
441
511
  }];
442
512
  }
443
513
  static get listeners() {
@@ -51,6 +51,7 @@ export class Q2Popover {
51
51
  if (this.open)
52
52
  return;
53
53
  this.currentDirection = undefined;
54
+ this.containerElement.style.removeProperty('display');
54
55
  this.containerElement.style.removeProperty('--comp-pop-max-height');
55
56
  }, { once: true });
56
57
  this.show = false;
@@ -84,9 +85,8 @@ export class Q2Popover {
84
85
  const { containerElement, contentElement, direction, controlElement, currentDirection } = this;
85
86
  if (containerElement)
86
87
  containerElement.style.maxHeight = null;
87
- // If direction defined, use it
88
- if (direction)
89
- return this.setDirectionAndShow(direction);
88
+ // If the direction is already set then use it, otherwise use the current direction
89
+ const currentOrStatedDirection = direction !== null && direction !== void 0 ? direction : currentDirection;
90
90
  // Set the container to block so we can get the height
91
91
  containerElement.style.setProperty('display', 'block');
92
92
  await waitForNextPaint();
@@ -105,13 +105,13 @@ export class Q2Popover {
105
105
  const canShowFullSizeAbove = contentHeight <= topOffset;
106
106
  let determinedDirection;
107
107
  // Show the full-size popover below or above if it will fit
108
- if (currentDirection === 'down' && canShowFullSizeBelow)
108
+ if (currentOrStatedDirection === 'down' && canShowFullSizeBelow)
109
109
  return this.setDirectionAndShow('down');
110
- else if (currentDirection === 'up' && canShowFullSizeAbove)
110
+ else if (currentOrStatedDirection === 'up' && canShowFullSizeAbove)
111
111
  return this.setDirectionAndShow('up');
112
- else if (currentDirection === undefined && canShowFullSizeBelow)
112
+ else if (currentOrStatedDirection === undefined && canShowFullSizeBelow)
113
113
  determinedDirection = 'down';
114
- else if (currentDirection === undefined && canShowFullSizeAbove)
114
+ else if (currentOrStatedDirection === undefined && canShowFullSizeAbove)
115
115
  determinedDirection = 'up';
116
116
  if (determinedDirection)
117
117
  return this.setDirectionAndShow(determinedDirection);
@@ -120,11 +120,11 @@ export class Q2Popover {
120
120
  const displayBuffer = 5;
121
121
  const canShowMinHeightBelow = bottomOffset >= minHeight + displayBuffer;
122
122
  let maxHeight;
123
- if (currentDirection === 'down') {
123
+ if (currentOrStatedDirection === 'down') {
124
124
  maxHeight = Math.max(bottomOffset - displayBuffer, minHeight);
125
125
  determinedDirection = 'down';
126
126
  }
127
- else if (currentDirection === 'up') {
127
+ else if (currentOrStatedDirection === 'up') {
128
128
  maxHeight = Math.max(topOffset - displayBuffer, minHeight);
129
129
  determinedDirection = 'up';
130
130
  }
@@ -150,7 +150,7 @@ export class Q2Popover {
150
150
  const containerClasses = ['container', this.currentDirection];
151
151
  if (this.show)
152
152
  containerClasses.push('show');
153
- return (h("div", { ref: el => (this.containerElement = el), class: containerClasses.join(' '), role: "menu" }, h("div", { ref: el => (this.contentElement = el), class: "content" }, h("slot", null))));
153
+ return (h("div", { ref: el => (this.containerElement = el), class: containerClasses.join(' '), "test-id": "outerContainer" }, h("div", { ref: el => (this.contentElement = el), class: "content" }, h("slot", null))));
154
154
  }
155
155
  static get is() { return "q2-popover"; }
156
156
  static get encapsulation() { return "shadow"; }
@@ -171,8 +171,11 @@ export class Q2Radio {
171
171
  "required": false,
172
172
  "optional": false,
173
173
  "docs": {
174
- "tags": [],
175
- "text": ""
174
+ "tags": [{
175
+ "name": "private",
176
+ "text": undefined
177
+ }],
178
+ "text": "Used by q2-radio-group to apply a name to all options in the group"
176
179
  },
177
180
  "attribute": "name",
178
181
  "reflect": true
@@ -188,8 +191,11 @@ export class Q2Radio {
188
191
  "required": false,
189
192
  "optional": false,
190
193
  "docs": {
191
- "tags": [],
192
- "text": ""
194
+ "tags": [{
195
+ "name": "private",
196
+ "text": undefined
197
+ }],
198
+ "text": "Used by q2-radio-group to disable all options in the group"
193
199
  },
194
200
  "attribute": "group-disabled",
195
201
  "reflect": false,
@@ -206,8 +212,11 @@ export class Q2Radio {
206
212
  "required": false,
207
213
  "optional": false,
208
214
  "docs": {
209
- "tags": [],
210
- "text": ""
215
+ "tags": [{
216
+ "name": "private",
217
+ "text": undefined
218
+ }],
219
+ "text": "Used by q2-radio-group to make all options in the group readonly"
211
220
  },
212
221
  "attribute": "group-readonly",
213
222
  "reflect": false,
@@ -224,8 +233,11 @@ export class Q2Radio {
224
233
  "required": false,
225
234
  "optional": false,
226
235
  "docs": {
227
- "tags": [],
228
- "text": ""
236
+ "tags": [{
237
+ "name": "private",
238
+ "text": undefined
239
+ }],
240
+ "text": "Used by q2-radio-group to make the options display as tiles"
229
241
  },
230
242
  "attribute": "group-tile-layout",
231
243
  "reflect": false,
@@ -75,6 +75,7 @@ button {
75
75
  margin-bottom: var(--tct-radio-margin-vertical, var(--tct-scale-2, 10px));
76
76
  }
77
77
  .radio-container label[for] {
78
+ color: var(--tct-radio-label-color);
78
79
  font-weight: var(--tct-radio-font-weight, var(--tct-checkbox-font-weight, 400));
79
80
  align-items: center;
80
81
  cursor: pointer;
@@ -117,6 +118,7 @@ button {
117
118
  flex-wrap: wrap;
118
119
  }
119
120
  .radio-tile label[for] {
121
+ color: var(--tct-radio-label-color);
120
122
  align-items: center;
121
123
  border-radius: 3px;
122
124
  border: 2px solid var(--tct-radio-stroke-color, var(--t-a11y-gray-color-AA, #949494));