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,324 @@
1
+ import { Component, State, Prop, h, Listen, Element, Fragment, Event } from '@stencil/core';
2
+ import { isEventFromElement, loc, overrideFocus } from 'src/utils';
3
+ export class Q2Pill {
4
+ constructor() {
5
+ this.selectedOptions = [];
6
+ this.scheduledAfterRender = [];
7
+ /// Helpers
8
+ this.determineHasOptions = () => {
9
+ const hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
10
+ this.hasOptions = hasOptions;
11
+ };
12
+ this.clearSelectedOptions = () => {
13
+ this.selectedOptions = [];
14
+ this.active = false;
15
+ this.open = false;
16
+ this.primaryBtn.focus();
17
+ this.change.emit({ value: null, values: [], active: false });
18
+ };
19
+ /// Event Handlers ///
20
+ this.handleClick = (event) => {
21
+ event.stopPropagation();
22
+ if (this.disabled)
23
+ return;
24
+ if (this.hasOptions) {
25
+ this.optionList.toggle();
26
+ }
27
+ else {
28
+ const { value, label } = this;
29
+ const isActive = (this.active = !this.active);
30
+ const values = isActive ? [{ value, display: label }] : [];
31
+ this.selectedOptions = values;
32
+ this.change.emit({
33
+ value: value,
34
+ values,
35
+ active: isActive
36
+ });
37
+ }
38
+ };
39
+ this.handleKeydown = (event) => {
40
+ if (!this.hasOptions || this.disabled)
41
+ return;
42
+ this.optionList.handleExternalKeydown(event);
43
+ };
44
+ this.handleChange = event => {
45
+ if (!this.hasOptions)
46
+ return;
47
+ const { value, values } = event.detail;
48
+ const isActive = !!values.length;
49
+ if (!this.hostElement.onchange) {
50
+ this.selectedOptions = values;
51
+ this.active = isActive;
52
+ }
53
+ this.change.emit({ value: value, values, active: isActive });
54
+ };
55
+ this.handleFocusout = (event) => {
56
+ const relatedTarget = event.relatedTarget;
57
+ if (Array.from(this.hostElement.children).includes(relatedTarget))
58
+ return;
59
+ if (relatedTarget && !(event.relatedTarget instanceof HTMLElement))
60
+ return;
61
+ if (relatedTarget && relatedTarget.closest('.btn-height-wrapper'))
62
+ return;
63
+ this.optionList.open = false;
64
+ };
65
+ this.handleWrapperClick = () => {
66
+ this.primaryBtn.focus();
67
+ this.primaryBtn.click();
68
+ };
69
+ }
70
+ /// LifeCycle Hooks ///
71
+ componentWillLoad() {
72
+ const observer = new MutationObserver(this.determineHasOptions);
73
+ observer.observe(this.hostElement, { childList: true, attributes: true });
74
+ this.mutationObserver = observer;
75
+ }
76
+ componentDidLoad() {
77
+ overrideFocus(this.hostElement);
78
+ }
79
+ componentDidRender() {
80
+ this.scheduledAfterRender.forEach(fn => fn());
81
+ this.scheduledAfterRender = [];
82
+ }
83
+ disconnectedCallback() {
84
+ this.mutationObserver.disconnect();
85
+ this.mutationObserver = null;
86
+ }
87
+ /// Getters ///
88
+ get buttonContent() {
89
+ const { label, selectedOptions, hasOptions } = this;
90
+ if (!hasOptions || selectedOptions.length === 0)
91
+ return label;
92
+ else if (selectedOptions.length === 1)
93
+ return selectedOptions[0].display;
94
+ return loc('tecton.element.pill.activeCount', { count: selectedOptions.length });
95
+ }
96
+ /// Listeners ///
97
+ delegateFocus(event) {
98
+ if (!isEventFromElement(event, this.hostElement))
99
+ return;
100
+ this.primaryBtn.focus();
101
+ }
102
+ optionListStateEvent({ detail: { open } }) {
103
+ this.open = open;
104
+ if (!open)
105
+ this.primaryBtn.focus();
106
+ }
107
+ /// DOM ///
108
+ generateIcon() {
109
+ const { hasOptions, active } = this;
110
+ const isButton = hasOptions && active;
111
+ const TagName = isButton ? 'button' : 'div';
112
+ const iconName = isButton || !hasOptions ? 'close' : 'chevron-down';
113
+ 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' },
114
+ h("q2-icon", { type: iconName })));
115
+ }
116
+ render() {
117
+ const { hasOptions, active, open } = this;
118
+ let wrapperClassNames = ['btn-wrapper'];
119
+ if (hasOptions || active)
120
+ wrapperClassNames.push('has-icon');
121
+ if (hasOptions)
122
+ wrapperClassNames.push('has-options');
123
+ return (h(Fragment, null,
124
+ h("div", { class: wrapperClassNames.join(' ') },
125
+ h("div", { class: "btn-height-wrapper", onClick: this.handleWrapperClick, tabIndex: -1 },
126
+ 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' },
127
+ this.buttonContent,
128
+ !hasOptions && active && (h("span", { class: "sr" },
129
+ "(",
130
+ loc('tecton.element.pill.active'),
131
+ ")")))),
132
+ this.generateIcon()),
133
+ 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 },
134
+ h("slot", null)))));
135
+ }
136
+ static get is() { return "q2-pill"; }
137
+ static get encapsulation() { return "shadow"; }
138
+ static get originalStyleUrls() { return {
139
+ "$": ["styles.scss"]
140
+ }; }
141
+ static get styleUrls() { return {
142
+ "$": ["styles.css"]
143
+ }; }
144
+ static get properties() { return {
145
+ "disabled": {
146
+ "type": "boolean",
147
+ "mutable": false,
148
+ "complexType": {
149
+ "original": "boolean",
150
+ "resolved": "boolean",
151
+ "references": {}
152
+ },
153
+ "required": false,
154
+ "optional": false,
155
+ "docs": {
156
+ "tags": [],
157
+ "text": ""
158
+ },
159
+ "attribute": "disabled",
160
+ "reflect": true
161
+ },
162
+ "active": {
163
+ "type": "boolean",
164
+ "mutable": true,
165
+ "complexType": {
166
+ "original": "boolean",
167
+ "resolved": "boolean",
168
+ "references": {}
169
+ },
170
+ "required": false,
171
+ "optional": false,
172
+ "docs": {
173
+ "tags": [],
174
+ "text": ""
175
+ },
176
+ "attribute": "active",
177
+ "reflect": true
178
+ },
179
+ "open": {
180
+ "type": "boolean",
181
+ "mutable": true,
182
+ "complexType": {
183
+ "original": "boolean",
184
+ "resolved": "boolean",
185
+ "references": {}
186
+ },
187
+ "required": false,
188
+ "optional": false,
189
+ "docs": {
190
+ "tags": [],
191
+ "text": ""
192
+ },
193
+ "attribute": "open",
194
+ "reflect": true
195
+ },
196
+ "multiple": {
197
+ "type": "boolean",
198
+ "mutable": false,
199
+ "complexType": {
200
+ "original": "boolean",
201
+ "resolved": "boolean",
202
+ "references": {}
203
+ },
204
+ "required": false,
205
+ "optional": false,
206
+ "docs": {
207
+ "tags": [],
208
+ "text": ""
209
+ },
210
+ "attribute": "multiple",
211
+ "reflect": true
212
+ },
213
+ "label": {
214
+ "type": "string",
215
+ "mutable": false,
216
+ "complexType": {
217
+ "original": "string",
218
+ "resolved": "string",
219
+ "references": {}
220
+ },
221
+ "required": false,
222
+ "optional": false,
223
+ "docs": {
224
+ "tags": [],
225
+ "text": ""
226
+ },
227
+ "attribute": "label",
228
+ "reflect": true
229
+ },
230
+ "value": {
231
+ "type": "string",
232
+ "mutable": false,
233
+ "complexType": {
234
+ "original": "string",
235
+ "resolved": "string",
236
+ "references": {}
237
+ },
238
+ "required": false,
239
+ "optional": false,
240
+ "docs": {
241
+ "tags": [],
242
+ "text": ""
243
+ },
244
+ "attribute": "value",
245
+ "reflect": true
246
+ },
247
+ "theme": {
248
+ "type": "string",
249
+ "mutable": false,
250
+ "complexType": {
251
+ "original": "'primary' | 'secondary' | 'tertiary'",
252
+ "resolved": "\"primary\" | \"secondary\" | \"tertiary\"",
253
+ "references": {}
254
+ },
255
+ "required": false,
256
+ "optional": false,
257
+ "docs": {
258
+ "tags": [],
259
+ "text": ""
260
+ },
261
+ "attribute": "theme",
262
+ "reflect": true
263
+ },
264
+ "selectedOptions": {
265
+ "type": "unknown",
266
+ "mutable": true,
267
+ "complexType": {
268
+ "original": "IOptionValue[]",
269
+ "resolved": "IOptionValue[]",
270
+ "references": {
271
+ "IOptionValue": {
272
+ "location": "import",
273
+ "path": "../q2-option-list"
274
+ }
275
+ }
276
+ },
277
+ "required": false,
278
+ "optional": false,
279
+ "docs": {
280
+ "tags": [],
281
+ "text": ""
282
+ },
283
+ "defaultValue": "[]"
284
+ }
285
+ }; }
286
+ static get states() { return {
287
+ "hasOptions": {}
288
+ }; }
289
+ static get events() { return [{
290
+ "method": "change",
291
+ "name": "change",
292
+ "bubbles": true,
293
+ "cancelable": true,
294
+ "composed": true,
295
+ "docs": {
296
+ "tags": [],
297
+ "text": ""
298
+ },
299
+ "complexType": {
300
+ "original": "{ value: string; values: IOptionValue[]; active: boolean }",
301
+ "resolved": "{ value: string; values: IOptionValue[]; active: boolean; }",
302
+ "references": {
303
+ "IOptionValue": {
304
+ "location": "import",
305
+ "path": "../q2-option-list"
306
+ }
307
+ }
308
+ }
309
+ }]; }
310
+ static get elementRef() { return "hostElement"; }
311
+ static get listeners() { return [{
312
+ "name": "focus",
313
+ "method": "delegateFocus",
314
+ "target": undefined,
315
+ "capture": false,
316
+ "passive": false
317
+ }, {
318
+ "name": "optionListState",
319
+ "method": "optionListStateEvent",
320
+ "target": undefined,
321
+ "capture": false,
322
+ "passive": false
323
+ }]; }
324
+ }
@@ -0,0 +1,227 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
4
+
5
+ *:active {
6
+ outline: none;
7
+ }
8
+
9
+ *:focus {
10
+ outline: none;
11
+ box-shadow: var(--const-global-focus);
12
+ }
13
+
14
+ :host {
15
+ box-shadow: none !important;
16
+ }
17
+
18
+ ::-moz-focus-inner {
19
+ border: none;
20
+ }
21
+
22
+ input,
23
+ textarea,
24
+ button {
25
+ font-family: inherit;
26
+ font-size: inherit;
27
+ }
28
+
29
+ :host(.sr),
30
+ :host(.sr) button {
31
+ border: 0;
32
+ clip: rect(0 0 0 0);
33
+ height: 1px;
34
+ margin: -1px;
35
+ overflow: hidden;
36
+ padding: 0;
37
+ position: absolute;
38
+ width: 1px;
39
+ white-space: nowrap;
40
+ }
41
+
42
+ .sr,
43
+ .sr button {
44
+ border: 0;
45
+ clip: rect(0 0 0 0);
46
+ height: 1px;
47
+ margin: -1px;
48
+ overflow: hidden;
49
+ padding: 0;
50
+ position: absolute;
51
+ width: 1px;
52
+ white-space: nowrap;
53
+ }
54
+
55
+ .hidden {
56
+ display: none;
57
+ }
58
+
59
+ :host([hidden]) {
60
+ display: none;
61
+ }
62
+
63
+ .invisible {
64
+ visibility: hidden;
65
+ }
66
+
67
+ :host {
68
+ display: inline-block;
69
+ position: relative;
70
+ }
71
+
72
+ :host(:not(:last-child)) {
73
+ margin-inline-end: var(--tct-pill-margin, var(--t-pill-margin, var(--app-scale-2x, 10px)));
74
+ }
75
+
76
+ .btn-wrapper {
77
+ --comp-pill-min-height: var(--tct-pill-min-height, var(--t-pill-min-height, 44px));
78
+ --comp-pill-btn-border-width: var(--tct-pill-btn-border-width, var(--t-pill-btn-border-width, 2px));
79
+ --comp-pill-btn-height: var(--tct-pill-btn-height, var(--t-pill-btn-height, 30px));
80
+ --comp-close-size: 0px;
81
+ --comp-btn-background: var(--tct-pill-btn-background, var(--t-pill-btn-background, var(--t-base, #ffffff)));
82
+ --compt-hover-btn-background: var(--tct-pill-hover-btn-background, var(--t-pill-hover-btn-background, var(--t-gray-13, #e6e6e6)));
83
+ --comp-btn-padding: var(--tct-pill-btn-padding-inline, var(--t-pill-btn-padding-inline, var(--app-scale-3x, 15px)));
84
+ --comp-btn-color: var(--tct-pill-btn-color, var(--t-pill-btn-color, var(--t-gray-3, #262626)));
85
+ --comp-active-btn-background: var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-7, #666666)));
86
+ --comp-active-btn-border-color: var(--tct-pill-active-btn-border-color, var(--t-pill-active-btn-border-color, var(--t-gray-7, #666666)));
87
+ --comp-hover-active-btn-background: var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-6, #4d4d4d)));
88
+ --comp-hover-active-btn-border-color: var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-6, #4d4d4d)));
89
+ position: relative;
90
+ }
91
+ :host(:not(:empty)) .btn-wrapper, .btn-wrapper.has-icon {
92
+ --comp-close-size: var(--comp-pill-btn-height);
93
+ }
94
+ :host([active]) .btn-wrapper {
95
+ --comp-btn-color: var(--tct-pill-active-btn-color, var(--t-pill-active-btn-color, var(--t-base, #ffffff)));
96
+ }
97
+ :host([theme=primary]) .btn-wrapper {
98
+ --comp-active-btn-background: var(--t-primary-l5, #61c4ff);
99
+ --comp-btn-color: var(--t-primary-text, #ffffff);
100
+ --comp-active-btn-border-color: var(--t-primary-l5, #61c4ff);
101
+ --comp-hover-active-btn-background: var(--t-primary-l3, #21acff);
102
+ --comp-hover-active-btn-border-color: var(--t-primary-l3, #21acff);
103
+ }
104
+ :host([theme=secondary]) .btn-wrapper {
105
+ --comp-active-btn-background: var(--t-secondary-l5, #61c4ff);
106
+ --comp-btn-color: var(--t-secondary-text, #000000);
107
+ --comp-active-btn-border-color: var(--t-secondary-l5, #61c4ff);
108
+ --comp-hover-active-btn-background: var(--t-secondary-l3, #21acff);
109
+ --comp-hover-active-btn-border-color: var(--t-secondary-l3, #21acff);
110
+ }
111
+ :host([theme=tertiary]) .btn-wrapper {
112
+ --comp-active-btn-background: var(--t-tertiary-l5, #61c4ff);
113
+ --comp-btn-color: var(--t-tertiary-text, #000000);
114
+ --comp-active-btn-border-color: var(--t-tertiary-l5, #61c4ff);
115
+ --comp-hover-active-btn-background: var(--t-tertiary-l3, #21acff);
116
+ --comp-hover-active-btn-border-color: var(--t-tertiary-l3, #21acff);
117
+ }
118
+
119
+ q2-option-list {
120
+ position: absolute;
121
+ left: 0;
122
+ }
123
+
124
+ .btn-height-wrapper {
125
+ height: var(--comp-pill-min-height);
126
+ display: flex;
127
+ align-items: center;
128
+ cursor: pointer;
129
+ }
130
+ .btn-height-wrapper:focus {
131
+ box-shadow: none;
132
+ }
133
+ :host([disabled]) .btn-height-wrapper {
134
+ cursor: not-allowed;
135
+ }
136
+
137
+ .btn-close,
138
+ .btn-primary {
139
+ cursor: pointer;
140
+ height: var(--comp-pill-btn-height);
141
+ border-style: solid;
142
+ border-radius: var(--tct-pill-btn-border-radius, var(--t-pill-btn-border-radius, 30px));
143
+ transition-property: background, color, padding, width, opacity;
144
+ transition: var(--tct-pill-btn-tween, var(--t-pill-btn-tween, var(--app-tween-1, 0.2s ease)));
145
+ }
146
+
147
+ :host([disabled]) .btn-close,
148
+ :host([disabled]) .btn-primary,
149
+ :host([disabled]) q2-icon {
150
+ opacity: var(--tct-pill-disabled-opacity, var(--t-pill-disabled-opacity, var(--tct-disabled-opacity, var(--app-disabled-opacity, 0.4))));
151
+ cursor: not-allowed;
152
+ }
153
+
154
+ .btn-primary {
155
+ background: var(--comp-btn-background);
156
+ border-width: var(--comp-pill-btn-border-width);
157
+ border-color: var(--tct-pill-btn-border-color, var(--t-pill-btn-border-color, var(--t-gray-9, #999999)));
158
+ padding-inline: var(--comp-btn-padding);
159
+ padding-right: calc(var(--comp-btn-padding) + var(--comp-close-size));
160
+ font-size: var(--tct-pill-btn-font-size, var(--t-pill-btn-font-size, var(--app-font-size, 14px)));
161
+ color: var(--comp-btn-color);
162
+ display: block;
163
+ width: 100%;
164
+ text-align: start;
165
+ }
166
+ .btn-primary:focus, .btn-primary:hover {
167
+ background: var(--comp-hover-btn-background);
168
+ }
169
+ :host(:not(:empty)) .btn-primary, .has-icon .btn-primary {
170
+ padding-right: calc( var(--tct-pill-icon-gap, var(--t-pill-icon-gap, var(--app-size-1x, 5px))) + var(--comp-close-size) );
171
+ }
172
+ .has-options .btn-primary {
173
+ text-overflow: ellipsis;
174
+ overflow: hidden;
175
+ white-space: nowrap;
176
+ max-width: var(--tct-pill-max-width, var(--t-pill-max-width, 200px));
177
+ }
178
+ :host([active]) .btn-primary {
179
+ background: var(--comp-active-btn-background);
180
+ border-color: var(--comp-active-btn-border-color);
181
+ }
182
+ :host([active]) .btn-primary:focus, :host([active]) .btn-primary:hover {
183
+ background: var(--comp-hover-active-btn-background);
184
+ border-color: var(--comp-hover-active-btn-border-color);
185
+ }
186
+
187
+ .btn-close {
188
+ background: transparent;
189
+ border-color: transparent;
190
+ border-width: var(--comp-pill-btn-border-width);
191
+ width: var(--comp-close-size);
192
+ height: var(--comp-close-size);
193
+ padding: 0;
194
+ border: 0;
195
+ display: inline-flex;
196
+ justify-content: center;
197
+ align-items: center;
198
+ position: absolute;
199
+ right: 0;
200
+ top: 50%;
201
+ transform: translateY(-50%);
202
+ opacity: 0;
203
+ stroke: var(--comp-btn-color);
204
+ --tct-icon-stroke-primary: var(--comp-btn-color);
205
+ }
206
+ :host(:not(:empty)) .btn-close, .has-icon .btn-close {
207
+ opacity: 1;
208
+ }
209
+
210
+ q2-icon {
211
+ width: var(--tct-pill-icon-size, var(--t-pill-icon-size, 14px));
212
+ height: var(--tct-pill-icon-size, var(--t-pill-icon-size, 14px));
213
+ transition-property: transform;
214
+ transition: var(--tct-pill-btn-tween, var(--t-pill-btn-tween, var(--app-tween-1, 0.2s ease)));
215
+ }
216
+
217
+ div.btn-close {
218
+ pointer-events: none;
219
+ }
220
+ :host([open]) div.btn-close q2-icon {
221
+ transform: rotate(180deg);
222
+ }
223
+
224
+ :host([active]) button.btn-close:focus, :host([active]) button.btn-close:hover {
225
+ 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))));
226
+ 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))));
227
+ }
@@ -5,11 +5,19 @@ export class Q2Radio {
5
5
  this.disabled = false;
6
6
  this.checked = false;
7
7
  this.groupDisabled = false;
8
+ this.groupReadonly = false;
8
9
  this.groupTileLayout = false;
9
10
  this.id = `radio-${createGuid()}`;
11
+ this.isLoaded = false;
10
12
  this.inputChange = (event) => {
11
13
  event.stopPropagation();
12
- this.change.emit({ value: this.value });
14
+ if (this.groupReadonly) {
15
+ event.preventDefault();
16
+ return false;
17
+ }
18
+ if (event.target instanceof HTMLInputElement) {
19
+ this.checked = event.target.checked;
20
+ }
13
21
  };
14
22
  }
15
23
  ////////// LIFECYCLE HOOKS ////////
@@ -17,12 +25,20 @@ export class Q2Radio {
17
25
  handleAriaLabel(this);
18
26
  }
19
27
  componentDidLoad() {
28
+ this.isLoaded = true;
20
29
  overrideFocus(this.hostElement);
21
30
  }
22
31
  ////////// OBSERVERS //////////
23
32
  ariaLabelObserver() {
24
33
  handleAriaLabel(this);
25
34
  }
35
+ checkedObserver() {
36
+ if (!this.isLoaded)
37
+ return;
38
+ if (!this.checked)
39
+ return;
40
+ this.change.emit({ value: this.value });
41
+ }
26
42
  /////// HOST ELEMENT EVENTS ///////
27
43
  onHostClick(event) {
28
44
  if (this.disabled) {
@@ -193,6 +209,24 @@ export class Q2Radio {
193
209
  "reflect": false,
194
210
  "defaultValue": "false"
195
211
  },
212
+ "groupReadonly": {
213
+ "type": "boolean",
214
+ "mutable": false,
215
+ "complexType": {
216
+ "original": "boolean",
217
+ "resolved": "boolean",
218
+ "references": {}
219
+ },
220
+ "required": false,
221
+ "optional": false,
222
+ "docs": {
223
+ "tags": [],
224
+ "text": ""
225
+ },
226
+ "attribute": "group-readonly",
227
+ "reflect": false,
228
+ "defaultValue": "false"
229
+ },
196
230
  "groupTileLayout": {
197
231
  "type": "boolean",
198
232
  "mutable": false,
@@ -232,6 +266,9 @@ export class Q2Radio {
232
266
  static get watchers() { return [{
233
267
  "propName": "ariaLabel",
234
268
  "methodName": "ariaLabelObserver"
269
+ }, {
270
+ "propName": "checked",
271
+ "methodName": "checkedObserver"
235
272
  }]; }
236
273
  static get listeners() { return [{
237
274
  "name": "click",