lostcoords-ui 0.14.10 → 0.14.12

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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +58 -5
  3. data/app/assets/tailwind/lostcoords/ui/emoji-picker.css +18 -80
  4. data/app/assets/tailwind/lostcoords/ui/hovercard.css +5 -5
  5. data/app/assets/tailwind/lostcoords/ui/popover.css +4 -4
  6. data/app/assets/tailwind/lostcoords/ui/squircle.css +9 -1
  7. data/app/helpers/lostcoords/ui/badge_helper.rb +3 -1
  8. data/app/helpers/lostcoords/ui/button_helper.rb +1 -1
  9. data/app/helpers/lostcoords/ui/card_helper.rb +1 -1
  10. data/app/helpers/lostcoords/ui/form_helper.rb +4 -3
  11. data/app/helpers/lostcoords/ui/list_group_helper.rb +1 -1
  12. data/app/helpers/lostcoords/ui/navigation_helper.rb +1 -1
  13. data/app/helpers/lostcoords/ui/search_helper.rb +1 -1
  14. data/app/helpers/lostcoords/ui/structures_helper.rb +1 -0
  15. data/app/javascript/lostcoords/ui/controllers/lc_char_counter_controller.js +5 -0
  16. data/app/javascript/lostcoords/ui/controllers/lc_collapsible_controller.js +2 -1
  17. data/app/javascript/lostcoords/ui/controllers/lc_dialog_controller.js +6 -0
  18. data/app/javascript/lostcoords/ui/controllers/lc_emoji_picker_controller.js +3 -12
  19. data/app/javascript/lostcoords/ui/controllers/lc_search_controller.js +2 -0
  20. data/app/javascript/lostcoords/ui/controllers/lc_tabs_controller.js +2 -6
  21. data/app/javascript/lostcoords/ui/controllers/lc_tooltip_controller.js +8 -1
  22. data/app/javascript/lostcoords/ui/helpers/catalog_picker.js +6 -1
  23. data/app/javascript/lostcoords/ui/helpers/dismiss_stack.js +2 -0
  24. data/app/views/lostcoords/ui/components/_emoji_picker.html.erb +1 -1
  25. data/app/views/lostcoords/ui/components/_lc_search.html.erb +1 -1
  26. data/lib/lostcoords/ui/version.rb +1 -1
  27. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84077c9a58c40198412c3d229e69015dabe6a80f5a25bd257e22fc18abf73020
4
- data.tar.gz: 41782f8795d5c8c4e9dd45796ceba268a91f8bc7a427987b8006ec147b749f6f
3
+ metadata.gz: dc041cd2b9ef1078c34335a00669cc6fdcdc22622e16a656a6ca20d8e1aaada6
4
+ data.tar.gz: cd4f1528f765fde97389ce9242e7c47b18b37c916d87156cb682f1205644449a
5
5
  SHA512:
6
- metadata.gz: 38e4ae910c25a3d000052713ec957b36c49b2f1a1f146f31f85e46974514f7c11595351bb07fdf7b874304b0ba48fc3a8b1782f015d19441024ed65fc4f584b1
7
- data.tar.gz: 3606c135d2aa929104c5072b29c37737b5ce80dab8b471c59da29a2de1431c8101c5ef36d3c06efa362ca44077180b03c78dad9ba69041b39c52f180de74bc22
6
+ metadata.gz: d00c1bbca1ca15a7cd38aa205efe5c2caae746cfa4b1e56794e0a0f6160cff618fde0fcc96cf181b0c0a0aa3f618c3acc741921a15c8fff318b38ca7050ab6a3
7
+ data.tar.gz: a0fc3feba6f2aecccf32f92d7e015f60bba5b01daa5ea5e5ef48a93efab0d48896cbc00f2810ad241daed534e03cfeb6baaeb601baca20dbb7d2179a14297d9b
data/README.md CHANGED
@@ -51,13 +51,13 @@ 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`,
60
- `emoji-picker`, `table`, `prose` and `shell` (`lc_app_header`, `lc_sidebar`, `lc_docs_shell` and `lc_dock`; the
59
+ `menu` (menus and popovers), `toast`, `search`, `tooltip`, `hovercard`, `collapsible`, `code-block`,
60
+ `emoji-picker` (its phone sheet also needs `dialog`), `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
 
63
63
  The gem's stylesheets write into the `components` and `modules` layers, so the host declares that layer order.
@@ -170,6 +170,59 @@ 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.12
174
+
175
+ Needs an edit only if you import component entries one by one: `emoji-picker` now also needs `dialog`,
176
+ which holds the phone sheet. Changed:
177
+
178
+ - **The emoji picker's phone sheet is the shared `lc-sheet`.** It had its own copy with tighter corners,
179
+ a darker backdrop and a faster slide; it now has the radius, scrim and timing of every other sheet.
180
+ - **`lc_list_field` rows are inset like the rows around them** from `sm` up (`px-inset`); they sat 4px
181
+ further out than `lc_list_row` and the section heading.
182
+ - **`lc_icon_button_class` defaults to `shape: :circle`**, as `lc_icon_button` does, so the compact
183
+ pager's arrows are round. Pass `shape: :square` to keep the old look.
184
+ - **The responsive nav's links and indicator are squircles from `sm` up**, like `layout: :row`. Being
185
+ pills on phones had switched the squircle off at every width.
186
+ - **Popovers, hovercards and the emoji popover take their timing from `--lc-motion-feedback`**; they
187
+ wrote the same 160ms as a literal.
188
+
189
+ Fixed:
190
+
191
+ - **An avatar in an `lc_avatar_stack` shows the focus ring.** The stack removed every avatar's outline,
192
+ including the ring of one rendered as a button.
193
+
194
+ ## Changes in 0.14.11
195
+
196
+ Nothing needs an edit. Changed:
197
+
198
+ - **A disabled `lc_input`, `lc_select`, `lc_textarea` or toggle pill looks disabled**: muted text and a
199
+ not-allowed cursor, as buttons and segmented items already had. A disabled select no longer fills on hover.
200
+ - **Emoji grid buttons show the focus ring.** They marked keyboard focus with the hover fill alone.
201
+ - **The emoji picker has a set height**, on desktop and as a phone sheet. It grew when its catalog arrived
202
+ after opening, and on desktop could jump to the other side of its trigger.
203
+ - **`lc_search` group titles use the eyebrow role**, so under `lang="ja"` they drop the mono face and
204
+ uppercase like every other eyebrow.
205
+
206
+ Fixed:
207
+
208
+ - **Input methods.** Escape that cancels a conversion no longer closes the dialog, menu or popover around
209
+ the field. `lc_search` shows results for text committed from an input method in Chrome, which sends no
210
+ input event after the composition ends. In Safari, the Enter that commits a conversion no longer picks
211
+ the first match in the emoji picker or any other catalog picker.
212
+ - **A catalog that failed to load is asked for again** on the next open; the failure was kept until a
213
+ full page load.
214
+ - **An `lc_dialog` replaced while open releases the page.** A stream that swapped the open dialog sent no
215
+ close event, so the page stayed scroll-locked.
216
+ - **A linked or interactive card eases its lift and fill on hover.** The transition named `transform`,
217
+ which the lift does not use, and replaced the card's own.
218
+ - **A button-mode `lc_toggle_group` renders its `value:` selected.** The choice appeared only once the
219
+ controller connected.
220
+ - **An `lc_fieldset` with an error turns its legend red**, as a field does its label.
221
+ - **Skin-tone options carry `aria-checked`**, so a screen reader announces the chosen one.
222
+ - **`lc_char_counter` follows a form reset**, and a tooltip dismissed with Escape shows again after
223
+ coming back to a cached page.
224
+ - **A collapsible closes in a browser without `::details-content`**, where reading its duration threw.
225
+
173
226
  ## Changes in 0.14.10
174
227
 
175
228
  Nothing needs an edit. Added:
@@ -1404,7 +1457,7 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
1404
1457
  - `lc_toggle_class(active: false, ghost: false, size: :md, extra: nil)` (BadgeHelper)
1405
1458
  - `lc_button_class(variant: :primary, tone: :default, size: :md, block: false, extra: nil)` (ButtonHelper)
1406
1459
  - `lc_select_trigger_class(size: :md, block: false, extra: nil)` (ButtonHelper)
1407
- - `lc_icon_button_class(shape: :square, size: :md, icon_size: size, variant: :ghost, tone: :default, extra: nil)` (ButtonHelper)
1460
+ - `lc_icon_button_class(shape: :circle, size: :md, icon_size: size, variant: :ghost, tone: :default, extra: nil)` (ButtonHelper)
1408
1461
  - `lc_card_class(interactive: false, padding: :md, extra: nil)` (CardHelper)
1409
1462
  - `lc_choice_label_class(card: false, extra: nil)` (ChoiceHelper)
1410
1463
  - `lc_checkbox_class(extra: nil)` (ChoiceHelper)
@@ -46,87 +46,16 @@
46
46
  display: inline-flex;
47
47
  }
48
48
 
49
- /* ==================================================================== */
50
-
51
- /* Mobile-first: the picker opens as a bottom half-sheet. */
52
-
53
- /* ==================================================================== */
54
-
55
- /* The sheet renders in the top layer (Popover API), so this ::backdrop
56
- dims everything beneath it — including the app nav. The allow-discrete
57
- transitions keep it in the top layer while it eases out, so it fades
58
- both ways instead of snapping away on close. */
59
- .lc-emoji-picker__popover::backdrop {
60
- background: var(--lc-scrim);
61
- opacity: 0;
62
- transition:
63
- opacity 220ms var(--lc-ease-out),
64
- display 220ms allow-discrete,
65
- overlay 220ms allow-discrete;
66
-
67
- @media (prefers-reduced-motion: reduce) { transition: none; }
68
- }
69
-
70
- /* Only the phone sheet dims the page; the desktop popover rides the top
71
- layer too (so nothing paints over it) but floats over an undimmed page. */
72
- @media (width < 40rem) {
73
- .lc-emoji-picker__popover:popover-open::backdrop {
74
- opacity: 1;
75
-
76
- @starting-style { opacity: 0; }
77
- }
78
- }
79
-
80
- /* Phones get a solid sheet; on desktop the host paints the popover as a
81
- floating surface (glass in wariwari), so the gem leaves it unpainted. */
82
- @media (width < 40rem) {
83
- .lc-emoji-picker__popover {
84
- border: 1px solid var(--lc-glass-edge, var(--border));
85
- border-block-end: 0;
86
- background: var(--background);
87
- box-shadow: 0 -12px 40px -12px color-mix(in oklab, var(--foreground) 45%, transparent);
88
- }
89
- }
90
-
49
+ /* On a phone the popover is an lc-sheet, which owns its place, edge, backdrop and slide. From sm
50
+ up it is an anchored popover (below), painted by the host. */
91
51
  .lc-emoji-picker__popover {
92
- position: fixed;
93
- inset: auto 0 0;
94
52
  margin: 0;
95
53
  z-index: var(--lc-z-overlay);
96
54
  display: none;
55
+ flex-direction: column;
97
56
  max-inline-size: none;
98
57
  color: var(--foreground);
99
- flex-direction: column;
100
- inline-size: 100%;
101
- max-block-size: min(72svh, 34rem);
102
- padding-block-end: max(env(safe-area-inset-bottom), 8px);
103
- border-start-start-radius: var(--radius-3xl, 1.5rem);
104
- border-start-end-radius: var(--radius-3xl, 1.5rem);
105
58
  overscroll-behavior: contain;
106
- transform: translateY(100%);
107
- transition:
108
- transform 260ms var(--lc-ease-out-expo),
109
- display 260ms allow-discrete,
110
- overlay 260ms allow-discrete;
111
-
112
- /* Top-layer (Popover API) drives display, so showPopover()/hidePopover()
113
- animate the slide in AND out via the allow-discrete transitions. */
114
- &:popover-open {
115
- display: flex;
116
- transform: translateY(0);
117
-
118
- @starting-style { transform: translateY(100%); }
119
- }
120
-
121
- @media (prefers-reduced-motion: reduce) { transition: none; }
122
- }
123
-
124
- /* Fallback for browsers without the Popover API: class-driven display. */
125
- @supports not selector(:popover-open) {
126
- .lc-emoji-picker__popover[data-open] {
127
- display: flex;
128
- transform: translateY(0);
129
- }
130
59
  }
131
60
 
132
61
  /* ---- Search row --------------------------------------------------- */
@@ -340,7 +269,6 @@
340
269
  &:focus-visible {
341
270
  background: var(--muted);
342
271
  transform: scale(1.12);
343
- outline: none;
344
272
  }
345
273
 
346
274
  &[aria-current="true"] { background: color-mix(in oklab, var(--primary) 12%, var(--background)); }
@@ -405,16 +333,16 @@
405
333
  inset-block: calc(100% + 8px) auto;
406
334
  inset-inline: 0 auto;
407
335
  inline-size: min(var(--lc-emoji-picker-popover-width, 22rem), calc(100vw - 32px));
408
- max-block-size: min(28rem, calc(100vh - 96px));
336
+ block-size: min(28rem, calc(100vh - 96px));
409
337
  padding-block-end: 0;
410
338
  border-radius: var(--radius-3xl, 1.5rem);
411
339
  transform: translateY(-4px) scale(0.98);
412
340
  opacity: 0;
413
341
  transition:
414
- opacity 160ms var(--lc-ease-out-expo),
415
- transform 160ms var(--lc-ease-out-expo),
416
- display 160ms allow-discrete,
417
- overlay 160ms allow-discrete;
342
+ opacity var(--lc-motion-feedback) var(--lc-ease-out-expo),
343
+ transform var(--lc-motion-feedback) var(--lc-ease-out-expo),
344
+ display var(--lc-motion-feedback) allow-discrete,
345
+ overlay var(--lc-motion-feedback) allow-discrete;
418
346
 
419
347
  &[data-open] {
420
348
  display: flex;
@@ -436,3 +364,13 @@
436
364
  }
437
365
  }
438
366
  }
367
+
368
+ @layer modules {
369
+ /* A set height, not the sheet's fit to content: the catalog arrives after the sheet opens, and
370
+ it would grow under the reader's finger. */
371
+ @media (width < 40rem) {
372
+ .lc-emoji-picker__popover.lc-sheet {
373
+ block-size: min(calc(var(--lc-sheet-floor, 100svh) * 0.72), 34rem);
374
+ }
375
+ }
376
+ }
@@ -22,11 +22,11 @@
22
22
 
23
23
  /* allow-discrete keeps a lifted card in the top layer while it fades out. */
24
24
  transition:
25
- opacity 160ms var(--lc-ease-out-expo),
26
- transform 160ms var(--lc-ease-out-expo),
27
- visibility 160ms,
28
- display 160ms allow-discrete,
29
- overlay 160ms allow-discrete;
25
+ opacity var(--lc-motion-feedback) var(--lc-ease-out-expo),
26
+ transform var(--lc-motion-feedback) var(--lc-ease-out-expo),
27
+ visibility var(--lc-motion-feedback),
28
+ display var(--lc-motion-feedback) allow-discrete,
29
+ overlay var(--lc-motion-feedback) allow-discrete;
30
30
  }
31
31
 
32
32
  .lc-hovercard[data-side="top"] > .lc-hovercard__content {
@@ -7,10 +7,10 @@
7
7
  transform: var(--lc-popover-from, translateY(--spacing(-1)) scale(0.98));
8
8
  pointer-events: none;
9
9
  transition:
10
- opacity 160ms var(--lc-ease-out-expo),
11
- transform 160ms var(--lc-ease-out-expo),
12
- display 160ms allow-discrete,
13
- overlay 160ms allow-discrete;
10
+ opacity var(--lc-motion-feedback) var(--lc-ease-out-expo),
11
+ transform var(--lc-motion-feedback) var(--lc-ease-out-expo),
12
+ display var(--lc-motion-feedback) allow-discrete,
13
+ overlay var(--lc-motion-feedback) allow-discrete;
14
14
 
15
15
  &:is([data-open], :popover-open) {
16
16
  opacity: 1;
@@ -1,12 +1,20 @@
1
1
  /* Squircle corners where the browser supports corner-shape. WebKit keeps plain
2
2
  rounded corners. A squircle reads tighter than a circular arc of the same
3
3
  radius, so its radius grows by a third. Library surfaces carry this class;
4
- host elements are never matched by their rounded-* classes. */
4
+ host elements are never matched by their rounded-* classes. A pill is never
5
+ a squircle; an element that is a pill only on phones (max-sm:) is one from sm up. */
5
6
  @utility lc-squircle {
6
7
  @supports (corner-shape: squircle) {
7
8
  &:not([class*="rounded-full"], [class*="rounded-pill"]) {
8
9
  --lc-corner-scale: 1.333;
9
10
  corner-shape: squircle;
10
11
  }
12
+
13
+ @media (width >= 40rem) {
14
+ &:is([class~="max-sm:rounded-pill"], [class~="max-sm:rounded-full"]):not([class~="rounded-pill"], [class~="rounded-full"]) {
15
+ --lc-corner-scale: 1.333;
16
+ corner-shape: squircle;
17
+ }
18
+ }
11
19
  }
12
20
  }
@@ -52,7 +52,7 @@ module Lostcoords::Ui
52
52
  # its avatars, so a context's own `[&_.lc-avatar]:` override still wins. The border cuts each
53
53
  # avatar out of the one beneath, so it takes the fill it sits on (--lc-avatar-cutout).
54
54
  AVATAR_STACK_BASE =
55
- "lc-avatar-stack relative inline-flex items-center min-w-0 [&_.lc-avatar]:outline-none " \
55
+ "lc-avatar-stack relative inline-flex items-center min-w-0 [&_.lc-avatar:not(:focus-visible)]:outline-none " \
56
56
  "[--lc-avatar-size:--spacing(8)] [--lc-avatar-border:--spacing(0.5)] [--lc-avatar-ring-gap:1] " \
57
57
  "[--lc-avatar-stack-overlap:--spacing(1.5)]"
58
58
 
@@ -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 " \
@@ -139,7 +139,7 @@ module Lostcoords::Ui
139
139
  end
140
140
 
141
141
  # The base is already a ghost button, so variant: :ghost adds nothing; tone: recolours any variant.
142
- def lc_icon_button_class(shape: :square, size: :md, icon_size: size, variant: :ghost, tone: :default, extra: nil)
142
+ def lc_icon_button_class(shape: :circle, size: :md, icon_size: size, variant: :ghost, tone: :default, extra: nil)
143
143
  shape = lc_option!(:shape, shape, ICON_BUTTON_SHAPES.keys)
144
144
  size = lc_option!(:size, size, ICON_BUTTON_SIZES.keys)
145
145
  icon_size = lc_option!(:icon_size, icon_size, ICON_BUTTON_ICON_SIZES.keys)
@@ -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)
@@ -25,7 +25,7 @@ module Lostcoords::Ui
25
25
  "hover:bg-accent has-checked:bg-primary-soft has-checked:font-semibold has-lc-disabled:cursor-not-allowed has-lc-pending:cursor-progress has-lc-disabled:opacity-45"
26
26
  LIST_ROW_CHOICE_CHECK = "ms-auto size-4 shrink-0 text-primary invisible group-has-checked/choice:visible"
27
27
  LIST_FIELD_ELEMENTS = %i[div fieldset span].freeze
28
- LIST_FIELD = "@container px-content py-2.5 transition-colors duration-(--lc-motion-quick) has-[[data-plain]:focus]:bg-accent has-[[data-plain]:focus-visible]:lc-focus-ring"
28
+ LIST_FIELD = "@container px-content py-2.5 sm:px-inset transition-colors duration-(--lc-motion-quick) has-[[data-plain]:focus]:bg-accent has-[[data-plain]:focus-visible]:lc-focus-ring"
29
29
  LIST_FIELD_GRID = "grid min-h-9 grid-cols-[1.25rem_minmax(0,1fr)] items-center gap-x-heading gap-y-related @md:grid-cols-[8rem_minmax(0,1fr)]"
30
30
  LIST_FIELD_LABEL =
31
31
  "flex items-center gap-related text-label font-semibold text-muted-foreground " \
@@ -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) {
@@ -3,7 +3,6 @@ import { registerDismissable } from "lostcoords/ui/helpers/dismiss_stack"
3
3
  import { settleFocus } from "lostcoords/ui/helpers/focus"
4
4
  import { menuItems, navigateMenu } from "lostcoords/ui/helpers/menu_keys"
5
5
  import { navigate } from "lostcoords/ui/helpers/roving_focus"
6
- import { prefersReducedMotion } from "lostcoords/ui/helpers/viewport"
7
6
 
8
7
  const TONE_MODIFIERS = ["", "\u{1F3FB}", "\u{1F3FC}", "\u{1F3FD}", "\u{1F3FE}", "\u{1F3FF}"]
9
8
  const TONE_STORAGE_KEY = "lostcoords_ui:lc-emoji-picker:tone"
@@ -222,7 +221,9 @@ export default class extends CatalogPicker {
222
221
  }
223
222
  if (this.hasToneMenuTarget) {
224
223
  this.toneMenuTarget.querySelectorAll("[data-tone-index]").forEach((button) => {
225
- markCurrent(button, Number(button.dataset.toneIndex) === this.tone)
224
+ const chosen = Number(button.dataset.toneIndex) === this.tone
225
+ markCurrent(button, chosen)
226
+ button.setAttribute("aria-checked", String(chosen))
226
227
  })
227
228
  }
228
229
  }
@@ -355,16 +356,6 @@ export default class extends CatalogPicker {
355
356
  return this.hasRecentTarget ? this.recentTarget : null
356
357
  }
357
358
 
358
- get sheetMotion() {
359
- const duration = prefersReducedMotion() ? 0 : 260
360
- return {
361
- duration,
362
- settle: duration && 280,
363
- transition: "transform 260ms var(--lc-ease-out-expo, ease-out)",
364
- offscreen: "translateY(100%)",
365
- }
366
- }
367
-
368
359
  get quickButtons() {
369
360
  return Array.from(this.element.querySelectorAll(":scope > button[data-emoji]"))
370
361
  }
@@ -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
 
@@ -40,7 +40,7 @@
40
40
  </button>
41
41
 
42
42
  <div
43
- class="lc-emoji-picker__popover <%= popover_class %>"
43
+ class="lc-emoji-picker__popover lc-sheet <%= popover_class %>"
44
44
  data-lc-emoji-picker-target="popover"
45
45
  data-controller="lc-sheet"
46
46
  data-action="click->lc-emoji-picker#select pointerover->lc-emoji-picker#preview focusin->lc-emoji-picker#preview lc-sheet:dismiss->lc-emoji-picker#close"
@@ -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.12"
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.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lost Coordinates