@lofid/web 0.0.0-stage → 1.0.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 (55) hide show
  1. package/README.md +85 -2
  2. package/custom-elements.json +11166 -0
  3. package/dist/index.d.ts +2784 -0
  4. package/dist/index.js +18710 -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/vars.css +870 -0
  10. package/package.json +44 -4
  11. package/readmes/lof-accordion/README.md +140 -0
  12. package/readmes/lof-alert/README.md +142 -0
  13. package/readmes/lof-autocomplete/README.md +209 -0
  14. package/readmes/lof-avatar/README.md +228 -0
  15. package/readmes/lof-badge/README.md +102 -0
  16. package/readmes/lof-breadcrumb/README.md +97 -0
  17. package/readmes/lof-button/README.md +190 -0
  18. package/readmes/lof-calendar/README.md +111 -0
  19. package/readmes/lof-card/README.md +75 -0
  20. package/readmes/lof-cardmedia/README.md +100 -0
  21. package/readmes/lof-carousel/README.md +187 -0
  22. package/readmes/lof-checkbox/README.md +159 -0
  23. package/readmes/lof-chip/README.md +141 -0
  24. package/readmes/lof-container/README.md +107 -0
  25. package/readmes/lof-date-picker/README.md +221 -0
  26. package/readmes/lof-divider/README.md +88 -0
  27. package/readmes/lof-drawer/README.md +188 -0
  28. package/readmes/lof-kbd/README.md +188 -0
  29. package/readmes/lof-layout/README.md +122 -0
  30. package/readmes/lof-menu/README.md +187 -0
  31. package/readmes/lof-menubar/README.md +218 -0
  32. package/readmes/lof-otp/README.md +167 -0
  33. package/readmes/lof-pagination/README.md +141 -0
  34. package/readmes/lof-popover/README.md +220 -0
  35. package/readmes/lof-progress/README.md +88 -0
  36. package/readmes/lof-radio/README.md +142 -0
  37. package/readmes/lof-range-picker/README.md +194 -0
  38. package/readmes/lof-resizable/README.md +220 -0
  39. package/readmes/lof-segmented-button/README.md +158 -0
  40. package/readmes/lof-select/README.md +193 -0
  41. package/readmes/lof-sheet/README.md +170 -0
  42. package/readmes/lof-signature-pad/README.md +161 -0
  43. package/readmes/lof-skeleton/README.md +104 -0
  44. package/readmes/lof-slider/README.md +140 -0
  45. package/readmes/lof-snackbar/README.md +170 -0
  46. package/readmes/lof-split-button/README.md +129 -0
  47. package/readmes/lof-stepper/README.md +171 -0
  48. package/readmes/lof-switch/README.md +122 -0
  49. package/readmes/lof-tab/README.md +184 -0
  50. package/readmes/lof-textfield/README.md +206 -0
  51. package/readmes/lof-time-picker/README.md +188 -0
  52. package/readmes/lof-toast/README.md +174 -0
  53. package/readmes/lof-tooltip/README.md +120 -0
  54. package/readmes/lof-tree/README.md +157 -0
  55. package/readmes/lof-upload/README.md +223 -0
@@ -0,0 +1,104 @@
1
+ # lof-skeleton
2
+
3
+ Loading placeholder that reserves the space of content still being fetched: a neutral `block`, a `circle` (avatars, icons) or a stack of text `line` bars, animated with a `pulse` or `shimmer` until you set `loaded`, at which point it hides itself. Use it when you know the shape of the incoming content (cards, list rows, avatars); use a spinner for indeterminate waits with no layout to preserve.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Block (default): fills its container, height set explicitly -->
9
+ <lof-skeleton height="160px"></lof-skeleton>
10
+
11
+ <!-- Circle: only a width is needed, the aspect ratio keeps it round -->
12
+ <lof-skeleton shape="circle" width="48px"></lof-skeleton>
13
+
14
+ <!-- Paragraph: three text bars, the last one shorter -->
15
+ <lof-skeleton shape="line" lines="3"></lof-skeleton>
16
+
17
+ <!-- Animation variants -->
18
+ <lof-skeleton shape="line" lines="2" animation="shimmer"></lof-skeleton>
19
+ <lof-skeleton shape="block" height="80px" animation="none"></lof-skeleton>
20
+
21
+ <!-- Custom colours -->
22
+ <lof-skeleton
23
+ shape="block"
24
+ height="120px"
25
+ animation="shimmer"
26
+ style="--lof-skeleton-color: #e5e7eb; --lof-skeleton-highlight: #f9fafb;"
27
+ ></lof-skeleton>
28
+
29
+ <!-- A list-row placeholder that swaps for real content -->
30
+ <div style="display: flex; gap: 12px; align-items: center;">
31
+ <lof-skeleton id="avatar" shape="circle" width="40px"></lof-skeleton>
32
+ <div style="flex: 1;">
33
+ <lof-skeleton id="text" shape="line" lines="2"></lof-skeleton>
34
+ </div>
35
+ </div>
36
+ <script>
37
+ fetchUser().then(() => {
38
+ document.getElementById('avatar').loaded = true;
39
+ document.getElementById('text').loaded = true;
40
+ });
41
+ </script>
42
+ ```
43
+
44
+ <!-- readme-gen:start -->
45
+
46
+ <!-- Generated from lof-skeleton.ts — do not edit; run readme-generate.mjs -->
47
+
48
+ ## API
49
+
50
+ ### Attributes / Properties
51
+
52
+ | Property | Attribute | Type | Default | Description |
53
+ | --- | --- | --- | --- | --- |
54
+ | `shape` | `shape` | `"line" \| "circle" \| "block"` | `"block"` | Placeholder shape: `block` fills the host (min 16px tall), `circle` is a square-aspect disc sized by the host width, `line` renders `lines` 16px text bars with the last one at 65% width. Reflected. |
55
+ | `lines` | `lines` | `number` | `1` | Number of text bars when `shape="line"` (minimum 1, --lof-spacing-xs apart); ignored by the other shapes. |
56
+ | `width` | `width` | `string` | `""` | Any CSS width (e.g. `"240px"`, `"50%"`) applied to the host's inline style. Empty leaves the host at its natural block width. |
57
+ | `height` | `height` | `string` | `""` | Any CSS height (e.g. `"120px"`) applied to the host's inline style. Not needed for `circle`, which derives its height from the width. |
58
+ | `animation` | `animation` | `"pulse" \| "shimmer" \| "none"` | `"pulse"` | Motion: `pulse` fades opacity between 20% and 40% (Figma's Start/End states), `shimmer` sweeps a highlight band left to right, `none` is static. Both animations are disabled under `prefers-reduced-motion: reduce`. Reflected. |
59
+ | `loaded` | `loaded` | `boolean` | `false` | Set once the real content is ready: hides the skeleton (`display: none`) and removes its `role="status"` / "Loading" label. Reflected. |
60
+
61
+ ## Events
62
+
63
+ | Event | Detail | Bubbles / composed | Description |
64
+ | --- | --- | --- | --- |
65
+ | — | — | — | This element emits no custom events. |
66
+
67
+ ## Slots
68
+
69
+ | Slot | Description |
70
+ | --- | --- |
71
+ | — | This element has no slots. |
72
+
73
+ ## CSS Parts
74
+
75
+ | Part | Description |
76
+ | --- | --- |
77
+ | `base` | Each placeholder surface: the single block/circle, or every bar when `shape="line"`. |
78
+
79
+ ## Tokens / CSS Variables
80
+
81
+ ### Component hooks
82
+
83
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
84
+
85
+ | Custom property | Default | Description |
86
+ | --- | --- | --- |
87
+ | `--lof-skeleton-color` | `var(--lof-bg-neutral-elevated-3)` | Fill colour of the placeholder (defaults to the elevated-3 neutral background token). |
88
+ | `--lof-skeleton-highlight` | `var(--lof-bg-neutral-elevated-2)` | Lighter band that sweeps across the placeholder when `animation="shimmer"` (defaults to the elevated-2 neutral background token). |
89
+ | `--lof-skeleton-line-height` | `16px` | Height of each text bar when `shape="line"`; default 16px (Figma's Line shape). |
90
+
91
+ <!-- readme-gen:end -->
92
+
93
+ ## Accessibility
94
+
95
+ - While not `loaded`, the host carries `role="status"` and `aria-label="Loading"`, so assistive technology announces that the region is loading; both are removed once `loaded` is set (the attributes are managed on each update, so they appear after the first render).
96
+ - The placeholder is not focusable and has no keyboard interaction.
97
+ - Under `prefers-reduced-motion: reduce` both `pulse` and `shimmer` are disabled and the placeholder renders static.
98
+
99
+ ## Notes / Edge Cases
100
+
101
+ - **Sizing.** `width` / `height` are written to the host's inline `style` and accept any CSS length. A `block` with no `height` is 16px tall (its `min-height`); a `circle` needs only a width (`aspect-ratio: 1 / 1`); `line` bars are 16px tall, `--lof-spacing-xs` apart, full width, with the last bar at 65% when there is more than one.
102
+ - **`loaded` hides, it does not remove.** The host switches to `display: none` and stays in the DOM; place the real content as a sibling rather than inside the skeleton (the element has no slot).
103
+ - **Multiple `base` parts.** With `shape="line"` every bar carries `part="base"`, so `::part(base)` styles all of them.
104
+ - **Shimmer overrides the fill.** In `shimmer` mode the background becomes a gradient built from `--lof-skeleton-color` and `--lof-skeleton-highlight`; set both when customising colours.
@@ -0,0 +1,140 @@
1
+ # lof-slider
2
+
3
+ `<lof-slider>` implements the Figma **Slider** component (6417:1340): a pill-shaped track with a stroked round thumb, an optional value tooltip, discrete tick marks with labels, a dotted track style and a dual-thumb `range` mode. It is built on native `<input type="range">` elements, so keyboard and assistive-technology behaviour come from the browser. Use it when a user picks a value or an interval from a bounded numeric range and the relative position matters more than exact digits (volume, opacity, price band); for precise numeric entry use `<lof-textfield>`, and for a handful of named options use `<lof-radio>` or `<lof-tab>`.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Continuous slider -->
9
+ <lof-slider value="40" min="0" max="100" field-aria-label="Volume"></lof-slider>
10
+
11
+ <!-- Discrete slider: snaps to step, shows tick marks and tick labels -->
12
+ <lof-slider type="discrete" value="3" min="1" max="5" step="1" show-tick-labels field-aria-label="Rating"></lof-slider>
13
+
14
+ <!-- Range slider: two thumbs bounding value…value-end -->
15
+ <lof-slider type="range" value="20" value-end="80" min="0" max="100" field-aria-label="Price"></lof-slider>
16
+
17
+ <!-- Sizes (Figma S / M / L) -->
18
+ <lof-slider size="sm" value="30"></lof-slider>
19
+ <lof-slider size="md" value="50"></lof-slider>
20
+ <lof-slider size="lg" value="70"></lof-slider>
21
+
22
+ <!-- Dotted fill, no tooltip -->
23
+ <lof-slider id="opacity" track="dotted" value="60"></lof-slider>
24
+ <script>
25
+ // showBubble defaults to true; an absent attribute keeps the default, so switch it off from JS.
26
+ document.getElementById('opacity').showBubble = false;
27
+ </script>
28
+
29
+ <!-- Disabled -->
30
+ <lof-slider value="30" disabled></lof-slider>
31
+
32
+ <!-- Listening for changes -->
33
+ <lof-slider id="budget" type="range" value="10" value-end="90"></lof-slider>
34
+ <script>
35
+ document.getElementById('budget').addEventListener('lof-change', (e) => {
36
+ console.log(e.detail.value, e.detail.valueEnd); // valueEnd only in range mode
37
+ });
38
+ </script>
39
+ ```
40
+
41
+ ### Deprecated aliases
42
+
43
+ ```html
44
+ <!-- showticklabels / showbubble → show-tick-labels / show-bubble (since 1.5.0; still work, log a one-time
45
+ console notice, removed in 3.0). showTickLabels still reflects as showticklabels in 1.x. -->
46
+ <lof-slider type="discrete" min="1" max="5" step="1" showticklabels showbubble="false"></lof-slider>
47
+ <lof-slider type="discrete" min="1" max="5" step="1" show-tick-labels show-bubble="false"></lof-slider>
48
+ ```
49
+
50
+ <!-- readme-gen:start -->
51
+
52
+ <!-- Generated from lof-slider.ts — do not edit; run readme-generate.mjs -->
53
+
54
+ ## API
55
+
56
+ ### Attributes / Properties
57
+
58
+ | Property | Attribute | Type | Default | Description |
59
+ | --- | --- | --- | --- | --- |
60
+ | `type` | `type` | `"continuous" \| "discrete" \| "default" \| "range"` | `"continuous"` | Slider mode: `continuous` (or its alias `default`) accepts any integer value, `discrete` snaps to `step` and draws tick marks, `range` shows two thumbs bounding `value`…`valueEnd`. Reflected. |
61
+ | `showTicks` | `show-ticks` | `boolean` | `undefined` | Draws the tick marks (Figma's separate `Is Determinated` boolean). Works with ANY `type` — Figma shows ticks on every variant, where the code used to gate them behind the code-only `type="discrete"`, so a `default` or `range` slider could never show them. Left unset it follows `type="discrete"`, so nothing changes for existing sliders; set it explicitly to override in either direction. Reflected. |
62
+ | `size` | `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | `"medium"` | Figma Size axis: `small` (6px track / 16px thumb), `medium` (8 / 20, default) or `large` (10 / 24), which also scales the ticks and the value bubble. `sm` / `md` / `lg` are alternative spellings and stay supported — they are normalised to the full words, not deprecated. Reflected. |
63
+ | `min` | `min` | `number` | `0` | Lowest selectable value. |
64
+ | `max` | `max` | `number` | `100` | Highest selectable value. |
65
+ | `step` | `step` | `number` | `1` | Increment between values. In `discrete` mode it also spaces the tick marks; in `continuous` mode the native input always moves in steps of 1. |
66
+ | `disabled` | `disabled` | `boolean` | `false` | Disables interaction and dims the track, thumb and ticks; the tooltip is hidden. |
67
+ | `track` | `track` | `"solid" \| "dotted"` | `"solid"` | Style of the filled part of the track: `solid` or a `dotted` pattern. |
68
+ | `showTickLabels` | `show-tick-labels` | `boolean` | `false` | Print the numeric value under every tick mark. Only has an effect in `discrete` mode. Reflected (as `showticklabels` in 1.x). The `showticklabels` attribute spelling is deprecated (still works; removal targeted for 3.0). |
69
+ | `showBubble` | `show-bubble` | `boolean` | `true` | Show the value tooltip above the thumb(s). The `showbubble` attribute spelling is deprecated (still works; removal targeted for 3.0). |
70
+ | `value` | `value` | `number` | `0` | Current value (the lower value in `range` mode). |
71
+ | `valueEnd` | `value-end` | `number` | `100` | Upper value when type="range" (attribute value-end). |
72
+ | `fieldAriaLabel` | `field-aria-label` | `string` | `undefined` | Accessible name for the native range input. In `range` mode it is suffixed with " minimum" / " maximum" per thumb; without it the two thumbs read "Minimum value" / "Maximum value" and a single slider has no name. |
73
+
74
+ ## Events
75
+
76
+ | Event | Detail | Bubbles / composed | Description |
77
+ | --- | --- | --- | --- |
78
+ | `lof-change` | `{ value: this.value, valueEnd: this.valueEnd } / { value: this.value }` | bubbles / composed | Fired on every user change of the value. Detail: `{ value }` for single-thumb sliders, `{ value, valueEnd }` in `range` mode. |
79
+
80
+ ## Slots
81
+
82
+ | Slot | Description |
83
+ | --- | --- |
84
+ | — | This element has no slots. |
85
+
86
+ ## CSS Parts
87
+
88
+ | Part | Description |
89
+ | --- | --- |
90
+ | `tooltip` | The value bubble + chevron above each thumb (only while `showBubble` is on) |
91
+ | `thumb` | The round grab handle (one per thumb in range mode) |
92
+ | `track` | The rail behind the thumb (the filled portion has no part) |
93
+
94
+ ## Tokens / CSS Variables
95
+
96
+ ### Component hooks
97
+
98
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
99
+
100
+ | Custom property | Default | Description |
101
+ | --- | --- | --- |
102
+ | `--lof-slider-bubble-radius` | `var(--bubble-radius)` | Corner radius of the value bubble; 8px for size sm, otherwise 10px |
103
+ | `--lof-slider-thumb-halo-color` | `var(--thumb-halo-color)` | Colour of the keyboard-focus ring; default `var(--lof-border-default)` |
104
+ | `--lof-slider-thumb-size` | `var(--thumb-size)` | Thumb diameter; 16 / 20 / 24px for size sm / md / lg |
105
+ | `--lof-slider-thumb-stroke` | `var(--thumb-stroke)` | Width of the hover / pressed / focus ring around the thumb; default 6px |
106
+ | `--lof-slider-tick-size` | `var(--tick-size)` | Tick-mark diameter in discrete mode; 4 / 5 / 6px for size sm / md / lg |
107
+ | `--lof-slider-track-height` | `var(--track-height)` | Rail thickness; 6 / 8 / 10px for size sm / md / lg |
108
+
109
+ <!-- readme-gen:end -->
110
+
111
+ ## Accessibility
112
+
113
+ - Each thumb is a native `<input type="range">`; the custom track, thumb and tooltip are decorative (`pointer-events: none`) and the tooltip is `aria-hidden="true"`.
114
+ - `field-aria-label` becomes the input's `aria-label`. In `range` mode the two inputs are named `"<label> minimum"` / `"<label> maximum"`; without a label they fall back to `"Minimum value"` / `"Maximum value"`. A single-thumb slider without `field-aria-label` has no accessible name, so always set one (or label it from the surrounding form).
115
+ - `min`, `max` and `step` are forwarded to the native input, so screen readers announce the current value and the range. In `continuous` mode the native step is always 1 regardless of `step`.
116
+ - The keyboard-focus ring is drawn on the custom thumb via `:focus-visible` (`--lof-slider-thumb-halo-color`); mouse focus shows no ring.
117
+ - `disabled` disables the native inputs (removed from the tab order) and hides the tooltip.
118
+ - In `range` mode pointer input is handled by the container so either thumb can be grabbed (the nearer thumb wins); keyboard input still goes through the two native inputs.
119
+ - `prefers-reduced-motion: reduce` removes the thumb and tick transitions.
120
+
121
+ Keys come from the native range input:
122
+
123
+ | Key | Action |
124
+ | --- | --- |
125
+ | `ArrowRight` / `ArrowUp` | Increase by one step (`step` in `discrete` mode, 1 otherwise). |
126
+ | `ArrowLeft` / `ArrowDown` | Decrease by one step. |
127
+ | `Home` | Jump to `min`. |
128
+ | `End` | Jump to `max`. |
129
+ | `PageUp` / `PageDown` | Larger jump (browser-defined). |
130
+
131
+ ## Notes / Edge Cases
132
+
133
+ - `type="default"` is an alias of `continuous` (Figma's Type axis). Only `discrete` draws ticks and snaps to `step`; `continuous` sliders move in integer steps whatever `step` says.
134
+ - Ticks are generated from `min` to `max` in `step` increments; if the range does not divide evenly a final tick is added at `max`. `show-tick-labels` only has an effect in `discrete` mode.
135
+ - In `range` mode the thumbs cannot cross: `value` is clamped to `≤ value-end` and `value-end` to `≥ value`. The default `value-end` is 100.
136
+ - `lof-change` fires for user interaction only; setting `value` / `valueEnd` programmatically updates the visuals but emits nothing.
137
+ - The element is `display: block`. Its rail (the pointer target) is at least 24px tall at every size (since 1.5.0, so Small and Medium grow from 16 / 20px to 24px); the track and thumb keep their 6/16, 8/20 and 10/24px sizes. The value bubble overflows above the rail and is not reserved; tick labels reserve their own space below it.
138
+ - Size presets set the track/thumb/tick/bubble dimensions per `size`; a `--lof-slider-*` hook set on the host overrides the preset for every size.
139
+ - Legacy hook aliases still honoured: `--track-height`, `--thumb-size`, `--thumb-stroke`, `--thumb-halo-color`, `--tick-size` and `--bubble-radius` are read as fallbacks of the `--lof-slider-*` hooks.
140
+ - `registerOnChange`, `registerOnTouched` and `writeValue` exist for the Angular `ControlValueAccessor` wrapper and are not public API.
@@ -0,0 +1,170 @@
1
+ # lof-snackbar
2
+
3
+ `<lof-snackbar>` is the snackbar of the Lofid Design System (Figma "Snackbar"): a dark, elevated message bar with a 4px tone accent and leading status icon for the success / warning / destructive tones, an optional action button and a close icon, in single-line and double-line (Figma Type=Longer Action) layouts. It is shown by setting `show` and hides itself after `duration` milliseconds. Unlike `<lof-toast>` it is **not** positioned — it is a `display: block` element you place yourself (in-flow, or fixed via your own CSS). Use it for brief feedback with one follow-up action ("Undo", "Retry"); use `<lof-alert>` for messages that must stay on the page.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Hidden until `show` is set -->
9
+ <lof-snackbar id="uploaded" message="File uploaded"></lof-snackbar>
10
+
11
+ <!-- Initially visible; neutral tone (no accent, no icon), auto-hides after 4000 ms -->
12
+ <lof-snackbar show message="Settings saved"></lof-snackbar>
13
+
14
+ <!-- Status tones: left accent + leading icon -->
15
+ <lof-snackbar show tone="success" message="Invitation sent"></lof-snackbar>
16
+ <lof-snackbar show tone="warning" message="Connection is unstable"></lof-snackbar>
17
+ <lof-snackbar show tone="destructive" message="Payment failed"></lof-snackbar>
18
+
19
+ <!-- Action button -->
20
+ <lof-snackbar id="deleted" message="Item deleted" action="Undo"></lof-snackbar>
21
+
22
+ <!-- Double-line layout with a longer (2 × duration) dismiss delay -->
23
+ <lof-snackbar
24
+ id="archived"
25
+ message="12 conversations were archived and will be deleted in 30 days"
26
+ action="Undo"
27
+ variant="longer-action"
28
+ ></lof-snackbar>
29
+
30
+ <!-- Persistent, without the close icon ("false" switches a default-true boolean off, since 1.5.0) -->
31
+ <lof-snackbar id="busy" message="Processing…" duration="0" icon-close="false"></lof-snackbar>
32
+ ```
33
+
34
+ ```js
35
+ const uploaded = document.getElementById("uploaded");
36
+ uploaded.show = true; // starts the auto-dismiss timer and announces the message
37
+ uploaded.addEventListener("close", () => {
38
+ uploaded.show; // false — fired by the close icon, the action button and the timer
39
+ });
40
+
41
+ const deleted = document.getElementById("deleted");
42
+ deleted.addEventListener("actionClick", () => {
43
+ // undo the deletion… the snackbar dismisses itself right after (a `close` event follows)
44
+ });
45
+ deleted.show = true;
46
+
47
+ const busy = document.getElementById("busy");
48
+ busy.show = true;
49
+ busy.show = false; // hides silently — no `close` event when hidden from script
50
+ ```
51
+
52
+ ```css
53
+ /* The component is display: block; position it yourself */
54
+ lof-snackbar {
55
+ position: fixed;
56
+ bottom: 24px;
57
+ left: 50%;
58
+ transform: translateX(-50%);
59
+ }
60
+ ```
61
+
62
+ ### Deprecated aliases
63
+
64
+ ```html
65
+ <!-- type= is the deprecated alias of tone= (tone wins when both are set). Logs once per page:
66
+ [lof-snackbar] "type" is deprecated and will be removed in 3.0 — use "tone" instead. Note: tone="destructive" replaces type="error"; tone="neutral" replaces type="default". -->
67
+ <lof-snackbar type="error" message="Payment failed"></lof-snackbar>
68
+ <lof-snackbar type="default" message="Settings saved"></lof-snackbar>
69
+
70
+ <!-- tone="default" is the deprecated spelling of tone="neutral". Logs once:
71
+ [lof-snackbar] "tone="default"" is deprecated and will be removed in 3.0 — use "tone="neutral"" instead. -->
72
+ <lof-snackbar tone="default" message="Settings saved"></lof-snackbar>
73
+
74
+ <!-- tone="error" | "danger" | "critical" are deprecated spellings of tone="destructive". Logs once per spelling:
75
+ [lof-snackbar] "tone="error"" is deprecated and will be removed in 3.0 — use "tone="destructive"" instead. -->
76
+ <lof-snackbar tone="error" message="Payment failed"></lof-snackbar>
77
+ <lof-snackbar tone="critical" message="Payment failed"></lof-snackbar>
78
+
79
+ <!-- lines="double" and longeraction (lower-case attribute) are deprecated spellings of
80
+ variant="longer-action". Either one alone renders the full longer-action variant: stacked
81
+ layout and the doubled auto-dismiss delay. Ignored when variant is set; each logs once. -->
82
+ <lof-snackbar message="Older markup" action="Undo" lines="double"></lof-snackbar>
83
+ <lof-snackbar message="Older markup" action="Undo" longeraction></lof-snackbar>
84
+
85
+ <!-- iconclose → icon-close (since 1.5.0; still works, logs a one-time console notice, removed in 3.0) -->
86
+ <lof-snackbar message="Processing…" duration="0" iconclose="false"></lof-snackbar>
87
+ <lof-snackbar message="Processing…" duration="0" icon-close="false"></lof-snackbar>
88
+ ```
89
+
90
+ <!-- readme-gen:start -->
91
+
92
+ <!-- Generated from lof-snackbar.ts — do not edit; run readme-generate.mjs -->
93
+
94
+ ## API
95
+
96
+ ### Attributes / Properties
97
+
98
+ | Property | Attribute | Type | Default | Description |
99
+ | --- | --- | --- | --- | --- |
100
+ | `message` | `message` | `string` | `"This is a snackbar message"` | Message text. Announced to screen readers through the shared live-region announcer when the snackbar is shown and whenever it changes while shown. The default is a placeholder — always set it. |
101
+ | `action` | `action` | `string` | `undefined` | Label of the optional action button (Figma trailing button, Static / Small); omitted when unset. Clicking it fires `actionClick` and then dismisses the snackbar. |
102
+ | `variant` | `variant` | `"default" \| "longer-action"` | `undefined` | Layout and timing (Figma "Type"): `"default"` (the default: message and actions on one row) \| `"longer-action"` (message stacked above the actions, which align to the end, with the auto-dismiss delay doubled so there is time to use the action). Takes precedence over the deprecated `lines` and `longerAction` props. |
103
+ | `iconClose` | `icon-close` | `boolean` | `true` | Shows the trailing close icon button. Defaults to true; `icon-close="false"` (or the property set to `false`) hides the button. The `iconclose` attribute spelling is deprecated (still works; removal targeted for 3.0). |
104
+ | `duration` | `duration` | `number` | `4000` | Auto-dismiss delay in milliseconds (doubled by `variant="longer-action"`), started when `show` becomes true and restarted when `duration` or the layout changes while shown. `0` (or a negative value) disables auto-dismiss. |
105
+ | `tone` | `tone` | `"neutral" \| "success" \| "warning" \| "destructive" \| "default" \| "error" \| "danger" \| "critical"` | `undefined` | Semantic tone (Figma "Tone"): `"neutral"` (default: no accent, no icon) \| `"success"` \| `"warning"` \| `"destructive"` — the status tones add a 4px left accent and a leading icon (check-circle / warning / error) in the tone colour. `"default"` is a deprecated alias of `"neutral"`; `"error"`, `"danger"` and `"critical"` are deprecated aliases of `"destructive"`; each logs a one-time console notice. Takes precedence over the deprecated `type` prop. |
106
+ | `show` | `show` | `boolean` | `false` | Whether the snackbar is visible. Set it to true to show the snackbar and start the auto-dismiss timer; it is set back to false by the close icon, the action button and the timer. There is no open/close method — toggle this property. Reflected. |
107
+
108
+ #### Deprecated (still supported — removal targeted for 3.0)
109
+
110
+ | Property | Attribute | Type | Use instead |
111
+ | --- | --- | --- | --- |
112
+ | `longerAction` | `longeraction` | `boolean` | — use `variant="longer-action"`. On its own it renders the full longer-action variant (stacked layout and the doubled auto-dismiss delay, `duration * 2`). Ignored when `variant` is set. Logs a one-time console notice. |
113
+ | `lines` | `lines` | `"single" \| "double"` | — use `variant`; `lines="double"` maps to `variant="longer-action"` (stacked layout and the doubled auto-dismiss delay). Ignored when `variant` is set. Logs a one-time console notice. |
114
+ | `type` | `type` | `"neutral" \| "success" \| "warning" \| "destructive" \| "default" \| "error" \| "danger" \| "critical"` | Deprecated since 1.4.7 — alias of `tone`; use `tone`. Same values as `tone`; `type="error"` maps to `tone="destructive"` and `type="default"` to `tone="neutral"`. Ignored when `tone` is set. Logs a one-time console notice. |
115
+
116
+ ### Public fields / accessors
117
+
118
+ | Name | Type | Description |
119
+ | --- | --- | --- |
120
+ | `resolvedVariant` | `SnackbarVariant` | Read-only canonical layout actually rendered: explicit `variant` wins, else either deprecated prop (`lines="double"` or `longerAction`) promotes to `"longer-action"`, else `"default"`. |
121
+ | `resolvedTone` | `SnackbarTone` | Read-only canonical tone actually rendered: explicit `tone` wins, else `type`, else `"neutral"`; deprecated aliases are resolved to `"neutral"` / `"destructive"`. |
122
+
123
+ ## Events
124
+
125
+ | Event | Detail | Bubbles / composed | Description |
126
+ | --- | --- | --- | --- |
127
+ | `actionClick` | — | bubbles / composed | Fired when the action button is clicked, before the snackbar dismisses itself (a `close` event follows). No detail. |
128
+ | `close` | — | bubbles / composed | Fired whenever the snackbar dismisses itself — via the close icon, the action button or the auto-dismiss timer. Not fired when `show` is set to false from script. No detail. |
129
+
130
+ ## Slots
131
+
132
+ | Slot | Description |
133
+ | --- | --- |
134
+ | — | This element has no slots. |
135
+
136
+ ## CSS Parts
137
+
138
+ | Part | Description |
139
+ | --- | --- |
140
+ | `label` | The message text container |
141
+ | `action` | The action button; rendered only when `action` is set |
142
+ | `close-button` | The close icon button; rendered while `icon-close` is true |
143
+
144
+ <!-- readme-gen:end -->
145
+
146
+ ## Accessibility
147
+
148
+ - The bar is always in the shadow DOM and hidden with `display: none` while `show` is false. Its role follows the tone: `role="alert"` for `destructive` (implicitly assertive), `role="status"` for every other tone (implicitly polite); no explicit `aria-live` is set. Because toggling `display` is not reliably announced, the component also pushes `message` into the shared off-screen live-region announcer (`utils/announce`) when `show` becomes true and whenever `message` changes while shown — assertively for `destructive`, politely otherwise. Focus is never moved.
149
+ - The leading status icon and the close glyph are `<lof-icon>`s and render `aria-hidden="true"`; the close control is a native `<button>` with `aria-label="Close"`, the action button is labelled by `action`. Both are in the Tab order; the component registers no key handlers (there is no Escape-to-close):
150
+
151
+ | Key | Action |
152
+ | --- | --- |
153
+ | Tab / Shift + Tab | Move between the action button (if any) and the close button (if any) |
154
+ | Enter / Space | Activate the focused button: action fires `actionClick` then `close`; the close button fires `close` |
155
+
156
+ - Keyboard focus on either button is a 2px `--lof-text-static-light` outline with 2px offset (`:focus-visible` only); the close button adds `--lof-border-radius-xs` corners, the action button keeps its pill radius.
157
+ - The 0.3s slide-up animation is disabled under `prefers-reduced-motion: reduce`.
158
+ - A snackbar that auto-dismisses while one of its buttons has focus drops focus to `<body>`; use `duration="0"` (or `variant="longer-action"`, which doubles the delay) when the action matters.
159
+
160
+ ## Notes / Edge Cases
161
+
162
+ - Positioning is yours: the host is `display: block` and in flow. The bar itself is `min-width: 280px; max-width: 500px`.
163
+ - The auto-dismiss timer starts when `show` becomes true and restarts whenever `duration`, `variant` or a deprecated `lines` / `longerAction` changes while visible; `variant="longer-action"` doubles the delay (`duration * 2`). `duration="0"` disables it.
164
+ - Setting `show = false` from script hides the bar **without** firing `close`; `close` fires only for the close icon, the action button and the timer. Setting `show = true` on an already visible snackbar is a no-op (the value did not change).
165
+ - `variant="longer-action"` (Figma Longer Action) stacks the message over end-aligned actions with 16px top padding and doubles the auto-dismiss delay. The deprecated `lines="double"` and `longeraction` each produce the same full variant on their own (see "Deprecated aliases"); before 1.5.0 this README said each did only half of it.
166
+ - The status icon is fixed per tone (`check-circle`, `warning`, `error`) and neutral has none; there are no slots, so the icon cannot be replaced.
167
+ - `message` defaults to the placeholder "This is a snackbar message" — a snackbar that shows that text has simply not been given a message.
168
+ - `iconClose` is a boolean: presence or `""` means true, and since 1.5.0 `icon-close="false"` means false.
169
+ - Figma binds the success / destructive icon colours to dark-surface status text values that no light-mode semantic token resolves to; the component uses the status fill tokens (`--lof-bg-success` / `--lof-bg-danger` / `--lof-bg-warning`) for both the accent and the icon instead.
170
+ - `resolvedTone` is the tone actually rendered after alias resolution; use it (not `tone` / `type`) if you branch on tone in script.
@@ -0,0 +1,129 @@
1
+ # lof-split-button
2
+
3
+ <!-- @unreleased-component 1.5.0 -->
4
+
5
+ A button with a main action and a menu of related actions, also called a combo button. It is one pill in two segments with a 1px divider between them: the main action on the left, and a chevron on the right that opens a `lof-menu` of `items`, anchored below and end-aligned. Use it when one action is the usual choice and a few close variants should stay one click away, such as "New order" with "Duplicate" and "Save as template". Use `lof-button` for a single action, and a `lof-popover` with a `lof-menu` when no action is the default.
6
+
7
+ Each segment is a native `<button>` drawn with lof-button's own styles for the chosen `variant`, `tone` and `size`. The heights (32 / 40 / 48px), padding, type, hover, pressed, focus ring and disabled look are therefore lof-button's. The outer corners keep the pill radius and the seam between the segments is square. While the menu is open, the chevron keeps its pressed look and its arrow turns up.
8
+
9
+ ## Usage
10
+
11
+ ```html
12
+ <!-- Items are set as a property; the host's click is the main action -->
13
+ <lof-split-button id="order" label="New order"></lof-split-button>
14
+ <script>
15
+ const order = document.getElementById('order');
16
+ order.items = [
17
+ { value: 'duplicate', label: 'Duplicate', icon: 'copy' },
18
+ { value: 'template', label: 'Save as template' },
19
+ { value: 'archive', label: 'Archive', disabled: true }
20
+ ];
21
+ order.addEventListener('click', () => createOrder());
22
+ order.addEventListener('lof-select', (e) => {
23
+ console.log('chose', e.detail.value);
24
+ });
25
+ </script>
26
+
27
+ <!-- Filled, in the brand colour, with a leading icon -->
28
+ <lof-split-button variant="primary" tone="brand" icon="plus" label="New order"></lof-split-button>
29
+
30
+ <!-- Small, and a custom name for the chevron -->
31
+ <lof-split-button size="small" menu-label="More export formats" label="Export CSV"></lof-split-button>
32
+
33
+ <!-- The main action is busy: a spinner only, and the chevron is disabled -->
34
+ <lof-split-button loading label="Saving"></lof-split-button>
35
+
36
+ <!-- Icon-only: the main action is a square; aria-label names it -->
37
+ <lof-split-button icon-only icon="plus" aria-label="New order"></lof-split-button>
38
+
39
+ <!-- On a dark or coloured surface -->
40
+ <lof-split-button variant="static" label="Accept job"></lof-split-button>
41
+ ```
42
+
43
+ `items` is an array, so set it as a property, or as a JSON array attribute in static HTML. In React 19 and Next.js, pass it as a prop on the client: server rendering drops arrays on custom elements.
44
+
45
+ The divider between the segments follows the variant:
46
+
47
+ - `secondary` draws the tone's outline border (`--lof-action-neutral-border-outline`, or the danger outline), which takes the outline's hover colour while the main action is hovered or pressed. The segments drop their inner borders.
48
+ - `primary` draws the segment's label colour.
49
+ - `static` draws the static label colour (white).
50
+ - `ghost` draws `--lof-border-subtle`.
51
+
52
+ The divider is its own 1px column, so the pill is the main action, plus 1px, plus the chevron. A disabled split button dims each segment and keeps the divider's colour.
53
+
54
+ <!-- readme-gen:start -->
55
+
56
+ <!-- Generated from lof-split-button.ts — do not edit; run readme-generate.mjs -->
57
+
58
+ ## API
59
+
60
+ ### Attributes / Properties
61
+
62
+ | Property | Attribute | Type | Default | Description |
63
+ | --- | --- | --- | --- | --- |
64
+ | `label` | `label` | `string` | `""` | Text of the main action. Slotted content replaces it. |
65
+ | `variant` | `variant` | `"primary" \| "secondary" \| "ghost" \| "static"` | `"secondary"` | Style of both segments, as lof-button's `variant`: `primary` (filled), `secondary` (outlined, the default), `ghost` (no fill or border) or `static` (transparent with a white label and divider, for dark or coloured surfaces; neutral only, as on lof-button). Reflected. |
66
+ | `tone` | `tone` | `"neutral" \| "brand" \| "destructive"` | `"neutral"` | Colour of both segments, as lof-button's `tone`: `neutral` (default), `brand` or `destructive`. As on lof-button, `brand` changes only the `primary` style. Reflected. |
67
+ | `size` | `size` | `"small" \| "medium" \| "large"` | `"medium"` | Height of the pill and size of its text and icons, as lof-button's `size`: `small` = 32px, `medium` = 40px (default), `large` = 48px. The menu rows take the same size. Reflected. |
68
+ | `disabled` | `disabled` | `boolean` | `false` | Dims both segments to lof-button's disabled look (the divider keeps its colour), removes them from the Tab order and keeps the menu closed. Reflected. |
69
+ | `loading` | `loading` | `boolean` | `false` | The main action shows only lof-button's spinner, at its minimum width; its text stays its accessible name (visually hidden) and it is `aria-busy`. Its clicks are blocked and the chevron is disabled, so nothing else starts mid-request; an open menu closes. Reflected. |
70
+ | `iconOnly` | `icon-only` | `boolean` | `false` | The main action is a square of the button's height (32 / 40 / 48), as lof-button's `icon-only`: give it a single icon (`icon`, or a slotted `lof-icon`) and set `aria-label`. Reflected. |
71
+ | `ariaLabel` | `aria-label` | `string \| null` | `null` | Accessible name of the main action, forwarded to its native `<button>`. Required with `icon-only`, where the main action has no visible text (a console warning names split buttons without one). |
72
+ | `menuLabel` | `menu-label` | `string` | `"More options"` | Accessible name of the chevron button (attribute `menu-label`); it has no visible text. |
73
+ | `icon` | `icon` | `string` | `""` | `lof-icon` name drawn before the main action's text (16 / 18 / 20px by size). |
74
+ | `items` | `items` | `SplitButtonItem[]` | `[]` | The menu entries, each `{ value, label, icon?, disabled? }`. Set as a property (or a JSON array attribute). |
75
+ | `open` | `open` | `boolean` | `false` | Whether the menu is open. Updated by the component (and announced with `lof-open-change`); set it to open or close the menu from code. Reflected. |
76
+
77
+ ## Events
78
+
79
+ | Event | Detail | Bubbles / composed | Description |
80
+ | --- | --- | --- | --- |
81
+ | `lof-open-change` | `{ open }` | bubbles / composed | The menu opened or closed (chevron, keyboard, Escape, an outside click, Tab away, or a choice). Detail: `{ open: boolean }`. |
82
+ | `lof-select` | `{ value, item }` | bubbles / composed | A menu entry was chosen with a click, Enter or Space; the menu has closed and focus is back on the chevron. Detail: `{ value: string, item: SplitButtonItem }`. |
83
+
84
+ ## Slots
85
+
86
+ | Slot | Description |
87
+ | --- | --- |
88
+ | (default) | The main action's content (text, or a `lof-icon` and text). Falls back to `label`. |
89
+
90
+ ## CSS Parts
91
+
92
+ | Part | Description |
93
+ | --- | --- |
94
+ | `main` | The main action's native `<button>`. |
95
+ | `indicator` | The loading spinner on the main action, rendered only while `loading` is set. |
96
+ | `toggle` | The chevron's native `<button>` (`aria-haspopup="menu"`, `aria-expanded`, named by `menu-label`). |
97
+
98
+ ## Tokens / CSS Variables
99
+
100
+ ### Component hooks
101
+
102
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
103
+
104
+ | Custom property | Default | Description |
105
+ | --- | --- | --- |
106
+ | `--lof-split-button-menu-width` | `max-content` | Width of the menu (default `max-content`). The menu is never narrower than the split button. |
107
+
108
+ <!-- readme-gen:end -->
109
+
110
+ ## Accessibility
111
+
112
+ - The main action is a native `<button>` named by its content. The chevron is a native `<button>` with `aria-haspopup="menu"`, `aria-expanded` and the accessible name from `menu-label` (default "More options").
113
+ - The menu is a `lof-menu` (`role="menu"`); its rows are `role="menuitem"`, and a disabled entry has `aria-disabled="true"`. Item icons are hidden from assistive technology.
114
+ - `loading` shows only the spinner, sets `aria-busy="true"` on the main action and keeps its text as its accessible name (visually hidden). The chevron is disabled while it loads, so it leaves the Tab order.
115
+ - With `icon-only`, the main action has no visible text: set `aria-label`, which is forwarded to its `<button>`. The element logs a console warning without one (a `label` is not drawn and does not name it).
116
+ - Each segment shows lof-button's focus ring. A mouse open shows no ring in the menu, and none on the chevron when the menu closes; the first arrow key brings the row ring back.
117
+
118
+ ### Keyboard
119
+
120
+ | Key | Action |
121
+ | --- | --- |
122
+ | Tab / Shift+Tab | Two Tab stops: the main action, then the chevron |
123
+ | Enter / Space (main action) | Runs the main action (`click`) |
124
+ | Enter / Space / Down (chevron) | Opens the menu on its first entry |
125
+ | Up (chevron) | Opens the menu on its last entry |
126
+ | Down / Up, Home / End (menu) | Moves through the entries |
127
+ | Enter / Space (menu) | Chooses the entry: fires `lof-select`, closes the menu and returns focus to the chevron |
128
+ | Escape (menu) | Closes the menu and returns focus to the chevron |
129
+ | Tab (menu) | Closes the menu and moves focus on |