@lofid/web 0.0.0-stage → 1.1.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.
- package/README.md +104 -2
- package/custom-elements.json +12890 -0
- package/dist/index.d.ts +3192 -0
- package/dist/index.js +20807 -0
- package/dist/index.js.map +1 -0
- package/dist/styles/ag-grid.css +145 -0
- package/dist/styles/motion.css +32 -0
- package/dist/styles/motion.tokens.json +38 -0
- package/dist/styles/typography.css +41 -0
- package/dist/styles/typography.json +858 -0
- package/dist/styles/vars.css +1225 -0
- package/package.json +46 -4
- package/readmes/lof-accordion/README.md +140 -0
- package/readmes/lof-alert/README.md +142 -0
- package/readmes/lof-autocomplete/README.md +209 -0
- package/readmes/lof-avatar/README.md +228 -0
- package/readmes/lof-badge/README.md +102 -0
- package/readmes/lof-breadcrumb/README.md +97 -0
- package/readmes/lof-button/README.md +189 -0
- package/readmes/lof-calendar/README.md +111 -0
- package/readmes/lof-card/README.md +105 -0
- package/readmes/lof-cardmedia/README.md +100 -0
- package/readmes/lof-carousel/README.md +187 -0
- package/readmes/lof-checkbox/README.md +159 -0
- package/readmes/lof-chip/README.md +153 -0
- package/readmes/lof-container/README.md +107 -0
- package/readmes/lof-date-picker/README.md +221 -0
- package/readmes/lof-divider/README.md +88 -0
- package/readmes/lof-drawer/README.md +188 -0
- package/readmes/lof-empty-state/README.md +78 -0
- package/readmes/lof-image-input/README.md +75 -0
- package/readmes/lof-kbd/README.md +188 -0
- package/readmes/lof-layout/README.md +122 -0
- package/readmes/lof-link/README.md +67 -0
- package/readmes/lof-menu/README.md +187 -0
- package/readmes/lof-menubar/README.md +218 -0
- package/readmes/lof-nav/README.md +90 -0
- package/readmes/lof-otp/README.md +167 -0
- package/readmes/lof-page-header/README.md +71 -0
- package/readmes/lof-pagination/README.md +141 -0
- package/readmes/lof-popover/README.md +220 -0
- package/readmes/lof-progress/README.md +88 -0
- package/readmes/lof-radio/README.md +142 -0
- package/readmes/lof-range-picker/README.md +194 -0
- package/readmes/lof-rating/README.md +90 -0
- package/readmes/lof-resizable/README.md +220 -0
- package/readmes/lof-segmented-button/README.md +158 -0
- package/readmes/lof-select/README.md +193 -0
- package/readmes/lof-sheet/README.md +170 -0
- package/readmes/lof-signature-pad/README.md +161 -0
- package/readmes/lof-skeleton/README.md +104 -0
- package/readmes/lof-slider/README.md +140 -0
- package/readmes/lof-snackbar/README.md +170 -0
- package/readmes/lof-split-button/README.md +129 -0
- package/readmes/lof-stat/README.md +73 -0
- package/readmes/lof-stepper/README.md +171 -0
- package/readmes/lof-switch/README.md +122 -0
- package/readmes/lof-tab/README.md +188 -0
- package/readmes/lof-table/README.md +114 -0
- package/readmes/lof-textfield/README.md +206 -0
- package/readmes/lof-time-picker/README.md +188 -0
- package/readmes/lof-toast/README.md +174 -0
- package/readmes/lof-tooltip/README.md +120 -0
- package/readmes/lof-tree/README.md +157 -0
- package/readmes/lof-upload/README.md +223 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# lof-menubar
|
|
2
|
+
|
|
3
|
+
`<lof-menubar>` is a horizontal application menubar (`role="menubar"`) in the style of a desktop app's File / Edit / View strip. Each child `<lof-menubar-menu label="…">` becomes a trigger button, and that menu's light-DOM children — `data-item` buttons, `data-separator` rules, `data-submenu` groups, `data-checkbox` labels and `data-radio-group` blocks — are read by the menubar and rendered into a fixed-position dropdown panel with full arrow-key navigation, optional bound keyboard shortcuts and `lof-menubar-select` / `lof-menubar-change` events. Use it for dense, command-style navigation in tools and admin surfaces. For one dropdown hanging off a single button use `lof-menu`; for site navigation with links use the Navbar recipe (`/docs/recipes/navbar`).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<lof-menubar>
|
|
9
|
+
<lof-menubar-menu label="File">
|
|
10
|
+
<button data-item data-shortcut="Ctrl+N">New Tab</button>
|
|
11
|
+
<button data-item data-shortcut="Ctrl+Shift+N">New Window</button>
|
|
12
|
+
<div data-separator></div>
|
|
13
|
+
<button data-item disabled>Close</button>
|
|
14
|
+
</lof-menubar-menu>
|
|
15
|
+
|
|
16
|
+
<lof-menubar-menu label="Edit">
|
|
17
|
+
<button data-item data-shortcut="Ctrl+Z">Undo</button>
|
|
18
|
+
<button data-item data-shortcut="Ctrl+Y">Redo</button>
|
|
19
|
+
<div data-separator></div>
|
|
20
|
+
<button data-item data-shortcut="Ctrl+X">Cut</button>
|
|
21
|
+
<button data-item data-shortcut="Ctrl+C">Copy</button>
|
|
22
|
+
<button data-item data-shortcut="Ctrl+V">Paste</button>
|
|
23
|
+
</lof-menubar-menu>
|
|
24
|
+
</lof-menubar>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Width mode and disabled menus
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<!-- type="fit" (default) hugs its triggers; type="fixed" spans its container -->
|
|
31
|
+
<lof-menubar type="fixed">
|
|
32
|
+
<lof-menubar-menu label="File">
|
|
33
|
+
<button data-item>New Tab</button>
|
|
34
|
+
</lof-menubar-menu>
|
|
35
|
+
<lof-menubar-menu label="Edit">
|
|
36
|
+
<button data-item>Undo</button>
|
|
37
|
+
</lof-menubar-menu>
|
|
38
|
+
<!-- a disabled menu keeps its trigger visible and focusable but never opens -->
|
|
39
|
+
<lof-menubar-menu label="View" disabled>
|
|
40
|
+
<button data-item>Zoom In</button>
|
|
41
|
+
</lof-menubar-menu>
|
|
42
|
+
</lof-menubar>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Submenus, checkbox items and radio groups
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<lof-menubar>
|
|
49
|
+
<lof-menubar-menu label="File">
|
|
50
|
+
<button data-item>New Tab</button>
|
|
51
|
+
<div data-separator></div>
|
|
52
|
+
<div data-submenu label="Share">
|
|
53
|
+
<button data-item value="email">Email link</button>
|
|
54
|
+
<button data-item value="messages">Messages</button>
|
|
55
|
+
<button data-item value="notes">Notes</button>
|
|
56
|
+
</div>
|
|
57
|
+
</lof-menubar-menu>
|
|
58
|
+
|
|
59
|
+
<lof-menubar-menu label="View">
|
|
60
|
+
<label data-checkbox>
|
|
61
|
+
<input type="checkbox" />
|
|
62
|
+
Always Show Bookmarks Bar
|
|
63
|
+
</label>
|
|
64
|
+
<label data-checkbox>
|
|
65
|
+
<input type="checkbox" checked />
|
|
66
|
+
Always Show Full URLs
|
|
67
|
+
</label>
|
|
68
|
+
<div data-separator></div>
|
|
69
|
+
<div data-radio-group name="profile" value="andy">
|
|
70
|
+
<button data-radio value="andy">Andy</button>
|
|
71
|
+
<button data-radio value="benoit">Benoit</button>
|
|
72
|
+
<button data-radio value="luis">Luis</button>
|
|
73
|
+
</div>
|
|
74
|
+
</lof-menubar-menu>
|
|
75
|
+
</lof-menubar>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Bound shortcuts and events
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<lof-menubar id="app-menubar" bind-shortcuts>
|
|
82
|
+
<lof-menubar-menu label="Edit">
|
|
83
|
+
<button data-item value="undo" data-shortcut="Mod+Z">Undo</button>
|
|
84
|
+
<button data-item value="redo" data-shortcut="Mod+Shift+Z">Redo</button>
|
|
85
|
+
</lof-menubar-menu>
|
|
86
|
+
</lof-menubar>
|
|
87
|
+
|
|
88
|
+
<script>
|
|
89
|
+
const bar = document.getElementById('app-menubar');
|
|
90
|
+
// { label: "Undo", value: "undo", shortcut: "Mod+Z" }
|
|
91
|
+
bar.addEventListener('lof-menubar-select', (e) => console.log('select', e.detail));
|
|
92
|
+
// { type: "checkbox", label, checked } | { type: "radio", name, value }
|
|
93
|
+
bar.addEventListener('lof-menubar-change', (e) => console.log('change', e.detail));
|
|
94
|
+
</script>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Authoring items
|
|
98
|
+
|
|
99
|
+
Items are plain HTML placed inside a `<lof-menubar-menu>`; the menubar recognises them by data attribute and renders its own copy in the panel.
|
|
100
|
+
|
|
101
|
+
| Attribute | Put it on | What it becomes |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| `data-item` | `<button>` | A `role="menuitem"` row. Its text content is the label; `value` (optional) and `data-shortcut` are echoed in `lof-menubar-select`. A native `disabled` attribute renders the row `aria-disabled` and skips it for clicks and bound shortcuts. |
|
|
104
|
+
| `data-shortcut` | a `data-item` button | Shortcut text shown right-aligned in the row, exactly as written. With `bind-shortcuts` it is also matched against keydowns: `+`-joined tokens, case-insensitive, `Mod` = Cmd on Apple / Ctrl elsewhere, plus `Ctrl`, `Alt`, `Shift`, `Meta`. |
|
|
105
|
+
| `data-separator` | `<div>` | A `role="separator"` rule. |
|
|
106
|
+
| `data-submenu` + `label` | `<div>` wrapping `data-item` buttons | A submenu trigger row (`aria-haspopup="menu"`) that opens a nested panel to the right on hover, click, Enter or ArrowRight. |
|
|
107
|
+
| `data-checkbox` | `<label>` containing `<input type="checkbox">` | A `lof-checkbox` row. The label text is the element's own text nodes (or a `label` attribute); state lives on the wrapped `<input>`. |
|
|
108
|
+
| `data-radio-group` + `name` + `value` | `<div>` wrapping `data-radio` buttons | A `lof-radio` group. `value` on the wrapper is the current selection and is rewritten on change; the chosen `data-radio` also gets `data-checked="true"`. |
|
|
109
|
+
| `data-radio` + `value` | `<button>` inside a `data-radio-group` | One option; text content is its label. |
|
|
110
|
+
|
|
111
|
+
<!-- readme-gen:start -->
|
|
112
|
+
|
|
113
|
+
<!-- Generated from lof-menubar.ts, lof-menubar-menu.ts — do not edit; run readme-generate.mjs -->
|
|
114
|
+
|
|
115
|
+
## Elements
|
|
116
|
+
|
|
117
|
+
| Element | Class | Source |
|
|
118
|
+
| --- | --- | --- |
|
|
119
|
+
| `<lof-menubar>` | `LofMenubar` | `lof-menubar.ts` |
|
|
120
|
+
| `<lof-menubar-menu>` | `LofMenubarMenu` | `lof-menubar-menu.ts` |
|
|
121
|
+
|
|
122
|
+
## API
|
|
123
|
+
|
|
124
|
+
### `<lof-menubar>`
|
|
125
|
+
|
|
126
|
+
#### Attributes / Properties
|
|
127
|
+
|
|
128
|
+
| Property | Attribute | Type | Default | Description |
|
|
129
|
+
| --- | --- | --- | --- | --- |
|
|
130
|
+
| `bindShortcuts` | `bind-shortcuts` | `boolean` | `false` | Opt-in: actually bind the keys declared via `data-shortcut` on items (e.g. `data-shortcut="Ctrl+Z"`) instead of only displaying them; a "Mod" token means Cmd on Apple platforms and Ctrl elsewhere, and keystrokes that originate in inputs, textareas or contenteditable regions are ignored. |
|
|
131
|
+
| `type` | `type` | `"fixed" \| "fit"` | `"fit"` | Width mode (Figma "Menu Bar" Type, 8699:4): `fit` sizes the bar to its triggers, `fixed` stretches it across its container (override the stretched width with `--lof-menubar-width`). The default stays `fit`, which is how the bar has always rendered. Reflected. |
|
|
132
|
+
|
|
133
|
+
### Events
|
|
134
|
+
|
|
135
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
136
|
+
| --- | --- | --- | --- |
|
|
137
|
+
| `lof-menubar-change` | `detail` | bubbles / composed | Fired when a `data-checkbox` item is toggled or a `data-radio` option is picked. Detail: `{ type: "checkbox", label, checked }` or `{ type: "radio", name, value }`. |
|
|
138
|
+
| `lof-menubar-select` | `{ label: item.textContent?.trim() ?? "", value: item.getAttribute("value") ?? undefined, shortcut: item.getAttribute("data-shortcut") ?? undefined, }` | bubbles / composed | Fired when a regular `data-item` (in a panel or a submenu) is activated by click, Enter/Space or a bound shortcut. Detail: `{ label: string, value?: string, shortcut?: string }` taken from the item's text, `value` and `data-shortcut` attributes. |
|
|
139
|
+
|
|
140
|
+
### Slots
|
|
141
|
+
|
|
142
|
+
| Slot | Description |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| — | This element has no slots. |
|
|
145
|
+
|
|
146
|
+
### CSS Parts
|
|
147
|
+
|
|
148
|
+
| Part | Description |
|
|
149
|
+
| --- | --- |
|
|
150
|
+
| — | None exposed. |
|
|
151
|
+
|
|
152
|
+
### `<lof-menubar-menu>`
|
|
153
|
+
|
|
154
|
+
#### Attributes / Properties
|
|
155
|
+
|
|
156
|
+
| Property | Attribute | Type | Default | Description |
|
|
157
|
+
| --- | --- | --- | --- | --- |
|
|
158
|
+
| `label` | `label` | `string` | `""` | Text of the trigger button the parent menubar renders for this menu. |
|
|
159
|
+
| `disabled` | `disabled` | `boolean` | `false` | Renders this menu's trigger in the Figma State=Disabled style and stops it opening by pointer, keyboard or hover-switch. The trigger stays in the tab order and reachable with the arrow keys (`aria-disabled`, not the native `disabled` attribute), matching how disabled `data-item` rows behave. Reflected. |
|
|
160
|
+
|
|
161
|
+
### Events
|
|
162
|
+
|
|
163
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
164
|
+
| --- | --- | --- | --- |
|
|
165
|
+
| — | — | — | This element emits no custom events. |
|
|
166
|
+
|
|
167
|
+
### Slots
|
|
168
|
+
|
|
169
|
+
| Slot | Description |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| — | This element has no slots. |
|
|
172
|
+
|
|
173
|
+
### CSS Parts
|
|
174
|
+
|
|
175
|
+
| Part | Description |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| — | None exposed. |
|
|
178
|
+
|
|
179
|
+
<!-- readme-gen:end -->
|
|
180
|
+
|
|
181
|
+
## Accessibility
|
|
182
|
+
|
|
183
|
+
- Roles follow the APG menubar pattern: the strip is `role="menubar"`; each trigger is a `<button role="menuitem" aria-haspopup="menu" aria-expanded="true|false">`; each dropdown is a `role="menu"` panel with `tabindex="-1"`; rows are `role="menuitem"` (disabled ones add `aria-disabled="true"`), separators are `role="separator"`, and a submenu trigger row carries `aria-haspopup="menu"` / `aria-expanded` with its own nested `role="menu"` panel.
|
|
184
|
+
- Focus model: the triggers are real buttons in the tab order. When a menu opens from the keyboard, DOM focus moves to the panel itself and the highlighted row is exposed through `aria-activedescendant` (row ids are generated per menubar instance), so arrow keys move a virtual focus rather than DOM focus. `Escape` closes everything and returns DOM focus to the trigger that owned the menu.
|
|
185
|
+
- Checkbox items render as `lof-checkbox` and radio groups as `lof-radio` inside the panel, so those rows carry the native checkbox / radiogroup semantics of those components.
|
|
186
|
+
- There is no type-ahead and no wrap-around: arrow keys stop at the first / last trigger or row.
|
|
187
|
+
- Bound shortcuts (`bind-shortcuts`) listen on `document`, skip events whose `defaultPrevented` is already set, skip keystrokes that start in an input, textarea, select or contenteditable, and call `preventDefault()` on a match.
|
|
188
|
+
|
|
189
|
+
| Key | Where | Action |
|
|
190
|
+
| --- | --- | --- |
|
|
191
|
+
| `Tab` / `Shift+Tab` | anywhere | Native focus movement between the trigger buttons (and out of the menubar). |
|
|
192
|
+
| `ArrowRight` / `ArrowLeft` | trigger | Move focus to the next / previous trigger (does not open it). |
|
|
193
|
+
| `Enter` / `Space` / `ArrowDown` | trigger | Open that menu, focus the panel and highlight the first item. |
|
|
194
|
+
| `Enter` / `Space` / `ArrowDown` | trigger of a `disabled` menu | Nothing — the trigger is reachable but never opens. |
|
|
195
|
+
| `Escape` | trigger (menu open) | Close all menus and keep focus on the trigger. |
|
|
196
|
+
| `ArrowDown` / `ArrowUp` | open panel | Highlight the next / previous item (clamped, no wrap). |
|
|
197
|
+
| `Home` / `End` | open panel | Highlight the first / last item. |
|
|
198
|
+
| `ArrowRight` | open panel, on a submenu row | Open the submenu and highlight its first item. |
|
|
199
|
+
| `Enter` / `Space` | open panel | Activate the highlighted row: fire `lof-menubar-select` and close, toggle a checkbox, pick a radio option, or open a submenu. |
|
|
200
|
+
| `Escape` | open panel | Close all menus and return focus to the trigger. |
|
|
201
|
+
| `ArrowDown` / `ArrowUp` / `Home` / `End` | open submenu | Move the highlight inside the submenu. |
|
|
202
|
+
| `ArrowLeft` / `Escape` | open submenu | Close only the submenu; the parent panel stays open and focused. |
|
|
203
|
+
| `Enter` / `Space` | open submenu | Activate the highlighted sub-item: fire `lof-menubar-select`, close everything, refocus the trigger. |
|
|
204
|
+
|
|
205
|
+
## Notes / Edge Cases
|
|
206
|
+
|
|
207
|
+
- Both elements render into **light DOM** (`createRenderRoot()` returns the host): there are no slots, no `::part` hooks and no style encapsulation. The menubar injects its own `<style>` block; the `.menubar-trigger` / `.menubar-panel` / `.menu-item` class names are implementation details, not a styling contract.
|
|
208
|
+
- `<lof-menubar-menu>` is a hidden data holder (`display: none`) — it never renders its children itself. The menubar discovers menus once, when it connects; menus added or removed later are not picked up until the menubar is re-attached. Item lists inside a menu are re-read on each render, so item changes show up the next time a panel opens.
|
|
209
|
+
- Item content is flattened: a `data-item` row renders the button's `textContent` only, so markup inside the button (icons, `<lof-kbd>` chips) is not reproduced. Use `data-shortcut` for the shortcut hint — it is displayed verbatim, so `Mod+Z` is shown literally as "Mod+Z"; write `Ctrl+Z` if you want that text and only need Ctrl.
|
|
210
|
+
- Panels are `position: fixed` (z-index 1000, submenus 1001), placed flush under the trigger / against the right edge of the submenu row, and repositioned on scroll. They are not moved into the top layer, so a `lof-modal` or other top-layer surface can cover them.
|
|
211
|
+
- Panels are a fixed 300px wide, matching the Figma Menu component the bar is paired with; override with `--lof-menubar-panel-width`. There is no viewport clamping, so a panel opened near the right edge can overflow.
|
|
212
|
+
- The bar follows Figma's Menu Bar geometry: 40px tall triggers (`spacing/xs` × `spacing/md` padding on a `body/lg` label) on a `bg/fill/neutral/default` surface with `border-radius/sm` and no border. The trigger whose menu is open takes the hover overlay plus a medium-weight label, which widens it by a pixel or two — that weight shift is in the Figma spec, not an artefact.
|
|
213
|
+
- A `disabled` `<lof-menubar-menu>` renders its trigger in the disabled tone and refuses to open by click, hover-switch, Enter/Space/ArrowDown or a bound shortcut. It uses `aria-disabled`, not the native `disabled` attribute, so the trigger stays in the tab order — the same model the disabled `data-item` rows use.
|
|
214
|
+
- With a menu already open the bar is in hover-switch mode: moving the pointer onto another trigger opens that menu, so a *click* on it arrives when it is already open and toggles it shut. Switch menus by hovering, or click twice.
|
|
215
|
+
- Hover-switching between menus is armed only after a click has opened one; hovering triggers on a closed menubar does nothing. Clicking outside (checked via `composedPath`, so it works inside shadow roots) closes everything.
|
|
216
|
+
- Disabled `data-item` buttons ignore pointer clicks and bound shortcuts but are still reachable with the arrow keys.
|
|
217
|
+
- `lof-menubar-select` fires only for regular `data-item` rows (panel or submenu); checkbox and radio rows fire `lof-menubar-change` instead. Both events bubble and are composed.
|
|
218
|
+
- Only one submenu can be open at a time, and submenus nest one level deep (a `data-submenu` inside a `data-submenu` is not rendered).
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# lof-nav
|
|
2
|
+
|
|
3
|
+
`<lof-nav>` is the vertical navigation of an application sidebar: section headings, items with an icon and an optional badge ("Soon", "New", a count), collapsible groups of child links, and one active item (`value`) drawn with the accent. Items with `href` are real links; items without one are buttons that fire `lof-select` for in-app routing. `collapsed` turns it into an icon rail. New in the 2026-11 admin refresh, after the sidebars of admin dashboards.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<lof-nav id="side" value="light"></lof-nav>
|
|
9
|
+
<script>
|
|
10
|
+
document.getElementById('side').items = [
|
|
11
|
+
{ label: 'Dashboards', icon: 'dashboard', children: [
|
|
12
|
+
{ label: 'Light sidebar', value: 'light' },
|
|
13
|
+
{ label: 'Dark sidebar', value: 'dark' },
|
|
14
|
+
] },
|
|
15
|
+
{ heading: 'User' },
|
|
16
|
+
{ label: 'Public profile', icon: 'person', href: '/profile' },
|
|
17
|
+
{ label: 'My account', icon: 'settings', href: '/account' },
|
|
18
|
+
{ label: 'Network', icon: 'people', href: '/network' },
|
|
19
|
+
{ heading: 'Apps' },
|
|
20
|
+
{ label: 'Project planning', icon: 'calendar-month', href: '/planning' },
|
|
21
|
+
{ label: 'Invoice generator', icon: 'billing-invoices', badge: 'Soon', disabled: true },
|
|
22
|
+
];
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<!-- Plus / minus group toggles -->
|
|
26
|
+
<lof-nav indicator="plus"></lof-nav>
|
|
27
|
+
|
|
28
|
+
<!-- Icon rail -->
|
|
29
|
+
<lof-nav collapsed></lof-nav>
|
|
30
|
+
|
|
31
|
+
<!-- Route in-app instead of following hrefs -->
|
|
32
|
+
<script>
|
|
33
|
+
document.getElementById('side').addEventListener('lof-select', (e) => {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
router.go(e.detail.item.href ?? e.detail.value);
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
<!-- readme-gen:start -->
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
### Attributes / Properties
|
|
45
|
+
|
|
46
|
+
| Property | Attribute | Type | Default | Description |
|
|
47
|
+
| --- | --- | --- | --- | --- |
|
|
48
|
+
| `items` | `items` | `NavEntry[]` | `[]` | Items `{ label, value?, href?, icon?, badge?, disabled?, children?, expanded? }` and section labels `{ heading }`, in order. An item with `children` is a group that toggles instead of navigating. |
|
|
49
|
+
| `value` | `value` | `string` | `""` | The active item's identity (`value`, else `href`, else `label`). |
|
|
50
|
+
| `collapsed` | `collapsed` | `boolean` | `false` | Icon-only rail: labels, badges, headings and children hide; labels move to tooltips. |
|
|
51
|
+
| `indicator` | `indicator` | `"chevron" \| "plus"` | `"chevron"` | Group toggle glyph: chevron (default) or plus / minus. |
|
|
52
|
+
| `fieldAriaLabel` | `field-aria-label` | `string` | `"Main"` | Accessible name of the navigation landmark. |
|
|
53
|
+
|
|
54
|
+
## Events
|
|
55
|
+
|
|
56
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
57
|
+
| --- | --- | --- | --- |
|
|
58
|
+
| `lof-select` | `CustomEvent<NavSelectDetail>` | yes / yes | An item (not a group) was activated. `detail: { value, item }`. Cancelable: `preventDefault()` stops the link from navigating; `value` still updates. |
|
|
59
|
+
| `lof-toggle` | `CustomEvent<{ value: string; open: boolean; }>` | yes / yes | A group opened or closed. `detail: { value, open }`. |
|
|
60
|
+
|
|
61
|
+
## Slots
|
|
62
|
+
|
|
63
|
+
| Slot | Description |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| — | This element has no slots. |
|
|
66
|
+
|
|
67
|
+
## CSS Parts
|
|
68
|
+
|
|
69
|
+
| Part | Description |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `badge` | Each item badge |
|
|
72
|
+
| `link` | Each item link or button (groups also have `group`) |
|
|
73
|
+
| `group` | Each group toggle |
|
|
74
|
+
| `base` | The `<nav>` landmark |
|
|
75
|
+
| `heading` | Each section label |
|
|
76
|
+
|
|
77
|
+
<!-- readme-gen:end -->
|
|
78
|
+
|
|
79
|
+
## Accessibility
|
|
80
|
+
|
|
81
|
+
- A `<nav>` landmark named by `field-aria-label` (default "Main"), with plain lists inside. Tab moves through the items in order; Enter or Space activates.
|
|
82
|
+
- Group toggles are buttons with `aria-expanded`. A group that holds the active item opens on its own.
|
|
83
|
+
- The active item has `aria-current="page"`. Disabled link items lose their `href` and carry `aria-disabled`.
|
|
84
|
+
- In `collapsed` mode the labels become `title` tooltips; pair the rail with a visible label elsewhere (a header) or an expand control.
|
|
85
|
+
|
|
86
|
+
## Notes / Edge Cases
|
|
87
|
+
|
|
88
|
+
- An item's identity is `value`, else `href`, else `label`: set `value` when two items share a label.
|
|
89
|
+
- Children are one level deep, drawn with a bullet that takes the accent when active. Icons are shown on top-level items only.
|
|
90
|
+
- The element does not draw a sidebar surface: put it inside your own aside (Metronic-style sidebars are the page background with a hairline divider).
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# lof-otp
|
|
2
|
+
|
|
3
|
+
A one-time-password input implementing the Figma "OTP Input" cell: one single-character `<input>` per position, with auto-advance, smart backspace, paste distribution, mobile OTP autofill and optional group separators. The cells accept digits only (`input-mode="numeric"`, the default) or digits plus ASCII letters (`input-mode="alphanumeric"`), and can be masked password-style. Use it for SMS / authenticator verification codes and PINs; for free-form text use `lof-textfield`.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- 6-digit numeric code in two groups of three -->
|
|
9
|
+
<lof-otp length="6" group-size="3"></lof-otp>
|
|
10
|
+
|
|
11
|
+
<!-- Alphanumeric, masked, four per group, custom accessible name -->
|
|
12
|
+
<lof-otp
|
|
13
|
+
length="8"
|
|
14
|
+
input-mode="alphanumeric"
|
|
15
|
+
mask
|
|
16
|
+
group-size="4"
|
|
17
|
+
aria-label="Enter 8-character code">
|
|
18
|
+
</lof-otp>
|
|
19
|
+
|
|
20
|
+
<!-- Sizes: small 32px / medium 40px (default) / large 48px cells -->
|
|
21
|
+
<lof-otp size="small" length="4"></lof-otp>
|
|
22
|
+
<lof-otp size="medium" length="6"></lof-otp>
|
|
23
|
+
<lof-otp size="large" length="6"></lof-otp>
|
|
24
|
+
|
|
25
|
+
<!-- Form integration: `name` renders a hidden input carrying the value -->
|
|
26
|
+
<form id="verify-form">
|
|
27
|
+
<lof-otp id="otp-form" name="verification_code" length="6" required></lof-otp>
|
|
28
|
+
<button type="submit">Verify</button>
|
|
29
|
+
</form>
|
|
30
|
+
<script>
|
|
31
|
+
const form = document.getElementById('verify-form');
|
|
32
|
+
const otp = document.getElementById('otp-form');
|
|
33
|
+
|
|
34
|
+
form.addEventListener('submit', (e) => {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
console.log('OTP:', new FormData(form).get('verification_code'));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
otp.addEventListener('lof-change', (e) => {
|
|
40
|
+
console.log('Value:', e.detail.value, 'Complete:', e.detail.complete);
|
|
41
|
+
otp.invalid = false;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
otp.addEventListener('lof-complete', async (e) => {
|
|
45
|
+
otp.disabled = true;
|
|
46
|
+
const ok = await verifyOtp(e.detail.value);
|
|
47
|
+
otp.disabled = false;
|
|
48
|
+
if (!ok) {
|
|
49
|
+
otp.invalid = true; // danger border + aria-invalid
|
|
50
|
+
otp.value = ''; // clear for retry
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<!-- No separators ("false" switches a default-true boolean off, since 1.5.0) -->
|
|
56
|
+
<lof-otp length="6" show-separator="false"></lof-otp>
|
|
57
|
+
|
|
58
|
+
<!-- States -->
|
|
59
|
+
<lof-otp value="123456" readonly></lof-otp>
|
|
60
|
+
<lof-otp value="12" disabled></lof-otp>
|
|
61
|
+
<lof-otp invalid length="6"></lof-otp>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Deprecated aliases
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<!-- type= is a deprecated alias of input-mode; input-mode wins when both are set.
|
|
68
|
+
Logs once per page:
|
|
69
|
+
[lof-otp] "type" is deprecated and will be removed in 3.0 — use "input-mode" instead. It describes the accepted characters, not a semantic input type. -->
|
|
70
|
+
<lof-otp type="alphanumeric" length="8"></lof-otp>
|
|
71
|
+
|
|
72
|
+
<!-- sm / md / lg are deprecated aliases of size="small" / "medium" / "large" (no console notice) -->
|
|
73
|
+
<lof-otp size="lg" length="6"></lof-otp>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<!-- readme-gen:start -->
|
|
77
|
+
|
|
78
|
+
<!-- Generated from lof-otp.ts — do not edit; run readme-generate.mjs -->
|
|
79
|
+
|
|
80
|
+
## API
|
|
81
|
+
|
|
82
|
+
### Attributes / Properties
|
|
83
|
+
|
|
84
|
+
| Property | Attribute | Type | Default | Description |
|
|
85
|
+
| --- | --- | --- | --- | --- |
|
|
86
|
+
| `value` | `value` | `string` | `""` | The concatenated code (all cells joined). Set it to fill the cells programmatically; it never exceeds `length` characters. Reflected. |
|
|
87
|
+
| `length` | `length` | `number` | `6` | Total number of cells (characters in the code). |
|
|
88
|
+
| `groupSize` | `group-size` | `number` | `3` | Cells per visual group; a separator renders between groups. Grouping applies only when `length` divides evenly by this — otherwise the row renders ungrouped, because a ragged final group would put a separator before a lone cell. So the default `length="6"` is 3–3, `length="4"` is one ungrouped row of four, and `group-size="2"` with `length="4"` is 2–2. `0` (or `show-separator` off) also renders one ungrouped row. |
|
|
89
|
+
| `placeholder` | `placeholder` | `string` | `""` | Placeholder character shown in every empty cell. |
|
|
90
|
+
| `inputMode` | `input-mode` | `"numeric" \| "alphanumeric" \| ""` | `""` | Accepted character set (Trello 5). Describes what the field ACCEPTS, not a semantic input type — hence the name. Explicitly set it wins over the deprecated `type`; unset (`""`, like the native `inputMode` accessor it shadows on the host), `type` (default `"numeric"`) applies. Note the lowercase `inputmode` prop is a different thing: the raw native keyboard hint forwarded to each cell. |
|
|
91
|
+
| `mask` | `mask` | `boolean` | `false` | Renders the cells as `type="password"` so entered characters are masked. |
|
|
92
|
+
| `disabled` | `disabled` | `boolean` | `false` | Disables every cell and dims the control to 0.4 opacity (cell fill and border unchanged, as Figma specifies). Reflected. |
|
|
93
|
+
| `readonly` | `readonly` | `boolean` | `false` | Makes every cell read-only: the value is shown but typing, paste and keyboard editing are ignored. Reflected. |
|
|
94
|
+
| `required` | `required` | `boolean` | `false` | Marks the first cell `required` for native form validation. |
|
|
95
|
+
| `name` | `name` | `string \| null` | `null` | When set, renders a hidden `<input name="…">` (part `hidden-input`) carrying `value` for native form submission. |
|
|
96
|
+
| `autocomplete` | `autocomplete` | `string` | `"one-time-code"` | Reserved autocomplete hint. Currently every cell always renders `autocomplete="one-time-code"` regardless of this value. |
|
|
97
|
+
| `inputmode` | `inputmode` | `"numeric" \| "text" \| null` | `null` | Raw native `inputmode` keyboard hint forwarded to every cell. Unset, it follows the accepted character set: `numeric` for numeric, `text` for alphanumeric. |
|
|
98
|
+
| `pattern` | `pattern` | `string \| null` | `null` | Native `pattern` attribute forwarded to every cell (per-character regex for form validation). |
|
|
99
|
+
| `ariaLabel` | `aria-label` | `string \| null` | `null` | Accessible name of the whole group; defaults to "One-time password input". Each cell is additionally labelled "Digit/Character N of M". |
|
|
100
|
+
| `invalid` | `invalid` | `boolean` | `false` | Error styling (danger border on every cell) and `aria-invalid="true"`. Reflected. |
|
|
101
|
+
| `showSeparator` | `show-separator` | `boolean` | `true` | Renders the dash separator between groups. Presence or `""` means true; `show-separator="false"` (or the property set to `false`) hides them. Even when on, separators appear only if `length` divides evenly by `group-size`; see `groupSize`. |
|
|
102
|
+
| `size` | `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | `"medium"` | Cell size on the shared field scale (square, border-box): `small` 32px, `medium` 40px, `large` 48px (the Figma OTP Input cell). `sm` / `md` / `lg` are deprecated aliases of the full words. Reflected. |
|
|
103
|
+
|
|
104
|
+
#### Deprecated (still supported — removal targeted for 3.0)
|
|
105
|
+
|
|
106
|
+
| Property | Attribute | Type | Use instead |
|
|
107
|
+
| --- | --- | --- | --- |
|
|
108
|
+
| `type` | `type` | `"numeric" \| "alphanumeric"` | Deprecated alias of `inputMode` (attribute `input-mode`); use `input-mode` instead. Kept working in 1.x and logs a one-time console notice. |
|
|
109
|
+
|
|
110
|
+
## Events
|
|
111
|
+
|
|
112
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
113
|
+
| --- | --- | --- | --- |
|
|
114
|
+
| `lof-change` | `{ value: newValue, complete }` | bubbles / composed | Fired on every value change (typing, backspace, delete, paste). Detail: `{ value: string, complete: boolean }` — `complete` is true when all cells hold a valid character. |
|
|
115
|
+
| `lof-complete` | `{ value: newValue }` | bubbles / composed | Fired after `lof-change` once every cell holds a valid character. Detail: `{ value: string }` (the full code). |
|
|
116
|
+
|
|
117
|
+
## Slots
|
|
118
|
+
|
|
119
|
+
| Slot | Description |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| — | This element has no slots. |
|
|
122
|
+
|
|
123
|
+
## CSS Parts
|
|
124
|
+
|
|
125
|
+
| Part | Description |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `base` | The `role="group"` root container (same element as `root`) |
|
|
128
|
+
| `root` | Alias of `base`, kept for existing `::part(root)` selectors |
|
|
129
|
+
| `input` | Each single-character cell input (same element as `cell`) |
|
|
130
|
+
| `cell` | Alias of `input`, kept for existing `::part(cell)` selectors |
|
|
131
|
+
| `separator` | The dash rendered between cell groups |
|
|
132
|
+
| `hidden-input` | The hidden form input rendered when `name` is set |
|
|
133
|
+
|
|
134
|
+
<!-- readme-gen:end -->
|
|
135
|
+
|
|
136
|
+
## Accessibility
|
|
137
|
+
|
|
138
|
+
- The root renders `role="group"` with `aria-label` from the `aria-label` attribute (default "One-time password input").
|
|
139
|
+
- Every cell is a native `<input maxlength="1">` labelled "Digit N of M" (numeric) or "Character N of M" (alphanumeric), so screen readers announce the position while focus auto-advances.
|
|
140
|
+
- `invalid` sets `aria-invalid="true"` on every cell; `disabled`, `readonly` and `required` (first cell only) are the native attributes.
|
|
141
|
+
- The native `inputmode` hint on each cell follows the accepted character set — `numeric` for `input-mode="numeric"`, `text` for `alphanumeric` — unless the raw `inputmode` prop overrides it. Every cell carries `autocomplete="one-time-code"` so iOS / Android can inject an SMS code; a multi-character injection into any cell is distributed like a paste.
|
|
142
|
+
- Focus management: focusing a cell selects its content (replace-on-type); a pointer-down on a cell beyond the first empty one is redirected to that empty cell so the code cannot be entered out of order; after paste focus lands on the next empty cell (or the last cell when full).
|
|
143
|
+
- Live-region announcements (via the shared `announce()` utility): "Code complete" when every cell holds a valid character, and "N digits/characters entered" after a paste that does not fill the code.
|
|
144
|
+
|
|
145
|
+
| Key | Action |
|
|
146
|
+
| --- | --- |
|
|
147
|
+
| `0-9` (numeric) / `0-9` `A-Z` `a-z` (alphanumeric) | Enter the character and advance to the next cell; other characters are rejected |
|
|
148
|
+
| `Backspace` | Clear the current cell; if it is already empty, move to the previous cell and clear it |
|
|
149
|
+
| `Delete` | Clear the current cell and stay |
|
|
150
|
+
| `ArrowLeft` / `ArrowRight` | Move to the previous / next cell |
|
|
151
|
+
| `Home` / `End` | Jump to the first / last cell |
|
|
152
|
+
| `ArrowUp` / `ArrowDown` | Ignored (prevented so the page does not scroll) |
|
|
153
|
+
| `Ctrl/Cmd+V` | Paste: valid characters are distributed from the current cell onward, overflow past `length` is dropped |
|
|
154
|
+
| `Tab` / `Shift+Tab` | Move focus between cells (each cell is a tab stop) |
|
|
155
|
+
|
|
156
|
+
## Notes / Edge Cases
|
|
157
|
+
|
|
158
|
+
- `value` is truncated to `length` characters when synced into the cells; changing `length` re-initialises the cells from `value`.
|
|
159
|
+
- `lof-change` fires on every edit; `lof-complete` fires right after it when all cells hold a valid character for the current mode — validate the code server-side, the component only checks the character set.
|
|
160
|
+
- `input-mode` unset (`""`) falls back to the deprecated `type` prop (default `"numeric"`); set `input-mode` explicitly and it always wins.
|
|
161
|
+
- The lowercase `inputmode` prop is the raw native keyboard hint, not the accepted character set — normally leave it unset.
|
|
162
|
+
- `show-separator="false"` hides the separators (since 1.5.0; before that any value enabled them), as do `el.showSeparator = false` and `group-size="0"`.
|
|
163
|
+
- **Separators require an even split.** Grouping applies only when `length` divides evenly by `group-size`; otherwise the cells render as one ungrouped row. A separator marks a boundary between two equal groups, so a length that does not divide would put one before a lone trailing cell — `length="4"` with the default `group-size="3"` used to draw `3 – 1`. Affected lengths at the default group size are 4, 5, 7 and 8; each now renders ungrouped. To group a length of 4, set `group-size="2"` for `2 – 2`.
|
|
164
|
+
- `required` is applied to the first cell only, so native form validation blocks submission when the code is empty but not when it is partial — check `e.detail.complete` yourself.
|
|
165
|
+
- The `autocomplete` prop currently has no effect: every cell always renders `autocomplete="one-time-code"`.
|
|
166
|
+
- `disabled` and `readonly` also suppress paste and keyboard handling; the value stays visible.
|
|
167
|
+
- Style cells via `::part(cell)` (alias `::part(input)`) and the root via `::part(base)` (alias `::part(root)`); the two names in each pair target the same element.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# lof-page-header
|
|
2
|
+
|
|
3
|
+
`<lof-page-header>` is the bar at the top of a page: the page title, a line under it (`description`) or a breadcrumb trail (the `breadcrumb` slot), and the page actions on the right (the `actions` slot). `layout="inline"` puts the breadcrumb beside the title; `divider` draws a hairline under the bar. New in the 2026-11 admin refresh.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<lof-page-header heading="Dashboard" description="Central hub for personal customization">
|
|
9
|
+
<lof-button slot="actions" variant="secondary">View profile</lof-button>
|
|
10
|
+
<lof-button slot="actions">Create team</lof-button>
|
|
11
|
+
</lof-page-header>
|
|
12
|
+
|
|
13
|
+
<!-- Breadcrumb beside the title -->
|
|
14
|
+
<lof-page-header id="ph" heading="Team settings" layout="inline" divider>
|
|
15
|
+
<lof-breadcrumbs slot="breadcrumb" id="trail"></lof-breadcrumbs>
|
|
16
|
+
<lof-button slot="actions" variant="secondary"><lof-icon name="download"></lof-icon>Export</lof-button>
|
|
17
|
+
</lof-page-header>
|
|
18
|
+
<script>
|
|
19
|
+
document.getElementById('trail').items = [
|
|
20
|
+
{ label: 'Home', href: '/' }, { label: 'Client API', href: '/api' }, { label: 'Team settings' },
|
|
21
|
+
];
|
|
22
|
+
</script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<!-- readme-gen:start -->
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
### Attributes / Properties
|
|
30
|
+
|
|
31
|
+
| Property | Attribute | Type | Default | Description |
|
|
32
|
+
| --- | --- | --- | --- | --- |
|
|
33
|
+
| `heading` | `heading` | `string` | `""` | Page title (rendered as an h1 by default). |
|
|
34
|
+
| `description` | `description` | `string` | `""` | Line under (or beside) the title; the `breadcrumb` slot takes a lof-breadcrumbs instead. |
|
|
35
|
+
| `headingLevel` | `heading-level` | `number` | `1` | Heading level for the title (1 to 6). |
|
|
36
|
+
| `layout` | `layout` | `"stacked" \| "inline"` | `"stacked"` | stacked (default) \| inline. |
|
|
37
|
+
| `divider` | `divider` | `boolean` | `false` | A hairline under the bar. |
|
|
38
|
+
|
|
39
|
+
## Events
|
|
40
|
+
|
|
41
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
42
|
+
| --- | --- | --- | --- |
|
|
43
|
+
| — | — | — | This element emits no custom events. |
|
|
44
|
+
|
|
45
|
+
## Slots
|
|
46
|
+
|
|
47
|
+
| Slot | Description |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `title` | Rich title content (replaces `heading`). |
|
|
50
|
+
| `breadcrumb` | A lof-breadcrumbs or other line (replaces `description`). |
|
|
51
|
+
| `actions` | Page actions; fields here drop their label row. |
|
|
52
|
+
|
|
53
|
+
## CSS Parts
|
|
54
|
+
|
|
55
|
+
| Part | Description |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `base` | The bar |
|
|
58
|
+
| `title` | The title |
|
|
59
|
+
| `description` | The description |
|
|
60
|
+
| `actions` | The actions region |
|
|
61
|
+
|
|
62
|
+
<!-- readme-gen:end -->
|
|
63
|
+
|
|
64
|
+
## Accessibility
|
|
65
|
+
|
|
66
|
+
- The title is `role="heading"` at `heading-level` (default 1). Use one level 1 per page.
|
|
67
|
+
- Actions keep their own semantics; order them so the primary action is last (rightmost), as reading order follows the DOM.
|
|
68
|
+
|
|
69
|
+
## Notes / Edge Cases
|
|
70
|
+
|
|
71
|
+
- The bar wraps on narrow screens: actions drop under the title.
|