layered-ui-rails 0.22.0 → 0.24.0
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 +4 -4
- data/.claude/skills/layered-ui-rails/SKILL.md +11 -2
- data/.claude/skills/layered-ui-rails/references/CONTROLLERS.md +24 -0
- data/.claude/skills/layered-ui-rails/references/CSS.md +34 -0
- data/.claude/skills/layered-ui-rails/references/HELPERS.md +92 -4
- data/CHANGELOG.md +29 -0
- data/README.md +40 -1
- data/app/assets/tailwind/layered_ui/engine.css +265 -4
- data/app/controllers/concerns/layered/ui/combobox_options.rb +199 -0
- data/app/helpers/layered/ui/authentication_helper.rb +30 -0
- data/app/helpers/layered/ui/combobox_helper.rb +569 -0
- data/app/helpers/layered/ui/form_helper.rb +9 -0
- data/app/javascript/layered_ui/controllers/l_ui/combobox_controller.js +815 -0
- data/app/javascript/layered_ui/index.js +2 -0
- data/app/views/devise/confirmations/new.html.erb +2 -2
- data/app/views/devise/passwords/edit.html.erb +5 -5
- data/app/views/devise/passwords/new.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +86 -0
- data/app/views/devise/registrations/new.html.erb +7 -7
- data/app/views/devise/sessions/new.html.erb +3 -3
- data/app/views/devise/shared/_links.html.erb +9 -5
- data/app/views/devise/unlocks/new.html.erb +2 -2
- data/app/views/layered/ui/managed_resource/_field_input.html.erb +2 -3
- data/app/views/layouts/layered_ui/_authentication.html.erb +4 -4
- data/app/views/layouts/layered_ui/_navigation.html.erb +22 -14
- data/app/views/layouts/layered_ui/_user_name_and_email.html.erb +15 -0
- data/config/importmap.rb +1 -0
- data/lib/layered/ui/engine.rb +9 -0
- data/lib/layered/ui/version.rb +1 -1
- data/lib/layered/ui.rb +1 -0
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ffb58ab0d1712c81928bbf3685708f5571e98dd1af70484024219dc6a491f2cc
|
|
4
|
+
data.tar.gz: 495f951c875f7572f38b77e6739fcbd49856160a0d84e96cd76f701c97d1262d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f855f052b32a2b172a8bb390d1bd19680fccc568996a9b286c4edf9eec2665ad3e0c97b8ff686d760da9dd8f9306ef941cb1ed449f65b984ac01d139818230d
|
|
7
|
+
data.tar.gz: a0abb3efe8343044f8581ad5f1c476f3a822c7225daf3ec5638d4a61cb685d5db3886f7f884d461ab685a4b8ff67f68894fca25324665219051ebd439a6a428a
|
|
@@ -240,7 +240,7 @@ Override CSS custom properties after the engine import. Values are full CSS colo
|
|
|
240
240
|
}
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
-
Key tokens: `--accent`, `--accent-foreground`, `--background`, `--foreground`, `--foreground-muted`, `--border`, `--border-control`, `--surface`, `--surface-highlighted`, `--danger`, `--header-height`.
|
|
243
|
+
Key tokens: `--accent`, `--accent-foreground`, `--background`, `--foreground`, `--foreground-muted`, `--border`, `--border-control`, `--surface`, `--surface-highlighted`, `--danger`, `--header-height`, `--l-ui-navigation-width`.
|
|
244
244
|
|
|
245
245
|
## Asset overrides
|
|
246
246
|
|
|
@@ -250,9 +250,17 @@ Place files in `app/assets/images/layered_ui/` to replace engine defaults:
|
|
|
250
250
|
|
|
251
251
|
The panel toggle button uses an inline SVG that inherits `currentColor`. Recolor it by overriding the `--button-primary-icon` Tier 2 token, or replace the image by setting both `@l_ui_panel_icon_light_url` and `@l_ui_panel_icon_dark_url` (per-request).
|
|
252
252
|
|
|
253
|
+
## Ejecting a view
|
|
254
|
+
|
|
255
|
+
Any engine view can be replaced by copying it to the same path in the host application - `app/views/devise/registrations/edit.html.erb` overrides the Settings screen, `app/views/layouts/layered_ui/_navigation.html.erb` the sidebar, and so on. Application views resolve before engine views, so no configuration is needed.
|
|
256
|
+
|
|
257
|
+
Find the original to copy with `bundle info layered-ui-rails --path`. Unlike engine views, an ejected view lives in the host application, so it may use plain Tailwind utilities alongside the `l-ui-*` classes - the host's Tailwind build scans it.
|
|
258
|
+
|
|
259
|
+
Note that `bin/rails generate devise:views` copies Devise's own unstyled views into `app/views/devise/`, which overrides *every* styled view the engine provides, not just the one being changed. Eject the individual views instead.
|
|
260
|
+
|
|
253
261
|
## Optional integrations
|
|
254
262
|
|
|
255
|
-
- **Devise** - auto-detected. Provides styled auth views, header login/register buttons, sidebar user info
|
|
263
|
+
- **Devise** - auto-detected. Provides styled auth views (including an account settings screen at `registrations#edit`), header login/register buttons, and sidebar user info with a Settings/Logout menu. Setup: `bundle add devise`, run `devise:install` and `devise User` generators, add `devise_for :users` to routes. Configure `Layered::Ui.current_user_method` if not using `:current_user`, and `Layered::Ui.devise_scope` if the Devise mapping isn't `:user`. Helpers: `l_ui_devise_installed?`, `l_ui_user_signed_in?`.
|
|
256
264
|
- **Pagy** - auto-detected. Use `l_ui_pagy(@pagy)` for styled pagination.
|
|
257
265
|
- **Ransack** - auto-detected. Use `l_ui_search_form` and `l_ui_sort_link` for styled search and sortable tables.
|
|
258
266
|
|
|
@@ -261,6 +269,7 @@ The panel toggle button uses an inline SVG that inherits `currentColor`. Recolor
|
|
|
261
269
|
```ruby
|
|
262
270
|
# config/initializers/layered_ui.rb
|
|
263
271
|
Layered::Ui.current_user_method = :current_member # default: :current_user
|
|
272
|
+
Layered::Ui.devise_scope = :member # default: :user
|
|
264
273
|
```
|
|
265
274
|
|
|
266
275
|
## Common issues
|
|
@@ -132,6 +132,30 @@ Features:
|
|
|
132
132
|
- Flips to the opposite side if the preferred placement would overflow the viewport
|
|
133
133
|
- `data-l-ui--popover-open-value="true"` opens the popover on connect without a flash of unpositioned content
|
|
134
134
|
|
|
135
|
+
## Combobox (`l-ui--combobox`)
|
|
136
|
+
|
|
137
|
+
Drives the token select rendered by `l_ui_combobox`: type-ahead filtering, selections held as tokens with their own hidden inputs, optional creation of values outside the collection, optional reordering, and optional remote options.
|
|
138
|
+
|
|
139
|
+
**Targets:** `control`, `tokens`, `token`, `input`, `listbox`, `option`, `empty`, `notice`, `noticeText`, `busy`, `moreSpinner`, `template`, `optionTemplate`, `status`
|
|
140
|
+
**Values:** `multiple` (Boolean, default `true`), `create` (Boolean, default `false`), `reorder` (Boolean, default `false`), `disabled` (Boolean, default `false`), `name` (String - parameter existing values post under), `createName` (String - parameter created values post under), `url` (String - endpoint searched as the user types; empty means filter in the browser), `minChars` (Number, default `0` - characters needed before a remote search runs), `text` (Object - the wording for the messages built here, from the helper's `text:` option; `%{name}` placeholders are substituted at use, and a key the caller emptied is left unsaid)
|
|
141
|
+
**Actions:** `focusInput`, `open`, `close`, `blur`, `scrolled`, `filter`, `keydown`, `selectOption`, `removeToken`, `moveTokenEarlier`, `moveTokenLater`, `dragstart`, `dragover`, `drop`, `dragend`
|
|
142
|
+
|
|
143
|
+
Features:
|
|
144
|
+
- Focus never leaves the input while the list is browsed; the highlight follows `aria-activedescendant`
|
|
145
|
+
- Down/Up/Home/End move the highlight, Enter chooses, Escape closes then clears, Backspace on the empty input removes the last token
|
|
146
|
+
- With nothing highlighted, Down enters the list at the first option and Up at the last, matching the ARIA combobox pattern; the highlight wraps at either end
|
|
147
|
+
- Choosing an already-selected option removes it again (multi select); single select replaces the token and closes
|
|
148
|
+
- In create mode, a term matching no option is offered as `Add "term"` and posts under `createName`
|
|
149
|
+
- Reorder mode disables the dead-end move control on the first and last token and moves focus so it is never lost; a disabled combobox is left alone, so its controls stay disabled
|
|
150
|
+
- Dragging is a pointer enhancement only, advertised by a decorative grip handle - the move buttons are the accessible path, as WCAG 2.2 SC 2.5.7 requires
|
|
151
|
+
- Selections, filter counts, and moves are announced through a local `role="status"` region
|
|
152
|
+
- With `url` set, each keystroke schedules a debounced fetch of `url?term=...`; the previous request is aborted and an overtaken response is dropped, so the list always answers what is currently typed. Leaving the field abandons a search in flight, so nothing spins beside a closed listbox and nothing is announced after focus has moved on. Responses replace the options wholesale, cloned from the `optionTemplate`, and the browser does no filtering of its own
|
|
153
|
+
- Further pages are appended as the end of a remote list is reached - within `LOAD_MORE_MARGIN` of its foot (the `scrolled` action, bound to the listbox), or on Down/End at the last option, so the keyboard is not capped at the first page. Down loads instead of wrapping while pages remain, and highlights the first newly loaded option; option ids run on across pages so `aria-activedescendant` can never point at a reused id
|
|
154
|
+
- The `notice` row carries only durable messages: how far into the matches the list has got, a failed request, and the character threshold. Each appended page is announced through the status region
|
|
155
|
+
- A request in flight shows a spinner rather than a message - `busy` (trailing the input) while searching, `moreSpinner` (in the notice row) while a page loads - after `SPINNER_DELAY`, so a fast response never flashes one. `aria-busy` goes on the listbox immediately, since it costs nothing and says the same thing to a screen reader
|
|
156
|
+
|
|
157
|
+
Use the `l_ui_combobox` helper (see HELPERS.md) rather than writing the markup by hand.
|
|
158
|
+
|
|
135
159
|
## Panel (`l-ui--panel`)
|
|
136
160
|
|
|
137
161
|
Resizable side panel. Full-width overlay on mobile, docked sidebar on desktop.
|
|
@@ -289,6 +289,35 @@ Interactive tag - e.g. an email recipient or an active filter. A badge is a stat
|
|
|
289
289
|
|
|
290
290
|
A tag takes the same subtle corner radius as a badge by default; add `l-ui-tag--rounded` for a pill. Segments must be direct children in label-then-remove order; when a remove segment follows, the label segment automatically drops its right padding so the remove owns the gap and every part of the tag stays clickable. A tag never grows past its container; wrap label content in `l-ui-tag__label` so it truncates with an ellipsis instead of overflowing. Prefer the `l_ui_tag` helper (see HELPERS.md), which renders the label wrapper and wires an optional popover.
|
|
291
291
|
|
|
292
|
+
## Combobox
|
|
293
|
+
|
|
294
|
+
Token select: a text input with type-ahead filtering whose selections become tags. Built on the ARIA combobox pattern (`role="combobox"` input + `role="listbox"` popup).
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
.l-ui-combobox Wrapper (data-controller="l-ui--combobox"); position context for the listbox
|
|
298
|
+
.l-ui-combobox__control Field-styled wrapping flex row holding the tokens and the input; draws the focus ring via :focus-within
|
|
299
|
+
.l-ui-combobox__control--disabled Dimmed, non-interactive control
|
|
300
|
+
.l-ui-combobox__tokens <ul> of tokens inside the control (collapses when empty)
|
|
301
|
+
.l-ui-combobox__token A selection (<li>); combine with l-ui-tag, whose segments it reuses
|
|
302
|
+
.l-ui-combobox__token--draggable A token that can be dragged (reorder mode, not disabled); takes cursor-grab
|
|
303
|
+
.l-ui-combobox__token--dragging Applied to the token being dragged
|
|
304
|
+
.l-ui-combobox__grip Decorative drag handle at a draggable token's leading edge (aria-hidden)
|
|
305
|
+
.l-ui-combobox__move Move-earlier / move-later control inside a token (reorder mode)
|
|
306
|
+
.l-ui-combobox__input The combobox text input; borderless, grows to fill the control, and carries a token's min-height so the control doesn't grow as the first token lands
|
|
307
|
+
.l-ui-combobox__listbox Absolutely positioned option list (role="listbox"); toggled with the hidden attribute
|
|
308
|
+
.l-ui-combobox__option An option (role="option"); hover takes bg-surface
|
|
309
|
+
.l-ui-combobox__option--active The option pointed at by aria-activedescendant (highlight, not DOM focus); bg-surface-highlighted, so it stays legible under a stray pointer
|
|
310
|
+
.l-ui-combobox__option--create The "Add ..." option offered in create mode
|
|
311
|
+
.l-ui-combobox__option-check Accent-filled circle holding the tick, shown on options with aria-selected="true"; reserved space so options don't shift
|
|
312
|
+
.l-ui-combobox__option-check-icon The tick itself; sized well inside the circle and drawn with a stroke so its weight holds up at that size
|
|
313
|
+
.l-ui-combobox__empty "No matches" message
|
|
314
|
+
.l-ui-combobox__spinner Busy ring shown while a remote request is in flight; keeps its shape without the animation under prefers-reduced-motion
|
|
315
|
+
.l-ui-combobox__busy Wrapper holding the spinner at the control's trailing edge (hidden until a search is slow enough to report)
|
|
316
|
+
.l-ui-combobox__notice Presentational row for what the list has to say about itself - a remote search in flight, a failed one, or a truncated result set. Sticks to the foot of the scrolling list and is ruled off from the options above it; the listbox drops its bottom padding while the notice shows, so nothing scrolls through the gap
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
The listbox and filtered-out options are hidden with the `hidden` attribute, so `.l-ui-combobox [hidden] { display: none !important }` restores Preflight's rule (these components sit outside `@layer`, which would otherwise beat it). Prefer the `l_ui_combobox` helper (see HELPERS.md), which renders the whole structure with its ARIA wiring.
|
|
320
|
+
|
|
292
321
|
## Tabs
|
|
293
322
|
|
|
294
323
|
```
|
|
@@ -369,6 +398,9 @@ A tag takes the same subtle corner radius as a badge by default; add `l-ui-tag--
|
|
|
369
398
|
.l-ui-navigation__section-chevron Toggle chevron (rotates when closed)
|
|
370
399
|
.l-ui-navigation__section-items Section body (ul, hidden when closed)
|
|
371
400
|
.l-ui-navigation__user User info section
|
|
401
|
+
.l-ui-navigation__user-button Unpadded full-width account menu trigger (pair with .l-ui-button)
|
|
402
|
+
.l-ui-navigation__user-chevron Upward chevron inside the account menu trigger
|
|
403
|
+
.l-ui-navigation__user-popover Account menu popover sized to the sidebar's inner column
|
|
372
404
|
.l-ui-navigation__user-name User name text
|
|
373
405
|
.l-ui-navigation__user-email User email text
|
|
374
406
|
```
|
|
@@ -459,6 +491,7 @@ Always combine the base block with one size modifier (e.g. `class="l-ui-icon l-u
|
|
|
459
491
|
```
|
|
460
492
|
.l-ui-mt-0/2/3/4/6/8 Margin top (fixed scale)
|
|
461
493
|
.l-ui-mb-0 Margin bottom zero
|
|
494
|
+
.l-ui-mb-4 Margin bottom (1rem)
|
|
462
495
|
.l-ui-sr-only Visually hidden, screen reader only
|
|
463
496
|
.l-ui-skip-link Accessibility skip link
|
|
464
497
|
.l-ui-list Styled list
|
|
@@ -504,6 +537,7 @@ Tier 2 - Full palette (override individually as needed):
|
|
|
504
537
|
--error-text Error text
|
|
505
538
|
--header-height Header height (default 63px)
|
|
506
539
|
--l-ui-gutter Page/header horizontal + bottom padding (default 1rem)
|
|
540
|
+
--l-ui-navigation-width Sidebar navigation width (default 256px)
|
|
507
541
|
--l-ui-contained-width Max width of contained content - header + .l-ui-page__contained (default 80rem)
|
|
508
542
|
```
|
|
509
543
|
|
|
@@ -283,6 +283,7 @@ Field options:
|
|
|
283
283
|
l_ui_normalise_field(record, config) # Normalise a raw field config into canonical form
|
|
284
284
|
l_ui_field_error_id(record, attribute) # Error element ID for aria-describedby
|
|
285
285
|
l_ui_field_hint_id(record, attribute) # Hint element ID for aria-describedby
|
|
286
|
+
l_ui_field_describedby(record, attribute, hint: false) # Space-joined hint + error IDs for aria-describedby
|
|
286
287
|
```
|
|
287
288
|
|
|
288
289
|
## Modal
|
|
@@ -408,6 +409,87 @@ Text, button, and link segments wrap their content in `<span class="l-ui-tag__la
|
|
|
408
409
|
|
|
409
410
|
When a popover is declared, the tag container itself becomes the `l-ui--popover` controller root and placement target - the popover aligns with the whole tag rather than the label button inside it - and button segments are wired to open it via `popovertarget`. A tag without a popover renders no Stimulus wiring.
|
|
410
411
|
|
|
412
|
+
## Combobox
|
|
413
|
+
|
|
414
|
+
```ruby
|
|
415
|
+
l_ui_combobox(name, collection: nil, form: nil, selected: nil, multiple: true,
|
|
416
|
+
create: false, create_name: nil, reorder: false, url: nil,
|
|
417
|
+
min_chars: 0, text: {}, id: nil, label: nil, hint: nil, placeholder: nil,
|
|
418
|
+
required: false, disabled: false, container: {})
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Renders a token select (`class="l-ui-combobox"`): a text input with type-ahead filtering whose selections become removable tags, in the style of an email recipient field. Built on the ARIA combobox pattern - no third-party select library.
|
|
422
|
+
|
|
423
|
+
- `name` (String or Symbol) - the parameter, e.g. `"post[tag_ids]"`. A Symbol is resolved against `form:`
|
|
424
|
+
- `collection` (Array) - `["Label", value]` pairs, `{ label:, value: }` hashes, or plain strings. Required unless `url:` is given
|
|
425
|
+
- `form` (FormBuilder, optional) - derives parameter names from the builder for Symbol names
|
|
426
|
+
- `selected` (Array or value, optional) - selected values, or `["Label", value]` pairs / `{ label:, value: }` hashes where the label is not in `collection` (the only form a remote selection can take). A value with no label renders as a created token (requires `create:`)
|
|
427
|
+
- `multiple` (Boolean, default `true`) - multi select; `false` drops the `[]` suffix, replaces the token on choice, and closes the list
|
|
428
|
+
- `create` (Boolean, default `false`) - allow values outside the collection; requires `create_name:`
|
|
429
|
+
- `create_name` (String or Symbol) - parameter created values post under, keeping record IDs and free text unambiguous server-side
|
|
430
|
+
- `reorder` (Boolean, default `false`) - move controls plus mouse dragging (each token gains a decorative grip handle advertising the drag); parameters post in the displayed order
|
|
431
|
+
- `url` (String, optional) - endpoint searched as the user types; options come from it rather than from `collection:`
|
|
432
|
+
- `min_chars` (Integer, default `0`) - characters needed before a remote search runs; `0` searches as soon as the field is focused
|
|
433
|
+
- `text` (Hash, optional) - wording for every string the control shows, merged over `Layered::Ui::ComboboxHelper::COMBOBOX_TEXT`: `empty:` ("No matches"), `create:` ("Add “%{term}”"), `min_chars:` ("Type %{count} characters to search."), `progress:` ("Showing %{shown} of %{count} matches."), `error:`, `more_error:`. Placeholders use Rails' `%{name}` syntax; `progress: nil` drops the progress line; an unknown key raises
|
|
434
|
+
- `label`, `hint`, `placeholder`, `required`, `disabled`, `id`, `container` - as for a normal field
|
|
435
|
+
|
|
436
|
+
```erb
|
|
437
|
+
<%= form_with model: @post do |f| %>
|
|
438
|
+
<%= l_ui_combobox(:tag_ids, form: f,
|
|
439
|
+
label: "Tags",
|
|
440
|
+
collection: Tag.pluck(:name, :id),
|
|
441
|
+
selected: @post.tag_ids,
|
|
442
|
+
create: true,
|
|
443
|
+
create_name: :new_tag_names) %>
|
|
444
|
+
<% end %>
|
|
445
|
+
|
|
446
|
+
<%# post[tag_ids][] => ["", "7"] %>
|
|
447
|
+
<%# post[new_tag_names][] => ["urgent"] %>
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
Each selection carries its own hidden input, so the control submits with an ordinary form post, and a blank value is always posted first - clearing every token submits an empty collection instead of omitting the parameter and leaving the association untouched. Selections are announced through a local `role="status"` region, and the keyboard help is bound to the input with `aria-describedby`. Reordering exposes move buttons as well as dragging, since WCAG 2.2 SC 2.5.7 requires a single-pointer alternative to a drag.
|
|
451
|
+
|
|
452
|
+
### Remote options
|
|
453
|
+
|
|
454
|
+
With `url:`, options are fetched from that endpoint as the user types (debounced, with overtaken responses discarded) instead of being rendered up front and filtered in the browser. Matches load a page at a time, the next page appended as the end of the list is reached - by scrolling to its foot or by pressing Down on its last option, so the keyboard is not capped at the first page. A presentational note under the options (`class="l-ui-combobox__notice"`) says how far into the matches the list has got, or that they could not be loaded; a request in flight shows a spinner instead (trailing the field while searching, beside the note while a page loads), after a short delay so a quick answer never flashes one. Remote selections must be passed as `["Label", value]` pairs, since the browser has no collection to look a label up in.
|
|
455
|
+
|
|
456
|
+
```ruby
|
|
457
|
+
Layered::Ui::ComboboxOptions # Controller concern building the JSON the endpoint answers with
|
|
458
|
+
|
|
459
|
+
l_ui_combobox_options(scope, label:, value: :id, search: nil, predicate: :cont,
|
|
460
|
+
combinator: :or, term: nil, page: nil, limit: 20)
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
- `scope` (Relation or model class) - what the user is allowed to see; the endpoint stays an ordinary action in the host app, authorised as any index is
|
|
464
|
+
- `label` (Symbol or Proc) - attribute, or callable taking the record, used for the option's label
|
|
465
|
+
- `value` (Symbol or Proc, default `:id`) - attribute, or callable, used for the option's value
|
|
466
|
+
- `search` (Array, defaults to `label`) - attributes the term is matched against; required when `label:` is a callable, since a computed label gives the database nothing to search on. An attribute neither backend can search raises rather than quietly matching everything
|
|
467
|
+
- `predicate` (Symbol, default `:cont`) - Ransack predicate for the match; `:i_cont` ignores case. Without Ransack only `:cont` and `:i_cont` can be built, and any other raises rather than quietly matching on something else
|
|
468
|
+
- `combinator` (Symbol, default `:or`) - how the search attributes combine, `:or` or `:and`; honoured on both paths, and anything else raises
|
|
469
|
+
- `term`, `page` - default to `params[:term]` and `params[:page]`
|
|
470
|
+
- `limit` (Integer, default 20) - options per page
|
|
471
|
+
|
|
472
|
+
Ransack builds the predicate when it is available (so association attributes work) and Pagy takes the page; there is a plain `LIKE` plus `limit`/`offset` fallback, so neither gem is required. An unordered scope is ordered by the label so pages do not overlap.
|
|
473
|
+
|
|
474
|
+
```erb
|
|
475
|
+
<%= l_ui_combobox(:author_id, form: f, multiple: false,
|
|
476
|
+
url: options_users_path, min_chars: 2,
|
|
477
|
+
selected: [[@post.author.name, @post.author_id]]) %>
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
```ruby
|
|
481
|
+
class UsersController < ApplicationController
|
|
482
|
+
include Layered::Ui::ComboboxOptions
|
|
483
|
+
|
|
484
|
+
def options
|
|
485
|
+
render json: l_ui_combobox_options(policy_scope(User), label: :name, search: [:name, :email])
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
# GET /users/options?term=ali&page=1
|
|
490
|
+
# { "options": [{ "label": "Alice Johnson", "value": "2" }], "page": 1, "pages": 1, "count": 1 }
|
|
491
|
+
```
|
|
492
|
+
|
|
411
493
|
## Header
|
|
412
494
|
|
|
413
495
|
```ruby
|
|
@@ -430,16 +512,22 @@ Use these when overriding the header actions group with `:l_ui_header_actions` t
|
|
|
430
512
|
## Authentication
|
|
431
513
|
|
|
432
514
|
```ruby
|
|
433
|
-
l_ui_user_signed_in?
|
|
434
|
-
l_ui_current_user
|
|
435
|
-
l_ui_devise_installed?
|
|
515
|
+
l_ui_user_signed_in? # Returns true if current user is present
|
|
516
|
+
l_ui_current_user # Returns the current user object
|
|
517
|
+
l_ui_devise_installed? # Returns true if Devise is loaded
|
|
518
|
+
l_ui_settings_screen? # Returns true on the Settings screen (Devise registrations#edit)
|
|
519
|
+
l_ui_new_registration_path # Devise registration path for the configured scope, or nil
|
|
520
|
+
l_ui_edit_registration_path # Devise account settings path for the configured scope, or nil
|
|
521
|
+
l_ui_new_session_path # Devise sign-in path for the configured scope, or nil
|
|
522
|
+
l_ui_destroy_session_path # Devise sign-out path for the configured scope, or nil
|
|
436
523
|
```
|
|
437
524
|
|
|
438
|
-
Configure the current user method:
|
|
525
|
+
Configure the current user method, and the Devise scope used to build the login/register/settings/logout paths (`new_registration_path`, `edit_registration_path`, `new_session_path`, `destroy_session_path`):
|
|
439
526
|
|
|
440
527
|
```ruby
|
|
441
528
|
# config/initializers/layered_ui.rb
|
|
442
529
|
Layered::Ui.current_user_method = :current_member
|
|
530
|
+
Layered::Ui.devise_scope = :member
|
|
443
531
|
```
|
|
444
532
|
|
|
445
533
|
## Shared partials
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. This project follows [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [0.24.0] - 2026-08-22
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Devise account settings: Devise's `registrations#edit` is styled as a Settings screen at `/users/edit`, with the account details under an "Account" tab. A signed-in user can change their email (and their name, if the model has one), set a new password, or cancel their account - all of it confirmed with the current password, as Devise expects. If your user model has a `name` attribute, permit it for `:account_update` as well as `:sign_up`. Link to the screen with `l_ui_edit_registration_path`, and use `l_ui_settings_screen?` to keep application chrome that a layout otherwise strips from Devise views.
|
|
10
|
+
- Sidebar account menu: the signed-in user's name and email in the sidebar are now a menu button opening a popover holding Settings and Logout, replacing the standalone logout button. The menu is sized to the sidebar's inner column so it lines up with the name and email, and only the entries whose Devise routes exist are rendered.
|
|
11
|
+
- Ejecting a view: any engine view can be replaced by copying it to the matching path in your application - `app/views/devise/registrations/edit.html.erb` takes over the Settings screen, `app/views/layouts/layered_ui/_navigation.html.erb` the sidebar - with no configuration. The engine's views are still prepended so they beat Devise's own, but your `app/views` is prepended back on top, restoring the precedence Rails gives you by default. Note that `bin/rails generate devise:views` generates *every* Devise view, so it replaces the whole styled set rather than the one you meant to change. See `UPGRADING.md`.
|
|
12
|
+
- `--l-ui-navigation-width`: the sidebar navigation width (default 256px), previously hard-coded, now overridable alongside the other layout tokens.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Devise form fields are scoped to the mapping rather than the model, so an app whose mapping name differs from its model (`devise_for :members, class_name: "User"`) submits parameters under the name Devise looks for. Previously the fields were named after the model, and nothing the user typed reached the controller.
|
|
17
|
+
- Field hints on the Devise views carry an id and are referenced by their input's `aria-describedby` (assembled by the new `l_ui_field_describedby` helper), so a screen reader announces the password length requirement along with the field instead of leaving it unlinked.
|
|
18
|
+
- The "Need assistance?" heading on the Devise views is rendered only when at least one of the links beneath it is. Previously it appeared whenever the matching Devise modules were enabled, so a page whose only link was suppressed showed a heading over nothing.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Logout has moved out of the sidebar into the account menu. A host that targeted the sidebar's `l-ui-button--outline-danger` logout button, in CSS or in a system test, will need to look inside `l-ui-navigation__user-popover` instead.
|
|
23
|
+
|
|
24
|
+
## [0.23.0] - 2026-08-22
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Combobox: a token select (`l-ui-combobox`) - a text input with type-ahead filtering whose selections become removable tags, in the style of an email recipient field. Built on the ARIA combobox pattern (a `role="combobox"` input owning a `role="listbox"` popup, with the highlight following `aria-activedescendant` so focus stays in the input), with no third-party select library. The `l_ui_combobox` helper renders the whole control and its ARIA wiring; the new `l-ui--combobox` Stimulus controller drives it. Selections carry their own hidden inputs, so it submits with an ordinary form post.
|
|
29
|
+
- Combobox options: `multiple: false` for a one-of-many control; `create:` (with `create_name:`) to add a term that matches no option, posting new values under their own parameter so the server never has to guess whether a value is a record's ID or free text; `reorder:` for move controls and mouse dragging, the buttons being the accessible path WCAG 2.2 SC 2.5.7 requires; and `text:` to reword or translate every string the control shows, using Rails' own `%{name}` placeholders.
|
|
30
|
+
- Combobox remote options: pass `url:` and the options are fetched from that endpoint as the user types, for collections too large to send with the page. Requests are debounced and an overtaken response is discarded, `min_chars:` sets how much has to be typed first, and matches load a page at a time - reaching the end of the list appends the next page, by scrolling to its foot or by pressing Down on its last option, so the keyboard is not capped at the first page. A note under the options says how far into the matches the list has got; a request in flight shows a spinner after a short delay, so a quick answer never flashes one.
|
|
31
|
+
- `Layered::Ui::ComboboxOptions`: a controller concern building the JSON a remote combobox expects, so the endpoint is a couple of lines. `l_ui_combobox_options(scope, label:, search:)` reads `term` and `page` from the query string and answers with `{ options: [{ label:, value: }], page:, pages:, count: }`, searching with Ransack and paging with Pagy when they are available and falling back to a plain `LIKE` with `limit`/`offset` when they are not. Endpoints stay ordinary actions in the host app, scoped and authorised as any index is.
|
|
32
|
+
- `Layered::Ui.devise_scope`: the Devise mapping the header and sidebar link to, so an app that scopes authentication to something other than `:user` (`devise_for :members`) gets the right registration, session and logout paths. Defaults to `:user`.
|
|
33
|
+
|
|
5
34
|
## [0.22.0] - 2026-07-10
|
|
6
35
|
|
|
7
36
|
### Added
|
data/README.md
CHANGED
|
@@ -31,12 +31,33 @@ An open source, Rails 8+ engine that provides WCAG 2.2 AA compliant design token
|
|
|
31
31
|
</tr>
|
|
32
32
|
</table>
|
|
33
33
|
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
The fastest way to get going is [layered-foundation-rails](https://github.com/layered-ai-public/layered-foundation-rails) - an accessible Rails starter app with `layered-ui-rails` pre-installed and configured. It also includes additional skills and scripts to get you on your way.
|
|
37
|
+
|
|
38
|
+
Clone the complete starter app:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
git clone https://github.com/layered-ai-public/layered-foundation-rails.git myapp
|
|
42
|
+
cd myapp
|
|
43
|
+
bin/rails layered:foundation:setup
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or apply it as a Rails template:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
rails new myapp --css tailwind \
|
|
50
|
+
-m https://raw.githubusercontent.com/layered-ai-public/layered-foundation-rails/main/template.rb
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Adding `layered-ui-rails` to an existing app? See [Installation](#installation).
|
|
54
|
+
|
|
34
55
|
## Features
|
|
35
56
|
|
|
36
57
|
- **Dark/light theme** - system preference detection with localStorage persistence and manual toggle
|
|
37
58
|
- **Responsive layout** - header, sidebar navigation, main content area, and optional resizable panel
|
|
38
59
|
- **WCAG 2.2 AA compliant** - skip links, focus indicators, ARIA attributes, and 4.5:1 contrast ratios
|
|
39
|
-
- **Components** - buttons, forms, surfaces, tables, tabs, notices, badges, tags, conversations, modals, popovers, and pagination
|
|
60
|
+
- **Components** - buttons, forms, comboboxes, surfaces, tables, tabs, notices, badges, tags, conversations, modals, popovers, and pagination
|
|
40
61
|
- **Optional integrations** - Devise authentication and Pagy pagination with styled views
|
|
41
62
|
- **Customisable branding** - Override the default logos and icons and colors
|
|
42
63
|
- **Google Lighthouse** - `layered-ui-rails` scores a [perfect 100](https://github.com/layered-ai-public/layered-ui-rails/raw/refs/heads/main/test/dummy/app/assets/images/lighthouse.webp) across all four Google Lighthouse categories - performance, accessibility, best practices, and SEO
|
|
@@ -180,6 +201,24 @@ For per-request icons, set instance variables - the engine renders `<link>` and
|
|
|
180
201
|
|
|
181
202
|
> **Security:** Rails HTML-escapes URL values, so XSS via attribute injection is mitigated. However, if values are tenant-controlled, validate that they are legitimate URLs - reject `javascript:` schemes and ensure values point to expected origins.
|
|
182
203
|
|
|
204
|
+
## Authentication
|
|
205
|
+
|
|
206
|
+
The engine reads the signed-in user through `l_ui_current_user`, which delegates to your app's `current_user` helper by default. If your app uses a different helper (e.g. a Devise `Member` model, or Rails' built-in authentication generator with a custom name), configure it in an initializer:
|
|
207
|
+
|
|
208
|
+
```ruby
|
|
209
|
+
# config/initializers/layered_ui.rb
|
|
210
|
+
Layered::Ui.current_user_method = :current_member
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
If your Devise mapping isn't `:user` (e.g. `devise_for :members`), also set the scope so the header and sidebar link to the right registration, session, and logout paths:
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
# config/initializers/layered_ui.rb
|
|
217
|
+
Layered::Ui.devise_scope = :member
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Apps without authentication need no configuration - the user section of the navigation simply doesn't render. The sidebar shows the user's `name` and `email` when the model responds to those methods. Only one method is supported, so apps with multiple Devise scopes should pick the one to display.
|
|
221
|
+
|
|
183
222
|
## Documentation
|
|
184
223
|
|
|
185
224
|
An online version of the documentation is available at **[layered-ui-rails.layered.ai](https://layered-ui-rails.layered.ai)**.
|