tyrell-components 1.0.0-TC58 → 1.0.0-TC60

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 (73) hide show
  1. package/README.md +1 -1
  2. package/css/tyrell-colors-static.css +14 -0
  3. package/css/tyrell-theme.css +6 -5
  4. package/css/tyrell.css +8 -6
  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 +13 -12
  9. package/lib/base/ty-component.js +56 -21
  10. package/lib/components/button.d.ts +10 -0
  11. package/lib/components/button.js +22 -1
  12. package/lib/components/calendar-month.d.ts +7 -1
  13. package/lib/components/calendar-month.js +32 -18
  14. package/lib/components/calendar-navigation.js +19 -6
  15. package/lib/components/calendar.d.ts +25 -5
  16. package/lib/components/calendar.js +87 -37
  17. package/lib/components/checkbox.d.ts +5 -0
  18. package/lib/components/checkbox.js +18 -5
  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 +7 -26
  22. package/lib/components/date-picker.js +14 -84
  23. package/lib/components/file-upload.js +6 -2
  24. package/lib/components/input.d.ts +0 -9
  25. package/lib/components/input.js +18 -40
  26. package/lib/components/modal.js +59 -18
  27. package/lib/components/option.d.ts +19 -0
  28. package/lib/components/option.js +38 -26
  29. package/lib/components/popup.js +56 -5
  30. package/lib/components/radio.d.ts +6 -0
  31. package/lib/components/radio.js +12 -28
  32. package/lib/components/select.d.ts +132 -194
  33. package/lib/components/select.js +436 -836
  34. package/lib/components/selected-tags.d.ts +8 -4
  35. package/lib/components/selected-tags.js +26 -8
  36. package/lib/components/switch.d.ts +4 -0
  37. package/lib/components/switch.js +18 -5
  38. package/lib/components/tabs.js +1 -1
  39. package/lib/components/textarea.d.ts +1 -0
  40. package/lib/components/textarea.js +21 -8
  41. package/lib/index.d.ts +1 -0
  42. package/lib/index.js +1 -0
  43. package/lib/styles/button.js +1 -0
  44. package/lib/styles/calendar-month.js +1 -1
  45. package/lib/styles/calendar.js +3 -0
  46. package/lib/styles/checkbox.js +11 -5
  47. package/lib/styles/date-picker.js +5 -10
  48. package/lib/styles/input.js +5 -9
  49. package/lib/styles/option.d.ts +1 -1
  50. package/lib/styles/option.js +6 -7
  51. package/lib/styles/popup.d.ts +1 -1
  52. package/lib/styles/popup.js +2 -0
  53. package/lib/styles/radio.js +10 -4
  54. package/lib/styles/select-base.js +6 -70
  55. package/lib/styles/select.d.ts +1 -1
  56. package/lib/styles/select.js +13 -2
  57. package/lib/styles/switch.js +10 -5
  58. package/lib/styles/tag.js +2 -1
  59. package/lib/types/common.d.ts +3 -1
  60. package/lib/utils/calendar-utils.d.ts +49 -0
  61. package/lib/utils/calendar-utils.js +63 -6
  62. package/lib/utils/property-manager.d.ts +0 -5
  63. package/lib/utils/property-manager.js +0 -11
  64. package/lib/utils/scroll-lock.d.ts +10 -4
  65. package/lib/utils/scroll-lock.js +102 -2
  66. package/lib/utils/validity.d.ts +27 -1
  67. package/lib/utils/validity.js +68 -16
  68. package/lib/version.d.ts +1 -1
  69. package/lib/version.js +1 -1
  70. package/package.json +1 -1
  71. package/dist/tyrell.js.map +0 -1
  72. package/lib/utils/error-flavor.d.ts +0 -8
  73. package/lib/utils/error-flavor.js +0 -1
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * TySelectedOptions - out-of-band dismissible <ty-tag> chips for a picker's selection.
3
- * Pairs with any element exposing a comma-joined `value` + bubbling `change`; labels
4
- * and flavors are read from the picker's matching option (`[value="..."]`). Custom chips
5
- * come from an optional <template> child, stamped onto cloned nodes (never innerHTML).
3
+ * Draws the picker's comma-joined `value`, matched to its options by value for
4
+ * labels and flavors (`[value="..."]`). Works with any element exposing `value`
5
+ * and a bubbling `change`. Custom chips come from an optional <template> child,
6
+ * stamped onto cloned nodes (never innerHTML).
6
7
  */
7
8
  export declare class TySelectedOptions extends HTMLElement {
8
9
  static get observedAttributes(): string[];
@@ -11,6 +12,7 @@ export declare class TySelectedOptions extends HTMLElement {
11
12
  private _childObserver;
12
13
  private _pickerObserver;
13
14
  private _lastTemplate;
15
+ private _rendered;
14
16
  private _pickerOpen;
15
17
  private _onPickerOpen;
16
18
  private _onPickerClose;
@@ -22,13 +24,15 @@ export declare class TySelectedOptions extends HTMLElement {
22
24
  private bind;
23
25
  private unbind;
24
26
  private values;
27
+ /** Children are still exactly what the last render left. */
28
+ private intact;
25
29
  /** The optional chip template (direct child only). */
26
30
  private template;
27
31
  /**
28
32
  * Interpolation context for a value: value, label, flavor plus every
29
33
  * data-* attribute of the picker's matching option.
30
34
  */
31
- /** The picker's option for a value (never its display clone). */
35
+ /** The picker's option for a value. */
32
36
  private option;
33
37
  private context;
34
38
  /**
@@ -12,6 +12,7 @@ this._onChange = () => this.renderChips();
12
12
  this._childObserver = null;
13
13
  this._pickerObserver = null;
14
14
  this._lastTemplate = null;
15
+ this._rendered = [];
15
16
  this._pickerOpen = false;
16
17
  this._onPickerOpen = () => {
17
18
  this._pickerOpen = true;
@@ -30,16 +31,21 @@ this.style.display = 'contents';
30
31
  this.bind();
31
32
  this.renderChips();
32
33
  if (document.readyState === 'loading') {
33
- document.addEventListener('DOMContentLoaded', () => { if (this.isConnected)
34
- this.renderChips(); }, { once: true });
34
+ document.addEventListener('DOMContentLoaded', () => {
35
+ if (!this.isConnected)
36
+ return;
37
+ this.bind();
38
+ this.renderChips();
39
+ }, { once: true });
35
40
  }
36
41
  this._childObserver = new MutationObserver(() => {
37
- const template = this.template();
38
- if (template !== this._lastTemplate) {
42
+ if (!this.style.display)
43
+ this.style.display = 'contents';
44
+ if (this.template() !== this._lastTemplate || !this.intact()) {
39
45
  this.renderChips();
40
46
  }
41
47
  });
42
- this._childObserver.observe(this, { childList: true });
48
+ this._childObserver.observe(this, { childList: true, attributes: true, attributeFilter: ['style'] });
43
49
  }
44
50
  disconnectedCallback() {
45
51
  this.unbind();
@@ -69,12 +75,18 @@ this._picker?.addEventListener('change', this._onChange);
69
75
  this._picker?.addEventListener('open', this._onPickerOpen);
70
76
  this._picker?.addEventListener('close', this._onPickerClose);
71
77
  if (this._picker) {
78
+ const name = this._picker.localName;
79
+ if (name.includes('-') && !customElements.get(name)) {
80
+ customElements.whenDefined(name).then(() => { if (this.isConnected)
81
+ this.renderChips(); });
82
+ }
72
83
  this._pickerObserver = new MutationObserver(() => this.renderChips());
73
84
  this._pickerObserver.observe(this._picker, {
74
85
  childList: true,
75
86
  subtree: true,
87
+ characterData: true,
76
88
  attributes: true,
77
- attributeFilter: ['selected'],
89
+ attributeFilter: ['value', 'label', 'flavor'],
78
90
  });
79
91
  }
80
92
  }
@@ -90,11 +102,15 @@ this._pickerOpen = false;
90
102
  values() {
91
103
  return parseValues(this._picker?.value ?? '');
92
104
  }
105
+ intact() {
106
+ const kids = this.childNodes;
107
+ return kids.length === this._rendered.length && this._rendered.every((n, i) => kids[i] === n);
108
+ }
93
109
  template() {
94
110
  return this.querySelector(':scope > template');
95
111
  }
96
112
  option(value) {
97
- return this._picker?.querySelector(`[value="${CSS.escape(value)}"]:not([cloned])`);
113
+ return this._picker?.querySelector(`[value="${CSS.escape(value)}"]`);
98
114
  }
99
115
  context(value) {
100
116
  const opt = this.option(value);
@@ -174,7 +190,8 @@ return;
174
190
  const template = this.template();
175
191
  this._lastTemplate = template;
176
192
  if (!this._picker) {
177
- this.replaceChildren(...(template ? [template] : []));
193
+ this._rendered = template ? [template] : [];
194
+ this.replaceChildren(...this._rendered);
178
195
  return;
179
196
  }
180
197
  const frag = document.createDocumentFragment();
@@ -183,6 +200,7 @@ frag.appendChild(template);
183
200
  for (const value of this.values()) {
184
201
  frag.appendChild(template ? this.stampTemplate(template, value) : this.defaultChip(value));
185
202
  }
203
+ this._rendered = Array.from(frag.childNodes);
186
204
  this.replaceChildren(frag);
187
205
  }
188
206
  deselect(value) {
@@ -24,6 +24,8 @@ export interface TySwitchElement extends HTMLElement {
24
24
  }
25
25
  export declare class TySwitch extends TyComponent<SwitchState> implements TySwitchElement {
26
26
  static formAssociated: boolean;
27
+ protected static delegatesFocus: boolean;
28
+ protected static labelClicks: boolean;
27
29
  protected static properties: {
28
30
  checked: {
29
31
  type: "boolean";
@@ -78,6 +80,8 @@ export declare class TySwitch extends TyComponent<SwitchState> implements TySwit
78
80
  protected getFormValue(): FormDataEntryValue | null;
79
81
  private buildClassList;
80
82
  private handleSwitchClick;
83
+ /** Keys show the ring, a click hides it (see checkbox.ts). */
84
+ private showFocusRing;
81
85
  private handleSwitchKeydown;
82
86
  private removeEventListeners;
83
87
  private setupEventListeners;
@@ -19,6 +19,9 @@ ensureStyles(shadow, { css: switchStyles, id: "ty-switch" });
19
19
  onConnect() {
20
20
  this.setupEventListeners();
21
21
  this._syncCustomFlavor();
22
+ const el = this.shadowRoot.querySelector(".switch-container");
23
+ if (el && this.shadowRoot.activeElement !== el)
24
+ el.classList.remove("focused");
22
25
  }
23
26
  onDisconnect() {
24
27
  this.removeEventListeners();
@@ -45,8 +48,7 @@ return classes.join(" ");
45
48
  handleSwitchClick(e) {
46
49
  if (this.disabled)
47
50
  return;
48
- if (this.isDuplicateActivationClick())
49
- return;
51
+ this.showFocusRing(e instanceof KeyboardEvent);
50
52
  const newValue = !this.checked;
51
53
  this.checked = newValue;
52
54
  setTimeout(() => {
@@ -60,6 +62,9 @@ this.dispatchEvent(new CustomEvent("input", { detail: eventDetail, bubbles: true
60
62
  this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
61
63
  }, 0);
62
64
  }
65
+ showFocusRing(on) {
66
+ this.shadowRoot?.querySelector(".switch-container")?.classList.toggle("focused", on);
67
+ }
63
68
  handleSwitchKeydown(e) {
64
69
  if (this.disabled)
65
70
  return;
@@ -107,7 +112,7 @@ if (!el)
107
112
  return;
108
113
  this._clickHandler = (e) => this.handleSwitchClick(e);
109
114
  this._keydownHandler = (e) => this.handleSwitchKeydown(e);
110
- this._focusHandler = () => el.classList.add("focused");
115
+ this._focusHandler = () => el.classList.toggle("focused", el.matches(":focus-visible"));
111
116
  this._blurHandler = () => el.classList.remove("focused");
112
117
  this.addEventListener("click", this._clickHandler);
113
118
  el.addEventListener("keydown", this._keydownHandler);
@@ -122,7 +127,8 @@ const classes = this.buildClassList();
122
127
  if (!switchEl) {
123
128
  switchEl = document.createElement("div");
124
129
  switchEl.className = "switch-container " + classes;
125
- switchEl.tabIndex = this.disabled ? -1 : 0;
130
+ if (!this.disabled)
131
+ switchEl.tabIndex = 0;
126
132
  switchEl.setAttribute("role", "switch");
127
133
  switchEl.setAttribute("aria-checked", this.checked ? "true" : "false");
128
134
  switchEl.setAttribute("aria-disabled", this.disabled ? "true" : "false");
@@ -136,8 +142,13 @@ switchEl.appendChild(track);
136
142
  shadow.appendChild(switchEl);
137
143
  }
138
144
  else {
145
+ const focused = switchEl.classList.contains("focused") && shadow.activeElement === switchEl;
139
146
  switchEl.className = "switch-container " + classes;
140
- switchEl.tabIndex = this.disabled ? -1 : 0;
147
+ switchEl.classList.toggle("focused", focused && !this.disabled);
148
+ if (this.disabled)
149
+ switchEl.removeAttribute("tabindex");
150
+ else
151
+ switchEl.tabIndex = 0;
141
152
  switchEl.setAttribute("aria-checked", this.checked ? "true" : "false");
142
153
  switchEl.setAttribute("aria-disabled", this.disabled ? "true" : "false");
143
154
  switchEl.setAttribute("aria-required", this.required ? "true" : "false");
@@ -183,6 +194,8 @@ set flavor(value) { this.setProperty("flavor", value); }
183
194
  get form() { return this._internals.form; }
184
195
  }
185
196
  TySwitch.formAssociated = true;
197
+ TySwitch.delegatesFocus = true;
198
+ TySwitch.labelClicks = true;
186
199
  TySwitch.properties = {
187
200
  checked: {
188
201
  type: "boolean",
@@ -251,7 +251,7 @@ marker.style.top = `${position.top}px`;
251
251
  marker.style.width = `${position.width}px`;
252
252
  marker.style.height = `${position.height}px`;
253
253
  if (snap) {
254
- marker.offsetWidth;
254
+ marker.getBoundingClientRect();
255
255
  marker.style.transition = '';
256
256
  }
257
257
  }
@@ -191,6 +191,7 @@ export declare class TyTextarea extends TyComponent<TextareaState> implements Ty
191
191
  private buildClassList;
192
192
  private applyHeightConstraints;
193
193
  private setupTextareaEvents;
194
+ private removeTextareaEvents;
194
195
  protected render(): void;
195
196
  /**
196
197
  * minlength goes on the inner <textarea> for the browser's own too-short
@@ -15,6 +15,8 @@ this._scrollbar = null;
15
15
  this._isFocused = false;
16
16
  this.handleInputEvent = (e) => {
17
17
  this._userEdited = true;
18
+ e.stopPropagation();
19
+ e.stopImmediatePropagation();
18
20
  const target = e.target;
19
21
  const newValue = target.value;
20
22
  this.value = newValue;
@@ -46,20 +48,22 @@ ensureStyles(shadow, { css: customScrollbarStyles, id: 'ty-custom-scrollbar' });
46
48
  }
47
49
  }
48
50
  onConnect() {
51
+ this.updateFormValue();
52
+ if (this._rendered) {
53
+ this.render();
54
+ if (this._textareaEl)
55
+ this.setupTextareaEvents(this._textareaEl);
56
+ }
49
57
  }
50
58
  onDisconnect() {
51
59
  this._destroyScrollbar();
52
- if (this._textareaEl) {
53
- const newTextarea = this._textareaEl.cloneNode(true);
54
- this._textareaEl.parentNode?.replaceChild(newTextarea, this._textareaEl);
55
- this._textareaEl = null;
56
- }
57
- this._dummyEl = null;
60
+ if (this._textareaEl)
61
+ this.removeTextareaEvents(this._textareaEl);
58
62
  }
59
63
  onPropertiesChanged(changes) {
60
64
  }
61
65
  getFormValue() {
62
- return this.getProperty('value') || null;
66
+ return this.getProperty('value') || '';
63
67
  }
64
68
  get value() { return this.getProperty('value'); }
65
69
  set value(v) { this.setProperty('value', v); }
@@ -190,6 +194,10 @@ textareaEl.style.overflowY = 'hidden';
190
194
  this._destroyScrollbar();
191
195
  }
192
196
  }
197
+ else if (maxHeight !== null && measuredHeight >= maxHeight && !this._scrollbar) {
198
+ textareaEl.style.overflowY = 'auto';
199
+ this._setupScrollbar(textareaEl);
200
+ }
193
201
  this._scrollbar?.update();
194
202
  }
195
203
  _setupScrollbar(textareaEl) {
@@ -226,7 +234,7 @@ value: this.value,
226
234
  originalEvent
227
235
  }
228
236
  };
229
- setTimeout(() => this.dispatchEvent(new CustomEvent(type, data)), 0);
237
+ this.dispatchEvent(new CustomEvent(type, data));
230
238
  }
231
239
  buildClassList() {
232
240
  const classes = [this.size];
@@ -256,6 +264,11 @@ textareaEl.addEventListener('input', this.handleInputEvent);
256
264
  textareaEl.addEventListener('focus', this.handleFocusEvent);
257
265
  textareaEl.addEventListener('blur', this.handleBlurEvent);
258
266
  }
267
+ removeTextareaEvents(textareaEl) {
268
+ textareaEl.removeEventListener('input', this.handleInputEvent);
269
+ textareaEl.removeEventListener('focus', this.handleFocusEvent);
270
+ textareaEl.removeEventListener('blur', this.handleBlurEvent);
271
+ }
259
272
  render() {
260
273
  const root = this.shadowRoot;
261
274
  const existingContainer = root.querySelector('.textarea-container');
package/lib/index.d.ts CHANGED
@@ -75,6 +75,7 @@ declare global {
75
75
  tyResizeObserver: {
76
76
  getSize: (id: string) => ResizeSize | undefined;
77
77
  onResize: (id: string, callback: ResizeCallback) => () => void;
78
+ getAllSizes: () => Record<string, ResizeSize>;
78
79
  sizes: Record<string, ResizeSize>;
79
80
  };
80
81
  tyLoader: {
package/lib/index.js CHANGED
@@ -54,6 +54,7 @@ clearCache: () => clearIcons()
54
54
  window.tyResizeObserver = {
55
55
  getSize: (id) => getResizeSize(id),
56
56
  onResize: (id, callback) => subscribeResize(id, callback),
57
+ getAllSizes: () => getAllSizes(),
57
58
  get sizes() { return getAllSizes(); }
58
59
  };
59
60
  }
@@ -85,6 +85,7 @@ aspect-ratio: 1;
85
85
  :host([wide]) {
86
86
  display: grid;
87
87
  flex-grow: 1;
88
+ max-height: var(--_rung);
88
89
  grid-template-rows: minmax(var(--_rung), max-content);
89
90
  }
90
91
  :host([wide]) button {
@@ -124,7 +124,7 @@ color: var(--ty-calendar-weekend-color, var(--ty-calendar-day-color, var(--ty-te
124
124
  color: var(--ty-calendar-other-month-color, color-mix(in oklab, var(--ty-text-faint) 65%, transparent));
125
125
  }
126
126
  .calendar-day-cell.other-month:hover {
127
- color: var(--ty-calendar-day-hover-color, var(--ty-text-soft, var(--ty-text-)));
127
+ color: var(--ty-calendar-day-hover-color, var(--ty-text-soft));
128
128
  background-color: var(--ty-calendar-day-hover-bg, var(--ty-bg-neutral-soft));
129
129
  }
130
130
  .calendar-day-cell.disabled {
@@ -10,6 +10,9 @@ box-sizing: border-box;
10
10
  font-family: inherit;
11
11
  align-items: center;
12
12
  }
13
+ .calendar-container:focus {
14
+ outline: none;
15
+ }
13
16
  @media (max-width: 320px) {
14
17
  .calendar-container {
15
18
  gap: 0.375rem;
@@ -14,14 +14,21 @@ export const checkboxStyles = `
14
14
  :host {
15
15
  display: inline-flex;
16
16
  width: auto;
17
- vertical-align: middle;
17
+ height: 1.25em;
18
+ height: 1lh;
19
+ align-items: center;
20
+ vertical-align: baseline;
21
+ overflow: visible;
22
+ }
23
+ :host::before {
24
+ content: "\\200b";
25
+ width: 0;
18
26
  }
19
27
  .checkbox-container {
20
28
  display: inline-flex;
29
+ flex-shrink: 0;
21
30
  align-items: center;
22
31
  justify-content: center;
23
- min-height: 1.25em;
24
- min-height: 1lh;
25
32
  outline: none;
26
33
  transition: var(--ty-local-transition, all 0.15s ease-in-out);
27
34
  user-select: none;
@@ -42,8 +49,7 @@ color: var(--checkbox-color-off-hover, color-mix(in oklab, var(--ty-text) 50%, t
42
49
  .checkbox-container[aria-checked="true"] {
43
50
  color: var(--checkbox-color, var(--ty-text));
44
51
  }
45
- .checkbox-container.focused,
46
- .checkbox-container:focus-visible {
52
+ .checkbox-container.focused {
47
53
  box-shadow: 0 0 0 3px var(--checkbox-ring, color-mix(in oklab, var(--ty-color-primary) 25%, transparent));
48
54
  }
49
55
  .checkbox-icon {
@@ -1,6 +1,6 @@
1
1
  import { FLAVORS } from "../types/common.js";
2
2
  import { fieldSizeVars } from "./field-size.js";
3
- const datePickerFlavor = (f, fb) => {
3
+ const datePickerFlavor = (f, fb, also = "") => {
4
4
  const c = (s) => fb
5
5
  ? s
6
6
  ? `var(--ty-color-${f}${s}, var(--ty-color-${f}, var(--ty-color-${fb}${s})))`
@@ -9,7 +9,7 @@ const c = (s) => fb
9
9
  ? `var(--ty-color-${f}${s}, var(--ty-color-${f}))`
10
10
  : `var(--ty-color-${f})`;
11
11
  return `
12
- :host([flavor="${f}"]) {
12
+ :host([flavor="${f}"])${also} {
13
13
  --date-picker-accent: var(--ty-input-${f}-border, ${c("-soft")});
14
14
  --date-picker-accent-bold: ${c("")};
15
15
  --date-picker-ring: color-mix(in oklab, ${c("")} 15%, transparent);
@@ -26,6 +26,7 @@ return `
26
26
  }
27
27
  `;
28
28
  };
29
+ const errorLook = `,\n:host([error]:not([error=""]))`;
29
30
  export const datePickerCustomFlavorCss = (base) => datePickerFlavor(base, "neutral");
30
31
  export const datePickerStyles = `
31
32
  ${fieldSizeVars}
@@ -133,7 +134,7 @@ opacity: 0.6;
133
134
  border-color: var(--date-picker-accent-bold, var(--ty-date-picker-border-focus));
134
135
  box-shadow: 0 0 0 3px var(--date-picker-ring, var(--ty-date-picker-shadow-focus));
135
136
  }
136
- ${FLAVORS.filter((f) => f !== "neutral").map((f) => datePickerFlavor(f)).join("")}
137
+ ${FLAVORS.filter((f) => f !== "neutral").map((f) => datePickerFlavor(f, undefined, f === "danger" ? errorLook : "")).join("")}
137
138
  .error-message {
138
139
  font-size: var(--ty-font-xs);
139
140
  line-height: var(--ty-leading-xs);
@@ -142,15 +143,9 @@ color: var(--ty-color-danger);
142
143
  margin-top: 4px;
143
144
  padding-left: var(--ty-field-outer-pad-x);
144
145
  }
145
- .date-picker-stub.error {
146
- border-color: var(--ty-color-danger);
146
+ .date-picker-stub.error:not([disabled]) {
147
147
  background: var(--ty-bg-danger-soft);
148
148
  }
149
- .date-picker-stub.error:focus,
150
- .date-picker-stub.error.open {
151
- border-color: var(--ty-color-danger-bold);
152
- box-shadow: 0 0 0 3px var(--ty-date-picker-shadow-focus);
153
- }
154
149
  .stub-text {
155
150
  flex: 1;
156
151
  white-space: nowrap;
@@ -1,6 +1,6 @@
1
1
  import { FLAVORS } from "../types/common.js";
2
2
  import { fieldSizeVars } from "./field-size.js";
3
- const inputFlavor = (f, fb) => {
3
+ const inputFlavor = (f, fb, also = "") => {
4
4
  const c = (s) => fb
5
5
  ? s
6
6
  ? `var(--ty-color-${f}${s}, var(--ty-color-${f}, var(--ty-color-${fb}${s})))`
@@ -9,7 +9,7 @@ const c = (s) => fb
9
9
  ? `var(--ty-color-${f}${s}, var(--ty-color-${f}))`
10
10
  : `var(--ty-color-${f})`;
11
11
  return `
12
- :host([flavor="${f}"]) {
12
+ :host([flavor="${f}"])${also} {
13
13
  --input-accent: var(--ty-input-${f}-border, ${c("-soft")});
14
14
  --input-accent-bold: ${c("")};
15
15
  --input-ring: color-mix(in oklab, ${c("")} 15%, transparent);
@@ -26,6 +26,7 @@ return `
26
26
  }
27
27
  `;
28
28
  };
29
+ const errorLook = `,\n:host([error]:not([error=""]))`;
29
30
  export const inputCustomFlavorCss = (base) => inputFlavor(base, "neutral");
30
31
  export const inputStyles = `
31
32
  ${fieldSizeVars}
@@ -137,14 +138,9 @@ color: var(--ty-color-danger);
137
138
  margin-top: 4px;
138
139
  padding-left: var(--ty-field-outer-pad-x);
139
140
  }
140
- .input-wrapper.error {
141
- border-color: var(--ty-color-danger);
141
+ .input-wrapper.error:not(.disabled) {
142
142
  background: var(--ty-bg-danger-soft);
143
143
  }
144
- .input-wrapper.error.focused {
145
- border-color: var(--ty-color-danger-bold);
146
- box-shadow: 0 0 0 3px var(--input-shadow-focus, var(--ty-input-shadow-focus));
147
- }
148
144
  input {
149
145
  flex: 1;
150
146
  min-width: 0;
@@ -177,7 +173,7 @@ input::placeholder {
177
173
  color: var(--input-placeholder, var(--ty-input-placeholder));
178
174
  font-weight: 400;
179
175
  }
180
- ${FLAVORS.filter((f) => f !== "neutral").map((f) => inputFlavor(f)).join("")}
176
+ ${FLAVORS.filter((f) => f !== "neutral").map((f) => inputFlavor(f, undefined, f === "danger" ? errorLook : "")).join("")}
181
177
  input:focus-visible {
182
178
  outline: none;
183
179
  }
@@ -1,2 +1,2 @@
1
1
  /** Option Component Styles */
2
- export declare const optionStyles = "\n.option-content {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--ty-spacing-2);\n box-sizing: border-box;\n width: 100%;\n\n cursor: pointer;\n user-select: none;\n\n transition: var(--ty-transition-all);\n\n /* Linear-paired typography */\n color: var(--ty-text);\n font-family: inherit;\n font-size: var(--ty-font-sm);\n line-height: var(--ty-leading-sm);\n letter-spacing: var(--ty-tracking-sm);\n padding: var(--ty-spacing-2) var(--ty-spacing-3);\n border-radius: var(--ty-radius-md);\n}\n\n/* Cloned copy (projected into the select's trigger field): host defaults to\n inline like any unstyled custom element, which ignores width/overflow \u2014\n force a block box so the parent's flex-basis:0 truncation (select.ts\n .select-stub.has-clone slot[name=\"selected\"]) actually clips it, and\n collapse the content to a single ellipsized line instead of wrapping. */\n:host([cloned]) {\n display: block;\n min-width: 0;\n overflow: hidden;\n}\n\n/* The clone sits in the select's TRIGGER, so its type follows the field size\n ladder (styles/field-size.ts) rather than the dropdown list's own scale \u2014\n the --ty-field-* vars inherit from ty-select through the light DOM. The\n fallbacks cover a ty-option rendered outside a select. */\n:host([cloned]) .option-content {\n display: block;\n padding: 0px;\n background: transparent;\n min-width: 0;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n font-size: var(--ty-field-font, var(--ty-font-sm));\n line-height: var(--ty-field-leading, var(--ty-leading-sm));\n letter-spacing: var(--ty-field-tracking, var(--ty-tracking-sm));\n}\n\n.option-content:hover {\n background: var(--ty-bg-neutral-soft);\n}\n\n.option-content[highlighted] {\n background: var(--ty-bg-neutral-soft);\n color: var(--ty-text-strong);\n}\n\n/* Selected: quiet \u2014 bolder text color only, no background slab, no weight change */\n.option-content[selected] {\n background: transparent;\n color: var(--ty-text-bold);\n}\n\n/* Lucide check \u2014 right-aligned. Its box is always reserved so selecting\n (or highlighting) never changes the row's width and rewraps the text. */\n.option-check {\n display: block;\n visibility: hidden;\n flex-shrink: 0;\n width: 14px;\n height: 14px;\n margin-left: auto;\n color: var(--ty-color-primary);\n}\n\n.option-content[selected] .option-check {\n visibility: visible;\n}\n\n/* Never show the check on the copy cloned into the select's trigger field */\n:host([cloned]) .option-check {\n display: none;\n}\n\n.option-content[selected]:hover {\n background: var(--ty-bg-neutral-soft);\n}\n\n.option-content[disabled] {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.option-content[hidden] {}\n\n.option-content * {\n pointer-events: none;\n}\n";
2
+ export declare const optionStyles = "\n/* Options the author hid and options a ty-select search left out, at any\n depth in the select (a framework component's element around each option\n too). !important beats the select's mobile list display:block. The\n select's trigger sets the variable: a hidden option can still be the\n value it shows. */\n:host([hidden]),\n:host([filtered-out]) {\n display: var(--ty-option-hidden-display, none) !important;\n}\n\n.option-content {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--ty-spacing-2);\n box-sizing: border-box;\n width: 100%;\n\n cursor: pointer;\n user-select: none;\n\n transition: var(--ty-transition-all);\n\n /* Linear-paired typography */\n color: var(--ty-text);\n font-family: inherit;\n font-size: var(--ty-font-sm);\n line-height: var(--ty-leading-sm);\n letter-spacing: var(--ty-tracking-sm);\n padding: var(--ty-spacing-2) var(--ty-spacing-3);\n border-radius: var(--ty-radius-md);\n}\n\n/* Shown in the select's trigger (the select sets inTrigger): one ellipsized\n line on the field size ladder (styles/field-size.ts), no row chrome. The\n select sizes the host. */\n.option-content.in-trigger {\n display: block;\n padding: 0px;\n background: transparent;\n min-width: 0;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n font-size: var(--ty-field-font, var(--ty-font-sm));\n line-height: var(--ty-field-leading, var(--ty-leading-sm));\n letter-spacing: var(--ty-field-tracking, var(--ty-tracking-sm));\n}\n\n.option-content:hover {\n background: var(--ty-bg-neutral-soft);\n}\n\n.option-content[highlighted] {\n background: var(--ty-bg-neutral-soft);\n color: var(--ty-text-strong);\n}\n\n/* Selected: quiet \u2014 bolder text color only, no background slab, no weight change */\n.option-content[selected] {\n background: transparent;\n color: var(--ty-text-bold);\n}\n\n/* Lucide check \u2014 right-aligned. Its box is always reserved so selecting\n (or highlighting) never changes the row's width and rewraps the text. */\n.option-check {\n display: block;\n visibility: hidden;\n flex-shrink: 0;\n width: 14px;\n height: 14px;\n margin-left: auto;\n color: var(--ty-color-primary);\n}\n\n.option-content[selected] .option-check {\n visibility: visible;\n}\n\n.option-content.in-trigger .option-check {\n display: none;\n}\n\n.option-content[selected]:hover {\n background: var(--ty-bg-neutral-soft);\n}\n\n.option-content[disabled] {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.option-content[hidden] {}\n\n.option-content * {\n pointer-events: none;\n}\n";
@@ -1,4 +1,8 @@
1
1
  export const optionStyles = `
2
+ :host([hidden]),
3
+ :host([filtered-out]) {
4
+ display: var(--ty-option-hidden-display, none) !important;
5
+ }
2
6
  .option-content {
3
7
  display: flex;
4
8
  align-items: center;
@@ -17,12 +21,7 @@ letter-spacing: var(--ty-tracking-sm);
17
21
  padding: var(--ty-spacing-2) var(--ty-spacing-3);
18
22
  border-radius: var(--ty-radius-md);
19
23
  }
20
- :host([cloned]) {
21
- display: block;
22
- min-width: 0;
23
- overflow: hidden;
24
- }
25
- :host([cloned]) .option-content {
24
+ .option-content.in-trigger {
26
25
  display: block;
27
26
  padding: 0px;
28
27
  background: transparent;
@@ -57,7 +56,7 @@ color: var(--ty-color-primary);
57
56
  .option-content[selected] .option-check {
58
57
  visibility: visible;
59
58
  }
60
- :host([cloned]) .option-check {
59
+ .option-content.in-trigger .option-check {
61
60
  display: none;
62
61
  }
63
62
  .option-content[selected]:hover {
@@ -4,4 +4,4 @@
4
4
  * Popup component with dropdown-like behavior and tooltip positioning.
5
5
  * Uses dialog element for top layer rendering like dropdown and date-picker.
6
6
  */
7
- export declare const popupStyles = "\n.popup-dialog {\n position: fixed;\n top: 0;\n left: 0;\n\n /* Reset dialog defaults */\n margin: 0;\n border: none;\n background: transparent;\n max-width: none;\n max-height: none;\n\n /* Shadow infrastructure - provide space for user shadows */\n padding: var(--popup-padding, 16px);\n\n /* Hidden by default - even when [open] (for positioning phase) */\n visibility: hidden;\n opacity: 0;\n /* NO TRANSFORM here - apply only when animating to avoid measurement errors! */\n\n transition:\n opacity var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1)),\n visibility var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1)),\n transform var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1));\n\n /* Prevent interactions when hidden */\n pointer-events: none;\n}\n\n/* Apply position variables only when position is calculated (like dropdown) */\n.popup-dialog.position-calculated {\n top: var(--popup-y, 0px);\n left: var(--popup-x, 0px);\n}\n\n/* Entrance prep (right before .open): scale + a short slide from the anchor\n side. data-side is the RESOLVED side (post-flip), set by updatePosition. */\n.popup-dialog.preparing-animation {\n transform: scale(var(--ty-popup-scale, 0.96));\n}\n\n/* The prep pose must land instantly. Transitioned, it had barely left\n scale(1) when .open arrived a frame later, so the entrance (and any\n springy --ty-popup-ease) ran over almost no distance. */\n.popup-dialog.preparing-animation:not(.open) {\n transition: none;\n}\n\n.popup-dialog[data-side=\"bottom\"].preparing-animation:not(.open) {\n transform: translateY(-6px) scale(var(--ty-popup-scale, 0.96));\n}\n\n.popup-dialog[data-side=\"top\"].preparing-animation:not(.open) {\n transform: translateY(6px) scale(var(--ty-popup-scale, 0.96));\n}\n\n.popup-dialog[data-side=\"left\"].preparing-animation:not(.open) {\n transform: translateX(6px) scale(var(--ty-popup-scale, 0.96));\n}\n\n.popup-dialog[data-side=\"right\"].preparing-animation:not(.open) {\n transform: translateX(-6px) scale(var(--ty-popup-scale, 0.96));\n}\n\n.popup-dialog.open {\n visibility: visible;\n opacity: 1;\n transform: scale(1);\n pointer-events: auto;\n}\n\n/* Make dialog backdrop transparent like dropdown/date-picker */\n.popup-dialog::backdrop {\n background: transparent;\n}\n\n/* Neutral structural container \u2014 users control all visuals via slotted content */\n.popup-container {\n display: contents;\n}\n\n/* Slotted content defines its own styling */\n#popup-content {\n display: contents;\n}\n\n/* Users have complete control over the popup's appearance; only essential\n positioning is imposed here. */\n#popup-content ::slotted(*) {\n position: relative;\n\n /* Prevent content from being too wide - still helpful */\n max-width: min(400px, 90vw);\n max-height: min(500px, 80vh);\n overflow: auto;\n}\n";
7
+ export declare const popupStyles = "\n.popup-dialog {\n position: fixed;\n top: 0;\n left: 0;\n\n /* Reset dialog defaults */\n margin: 0;\n border: none;\n background: transparent;\n max-width: none;\n max-height: none;\n\n /* Shadow infrastructure - provide space for user shadows */\n padding: var(--popup-padding, 16px);\n\n /* Hidden by default - even when [open] (for positioning phase) */\n visibility: hidden;\n opacity: 0;\n /* NO TRANSFORM here - apply only when animating to avoid measurement errors! */\n\n transition:\n opacity var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1)),\n visibility var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1)),\n transform var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1));\n\n /* Prevent interactions when hidden */\n pointer-events: none;\n\n /* Focused on open when the content has nothing to focus: not a control */\n outline: none;\n}\n\n/* Apply position variables only when position is calculated (like dropdown) */\n.popup-dialog.position-calculated {\n top: var(--popup-y, 0px);\n left: var(--popup-x, 0px);\n}\n\n/* Entrance prep (right before .open): scale + a short slide from the anchor\n side. data-side is the RESOLVED side (post-flip), set by updatePosition. */\n.popup-dialog.preparing-animation {\n transform: scale(var(--ty-popup-scale, 0.96));\n}\n\n/* The prep pose must land instantly. Transitioned, it had barely left\n scale(1) when .open arrived a frame later, so the entrance (and any\n springy --ty-popup-ease) ran over almost no distance. */\n.popup-dialog.preparing-animation:not(.open) {\n transition: none;\n}\n\n.popup-dialog[data-side=\"bottom\"].preparing-animation:not(.open) {\n transform: translateY(-6px) scale(var(--ty-popup-scale, 0.96));\n}\n\n.popup-dialog[data-side=\"top\"].preparing-animation:not(.open) {\n transform: translateY(6px) scale(var(--ty-popup-scale, 0.96));\n}\n\n.popup-dialog[data-side=\"left\"].preparing-animation:not(.open) {\n transform: translateX(6px) scale(var(--ty-popup-scale, 0.96));\n}\n\n.popup-dialog[data-side=\"right\"].preparing-animation:not(.open) {\n transform: translateX(-6px) scale(var(--ty-popup-scale, 0.96));\n}\n\n.popup-dialog.open {\n visibility: visible;\n opacity: 1;\n transform: scale(1);\n pointer-events: auto;\n /* Visible at once, the opacity fades it in: focusable as soon as openPopup\n moves focus in. Closing still keeps it visible through the fade-out. */\n transition-duration: var(--ty-popup-duration, 180ms), 0s, var(--ty-popup-duration, 180ms);\n}\n\n/* Make dialog backdrop transparent like dropdown/date-picker */\n.popup-dialog::backdrop {\n background: transparent;\n}\n\n/* Neutral structural container \u2014 users control all visuals via slotted content */\n.popup-container {\n display: contents;\n}\n\n/* Slotted content defines its own styling */\n#popup-content {\n display: contents;\n}\n\n/* Users have complete control over the popup's appearance; only essential\n positioning is imposed here. */\n#popup-content ::slotted(*) {\n position: relative;\n\n /* Prevent content from being too wide - still helpful */\n max-width: min(400px, 90vw);\n max-height: min(500px, 80vh);\n overflow: auto;\n}\n";
@@ -16,6 +16,7 @@ opacity var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34,
16
16
  visibility var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1)),
17
17
  transform var(--ty-popup-duration, 180ms) var(--ty-popup-ease, cubic-bezier(0.34, 1.56, 0.64, 1));
18
18
  pointer-events: none;
19
+ outline: none;
19
20
  }
20
21
  .popup-dialog.position-calculated {
21
22
  top: var(--popup-y, 0px);
@@ -44,6 +45,7 @@ visibility: visible;
44
45
  opacity: 1;
45
46
  transform: scale(1);
46
47
  pointer-events: auto;
48
+ transition-duration: var(--ty-popup-duration, 180ms), 0s, var(--ty-popup-duration, 180ms);
47
49
  }
48
50
  .popup-dialog::backdrop {
49
51
  background: transparent;
@@ -16,7 +16,15 @@ ${inputStyles}
16
16
  :host(ty-radio) {
17
17
  display: inline-flex;
18
18
  width: auto;
19
- vertical-align: middle;
19
+ height: 1.25em;
20
+ height: 1lh;
21
+ align-items: center;
22
+ vertical-align: baseline;
23
+ overflow: visible;
24
+ }
25
+ :host(ty-radio)::before {
26
+ content: "\\200b";
27
+ width: 0;
20
28
  }
21
29
  :host(ty-radio-group) {
22
30
  display: block;
@@ -68,13 +76,11 @@ height: 100%;
68
76
  }
69
77
  .radio-container {
70
78
  display: inline-flex;
79
+ flex-shrink: 0;
71
80
  align-items: center;
72
- min-height: 1.25em;
73
- min-height: 1lh;
74
81
  cursor: pointer;
75
82
  user-select: none;
76
83
  outline: none;
77
- vertical-align: middle;
78
84
  }
79
85
  .radio-container:not(.disabled):not([aria-checked="true"]):hover .radio-circle {
80
86
  border-color: var(--radio-ring-off-hover, color-mix(in oklab, var(--ty-text) 80%, transparent));