@jungherz-de/notionkit-elements 1.5.3 β†’ 1.7.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 (115) hide show
  1. package/README.md +27 -18
  2. package/dist/components/base.js +346 -0
  3. package/dist/components/nk-ai-input-row.js +2 -1
  4. package/dist/components/nk-ai-msg.js +10 -3
  5. package/dist/components/nk-ai-thread.js +2 -1
  6. package/dist/components/nk-app.js +2 -1
  7. package/dist/components/nk-avatar-group.js +2 -1
  8. package/dist/components/nk-avatar.js +57 -0
  9. package/dist/components/nk-banner.js +2 -1
  10. package/dist/components/nk-block-host.js +2 -1
  11. package/dist/components/nk-board-view.js +4 -2
  12. package/dist/components/nk-breadcrumb.js +2 -1
  13. package/dist/components/nk-btn.js +31 -4
  14. package/dist/components/nk-callout.js +2 -1
  15. package/dist/components/nk-check.js +2 -1
  16. package/dist/components/nk-cmdk.js +3 -2
  17. package/dist/components/nk-code.js +2 -1
  18. package/dist/components/nk-comment.js +9 -6
  19. package/dist/components/nk-comments.js +2 -1
  20. package/dist/components/nk-danger-zone.js +2 -1
  21. package/dist/components/nk-database.js +16 -6
  22. package/dist/components/nk-divider.js +2 -1
  23. package/dist/components/nk-emoji-picker.js +2 -1
  24. package/dist/components/nk-empty.js +2 -1
  25. package/dist/components/nk-field.js +2 -1
  26. package/dist/components/nk-fields.js +2 -1
  27. package/dist/components/nk-filter-bar.js +59 -37
  28. package/dist/components/nk-heading.js +2 -1
  29. package/dist/components/nk-input.js +2 -1
  30. package/dist/components/nk-kbd.js +2 -1
  31. package/dist/components/nk-list-view.js +96 -0
  32. package/dist/components/nk-member-list.js +2 -1
  33. package/dist/components/nk-member-row.js +10 -6
  34. package/dist/components/nk-mention.js +2 -1
  35. package/dist/components/nk-menu-item.js +27 -3
  36. package/dist/components/nk-menu.js +88 -2
  37. package/dist/components/nk-modal.js +3 -2
  38. package/dist/components/nk-model-card.js +2 -1
  39. package/dist/components/nk-page-actions.js +2 -1
  40. package/dist/components/nk-page-cover.js +12 -11
  41. package/dist/components/nk-page-title.js +2 -1
  42. package/dist/components/nk-page.js +12 -4
  43. package/dist/components/nk-panel.js +61 -0
  44. package/dist/components/nk-panels.js +18 -0
  45. package/dist/components/nk-pop.js +2 -1
  46. package/dist/components/nk-profile-row.js +2 -1
  47. package/dist/components/nk-progress.js +5 -2
  48. package/dist/components/nk-prop.js +54 -0
  49. package/dist/components/nk-props.js +21 -0
  50. package/dist/components/nk-quote.js +2 -1
  51. package/dist/components/nk-radio.js +2 -1
  52. package/dist/components/nk-section-label.js +2 -1
  53. package/dist/components/nk-segmented.js +21 -1
  54. package/dist/components/nk-select.js +2 -1
  55. package/dist/components/nk-settings-pane.js +2 -1
  56. package/dist/components/nk-settings-user.js +2 -1
  57. package/dist/components/nk-sheet.js +97 -0
  58. package/dist/components/nk-sidebar.js +17 -37
  59. package/dist/components/nk-skeleton.js +2 -1
  60. package/dist/components/nk-slider.js +2 -1
  61. package/dist/components/nk-stat.js +2 -1
  62. package/dist/components/nk-stats.js +2 -1
  63. package/dist/components/nk-steps.js +61 -0
  64. package/dist/components/nk-switch.js +2 -1
  65. package/dist/components/nk-synced.js +2 -1
  66. package/dist/components/nk-tab-bar-item.js +2 -1
  67. package/dist/components/nk-tab-bar.js +2 -1
  68. package/dist/components/nk-tab.js +2 -1
  69. package/dist/components/nk-table-view.js +6 -2
  70. package/dist/components/nk-tabs.js +2 -1
  71. package/dist/components/nk-tag.js +2 -1
  72. package/dist/components/nk-template-btn.js +2 -1
  73. package/dist/components/nk-textarea.js +2 -1
  74. package/dist/components/nk-theme-toggle.js +2 -1
  75. package/dist/components/nk-toast.js +2 -1
  76. package/dist/components/nk-todo.js +2 -1
  77. package/dist/components/nk-toggle.js +2 -1
  78. package/dist/components/nk-topbar.js +2 -1
  79. package/dist/components/nk-tree-item.js +2 -1
  80. package/dist/components/nk-tree.js +2 -1
  81. package/dist/components/nk-workspace-switcher.js +2 -1
  82. package/dist/components/shared/avatar-BiqCaHOt.js +19 -0
  83. package/dist/components/shared/{focus-DXrK9oLe.js β†’ focus-BNAChOXO.js} +12 -4
  84. package/dist/components/shared/{property-cell-CtXQpUjQ.js β†’ property-cell-o7N30kAQ.js} +8 -3
  85. package/dist/notionkit-elements.esm.js +759 -120
  86. package/dist/notionkit-elements.js +767 -119
  87. package/dist/notionkit-elements.min.js +1 -1
  88. package/package.json +7 -6
  89. package/src/components/content/nk-progress.js +3 -1
  90. package/src/components/data/nk-ai-msg.js +8 -2
  91. package/src/components/data/nk-comment.js +7 -5
  92. package/src/components/data/nk-database.js +14 -5
  93. package/src/components/data/nk-filter-bar.js +57 -36
  94. package/src/components/data/nk-list-view.js +93 -0
  95. package/src/components/data/nk-table-view.js +2 -0
  96. package/src/components/forms/nk-btn.js +29 -3
  97. package/src/components/overlays/nk-menu-item.js +25 -2
  98. package/src/components/overlays/nk-menu.js +86 -1
  99. package/src/components/overlays/nk-sheet.js +95 -0
  100. package/src/components/page/nk-avatar.js +55 -0
  101. package/src/components/page/nk-member-row.js +8 -5
  102. package/src/components/page/nk-page-cover.js +10 -10
  103. package/src/components/page/nk-page.js +10 -3
  104. package/src/components/page/nk-panel.js +59 -0
  105. package/src/components/page/nk-panels.js +16 -0
  106. package/src/components/page/nk-prop.js +52 -0
  107. package/src/components/page/nk-props.js +19 -0
  108. package/src/components/page/nk-segmented.js +19 -0
  109. package/src/components/page/nk-steps.js +59 -0
  110. package/src/components/shell/nk-sidebar.js +15 -36
  111. package/src/index.js +18 -0
  112. package/src/util/avatar.js +17 -0
  113. package/src/util/focus.js +11 -3
  114. package/src/util/property-cell.js +7 -3
  115. package/dist/components/shared/base-C3eJwHKA.js +0 -366
@@ -1,11 +1,18 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-menu-item icon="✏️" shortcut="⌘E" value="rename">Rename</nk-menu-item>
4
5
  // <nk-menu-item type="separator"></nk-menu-item> <nk-menu-item type="label">Danger</nk-menu-item>
5
6
  // <nk-menu-item icon="πŸ—‘οΈ" danger value="delete">Delete</nk-menu-item>
7
+ // <nk-menu-item type="switch" icon="πŸ”‘" value="small" checked>Small text</nk-menu-item>
8
+ // <nk-menu-item type="check" icon="β—‰" value="open" checked>Status: Open</nk-menu-item>
6
9
  // β†’ <div class="nk-menu-item danger"><span class="m-icon">πŸ—‘οΈ</span>Delete<span class="m-shortcut">…</span></div>
10
+ // A switch item carries a .nk-switch on the right, as "Small text" does in
11
+ // Notion's page menu; a check item a βœ“ where the shortcut stands, as in a
12
+ // filter menu. A click on either flips `checked` and fires nk-change
13
+ // { value, checked } instead of nk-select, so the menu around it stays open.
7
14
  class NkMenuItem extends NkElement {
8
- static get observedAttributes() { return ['icon', 'shortcut', 'danger', 'value', 'type', 'disabled']; }
15
+ static get observedAttributes() { return ['icon', 'shortcut', 'danger', 'value', 'type', 'disabled', 'checked']; }
9
16
 
10
17
  render() { this._build(); }
11
18
 
@@ -18,12 +25,16 @@ class NkMenuItem extends NkElement {
18
25
  el = this.createElement('div', ['nk-menu-label']);
19
26
  el.appendChild(document.createElement('slot'));
20
27
  } else {
21
- el = this.createElement('div', ['nk-menu-item'], { role: 'menuitem', tabindex: '-1' });
28
+ const isSwitch = type === 'switch';
29
+ this._check = type === 'check';
30
+ el = this.createElement('div', ['nk-menu-item'], { role: isSwitch || this._check ? 'menuitemcheckbox' : 'menuitem', tabindex: '-1' });
22
31
  this._icon = this.createElement('span', ['m-icon']);
23
32
  const iconSlot = this.createElement('slot', [], { name: 'icon' });
24
33
  iconSlot.appendChild(this._icon);
25
34
  this._shortcut = this.createElement('span', ['m-shortcut']);
26
35
  el.append(iconSlot, document.createElement('slot'), this._shortcut);
36
+ this._switch = isSwitch ? this.createElement('span', ['nk-switch'], { 'aria-hidden': 'true' }) : null;
37
+ if (this._switch) el.appendChild(this._switch);
27
38
  }
28
39
  if (this._el) { this._el.removeEventListener('click', this._onClick); this._el.replaceWith(el); } else this._wrapper.appendChild(el);
29
40
  this._el = el;
@@ -41,6 +52,12 @@ class NkMenuItem extends NkElement {
41
52
  this._shortcut.style.display = sc ? '' : 'none';
42
53
  this._el.classList.toggle('danger', this.getBoolAttr('danger'));
43
54
  this._el.setAttribute('aria-disabled', this.getBoolAttr('disabled') ? 'true' : 'false');
55
+ if (this._switch || this._check) {
56
+ const on = this.getBoolAttr('checked') ? 'true' : 'false';
57
+ this._el.setAttribute('aria-checked', on);
58
+ if (this._switch) this._switch.setAttribute('aria-checked', on);
59
+ if (this._check) { this._shortcut.textContent = on === 'true' ? 'βœ“' : ''; this._shortcut.style.display = ''; }
60
+ }
44
61
  }
45
62
 
46
63
  setupEvents() {
@@ -52,6 +69,11 @@ class NkMenuItem extends NkElement {
52
69
 
53
70
  select() {
54
71
  if (!this._el.classList.contains('nk-menu-item') || this.getBoolAttr('disabled')) return;
72
+ if (this._switch || this._check) {
73
+ this.checked = !this.checked;
74
+ this.emit('nk-change', { value: this.value, checked: this.checked, item: this });
75
+ return;
76
+ }
55
77
  this.emit('nk-select', { value: this.value, label: this.textContent.trim(), item: this });
56
78
  }
57
79
 
@@ -59,6 +81,8 @@ class NkMenuItem extends NkElement {
59
81
  focus(o) { this._el?.focus(o); }
60
82
  get selectable() { return this._el?.classList.contains('nk-menu-item') && !this.getBoolAttr('disabled'); }
61
83
 
84
+ get checked() { return this.getBoolAttr('checked'); }
85
+ set checked(v) { this.setBoolAttr('checked', v); }
62
86
  get value() { return this.getAttribute('value') ?? this.textContent.trim(); }
63
87
  set value(v) { this.setAttribute('value', v); }
64
88
  }
@@ -1,4 +1,6 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import { d as deepActiveElement } from './shared/focus-BNAChOXO.js';
3
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
4
 
3
5
  // <nk-menu>
4
6
  // <nk-menu-item type="label">Page</nk-menu-item>
@@ -8,13 +10,79 @@ import { N as NkElement } from './shared/base-C3eJwHKA.js';
8
10
  // </nk-menu>
9
11
  // β†’ <div class="nk-pop nk-menu" role="menu">…</div>
10
12
  // ↑↓ move between items, Enter selects, nk-select bubbles from the item.
13
+ //
14
+ // <nk-menu floating sheet> is a menu over the page (NotionKit 1.7.0): it
15
+ // fades in like the palette when `open` is set and is a bottom sheet on a
16
+ // phone. The host becomes the fixed box you position – show(anchor) puts it
17
+ // under the anchor, right edges aligned (align="start": left edges). A tap
18
+ // outside closes it and reaches nothing else; Escape and a chosen item
19
+ // close it too, a switch row does not. Opened from the keyboard, focus moves
20
+ // to the first item; closing returns it to where it was.
21
+ const floatSheet = new CSSStyleSheet();
22
+ floatSheet.replaceSync(`:host([floating]) { display: block; position: fixed; z-index: 60; pointer-events: none; }`);
23
+
24
+ /** The border box of an element, or of the first descendant with one (display: contents hosts). */
25
+ function boxOf(el) {
26
+ if (el.getClientRects().length) return el.getBoundingClientRect();
27
+ for (const child of [...(el.shadowRoot?.children ?? []), ...el.children]) {
28
+ const r = boxOf(child);
29
+ if (r.width || r.height) return r;
30
+ }
31
+ return el.getBoundingClientRect();
32
+ }
33
+
11
34
  class NkMenu extends NkElement {
35
+ static get hostStyles() { return floatSheet; }
36
+ static get observedAttributes() { return ['floating', 'sheet', 'open', 'align']; }
37
+
12
38
  render() {
13
39
  this._box = this.createElement('div', ['nk-pop', 'nk-menu'], { role: 'menu' });
14
40
  this._box.appendChild(document.createElement('slot'));
15
41
  this._wrapper.appendChild(this._box);
42
+ this._syncMode();
43
+ }
44
+
45
+ _syncMode() {
46
+ this._box.classList.toggle('floating', this.getBoolAttr('floating'));
47
+ this._box.classList.toggle('sheet', this.getBoolAttr('sheet'));
48
+ this._box.classList.toggle('open', this.getBoolAttr('open'));
16
49
  }
17
50
 
51
+ onAttributeChanged(name) {
52
+ this._syncMode();
53
+ if (name !== 'open') return;
54
+ const open = this.getBoolAttr('open');
55
+ // aria-expanded belongs on the control itself, inside a host such as <nk-btn>.
56
+ if (this._anchor) (this._anchor.shadowRoot?.querySelector('button, a[href]') ?? this._anchor).setAttribute('aria-expanded', String(open));
57
+ if (open) {
58
+ this._returnFocus = deepActiveElement();
59
+ if (this._returnFocus?.matches(':focus-visible')) requestAnimationFrame(() => this.focusFirst());
60
+ document.addEventListener('click', this._onOutside, true);
61
+ } else {
62
+ document.removeEventListener('click', this._onOutside, true);
63
+ const back = this._returnFocus;
64
+ this._returnFocus = null;
65
+ if (back?.isConnected && this.contains(document.activeElement)) back.focus({ preventScroll: true });
66
+ }
67
+ this.emit('nk-toggle', { open });
68
+ }
69
+
70
+ /** Opens under `anchor` (any element, display: contents hosts included). */
71
+ show(anchor) {
72
+ if (anchor) {
73
+ this._anchor = anchor;
74
+ const r = boxOf(anchor);
75
+ this.style.top = `${r.bottom + 6}px`;
76
+ if (this.getAttribute('align') === 'start') { this.style.left = `${r.left}px`; this.style.right = ''; }
77
+ else { this.style.right = `${Math.max(8, innerWidth - r.right)}px`; this.style.left = ''; }
78
+ }
79
+ this.setBoolAttr('open', true);
80
+ }
81
+ close() { this.setBoolAttr('open', false); }
82
+ toggle(anchor) { this.getBoolAttr('open') ? this.close() : this.show(anchor); }
83
+ get open() { return this.getBoolAttr('open'); }
84
+ set open(v) { this.setBoolAttr('open', v); }
85
+
18
86
  get items() { return [...this.querySelectorAll(':scope > nk-menu-item')].filter(i => i.selectable); }
19
87
 
20
88
  setupEvents() {
@@ -32,9 +100,27 @@ class NkMenu extends NkElement {
32
100
  }
33
101
  };
34
102
  this.addEventListener('keydown', this._onKey);
103
+ // Floating: outside taps close and go nowhere else; Escape and a chosen item close.
104
+ this._onOutside = (e) => {
105
+ const path = e.composedPath();
106
+ if (path.includes(this) || (this._anchor && path.includes(this._anchor))) return;
107
+ e.preventDefault(); e.stopPropagation();
108
+ this.close();
109
+ };
110
+ // Captured, so a menu inside a modal or sheet closes before they do.
111
+ this._onEscape = (e) => { if (e.key === 'Escape' && this.getBoolAttr('floating') && this.getBoolAttr('open')) { e.stopPropagation(); this.close(); } };
112
+ this._onSelect = () => { if (this.getBoolAttr('floating')) this.close(); };
113
+ document.addEventListener('keydown', this._onEscape, true);
114
+ this.addEventListener('nk-select', this._onSelect);
115
+ if (this.getBoolAttr('open')) document.addEventListener('click', this._onOutside, true);
35
116
  }
36
117
 
37
- teardownEvents() { this.removeEventListener('keydown', this._onKey); }
118
+ teardownEvents() {
119
+ this.removeEventListener('keydown', this._onKey);
120
+ document.removeEventListener('keydown', this._onEscape, true);
121
+ this.removeEventListener('nk-select', this._onSelect);
122
+ document.removeEventListener('click', this._onOutside, true);
123
+ }
38
124
 
39
125
  /** Focuses the first item (called by a popover when it opens). */
40
126
  focusFirst() { this.items[0]?.focus(); }
@@ -1,5 +1,6 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
2
- import { l as lockScroll, i as inertOutside, f as firstFocusable, u as unlockScroll } from './shared/focus-DXrK9oLe.js';
1
+ import { NkElement } from './base.js';
2
+ import { l as lockScroll, i as inertOutside, f as firstFocusable, u as unlockScroll } from './shared/focus-BNAChOXO.js';
3
+ import '@jungherz-de/notionkit/notionkit-styles.js';
3
4
 
4
5
  // <nk-modal id="settings">
5
6
  // <nk-settings-user slot="user" name="…" mail="…"></nk-settings-user>
@@ -1,4 +1,5 @@
1
- import { a as NkFormElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkFormElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-model-card name="model" value="gpt" title="Mona Pro" desc="Best for long documents" selected></nk-model-card>
4
5
  // β†’ <div class="nk-model-card selected"><div class="m-radio"></div><div><div class="m-name">…</div><div class="m-desc">…</div></div></div>
@@ -1,4 +1,5 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-page-actions><span>πŸ‘€ Ada</span><span>πŸ“… 12 May</span><span>🏷️ <nk-tag color="purple">Design</nk-tag></span></nk-page-actions>
4
5
  // β†’ <div class="nk-page-meta">…</div> – the meta row under the title
@@ -1,12 +1,17 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-page-cover slot="cover"></nk-page-cover> β†’ the token gradient
4
- // <nk-page-cover slot="cover" src="cover.jpg"></nk-page-cover> β†’ an image
5
+ // <nk-page-cover slot="cover" src="cover.jpg" position="center 30%"></nk-page-cover> β†’ a picture
6
+ // β†’ <div class="nk-cover"><img src="cover.jpg" alt=""></div>: the picture fills
7
+ // the band, cropped rather than stretched; `position` moves the crop, as
8
+ // Notion's "Reposition" does. The gradient stays underneath while it loads.
5
9
  class NkPageCover extends NkElement {
6
- static get observedAttributes() { return ['src']; }
10
+ static get observedAttributes() { return ['src', 'position']; }
7
11
 
8
12
  render() {
9
13
  this._cover = this.createElement('div', ['nk-cover']);
14
+ this._img = this.createElement('img', [], { alt: '' });
10
15
  this._wrapper.appendChild(this._cover);
11
16
  this._sync();
12
17
  }
@@ -14,14 +19,10 @@ class NkPageCover extends NkElement {
14
19
  _sync() {
15
20
  const src = this.getAttribute('src');
16
21
  if (src) {
17
- this._cover.style.backgroundImage = `url("${src}")`;
18
- this._cover.style.backgroundSize = 'cover';
19
- this._cover.style.backgroundPosition = 'center';
20
- } else {
21
- this._cover.style.backgroundImage = '';
22
- this._cover.style.backgroundSize = '';
23
- this._cover.style.backgroundPosition = '';
24
- }
22
+ this._img.src = src;
23
+ this._img.style.objectPosition = this.getAttribute('position') || '';
24
+ if (!this._img.isConnected) this._cover.appendChild(this._img);
25
+ } else this._img.remove();
25
26
  }
26
27
 
27
28
  onAttributeChanged() { this._sync(); }
@@ -1,4 +1,5 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-page-title>NotionKit MVP</nk-page-title> β†’ <h1 class="nk-page-title">
4
5
  // <nk-page-title editable placeholder="Untitled">…</nk-page-title>
@@ -1,6 +1,7 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
- // <nk-page icon="πŸš€" cover>
4
+ // <nk-page icon="πŸš€" cover full small>
4
5
  // <nk-page-title>NotionKit MVP</nk-page-title>
5
6
  // <nk-page-actions>…</nk-page-actions>
6
7
  // <p class="lead">…</p>
@@ -12,9 +13,10 @@ import { N as NkElement } from './shared/base-C3eJwHKA.js';
12
13
  // The host is display:contents, so .nk-page-scroll is the flex child of
13
14
  // .nk-main that scrolls. `narrow` drops the scroll wrapper for pages that are
14
15
  // the document itself (landing / docs skeleton). The page icon is rendered
15
- // here because its ::slotted twin is keyed on the parent (.nk-page).
16
+ // here because its ::slotted twin is keyed on the parent (.nk-page). `full` and
17
+ // `small` are Notion's page options – full width, 14px text – set on the page.
16
18
  class NkPage extends NkElement {
17
- static get observedAttributes() { return ['icon', 'cover', 'narrow']; }
19
+ static get observedAttributes() { return ['icon', 'cover', 'narrow', 'full', 'small']; }
18
20
 
19
21
  render() {
20
22
  this._page = this.createElement('div', ['nk-page']);
@@ -51,6 +53,8 @@ class NkPage extends NkElement {
51
53
  // (attribute or a slotted nk-page-cover) the icon sits in the padding.
52
54
  const slotted = this._coverSlot.assignedNodes().some(n => n.nodeType === Node.ELEMENT_NODE || n.data.trim());
53
55
  this._page.classList.toggle('covered', this.getBoolAttr('cover') || slotted);
56
+ this._page.classList.toggle('full', this.getBoolAttr('full'));
57
+ this._page.classList.toggle('small', this.getBoolAttr('small'));
54
58
  }
55
59
 
56
60
  setupEvents() {
@@ -72,6 +76,10 @@ class NkPage extends NkElement {
72
76
  set icon(v) { v == null ? this.removeAttribute('icon') : this.setAttribute('icon', v); }
73
77
  get cover() { return this.getBoolAttr('cover'); }
74
78
  set cover(v) { this.setBoolAttr('cover', v); }
79
+ get full() { return this.getBoolAttr('full'); }
80
+ set full(v) { this.setBoolAttr('full', v); }
81
+ get small() { return this.getBoolAttr('small'); }
82
+ set small(v) { this.setBoolAttr('small', v); }
75
83
  }
76
84
 
77
85
  customElements.define('nk-page', NkPage);
@@ -0,0 +1,61 @@
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
3
+
4
+ // <nk-panel title="Weekly review"><p>Three pages changed.</p></nk-panel>
5
+ // <nk-panel href="/roadmap" cover="covers/aurora.svg" icon="πŸš€" title="Roadmap"><p>2 min ago</p></nk-panel>
6
+ // β†’ <a class="nk-panel" href="/roadmap"><div class="nk-cover"><img src="…" alt=""></div>
7
+ // <div class="nk-page-icon">πŸš€</div><h3>Roadmap</h3>…</a>
8
+ // `cover` without a value draws the token gradient, with one a picture; `icon`
9
+ // overlaps the cover as on a page – a page tile, as on Notion's Home. With
10
+ // `href` the panel is a link. `title` is the heading, never a tooltip.
11
+ class NkPanel extends NkElement {
12
+ static get observedAttributes() { return ['title', 'icon', 'cover', 'href', 'target']; }
13
+
14
+ render() {
15
+ this._cover = this.createElement('div', ['nk-cover']);
16
+ this._img = this.createElement('img', [], { alt: '' });
17
+ this._icon = this.createElement('div', ['nk-page-icon']);
18
+ this._heading = document.createElement('h3');
19
+ this._slot = document.createElement('slot');
20
+ this.takeTitle();
21
+ this._build();
22
+ }
23
+
24
+ _build() {
25
+ const href = this.getAttribute('href');
26
+ const box = this.createElement(href ? 'a' : 'div', ['nk-panel']);
27
+ box.append(this._cover, this._icon, this._heading, this._slot);
28
+ this._wrapper.replaceChildren(box);
29
+ this._box = box;
30
+ this._sync();
31
+ }
32
+
33
+ _sync() {
34
+ const href = this.getAttribute('href');
35
+ if (href) { this._box.setAttribute('href', href); this._box.target = this.getAttribute('target') || ''; }
36
+ const cover = this.getAttribute('cover');
37
+ this._cover.style.display = cover === null ? 'none' : '';
38
+ if (cover) { this._img.src = cover; if (!this._img.isConnected) this._cover.appendChild(this._img); }
39
+ else this._img.remove();
40
+ const icon = this.getAttribute('icon');
41
+ this._icon.textContent = icon || '';
42
+ this._icon.style.display = icon ? '' : 'none';
43
+ this._heading.textContent = this._titleText || '';
44
+ this._heading.style.display = this._titleText ? '' : 'none';
45
+ }
46
+
47
+ onAttributeChanged(name, _old, value) {
48
+ if (name === 'title' && !this.takeTitle(value)) return;
49
+ if (name === 'href' && (value === null) !== (this._box.localName === 'div')) { this._build(); return; }
50
+ this._sync();
51
+ }
52
+
53
+ get title() { return this._titleText ?? ''; }
54
+ set title(v) { this._titleText = v == null ? '' : String(v); if (this._initialized) this._sync(); }
55
+ get href() { return this.getAttribute('href'); }
56
+ set href(v) { v == null ? this.removeAttribute('href') : this.setAttribute('href', v); }
57
+ }
58
+
59
+ customElements.define('nk-panel', NkPanel);
60
+
61
+ export { NkPanel };
@@ -0,0 +1,18 @@
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
3
+
4
+ // <nk-panels><nk-panel …></nk-panel><nk-panel …></nk-panel></nk-panels>
5
+ // β†’ <div class="nk-panels">…</div>: columns of at least 200px that share the
6
+ // row and fall to one on a phone. The <nk-panel> hosts are display: contents,
7
+ // so each .nk-panel is a cell of this grid.
8
+ class NkPanels extends NkElement {
9
+ render() {
10
+ const grid = this.createElement('div', ['nk-panels']);
11
+ grid.appendChild(document.createElement('slot'));
12
+ this._wrapper.appendChild(grid);
13
+ }
14
+ }
15
+
16
+ customElements.define('nk-panels', NkPanels);
17
+
18
+ export { NkPanels };
@@ -1,4 +1,5 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-pop placement="bottom-start">
4
5
  // <nk-btn slot="trigger" variant="secondary">Options</nk-btn>
@@ -1,4 +1,5 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-profile-row avatar="MK"><nk-btn variant="secondary" small>Change photo</nk-btn></nk-profile-row>
4
5
  // β†’ <div class="nk-profile-row"><div class="big-avatar">MK</div>…</div>
@@ -1,9 +1,11 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-progress value="72" label="72%"></nk-progress>
5
+ // <nk-progress value="72" label="72 %" wide></nk-progress> β†’ fills its row, the label stays beside it
4
6
  // The bar is `.nk-progress > i` β€” a child combinator, so both nodes live here.
5
7
  class NkProgress extends NkElement {
6
- static get observedAttributes() { return ['value', 'max', 'label']; }
8
+ static get observedAttributes() { return ['value', 'max', 'label', 'wide']; }
7
9
 
8
10
  render() {
9
11
  this._bar = this.createElement('span', ['nk-progress'], { role: 'progressbar' });
@@ -22,6 +24,7 @@ class NkProgress extends NkElement {
22
24
  const max = Number(this.getAttribute('max')) || 100;
23
25
  const value = Math.min(max, Math.max(0, Number(this.getAttribute('value')) || 0));
24
26
  this._fill.style.width = `${(value / max) * 100}%`;
27
+ this._bar.classList.toggle('wide', this.getBoolAttr('wide'));
25
28
  this._bar.setAttribute('aria-valuenow', value);
26
29
  this._bar.setAttribute('aria-valuemin', 0);
27
30
  this._bar.setAttribute('aria-valuemax', max);
@@ -0,0 +1,54 @@
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
3
+
4
+ // <nk-prop label="Due" icon="πŸ“…">2 June 2026</nk-prop>
5
+ // β†’ <div class="nk-prop"><dt class="p-name"><span class="p-icon">πŸ“…</span>Due</dt><dd class="p-value">2 June 2026</dd></div>
6
+ // The value is the element's content – tags, an avatar and a name, a date, a
7
+ // <nk-progress wide>. slot="icon" replaces the icon glyph. A click on the
8
+ // name or the value fires nk-action { action: 'name' | 'value', label }, the
9
+ // moment Notion opens the property's editor.
10
+ class NkProp extends NkElement {
11
+ static get observedAttributes() { return ['label', 'icon']; }
12
+
13
+ render() {
14
+ this._row = this.createElement('div', ['nk-prop']);
15
+ this._name = this.createElement('dt', ['p-name']);
16
+ this._icon = this.createElement('span', ['p-icon']);
17
+ const iconSlot = this.createElement('slot', [], { name: 'icon' });
18
+ iconSlot.appendChild(this._icon);
19
+ this._label = document.createTextNode('');
20
+ this._name.append(iconSlot, this._label);
21
+ this._value = this.createElement('dd', ['p-value']);
22
+ this._value.appendChild(document.createElement('slot'));
23
+ this._row.append(this._name, this._value);
24
+ this._wrapper.appendChild(this._row);
25
+ this._sync();
26
+ }
27
+
28
+ _sync() {
29
+ const icon = this.getAttribute('icon');
30
+ this._icon.textContent = icon || '';
31
+ this._icon.style.display = icon ? '' : 'none';
32
+ this._label.data = this.getAttribute('label') || '';
33
+ }
34
+
35
+ setupEvents() {
36
+ this._onClick = (e) => {
37
+ const part = e.composedPath().includes(this._name) ? 'name' : 'value';
38
+ this.emit('nk-action', { action: part, label: this.label });
39
+ };
40
+ this._row.addEventListener('click', this._onClick);
41
+ }
42
+
43
+ teardownEvents() { this._row?.removeEventListener('click', this._onClick); }
44
+ onAttributeChanged() { this._sync(); }
45
+
46
+ get label() { return this.getAttribute('label') || ''; }
47
+ set label(v) { this.setAttribute('label', v); }
48
+ get icon() { return this.getAttribute('icon'); }
49
+ set icon(v) { v == null ? this.removeAttribute('icon') : this.setAttribute('icon', v); }
50
+ }
51
+
52
+ customElements.define('nk-prop', NkProp);
53
+
54
+ export { NkProp };
@@ -0,0 +1,21 @@
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
3
+
4
+ // <nk-props>
5
+ // <nk-prop label="Status" icon="β—‰"><nk-tag color="blue">In progress</nk-tag></nk-prop>
6
+ // <nk-prop label="Owner" icon="πŸ‘€"><nk-avatar size="small">MK</nk-avatar>Marcel Karas</nk-prop>
7
+ // </nk-props>
8
+ // β†’ <dl class="nk-props">…</dl> – the properties under a page title. The rows
9
+ // are <nk-prop> hosts with display: contents, so each .nk-prop is a row of
10
+ // this list.
11
+ class NkProps extends NkElement {
12
+ render() {
13
+ const list = this.createElement('dl', ['nk-props']);
14
+ list.appendChild(document.createElement('slot'));
15
+ this._wrapper.appendChild(list);
16
+ }
17
+ }
18
+
19
+ customElements.define('nk-props', NkProps);
20
+
21
+ export { NkProps };
@@ -1,4 +1,5 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-quote cite="Ada Lovelace">The Analytical Engine weaves…</nk-quote>
4
5
  // .q-cite has no ::slotted() twin, so the citation is rendered here.
@@ -1,4 +1,5 @@
1
- import { a as NkFormElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkFormElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-radio name="style" value="concise" checked>Concise</nk-radio>
4
5
  // β†’ <label class="nk-check"><input type="radio"> Concise</label>
@@ -1,4 +1,5 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-section-label addable>Favourites</nk-section-label>
4
5
  // β†’ <div class="nk-section-label">Favourites <span class="plus">οΌ‹</span></div>
@@ -1,4 +1,5 @@
1
- import { a as NkFormElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkFormElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-segmented name="range" value="week">
4
5
  // <button value="week">Week</button><button value="month">Month</button>
@@ -6,6 +7,9 @@ import { a as NkFormElement } from './shared/base-C3eJwHKA.js';
6
7
  // β†’ <div class="nk-segmented">…</div> with .active on the chosen button.
7
8
  // The buttons stay in the light DOM (their look comes from the ::slotted
8
9
  // twins); the element sets type/role, moves .active and submits the value.
10
+ // With `scroll` the chosen option is kept in view – after the first layout,
11
+ // on every change and when the row's width changes – by scrolling the row
12
+ // alone, never the page, by a relative distance, so right-to-left works too.
9
13
  const KEYS = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 };
10
14
 
11
15
  class NkSegmented extends NkFormElement {
@@ -49,6 +53,19 @@ class NkSegmented extends NkFormElement {
49
53
  }
50
54
  this._value = value;
51
55
  this.setFormValue(value);
56
+ this._reveal(this._revealed ? 'smooth' : 'instant');
57
+ }
58
+
59
+ /** Scrolls the row the least distance that shows the chosen button whole. */
60
+ _reveal(behavior) {
61
+ if (!this.getBoolAttr('scroll') || !this._box?.clientWidth) return;
62
+ const btn = this.buttons.find(b => b.classList.contains('active'));
63
+ if (!btn) return;
64
+ const row = this._box.getBoundingClientRect(), r = btn.getBoundingClientRect(), pad = 8;
65
+ const delta = r.left < row.left ? r.left - row.left - pad : r.right > row.right ? r.right - row.right + pad : 0;
66
+ const smooth = behavior === 'smooth' && !matchMedia('(prefers-reduced-motion: reduce)').matches;
67
+ if (delta) this._box.scrollBy({ left: delta, behavior: smooth ? 'smooth' : 'instant' });
68
+ this._revealed = true;
52
69
  }
53
70
 
54
71
  setupEvents() {
@@ -72,6 +89,8 @@ class NkSegmented extends NkFormElement {
72
89
  this._slot.addEventListener('slotchange', this._onSlot);
73
90
  this.addEventListener('click', this._onClick);
74
91
  this.addEventListener('keydown', this._onKey);
92
+ this._resize = new ResizeObserver(() => this._reveal('instant'));
93
+ this._resize.observe(this._box);
75
94
  this._sync();
76
95
  }
77
96
 
@@ -79,6 +98,7 @@ class NkSegmented extends NkFormElement {
79
98
  this._slot?.removeEventListener('slotchange', this._onSlot);
80
99
  this.removeEventListener('click', this._onClick);
81
100
  this.removeEventListener('keydown', this._onKey);
101
+ this._resize?.disconnect();
82
102
  }
83
103
 
84
104
  _choose(value) {
@@ -1,4 +1,5 @@
1
- import { a as NkFormElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkFormElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-select name="role" value="editor">
4
5
  // <option value="viewer">Viewer</option>
@@ -1,4 +1,5 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-settings-pane name="profile" label="My profile" icon="πŸ‘€" group="Account" title="My profile" active>…</nk-settings-pane>
4
5
  // `title` is the heading, never a tooltip – see NkElement.takeTitle().
@@ -1,4 +1,5 @@
1
- import { N as NkElement } from './shared/base-C3eJwHKA.js';
1
+ import { NkElement } from './base.js';
2
+ import '@jungherz-de/notionkit/notionkit-styles.js';
2
3
 
3
4
  // <nk-settings-user slot="user" name="Marcel Karas" mail="marcel@…" avatar="MK"></nk-settings-user>
4
5
  // β†’ <div class="nk-settings-user"><div class="avatar">MK</div><div class="u-text"><div class="name">…</div><div class="mail">…</div></div></div>