sinwan-ui-core 1.5.1 → 2.0.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 (57) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +29 -1
  3. package/agents/internal/llms.controlled.txt +39 -0
  4. package/agents/internal/llms.form.txt +43 -0
  5. package/agents/internal/llms.ids.txt +46 -0
  6. package/agents/internal/llms.modal.txt +51 -0
  7. package/agents/llms.controls.txt +82 -0
  8. package/agents/llms.core.txt +73 -0
  9. package/agents/llms.direction.txt +51 -0
  10. package/agents/llms.dismiss.txt +79 -0
  11. package/agents/llms.floating.txt +47 -0
  12. package/agents/llms.index.txt +46 -0
  13. package/agents/llms.menu-sub.txt +66 -0
  14. package/agents/llms.menu.txt +94 -0
  15. package/agents/llms.overlay.txt +122 -0
  16. package/agents/llms.sinwan-preload.txt +33 -0
  17. package/agents/llms.slot.txt +51 -0
  18. package/agents/llms.theme.txt +59 -0
  19. package/agents/llms.txt +45 -0
  20. package/agents/llms.types.txt +39 -0
  21. package/dist/chunks/chunk-7c8ct63g.js +126 -0
  22. package/dist/chunks/{chunk-16d43dkc.js → chunk-assqp8wg.js} +86 -13
  23. package/dist/chunks/{chunk-saen52f0.js → chunk-eczk2z48.js} +26 -14
  24. package/dist/chunks/{chunk-f6hw8ash.js → chunk-fe933s8d.js} +2 -2
  25. package/dist/chunks/chunk-rxbeqj7g.js +65 -0
  26. package/dist/chunks/{chunk-0dsacv44.js → chunk-s84my297.js} +124 -27
  27. package/dist/chunks/{chunk-6bm550r5.js → chunk-w6wwgdg6.js} +205 -46
  28. package/dist/chunks/{chunk-bw9vp0y9.js → chunk-wjzadrvr.js} +54 -0
  29. package/dist/chunks/{chunk-zmvg5gy1.js → chunk-y1ag4hk4.js} +57 -9
  30. package/dist/controls.d.ts +4 -0
  31. package/dist/controls.js +4 -4
  32. package/dist/core.d.ts +8 -0
  33. package/dist/core.js +4 -2
  34. package/dist/direction.d.ts +7 -1
  35. package/dist/direction.js +1 -1
  36. package/dist/dismiss.d.ts +18 -0
  37. package/dist/dismiss.js +9 -3
  38. package/dist/floating.d.ts +1 -0
  39. package/dist/index.d.ts +2 -0
  40. package/dist/index.js +54 -26
  41. package/dist/internal/controlled.d.ts +1 -0
  42. package/dist/internal/form.d.ts +6 -0
  43. package/dist/internal/ids.d.ts +8 -0
  44. package/dist/internal/modal.d.ts +8 -0
  45. package/dist/menu-sub.d.ts +10 -2
  46. package/dist/menu-sub.js +3 -2
  47. package/dist/menu.d.ts +66 -0
  48. package/dist/menu.js +16 -0
  49. package/dist/overlay.d.ts +27 -2
  50. package/dist/overlay.js +6 -4
  51. package/dist/slot.d.ts +1 -0
  52. package/dist/slot.js +1 -1
  53. package/dist/theme.d.ts +30 -2
  54. package/dist/theme.js +5 -1
  55. package/dist/types.d.ts +1 -0
  56. package/package.json +16 -7
  57. package/dist/chunks/chunk-9whagkb6.js +0 -31
@@ -1,4 +1,6 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.direction.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  import { type InjectionKey, type SinwanNode } from "sinwan/component";
3
+ import { type Computed } from "sinwan/reactivity";
2
4
  export type Direction = "ltr" | "rtl";
3
5
  export type DirectionApi = {
4
6
  dir: {
@@ -12,4 +14,8 @@ export type DirectionProviderProps = {
12
14
  dir?: Direction;
13
15
  };
14
16
  export declare const DirectionProvider: import("sinwan/component").SinwanComponent<DirectionProviderProps>;
15
- export declare function useDirection(): Direction;
17
+ /**
18
+ * The direction of the nearest `DirectionProvider` (`ltr` without one), as a
19
+ * computed: read `dir.value` where it is used, so it follows the provider.
20
+ */
21
+ export declare function useDirection(): Computed<Direction>;
package/dist/direction.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  DirectionKey2,
3
3
  DirectionProvider2,
4
4
  useDirection2
5
- } from "./chunks/chunk-f6hw8ash.js";
5
+ } from "./chunks/chunk-fe933s8d.js";
6
6
  export {
7
7
  DirectionKey2 as DirectionKey,
8
8
  DirectionProvider2 as DirectionProvider,
package/dist/dismiss.d.ts CHANGED
@@ -1 +1,19 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.dismiss.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  export declare function isDismissExemptPointerTarget(target: EventTarget | null): boolean;
3
+ /**
4
+ * Adds an open layer on top of the stack; returns the function that removes
5
+ * it. For code outside components (use `useDismissLayer` in components).
6
+ */
7
+ export declare function pushDismissLayer(token: object): () => void;
8
+ /** Whether `token` is the most recently opened layer still open. */
9
+ export declare function isTopDismissLayer(token: object): boolean;
10
+ export type DismissLayer = {
11
+ /** This layer is open and no layer opened after it is still open. */
12
+ isTop(): boolean;
13
+ };
14
+ /**
15
+ * Registers a layer (dialog, popover, menu, select, tooltip) on the stack
16
+ * while `open()` is true, so one Escape closes only the topmost layer: check
17
+ * `layer.isTop()` in the layer's Escape handler. Call in a component body.
18
+ */
19
+ export declare function useDismissLayer(open: () => boolean): DismissLayer;
package/dist/dismiss.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import {
2
- isDismissExemptPointerTarget2
3
- } from "./chunks/chunk-9whagkb6.js";
2
+ isDismissExemptPointerTarget2,
3
+ pushDismissLayer2,
4
+ isTopDismissLayer2,
5
+ useDismissLayer2
6
+ } from "./chunks/chunk-rxbeqj7g.js";
4
7
  export {
5
- isDismissExemptPointerTarget2 as isDismissExemptPointerTarget
8
+ isDismissExemptPointerTarget2 as isDismissExemptPointerTarget,
9
+ isTopDismissLayer2 as isTopDismissLayer,
10
+ pushDismissLayer2 as pushDismissLayer,
11
+ useDismissLayer2 as useDismissLayer
6
12
  };
@@ -1,3 +1,4 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.floating.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  import { type Placement as FuiPlacement } from "@floating-ui/dom";
2
3
  import { type Computed, type Signal } from "sinwan/reactivity";
3
4
  type SignalOrComputed<T> = Signal<T> | Computed<T>;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.index.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  export * from "./controls";
2
3
  export * from "./core";
3
4
  export * from "./direction";
4
5
  export * from "./dismiss";
5
6
  export * from "./floating";
7
+ export * from "./menu";
6
8
  export * from "./menu-sub";
7
9
  export * from "./overlay";
8
10
  export * from "./slot";
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunks/chunk-7r6fwdyt.js";
5
5
  import {
6
6
  Slot2
7
- } from "./chunks/chunk-bw9vp0y9.js";
7
+ } from "./chunks/chunk-wjzadrvr.js";
8
8
  import {
9
9
  SinwanPortal2,
10
10
  signal2,
@@ -12,25 +12,9 @@ import {
12
12
  UiPortal2,
13
13
  useControllableState2,
14
14
  getFocusableElements2,
15
- trapFocus2
16
- } from "./chunks/chunk-saen52f0.js";
17
- import {
18
- toFloatingPlacement2,
19
- basePlacement2,
20
- readDocumentRtl2,
21
- createRectReference2,
22
- createSizeFloating2,
23
- createPointReference2,
24
- computePosition2,
25
- estimatePosition2,
26
- useAnchorPosition2,
27
- usePointPosition2
28
- } from "./chunks/chunk-6r59k5mb.js";
29
- import {
30
- DirectionKey2,
31
- DirectionProvider2,
32
- useDirection2
33
- } from "./chunks/chunk-f6hw8ash.js";
15
+ trapFocus2,
16
+ usePartId2
17
+ } from "./chunks/chunk-eczk2z48.js";
34
18
  import {
35
19
  For2,
36
20
  TabsKey2,
@@ -53,16 +37,44 @@ import {
53
37
  ToggleGroupKey2,
54
38
  ToggleGroupRoot2,
55
39
  ToggleGroupItem2
56
- } from "./chunks/chunk-0dsacv44.js";
40
+ } from "./chunks/chunk-s84my297.js";
41
+ import {
42
+ toFloatingPlacement2,
43
+ basePlacement2,
44
+ readDocumentRtl2,
45
+ createRectReference2,
46
+ createSizeFloating2,
47
+ createPointReference2,
48
+ computePosition2,
49
+ estimatePosition2,
50
+ useAnchorPosition2,
51
+ usePointPosition2
52
+ } from "./chunks/chunk-6r59k5mb.js";
53
+ import {
54
+ DirectionKey2,
55
+ DirectionProvider2,
56
+ useDirection2
57
+ } from "./chunks/chunk-fe933s8d.js";
58
+ import {
59
+ isDismissExemptPointerTarget2,
60
+ pushDismissLayer2,
61
+ isTopDismissLayer2,
62
+ useDismissLayer2
63
+ } from "./chunks/chunk-rxbeqj7g.js";
57
64
  import {
58
- isDismissExemptPointerTarget2
59
- } from "./chunks/chunk-9whagkb6.js";
65
+ MENU_ITEM_SELECTOR2,
66
+ getMenuItems2,
67
+ focusMenuItem2,
68
+ isKeyboardClick2,
69
+ handleMenuKeyDown2,
70
+ useMenuFocus2
71
+ } from "./chunks/chunk-7c8ct63g.js";
60
72
  import {
61
73
  createMenuSubApi2,
62
74
  createMenuSubTriggerHandlers2,
63
75
  isInsideMenuSubContent2,
64
76
  MenuSubContentLayer2
65
- } from "./chunks/chunk-zmvg5gy1.js";
77
+ } from "./chunks/chunk-y1ag4hk4.js";
66
78
  import {
67
79
  DialogKey2,
68
80
  DialogLabelsKey2,
@@ -82,17 +94,20 @@ import {
82
94
  PopoverTrigger2,
83
95
  PopoverContent2,
84
96
  TooltipKey2,
97
+ TooltipProviderKey2,
85
98
  TooltipProvider2,
86
99
  TooltipRoot2,
87
100
  TooltipTrigger2,
88
101
  TooltipContent2
89
- } from "./chunks/chunk-6bm550r5.js";
102
+ } from "./chunks/chunk-w6wwgdg6.js";
90
103
  import {
104
+ BUILT_IN_PALETTES2,
105
+ discoverPalettes2,
91
106
  ThemeKey2,
92
107
  ThemeProvider2,
93
108
  useTheme2,
94
109
  ThemeToggle2
95
- } from "./chunks/chunk-16d43dkc.js";
110
+ } from "./chunks/chunk-assqp8wg.js";
96
111
  export {
97
112
  AccordionContent2 as AccordionContent,
98
113
  AccordionItem2 as AccordionItem,
@@ -100,6 +115,7 @@ export {
100
115
  AccordionKey2 as AccordionKey,
101
116
  AccordionRoot2 as AccordionRoot,
102
117
  AccordionTrigger2 as AccordionTrigger,
118
+ BUILT_IN_PALETTES2 as BUILT_IN_PALETTES,
103
119
  CheckboxRoot2 as CheckboxRoot,
104
120
  CollapsibleContent2 as CollapsibleContent,
105
121
  CollapsibleKey2 as CollapsibleKey,
@@ -117,6 +133,7 @@ export {
117
133
  DirectionKey2 as DirectionKey,
118
134
  DirectionProvider2 as DirectionProvider,
119
135
  For2 as For,
136
+ MENU_ITEM_SELECTOR2 as MENU_ITEM_SELECTOR,
120
137
  MenuSubContentLayer2 as MenuSubContentLayer,
121
138
  PopoverContent2 as PopoverContent,
122
139
  PopoverKey2 as PopoverKey,
@@ -144,6 +161,7 @@ export {
144
161
  TooltipContent2 as TooltipContent,
145
162
  TooltipKey2 as TooltipKey,
146
163
  TooltipProvider2 as TooltipProvider,
164
+ TooltipProviderKey2 as TooltipProviderKey,
147
165
  TooltipRoot2 as TooltipRoot,
148
166
  TooltipTrigger2 as TooltipTrigger,
149
167
  UiPortal2 as UiPortal,
@@ -154,12 +172,19 @@ export {
154
172
  createPointReference2 as createPointReference,
155
173
  createRectReference2 as createRectReference,
156
174
  createSizeFloating2 as createSizeFloating,
175
+ discoverPalettes2 as discoverPalettes,
157
176
  estimatePosition2 as estimatePosition,
158
177
  flattenChildren2 as flattenChildren,
178
+ focusMenuItem2 as focusMenuItem,
159
179
  getFocusableElements2 as getFocusableElements,
180
+ getMenuItems2 as getMenuItems,
181
+ handleMenuKeyDown2 as handleMenuKeyDown,
160
182
  isDismissExemptPointerTarget2 as isDismissExemptPointerTarget,
161
183
  isInsideMenuSubContent2 as isInsideMenuSubContent,
184
+ isKeyboardClick2 as isKeyboardClick,
162
185
  isSinwanElement2 as isSinwanElement,
186
+ isTopDismissLayer2 as isTopDismissLayer,
187
+ pushDismissLayer2 as pushDismissLayer,
163
188
  readDocumentRtl2 as readDocumentRtl,
164
189
  signal2 as signal,
165
190
  toFloatingPlacement2 as toFloatingPlacement,
@@ -167,6 +192,9 @@ export {
167
192
  useAnchorPosition2 as useAnchorPosition,
168
193
  useControllableState2 as useControllableState,
169
194
  useDirection2 as useDirection,
195
+ useDismissLayer2 as useDismissLayer,
196
+ useMenuFocus2 as useMenuFocus,
197
+ usePartId2 as usePartId,
170
198
  usePointPosition2 as usePointPosition,
171
199
  useTheme2 as useTheme
172
200
  };
@@ -1,3 +1,4 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/internal/llms.controlled.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  /**
2
3
  * Whether a control is controlled through `key`: the prop is present, even
3
4
  * when its value is `undefined`. In development, a present prop that is
@@ -0,0 +1,6 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/internal/llms.form.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
2
+ /**
3
+ * Restores a control when its `<form>` is reset. `input` is the control's
4
+ * hidden input (set from its `ref`); without one (no `name`) nothing happens.
5
+ */
6
+ export declare function useFormReset(input: () => HTMLInputElement | null, reset: () => void): void;
@@ -0,0 +1,8 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/internal/llms.ids.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
2
+ /**
3
+ * An id for linking parts (`aria-controls`, `aria-labelledby`), from the
4
+ * component's position in the tree when it has one (server renders and
5
+ * `hydrate`: the same on both sides, so hydration keeps the links), else
6
+ * unique in the page (`mount`). Call in a component body.
7
+ */
8
+ export declare function treeId(prefix: string): string;
@@ -0,0 +1,8 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/internal/llms.modal.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
2
+ /**
3
+ * What a modal layer does to the rest of the page while it is open: the page
4
+ * does not scroll, and screen readers stay in the layer (`aria-hidden` on the
5
+ * other top-level elements, as Radix does). Nested modals stack.
6
+ */
7
+ /** Locks scroll and hides the rest of the page from assistive technology; returns the release. */
8
+ export declare function enterModal(layer: HTMLElement): () => void;
@@ -1,3 +1,4 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.menu-sub.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  import { type SinwanNode } from "sinwan/component";
2
3
  import { type Computed, type Signal } from "sinwan/reactivity";
3
4
  export type MenuSubApi = {
@@ -6,6 +7,8 @@ export type MenuSubApi = {
6
7
  triggerEl: Signal<HTMLElement | null>;
7
8
  cancelClose: () => void;
8
9
  requestClose: (delayMs?: number) => void;
10
+ /** Set by the trigger handlers: the sub was opened with a key, so its first item gets focus. */
11
+ openedByKeyboard: boolean;
9
12
  };
10
13
  export type MenuSubOptions = {
11
14
  controlled: boolean;
@@ -18,11 +21,16 @@ export type MenuSubOptions = {
18
21
  export type MenuSubTriggerHandlers = {
19
22
  onMouseEnter: () => void;
20
23
  onMouseLeave: () => void;
21
- onClick: () => void;
24
+ /** Pass the click event: a keyboard activation (Enter / Space) focuses the sub's first item. */
25
+ onClick: (event?: MouseEvent) => void;
22
26
  onKeyDown: (event: KeyboardEvent) => void;
23
27
  };
24
28
  export declare function createMenuSubApi(options: MenuSubOptions): MenuSubApi;
25
- /** Hover, click and ArrowRight open the sub (never toggle it closed); leaving starts the hover close delay. */
29
+ /**
30
+ * Hover, click and the arrow key toward the sub (ArrowRight, ArrowLeft in
31
+ * right-to-left layouts) open the sub (never toggle it closed); leaving starts
32
+ * the hover close delay.
33
+ */
26
34
  export declare function createMenuSubTriggerHandlers(api: MenuSubApi): MenuSubTriggerHandlers;
27
35
  export declare function isInsideMenuSubContent(target: EventTarget | null): boolean;
28
36
  export type MenuSubContentLayerProps = {
package/dist/menu-sub.js CHANGED
@@ -3,9 +3,10 @@ import {
3
3
  createMenuSubTriggerHandlers2,
4
4
  isInsideMenuSubContent2,
5
5
  MenuSubContentLayer2
6
- } from "./chunks/chunk-zmvg5gy1.js";
7
- import"./chunks/chunk-saen52f0.js";
6
+ } from "./chunks/chunk-y1ag4hk4.js";
7
+ import"./chunks/chunk-eczk2z48.js";
8
8
  import"./chunks/chunk-6r59k5mb.js";
9
+ import"./chunks/chunk-7c8ct63g.js";
9
10
  export {
10
11
  MenuSubContentLayer2 as MenuSubContentLayer,
11
12
  createMenuSubApi2 as createMenuSubApi,
package/dist/menu.d.ts ADDED
@@ -0,0 +1,66 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.menu.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
2
+ /**
3
+ * Keyboard behaviour shared by menus (dropdown, context menu, menubar and
4
+ * their submenus): focus moves into the menu when it opens and back to the
5
+ * trigger when it closes; Arrow keys, Home/End and a typed letter move
6
+ * between items; Tab closes the menu.
7
+ */
8
+ /** The roles a menu item can have. */
9
+ export declare const MENU_ITEM_SELECTOR = "[role=\"menuitem\"],[role=\"menuitemcheckbox\"],[role=\"menuitemradio\"]";
10
+ /**
11
+ * The enabled, visible items of `menu` itself (items of a nested
12
+ * `role="menu"` belong to that menu), in DOM order.
13
+ */
14
+ export declare function getMenuItems(menu: HTMLElement): HTMLElement[];
15
+ /** Focuses the first or last item of `menu`; false when it has none. */
16
+ export declare function focusMenuItem(menu: HTMLElement, which: "first" | "last"): boolean;
17
+ /** A click activated from the keyboard (Enter / Space on a button) has `detail` 0. */
18
+ export declare function isKeyboardClick(event: MouseEvent): boolean;
19
+ export type MenuKeyDownOptions = {
20
+ /** Called on Tab (the key is not prevented, so focus moves on). Close the menu here. */
21
+ onTab?: () => void;
22
+ };
23
+ /**
24
+ * Handles a keydown inside `menu`: ArrowDown / ArrowUp (wrapping), Home,
25
+ * End, a printable character (the next item starting with it), Tab
26
+ * (`onTab`). Returns true when it moved focus (the event is then
27
+ * prevented). Keys from a nested menu are left to that menu.
28
+ */
29
+ export declare function handleMenuKeyDown(event: KeyboardEvent, menu: HTMLElement, options?: MenuKeyDownOptions): boolean;
30
+ export type MenuFocusOptions = {
31
+ /** Whether the menu is open (read in an effect). */
32
+ open: () => boolean;
33
+ /** The menu element (`role="menu"`, `tabIndex={-1}`); null while unmounted. */
34
+ content: {
35
+ readonly value: HTMLElement | null;
36
+ };
37
+ /** The element focus returns to when the menu closes. */
38
+ trigger: {
39
+ readonly value: HTMLElement | null;
40
+ };
41
+ /** Closes the menu (used on Tab). */
42
+ close: () => void;
43
+ /** Also focus the first item when this returns true at open time (a submenu opened with a key). */
44
+ openedByKeyboard?: () => boolean;
45
+ /**
46
+ * Return focus to the trigger when focus was lost to `<body>` too (default
47
+ * true). Submenus pass false so a hover close never moves focus.
48
+ */
49
+ restoreFromBody?: boolean;
50
+ };
51
+ export type MenuFocusReturn = {
52
+ /**
53
+ * Call from the trigger's click (or the key that opens the menu): a
54
+ * keyboard activation focuses the first item, a pointer one focuses the
55
+ * menu itself so Arrow keys work without highlighting an item.
56
+ */
57
+ markOpenedByKeyboard: (event: MouseEvent | KeyboardEvent) => void;
58
+ /** The menu's keydown handler (`onkeydown` on the content element). */
59
+ onKeyDown: (event: KeyboardEvent) => void;
60
+ };
61
+ /**
62
+ * Focus management for one menu: focus moves into it once per opening (after
63
+ * the content mounts), and back to the trigger when it closes while focus is
64
+ * inside it. Call from a component.
65
+ */
66
+ export declare function useMenuFocus(options: MenuFocusOptions): MenuFocusReturn;
package/dist/menu.js ADDED
@@ -0,0 +1,16 @@
1
+ import {
2
+ MENU_ITEM_SELECTOR2,
3
+ getMenuItems2,
4
+ focusMenuItem2,
5
+ isKeyboardClick2,
6
+ handleMenuKeyDown2,
7
+ useMenuFocus2
8
+ } from "./chunks/chunk-7c8ct63g.js";
9
+ export {
10
+ MENU_ITEM_SELECTOR2 as MENU_ITEM_SELECTOR,
11
+ focusMenuItem2 as focusMenuItem,
12
+ getMenuItems2 as getMenuItems,
13
+ handleMenuKeyDown2 as handleMenuKeyDown,
14
+ isKeyboardClick2 as isKeyboardClick,
15
+ useMenuFocus2 as useMenuFocus
16
+ };
package/dist/overlay.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.overlay.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  import { type InjectionKey, type SinwanComponent, type SinwanNode } from "sinwan/component";
2
3
  import { signal, type Computed, type Signal } from "sinwan/reactivity";
3
4
  import { type Align, type Placement } from "./core";
@@ -11,12 +12,21 @@ export type OpenApi = {
11
12
  isHoverOpenBlocked: () => boolean;
12
13
  setPointerOverTrigger: (over: boolean) => void;
13
14
  };
14
- export declare const DialogKey: InjectionKey<OpenApi>;
15
+ /** A dialog's open state, and whether it is modal. */
16
+ export type DialogApi = OpenApi & {
17
+ modal: boolean;
18
+ };
19
+ export declare const DialogKey: InjectionKey<DialogApi>;
15
20
  export type DialogRootProps = {
16
21
  children?: SinwanNode;
17
22
  open?: boolean;
18
23
  defaultOpen?: boolean;
19
24
  onOpenChange?: (open: boolean) => void;
25
+ /**
26
+ * Modal (default): while open, the page does not scroll and screen readers
27
+ * stay in the dialog (the rest of the page is `aria-hidden`). Read at setup.
28
+ */
29
+ modal?: boolean;
20
30
  };
21
31
  /** Which title and description name the open dialog (`aria-labelledby` / `aria-describedby`). */
22
32
  export type DialogLabels = {
@@ -102,9 +112,22 @@ export declare const PopoverContent: SinwanComponent<{
102
112
  onmouseenter?: (event: MouseEvent) => void;
103
113
  onmouseleave?: (event: MouseEvent) => void;
104
114
  }>;
105
- export declare const TooltipKey: InjectionKey<OpenApi>;
115
+ /** A tooltip's open state, its delay and the id that describes its trigger. */
116
+ export type TooltipApi = OpenApi & {
117
+ /** Opens after the delay (pointer); `cancelOpen` drops a pending open. */
118
+ scheduleOpen: () => void;
119
+ cancelOpen: () => void;
120
+ /** The content's id, for the trigger's `aria-describedby` while open. */
121
+ contentId: string;
122
+ };
123
+ export declare const TooltipKey: InjectionKey<TooltipApi>;
124
+ /** The provider's default delay for the tooltips inside it. */
125
+ export declare const TooltipProviderKey: InjectionKey<{
126
+ delayDuration: number;
127
+ }>;
106
128
  export declare const TooltipProvider: SinwanComponent<{
107
129
  children?: SinwanNode;
130
+ /** Milliseconds between the pointer entering a trigger and the tooltip opening (default 0). Focus opens at once. */
108
131
  delayDuration?: number;
109
132
  }>;
110
133
  export declare const TooltipRoot: SinwanComponent<{
@@ -112,6 +135,8 @@ export declare const TooltipRoot: SinwanComponent<{
112
135
  open?: boolean;
113
136
  defaultOpen?: boolean;
114
137
  onOpenChange?: (open: boolean) => void;
138
+ /** Overrides the provider's `delayDuration`. */
139
+ delayDuration?: number;
115
140
  }>;
116
141
  export declare const TooltipTrigger: SinwanComponent<{
117
142
  children?: SinwanNode;
package/dist/overlay.js CHANGED
@@ -17,15 +17,16 @@ import {
17
17
  PopoverTrigger2,
18
18
  PopoverContent2,
19
19
  TooltipKey2,
20
+ TooltipProviderKey2,
20
21
  TooltipProvider2,
21
22
  TooltipRoot2,
22
23
  TooltipTrigger2,
23
24
  TooltipContent2
24
- } from "./chunks/chunk-6bm550r5.js";
25
- import"./chunks/chunk-bw9vp0y9.js";
25
+ } from "./chunks/chunk-w6wwgdg6.js";
26
+ import"./chunks/chunk-wjzadrvr.js";
26
27
  import"./chunks/chunk-7r6fwdyt.js";
27
- import"./chunks/chunk-9whagkb6.js";
28
- import"./chunks/chunk-saen52f0.js";
28
+ import"./chunks/chunk-rxbeqj7g.js";
29
+ import"./chunks/chunk-eczk2z48.js";
29
30
  import"./chunks/chunk-6r59k5mb.js";
30
31
  export {
31
32
  CollapsibleContent2 as CollapsibleContent,
@@ -48,6 +49,7 @@ export {
48
49
  TooltipContent2 as TooltipContent,
49
50
  TooltipKey2 as TooltipKey,
50
51
  TooltipProvider2 as TooltipProvider,
52
+ TooltipProviderKey2 as TooltipProviderKey,
51
53
  TooltipRoot2 as TooltipRoot,
52
54
  TooltipTrigger2 as TooltipTrigger
53
55
  };
package/dist/slot.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.slot.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  import type { SinwanNode } from "sinwan/component";
2
3
  /**
3
4
  * Merge Slot props onto a single Sinwan element child (asChild pattern).
package/dist/slot.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Slot2
3
- } from "./chunks/chunk-bw9vp0y9.js";
3
+ } from "./chunks/chunk-wjzadrvr.js";
4
4
  import"./chunks/chunk-7r6fwdyt.js";
5
5
  export {
6
6
  Slot2 as Slot
package/dist/theme.d.ts CHANGED
@@ -1,8 +1,24 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.theme.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  import { type InjectionKey, type SinwanNode } from "sinwan/component";
2
3
  import { type Signal } from "sinwan/reactivity";
3
4
  export type Theme = "light" | "dark" | "system";
4
5
  export type ResolvedTheme = "light" | "dark";
5
- export type Palette = "carzow" | "jomlaty" | "cazview" | "voltzig";
6
+ /** The palettes the sinwan-ui stylesheet ships. `carzow` is the `:root` default. */
7
+ export type BuiltInPalette = "carzow" | "jomlaty" | "cazview" | "voltzig";
8
+ /**
9
+ * A built-in palette, or a custom one: any name the app's stylesheet defines
10
+ * as `html[data-palette="name"]`. Built-in names keep their autocompletion.
11
+ */
12
+ export type Palette = BuiltInPalette | (string & Record<never, never>);
13
+ export declare const BUILT_IN_PALETTES: readonly BuiltInPalette[];
14
+ /**
15
+ * The palettes the page's stylesheets define, in stylesheet order: every
16
+ * `html[data-palette="name"]` selector names one, inside `@media`, `@supports`,
17
+ * `@layer` and `@import` too. `carzow` comes first when any is found, since
18
+ * the stylesheet's `:root` tokens are that palette. Empty when no stylesheet
19
+ * defines a palette (no DOM, CSS not loaded yet, or cross-origin CSS).
20
+ */
21
+ export declare function discoverPalettes(doc?: Document): Palette[];
6
22
  export type ThemeApi = {
7
23
  theme: Signal<Theme>;
8
24
  resolved: Signal<ResolvedTheme>;
@@ -10,7 +26,14 @@ export type ThemeApi = {
10
26
  themes: Theme[];
11
27
  palette: Signal<Palette>;
12
28
  setPalette: (palette: Palette) => void;
13
- palettes: Palette[];
29
+ /**
30
+ * The palettes `setPalette` accepts: the `palettes` prop, or the ones the
31
+ * stylesheets define (see `discoverPalettes`). A signal, so a palette
32
+ * picker follows `refreshPalettes`.
33
+ */
34
+ palettes: Signal<Palette[]>;
35
+ /** Scans the stylesheets again, for CSS loaded after the provider mounted. */
36
+ refreshPalettes: () => Palette[];
14
37
  };
15
38
  export declare const ThemeKey: InjectionKey<ThemeApi>;
16
39
  export type ThemeProviderProps = {
@@ -21,6 +44,11 @@ export type ThemeProviderProps = {
21
44
  defaultPalette?: Palette;
22
45
  forcedPalette?: Palette;
23
46
  paletteStorageKey?: string;
47
+ /**
48
+ * The palettes to allow. Omit it (or pass `[]`) to discover them from the
49
+ * stylesheets: a custom `html[data-palette="name"]` block in the app's CSS
50
+ * is then a palette like the built-in ones.
51
+ */
24
52
  palettes?: Palette[];
25
53
  disableTransitionOnChange?: boolean;
26
54
  enableSystem?: boolean;
package/dist/theme.js CHANGED
@@ -1,12 +1,16 @@
1
1
  import {
2
+ BUILT_IN_PALETTES2,
3
+ discoverPalettes2,
2
4
  ThemeKey2,
3
5
  ThemeProvider2,
4
6
  useTheme2,
5
7
  ThemeToggle2
6
- } from "./chunks/chunk-16d43dkc.js";
8
+ } from "./chunks/chunk-assqp8wg.js";
7
9
  export {
10
+ BUILT_IN_PALETTES2 as BUILT_IN_PALETTES,
8
11
  ThemeKey2 as ThemeKey,
9
12
  ThemeProvider2 as ThemeProvider,
10
13
  ThemeToggle2 as ThemeToggle,
14
+ discoverPalettes2 as discoverPalettes,
11
15
  useTheme2 as useTheme
12
16
  };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /** Agent docs: node_modules/sinwan-ui-core/agents/llms.types.txt (start at node_modules/sinwan-ui-core/agents/llms.txt). */
1
2
  import type { SinwanElement, SinwanNode } from "sinwan/component";
2
3
  export type DivProps = JSX.IntrinsicElements["div"];
3
4
  export type ButtonHTMLProps = JSX.IntrinsicElements["button"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinwan-ui-core",
3
- "version": "1.5.1",
3
+ "version": "2.0.0",
4
4
  "description": "Headless behaviour primitives for Sinwan UI components: overlays, floating positioning, dismiss layers, controls, slots, theme and direction.",
5
5
  "author": "Mohammed Ben Cheikh",
6
6
  "license": "MIT",
@@ -51,6 +51,12 @@
51
51
  "import": "./dist/floating.js",
52
52
  "default": "./dist/floating.js"
53
53
  },
54
+ "./menu": {
55
+ "types": "./dist/menu.d.ts",
56
+ "sinwan-ui-core:source": "./src/menu.ts",
57
+ "import": "./dist/menu.js",
58
+ "default": "./dist/menu.js"
59
+ },
54
60
  "./menu-sub": {
55
61
  "types": "./dist/menu-sub.d.ts",
56
62
  "sinwan-ui-core:source": "./src/menu-sub.tsx",
@@ -85,6 +91,7 @@
85
91
  "sideEffects": false,
86
92
  "files": [
87
93
  "dist",
94
+ "agents",
88
95
  "CHANGELOG.md"
89
96
  ],
90
97
  "keywords": [
@@ -100,19 +107,21 @@
100
107
  "test": "bun test --coverage ./__tests__",
101
108
  "typecheck": "bunx tsc -p tsconfig.json",
102
109
  "exports:check": "bun run scripts/export-map.ts --check",
103
- "exports:sync": "bun run scripts/export-map.ts --write"
110
+ "exports:sync": "bun run scripts/export-map.ts --write",
111
+ "check:agents": "bun run scripts/check-agents.ts",
112
+ "prepublishOnly": "bun run typecheck && bun run exports:check && bun run check:agents && bun run test && bun run build"
104
113
  },
105
114
  "dependencies": {
106
115
  "@floating-ui/dom": "^1.8.0"
107
116
  },
108
117
  "devDependencies": {
109
118
  "@types/bun": "latest",
110
- "bun-plugin-sinwan": "^1.0.1",
111
- "happy-dom": "^20.14.5",
112
- "sinwan": "^2.5.0",
119
+ "bun-plugin-sinwan": "^1.3.0",
120
+ "happy-dom": "^20.14.6",
121
+ "sinwan": ">=2.6.1 <3.0.0",
113
122
  "typescript": "^5.9.3"
114
123
  },
115
124
  "peerDependencies": {
116
- "sinwan": ">=2.5.0 <3.0.0"
125
+ "sinwan": ">=2.6.1 <3.0.0"
117
126
  }
118
- }
127
+ }