@kitnai/chat 0.6.0 → 0.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.
Files changed (211) hide show
  1. package/README.md +9 -9
  2. package/dist/custom-elements.json +1676 -881
  3. package/dist/kitn-chat.es.js +36 -36
  4. package/dist/llms/llms-full.txt +316 -155
  5. package/dist/llms/llms.txt +18 -18
  6. package/dist/schemas/card-envelope.schema.json +14 -0
  7. package/dist/schemas/card-event.schema.json +12 -0
  8. package/dist/schemas/confirm.schema.json +65 -0
  9. package/dist/schemas/embed.schema.json +65 -0
  10. package/dist/schemas/form.result.schema.json +7 -0
  11. package/dist/schemas/form.schema.json +33 -0
  12. package/dist/schemas/link.schema.json +56 -0
  13. package/dist/schemas/task-list.result.schema.json +16 -0
  14. package/dist/schemas/task-list.schema.json +78 -0
  15. package/dist/theme.tokens.css +65 -65
  16. package/dist/tsx-B8rCNbgL.js +1 -0
  17. package/dist/typescript-RycA9KXf.js +1 -0
  18. package/frameworks/react/index.tsx +382 -193
  19. package/frameworks/react/runtime.tsx +2 -2
  20. package/llms-full.txt +316 -155
  21. package/llms.txt +18 -18
  22. package/package.json +5 -2
  23. package/src/components/artifact.stories.tsx +138 -0
  24. package/src/components/artifact.tsx +581 -0
  25. package/src/components/attachments.stories.tsx +7 -8
  26. package/src/components/attachments.tsx +2 -2
  27. package/src/components/card.tsx +110 -0
  28. package/src/components/chain-of-thought.stories.tsx +7 -8
  29. package/src/components/chat-container.stories.tsx +7 -8
  30. package/src/components/chat-container.tsx +4 -0
  31. package/src/components/checkpoint.stories.tsx +7 -8
  32. package/src/components/code-block.stories.tsx +8 -9
  33. package/src/components/component-meta.json +3411 -0
  34. package/src/components/confirm-card.stories.tsx +74 -0
  35. package/src/components/confirm-card.tsx +299 -0
  36. package/src/components/context.stories.tsx +7 -8
  37. package/src/components/conversation-item.stories.tsx +7 -8
  38. package/src/components/conversation-item.tsx +2 -2
  39. package/src/components/conversation-list.stories.tsx +7 -8
  40. package/src/components/conversation-list.tsx +1 -1
  41. package/src/components/embed.tsx +196 -0
  42. package/src/components/empty.stories.tsx +8 -9
  43. package/src/components/feedback-bar.stories.tsx +7 -8
  44. package/src/components/file-tree.stories.tsx +73 -0
  45. package/src/components/file-tree.tsx +383 -0
  46. package/src/components/file-upload.stories.tsx +7 -8
  47. package/src/components/form-widgets.tsx +461 -0
  48. package/src/components/form.tsx +796 -0
  49. package/src/components/image.stories.tsx +7 -8
  50. package/src/components/link-card.tsx +194 -0
  51. package/src/components/loader.stories.tsx +7 -8
  52. package/src/components/markdown.stories.tsx +7 -8
  53. package/src/components/message-narrow.stories.tsx +12 -13
  54. package/src/components/message-skills.stories.tsx +16 -17
  55. package/src/components/message.stories.tsx +17 -18
  56. package/src/components/model-switcher.stories.tsx +7 -8
  57. package/src/components/prompt-input.stories.tsx +8 -9
  58. package/src/components/prompt-suggestion.stories.tsx +7 -8
  59. package/src/components/prompt-suggestion.tsx +3 -3
  60. package/src/components/reasoning.stories.tsx +7 -8
  61. package/src/components/scroll-button.stories.tsx +7 -8
  62. package/src/components/slash-command.stories.tsx +8 -9
  63. package/src/components/slash-command.tsx +2 -2
  64. package/src/components/source.stories.tsx +7 -8
  65. package/src/components/source.tsx +1 -1
  66. package/src/components/task-list-card.stories.tsx +78 -0
  67. package/src/components/task-list-card.tsx +388 -0
  68. package/src/components/text-shimmer.stories.tsx +7 -8
  69. package/src/components/thinking-bar.stories.tsx +7 -8
  70. package/src/components/tool.stories.tsx +7 -8
  71. package/src/components/tool.tsx +2 -2
  72. package/src/components/voice-input.stories.tsx +7 -8
  73. package/src/elements/artifact.stories.tsx +291 -0
  74. package/src/elements/artifact.tsx +72 -0
  75. package/src/elements/{kitn-attachments.stories.tsx → attachments.stories.tsx} +11 -11
  76. package/src/elements/attachments.tsx +4 -4
  77. package/src/elements/card.stories.tsx +118 -0
  78. package/src/elements/card.tsx +40 -0
  79. package/src/elements/catalog.stories.tsx +491 -0
  80. package/src/elements/{kitn-chain-of-thought.stories.tsx → chain-of-thought.stories.tsx} +13 -13
  81. package/src/elements/chain-of-thought.tsx +3 -3
  82. package/src/elements/{kitn-chat-scope-picker.stories.tsx → chat-scope-picker.stories.tsx} +10 -10
  83. package/src/elements/chat-scope-picker.tsx +4 -4
  84. package/src/elements/{kitn-chat-workspace.stories.tsx → chat-workspace.stories.tsx} +71 -29
  85. package/src/elements/chat-workspace.tsx +29 -3
  86. package/src/elements/{kitn-chat.stories.tsx → chat.stories.tsx} +61 -16
  87. package/src/elements/chat.tsx +23 -2
  88. package/src/elements/{kitn-checkpoint.stories.tsx → checkpoint.stories.tsx} +11 -11
  89. package/src/elements/checkpoint.tsx +4 -4
  90. package/src/elements/{kitn-code-block.stories.tsx → code-block.stories.tsx} +10 -10
  91. package/src/elements/code-block.tsx +3 -3
  92. package/src/elements/compiled.css +1 -1
  93. package/src/elements/composed-shell.stories.tsx +316 -0
  94. package/src/elements/confirm-card.stories.tsx +186 -0
  95. package/src/elements/confirm-card.tsx +45 -0
  96. package/src/elements/{kitn-context-meter.stories.tsx → context-meter.stories.tsx} +10 -10
  97. package/src/elements/context-meter.tsx +3 -3
  98. package/src/elements/{kitn-conversation-list.stories.tsx → conversation-list.stories.tsx} +35 -22
  99. package/src/elements/conversation-list.tsx +11 -2
  100. package/src/elements/css.ts +1 -1
  101. package/src/elements/define.tsx +10 -10
  102. package/src/elements/element-meta.json +2649 -0
  103. package/src/elements/element-types.d.ts +251 -125
  104. package/src/elements/embed.stories.tsx +197 -0
  105. package/src/elements/embed.tsx +35 -0
  106. package/src/elements/{kitn-empty.stories.tsx → empty.stories.tsx} +12 -12
  107. package/src/elements/empty.tsx +3 -3
  108. package/src/elements/{kitn-feedback-bar.stories.tsx → feedback-bar.stories.tsx} +11 -11
  109. package/src/elements/feedback-bar.tsx +4 -4
  110. package/src/elements/file-tree.stories.tsx +133 -0
  111. package/src/elements/file-tree.tsx +52 -0
  112. package/src/elements/{kitn-file-upload.stories.tsx → file-upload.stories.tsx} +12 -12
  113. package/src/elements/file-upload.tsx +4 -4
  114. package/src/elements/form.stories.tsx +204 -0
  115. package/src/elements/form.tsx +37 -0
  116. package/src/elements/{kitn-image.stories.tsx → image.stories.tsx} +10 -10
  117. package/src/elements/image.tsx +3 -3
  118. package/src/elements/link-card.stories.tsx +193 -0
  119. package/src/elements/link-card.tsx +34 -0
  120. package/src/elements/{kitn-loader.stories.tsx → loader.stories.tsx} +11 -11
  121. package/src/elements/loader.tsx +3 -3
  122. package/src/elements/{kitn-markdown.stories.tsx → markdown.stories.tsx} +10 -10
  123. package/src/elements/markdown.tsx +3 -3
  124. package/src/elements/{kitn-message-skills.stories.tsx → message-skills.stories.tsx} +10 -10
  125. package/src/elements/message-skills.tsx +3 -3
  126. package/src/elements/{kitn-message.stories.tsx → message.stories.tsx} +12 -12
  127. package/src/elements/message.tsx +5 -5
  128. package/src/elements/{kitn-model-switcher.stories.tsx → model-switcher.stories.tsx} +10 -10
  129. package/src/elements/model-switcher.tsx +5 -5
  130. package/src/elements/{kitn-prompt-input.stories.tsx → prompt-input.stories.tsx} +41 -19
  131. package/src/elements/prompt-input.tsx +5 -5
  132. package/src/elements/{kitn-prompt-suggestions.stories.tsx → prompt-suggestions.stories.tsx} +13 -13
  133. package/src/elements/prompt-suggestions.tsx +4 -4
  134. package/src/elements/{kitn-reasoning.stories.tsx → reasoning.stories.tsx} +10 -10
  135. package/src/elements/reasoning.tsx +4 -4
  136. package/src/elements/register.ts +11 -1
  137. package/src/elements/resizable.stories.tsx +200 -0
  138. package/src/elements/resizable.tsx +264 -0
  139. package/src/elements/{kitn-response-stream.stories.tsx → response-stream.stories.tsx} +10 -10
  140. package/src/elements/response-stream.tsx +4 -4
  141. package/src/elements/{kitn-source-list.stories.tsx → source-list.stories.tsx} +11 -11
  142. package/src/elements/{kitn-source.stories.tsx → source.stories.tsx} +12 -12
  143. package/src/elements/source.tsx +5 -5
  144. package/src/elements/styles.css +140 -1
  145. package/src/elements/task-list-card.stories.tsx +194 -0
  146. package/src/elements/task-list-card.tsx +40 -0
  147. package/src/elements/{kitn-text-shimmer.stories.tsx → text-shimmer.stories.tsx} +10 -10
  148. package/src/elements/text-shimmer.tsx +3 -3
  149. package/src/elements/{kitn-thinking-bar.stories.tsx → thinking-bar.stories.tsx} +11 -11
  150. package/src/elements/thinking-bar.tsx +5 -5
  151. package/src/elements/{kitn-tool.stories.tsx → tool.stories.tsx} +10 -10
  152. package/src/elements/tool.tsx +3 -3
  153. package/src/elements/{kitn-voice-input.stories.tsx → voice-input.stories.tsx} +10 -10
  154. package/src/elements/voice-input.tsx +4 -4
  155. package/src/index.ts +94 -2
  156. package/src/primitives/card-contract.ts +60 -0
  157. package/src/primitives/card-host.tsx +35 -0
  158. package/src/primitives/card-routing.ts +79 -0
  159. package/src/primitives/card-schemas/card-envelope.schema.json +14 -0
  160. package/src/primitives/card-schemas/card-event.schema.json +12 -0
  161. package/src/primitives/card-schemas/confirm.schema.json +65 -0
  162. package/src/primitives/card-schemas/embed.schema.json +65 -0
  163. package/src/primitives/card-schemas/form.result.schema.json +7 -0
  164. package/src/primitives/card-schemas/form.schema.json +33 -0
  165. package/src/primitives/card-schemas/link.schema.json +56 -0
  166. package/src/primitives/card-schemas/task-list.result.schema.json +16 -0
  167. package/src/primitives/card-schemas/task-list.schema.json +78 -0
  168. package/src/primitives/card-validate.ts +95 -0
  169. package/src/primitives/embed-providers.ts +254 -0
  170. package/src/primitives/highlighter.ts +4 -0
  171. package/src/primitives/link-preview.ts +87 -0
  172. package/src/primitives/pdf-preview.ts +121 -0
  173. package/src/stories/chat-panel-layout.stories.tsx +2 -1
  174. package/src/stories/chat-scene.tsx +22 -21
  175. package/src/stories/checkpoint-restore.stories.tsx +10 -10
  176. package/src/stories/conversation-with-reasoning.stories.tsx +4 -4
  177. package/src/stories/conversation-with-sources.stories.tsx +7 -7
  178. package/src/stories/docs/Accessibility.mdx +2 -2
  179. package/src/stories/docs/ForAIAgents.mdx +3 -3
  180. package/src/stories/docs/GettingStarted.mdx +2 -2
  181. package/src/stories/docs/Installation.mdx +2 -2
  182. package/src/stories/docs/Integrations.mdx +29 -29
  183. package/src/stories/docs/Introduction.mdx +3 -3
  184. package/src/stories/docs/Theming.mdx +2 -2
  185. package/src/stories/docs/element-controls.ts +60 -0
  186. package/src/stories/docs/theme-editor/theme-editor.tsx +1 -0
  187. package/src/stories/examples/ChoosingComponents.mdx +94 -0
  188. package/src/stories/examples/sample-data.ts +79 -0
  189. package/src/stories/message-actions.stories.tsx +13 -13
  190. package/src/stories/pattern-centered-conversation.stories.tsx +3 -3
  191. package/src/stories/pattern-docked-widget.stories.tsx +1 -1
  192. package/src/stories/pattern-empty-state.stories.tsx +3 -3
  193. package/src/stories/prompt-input-variants.stories.tsx +13 -13
  194. package/src/stories/streaming-response.stories.tsx +3 -3
  195. package/src/stories/typography.stories.tsx +4 -4
  196. package/src/ui/avatar.stories.tsx +7 -8
  197. package/src/ui/badge.stories.tsx +7 -8
  198. package/src/ui/button.stories.tsx +8 -9
  199. package/src/ui/button.tsx +1 -0
  200. package/src/ui/collapsible.stories.tsx +6 -7
  201. package/src/ui/dropdown.stories.tsx +6 -7
  202. package/src/ui/hover-card.stories.tsx +6 -7
  203. package/src/ui/resizable.stories.tsx +74 -9
  204. package/src/ui/resizable.tsx +351 -71
  205. package/src/ui/scroll-area.stories.tsx +6 -7
  206. package/src/ui/scroll-area.tsx +3 -1
  207. package/src/ui/separator.stories.tsx +7 -8
  208. package/src/ui/skeleton.stories.tsx +7 -8
  209. package/src/ui/textarea.stories.tsx +6 -7
  210. package/src/ui/tooltip.stories.tsx +8 -9
  211. package/theme.css +65 -65
@@ -0,0 +1,264 @@
1
+ import { createSignal, onMount, onCleanup, For, Show, type JSX } from 'solid-js';
2
+ import { defineWebComponent } from './define';
3
+ import { ResizableHandle, normalizeSize } from '../ui/resizable';
4
+
5
+ type Orientation = 'horizontal' | 'vertical';
6
+
7
+ /** Parsed view of a `<kc-resizable-item>` light child. */
8
+ interface ItemInfo {
9
+ el: HTMLElement;
10
+ size?: string;
11
+ min?: string;
12
+ max?: string;
13
+ locked: boolean;
14
+ hidden: boolean;
15
+ }
16
+
17
+ /** Max number of panels a single group lays out (nest for more). */
18
+ const MAX_ITEMS = 3;
19
+
20
+ /** Convert a px-or-% bound to `data-*` attribute values the handle understands. */
21
+ function boundAttrs(value: string | undefined): { pxAttr?: string; pctAttr?: string } {
22
+ if (value === undefined || value === '') return {};
23
+ const t = value.trim();
24
+ if (t.endsWith('px')) return { pxAttr: String(parseFloat(t)) };
25
+ if (t.endsWith('%')) return { pctAttr: String(parseFloat(t)) };
26
+ if (Number.isFinite(Number(t))) return { pctAttr: t };
27
+ return {};
28
+ }
29
+
30
+ interface GroupProps extends Record<string, unknown> {
31
+ /** Layout axis: `horizontal` (row, default) or `vertical` (column). */
32
+ orientation?: Orientation;
33
+ }
34
+
35
+ interface GroupEvents extends Record<string, unknown> {
36
+ /** Fired on drag-end / keyboard resize / visibility change. `detail.sizes` = panel sizes in percent. */
37
+ change: { sizes: number[] };
38
+ }
39
+
40
+ /**
41
+ * `<kc-resizable>` — a composable, resizable multi-panel layout (up to 3 panels)
42
+ * with auto-inserted draggable dividers. It lays out its `<kc-resizable-item>`
43
+ * light children along an axis (`orientation`), reading each item's `size`,
44
+ * `min`, `max`, `locked` and `hidden` attributes via a `MutationObserver`. A
45
+ * divider is interactive only between two unlocked, visible panels. Emits a
46
+ * `change` event (`detail.sizes`, percent) on resize / visibility change.
47
+ */
48
+ defineWebComponent<GroupProps, GroupEvents>('kc-resizable', {
49
+ orientation: 'horizontal',
50
+ }, (props, { element, dispatch }) => {
51
+ const [items, setItems] = createSignal<ItemInfo[]>([]);
52
+ const orientation = (): Orientation => (props.orientation === 'vertical' ? 'vertical' : 'horizontal');
53
+
54
+ /** Read the current `<kc-resizable-item>` light children + their attributes. */
55
+ function readItems() {
56
+ const all = Array.from(element.children).filter(
57
+ (c): c is HTMLElement => c.tagName.toLowerCase() === 'kc-resizable-item',
58
+ );
59
+ if (all.length > MAX_ITEMS) {
60
+ // eslint-disable-next-line no-console
61
+ console.warn(
62
+ `<kc-resizable>: only the first ${MAX_ITEMS} <kc-resizable-item> children are laid out ` +
63
+ `(got ${all.length}). Nest <kc-resizable> for more.`,
64
+ );
65
+ }
66
+ const capped = all.slice(0, MAX_ITEMS);
67
+ const parsed: ItemInfo[] = capped.map((el) => ({
68
+ el,
69
+ size: el.getAttribute('size') ?? undefined,
70
+ min: el.getAttribute('min') ?? undefined,
71
+ max: el.getAttribute('max') ?? undefined,
72
+ locked: el.hasAttribute('locked') && el.getAttribute('locked') !== 'false',
73
+ // Honour both the `hidden` boolean attribute and the IDL property — Solid
74
+ // (and direct `el.hidden = true`) set the property, which doesn't reflect
75
+ // to the attribute on a custom element.
76
+ hidden: el.hidden || (el.hasAttribute('hidden') && el.getAttribute('hidden') !== 'false'),
77
+ }));
78
+
79
+ // Assign each visible item to its panel slot by visible order; clear the
80
+ // rest so hidden/extra items don't leak into a slot.
81
+ let visIdx = 0;
82
+ for (const info of parsed) {
83
+ if (info.hidden) {
84
+ info.el.removeAttribute('slot');
85
+ } else {
86
+ info.el.setAttribute('slot', `p${visIdx}`);
87
+ visIdx++;
88
+ }
89
+ }
90
+ for (const el of all.slice(MAX_ITEMS)) el.removeAttribute('slot');
91
+
92
+ setItems(parsed);
93
+ }
94
+
95
+ const visible = () => items().filter((i) => !i.hidden);
96
+
97
+ /** Compute current panel sizes (percent of container) from the rendered DOM. */
98
+ function currentSizes(): number[] {
99
+ return visible().map((info) => {
100
+ const panel = info.el.assignedSlot?.closest('[data-panel]') as HTMLElement | null;
101
+ const target = panel ?? info.el;
102
+ const parent = target.parentElement;
103
+ const dim = orientation() === 'horizontal' ? 'width' : 'height';
104
+ const total = parent ? parent.getBoundingClientRect()[dim] : 0;
105
+ const val = target.getBoundingClientRect()[dim];
106
+ return total > 0 ? Math.round((val / total) * 100) : 0;
107
+ });
108
+ }
109
+
110
+ function emitChange() {
111
+ dispatch('change', { sizes: currentSizes() });
112
+ }
113
+
114
+ onMount(() => {
115
+ readItems();
116
+ const mo = new MutationObserver(() => {
117
+ readItems();
118
+ // A childList / attribute change (e.g. show/hide) re-lays out → emit.
119
+ queueMicrotask(emitChange);
120
+ });
121
+ mo.observe(element, {
122
+ childList: true,
123
+ // Attribute changes happen on the <kc-resizable-item> *children*, so we
124
+ // must observe the subtree (filtered to the config attributes) — not just
125
+ // the host's own attributes.
126
+ subtree: true,
127
+ attributes: true,
128
+ attributeFilter: ['size', 'locked', 'min', 'max', 'hidden'],
129
+ });
130
+ onCleanup(() => mo.disconnect());
131
+ });
132
+
133
+ const isHoriz = () => orientation() === 'horizontal';
134
+
135
+ return (
136
+ <>
137
+ {/* A resizable layout fills its container — default the host to a block
138
+ that stretches, so consumers only need to give a parent (or the element)
139
+ a height. Override with an explicit height on the element if needed. */}
140
+ <style>{':host{display:block;height:100%}'}</style>
141
+ <div
142
+ data-resizable-root
143
+ data-orientation={orientation()}
144
+ style={{
145
+ display: 'flex',
146
+ 'flex-direction': isHoriz() ? 'row' : 'column',
147
+ width: '100%',
148
+ height: '100%',
149
+ }}
150
+ >
151
+ <For each={visible()}>
152
+ {(info, i) => {
153
+ const min = boundAttrs(info.min);
154
+ const max = boundAttrs(info.max);
155
+ const basis = normalizeSize(info.size);
156
+ const prev = () => visible()[i() - 1];
157
+ const isStatic = () => !!(info.locked || prev()?.locked);
158
+ return (
159
+ <>
160
+ <Show when={i() > 0}>
161
+ <ResizableHandle
162
+ withHandle
163
+ orientation={orientation()}
164
+ static={isStatic()}
165
+ onPanelResize={() => queueMicrotask(emitChange)}
166
+ />
167
+ </Show>
168
+ <div
169
+ data-panel
170
+ data-locked={info.locked ? '' : undefined}
171
+ data-min-size={min.pxAttr}
172
+ data-min-size-pct={min.pctAttr}
173
+ data-max-size={max.pxAttr}
174
+ data-max-size-pct={max.pctAttr}
175
+ style={{
176
+ // The panel is a flex item of the root: `flex-basis` sizes its
177
+ // MAIN axis (width when horizontal, height when vertical) and the
178
+ // drag/keyboard handlers rewrite that basis — so the layout spine
179
+ // stays a plain flex row/column (drag math unchanged).
180
+ //
181
+ // For the FILL, the panel is itself a `display:grid` with a single
182
+ // `minmax(0,1fr)` cell on BOTH axes. A grid item (the slotted
183
+ // `<kc-resizable-item>`) stretches to fill its cell on both axes by
184
+ // default (`place-items:stretch`), and a `1fr` track inside a
185
+ // definite-sized grid is a *definite* length — so content fills
186
+ // height AND width whether or not it sets `height:100%`, in both
187
+ // orientations. A flex panel only stretches the CROSS axis (which is
188
+ // why the previous `display:flex` panel collapsed the main axis to
189
+ // content height). This mirrors how Shoelace/Web Awesome
190
+ // `<sl-split-panel>` lay panels out with grid for guaranteed fill,
191
+ // adapted here to a per-panel grid cell (our double slot boundary
192
+ // makes a slot-as-grid-item unusable — a slot with assigned nodes
193
+ // has a zero box). min:0 on both axes enables shrink-to-scroll;
194
+ // overflow clips (the item owns the scroll).
195
+ ...(basis !== undefined
196
+ ? { 'flex-basis': basis, 'flex-grow': '0', 'flex-shrink': '0' }
197
+ : { flex: '1 1 0%' }),
198
+ display: 'grid',
199
+ 'grid-template-rows': 'minmax(0, 1fr)',
200
+ 'grid-template-columns': 'minmax(0, 1fr)',
201
+ 'min-width': '0',
202
+ 'min-height': '0',
203
+ overflow: 'hidden',
204
+ }}
205
+ >
206
+ <slot name={`p${i()}`} />
207
+ </div>
208
+ </>
209
+ );
210
+ }}
211
+ </For>
212
+ </div>
213
+ </>
214
+ );
215
+ });
216
+
217
+ interface ItemProps extends Record<string, unknown> {
218
+ /** Initial main-axis size: `"280px"` (fixed) or `"25%"`/`25` (percent). Omitted → flexible. */
219
+ size?: string;
220
+ /** Minimum size during resize (px or %). */
221
+ min?: string;
222
+ /** Maximum size during resize (px or %). */
223
+ max?: string;
224
+ /** Fix this panel's size; adjacent dividers become non-draggable. */
225
+ locked?: boolean;
226
+ /** Hide this panel; its divider is dropped and the rest reflow. */
227
+ hidden?: boolean;
228
+ }
229
+
230
+ /**
231
+ * `<kc-resizable-item>` — a passive config-carrier inside `<kc-resizable>`. It
232
+ * renders its own slotted light content (`<slot/>`); the parent `<kc-resizable>`
233
+ * reads its `size`/`min`/`max`/`locked`/`hidden` attributes to lay it out.
234
+ */
235
+ defineWebComponent<ItemProps>('kc-resizable-item', {
236
+ size: undefined,
237
+ min: undefined,
238
+ max: undefined,
239
+ locked: false,
240
+ hidden: false,
241
+ }, () => (
242
+ <>
243
+ {/* The item host fills the panel's single grid cell (the panel stretches it on
244
+ both axes) and OWNS the scroll: `display:block; width/height:100%;
245
+ overflow:auto`. min:0 enables shrink-to-scroll.
246
+
247
+ The FILL of the *slotted* content happens one level in: a `display:grid`
248
+ wrapper with a single `minmax(0,1fr)` cell whose ONLY child is the `<slot>`.
249
+ A grid item stretches to fill its cell on BOTH axes by default
250
+ (`place-items:stretch`) into a *definite* `1fr` track, so slotted content
251
+ fills width AND height whether or not it sets `height:100%`. The grid MUST
252
+ be its own element wrapping the slot — NOT the host — because the element
253
+ facade renders an empty portal-mount `<div>` (for overlays) as a sibling of
254
+ the facade output; if the host itself were the grid, that portal div would
255
+ become a second grid item and steal a track (collapsing content to the auto
256
+ row). Scoping the grid to a wrapper whose sole child is the slot keeps
257
+ exactly one grid item and is robust to the facade's portal sibling.
258
+ Mirrors how Shoelace/Web Awesome `<sl-split-panel>` use grid for fill. */}
259
+ <style>{':host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:auto}'}</style>
260
+ <div style={{ display: 'grid', 'grid-template-rows': 'minmax(0, 1fr)', 'grid-template-columns': 'minmax(0, 1fr)', width: '100%', height: '100%', 'min-width': '0', 'min-height': '0' }}>
261
+ <slot />
262
+ </div>
263
+ </>
264
+ ) as unknown as JSX.Element);
@@ -1,13 +1,14 @@
1
1
  import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
2
  import { onMount } from 'solid-js';
3
3
  import './register'; // side effect: registers the custom elements
4
+ import { argTypesFor, specDescription } from '../stories/docs/element-controls';
4
5
 
5
6
  // The web components are custom DOM elements, so declare the tags for JSX.
6
7
  declare module 'solid-js' {
7
8
  // eslint-disable-next-line @typescript-eslint/no-namespace
8
9
  namespace JSX {
9
10
  interface IntrinsicElements {
10
- 'kitn-response-stream': JSX.HTMLAttributes<HTMLElement> & {
11
+ 'kc-response-stream': JSX.HTMLAttributes<HTMLElement> & {
11
12
  mode?: string;
12
13
  speed?: number;
13
14
  };
@@ -18,14 +19,14 @@ declare module 'solid-js' {
18
19
  const STREAM_TEXT =
19
20
  "This text reveals with a typewriter animation, streamed character by character — exactly how you'd render a live assistant reply.";
20
21
 
21
- /** Render `<kitn-response-stream>` with the `text` set as a JS property. */
22
+ /** Render `<kc-response-stream>` with the `text` set as a JS property. */
22
23
  function StreamElement(props: { text: string; mode?: string; speed?: number }) {
23
24
  let el: (HTMLElement & { text?: string }) | undefined;
24
25
  onMount(() => {
25
26
  if (el) el.text = props.text;
26
27
  });
27
28
  return (
28
- <kitn-response-stream
29
+ <kc-response-stream
29
30
  ref={(e) => (el = e as HTMLElement)}
30
31
  mode={props.mode}
31
32
  speed={props.speed}
@@ -35,7 +36,7 @@ function StreamElement(props: { text: string; mode?: string; speed?: number }) {
35
36
  }
36
37
 
37
38
  const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
38
- <kitn-response-stream id="stream" mode="typewriter" speed="20"></kitn-response-stream>
39
+ <kc-response-stream id="stream" mode="typewriter" speed="20"></kc-response-stream>
39
40
 
40
41
  <script type="module">
41
42
  import '@kitnai/chat/elements'; // registers the custom elements
@@ -47,19 +48,18 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
47
48
  </script>`;
48
49
 
49
50
  const meta = {
50
- title: 'Web Components/kitn-response-stream',
51
+ title: 'Web Components/kc-response-stream',
51
52
  tags: ['autodocs'],
53
+ argTypes: argTypesFor('kc-response-stream'),
52
54
  parameters: {
53
55
  layout: 'fullscreen',
54
56
  docs: {
55
- description: {
56
- component: [
57
- '`<kitn-response-stream>` is the framework-agnostic **web component** that reveals text with a typewriter or fade animation — the building block for streamed assistant replies, isolated in **Shadow DOM**.',
57
+ description: specDescription('kc-response-stream', [
58
+ '`<kc-response-stream>` is the framework-agnostic **web component** that reveals text with a typewriter or fade animation — the building block for streamed assistant replies, isolated in **Shadow DOM**.',
58
59
  '**When to use:** animating a response as it arrives. Pass a finished string to replay an animation, or an `AsyncIterable<string>` to drive it from a live stream. In SolidJS, use the `ResponseStream` primitive.',
59
60
  "**How to use:** register once with `import '@kitnai/chat/elements'`, set the `text` **property** (string or async iterable), tune `mode` (`typewriter` / `fade`) and `speed`, and listen for the `complete` **CustomEvent**.",
60
61
  'See the **Code** tab for HTML usage.',
61
- ].join('\n\n'),
62
- },
62
+ ]),
63
63
  },
64
64
  },
65
65
  } satisfies Meta;
@@ -1,4 +1,4 @@
1
- import { defineKitnElement } from './define';
1
+ import { defineWebComponent } from './define';
2
2
  import { ResponseStream, type Mode } from '../components/response-stream';
3
3
 
4
4
  interface Props extends Record<string, unknown> {
@@ -13,17 +13,17 @@ interface Props extends Record<string, unknown> {
13
13
  as?: string;
14
14
  }
15
15
 
16
- /** Events fired by `<kitn-response-stream>`. */
16
+ /** Events fired by `<kc-response-stream>`. */
17
17
  interface Events {
18
18
  /** Streaming finished. */
19
19
  complete: void;
20
20
  }
21
21
 
22
22
  /**
23
- * `<kitn-response-stream>` — reveals text with a typewriter or fade animation.
23
+ * `<kc-response-stream>` — reveals text with a typewriter or fade animation.
24
24
  * Text via the `text` property; `mode`/`speed` attributes; emits `complete`.
25
25
  */
26
- defineKitnElement<Props, Events>('kitn-response-stream', {
26
+ defineWebComponent<Props, Events>('kc-response-stream', {
27
27
  text: '',
28
28
  mode: 'typewriter',
29
29
  speed: 20,
@@ -1,13 +1,14 @@
1
1
  import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
2
  import { onMount } from 'solid-js';
3
3
  import './register'; // side effect: registers the custom elements
4
+ import { argTypesFor, specDescription } from '../stories/docs/element-controls';
4
5
 
5
6
  // The web components are custom DOM elements, so declare the tags for JSX.
6
7
  declare module 'solid-js' {
7
8
  // eslint-disable-next-line @typescript-eslint/no-namespace
8
9
  namespace JSX {
9
10
  interface IntrinsicElements {
10
- 'kitn-source-list': JSX.HTMLAttributes<HTMLElement>;
11
+ 'kc-sources': JSX.HTMLAttributes<HTMLElement>;
11
12
  }
12
13
  }
13
14
  }
@@ -25,19 +26,19 @@ const sampleSources: SourceItem[] = [
25
26
  { href: 'https://solidjs.com', title: 'SolidJS', description: 'A reactive UI library.', showFavicon: true },
26
27
  ];
27
28
 
28
- /** Render the actual `<kitn-source-list>` custom element with a `sources` property. */
29
+ /** Render the actual `<kc-sources>` custom element with a `sources` property. */
29
30
  function SourceListElement() {
30
31
  let el: (HTMLElement & { sources?: SourceItem[] }) | undefined;
31
32
  onMount(() => {
32
33
  if (el) el.sources = sampleSources;
33
34
  });
34
35
  return (
35
- <kitn-source-list ref={(e) => (el = e as HTMLElement)} style={{ display: 'block', padding: '16px', 'max-width': '720px' }} />
36
+ <kc-sources ref={(e) => (el = e as HTMLElement)} style={{ display: 'block', padding: '16px', 'max-width': '720px' }} />
36
37
  );
37
38
  }
38
39
 
39
40
  const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
40
- <kitn-source-list id="srcs" show-favicon></kitn-source-list>
41
+ <kc-sources id="srcs" show-favicon></kc-sources>
41
42
 
42
43
  <script type="module">
43
44
  import '@kitnai/chat/elements'; // registers the custom elements
@@ -50,19 +51,18 @@ const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
50
51
  </script>`;
51
52
 
52
53
  const meta = {
53
- title: 'Web Components/kitn-source-list',
54
+ title: 'Web Components/kc-sources',
54
55
  tags: ['autodocs'],
56
+ argTypes: argTypesFor('kc-sources'),
55
57
  parameters: {
56
58
  layout: 'fullscreen',
57
59
  docs: {
58
- description: {
59
- component: [
60
- '`<kitn-source-list>` is the framework-agnostic **web component** for a wrapped row of citation links (each with its own hover-card preview), isolated in **Shadow DOM**.',
61
- '**When to use:** showing the sources behind an assistant answer in a non-Solid app. For a single citation, use `<kitn-source>`; in SolidJS, compose `SourceList` + `Source`.',
60
+ description: specDescription('kc-sources', [
61
+ '`<kc-sources>` is the framework-agnostic **web component** for a wrapped row of citation links (each with its own hover-card preview), isolated in **Shadow DOM**.',
62
+ '**When to use:** showing the sources behind an assistant answer in a non-Solid app. For a single citation, use `<kc-source>`; in SolidJS, compose `SourceList` + `Source`.',
62
63
  "**How to use:** register once with `import '@kitnai/chat/elements'`, set the data via the `sources` **property** (each item: `href`, `title`, `description`, `label`, `showFavicon`), and set `show-favicon` to enable favicons for all items (a per-item `showFavicon` overrides it).",
63
64
  'See the **Code** tab for HTML usage.',
64
- ].join('\n\n'),
65
- },
65
+ ]),
66
66
  },
67
67
  },
68
68
  } satisfies Meta;
@@ -1,18 +1,19 @@
1
1
  import type { Meta, StoryObj } from 'storybook-solidjs-vite';
2
2
  import { onMount } from 'solid-js';
3
3
  import './register'; // side effect: registers the custom elements
4
+ import { argTypesFor, specDescription } from '../stories/docs/element-controls';
4
5
 
5
6
  // The web components are custom DOM elements, so declare the tags for JSX.
6
7
  declare module 'solid-js' {
7
8
  // eslint-disable-next-line @typescript-eslint/no-namespace
8
9
  namespace JSX {
9
10
  interface IntrinsicElements {
10
- 'kitn-source': JSX.HTMLAttributes<HTMLElement>;
11
+ 'kc-source': JSX.HTMLAttributes<HTMLElement>;
11
12
  }
12
13
  }
13
14
  }
14
15
 
15
- /** Render the actual `<kitn-source>` custom element configured by attributes. */
16
+ /** Render the actual `<kc-source>` custom element configured by attributes. */
16
17
  function SourceElement(props: {
17
18
  href: string;
18
19
  label?: string;
@@ -29,36 +30,35 @@ function SourceElement(props: {
29
30
  if (props.description) el.setAttribute('description', props.description);
30
31
  if (props.showFavicon) el.setAttribute('show-favicon', '');
31
32
  });
32
- return <kitn-source ref={(e) => (el = e as HTMLElement)} style={{ display: 'inline-block', padding: '16px' }} />;
33
+ return <kc-source ref={(e) => (el = e as HTMLElement)} style={{ display: 'inline-block', padding: '16px' }} />;
33
34
  }
34
35
 
35
36
  const HTML_SNIPPET = `<!-- Works in any framework or plain HTML -->
36
- <kitn-source
37
+ <kc-source
37
38
  href="https://kitn.dev"
38
39
  label="kitn"
39
40
  headline="kitn — the kit"
40
41
  description="Composable SolidJS + web-component chat UI."
41
42
  show-favicon
42
- ></kitn-source>
43
+ ></kc-source>
43
44
 
44
45
  <script type="module">
45
46
  import '@kitnai/chat/elements'; // registers the custom elements
46
47
  </script>`;
47
48
 
48
49
  const meta = {
49
- title: 'Web Components/kitn-source',
50
+ title: 'Web Components/kc-source',
50
51
  tags: ['autodocs'],
52
+ argTypes: argTypesFor('kc-source'),
51
53
  parameters: {
52
54
  layout: 'fullscreen',
53
55
  docs: {
54
- description: {
55
- component: [
56
- '`<kitn-source>` is the framework-agnostic **web component** for a single citation link with a hover-card preview, isolated in **Shadow DOM**.',
57
- '**When to use:** inlining a single source citation in a non-Solid app. For multiple sources, use `<kitn-source-list>`; in SolidJS, compose the `Source` primitives.',
56
+ description: specDescription('kc-source', [
57
+ '`<kc-source>` is the framework-agnostic **web component** for a single citation link with a hover-card preview, isolated in **Shadow DOM**.',
58
+ '**When to use:** inlining a single source citation in a non-Solid app. For multiple sources, use `<kc-sources>`; in SolidJS, compose the `Source` primitives.',
58
59
  "**How to use:** register once with `import '@kitnai/chat/elements'`, then set `href` (the link, also the default label/favicon source), `label`, `headline` (the hover headline — note `headline`, not `title`), `description`, and the `show-favicon` flag via attributes.",
59
60
  'See the **Code** tab for HTML usage.',
60
- ].join('\n\n'),
61
- },
61
+ ]),
62
62
  },
63
63
  },
64
64
  } satisfies Meta;
@@ -1,8 +1,8 @@
1
1
  import { For, Show } from 'solid-js';
2
- import { defineKitnElement } from './define';
2
+ import { defineWebComponent } from './define';
3
3
  import { Source, SourceTrigger, SourceContent, SourceList } from '../components/source';
4
4
 
5
- // --- <kitn-source> — a single citation link with hover preview ---
5
+ // --- <kc-source> — a single citation link with hover preview ---
6
6
 
7
7
  interface SourceProps extends Record<string, unknown> {
8
8
  /** The URL this citation links to (the domain also seeds the default label/favicon). */
@@ -18,7 +18,7 @@ interface SourceProps extends Record<string, unknown> {
18
18
  showFavicon?: boolean;
19
19
  }
20
20
 
21
- defineKitnElement<SourceProps>('kitn-source', {
21
+ defineWebComponent<SourceProps>('kc-source', {
22
22
  href: '',
23
23
  label: undefined,
24
24
  headline: '',
@@ -33,7 +33,7 @@ defineKitnElement<SourceProps>('kitn-source', {
33
33
  </Show>
34
34
  ));
35
35
 
36
- // --- <kitn-source-list> — a wrapped list of citation links ---
36
+ // --- <kc-sources> — a wrapped list of citation links ---
37
37
 
38
38
  interface SourceItem {
39
39
  href: string;
@@ -50,7 +50,7 @@ interface SourceListProps extends Record<string, unknown> {
50
50
  showFavicon?: boolean;
51
51
  }
52
52
 
53
- defineKitnElement<SourceListProps>('kitn-source-list', {
53
+ defineWebComponent<SourceListProps>('kc-sources', {
54
54
  sources: [],
55
55
  showFavicon: false,
56
56
  }, (props, { flag }) => (