@threadlabs/looma 0.53.9 → 0.53.11

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 (74) hide show
  1. package/README.md +16 -0
  2. package/blocks/editor-workspace.html +53 -0
  3. package/blocks/editor-workspace.js +15 -0
  4. package/blocks/list-detail.html +54 -0
  5. package/blocks/list-detail.js +62 -0
  6. package/blocks/search-and-open.html +33 -0
  7. package/blocks/search-and-open.js +53 -0
  8. package/blocks/settings-form.html +26 -0
  9. package/blocks/settings-form.js +16 -0
  10. package/components/shared/behaviors.d.ts +2 -0
  11. package/components/shared/behaviors.js +2 -0
  12. package/components/shared/collection-navigation.d.ts +28 -0
  13. package/components/shared/collection-navigation.js +40 -0
  14. package/components/shared/deferred-focus.d.ts +8 -0
  15. package/components/shared/deferred-focus.js +21 -0
  16. package/components/shared/form-reset.js +14 -6
  17. package/components/shared/menu-navigation.js +19 -22
  18. package/components/shared/overlay-dismissal.js +7 -0
  19. package/components/shared/overlay.js +3 -2
  20. package/components/ui-button/ui-button.html +1 -0
  21. package/components/ui-checkbox/ui-checkbox.html +1 -0
  22. package/components/ui-color-picker/ui-color-picker.html +1 -1
  23. package/components/ui-combobox/ui-combobox.html +5 -2
  24. package/components/ui-combobox/ui-combobox.js +6 -6
  25. package/components/ui-date-picker/ui-date-picker.js +5 -6
  26. package/components/ui-date-range-picker/ui-date-range-picker.js +6 -8
  27. package/components/ui-disclosure/ui-disclosure.html +3 -2
  28. package/components/ui-editor-toolbar/ui-editor-toolbar.js +8 -6
  29. package/components/ui-form-field/ui-form-field.html +1 -1
  30. package/components/ui-input/ui-input.html +1 -0
  31. package/components/ui-list-item/ui-list-item.html +3 -3
  32. package/components/ui-listbox/ui-listbox.html +1 -0
  33. package/components/ui-listbox/ui-listbox.js +10 -16
  34. package/components/ui-menu/ui-menu.html +1 -1
  35. package/components/ui-menu-item/ui-menu-item.html +1 -1
  36. package/components/ui-nav-item/ui-nav-item.html +2 -2
  37. package/components/ui-radio/ui-radio.html +1 -0
  38. package/components/ui-radio-group/ui-radio-group.html +1 -0
  39. package/components/ui-search-shell/ui-search-shell.js +4 -5
  40. package/components/ui-segmented-control/ui-segmented-control.html +3 -2
  41. package/components/ui-select/ui-select.html +4 -1
  42. package/components/ui-sidebar/ui-sidebar.html +7 -0
  43. package/components/ui-switch/ui-switch.html +1 -0
  44. package/components/ui-switcher/ui-switcher.html +28 -1
  45. package/components/ui-tabs/ui-tabs.js +5 -3
  46. package/components/ui-textarea/ui-textarea.html +5 -2
  47. package/dist/index.js +1 -1
  48. package/docs/catalog.json +80 -32
  49. package/editor/components.css +7 -3
  50. package/editor/index.js +77 -43
  51. package/package.json +8 -1
  52. package/styles/ui-button.css +1 -0
  53. package/styles/ui-checkbox.css +1 -0
  54. package/styles/ui-color-picker.css +2 -2
  55. package/styles/ui-combobox.css +8 -4
  56. package/styles/ui-disclosure.css +2 -1
  57. package/styles/ui-form-field.css +1 -1
  58. package/styles/ui-input.css +1 -0
  59. package/styles/ui-list-item.css +3 -3
  60. package/styles/ui-listbox.css +2 -0
  61. package/styles/ui-menu-item.css +1 -1
  62. package/styles/ui-nav-item.css +1 -1
  63. package/styles/ui-radio-group.css +1 -0
  64. package/styles/ui-radio.css +1 -0
  65. package/styles/ui-segmented-control.css +3 -2
  66. package/styles/ui-select.css +4 -1
  67. package/styles/ui-sidebar.css +12 -1
  68. package/styles/ui-switch.css +1 -0
  69. package/styles/ui-switcher.css +22 -1
  70. package/styles/ui-textarea.css +5 -2
  71. package/theme-system.css +3 -2
  72. package/tokens.css +1 -1
  73. package/vanilla/UiSwitcher.d.ts +2 -1
  74. package/vanilla/UiSwitcher.js +96 -16
@@ -1,4 +1,5 @@
1
1
  import { cancelActiveItemReveal, revealActiveItem } from "../shared/active-item-reveal.js";
2
+ import { enabledOptionIndices, nextActiveIndex } from "../shared/collection-navigation.js";
2
3
  import { afterFormReset } from "../shared/form-reset.js";
3
4
  import { closeOverlay, createAnchoredSurface, openOverlay } from "../shared/overlay.js";
4
5
 
@@ -168,7 +169,7 @@ export function connect(host) {
168
169
  // the one Enter makes, and it is highlighted as such.
169
170
  if (query && !host.state.rows.some((row) => !row.disabled) && canCreate()) host.state.active = host.state.rows.length;
170
171
  if (query && host.props.autoHighlight.value === "single") {
171
- const enabled = host.state.rows.flatMap((row, index) => row.disabled ? [] : [index]);
172
+ const enabled = enabledOptionIndices(host.state.rows);
172
173
  if (enabled.length === 1) host.state.active = enabled[0];
173
174
  }
174
175
  // Options in their declared shape: a row's `selected` flag is the list's own view state.
@@ -323,12 +324,11 @@ export function connect(host) {
323
324
  };
324
325
  const move = (key) => {
325
326
  const rows = host.state.rows ?? [];
326
- const indices = rows.flatMap((row, index) => row.disabled ? [] : [index]);
327
+ const indices = enabledOptionIndices(rows);
327
328
  if (canCreate()) indices.push(rows.length);
328
- if (!indices.length) return;
329
- const current = indices.indexOf(host.state.active);
330
- const next = key === "Home" ? 0 : key === "End" ? indices.length - 1 : key === "ArrowDown" ? Math.min(current + 1, indices.length - 1) : current < 0 ? indices.length - 1 : Math.max(0, current - 1);
331
- host.state.active = indices[next];
329
+ const next = nextActiveIndex(indices, host.state.active, key);
330
+ if (next < 0) return;
331
+ host.state.active = next;
332
332
  revealActiveItem(popup, () => document.getElementById(`${uid}-option-${host.state.active}`));
333
333
  };
334
334
  const validateCurrent = async () => {
@@ -6,6 +6,7 @@ import { afterFormReset } from "../shared/form-reset.js";
6
6
  import { externalValueTracker } from "../shared/external-value.js";
7
7
  import { readOptionalInput } from "../shared/binding-inputs.js";
8
8
  import { initialFieldValue } from "../shared/initial-field-value.js";
9
+ import { deferredFocus } from "../shared/deferred-focus.js";
9
10
 
10
11
  const optionNames = ["type", "valueFormat", "timeZone", "disambiguation", "min", "max", "allowedDates", "allowedRanges", "disabledDates", "disabledRanges", "disabledWeekdays"];
11
12
 
@@ -22,7 +23,7 @@ function interactions(host) {
22
23
  let current = host.state.current ?? host.props.value.value ?? "";
23
24
  const externalChanged = externalValueTracker(element, { initialValue: host.props.value.value });
24
25
  let connected = true;
25
- let frame;
26
+ const focus = deferredFocus(element.ownerDocument.defaultView);
26
27
  const settings = () => Object.fromEntries(optionNames.map(name => [name, host.props[name].value]));
27
28
  const initial = initialFieldValue(field, { ...settings(), locale: host.props.locale.value });
28
29
  try {
@@ -34,8 +35,7 @@ function interactions(host) {
34
35
  const close = restore => {
35
36
  host.state.opened = false; host.state.error = "";
36
37
  if (restore) {
37
- cancelAnimationFrame(frame);
38
- frame = requestAnimationFrame(() => { if (connected) trigger.focus(); });
38
+ focus.schedule(() => trigger.focus());
39
39
  }
40
40
  };
41
41
  const seed = () => {
@@ -60,8 +60,7 @@ function interactions(host) {
60
60
  queueMicrotask(() => {
61
61
  if (connected && host.state.opened && element.ownerDocument.activeElement !== clock) time.dispatchEvent(new CustomEvent("set-value", { cancelable: true, detail: { value: host.state.draftTime } }));
62
62
  });
63
- cancelAnimationFrame(frame);
64
- frame = requestAnimationFrame(() => {
63
+ focus.schedule(() => {
65
64
  if (!connected || !host.state.opened || popover.contains(element.ownerDocument.activeElement)) return;
66
65
  const date = host.state.draftDate || host.props.today.value;
67
66
  if (date) calendar.dispatchEvent(new CustomEvent("focus-date", { detail: { value: date } }));
@@ -122,7 +121,7 @@ function interactions(host) {
122
121
  });
123
122
  const reset = afterFormReset(control, () => { current = host.props.value.value ?? ""; host.state.current = current; close(); });
124
123
  return () => {
125
- connected = false; cancelAnimationFrame(frame); observer.disconnect(); stop(); reset(); close(); host.state.enhanced = false;
124
+ connected = false; focus.cancel(); observer.disconnect(); stop(); reset(); close(); host.state.enhanced = false;
126
125
  for (const name of fieldEvents) field.removeEventListener(name, relay);
127
126
  for (const name of ["open", "close"]) popover.removeEventListener(name, overlay);
128
127
  for (const name of fieldEvents) popover.removeEventListener(name, draft);
@@ -6,6 +6,7 @@ import { afterFormReset } from "../shared/form-reset.js";
6
6
  import { externalValueTracker } from "../shared/external-value.js";
7
7
  import { readOptionalInput } from "../shared/binding-inputs.js";
8
8
  import { initialFieldValue } from "../shared/initial-field-value.js";
9
+ import { deferredFocus } from "../shared/deferred-focus.js";
9
10
 
10
11
  const ruleNames = ["min", "max", "allowedDates", "allowedRanges", "disabledDates", "disabledRanges", "disabledWeekdays"];
11
12
  const endpoints = ["start", "end"];
@@ -24,9 +25,8 @@ function interactions(host) {
24
25
  let current = copy(host.state.current ?? host.props.value.value);
25
26
  const externalChanged = externalValueTracker(element, { initialValue: signature(copy(host.props.value.value)) });
26
27
  let committed = signature(current);
27
- let connected = true;
28
28
  let setting = false;
29
- let frame;
29
+ const focus = deferredFocus(element.ownerDocument.defaultView);
30
30
  let lastTrigger = "keyboard";
31
31
  const settings = () => Object.fromEntries(ruleNames.map(name => [name, host.props[name].value]));
32
32
  const allowed = range => isRangeAllowed(range, compileDateRules(settings()), host.props.allowUnavailableWithinRange.value);
@@ -63,8 +63,7 @@ function interactions(host) {
63
63
  host.state.opened = false; host.state.anchor = ""; host.state.error = "";
64
64
  if (wasOpen) host.dispatch("close", { open: false, reason, trigger });
65
65
  if (restore) {
66
- cancelAnimationFrame(frame);
67
- frame = requestAnimationFrame(() => { if (connected) element.ownerDocument.getElementById(host.state.activeAnchor)?.focus(); });
66
+ focus.schedule(() => element.ownerDocument.getElementById(host.state.activeAnchor)?.focus());
68
67
  }
69
68
  };
70
69
  const replaceFields = range => {
@@ -119,9 +118,8 @@ function interactions(host) {
119
118
  host.state.anchor = ""; host.state.popupValue = range[name] || range.start || range.end || "";
120
119
  host.state.activeAnchor = anchorId; host.state.error = ""; host.state.opened = true;
121
120
  host.dispatch("open", { open: true, reason: "action", trigger });
122
- cancelAnimationFrame(frame);
123
- frame = requestAnimationFrame(() => {
124
- if (!connected || !host.state.opened) return;
121
+ focus.schedule(() => {
122
+ if (!host.state.opened) return;
125
123
  const date = host.state.popupValue || host.props.today.value;
126
124
  if (date) calendar.dispatchEvent(new CustomEvent("focus-date", { detail: { value: date } }));
127
125
  else calendar.querySelector('[data-calendar-day][tabindex="0"], [data-calendar-days][tabindex="0"]')?.focus();
@@ -193,7 +191,7 @@ function interactions(host) {
193
191
  accept(copy(host.props.value.value)); committed = signature(current); close(); replaceFields(current);
194
192
  });
195
193
  return () => {
196
- connected = false; cancelAnimationFrame(frame); observer.disconnect(); stop(); reset();
194
+ focus.cancel(); observer.disconnect(); stop(); reset();
197
195
  for (const release of listeners) release();
198
196
  host.state.opened = false; host.state.enhanced = false;
199
197
  };
@@ -1,7 +1,7 @@
1
1
  <template component="ui-disclosure" module="./ui-disclosure.js">
2
2
  <defs>
3
3
  <prop name="density" type="keyword" values="comfortable, compact" default="comfortable"
4
- >Compact trades padding and type size for rows that fit more on screen.</prop>
4
+ >Compact reduces row spacing while keeping the shared UI text size.</prop>
5
5
  <prop name="variant" type="keyword" values="plain, navigation" default="plain"
6
6
  >Navigation shares icon columns, spacing, type, hover, and corners with Nav Item, while keeping expanded sections neutral: opening content is not route
7
7
  selection. Plain retains the standard disclosure treatment.</prop>
@@ -94,6 +94,7 @@
94
94
  background: transparent;
95
95
  color: inherit;
96
96
  font: inherit;
97
+ font-size: var(--ui-font-size-sm);
97
98
  font-weight: var(--ui-font-semibold);
98
99
  text-align: start;
99
100
  cursor: pointer;
@@ -200,7 +201,7 @@
200
201
  min-block-size: var(--ui-nav-min-block-size);
201
202
  padding-block: var(--ui-nav-padding-block) !important;
202
203
  border-radius: var(--ui-selection-radius);
203
- font-size: var(--ui-font-size-md);
204
+ font-size: var(--ui-font-size-sm);
204
205
  font-weight: var(--ui-font-normal);
205
206
  color: var(--ui-text-secondary);
206
207
  }
@@ -1,3 +1,5 @@
1
+ import { nextCollectionPosition } from "../shared/collection-navigation.js";
2
+
1
3
  const selector = 'button, a[href], [role="button"], select, input:not([type="hidden"])';
2
4
 
3
5
  /** Keep one Tab stop in the toolbar; arrow keys move among its enabled authored controls. */
@@ -24,12 +26,12 @@ export function connect(host) {
24
26
  const index = items.indexOf(event.target.closest?.(selector));
25
27
  if (index < 0) return;
26
28
  const rtl = getComputedStyle(strip).direction === "rtl";
27
- let next;
28
- if (event.key === "ArrowRight") next = (index + (rtl ? -1 : 1) + items.length) % items.length;
29
- else if (event.key === "ArrowLeft") next = (index + (rtl ? 1 : -1) + items.length) % items.length;
30
- else if (event.key === "Home") next = 0;
31
- else if (event.key === "End") next = items.length - 1;
32
- else return;
29
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") return;
30
+ const previousKey = rtl ? "ArrowRight" : "ArrowLeft";
31
+ const nextKey = rtl ? "ArrowLeft" : "ArrowRight";
32
+ const key = event.key === previousKey ? "ArrowUp" : event.key === nextKey ? "ArrowDown" : event.key;
33
+ const next = nextCollectionPosition(items.length, index, key, true);
34
+ if (next < 0) return;
33
35
  event.preventDefault();
34
36
  items[next]?.focus();
35
37
  };
@@ -46,7 +46,7 @@
46
46
 
47
47
  .label {
48
48
  color: var(--_ui-form-field-label-text, var(--ui-text-secondary));
49
- font-size: var(--_ui-form-field-label-font-size, var(--ui-field-label-font-size, var(--ui-font-size-md)));
49
+ font-size: var(--_ui-form-field-label-font-size, var(--ui-field-label-font-size, var(--ui-font-size-sm)));
50
50
  }
51
51
 
52
52
  /* A label action, such as a small help button, sits after the label text in a box one line
@@ -77,6 +77,7 @@
77
77
  background-image: var(--_ui-default-input-highlight, var(--ui-surface-highlight, none));
78
78
  color: var(--ui-text-primary);
79
79
  font: inherit;
80
+ font-size: var(--ui-font-size-sm);
80
81
  line-height: var(--ui-line-height-tight);
81
82
  box-shadow: var(--ui-input-shadow, var(--_ui-default-input-shadow, var(--ui-control-inset)));
82
83
  transition:
@@ -141,9 +141,9 @@
141
141
  }
142
142
 
143
143
  .title {
144
- font-size: var(--ui-font-size-md);
144
+ font-size: var(--ui-font-size-sm);
145
145
  font-weight: var(--_ui-list-item-title-weight, var(--ui-font-medium));
146
- line-height: var(--ui-line-height-tight);
146
+ line-height: var(--ui-line-height);
147
147
  }
148
148
 
149
149
  /* Keep identity and disclosure marks beside the first line, even with a long description. */
@@ -153,7 +153,7 @@
153
153
 
154
154
  :host([align="title"]) .leading,
155
155
  :host([align="title"]) .trailing {
156
- min-block-size: calc(var(--ui-font-size-md) * var(--ui-line-height-tight));
156
+ min-block-size: calc(var(--ui-font-size-sm) * var(--ui-line-height));
157
157
  }
158
158
 
159
159
  .description {
@@ -91,6 +91,7 @@
91
91
  background: var(--ui-listbox-surface, var(--ui-control-surface));
92
92
  color: var(--ui-text-primary);
93
93
  font: inherit;
94
+ font-size: var(--ui-font-size-sm);
94
95
  line-height: var(--ui-line-height-md);
95
96
  box-shadow: var(--ui-control-inset);
96
97
  outline: none;
@@ -1,4 +1,6 @@
1
1
  import { cancelActiveItemReveal, revealActiveItem } from "../shared/active-item-reveal.js";
2
+ import { collectionNavigationKeys, enabledOptionIndices, nextActiveIndex } from "../shared/collection-navigation.js";
3
+ import { afterFormReset } from "../shared/form-reset.js";
2
4
  let nextId = 0;
3
5
 
4
6
  const same = (left, right) => JSON.stringify(left) === JSON.stringify(right);
@@ -17,7 +19,6 @@ function readOptions(container) {
17
19
  export function connect(host) {
18
20
  const element = host.element;
19
21
  const { options: authored, validity } = host.refs;
20
- const form = element.closest("form");
21
22
  host.state.uid = `ui-listbox-${++nextId}`;
22
23
  if (element.id && !element.hasAttribute("aria-label") && !element.hasAttribute("aria-labelledby")) {
23
24
  const label = Array.from(element.ownerDocument.querySelectorAll("label[for]")).find((candidate) => candidate.htmlFor === element.id);
@@ -39,7 +40,6 @@ export function connect(host) {
39
40
  : (host.props.value.value === undefined || host.props.value.value === null ? null : [String(host.props.value.value)]);
40
41
  const defaultSelection = () => externallySelected()
41
42
  ?? options.filter((option) => option.selected).map((option) => option.value).slice(0, host.props.multiple.value ? undefined : 1);
42
- const enabledIndices = () => options.filter((option) => !option.disabled).map((option) => option.index);
43
43
  const render = () => {
44
44
  const set = new Set(selected());
45
45
  const rows = options.map((option) => ({
@@ -94,15 +94,10 @@ export function connect(host) {
94
94
  } else setSelection([option.value], trigger);
95
95
  };
96
96
  const move = (key) => {
97
- const indices = enabledIndices();
98
- if (!indices.length) return;
99
- const current = indices.indexOf(host.state.active);
100
- const next = key === "Home" ? indices[0]
101
- : key === "End" ? indices[indices.length - 1]
102
- : key === "ArrowDown" ? indices[(current + 1) % indices.length]
103
- : indices[(current <= 0 ? indices.length : current) - 1];
104
- activate(next);
105
- if (!host.props.multiple.value) choose(next, "keyboard");
97
+ const next = nextActiveIndex(enabledOptionIndices(options), host.state.active, key, { wrap: true });
98
+ if (next < 0) return;
99
+ if (host.props.multiple.value) activate(next);
100
+ else choose(next, "keyboard");
106
101
  };
107
102
  const onClick = (event) => {
108
103
  if (host.props.disabled.value) return;
@@ -113,12 +108,12 @@ export function connect(host) {
113
108
  };
114
109
  const onKeydown = (event) => {
115
110
  if (host.props.disabled.value || event.altKey || event.metaKey || event.ctrlKey) return;
116
- if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
111
+ if (collectionNavigationKeys.includes(event.key)) {
117
112
  event.preventDefault();
118
113
  move(event.key);
119
114
  } else if (event.key === " " || event.key === "Enter") {
120
115
  event.preventDefault();
121
- choose(host.state.active >= 0 ? host.state.active : enabledIndices()[0], "keyboard");
116
+ choose(host.state.active >= 0 ? host.state.active : enabledOptionIndices(options)[0], "keyboard");
122
117
  } else if (event.key.length === 1 && !event.shiftKey) {
123
118
  typeahead += event.key.toLocaleLowerCase();
124
119
  clearTimeout(typeaheadTimer);
@@ -130,7 +125,7 @@ export function connect(host) {
130
125
  }
131
126
  }
132
127
  };
133
- const onReset = () => queueMicrotask(() => {
128
+ const stopReset = afterFormReset(validity, () => {
134
129
  setSelection(initial);
135
130
  host.state.validationError = false;
136
131
  });
@@ -156,7 +151,6 @@ export function connect(host) {
156
151
  });
157
152
  element.addEventListener("click", onClick);
158
153
  element.addEventListener("keydown", onKeydown);
159
- form?.addEventListener("reset", onReset);
160
154
  validity.addEventListener("invalid", onInvalid);
161
155
  return () => {
162
156
  cancelActiveItemReveal(element);
@@ -167,7 +161,7 @@ export function connect(host) {
167
161
  clearTimeout(typeaheadTimer);
168
162
  element.removeEventListener("click", onClick);
169
163
  element.removeEventListener("keydown", onKeydown);
170
- form?.removeEventListener("reset", onReset);
164
+ stopReset();
171
165
  validity.removeEventListener("invalid", onInvalid);
172
166
  };
173
167
  }
@@ -1,7 +1,7 @@
1
1
  <template component="ui-menu" module="./ui-menu.js">
2
2
  <defs>
3
3
  <prop name="density" type="keyword" values="comfortable, compact" default="comfortable"
4
- >Compact trades padding and type size for rows that fit more on screen.</prop>
4
+ >Compact reduces row spacing while keeping the shared UI text size.</prop>
5
5
  <prop name="icons" type="boolean" default="false"
6
6
  >Reserves a fixed icon column in every item, including items without an icon. Supply item icons through their icon slot.</prop>
7
7
  <prop name="size" type="keyword" values="sm, md" default="md"
@@ -60,7 +60,7 @@
60
60
  text-align: left;
61
61
  border-radius: var(--ui-menu-item-radius, var(--_ui-default-menu-item-radius, var(--ui-selection-radius)));
62
62
  color: var(--ui-text-primary);
63
- font-size: var(--ui-menu-item-font-size, var(--_ui-default-menu-item-font-size, var(--ui-font-size-md)));
63
+ font-size: var(--ui-menu-item-font-size, var(--_ui-default-menu-item-font-size, var(--ui-font-size-sm)));
64
64
  font-weight: var(--ui-font-medium);
65
65
  text-decoration: none;
66
66
  cursor: pointer;
@@ -4,7 +4,7 @@
4
4
  >surface marks the current row with a quiet filled surface and shared corners. line uses square corners and a continuous logical start edge. Both retain the
5
5
  resting label weight and expose aria-current.</prop>
6
6
  <prop name="density" type="keyword" values="comfortable, compact" default="comfortable"
7
- >Compact uses smaller type and row spacing to sit alongside a compact tree; comfortable keeps the regular navigation row.</prop>
7
+ >Compact reduces row spacing to sit alongside a compact tree; both densities keep the shared UI text size.</prop>
8
8
  <prop name="current" type="keyword" values="true, false, page, step, location" default="false"
9
9
  >Marks the item as where you are: it takes the selected surface, the selected text, and the chosen surface or line treatment, and states aria-current, which
10
10
  assistive technology announces. "true" means the current page (aria-current="page"); "step" marks the current step of a process, and "location" the
@@ -162,7 +162,7 @@
162
162
  }
163
163
 
164
164
  .label {
165
- font-size: var(--ui-font-size-md);
165
+ font-size: var(--ui-font-size-sm);
166
166
  line-height: var(--ui-line-height-tight);
167
167
  }
168
168
 
@@ -44,6 +44,7 @@
44
44
  gap: var(--ui-radio-gap, var(--ui-space-2)) !important;
45
45
  max-inline-size: 100%;
46
46
  color: var(--ui-text-primary);
47
+ font-size: var(--ui-font-size-sm);
47
48
  cursor: pointer;
48
49
  }
49
50
 
@@ -57,6 +57,7 @@
57
57
  margin: 0 0 var(--ui-space-2) !important;
58
58
  padding: 0 !important;
59
59
  color: var(--ui-text-primary);
60
+ font-size: var(--ui-field-label-font-size, var(--ui-font-size-sm));
60
61
  font-weight: var(--ui-font-medium);
61
62
  }
62
63
 
@@ -1,4 +1,5 @@
1
1
  import { cancelActiveItemReveal, focusAndRevealItem } from "../shared/active-item-reveal.js";
2
+ import { collectionNavigationKeys, nextCollectionPosition } from "../shared/collection-navigation.js";
2
3
  import { closeDialog, closeOverlay, openOverlay, showDialog } from "../shared/overlay.js";
3
4
  import { trackTrigger } from "../shared/trigger.js";
4
5
 
@@ -57,7 +58,7 @@ export function connect(host) {
57
58
  dispatchClose("escape", "keyboard");
58
59
  return;
59
60
  }
60
- if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
61
+ if (!collectionNavigationKeys.includes(event.key)) return;
61
62
  const rows = resultRows();
62
63
  if (!rows.length) return;
63
64
  const target = event.target;
@@ -65,10 +66,8 @@ export function connect(host) {
65
66
  const index = rows.indexOf(target.closest?.(".body button[aria-current]"));
66
67
  if (!fromSearch && index < 0) return;
67
68
  event.preventDefault();
68
- if (event.key === "Home") focusAndRevealItem(dialog, rows[0]);
69
- else if (event.key === "End") focusAndRevealItem(dialog, rows.at(-1));
70
- else if (event.key === "ArrowDown") focusAndRevealItem(dialog, rows[fromSearch ? 0 : (index + 1) % rows.length]);
71
- else focusAndRevealItem(dialog, rows[fromSearch ? rows.length - 1 : (index - 1 + rows.length) % rows.length]);
69
+ const next = nextCollectionPosition(rows.length, fromSearch ? -1 : index, event.key, true);
70
+ focusAndRevealItem(dialog, rows[next]);
72
71
  };
73
72
  const onClick = (event) => {
74
73
  if (host.props.dismissible.value && event.target === dialog) dispatchClose("light-dismiss", trigger());
@@ -42,7 +42,7 @@
42
42
  :host {
43
43
  --_segmented-size: var(--ui-control-size-md);
44
44
  --_segmented-inset: var(--ui-space-3);
45
- --_segmented-font-size: var(--ui-font-size-md);
45
+ --_segmented-font-size: var(--ui-font-size-sm);
46
46
  --_segmented-padding: var(--ui-space-1) !important;
47
47
  --_segmented-radius: var(--ui-field-radius, var(--ui-radius-md));
48
48
  display: inline-grid !important;
@@ -55,6 +55,7 @@
55
55
  border: 0;
56
56
  color: var(--ui-text-primary);
57
57
  font: inherit;
58
+ font-size: var(--ui-field-label-font-size, var(--ui-font-size-sm));
58
59
  }
59
60
  legend {
60
61
  float: inline-start;
@@ -115,7 +116,7 @@
115
116
  :host([invalid]) .segments { border-color: var(--ui-field-danger, var(--ui-danger-solid)); }
116
117
  :host([invalid]) legend { color: var(--ui-field-danger, var(--ui-danger-solid)); }
117
118
  :host([size="sm"]) { --_segmented-size: var(--ui-control-size-sm); --_segmented-inset: var(--ui-space-2); --_segmented-font-size: var(--ui-font-size-sm); }
118
- :host([size="lg"]) { --_segmented-size: var(--ui-control-size-lg); --_segmented-inset: var(--ui-space-4); --_segmented-font-size: var(--ui-font-size-lg); }
119
+ :host([size="lg"]) { --_segmented-size: var(--ui-control-size-lg); --_segmented-inset: var(--ui-space-4); --_segmented-font-size: var(--ui-font-size-md); }
119
120
  :host[hidden] { display: none !important; }
120
121
  @media (forced-colors: active) {
121
122
  .segments { border-color: ButtonText; }
@@ -35,6 +35,7 @@
35
35
  color: var(--ui-text-primary);
36
36
  color-scheme: inherit;
37
37
  font: inherit;
38
+ font-size: var(--ui-font-size-sm);
38
39
  line-height: var(--ui-line-height-tight);
39
40
  box-shadow: var(--ui-select-shadow, var(--ui-shadow-sm));
40
41
  transition:
@@ -134,7 +135,9 @@
134
135
 
135
136
  /* Touch may use body-size text in a small native field to avoid focus zoom; this does not impose a larger visible control height. */
136
137
  @media (pointer: coarse) {
137
- :host([size="sm"]) {
138
+ :host,
139
+ :host([size="sm"]),
140
+ :host([size="lg"]) {
138
141
  font-size: var(--ui-font-size-md);
139
142
  }
140
143
  }
@@ -57,6 +57,13 @@
57
57
  transition: inline-size var(--ui-motion-layout) var(--ui-motion-layout-ease), visibility var(--ui-motion-layout);
58
58
  }
59
59
 
60
+ /* Without a drawer controller, keep navigation in flow and reserve most of the row for content. */
61
+ @media (scripting: none) {
62
+ :host {
63
+ max-inline-size: 33%;
64
+ }
65
+ }
66
+
60
67
  :host([side="end"]) {
61
68
  border-inline-end: 0;
62
69
  border-inline-start: var(--ui-border-width) solid var(--ui-sidebar-border, var(--ui-border-divider));
@@ -54,6 +54,7 @@
54
54
  gap: var(--ui-switch-gap, var(--ui-space-2)) !important;
55
55
  max-inline-size: 100%;
56
56
  color: var(--ui-text-primary);
57
+ font-size: var(--ui-font-size-sm);
57
58
  cursor: pointer;
58
59
  }
59
60
 
@@ -11,9 +11,18 @@
11
11
  bottoms.</prop>
12
12
  <prop name="limit" type="integer"
13
13
  >Most children allowed in a horizontal row. When the count exceeds this value, every child stacks regardless of width. Omit it for no count limit.</prop>
14
+ <prop name="balance" type="keyword" values="equal, narrow-start, narrow-end" default="equal"
15
+ >Use the start and end slots to give one pane about a third of the row for a rail or inspector. At the same threshold, the start pane stacks above the end
16
+ pane. Equal uses the default slot and gives children the same width.</prop>
14
17
  <state type="boolean" name="overLimit" value="false"></state>
15
18
  </defs>
16
- <div><slot></slot></div>
19
+ <template $match>
20
+ <div $when="$balance = 'equal'"><slot></slot></div>
21
+ <div $else>
22
+ <div class="start"><slot name="start"></slot></div>
23
+ <div class="end"><slot name="end"></slot></div>
24
+ </div>
25
+ </template>
17
26
  <style>
18
27
  :host {
19
28
  --_switcher-gap: var(--ui-space-4);
@@ -34,6 +43,24 @@
34
43
  grid-template-columns: minmax(0, 1fr);
35
44
  }
36
45
 
46
+ /* Reuse the width threshold as the flex basis. Below it, each full-width item
47
+ gets its own line. Above it, grow factors divide the available space. */
48
+ :host(:is([balance="narrow-start"], [balance="narrow-end"]):not(:state(overLimit))):not([hidden]) {
49
+ display: flex !important;
50
+ flex-flow: row wrap !important;
51
+ }
52
+
53
+ .start,
54
+ .end {
55
+ flex: 2 1 var(--_switcher-track) !important;
56
+ min-inline-size: 0;
57
+ }
58
+
59
+ :host([balance="narrow-start"]) > .start,
60
+ :host([balance="narrow-end"]) > .end {
61
+ flex-grow: 1 !important;
62
+ }
63
+
37
64
  :host([gap="xs"]) {
38
65
  --_switcher-gap: var(--ui-space-2);
39
66
  }
@@ -1,4 +1,5 @@
1
1
  import { trackTrigger } from "../shared/trigger.js";
2
+ import { nextCollectionPosition } from "../shared/collection-navigation.js";
2
3
 
3
4
  let panelIds = 0;
4
5
  const GROUP_EVENT = "looma-tabs-group";
@@ -111,10 +112,11 @@ export function connect(host) {
111
112
  select(button, "keyboard");
112
113
  return;
113
114
  }
114
- if (event.key !== previousKey && event.key !== nextKey && event.key !== "Home" && event.key !== "End") return;
115
+ const key = event.key === previousKey ? "ArrowUp" : event.key === nextKey ? "ArrowDown" : event.key;
116
+ if (!vertical && (event.key === "ArrowUp" || event.key === "ArrowDown")) return;
117
+ const next = buttons[nextCollectionPosition(buttons.length, buttons.indexOf(button), key, true)];
118
+ if (!next) return;
115
119
  event.preventDefault();
116
- const index = buttons.indexOf(button);
117
- const next = event.key === "Home" ? buttons[0] : event.key === "End" ? buttons.at(-1) : buttons[(index + (event.key === nextKey ? 1 : buttons.length - 1)) % buttons.length];
118
120
  if (host.props.activation.value !== "manual") select(next, "keyboard");
119
121
  focusTab(next);
120
122
  };
@@ -47,6 +47,7 @@
47
47
  background-image: var(--_ui-default-textarea-highlight, var(--ui-surface-highlight, none));
48
48
  color: var(--ui-text-primary);
49
49
  font: inherit;
50
+ font-size: var(--ui-font-size-sm);
50
51
  line-height: var(--ui-line-height-md);
51
52
  box-shadow: var(--ui-textarea-shadow, var(--_ui-default-textarea-shadow, var(--ui-control-inset)));
52
53
  transition:
@@ -131,8 +132,10 @@
131
132
 
132
133
  /* Below 16px, iOS zooms the page into the focused field, so touch keeps body-size text. */
133
134
  @media (pointer: coarse) {
134
- :host([size="sm"]) {
135
- font-size: inherit;
135
+ :host,
136
+ :host([size="sm"]),
137
+ :host([size="lg"]) {
138
+ font-size: var(--ui-font-size-md);
136
139
  }
137
140
  }
138
141