lostcoords-ui 0.14.10 → 0.14.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84077c9a58c40198412c3d229e69015dabe6a80f5a25bd257e22fc18abf73020
4
- data.tar.gz: 41782f8795d5c8c4e9dd45796ceba268a91f8bc7a427987b8006ec147b749f6f
3
+ metadata.gz: df62b2154bc5fe1c0561cc8f5a92db48a0dffdb2b6e73afce18ebeefaa5dd50a
4
+ data.tar.gz: 986cb18b76430f68a676d6786c65f3c3c4483e23bf445cd3248702df46a3d282
5
5
  SHA512:
6
- metadata.gz: 38e4ae910c25a3d000052713ec957b36c49b2f1a1f146f31f85e46974514f7c11595351bb07fdf7b874304b0ba48fc3a8b1782f015d19441024ed65fc4f584b1
7
- data.tar.gz: 3606c135d2aa929104c5072b29c37737b5ce80dab8b471c59da29a2de1431c8101c5ef36d3c06efa362ca44077180b03c78dad9ba69041b39c52f180de74bc22
6
+ metadata.gz: 03ae7326f876da302da67b0ee3f2c6edd98ca240cbe54ec9d7233e954e145593895616c2ac0d52fff637366b32cfa8a57ab01071719a3b7fb4744298335cb085
7
+ data.tar.gz: 1e4c6fbccdf6b5a969a37588f1aed9eb4e0847b64e646d53b12d8b554f02301737353e6480e9546b8f2a6585af1273d8ec48e599165d04ab1d295d53e7d84d78
data/README.md CHANGED
@@ -51,12 +51,12 @@ Tailwind build writes stable paths for them next to the engine's own import:
51
51
  @import "../builds/tailwind/lostcoords_ui/components/menu.css";
52
52
  ```
53
53
 
54
- `base.css` holds the document defaults: body styles, heading defaults, global inline-code styles and
55
- document corner radii. Skip it when the host owns its base styles, map the library's tokens to your
54
+ `base.css` holds the document defaults: body styles, heading defaults, global inline-code styles, the
55
+ focus ring and the reduced-motion reset. Skip it when the host owns its base styles, map the library's tokens to your
56
56
  app's theme and keep your Tailwind theme declarations after the imports.
57
57
  `core.css` holds the tokens, buttons, badges, avatars, cards, alerts, form controls, choices,
58
58
  toggles, layout, typography and navigation. The opt-in entries are `dialog` (with the phone sheet),
59
- `menu` (menus and popovers), `toast`, `search`, `tooltip`, `collapsible`, `code-block`,
59
+ `menu` (menus and popovers), `toast`, `search`, `tooltip`, `hovercard`, `collapsible`, `code-block`,
60
60
  `emoji-picker`, `table`, `prose` and `shell` (`lc_app_header`, `lc_sidebar`, `lc_docs_shell` and `lc_dock`; the
61
61
  dock's action menu and the sidebar's account menu also need `menu`). A component whose entry is missing renders unstyled.
62
62
 
@@ -170,6 +170,38 @@ Omit `only` to register every library controller. Unknown identifiers raise befo
170
170
  registered, and repeated calls on the same application keep later overrides, so register defaults
171
171
  before application overrides.
172
172
 
173
+ ## Changes in 0.14.11
174
+
175
+ Nothing needs an edit. Changed:
176
+
177
+ - **A disabled `lc_input`, `lc_select`, `lc_textarea` or toggle pill looks disabled**: muted text and a
178
+ not-allowed cursor, as buttons and segmented items already had. A disabled select no longer fills on hover.
179
+ - **Emoji grid buttons show the focus ring.** They marked keyboard focus with the hover fill alone.
180
+ - **The emoji picker has a set height**, on desktop and as a phone sheet. It grew when its catalog arrived
181
+ after opening, and on desktop could jump to the other side of its trigger.
182
+ - **`lc_search` group titles use the eyebrow role**, so under `lang="ja"` they drop the mono face and
183
+ uppercase like every other eyebrow.
184
+
185
+ Fixed:
186
+
187
+ - **Input methods.** Escape that cancels a conversion no longer closes the dialog, menu or popover around
188
+ the field. `lc_search` shows results for text committed from an input method in Chrome, which sends no
189
+ input event after the composition ends. In Safari, the Enter that commits a conversion no longer picks
190
+ the first match in the emoji picker or any other catalog picker.
191
+ - **A catalog that failed to load is asked for again** on the next open; the failure was kept until a
192
+ full page load.
193
+ - **An `lc_dialog` replaced while open releases the page.** A stream that swapped the open dialog sent no
194
+ close event, so the page stayed scroll-locked.
195
+ - **A linked or interactive card eases its lift and fill on hover.** The transition named `transform`,
196
+ which the lift does not use, and replaced the card's own.
197
+ - **A button-mode `lc_toggle_group` renders its `value:` selected.** The choice appeared only once the
198
+ controller connected.
199
+ - **An `lc_fieldset` with an error turns its legend red**, as a field does its label.
200
+ - **Skin-tone options carry `aria-checked`**, so a screen reader announces the chosen one.
201
+ - **`lc_char_counter` follows a form reset**, and a tooltip dismissed with Escape shows again after
202
+ coming back to a cached page.
203
+ - **A collapsible closes in a browser without `::details-content`**, where reading its duration threw.
204
+
173
205
  ## Changes in 0.14.10
174
206
 
175
207
  Nothing needs an edit. Added:
@@ -98,7 +98,10 @@
98
98
  color: var(--foreground);
99
99
  flex-direction: column;
100
100
  inline-size: 100%;
101
- max-block-size: min(72svh, 34rem);
101
+
102
+ /* A set height, not a maximum: the catalog arrives after the panel opens, and the panel would
103
+ grow under the reader's finger, or jump to the other side of its trigger on desktop. */
104
+ block-size: min(72svh, 34rem);
102
105
  padding-block-end: max(env(safe-area-inset-bottom), 8px);
103
106
  border-start-start-radius: var(--radius-3xl, 1.5rem);
104
107
  border-start-end-radius: var(--radius-3xl, 1.5rem);
@@ -340,7 +343,6 @@
340
343
  &:focus-visible {
341
344
  background: var(--muted);
342
345
  transform: scale(1.12);
343
- outline: none;
344
346
  }
345
347
 
346
348
  &[aria-current="true"] { background: color-mix(in oklab, var(--primary) 12%, var(--background)); }
@@ -405,7 +407,7 @@
405
407
  inset-block: calc(100% + 8px) auto;
406
408
  inset-inline: 0 auto;
407
409
  inline-size: min(var(--lc-emoji-picker-popover-width, 22rem), calc(100vw - 32px));
408
- max-block-size: min(28rem, calc(100vh - 96px));
410
+ block-size: min(28rem, calc(100vh - 96px));
409
411
  padding-block-end: 0;
410
412
  border-radius: var(--radius-3xl, 1.5rem);
411
413
  transform: translateY(-4px) scale(0.98);
@@ -102,6 +102,8 @@ module Lostcoords::Ui
102
102
  "font-sans text-muted-foreground whitespace-nowrap cursor-pointer no-underline " \
103
103
  "transition-[background-color,border-color,color,transform] duration-(--lc-motion-quick) ease-(--lc-ease-out) " \
104
104
  "lc-press hover:text-foreground " \
105
+ "lc-disabled:cursor-not-allowed lc-disabled:text-[color-mix(in_oklab,var(--foreground)_38%,transparent)] " \
106
+ "has-lc-disabled:cursor-not-allowed has-lc-disabled:text-[color-mix(in_oklab,var(--foreground)_38%,transparent)] " \
105
107
  "aria-pressed:bg-primary aria-pressed:border-transparent aria-pressed:text-primary-foreground aria-pressed:shadow-none " \
106
108
  "aria-checked:bg-primary aria-checked:border-transparent aria-checked:text-primary-foreground aria-checked:shadow-none " \
107
109
  "aria-[current]:not-aria-[current=false]:bg-primary aria-[current]:not-aria-[current=false]:border-transparent " \
@@ -8,7 +8,7 @@ module Lostcoords::Ui
8
8
  md: "p-inset",
9
9
  sm: "[--lc-inset:var(--spacing-content)] p-inset"
10
10
  }.freeze
11
- HOVER_LIFT = "transition-[transform,box-shadow] duration-(--lc-motion-control) ease-(--lc-ease-out) motion-safe:hover:-translate-y-0.5 hover:shadow-(--lc-shadow)"
11
+ HOVER_LIFT = "transition-[background-color,border-color,box-shadow,translate] duration-(--lc-motion-control) ease-(--lc-ease-out) motion-safe:hover:-translate-y-0.5 hover:shadow-(--lc-shadow)"
12
12
 
13
13
  def lc_card_class(interactive: false, padding: :md, extra: nil)
14
14
  padding = lc_option!(:padding, padding, CARD_PADDING.keys)
@@ -49,14 +49,15 @@ module Lostcoords::Ui
49
49
  "font-sans text-base bg-(--lc-field-bg,var(--input)) text-foreground placeholder:text-muted-foreground " \
50
50
  "border border-transparent rounded-xl lc-squircle " \
51
51
  "transition-[border-color,box-shadow] duration-(--lc-motion-quick) ease-(--lc-ease-out) " \
52
- "aria-invalid:border-destructive aria-invalid:shadow-[0_0_0_3px_color-mix(in_oklab,var(--destructive)_16%,transparent)]"
52
+ "aria-invalid:border-destructive aria-invalid:shadow-[0_0_0_3px_color-mix(in_oklab,var(--destructive)_16%,transparent)] " \
53
+ "lc-disabled:cursor-not-allowed lc-disabled:text-[color-mix(in_oklab,var(--foreground)_38%,transparent)]"
53
54
 
54
55
  # Text and nothing else: for a control inside a row that draws the focus ring itself, such as lc_list_field.
55
56
  INPUT_PLAIN =
56
57
  "w-full max-w-full min-w-0 min-h-9 p-0 border-0 bg-transparent font-sans text-base text-foreground " \
57
58
  "placeholder:text-muted-foreground aria-invalid:placeholder:text-destructive outline-none"
58
59
 
59
- FIELD_BASE = "lc-field grid min-w-0 has-aria-invalid:[&>label]:text-destructive"
60
+ FIELD_BASE = "lc-field grid min-w-0 has-aria-invalid:[&>label]:text-destructive aria-invalid:[&>legend]:text-destructive"
60
61
  FIELD_SIZES = { sm: "gap-tight", md: "gap-related" }.freeze
61
62
  # Field labels use the text roles; TypographyHelper loads after this file, so its sizes are read at call time.
62
63
  FIELD_LABEL_ROLES = { sm: :caption, md: :label }.freeze
@@ -96,7 +97,7 @@ module Lostcoords::Ui
96
97
 
97
98
 
98
99
  def lc_select_class(size: :md, extra: nil)
99
- lc_tw(lc_input_class(size: size), "lc-select rounded-pill ps-4 pe-10 cursor-pointer hover:bg-(--lc-input-hover)", extra)
100
+ lc_tw(lc_input_class(size: size), "lc-select rounded-pill ps-4 pe-10 cursor-pointer enabled:hover:bg-(--lc-input-hover)", extra)
100
101
  end
101
102
 
102
103
  def lc_textarea_class(extra: nil)
@@ -38,7 +38,7 @@ module Lostcoords::Ui
38
38
  }
39
39
  }.freeze
40
40
  NAV_INDICATOR = "pointer-events-none absolute start-0 top-0 bg-(--lc-nav-indicator,var(--accent)) opacity-0 " \
41
- "transition-[translate,width,height,opacity] duration-[400ms] ease-(--lc-ease-out-expo) motion-reduce:transition-none " \
41
+ "transition-[translate,width,height,opacity] duration-400 ease-(--lc-ease-out-expo) motion-reduce:transition-none " \
42
42
  "group-data-[indicator]/nav:opacity-100"
43
43
 
44
44
  # An inline text link. Prose inside lc_prose styles its links already.
@@ -34,7 +34,7 @@ module Lostcoords::Ui
34
34
  lc_label!(title, :title)
35
35
  defaults = { class: "flex flex-col py-related", aria: { label: title }, data: { slot: "search-group" } }
36
36
  tag.section(**lc_attributes(defaults, attributes)) do
37
- safe_join([ tag.h2(title, class: "px-heading pb-related font-mono text-xs font-medium uppercase tracking-widest text-muted-foreground", data: { slot: "search-group-title" }), (capture(&block) if block) ])
37
+ safe_join([ tag.h2(title, class: lc_text_class(size: :eyebrow, tone: :muted, extra: "px-heading pb-related"), data: { slot: "search-group-title" }), (capture(&block) if block) ])
38
38
  end
39
39
  end
40
40
 
@@ -161,6 +161,7 @@ module Lostcoords::Ui
161
161
  return lc_toggle_radio(content, group[:name], value, checked, input, defaults, attributes)
162
162
  end
163
163
 
164
+ selected = group[:value] == value.to_s if selected.nil?
164
165
  required = { type: "button", role: "radio", data: { lc_selection_target: "option", value: value } }
165
166
  tag.button(content, **lc_attributes(defaults.merge(aria: { checked: selected || false }), attributes, required))
166
167
  end
@@ -19,11 +19,16 @@ export default class extends Controller {
19
19
  this.field = this.forValue ? document.getElementById(this.forValue) : this.nearestField()
20
20
  this.input = () => this.render()
21
21
  this.field?.addEventListener("input", this.input)
22
+ // A reset empties the field after its event, and sends no input event of its own.
23
+ this.form = this.field?.form
24
+ this.reset = () => setTimeout(this.input)
25
+ this.form?.addEventListener("reset", this.reset)
22
26
  this.render()
23
27
  }
24
28
 
25
29
  disconnect() {
26
30
  this.field?.removeEventListener("input", this.input)
31
+ this.form?.removeEventListener("reset", this.reset)
27
32
  }
28
33
 
29
34
  update({ detail }) {
@@ -89,10 +89,11 @@ export default class extends Controller {
89
89
  return this.element.querySelector(":scope > summary").offsetHeight + chrome
90
90
  }
91
91
 
92
+ // A browser without ::details-content reports no duration: close at once instead of throwing.
92
93
  transitionDurations() {
93
94
  return getComputedStyle(this.element, "::details-content")
94
95
  .transitionDuration.split(",")
95
- .map((duration) => parseFloat(duration) * 1000)
96
+ .map((duration) => parseFloat(duration) * 1000 || 0)
96
97
  }
97
98
 
98
99
  // Opening near the bottom of a scroller grows content off-screen, so the
@@ -10,6 +10,12 @@ export default class extends Controller {
10
10
  this.unregisterDialog?.()
11
11
  }
12
12
 
13
+ // A stream that replaces an open dialog sends no close event, and the page would stay locked.
14
+ dialogTargetDisconnected() {
15
+ this.unregisterDialog?.()
16
+ this.unregisterDialog = null
17
+ }
18
+
13
19
  open(event) {
14
20
  event?.preventDefault()
15
21
  if (this.hasFrameTarget) {
@@ -222,7 +222,9 @@ export default class extends CatalogPicker {
222
222
  }
223
223
  if (this.hasToneMenuTarget) {
224
224
  this.toneMenuTarget.querySelectorAll("[data-tone-index]").forEach((button) => {
225
- markCurrent(button, Number(button.dataset.toneIndex) === this.tone)
225
+ const chosen = Number(button.dataset.toneIndex) === this.tone
226
+ markCurrent(button, chosen)
227
+ button.setAttribute("aria-checked", String(chosen))
226
228
  })
227
229
  }
228
230
  }
@@ -102,6 +102,8 @@ export default class extends Controller {
102
102
  this.input()
103
103
  }
104
104
 
105
+ // Chrome's last input event of a composition still reports isComposing, so the field also sends
106
+ // compositionend here.
105
107
  input(event) {
106
108
  if (event?.isComposing) return
107
109
  this.clearTarget.hidden = !this.inputTarget.value
@@ -1,5 +1,5 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
- import { navigate } from "lostcoords/ui/helpers/roving_focus"
2
+ import { navigate, rove } from "lostcoords/ui/helpers/roving_focus"
3
3
 
4
4
  // The ARIA tabs pattern. Arrow keys follow the tab list's aria-orientation, and
5
5
  // Home and End jump to the ends. With automatic activation, moving focus selects
@@ -21,14 +21,10 @@ export default class extends Controller {
21
21
  })
22
22
  if (!tab) return
23
23
 
24
- if (this.activationValue === "manual") this.focusOnly(tab)
24
+ if (this.activationValue === "manual") rove(this.tabTargets, tab)
25
25
  else this.show(tab)
26
26
  }
27
27
 
28
- focusOnly(tab) {
29
- for (const candidate of this.tabTargets) candidate.tabIndex = candidate === tab ? 0 : -1
30
- }
31
-
32
28
  show(tab) {
33
29
  for (const candidate of this.tabTargets) {
34
30
  const selected = candidate === tab
@@ -19,7 +19,7 @@ export default class extends Controller {
19
19
 
20
20
  this.element.toggleAttribute("data-open", true)
21
21
  this.release = liftToTopLayer(this.contentTarget, this.element)
22
- this.stopPageLeave = onPageLeave(() => this.close({ immediate: true }))
22
+ this.stopPageLeave = onPageLeave(() => this.leave())
23
23
  this.unregister = registerDismissable({
24
24
  type: "tooltip",
25
25
  element: this.element,
@@ -38,6 +38,13 @@ export default class extends Controller {
38
38
  dismiss() {
39
39
  this.element.dataset.dismissed = ""
40
40
  this.close({ immediate: true })
41
+ this.stopPageLeave = onPageLeave(() => this.leave())
42
+ }
43
+
44
+ // A cached page must not remember an Escape: the tooltip would stay hidden on the way back.
45
+ leave() {
46
+ delete this.element.dataset.dismissed
47
+ this.close({ immediate: true })
41
48
  }
42
49
 
43
50
  close({ immediate = false } = {}) {
@@ -174,7 +174,7 @@ export class CatalogPicker extends FloatingPanel {
174
174
  // Arrow Down leaves the search for the first option in view; Enter picks
175
175
  // the best match.
176
176
  onSearchKeydown(event) {
177
- if (event.isComposing) return
177
+ if (event.isComposing || event.keyCode === 229) return
178
178
 
179
179
  if (event.key === "ArrowDown") {
180
180
  const top = this.bodyTarget.getBoundingClientRect().top
@@ -387,6 +387,11 @@ export class CatalogPicker extends FloatingPanel {
387
387
  )
388
388
  catalog.template = template
389
389
  })
390
+ .catch(() => {})
391
+ // A failed load is forgotten, so the next open asks again.
392
+ .finally(() => {
393
+ if (!catalog.template) catalog.request = null
394
+ })
390
395
  return catalog.request
391
396
  }
392
397
 
@@ -49,6 +49,8 @@ export function closeTopDismissable(event) {
49
49
 
50
50
  function dismissOnEscape(event) {
51
51
  if (event.key !== "Escape" && event.key !== "Esc") return
52
+ // Escape that cancels an IME conversion belongs to the input method, as it does for a native dialog.
53
+ if (event.isComposing || event.keyCode === 229) return
52
54
  if (clearSearchField(event)) return
53
55
  if (!closeTopDismissable(event)) return
54
56
 
@@ -10,7 +10,7 @@
10
10
  <%= tag.form action: src, method: :get, role: "search", class: "flex shrink-0 items-center gap-heading", data: { action: "submit->lc-search#submit" } do %>
11
11
  <label class="<%= lc_glass_class(extra: "flex min-h-14 min-w-0 flex-1 cursor-text items-center gap-heading ps-5 pe-2 sm:min-h-16") %>" data-lc-search-target="bar">
12
12
  <%= lc_icon "magnifying-glass", options: { class: "size-6 shrink-0 text-muted-foreground", "aria-hidden": true, "data-lc-search-target": "glyph" } %>
13
- <input type="search" name="<%= param %>" class="lc-search-input min-w-0 flex-1 self-stretch border-0 bg-transparent text-base text-foreground outline-none placeholder:text-muted-foreground" aria-label="<%= label %>" placeholder="<%= placeholder %>" autocomplete="off" autocapitalize="off" spellcheck="false" enterkeyhint="search" data-lc-search-target="input" data-action="input->lc-search#input"<% if shortcut %> data-controller="lc-shortcut" data-lc-shortcut-keys-value="<%= shortcut %>"<% end %>>
13
+ <input type="search" name="<%= param %>" class="lc-search-input min-w-0 flex-1 self-stretch border-0 bg-transparent text-base text-foreground outline-none placeholder:text-muted-foreground" aria-label="<%= label %>" placeholder="<%= placeholder %>" autocomplete="off" autocapitalize="off" spellcheck="false" enterkeyhint="search" data-lc-search-target="input" data-action="input->lc-search#input compositionend->lc-search#input"<% if shortcut %> data-controller="lc-shortcut" data-lc-shortcut-keys-value="<%= shortcut %>"<% end %>>
14
14
  <%= lc_icon_button lc_t("lostcoords.ui.search.clear"), icon: "x-circle", size: :sm, shape: :circle, hidden: true, data: { lc_search_target: "clear", action: "lc-search#clear" } %>
15
15
  </label>
16
16
  <%= lc_button lc_t("lostcoords.ui.search.cancel"), variant: :ghost, size: :sm, class: "sm:hidden", data: { lc_search_target: "cancel", action: "lc-search#close" } %>
@@ -1,5 +1,5 @@
1
1
  module Lostcoords
2
2
  module Ui
3
- VERSION = "0.14.10"
3
+ VERSION = "0.14.11"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lostcoords-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.10
4
+ version: 0.14.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lost Coordinates