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
@@ -5,6 +5,7 @@
5
5
  "./components/q2-carousel/index.js",
6
6
  "./components/q2-checkbox/index.js",
7
7
  "./components/q2-dropdown/index.js",
8
+ "./components/q2-option-list/index.js",
8
9
  "./components/q2-dropdown-item/index.js",
9
10
  "./components/q2-editable-field/index.js",
10
11
  "./components/q2-loading/index.js",
@@ -14,6 +15,7 @@
14
15
  "./components/q2-textarea/index.js",
15
16
  "./components/click-elsewhere/index.js",
16
17
  "./components/q2-avatar/index.js",
18
+ "./components/q2-card/index.js",
17
19
  "./components/q2-carousel-pane/index.js",
18
20
  "./components/q2-checkbox-group/index.js",
19
21
  "./components/q2-icon/index.js",
@@ -22,12 +24,15 @@
22
24
  "./components/q2-message/index.js",
23
25
  "./components/q2-optgroup/index.js",
24
26
  "./components/q2-option/index.js",
27
+ "./components/q2-pagination/index.js",
28
+ "./components/q2-pill/index.js",
25
29
  "./components/q2-radio-group/index.js",
26
30
  "./components/q2-section/index.js",
27
31
  "./components/q2-stepper/index.js",
28
32
  "./components/q2-stepper-pane/index.js",
29
33
  "./components/q2-tab-container/index.js",
30
34
  "./components/q2-tab-pane/index.js",
35
+ "./components/q2-tag/index.js",
31
36
  "./components/tecton-tab-pane/index.js"
32
37
  ],
33
38
  "compiler": {
@@ -237,7 +237,7 @@ button:disabled {
237
237
  }
238
238
  :host([badge]) button {
239
239
  padding: var(--tct-btn-badge-padding, var(--t-btn-badge-padding, 2px 5px));
240
- font-size: var(--tct-btn-badge-font-size, var(--t-btn-badge-font-size, var(--tct---btn-font-size, var(--t---btn-font-size, inherit))));
240
+ font-size: var(--tct-btn-badge-font-size, var(--t-btn-badge-font-size, var(--tct-btn-font-size, var(--t-btn-font-size, inherit))));
241
241
  border-radius: var(--tct-btn-badge-border-radius, var(--t-btn-badge-border-radius, var(--tct-border-radius-1, var(--app-border-radius-1, 3px))));
242
242
  background-color: var(--tct-btn-badge-bg, var(--t-btn-badge-bg, transparent));
243
243
  color: var(--tct-btn-badge-font-color, var(--t-btn-badge-font-color, inherit));
@@ -214,6 +214,12 @@ export function handleMissingZeros(input) {
214
214
  }
215
215
  return input;
216
216
  }
217
+ export function reorderDateString(input) {
218
+ const dateParts = (input || '').split('-');
219
+ if (dateParts.length !== 3)
220
+ return '';
221
+ return `${dateParts[1]}/${dateParts[2]}/${dateParts[0]}`;
222
+ }
217
223
  export function firstDayOfWeekInMonth(month, year) {
218
224
  return new Date(year, month, 1, 1, 1, 1, 1).getDay();
219
225
  }
@@ -1,6 +1,6 @@
1
1
  import { Component, Prop, Element, State, Event, Listen, Watch, h } from '@stencil/core';
2
2
  import { addDays, isSameDay, format, isValid as isValidDate } from 'date-fns';
3
- import { stringToDate, setupMonthYear, getMonths, getDays, getDaysOfWeek, stringArrayToDate, convertMomentFormat, validateInput, handleMissingZeros, formatDateISO, formatDateLong, formatDateShort, removeTimezoneOffset } from './helpers';
3
+ import { stringToDate, setupMonthYear, getMonths, getDays, getDaysOfWeek, stringArrayToDate, convertMomentFormat, validateInput, handleMissingZeros, formatDateISO, formatDateLong, formatDateShort, removeTimezoneOffset, reorderDateString } from './helpers';
4
4
  import { buildDates, getValidDaysOfWeek } from './validation';
5
5
  import { handleAriaLabel, loc, setPopProperties, overrideFocus, isEventFromElement } from 'src/utils';
6
6
  export class Q2Calendar {
@@ -26,7 +26,7 @@ export class Q2Calendar {
26
26
  }
27
27
  };
28
28
  this.openCalendar = () => {
29
- if (!this.dropdownOpen) {
29
+ if (!this.readonly && !this.dropdownOpen) {
30
30
  this.selectedMonthYear = setupMonthYear(this.dateValue);
31
31
  this.dateList = this.buildDateList(this.selectedMonthYear);
32
32
  this.dropdownOpen = true;
@@ -35,6 +35,8 @@ export class Q2Calendar {
35
35
  }
36
36
  };
37
37
  this.toggleCalendar = () => {
38
+ if (this.readonly)
39
+ return;
38
40
  this.dropdownOpen = !this.dropdownOpen;
39
41
  this.scheduledAfterRender.push(this.resizeIframe);
40
42
  if (this.dropdownOpen) {
@@ -257,6 +259,9 @@ export class Q2Calendar {
257
259
  connectedCallback() {
258
260
  this.selectedMonthYear = setupMonthYear(this.dateValue);
259
261
  this.dateList = this.buildDateList(this.selectedMonthYear);
262
+ if (this.value && this.isTypeable && !this.typedValue) {
263
+ this.typedValue = reorderDateString(this.value);
264
+ }
260
265
  this.validateDate();
261
266
  }
262
267
  componentWillLoad() {
@@ -333,10 +338,11 @@ export class Q2Calendar {
333
338
  }
334
339
  }
335
340
  get dateValidators() {
341
+ const ct = new Date(this.cutoffTime || ''); // should fallback to InvalidDate
336
342
  return {
337
343
  startDate: stringToDate(this.startDate),
338
344
  endDate: stringToDate(this.endDate),
339
- cutOffTime: stringToDate(this.cutoffTime)
345
+ cutOffTime: isValidDate(ct) ? ct : undefined
340
346
  };
341
347
  }
342
348
  get isTypeable() {
@@ -537,7 +543,7 @@ export class Q2Calendar {
537
543
  });
538
544
  }
539
545
  calendarField() {
540
- return (h("q2-input", { ref: el => (this.inputField = el), class: "calendar-input-field", value: this.formattedValue, label: loc(this.label), hideLabel: this.hideLabel, disabled: !!this.disabled, placeholder: this.computedPlaceholder, optional: !!this.optional, ariaExpanded: this.dropdownOpen, errors: (this.localizedErrors.length > 0 && this.localizedErrors) ||
546
+ return (h("q2-input", { ref: el => (this.inputField = el), class: "calendar-input-field", value: this.formattedValue, label: loc(this.label), hideLabel: this.hideLabel, disabled: !!this.disabled, readonly: !!this.readonly, placeholder: this.computedPlaceholder, optional: !!this.optional, ariaExpanded: this.dropdownOpen, errors: (this.localizedErrors.length > 0 && this.localizedErrors) ||
541
547
  (this.invalid && ['tecton.element.calendar.invalid']) ||
542
548
  [], onClick: this.onInputClick, onChange: this.onInputChange, onInput: this.onInputInput, onKeyDown: this.onInputKeydown, onKeyUp: this.onInputKeyup, onBlur: this.onInputBlur, "icon-right": "calendar", "format-modifier": this.isTypeable ? this.formatModifier : '', pseudo: !this.isTypeable, type: "date", "hide-messages": true, "test-id": "inputAndCalendarToggle" }));
543
549
  }
@@ -691,6 +697,23 @@ export class Q2Calendar {
691
697
  "attribute": "disabled",
692
698
  "reflect": true
693
699
  },
700
+ "readonly": {
701
+ "type": "boolean",
702
+ "mutable": false,
703
+ "complexType": {
704
+ "original": "boolean",
705
+ "resolved": "boolean",
706
+ "references": {}
707
+ },
708
+ "required": false,
709
+ "optional": false,
710
+ "docs": {
711
+ "tags": [],
712
+ "text": ""
713
+ },
714
+ "attribute": "readonly",
715
+ "reflect": true
716
+ },
694
717
  "invalid": {
695
718
  "type": "boolean",
696
719
  "mutable": true,
@@ -149,7 +149,7 @@ q2-input {
149
149
  .calendar-label {
150
150
  font-size: var(--tct-calendar-label-font-size, var(--t-calendar-label-font-size, 16px));
151
151
  flex: 1 1;
152
- flex-basis: calc(100% - var(--tct-btn-icon-width, 44px));
152
+ flex-basis: calc(100% - var-list(--tct-btn-icon-width, 44px));
153
153
  margin: 0;
154
154
  padding: var(--tct-calendar-label-vertical-padding, var(--t-calendar-label-vertical-padding, var(--tct-scale-2, var(--app-scale-2, 10px)))) 0;
155
155
  }
@@ -0,0 +1,290 @@
1
+ import { Component, Prop, Event, h, Fragment, Listen, Element, State } from '@stencil/core';
2
+ import { isTouchDevice, overrideFocus, isEventFromElement } from 'src/utils';
3
+ export class Q2Card {
4
+ constructor() {
5
+ this.isTouch = isTouchDevice();
6
+ this.isAutoTouch = false;
7
+ this.isAutoSmall = false;
8
+ this.handleClick = (event) => {
9
+ if (this.url)
10
+ return true;
11
+ event.preventDefault();
12
+ event.stopPropagation();
13
+ this.click.emit();
14
+ };
15
+ }
16
+ componentDidLoad() {
17
+ const { hostElement, clickableElement } = this;
18
+ hostElement.click = () => clickableElement.click();
19
+ overrideFocus(this.hostElement);
20
+ this.resizeObserver = new ResizeObserver(() => this.determineAutoSmall());
21
+ this.resizeObserver.observe(this.hostElement);
22
+ }
23
+ willDestroyElement() {
24
+ this.resizeObserver = null;
25
+ }
26
+ onHostElementFocus(event) {
27
+ if (!isEventFromElement(event, this.hostElement))
28
+ return;
29
+ this.clickableElement.focus();
30
+ }
31
+ determineAutoTouch() {
32
+ if (this.hostElement.hasAttribute('is-touch'))
33
+ return;
34
+ this.isAutoTouch = isTouchDevice();
35
+ }
36
+ determineAutoSmall() {
37
+ var _a, _b;
38
+ if (this.hostElement.hasAttribute('is-small'))
39
+ return;
40
+ const { containerElement, avatarElement } = this;
41
+ const avatarWidth = (_a = avatarElement === null || avatarElement === void 0 ? void 0 : avatarElement.offsetWidth) !== null && _a !== void 0 ? _a : 0;
42
+ const containerWidth = (_b = containerElement === null || containerElement === void 0 ? void 0 : containerElement.offsetWidth) !== null && _b !== void 0 ? _b : 0;
43
+ const totalWidth = avatarWidth + containerWidth;
44
+ this.isAutoSmall = totalWidth < 350;
45
+ }
46
+ generateAvatar() {
47
+ const { avatarName, avatarInitials, avatarSrc, avatarIcon } = this;
48
+ if (avatarIcon) {
49
+ return (h("q2-icon", { type: avatarIcon, ref: e => (this.avatarElement = e), "test-id": "avatar" }));
50
+ }
51
+ else if (avatarName || avatarInitials || avatarSrc) {
52
+ return (h("q2-avatar", { name: avatarName, initials: avatarInitials, src: avatarSrc, ref: e => (this.avatarElement = e), "test-id": "avatar" }));
53
+ }
54
+ }
55
+ generateContent() {
56
+ return (h(Fragment, null,
57
+ this.generateAvatar(),
58
+ h("div", { class: "container", "test-id": "contentContainer", ref: e => (this.containerElement = e) },
59
+ this.title && h("h3", { "test-id": "title" }, this.title),
60
+ this.description && h("p", { "test-id": "description" }, this.description)),
61
+ this.isTouch && (h("q2-icon", { "test-id": "touchIndicator", type: "chevron-right", class: "touch-indicator" }))));
62
+ }
63
+ generateContainerClasses() {
64
+ const { isSmall, isAutoSmall, avatarName, avatarInitials, avatarSrc, avatarIcon, isTouch, isAutoTouch } = this;
65
+ let result = [];
66
+ const showSmall = isSmall || isAutoSmall;
67
+ const showTouch = isTouch || isAutoTouch;
68
+ const hasAvatar = avatarName || avatarInitials || avatarSrc || avatarIcon;
69
+ if (showSmall)
70
+ result.push('is-small');
71
+ if (showTouch)
72
+ result.push('is-touch');
73
+ if (hasAvatar)
74
+ result.push('has-avatar');
75
+ return result.join(' ');
76
+ }
77
+ render() {
78
+ const { url } = this;
79
+ return !!url ? (h("a", { ref: e => (this.clickableElement = e), href: this.url, class: this.generateContainerClasses(), target: this.target, rel: "noopener noreferrer", "test-id": "clickableElement", onClick: this.handleClick }, this.generateContent())) : (h("button", { ref: e => (this.clickableElement = e), class: this.generateContainerClasses(), "test-id": "clickableElement", type: "button", onClick: this.handleClick }, this.generateContent()));
80
+ }
81
+ static get is() { return "q2-card"; }
82
+ static get encapsulation() { return "shadow"; }
83
+ static get originalStyleUrls() { return {
84
+ "$": ["styles.scss"]
85
+ }; }
86
+ static get styleUrls() { return {
87
+ "$": ["styles.css"]
88
+ }; }
89
+ static get properties() { return {
90
+ "title": {
91
+ "type": "string",
92
+ "mutable": false,
93
+ "complexType": {
94
+ "original": "string",
95
+ "resolved": "string",
96
+ "references": {}
97
+ },
98
+ "required": false,
99
+ "optional": false,
100
+ "docs": {
101
+ "tags": [],
102
+ "text": ""
103
+ },
104
+ "attribute": "title",
105
+ "reflect": true
106
+ },
107
+ "description": {
108
+ "type": "string",
109
+ "mutable": false,
110
+ "complexType": {
111
+ "original": "string",
112
+ "resolved": "string",
113
+ "references": {}
114
+ },
115
+ "required": false,
116
+ "optional": false,
117
+ "docs": {
118
+ "tags": [],
119
+ "text": ""
120
+ },
121
+ "attribute": "description",
122
+ "reflect": true
123
+ },
124
+ "avatarName": {
125
+ "type": "string",
126
+ "mutable": false,
127
+ "complexType": {
128
+ "original": "string",
129
+ "resolved": "string",
130
+ "references": {}
131
+ },
132
+ "required": false,
133
+ "optional": false,
134
+ "docs": {
135
+ "tags": [],
136
+ "text": ""
137
+ },
138
+ "attribute": "avatar-name",
139
+ "reflect": true
140
+ },
141
+ "avatarInitials": {
142
+ "type": "string",
143
+ "mutable": false,
144
+ "complexType": {
145
+ "original": "string",
146
+ "resolved": "string",
147
+ "references": {}
148
+ },
149
+ "required": false,
150
+ "optional": false,
151
+ "docs": {
152
+ "tags": [],
153
+ "text": ""
154
+ },
155
+ "attribute": "avatar-initials",
156
+ "reflect": true
157
+ },
158
+ "avatarIcon": {
159
+ "type": "string",
160
+ "mutable": false,
161
+ "complexType": {
162
+ "original": "string",
163
+ "resolved": "string",
164
+ "references": {}
165
+ },
166
+ "required": false,
167
+ "optional": false,
168
+ "docs": {
169
+ "tags": [],
170
+ "text": ""
171
+ },
172
+ "attribute": "avatar-icon",
173
+ "reflect": true
174
+ },
175
+ "avatarSrc": {
176
+ "type": "string",
177
+ "mutable": false,
178
+ "complexType": {
179
+ "original": "string",
180
+ "resolved": "string",
181
+ "references": {}
182
+ },
183
+ "required": false,
184
+ "optional": false,
185
+ "docs": {
186
+ "tags": [],
187
+ "text": ""
188
+ },
189
+ "attribute": "avatar-src",
190
+ "reflect": true
191
+ },
192
+ "isSmall": {
193
+ "type": "boolean",
194
+ "mutable": false,
195
+ "complexType": {
196
+ "original": "boolean",
197
+ "resolved": "boolean",
198
+ "references": {}
199
+ },
200
+ "required": false,
201
+ "optional": false,
202
+ "docs": {
203
+ "tags": [],
204
+ "text": ""
205
+ },
206
+ "attribute": "is-small",
207
+ "reflect": true
208
+ },
209
+ "isTouch": {
210
+ "type": "boolean",
211
+ "mutable": false,
212
+ "complexType": {
213
+ "original": "boolean",
214
+ "resolved": "boolean",
215
+ "references": {}
216
+ },
217
+ "required": false,
218
+ "optional": false,
219
+ "docs": {
220
+ "tags": [],
221
+ "text": ""
222
+ },
223
+ "attribute": "is-touch",
224
+ "reflect": true,
225
+ "defaultValue": "isTouchDevice()"
226
+ },
227
+ "url": {
228
+ "type": "string",
229
+ "mutable": false,
230
+ "complexType": {
231
+ "original": "string",
232
+ "resolved": "string",
233
+ "references": {}
234
+ },
235
+ "required": false,
236
+ "optional": false,
237
+ "docs": {
238
+ "tags": [],
239
+ "text": ""
240
+ },
241
+ "attribute": "url",
242
+ "reflect": true
243
+ },
244
+ "target": {
245
+ "type": "string",
246
+ "mutable": false,
247
+ "complexType": {
248
+ "original": "'_self' | '_blank' | '_parent' | '_top'",
249
+ "resolved": "\"_blank\" | \"_parent\" | \"_self\" | \"_top\"",
250
+ "references": {}
251
+ },
252
+ "required": false,
253
+ "optional": false,
254
+ "docs": {
255
+ "tags": [],
256
+ "text": ""
257
+ },
258
+ "attribute": "target",
259
+ "reflect": true
260
+ }
261
+ }; }
262
+ static get states() { return {
263
+ "isAutoTouch": {},
264
+ "isAutoSmall": {}
265
+ }; }
266
+ static get events() { return [{
267
+ "method": "click",
268
+ "name": "click",
269
+ "bubbles": true,
270
+ "cancelable": true,
271
+ "composed": true,
272
+ "docs": {
273
+ "tags": [],
274
+ "text": ""
275
+ },
276
+ "complexType": {
277
+ "original": "any",
278
+ "resolved": "any",
279
+ "references": {}
280
+ }
281
+ }]; }
282
+ static get elementRef() { return "hostElement"; }
283
+ static get listeners() { return [{
284
+ "name": "focus",
285
+ "method": "onHostElementFocus",
286
+ "target": undefined,
287
+ "capture": false,
288
+ "passive": false
289
+ }]; }
290
+ }
@@ -0,0 +1,161 @@
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: block;
69
+ }
70
+
71
+ button,
72
+ a {
73
+ width: 100%;
74
+ text-align: start;
75
+ cursor: pointer;
76
+ height: 100%;
77
+ display: grid;
78
+ gap: var(--tct-card-gap, var(--t-card-gap, var(--app-scale-3x, 15px)));
79
+ margin: 0;
80
+ border: none;
81
+ background: var(--tct-card-background, var(--t-card-background, var(--t-base, #ffffff)));
82
+ padding: var(--tct-card-padding, var(--t-card-padding, var(--app-scale-4x, 20px)));
83
+ color: var(--tct-card-color, var(--t-card-color, var(--t-text, #4d4d4d)));
84
+ text-decoration: none;
85
+ border-radius: var(--tct-card-border-radius, var(--t-card-border-radius, var(--app-border-radius-1, 3px)));
86
+ transition: box-shadow var(--tct-tween-1, var(--app-tween-1, 0.2s ease));
87
+ box-shadow: var(--tct-card-box-shadow, var(--t-card-box-shadow, var(--app-shadow-2, 0 3px 6px rgba(0, 0, 0, 0.3))));
88
+ --comp-avatar-size: var(--tct-card-avatar-size, var(--t-card-avatar-size, 44px));
89
+ --comp-chevron-size: 0;
90
+ }
91
+ @media (hover: hover) {
92
+ button:hover, button:active, button:focus,
93
+ a:hover,
94
+ a:active,
95
+ a:focus {
96
+ color: var(--tct-card-color, var(--t-card-color, var(--t-text, #4d4d4d)));
97
+ }
98
+ button:hover,
99
+ a:hover {
100
+ box-shadow: var(--tct-card-hover-box-shadow, var(--t-card-hover-box-shadow, var(--app-shadow-3, 0 4px 12px rgba(0, 0, 0, 0.3))));
101
+ }
102
+ button:active,
103
+ a:active {
104
+ box-shadow: var(--tct-card-active-box-shadow, var(--t-card-active-box-shadow, var(--app-shadow-1, 0 2px 4px rgba(0, 0, 0, 0.3))));
105
+ }
106
+ }
107
+ button.is-small,
108
+ a.is-small {
109
+ --comp-avatar-size: var(--tct-card-avatar-size, var(--t-card-avatar-size, 26px));
110
+ }
111
+ button.is-touch,
112
+ a.is-touch {
113
+ --comp-chevron-size: var(--tct-card-chevron-size, var(--t-card-chevron-size, 26px));
114
+ grid-template-columns: 1fr var(--comp-chevron-size);
115
+ }
116
+ button.has-avatar,
117
+ a.has-avatar {
118
+ grid-template-columns: var(--comp-avatar-size) 1fr;
119
+ --tct-avatar-width: var(--comp-avatar-size);
120
+ --tct-avatar-height: var(--comp-avatar-size);
121
+ --tct-icon-size: var(--comp-avatar-size);
122
+ }
123
+ button.has-avatar.is-touch,
124
+ a.has-avatar.is-touch {
125
+ grid-template-columns: var(--comp-avatar-size) 1fr var(--comp-chevron-size);
126
+ }
127
+
128
+ .container {
129
+ overflow: hidden;
130
+ display: grid;
131
+ gap: var(--tct-card-container-gap, var(--t-card-container-gap, var(--app-scale-1x, 5px)));
132
+ align-content: start;
133
+ }
134
+
135
+ h3,
136
+ p {
137
+ margin: 0;
138
+ padding: 0;
139
+ line-height: var(--tct-card-font-height, var(--t-card-font-height, 20px));
140
+ }
141
+
142
+ h3 {
143
+ font-weight: var(--tct-card-font-weight, var(--t-card-font-weight, 600));
144
+ font-size: var(--tct-card-font-size, var(--t-card-font-size, 17px));
145
+ text-overflow: ellipsis;
146
+ overflow: hidden;
147
+ white-space: nowrap;
148
+ }
149
+
150
+ p {
151
+ text-overflow: ellipsis;
152
+ overflow: hidden;
153
+ display: -webkit-box;
154
+ -webkit-line-clamp: 2;
155
+ -webkit-box-orient: vertical;
156
+ }
157
+
158
+ .touch-indicator {
159
+ align-self: center;
160
+ --tct-icon-size: var(--comp-chevron-size);
161
+ }
@@ -5,9 +5,10 @@ export class Q2Checkbox {
5
5
  this.checked = false;
6
6
  this.id = `checkbox-${createGuid()}`;
7
7
  ///// Actions ////////
8
- this.onInputChange = (event) => {
8
+ this.onInputClick = (event) => {
9
9
  event.stopPropagation();
10
- if (this.disabled)
10
+ event.preventDefault();
11
+ if (this.disabled || this.readonly)
11
12
  return;
12
13
  if (!(event.target instanceof HTMLInputElement))
13
14
  return;
@@ -19,8 +20,15 @@ export class Q2Checkbox {
19
20
  };
20
21
  this.onControlClick = (event) => {
21
22
  event.stopPropagation();
23
+ if (this.readonly)
24
+ return;
22
25
  this.inputElement.click();
23
26
  };
27
+ this.onKeyDown = (event) => {
28
+ if (this.readonly && event.code === 'Space') {
29
+ event.preventDefault();
30
+ }
31
+ };
24
32
  }
25
33
  ////////// LIFECYCLE HOOKS ////////
26
34
  componentWillLoad() {
@@ -31,7 +39,10 @@ export class Q2Checkbox {
31
39
  }
32
40
  //////// Host Element Events ////////
33
41
  defaultChangeHandler(event) {
34
- if (event.target === this.hostElement && !this.hostElement.onchange && !!event.detail) {
42
+ if (!this.readonly &&
43
+ event.target === this.hostElement &&
44
+ !this.hostElement.onchange &&
45
+ !!event.detail) {
35
46
  this.checked = event.detail.checked;
36
47
  }
37
48
  }
@@ -47,7 +58,7 @@ export class Q2Checkbox {
47
58
  /////// View Methods ///////
48
59
  render() {
49
60
  return (h("div", { class: "checkbox-container" },
50
- h("input", { ref: el => (this.inputElement = el), id: this.id, type: "checkbox", checked: this.indeterminate || this.checked || false, disabled: !!this.disabled || !!this.groupDisabled, class: "sr", value: this.value, name: this.name || this.id, "aria-label": this.label && this.hideLabel ? loc(this.label) : undefined, "test-id": "q2CheckboxInnerCheckBox", onChange: this.onInputChange }),
61
+ h("input", { ref: el => (this.inputElement = el), id: this.id, type: "checkbox", checked: this.indeterminate || this.checked || false, disabled: !!this.disabled || !!this.groupDisabled, class: "sr", value: this.value, name: this.name || this.id, "aria-label": this.label ? loc(this.label) : undefined, "test-id": "q2CheckboxInnerCheckBox", onKeyDown: this.onKeyDown, onClick: this.onInputClick }),
51
62
  h("label", { "test-id": "checkboxButton" },
52
63
  this.generateCheckboxSVG(),
53
64
  !this.hideLabel && (h("div", { class: "q2-checkbox-label-content" },
@@ -210,6 +221,23 @@ export class Q2Checkbox {
210
221
  "attribute": "disabled",
211
222
  "reflect": true
212
223
  },
224
+ "readonly": {
225
+ "type": "boolean",
226
+ "mutable": false,
227
+ "complexType": {
228
+ "original": "boolean",
229
+ "resolved": "boolean",
230
+ "references": {}
231
+ },
232
+ "required": false,
233
+ "optional": false,
234
+ "docs": {
235
+ "tags": [],
236
+ "text": ""
237
+ },
238
+ "attribute": "readonly",
239
+ "reflect": true
240
+ },
213
241
  "value": {
214
242
  "type": "string",
215
243
  "mutable": false,
@@ -66,6 +66,7 @@ button {
66
66
 
67
67
  :host {
68
68
  display: block;
69
+ position: relative;
69
70
  padding: var(--tct-checkbox-vertical-padding, var(--tct-scale-2, var(--app-scale-2, 10px))) 0;
70
71
  }
71
72
 
@@ -138,7 +139,7 @@ input:focus + label .checkbox-icon {
138
139
 
139
140
  .q2-checkbox-label-content {
140
141
  font-weight: var(--tct-checkbox-font-weight, 400);
141
- width: calc(100% - var(--tct-checkbox-size, 20px) - var(--tct-scale-2, var(--app-scale-2, 10px)));
142
+ width: calc( 100% - var(--tct-checkbox-size, 20px) - var(--tct-scale-2, var(--app-scale-2, 10px)) );
142
143
  cursor: inherit;
143
144
  }
144
145