@jungherz-de/notionkit-elements 1.15.0 → 1.16.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/CHANGELOG.md +19 -0
- package/README.md +9 -7
- package/SKILL.md +29 -27
- package/dist/components/base.js +4 -0
- package/dist/components/nk-calendar.js +2 -2
- package/dist/components/nk-cmdk.js +1 -1
- package/dist/components/nk-dialog.js +1 -1
- package/dist/components/nk-menu.js +2 -2
- package/dist/components/nk-modal.js +1 -1
- package/dist/components/nk-panel.js +4 -1
- package/dist/components/nk-peek.js +1 -1
- package/dist/components/nk-select.js +13 -8
- package/dist/components/nk-sheet.js +1 -1
- package/dist/components/nk-sidebar.js +1 -1
- package/dist/components/nk-tooltip.js +1 -1
- package/dist/components/shared/{focus-BNAChOXO.js → focus-C4tbSNND.js} +7 -2
- package/dist/notionkit-elements.esm.js +32 -15
- package/dist/notionkit-elements.esm.min.js +2 -0
- package/dist/notionkit-elements.esm.min.js.map +1 -0
- package/dist/notionkit-elements.js +32 -15
- package/dist/notionkit-elements.min.js +1 -1
- package/package.json +4 -3
- package/src/base.js +4 -0
- package/src/components/forms/nk-calendar.js +1 -1
- package/src/components/forms/nk-select.js +13 -8
- package/src/components/overlays/nk-menu.js +1 -1
- package/src/components/page/nk-panel.js +4 -1
- package/src/util/focus.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jungherz-de/notionkit-elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Vanilla JavaScript Web Components wrapping the NotionKit CSS foundation – <nk-*> custom elements with Shadow DOM, automatic theme sync and native form participation.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jungherz GmbH <info@jungherz.com> (https://www.jungherz.com)",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"import": "./dist/notionkit-elements.esm.js",
|
|
21
21
|
"default": "./dist/notionkit-elements.js"
|
|
22
22
|
},
|
|
23
|
+
"./esm.min.js": "./dist/notionkit-elements.esm.min.js",
|
|
23
24
|
"./base.js": "./dist/components/base.js",
|
|
24
25
|
"./components/*.js": "./dist/components/*.js",
|
|
25
26
|
"./package.json": "./package.json"
|
|
@@ -62,10 +63,10 @@
|
|
|
62
63
|
"dark-mode"
|
|
63
64
|
],
|
|
64
65
|
"peerDependencies": {
|
|
65
|
-
"@jungherz-de/notionkit": ">=1.
|
|
66
|
+
"@jungherz-de/notionkit": ">=1.16.0"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@jungherz-de/notionkit": "^1.
|
|
69
|
+
"@jungherz-de/notionkit": "^1.16.0",
|
|
69
70
|
"@playwright/test": "^1.50.0",
|
|
70
71
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
71
72
|
"@rollup/plugin-terser": "^0.4.0",
|
package/src/base.js
CHANGED
|
@@ -60,6 +60,9 @@ if (typeof window !== 'undefined' && typeof MutationObserver !== 'undefined') {
|
|
|
60
60
|
// Layout plumbing only: how the host box participates in the outer layout, and
|
|
61
61
|
// that `hidden` keeps working. :host([hidden]) has a higher specificity than
|
|
62
62
|
// :host, so it wins regardless of order. The wrapper is layout-transparent.
|
|
63
|
+
// `flush` on any element drops the outer margin of its box (NotionKit
|
|
64
|
+
// 1.16.0) – for a block in a flex column with a gap of its own; a whole
|
|
65
|
+
// column does it for every block with --nk-block-space: 0.
|
|
63
66
|
|
|
64
67
|
const hostSheets = new Map();
|
|
65
68
|
|
|
@@ -70,6 +73,7 @@ function hostSheetFor(display) {
|
|
|
70
73
|
sheet.replaceSync(`
|
|
71
74
|
:host { display: ${display}; }
|
|
72
75
|
:host([hidden]) { display: none; }
|
|
76
|
+
:host([flush]) .nk-wrapper > * { margin-top: 0; margin-bottom: 0; }
|
|
73
77
|
.nk-wrapper { display: contents; }
|
|
74
78
|
`);
|
|
75
79
|
hostSheets.set(display, sheet);
|
|
@@ -43,7 +43,7 @@ import { deepActiveElement } from '../../util/focus.js';
|
|
|
43
43
|
// outside does. Put a floating calendar directly under <body>.
|
|
44
44
|
const STEPS = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 };
|
|
45
45
|
const floatSheet = new CSSStyleSheet();
|
|
46
|
-
floatSheet.replaceSync(`:host([floating]) { display: block; position: fixed; top: 0; left: 0; z-index:
|
|
46
|
+
floatSheet.replaceSync(`:host([floating]) { display: block; position: fixed; top: 0; left: 0; z-index: 106; pointer-events: none; }`);
|
|
47
47
|
|
|
48
48
|
class NkCalendar extends NkFormElement {
|
|
49
49
|
static get hostStyles() { return floatSheet; }
|
|
@@ -8,8 +8,10 @@ import { NkFormElement } from '../../base.js';
|
|
|
8
8
|
// The light-DOM <option>s are copied into the shadow <select>. A
|
|
9
9
|
// MutationObserver keeps the copy in step when a framework swaps them; the
|
|
10
10
|
// empty string is a valid value; the live selection survives a rebuild. A
|
|
11
|
-
// value
|
|
12
|
-
//
|
|
11
|
+
// value – attribute or property – whose option is not there yet waits and
|
|
12
|
+
// wins over the browser's preselection once the option arrives, unless
|
|
13
|
+
// someone has chosen another option in the meantime; settling on it fires
|
|
14
|
+
// no nk-change.
|
|
13
15
|
class NkSelect extends NkFormElement {
|
|
14
16
|
static get observedAttributes() { return ['value', 'name', 'disabled', 'required', 'compact', 'wide', 'aria-label']; }
|
|
15
17
|
static get observesLightDom() { return true; }
|
|
@@ -19,6 +21,7 @@ class NkSelect extends NkFormElement {
|
|
|
19
21
|
this._forwardAll();
|
|
20
22
|
this._wrapper.appendChild(this._select);
|
|
21
23
|
this._defaultValue = this.getAttribute('value');
|
|
24
|
+
this._pending = this._defaultValue;
|
|
22
25
|
// Children may not be parsed yet when connectedCallback runs.
|
|
23
26
|
this.projectLightDom();
|
|
24
27
|
requestAnimationFrame(() => this.projectLightDom());
|
|
@@ -52,11 +55,11 @@ class NkSelect extends NkFormElement {
|
|
|
52
55
|
this._select.innerHTML = '';
|
|
53
56
|
for (const node of nodes) this._select.appendChild(node.cloneNode(true));
|
|
54
57
|
|
|
55
|
-
// A value that
|
|
56
|
-
//
|
|
57
|
-
// default (first option / `selected`).
|
|
58
|
-
if (this._pending != null
|
|
59
|
-
else
|
|
58
|
+
// A value that waits for its option first – it keeps waiting while the
|
|
59
|
+
// option is missing; else the live selection when it survived; else the
|
|
60
|
+
// browser default (first option / `selected`).
|
|
61
|
+
if (this._pending != null) { if (this._applyValue(this._pending)) this._pending = null; }
|
|
62
|
+
else this._applyValue(previous);
|
|
60
63
|
this._syncFormValue();
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -85,7 +88,8 @@ class NkSelect extends NkFormElement {
|
|
|
85
88
|
onAttributeChanged(name) {
|
|
86
89
|
if (!this._select) return;
|
|
87
90
|
if (name === 'value') {
|
|
88
|
-
this.
|
|
91
|
+
const value = this.getAttribute('value');
|
|
92
|
+
this._pending = value === null || this._applyValue(value) ? null : value;
|
|
89
93
|
this._syncFormValue();
|
|
90
94
|
return;
|
|
91
95
|
}
|
|
@@ -99,6 +103,7 @@ class NkSelect extends NkFormElement {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
resetValue() {
|
|
106
|
+
this._pending = null;
|
|
102
107
|
if (!this._applyValue(this._defaultValue)) this._select.selectedIndex = 0;
|
|
103
108
|
this._syncFormValue();
|
|
104
109
|
}
|
|
@@ -19,7 +19,7 @@ import { placeUnder } from '../../util/floating.js';
|
|
|
19
19
|
// close it too, a switch row does not. Opened from the keyboard, focus moves
|
|
20
20
|
// to the first item; closing returns it to where it was.
|
|
21
21
|
const floatSheet = new CSSStyleSheet();
|
|
22
|
-
floatSheet.replaceSync(`:host([floating]) { display: block; position: fixed; top: 0; left: 0; z-index:
|
|
22
|
+
floatSheet.replaceSync(`:host([floating]) { display: block; position: fixed; top: 0; left: 0; z-index: 106; pointer-events: none; }`);
|
|
23
23
|
|
|
24
24
|
class NkMenu extends NkElement {
|
|
25
25
|
static get hostStyles() { return floatSheet; }
|
|
@@ -42,7 +42,10 @@ class NkPanel extends NkElement {
|
|
|
42
42
|
const href = this.getAttribute('href');
|
|
43
43
|
if (href) { this._box.setAttribute('href', href); this._box.target = this.getAttribute('target') || ''; }
|
|
44
44
|
const cover = this.getAttribute('cover');
|
|
45
|
-
|
|
45
|
+
// The band is in the tree only with `cover`: hidden, it still matched
|
|
46
|
+
// `.nk-cover + .nk-page-icon` and pulled a lone icon over the tile's edge.
|
|
47
|
+
if (cover === null) this._cover.remove();
|
|
48
|
+
else if (!this._cover.isConnected) this._box.prepend(this._cover);
|
|
46
49
|
if (cover) { this._img.src = cover; if (!this._img.isConnected) this._cover.appendChild(this._img); }
|
|
47
50
|
else this._img.remove();
|
|
48
51
|
const icon = this.getAttribute('icon');
|
package/src/util/focus.js
CHANGED
|
@@ -15,7 +15,12 @@ export function unlockScroll() {
|
|
|
15
15
|
if (locks > 0 && --locks === 0) document.documentElement.style.overflow = previousOverflow;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// Floating layers under <body> that open from inside an overlay – a menu, a
|
|
19
|
+
// date picker – and the tooltip and toast stay usable: made inert, a date
|
|
20
|
+
// picker opened from a dialog showed but took no click.
|
|
21
|
+
const LAYERS = 'nk-menu[floating], nk-calendar[floating], nk-tooltip, nk-toast';
|
|
22
|
+
|
|
23
|
+
/** Makes every sibling along `el`'s ancestor chain inert (shadow hosts included), floating layers aside; returns the undo. */
|
|
19
24
|
export function inertOutside(el) {
|
|
20
25
|
const made = [];
|
|
21
26
|
let node = el;
|
|
@@ -23,7 +28,7 @@ export function inertOutside(el) {
|
|
|
23
28
|
const parent = node.parentNode instanceof ShadowRoot ? node.parentNode : node.parentNode;
|
|
24
29
|
if (!parent) break;
|
|
25
30
|
for (const sib of parent.children) {
|
|
26
|
-
if (sib === node || sib.inert || /^(SCRIPT|STYLE|LINK|TEMPLATE)$/.test(sib.tagName)) continue;
|
|
31
|
+
if (sib === node || sib.inert || /^(SCRIPT|STYLE|LINK|TEMPLATE)$/.test(sib.tagName) || sib.matches(LAYERS)) continue;
|
|
27
32
|
sib.inert = true;
|
|
28
33
|
made.push(sib);
|
|
29
34
|
}
|