@dominevo/ui-library 0.1.5 → 0.1.7

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.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * form-grid — the ONE place a form's column grid and field spans are decided.
3
+ *
4
+ * Both schema renderers (ui-library `ConfigFormBuilder` and admin-ui
5
+ * `FormBuilder`) and every span site in `config-form-field.tsx` call this
6
+ * module, so a change to the tiers lands everywhere at once.
7
+ *
8
+ * The grid follows the width of its own container (`@container` on each
9
+ * section), never the viewport: the same schema is drawn in a full page, a
10
+ * split device pane and a dialog. A section's `columns` is a MAXIMUM; unset
11
+ * means "as many tracks as the width earns":
12
+ *
13
+ * container width <480 480-879 880-1319 >=1320
14
+ * unset 1 2 3 4
15
+ * columns: 2 1 2 2 2
16
+ * columns: 3 1 2 3 3
17
+ * columns: 4 1 2 2 (to 1139) 4 from 1140
18
+ * columns: 1 1 1 1 1 (capped at max-w-3xl)
19
+ *
20
+ * Class strings stay LITERAL in this file: the Tailwind scan
21
+ * (`@source "../../ui-library/src"`) only emits classes it can read.
22
+ */
23
+ import { type Context } from "react";
24
+ /** A section's declared maximum. `undefined` = automatic. */
25
+ export type FormColumns = 1 | 2 | 3 | 4 | undefined;
26
+ /** Container widths (px) where an automatic grid gains a track. */
27
+ export declare const FORM_GRID_TIERS: readonly [480, 880, 1320];
28
+ /** Gap between fields — shared so both renderers agree. */
29
+ export declare const FORM_GRID_GAP: "gap-x-3 gap-y-2.5";
30
+ /** Vertical rhythm between the sections of one form. */
31
+ export declare const FORM_SECTIONS_GAP: "space-y-4";
32
+ /** Section/field helper text: a readable measure, never the full line. */
33
+ export declare const FORM_DESCRIPTION_MEASURE: "max-w-prose";
34
+ /**
35
+ * Tracks the grid has at a container width. Mirrors {@link formGridClass}
36
+ * exactly; the spec parses the classes and checks both agree.
37
+ */
38
+ export declare function formTracks(columns: FormColumns, containerWidth: number): number;
39
+ /**
40
+ * The section grid's column classes. A one-column grid also gets
41
+ * `max-w-3xl` so a lone column never stretches inputs across a wide page.
42
+ */
43
+ export declare function formGridClass(columns: FormColumns): string;
44
+ /** Grid + gap, the full className of a section's field grid. */
45
+ export declare function formGridClassWithGap(columns: FormColumns): string;
46
+ /**
47
+ * A field's column span, clamped to the tracks its grid really has at each
48
+ * tier. Below 480px the grid is one column and every span is `col-span-1`: a
49
+ * raw `col-span-2` there forces an implicit auto-sized column that siblings
50
+ * collapse into. `span >= 4` means "the whole row" at every tier.
51
+ */
52
+ export declare function formSpanClass(span: number | undefined, columns: FormColumns): string;
53
+ /**
54
+ * The span a field gets: its own `span` when set (an explicit `1` on a
55
+ * textarea wins), else the whole row for a full-row kind, else one track.
56
+ */
57
+ export declare function fieldSpan(field: {
58
+ readonly type: string;
59
+ readonly span?: number;
60
+ }): number | undefined;
61
+ /**
62
+ * The enclosing section's `columns`, so a field's span is clamped to its own
63
+ * grid. Provided by each renderer around the section grid.
64
+ */
65
+ export declare const FormColumnsContext: Context<FormColumns>;
66
+ export declare function useFormColumns(): FormColumns;
@@ -20,3 +20,4 @@ export { scrubReducer, initialScrubState, shouldEmit, shouldCommit, cursorFracti
20
20
  export type { ScrubSource, ScrubState, ScrubAction, ScrubController, PlaybackControlSink, LastCommit } from "./scrub-controller";
21
21
  export { applyFleetQueryDefaults, FLEET_LIST_QUERY_KEY, FLEET_LIST_STALE_TIME_MS, FLEET_LIST_GC_TIME_MS } from "./fleet-query-defaults";
22
22
  export * from "./subject-path";
23
+ export * from "./form-grid";
@@ -7,7 +7,7 @@ interface DialogProps {
7
7
  export declare function Dialog({ children, open: controlledOpen, onOpenChange }: DialogProps): JSX.Element;
8
8
  export declare function DialogTrigger({ children, ...props }: HTMLAttributes<HTMLButtonElement>): JSX.Element;
9
9
  export interface DialogContentProps extends DialogHTMLAttributes<HTMLDialogElement> {
10
- width?: "sm" | "md" | "lg" | "xl" | "full";
10
+ width?: "sm" | "md" | "lg" | "form" | "xl" | "full";
11
11
  scroll?: "content" | "body";
12
12
  placement?: "center" | "sheet-on-mobile";
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dominevo/ui-library",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dominevo/server.git",