@lmfaole/basics 0.4.0 → 0.5.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/LICENSE +21 -0
- package/README.md +78 -499
- package/basic-components/basic-accordion/README.md +53 -0
- package/{components → basic-components}/basic-accordion/index.js +59 -37
- package/basic-components/basic-alert/README.md +48 -0
- package/basic-components/basic-carousel/README.md +108 -0
- package/basic-components/basic-carousel/index.d.ts +73 -0
- package/basic-components/basic-carousel/index.js +255 -0
- package/basic-components/basic-carousel/register.js +3 -0
- package/basic-components/basic-dialog/README.md +57 -0
- package/basic-components/basic-popover/README.md +56 -0
- package/basic-components/basic-summary-table/README.md +93 -0
- package/basic-components/basic-table/README.md +89 -0
- package/basic-components/basic-tabs/README.md +63 -0
- package/basic-components/basic-toast/README.md +62 -0
- package/{components → basic-components}/basic-toast/index.d.ts +3 -0
- package/{components → basic-components}/basic-toast/index.js +264 -3
- package/basic-components/basic-toc/README.md +43 -0
- package/basic-components/basic-toc/register.d.ts +1 -0
- package/basic-styling/components/basic-accordion.css +38 -4
- package/basic-styling/components/basic-carousel.css +183 -0
- package/basic-styling/components/basic-popover.css +2 -4
- package/basic-styling/components/basic-summary-table.css +27 -5
- package/basic-styling/components/basic-table.css +22 -4
- package/basic-styling/components/basic-tabs.css +26 -10
- package/basic-styling/components.css +2 -0
- package/basic-styling/forms.css +55 -0
- package/basic-styling/global.css +1 -0
- package/basic-styling/interaction.css +90 -0
- package/basic-styling/tokens/palette.css +112 -0
- package/basic-styling/tokens/palette.tokens.json +768 -0
- package/index.d.ts +10 -9
- package/index.js +10 -9
- package/package.json +49 -29
- package/readme.mdx +0 -6
- /package/{components → basic-components}/basic-accordion/index.d.ts +0 -0
- /package/{components → basic-components}/basic-accordion/register.d.ts +0 -0
- /package/{components → basic-components}/basic-accordion/register.js +0 -0
- /package/{components → basic-components}/basic-alert/index.d.ts +0 -0
- /package/{components → basic-components}/basic-alert/index.js +0 -0
- /package/{components → basic-components}/basic-alert/register.d.ts +0 -0
- /package/{components → basic-components}/basic-alert/register.js +0 -0
- /package/{components/basic-dialog → basic-components/basic-carousel}/register.d.ts +0 -0
- /package/{components → basic-components}/basic-dialog/index.d.ts +0 -0
- /package/{components → basic-components}/basic-dialog/index.js +0 -0
- /package/{components/basic-popover → basic-components/basic-dialog}/register.d.ts +0 -0
- /package/{components → basic-components}/basic-dialog/register.js +0 -0
- /package/{components → basic-components}/basic-popover/index.d.ts +0 -0
- /package/{components → basic-components}/basic-popover/index.js +0 -0
- /package/{components/basic-summary-table → basic-components/basic-popover}/register.d.ts +0 -0
- /package/{components → basic-components}/basic-popover/register.js +0 -0
- /package/{components → basic-components}/basic-summary-table/index.d.ts +0 -0
- /package/{components → basic-components}/basic-summary-table/index.js +0 -0
- /package/{components/basic-table → basic-components/basic-summary-table}/register.d.ts +0 -0
- /package/{components → basic-components}/basic-summary-table/register.js +0 -0
- /package/{components → basic-components}/basic-table/index.d.ts +0 -0
- /package/{components → basic-components}/basic-table/index.js +0 -0
- /package/{components/basic-tabs → basic-components/basic-table}/register.d.ts +0 -0
- /package/{components → basic-components}/basic-table/register.js +0 -0
- /package/{components → basic-components}/basic-tabs/index.d.ts +0 -0
- /package/{components → basic-components}/basic-tabs/index.js +0 -0
- /package/{components/basic-toast → basic-components/basic-tabs}/register.d.ts +0 -0
- /package/{components → basic-components}/basic-tabs/register.js +0 -0
- /package/{components/basic-toc → basic-components/basic-toast}/register.d.ts +0 -0
- /package/{components → basic-components}/basic-toast/register.js +0 -0
- /package/{components → basic-components}/basic-toc/index.d.ts +0 -0
- /package/{components → basic-components}/basic-toc/index.js +0 -0
- /package/{components → basic-components}/basic-toc/register.js +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# `basic-dialog`
|
|
2
|
+
|
|
3
|
+
Modal dialog flow built on native `<dialog>`.
|
|
4
|
+
|
|
5
|
+
## Register
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import "@lmfaole/basics/basic-components/basic-dialog/register";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<basic-dialog data-label="Bekreft handling" data-backdrop-close>
|
|
15
|
+
<button type="button" data-dialog-open>Open dialog</button>
|
|
16
|
+
|
|
17
|
+
<dialog data-dialog-panel>
|
|
18
|
+
<h2 data-dialog-title>Bekreft handling</h2>
|
|
19
|
+
<p>Dialog body.</p>
|
|
20
|
+
<button type="button" data-dialog-close>Cancel</button>
|
|
21
|
+
<button type="button" data-dialog-close data-dialog-close-value="confirmed">
|
|
22
|
+
Confirm
|
|
23
|
+
</button>
|
|
24
|
+
</dialog>
|
|
25
|
+
</basic-dialog>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Props
|
|
29
|
+
|
|
30
|
+
| Prop | Description | Type | Default | Options |
|
|
31
|
+
| --- | --- | --- | --- | --- |
|
|
32
|
+
| `data-label` | Fallback accessible name when the dialog has no `aria-label`, `aria-labelledby`, or `[data-dialog-title]`. | string | `Dialog` | any string |
|
|
33
|
+
| `data-backdrop-close` | Allows clicks on the dialog backdrop to close the modal. | boolean attribute | off | `present`, `omitted` |
|
|
34
|
+
|
|
35
|
+
## Markup Hooks
|
|
36
|
+
|
|
37
|
+
| Hook | Description | Type | Default | Options |
|
|
38
|
+
| --- | --- | --- | --- | --- |
|
|
39
|
+
| `data-dialog-open` | Opens the managed dialog. | descendant control attribute | none | present on a descendant button or control |
|
|
40
|
+
| `data-dialog-panel` | Marks the native dialog element managed by the component. | descendant `<dialog>` attribute | required | present on one descendant `<dialog>` |
|
|
41
|
+
| `data-dialog-title` | Makes the visible heading the dialog's accessible name. | descendant heading attribute | none | present on a descendant heading |
|
|
42
|
+
| `data-dialog-close` | Closes the dialog when activated. | descendant control attribute | none | present on a descendant button or control |
|
|
43
|
+
| `data-dialog-close-value` | Return value passed to `dialog.close()` when used on a `[data-dialog-close]` control. | string | empty string | any string |
|
|
44
|
+
|
|
45
|
+
## Behavior
|
|
46
|
+
|
|
47
|
+
- Uses native modal dialog behavior via `showModal()`
|
|
48
|
+
- Restores focus to the opener on close
|
|
49
|
+
- Lets the platform handle modal focus and `Esc` dismissal
|
|
50
|
+
- `[data-dialog-close]` can optionally set `data-dialog-close-value`
|
|
51
|
+
|
|
52
|
+
## Markup Contract
|
|
53
|
+
|
|
54
|
+
- Provide one descendant `<dialog data-dialog-panel>`
|
|
55
|
+
- Use `[data-dialog-open]` on buttons that should open the modal
|
|
56
|
+
- Use `[data-dialog-title]` when the heading should become the accessible name
|
|
57
|
+
- Keep layout and styling outside the package
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# `basic-popover`
|
|
2
|
+
|
|
3
|
+
Non-modal overlay behavior using the Popover API.
|
|
4
|
+
|
|
5
|
+
## Register
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import "@lmfaole/basics/basic-components/basic-popover/register";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<basic-popover data-label="Filtre" data-anchor-trigger data-position-area="bottom">
|
|
15
|
+
<button type="button" data-popover-open>Toggle popover</button>
|
|
16
|
+
|
|
17
|
+
<section data-popover-panel>
|
|
18
|
+
<h2 data-popover-title>Filtre</h2>
|
|
19
|
+
<p>Popover body.</p>
|
|
20
|
+
<button type="button" data-popover-close>Close</button>
|
|
21
|
+
</section>
|
|
22
|
+
</basic-popover>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Props
|
|
26
|
+
|
|
27
|
+
| Prop | Description | Type | Default | Options |
|
|
28
|
+
| --- | --- | --- | --- | --- |
|
|
29
|
+
| `data-label` | Fallback accessible name when the popover has no `aria-label`, `aria-labelledby`, or `[data-popover-title]`. | string | `Popover` | any string |
|
|
30
|
+
| `data-anchor-trigger` | Uses the opener as the popover's implicit anchor. | boolean attribute | off | `present`, `omitted` |
|
|
31
|
+
| `data-position-area` | Default anchored placement used when `data-anchor-trigger` is enabled. | CSS `position-area` token | `bottom` | any CSS `position-area` token such as `bottom`, `top`, `left`, `right`, `block-start`, `block-end`, `inline-start`, or `inline-end` |
|
|
32
|
+
| `data-position-try-fallbacks` | Overrides the built-in fallback sequence used when the default placement would overflow. | comma-separated string list | derived from `data-position-area` | comma-separated CSS fallback list |
|
|
33
|
+
|
|
34
|
+
## Markup Hooks
|
|
35
|
+
|
|
36
|
+
| Hook | Description | Type | Default | Options |
|
|
37
|
+
| --- | --- | --- | --- | --- |
|
|
38
|
+
| `data-popover-open` | Toggles the popover open state. | descendant control attribute | none | present on a descendant button or control |
|
|
39
|
+
| `data-popover-panel` | Marks the overlay panel managed by the component. | descendant element attribute | required | present on one descendant element |
|
|
40
|
+
| `data-popover-title` | Makes the visible heading the popover's accessible name. | descendant heading attribute | none | present on a descendant heading |
|
|
41
|
+
| `data-popover-close` | Closes the popover when activated. | descendant control attribute | none | present on a descendant button or control |
|
|
42
|
+
|
|
43
|
+
## Behavior
|
|
44
|
+
|
|
45
|
+
- Uses the native Popover API in auto mode for outside-click and `Esc` dismissal
|
|
46
|
+
- Syncs `aria-expanded`, `aria-controls`, and `data-open` between the trigger and panel
|
|
47
|
+
- Restores focus when dismissal should return to the opener
|
|
48
|
+
- Supports anchored placement when `data-anchor-trigger` is set
|
|
49
|
+
|
|
50
|
+
## Markup Contract
|
|
51
|
+
|
|
52
|
+
- Provide one descendant `[data-popover-panel]`
|
|
53
|
+
- Use `[data-popover-open]` on buttons that should toggle the panel
|
|
54
|
+
- Use `[data-popover-title]` when the heading should become the accessible name
|
|
55
|
+
- Use `[data-popover-close]` when the panel should expose an explicit dismiss action
|
|
56
|
+
- Keep layout and styling outside the package
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# `basic-summary-table`
|
|
2
|
+
|
|
3
|
+
Tables with generated totals in `<tfoot>`.
|
|
4
|
+
|
|
5
|
+
## Register
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import "@lmfaole/basics/basic-components/basic-summary-table/register";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<basic-summary-table
|
|
15
|
+
data-caption="Månedlig kostnadsoversikt"
|
|
16
|
+
data-description="Viser antall og summerte beløp for faste kostnader."
|
|
17
|
+
data-row-headers
|
|
18
|
+
data-summary-columns="2,4"
|
|
19
|
+
data-total-label="Totalt"
|
|
20
|
+
data-locale="nb-NO"
|
|
21
|
+
>
|
|
22
|
+
<table>
|
|
23
|
+
<thead>
|
|
24
|
+
<tr>
|
|
25
|
+
<th>Post</th>
|
|
26
|
+
<th>Antall</th>
|
|
27
|
+
<th>Enhetspris</th>
|
|
28
|
+
<th>Beløp</th>
|
|
29
|
+
</tr>
|
|
30
|
+
</thead>
|
|
31
|
+
<tbody>
|
|
32
|
+
<tr>
|
|
33
|
+
<td>Basisabonnement</td>
|
|
34
|
+
<td>12</td>
|
|
35
|
+
<td>49,00 kr</td>
|
|
36
|
+
<td>588,00 kr</td>
|
|
37
|
+
</tr>
|
|
38
|
+
<tr>
|
|
39
|
+
<td>Supportavtale</td>
|
|
40
|
+
<td>1</td>
|
|
41
|
+
<td>299,00 kr</td>
|
|
42
|
+
<td>299,00 kr</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td>Lagringstillegg</td>
|
|
46
|
+
<td>4</td>
|
|
47
|
+
<td>120,00 kr</td>
|
|
48
|
+
<td>480,00 kr</td>
|
|
49
|
+
</tr>
|
|
50
|
+
</tbody>
|
|
51
|
+
</table>
|
|
52
|
+
</basic-summary-table>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Props
|
|
56
|
+
|
|
57
|
+
| Prop | Description | Type | Default | Options |
|
|
58
|
+
| --- | --- | --- | --- | --- |
|
|
59
|
+
| `data-caption` | Generates a visible `<caption>` when the wrapped table does not already define one. | string | none | any string |
|
|
60
|
+
| `data-description` | Generates hidden helper text and connects it with `aria-describedby`. | string | none | any string |
|
|
61
|
+
| `data-label` | Fallback accessible name when the table has no caption, `aria-label`, or `aria-labelledby`. | string | `Tabell` | any string |
|
|
62
|
+
| `data-row-headers` | Enables generated row headers in body rows. This is also enabled automatically when `data-row-header-column` is present. | boolean attribute | off | `present`, `omitted` |
|
|
63
|
+
| `data-row-header-column` | Chooses which one-based body column becomes the row header. | positive integer | `1` | positive integer |
|
|
64
|
+
| `data-summary-columns` | Selects which columns are totalled in the generated footer row. | comma-separated integer list | infer numeric body columns | comma-separated one-based column indexes |
|
|
65
|
+
| `data-total-label` | Footer row label used for the generated totals row. | string | `Totalt` | any string |
|
|
66
|
+
| `data-locale` | Locale passed to generated footer totals. | locale string | browser default | any `Intl.NumberFormat` locale string |
|
|
67
|
+
|
|
68
|
+
## Starter Styling Prop
|
|
69
|
+
|
|
70
|
+
| Prop | Description | Type | Default | Options |
|
|
71
|
+
| --- | --- | --- | --- | --- |
|
|
72
|
+
| `data-zebra` | Optional starter-CSS hook that adds alternating body-row backgrounds when you import `basic-styling`. | boolean attribute | off | `present`, `omitted` |
|
|
73
|
+
| `data-separators` | Optional starter-CSS hook that chooses whether interior dividers appear between rows, columns, or both when you import `basic-styling`. | enum string | `rows` | `rows`, `columns`, `both` |
|
|
74
|
+
|
|
75
|
+
## Cell Hooks
|
|
76
|
+
|
|
77
|
+
| Hook | Description | Type | Default | Options |
|
|
78
|
+
| --- | --- | --- | --- | --- |
|
|
79
|
+
| `data-value` on a body cell | Raw numeric value used for calculations when the displayed text is formatted differently. | numeric string | uses the cell text | any parseable numeric string |
|
|
80
|
+
|
|
81
|
+
## Behavior
|
|
82
|
+
|
|
83
|
+
- Inherits caption, description, row-header, and `headers` association behavior from `basic-table`
|
|
84
|
+
- Parses numbers from cell text and supports raw values through `data-value` on body cells
|
|
85
|
+
- Generates and updates a totals row in `<tfoot>`
|
|
86
|
+
- Recalculates when body rows or `data-value` attributes change
|
|
87
|
+
|
|
88
|
+
## Markup Contract
|
|
89
|
+
|
|
90
|
+
- Provide one descendant `<table>` with line items in `<tbody>`
|
|
91
|
+
- Prefer a label column and enable `data-row-headers` so each row remains easy to navigate
|
|
92
|
+
- Use `data-value` on cells when the displayed text differs from the numeric value you want summed
|
|
93
|
+
- Keep layout and styling outside the package
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# `basic-table`
|
|
2
|
+
|
|
3
|
+
Accessible naming and header relationships for regular tables.
|
|
4
|
+
|
|
5
|
+
## Register
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import "@lmfaole/basics/basic-components/basic-table/register";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<basic-table
|
|
15
|
+
data-caption="Bemanning per sprint"
|
|
16
|
+
data-description="Viser team, lokasjon og ledig kapasitet per sprint."
|
|
17
|
+
data-row-headers
|
|
18
|
+
data-row-header-column="2"
|
|
19
|
+
>
|
|
20
|
+
<table>
|
|
21
|
+
<thead>
|
|
22
|
+
<tr>
|
|
23
|
+
<th>Statuskode</th>
|
|
24
|
+
<th>Team</th>
|
|
25
|
+
<th>Lokasjon</th>
|
|
26
|
+
<th>Sprint</th>
|
|
27
|
+
<th>Ledige timer</th>
|
|
28
|
+
</tr>
|
|
29
|
+
</thead>
|
|
30
|
+
<tbody>
|
|
31
|
+
<tr>
|
|
32
|
+
<td>A1</td>
|
|
33
|
+
<td>Plattform</td>
|
|
34
|
+
<td>Oslo</td>
|
|
35
|
+
<td>14</td>
|
|
36
|
+
<td>18</td>
|
|
37
|
+
</tr>
|
|
38
|
+
<tr>
|
|
39
|
+
<td>B4</td>
|
|
40
|
+
<td>Designsystem</td>
|
|
41
|
+
<td>Trondheim</td>
|
|
42
|
+
<td>14</td>
|
|
43
|
+
<td>10</td>
|
|
44
|
+
</tr>
|
|
45
|
+
<tr>
|
|
46
|
+
<td>C2</td>
|
|
47
|
+
<td>Innsikt</td>
|
|
48
|
+
<td>Bergen</td>
|
|
49
|
+
<td>15</td>
|
|
50
|
+
<td>26</td>
|
|
51
|
+
</tr>
|
|
52
|
+
</tbody>
|
|
53
|
+
</table>
|
|
54
|
+
</basic-table>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Props
|
|
58
|
+
|
|
59
|
+
| Prop | Description | Type | Default | Options |
|
|
60
|
+
| --- | --- | --- | --- | --- |
|
|
61
|
+
| `data-caption` | Generates a visible `<caption>` when the table does not already define one. | string | none | any string |
|
|
62
|
+
| `data-column-headers` | Promotes the first row to column headers when the author provides a plain table without a header row. | boolean attribute | off | `present`, `omitted` |
|
|
63
|
+
| `data-description` | Generates hidden helper text and connects it with `aria-describedby`. | string | none | any string |
|
|
64
|
+
| `data-label` | Fallback accessible name when the table has no caption, `aria-label`, or `aria-labelledby`. | string | `Tabell` | any string |
|
|
65
|
+
| `data-row-header-column` | One-based body column that should become the generated row header. | positive integer | `1` | positive integer |
|
|
66
|
+
| `data-row-headers` | Enables generated row headers in body rows. This is also enabled automatically when `data-row-header-column` is present. | boolean attribute | off | `present`, `omitted` |
|
|
67
|
+
|
|
68
|
+
## Starter Styling Prop
|
|
69
|
+
|
|
70
|
+
| Prop | Description | Type | Default | Options |
|
|
71
|
+
| --- | --- | --- | --- | --- |
|
|
72
|
+
| `data-zebra` | Optional starter-CSS hook that adds alternating body-row backgrounds when you import `basic-styling`. | boolean attribute | off | `present`, `omitted` |
|
|
73
|
+
| `data-separators` | Optional starter-CSS hook that chooses whether interior dividers appear between rows, columns, or both when you import `basic-styling`. | enum string | `rows` | `rows`, `columns`, `both` |
|
|
74
|
+
|
|
75
|
+
## Behavior
|
|
76
|
+
|
|
77
|
+
- Preserves author-provided captions and only generates one when needed
|
|
78
|
+
- Can generate hidden helper text for extra context
|
|
79
|
+
- Can promote a plain first row to column headers
|
|
80
|
+
- Assigns missing header ids and populates `headers` on data cells
|
|
81
|
+
- Re-runs automatically when the wrapped table changes
|
|
82
|
+
|
|
83
|
+
## Markup Contract
|
|
84
|
+
|
|
85
|
+
- Provide one descendant `<table>`
|
|
86
|
+
- Use real table sections and header cells where possible
|
|
87
|
+
- Add `data-row-headers` when one body column identifies each row
|
|
88
|
+
- Add `data-column-headers` only when you want the component to promote a plain first row
|
|
89
|
+
- Keep layout and styling outside the package
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# `basic-tabs`
|
|
2
|
+
|
|
3
|
+
Accessible tablists and panels from existing markup.
|
|
4
|
+
|
|
5
|
+
## Register
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import "@lmfaole/basics/basic-components/basic-tabs/register";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<basic-tabs data-label="Eksempelkode">
|
|
15
|
+
<div data-tabs-list>
|
|
16
|
+
<button type="button" data-tab>Oversikt</button>
|
|
17
|
+
<button type="button" data-tab>Implementasjon</button>
|
|
18
|
+
<button type="button" data-tab>Tilgjengelighet</button>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<section data-tab-panel>
|
|
22
|
+
<p>Viser en kort oppsummering.</p>
|
|
23
|
+
</section>
|
|
24
|
+
<section data-tab-panel>
|
|
25
|
+
<p>Viser implementasjonsdetaljer.</p>
|
|
26
|
+
</section>
|
|
27
|
+
<section data-tab-panel>
|
|
28
|
+
<p>Viser tilgjengelighetsnotater.</p>
|
|
29
|
+
</section>
|
|
30
|
+
</basic-tabs>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Props
|
|
34
|
+
|
|
35
|
+
| Prop | Description | Type | Default | Options |
|
|
36
|
+
| --- | --- | --- | --- | --- |
|
|
37
|
+
| `data-label` | Accessible name for the generated tablist when it does not already have one. | string | `Faner` | any string |
|
|
38
|
+
| `data-activation` | Chooses whether arrow-key focus changes also activate the selected panel. | enum string | `automatic` | `automatic`, `manual` |
|
|
39
|
+
| `data-selected-index` | Sets the initially selected tab by index. Invalid values fall back to the first enabled tab. | zero-based integer | first enabled tab | zero-based integer |
|
|
40
|
+
|
|
41
|
+
## Markup Hooks
|
|
42
|
+
|
|
43
|
+
| Hook | Description | Type | Default | Options |
|
|
44
|
+
| --- | --- | --- | --- | --- |
|
|
45
|
+
| `data-tabs-list` | Holds the interactive tab controls. | descendant container attribute | required | present on one descendant container |
|
|
46
|
+
| `data-tab` | Marks each tab control. Prefer `<button>` elements. | descendant control attribute | required | present on matching descendant controls |
|
|
47
|
+
| `data-tab-panel` | Marks each panel in the same order as the tabs. | descendant panel attribute | required | present on matching descendant panels |
|
|
48
|
+
| `disabled` on a `[data-tab]` control | Removes that tab from keyboard navigation and selection. | boolean attribute | off | `present`, `omitted` |
|
|
49
|
+
|
|
50
|
+
## Behavior
|
|
51
|
+
|
|
52
|
+
- Generates missing tab and panel ids
|
|
53
|
+
- Keeps `aria-selected`, `aria-controls`, `aria-labelledby`, `hidden`, and `data-selected` in sync
|
|
54
|
+
- Supports click, `ArrowLeft`, `ArrowRight`, `Home`, and `End`
|
|
55
|
+
- Skips disabled tabs during keyboard navigation
|
|
56
|
+
- In `manual` mode, arrow keys move focus and `Enter` or `Space` activates
|
|
57
|
+
|
|
58
|
+
## Markup Contract
|
|
59
|
+
|
|
60
|
+
- Provide one descendant element with `data-tabs-list`
|
|
61
|
+
- Provide matching counts of `[data-tab]` and `[data-tab-panel]` in the same order
|
|
62
|
+
- Prefer `<button>` elements for tabs
|
|
63
|
+
- Keep layout and styling outside the package
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# `basic-toast`
|
|
2
|
+
|
|
3
|
+
Toast notifications with managed open state and live-region announcements.
|
|
4
|
+
|
|
5
|
+
## Register
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import "@lmfaole/basics/basic-components/basic-toast/register";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<basic-toast data-label="Lagring fullfort" data-duration="5000">
|
|
15
|
+
<button type="button" data-toast-open>Show toast</button>
|
|
16
|
+
|
|
17
|
+
<section data-toast-panel>
|
|
18
|
+
<h2 data-toast-title>Lagret</h2>
|
|
19
|
+
<p>Meldingen ble lagret uten feil.</p>
|
|
20
|
+
</section>
|
|
21
|
+
</basic-toast>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Props
|
|
25
|
+
|
|
26
|
+
| Prop | Description | Type | Default | Options |
|
|
27
|
+
| --- | --- | --- | --- | --- |
|
|
28
|
+
| `data-label` | Fallback accessible name when the toast panel has no `aria-label`, `aria-labelledby`, or `[data-toast-title]`. | string | `Toast` | any string |
|
|
29
|
+
| `data-live` | Chooses whether the announcement behaves like `status` or `alert`. | enum string | `polite` | `polite`, `assertive` |
|
|
30
|
+
| `data-duration` | Auto-dismiss timeout for the toast. | non-negative integer | `5000` | non-negative integer milliseconds, `0` disables auto-dismiss |
|
|
31
|
+
| `data-open` | Optional initial open state for the managed toast panel. | boolean-ish attribute | closed | `present`, `omitted`, `false` |
|
|
32
|
+
|
|
33
|
+
## Starter Styling Prop
|
|
34
|
+
|
|
35
|
+
| Prop | Description | Type | Default | Options |
|
|
36
|
+
| --- | --- | --- | --- | --- |
|
|
37
|
+
| `data-toast-position` | Optional starter-CSS hook for viewport placement when you import `basic-styling`. | enum string | none | `top-left`, `top-center`, `top-right`, `center-left`, `center`, `center-right`, `bottom-left`, `bottom-center`, `bottom-right` |
|
|
38
|
+
|
|
39
|
+
## Markup Hooks
|
|
40
|
+
|
|
41
|
+
| Hook | Description | Type | Default | Options |
|
|
42
|
+
| --- | --- | --- | --- | --- |
|
|
43
|
+
| `data-toast-open` | Shows or toggles the toast. | descendant control attribute | none | present on a descendant button or control |
|
|
44
|
+
| `data-toast-panel` | Marks the message container managed by the component. | descendant element attribute | required | present on one descendant element |
|
|
45
|
+
| `data-toast-title` | Makes the visible heading the toast's accessible name. | descendant heading attribute | none | present on a descendant heading |
|
|
46
|
+
| `data-toast-close` | Closes the toast when activated. | descendant control attribute | none | present on a descendant control outside `[data-toast-panel]` |
|
|
47
|
+
|
|
48
|
+
## Behavior
|
|
49
|
+
|
|
50
|
+
- Uses the Popover API in manual mode when available so the toast can render in the top layer
|
|
51
|
+
- Announces the current toast text through an internal live region whenever the toast opens
|
|
52
|
+
- Syncs `hidden` and `data-open` on the panel and root element
|
|
53
|
+
- Uses `[data-toast-title]` as the accessible name when present, otherwise falls back to `data-label`
|
|
54
|
+
- Supports `show()`, `hide()`, and `toggle()`
|
|
55
|
+
|
|
56
|
+
## Markup Contract
|
|
57
|
+
|
|
58
|
+
- Provide one descendant `[data-toast-panel]`
|
|
59
|
+
- Keep `[data-toast-panel]` to non-interactive message content
|
|
60
|
+
- Use `[data-toast-open]` on buttons that should show or toggle the toast
|
|
61
|
+
- If you need an explicit dismiss control, place `[data-toast-close]` outside `[data-toast-panel]`
|
|
62
|
+
- Keep layout and styling outside the package
|
|
@@ -49,6 +49,9 @@ export function normalizeToastOpen(
|
|
|
49
49
|
* Behavior:
|
|
50
50
|
* - uses the Popover API in manual mode when available so the toast panel can
|
|
51
51
|
* render in the top layer
|
|
52
|
+
* - announces the current toast text through an internal live region whenever
|
|
53
|
+
* the toast opens
|
|
54
|
+
* - expects `[data-toast-panel]` to contain non-interactive message content
|
|
52
55
|
*/
|
|
53
56
|
export class ToastElement extends HTMLElement {
|
|
54
57
|
static observedAttributes: string[];
|