@jungherz-de/notionkit-elements 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/dist/components/nk-bookmark.js +69 -0
- package/dist/components/nk-btn.js +29 -3
- package/dist/components/nk-cmdk.js +1 -1
- package/dist/components/nk-copy-field.js +88 -0
- package/dist/components/nk-database.js +14 -5
- package/dist/components/nk-filter-bar.js +57 -36
- package/dist/components/nk-image-picker.js +130 -0
- package/dist/components/nk-menu-item.js +10 -6
- package/dist/components/nk-menu.js +86 -1
- package/dist/components/nk-modal.js +1 -1
- package/dist/components/nk-peek.js +122 -0
- package/dist/components/nk-segmented.js +19 -0
- package/dist/components/nk-sheet.js +97 -0
- package/dist/components/nk-sidebar.js +15 -36
- package/dist/components/nk-steps.js +61 -0
- package/dist/components/shared/{focus-DXrK9oLe.js → focus-BNAChOXO.js} +12 -4
- package/dist/notionkit-elements.esm.js +786 -95
- package/dist/notionkit-elements.js +791 -94
- package/dist/notionkit-elements.min.js +1 -1
- package/package.json +6 -6
- package/src/components/content/nk-bookmark.js +67 -0
- package/src/components/data/nk-database.js +14 -5
- package/src/components/data/nk-filter-bar.js +57 -36
- package/src/components/forms/nk-btn.js +29 -3
- package/src/components/forms/nk-copy-field.js +86 -0
- package/src/components/forms/nk-image-picker.js +128 -0
- package/src/components/overlays/nk-menu-item.js +10 -6
- package/src/components/overlays/nk-menu.js +86 -1
- package/src/components/overlays/nk-peek.js +120 -0
- package/src/components/overlays/nk-sheet.js +95 -0
- package/src/components/page/nk-segmented.js +19 -0
- package/src/components/page/nk-steps.js +59 -0
- package/src/components/shell/nk-sidebar.js +15 -36
- package/src/index.js +10 -0
- package/src/util/focus.js +11 -3
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { NkElement } from './base.js';
|
|
2
|
+
import '@jungherz-de/notionkit/notionkit-styles.js';
|
|
3
|
+
|
|
4
|
+
// <nk-steps label="Connect your own model" current="2"
|
|
5
|
+
// steps="Choose a provider, Enter the API key, Test the connection"></nk-steps>
|
|
6
|
+
// steps.steps = [{ label: 'Choose a provider', desc: 'Anthropic' }, 'Enter the API key', …];
|
|
7
|
+
// → <ol class="nk-steps" aria-label="…">
|
|
8
|
+
// <li class="nk-step done"><span class="st-mark">✓</span><span>Choose a provider<span class="st-desc">Anthropic</span></span></li>
|
|
9
|
+
// <li class="nk-step current" aria-current="step"><span class="st-mark">2</span><span>Enter the API key</span></li>
|
|
10
|
+
// <li class="nk-step"><span class="st-mark">3</span><span>Test the connection</span></li></ol>
|
|
11
|
+
// A setup in a few steps (NotionKit 1.7.0). `current` counts from 1; the
|
|
12
|
+
// steps before it are done, one past the last marks all of them done. The
|
|
13
|
+
// `steps` attribute is a comma-separated list; the property also takes
|
|
14
|
+
// { label, desc } objects for a line under the label.
|
|
15
|
+
class NkSteps extends NkElement {
|
|
16
|
+
static get observedAttributes() { return ['steps', 'current', 'label']; }
|
|
17
|
+
|
|
18
|
+
render() {
|
|
19
|
+
this._list = this.createElement('ol', ['nk-steps']);
|
|
20
|
+
this._wrapper.appendChild(this._list);
|
|
21
|
+
this._sync();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_items() {
|
|
25
|
+
if (this._steps) return this._steps;
|
|
26
|
+
return (this.getAttribute('steps') || '').split(',').map(s => s.trim()).filter(Boolean);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_sync() {
|
|
30
|
+
const label = this.getAttribute('label');
|
|
31
|
+
if (label) this._list.setAttribute('aria-label', label); else this._list.removeAttribute('aria-label');
|
|
32
|
+
const current = this.current;
|
|
33
|
+
this._list.replaceChildren(...this._items().map((step, i) => {
|
|
34
|
+
const n = i + 1, { label: text, desc } = typeof step === 'object' && step ? step : { label: String(step) };
|
|
35
|
+
const li = this.createElement('li', ['nk-step']);
|
|
36
|
+
li.classList.toggle('done', n < current);
|
|
37
|
+
li.classList.toggle('current', n === current);
|
|
38
|
+
if (n === current) li.setAttribute('aria-current', 'step');
|
|
39
|
+
const mark = this.createElement('span', ['st-mark'], { 'aria-hidden': 'true' });
|
|
40
|
+
mark.textContent = n < current ? '✓' : String(n);
|
|
41
|
+
const body = document.createElement('span');
|
|
42
|
+
body.textContent = text ?? '';
|
|
43
|
+
if (desc) { const d = this.createElement('span', ['st-desc']); d.textContent = desc; body.appendChild(d); }
|
|
44
|
+
li.append(mark, body);
|
|
45
|
+
return li;
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onAttributeChanged() { this._sync(); }
|
|
50
|
+
|
|
51
|
+
get steps() { return this._items(); }
|
|
52
|
+
set steps(v) { this._steps = Array.isArray(v) ? v : null; if (this._list) this._sync(); }
|
|
53
|
+
get current() { const n = parseInt(this.getAttribute('current'), 10); return Number.isFinite(n) ? n : 1; }
|
|
54
|
+
set current(v) { this.setAttribute('current', String(v)); }
|
|
55
|
+
/** Moves on to the next step; returns the new current step. */
|
|
56
|
+
next() { this.current = Math.min(this.current + 1, this._items().length + 1); return this.current; }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
customElements.define('nk-steps', NkSteps);
|
|
60
|
+
|
|
61
|
+
export { NkSteps };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Overlay plumbing shared by nk-modal and nk-
|
|
2
|
-
// refcount,
|
|
3
|
-
// assistive technology stay inside – nested shadow roots included
|
|
1
|
+
// Overlay plumbing shared by nk-modal, nk-sheet, nk-cmdk and nk-menu: body
|
|
2
|
+
// scroll lock with a refcount, `inert` on everything outside the overlay so
|
|
3
|
+
// focus and assistive technology stay inside – nested shadow roots included –
|
|
4
|
+
// and the focused element behind shadow hosts, to return focus to.
|
|
4
5
|
let locks = 0, previousOverflow = '';
|
|
5
6
|
|
|
6
7
|
function lockScroll() {
|
|
@@ -31,6 +32,13 @@ function inertOutside(el) {
|
|
|
31
32
|
return () => { for (const c of made) c.inert = false; };
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
/** The focused element itself, looking into shadow roots (document.activeElement stops at the host). */
|
|
36
|
+
function deepActiveElement() {
|
|
37
|
+
let el = document.activeElement;
|
|
38
|
+
while (el?.shadowRoot?.activeElement) el = el.shadowRoot.activeElement;
|
|
39
|
+
return el;
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
/** The first tabbable element inside a light-DOM subtree, looking into shadow roots. */
|
|
35
43
|
function firstFocusable(root) {
|
|
36
44
|
const SEL = 'a[href], button:not([disabled]), input:not([disabled]):not([type=hidden]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [contenteditable="true"], [contenteditable="plaintext-only"]';
|
|
@@ -44,4 +52,4 @@ function firstFocusable(root) {
|
|
|
44
52
|
return walk(root);
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
export { firstFocusable as f, inertOutside as i, lockScroll as l, unlockScroll as u };
|
|
55
|
+
export { deepActiveElement as d, firstFocusable as f, inertOutside as i, lockScroll as l, unlockScroll as u };
|