@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.
Files changed (65) hide show
  1. package/README.md +104 -2
  2. package/custom-elements.json +12890 -0
  3. package/dist/index.d.ts +3192 -0
  4. package/dist/index.js +20807 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/styles/ag-grid.css +145 -0
  7. package/dist/styles/motion.css +32 -0
  8. package/dist/styles/motion.tokens.json +38 -0
  9. package/dist/styles/typography.css +41 -0
  10. package/dist/styles/typography.json +858 -0
  11. package/dist/styles/vars.css +1225 -0
  12. package/package.json +46 -4
  13. package/readmes/lof-accordion/README.md +140 -0
  14. package/readmes/lof-alert/README.md +142 -0
  15. package/readmes/lof-autocomplete/README.md +209 -0
  16. package/readmes/lof-avatar/README.md +228 -0
  17. package/readmes/lof-badge/README.md +102 -0
  18. package/readmes/lof-breadcrumb/README.md +97 -0
  19. package/readmes/lof-button/README.md +189 -0
  20. package/readmes/lof-calendar/README.md +111 -0
  21. package/readmes/lof-card/README.md +105 -0
  22. package/readmes/lof-cardmedia/README.md +100 -0
  23. package/readmes/lof-carousel/README.md +187 -0
  24. package/readmes/lof-checkbox/README.md +159 -0
  25. package/readmes/lof-chip/README.md +153 -0
  26. package/readmes/lof-container/README.md +107 -0
  27. package/readmes/lof-date-picker/README.md +221 -0
  28. package/readmes/lof-divider/README.md +88 -0
  29. package/readmes/lof-drawer/README.md +188 -0
  30. package/readmes/lof-empty-state/README.md +78 -0
  31. package/readmes/lof-image-input/README.md +75 -0
  32. package/readmes/lof-kbd/README.md +188 -0
  33. package/readmes/lof-layout/README.md +122 -0
  34. package/readmes/lof-link/README.md +67 -0
  35. package/readmes/lof-menu/README.md +187 -0
  36. package/readmes/lof-menubar/README.md +218 -0
  37. package/readmes/lof-nav/README.md +90 -0
  38. package/readmes/lof-otp/README.md +167 -0
  39. package/readmes/lof-page-header/README.md +71 -0
  40. package/readmes/lof-pagination/README.md +141 -0
  41. package/readmes/lof-popover/README.md +220 -0
  42. package/readmes/lof-progress/README.md +88 -0
  43. package/readmes/lof-radio/README.md +142 -0
  44. package/readmes/lof-range-picker/README.md +194 -0
  45. package/readmes/lof-rating/README.md +90 -0
  46. package/readmes/lof-resizable/README.md +220 -0
  47. package/readmes/lof-segmented-button/README.md +158 -0
  48. package/readmes/lof-select/README.md +193 -0
  49. package/readmes/lof-sheet/README.md +170 -0
  50. package/readmes/lof-signature-pad/README.md +161 -0
  51. package/readmes/lof-skeleton/README.md +104 -0
  52. package/readmes/lof-slider/README.md +140 -0
  53. package/readmes/lof-snackbar/README.md +170 -0
  54. package/readmes/lof-split-button/README.md +129 -0
  55. package/readmes/lof-stat/README.md +73 -0
  56. package/readmes/lof-stepper/README.md +171 -0
  57. package/readmes/lof-switch/README.md +122 -0
  58. package/readmes/lof-tab/README.md +188 -0
  59. package/readmes/lof-table/README.md +114 -0
  60. package/readmes/lof-textfield/README.md +206 -0
  61. package/readmes/lof-time-picker/README.md +188 -0
  62. package/readmes/lof-toast/README.md +174 -0
  63. package/readmes/lof-tooltip/README.md +120 -0
  64. package/readmes/lof-tree/README.md +157 -0
  65. package/readmes/lof-upload/README.md +223 -0
@@ -0,0 +1,188 @@
1
+ # lof-tab
2
+
3
+ `<lof-tab>` implements the Figma **Tab Item** component (6473:1075) as an underline tab strip with roving-tabindex keyboard navigation, optional count or dot badges and a single shared tabpanel below the strip. Tabs are declared either with slotted `<lof-tab-item>` elements (registered by this folder; they render nothing themselves) or with the `tabs` array property. Use it to switch between peer views of the same content in place; for moving between pages use links or the navbar recipe, and for ordered multi-step flows use `<lof-stepper>`.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Declarative tabs with badges and a disabled item -->
9
+ <lof-tab id="inbox-tabs" size="medium">
10
+ <lof-tab-item slot="items" label="Inbox" value="inbox" badge="5"></lof-tab-item>
11
+ <lof-tab-item slot="items" label="Drafts" value="drafts" badge-dot></lof-tab-item>
12
+ <lof-tab-item slot="items" label="Archive" value="archive" disabled></lof-tab-item>
13
+ <div id="inbox-panel">Inbox content.</div>
14
+ </lof-tab>
15
+
16
+ <script>
17
+ const tabs = document.getElementById('inbox-tabs');
18
+ tabs.addEventListener('lof-tab-change', (e) => {
19
+ const index = e.detail; // number
20
+ const item = tabs.querySelectorAll('lof-tab-item')[index];
21
+ document.getElementById('inbox-panel').textContent = `${item.value} content.`;
22
+ });
23
+ </script>
24
+
25
+ <!-- Sizes: small (34px), medium (40px), large (48px) -->
26
+ <lof-tab size="small">
27
+ <lof-tab-item slot="items" label="Overview"></lof-tab-item>
28
+ <lof-tab-item slot="items" label="Details"></lof-tab-item>
29
+ </lof-tab>
30
+ <lof-tab size="large" active-index="1">
31
+ <lof-tab-item slot="items" label="Overview"></lof-tab-item>
32
+ <lof-tab-item slot="items" label="Details"></lof-tab-item>
33
+ </lof-tab>
34
+
35
+ <!-- Tabs from the `tabs` property -->
36
+ <lof-tab id="array-tabs"></lof-tab>
37
+ <script>
38
+ document.getElementById('array-tabs').tabs = [
39
+ { label: 'Overview' },
40
+ { label: 'Alerts', badge: 2 },
41
+ { label: 'Beta', badgeDot: true },
42
+ { label: 'Coming soon', disabled: true },
43
+ ];
44
+ </script>
45
+ ```
46
+
47
+ ### Deprecated aliases
48
+
49
+ ```html
50
+ <!-- size="sm" / "md" / "lg" → size="small" / "medium" / "large" (still accepted; no console notice is logged) -->
51
+ <lof-tab size="sm">
52
+ <lof-tab-item slot="items" label="Overview"></lof-tab-item>
53
+ </lof-tab>
54
+
55
+ <!-- activeindex → active-index (since 1.5.0; still works, logs a one-time console notice, removed in 3.0).
56
+ activeIndex still reflects as activeindex in 1.x. -->
57
+ <lof-tab activeindex="1">
58
+ <lof-tab-item slot="items" label="Overview"></lof-tab-item>
59
+ <lof-tab-item slot="items" label="Details"></lof-tab-item>
60
+ </lof-tab>
61
+ ```
62
+
63
+ <!-- readme-gen:start -->
64
+
65
+ <!-- Generated from lof-tab.ts — do not edit; run readme-generate.mjs -->
66
+
67
+ ## Elements
68
+
69
+ | Element | Class | Source |
70
+ | --- | --- | --- |
71
+ | `<lof-tab>` | `LofTab` | `lof-tab.ts` |
72
+ | `<lof-tab-item>` | `LofTabItem` | `lof-tab.ts` |
73
+
74
+ ## API
75
+
76
+ ### `<lof-tab>`
77
+
78
+ #### Attributes / Properties
79
+
80
+ | Property | Attribute | Type | Default | Description |
81
+ | --- | --- | --- | --- | --- |
82
+ | `tabs` | `tabs` | `TabItem[]` | `[]` | Tab definitions as `{ label, badge?, badgeDot?, disabled? }` objects — normally set as a property (as an attribute it must be a JSON string). Assign a new array to update; mutating in place does not re-render. Ignored when `<lof-tab-item>` children are slotted into `items`. |
83
+ | `activeIndex` | `active-index` | `number` | `0` | Zero-based index of the selected tab. Set it to switch tabs programmatically (no event is fired for programmatic changes). Reflected (as `activeindex` in 1.x). The `activeindex` attribute spelling is deprecated (still works; removal targeted for 3.0). |
84
+ | `size` | `size` | `"sm" \| "md" \| "lg" \| "small" \| "medium" \| "large"` | `"md"` | Tab size — styled via :host([size]) rules. Explicit item heights 34 / 40 / 48px (audit 34); `small\|medium\|large` alias `sm\|md\|lg`. Reflected. |
85
+ | `orientation` | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | New in 1.5.0. Tab list layout: `horizontal` (default, a row above the panel) or `vertical` (a column beside the panel as wide as its longest label, tabs 24px apart along a rule on the list's inline-start edge, the active bar on that edge, labels that wrap rather than truncate; Up / Down move between tabs). There is no built-in breakpoint: switch to horizontal on small screens in your app. Reflected. |
86
+ | `iconPlacement` | `icon-placement` | `"start" \| "top"` | `"start"` | New in 1.5.0. Icon position in every tab: `start` (default, before the label) or `top` (stacked above the label, with the badge beside the label). Stacked tabs are 76 / 64 / 52px tall at large / medium / small. Works in both orientations. Reflected. |
87
+
88
+ ### Events
89
+
90
+ | Event | Detail | Bubbles / composed | Description |
91
+ | --- | --- | --- | --- |
92
+ | `lof-change` | `index` | bubbles / composed | Prefixed alias of `lof-tab-change`, added in 1.4.9 — fired on the same action with the same detail. Both events fire; listen to one. Prefer this in new code, since every interactive component in the library emits `lof-change`. `lof-tab-change` is kept for as long as 1.x. |
93
+ | `lof-tab-change` | `index` | bubbles / composed | Fired when the user selects a tab by click or keyboard (not on programmatic `activeIndex` changes). Detail: the new active index (number). |
94
+
95
+ ### Slots
96
+
97
+ | Slot | Description |
98
+ | --- | --- |
99
+ | (default) | Content of the single tabpanel rendered under the strip (always visible — swap it yourself on `lof-tab-change`) |
100
+ | `items` | `<lof-tab-item>` definitions; when present they take precedence over the `tabs` array |
101
+
102
+ ### CSS Parts
103
+
104
+ | Part | Description |
105
+ | --- | --- |
106
+ | `list` | The `role="tablist"` row |
107
+ | `item` | Each `role="tab"` element |
108
+ | `icon` | — |
109
+ | `label` | The text span inside each tab |
110
+
111
+ ### Tokens / CSS Variables
112
+
113
+ #### Component hooks
114
+
115
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
116
+
117
+ | Custom property | Default | Description |
118
+ | --- | --- | --- |
119
+ | `--lof-tab-active-color` | `var(--tab-active-color)` | Indicator colour of the active tab; default `var(--lof-border-strong)` (set it to `var(--lof-bg-brand)` for the pre-2026-11 brand line) |
120
+ | `--lof-tab-hover-color` | `var(--tab-hover-color)` | Background of an inactive tab on hover; default `transparent` (the design darkens the label instead). Set it to bring a hover fill back. |
121
+ | `--lof-tab-list-width` | `max-content` | Width of the tab list when `orientation="vertical"`; default `max-content` |
122
+ | `--lof-tab-text-default` | `var(--tab-text-default)` | Label colour of the active tab; default `var(--lof-text-default)` |
123
+ | `--lof-tab-text-disabled` | `var(--lof-text-default)` | Label colour of a disabled tab; default `var(--lof-text-disabled)` |
124
+ | `--lof-tab-text-hover` | `var(--tab-text-hover)` | Label colour while hovering an enabled tab; default `var(--lof-text-default)` |
125
+ | `--lof-tab-underline-height` | `var(--tab-underline-height)` | Thickness of the active underline; default 1px (`--lof-stroke-sm`, the weight Figma draws). Set it to restore the heavier 3px bar shipped previously. |
126
+
127
+ ### `<lof-tab-item>`
128
+
129
+ #### Attributes / Properties
130
+
131
+ | Property | Attribute | Type | Default | Description |
132
+ | --- | --- | --- | --- | --- |
133
+ | `label` | `label` | `string` | `""` | Text shown on the tab. |
134
+ | `icon` | `icon` | `string` | `""` | Icon name from the generated icon dictionary, rendered before the label (Figma "Show Icon" / "Icon"). Sized 20 / 18 / 16px with the tab's own size step. |
135
+ | `value` | `value` | `string` | `""` | Optional identifier for the tab. `<lof-tab>` does not read it; look it up from the item at `event.detail` when handling `lof-tab-change`. |
136
+ | `badge` | `badge` | `number` | `0` | Count shown in a small badge after the label; `0` hides the badge. |
137
+ | `badgeDot` | `badge-dot` | `boolean` | `false` | Shows a small dot instead of a numbered badge — takes precedence over `badge`. |
138
+ | `disabled` | `disabled` | `boolean` | `false` | Greys the tab out and skips it in click, arrow-key and Home/End navigation. |
139
+
140
+ ### Events
141
+
142
+ | Event | Detail | Bubbles / composed | Description |
143
+ | --- | --- | --- | --- |
144
+ | — | — | — | This element emits no custom events. |
145
+
146
+ ### Slots
147
+
148
+ | Slot | Description |
149
+ | --- | --- |
150
+ | — | This element has no slots. |
151
+
152
+ ### CSS Parts
153
+
154
+ | Part | Description |
155
+ | --- | --- |
156
+ | — | None exposed. |
157
+
158
+ <!-- readme-gen:end -->
159
+
160
+ ## Look
161
+
162
+ - 2026-11 refresh: the active tab is accent text over a full-width 2px accent underline; hover turns a tab's text accent. Horizontal tabs have no side padding and sit 24px apart (`--lof-tab-gap`); vertical tabs keep an 80px minimum and 16px side padding.
163
+
164
+ ## Accessibility
165
+
166
+ - The strip is `role="tablist"`; every tab is `role="tab"` with `aria-selected`, `aria-disabled` and `aria-controls` pointing at the shared `role="tabpanel"`, which in turn is `aria-labelledby` the active tab and is focusable (`tabindex="0"`).
167
+ - Roving tabindex: only the active tab is in the Tab order (`tabindex="0"`); other and disabled tabs are `tabindex="-1"`.
168
+ - Arrow keys use automatic activation — moving focus also selects the tab and fires `lof-tab-change`.
169
+ - Focus is shown as a 2px outline inset inside the tab.
170
+ - Disabled tabs ignore clicks and keys and are skipped by arrow, Home and End navigation.
171
+
172
+ | Key | Action |
173
+ | --- | --- |
174
+ | `ArrowRight` | Selects and focuses the next enabled tab (wraps to the first). |
175
+ | `ArrowLeft` | Selects and focuses the previous enabled tab (wraps to the last). |
176
+ | `Home` | Selects and focuses the first enabled tab. |
177
+ | `End` | Selects and focuses the last enabled tab. |
178
+ | `Enter` / `Space` | Selects the focused tab (no-op when disabled). |
179
+ | `Tab` | Leaves the strip (moves to the tabpanel). |
180
+
181
+ ## Notes / Edge Cases
182
+
183
+ - There is one always-visible tabpanel (the default slot). The component does not show/hide content per tab — swap or filter the panel content yourself on `lof-tab-change` or by watching `activeIndex`.
184
+ - `lof-tab-change` fires for user selection only; setting `activeIndex` programmatically updates the strip silently.
185
+ - Slotted `<lof-tab-item>` elements take precedence over the `tabs` array. Their `value` is not read by `<lof-tab>` — look it up from the item at `event.detail` when you need an identifier. The `items` slot itself is hidden.
186
+ - `badge-dot` wins over `badge`; a `badge` of `0` renders no badge. Badges use the danger tone on enabled tabs and a neutral inverse tone on disabled tabs.
187
+ - `size` accepts `small` / `medium` / `large` (item heights 34 / 40 / 48px with body-sm / md / lg type); the short forms `sm` / `md` / `lg` are aliases (see Deprecated aliases).
188
+ - Legacy hook aliases still honoured: `--tab-active-color`, `--tab-underline-height`, `--tab-text-default`, `--tab-text-hover`, `--tab-text-disabled` and `--tab-hover-color` are read as fallbacks of the `--lof-tab-*` hooks.
@@ -0,0 +1,114 @@
1
+ # lof-table
2
+
3
+ `<lof-table>` is the data table of an admin screen: header row with sortable columns, row selection with a select-all box, two-line cells (a value and a muted line under it), custom cell content, client-side paging with a "Show N per page" footer and a page range, plus loading and empty states. By default (`appearance="card"`) it draws the 12px hairline surface of a card, with an optional header (`heading` and the `toolbar` slot for search or actions); `appearance="plain"` drops the surface so it can sit inside a flush `lof-card`. With `server-side` the app owns sorting and paging: the table shows `rows` as given and reports `lof-sort` and `lof-page-change`. New in the 2026-11 admin refresh.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <lof-table id="teams" heading="Teams" selectable page-size="5" grid>
9
+ <lof-textfield slot="toolbar" size="small" prefix-icon="search" placeholder="Search teams" field-aria-label="Search teams"></lof-textfield>
10
+ </lof-table>
11
+ <script>
12
+ const t = document.getElementById('teams');
13
+ t.columns = [
14
+ { key: 'team', label: 'Team', sortable: true, subKey: 'desc', width: '40%' },
15
+ { key: 'rating', label: 'Rating', sortable: true,
16
+ render: (row) => Object.assign(document.createElement('lof-rating'), { value: row.rating, readonly: true }) },
17
+ { key: 'modified', label: 'Last modified', sortable: true },
18
+ { key: 'members', label: 'Members', align: 'end' },
19
+ ];
20
+ t.rows = [
21
+ { id: 1, team: 'Product Management', desc: 'Product development & lifecycle', rating: 5, modified: '21 Oct, 2024', members: 14 },
22
+ { id: 2, team: 'Marketing Team', desc: 'Campaigns & market analysis', rating: 3.5, modified: '15 Oct, 2024', members: 6 },
23
+ { id: 3, team: 'HR Department', desc: 'Talent acquisition, employee welfare', rating: 5, modified: '10 Oct, 2024', members: 9 },
24
+ { id: 4, team: 'Sales Division', desc: 'Customer relations, sales strategy', rating: 4, modified: '05 Oct, 2024', members: 2 },
25
+ { id: 5, team: 'Development Team', desc: 'Software development', rating: 4.5, modified: '01 Oct, 2024', members: 21 },
26
+ { id: 6, team: 'Design', desc: 'Product and brand design', rating: 4.5, modified: '20 Sep, 2024', members: 7 },
27
+ ];
28
+ t.addEventListener('lof-selection-change', (e) => console.log(e.detail.selected));
29
+ </script>
30
+
31
+ <!-- Inside a card, edge to edge, server-side -->
32
+ <lof-card heading="Orders" flush>
33
+ <lof-table id="orders" appearance="plain" server-side page-size="10" total-items="240"></lof-table>
34
+ </lof-card>
35
+ ```
36
+
37
+ <!-- readme-gen:start -->
38
+
39
+ ## API
40
+
41
+ ### Attributes / Properties
42
+
43
+ | Property | Attribute | Type | Default | Description |
44
+ | --- | --- | --- | --- | --- |
45
+ | `columns` | `columns` | `TableColumn[]` | `[]` | Column definitions: `{ key, label, sortable?, align?, width?, subKey?, render?(row, column), compare?(a, b) }`. `render` may return a string, a DOM node or a Lit template. |
46
+ | `rows` | `rows` | `TableRow[]` | `[]` | Row objects. Each column shows `row[column.key]` (and `row[column.subKey]` under it). |
47
+ | `rowKey` | `row-key` | `string` | `"id"` | Row field that identifies a row (for selection). |
48
+ | `selectable` | `selectable` | `boolean` | `false` | Adds a checkbox column and a select-all box. |
49
+ | `selected` | `selected` | `string[]` | `[]` | Keys (`row[row-key]` as strings) of the selected rows. |
50
+ | `sortKey` | `sort-key` | `string` | `""` | Key of the sorted column (`""` = unsorted). Header clicks cycle ascending → descending → unsorted. |
51
+ | `sortDirection` | `sort-direction` | `"asc" \| "desc" \| ""` | `""` | |
52
+ | `pageSize` | `page-size` | `number` | `0` | Rows per page. `0` shows every row and hides the footer. |
53
+ | `page` | `page` | `number` | `1` | |
54
+ | `pageSizeOptions` | `page-size-options` | `number[]` | `[5, 10, 20, 50]` | |
55
+ | `serverSide` | `server-side` | `boolean` | `false` | The app sorts and pages: `rows` are shown as given, `total-items` drives the footer. |
56
+ | `totalItems` | `total-items` | `number` | `0` | |
57
+ | `appearance` | `appearance` | `"card" \| "plain"` | `"card"` | card (default) \| plain. |
58
+ | `grid` | `grid` | `boolean` | `false` | Column dividers as well as row dividers. |
59
+ | `density` | `density` | `"comfortable" \| "compact"` | `"comfortable"` | comfortable (default) \| compact. |
60
+ | `stickyHeader` | `sticky-header` | `boolean` | `false` | |
61
+ | `loading` | `loading` | `boolean` | `false` | |
62
+ | `heading` | `heading` | `string` | `""` | Card header title. |
63
+ | `emptyText` | `empty-text` | `string` | `"No results"` | Text when there are no rows (the `empty` slot replaces it). |
64
+ | `fieldAriaLabel` | `field-aria-label` | `string` | `""` | Accessible name of the table (default: `heading`). |
65
+ | `pageSizeLabel` | `page-size-label` | `string` | `"Show"` | Footer label before the page-size select. |
66
+ | `pageSizeSuffix` | `page-size-suffix` | `string` | `"per page"` | Footer label after the page-size select. |
67
+ | `rangeTemplate` | `range-template` | `string` | `"{start}-{end} of {total}"` | Footer range text; {start}, {end} and {total} are replaced. |
68
+
69
+ ## Events
70
+
71
+ | Event | Detail | Bubbles / composed | Description |
72
+ | --- | --- | --- | --- |
73
+ | `lof-page-change` | `CustomEvent<TablePageDetail>` | yes / yes | The page or page size changed. `detail: { page, pageSize }`. |
74
+ | `lof-selection-change` | `CustomEvent<TableSelectionDetail>` | yes / yes | A row or the select-all box changed. `detail.selected` is the new key list. |
75
+ | `lof-sort` | `CustomEvent<TableSortDetail>` | yes / yes | A sortable header was activated. `detail: { key, direction }`. Cancelable: `preventDefault()` keeps the current sort (sort on the server, then set `sort-key` / `sort-direction`). |
76
+
77
+ ## Slots
78
+
79
+ | Slot | Description |
80
+ | --- | --- |
81
+ | `toolbar` | Search, filters or actions on the right of the header row. |
82
+ | `empty` | Content for a table with no rows (default: `empty-text`). |
83
+
84
+ ## CSS Parts
85
+
86
+ | Part | Description |
87
+ | --- | --- |
88
+ | `page-size` | The page-size `<select>` |
89
+ | `cell` | Each body `<td>` |
90
+ | `base` | The surface |
91
+ | `head` | Header row (title and toolbar) |
92
+ | `title` | Header title |
93
+ | `scroll` | Scrolling wrapper around the table |
94
+ | `table` | The `<table>` |
95
+ | `header-row` | Header `<tr>` |
96
+ | `header-cell` | Each header `<th>` |
97
+ | `row` | Each body `<tr>` |
98
+ | `footer` | The page-size and pager row |
99
+
100
+ <!-- readme-gen:end -->
101
+
102
+ ## Accessibility
103
+
104
+ - A native `<table>` with `scope="col"` headers, named by `field-aria-label` or `heading`. Sortable headers are buttons and carry `aria-sort` (ascending, descending or none).
105
+ - Selection boxes are native checkboxes named "Select row <first column>"; the header box is named "Select all rows on this page" and shows mixed when some are selected. Selected rows carry `aria-selected`.
106
+ - The footer is a `nav` named Pagination; the range text is a polite live region, and the current page button has `aria-current="page"`.
107
+ - While `loading` the table is `aria-busy` and shows skeleton rows.
108
+
109
+ ## Notes / Edge Cases
110
+
111
+ - Client-side sorting compares numbers numerically, dates by time, and everything else with a locale-aware, numeric collator ("Item 2" before "Item 10"). Give a column `compare` for anything else.
112
+ - Select-all toggles the rows on the current page only; selections on other pages are kept.
113
+ - `grid` adds column dividers (the bordered admin table look); `density="compact"` trims the row padding to 8px.
114
+ - `sticky-header` keeps the header visible inside a height-constrained table (set a height on the `scroll` part).
@@ -0,0 +1,206 @@
1
+ # lof-textfield
2
+
3
+ `<lof-textfield>` is the single-line and multi-line text input from the Figma "Text Field" component: a labelled control with three chromes (`default` outlined, `underline`, `legend` notched outline), three heights (28 / 34 / 40px), prefix and suffix blocks (icon, short text or slotted content), error / helper text and full-width or inline layout. Use it for free-text entry — names, emails, passwords, numbers, notes (`multiline`). For picking from a fixed list use `lof-select`; for type-ahead against a list use `lof-autocomplete`; for dates and times use the picker components, which reuse this field's chrome.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Basic field -->
9
+ <lof-textfield label="Email" placeholder="you@example.com" type="email"></lof-textfield>
10
+
11
+ <!-- Sizes and chromes -->
12
+ <lof-textfield label="Small" size="small"></lof-textfield>
13
+ <lof-textfield label="Large" size="large"></lof-textfield>
14
+ <lof-textfield label="Underline" variant="underline"></lof-textfield>
15
+ <lof-textfield label="Legend" variant="legend"></lof-textfield>
16
+
17
+ <!-- Label styles -->
18
+ <lof-textfield label="Floating label" label-style="floating"></lof-textfield>
19
+ <lof-textfield label-style="none" placeholder="Search orders" field-aria-label="Search orders"></lof-textfield>
20
+
21
+ <!-- Leading icon, helper text, required -->
22
+ <lof-textfield label="Search" prefix-icon="search" helper-text="Type at least 3 characters" required></lof-textfield>
23
+
24
+ <!-- Prefix / suffix text (Figma .Preffix / .Suffix) -->
25
+ <lof-textfield label="Website" prefix-text="https://" prefix-style="fill"></lof-textfield>
26
+ <lof-textfield label="Weight" suffix-text="kg" suffix-divider></lof-textfield>
27
+
28
+ <!-- Slotted prefix / suffix content -->
29
+ <lof-textfield label="Amount">
30
+ <span slot="prefix">$</span>
31
+ <lof-button slot="suffix" variant="ghost" size="small">Max</lof-button>
32
+ </lof-textfield>
33
+
34
+ <!-- Clickable trailing icon (e.g. password toggle) -->
35
+ <lof-textfield
36
+ id="pw"
37
+ label="Password"
38
+ type="password"
39
+ right-icon="visibility-on"
40
+ clickable-right-icon
41
+ right-icon-aria-label="Show password">
42
+ </lof-textfield>
43
+ <script>
44
+ const pw = document.getElementById("pw");
45
+ pw.addEventListener("lof-right-icon-click", () => {
46
+ pw.type = pw.type === "password" ? "text" : "password";
47
+ });
48
+ pw.addEventListener("lof-change", (e) => console.log("typed:", e.detail));
49
+ </script>
50
+
51
+ <!-- Error state -->
52
+ <lof-textfield label="Username" value="a" error error-message="Must be at least 3 characters"></lof-textfield>
53
+
54
+ <!-- Multiline (textarea) -->
55
+ <lof-textfield label="Notes" multiline rows="5" maxlength="500"></lof-textfield>
56
+
57
+ <!-- Read-only, disabled, inline width -->
58
+ <lof-textfield label="Order ID" value="SO-4821" readonly></lof-textfield>
59
+ <lof-textfield label="Disabled" disabled></lof-textfield>
60
+ <lof-textfield id="qty" label="Quantity" type="number"></lof-textfield>
61
+ <script>
62
+ // fullWidth defaults to true; full-width="false" in markup does the same as this
63
+ document.getElementById("qty").fullWidth = false;
64
+ </script>
65
+ ```
66
+
67
+ ### Deprecated aliases
68
+
69
+ ```html
70
+ <!-- floatingLabel → label-style="floating" (kept permanently as an alias; no console notice) -->
71
+ <lof-textfield label="Old spelling" floatinglabel></lof-textfield>
72
+ <lof-textfield label="Canonical" label-style="floating"></lof-textfield>
73
+
74
+ <!-- Lowercase-joined attribute spellings → kebab-case (since 1.5.0; the old ones still work,
75
+ log a one-time console notice, and are removed in 3.0) -->
76
+ <lof-textfield label="Old spelling" prefixicon="search" lefticon="search" righticon="visibility-on" prefixiconarialabel="Search"
77
+ helpertext="Helper" errormessage="Error" fullwidth></lof-textfield>
78
+ <lof-textfield label="Canonical" prefix-icon="search" left-icon="search" right-icon="visibility-on" prefix-icon-aria-label="Search"
79
+ helper-text="Helper" error-message="Error" full-width></lof-textfield>
80
+ ```
81
+
82
+ <!-- readme-gen:start -->
83
+
84
+ <!-- Generated from lof-textfield.ts — do not edit; run readme-generate.mjs -->
85
+
86
+ ## API
87
+
88
+ ### Attributes / Properties
89
+
90
+ | Property | Attribute | Type | Default | Description |
91
+ | --- | --- | --- | --- | --- |
92
+ | `label` | `label` | `string` | `undefined` | Visible label text. Rendered above the control (default), inside it as a floating label (`labelStyle="floating"`) or as the notch of the `legend` variant; omitted entirely under `labelStyle="none"`. |
93
+ | `placeholder` | `placeholder` | `string` | `""` | Placeholder shown while the field is empty. Under the floating label style it stays hidden until the field is focused. |
94
+ | `type` | `type` | `string` | `"text"` | Native input `type` (`text`, `email`, `password`, `number`, …). Ignored when `multiline` is set. |
95
+ | `value` | `value` | `string` | `""` | Current text. Updated on every keystroke; set it to control the field programmatically. |
96
+ | `leftIcon` | `left-icon` | `string` | `undefined` | Legacy name for the leading icon (a `lof-icon` name). `prefixIcon` wins when both are set. The `lefticon` attribute spelling is deprecated (still works; removal targeted for 3.0). |
97
+ | `rightIcon` | `right-icon` | `string` | `undefined` | Trailing `lof-icon` name rendered in the suffix block. Decorative unless `clickableRightIcon` is set. The `righticon` attribute spelling is deprecated (still works; removal targeted for 3.0). |
98
+ | `clickableRightIcon` | `clickable-right-icon` | `boolean` | `false` | Makes the trailing icon interactive (pointer + focusable) and emits `lof-right-icon-click` — e.g. a password show/hide toggle or clear button. |
99
+ | `rightIconAriaLabel` | `right-icon-aria-label` | `string` | `undefined` | Accessible label for the trailing icon when it is clickable. |
100
+ | `prefixText` | `prefix-text` | `string` | `undefined` | Short text rendered before the input, e.g. `"http://"` or `"$"`. Sits in the same prefix block as `prefixIcon` and is styled by `prefixStyle`. |
101
+ | `prefixStyle` | `prefix-style` | `"clear" \| "divider" \| "fill"` | `"clear"` | Visual treatment of the prefix block — applies to the prefix icon, text and slotted `prefix` content alike. See `TextFieldPrefixStyle`. |
102
+ | `suffixText` | `suffix-text` | `string` | `undefined` | Short text rendered after the input, e.g. `"kg"` or `".00"`. Shares the suffix block with `rightIcon` and slotted `suffix` content. |
103
+ | `suffixDivider` | `suffix-divider` | `boolean` | `false` | Draws a hairline between the input and the suffix block. |
104
+ | `supportingText` | `supportingtext` | `string` | `undefined` | Legacy name for the helper line below the control. `helperText` wins when both are set. |
105
+ | `state` | `state` | `"default" \| "error" \| "disabled"` | `"default"` | Legacy visual state. `"error"` / `"disabled"` behave like the `error` / `disabled` booleans, which are preferred and take precedence. Typing into a `state="error"` field resets it to `"default"` until the value is emptied again. |
106
+ | `size` | `size` | `"small" \| "medium" \| "large"` | `"medium"` | Control height — `small` 32px, `medium` 40px, `large` 48px — which also scales the text and the affix icons. |
107
+ | `labelStyle` | `label-style` | `"default" \| "floating" \| "none"` | `undefined` | Label presentation. Left `undefined` the deprecated `floatingLabel` boolean decides, so existing markup keeps working; set explicitly and it wins. Declares `attribute` because Lit would otherwise only listen for the all-lowercase `labelstyle`. Reflected. |
108
+ | `fieldAriaLabel` | `field-aria-label` | `string` | `undefined` | Accessible name for the input. Required when `labelStyle="none"`, since no `<label>` renders and a placeholder is not a valid naming mechanism. |
109
+ | `fieldAriaLabelledby` | `field-aria-labelledby` | `string` | `undefined` | IDREF list of external element(s) naming the input. Wins over `fieldAriaLabel`. |
110
+ | `variant` | `variant` | `"default" \| "underline" \| "legend"` | `"default"` | Field chrome: `default` outlined box, `underline` bottom border only, `legend` notched outline with the label sitting in the top border (native fieldset/legend). Reflected. |
111
+ | `disabled` | `disabled` | `boolean` | `false` | Disables the input (not focusable, not editable) and dims the control. |
112
+ | `required` | `required` | `boolean` | `false` | Marks the input required: sets native `required` / `aria-required` and appends an asterisk to the label. |
113
+ | `multiline` | `multiline` | `boolean` | `false` | Renders a textarea instead of a single-line input (see `rows`). Prefix/suffix blocks and `type` are ignored in this mode. Reflected. |
114
+ | `rows` | `rows` | `number` | `3` | Visible text rows of the textarea when `multiline` is set. |
115
+ | `prefixIcon` | `prefix-icon` | `string` | `undefined` | Leading `lof-icon` name rendered in the prefix block (preferred over the legacy `leftIcon`). The `prefixicon` attribute spelling is deprecated (still works; removal targeted for 3.0). |
116
+ | `prefixIconAriaLabel` | `prefix-icon-aria-label` | `string` | `undefined` | Accessible label for the leading icon. Without it the icon is `aria-hidden` (decorative). The `prefixiconarialabel` attribute spelling is deprecated (still works; removal targeted for 3.0). |
117
+ | `error` | `error` | `boolean` | `false` | Puts the field in the error state: danger border, `aria-invalid`, and `errorMessage` replacing the helper text. |
118
+ | `errorMessage` | `error-message` | `string` | `undefined` | Text shown below the control instead of `helperText` while the field is in the error state. The `errormessage` attribute spelling is deprecated (still works; removal targeted for 3.0). |
119
+ | `helperText` | `helper-text` | `string` | `undefined` | Helper line below the control (preferred over the legacy `supportingText`); linked to the input via `aria-describedby`. The `helpertext` attribute spelling is deprecated (still works; removal targeted for 3.0). |
120
+ | `helperIcon` | `helper-icon` | `string` | `undefined` | Icon name from the generated icon dictionary, rendered before the helper line (Figma "Supporting Icon"). Sized 16px, or 14px at `size="small"`, and it takes the helper's colour — so it turns `--lof-text-danger` in the error state. Decorative: it is hidden from screen readers, since the helper text it sits beside is already announced. |
121
+ | `readonly` | `readonly` | `boolean` | `false` | Makes the input read-only: focusable and selectable but not editable. |
122
+ | `maxLength` | `maxlength` | `number` | `undefined` | Maximum number of characters (native `maxlength`). |
123
+ | `name` | `name` | `string` | `undefined` | Form field name forwarded to the native input, for form submission and autofill. |
124
+ | `fullWidth` | `full-width` | `boolean` | `true` | Fills the parent width as a block element (default). Unset it to render inline at the content's natural width. Reflected (as `fullwidth` in 1.x). The `fullwidth` attribute spelling is deprecated (still works; removal targeted for 3.0). |
125
+
126
+ #### Deprecated (still supported — removal targeted for 3.0)
127
+
128
+ | Property | Attribute | Type | Use instead |
129
+ | --- | --- | --- | --- |
130
+ | `floatingLabel` | `floatinglabel` | `boolean` | Use `labelStyle="floating"`. Kept permanently as an alias. |
131
+
132
+ ### Methods
133
+
134
+ | Method | Signature | Description |
135
+ | --- | --- | --- |
136
+ | `focus` | `focus(options?: FocusOptions)` | Focuses the inner input/textarea (the host itself is not focusable). |
137
+
138
+ ## Events
139
+
140
+ | Event | Detail | Bubbles / composed | Description |
141
+ | --- | --- | --- | --- |
142
+ | `lof-change` | `value` | bubbles / composed | Fired on every keystroke. Detail: the current text (`value`). |
143
+ | `lof-right-icon-click` | — | bubbles / composed | Fired when the trailing icon is clicked or activated with Enter / Space while `clickableRightIcon` is set. No detail. |
144
+
145
+ ## Slots
146
+
147
+ | Slot | Description |
148
+ | --- | --- |
149
+ | `prefix` | Custom content at the far left of the control (e.g. a unit dropdown); shares the prefix block with `prefixIcon` / `prefixText`. Hidden when `multiline` is set. |
150
+ | `suffix` | Custom content at the far right of the control (e.g. an action button); shares the suffix block with `rightIcon` / `suffixText`. Hidden when `multiline` is set. |
151
+
152
+ ## CSS Parts
153
+
154
+ | Part | Description |
155
+ | --- | --- |
156
+ | `label` | The visible label element (default and floating label styles) |
157
+ | `input` | The native input / textarea |
158
+ | `right-icon` | The trailing `lof-icon` |
159
+ | `prefix` | The prefix block (leading icon, prefix text and the `prefix` slot) |
160
+ | `suffix` | The suffix block (suffix text, trailing icon and the `suffix` slot) |
161
+ | `helper` | The helper / error text line below the control |
162
+ | `helper-icon` | The leading `lof-icon` in the helper line; rendered only when `helper-icon` is set and there is helper text |
163
+ | `control` | The bordered control box. **Changed in 1.4.9:** in `variant="legend"` this is now the same `div` as every other variant, not the `fieldset` — the fieldset was demoted to a decorative outline layer behind the content so the control sits on the 32/40/48 size ladder and centres its value like the other variants. `::part(control)` still matches; only rules that depended on it being a fieldset do not. |
164
+
165
+ ## Tokens / CSS Variables
166
+
167
+ ### Component hooks
168
+
169
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
170
+
171
+ | Custom property | Default | Description |
172
+ | --- | --- | --- |
173
+ | `--lof-field-label-reserve` | `calc(var(--lof-body-field-label-line-height) + var(--lof-spacing-2xs))` | Height held for the label row whenever no label renders above the control — `labelStyle="none"`, and `labelStyle="floating"` where the label sits inside the control — so the control still lines up with labelled siblings in a form row. Defaults to that size's label line-height plus the wrapper gap (24px at `small`, 26px at `medium` and `large`). Set to `0` to collapse the row entirely (toolbars, table cells). |
174
+ | `--lof-textfield-surface` | `var(--lof-bg-neutral)` | Colour of the strip the floating label lays over the control's top border and focus ring so the label appears to sit in a notch. It overshoots the band by 2px on the page side, so it must match the surface the field sits on; defaults to the control's own fill (`--lof-bg-neutral`). Set it on a tinted or elevated surface, otherwise the strip shows as a light dash across the border. |
175
+
176
+ <!-- readme-gen:end -->
177
+
178
+ ## Accessibility
179
+
180
+ - The visible `<label>` is linked to the native input via `for`/`id` (the host `id`, or a generated one). In the `legend` variant the input is instead named through `aria-labelledby` pointing at the `<legend>`.
181
+ - With `label-style="none"` no label renders: `field-aria-labelledby` (wins) or `field-aria-label` must supply the accessible name. The component logs a console warning once when neither is set, because a placeholder is not a valid naming mechanism.
182
+ - The input carries `aria-required`, `aria-invalid` (true in the error state) and `aria-describedby` pointing at the helper line. That line is always rendered with `aria-live="polite"`, so a change from helper text to `errorMessage` is announced.
183
+ - The leading icon is `aria-hidden` unless `prefixIconAriaLabel` is set, in which case it becomes `role="img"` with that label. The trailing icon is `aria-hidden` unless `clickable-right-icon` is set, in which case it is `role="button"`, `tabindex="0"` and named by `right-icon-aria-label`.
184
+ - No screen-reader announcements are made via `announce()`; the live helper region is the only announcement path.
185
+
186
+ | Key | Action |
187
+ |-----|--------|
188
+ | `Tab` | Focus the input; with `clickable-right-icon` the trailing icon is the next Tab stop |
189
+ | `Enter` / `Space` (on the trailing icon) | Fires `lof-right-icon-click` (default prevented) |
190
+
191
+ Focus behaviour: `focus()` on the host focuses the inner input / textarea (the host itself is not focusable). A mousedown anywhere on the control — border, legend notch, prefix / suffix padding — focuses the input like clicking a label would; presses on the input, a clickable icon or slotted content keep their native behaviour. The focused control shows a `--lof-border-strong` border plus a 1px ring; the `legend` variant recolours the border and legend only (a ring would strike through the notch).
192
+
193
+ ## Notes / Edge Cases
194
+
195
+ - Attribute spellings: every multi-word attribute is kebab-case (`label-style`, `prefix-text`, `prefix-icon`, `left-icon`, `right-icon`, `prefix-icon-aria-label`, `helper-text`, `error-message`, `full-width`, …), the same spelling `lof-autocomplete` and `lof-select` use — see the Attribute column above. The older all-lowercase spellings still work since 1.5.0 but log a one-time console notice and are removed in 3.0 (see Deprecated aliases); when both spellings are present the kebab one wins. `maxlength` keeps the native HTML spelling, and the deprecated `supportingText` / `floatingLabel` props keep their old attributes. In a Lit template a property binding (`.prefixIcon=${…}`) sidesteps spelling entirely.
196
+ - Legacy names still work but the canonical ones win when both are set: `leftIcon` → `prefixIcon`, `supportingText` → `helperText`, `state="error"` → `error`, `state="disabled"` → `disabled`.
197
+ - `errorMessage` replaces the helper line only while the field is in the error state **and** the message is set; otherwise the helper text stays visible. There is no built-in validation — set `error` from your form layer.
198
+ - `state="error"` (legacy) auto-clears to `"default"` as soon as the user types a non-empty value and comes back once the value is emptied again; the `error` boolean never auto-clears.
199
+ - `multiline` renders a `<textarea>` (`rows`, vertical resize, 80px minimum height). `type`, the prefix / suffix blocks and their slots are ignored in this mode (the slots stay mounted but hidden).
200
+ - `fullWidth` defaults to `true`; without it the host becomes `inline-block` at its content width. Turn it off with `full-width="false"` (since 1.5.0) or the property (`.fullWidth=${false}`). In 1.x it still reflects as the `fullwidth` attribute, so `lof-textfield[fullwidth]` selectors keep matching.
201
+ - `label-style="floating"`: the placeholder is hidden until the field is focused; the label floats onto the border when focused or filled. Internally the deprecated `floatingLabel` boolean is kept in sync with `labelStyle` and its reflected `floatinglabel` attribute is the styling hook, so both spellings render identically. With a `prefix-style="clear"` prefix the floated label slides back over the control's left edge (Figma "Floating Label"); `divider` / `fill` prefixes keep it after the block.
202
+ - `variant="legend"` + `label-style="none"` drops the `<legend>` entirely so the top border runs continuous; a `fill` prefix is squared off in this variant because it cannot reach the notched top border.
203
+ - `--lof-field-label-reserve` (see Component hooks) keeps a `label-style="none"` field bottom-aligned with labelled siblings; set it to `0` in toolbars or table cells.
204
+ - Inside the prefix block the order is slotted content → icon → text (nearest the input); in the suffix block it is text → icon → slotted content. Clicking a non-interactive part of either block focuses the input.
205
+ - The control height (28 / 34 / 40px) is explicit so the field lines up with `lof-select` and the date / time / range picker triggers; the textarea keeps the padding model and grows with `rows`.
206
+ - In Figma, the `error` state's border has no focus ring; that matches the code (`box-shadow: none` in error).