@apliteni/apliteni-ui 0.142.0 → 0.142.3

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 (46) hide show
  1. package/README.md +24 -36
  2. package/guidelines/state-set.md +4 -4
  3. package/package.json +3 -3
  4. package/react/dist/index.css +2 -2
  5. package/react/dist/index.js +12 -5
  6. package/src/index.d.ts +13 -96
  7. package/src/index.js +17 -30
  8. package/src/logic/account-nav.js +9 -0
  9. package/src/logic/code.js +75 -0
  10. package/src/logic/dropdown-placement.js +671 -0
  11. package/src/logic/feedback.js +16 -0
  12. package/src/logic/theme.js +5 -0
  13. package/src/styles/command-palette.css +9 -5
  14. package/src/styles/drawer.css +8 -0
  15. package/src/styles/dropdown.css +30 -8
  16. package/src/styles/feedback.css +1 -1
  17. package/src/styles/filter-bar.css +5 -2
  18. package/src/styles/input.css +14 -15
  19. package/src/styles/layout.css +5 -2
  20. package/src/styles/table.css +28 -2
  21. package/src/styles/topbar.css +8 -6
  22. package/src/components/account-nav.js +0 -44
  23. package/src/components/avatar.js +0 -53
  24. package/src/components/back.js +0 -57
  25. package/src/components/button-busy.js +0 -69
  26. package/src/components/command-palette.js +0 -471
  27. package/src/components/confirm.js +0 -131
  28. package/src/components/drawer.js +0 -169
  29. package/src/components/dropdown.js +0 -1713
  30. package/src/components/feedback.js +0 -182
  31. package/src/components/filter-bar.js +0 -86
  32. package/src/components/footer.js +0 -102
  33. package/src/components/index.js +0 -424
  34. package/src/components/loading.js +0 -127
  35. package/src/components/nav.js +0 -220
  36. package/src/components/overlay.js +0 -263
  37. package/src/components/pagination.js +0 -323
  38. package/src/components/segmented.js +0 -33
  39. package/src/components/shell.js +0 -511
  40. package/src/components/stat.js +0 -82
  41. package/src/components/success.js +0 -131
  42. package/src/components/table-values.js +0 -32
  43. package/src/components/tabs.js +0 -82
  44. package/src/components/toasts.js +0 -118
  45. package/src/components/tooltip.js +0 -347
  46. package/src/components/topbar.js +0 -269
package/README.md CHANGED
@@ -4,14 +4,15 @@
4
4
  [![license: MIT](https://img.shields.io/npm/l/@apliteni/apliteni-ui?color=3b9dff)](./LICENSE)
5
5
  [![live: ui.apli.tech](https://img.shields.io/badge/live-ui.apli.tech-9b5dff)](https://ui.apli.tech)
6
6
 
7
- The Apliteni design system and UI kit provides shared design tokens, components, themes and
8
- UI rules for the strategy deck, the text portal, `/account` and future product surfaces.
7
+ The Apliteni design system and UI kit provides shared design tokens, React components,
8
+ themes and UI rules for the strategy deck, the text portal, `/account` and future product
9
+ surfaces.
9
10
 
10
- One package carries two layers. **HTML + CSS** includes token CSS, component CSS and
11
- HTML-string factories. Use this layer for server-rendered pages that do not use a component
12
- framework. **React components** support surfaces with client-side state, such as tables,
13
- filters, forms and modals. Both layers use the same `.ui-*` classes and tokens, so a page
14
- can use both. Choose React when the surface needs state.
11
+ The kit ships tokens, component CSS and React components together. Server-rendered pages
12
+ that do not use a component framework can still take the CSS, tokens and the inline
13
+ strings, or write the kit's `.ui-*` classes by hand. The helpers the root entry publishes —
14
+ `icon`, `prism`, `sun`, `moon`, `brand`, `esc`, `safeUrl` and the shared logic — serve
15
+ both.
15
16
 
16
17
  Every component is in Storybook at **[ui.apli.tech](https://ui.apli.tech)**.
17
18
 
@@ -27,8 +28,7 @@ npm install @apliteni/apliteni-ui react react-dom
27
28
  Install React and React DOM yourself, using version 18 or newer. The kit does not declare
28
29
  either package as a regular or peer dependency. npm therefore does not install them or warn
29
30
  when they are missing. If they are missing, importing `@apliteni/apliteni-ui/react` fails
30
- at build time or runtime with a module-not-found error. A plain HTML consumer installs only
31
- the kit and is unaffected because React is not added to its dependency tree.
31
+ at build time or runtime with a module-not-found error.
32
32
 
33
33
  The React components are a subpath of this package, not a separate package. You get one
34
34
  install, one version and one version pin.
@@ -36,7 +36,7 @@ install, one version and one version pin.
36
36
  | Import | What it is |
37
37
  | --- | --- |
38
38
  | `@apliteni/apliteni-ui/css` | Tokens and every component stylesheet. Import once at the app root. |
39
- | `@apliteni/apliteni-ui` | The HTML-string factories: `button()`, `card()`, `topbar()`, `appShell()` and the rest. |
39
+ | `@apliteni/apliteni-ui` | The helpers and shared logic: `icon`, `prism`, `sun`, `moon`, `brand`, `esc`, `safeUrl`, motion and the dropdown, chart, pagination and filter helpers. |
40
40
  | `@apliteni/apliteni-ui/react` | The React components, TypeScript types included. |
41
41
  | `@apliteni/apliteni-ui/react/css` | Their shell styles. |
42
42
  | `@apliteni/apliteni-ui/inline` | The same CSS as strings, for a server that inlines it. |
@@ -44,24 +44,16 @@ install, one version and one version pin.
44
44
 
45
45
  ## Use it
46
46
 
47
- ```js
48
- import '@apliteni/apliteni-ui/css';
49
- import { topbar, card, button, wireTopbar } from '@apliteni/apliteni-ui';
50
-
51
- el.innerHTML = topbar({ word: 'Strategy', account: { name, email } })
52
- + card({ title: 'Appearance', body: button({ label: 'Save', variant: 'primary' }) });
53
- wireTopbar(document); // theme toggle, menus, segmented controls, copy buttons
54
- ```
55
-
56
47
  ```tsx
57
48
  import '@apliteni/apliteni-ui/css';
58
49
  import '@apliteni/apliteni-ui/react/css';
59
- import { DataTable, Modal } from '@apliteni/apliteni-ui/react';
50
+ import { AppShell, DataTable, Modal } from '@apliteni/apliteni-ui/react';
51
+ import { icon } from '@apliteni/apliteni-ui';
60
52
  ```
61
53
 
62
- The `appShell()` factory provides the complete product layout: the sticky rail, the page body
63
- and a topbar over it when you ask for one, so no product rebuilds it. The
64
- [component catalog](docs/components.md#component-catalog) lists this factory and every other one.
54
+ The `AppShell` component provides the complete product layout: the rail, the page body and
55
+ a topbar over it when you ask for one, so no product rebuilds it. The
56
+ [component catalog](docs/components.md#component-catalog) lists it and every other component.
65
57
  Account and personal settings belong in a modal over the product rather than on a page of
66
58
  their own — see [Guidelines / Account and settings](guidelines/account-and-settings.md).
67
59
 
@@ -102,14 +94,10 @@ rule. If the host wants to follow the operating system preference, its JavaScrip
102
94
  choose the theme and add the attribute. See
103
95
  [an absent attribute means dark](docs/components.md#an-absent-attribute-means-dark).
104
96
 
105
- You can change the settings at runtime with `applyTheme('light')` and
106
- `applyAccent('phoenix')`. These functions save the choices to `localStorage`. You can also
107
- use `accentPicker()`, which `wireTopbar()` connects.
108
-
109
97
  ## The rules
110
98
 
111
99
  The **Guidelines** explain what a page may contain, which component to choose, which states
112
- it must support, and how to handle colour and wording. Both kit layers follow these rules.
100
+ it must support, and how to handle colour and wording. The kit follows these rules.
113
101
  The guidelines ship as Markdown in the package and are also available as a Storybook
114
102
  section.
115
103
 
@@ -123,7 +111,7 @@ section.
123
111
  | --- | --- |
124
112
  | [foundations.md](docs/foundations.md) | The tokens and the floors: widths, breakpoints, spacing, type, colour, elevation, the focus ring, the tap floor. |
125
113
  | [components.md](docs/components.md) | The package: what to import, theming, the component catalog, and what each component guarantees. |
126
- | [react/README.md](react/README.md) | The React components, their props, and the Storybook on port 6007. |
114
+ | [react/README.md](react/README.md) | The React components and their props. |
127
115
  | [contributing.md](docs/contributing.md) | Working on the kit: the repository's layout, Storybook, the guidelines collection, the site, the changelog and releases. |
128
116
 
129
117
  ## Contribute
@@ -132,7 +120,7 @@ Use Node 20 or newer. Install [jq](https://jqlang.github.io/jq/), then run:
132
120
 
133
121
  ```bash
134
122
  npm ci
135
- npm run storybook # the kit; add -w react for the React workspace
123
+ npm run storybook
136
124
  npm test && npm test -w react && npm run build-storybook && node site/build.mjs
137
125
  ```
138
126
 
@@ -142,14 +130,14 @@ Add a general, composable kit component only when all three conditions are true:
142
130
  names at least two products that use it or have requested it; existing components cannot
143
131
  provide it without copying markup or logic; and it contains no domain-specific data or
144
132
  rules. If any condition is missing, compose the UI from existing components and add a
145
- Storybook showcase. Preserve the vanilla kit's existing look.
133
+ Storybook showcase.
146
134
 
147
135
  To add a component, put its token-based CSS in `src/styles/`. Include that CSS in
148
- `src/index.css` and in both the `styles` map and `cssText` in `src/inline.js`. Put the HTML
149
- factory in `src/components/` and export it from `src/index.js`. Add a playground and state
150
- examples in `stories/components/`. Put React components in `react/src/`; each one needs a
151
- test and a story that use the shared classes and tokens. The
152
- [guidelines](guidelines/overview.md) define the design rules.
136
+ `src/index.css` and in both the `styles` map and `cssText` in `src/inline.js`. Put the
137
+ React component in `react/src/`; each one needs a test and a story that use the shared
138
+ classes and tokens. Shared logic the React components take from the root entry lives in
139
+ `src/logic/` and is exported from `src/index.js`. The [guidelines](guidelines/overview.md)
140
+ define the design rules.
153
141
 
154
142
  Open an issue, create a branch from `main`, and link the issue in your PR. If you change a
155
143
  published file, including this README, bump the version in `package.json` and
@@ -4,15 +4,15 @@
4
4
 
5
5
  <!-- rule: focus-visible -->
6
6
 
7
- **Rule:** Give every focusable control the same `--ring`, and show it only on `:focus-visible`.
7
+ **Rule:** Show one ring when focus is visible, and make a focused field's border transparent.
8
8
 
9
9
  **Why:** One solid band keeps focus consistent while the browser decides when to show it.
10
10
 
11
- **Do:** Apply `--ring`, with `--ring-offset`, to both the button and input on keyboard focus.
11
+ **Do:** Give buttons and fields the same ring, with one clear gap around each control.
12
12
 
13
- **Don't:** Give the input a separate muted outline while the button uses `--ring`.
13
+ **Don't:** Leave a field border visible inside its focus ring.
14
14
 
15
- **Except:** A box whose own edges are a surface's — a scroll region, or a box filling a table cell — takes `--ring-scroll` with `--ring-scroll-offset`. A box that is the outermost surface, such as a panel or card, keeps `--ring`. Text-entry controls may match `:focus-visible` on mouse focus. Both bands are declared once at the root and recomposed nowhere, because an outline leaves its offset unpainted. Adjust width and colour there.
15
+ **Except:** A scroll region or a box that fills a table cell uses `--ring-scroll` with its offset. A panel or card uses `--ring`. A text field can match `:focus-visible` on mouse focus. Both rings are defined once at the root because an outline leaves its offset unpainted. Adjust width and colour there.
16
16
 
17
17
  ## Busy controls
18
18
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.142.0",
3
+ "version": "0.142.3",
4
4
 
5
5
  "workspaces": [
6
6
  "react"
7
7
  ],
8
- "description": "Apliteni shared design system & UI kit — tokens, components and the deck theme, framework-agnostic (HTML + CSS).",
8
+ "description": "Apliteni shared design system & UI kit — tokens, React components and the deck theme.",
9
9
  "type": "module",
10
10
  "license": "MIT",
11
11
  "author": "Apliteni",
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@storybook/addon-a11y": "^10.5.5",
71
- "@storybook/html-vite": "^10.5.5",
71
+ "@storybook/react-vite": "^10.6.1",
72
72
  "axe-core": "^4.12.1",
73
73
  "jsdom": "^30.0.1",
74
74
  "storybook": "^10.5.5",
@@ -246,9 +246,9 @@
246
246
  .rx-modal__title {
247
247
  margin: 0;
248
248
  font-family: var(--font-sans);
249
- font-weight: var(--weight-normal);
249
+ font-weight: var(--weight-semibold);
250
250
  font-size: var(--text-base);
251
- color: var(--text);
251
+ color: var(--strong);
252
252
  }
253
253
  .rx-modal__body {
254
254
  padding: var(--space-4);
@@ -3138,7 +3138,14 @@ function FilterBar({ filters, label = "Filters", clearLabel = "Clear all", clear
3138
3138
  }
3139
3139
  }
3140
3140
  const prior = focused.current;
3141
- if (!prior || prior.id === null && filters.length > 0 || filters.some((f) => f.id === prior.id)) return;
3141
+ if (!prior || prior.id === null && filters.some((f) => !filterChipUnset(f))) return;
3142
+ const kept = filters.some((f) => f.id === prior.id);
3143
+ if (kept) {
3144
+ const held = chips.find((c) => c.dataset.filterId === prior.id && !c.disabled);
3145
+ const lost = prior.remove && !held?.querySelector("[data-filter-remove]") && !blocked && held && bar.current && bar.current.ownerDocument.activeElement === bar.current.ownerDocument.body && held.querySelector("[data-dropdown-trigger]");
3146
+ if (lost) lost.focus();
3147
+ return;
3148
+ }
3142
3149
  const next = chips.slice(prior.index).find((chip) => !chip.disabled) || chips.slice(0, prior.index).reverse().find((chip) => !chip.disabled);
3143
3150
  const target = !blocked && next?.querySelector("[data-dropdown-trigger]");
3144
3151
  focused.current = null;
@@ -3165,8 +3172,8 @@ function FilterBar({ filters, label = "Filters", clearLabel = "Clear all", clear
3165
3172
  className: "ui-filter-bar__chip",
3166
3173
  "data-filter-id": filter.id,
3167
3174
  disabled: filter.disabled,
3168
- onFocus: () => {
3169
- focused.current = { id: filter.id, index };
3175
+ onFocus: (event) => {
3176
+ focused.current = { id: filter.id, index, remove: Boolean(event.target.closest("[data-filter-remove]")) };
3170
3177
  },
3171
3178
  children: [
3172
3179
  /* @__PURE__ */ jsx26("legend", { className: "ui-filter-bar__legend", children: filter.label }),
@@ -3184,7 +3191,7 @@ function FilterBar({ filters, label = "Filters", clearLabel = "Clear all", clear
3184
3191
  }
3185
3192
  }
3186
3193
  ),
3187
- /* @__PURE__ */ jsx26(
3194
+ !filterChipUnset(filter) && /* @__PURE__ */ jsx26(
3188
3195
  "button",
3189
3196
  {
3190
3197
  type: "button",
@@ -3224,7 +3231,7 @@ function FilterBar({ filters, label = "Filters", clearLabel = "Clear all", clear
3224
3231
  }
3225
3232
  }
3226
3233
  ) }),
3227
- filters.length > 0 && /* @__PURE__ */ jsx26("span", { "data-filter-clear": "", onFocus: () => {
3234
+ filters.some((filter) => !filterChipUnset(filter)) && /* @__PURE__ */ jsx26("span", { "data-filter-clear": "", onFocus: () => {
3228
3235
  focused.current = { id: null, index: 0 };
3229
3236
  }, children: /* @__PURE__ */ jsx26(Button, { size: "sm", variant: clearVariant, onClick: () => {
3230
3237
  if (!blocked) onClear();
package/src/index.d.ts CHANGED
@@ -1,20 +1,13 @@
1
1
  /** Watch tab content and width without changing the current route. Call the result on removal. */
2
2
  export declare function observeNavFit(nav: HTMLElement): () => void;
3
3
  export declare function esc(value: unknown): string;
4
- /** The URL boundary every factory and React component sends a destination through. */
4
+ /** The URL boundary every component sends a destination through. */
5
5
  export declare function safeUrl(value: unknown, fallback?: string): string;
6
6
  /** Scroll a tab row so its `aria-current` link is inside the viewport. */
7
7
  export declare function revealCurrentNav(nav: HTMLElement): void;
8
8
  /** Scroll a tab row so the link a focus event landed on clears the row's edge. */
9
9
  export declare function revealFocusedNav(nav: HTMLElement, target: EventTarget | null): void;
10
- export declare function field(opts?: Record<string, unknown>): string;
11
- export declare function input(opts?: Record<string, unknown>): string;
12
- export declare function textarea(opts?: Record<string, unknown>): string;
13
- export declare function select(opts?: Record<string, unknown>): string;
14
- export declare function numericValue(opts?: Record<string, unknown>): string;
15
- export declare function deltaValue(opts?: Record<string, unknown>): string;
16
- export declare function filterBar(opts?: Record<string, unknown>): string;
17
- export declare function initFilterBar(host: Element, opts?: Record<string, unknown>): { update: (opts: Record<string, unknown>) => void; destroy: () => void };
10
+
18
11
  export declare function filterChipText(filter?: { label?: string; value?: string }): string;
19
12
  export declare function filterChipName(filter?: { label?: string; value?: string }): string;
20
13
  export declare function filterChipUnset(filter?: { value?: string }): boolean;
@@ -26,27 +19,19 @@ export declare function focusNextStop(host: Element | null | undefined): HTMLEle
26
19
  * whose value is in no row marks nothing rather than leaving a `selected` the caller
27
20
  * set standing. The caller's array and objects are not written to. */
28
21
  export declare function filterChipItems<T>(filter?: { value?: string; items?: T[] }): T[];
22
+
29
23
  export declare function segmentedNextIndex(key: string, index: number, length: number): number | null;
24
+
30
25
  export declare function icon(name: string, className?: string): string;
31
- export declare function snippet(opts?: Record<string, unknown>): string;
32
- export declare function button(opts?: Record<string, unknown>): string;
33
- export declare function badge(label: string, variant?: string): string;
26
+
34
27
  export declare const AVATAR_HUES: 8;
35
28
  /** Which of the eight person hues a key gets: FNV-1a 32 bit over its UTF-8 bytes, modulo 8. */
36
29
  export declare function avatarHue(key: unknown): number;
37
30
  /** The first letter of the first word and of the last word, upper-cased; '' for no name. */
38
31
  export declare function avatarInitials(name: unknown): string;
39
- export declare function avatar(opts?: {
40
- key?: string | number; name?: string | null; initials?: string; src?: string; size?: 24 | 32; empty?: boolean;
41
- }): string;
32
+
42
33
  export declare const calloutIcons: Record<'neutral' | 'info' | 'success' | 'warn' | 'danger', string>;
43
- export declare function callout(opts?: Record<string, unknown>): string;
44
- export declare function card(opts?: Record<string, unknown>): string;
45
- export declare function pagination(opts?: Record<string, unknown>): string;
46
- export declare function drawerSection(opts?: Record<string, unknown>): string;
47
- export declare function drawer(opts?: Record<string, unknown>): string;
48
- export declare function dropdown(opts?: Record<string, unknown>): string;
49
- export declare function wireDropdown(root?: Document | Element): void;
34
+
50
35
  /** The kit's own match, asked rather than re-implemented by <Dropdown>. */
51
36
  export declare function dropdownMatch(label: unknown, query: unknown): boolean;
52
37
  export declare function dropdownFiltering(query: unknown): boolean;
@@ -127,13 +112,12 @@ export declare function dropdownRest(
127
112
  open: boolean,
128
113
  wait?: number,
129
114
  ): () => void;
130
- export declare function backLink(opts?: Record<string, unknown>): string;
131
- export declare function statBand(opts?: Record<string, unknown>): string;
132
- export declare function commandPalette(opts?: Record<string, unknown>): string;
115
+
133
116
  export declare function rankGroups<G>(groups: readonly G[], query: string): G[];
134
117
  export declare function rankCommands<I>(items: readonly I[], query: string): I[];
135
118
  export declare function scoreCommand(item: Record<string, unknown>, query: string): number;
136
119
  export declare function paletteHotkey(platform?: string): string;
120
+
137
121
  export declare const PAGE_SIZES: number[];
138
122
  export declare const DEFAULT_PAGE_SIZE: number;
139
123
  export type NumericValueOptions = { value?: string | number | null; unit?: string; missing?: string };
@@ -159,6 +143,7 @@ export declare function pointTarget(
159
143
  point: { x: number; y: number }, limits: PointTargetLimits,
160
144
  ): ChartTarget;
161
145
  export declare const SCORE: Record<'exact' | 'prefix' | 'wordStart' | 'contains' | 'keyword' | 'description' | 'subsequence', number>;
146
+
162
147
  export declare const iconNames: string[];
163
148
  export declare const iconCategories: { name: string; names: string[] }[];
164
149
  export declare const iconOnlyAllowed: Record<string, string>;
@@ -173,89 +158,21 @@ export declare function illo(name: string): string;
173
158
  export * from './motion.js';
174
159
  export declare const illoNames: string[];
175
160
 
176
- // The custom properties one accent swatch button carries. ACCENTS is declared
177
- // with the topbar wiring that re-exports it.
161
+ /** The custom properties one accent swatch button carries. */
178
162
  export declare function accentSwatchStyle(accent: string): Record<string, string>;
179
163
 
180
- // Vanilla factories accept their existing option bags and return HTML.
181
- export declare function accentPicker(opts?: Record<string, unknown>): string;
182
- export declare function accountMenu(opts?: Record<string, unknown>): string;
183
- export declare function appShell(opts?: Record<string, unknown>): string;
184
- export declare function breadcrumbs(opts?: Record<string, unknown>): string;
185
- export declare function busyRegion(opts?: Record<string, unknown>): string;
186
- export declare function checkbox(opts?: Record<string, unknown>): string;
187
- export declare function confirm(opts?: Record<string, unknown>): string;
188
- export declare function deniedState(opts?: Record<string, unknown>): string;
189
- export declare function emptyState(opts?: Record<string, unknown>): string;
190
- export declare function feedbackWidget(opts?: Record<string, unknown>): string;
191
- export declare function footer(opts?: Record<string, unknown>): string;
192
- export declare function nav(opts?: Record<string, unknown>): string;
193
- export declare function navTabs(opts?: Record<string, unknown>): string;
194
- export declare function rowIdentity(opts?: Record<string, unknown>): string;
195
- export declare function segmented(opts?: Record<string, unknown>): string;
196
- export declare function sidebarNav(opts?: Record<string, unknown>): string;
197
- export declare function skeleton(opts?: Record<string, unknown>): string;
198
- export declare function skeletonTable(opts?: Record<string, unknown>): string;
199
- export declare function success(opts?: Record<string, unknown>): string;
200
- export declare function successPanel(opts?: Record<string, unknown>): string;
201
- export declare function switchToggle(opts?: Record<string, unknown>): string;
202
- export declare function tabs(opts?: Record<string, unknown>): string;
203
- export declare function toast(opts?: Record<string, unknown>): string;
204
- export declare function tooltip(opts?: Record<string, unknown>): string;
205
- export declare function topbar(opts?: Record<string, unknown>): string;
206
- export declare function commandPaletteList(groups?: readonly Record<string, unknown>[], opts?: { uid?: string; from?: number }): string;
207
- export declare function deckTextSwitch(active?: string): string;
208
- export declare function hlShell(raw: string): string;
209
164
  /** Token class from styles/code.css, or null for the text between tokens. */
210
165
  export type CodeTokenClass = 'c' | 'f' | 'k' | 's' | 'u';
211
166
  export type CodeLanguage = 'shell' | 'json' | 'ts';
212
167
  export declare const codeLanguages: readonly CodeLanguage[];
213
168
  export declare function codeTokens(raw: string, lang?: CodeLanguage): { cls: CodeTokenClass | null; text: string }[];
214
169
  export declare function hlCode(raw: string, lang?: CodeLanguage): string;
215
- export declare function pill(label: string, variant?: string): string;
216
- export declare function statusDot(live?: boolean): string;
217
- export declare function successCheck(variant?: 'line' | 'circled'): string;
170
+ export declare function hlShell(raw: string): string;
171
+
218
172
  export declare function themeIcon(theme: string): string;
219
- export declare function themeName(theme: string): string;
220
- export declare function themeToggle(theme?: string): string;
221
- export declare function versionSwitcher(versions?: { label: string; meta?: string; badge?: string }[], activeIdx?: number): string;
222
173
 
223
174
  // A tuple, so React can derive its Accent union from it.
224
175
  export declare const ACCENTS: readonly ['default', 'phoenix', 'ocean', 'emerald'];
225
176
  export declare const ACCOUNT_NAV: { id: string; icon: string; label: string }[];
226
- export declare const RAIL_COOKIE: 'apliteni-ui-rail';
227
- export declare const STAT_TONES: string[];
228
- export declare const STAT_VARIANTS: string[];
229
177
 
230
- export declare function applyAccent(name: string, root?: HTMLElement): void;
231
- export declare function applyTheme(theme: string, root?: HTMLElement): void;
232
- export declare function railCollapsed(cookies?: string): boolean | null;
233
- export declare function closeCommandPalette(root: Element | null): void;
234
- export declare function closeConfirm(root: Element | null): void;
235
- export declare function closeDrawer(root: Element | null): void;
236
- export declare function openCommandPalette(root: Element | null, returnFocusTo?: HTMLElement | null): void;
237
- export declare function openConfirm(root: Element | null, returnFocusTo?: HTMLElement | null): void;
238
- export declare function openDrawer(root: Element | null, returnFocusTo?: HTMLElement | null): void;
239
- export declare function setPaletteResults(root: HTMLElement, groups: readonly Record<string, unknown>[]): void;
240
- export declare function hideTooltip(host: HTMLElement): void;
241
- export declare function showTooltip(host: HTMLElement, mark: Element): void;
242
- export declare function initRowIdentity(root?: Document | Element): void;
243
- export declare function initSegmented(root?: Document | Element): () => void;
244
- export declare function initTabs(root?: Document | Element): void;
245
- export declare function wireCommandPalette(root?: Document | Element): void;
246
- export declare function wireConfirm(root?: Document | Element): void;
247
- export declare function wireDrawer(root?: Document | Element): void;
248
- export declare function wireFeedback(opts?: Record<string, unknown>): void;
249
- export declare function wireNav(root?: Document | Element): void;
250
- export declare function wireShell(root?: Document | Element, opts?: { persist?: boolean }): void;
251
- export declare function wireTooltip(root?: Document | Element): void;
252
- export declare function wireTopbar(root?: Document | Element): void;
253
- export declare function wireSuccess(root: Element, opts?: { onDone?: () => void }): () => void;
254
- export declare function wirePagination(root?: Document | Element | string | null, opts?: { onPage?: (page: number) => void; onPageSize?: (size: number) => void }): () => void;
255
178
  export declare function nearestSection(node: Node | null, root?: Element | null): Element | null;
256
- export declare function dismissToast(element: HTMLElement): void;
257
- export declare function wireToastStack(container: Element | string | null): Element | null;
258
- export declare function pushToast(container: Element | string | null, opts?: Record<string, unknown>): Element | null;
259
- export declare function setBusy(root: Element | string | null, opts?: { busy?: boolean; message?: string; body?: string }): Element | null;
260
- export declare function setButtonBusy(element: HTMLElement, opts?: { busy?: boolean }): void;
261
- export declare function setPagerStatus(root: Element | string | null, text: string): Element | null;
package/src/index.js CHANGED
@@ -1,40 +1,27 @@
1
1
  // apliteni-ui — public entry.
2
2
  // Styles ship separately: `import 'apliteni-ui/css'`.
3
- export * from './components/index.js';
4
- export * from './components/avatar.js';
5
- export * from './components/dropdown.js';
6
- export * from './components/tooltip.js';
7
- export * from './components/tabs.js';
8
- export * from './components/nav.js';
9
- export * from './components/back.js';
10
- export * from './components/drawer.js';
11
- export * from './components/confirm.js';
12
- export * from './components/command-palette.js';
13
- export * from './components/topbar.js';
14
- export * from './components/shell.js';
15
- export * from './components/footer.js';
16
- export * from './components/feedback.js';
17
- export * from './components/toasts.js';
18
- export * from './components/success.js';
19
- export * from './components/loading.js';
20
- export * from './components/pagination.js';
21
- export * from './components/stat.js';
22
3
  export * from './assets/icons.js';
23
4
  export * from './assets/brand.js';
5
+ export * from './assets/illustrations.js';
24
6
  export * from './motion.js';
25
- export { setButtonBusy } from './components/button-busy.js';
7
+ export { esc, safeUrl } from './html.js';
26
8
 
27
- export * from './components/table-values.js';
28
- export * from './components/segmented.js';
29
- export * from './components/filter-bar.js';
30
-
31
- export { dropdownMatch, dropdownFiltering, dropdownAvail } from './logic/dropdown.js';
9
+ export { ACCENTS, accentSwatchStyle } from './logic/accents.js';
10
+ export { ACCOUNT_NAV } from './logic/account-nav.js';
11
+ export { AVATAR_HUES, avatarHue, avatarInitials } from './logic/avatar.js';
12
+ export { calloutIcons } from './logic/callout.js';
13
+ export { CHART_FLOOR, chartScale, bridgeWalk, pointTarget } from './logic/chart.js';
14
+ export { codeLanguages, codeTokens, hlCode, hlShell } from './logic/code.js';
32
15
  export { SCORE, rankGroups, rankCommands, scoreCommand, paletteHotkey } from './logic/command-palette.js';
33
- export { segmentedNextIndex } from './logic/segmented.js';
16
+ export { dropdownMatch, dropdownFiltering, dropdownAvail } from './logic/dropdown.js';
17
+ export {
18
+ DD_MENU_FLOOR, filterPanelRow, filterPanelFit, dropdownHeightFit, dropdownLift,
19
+ dropdownReveal, dropdownRest, dropdownSnap, dropdownViewportFit,
20
+ } from './logic/dropdown-placement.js';
21
+ export { nearestSection } from './logic/feedback.js';
34
22
  export { filterChipText, filterChipName, filterChipUnset, filterChipItems, nextFocusStop, focusNextStop } from './logic/filter-bar.js';
23
+ export { observeNavFit, revealCurrentNav, revealFocusedNav } from './logic/nav.js';
35
24
  export { PAGE_SIZES, DEFAULT_PAGE_SIZE } from './logic/pagination.js';
36
- export { calloutIcons } from './logic/callout.js';
25
+ export { segmentedNextIndex } from './logic/segmented.js';
37
26
  export { formatNumericValue, formatDeltaValue } from './logic/table-values.js';
38
- export { accentSwatchStyle } from './logic/accents.js';
39
- export { observeNavFit, revealCurrentNav, revealFocusedNav } from './logic/nav.js';
40
- export { CHART_FLOOR, chartScale, bridgeWalk, pointTarget } from './logic/chart.js';
27
+ export { themeIcon } from './logic/theme.js';
@@ -0,0 +1,9 @@
1
+ // The one account navigation definition: the kit's default rows for a consumer's
2
+ // /account page. Labels are raw text, because every nav primitive escapes. `key` means
3
+ // credentials; `plug` means integration. A screen the kit does not ship belongs in the
4
+ // caller's own nav, not here. The vanilla shell and the React AppShell both read it.
5
+ // why: docs/components.md#the-page-shell
6
+ export const ACCOUNT_NAV = [
7
+ { id: 'prefs', icon: 'gear', label: 'Preferences' },
8
+ { id: 'access', icon: 'key', label: 'Access & agents' },
9
+ ];
@@ -0,0 +1,75 @@
1
+ import { esc } from '../html.js';
2
+
3
+ // Tiny highlighters. Each escapes first, then wraps the tokens its language
4
+ // shows, using the class names in styles/code.css (.k .f .s .u .c). Shell is
5
+ // ported from viz/account.mjs; JSON and TypeScript were added for the snippets
6
+ // the kit's own docs show.
7
+ //
8
+ // Every pattern runs over ESCAPED text, so a quoted string ends at &quot; and a
9
+ // shell URL stops at any entity. The group order is the class order beside it.
10
+ //
11
+ // They are small on purpose — they colour short documentation snippets, not
12
+ // arbitrary programs. Known limits: no nested template expressions, no regex
13
+ // literals, and in TypeScript a `//` inside a string reads as a comment unless a
14
+ // `:` precedes it, which is what keeps a URL in a string whole.
15
+ const LANGUAGES = {
16
+ shell: {
17
+ pattern: /(#[^\n]*)|(&quot;(?:[^&]|&(?!quot;))*&quot;|'[^']*')|(https?:\/\/[^\s"'&]+)|(\B--?[A-Za-z][\w-]*)|(^[a-z][\w.-]*)/gm,
18
+ classes: ['c', 's', 'u', 'f', 'k'],
19
+ },
20
+ // A key is a string followed by a colon, matched by lookahead so the colon
21
+ // stays unpainted. Keys, string values and scalars take three different
22
+ // classes, because a number that looks exactly like a key is not highlighting.
23
+ json: {
24
+ pattern: /(&quot;(?:[^&]|&(?!quot;))*&quot;)(?=\s*:)|(&quot;(?:[^&]|&(?!quot;))*&quot;)|(\b(?:true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,
25
+ classes: ['k', 's', 'f'],
26
+ },
27
+ ts: {
28
+ pattern: /(\/\*[\s\S]*?\*\/|(?<![:/])\/\/[^\n]*)|(&quot;(?:[^&]|&(?!quot;))*&quot;|'[^']*'|`[^`]*`)|(\b(?:import|export|from|const|let|var|function|return|async|await|class|extends|implements|interface|type|enum|new|if|else|for|while|of|in|as|default|readonly|void)\b)|(\b(?:true|false|null|undefined)\b|\b\d+(?:\.\d+)?\b)/g,
29
+ classes: ['c', 's', 'k', 'f'],
30
+ },
31
+ };
32
+
33
+ /** The languages codeTokens and hlCode understand, so a gate can discover them. */
34
+ export const codeLanguages = Object.keys(LANGUAGES);
35
+
36
+ const ENTITY = { amp: '&', lt: '<', gt: '>', quot: '"' };
37
+ // The exact inverse of esc: every & in escaped text starts one of these four.
38
+ const unesc = (text) => text.replace(/&(amp|lt|gt|quot);/g, (_, name) => ENTITY[name]);
39
+
40
+ /**
41
+ * A language's tokens, as `[{ cls, text }]` with `cls` null between tokens and
42
+ * `text` the original unescaped source. Concatenating `text` returns `raw`, so a
43
+ * React caller renders the spans from the same string it copies instead of
44
+ * keeping a second hand-written copy in step. hlCode joins the same tokens into
45
+ * HTML; neither can drift from the other. An unrecognised `lang` is read as
46
+ * shell, the way the kit reads every other unknown option name.
47
+ *
48
+ * No pattern ever matches inside an entity — `#`, `h`, `-`, `/`, `*`, a digit and
49
+ * `^[a-z]` do not occur in `&amp;`, `&lt;`, `&gt;` or `&quot;`, no keyword is one
50
+ * of `amp`, `lt`, `gt` or `quot`, and every alternative either stops before `&` or
51
+ * consumes a whole `&quot;` — so each slice is entity-complete and
52
+ * `esc(unesc(slice))` returns the slice unchanged. hlCode's output is therefore
53
+ * byte-identical to wrapping the matches in place, which
54
+ * src/logic/code.test.js holds for every language, against a copy
55
+ * of the one-pass implementation hlShell had before #474.
56
+ */
57
+ export function codeTokens(raw, lang = 'shell') {
58
+ const { pattern, classes } = LANGUAGES[lang] || LANGUAGES.shell;
59
+ const escaped = esc(raw);
60
+ const out = [];
61
+ let at = 0;
62
+ pattern.lastIndex = 0;
63
+ for (const match of escaped.matchAll(pattern)) {
64
+ if (match.index > at) out.push({ cls: null, text: unesc(escaped.slice(at, match.index)) });
65
+ out.push({ cls: classes[match.slice(1).findIndex(Boolean)], text: unesc(match[0]) });
66
+ at = match.index + match[0].length;
67
+ }
68
+ if (at < escaped.length) out.push({ cls: null, text: unesc(escaped.slice(at)) });
69
+ return out;
70
+ }
71
+
72
+ export const hlCode = (raw, lang = 'shell') =>
73
+ codeTokens(raw, lang).map(({ cls, text }) => (cls ? `<span class="${cls}">${esc(text)}</span>` : esc(text))).join('');
74
+
75
+ export const hlShell = (raw) => hlCode(raw, 'shell');