@k2b/ui 0.65.0 → 0.66.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 (106) hide show
  1. package/README.md +47 -0
  2. package/dist/browser/v2/button.js +180 -0
  3. package/dist/browser/v2/button.js.map +1 -0
  4. package/dist/browser/v2/components.js +763 -0
  5. package/dist/browser/v2/components.js.map +1 -0
  6. package/dist/browser/v2/content.js +1107 -0
  7. package/dist/browser/v2/content.js.map +1 -0
  8. package/dist/browser/v2/controls.js +568 -0
  9. package/dist/browser/v2/controls.js.map +1 -0
  10. package/dist/browser/v2/describe.js +397 -0
  11. package/dist/browser/v2/describe.js.map +1 -0
  12. package/dist/browser/v2/index.js +25 -0
  13. package/dist/browser/v2/index.js.map +1 -0
  14. package/dist/browser/v2/layout.js +578 -0
  15. package/dist/browser/v2/layout.js.map +1 -0
  16. package/dist/browser/v2/link.js +9 -0
  17. package/dist/browser/v2/link.js.map +1 -0
  18. package/dist/browser/v2/marks.js +211 -0
  19. package/dist/browser/v2/marks.js.map +1 -0
  20. package/dist/browser/v2/states.js +180 -0
  21. package/dist/browser/v2/states.js.map +1 -0
  22. package/dist/browser/v2/structure.js +328 -0
  23. package/dist/browser/v2/structure.js.map +1 -0
  24. package/dist/browser/v2/testing/index.js +23 -0
  25. package/dist/browser/v2/testing/index.js.map +1 -0
  26. package/dist/browser/v2/testing/measure-v2-layout.js +762 -0
  27. package/dist/browser/v2/testing/measure-v2-layout.js.map +1 -0
  28. package/dist/browser/v2/testing/settled.js +52 -0
  29. package/dist/browser/v2/testing/settled.js.map +1 -0
  30. package/dist/browser/v2/tokens.js +83 -0
  31. package/dist/browser/v2/tokens.js.map +1 -0
  32. package/dist/browser/v2/types.js +24 -0
  33. package/dist/browser/v2/types.js.map +1 -0
  34. package/dist/ssr/v2/button.js +177 -0
  35. package/dist/ssr/v2/button.js.map +1 -0
  36. package/dist/ssr/v2/components.js +518 -0
  37. package/dist/ssr/v2/components.js.map +1 -0
  38. package/dist/ssr/v2/content.js +727 -0
  39. package/dist/ssr/v2/content.js.map +1 -0
  40. package/dist/ssr/v2/controls.js +268 -0
  41. package/dist/ssr/v2/controls.js.map +1 -0
  42. package/dist/ssr/v2/describe.js +397 -0
  43. package/dist/ssr/v2/describe.js.map +1 -0
  44. package/dist/ssr/v2/index.js +25 -0
  45. package/dist/ssr/v2/index.js.map +1 -0
  46. package/dist/ssr/v2/layout.js +377 -0
  47. package/dist/ssr/v2/layout.js.map +1 -0
  48. package/dist/ssr/v2/link.js +9 -0
  49. package/dist/ssr/v2/link.js.map +1 -0
  50. package/dist/ssr/v2/marks.js +126 -0
  51. package/dist/ssr/v2/marks.js.map +1 -0
  52. package/dist/ssr/v2/states.js +128 -0
  53. package/dist/ssr/v2/states.js.map +1 -0
  54. package/dist/ssr/v2/structure.js +229 -0
  55. package/dist/ssr/v2/structure.js.map +1 -0
  56. package/dist/ssr/v2/testing/index.js +23 -0
  57. package/dist/ssr/v2/testing/index.js.map +1 -0
  58. package/dist/ssr/v2/testing/measure-v2-layout.js +762 -0
  59. package/dist/ssr/v2/testing/measure-v2-layout.js.map +1 -0
  60. package/dist/ssr/v2/testing/settled.js +52 -0
  61. package/dist/ssr/v2/testing/settled.js.map +1 -0
  62. package/dist/ssr/v2/tokens.js +83 -0
  63. package/dist/ssr/v2/tokens.js.map +1 -0
  64. package/dist/ssr/v2/types.js +24 -0
  65. package/dist/ssr/v2/types.js.map +1 -0
  66. package/dist/types/v2/button.d.ts +54 -0
  67. package/dist/types/v2/components.d.ts +173 -0
  68. package/dist/types/v2/content.d.ts +233 -0
  69. package/dist/types/v2/controls.d.ts +118 -0
  70. package/dist/types/v2/describe.d.ts +18 -0
  71. package/dist/types/v2/index.d.ts +22 -0
  72. package/dist/types/v2/layout.d.ts +124 -0
  73. package/dist/types/v2/link.d.ts +7 -0
  74. package/dist/types/v2/marks.d.ts +90 -0
  75. package/dist/types/v2/states.d.ts +45 -0
  76. package/dist/types/v2/structure.d.ts +47 -0
  77. package/dist/types/v2/testing/index.d.ts +16 -0
  78. package/dist/types/v2/testing/measure-v2-layout.d.ts +99 -0
  79. package/dist/types/v2/testing/settled.d.ts +13 -0
  80. package/dist/types/v2/tokens.d.ts +77 -0
  81. package/dist/types/v2/types.d.ts +44 -0
  82. package/dist/v2.css +3072 -0
  83. package/package.json +23 -4
  84. package/skills/k2b-ui/SKILL.md +201 -0
  85. package/skills/k2b-ui/images/form-1440.png +0 -0
  86. package/skills/k2b-ui/images/form-390.png +0 -0
  87. package/skills/k2b-ui/images/list-detail-1440.png +0 -0
  88. package/skills/k2b-ui/images/list-detail-390.png +0 -0
  89. package/skills/k2b-ui/images/mail-1440.png +0 -0
  90. package/skills/k2b-ui/images/mail-390.png +0 -0
  91. package/skills/k2b-ui/images/record-1440.png +0 -0
  92. package/skills/k2b-ui/images/record-390.png +0 -0
  93. package/skills/k2b-ui/images/record-groups-1440.png +0 -0
  94. package/skills/k2b-ui/images/record-groups-390.png +0 -0
  95. package/skills/k2b-ui/images/table-1440.png +0 -0
  96. package/skills/k2b-ui/images/table-390.png +0 -0
  97. package/skills/k2b-ui/recipes/form.tsx +54 -0
  98. package/skills/k2b-ui/recipes/list-detail.tsx +105 -0
  99. package/skills/k2b-ui/recipes/mail.tsx +193 -0
  100. package/skills/k2b-ui/recipes/record-groups.tsx +115 -0
  101. package/skills/k2b-ui/recipes/record.tsx +163 -0
  102. package/skills/k2b-ui/recipes/table.tsx +68 -0
  103. package/skills/k2b-ui/references/mistakes.md +162 -0
  104. package/skills/k2b-ui/references/primitives.md +310 -0
  105. package/skills/k2b-ui/references/recipes.md +101 -0
  106. package/skills/k2b-ui/references/seeing.md +94 -0
@@ -0,0 +1,47 @@
1
+ import { type JSX } from "solid-js";
2
+ import type { Action, TwoActions } from "./types";
3
+ export type SectionProps = {
4
+ /** The symbol of the section. With `color` it stands on a tinted tile, otherwise plain. */
5
+ icon?: string;
6
+ /** The data colour of the section's area, such as the colour of deliveries. */
7
+ color?: string;
8
+ title: string;
9
+ count?: number | string;
10
+ /** At most two text buttons in the head; on the phone they keep only their symbol. */
11
+ actions?: TwoActions;
12
+ /** One sentence under the head that sums the section up. */
13
+ summary?: JSX.Element;
14
+ /** The way to all of it, at the end ("All deliveries ›"). */
15
+ more?: Action;
16
+ children?: JSX.Element;
17
+ };
18
+ /**
19
+ * A section: a head with symbol, title, count and at most two text buttons. Rule 9: no line under the head, none
20
+ * between the entries, one line at the end.
21
+ */
22
+ export declare const Section: (props: SectionProps) => JSX.Element;
23
+ export type GroupProps = {
24
+ icon?: string;
25
+ color?: string;
26
+ title: string;
27
+ count?: number | string;
28
+ /** A quiet line under the title; the head grows from 40 to 56 px. */
29
+ meta?: JSX.Element;
30
+ /** A state at the end of the head, such as `<Text weight="medium"><Icon name="gavel" /> Läuft</Text>` or an amount. */
31
+ state?: JSX.Element;
32
+ /** More deeds of the group behind one "…" button. (The menu opens with the behaviour layer.) */
33
+ menu?: Action;
34
+ /** At most two text buttons at the end of the head; more deeds go into `menu`. */
35
+ actions?: TwoActions;
36
+ /**
37
+ * Only the head with its result; the content is hidden, and a chevron at the end opens it. (Opening comes with the
38
+ * behaviour layer.)
39
+ */
40
+ folded?: boolean;
41
+ children?: JSX.Element;
42
+ };
43
+ /**
44
+ * The one framed group: what belongs together (a delivery, the items of one consignor, a thread). A square frame of
45
+ * one hairline, a tinted head, and no line inside: entries are told apart by spacing alone. Never nested.
46
+ */
47
+ export declare const Group: (props: GroupProps) => JSX.Element;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `@k2b/ui/v2/testing`: check a v2 screen in a Playwright test the same way @k2b/ui checks its own primitives.
3
+ *
4
+ * - `measureV2Layout(page)`: edges, double lines, type roles and grips as numbers; `problems` is empty when the page
5
+ * keeps the v2 rules.
6
+ * - `describeV2Page(page)`: the text outline of `describeV2` from a laid-out page, with hidden parts and dropped
7
+ * columns at the page's width.
8
+ * - `settled(page)`: waits for fonts, layout and finite animations before anything is read.
9
+ *
10
+ * Needs Playwright in the consumer (an optional peer dependency); nothing here is part of the main export.
11
+ */
12
+ import type { Page } from "playwright";
13
+ export { measureV2Layout, type V2GripMeasure, type V2Layout, type V2LayoutOptions } from "./measure-v2-layout";
14
+ export { settled } from "./settled";
15
+ /** The `describeV2` outline of a laid-out page, from `root` (the whole body by default). */
16
+ export declare const describeV2Page: (page: Page, root?: string) => Promise<string>;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * A test helper, shipped as `@k2b/ui/v2/testing`: measures the layout rules of @k2b/ui v2 on a Playwright page, as numbers
3
+ * against the mockup instead of a count of error classes (the lesson of the flat audit, 22.11.).
4
+ *
5
+ * - **edge:** a horizontal hairline or a tinted band reaches both edges of its column (within 1.5 px). A column edge
6
+ * is a vertical hairline, an element matched by `columns`, or the edge of `root`.
7
+ * - **double:** no two parallel lines lie at most 1 px apart over more than 1 px of length, also across components.
8
+ * - **type:** every run of text is set in a type role: 12, 13, 14 or 18 px on a 16, 20 or 24 px line, in 400, 500 or
9
+ * 600. Reading text (`prose`) may also use 16 px and a 22 px line.
10
+ * - **grip:** the pill of every grip is centred on its 1 px line within ±0.25 CSS px, measured in the DOM and again
11
+ * in the screenshot at the page's device pixel ratio, inside the grip only.
12
+ *
13
+ * A line is any way to draw one: a border side, a `box-shadow` without blur (offset or spread), a box of at most
14
+ * 1.5 px, and the same on `::before` and `::after`, also under a `display: contents` parent whose own box has no
15
+ * size. To measure a pseudo-element, the helper puts a stand-in element with the pseudo's computed style in its place
16
+ * for the moment of the measurement and restores the page afterwards.
17
+ *
18
+ * Only what a person sees counts: a line or band is cut to the viewport and to every ancestor that clips it (a
19
+ * scrolled column), so content scrolled out of view is measured after scrolling, not before. A rounded box (a
20
+ * control, a mark, an overlay) floats on its own: its outline is no divider and makes no double line.
21
+ *
22
+ * The DOM contract of v2 marks what the rules need: `data-k2-column` (a column), `data-k2-grip` (a grip whose box is
23
+ * its pill), `data-k2-prose` (reading text), `data-k2-figure` (a drawn mark such as the track of steps; its lines are
24
+ * no dividers), `data-k2-canvas` (free drawing: never measured inside, only the line it draws itself) and
25
+ * `data-k2-avatar` (initials, no type role). The options take other selectors, for the mockup's classes for example.
26
+ *
27
+ * - **inside:** a band or a group is one thing (rule 9): a horizontal hairline inside it separates its parts and is a
28
+ * finding at any distance from other lines. A frame, a control's outline and a figure's track are no such line.
29
+ * - **cut:** a control's label never leaves its box and is never clipped, unless it ends in "…" in its own box (the
30
+ * way back to a list with a long name); a one-line text (the lines of a row, the
31
+ * cells of a table with column widths) never wraps, it ends with "…"; a box that clips its text shows every line
32
+ * whole and cuts a line at its end only with "…".
33
+ *
34
+ * ```ts
35
+ * import { measureV2Layout } from "@k2b/ui/v2/testing";
36
+ *
37
+ * for (const deviceScaleFactor of [1, 2])
38
+ * test(`DPR ${deviceScaleFactor}: the layout keeps the v2 rules`, async () => {
39
+ * const page = await browser.newPage({ viewport: { width: 1440, height: 900 }, deviceScaleFactor });
40
+ * await page.setContent(html);
41
+ * expect((await measureV2Layout(page)).problems).toEqual([]);
42
+ * });
43
+ * ```
44
+ */
45
+ import type { Page } from "playwright";
46
+ export type V2LayoutOptions = {
47
+ /** The element to measure; the whole body by default. */
48
+ root?: string;
49
+ /** Columns whose edges lines must reach. */
50
+ columns?: string;
51
+ /** Grips; each one's box is its pill. */
52
+ grips?: string;
53
+ /** Reading text, which may also use 16 px and a 22 px line. */
54
+ prose?: string;
55
+ /** Subtrees whose inside is never measured: free drawing in `Canvas`. The line such a surface draws itself counts. */
56
+ skip?: string;
57
+ /** One thing in one frame or band (rule 9): spacing alone separates its parts, so any line inside is a finding. */
58
+ unbroken?: string;
59
+ /** Controls whose label must never be cut: a text that leaves the control's box or is clipped by it. */
60
+ controls?: string;
61
+ /** Text that stays on one line and ends with "…" when it is too long; wrapping to a second line is a finding. */
62
+ oneLine?: string;
63
+ /** Drawn marks whose lines are no dividers, such as the track of steps; their text is still measured. */
64
+ figure?: string;
65
+ /** Text that has no type role, such as initials in an avatar. */
66
+ untyped?: string;
67
+ };
68
+ export type V2GripMeasure = {
69
+ grip: string;
70
+ /** Pill centre minus line centre in CSS px, from the DOM. */
71
+ dom: number;
72
+ /** The same from the screenshot, or null when the pill or its line could not be told from the background. */
73
+ pixels: number | null;
74
+ /** The width of the line in CSS px, from the screenshot. */
75
+ lineWidth: number | null;
76
+ };
77
+ export type V2Layout = {
78
+ edge: string[];
79
+ double: string[];
80
+ /** Lines inside one thing (a band, a group), whatever their distance to other lines. */
81
+ inside: string[];
82
+ /** Cut control labels and one-line texts that wrap. */
83
+ cut: string[];
84
+ type: string[];
85
+ grip: string[];
86
+ grips: V2GripMeasure[];
87
+ /** Pseudo-elements the helper could not measure without changing the page; each one is a problem, never a pass. */
88
+ pseudo: string[];
89
+ /** How many hairlines and tinted bands were measured, so a test can tell an empty page from a clean one. */
90
+ measured: {
91
+ lines: number;
92
+ bands: number;
93
+ texts: number;
94
+ };
95
+ /** Every problem as one readable line; empty when the page keeps the rules. */
96
+ problems: string[];
97
+ };
98
+ /** Measures the v2 layout rules on the page as it stands. Restores the page before it returns. */
99
+ export declare function measureV2Layout(page: Page, options?: V2LayoutOptions): Promise<V2Layout>;
@@ -0,0 +1,13 @@
1
+ import type { Page } from "playwright";
2
+ /**
3
+ * Guards against state sampled before it settled (#1476, #1499).
4
+ * Waits for fonts, the first resize delivery and its scheduled frame, running finite document-timeline animations, then two frames.
5
+ * Infinite, scroll-driven, and paused animations are not waited for. A page that
6
+ * keeps starting finite animations is not settled: this throws with their names,
7
+ * and the test must wait for its own condition instead. Suites not about motion
8
+ * pass `reducedMotion: "reduce"` to newPage/newContext themselves. Playwright's
9
+ * pointer rests at the top left from the first page on, touch contexts included,
10
+ * so content that arrives there later fades into hover; the error marks such
11
+ * targets with `"hovered":true`.
12
+ */
13
+ export declare const settled: (page: Page) => Promise<void>;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The measured numbers of @k2b/ui v2, taken from the approved mockup (`v2.css`, draft 16). `v2.css` declares the same
3
+ * values as custom properties; a unit test keeps both in step, and the layout measurements in the browser tests read
4
+ * their limits from here.
5
+ */
6
+ /** The four type roles. A primitive picks a role, never a size. */
7
+ export declare const typeRoles: {
8
+ /** Labels, times, counters. */
9
+ readonly meta: {
10
+ readonly size: 12;
11
+ readonly lineHeight: 16;
12
+ readonly weight: 400;
13
+ };
14
+ /** Rows and controls. */
15
+ readonly row: {
16
+ readonly size: 13;
17
+ readonly lineHeight: 20;
18
+ readonly weight: 400;
19
+ };
20
+ /** Titles in a head, reading text. */
21
+ readonly body: {
22
+ readonly size: 14;
23
+ readonly lineHeight: 20;
24
+ readonly weight: 400;
25
+ };
26
+ /** The one main statement or name. */
27
+ readonly lead: {
28
+ readonly size: 18;
29
+ readonly lineHeight: 24;
30
+ readonly weight: 600;
31
+ };
32
+ };
33
+ export type TypeRole = keyof typeof typeRoles;
34
+ /** The three weights; emphasis is a weight, never a size. */
35
+ export declare const fontWeights: readonly [400, 500, 600];
36
+ /**
37
+ * Where text starts in a column: 20 px from 768 px, 16 px below. After an icon the text edge is 24 px further in
38
+ * (16 px icon and 8 px gap), so 44 px and 40 px on the phone.
39
+ */
40
+ export declare const textEdge: {
41
+ readonly wide: 20;
42
+ readonly phone: 16;
43
+ readonly afterIcon: 24;
44
+ readonly phoneBelow: 768;
45
+ };
46
+ /** The one hairline: 1 px in one colour. Lines separate groups and reach the edges of their column. */
47
+ export declare const hairline: {
48
+ readonly width: 1;
49
+ };
50
+ /** Radii by role: a mark (4), a control or an overlay (8), round (999), the app card (14). Structure is square. */
51
+ export declare const radii: {
52
+ readonly mark: 4;
53
+ readonly control: 8;
54
+ readonly overlay: 8;
55
+ readonly round: 999;
56
+ readonly card: 14;
57
+ };
58
+ /**
59
+ * Fixed heights by place; a primitive takes its height from where it stands. The row heights are minima, as in the
60
+ * mockup: a row of two or three lines is taller than its minimum by its line, so it stands 53 and 73 px apart
61
+ * (`row2 + hairline.width`), exactly as the approved mockup renders it.
62
+ */
63
+ export declare const heights: {
64
+ readonly head: 56;
65
+ readonly status: 52;
66
+ readonly tabs: 44;
67
+ readonly bar: 40;
68
+ readonly columns: 36;
69
+ readonly row: 40;
70
+ readonly row2: 52;
71
+ readonly row3: 72;
72
+ readonly dense: 32;
73
+ readonly control: 36;
74
+ readonly controlSmall: 28;
75
+ };
76
+ /** A grip's pill centre lies on the centre of its line within this many CSS px, at device pixel ratio 1 and 2. */
77
+ export declare const gripTolerance = 0.25;
@@ -0,0 +1,44 @@
1
+ import type { LinkNavigateEvent } from "@k2b/ssr/nav";
2
+ /**
3
+ * Opens a link's page in place, beside the real link (`href`): the contract of `@k2b/ssr/nav`'s `Link`, which the
4
+ * primitive renders. A plain same-origin click (the main button, no modifier key, no other target) reaches it; the
5
+ * link has then taken the click and cancelled a pending page swap, and the handler moves history with `push` or
6
+ * `replaceWith`, or loads the page with `fallback`. A click with a modifier key, "open in new tab" and a click before
7
+ * the page is live stay the browser's.
8
+ */
9
+ export type OnNavigate = (event: LinkNavigateEvent) => void | Promise<void>;
10
+ /** The width of a column that can be dragged: its minimum and its default, in CSS px. Nothing else. */
11
+ export type Width = {
12
+ min: number;
13
+ default: number;
14
+ };
15
+ /**
16
+ * An action as data. The primitive decides whether it becomes a button, an icon button or a text button, so the
17
+ * same action looks the same in every place (concept, API style).
18
+ */
19
+ export type Action = {
20
+ label: string;
21
+ /** A Tabler icon name without the `ti-` prefix, such as `plus`. */
22
+ icon?: string;
23
+ href?: string;
24
+ /** With `href`: opens the page in place on a plain click (see `OnNavigate`). */
25
+ onNavigate?: OnNavigate;
26
+ onClick?: () => void;
27
+ /** A quiet summary after the label where the place shows one, such as "Bank, Person, Portal". */
28
+ meta?: string;
29
+ /** The action leads further, to a page with more: a chevron to the right after the label. */
30
+ forward?: boolean;
31
+ };
32
+ /** At most two actions, such as the text buttons in the head of a section; a third does not fit by type. */
33
+ export type TwoActions = readonly [Action] | readonly [Action, Action];
34
+ /** The colours of meaning. A tone is never decoration: it says ok, wait, wrong, AI or "yours". */
35
+ export type Status = "ok" | "warn" | "bad";
36
+ /** A person or an organisation shown as initials on a colour. */
37
+ export type Person = {
38
+ name: string;
39
+ initials?: string;
40
+ /** The colour behind the initials; without it the fixed colour of the name, the same everywhere in Cloud. */
41
+ color?: string;
42
+ };
43
+ /** The initials of a name: the first letters of its first two words. */
44
+ export declare const initialsOf: (person: Person) => string;