@sybilion/uilib 1.4.16 → 1.4.18

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 (39) hide show
  1. package/dist/agent-glossary/workspace.generated.ts +1 -0
  2. package/dist/agent-glossary/workspace.index.md +1 -0
  3. package/dist/agent-glossary/workspace.md +1 -0
  4. package/dist/esm/components/ui/AppHeader/AppHeader.js +1 -1
  5. package/dist/esm/components/ui/Chip/Chip.js +1 -1
  6. package/dist/esm/components/ui/Form/Form.js +96 -0
  7. package/dist/esm/components/ui/Form/Form.styl.js +7 -0
  8. package/dist/esm/components/widgets/DriversComparisonChart/DriversComparisonChart.js +5 -18
  9. package/dist/esm/components/widgets/DriversComparisonChart/DriversComparisonChart.styl.js +1 -1
  10. package/dist/esm/components/widgets/DriversComparisonChart/driversComparisonChart.helpers.js +22 -5
  11. package/dist/esm/components/widgets/SybilionAppHeader/SybilionAppHeader.styl.js +1 -1
  12. package/dist/esm/index.js +1 -0
  13. package/dist/esm/types/src/components/ui/Form/Form.d.ts +48 -0
  14. package/dist/esm/types/src/components/ui/Form/Form.example.d.ts +1 -0
  15. package/dist/esm/types/src/components/ui/Form/Form.types.d.ts +14 -0
  16. package/dist/esm/types/src/components/ui/Form/index.d.ts +2 -0
  17. package/dist/esm/types/src/components/widgets/DriversComparisonChart/driversComparisonChart.helpers.d.ts +10 -0
  18. package/dist/esm/types/src/docs/pages/FormPage.d.ts +1 -0
  19. package/dist/esm/types/src/index.d.ts +1 -0
  20. package/dist/esm/types/tests/form.test.d.ts +1 -0
  21. package/package.json +9 -3
  22. package/src/components/ui/AppHeader/AppHeader.tsx +1 -0
  23. package/src/components/ui/Chip/Chip.tsx +3 -3
  24. package/src/components/ui/Form/AGENT.md +29 -0
  25. package/src/components/ui/Form/Form.example.tsx +193 -0
  26. package/src/components/ui/Form/Form.styl +12 -0
  27. package/src/components/ui/Form/Form.styl.d.ts +9 -0
  28. package/src/components/ui/Form/Form.tsx +231 -0
  29. package/src/components/ui/Form/Form.types.ts +32 -0
  30. package/src/components/ui/Form/index.ts +11 -0
  31. package/src/components/widgets/DriversComparisonChart/DriversComparisonChart.styl +4 -4
  32. package/src/components/widgets/DriversComparisonChart/DriversComparisonChart.tsx +21 -37
  33. package/src/components/widgets/DriversComparisonChart/driversComparisonChart.helpers.test.ts +49 -0
  34. package/src/components/widgets/DriversComparisonChart/driversComparisonChart.helpers.ts +40 -9
  35. package/src/components/widgets/SybilionAppHeader/SybilionAppHeader.styl +7 -2
  36. package/src/docs/App/App.tsx +17 -18
  37. package/src/docs/pages/FormPage.tsx +21 -0
  38. package/src/docs/registry.ts +6 -0
  39. package/src/index.ts +1 -0
@@ -32,6 +32,7 @@ Entry point for \`@sybilion/uilib\`. Open linked AGENT.md before using a compone
32
32
  - [FileChip](src/components/ui/FileChip/AGENT.md) — FileChip is a compact row that represents a file with a format icon, name, and hint text. It supports an onClick hand…
33
33
  - [FlickeringGrid](src/components/ui/FlickeringGrid/AGENT.md) — FlickeringGrid is a purely decorative animated grid of squares that flicker at random. Place it behind content in a p…
34
34
  - [Foldable](src/components/ui/Foldable/AGENT.md) — Foldable is a collapsible section with a clickable header that shows or hides its content. Pass the header and conten…
35
+ - [Form](src/components/ui/Form/AGENT.md) — Validated forms via root Form with zod schema and inline field errors
35
36
  - [Gap](src/components/ui/Gap/AGENT.md) — Gap is a flex-grow spacer that absorbs remaining horizontal or vertical space inside a flex container. Render it betw…
36
37
  - [GridLayout](src/components/ui/GridLayout/AGENT.md) — GridLayout is a responsive CSS grid that fits as many columns as the container allows, with each cell keeping at leas…
37
38
  - [Image](src/components/ui/Image/AGENT.md) — Image is a thin wrapper around the native img element that loads a remote URL and accepts a fallback for when the req…
@@ -31,6 +31,7 @@ Entry point for `@sybilion/uilib`. Open linked AGENT.md before using a component
31
31
  - [FileChip](src/components/ui/FileChip/AGENT.md) — FileChip is a compact row that represents a file with a format icon, name, and hint text. It supports an onClick hand…
32
32
  - [FlickeringGrid](src/components/ui/FlickeringGrid/AGENT.md) — FlickeringGrid is a purely decorative animated grid of squares that flicker at random. Place it behind content in a p…
33
33
  - [Foldable](src/components/ui/Foldable/AGENT.md) — Foldable is a collapsible section with a clickable header that shows or hides its content. Pass the header and conten…
34
+ - [Form](src/components/ui/Form/AGENT.md) — Validated forms via root Form with zod schema and inline field errors
34
35
  - [Gap](src/components/ui/Gap/AGENT.md) — Gap is a flex-grow spacer that absorbs remaining horizontal or vertical space inside a flex container. Render it betw…
35
36
  - [GridLayout](src/components/ui/GridLayout/AGENT.md) — GridLayout is a responsive CSS grid that fits as many columns as the container allows, with each cell keeping at leas…
36
37
  - [Image](src/components/ui/Image/AGENT.md) — Image is a thin wrapper around the native img element that loads a remote URL and accepts a fallback for when the req…
@@ -31,6 +31,7 @@ Entry point for `@sybilion/uilib`. Open linked AGENT.md before using a component
31
31
  - [FileChip](src/components/ui/FileChip/AGENT.md) — FileChip is a compact row that represents a file with a format icon, name, and hint text. It supports an onClick hand…
32
32
  - [FlickeringGrid](src/components/ui/FlickeringGrid/AGENT.md) — FlickeringGrid is a purely decorative animated grid of squares that flicker at random. Place it behind content in a p…
33
33
  - [Foldable](src/components/ui/Foldable/AGENT.md) — Foldable is a collapsible section with a clickable header that shows or hides its content. Pass the header and conten…
34
+ - [Form](src/components/ui/Form/AGENT.md) — Validated forms via root Form with zod schema and inline field errors
34
35
  - [Gap](src/components/ui/Gap/AGENT.md) — Gap is a flex-grow spacer that absorbs remaining horizontal or vertical space inside a flex container. Render it betw…
35
36
  - [GridLayout](src/components/ui/GridLayout/AGENT.md) — GridLayout is a responsive CSS grid that fits as many columns as the container allows, with each cell keeping at leas…
36
37
  - [Image](src/components/ui/Image/AGENT.md) — Image is a thin wrapper around the native img element that loads a remote URL and accepts a fallback for when the req…
@@ -6,7 +6,7 @@ import S from './AppHeader.styl.js';
6
6
  import { PAGE_HEADER_ID } from './appChromeAnchors.js';
7
7
 
8
8
  function AppHeaderHost({ className, anchorId = PAGE_HEADER_ID, sticky, }) {
9
- return (jsx("header", { className: cn(S.root, sticky && S.sticky, className), id: anchorId }));
9
+ return (jsx("header", { className: cn(S.root, sticky && S.sticky, className), "data-sticky": sticky ? 'true' : 'false', id: anchorId }));
10
10
  }
11
11
  function AppHeaderPortal({ children, pageHeaderId = PAGE_HEADER_ID, }) {
12
12
  const [container, setContainer] = useState(null);
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import cn from 'classnames';
2
3
  import { TrendingUp, TrendingDown } from 'lucide-react';
3
4
  import S from './Chip.styl.js';
4
- import cn from 'classnames';
5
5
 
6
6
  function Chip({ className, variant = 'neutral', dot, trend, squared = false, children, ...props }) {
7
7
  const TrendIcon = trend === 'up' ? TrendingUp : trend === 'down' ? TrendingDown : null;
@@ -0,0 +1,96 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import cn from 'classnames';
3
+ import { createContext, useId, useContext } from 'react';
4
+ import { useForm, FormProvider, useFormContext, Controller, useFormState } from 'react-hook-form';
5
+ import { Label } from '../Label/Label.js';
6
+ import { zodResolver } from '@hookform/resolvers/zod';
7
+ import { Slot } from '@radix-ui/react-slot';
8
+ import S from './Form.styl.js';
9
+
10
+ const FormFieldContext = createContext(null);
11
+ const FormItemContext = createContext(null);
12
+ /**
13
+ * Root validated form. Owns `useForm`, applies `zodResolver(schema)` when `schema` is
14
+ * passed, and renders a native `<form>` wired to `onSubmit`. Wrap fields in {@link FormField}.
15
+ */
16
+ function Form({ schema, defaultValues, onSubmit, resolver, formOptions, form: externalForm, className, children, ...formHTMLProps }) {
17
+ const internalForm = useForm({
18
+ defaultValues,
19
+ resolver: resolver ??
20
+ (schema ? zodResolver(schema) : undefined),
21
+ ...formOptions,
22
+ });
23
+ const methods = externalForm ?? internalForm;
24
+ return (jsx(FormProvider, { ...methods, children: jsx("form", { "data-slot": "form", className: cn(className), onSubmit: methods.handleSubmit(onSubmit), ...formHTMLProps, children: children }) }));
25
+ }
26
+ /**
27
+ * Connects a field to react-hook-form via `Controller`. Reads `control` from the nearest
28
+ * {@link Form} context — do not pass `control` manually. Must wrap {@link FormItem} inside `render`.
29
+ */
30
+ function FormField({ ...props }) {
31
+ const { control } = useFormContext();
32
+ return (jsx(FormFieldContext.Provider, { value: { name: props.name }, children: jsx(Controller, { ...props, control: control }) }));
33
+ }
34
+ /** Vertical field shell; generates stable ids for label, control, description, and message. */
35
+ function FormItem({ className, ...props }) {
36
+ const id = useId();
37
+ return (jsx(FormItemContext.Provider, { value: { id }, children: jsx("div", { "data-slot": "form-item", className: cn(S.item, className), ...props }) }));
38
+ }
39
+ /**
40
+ * Field metadata for {@link FormLabel}, {@link FormControl}, {@link FormDescription}, and
41
+ * {@link FormMessage}. Requires {@link FormField} + {@link FormItem} ancestors.
42
+ */
43
+ function useFormField() {
44
+ const fieldContext = useContext(FormFieldContext);
45
+ const itemContext = useContext(FormItemContext);
46
+ const { getFieldState, control } = useFormContext();
47
+ const formState = useFormState({ control, name: fieldContext?.name });
48
+ const fieldState = getFieldState(fieldContext?.name ?? '', formState);
49
+ if (!fieldContext) {
50
+ throw new Error('useFormField should be used within <FormField>');
51
+ }
52
+ if (!itemContext) {
53
+ throw new Error('useFormField should be used within <FormItem>');
54
+ }
55
+ const { id } = itemContext;
56
+ return {
57
+ id,
58
+ name: fieldContext.name,
59
+ formItemId: `${id}-form-item`,
60
+ formDescriptionId: `${id}-form-item-description`,
61
+ formMessageId: `${id}-form-item-message`,
62
+ ...fieldState,
63
+ };
64
+ }
65
+ /** Accessible label linked to the control id from {@link FormItem}. */
66
+ function FormLabel({ className, ...props }) {
67
+ const { formItemId } = useFormField();
68
+ return (jsx(Label, { "data-slot": "form-label", className: cn(className), htmlFor: formItemId, ...props }));
69
+ }
70
+ /**
71
+ * Slot wrapper for the actual input. Forwards `id`, `aria-invalid`, and `aria-describedby`
72
+ * so uilib controls show validation styling (P-07 inline errors).
73
+ */
74
+ function FormControl({ ...props }) {
75
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
76
+ return (jsx(Slot, { "data-slot": "form-control", id: formItemId, "aria-describedby": error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId, "aria-invalid": !!error, ...props }));
77
+ }
78
+ /** Optional helper text below the label; referenced by `aria-describedby` on {@link FormControl}. */
79
+ function FormDescription({ className, ...props }) {
80
+ const { formDescriptionId } = useFormField();
81
+ return (jsx("p", { "data-slot": "form-description", id: formDescriptionId, className: cn(S.description, className), ...props }));
82
+ }
83
+ /**
84
+ * Inline validation message (`role="alert"`). Shows `fieldState.error.message` when present;
85
+ * omit for empty fields — never use toast for field errors.
86
+ */
87
+ function FormMessage({ className, children, ...props }) {
88
+ const { error, formMessageId } = useFormField();
89
+ const body = error ? String(error?.message ?? '') : children;
90
+ if (!body) {
91
+ return null;
92
+ }
93
+ return (jsx("p", { "data-slot": "form-message", id: formMessageId, role: "alert", className: cn(S.message, className), ...props, children: body }));
94
+ }
95
+
96
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
@@ -0,0 +1,7 @@
1
+ import styleInject from 'style-inject';
2
+
3
+ var css_248z = ".Form_item__zPDBr{display:flex;flex-direction:column;gap:var(--spacing-xs)}.Form_message__2ch7w{color:var(--destructive);font-size:var(--text-sm)}.Form_description__rVj8c{color:var(--muted-foreground);font-size:var(--text-sm)}";
4
+ var S = {"item":"Form_item__zPDBr","message":"Form_message__2ch7w","description":"Form_description__rVj8c"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };
@@ -53,7 +53,7 @@ import { Table, TableHeader, TableRow, TableHead, TableCellValue, TableBody, Tab
53
53
  import { TextShimmer } from '../../ui/TextShimmer/TextShimmer.js';
54
54
  import { TIME_RANGES } from '../../ui/TimeRangeControls/TimeRangeControls.constants.js';
55
55
  import S from './DriversComparisonChart.styl.js';
56
- import { applyDriversComparisonViewToPayload, mergeBacktestsChartData, mergeDatasetHistoricalWithBacktestsChartData, computeDriversComparisonHistoricalWindowFloor, DRIVER_FORECAST_ID_BASE, getLagDisplayForView, resolveDriverLagLabel, INITIAL_VISIBLE_SERIES_COUNT, buildDriversComparisonChartData, formatSeriesImportance } from './driversComparisonChart.helpers.js';
56
+ import { applyDriversComparisonViewToPayload, getDriversWithDataSortedByImportance, mergeBacktestsChartData, mergeDatasetHistoricalWithBacktestsChartData, DRIVER_FORECAST_ID_BASE, computeDriversComparisonHistoricalWindowFloor, getLagDisplayForView, resolveDriverLagLabel, INITIAL_VISIBLE_SERIES_COUNT, buildDriversComparisonChartData, formatSeriesImportance } from './driversComparisonChart.helpers.js';
57
57
 
58
58
  const ALL_TIME_RANGE = TIME_RANGES[TIME_RANGES.length - 1];
59
59
  function toForecastDataKey(id) {
@@ -105,24 +105,13 @@ function DriversComparisonChart({ payload, datasetHistorical = [], loading = fal
105
105
  });
106
106
  }, [setHiddenSeries]);
107
107
  const payloadForView = useMemo(() => applyDriversComparisonViewToPayload(payload, viewTab), [payload, viewTab]);
108
- const sortedDriversWithData = useMemo(() => {
109
- const driversList = payloadForView?.drivers ?? [];
110
- if (!driversList.length)
111
- return [];
112
- return [...driversList]
113
- .filter(d => d.normalized_series &&
114
- Object.keys(d.normalized_series).some(key => d.normalized_series[key] != null))
115
- .sort((a, b) => String(a.id).localeCompare(String(b.id)));
116
- }, [payloadForView?.drivers]);
108
+ const sortedDriversWithData = useMemo(() => getDriversWithDataSortedByImportance(payloadForView?.drivers), [payloadForView?.drivers]);
117
109
  const mergedChartData = useMemo(() => mergeBacktestsChartData(payloadForView), [payloadForView]);
118
110
  const mergedWithHistorical = useMemo(() => mergeDatasetHistoricalWithBacktestsChartData(datasetHistorical, mergedChartData), [datasetHistorical, mergedChartData]);
119
111
  const historicalWindowFloor = useMemo(() => {
120
112
  const laggedMerged = mergeBacktestsChartData(payload);
121
113
  const merged = mergeDatasetHistoricalWithBacktestsChartData(datasetHistorical, laggedMerged);
122
- const sortedDrivers = [...(payload?.drivers ?? [])]
123
- .filter(d => d.normalized_series &&
124
- Object.keys(d.normalized_series).some(key => d.normalized_series[key] != null))
125
- .sort((a, b) => String(a.id).localeCompare(String(b.id)));
114
+ const sortedDrivers = getDriversWithDataSortedByImportance(payload?.drivers);
126
115
  const forecastIds = sortedDrivers.map((_, idx) => DRIVER_FORECAST_ID_BASE + idx);
127
116
  return computeDriversComparisonHistoricalWindowFloor(merged, forecastIds);
128
117
  }, [payload, datasetHistorical]);
@@ -145,8 +134,7 @@ function DriversComparisonChart({ payload, datasetHistorical = [], loading = fal
145
134
  const tableSeriesRows = useMemo(() => {
146
135
  if (sortedDriversWithData.length === 0)
147
136
  return [];
148
- return sortedDriversWithData
149
- .map((driver, idx) => {
137
+ return sortedDriversWithData.map((driver, idx) => {
150
138
  const raw = driver.importance;
151
139
  const importance = typeof raw === 'number' && Number.isFinite(raw) ? raw : null;
152
140
  const lagSource = originalDriversById.get(String(driver.id)) ?? driver;
@@ -157,8 +145,7 @@ function DriversComparisonChart({ payload, datasetHistorical = [], loading = fal
157
145
  importance,
158
146
  lag: getLagDisplayForView(resolveDriverLagLabel(lagSource), viewTab),
159
147
  };
160
- })
161
- .sort((a, b) => b.importance - a.importance);
148
+ });
162
149
  }, [originalDriversById, sortedDriversWithData, viewTab]);
163
150
  const seriesInitKeyResolved = seriesInitKey ?? `${tableSeriesRows.map(r => r.id).join(',') || 'none'}`;
164
151
  const backtestsSeriesInitKeyRef = useRef('');
@@ -1,6 +1,6 @@
1
1
  import styleInject from 'style-inject';
2
2
 
3
- var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.DriversComparisonChart_root__GLnlF{display:flex;flex-direction:column;gap:var(--p-4);width:100%}.DriversComparisonChart_chartShell__0AzAz{position:relative;width:100%}.DriversComparisonChart_chartShellLoading__wTLod .DriversComparisonChart_chartSlot__WKe6N{opacity:.3;pointer-events:none}.DriversComparisonChart_chartShellLoading__wTLod .recharts-line-dots{display:none}.DriversComparisonChart_chartSlot__WKe6N{width:100%}.DriversComparisonChart_loadingLayer__HlEmA{inset:0;pointer-events:none;position:absolute;z-index:10}.DriversComparisonChart_loadingMessage__Li3S7{color:var(--foreground);display:block;left:0;position:absolute;text-align:center;top:calc(50% - 4em);width:100%;z-index:1}.DriversComparisonChart_loadingText__0y3Ms{backdrop-filter:blur(10px);border-radius:var(--p-4);box-shadow:0 0 0 2px var(--page-color);color:var(--foreground);font-size:16px;font-weight:500;padding:0 var(--p-3)}.DriversComparisonChart_chartWithOverlay__SMToK{position:relative;width:100%}.DriversComparisonChart_chartInteractiveLayer__0aquh{transition:opacity .2s ease-out;width:100%}.DriversComparisonChart_chartInteractiveDimmed__us1dv{opacity:.3;pointer-events:none}.DriversComparisonChart_chartInteractiveDimmed__us1dv .recharts-line-dots{display:none}.DriversComparisonChart_chartEmptyOverlay__eXqzk{align-items:center;display:flex;inset:0;justify-content:center;padding:var(--p-4);pointer-events:none;position:absolute;z-index:6}.DriversComparisonChart_chartEmptyBlurb__Tjy9E{max-width:42rem;padding:0 var(--p-3)}.DriversComparisonChart_seriesEmptyWrap__RyRs5{display:flex;justify-content:center;padding:var(--p-8) var(--p-4)}.DriversComparisonChart_seriesSection__yrf4I{width:100%}.DriversComparisonChart_seriesTableWrapper__oredC{margin:0 calc(var(--page-x-padding)*-1);position:relative}.DriversComparisonChart_seriesTableContainer__dhfXK{overflow-x:auto;position:relative;width:100%}.DriversComparisonChart_seriesScrollbar__2jgk6{bottom:calc(var(--p-7)*-1 + 2px)!important}.DriversComparisonChart_seriesTable__NybPR{max-width:100%;table-layout:auto;width:100%}.DriversComparisonChart_seriesTable__NybPR tr{cursor:pointer;position:relative}.DriversComparisonChart_seriesTable__NybPR td:not(:first-child),.DriversComparisonChart_seriesTable__NybPR th:not(:first-child){text-align:right}.DriversComparisonChart_seriesColSeries__--0mj{text-align:left;vertical-align:middle}.DriversComparisonChart_rowHidden__Fwhna{opacity:.4}.DriversComparisonChart_colorSwatch__o3ZVr{border-radius:2px;display:inline-flex;flex-shrink:0;height:10px;margin-right:var(--p-2);width:10px}.DriversComparisonChart_seriesLabel__Aidof{display:-webkit-box;-webkit-line-clamp:3;max-width:60vw;min-width:0;-webkit-box-orient:vertical;white-space:break-spaces}.DriversComparisonChart_chartContainer__1eM-O{margin-left:calc(var(--page-x-padding)*-1 + 26px);max-width:calc(100% + 60px);transition:opacity .3s ease-out;width:calc(100% + 60px)}.DriversComparisonChart_chartContainer__1eM-O .recharts-yAxis-tick-labels{display:none}@media (max-width:768px){.DriversComparisonChart_chartContainer__1eM-O{margin-left:calc(var(--page-x-padding)*-1 + 10px);width:calc(100% + 30px)}}";
3
+ var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.DriversComparisonChart_root__GLnlF{display:flex;flex-direction:column;gap:var(--p-4);width:100%}.DriversComparisonChart_chartShell__0AzAz{position:relative;width:100%}.DriversComparisonChart_chartShellLoading__wTLod .DriversComparisonChart_chartSlot__WKe6N{opacity:.3;pointer-events:none}.DriversComparisonChart_chartShellLoading__wTLod .recharts-line-dots{display:none}.DriversComparisonChart_chartSlot__WKe6N{width:100%}.DriversComparisonChart_loadingLayer__HlEmA{inset:0;pointer-events:none;position:absolute;z-index:10}.DriversComparisonChart_loadingMessage__Li3S7{color:var(--foreground);display:block;left:0;position:absolute;text-align:center;top:calc(50% - 4em);width:100%;z-index:1}.DriversComparisonChart_loadingText__0y3Ms{backdrop-filter:blur(10px);border-radius:var(--p-4);box-shadow:0 0 0 2px var(--page-color);color:var(--foreground);font-size:16px;font-weight:500;padding:0 var(--p-3)}.DriversComparisonChart_chartWithOverlay__SMToK{position:relative;width:100%}.DriversComparisonChart_chartInteractiveLayer__0aquh{transition:opacity .2s ease-out;width:100%}.DriversComparisonChart_chartInteractiveDimmed__us1dv{opacity:.3;pointer-events:none}.DriversComparisonChart_chartInteractiveDimmed__us1dv .recharts-line-dots{display:none}.DriversComparisonChart_chartEmptyOverlay__eXqzk{align-items:center;display:flex;inset:0;justify-content:center;padding:var(--p-4);pointer-events:none;position:absolute;z-index:6}.DriversComparisonChart_chartEmptyBlurb__Tjy9E{max-width:42rem;padding:0 var(--p-3)}.DriversComparisonChart_seriesEmptyWrap__RyRs5{display:flex;justify-content:center;padding:var(--p-8) var(--p-4)}.DriversComparisonChart_seriesSection__yrf4I{width:100%}.DriversComparisonChart_seriesTableWrapper__oredC{margin:0 calc(var(--page-x-padding)*-1);position:relative}.DriversComparisonChart_seriesTableContainer__dhfXK{overflow-x:auto;position:relative;width:100%}.DriversComparisonChart_seriesScrollbar__2jgk6{bottom:calc(var(--p-7)*-1 + 2px)!important}.DriversComparisonChart_seriesTable__NybPR{max-width:100%;table-layout:auto;width:100%}.DriversComparisonChart_seriesTable__NybPR tr{cursor:pointer;position:relative}.DriversComparisonChart_seriesTable__NybPR th:not(:first-child)>caption{justify-content:flex-end}.DriversComparisonChart_seriesTable__NybPR td:not(:first-child){text-align:right}.DriversComparisonChart_seriesColSeries__--0mj{text-align:left;vertical-align:middle}.DriversComparisonChart_rowHidden__Fwhna{opacity:.4}.DriversComparisonChart_colorSwatch__o3ZVr{border-radius:2px;display:inline-flex;flex-shrink:0;height:10px;margin-right:var(--p-2);width:10px}.DriversComparisonChart_seriesLabel__Aidof{display:-webkit-box;-webkit-line-clamp:3;max-width:60vw;min-width:0;-webkit-box-orient:vertical;white-space:break-spaces}.DriversComparisonChart_chartContainer__1eM-O{margin-left:calc(var(--page-x-padding)*-1 + 26px);max-width:calc(100% + 60px);transition:opacity .3s ease-out;width:calc(100% + 60px)}.DriversComparisonChart_chartContainer__1eM-O .recharts-yAxis-tick-labels{display:none}@media (max-width:768px){.DriversComparisonChart_chartContainer__1eM-O{margin-left:calc(var(--page-x-padding)*-1 + 10px);width:calc(100% + 30px)}}";
4
4
  var S = {"root":"DriversComparisonChart_root__GLnlF","chartShell":"DriversComparisonChart_chartShell__0AzAz","chartShellLoading":"DriversComparisonChart_chartShellLoading__wTLod","chartSlot":"DriversComparisonChart_chartSlot__WKe6N","loadingLayer":"DriversComparisonChart_loadingLayer__HlEmA","loadingMessage":"DriversComparisonChart_loadingMessage__Li3S7","loadingText":"DriversComparisonChart_loadingText__0y3Ms","chartWithOverlay":"DriversComparisonChart_chartWithOverlay__SMToK","chartInteractiveLayer":"DriversComparisonChart_chartInteractiveLayer__0aquh","chartInteractiveDimmed":"DriversComparisonChart_chartInteractiveDimmed__us1dv","chartEmptyOverlay":"DriversComparisonChart_chartEmptyOverlay__eXqzk","chartEmptyBlurb":"DriversComparisonChart_chartEmptyBlurb__Tjy9E","seriesEmptyWrap":"DriversComparisonChart_seriesEmptyWrap__RyRs5","seriesSection":"DriversComparisonChart_seriesSection__yrf4I","seriesTableWrapper":"DriversComparisonChart_seriesTableWrapper__oredC","seriesTableContainer":"DriversComparisonChart_seriesTableContainer__dhfXK","seriesScrollbar":"DriversComparisonChart_seriesScrollbar__2jgk6","seriesTable":"DriversComparisonChart_seriesTable__NybPR","seriesColSeries":"DriversComparisonChart_seriesColSeries__--0mj","rowHidden":"DriversComparisonChart_rowHidden__Fwhna","colorSwatch":"DriversComparisonChart_colorSwatch__o3ZVr","seriesLabel":"DriversComparisonChart_seriesLabel__Aidof","chartContainer":"DriversComparisonChart_chartContainer__1eM-O"};
5
5
  styleInject(css_248z);
6
6
 
@@ -11,6 +11,26 @@ function formatSeriesImportance(value) {
11
11
  return '—';
12
12
  return `${value.toFixed(1)}%`;
13
13
  }
14
+ function driverImportanceSortKey(importance) {
15
+ return typeof importance === 'number' && Number.isFinite(importance)
16
+ ? importance
17
+ : -Infinity;
18
+ }
19
+ /** Higher importance first; ties broken by driver id for stable ordering. */
20
+ function compareDriversByImportance(a, b) {
21
+ const importanceDelta = driverImportanceSortKey(b.importance) -
22
+ driverImportanceSortKey(a.importance);
23
+ if (importanceDelta !== 0)
24
+ return importanceDelta;
25
+ return String(a.id).localeCompare(String(b.id));
26
+ }
27
+ function sortDriversByImportance(drivers) {
28
+ return [...drivers].sort(compareDriversByImportance);
29
+ }
30
+ function getDriversWithDataSortedByImportance(drivers) {
31
+ return sortDriversByImportance((drivers ?? []).filter(d => d.normalized_series &&
32
+ Object.keys(d.normalized_series).some(key => d.normalized_series[key] != null)));
33
+ }
14
34
  function resolveDriverLagLabel(driver) {
15
35
  if (typeof driver.lag === 'string' && driver.lag.trim()) {
16
36
  return driver.lag;
@@ -132,10 +152,7 @@ function mergeBacktestsChartData(payload) {
132
152
  map.set(k, existing);
133
153
  });
134
154
  if (payload.drivers?.length) {
135
- const sorted = [...payload.drivers]
136
- .filter(d => d.normalized_series &&
137
- Object.keys(d.normalized_series).some(key => d.normalized_series[key] != null))
138
- .sort((a, b) => String(a.id).localeCompare(String(b.id)));
155
+ const sorted = getDriversWithDataSortedByImportance(payload.drivers);
139
156
  sorted.forEach((driver, idx) => {
140
157
  const fid = DRIVER_FORECAST_ID_BASE + idx;
141
158
  const series = driver.normalized_series;
@@ -271,4 +288,4 @@ function buildDriversComparisonChartData(mergedWithHistorical, datasetHistorical
271
288
  return withLead.filter(p => normalizeToMonthStart(p.date) >= xMin);
272
289
  }
273
290
 
274
- export { DRIVER_COMPARISON_CHART_LEAD_MONTHS, DRIVER_FORECAST_ID_BASE, INITIAL_VISIBLE_SERIES_COUNT, applyDriversComparisonViewToPayload, buildDriversComparisonChartData, computeDriversComparisonHistoricalWindowFloor, formatLagMonthsLabel, formatSeriesImportance, getLagDisplayForView, getZoomAnchorMonthFromDriverMaterialStarts, mergeBacktestsChartData, mergeDatasetHistoricalWithBacktestsChartData, parseLagMonthsFromLabel, prependHistoricalLeadFromDataset, resolveDriverLagLabel, shiftNormalizedSeriesBackward, shiftNormalizedSeriesForward, subtractMonthsFromMonthStart };
291
+ export { DRIVER_COMPARISON_CHART_LEAD_MONTHS, DRIVER_FORECAST_ID_BASE, INITIAL_VISIBLE_SERIES_COUNT, applyDriversComparisonViewToPayload, buildDriversComparisonChartData, compareDriversByImportance, computeDriversComparisonHistoricalWindowFloor, formatLagMonthsLabel, formatSeriesImportance, getDriversWithDataSortedByImportance, getLagDisplayForView, getZoomAnchorMonthFromDriverMaterialStarts, mergeBacktestsChartData, mergeDatasetHistoricalWithBacktestsChartData, parseLagMonthsFromLabel, prependHistoricalLeadFromDataset, resolveDriverLagLabel, shiftNormalizedSeriesBackward, shiftNormalizedSeriesForward, sortDriversByImportance, subtractMonthsFromMonthStart };
@@ -1,6 +1,6 @@
1
1
  import styleInject from 'style-inject';
2
2
 
3
- var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.SybilionAppHeader_actionsAnchor__ress2{align-items:center;display:flex;flex-shrink:0;gap:var(--p-2)}.SybilionAppHeader_pageActionsPortal__9C5ww{align-items:center;display:flex;flex-shrink:0;gap:var(--p-1)}.SybilionAppHeader_pageActionsPortal__9C5ww:empty{display:none}.SybilionAppHeader_logoArea__3HAhG{align-items:center;display:flex;gap:var(--p-2);left:40px;position:absolute;top:22px;z-index:10}@media (max-width:768px){.SybilionAppHeader_logoArea__3HAhG{left:22px}}@media (min-width:768px){[data-slot=sidebar-wrapper][data-state=expanded]:not([data-slot=app-shell] [data-slot=sidebar-wrapper]) [data-slot=app-shell]:not([data-slot=app-shell] [data-slot=app-shell]) .SybilionAppHeader_logoArea__3HAhG:not([data-slot=app-shell] [data-slot=app-shell] *){left:calc(var(--sidebar-width)*-1 + 52px);position:absolute}[data-slot=app-shell] [data-slot=sidebar-wrapper][data-state=expanded] [data-slot=app-shell] .SybilionAppHeader_logoArea__3HAhG{left:calc(var(--sidebar-width)*-1 + 44px);position:absolute}[data-slot=app-shell] [data-slot=sidebar-wrapper][data-state=collapsed] [data-slot=app-shell] .SybilionAppHeader_logoArea__3HAhG{left:var(--p-8);position:absolute}}.SybilionAppHeader_logoLink__bH-KX{align-items:center;color:var(--color-foreground);display:flex;font-size:1.5rem;font-weight:400;gap:.5rem;text-decoration:none;white-space:nowrap;width:-moz-fit-content;width:fit-content}.SybilionAppHeader_logoLink__bH-KX svg{display:inline-flex;flex-shrink:0;height:32px;transition:transform .1s ease-in-out;width:auto}.SybilionAppHeader_logoLink__bH-KX:hover svg{transform:scale(1.05)}";
3
+ var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.SybilionAppHeader_actionsAnchor__ress2{align-items:center;display:flex;flex-shrink:0;gap:var(--p-2)}.SybilionAppHeader_pageActionsPortal__9C5ww{align-items:center;display:flex;flex-shrink:0;gap:var(--p-1)}.SybilionAppHeader_pageActionsPortal__9C5ww:empty{display:none}.SybilionAppHeader_logoArea__3HAhG{align-items:center;display:flex;gap:var(--p-2);left:40px;position:absolute;top:22px;z-index:10}@media (max-width:768px){.SybilionAppHeader_logoArea__3HAhG{left:22px}}@media (min-width:768px){[data-slot=sidebar-wrapper][data-state=expanded]:not([data-slot=app-shell] [data-slot=sidebar-wrapper]) [data-slot=app-shell]:not([data-slot=app-shell] [data-slot=app-shell]) header[data-sticky=false] .SybilionAppHeader_logoArea__3HAhG:not([data-slot=app-shell] [data-slot=app-shell] *){left:52px;position:fixed;top:22px;top:calc(22px + var(--app-banner-height, 0px))}[data-slot=sidebar-wrapper][data-state=expanded]:not([data-slot=app-shell] [data-slot=sidebar-wrapper]) [data-slot=app-shell]:not([data-slot=app-shell] [data-slot=app-shell]) header[data-sticky=true] .SybilionAppHeader_logoArea__3HAhG:not([data-slot=app-shell] [data-slot=app-shell] *){left:calc(var(--sidebar-width)*-1 + 52px);position:absolute}[data-slot=app-shell] [data-slot=sidebar-wrapper][data-state=expanded] [data-slot=app-shell] .SybilionAppHeader_logoArea__3HAhG{left:calc(var(--sidebar-width)*-1 + 44px);position:absolute}[data-slot=app-shell] [data-slot=sidebar-wrapper][data-state=collapsed] [data-slot=app-shell] .SybilionAppHeader_logoArea__3HAhG{left:var(--p-8);position:absolute}}.SybilionAppHeader_logoLink__bH-KX{align-items:center;color:var(--color-foreground);display:flex;font-size:1.5rem;font-weight:400;gap:.5rem;text-decoration:none;white-space:nowrap;width:-moz-fit-content;width:fit-content}.SybilionAppHeader_logoLink__bH-KX svg{display:inline-flex;flex-shrink:0;height:32px;transition:transform .1s ease-in-out;width:auto}.SybilionAppHeader_logoLink__bH-KX:hover svg{transform:scale(1.05)}";
4
4
  var S = {"actionsAnchor":"SybilionAppHeader_actionsAnchor__ress2","pageActionsPortal":"SybilionAppHeader_pageActionsPortal__9C5ww","logoArea":"SybilionAppHeader_logoArea__3HAhG","logoLink":"SybilionAppHeader_logoLink__bH-KX"};
5
5
  styleInject(css_248z);
6
6
 
package/dist/esm/index.js CHANGED
@@ -54,6 +54,7 @@ export { DropZone } from './components/ui/DropZone/DropZone.js';
54
54
  export { FileChip } from './components/ui/FileChip/FileChip.js';
55
55
  export { FlickeringGrid } from './components/ui/FlickeringGrid/FlickeringGrid.js';
56
56
  export { Foldable } from './components/ui/Foldable/Foldable.js';
57
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField } from './components/ui/Form/Form.js';
57
58
  export { Gap } from './components/ui/Gap/Gap.js';
58
59
  export { GridLayout } from './components/ui/GridLayout/GridLayout.js';
59
60
  export { Image } from './components/ui/Image/Image.js';
@@ -0,0 +1,48 @@
1
+ import { type ComponentProps, type HTMLAttributes } from 'react';
2
+ import { type FieldPath, type FieldValues } from 'react-hook-form';
3
+ import { Label } from '#uilib/components/ui/Label';
4
+ import { Slot } from '@radix-ui/react-slot';
5
+ import type { FormFieldProps, FormProps } from './Form.types';
6
+ /**
7
+ * Root validated form. Owns `useForm`, applies `zodResolver(schema)` when `schema` is
8
+ * passed, and renders a native `<form>` wired to `onSubmit`. Wrap fields in {@link FormField}.
9
+ */
10
+ declare function Form<TFieldValues extends FieldValues>({ schema, defaultValues, onSubmit, resolver, formOptions, form: externalForm, className, children, ...formHTMLProps }: FormProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
11
+ /**
12
+ * Connects a field to react-hook-form via `Controller`. Reads `control` from the nearest
13
+ * {@link Form} context — do not pass `control` manually. Must wrap {@link FormItem} inside `render`.
14
+ */
15
+ declare function FormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: FormFieldProps<TFieldValues, TName>): import("react/jsx-runtime").JSX.Element;
16
+ /** Vertical field shell; generates stable ids for label, control, description, and message. */
17
+ declare function FormItem({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
18
+ /**
19
+ * Field metadata for {@link FormLabel}, {@link FormControl}, {@link FormDescription}, and
20
+ * {@link FormMessage}. Requires {@link FormField} + {@link FormItem} ancestors.
21
+ */
22
+ declare function useFormField(): {
23
+ invalid: boolean;
24
+ isDirty: boolean;
25
+ isTouched: boolean;
26
+ isValidating: boolean;
27
+ error?: import("react-hook-form").FieldError;
28
+ id: string;
29
+ name: string;
30
+ formItemId: string;
31
+ formDescriptionId: string;
32
+ formMessageId: string;
33
+ };
34
+ /** Accessible label linked to the control id from {@link FormItem}. */
35
+ declare function FormLabel({ className, ...props }: ComponentProps<typeof Label>): import("react/jsx-runtime").JSX.Element;
36
+ /**
37
+ * Slot wrapper for the actual input. Forwards `id`, `aria-invalid`, and `aria-describedby`
38
+ * so uilib controls show validation styling (P-07 inline errors).
39
+ */
40
+ declare function FormControl({ ...props }: ComponentProps<typeof Slot>): import("react/jsx-runtime").JSX.Element;
41
+ /** Optional helper text below the label; referenced by `aria-describedby` on {@link FormControl}. */
42
+ declare function FormDescription({ className, ...props }: HTMLAttributes<HTMLParagraphElement>): import("react/jsx-runtime").JSX.Element;
43
+ /**
44
+ * Inline validation message (`role="alert"`). Shows `fieldState.error.message` when present;
45
+ * omit for empty fields — never use toast for field errors.
46
+ */
47
+ declare function FormMessage({ className, children, ...props }: HTMLAttributes<HTMLParagraphElement>): import("react/jsx-runtime").JSX.Element;
48
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField, };
@@ -0,0 +1 @@
1
+ export declare function FormExample(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ import type { ControllerProps, DefaultValues, FieldPath, FieldValues, Resolver, SubmitHandler, UseFormProps, UseFormReturn } from 'react-hook-form';
3
+ import type { z } from 'zod';
4
+ export type FormProps<TFieldValues extends FieldValues = FieldValues> = Omit<ComponentPropsWithoutRef<'form'>, 'onSubmit' | 'children'> & {
5
+ schema?: z.ZodType<TFieldValues>;
6
+ defaultValues?: DefaultValues<TFieldValues>;
7
+ onSubmit: SubmitHandler<TFieldValues>;
8
+ resolver?: Resolver<TFieldValues>;
9
+ formOptions?: Omit<UseFormProps<TFieldValues>, 'defaultValues' | 'resolver'>;
10
+ form?: UseFormReturn<TFieldValues>;
11
+ children?: ReactNode;
12
+ className?: string;
13
+ };
14
+ export type FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<ControllerProps<TFieldValues, TName>, 'control'>;
@@ -0,0 +1,2 @@
1
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField, } from './Form';
2
+ export type { FormFieldProps, FormProps } from './Form.types';
@@ -6,6 +6,16 @@ export declare const INITIAL_VISIBLE_SERIES_COUNT = 3;
6
6
  export declare const DRIVER_COMPARISON_CHART_LEAD_MONTHS = 6;
7
7
  export type DriversComparisonViewTab = 'overlapped' | 'lagged';
8
8
  export declare function formatSeriesImportance(value: number | null): string;
9
+ /** Higher importance first; ties broken by driver id for stable ordering. */
10
+ export declare function compareDriversByImportance<T extends {
11
+ id?: string | number;
12
+ importance?: number | null;
13
+ }>(a: T, b: T): number;
14
+ export declare function sortDriversByImportance<T extends {
15
+ id?: string | number;
16
+ importance?: number | null;
17
+ }>(drivers: T[]): T[];
18
+ export declare function getDriversWithDataSortedByImportance(drivers: BacktestsComponentPayload['drivers'] | undefined): NonNullable<BacktestsComponentPayload['drivers']>;
9
19
  export declare function resolveDriverLagLabel(driver: {
10
20
  lag?: string | null;
11
21
  overall_lag?: string | null;
@@ -0,0 +1 @@
1
+ export default function FormPage(): import("react/jsx-runtime").JSX.Element;
@@ -35,6 +35,7 @@ export * from './components/ui/DropZone/DropZone';
35
35
  export * from './components/ui/FileChip';
36
36
  export * from './components/ui/FlickeringGrid';
37
37
  export * from './components/ui/Foldable';
38
+ export * from './components/ui/Form';
38
39
  export * from './components/ui/Gap/Gap';
39
40
  export * from './components/ui/GridLayout/GridLayout';
40
41
  export * from './components/ui/Image';
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybilion/uilib",
3
- "version": "1.4.16",
3
+ "version": "1.4.18",
4
4
  "description": "Sybilion Design System — React UI components (Webpack + Stylus)",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -125,11 +125,14 @@
125
125
  },
126
126
  "peerDependencies": {
127
127
  "@auth0/auth0-react": "^2.3.1",
128
+ "@hookform/resolvers": "^5.0.0",
128
129
  "@sybilion/platform-sdk": ">=0.0.1",
129
130
  "react": ">=18.0.0",
130
131
  "react-dom": ">=18.0.0",
132
+ "react-hook-form": "^7.55.0",
131
133
  "react-router-dom": ">=6.0.0",
132
- "vite": "^6.0.0"
134
+ "vite": "^6.0.0",
135
+ "zod": "^4.0.0"
133
136
  },
134
137
  "peerDependenciesMeta": {
135
138
  "@auth0/auth0-react": {
@@ -147,6 +150,7 @@
147
150
  "@babel/core": "^7.20.12",
148
151
  "@babel/preset-typescript": "^7.21.0",
149
152
  "@homecode/ui": "^4.30.6",
153
+ "@hookform/resolvers": "^5.0.0",
150
154
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
151
155
  "@rollup/plugin-alias": "^6.0.0",
152
156
  "@rollup/plugin-commonjs": "^24.0.1",
@@ -187,6 +191,7 @@
187
191
  "prettier": "^3.6.2",
188
192
  "react": "^19.0.0",
189
193
  "react-dom": "^19.1.1",
194
+ "react-hook-form": "^7.55.0",
190
195
  "react-markdown": "^10.1.0",
191
196
  "react-refresh": "^0.17.0",
192
197
  "react-router-dom": "^6.28.0",
@@ -206,7 +211,8 @@
206
211
  "vite": "^6.0.0",
207
212
  "webpack": "^5.75.0",
208
213
  "webpack-cli": "^5.0.1",
209
- "webpack-dev-server": "^5.2.3"
214
+ "webpack-dev-server": "^5.2.3",
215
+ "zod": "^4.0.0"
210
216
  },
211
217
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
212
218
  }
@@ -25,6 +25,7 @@ export function AppHeaderHost({
25
25
  return (
26
26
  <header
27
27
  className={cn(S.root, sticky && S.sticky, className)}
28
+ data-sticky={sticky ? 'true' : 'false'}
28
29
  id={anchorId}
29
30
  />
30
31
  );
@@ -1,8 +1,9 @@
1
+ import cn from 'classnames';
2
+
1
3
  import { TrendingDown, TrendingUp } from 'lucide-react';
2
4
 
3
- import { ChipProps } from './Chip.types';
4
5
  import S from './Chip.styl';
5
- import cn from 'classnames';
6
+ import { ChipProps } from './Chip.types';
6
7
 
7
8
  function Chip({
8
9
  className,
@@ -15,7 +16,6 @@ function Chip({
15
16
  }: ChipProps) {
16
17
  const TrendIcon =
17
18
  trend === 'up' ? TrendingUp : trend === 'down' ? TrendingDown : null;
18
-
19
19
  return (
20
20
  <span
21
21
  data-slot="chip"
@@ -0,0 +1,29 @@
1
+ ---
2
+ summary: Validated forms via root Form with zod schema and inline field errors
3
+ ---
4
+
5
+ Root `<Form>` owns schema validation, default values, and submit handling — it wraps react-hook-form and zodResolver internally and renders the native `<form>` element. Pair field primitives with uilib controls for inline validation errors.
6
+
7
+ ## When to use
8
+
9
+ - Demo forms validated with a zod schema.
10
+ - Controls that need `Controller` wiring (Select, Checkbox, custom inputs).
11
+ - Inline field errors after submit or blur.
12
+
13
+ ## When not to use
14
+
15
+ - Simple label-plus-input rows without validation — use `LabeledInput`.
16
+ - Page-level or session errors — use `Banner`.
17
+ - Success or info feedback — use Sonner toasts, not field errors.
18
+
19
+ ## Do
20
+
21
+ - Pass `schema`, `defaultValues`, and `onSubmit` to the root `Form`.
22
+ - Wrap each control in `FormControl` inside `FormItem`.
23
+ - Show validation messages with `FormMessage`.
24
+
25
+ ## Don't
26
+
27
+ - Call `useForm` or `zodResolver` in page code — the root `Form` handles that.
28
+ - Use `toast.error` for field validation failures.
29
+ - Render manual error `<p>` elements outside `FormMessage`.