@tradalab/lyra 3.17.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.
@@ -1,4 +1,5 @@
1
1
  import { useStoredSetting, PLATE_KEY, isPlate, useRootAttribute, COMPACT_KEY } from './chunk-D7DMRCDY.js';
2
+ import * as React from 'react';
2
3
  import { useCallback } from 'react';
3
4
 
4
5
  // src/hooks/use-plate.ts
@@ -15,7 +16,15 @@ function useCompact() {
15
16
  useRootAttribute("data-compact", compact ? "true" : null);
16
17
  return [compact, setCompact];
17
18
  }
19
+ var same = (a, b) => a === b || JSON.stringify(a) === JSON.stringify(b);
20
+ function useDirtyFields(initial, current) {
21
+ return React.useMemo(() => {
22
+ const dirty = Object.keys(current).filter((k) => !same(initial[k], current[k]));
23
+ const set = new Set(dirty);
24
+ return { dirty, isDirty: dirty.length > 0, is: (key) => set.has(key) };
25
+ }, [initial, current]);
26
+ }
18
27
 
19
- export { useCompact, usePlate };
20
- //# sourceMappingURL=chunk-AIULLZYM.js.map
21
- //# sourceMappingURL=chunk-AIULLZYM.js.map
28
+ export { useCompact, useDirtyFields, usePlate };
29
+ //# sourceMappingURL=chunk-D2O4GTCC.js.map
30
+ //# sourceMappingURL=chunk-D2O4GTCC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-plate.ts","../src/hooks/use-compact.ts","../src/hooks/use-dirty-fields.ts"],"names":[],"mappings":";;;;;AAaO,SAAS,QAAA,GAA0D;AACxE,EAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,iBAAiB,SAAS,CAAA;AAClD,EAAA,MAAM,QAAQ,MAAA,KAAW,IAAA,IAAQ,OAAA,CAAQ,MAAM,IAAI,MAAA,GAAS,IAAA;AAC5D,EAAA,gBAAA,CAAiB,cAAc,KAAK,CAAA;AACpC,EAAA,OAAO,CAAC,OAAO,KAAK,CAAA;AACtB;ACbO,SAAS,UAAA,GAAoD;AAClE,EAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,iBAAiB,WAAW,CAAA;AACpD,EAAA,MAAM,UAAU,MAAA,KAAW,MAAA;AAC3B,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,CAAC,IAAA,KAAkB,KAAA,CAAM,IAAA,GAAO,MAAA,GAAS,IAAI,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACtF,EAAA,gBAAA,CAAiB,cAAA,EAAgB,OAAA,GAAU,MAAA,GAAS,IAAI,CAAA;AACxD,EAAA,OAAO,CAAC,SAAS,UAAU,CAAA;AAC7B;ACTA,IAAM,IAAA,GAAO,CAAC,CAAA,EAAY,CAAA,KAAe,CAAA,KAAM,CAAA,IAAK,IAAA,CAAK,SAAA,CAAU,CAAC,CAAA,KAAM,IAAA,CAAK,SAAA,CAAU,CAAC,CAAA;AAGnF,SAAS,cAAA,CAAkD,SAAY,OAAA,EAAY;AACxF,EAAA,OAAa,cAAQ,MAAM;AACzB,IAAA,MAAM,QAAS,MAAA,CAAO,IAAA,CAAK,OAAO,CAAA,CAAkB,OAAO,CAAC,CAAA,KAAM,CAAC,IAAA,CAAK,QAAQ,CAAC,CAAA,EAAG,OAAA,CAAQ,CAAC,CAAC,CAAC,CAAA;AAC/F,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAa,KAAK,CAAA;AAClC,IAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,CAAM,MAAA,GAAS,CAAA,EAAG,EAAA,EAAI,CAAC,GAAA,KAAiB,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA,EAAE;AAAA,EAChF,CAAA,EAAG,CAAC,OAAA,EAAS,OAAO,CAAC,CAAA;AACvB","file":"chunk-D2O4GTCC.js","sourcesContent":["\"use client\"\n\nimport { PLATE_KEY, useRootAttribute, useStoredSetting } from \"./device-setting.js\"\nimport { isPlate, type Plate } from \"./plate.js\"\n\n/**\n * The plate this device is set to, and a way to change it.\n *\n * A stored name that is no longer a plate - a rename, a downgrade to an older lyra - reads as no\n * plate. The alternative is an attribute no rule matches, which looks identical to the neutral\n * default on screen while the picker shows nothing selected at all, so the reader cannot tell that\n * their choice was dropped or get back to a known state.\n */\nexport function usePlate(): [Plate | null, (plate: Plate | null) => void] {\n const [stored, store] = useStoredSetting(PLATE_KEY)\n const plate = stored !== null && isPlate(stored) ? stored : null\n useRootAttribute(\"data-plate\", plate)\n return [plate, store]\n}\n","\"use client\"\n\nimport { useCallback } from \"react\"\nimport { COMPACT_KEY, useRootAttribute, useStoredSetting } from \"./device-setting.js\"\n\nexport function useCompact(): [boolean, (compact: boolean) => void] {\n const [stored, store] = useStoredSetting(COMPACT_KEY)\n const compact = stored === \"true\"\n const setCompact = useCallback((next: boolean) => store(next ? \"true\" : null), [store])\n useRootAttribute(\"data-compact\", compact ? \"true\" : null)\n return [compact, setCompact]\n}\n","import * as React from \"react\"\n\nconst same = (a: unknown, b: unknown) => a === b || JSON.stringify(a) === JSON.stringify(b)\n\n/** Keys of `current` that differ from `initial`, compared by value; `isDirty` when any does. */\nexport function useDirtyFields<T extends Record<string, unknown>>(initial: T, current: T) {\n return React.useMemo(() => {\n const dirty = (Object.keys(current) as (keyof T)[]).filter((k) => !same(initial[k], current[k]))\n const set = new Set<keyof T>(dirty)\n return { dirty, isDirty: dirty.length > 0, is: (key: keyof T) => set.has(key) }\n }, [initial, current])\n}\n"]}
@@ -1,5 +1,5 @@
1
- export { B as BEARING_PLATES, a as BearingPlate, P as PLATES, b as Plate, d as derivePlate, i as isPlate } from '../plate-BJ19iaVV.js';
2
- export { u as useCompact, a as usePlate } from '../use-compact-BvI4sJf9.js';
1
+ export { B as BEARING_PLATES, a as BearingPlate, b as PLATES, P as Plate, d as derivePlate, i as isPlate } from '../plate-iXwbupLU.js';
2
+ export { u as useCompact, a as usePlate } from '../use-compact-ahmJWpSH.js';
3
3
 
4
4
  /**
5
5
  * Returns `true` when viewport width is below the given mobile breakpoint.
@@ -9,4 +9,11 @@ export { u as useCompact, a as usePlate } from '../use-compact-BvI4sJf9.js';
9
9
  */
10
10
  declare function useMobile(breakpointPx?: number): boolean;
11
11
 
12
- export { useMobile };
12
+ /** Keys of `current` that differ from `initial`, compared by value; `isDirty` when any does. */
13
+ declare function useDirtyFields<T extends Record<string, unknown>>(initial: T, current: T): {
14
+ dirty: (keyof T)[];
15
+ isDirty: boolean;
16
+ is: (key: keyof T) => boolean;
17
+ };
18
+
19
+ export { useDirtyFields, useMobile };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- export { useCompact, usePlate } from '../chunk-AIULLZYM.js';
2
+ export { useCompact, useDirtyFields, usePlate } from '../chunk-D2O4GTCC.js';
3
3
  export { BEARING_PLATES, PLATES, derivePlate, isPlate, useMobile } from '../chunk-D7DMRCDY.js';
4
4
  //# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map
@@ -35,4 +35,4 @@ declare function isPlate(s: string): s is Plate;
35
35
  */
36
36
  declare function derivePlate(id: string): BearingPlate;
37
37
 
38
- export { BEARING_PLATES as B, PLATES as P, type BearingPlate as a, type Plate as b, derivePlate as d, isPlate as i };
38
+ export { BEARING_PLATES as B, type Plate as P, type BearingPlate as a, PLATES as b, derivePlate as d, isPlate as i };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { b as Plate } from './plate-BJ19iaVV.js';
2
+ import { P as Plate } from './plate-iXwbupLU.js';
3
3
 
4
4
  interface PlatePickerProps {
5
5
  value: Plate | null;
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentProps, ReactNode } from 'react';
3
3
  import { S as SidebarProvider, a as SidebarInset, b as Sidebar, A as AccountMenuUser, c as AccountMenuLabels, B as Breadcrumb, T as Tabs } from '../account-menu-q2VMEk3b.js';
4
- import { P as PlatePickerProps } from '../plate-picker-dhKLjz_6.js';
4
+ import { P as PlatePickerProps } from '../plate-picker-DdC2HFo6.js';
5
5
  import 'class-variance-authority/types';
6
6
  import 'class-variance-authority';
7
7
  import 'radix-ui';
8
- import '../plate-BJ19iaVV.js';
8
+ import '../plate-iXwbupLU.js';
9
9
 
10
10
  interface AppShellProps extends Omit<ComponentProps<typeof SidebarProvider>, "children"> {
11
11
  children: ReactNode;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { usePlate, useCompact } from '../chunk-AIULLZYM.js';
2
+ import { usePlate, useCompact } from '../chunk-D2O4GTCC.js';
3
3
  import { SidebarInset, SidebarProvider, useSidebar, Sidebar, SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, defaultAccountMenuLabels, initialsOf, PlatePicker, Switch, ScrollArea, ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ScrollBar, Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbPage, BreadcrumbLink, BreadcrumbSeparator, Card, CardTitle, CardDescription, Tabs } from '../chunk-UNRT3B6P.js';
4
4
  import '../chunk-D7DMRCDY.js';
5
5
  import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuSeparator, DropdownMenuLabel, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuItem } from '../chunk-OH3OMK7A.js';
@@ -19,9 +19,9 @@ export { useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVis
19
19
  import { Questionnaire as Questionnaire$1 } from '@shadcn/react/questionnaire';
20
20
  import * as ResizablePrimitive from 'react-resizable-panels';
21
21
  import { Toast as Toast$1 } from '@base-ui/react/toast';
22
- export { a as PlatePicker, P as PlatePickerProps } from '../plate-picker-dhKLjz_6.js';
22
+ export { a as PlatePicker, P as PlatePickerProps } from '../plate-picker-DdC2HFo6.js';
23
23
  export { P as PreferenceScript } from '../preference-script-Dm-LEoYX.js';
24
- import '../plate-BJ19iaVV.js';
24
+ import '../plate-iXwbupLU.js';
25
25
 
26
26
  declare function Accordion({ className, ...props }: React$1.ComponentProps<typeof Accordion$1.Root>): React$1.JSX.Element;
27
27
  declare function AccordionItem({ className, ...props }: React$1.ComponentProps<typeof Accordion$1.Item>): React$1.JSX.Element;
@@ -1,4 +1,4 @@
1
- import { b as Plate } from './plate-BJ19iaVV.js';
1
+ import { P as Plate } from './plate-iXwbupLU.js';
2
2
 
3
3
  /**
4
4
  * The plate this device is set to, and a way to change it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradalab/lyra",
3
- "version": "3.17.0",
3
+ "version": "3.18.0",
4
4
  "description": "Tradalab UI kit - shadcn (radix-lyra) primitives, composed components, and app shell for React 19 / Next 16 / Tailwind v4.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/use-plate.ts","../src/hooks/use-compact.ts"],"names":[],"mappings":";;;;AAaO,SAAS,QAAA,GAA0D;AACxE,EAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,iBAAiB,SAAS,CAAA;AAClD,EAAA,MAAM,QAAQ,MAAA,KAAW,IAAA,IAAQ,OAAA,CAAQ,MAAM,IAAI,MAAA,GAAS,IAAA;AAC5D,EAAA,gBAAA,CAAiB,cAAc,KAAK,CAAA;AACpC,EAAA,OAAO,CAAC,OAAO,KAAK,CAAA;AACtB;ACbO,SAAS,UAAA,GAAoD;AAClE,EAAA,MAAM,CAAC,MAAA,EAAQ,KAAK,CAAA,GAAI,iBAAiB,WAAW,CAAA;AACpD,EAAA,MAAM,UAAU,MAAA,KAAW,MAAA;AAC3B,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,CAAC,IAAA,KAAkB,KAAA,CAAM,IAAA,GAAO,MAAA,GAAS,IAAI,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACtF,EAAA,gBAAA,CAAiB,cAAA,EAAgB,OAAA,GAAU,MAAA,GAAS,IAAI,CAAA;AACxD,EAAA,OAAO,CAAC,SAAS,UAAU,CAAA;AAC7B","file":"chunk-AIULLZYM.js","sourcesContent":["\"use client\"\n\nimport { PLATE_KEY, useRootAttribute, useStoredSetting } from \"./device-setting.js\"\nimport { isPlate, type Plate } from \"./plate.js\"\n\n/**\n * The plate this device is set to, and a way to change it.\n *\n * A stored name that is no longer a plate - a rename, a downgrade to an older lyra - reads as no\n * plate. The alternative is an attribute no rule matches, which looks identical to the neutral\n * default on screen while the picker shows nothing selected at all, so the reader cannot tell that\n * their choice was dropped or get back to a known state.\n */\nexport function usePlate(): [Plate | null, (plate: Plate | null) => void] {\n const [stored, store] = useStoredSetting(PLATE_KEY)\n const plate = stored !== null && isPlate(stored) ? stored : null\n useRootAttribute(\"data-plate\", plate)\n return [plate, store]\n}\n","\"use client\"\n\nimport { useCallback } from \"react\"\nimport { COMPACT_KEY, useRootAttribute, useStoredSetting } from \"./device-setting.js\"\n\nexport function useCompact(): [boolean, (compact: boolean) => void] {\n const [stored, store] = useStoredSetting(COMPACT_KEY)\n const compact = stored === \"true\"\n const setCompact = useCallback((next: boolean) => store(next ? \"true\" : null), [store])\n useRootAttribute(\"data-compact\", compact ? \"true\" : null)\n return [compact, setCompact]\n}\n"]}