anentrypoint-design 0.0.121 → 0.0.124

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 (202) hide show
  1. package/README.md +253 -253
  2. package/app-shell.css +931 -594
  3. package/colors_and_type.css +226 -226
  4. package/community.css +817 -1222
  5. package/dist/247420.css +2202 -2084
  6. package/dist/247420.js +13 -13
  7. package/package.json +80 -80
  8. package/src/bootstrap.js +25 -25
  9. package/src/components/chat.js +199 -199
  10. package/src/components/community.js +190 -208
  11. package/src/components/content.js +269 -269
  12. package/src/components/editor-primitives.js +100 -0
  13. package/src/components/files-modals.js +107 -107
  14. package/src/components/files.js +118 -118
  15. package/src/components/freddie/helpers.js +50 -50
  16. package/src/components/freddie.js +33 -33
  17. package/src/components/shell.js +117 -117
  18. package/src/components/theme-toggle.js +70 -70
  19. package/src/components.js +59 -57
  20. package/src/debug.js +30 -30
  21. package/src/deck-stage.js +21 -21
  22. package/src/highlight.js +65 -32
  23. package/src/index.js +86 -86
  24. package/src/kits/os/about-app.js +52 -52
  25. package/src/kits/os/app-panes.css +152 -152
  26. package/src/kits/os/browser-app.js +58 -58
  27. package/src/kits/os/files-app.js +44 -44
  28. package/src/kits/os/freddie/helpers.js +59 -59
  29. package/src/kits/os/freddie/pages-chat.js +143 -143
  30. package/src/kits/os/freddie/pages-core.js +101 -101
  31. package/src/kits/os/freddie/pages-os.js +51 -51
  32. package/src/kits/os/freddie/pages-tools.js +183 -183
  33. package/src/kits/os/freddie/routes.js +24 -24
  34. package/src/kits/os/freddie-dashboard.css +51 -51
  35. package/src/kits/os/freddie-dashboard.js +101 -101
  36. package/src/kits/os/icons.js +17 -17
  37. package/src/kits/os/index.js +17 -17
  38. package/src/kits/os/launcher.css +61 -61
  39. package/src/kits/os/launcher.js +79 -79
  40. package/src/kits/os/monitor-app.js +34 -34
  41. package/src/kits/os/shell.js +214 -214
  42. package/src/kits/os/terminal-app.js +45 -45
  43. package/src/kits/os/theme.css +450 -450
  44. package/src/kits/os/validate.css +19 -19
  45. package/src/kits/os/validator-app.js +55 -55
  46. package/src/kits/os/wm.css +115 -115
  47. package/src/kits/os/wm.js +111 -111
  48. package/src/markdown.js +39 -39
  49. package/src/motion.js +35 -35
  50. package/src/page-html.js +196 -196
  51. package/src/styles.js +25 -25
  52. package/src/theme.js +99 -99
  53. package/src/web-components/ds-chat.js +116 -116
  54. package/dist/.nojekyll +0 -0
  55. package/dist/app-shell.css +0 -594
  56. package/dist/colors_and_type.css +0 -197
  57. package/dist/favicon.svg +0 -1
  58. package/dist/index.html +0 -308
  59. package/dist/preview/buttons.html +0 -28
  60. package/dist/preview/colors-core.html +0 -45
  61. package/dist/preview/colors-lore.html +0 -28
  62. package/dist/preview/colors-semantic.html +0 -34
  63. package/dist/preview/dateline.html +0 -19
  64. package/dist/preview/dropzone.html +0 -30
  65. package/dist/preview/file-grid.html +0 -19
  66. package/dist/preview/file-row.html +0 -20
  67. package/dist/preview/file-toolbar.html +0 -40
  68. package/dist/preview/file-viewer.html +0 -31
  69. package/dist/preview/header.html +0 -24
  70. package/dist/preview/icons-unicode.html +0 -26
  71. package/dist/preview/index-row.html +0 -25
  72. package/dist/preview/inputs.html +0 -22
  73. package/dist/preview/manifesto.html +0 -52
  74. package/dist/preview/motion-default.js +0 -106
  75. package/dist/preview/rules.html +0 -16
  76. package/dist/preview/spacing.html +0 -18
  77. package/dist/preview/stamps-lore.html +0 -20
  78. package/dist/preview/stamps.html +0 -14
  79. package/dist/preview/theme-ink.html +0 -15
  80. package/dist/preview/type-display.html +0 -16
  81. package/dist/preview/type-mono.html +0 -15
  82. package/dist/preview/type-prose.html +0 -11
  83. package/dist/preview/type-scale.html +0 -20
  84. package/dist/preview/wordmarks.html +0 -28
  85. package/dist/robots.txt +0 -8
  86. package/dist/site/content/globals/navigation.yaml +0 -5
  87. package/dist/site/content/globals/site.yaml +0 -16
  88. package/dist/site/content/pages/freddie.yaml +0 -88
  89. package/dist/site/content/pages/home.yaml +0 -190
  90. package/dist/site/theme.mjs +0 -368
  91. package/dist/sitemap.xml +0 -31
  92. package/dist/slides/deck-stage-overlay.js +0 -63
  93. package/dist/slides/deck-stage-state.js +0 -81
  94. package/dist/slides/deck-stage-style.js +0 -117
  95. package/dist/slides/deck-stage.js +0 -159
  96. package/dist/slides/index.html +0 -276
  97. package/dist/src/bootstrap.js +0 -25
  98. package/dist/src/components/chat.js +0 -199
  99. package/dist/src/components/community.js +0 -167
  100. package/dist/src/components/content.js +0 -213
  101. package/dist/src/components/files-modals.js +0 -107
  102. package/dist/src/components/files.js +0 -118
  103. package/dist/src/components/freddie/helpers.js +0 -50
  104. package/dist/src/components/freddie.js +0 -33
  105. package/dist/src/components/shell.js +0 -117
  106. package/dist/src/components/theme-toggle.js +0 -70
  107. package/dist/src/components.js +0 -52
  108. package/dist/src/debug.js +0 -30
  109. package/dist/src/deck-stage.js +0 -21
  110. package/dist/src/highlight.js +0 -32
  111. package/dist/src/index.js +0 -86
  112. package/dist/src/kits/os/about-app.js +0 -52
  113. package/dist/src/kits/os/app-panes.css +0 -152
  114. package/dist/src/kits/os/browser-app.js +0 -58
  115. package/dist/src/kits/os/files-app.js +0 -44
  116. package/dist/src/kits/os/freddie/helpers.js +0 -59
  117. package/dist/src/kits/os/freddie/pages-chat.js +0 -143
  118. package/dist/src/kits/os/freddie/pages-core.js +0 -101
  119. package/dist/src/kits/os/freddie/pages-os.js +0 -51
  120. package/dist/src/kits/os/freddie/pages-tools.js +0 -183
  121. package/dist/src/kits/os/freddie/routes.js +0 -24
  122. package/dist/src/kits/os/freddie-dashboard.css +0 -51
  123. package/dist/src/kits/os/freddie-dashboard.js +0 -101
  124. package/dist/src/kits/os/icons.js +0 -17
  125. package/dist/src/kits/os/index.js +0 -5
  126. package/dist/src/kits/os/launcher.css +0 -61
  127. package/dist/src/kits/os/launcher.js +0 -79
  128. package/dist/src/kits/os/monitor-app.js +0 -34
  129. package/dist/src/kits/os/shell.js +0 -214
  130. package/dist/src/kits/os/terminal-app.js +0 -45
  131. package/dist/src/kits/os/theme.css +0 -412
  132. package/dist/src/kits/os/validate.css +0 -19
  133. package/dist/src/kits/os/validator-app.js +0 -55
  134. package/dist/src/kits/os/wm.css +0 -115
  135. package/dist/src/kits/os/wm.js +0 -111
  136. package/dist/src/markdown.js +0 -39
  137. package/dist/src/motion.js +0 -35
  138. package/dist/src/page-html.js +0 -196
  139. package/dist/src/styles.js +0 -25
  140. package/dist/src/theme.js +0 -99
  141. package/dist/src/web-components/ds-chat.js +0 -45
  142. package/dist/ui_kits/aicat/README.md +0 -7
  143. package/dist/ui_kits/aicat/app.js +0 -156
  144. package/dist/ui_kits/aicat/index.html +0 -26
  145. package/dist/ui_kits/aicat/sample-square.png +0 -0
  146. package/dist/ui_kits/aicat/sample-svg.svg +0 -1
  147. package/dist/ui_kits/aicat/sample.pdf +0 -32
  148. package/dist/ui_kits/blog/README.md +0 -3
  149. package/dist/ui_kits/blog/index.html +0 -90
  150. package/dist/ui_kits/chat/README.md +0 -5
  151. package/dist/ui_kits/chat/app.js +0 -110
  152. package/dist/ui_kits/chat/index.html +0 -26
  153. package/dist/ui_kits/chat/sample-square.png +0 -0
  154. package/dist/ui_kits/chat/sample-svg.svg +0 -1
  155. package/dist/ui_kits/chat/sample.pdf +0 -32
  156. package/dist/ui_kits/community/app.js +0 -134
  157. package/dist/ui_kits/community/index.html +0 -24
  158. package/dist/ui_kits/dashboard/app.js +0 -92
  159. package/dist/ui_kits/dashboard/index.html +0 -26
  160. package/dist/ui_kits/docs/README.md +0 -3
  161. package/dist/ui_kits/docs/index.html +0 -123
  162. package/dist/ui_kits/error_404/app.js +0 -56
  163. package/dist/ui_kits/error_404/index.html +0 -26
  164. package/dist/ui_kits/file_browser/README.md +0 -48
  165. package/dist/ui_kits/file_browser/app.js +0 -231
  166. package/dist/ui_kits/file_browser/index.html +0 -33
  167. package/dist/ui_kits/gallery/app.js +0 -121
  168. package/dist/ui_kits/gallery/index.html +0 -26
  169. package/dist/ui_kits/homepage/README.md +0 -7
  170. package/dist/ui_kits/homepage/app.js +0 -167
  171. package/dist/ui_kits/homepage/index.html +0 -46
  172. package/dist/ui_kits/project_page/README.md +0 -3
  173. package/dist/ui_kits/project_page/app.js +0 -154
  174. package/dist/ui_kits/project_page/index.html +0 -45
  175. package/dist/ui_kits/search/app.js +0 -107
  176. package/dist/ui_kits/search/index.html +0 -26
  177. package/dist/ui_kits/settings/app.js +0 -133
  178. package/dist/ui_kits/settings/index.html +0 -26
  179. package/dist/ui_kits/signin/app.js +0 -115
  180. package/dist/ui_kits/signin/index.html +0 -26
  181. package/dist/ui_kits/slide_deck/app.js +0 -174
  182. package/dist/ui_kits/slide_deck/index.html +0 -26
  183. package/dist/ui_kits/system_primer/app.js +0 -152
  184. package/dist/ui_kits/system_primer/index.html +0 -26
  185. package/dist/ui_kits/terminal/app.js +0 -150
  186. package/dist/ui_kits/terminal/index.html +0 -26
  187. package/dist/vendor/webjsx/applyDiff.js +0 -182
  188. package/dist/vendor/webjsx/attributes.js +0 -154
  189. package/dist/vendor/webjsx/constants.js +0 -4
  190. package/dist/vendor/webjsx/createDOMElement.js +0 -52
  191. package/dist/vendor/webjsx/createElement.js +0 -75
  192. package/dist/vendor/webjsx/elementTags.js +0 -115
  193. package/dist/vendor/webjsx/factory.js +0 -6
  194. package/dist/vendor/webjsx/index.js +0 -6
  195. package/dist/vendor/webjsx/jsx-dev-runtime.js +0 -2
  196. package/dist/vendor/webjsx/jsx-runtime.js +0 -30
  197. package/dist/vendor/webjsx/jsx.js +0 -2
  198. package/dist/vendor/webjsx/package.json +0 -39
  199. package/dist/vendor/webjsx/renderSuspension.js +0 -25
  200. package/dist/vendor/webjsx/types.js +0 -5
  201. package/dist/vendor/webjsx/utils.js +0 -84
  202. package/src/components/overlays.js +0 -151
package/src/theme.js CHANGED
@@ -1,99 +1,99 @@
1
- // 247420 design system — theme controller.
2
- //
3
- // Three modes:
4
- // 'auto' — follow OS (prefers-color-scheme). Live-updates on OS change.
5
- // 'paper' — force light.
6
- // 'ink' — force dark.
7
- //
8
- // Writes the chosen mode to <html data-theme="..."> so CSS rules in
9
- // system.css / colors_and_type.css resolve correctly. Persists to
10
- // localStorage under '247420:theme'. Auto-initializes on import in a
11
- // browser context; safe no-op on server.
12
-
13
- const KEY = '247420:theme';
14
- const VALID = new Set(['auto', 'paper', 'ink']);
15
- const listeners = new Set();
16
- let _mq = null;
17
- let _current = 'auto';
18
-
19
- function isBrowser() {
20
- return typeof document !== 'undefined' && typeof window !== 'undefined';
21
- }
22
-
23
- function readStored() {
24
- try {
25
- const v = window.localStorage.getItem(KEY);
26
- return VALID.has(v) ? v : null;
27
- } catch { return null; }
28
- }
29
-
30
- function writeStored(mode) {
31
- try { window.localStorage.setItem(KEY, mode); } catch {}
32
- }
33
-
34
- function writeAttr(mode) {
35
- if (!isBrowser()) return;
36
- document.documentElement.setAttribute('data-theme', mode);
37
- }
38
-
39
- function ensureMq() {
40
- if (_mq || !isBrowser() || !window.matchMedia) return;
41
- _mq = window.matchMedia('(prefers-color-scheme: dark)');
42
- const onChange = () => {
43
- if (_current === 'auto') {
44
- // Re-emit so listeners can re-render derived UI even though
45
- // data-theme stays "auto" — the CSS @media handles the swap.
46
- for (const cb of listeners) {
47
- try { cb({ mode: 'auto', resolved: _mq.matches ? 'ink' : 'paper' }); } catch {}
48
- }
49
- }
50
- };
51
- if (_mq.addEventListener) _mq.addEventListener('change', onChange);
52
- else if (_mq.addListener) _mq.addListener(onChange);
53
- }
54
-
55
- export function applyTheme(mode) {
56
- if (!VALID.has(mode)) mode = 'auto';
57
- _current = mode;
58
- writeAttr(mode);
59
- writeStored(mode);
60
- ensureMq();
61
- const resolved = mode === 'auto'
62
- ? (_mq && _mq.matches ? 'ink' : 'paper')
63
- : mode;
64
- for (const cb of listeners) {
65
- try { cb({ mode, resolved }); } catch {}
66
- }
67
- return mode;
68
- }
69
-
70
- export function getTheme() {
71
- return _current;
72
- }
73
-
74
- export function resolvedTheme() {
75
- if (_current !== 'auto') return _current;
76
- ensureMq();
77
- return _mq && _mq.matches ? 'ink' : 'paper';
78
- }
79
-
80
- export function onThemeChange(cb) {
81
- listeners.add(cb);
82
- return () => listeners.delete(cb);
83
- }
84
-
85
- // Auto-init on browser import. Picks stored value, else falls back to
86
- // whatever data-theme is already on <html> (set by page-html.js), else 'auto'.
87
- export function initTheme() {
88
- if (!isBrowser()) return 'auto';
89
- const stored = readStored();
90
- const fromAttr = document.documentElement.getAttribute('data-theme');
91
- const initial = stored || (VALID.has(fromAttr) ? fromAttr : 'auto');
92
- applyTheme(initial);
93
- return initial;
94
- }
95
-
96
- if (isBrowser()) {
97
- // Run on next microtask so SSR-injected attributes settle first.
98
- Promise.resolve().then(() => { try { initTheme(); } catch {} });
99
- }
1
+ // 247420 design system — theme controller.
2
+ //
3
+ // Three modes:
4
+ // 'auto' — follow OS (prefers-color-scheme). Live-updates on OS change.
5
+ // 'paper' — force light.
6
+ // 'ink' — force dark.
7
+ //
8
+ // Writes the chosen mode to <html data-theme="..."> so CSS rules in
9
+ // system.css / colors_and_type.css resolve correctly. Persists to
10
+ // localStorage under '247420:theme'. Auto-initializes on import in a
11
+ // browser context; safe no-op on server.
12
+
13
+ const KEY = '247420:theme';
14
+ const VALID = new Set(['auto', 'paper', 'ink']);
15
+ const listeners = new Set();
16
+ let _mq = null;
17
+ let _current = 'auto';
18
+
19
+ function isBrowser() {
20
+ return typeof document !== 'undefined' && typeof window !== 'undefined';
21
+ }
22
+
23
+ function readStored() {
24
+ try {
25
+ const v = window.localStorage.getItem(KEY);
26
+ return VALID.has(v) ? v : null;
27
+ } catch { return null; }
28
+ }
29
+
30
+ function writeStored(mode) {
31
+ try { window.localStorage.setItem(KEY, mode); } catch {}
32
+ }
33
+
34
+ function writeAttr(mode) {
35
+ if (!isBrowser()) return;
36
+ document.documentElement.setAttribute('data-theme', mode);
37
+ }
38
+
39
+ function ensureMq() {
40
+ if (_mq || !isBrowser() || !window.matchMedia) return;
41
+ _mq = window.matchMedia('(prefers-color-scheme: dark)');
42
+ const onChange = () => {
43
+ if (_current === 'auto') {
44
+ // Re-emit so listeners can re-render derived UI even though
45
+ // data-theme stays "auto" — the CSS @media handles the swap.
46
+ for (const cb of listeners) {
47
+ try { cb({ mode: 'auto', resolved: _mq.matches ? 'ink' : 'paper' }); } catch {}
48
+ }
49
+ }
50
+ };
51
+ if (_mq.addEventListener) _mq.addEventListener('change', onChange);
52
+ else if (_mq.addListener) _mq.addListener(onChange);
53
+ }
54
+
55
+ export function applyTheme(mode) {
56
+ if (!VALID.has(mode)) mode = 'auto';
57
+ _current = mode;
58
+ writeAttr(mode);
59
+ writeStored(mode);
60
+ ensureMq();
61
+ const resolved = mode === 'auto'
62
+ ? (_mq && _mq.matches ? 'ink' : 'paper')
63
+ : mode;
64
+ for (const cb of listeners) {
65
+ try { cb({ mode, resolved }); } catch {}
66
+ }
67
+ return mode;
68
+ }
69
+
70
+ export function getTheme() {
71
+ return _current;
72
+ }
73
+
74
+ export function resolvedTheme() {
75
+ if (_current !== 'auto') return _current;
76
+ ensureMq();
77
+ return _mq && _mq.matches ? 'ink' : 'paper';
78
+ }
79
+
80
+ export function onThemeChange(cb) {
81
+ listeners.add(cb);
82
+ return () => listeners.delete(cb);
83
+ }
84
+
85
+ // Auto-init on browser import. Picks stored value, else falls back to
86
+ // whatever data-theme is already on <html> (set by page-html.js), else 'auto'.
87
+ export function initTheme() {
88
+ if (!isBrowser()) return 'auto';
89
+ const stored = readStored();
90
+ const fromAttr = document.documentElement.getAttribute('data-theme');
91
+ const initial = stored || (VALID.has(fromAttr) ? fromAttr : 'auto');
92
+ applyTheme(initial);
93
+ return initial;
94
+ }
95
+
96
+ if (isBrowser()) {
97
+ // Run on next microtask so SSR-injected attributes settle first.
98
+ Promise.resolve().then(() => { try { initTheme(); } catch {} });
99
+ }
@@ -1,116 +1,116 @@
1
- // <ds-chat> custom element — auto-registers when SDK loads in a browser.
2
- // Attributes / properties:
3
- // el.messages = [{who,text,time,name,...}, ...]
4
- // el.placeholder, el.title, el.sub, el.disabled
5
- // Emits a bubbling, composed 'send' event with { detail: { text } } when the
6
- // user submits via the built-in composer.
7
-
8
- import * as webjsx from '../../vendor/webjsx/index.js';
9
- import { Chat, ChatComposer } from '../components/chat.js';
10
-
11
- class DsChat extends HTMLElement {
12
- constructor() {
13
- super();
14
- this._messages = [];
15
- this._placeholder = 'type, then ⏎';
16
- this._title = 'chat';
17
- this._sub = '';
18
- this._composerValue = '';
19
- this._disabled = false;
20
- this._scrollPending = false;
21
- }
22
- static get observedAttributes() { return ['messages', 'placeholder', 'title', 'sub', 'disabled']; }
23
- attributeChangedCallback(name, _old, val) {
24
- if (name === 'messages') {
25
- try { this._messages = JSON.parse(val); } catch { this._messages = []; }
26
- this._scrollPending = true;
27
- } else if (name === 'placeholder') {
28
- this._placeholder = val || '';
29
- } else if (name === 'title') {
30
- this._title = val || 'chat';
31
- } else if (name === 'sub') {
32
- this._sub = val || '';
33
- } else if (name === 'disabled') {
34
- this._disabled = val != null && val !== 'false';
35
- }
36
- this._render();
37
- }
38
- set messages(v) { this._messages = Array.isArray(v) ? v : []; this._scrollPending = true; this._render(); }
39
- get messages() { return this._messages; }
40
- set placeholder(v) { this._placeholder = v || ''; this._render(); }
41
- get placeholder() { return this._placeholder; }
42
- set title(v) { this._title = v || 'chat'; this._render(); }
43
- get title() { return this._title; }
44
- set sub(v) { this._sub = v || ''; this._render(); }
45
- get sub() { return this._sub; }
46
- set disabled(v) { this._disabled = !!v; this._render(); }
47
- get disabled() { return this._disabled; }
48
- connectedCallback() {
49
- this.classList.add('ds-247420');
50
- this._render();
51
- }
52
- _send(text) {
53
- this._composerValue = '';
54
- this.dispatchEvent(new CustomEvent('send', { detail: { text }, bubbles: true, composed: true }));
55
- this._render();
56
- }
57
- _render() {
58
- if (!this.isConnected) return;
59
- // The factory captures `value` at construction time, so the click handler
60
- // it builds sees a stale empty string. Pass a no-op and own send wiring
61
- // ourselves by reading the live textarea below.
62
- const self = this;
63
- const composer = ChatComposer({
64
- value: this._composerValue,
65
- placeholder: this._placeholder,
66
- disabled: this._disabled,
67
- onInput: (v) => { self._composerValue = v; self._syncSendButton(); },
68
- onSend: () => { /* superseded by live read below */ },
69
- });
70
- const node = Chat({
71
- title: this._title,
72
- sub: this._sub,
73
- messages: this._messages,
74
- composer,
75
- });
76
- webjsx.applyDiff(this, node);
77
- // Wire send button + Enter-key to read the LIVE textarea value rather than
78
- // the closure's stale prop. Idempotent — only attach once per composer DOM node.
79
- const composerEl = this.querySelector('.chat-composer');
80
- if (composerEl && !composerEl._dsBound) {
81
- composerEl._dsBound = true;
82
- const ta = composerEl.querySelector('textarea');
83
- const btn = composerEl.querySelector('button.send');
84
- const submit = () => {
85
- const v = ta ? ta.value.trim() : '';
86
- if (!v || this._disabled) return;
87
- if (ta) ta.value = '';
88
- this._send(v);
89
- };
90
- if (btn) btn.addEventListener('click', (e) => { e.preventDefault(); submit(); });
91
- if (ta) ta.addEventListener('keydown', (e) => {
92
- if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); submit(); }
93
- });
94
- }
95
- if (this._scrollPending) {
96
- this._scrollPending = false;
97
- const thread = this.querySelector('.chat-thread');
98
- if (thread) thread.scrollTop = thread.scrollHeight;
99
- }
100
- }
101
- _syncSendButton() {
102
- const btn = this.querySelector('.chat-composer button.send');
103
- if (btn) btn.disabled = this._disabled || !this._composerValue.trim();
104
- }
105
- }
106
-
107
- export { DsChat };
108
-
109
- let _registered = false;
110
- export function registerChatElement() {
111
- if (_registered) return;
112
- if (typeof customElements === 'undefined') return;
113
- if (customElements.get('ds-chat')) { _registered = true; return; }
114
- customElements.define('ds-chat', DsChat);
115
- _registered = true;
116
- }
1
+ // <ds-chat> custom element — auto-registers when SDK loads in a browser.
2
+ // Attributes / properties:
3
+ // el.messages = [{who,text,time,name,...}, ...]
4
+ // el.placeholder, el.title, el.sub, el.disabled
5
+ // Emits a bubbling, composed 'send' event with { detail: { text } } when the
6
+ // user submits via the built-in composer.
7
+
8
+ import * as webjsx from '../../vendor/webjsx/index.js';
9
+ import { Chat, ChatComposer } from '../components/chat.js';
10
+
11
+ class DsChat extends HTMLElement {
12
+ constructor() {
13
+ super();
14
+ this._messages = [];
15
+ this._placeholder = 'type, then ⏎';
16
+ this._title = 'chat';
17
+ this._sub = '';
18
+ this._composerValue = '';
19
+ this._disabled = false;
20
+ this._scrollPending = false;
21
+ }
22
+ static get observedAttributes() { return ['messages', 'placeholder', 'title', 'sub', 'disabled']; }
23
+ attributeChangedCallback(name, _old, val) {
24
+ if (name === 'messages') {
25
+ try { this._messages = JSON.parse(val); } catch { this._messages = []; }
26
+ this._scrollPending = true;
27
+ } else if (name === 'placeholder') {
28
+ this._placeholder = val || '';
29
+ } else if (name === 'title') {
30
+ this._title = val || 'chat';
31
+ } else if (name === 'sub') {
32
+ this._sub = val || '';
33
+ } else if (name === 'disabled') {
34
+ this._disabled = val != null && val !== 'false';
35
+ }
36
+ this._render();
37
+ }
38
+ set messages(v) { this._messages = Array.isArray(v) ? v : []; this._scrollPending = true; this._render(); }
39
+ get messages() { return this._messages; }
40
+ set placeholder(v) { this._placeholder = v || ''; this._render(); }
41
+ get placeholder() { return this._placeholder; }
42
+ set title(v) { this._title = v || 'chat'; this._render(); }
43
+ get title() { return this._title; }
44
+ set sub(v) { this._sub = v || ''; this._render(); }
45
+ get sub() { return this._sub; }
46
+ set disabled(v) { this._disabled = !!v; this._render(); }
47
+ get disabled() { return this._disabled; }
48
+ connectedCallback() {
49
+ this.classList.add('ds-247420');
50
+ this._render();
51
+ }
52
+ _send(text) {
53
+ this._composerValue = '';
54
+ this.dispatchEvent(new CustomEvent('send', { detail: { text }, bubbles: true, composed: true }));
55
+ this._render();
56
+ }
57
+ _render() {
58
+ if (!this.isConnected) return;
59
+ // The factory captures `value` at construction time, so the click handler
60
+ // it builds sees a stale empty string. Pass a no-op and own send wiring
61
+ // ourselves by reading the live textarea below.
62
+ const self = this;
63
+ const composer = ChatComposer({
64
+ value: this._composerValue,
65
+ placeholder: this._placeholder,
66
+ disabled: this._disabled,
67
+ onInput: (v) => { self._composerValue = v; self._syncSendButton(); },
68
+ onSend: () => { /* superseded by live read below */ },
69
+ });
70
+ const node = Chat({
71
+ title: this._title,
72
+ sub: this._sub,
73
+ messages: this._messages,
74
+ composer,
75
+ });
76
+ webjsx.applyDiff(this, node);
77
+ // Wire send button + Enter-key to read the LIVE textarea value rather than
78
+ // the closure's stale prop. Idempotent — only attach once per composer DOM node.
79
+ const composerEl = this.querySelector('.chat-composer');
80
+ if (composerEl && !composerEl._dsBound) {
81
+ composerEl._dsBound = true;
82
+ const ta = composerEl.querySelector('textarea');
83
+ const btn = composerEl.querySelector('button.send');
84
+ const submit = () => {
85
+ const v = ta ? ta.value.trim() : '';
86
+ if (!v || this._disabled) return;
87
+ if (ta) ta.value = '';
88
+ this._send(v);
89
+ };
90
+ if (btn) btn.addEventListener('click', (e) => { e.preventDefault(); submit(); });
91
+ if (ta) ta.addEventListener('keydown', (e) => {
92
+ if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); submit(); }
93
+ });
94
+ }
95
+ if (this._scrollPending) {
96
+ this._scrollPending = false;
97
+ const thread = this.querySelector('.chat-thread');
98
+ if (thread) thread.scrollTop = thread.scrollHeight;
99
+ }
100
+ }
101
+ _syncSendButton() {
102
+ const btn = this.querySelector('.chat-composer button.send');
103
+ if (btn) btn.disabled = this._disabled || !this._composerValue.trim();
104
+ }
105
+ }
106
+
107
+ export { DsChat };
108
+
109
+ let _registered = false;
110
+ export function registerChatElement() {
111
+ if (_registered) return;
112
+ if (typeof customElements === 'undefined') return;
113
+ if (customElements.get('ds-chat')) { _registered = true; return; }
114
+ customElements.define('ds-chat', DsChat);
115
+ _registered = true;
116
+ }
package/dist/.nojekyll DELETED
File without changes