@k2b/ui 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -312
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,343 +1,108 @@
|
|
|
1
1
|
# @k2b/ui
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
in another Solid application.
|
|
3
|
+
Over 100 SolidJS components and growing, for forms, content, and application
|
|
4
|
+
layouts. Includes scoped, precompiled CSS, configurable design tokens, and
|
|
5
|
+
separate browser and server builds.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
@import "@k2b/ui/global.css";
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Or load only the component styles when the application provides its own fonts
|
|
13
|
-
and icons:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import "@k2b/ui/styles.css";
|
|
17
|
-
import { Button, DatePicker, StatusBadge, prompts } from "@k2b/ui";
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Wrap the rendered application in the UI scope:
|
|
21
|
-
|
|
22
|
-
```tsx
|
|
23
|
-
<main class="k2b-ui">
|
|
24
|
-
<Placeholder title="Nothing here yet" />
|
|
25
|
-
</main>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
The scope uses `0.9375rem` body text at weight `400` without changing the
|
|
29
|
-
document's global `body`.
|
|
30
|
-
|
|
31
|
-
Fonts and theme stacks are CSS variables and can be replaced without
|
|
32
|
-
JavaScript:
|
|
33
|
-
|
|
34
|
-
```css
|
|
35
|
-
.k2b-ui {
|
|
36
|
-
--k2b-font-sans: Inter, sans-serif;
|
|
37
|
-
--k2b-accent-50: #f5f3ff;
|
|
38
|
-
--k2b-accent-100: #ede9fe;
|
|
39
|
-
--k2b-accent-300: #c4b5fd;
|
|
40
|
-
--k2b-accent-400: #a78bfa;
|
|
41
|
-
--k2b-accent-500: #8b5cf6;
|
|
42
|
-
--k2b-accent-600: #7c3aed;
|
|
43
|
-
--k2b-accent-700: #6d28d9;
|
|
44
|
-
--k2b-accent-950: #2e1065;
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
`--k2b-action` is the accessible foreground color for links and text actions.
|
|
49
|
-
`--k2b-action-solid` is the background color for filled controls; override both
|
|
50
|
-
with matching hover tokens when defining a custom theme.
|
|
51
|
-
|
|
52
|
-
AI surfaces can use a distinct semantic treatment without changing the general
|
|
53
|
-
application accent:
|
|
54
|
-
|
|
55
|
-
```css
|
|
56
|
-
.k2b-ui {
|
|
57
|
-
--k2b-ai-accent: #0891b2;
|
|
58
|
-
--k2b-ai-accent-hover: #0e7490;
|
|
59
|
-
--k2b-ai-border: #06b6d4;
|
|
60
|
-
--k2b-ai-surface: #ecfeff;
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
IBM Plex is an optional preset:
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
import "@k2b/ui/fonts/plex.css";
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Tabler's webfont is the supported icon preset:
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
import "@k2b/ui/icons/tabler.css";
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Component tranches
|
|
77
|
-
|
|
78
|
-
The public package surface only exposes components that have passed the
|
|
79
|
-
standalone SSR, behavior, styling, and migration checks:
|
|
7
|
+
[Documentation and live examples](https://cloud.k2b.dev/en/ui)
|
|
80
8
|
|
|
81
|
-
|
|
82
|
-
search, copy, remove, segmented controls, controlled tabs, native
|
|
83
|
-
disclosures, and semantic toolbars
|
|
84
|
-
- Inputs: text, number, checkbox and switch controls; select, combobox,
|
|
85
|
-
multi-select, freeform tags, managed tag editing, icons, PIN, slider, color,
|
|
86
|
-
and date/time pickers;
|
|
87
|
-
dropzones, image selection/cropping, completion-aware plain text,
|
|
88
|
-
Markdown, and template editors
|
|
89
|
-
- Layout: `AppOverview`, `DataPanel`, `PanelHeader`, `PanelDialog`,
|
|
90
|
-
`SettingsModal`, `AppWorkspace`, `Panes`, `FloatingWindow`, and generic
|
|
91
|
-
settings-form helpers
|
|
92
|
-
- Surfaces: `Paper`, `Avatar`, `LinkCard`, `StatGrid`, `StatCell`, `StatusBadge`,
|
|
93
|
-
`ProgressBar`, `NoticeCard` (with `NoticeCard.Grid`), `Tag`,
|
|
94
|
-
`DescriptionList`, `Placeholder`, and `NotFoundState`
|
|
95
|
-
- Feedback: the complete scoped prompt family, `Tooltip`, and scoped `toast`
|
|
96
|
-
- AI: the controlled compound `Chat` surface with timeline, messages,
|
|
97
|
-
activity, composer, and compact context usage
|
|
98
|
-
- Content: data and log tables, charts and interactive state timelines,
|
|
99
|
-
calendars, file trees/browsers/previews, lightboxes, PDF previews,
|
|
100
|
-
documentation primitives, pagination, range navigation, code and Markdown
|
|
101
|
-
views, and structured-data previews
|
|
102
|
-
- Widgets: `Widget`, `WidgetHero`, `WidgetList`, `WidgetPills`,
|
|
103
|
-
`WidgetStat`, and `WidgetStatus`
|
|
104
|
-
- Intl: `LocaleProvider`, `useLocale`, and the unstyled `Format` namespace
|
|
105
|
-
(`Number`, `Percent`, `Currency`, `Bytes`, `Date`, `Time`, `DateTime`,
|
|
106
|
-
`RelativeTime`, `Duration`, `DurationMs`)
|
|
9
|
+
## Installation
|
|
107
10
|
|
|
108
|
-
|
|
109
|
-
the explicit `trustedHtml` prop and stays an application-owned trust boundary.
|
|
110
|
-
Authoring previews may pass an exact `inlineTokens` allowlist to emphasize
|
|
111
|
-
standalone placeholders during safe Markdown parsing.
|
|
11
|
+
In an existing SolidJS project:
|
|
112
12
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Form controls share one controlled contract. The same prop always has the same
|
|
116
|
-
meaning:
|
|
117
|
-
|
|
118
|
-
- `id`, `class`, `label`, `description`, `error`, `required`, and `disabled`
|
|
119
|
-
describe the field around the control.
|
|
120
|
-
- Use a visible `label` whenever possible. If the surrounding UI already
|
|
121
|
-
provides the label, use the native `"aria-label"` or `"aria-describedby"`
|
|
122
|
-
props. A placeholder is never an accessible label.
|
|
123
|
-
- `value` accepts either a direct value or a Solid accessor.
|
|
124
|
-
- `onValueChange` reports every controlled edit.
|
|
125
|
-
- `onValueCommit` reports the value when the user finishes the edit: on blur
|
|
126
|
-
or Enter for text-like controls, and on an explicit selection or Apply action
|
|
127
|
-
for pickers.
|
|
128
|
-
|
|
129
|
-
```tsx
|
|
130
|
-
const [name, setName] = createSignal("");
|
|
131
|
-
const [date, setDate] = createSignal<string | null>(null);
|
|
132
|
-
|
|
133
|
-
<TextInput
|
|
134
|
-
label="Project name"
|
|
135
|
-
value={name}
|
|
136
|
-
onValueChange={setName}
|
|
137
|
-
onValueCommit={saveName}
|
|
138
|
-
/>
|
|
139
|
-
<DatePicker
|
|
140
|
-
label="Release date"
|
|
141
|
-
value={date}
|
|
142
|
-
onValueChange={setDate}
|
|
143
|
-
onValueCommit={saveReleaseDate}
|
|
144
|
-
/>
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
Select, date, combobox, tags, and text controls use the same field metadata,
|
|
148
|
-
ARIA wiring, disabled and invalid states, and stable one-border focus shell.
|
|
149
|
-
Control-specific props only describe genuinely different behavior. For
|
|
150
|
-
example, `Combobox` owns a transient search `query` and hands the selected
|
|
151
|
-
domain object to `onSelect`; `FileDropzone` and `ImageCropper` are action/editor
|
|
152
|
-
primitives rather than value fields.
|
|
153
|
-
|
|
154
|
-
The package does not read Cloud routes, services, permissions, or application
|
|
155
|
-
state. Product-specific composition stays with the consuming application.
|
|
156
|
-
`Avatar` is therefore an additive portable presentation adapter. It does not
|
|
157
|
-
migrate Cloud's routed `./misc/Avatar` source contract, which remains
|
|
158
|
-
Cloud-specific.
|
|
159
|
-
|
|
160
|
-
Composition components intentionally use semantic data instead of application
|
|
161
|
-
stores:
|
|
162
|
-
|
|
163
|
-
```tsx
|
|
164
|
-
<Widget title="Platform health" icon="ti ti-heartbeat">
|
|
165
|
-
<WidgetStatus title="Operational" tone="success" />
|
|
166
|
-
<WidgetPills pills={[{ label: "Checks", value: 48, tone: "emerald" }]} />
|
|
167
|
-
</Widget>
|
|
13
|
+
```bash
|
|
14
|
+
bun add @k2b/ui 'solid-js@^1.9.10' '@k2b/ssr@^0.12.0'
|
|
168
15
|
```
|
|
169
16
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
`AccentColor` (`zinc`, `blue`, `emerald`, `amber`, `red`). Specialized state
|
|
173
|
-
components such as `StatusBadge` keep a smaller domain-specific vocabulary
|
|
174
|
-
where the states carry meaning beyond color.
|
|
17
|
+
`solid-js` and `@k2b/ssr` are required peer dependencies. Use your application's
|
|
18
|
+
existing Solid setup.
|
|
175
19
|
|
|
176
|
-
##
|
|
20
|
+
## Quick Start
|
|
177
21
|
|
|
178
|
-
|
|
179
|
-
component `locale` prop, the nearest `LocaleProvider`, the browser's
|
|
180
|
-
`document.documentElement.lang`, then `"en"`. The package never reads
|
|
181
|
-
`navigator.language` and holds no global locale state, so one server can
|
|
182
|
-
render different locales concurrently.
|
|
22
|
+
Import the stylesheet once and wrap your components in `.k2b-ui`:
|
|
183
23
|
|
|
184
24
|
```tsx
|
|
185
|
-
import {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
25
|
+
import { createSignal } from "solid-js";
|
|
26
|
+
import { Button, TextInput } from "@k2b/ui";
|
|
27
|
+
import "@k2b/ui/global.css";
|
|
28
|
+
|
|
29
|
+
export default function App() {
|
|
30
|
+
const [name, setName] = createSignal("");
|
|
31
|
+
const [savedName, setSavedName] = createSignal("");
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<form
|
|
35
|
+
class="k2b-ui"
|
|
36
|
+
onSubmit={(event) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
setSavedName(name().trim());
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<TextInput label="Project name" value={name} onValueChange={setName} required />
|
|
42
|
+
<Button type="submit" variant="primary" disabled={!name().trim()}>
|
|
43
|
+
Save
|
|
44
|
+
</Button>
|
|
45
|
+
<p role="status">{savedName() && `Saved: ${savedName()}`}</p>
|
|
46
|
+
</form>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
194
49
|
```
|
|
195
50
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
Changing the language without a reload is out of scope.
|
|
51
|
+
Value fields share `label`, `description`, `error`, `required`, and `disabled`
|
|
52
|
+
props. Use `value` and `onValueChange` for controlled edits; `onValueCommit`
|
|
53
|
+
reports a completed edit, such as leaving a text field or confirming a picker.
|
|
54
|
+
See the [TextInput guide](https://cloud.k2b.dev/en/ui/input/text) for details.
|
|
201
55
|
|
|
202
|
-
|
|
203
|
-
`<span>`, temporal components render `<time>` with a canonical `datetime`
|
|
204
|
-
attribute. `Format.Percent` takes a ratio (`0.12` → `12%`), `Format.Currency`
|
|
205
|
-
requires an ISO 4217 code, and `Format.Date`/`Time`/`DateTime` format in UTC
|
|
206
|
-
unless an explicit `timeZone` is passed, so server and browser text cannot
|
|
207
|
-
drift with the runtime timezone. Null and invalid input renders a `"—"`
|
|
208
|
-
fallback (override with `fallback`).
|
|
56
|
+
## Components
|
|
209
57
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
58
|
+
| Area | Examples |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| Actions | Buttons, menus, tabs, toolbars |
|
|
61
|
+
| Inputs | Text fields, selectors, date pickers, file inputs |
|
|
62
|
+
| Layout | Panels, settings, split panes, floating windows |
|
|
63
|
+
| Surfaces | Cards, avatars, badges, empty states |
|
|
64
|
+
| Feedback | Dialogs, prompts, tooltips, toasts |
|
|
65
|
+
| Content | Tables, charts, calendars, Markdown, file previews |
|
|
66
|
+
| Chat | Timeline, messages, composer, context usage |
|
|
67
|
+
| Widgets | Dashboard summaries, lists, statistics |
|
|
68
|
+
| Formatting | Numbers, currencies, dates, durations |
|
|
214
69
|
|
|
215
|
-
|
|
70
|
+
Browse the [component catalog](https://cloud.k2b.dev/en/ui) for APIs and
|
|
71
|
+
interactive examples.
|
|
216
72
|
|
|
217
|
-
|
|
218
|
-
UI showcase: AI, Inputs, Actions, Layout, Surfaces, Feedback, Content, and
|
|
219
|
-
Widgets. Cloud-specific integrations are intentionally not part of this
|
|
220
|
-
package.
|
|
73
|
+
## Styling
|
|
221
74
|
|
|
222
|
-
|
|
223
|
-
|
|
75
|
+
`global.css` includes component styles, IBM Plex fonts, and Tabler icons.
|
|
76
|
+
To choose the assets yourself, replace it with these individual imports:
|
|
224
77
|
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
<Chat.Timeline
|
|
230
|
-
items={items()}
|
|
231
|
-
hasMore={hasMore()}
|
|
232
|
-
onLoadOlder={loadOlder}
|
|
233
|
-
/>
|
|
234
|
-
<Chat.Composer
|
|
235
|
-
value={draft()}
|
|
236
|
-
onValueChange={setDraft}
|
|
237
|
-
onSubmit={sendMessage}
|
|
238
|
-
state={runState()}
|
|
239
|
-
models={models}
|
|
240
|
-
selectedModelId={modelId()}
|
|
241
|
-
onModelChange={setModelId}
|
|
242
|
-
contextUsage={{ usage: usage(), contextWindow: 128_000 }}
|
|
243
|
-
/>
|
|
244
|
-
</Chat>;
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
Return `false` or throw from `onSubmit` to restore the controlled draft and
|
|
248
|
-
attachments. A synchronous throw and a rejected promise are treated identically,
|
|
249
|
-
and the failure is handed to
|
|
250
|
-
`onError` for user-facing reporting. Raw selected files are handed to
|
|
251
|
-
`fileSelection.onSelect`; storage and upload policy remain application-owned.
|
|
252
|
-
`Chat.Timeline` requests older items through `hasMore`/`onLoadOlder` and keeps
|
|
253
|
-
the reader's position once they are prepended.
|
|
254
|
-
|
|
255
|
-
`Panes` is a controlled, serializable layout for IDE-like workspaces. The
|
|
256
|
-
package owns tabs, nested splits, resize and drag-and-drop; applications own
|
|
257
|
-
pane content, open and close behavior, routing, and persistence:
|
|
258
|
-
|
|
259
|
-
```tsx
|
|
260
|
-
const [layout, setLayout] = createSignal(createPanesLayout(["result", "query"]));
|
|
261
|
-
const items: PanesItem[] = [
|
|
262
|
-
{
|
|
263
|
-
id: "result",
|
|
264
|
-
title: "Result",
|
|
265
|
-
icon: "ti ti-table",
|
|
266
|
-
render: () => <ResultView />,
|
|
267
|
-
onClose: () => setLayout((current) => removePanesItem(current, "result")),
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
id: "query",
|
|
271
|
-
title: "Query",
|
|
272
|
-
icon: "ti ti-code",
|
|
273
|
-
render: () => <QueryEditor />,
|
|
274
|
-
},
|
|
275
|
-
];
|
|
276
|
-
|
|
277
|
-
<Panes layout={layout()} onLayoutChange={setLayout} items={items} />;
|
|
78
|
+
```ts
|
|
79
|
+
import "@k2b/ui/styles.css";
|
|
80
|
+
import "@k2b/ui/fonts/plex.css"; // Optional font preset
|
|
81
|
+
import "@k2b/ui/icons/tabler.css"; // Icon preset used by built-in controls
|
|
278
82
|
```
|
|
279
83
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
item's `render` function only while that item is active in its tab group.
|
|
284
|
-
Tab rows remain one line and scroll horizontally when needed. Dragging exposes
|
|
285
|
-
separate tab-insertion, group, and directional split targets while the pointer
|
|
286
|
-
preview retains the source tab's compact pill treatment.
|
|
287
|
-
|
|
288
|
-
Cloud applications import portable components directly from `@k2b/ui`.
|
|
289
|
-
Product-owned behavior such as permissions, account routes, stored AI
|
|
290
|
-
protocols, and workflow contracts stays behind focused Cloud package exports;
|
|
291
|
-
there is no generic Cloud UI compatibility layer.
|
|
292
|
-
|
|
293
|
-
The Fibel component showcase is the canonical acceptance consumer. Its
|
|
294
|
-
portable pages import `@k2b/ui` directly, while Cloud API integrations remain
|
|
295
|
-
in a visibly separate section. Together with `packages/ui/fixture`, it
|
|
296
|
-
exercises the package boundary and public API ergonomics outside the Cloud
|
|
297
|
-
shell. The fixture provides automated server-render and shipped-class checks;
|
|
298
|
-
the catalog owns representative browser interaction, theme, responsive, and
|
|
299
|
-
accessibility states.
|
|
84
|
+
Styles stay inside `.k2b-ui` without resetting the page's global styles.
|
|
85
|
+
Customize fonts and colors through CSS variables on that scope. For dark mode,
|
|
86
|
+
set `data-theme="dark"` on the scope.
|
|
300
87
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
```bash
|
|
304
|
-
bun run typecheck # package sources
|
|
305
|
-
bun run test # builds the stylesheet first, then runs every suite
|
|
306
|
-
bun run build # dist/styles.css and the optional font/icon presets
|
|
307
|
-
bun run fixture:typecheck # standalone consumer fixture
|
|
308
|
-
bun run fixture:build # standalone SSR build, no Cloud CSS or runtime
|
|
309
|
-
```
|
|
88
|
+
See [Theme and styles](https://cloud.k2b.dev/en/ui/surfaces/utilities) for
|
|
89
|
+
configuration and accessible color choices.
|
|
310
90
|
|
|
311
|
-
|
|
312
|
-
conditions. Bundlers can therefore tree-shake unused component families instead
|
|
313
|
-
of retaining the complete package through the root export.
|
|
91
|
+
## Documentation
|
|
314
92
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
is the supported one-step command.
|
|
93
|
+
- [Getting started and SSR setup](https://cloud.k2b.dev/en/ui/getting-started)
|
|
94
|
+
- [Component reference and live examples](https://cloud.k2b.dev/en/ui)
|
|
95
|
+
- [Locale, formatting, and SSR consistency](https://cloud.k2b.dev/en/ui/content/intl)
|
|
319
96
|
|
|
320
|
-
|
|
321
|
-
regressed silently during the extraction:
|
|
97
|
+
## Background
|
|
322
98
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
scoped source sheets; Tailwind `@reference` directives live in source sheets
|
|
327
|
-
such as `index.css` and `content-parity.css` and emit no generic utilities, so
|
|
328
|
-
a leftover utility class in markup styles nothing.
|
|
329
|
-
- `src/styles/focus-contract.test.ts` — at most one focus signal per selector
|
|
330
|
-
and cascade context, box-shadow-only focus rings have a forced-colors outline
|
|
331
|
-
fallback, and AI tokens stay inside AI surfaces.
|
|
332
|
-
- Per-group single-ownership tests — a selector may be declared in only one
|
|
333
|
-
stylesheet. Two partial declarations of the same selector merge into a third
|
|
334
|
-
geometry matching neither Cloud nor either source.
|
|
99
|
+
Originally developed as the component library for `@k2b/cloud`, `@k2b/ui` is
|
|
100
|
+
now an independent, application-agnostic SolidJS library. It has no dependency
|
|
101
|
+
on Cloud services, routes, or application state.
|
|
335
102
|
|
|
336
103
|
## License
|
|
337
104
|
|
|
338
|
-
|
|
339
|
-
The bundled IBM Plex fonts retain their SIL Open Font License, and Tabler
|
|
340
|
-
Icons retain their MIT license. Their complete notices ship in `dist/licenses`.
|
|
105
|
+
AGPL-3.0-or-later. See [LICENSE](./LICENSE).
|
|
341
106
|
|
|
342
|
-
|
|
343
|
-
|
|
107
|
+
Bundled IBM Plex fonts use the SIL Open Font License; Tabler Icons use the
|
|
108
|
+
MIT license. Their complete notices ship in `dist/licenses`.
|