@tradalab/lyra 3.16.0 → 3.18.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.
package/README.md CHANGED
@@ -24,10 +24,10 @@ The stylesheet pulls in Tailwind v4, so your app needs `@tailwindcss/postcss`.
24
24
 
25
25
  | Subpath | Exports | Boundary |
26
26
  |---|---|---|
27
- | `@tradalab/lyra/utils` | `cn` | server-safe |
28
- | `@tradalab/lyra/hooks` | `useMobile` | client |
27
+ | `@tradalab/lyra/utils` | `cn`, `foldText`, `formatBytes`/`formatCount`, `addTag`/`matchesKeyword`, `pickDelimiter`/`groupByPrefix`, `CONNECTION_COLORS`/`resolveColor`/`ENV_FRAME` | server-safe |
28
+ | `@tradalab/lyra/hooks` | `useMobile`, `useDirtyFields` | client |
29
29
  | `@tradalab/lyra/ui` | 61 shadcn primitives + `AccountMenu`, `ActionButton`, `Container`, `EmptyState`, `StatusBadge` | client |
30
- | `@tradalab/lyra/blocks` | `Form`/`FormField` + RHF glue, `Panel`, `Confirm`/`useConfirm`, `Tree`, `TzPicker`, `OptionPicker`, `MobileSheet`, `ChoiceDrawer`, `McpSettings`, `LlmSettings`, `PlatePicker`, `usePlate`, `useCompact`, `PreferenceScript` | client |
30
+ | `@tradalab/lyra/blocks` | `Form`/`FormField` + RHF glue, `Panel`, `Confirm`/`useConfirm`, `Tree`, `TzPicker`, `OptionPicker`, `MobileSheet`, `ChoiceDrawer`, `McpSettings`, `LlmSettings`, `PlatePicker`, `usePlate`, `useCompact`, `PreferenceScript`, `StatTile`, `BarList`, `ColorSwatches`, `TagInput`, `loadExpanded`/`saveExpanded`, `DateField`, `LockedReason`, `UnsavedBadge`, `useConfirmReason`, `useBlocked` | client |
31
31
  | `@tradalab/lyra/data-table` | `DataTable` + `usePager`, `TableFilterBar`, `TableFilterChips`, `TableSearch`, `TableReload`, `filterRows`, `pageWindow` | client |
32
32
  | `@tradalab/lyra/shell` | `AppShell`, `PageShell`, `PageHeader`, `NavItem`, `NavGroup`, `Breadcrumbs`, `BottomNav`, `useActiveRoute`, `useSearchParam`, `useTabParam`, `usePageParam`, `UrlTabs` | client |
33
33
  | `@tradalab/lyra/styles.css` | Tailwind v4 base + `radix-lyra` tokens (light/dark) | CSS |
@@ -1,12 +1,13 @@
1
1
  import * as react_hook_form from 'react-hook-form';
2
2
  import { FieldValues, FieldPath, ControllerProps } from 'react-hook-form';
3
3
  import * as React$1 from 'react';
4
- import { ReactNode, DragEvent, HTMLAttributes, ReactElement } from 'react';
4
+ import { ReactNode, DragEvent, HTMLAttributes, ComponentProps, ReactElement } from 'react';
5
5
  import { Slot, Label } from 'radix-ui';
6
6
  import { LucideIcon } from 'lucide-react';
7
- export { B as BEARING_PLATES, a as BearingPlate, P as PLATES, b as Plate, d as derivePlate, i as isPlate } from '../plate-BJ19iaVV.js';
8
- export { u as useCompact, a as usePlate } from '../use-compact-BvI4sJf9.js';
9
- export { P as PlatePicker, a as PlatePickerProps } from '../plate-picker-CXxUGyNz.js';
7
+ import { d as ConnectionColor } from '../connection-color-DxEs04ll.js';
8
+ export { B as BEARING_PLATES, a as BearingPlate, b as PLATES, P as Plate, d as derivePlate, i as isPlate } from '../plate-iXwbupLU.js';
9
+ export { u as useCompact, a as usePlate } from '../use-compact-ahmJWpSH.js';
10
+ export { a as PlatePicker, P as PlatePickerProps } from '../plate-picker-DdC2HFo6.js';
10
11
  export { P as PreferenceScript } from '../preference-script-Dm-LEoYX.js';
11
12
 
12
13
  declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe, }: react_hook_form.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React$1.JSX.Element;
@@ -72,22 +73,62 @@ type ConfirmOptions = {
72
73
  confirmText?: string;
73
74
  cancelText?: string;
74
75
  danger?: boolean;
76
+ /** What the action does to other records or people, one line each. */
77
+ consequences?: ReactNode[];
78
+ /** Set to say whether the action can be undone; the line is shown only when it is set. */
79
+ reversible?: boolean;
80
+ reversibleText?: string;
81
+ irreversibleText?: string;
82
+ };
83
+ type ReasonField = {
84
+ label: string;
85
+ placeholder?: string;
86
+ required?: boolean;
87
+ };
88
+ type ConfirmReasonOptions = ConfirmOptions & {
89
+ reason: ReasonField;
90
+ };
91
+ type BlockedOptions = {
92
+ title: string;
93
+ description?: ReactNode;
94
+ /** What stands in the way, one line each. */
95
+ blockers: ReactNode[];
96
+ closeText?: string;
97
+ /** A way to the place where the blocker is resolved; there is never a confirm button. */
98
+ action?: {
99
+ label: string;
100
+ onClick: () => void;
101
+ };
75
102
  };
76
103
 
77
104
  type Props = {
78
- options: ConfirmOptions;
79
- onConfirm: () => void;
105
+ options: ConfirmOptions & {
106
+ reason?: ReasonField;
107
+ };
108
+ onConfirm: (reason: string) => void;
80
109
  onCancel: () => void;
81
110
  };
82
111
  declare function ConfirmDialog({ options, onConfirm, onCancel }: Props): React$1.JSX.Element;
112
+ declare function BlockedDialog({ options, onClose }: {
113
+ options: BlockedOptions;
114
+ onClose: () => void;
115
+ }): React$1.JSX.Element;
83
116
 
84
117
  type ConfirmFn = (options: ConfirmOptions) => Promise<boolean>;
118
+ type ConfirmReasonFn = (options: ConfirmReasonOptions) => Promise<string | null>;
119
+ type BlockedFn = (options: BlockedOptions) => Promise<void>;
85
120
  declare const ConfirmContext: React$1.Context<ConfirmFn | null>;
121
+ declare const ConfirmReasonContext: React$1.Context<ConfirmReasonFn | null>;
122
+ declare const BlockedContext: React$1.Context<BlockedFn | null>;
86
123
  declare function ConfirmProvider({ children }: {
87
124
  children: ReactNode;
88
125
  }): React$1.JSX.Element;
89
126
 
90
127
  declare const useConfirm: () => ConfirmFn;
128
+ /** Like `useConfirm`, with a reason box; resolves to the trimmed reason, or `null` when cancelled. */
129
+ declare const useConfirmReason: () => ConfirmReasonFn;
130
+ /** Explains why an action cannot run, listing what blocks it; offers no confirm button. */
131
+ declare const useBlocked: () => BlockedFn;
91
132
 
92
133
  type TreeData<T> = {
93
134
  id: string;
@@ -217,6 +258,55 @@ declare const TreeIcon: ({ icon, hasChildren, className, ...props }: TreeIconPro
217
258
  type TreeLabelProps = HTMLAttributes<HTMLSpanElement>;
218
259
  declare const TreeLabel: ({ className, ...props }: TreeLabelProps) => React$1.JSX.Element;
219
260
 
261
+ interface StatTileProps {
262
+ label: ReactNode;
263
+ value: ReactNode;
264
+ tone?: "default" | "bad";
265
+ className?: string;
266
+ }
267
+ /** One labelled number in a bordered box; `tone="bad"` paints border and value destructive. */
268
+ declare function StatTile({ label, value, tone, className }: StatTileProps): React$1.JSX.Element;
269
+ interface BarListItem {
270
+ key: string;
271
+ label: string;
272
+ value: ReactNode;
273
+ ratio: number;
274
+ onSelect?: () => void;
275
+ }
276
+ /** Rows with a bar behind each label sized by `ratio` (clamped to 0..1, NaN as 0, as 0/0 gives); a row with `onSelect` is a button. */
277
+ declare function BarList({ items, className }: {
278
+ items: readonly BarListItem[];
279
+ className?: string;
280
+ }): React$1.JSX.Element;
281
+
282
+ /** The group ids saved under `key` in localStorage; empty when storage is blocked or holds something else. */
283
+ declare function loadExpanded(key: string): Set<string>;
284
+ /** Saves `ids` under `key`; a blocked write is ignored. */
285
+ declare function saveExpanded(key: string, ids: ReadonlySet<string>): void;
286
+
287
+ interface ColorSwatchesProps {
288
+ value?: string;
289
+ onChange: (value: ConnectionColor | "") => void;
290
+ emptyLabel: string;
291
+ labels?: Partial<Record<ConnectionColor, string>>;
292
+ className?: string;
293
+ "aria-label"?: string;
294
+ "aria-labelledby"?: string;
295
+ }
296
+ /** A row of the eight connection colours plus a dashed "none" dot, which reports `""`. An unknown `value` shows as none. */
297
+ declare function ColorSwatches({ value, onChange, emptyLabel, labels, className, ...aria }: ColorSwatchesProps): React$1.JSX.Element;
298
+
299
+ interface TagInputProps extends Pick<ComponentProps<"input">, "id" | "aria-describedby" | "aria-invalid" | "aria-label" | "disabled"> {
300
+ value?: readonly string[];
301
+ onChange: (value: string[]) => void;
302
+ suggestions?: readonly string[];
303
+ placeholder?: string;
304
+ removeLabel?: (tag: string) => string;
305
+ className?: string;
306
+ }
307
+ /** Tags as chips plus a text box: Enter, comma or blur adds, Backspace on an empty box removes the last. Repeats ignoring case are dropped, also from `value`. */
308
+ declare function TagInput({ value, onChange, suggestions, placeholder, removeLabel, className, disabled, ...aria }: TagInputProps): React$1.JSX.Element;
309
+
220
310
  interface TzPickerLabels {
221
311
  /** Shown when the value is empty and `allowInherit`. Default: "Inherit". */
222
312
  inherit?: string;
@@ -241,6 +331,49 @@ interface TzPickerProps {
241
331
  }
242
332
  declare function TzPicker({ value, onChange, allowInherit, labels, disabled, id, className, }: TzPickerProps): React$1.JSX.Element;
243
333
 
334
+ type Part = "d" | "m" | "y";
335
+ interface DatePattern {
336
+ order: Part[];
337
+ sep: string;
338
+ }
339
+ /** Day, month and year order and separator the locale writes dates with, read from `Intl`. */
340
+ declare function datePattern(locale: string): DatePattern;
341
+ /** `YYYY-MM-DD` written the locale's way, `""` for an empty or malformed value. */
342
+ declare function formatDate(iso: string, pattern: DatePattern): string;
343
+ /** Typed text to `YYYY-MM-DD`: the locale's order, any separator, or ISO. A two-digit year lands within ten years ahead or the century before. `null` when it is not a real date. */
344
+ declare function parseDate(text: string, pattern: DatePattern): string | null;
345
+ interface DateFieldProps {
346
+ /** `YYYY-MM-DD`, or `""` for no date. */
347
+ value: string;
348
+ onChange: (value: string) => void;
349
+ /** BCP 47 tag of the APP's language, not the browser's: it decides how the date is written. */
350
+ locale: string;
351
+ id?: string;
352
+ disabled?: boolean;
353
+ required?: boolean;
354
+ min?: string;
355
+ max?: string;
356
+ todayLabel?: string;
357
+ clearLabel?: string;
358
+ pickLabel?: string;
359
+ className?: string;
360
+ "aria-label"?: string;
361
+ "aria-invalid"?: boolean;
362
+ }
363
+ /** A date typed in the app's own format, with a calendar beside it: a popover under a mouse, a bottom sheet under a finger. */
364
+ declare function DateField({ value, onChange, locale, id, disabled, required, min, max, todayLabel, clearLabel, pickLabel, className, ...aria }: DateFieldProps): React$1.JSX.Element;
365
+
366
+ /** Why a disabled field cannot be edited and where it is changed instead; text, not a tooltip, so it reads on a phone. */
367
+ declare function LockedReason({ children, className }: {
368
+ children: ReactNode;
369
+ className?: string;
370
+ }): React$1.JSX.Element;
371
+ /** Marks a form that holds edits not yet saved; render it next to the save button. */
372
+ declare function UnsavedBadge({ children, className }: {
373
+ children: ReactNode;
374
+ className?: string;
375
+ }): React$1.JSX.Element;
376
+
244
377
  /**
245
378
  * Pick one id from a known set.
246
379
  *
@@ -634,4 +767,4 @@ interface LlmSettingsProps {
634
767
  }
635
768
  declare function LlmSettings({ api, labels, className, header, footer }: LlmSettingsProps): React$1.JSX.Element;
636
769
 
637
- export { AuthCard, type AuthCardProps, AvatarTile, type AvatarTileProps, ChoiceDrawer, type ChoiceDrawerProps, type ChoiceOption, ConfirmContext, ConfirmDialog, type ConfirmFn, type ConfirmOptions, ConfirmProvider, type DropPlan, type DropPosition, type FlatTreeNode, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, type LlmCapability, type LlmDriver, type LlmField, type LlmFound, type LlmModel, type LlmProvider, type LlmProviderInput, type LlmPullProgress, LlmSettings, type LlmSettingsApi, type LlmSettingsFormat, type LlmSettingsLabels, type LlmSettingsProps, type LlmSlot, type LlmState, type McpCall, type McpClient, McpSettings, type McpSettingsApi, type McpSettingsLabels, type McpStatus, type McpTool, MobileSheet, type MobileSheetProps, OptionPicker, type OptionPickerLabels, Panel, PanelCard, type PanelCardProps, type PanelItemProps, type PickOption, type TreeData, TreeDndProvider, type TreeDndProviderProps, TreeExpander, type TreeExpanderProps, TreeIcon, type TreeIconProps, TreeLabel, type TreeLabelProps, TreeLines, TreeNode, TreeNodeContent, type TreeNodeContentProps, type TreeNodeProps, TreeNodeTrigger, type TreeNodeTriggerProps, TreeProvider, type TreeProviderProps, TreeView, type TreeViewProps, TzPicker, type TzPickerLabels, type TzPickerProps, filterTree, flattenTree, moveId, planDrop, sameOrder, sortTree, useConfirm, useFormField, useTreeDndNode, useTreeDndRoot };
770
+ export { AuthCard, type AuthCardProps, AvatarTile, type AvatarTileProps, BarList, type BarListItem, BlockedContext, BlockedDialog, type BlockedFn, type BlockedOptions, ChoiceDrawer, type ChoiceDrawerProps, type ChoiceOption, ColorSwatches, type ColorSwatchesProps, ConfirmContext, ConfirmDialog, type ConfirmFn, type ConfirmOptions, ConfirmProvider, ConfirmReasonContext, type ConfirmReasonFn, type ConfirmReasonOptions, DateField, type DateFieldProps, type DatePattern, type DropPlan, type DropPosition, type FlatTreeNode, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, type LlmCapability, type LlmDriver, type LlmField, type LlmFound, type LlmModel, type LlmProvider, type LlmProviderInput, type LlmPullProgress, LlmSettings, type LlmSettingsApi, type LlmSettingsFormat, type LlmSettingsLabels, type LlmSettingsProps, type LlmSlot, type LlmState, LockedReason, type McpCall, type McpClient, McpSettings, type McpSettingsApi, type McpSettingsLabels, type McpStatus, type McpTool, MobileSheet, type MobileSheetProps, OptionPicker, type OptionPickerLabels, Panel, PanelCard, type PanelCardProps, type PanelItemProps, type PickOption, type ReasonField, StatTile, type StatTileProps, TagInput, type TagInputProps, type TreeData, TreeDndProvider, type TreeDndProviderProps, TreeExpander, type TreeExpanderProps, TreeIcon, type TreeIconProps, TreeLabel, type TreeLabelProps, TreeLines, TreeNode, TreeNodeContent, type TreeNodeContentProps, type TreeNodeProps, TreeNodeTrigger, type TreeNodeTriggerProps, TreeProvider, type TreeProviderProps, TreeView, type TreeViewProps, TzPicker, type TzPickerLabels, type TzPickerProps, UnsavedBadge, datePattern, filterTree, flattenTree, formatDate, loadExpanded, moveId, parseDate, planDrop, sameOrder, saveExpanded, sortTree, useBlocked, useConfirm, useConfirmReason, useFormField, useTreeDndNode, useTreeDndRoot };