tyrell-components 1.0.0-RC16 → 1.0.0-RC18

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 (240) hide show
  1. package/README.md +1 -1
  2. package/css/tyrell-colors-static.css +1 -316
  3. package/css/tyrell-theme.css +1 -1471
  4. package/css/tyrell.css +1 -1385
  5. package/dist/tyrell-colors-static.css +1 -1
  6. package/dist/tyrell-theme.css +1 -1
  7. package/dist/tyrell.js +1 -1
  8. package/lib/base/ty-component.d.ts +28 -15
  9. package/lib/base/ty-component.js +81 -38
  10. package/lib/components/button.d.ts +14 -0
  11. package/lib/components/button.js +55 -7
  12. package/lib/components/calendar-month.d.ts +7 -1
  13. package/lib/components/calendar-month.js +35 -28
  14. package/lib/components/calendar-navigation.js +19 -6
  15. package/lib/components/calendar.d.ts +27 -3
  16. package/lib/components/calendar.js +107 -63
  17. package/lib/components/checkbox.d.ts +8 -1
  18. package/lib/components/checkbox.js +27 -6
  19. package/lib/components/copy.d.ts +2 -0
  20. package/lib/components/copy.js +15 -31
  21. package/lib/components/date-picker.d.ts +53 -18
  22. package/lib/components/date-picker.js +217 -146
  23. package/lib/components/file-upload.d.ts +4 -1
  24. package/lib/components/file-upload.js +23 -5
  25. package/lib/components/input.d.ts +73 -3
  26. package/lib/components/input.js +158 -22
  27. package/lib/components/modal.d.ts +2 -0
  28. package/lib/components/modal.js +97 -17
  29. package/lib/components/option.d.ts +19 -0
  30. package/lib/components/option.js +45 -31
  31. package/lib/components/popup.js +115 -15
  32. package/lib/components/radio.d.ts +10 -1
  33. package/lib/components/radio.js +22 -29
  34. package/lib/components/resize-observer.js +2 -0
  35. package/lib/components/scroll-container.js +2 -0
  36. package/lib/components/select.d.ts +150 -190
  37. package/lib/components/select.js +501 -796
  38. package/lib/components/selected-tags.d.ts +14 -4
  39. package/lib/components/selected-tags.js +35 -8
  40. package/lib/components/switch.d.ts +9 -1
  41. package/lib/components/switch.js +27 -6
  42. package/lib/components/tabs.js +1 -1
  43. package/lib/components/tag.d.ts +0 -9
  44. package/lib/components/tag.js +0 -11
  45. package/lib/components/textarea.d.ts +47 -2
  46. package/lib/components/textarea.js +81 -17
  47. package/lib/index.d.ts +1 -0
  48. package/lib/index.js +1 -0
  49. package/lib/styles/button.js +21 -19
  50. package/lib/styles/calendar-month.js +1 -1
  51. package/lib/styles/calendar.js +3 -0
  52. package/lib/styles/checkbox.js +11 -5
  53. package/lib/styles/date-picker.js +16 -4
  54. package/lib/styles/file-upload.d.ts +1 -1
  55. package/lib/styles/file-upload.js +3 -3
  56. package/lib/styles/icon.d.ts +1 -1
  57. package/lib/styles/icon.js +2 -2
  58. package/lib/styles/input.js +6 -10
  59. package/lib/styles/option.d.ts +1 -1
  60. package/lib/styles/option.js +6 -7
  61. package/lib/styles/popup.d.ts +1 -1
  62. package/lib/styles/popup.js +2 -0
  63. package/lib/styles/radio.js +12 -6
  64. package/lib/styles/select-base.js +22 -60
  65. package/lib/styles/select.d.ts +1 -1
  66. package/lib/styles/select.js +13 -2
  67. package/lib/styles/switch.js +10 -5
  68. package/lib/styles/tag.js +3 -5
  69. package/lib/styles/textarea.d.ts +1 -1
  70. package/lib/styles/textarea.js +7 -0
  71. package/lib/types/common.d.ts +3 -3
  72. package/lib/utils/calendar-utils.d.ts +49 -0
  73. package/lib/utils/calendar-utils.js +63 -6
  74. package/lib/utils/property-manager.d.ts +6 -5
  75. package/lib/utils/property-manager.js +14 -15
  76. package/lib/utils/scroll-lock.d.ts +10 -4
  77. package/lib/utils/scroll-lock.js +102 -2
  78. package/lib/utils/upgrade-properties.d.ts +21 -0
  79. package/lib/utils/upgrade-properties.js +47 -0
  80. package/lib/utils/validity.d.ts +98 -2
  81. package/lib/utils/validity.js +244 -8
  82. package/lib/version.d.ts +1 -1
  83. package/lib/version.js +1 -1
  84. package/package.json +8 -6
  85. package/lib/base/ty-component.d.ts.map +0 -1
  86. package/lib/base/ty-component.js.map +0 -1
  87. package/lib/components/button.d.ts.map +0 -1
  88. package/lib/components/button.js.map +0 -1
  89. package/lib/components/calendar-month.d.ts.map +0 -1
  90. package/lib/components/calendar-month.js.map +0 -1
  91. package/lib/components/calendar-navigation.d.ts.map +0 -1
  92. package/lib/components/calendar-navigation.js.map +0 -1
  93. package/lib/components/calendar.d.ts.map +0 -1
  94. package/lib/components/calendar.js.map +0 -1
  95. package/lib/components/checkbox.d.ts.map +0 -1
  96. package/lib/components/checkbox.js.map +0 -1
  97. package/lib/components/copy.d.ts.map +0 -1
  98. package/lib/components/copy.js.map +0 -1
  99. package/lib/components/date-picker.d.ts.map +0 -1
  100. package/lib/components/date-picker.js.map +0 -1
  101. package/lib/components/dropdown.d.ts +0 -403
  102. package/lib/components/dropdown.d.ts.map +0 -1
  103. package/lib/components/dropdown.js +0 -1315
  104. package/lib/components/dropdown.js.map +0 -1
  105. package/lib/components/icon.d.ts.map +0 -1
  106. package/lib/components/icon.js.map +0 -1
  107. package/lib/components/input.d.ts.map +0 -1
  108. package/lib/components/input.js.map +0 -1
  109. package/lib/components/modal.d.ts.map +0 -1
  110. package/lib/components/modal.js.map +0 -1
  111. package/lib/components/multiselect.d.ts +0 -389
  112. package/lib/components/multiselect.d.ts.map +0 -1
  113. package/lib/components/multiselect.js +0 -1301
  114. package/lib/components/multiselect.js.map +0 -1
  115. package/lib/components/option.d.ts.map +0 -1
  116. package/lib/components/option.js.map +0 -1
  117. package/lib/components/popup.d.ts.map +0 -1
  118. package/lib/components/popup.js.map +0 -1
  119. package/lib/components/resize-observer.d.ts.map +0 -1
  120. package/lib/components/resize-observer.js.map +0 -1
  121. package/lib/components/scroll-container.d.ts.map +0 -1
  122. package/lib/components/scroll-container.js.map +0 -1
  123. package/lib/components/step.d.ts.map +0 -1
  124. package/lib/components/step.js.map +0 -1
  125. package/lib/components/tab.d.ts.map +0 -1
  126. package/lib/components/tab.js.map +0 -1
  127. package/lib/components/tabs.d.ts.map +0 -1
  128. package/lib/components/tabs.js.map +0 -1
  129. package/lib/components/tag.d.ts.map +0 -1
  130. package/lib/components/tag.js.map +0 -1
  131. package/lib/components/textarea.d.ts.map +0 -1
  132. package/lib/components/textarea.js.map +0 -1
  133. package/lib/components/tooltip.d.ts.map +0 -1
  134. package/lib/components/tooltip.js.map +0 -1
  135. package/lib/components/wizard.d.ts.map +0 -1
  136. package/lib/components/wizard.js.map +0 -1
  137. package/lib/icons/fontawesome/brands.d.ts.map +0 -1
  138. package/lib/icons/fontawesome/brands.js.map +0 -1
  139. package/lib/icons/fontawesome/regular.d.ts.map +0 -1
  140. package/lib/icons/fontawesome/regular.js.map +0 -1
  141. package/lib/icons/fontawesome/solid.d.ts.map +0 -1
  142. package/lib/icons/fontawesome/solid.js.map +0 -1
  143. package/lib/icons/heroicons/micro.d.ts.map +0 -1
  144. package/lib/icons/heroicons/micro.js.map +0 -1
  145. package/lib/icons/heroicons/mini.d.ts.map +0 -1
  146. package/lib/icons/heroicons/mini.js.map +0 -1
  147. package/lib/icons/heroicons/outline.d.ts.map +0 -1
  148. package/lib/icons/heroicons/outline.js.map +0 -1
  149. package/lib/icons/heroicons/solid.d.ts.map +0 -1
  150. package/lib/icons/heroicons/solid.js.map +0 -1
  151. package/lib/icons/lucide.d.ts.map +0 -1
  152. package/lib/icons/lucide.js.map +0 -1
  153. package/lib/icons/material/filled.d.ts.map +0 -1
  154. package/lib/icons/material/filled.js.map +0 -1
  155. package/lib/icons/material/outlined.d.ts.map +0 -1
  156. package/lib/icons/material/outlined.js.map +0 -1
  157. package/lib/icons/material/round.d.ts.map +0 -1
  158. package/lib/icons/material/round.js.map +0 -1
  159. package/lib/icons/material/sharp.d.ts.map +0 -1
  160. package/lib/icons/material/sharp.js.map +0 -1
  161. package/lib/icons/material/two-tone.d.ts.map +0 -1
  162. package/lib/icons/material/two-tone.js.map +0 -1
  163. package/lib/index.d.ts.map +0 -1
  164. package/lib/index.js.map +0 -1
  165. package/lib/styles/button.d.ts.map +0 -1
  166. package/lib/styles/button.js.map +0 -1
  167. package/lib/styles/calendar-month.d.ts.map +0 -1
  168. package/lib/styles/calendar-month.js.map +0 -1
  169. package/lib/styles/calendar-navigation.d.ts.map +0 -1
  170. package/lib/styles/calendar-navigation.js.map +0 -1
  171. package/lib/styles/calendar.d.ts.map +0 -1
  172. package/lib/styles/calendar.js.map +0 -1
  173. package/lib/styles/copy.d.ts.map +0 -1
  174. package/lib/styles/copy.js.map +0 -1
  175. package/lib/styles/date-picker.d.ts.map +0 -1
  176. package/lib/styles/date-picker.js.map +0 -1
  177. package/lib/styles/dropdown.d.ts +0 -12
  178. package/lib/styles/dropdown.d.ts.map +0 -1
  179. package/lib/styles/dropdown.js +0 -725
  180. package/lib/styles/dropdown.js.map +0 -1
  181. package/lib/styles/icon.d.ts.map +0 -1
  182. package/lib/styles/icon.js.map +0 -1
  183. package/lib/styles/input.d.ts.map +0 -1
  184. package/lib/styles/input.js.map +0 -1
  185. package/lib/styles/modal.d.ts.map +0 -1
  186. package/lib/styles/modal.js.map +0 -1
  187. package/lib/styles/multiselect.d.ts +0 -6
  188. package/lib/styles/multiselect.d.ts.map +0 -1
  189. package/lib/styles/multiselect.js +0 -568
  190. package/lib/styles/multiselect.js.map +0 -1
  191. package/lib/styles/option.d.ts.map +0 -1
  192. package/lib/styles/option.js.map +0 -1
  193. package/lib/styles/popup.d.ts.map +0 -1
  194. package/lib/styles/popup.js.map +0 -1
  195. package/lib/styles/resize-observer.d.ts.map +0 -1
  196. package/lib/styles/resize-observer.js.map +0 -1
  197. package/lib/styles/scroll-container.d.ts.map +0 -1
  198. package/lib/styles/scroll-container.js.map +0 -1
  199. package/lib/styles/step.d.ts.map +0 -1
  200. package/lib/styles/step.js.map +0 -1
  201. package/lib/styles/tab.d.ts.map +0 -1
  202. package/lib/styles/tab.js.map +0 -1
  203. package/lib/styles/tabs.d.ts.map +0 -1
  204. package/lib/styles/tabs.js.map +0 -1
  205. package/lib/styles/tag.d.ts.map +0 -1
  206. package/lib/styles/tag.js.map +0 -1
  207. package/lib/styles/textarea.d.ts.map +0 -1
  208. package/lib/styles/textarea.js.map +0 -1
  209. package/lib/styles/tooltip.d.ts.map +0 -1
  210. package/lib/styles/tooltip.js.map +0 -1
  211. package/lib/styles/wizard.d.ts.map +0 -1
  212. package/lib/styles/wizard.js.map +0 -1
  213. package/lib/types/common.d.ts.map +0 -1
  214. package/lib/types/common.js.map +0 -1
  215. package/lib/utils/calendar-utils.d.ts.map +0 -1
  216. package/lib/utils/calendar-utils.js.map +0 -1
  217. package/lib/utils/icon-registry.d.ts.map +0 -1
  218. package/lib/utils/icon-registry.js.map +0 -1
  219. package/lib/utils/locale.d.ts.map +0 -1
  220. package/lib/utils/locale.js.map +0 -1
  221. package/lib/utils/number-format.d.ts.map +0 -1
  222. package/lib/utils/number-format.js.map +0 -1
  223. package/lib/utils/parse-boolean.d.ts +0 -39
  224. package/lib/utils/parse-boolean.d.ts.map +0 -1
  225. package/lib/utils/parse-boolean.js +0 -23
  226. package/lib/utils/parse-boolean.js.map +0 -1
  227. package/lib/utils/positioning.d.ts.map +0 -1
  228. package/lib/utils/positioning.js.map +0 -1
  229. package/lib/utils/property-capture.d.ts.map +0 -1
  230. package/lib/utils/property-capture.js.map +0 -1
  231. package/lib/utils/property-manager.d.ts.map +0 -1
  232. package/lib/utils/property-manager.js.map +0 -1
  233. package/lib/utils/resize-observer.d.ts.map +0 -1
  234. package/lib/utils/resize-observer.js.map +0 -1
  235. package/lib/utils/scroll-lock.d.ts.map +0 -1
  236. package/lib/utils/scroll-lock.js.map +0 -1
  237. package/lib/utils/styles.d.ts.map +0 -1
  238. package/lib/utils/styles.js.map +0 -1
  239. package/lib/version.d.ts.map +0 -1
  240. package/lib/version.js.map +0 -1
@@ -4,6 +4,7 @@ import { ensureStyles } from "../utils/styles.js";
4
4
  import { syncCustomFlavorSheet } from "../utils/flavor-sheet.js";
5
5
  import { radioStyles, radioCustomFlavorCss } from "../styles/radio.js";
6
6
  import { REQUIRED_ICON_SVG } from "../utils/icons.js";
7
+ import { nativeMessage } from "../utils/validity.js";
7
8
  export class TyRadio extends TyComponent {
8
9
  constructor() {
9
10
  super();
@@ -133,6 +134,7 @@ set size(v) { this.setProperty("size", v); }
133
134
  get flavor() { return this.getProperty("flavor"); }
134
135
  set flavor(v) { this.setProperty("flavor", v); }
135
136
  }
137
+ TyRadio.labelClicks = true;
136
138
  TyRadio.properties = {
137
139
  value: { type: "string", default: "" },
138
140
  checked: {
@@ -184,6 +186,14 @@ this.syncChildren();
184
186
  getFormValue() {
185
187
  return this.value || null;
186
188
  }
189
+ focus(options) {
190
+ const enabled = this.getRadios().filter((r) => !r.disabled);
191
+ const stop = enabled.find((r) => r.checked) ?? enabled[0];
192
+ if (stop)
193
+ stop.focus(options);
194
+ else
195
+ super.focus(options);
196
+ }
187
197
  getRadios() {
188
198
  return Array.from(this.querySelectorAll("ty-radio"))
189
199
  .filter((r) => typeof r.setTabStop === "function");
@@ -215,7 +225,7 @@ updateValidity() {
215
225
  if (this.required && !this.disabled && !this.value) {
216
226
  const anchor = this.getRadios().find((r) => !r.disabled);
217
227
  const target = anchor?.shadowRoot?.querySelector(".radio-container");
218
- this.applyValidity({ valueMissing: true }, "Please select an option", target ?? undefined);
228
+ this.applyValidity({ valueMissing: true }, nativeMessage("input", { type: "radio", name: "ty", required: true }), target ?? undefined);
219
229
  }
220
230
  else {
221
231
  this.applyValidity({});
@@ -228,16 +238,17 @@ const detail = e.detail;
228
238
  const newValue = detail?.value;
229
239
  if (typeof newValue !== "string" || newValue === this.value)
230
240
  return;
231
- this.value = newValue;
241
+ this.select(newValue, e);
242
+ }
243
+ select(value, originalEvent) {
244
+ if (value === this.value)
245
+ return;
246
+ this.value = value;
232
247
  this.syncChildren();
248
+ const detail = { value, formValue: value, originalEvent };
233
249
  setTimeout(() => {
234
- const eventDetail = {
235
- value: newValue,
236
- formValue: newValue,
237
- originalEvent: e,
238
- };
239
- this.dispatchEvent(new CustomEvent("input", { detail: eventDetail, bubbles: true, composed: true }));
240
- this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
250
+ this.dispatchEvent(new CustomEvent("input", { detail, bubbles: true, composed: true }));
251
+ this.dispatchEvent(new CustomEvent("change", { detail, bubbles: true, composed: true }));
241
252
  }, 0);
242
253
  }
243
254
  handleKeydown(e) {
@@ -262,16 +273,7 @@ nextIndex = current
262
273
  else if (["Space", " ", "Enter"].includes(e.key)) {
263
274
  if (current) {
264
275
  e.preventDefault();
265
- this.value = current.value;
266
- this.syncChildren();
267
- const eventDetail = {
268
- value: current.value,
269
- formValue: current.value,
270
- originalEvent: e,
271
- };
272
- setTimeout(() => {
273
- this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
274
- }, 0);
276
+ this.select(current.value, e);
275
277
  }
276
278
  return;
277
279
  }
@@ -281,16 +283,7 @@ return;
281
283
  const next = radios[nextIndex];
282
284
  if (next) {
283
285
  next.focus();
284
- this.value = next.value;
285
- this.syncChildren();
286
- const eventDetail = {
287
- value: next.value,
288
- formValue: next.value,
289
- originalEvent: e,
290
- };
291
- setTimeout(() => {
292
- this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
293
- }, 0);
286
+ this.select(next.value, e);
294
287
  }
295
288
  }
296
289
  removeEventListeners() {
@@ -1,6 +1,7 @@
1
1
  import { ensureStyles } from '../utils/styles.js';
2
2
  import { resizeObserverStyles } from '../styles/resize-observer.js';
3
3
  import { updateSize, removeSize } from '../utils/resize-observer.js';
4
+ import { upgradeProperties } from '../utils/upgrade-properties.js';
4
5
  export class TyResizeObserver extends HTMLElement {
5
6
  static get observedAttributes() {
6
7
  return ['id', 'debounce'];
@@ -20,6 +21,7 @@ ensureStyles(shadow, { css: resizeObserverStyles, id: 'ty-resize-observer' });
20
21
  shadow.innerHTML = '<slot></slot>';
21
22
  }
22
23
  connectedCallback() {
24
+ upgradeProperties(this);
23
25
  this.setupObserver();
24
26
  }
25
27
  attributeChangedCallback(name, oldValue, newValue) {
@@ -1,6 +1,7 @@
1
1
  import { ensureStyles } from '../utils/styles.js';
2
2
  import { scrollContainerStyles } from '../styles/scroll-container.js';
3
3
  import { CustomScrollbar } from '../utils/custom-scrollbar.js';
4
+ import { upgradeProperties } from '../utils/upgrade-properties.js';
4
5
  export class TyScrollContainer extends HTMLElement {
5
6
  static get observedAttributes() {
6
7
  return ['no-shadow', 'max-height', 'hide-scrollbar', 'custom-scrollbar', 'overflow-x', 'scroll-anchoring'];
@@ -112,6 +113,7 @@ this._shadowLeft = shadow.querySelector('.shadow-left');
112
113
  this._shadowRight = shadow.querySelector('.shadow-right');
113
114
  }
114
115
  connectedCallback() {
116
+ upgradeProperties(this);
115
117
  this._scrollWrapper?.addEventListener('scroll', this._onScroll, { passive: true });
116
118
  this._resizeObserver = new ResizeObserver(() => {
117
119
  this._scrollbar?.update();
@@ -3,6 +3,14 @@
3
3
  * Cardinality follows native <select>: default single (scalar value, picking closes
4
4
  * the popup), `multiple` toggles options and submits repeated `name=` FormData entries.
5
5
  * Skins: default form field, `compact` content-hugging trigger, slot="trigger" custom.
6
+ *
7
+ * The selection is the `value` attribute/property, nothing else. Options are a
8
+ * plain list: the select draws their check through `option.checked`, a
9
+ * property, and never writes selection state onto them. A closed single select
10
+ * shows the picked option itself in its trigger (manual slot assignment), so
11
+ * nothing is added to the children a framework renders. `external-selection` hands
12
+ * the selection to the app: it marks the options it holds `selected`, the
13
+ * select reads those marks and reports picks as `change` events.
6
14
  */
7
15
  import type { Flavor, Size } from "../types/common.js";
8
16
  import { type Placement } from "../utils/positioning.js";
@@ -18,13 +26,13 @@ interface SelectState {
18
26
  search: string;
19
27
  highlightedIndex: number;
20
28
  filteredTags: TagData[];
21
- selectedValues: string[];
22
29
  mode: "desktop" | "mobile";
23
30
  }
24
31
  /**
25
32
  * Ty Select Component
26
33
  */
27
34
  export declare class TySelect extends TyComponent<SelectState> {
35
+ protected static slotAssignment: SlotAssignmentMode;
28
36
  protected static properties: {
29
37
  value: {
30
38
  type: "string";
@@ -73,6 +81,11 @@ export declare class TySelect extends TyComponent<SelectState> {
73
81
  visual: boolean;
74
82
  default: boolean;
75
83
  };
84
+ error: {
85
+ type: "string";
86
+ visual: boolean;
87
+ default: string;
88
+ };
76
89
  noClear: {
77
90
  type: "boolean";
78
91
  visual: boolean;
@@ -82,25 +95,21 @@ export declare class TySelect extends TyComponent<SelectState> {
82
95
  type: "boolean";
83
96
  visual: boolean;
84
97
  default: boolean;
85
- aliases: {
86
- "external-search": boolean;
87
- };
98
+ };
99
+ externalSelection: {
100
+ type: "boolean";
101
+ visual: boolean;
102
+ default: boolean;
88
103
  };
89
104
  allowCreate: {
90
105
  type: "boolean";
91
106
  visual: boolean;
92
107
  default: boolean;
93
- aliases: {
94
- "allow-create": boolean;
95
- };
96
108
  };
97
109
  createTransform: {
98
110
  type: "string";
99
111
  visual: boolean;
100
112
  default: string;
101
- aliases: {
102
- "create-transform": boolean;
103
- };
104
113
  coerce: (v: any) => "none" | "slug";
105
114
  };
106
115
  notSearchable: {
@@ -108,13 +117,6 @@ export declare class TySelect extends TyComponent<SelectState> {
108
117
  visual: boolean;
109
118
  default: boolean;
110
119
  };
111
- align: {
112
- type: "string";
113
- visual: boolean;
114
- default: string;
115
- validate: (v: any) => boolean;
116
- coerce: (v: any) => "start" | "end" | "center";
117
- };
118
120
  placement: {
119
121
  type: "string";
120
122
  visual: boolean;
@@ -159,39 +161,18 @@ export declare class TySelect extends TyComponent<SelectState> {
159
161
  default: string;
160
162
  };
161
163
  };
162
- private _name;
163
- private _multiple;
164
- private _compact;
165
- private _placeholder;
166
- private _label;
167
- private _disabled;
168
- private _readonly;
169
- private _required;
170
- private _clearable;
171
- private _externalSearch;
172
- private _allowCreate;
173
- private _createTransform;
174
- private _notSearchable;
175
- private _loading;
176
- private _scrollLockId;
177
- private _size;
178
- private _availableLabel;
179
- private _selectedLabel;
180
- private _noOptionsMessage;
164
+ private readonly _uid;
181
165
  private _state;
182
- private _stubClickHandler;
183
- private _tagClickHandler;
184
- private _searchInputHandler;
185
- private _blockSearchClick;
166
+ private _scrollLockId;
186
167
  private _keyboardHandler;
187
- private _debounce;
188
168
  private _searchDebounceTimer;
189
169
  private _optionsScrollbar;
190
170
  private _childObserver;
191
- private _selectedClone;
192
171
  private _customFlavorSheet;
172
+ private _ariaTrigger;
173
+ private _ariaObserver;
193
174
  constructor();
194
- /** TyComponent handles property capture automatically. */
175
+ /** TyComponent renders right after this on the first connect. */
195
176
  protected onConnect(): void;
196
177
  /** Custom (non-built-in) flavors — see utils/flavor-sheet.ts. */
197
178
  private _syncCustomFlavor;
@@ -199,98 +180,73 @@ export declare class TySelect extends TyComponent<SelectState> {
199
180
  /** Handle state synchronization BEFORE render. */
200
181
  protected onPropertiesChanged(changes: PropertyChange[]): void;
201
182
  /**
202
- * Toggle the loading visual state on the open popup.
203
- * Replaces the available-options area with a centered spinner; search input stays usable.
204
- * Pulls the latest registered loader SVG on each call so registry changes
205
- * take effect on the next loading toggle.
183
+ * Toggle the loading visual state on the open popup: a centered spinner in
184
+ * place of the options; the search input stays usable. Reads the loader
185
+ * registry each time, so a newly registered loader shows next time.
206
186
  */
207
187
  private applyLoadingState;
208
188
  /** Form value: a plain entry for single, FormData with repeated entries for multiple (HTMX standard). */
209
189
  protected getFormValue(): FormDataEntryValue | FormData | null;
210
- private parseValue;
211
- /** Initialize component state from the value property / pre-selected children. */
212
- private initializeState;
213
- /**
214
- * Declarative init: no `value` attribute, but markup pre-marked one or more
215
- * options `selected` — native <select> semantics. This is the ONE place
216
- * selection is read FROM the DOM rather than treated as a rendering of
217
- * state (see getSelectedValues()): it seeds initial state, once. After
218
- * this, `value` rules — flipping an option's `selected` property later
219
- * does nothing, same as native.
220
- *
221
- * Called from initializeState() at connect AND from the child observer:
222
- * a real HTML parser upgrades a custom element the moment its start tag is
223
- * seen, BEFORE its children exist — `<ty-select>` connects with zero
224
- * `<ty-option>` children when it's part of the page's own markup (as
225
- * opposed to an already-built fragment attached via innerHTML/appendChild,
226
- * where children exist at connect). Calling this only at connect would
227
- * silently miss every option parsed after that instant, which is the
228
- * common case for markup that is literally in the page's initial HTML.
229
- *
230
- * Safe to call repeatedly: no-ops once `value` has ever been explicitly
231
- * set (attribute or property) or state is already non-empty — including
232
- * after a real `.clear()`, which removes `selected` from every option via
233
- * syncSelectedTags, so there is nothing left here to (re-)seed from.
234
- */
235
- private resolveDeclarativeSelection;
236
190
  /**
237
- * Get all option elements from the component (ty-option preferred, ty-tag accepted)
191
+ * Focus the trigger: a slotted one, else the field. The host itself isn't
192
+ * focusable. A slotted trigger that can't take focus (a <span>, a disabled
193
+ * button) leaves it to the field.
238
194
  */
195
+ focus(options?: FocusOptions): void;
196
+ private parseValue;
197
+ /** The selection: the `value` property. external-selection holds none. */
198
+ private getSelectedValues;
239
199
  private getTagElements;
240
- private getTagData;
241
- /**
242
- * Select an option - attribute only. The option stays in the list with
243
- * selected styling; chips are rendered out-of-band (ty-selected-options).
244
- */
245
- private selectTag;
246
200
  /**
247
- * Deselect an option - attribute only.
201
+ * The options on offer: all but the ones the author hid (`hidden`, like a
202
+ * native <option hidden>). The search filters these and the keyboard walks
203
+ * them; a hidden option can still be the value.
248
204
  */
249
- private deselectTag;
205
+ private getOfferedTags;
206
+ private getTagData;
207
+ private findOption;
208
+ /** Draw each option's check from the selection (or, external, the app's marks). */
209
+ private paintOptions;
250
210
  /**
251
- * Get the array of currently selected values.
252
- *
253
- * Reads STATE (`_state.selectedValues`), not the DOM: `value` is the
254
- * selection, and an option's `selected` attribute is a rendering of it
255
- * (written by syncSelectedTags below), never the other way round. This
256
- * matters whenever options don't fully reflect the selection — external
257
- * search legitimately has a selected value with no matching option
258
- * present; a DOM scan would report empty and desync .value, `required`
259
- * validation and the click-toggle logic from what's actually selected.
211
+ * The option the trigger shows: single select, list closed, the picked
212
+ * option — if it is a direct child (only those can be slotted).
260
213
  */
261
- private getSelectedValues;
262
- private syncSelectedTags;
214
+ private shownOption;
263
215
  /**
264
- * role="option" for every current option/tag — separate from
265
- * syncSelectedTags (which only runs when the `value` property changes)
266
- * so it also covers the "nothing selected yet, value never touched"
267
- * startup case. Idempotent; cheap to call from the child MutationObserver
268
- * on every light-DOM change.
216
+ * Every child goes to the slot it asks for, the rest to the list — except
217
+ * the option the trigger shows. The real node: page CSS styles it, and the
218
+ * children a framework rendered stay exactly its own.
269
219
  */
270
- private ensureOptionRoles;
271
- /** Central update function — synchronizes everything via TyComponent's property system. */
220
+ private assignSlots;
221
+ /** What the trigger shows, and where every child is slotted. */
222
+ private syncTrigger;
223
+ /** Set the selection; with `dispatchChange`, also fire `change` (a user action). */
272
224
  private updateComponentValue;
273
- /**
274
- * Build rich item info for values, read off the matching option elements
275
- */
225
+ /** Rich item info for values, read off the matching options. */
276
226
  private getSelectedItems;
277
227
  private calculatePosition;
278
228
  private _setupOptionsScrollbar;
279
229
  private _destroyOptionsScrollbar;
230
+ /** Open the popup (desktop dropdown or mobile full-screen dialog). */
231
+ private open;
232
+ private close;
280
233
  /**
281
- * Open dropdown dialog (desktop mode)
282
- *
283
- * `<dialog>.showModal()` puts the dialog in the top layer with a backdrop, but
284
- * does NOT prevent the page behind it from scrolling. We use the shared scroll
285
- * lock utility (overflow:hidden on <html>) to keep wheel/touch scrolling from
286
- * leaking through to the body — same behavior <ty-dropdown> and <ty-modal>
287
- * implement.
234
+ * `<dialog>.showModal()` puts the popup in the top layer but does NOT stop
235
+ * the page behind it from scrolling: the shared scroll lock does.
288
236
  */
237
+ private lockPageScroll;
238
+ private unlockPageScroll;
239
+ private setExpanded;
289
240
  private openDropdown;
290
241
  private closeDropdown;
291
- /** Open mobile modal — <dialog> handles z-index natively. */
292
242
  private openMobileModal;
293
243
  private closeMobileModal;
244
+ /**
245
+ * On close: empty the search box and show every option again. With
246
+ * external-search the app filters, so it gets an empty `search` instead
247
+ * (right away, not debounced: its list should be reset before a reopen).
248
+ */
249
+ private resetSearch;
294
250
  private handleStubClick;
295
251
  /**
296
252
  * .select-clear click — must stop propagation before it bubbles to the
@@ -298,22 +254,12 @@ export declare class TySelect extends TyComponent<SelectState> {
298
254
  */
299
255
  private handleClearClick;
300
256
  /**
301
- * Keyboard-open the (closed) stub. The stub is a plain div with
302
- * tabindex="0", not a native <button> — Enter/Space don't turn into
303
- * click events on their own the way they do for real form controls, and
304
- * without this a keyboard-only user could Tab to the field but never
305
- * open it. document-level handleKeyboard() only runs once already open
306
- * (it early-returns on !this._state.open), so this is the other half.
257
+ * Keyboard-open the closed stub: it is a div with tabindex="0", so
258
+ * Enter/Space don't click it. handleKeyboard takes over once open.
307
259
  */
308
260
  private handleStubKeydown;
309
261
  private handleTagClick;
310
- /**
311
- * Select/toggle a tag by element — the part of handleTagClick that has no
312
- * dependency on a real DOM event, so keyboard/programmatic callers (Enter
313
- * on a highlighted option, allow-create's exact-match dedup) can call it
314
- * directly instead of faking an Event object just to satisfy
315
- * preventDefault()/stopPropagation().
316
- */
262
+ /** Pick an option: click, Enter on a highlighted one, allow-create's exact match. */
317
263
  private selectByTag;
318
264
  /**
319
265
  * allow-create: Enter with unmatched search text mints a new option.
@@ -324,85 +270,105 @@ export declare class TySelect extends TyComponent<SelectState> {
324
270
  */
325
271
  private tryCreateFromSearch;
326
272
  /**
327
- * Multiple + allow-create: clear the search box and re-show the full
328
- * (now-longer) option list so the next tag can be typed immediately —
329
- * the tags-input pattern.
273
+ * Multiple + allow-create: clear the search box and show the full (now
274
+ * longer) list, so the next tag can be typed right away.
330
275
  */
331
276
  private clearSearchAfterCreate;
332
- private blockSearchClick;
277
+ private searchInput;
333
278
  private handleSearchInput;
334
279
  private handleKeyboard;
335
280
  /**
336
- * Next tag index in `direction` (-1/1) that isn't disabled, wrapping
337
- * around — mirrors handleTagClick's disabled check so keyboard nav can
338
- * never land on/select what a click already refuses to. Returns -1 if
339
- * every tag is disabled (or there are none).
281
+ * Next tag index in `direction` (-1/1) that a click would accept, wrapping
282
+ * around: not disabled, and not out of sight (`tags` is the list as it was
283
+ * offered; an option can get `hidden` while open, by a server patch).
284
+ * -1 if there is none.
340
285
  */
341
286
  private nextEnabledTagIndex;
342
287
  private filterTags;
288
+ /**
289
+ * Search filtering marks the options it leaves out `filtered-out`, never
290
+ * `hidden`: that one is the author's (see getOfferedTags).
291
+ */
343
292
  private updateTagVisibility;
344
293
  private updateOptionsVisibility;
345
294
  private clearHighlights;
346
295
  private highlightTag;
347
- /** Dispatch the search event for external search handling, with optional debounce. */
296
+ /** external-search: fire `search`, after `debounce` ms when set. */
348
297
  private dispatchSearchEvent;
349
298
  private fireSearchEvent;
350
299
  /**
351
- * Dispatch lifecycle events for popup open/close.
352
- * On open with external-search, also fire a `search` event with an empty
353
- * query so consumers have a clean hook to reset/refetch the option list.
300
+ * Popup lifecycle events. They do NOT bubble, like native <dialog>
301
+ * open/close: a bubbling `close` from a select in a ty-modal would close
302
+ * the modal. On open, external-search also gets an empty `search`, a hook
303
+ * to reset or refetch the list.
354
304
  */
355
305
  private fireOpenEvent;
356
306
  private fireCloseEvent;
357
307
  private dispatchChangeEvent;
308
+ /** One sync of everything the state shows; idempotent. */
358
309
  protected render(): void;
310
+ /**
311
+ * The options changed while the list is open (a morph, an external-search
312
+ * swap): filter the new ones by the query (a morph also strips the marks
313
+ * of the old filter), and let the keyboard walk them, not the old ones.
314
+ */
315
+ private refreshOpenList;
359
316
  /**
360
317
  * Patch label, required marker and disabled/compact state onto the
361
- * already-built shadow DOM. renderDesktop/renderMobile only write markup on
362
- * first render, so without this toggling `required`, `label`, `disabled` or
363
- * `compact` after connect never showed up.
318
+ * already-built shadow DOM (build() writes the markup once).
364
319
  */
365
320
  private syncFieldChrome;
366
321
  /**
367
- * Reflect constraint validation to the owning <form> via ElementInternals.
368
- * Without this `required` is only cosmetic — form.checkValidity() (and a
369
- * real submit) never actually blocks on an empty required select. Mirrors
370
- * ty-input's updateValidity(): empty + required => valueMissing; disabled
371
- * fields are barred from constraint validation.
322
+ * A slotted trigger is what takes focus (focus()), so it carries the error
323
+ * state too. aria-describedby can't reach into our shadow root from the
324
+ * light DOM: the message goes in aria-description instead. The trigger is
325
+ * the author's markup, so a morph can strip these while the error stays:
326
+ * a watch on them puts them back. Writes only on a real change, or the
327
+ * watch would feed itself.
328
+ */
329
+ private syncTriggerAria;
330
+ /**
331
+ * Reflect constraint validation to the owning <form> via ElementInternals:
332
+ * empty + required => valueMissing, with a native <select>'s message.
333
+ * Disabled fields, and external-selection (the app holds the selection),
334
+ * are barred from it.
372
335
  */
373
336
  private updateValidity;
374
337
  /**
375
- * When a consumer slots their own trigger (slot="trigger"), strip the
376
- * default field chrome so the trigger is styled entirely by the consumer.
338
+ * A slotted trigger (slot="trigger") replaces the field chrome. has-trigger
339
+ * on the host sizes it to the trigger (Blink can't parse :has() inside
340
+ * :host()); render() puts it back if a morph strips it.
377
341
  */
378
- private setupTriggerSlot;
379
- private setupEventListeners;
380
- private buildStubClasses;
381
- private renderDesktop;
382
- private renderMobile;
383
- private setupMobileEventListeners;
384
- private handleMobileStubClick;
385
- /** Keyboard-open the (closed) mobile stub — see handleStubKeydown for why this is needed. */
386
- private handleMobileStubKeydown;
387
- private handleMobileTagClick;
342
+ private syncTriggerSlot;
343
+ /**
344
+ * Build the shadow DOM once. Mobile (touch, narrow) gets a full-screen
345
+ * dialog with a selected strip; desktop an anchored dropdown. The mode is
346
+ * fixed here: everything wired below belongs to one of them.
347
+ */
348
+ private build;
349
+ /**
350
+ * The dialog was closed by someone else — a ty-modal around this select
351
+ * closes the dialogs still open inside it. Run our own close too, so the
352
+ * open state, aria-expanded and the scroll lock follow. Watches the `open`
353
+ * attribute rather than the `close` event: that one comes a task later,
354
+ * so right after modal.hide() the stub would still say expanded. Our own
355
+ * close() calls land here with the state already closed, and a dialog
356
+ * reopened since then is open again: both are no-ops.
357
+ */
358
+ private syncOnOutsideClose;
388
359
  private updateMobileSelectedState;
389
- /** "Label (n)" with the count in its own muted span — same shape for both
390
- sections, and re-reads the label so selected-label/available-label
391
- changes after first render show up. */
360
+ /** "Label (n)" with the count in its own muted span. */
392
361
  private setMobileSectionTitle;
393
362
  /**
394
- * Hand the dialog's spare vertical space to one section or the other. Only
395
- * one can own it: on a phone there isn't enough height for two scrollable
396
- * lists to both be usefully tall, so tapping a header trades the space
397
- * rather than splitting it. Selecting from the list hands it back to
398
- * "available" — you're still picking, so that's the list you want open.
363
+ * Hand the dialog's spare height to one section: a phone has no room for
364
+ * two usefully tall lists. Selecting from the list hands it back to
365
+ * "available".
399
366
  */
400
367
  private expandMobileSection;
401
368
  /**
402
369
  * The selected values as dismissible chips, pinned above the available
403
370
  * list so a long list can never scroll the current selection out of sight.
404
- * Rebuilt wholesale: the strip is small, and diffing it would have to
405
- * track chip identity for the sake of a handful of nodes.
371
+ * Rebuilt wholesale: the strip is small.
406
372
  */
407
373
  private renderMobileSelectedChips;
408
374
  /**
@@ -412,37 +378,25 @@ export declare class TySelect extends TyComponent<SelectState> {
412
378
  * more options than fit without scrolling.
413
379
  */
414
380
  private shouldShowSearch;
415
- /**
416
- * Toggle the search row (desktop header / mobile input) per shouldShowSearch.
417
- */
381
+ /** Toggle the search row (desktop header / mobile input) per shouldShowSearch. */
418
382
  private updateSearchVisibility;
419
383
  /**
420
- * Selection summary appropriate to cardinality × skin:
421
- * - single (field or compact): the selected OPTION itself — cloned into
422
- * slot="selected" so rich HTML options display intact (dropdown parity);
423
- * placeholder when empty
424
- * - multiple + field: joined labels (ellipsis via CSS), or placeholder
384
+ * The trigger, list closed:
385
+ * - single: the picked option itself (`shown`), else its label, else the placeholder
386
+ * - multiple + field: the labels, comma-joined (ellipsis via CSS)
425
387
  * - multiple + compact: placeholder + count badge
388
+ * Open, the list shows what is picked: the trigger shows the placeholder.
426
389
  */
427
390
  private updateSelectionDisplay;
428
391
  /**
429
- * Keep exactly one display clone (slot="selected", marked `cloned`) in our
430
- * light DOM matching the given value — or none. The clone never counts as
431
- * an option (getTagElements filters [cloned]) and ty-option's own
432
- * :host([cloned]) styling strips its list-row chrome.
433
- */
434
- private syncSelectedClone;
435
- /**
436
- * Deselect a value programmatically WITH a change event.
437
- * Used by out-of-band chip displays (ty-selected-options) so dismissing a chip
438
- * fires change like any in-popup interaction (HTMX hx-trigger="change" etc.).
392
+ * Deselect a value WITH a change event, like a pick in the popup (HTMX
393
+ * hx-trigger="change" etc.). Used by ty-selected-options chips.
439
394
  */
440
395
  deselectValue(value: string): void;
441
396
  /**
442
- * Clear the entire selection programmatically WITH a change event
443
- * (action: 'clear'). No-op if nothing is selected. Exists so slot="trigger"
444
- * consumers (custom chrome, built-in clear UI hidden by design) can wire
445
- * their own clear icon's click handler to it.
397
+ * Clear the selection WITH a change event (action: 'clear'), for a custom
398
+ * trigger's own clear control. Shows no validation message (a code reset
399
+ * after a save shouldn't flag the field); the built-in × does.
446
400
  */
447
401
  clear(): void;
448
402
  get value(): string;
@@ -467,16 +421,22 @@ export declare class TySelect extends TyComponent<SelectState> {
467
421
  set noClear(value: boolean);
468
422
  get required(): boolean;
469
423
  set required(value: boolean);
424
+ get error(): string;
425
+ set error(value: string);
470
426
  get notSearchable(): boolean;
471
427
  set notSearchable(value: boolean);
472
428
  get externalSearch(): boolean;
473
429
  set externalSearch(value: boolean);
430
+ get externalSelection(): boolean;
431
+ set externalSelection(value: boolean);
432
+ get allowCreate(): boolean;
433
+ set allowCreate(value: boolean);
434
+ get createTransform(): "none" | "slug";
435
+ set createTransform(value: "none" | "slug");
474
436
  get debounce(): number;
475
437
  set debounce(value: number | string);
476
438
  get size(): Size;
477
439
  set size(value: Size);
478
- get align(): "start" | "center" | "end";
479
- set align(value: "start" | "center" | "end");
480
440
  get placement(): Placement | "";
481
441
  set placement(value: Placement | "");
482
442
  get flavor(): Flavor;