@jungherz-de/notionkit-elements 1.17.0 → 1.19.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 (39) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +7 -7
  3. package/SKILL.md +53 -42
  4. package/dist/components/nk-calendar.js +6 -5
  5. package/dist/components/nk-cmdk.js +7 -5
  6. package/dist/components/nk-copy-field.js +33 -5
  7. package/dist/components/nk-dialog.js +5 -5
  8. package/dist/components/nk-menu.js +19 -6
  9. package/dist/components/nk-modal.js +7 -6
  10. package/dist/components/nk-peek.js +5 -4
  11. package/dist/components/nk-pop.js +3 -3
  12. package/dist/components/nk-progress.js +6 -3
  13. package/dist/components/nk-sheet.js +5 -5
  14. package/dist/components/nk-sidebar.js +1 -1
  15. package/dist/components/nk-tab-bar.js +10 -4
  16. package/dist/components/nk-toast.js +107 -11
  17. package/dist/components/nk-tooltip.js +1 -1
  18. package/dist/components/shared/{focus-C4tbSNND.js → focus-D55JGjRA.js} +7 -1
  19. package/dist/components/shared/layers-D9YYYA5g.js +35 -0
  20. package/dist/notionkit-elements.esm.js +241 -59
  21. package/dist/notionkit-elements.esm.min.js +1 -1
  22. package/dist/notionkit-elements.esm.min.js.map +1 -1
  23. package/dist/notionkit-elements.js +241 -59
  24. package/dist/notionkit-elements.min.js +1 -1
  25. package/package.json +3 -3
  26. package/src/components/content/nk-progress.js +6 -3
  27. package/src/components/forms/nk-calendar.js +5 -4
  28. package/src/components/forms/nk-copy-field.js +33 -5
  29. package/src/components/overlays/nk-cmdk.js +7 -5
  30. package/src/components/overlays/nk-dialog.js +4 -4
  31. package/src/components/overlays/nk-menu.js +19 -6
  32. package/src/components/overlays/nk-modal.js +7 -6
  33. package/src/components/overlays/nk-peek.js +4 -3
  34. package/src/components/overlays/nk-pop.js +3 -3
  35. package/src/components/overlays/nk-sheet.js +4 -4
  36. package/src/components/overlays/nk-toast.js +107 -11
  37. package/src/components/shell/nk-tab-bar.js +10 -4
  38. package/src/util/focus.js +6 -0
  39. package/src/util/layers.js +33 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,34 @@ All notable changes to NotionKit Elements are documented here. The format follow
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [1.19.0] – 2026-09-25
8
+
9
+ Built against NotionKit CSS 1.19.1 (peer `>= 1.19.1`). Auxdesk's wish 24 and what SupaGantt's mock-ups found – 14, 15 and 16 – together with a toast that never hid.
10
+
11
+ ### Added
12
+ - **`<nk-toast>` with an action.** `toast.show('Moved to trash', { action: { label: 'Undo', value: 'undo' } })`, or a `<button slot="action">`, gives the toast a button and an ×, as Notion's "Moved to trash · Undo". Such a toast stays until one of them is used, unless `show()` names a duration, and waits while the pointer or the focus is on it. The action fires `nk-action { action, value, label }` and, unless cancelled, closes the toast – a handler that shows the next message, "Restored", keeps it open; Escape closes it while the focus is inside, and the focus goes back to where it came from (Auxdesk's wish 24, which showed "A new version of Auxdesk · Reload" as a banner under the topbar). The demo's trash toast offers Undo.
13
+
14
+ ### Fixed
15
+ - **A toast without a `duration` attribute hides by itself again.** `show()` read the missing attribute as 0 – "stay" – so every such toast stayed on screen since 1.0.0, the demo's too; the default of 2200ms applies again, and a set attribute or `show()`'s `duration` still win.
16
+ - **Escape closes the layer that opened last.** A floating date picker or menu opened from a `<nk-dialog>` and the dialog both listened for Escape on the document in the capture phase, where `stopPropagation()` does not part them, so one Escape closed both. The overlays – modal, sheet, dialog, side peek, palette, popover, floating menu and date picker – now join one stack while they are open, and Escape goes to its top only; a second one closes the dialog (SupaGantt's finding 15).
17
+ - **The focus goes back into a shadow root.** `<nk-menu>` checked `document.activeElement`, `<nk-modal>` and `<nk-cmdk>` remembered it – both stop at the host of a view that holds the trigger, so the focus ended on `<body>`. They look behind shadow hosts now, like the dialog and the sheet (SupaGantt's finding 14).
18
+ - **A long floating menu opens at its top again** – or with its first checked item in view. It kept the place it had been scrolled to, its heading out of sight (SupaGantt's finding 16).
19
+ - **A toast whose message is empty takes no place**, so static text in its slot no longer stands a second gap away from the icon.
20
+
21
+ ## [1.18.0] – 2026-09-25
22
+
23
+ Built against NotionKit CSS 1.18.0 (peer `>= 1.18.0`). What LearnHub and Auxdesk found after their move to 1.17.0: LearnHub's finding 17 and Auxdesk's 26, 27 and 28.
24
+
25
+ ### Added
26
+ - **`<nk-copy-field>` shows icons on a phone.** Each button carries an icon beside its word; below 860px, and with the new `icons` attribute at every width, the icon stands in for the word – two overlapping squares for Copy, an eye and an eye struck through for Show and Hide, a green check for the moment after – and a masked key keeps a dozen characters more (Auxdesk's wish 27). The word stays the button's `aria-label`, from the dictionary or `copy-label` and the other attributes, and while the icons show, its tooltip for `<nk-tooltip>`.
27
+
28
+ ### Changed
29
+ - **`<nk-tab-bar>` marks "More" for a page without a tab of its own.** A `value` no item has – a mailbox, the settings, an account page opened from the drawer – makes the `drawer` item active, as iOS marks "More"; a bar without a drawer item marks none. Before, the bar kept the tab the user came from (Auxdesk's finding 28). `nk-change` reports such a value too; without a value the item marked `active`, else the first, is the one, as before.
30
+
31
+ ### Fixed
32
+ - **`<nk-progress wide label>` in a panel keeps its label beside the bar.** The host is `display: contents`, so bar and label were two flex items of the panel and stood one under the other. With a label the element sets both in one `.nk-progress-row` (NotionKit 1.18.0): beside each other, the label on the bar's middle, the bar filling the rest (LearnHub's finding 17). In a property value the label now stands 7px from the bar, as in a table cell, instead of 13px.
33
+ - **`<nk-prop>` on a phone keeps a long copy field inside its card** – NotionKit 1.18.0's fix for Auxdesk's finding 26 reaches the element's shadow root.
34
+
7
35
  ## [1.17.0] – 2026-09-25
8
36
 
9
37
  Built against NotionKit CSS 1.17.0 (peer `>= 1.17.0`). The rest of LearnHub's consolidated list: German texts in the elements (finding 9) and steps and gallery cards as links (6 and 16), under one link contract. Additive – with `lang="en"` every text stays as it was.
@@ -718,6 +746,8 @@ built and tested against NotionKit CSS 1.1.1 (peer range `>= 1.0.0`).
718
746
  import, never in the core bundle – shadow-less, adding `nk-block-host` to
719
747
  itself so the foundation's editor adapter rules apply.
720
748
 
749
+ [1.19.0]: https://github.com/JUNGHERZ/NotionKit-Elements/releases/tag/v1.19.0
750
+ [1.18.0]: https://github.com/JUNGHERZ/NotionKit-Elements/releases/tag/v1.18.0
721
751
  [1.17.0]: https://github.com/JUNGHERZ/NotionKit-Elements/releases/tag/v1.17.0
722
752
  [1.16.0]: https://github.com/JUNGHERZ/NotionKit-Elements/releases/tag/v1.16.0
723
753
  [1.15.0]: https://github.com/JUNGHERZ/NotionKit-Elements/releases/tag/v1.15.0
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  <h1 align="center">🧩 NotionKit Elements</h1>
2
2
 
3
3
  <p align="center">
4
- <a href="https://www.npmjs.com/package/@jungherz-de/notionkit-elements"><img src="https://img.shields.io/badge/version-1.17.0-2383e2?style=flat-square" alt="Version"></a>
4
+ <a href="https://www.npmjs.com/package/@jungherz-de/notionkit-elements"><img src="https://img.shields.io/badge/version-1.19.0-2383e2?style=flat-square" alt="Version"></a>
5
5
  <a href="#"><img src="https://img.shields.io/badge/vanilla_JS-no_dependencies-448361?style=flat-square" alt="Vanilla JS"></a>
6
6
  <a href="#"><img src="https://img.shields.io/badge/elements-88-529cca?style=flat-square" alt="88 Elements"></a>
7
7
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-9065b0?style=flat-square" alt="MIT License"></a>
8
- <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/changelog-v1.17.0-lightgrey?style=flat-square" alt="Changelog"></a>
8
+ <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/changelog-v1.19.0-lightgrey?style=flat-square" alt="Changelog"></a>
9
9
  <a href="https://www.npmjs.com/package/@jungherz-de/notionkit-elements"><img src="https://img.shields.io/badge/npm-%40jungherz--de%2Fnotionkit--elements-cb3837?style=flat-square&logo=npm" alt="npm"></a>
10
10
  </p>
11
11
 
@@ -59,7 +59,7 @@ It is the **app layer** of the NotionKit family – three layers, one design lan
59
59
  | 🧩 **88 Elements** | Forms with copy field, image picker and date picker, content blocks with bookmarks, app shell & tree with the ☰ drawer and the collapsing sidebar, page shell with properties, panels, avatars and steps, overlays (modal, sheet, dialog, resizable side peek, tooltip, ⌘K palette, menus that float in and become sheets on a phone, popover, emoji picker, toast), database table, board, list, calendar & gallery with toolbar and filter pills, comments, AI thread |
60
60
  | 🎛️ **Form participation** | Input, textarea, select, switch, check, radio, slider, segmented and model card work natively with `<form>` via `ElementInternals`; radios group across shadow roots |
61
61
  | 🌗 **Theme sync** | One observer mirrors `data-theme` on `<html>` into every element |
62
- | 🪶 **Lightweight** | 286 KB minified / 57 KB gzipped (IIFE, foundation sheet included), no external dependencies |
62
+ | 🪶 **Lightweight** | 292 KB minified / 59 KB gzipped (IIFE, foundation sheet included), no external dependencies |
63
63
  | 📦 **Five bundle shapes** | IIFE, minified IIFE, ESM, minified ESM with a source map (`esm.min.js`), and per-component ESM entries on a stable `base.js`, which import NotionKit's sheet instead of carrying a copy |
64
64
  | 🤖 **AI-ready** | `SKILL.md` with copy-paste markup, six app skeletons and the rules – an agent given only that file built a working app in the release test |
65
65
 
@@ -71,8 +71,8 @@ It is the **app layer** of the NotionKit family – three layers, one design lan
71
71
  <!DOCTYPE html>
72
72
  <html lang="en" data-theme="light">
73
73
  <head>
74
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
75
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
74
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
75
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
76
76
  </head>
77
77
  <body class="nk-body">
78
78
  <nk-field label="Display name" desc="Shown next to your comments">
@@ -104,7 +104,7 @@ Without a build step, an import map can point at the minified module instead: `"
104
104
 
105
105
  Do not mix the full bundle with the per-component files: each brings its own `NkElement`. With the bundle, take `componentsSheet` and `NkElement` from the bundle (`NotionKitElements.componentsSheet` from the `<script>` build).
106
106
 
107
- Two prerequisites, always: `notionkit.css` on the document (the peer dependency, `>= 1.17.0`; 1.17.0 brings a step's label and a gallery card as links, 1.16.0 brings `--nk-block-space` and `flush` for blocks in a column, keeps a wide progress bar and a stretched button's label in shape and lays floating menus above dialogs, 1.15.0 brings table text with a tone and a second line, 1.14.0 brings the gallery view and a banner action that stands at the right edge again, 1.13.0 keeps fields inside narrow panels, leaves a page without icon its padding under the cover and makes cover heights tokens, 1.12.0 brings a tag or button beside a panel's title, lists and grids without outer margin, text values, steps with states in any order and in a row, scrolling tabs, a cap for full pages and buttons per table row, 1.11.0 keeps a floating menu inside an open modal or dialog in place and inside the window and brings the banner's action as a button, fields that share a row and tooltips of several lines, 1.10.1 lets a disabled button show its tooltip, 1.10.0 brings the collapsing sidebar, the resizable side peek, the dialog and the tooltip, 1.9.0 the date picker and the calendar view, 1.8.0 the side peek, the bookmark, the copy field and pictures on the profile row, 1.7.0 the sheet, menus that float in and become sheets on a phone, the sidebar drawer, the database toolbar with filter pills and the steps, 1.7.1 minified files that carry all of it, 1.6.0 page properties, page options, list view, panels, prose and the avatar, 1.5.1 the safe areas, 1.5.0 the Notion-2025 tokens, the nine tag colours and the filled inputs; from 1.5.0 on, Elements and the foundation share one version number – the elements are built and tested against the same release) and `class="nk-body"` on `<body>`. The elements ship no visual CSS of their own – every rule comes from the foundation. The bundle injects the design tokens once as `@layer notionkit-defaults`, so any plain `:root { --nk-accent: … }` of yours re-brands every element in both themes.
107
+ Two prerequisites, always: `notionkit.css` on the document (the peer dependency, `>= 1.19.1`; 1.19.1 keeps a toast with an × at its height, 1.19.0 brings the toast with an action, 1.18.0 brings a bar and its label in one row, stacked properties that keep to their card on a phone and icons in the copy field, 1.17.0 brings a step's label and a gallery card as links, 1.16.0 brings `--nk-block-space` and `flush` for blocks in a column, keeps a wide progress bar and a stretched button's label in shape and lays floating menus above dialogs, 1.15.0 brings table text with a tone and a second line, 1.14.0 brings the gallery view and a banner action that stands at the right edge again, 1.13.0 keeps fields inside narrow panels, leaves a page without icon its padding under the cover and makes cover heights tokens, 1.12.0 brings a tag or button beside a panel's title, lists and grids without outer margin, text values, steps with states in any order and in a row, scrolling tabs, a cap for full pages and buttons per table row, 1.11.0 keeps a floating menu inside an open modal or dialog in place and inside the window and brings the banner's action as a button, fields that share a row and tooltips of several lines, 1.10.1 lets a disabled button show its tooltip, 1.10.0 brings the collapsing sidebar, the resizable side peek, the dialog and the tooltip, 1.9.0 the date picker and the calendar view, 1.8.0 the side peek, the bookmark, the copy field and pictures on the profile row, 1.7.0 the sheet, menus that float in and become sheets on a phone, the sidebar drawer, the database toolbar with filter pills and the steps, 1.7.1 minified files that carry all of it, 1.6.0 page properties, page options, list view, panels, prose and the avatar, 1.5.1 the safe areas, 1.5.0 the Notion-2025 tokens, the nine tag colours and the filled inputs; from 1.5.0 on, Elements and the foundation share one version number – the elements are built and tested against the same release) and `class="nk-body"` on `<body>`. The elements ship no visual CSS of their own – every rule comes from the foundation. The bundle injects the design tokens once as `@layer notionkit-defaults`, so any plain `:root { --nk-accent: … }` of yours re-brands every element in both themes.
108
108
 
109
109
  ## Elements
110
110
 
@@ -184,7 +184,7 @@ A step of `<nk-steps>` with `href` and a card of `<nk-gallery-view>` whose row h
184
184
  - Form controls are form-associated custom elements: `FormData`, `reset`, `required` and `<fieldset disabled>` just work. `<nk-radio>`s with the same `name` form a real group across shadow roots, with one tab stop and arrow keys.
185
185
  - Elements that copy light-DOM children (`nk-select` options, breadcrumb crumbs) watch them; `element.refresh()` is the escape hatch. Listeners are re-armed on every connect, so a moved element keeps working.
186
186
  - `::slotted()` matches only the assigned node: pass icons directly (`<span slot="icon">📁</span>`), never wrapped. For the same reason there is no `<nk-prose>`: rendered Markdown goes into a light-DOM `<div class="nk-prose">`, which reads the same rules as the editor adapter.
187
- - Overlays (`nk-modal`, `nk-sheet`, `nk-peek`, `nk-cmdk`, `nk-toast`, a floating `nk-menu`) go directly under `<body>`. The modal, the sheet and the palette lock scroll and make the rest of the page `inert` – the side peek only as a sheet on a phone, beside the page it leaves it usable; all of them return focus to the control that had it.
187
+ - Overlays (`nk-modal`, `nk-sheet`, `nk-peek`, `nk-cmdk`, `nk-toast`, a floating `nk-menu`) go directly under `<body>`. The modal, the sheet and the palette lock scroll and make the rest of the page `inert` – the side peek only as a sheet on a phone, beside the page it leaves it usable; all of them return focus to the control that had it, inside a shadow root too. Escape closes the layer that opened last: a date picker or menu opened from a dialog first, then the dialog.
188
188
  - The editor stays an adapter: `nk-block-host` is the shell, `docs-editor.js` the TipTap recipe (used in the demo app). `<nk-editor>` follows in v1.1 as an optional import, never in the core bundle.
189
189
 
190
190
  ## Development
package/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: notionkit-elements
3
- description: NotionKit Elements is a vanilla-JS Web Components library (v1.17.0) wrapping NotionKit CSS v1.17.0 – the calm, document-centric design system in the Notion idiom. 88 custom elements with the `nk-` prefix, Shadow DOM, automatic light/dark sync via data-theme on <html>, and form-associated controls. Use this reference whenever generating HTML that uses <nk-*> tags to get attributes, slots, events and composition right.
3
+ description: NotionKit Elements is a vanilla-JS Web Components library (v1.19.0) wrapping NotionKit CSS v1.19.1 – the calm, document-centric design system in the Notion idiom. 88 custom elements with the `nk-` prefix, Shadow DOM, automatic light/dark sync via data-theme on <html>, and form-associated controls. Use this reference whenever generating HTML that uses <nk-*> tags to get attributes, slots, events and composition right.
4
4
  ---
5
5
 
6
6
  # NotionKit Elements – AI Component Reference
@@ -21,8 +21,8 @@ description: NotionKit Elements is a vanilla-JS Web Components library (v1.17.0)
21
21
  <head>
22
22
  <meta charset="UTF-8">
23
23
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
24
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
25
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
24
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
25
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
26
26
  </head>
27
27
  <body class="nk-body">
28
28
  <nk-btn variant="primary">Save</nk-btn>
@@ -148,17 +148,19 @@ A native `<input>` inside the shadow root, wired into the surrounding form throu
148
148
 
149
149
  ### 3.3 `<nk-copy-field>` – Copy field
150
150
 
151
- A value to take along – a link, an address, a key – as tall as an input, with Copy inside on the right: it writes the clipboard and says “Copied” in green for a moment; where the clipboard is not allowed, the value is shown and selected for ⌘C. `secret` masks it behind Show/Hide, Copy still copies the real value. `value` set as a property is not reflected, so a key never lands in the markup.
151
+ A value to take along – a link, an address, a key – as tall as an input, with Copy inside on the right: it writes the clipboard and says “Copied” in green for a moment; where the clipboard is not allowed, the value is shown and selected for ⌘C. `secret` masks it behind Show/Hide, Copy still copies the real value. `value` set as a property is not reflected, so a key never lands in the markup. Each button carries an icon beside its word: on a phone, and with `icons` anywhere, the icon stands in for the word – two overlapping squares, an eye, a check in green for the moment after – and a masked key keeps a dozen characters more. The word stays the button’s name, and while the icons show, its tooltip for `nk-tooltip`.
152
152
 
153
153
  ```html
154
154
  <div style="max-width:340px"><nk-copy-field value="https://monahilft.notionkit.app" copy-label="Copy"></nk-copy-field></div>
155
155
  <div style="max-width:340px;margin-top:10px"><nk-copy-field value="ntn_4f2a9c1e8b7d6a5f3e2c" secret mono copy-label="Copy" show-label="Show"></nk-copy-field></div>
156
+ <div style="max-width:340px;margin-top:10px"><nk-copy-field value="ntn_4f2a9c1e8b7d6a5f3e2c" secret mono icons copy-label="Copy" show-label="Show"></nk-copy-field></div>
156
157
  ```
157
158
 
158
159
  | Attribute | Type | Default | Description |
159
160
  |---|---|---|---|
160
161
  | `value` | string | – | The value. |
161
162
  | `secret` | boolean | – | Masked, with Show/Hide. |
163
+ | `icons` | boolean | – | Icons instead of words at every width, not only on a phone. |
162
164
  | `mono` | boolean | – | Monospace – addresses, keys, code. |
163
165
  | `wrap` | boolean | – | A long value breaks instead of an ellipsis. |
164
166
  | `wide` | boolean | – | Fills the row. |
@@ -169,17 +171,18 @@ A value to take along – a link, an address, a key – as tall as an input, wit
169
171
 
170
172
  **Events:** `nk-action` `{ action: 'copy', value, ok }` – Copy clicked; `ok` is false where the clipboard refused.
171
173
 
172
- **Properties:** `value`, `secret` · **Methods:** `copy()`
174
+ **Properties:** `value`, `secret`, `icons` · **Methods:** `copy()`
173
175
 
174
- **Replaces:** `.nk-copy-field`, `.cf-value`, `.cf-btn`, `.copied`, `.mono`, `.wrap`, `.wide`
176
+ **Replaces:** `.nk-copy-field`, `.cf-value`, `.cf-btn`, `.copied`, `.mono`, `.wrap`, `.wide`, `.icons`
175
177
 
176
178
  ```html
177
179
  <!-- equivalent class markup -->
178
- <div style="max-width:340px"><div class="nk-copy-field"><span class="cf-value">https://monahilft.notionkit.app</span><button class="cf-btn">Copy</button></div></div>
179
- <div style="max-width:340px;margin-top:10px"><div class="nk-copy-field mono"><span class="cf-value">••••••••••••••••••••••••</span><button class="cf-btn">Show</button><button class="cf-btn">Copy</button></div></div>
180
+ <div style="max-width:340px"><div class="nk-copy-field"><span class="cf-value">https://monahilft.notionkit.app</span><button class="cf-btn" aria-label="Copy"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M15 9V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4"/><rect x="9" y="9" width="12" height="12" rx="2"/></svg><span>Copy</span></button></div></div>
181
+ <div style="max-width:340px;margin-top:10px"><div class="nk-copy-field mono"><span class="cf-value">••••••••••••••••••••••••</span><button class="cf-btn" aria-label="Show"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/></svg><span>Show</span></button><button class="cf-btn" aria-label="Copy"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M15 9V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4"/><rect x="9" y="9" width="12" height="12" rx="2"/></svg><span>Copy</span></button></div></div>
182
+ <div style="max-width:340px;margin-top:10px"><div class="nk-copy-field mono icons"><span class="cf-value">••••••••••••••••••••••••</span><button class="cf-btn" aria-label="Show"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/></svg><span>Show</span></button><button class="cf-btn" aria-label="Copy"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M15 9V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4"/><rect x="9" y="9" width="12" height="12" rx="2"/></svg><span>Copy</span></button></div></div>
180
183
  ```
181
184
 
182
- **Small screens:** Keeps to its column – inside a panel even below its 210px: the value is cut, never the actions.
185
+ **Small screens:** Keeps to its column – inside a panel even below its 210px: the value is cut, never the actions. The actions are icons, with the words as their names and tooltips.
183
186
 
184
187
  ### 3.4 `<nk-image-picker>` – Image picker
185
188
 
@@ -607,10 +610,11 @@ The select option as Notion draws it, in its nine colours. The colour modifier c
607
610
 
608
611
  ### 3.15 `<nk-progress>` – Progress
609
612
 
610
- A 60px bar with an optional label. `value`/`max` set the fill; the bar carries `role="progressbar"`. `wide` fills its row, and in a flex column – a panel – it stays a 6px bar.
613
+ A 60px bar with an optional label. `value`/`max` set the fill; the bar carries `role="progressbar"`. `wide` fills its row, and in a flex column – a panel – it stays a 6px bar. With a `label` the bar and its label form one `.nk-progress-row`: the label sits beside the bar, on its middle, in a panel too, where the host – `display: contents` – would let them stand one under the other.
611
614
 
612
615
  ```html
613
616
  <nk-progress value="72" label="72%"></nk-progress>
617
+ <div class="nk-panel" style="margin-top:12px"><h3>Progress</h3><nk-progress value="40" label="40%" wide></nk-progress></div>
614
618
  ```
615
619
 
616
620
  | Attribute | Type | Default | Description |
@@ -622,11 +626,12 @@ A 60px bar with an optional label. `value`/`max` set the fill; the bar carries `
622
626
 
623
627
 
624
628
 
625
- **Replaces:** `.nk-progress`, `.nk-progress-label`, `.wide`
629
+ **Replaces:** `.nk-progress`, `.nk-progress-label`, `.wide`, `.nk-progress-row`
626
630
 
627
631
  ```html
628
632
  <!-- equivalent class markup -->
629
- <span class="nk-progress"><i style="width:72%"></i></span><span class="nk-progress-label">72%</span>
633
+ <span class="nk-progress-row"><span class="nk-progress"><i style="width:72%"></i></span><span class="nk-progress-label">72%</span></span>
634
+ <div class="nk-panel" style="margin-top:12px"><h3>Progress</h3><span class="nk-progress-row"><span class="nk-progress wide"><i style="width:40%"></i></span><span class="nk-progress-label">40%</span></span></div>
630
635
  ```
631
636
 
632
637
  **Small screens:** Unchanged.
@@ -1198,7 +1203,7 @@ The ☀️/🌙 button. Flips `data-theme` on `<html>`, remembers the choice in
1198
1203
 
1199
1204
  ### 3.34 `<nk-tab-bar>` – Tab bar (mobile)
1200
1205
 
1201
- The thumb-reachable twin of the sidebar for phones and installed PWAs. Put it last inside `nk-app`: it is slotted into the main column below the scrolling page, so it never moves and no bottom padding is needed. Keeps exactly one `nk-tab-bar-item` active (listening to `nk-select`); a `drawer` item opens the sidebar instead. Needs NotionKit CSS 1.2.0.
1206
+ The thumb-reachable twin of the sidebar for phones and installed PWAs. Put it last inside `nk-app`: it is slotted into the main column below the scrolling page, so it never moves and no bottom padding is needed. Keeps the `nk-tab-bar-item` whose value is `value` active (listening to `nk-select`); a `drawer` item opens the sidebar instead. A value no item has – a page without a tab of its own, opened from the drawer – marks the `drawer` item, as iOS marks “More”; without one no item is active. Needs NotionKit CSS 1.2.0.
1202
1207
 
1203
1208
  ```html
1204
1209
  <div style="max-width:390px;border:1px solid var(--nk-border);border-radius:12px;overflow:hidden"><nk-tab-bar always value="inbox">
@@ -1212,7 +1217,7 @@ The thumb-reachable twin of the sidebar for phones and installed PWAs. Put it la
1212
1217
 
1213
1218
  | Attribute | Type | Default | Description |
1214
1219
  |---|---|---|---|
1215
- | `value` | string | – | Active item value (default: the item with `active`, else the first). |
1220
+ | `value` | string | – | Active item value (default: the item with `active`, else the first); a value no item has marks the `drawer` item. |
1216
1221
  | `always` | boolean | – | Visible at every width, not only below 860px. |
1217
1222
  | `fixed` | boolean | – | Pinned to the viewport bottom instead of sitting in the column – for standalone PWAs; a spacer keeps its height (`--nk-tab-bar-height` + safe area) in the flow. |
1218
1223
  | `floating` | boolean | – | A fixed capsule with rounded corners instead of the full-width bar. |
@@ -2526,29 +2531,29 @@ Search field, 8-column grid, category strip. Ships with a built-in set (names fo
2526
2531
 
2527
2532
  ### 3.75 `<nk-toast>` – Toast
2528
2533
 
2529
- One inverted pill at the bottom centre, above every overlay; over a tab bar at the bottom of the screen it rises 12px above the bar. `toast.show("Saved")` shows it and hides it after `duration` ms; `open` is the state.
2534
+ One inverted pill at the bottom centre, above every overlay; over a tab bar at the bottom of the screen it rises 12px above the bar. `toast.show("Saved")` shows it and hides it after `duration` ms; `open` is the state. With an action – `show("Moved to trash", { action: { label: "Undo", value: "undo" } })` or a `<button slot="action">` – it is Notion’s toast with a button and an ×: it stays until one of them is used, unless `show()` names a duration, and waits while the pointer or the focus is on it. The action fires `nk-action` and, unless cancelled, closes it; Escape closes it while the focus is inside.
2530
2535
 
2531
2536
  ```html
2532
- <nk-toast open duration="0">Settings saved</nk-toast>
2537
+ <nk-toast open duration="0" icon="🗑️">Moved to trash<button slot="action" value="undo">Undo</button></nk-toast>
2533
2538
  ```
2534
2539
 
2535
2540
  | Attribute | Type | Default | Description |
2536
2541
  |---|---|---|---|
2537
2542
  | `open` | boolean | – | Visible. |
2538
- | `duration` | ms | `2200` | Auto-hide delay (0 = stay). |
2543
+ | `duration` | ms | `2200` | Auto-hide delay (0 = stay); a toast with an action stays unless show() names one. |
2539
2544
  | `icon` | string | `✓` | Leading glyph. |
2540
2545
 
2541
- **Slots:** `(default)` – Static content (when `show()` gets no message).
2546
+ **Slots:** `(default)` – Static content (when `show()` gets no message). · `action` – A button for the action; its `value` goes out with `nk-action`.
2542
2547
 
2543
- **Events:** `nk-toggle` `{ open }` – Shown / hidden.
2548
+ **Events:** `nk-toggle` `{ open }` – Shown / hidden. · `nk-action` `{ action, value, label }` – The action used; cancel it to keep the toast.
2544
2549
 
2545
- **Properties:** `open`, `message` · **Methods:** `show(message?, { duration })`, `close()`
2550
+ **Properties:** `open`, `message` · **Methods:** `show(message?, { duration, action: { label, value } })`, `close()`
2546
2551
 
2547
- **Replaces:** `.nk-toast`, `.show`
2552
+ **Replaces:** `.nk-toast`, `.show`, `.t-action`, `.t-close`
2548
2553
 
2549
2554
  ```html
2550
2555
  <!-- equivalent class markup -->
2551
- <div class="nk-toast show">✓ <span>Settings saved</span></div>
2556
+ <div class="nk-toast show">🗑️ <span>Moved to trash</span><button class="t-action" type="button">Undo</button><button class="t-close" type="button" aria-label="Close"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"/></svg></button></div>
2552
2557
  ```
2553
2558
 
2554
2559
  **Small screens:** Unchanged.
@@ -3145,8 +3150,8 @@ Eight skeletons, one per app shape, mirroring the NotionKit CSS SKILL.md. Copy o
3145
3150
  <html lang="en" data-theme="light">
3146
3151
  <head>
3147
3152
  <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
3148
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
3149
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
3153
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
3154
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
3150
3155
  </head>
3151
3156
  <body class="nk-body">
3152
3157
  <nk-app>
@@ -3227,8 +3232,8 @@ Rules of the shell: `nk-sidebar`, `nk-topbar` and `nk-page` are `display: conten
3227
3232
  <html lang="en" data-theme="light">
3228
3233
  <head>
3229
3234
  <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
3230
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
3231
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
3235
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
3236
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
3232
3237
  </head>
3233
3238
  <body class="nk-body">
3234
3239
  <nk-app>
@@ -3335,8 +3340,8 @@ Data contract: `columns` describe the properties (`type`: text | select | multi-
3335
3340
  <html lang="en" data-theme="light">
3336
3341
  <head>
3337
3342
  <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
3338
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
3339
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
3343
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
3344
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
3340
3345
  </head>
3341
3346
  <body class="nk-body">
3342
3347
  <nk-app>
@@ -3395,8 +3400,8 @@ Data contract: `columns` describe the properties (`type`: text | select | multi-
3395
3400
  <html lang="en" data-theme="light">
3396
3401
  <head>
3397
3402
  <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
3398
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
3399
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
3403
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
3404
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
3400
3405
  </head>
3401
3406
  <body class="nk-body">
3402
3407
  <!-- your app -->
@@ -3473,8 +3478,8 @@ The open/close contract is one attribute: `settings.open = true`, `settings.show
3473
3478
  <html lang="en" data-theme="light">
3474
3479
  <head>
3475
3480
  <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
3476
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
3477
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
3481
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
3482
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
3478
3483
  </head>
3479
3484
  <body class="nk-body">
3480
3485
  <div class="nk-page" style="padding-top:48px">
@@ -3520,8 +3525,8 @@ The open/close contract is one attribute: `settings.open = true`, `settings.show
3520
3525
  <html lang="en" data-theme="light">
3521
3526
  <head>
3522
3527
  <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
3523
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
3524
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
3528
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
3529
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
3525
3530
  </head>
3526
3531
  <body class="nk-body">
3527
3532
  <nk-page narrow icon="📘" cover>
@@ -3565,8 +3570,8 @@ Note `narrow`: the page is the document, so there is no inner scroll wrapper –
3565
3570
  <html lang="en" data-theme="light">
3566
3571
  <head>
3567
3572
  <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
3568
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
3569
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
3573
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
3574
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
3570
3575
  </head>
3571
3576
  <body class="nk-body">
3572
3577
  <nk-app>
@@ -3620,8 +3625,8 @@ Note `narrow`: the page is the document, so there is no inner scroll wrapper –
3620
3625
  <html lang="en" data-theme="light">
3621
3626
  <head>
3622
3627
  <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
3623
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.17.0/notionkit.min.css">
3624
- <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.17.0/dist/notionkit-elements.min.js"></script>
3628
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit@1.19.1/notionkit.min.css">
3629
+ <script src="https://cdn.jsdelivr.net/npm/@jungherz-de/notionkit-elements@1.19.0/dist/notionkit-elements.min.js"></script>
3625
3630
  </head>
3626
3631
  <body class="nk-body">
3627
3632
  <!-- A narrow column, centred: layout is yours, so it is inline. -->
@@ -3712,6 +3717,12 @@ Form controls additionally re-dispatch a native, bubbling `change` event, so `fo
3712
3717
  | Rows laid out in a table of weeks to show them by date | `<nk-calendar-view date-key="due">` in `<nk-database>` – a tab like table and board |
3713
3718
  | German labels on every instance (`copy-label="Kopieren"`, `today-label="Heute"`, `new-row-label="+ Neue Seite"` …) | `<html lang="de">` – the elements bring the German texts, the accessible names too; keep an attribute for a label with a meaning of its own, `setStrings()` for another language |
3714
3719
  | `<nk-steps selectable>` or a gallery whose `nk-select` sets `location.href` | `href` on the step, `href-key` on the gallery: a real link opens in a new tab and can be copied; cancel `nk-select` to route yourself |
3720
+ | A `<div style="display:flex">` around `<nk-progress wide label>` in a panel so the label stays beside the bar | Not needed: with a `label` the element sets bar and label in one `.nk-progress-row` – beside each other in a flex column too |
3721
+ | `copy-label="⧉"` or other glyphs to save room in `<nk-copy-field>` on a phone | Nothing: on a phone the buttons show icons by themselves, the words stay their names; `icons` does it at every width |
3722
+ | `<nk-tab-bar>` kept on the last tab while a page from the drawer is open | Set `value` to that page's own value: a value no item has marks the `drawer` item ("More"), as on iOS |
3723
+ | A banner under the topbar for "New version · Reload", or a toast plus a separate Undo button | `toast.show('Moved to trash', { action: { label: 'Undo', value: 'undo' } })` – a button and an ×, it stays until used; `nk-action` names the action |
3724
+ | `stopImmediatePropagation()` or a check of your own so that Escape in a dialog closes only its date picker | Nothing: Escape closes the layer that opened last – the floating date picker or menu first, then the dialog |
3725
+ | A `focusBack()` helper after a menu, the modal or the palette opened from a view's shadow root | Nothing: the overlays find the focused control behind shadow hosts and give the focus back to it |
3715
3726
 
3716
3727
 
3717
3728
  # 7. Quick Reference
@@ -3720,7 +3731,7 @@ Form controls additionally re-dispatch a native, bubbling `change` event, so `fo
3720
3731
  |---|---|---|---|---|
3721
3732
  | `<nk-btn>` | forms | `variant`, `active`, `small`, `disabled` | `(default)` | `click` |
3722
3733
  | `<nk-input>` | forms | `value`, `type`, `placeholder`, `name` | – | `nk-change`, `nk-input` |
3723
- | `<nk-copy-field>` | forms | `value`, `secret`, `mono`, `wrap` | – | `nk-action` |
3734
+ | `<nk-copy-field>` | forms | `value`, `secret`, `icons`, `mono` | – | `nk-action` |
3724
3735
  | `<nk-image-picker>` | forms | `src`, `initials`, `square`, `max` | – | `nk-change`, `nk-error` |
3725
3736
  | `<nk-calendar>` | forms | `value`, `month`, `min`, `max` | – | `nk-change`, `nk-month`, `nk-toggle` |
3726
3737
  | `<nk-textarea>` | forms | `value`, `placeholder`, `rows`, `name` | `(default)` | `nk-change`, `nk-input` |
@@ -3792,7 +3803,7 @@ Form controls additionally re-dispatch a native, bubbling `change` event, so `fo
3792
3803
  | `<nk-menu-item>` | overlays | `icon`, `shortcut`, `value`, `danger` | `(default)`, `icon` | `nk-select`, `nk-change` |
3793
3804
  | `<nk-pop>` | overlays | `open`, `placement`, `bare` | `trigger`, `(default)` | `nk-toggle` |
3794
3805
  | `<nk-emoji-picker>` | overlays | `placeholder`, `value` | – | `nk-select` |
3795
- | `<nk-toast>` | overlays | `open`, `duration`, `icon` | `(default)` | `nk-toggle` |
3806
+ | `<nk-toast>` | overlays | `open`, `duration`, `icon` | `(default)`, `action` | `nk-toggle`, `nk-action` |
3796
3807
  | `<nk-tooltip>` | overlays | `for`, `shortcut`, `delay`, `placement` | `(default)` | – |
3797
3808
  | `<nk-database>` | data | `view`, `add-view` | `(default)`, `tools`, `filters` | `nk-view-change`, `nk-action`, `nk-select / nk-change / nk-action` |
3798
3809
  | `<nk-table-view>` | data | `name`, `label`, `badge`, `count` | – | `nk-select`, `nk-change`, `nk-action` |
@@ -3826,10 +3837,10 @@ Form controls additionally re-dispatch a native, bubbling `change` event, so `fo
3826
3837
  | Texts | `src/util/strings.js` – the English and German dictionary and `setStrings()`; `NkElement#str(key)` reads it in the element's language, `onStringsChanged()` runs after `setStrings()` and when `<html lang>` changes |
3827
3838
  | Components | `src/components/{forms,content,shell,page,overlays,data}/nk-*.js`, one tag per file, `customElements.define` at the bottom |
3828
3839
  | Build | Rollup: IIFE, minified IIFE, ESM, and per-component ESM entries on a stable `dist/components/base.js` that import NotionKit's sheet (`@jungherz-de/notionkit/notionkit-styles.js`) instead of inlining it; the full bundles inline it and export `componentsSheet` |
3829
- | Peer | `@jungherz-de/notionkit >= 1.17.0` – from 1.5.0 on the elements and the foundation share one version number; the bundle embeds that release's stylesheet, so keep them in step |
3840
+ | Peer | `@jungherz-de/notionkit >= 1.19.0` – from 1.5.0 on the elements and the foundation share one version number; the bundle embeds that release's stylesheet, so keep them in step |
3830
3841
 
3831
3842
  Lifecycle: construct (attach shadow, adopt sheets) → first connect (wrapper + `render()`) → every connect (`setupEvents()`, theme registration, light-DOM observer) → `attributeChangedCallback` → `onAttributeChanged` → disconnect (`teardownEvents()`, unregister).
3832
3843
 
3833
3844
 
3834
3845
  ---
3835
- *NotionKit Elements v1.17.0 · wrapping NotionKit CSS v1.17.0 · MIT · Jungherz GmbH*
3846
+ *NotionKit Elements v1.19.0 · wrapping NotionKit CSS v1.19.1 · MIT · Jungherz GmbH*
@@ -1,7 +1,8 @@
1
1
  import { NkFormElement } from './base.js';
2
2
  import { p as parseDay, i as isoOf, C as CHEVRONS, r as resolveLocale, f as firstWeekday, m as monthGrid, w as weekLabel, a as weekdayNames, b as isoWeek, s as stepMonth, c as addDays } from './shared/dates-a32DcW1l.js';
3
3
  import { p as placeUnder } from './shared/floating-DOK73b_D.js';
4
- import { d as deepActiveElement } from './shared/focus-C4tbSNND.js';
4
+ import { d as deepActiveElement } from './shared/focus-D55JGjRA.js';
5
+ import { c as closeLayer, o as openLayer } from './shared/layers-D9YYYA5g.js';
5
6
  import '@jungherz-de/notionkit/notionkit-styles.js';
6
7
 
7
8
  // <nk-calendar name="due" value="2026-06-02" weeks weekend="6,0"></nk-calendar>
@@ -272,14 +273,13 @@ class NkCalendar extends NkFormElement {
272
273
  this._draw();
273
274
  this.emit('nk-change', { value: '', start: null, end: null, time: null });
274
275
  };
275
- // Floating: a tap outside closes it and reaches nothing else; Escape closes (captured, before a modal around it).
276
+ // Floating: a tap outside closes it and reaches nothing else; Escape closes it, before a dialog around it (util/layers.js).
276
277
  this._onOutside = (e) => {
277
278
  const path = e.composedPath();
278
279
  if (path.includes(this) || (this._anchor && path.includes(this._anchor))) return;
279
280
  e.preventDefault(); e.stopPropagation();
280
281
  this.close();
281
282
  };
282
- this._onEscape = (e) => { if (e.key === 'Escape' && this.getBoolAttr('floating') && this.getBoolAttr('open')) { e.stopPropagation(); this.close(); } };
283
283
  this._grid.addEventListener('click', this._onGrid);
284
284
  this._grid.addEventListener('keydown', this._onKey);
285
285
  this._todayBtn.addEventListener('click', this._onToday);
@@ -287,7 +287,6 @@ class NkCalendar extends NkFormElement {
287
287
  this._next.addEventListener('click', this._onNext);
288
288
  this._timeInput.addEventListener('change', this._onTime);
289
289
  this._clear.addEventListener('click', this._onClear);
290
- document.addEventListener('keydown', this._onEscape, true);
291
290
  if (this.getBoolAttr('open')) document.addEventListener('click', this._onOutside, true);
292
291
  }
293
292
 
@@ -299,7 +298,7 @@ class NkCalendar extends NkFormElement {
299
298
  this._next?.removeEventListener('click', this._onNext);
300
299
  this._timeInput?.removeEventListener('change', this._onTime);
301
300
  this._clear?.removeEventListener('click', this._onClear);
302
- document.removeEventListener('keydown', this._onEscape, true);
301
+ closeLayer(this);
303
302
  document.removeEventListener('click', this._onOutside, true);
304
303
  }
305
304
 
@@ -323,7 +322,9 @@ class NkCalendar extends NkFormElement {
323
322
  this._returnFocus = deepActiveElement();
324
323
  if (this._returnFocus?.matches(':focus-visible')) requestAnimationFrame(() => this.focusDay());
325
324
  document.addEventListener('click', this._onOutside, true);
325
+ if (this.getBoolAttr('floating')) openLayer(this, () => this.close());
326
326
  } else {
327
+ closeLayer(this);
327
328
  document.removeEventListener('click', this._onOutside, true);
328
329
  const back = this._returnFocus;
329
330
  this._returnFocus = null;
@@ -1,5 +1,6 @@
1
1
  import { NkElement } from './base.js';
2
- import { l as lockScroll, i as inertOutside, u as unlockScroll } from './shared/focus-C4tbSNND.js';
2
+ import { d as deepActiveElement, l as lockScroll, i as inertOutside, u as unlockScroll } from './shared/focus-D55JGjRA.js';
3
+ import { o as openLayer, c as closeLayer } from './shared/layers-D9YYYA5g.js';
3
4
  import '@jungherz-de/notionkit/notionkit-styles.js';
4
5
 
5
6
  // Subsequence scoring for the command palette: every query character must
@@ -153,14 +154,16 @@ class NkCmdk extends NkElement {
153
154
  if (open === this._wasOpen) return;
154
155
  this._wasOpen = open;
155
156
  if (open) {
156
- this._returnFocus = document.activeElement;
157
+ this._returnFocus = deepActiveElement();
157
158
  this._input.value = '';
158
159
  this._index = 0;
159
160
  this._renderList();
160
161
  lockScroll();
161
162
  this._undoInert = inertOutside(this);
163
+ openLayer(this, () => this.close());
162
164
  requestAnimationFrame(() => this._input.focus({ preventScroll: true }));
163
165
  } else {
166
+ closeLayer(this);
164
167
  unlockScroll();
165
168
  this._undoInert?.(); this._undoInert = null;
166
169
  const back = this._returnFocus;
@@ -171,8 +174,7 @@ class NkCmdk extends NkElement {
171
174
 
172
175
  setupEvents() {
173
176
  this._onDocKey = (e) => {
174
- if (this._matchesHotkey(e)) { e.preventDefault(); this.toggle(); return; }
175
- if (e.key === 'Escape' && this.getBoolAttr('open')) { e.stopPropagation(); this.close(); }
177
+ if (this._matchesHotkey(e)) { e.preventDefault(); this.toggle(); }
176
178
  };
177
179
  this._onInput = () => { this._index = 0; this._renderList(); };
178
180
  this._onInputKey = (e) => {
@@ -201,7 +203,7 @@ class NkCmdk extends NkElement {
201
203
  this._list?.removeEventListener('mousemove', this._onListMove);
202
204
  this._list?.removeEventListener('mousedown', this._onListDown);
203
205
  this._backdrop?.removeEventListener('click', this._onBackdrop);
204
- if (this._wasOpen) { unlockScroll(); this._undoInert?.(); this._undoInert = null; this._wasOpen = false; }
206
+ if (this._wasOpen) { closeLayer(this); unlockScroll(); this._undoInert?.(); this._undoInert = null; this._wasOpen = false; }
205
207
  }
206
208
 
207
209
  onAttributeChanged(name) {
@@ -4,7 +4,8 @@ import '@jungherz-de/notionkit/notionkit-styles.js';
4
4
  // <nk-copy-field value="https://monahilft.notionkit.app"></nk-copy-field>
5
5
  // <nk-copy-field value="ntn_4f2…" secret mono></nk-copy-field>
6
6
  // → <div class="nk-copy-field mono"><span class="cf-value">…</span>
7
- // <button class="cf-btn">Show</button><button class="cf-btn">Copy</button></div>
7
+ // <button class="cf-btn" aria-label="Show"><svg>…</svg><span>Show</span></button>
8
+ // <button class="cf-btn" aria-label="Copy"><svg>…</svg><span>Copy</span></button></div>
8
9
  // A value to take along – a link, an address, a key (NotionKit 1.8.0). Copy
9
10
  // writes it to the clipboard and says "Copied" in green for a moment; where
10
11
  // the clipboard is not allowed, the value is shown and selected instead, for
@@ -13,8 +14,21 @@ import '@jungherz-de/notionkit/notionkit-styles.js';
13
14
  // lands in the markup. Fires nk-action { action: 'copy', value, ok }. The
14
15
  // texts come in English or German after the language (1.17.0, setStrings()
15
16
  // for others); copy-label, copied-label, show-label, hide-label set them here.
17
+ // Each button carries an icon beside its word (1.18.0): on a phone, and with
18
+ // `icons` anywhere, the icon stands in for the word – two overlapping squares,
19
+ // an eye, a check in green for the moment after – and a masked key keeps a
20
+ // dozen characters more. The word stays the button's name, and while the
21
+ // icons show, its tooltip for <nk-tooltip>.
22
+ const ICONS = {
23
+ copy: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M15 9V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4"/><rect x="9" y="9" width="12" height="12" rx="2"/></svg>',
24
+ copied: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>',
25
+ show: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/></svg>',
26
+ hide: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/><path d="m3 3 18 18"/></svg>',
27
+ };
28
+ const PHONE = typeof matchMedia === 'function' ? matchMedia('(max-width: 860px)') : null;
29
+
16
30
  class NkCopyField extends NkElement {
17
- static get observedAttributes() { return ['value', 'mono', 'wrap', 'wide', 'secret', 'copy-label', 'copied-label', 'show-label', 'hide-label']; }
31
+ static get observedAttributes() { return ['value', 'mono', 'wrap', 'wide', 'secret', 'icons', 'copy-label', 'copied-label', 'show-label', 'hide-label']; }
18
32
 
19
33
  render() {
20
34
  this._val ??= this.getAttribute('value') ?? '';
@@ -29,29 +43,41 @@ class NkCopyField extends NkElement {
29
43
 
30
44
  _sync() {
31
45
  if (!this._box) return;
32
- for (const m of ['mono', 'wrap', 'wide']) this._box.classList.toggle(m, this.getBoolAttr(m));
46
+ for (const m of ['mono', 'wrap', 'wide', 'icons']) this._box.classList.toggle(m, this.getBoolAttr(m));
33
47
  const secret = this.getBoolAttr('secret');
34
48
  this._text.textContent = secret && !this._revealed ? '•'.repeat(Math.min(this._val.length, 24)) : this._val;
35
49
  // Not `hidden`: .cf-btn sets no display of its own that could lose to it,
36
50
  // but a button that is not there cannot be tabbed to either.
37
51
  if (secret && !this._show.isConnected) this._copy.before(this._show);
38
52
  if (!secret) this._show.remove();
39
- this._show.textContent = this._revealed ? (this.getAttribute('hide-label') || this.str('hide')) : (this.getAttribute('show-label') || this.str('show'));
53
+ const tip = this.getBoolAttr('icons') || !!PHONE?.matches;
54
+ this._button(this._show, this._revealed ? 'hide' : 'show', this._revealed ? (this.getAttribute('hide-label') || this.str('hide')) : (this.getAttribute('show-label') || this.str('show')), tip);
40
55
  this._show.setAttribute('aria-pressed', String(!!this._revealed));
41
- this._copy.textContent = this._copied ? (this.getAttribute('copied-label') || this.str('copied')) : (this.getAttribute('copy-label') || this.str('copy'));
56
+ this._button(this._copy, this._copied ? 'copied' : 'copy', this._copied ? (this.getAttribute('copied-label') || this.str('copied')) : (this.getAttribute('copy-label') || this.str('copy')), tip);
42
57
  this._copy.classList.toggle('copied', !!this._copied);
43
58
  }
44
59
 
60
+ /** The icon and the word of a button; the word is its name, and its tooltip while the icon stands in for it. */
61
+ _button(btn, icon, word, tip) {
62
+ if (btn.dataset.icon !== icon) { btn.innerHTML = `${ICONS[icon]}<span></span>`; btn.dataset.icon = icon; }
63
+ btn.lastChild.textContent = word;
64
+ btn.setAttribute('aria-label', word);
65
+ if (tip) btn.setAttribute('data-tooltip', word); else btn.removeAttribute('data-tooltip');
66
+ }
67
+
45
68
  setupEvents() {
46
69
  this._onCopy = () => this.copy();
47
70
  this._onShow = () => { this._revealed = !this._revealed; this._sync(); };
71
+ this._onPhone = () => this._sync();
48
72
  this._copy.addEventListener('click', this._onCopy);
49
73
  this._show.addEventListener('click', this._onShow);
74
+ PHONE?.addEventListener('change', this._onPhone);
50
75
  }
51
76
 
52
77
  teardownEvents() {
53
78
  this._copy?.removeEventListener('click', this._onCopy);
54
79
  this._show?.removeEventListener('click', this._onShow);
80
+ PHONE?.removeEventListener('change', this._onPhone);
55
81
  clearTimeout(this._timer);
56
82
  }
57
83
 
@@ -84,6 +110,8 @@ class NkCopyField extends NkElement {
84
110
  set value(v) { this._val = v == null ? '' : String(v); this._sync(); }
85
111
  get secret() { return this.getBoolAttr('secret'); }
86
112
  set secret(v) { this.setBoolAttr('secret', v); }
113
+ get icons() { return this.getBoolAttr('icons'); }
114
+ set icons(v) { this.setBoolAttr('icons', v); }
87
115
  }
88
116
 
89
117
  customElements.define('nk-copy-field', NkCopyField);