@voxel51/voodo 0.0.27 → 0.0.29

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 (68) hide show
  1. package/README.md +0 -41
  2. package/dist/components/Collapsible/Collapsible.d.ts +78 -0
  3. package/dist/components/Collapsible/Collapsible.d.ts.map +1 -0
  4. package/dist/components/Collapsible/index.d.ts +3 -0
  5. package/dist/components/Collapsible/index.d.ts.map +1 -0
  6. package/dist/components/Drawer/Drawer.d.ts +68 -0
  7. package/dist/components/Drawer/Drawer.d.ts.map +1 -0
  8. package/dist/components/Drawer/index.d.ts +3 -0
  9. package/dist/components/Drawer/index.d.ts.map +1 -0
  10. package/dist/components/Dropdown/Dropdown.d.ts +94 -0
  11. package/dist/components/Dropdown/Dropdown.d.ts.map +1 -0
  12. package/dist/components/Dropdown/DropdownTrigger.d.ts +26 -0
  13. package/dist/components/Dropdown/DropdownTrigger.d.ts.map +1 -0
  14. package/dist/components/Dropdown/index.d.ts +3 -0
  15. package/dist/components/Dropdown/index.d.ts.map +1 -0
  16. package/dist/components/Menu/MenuCheckItem.d.ts +35 -0
  17. package/dist/components/Menu/MenuCheckItem.d.ts.map +1 -0
  18. package/dist/components/Menu/MenuIconTextItem.d.ts +43 -0
  19. package/dist/components/Menu/MenuIconTextItem.d.ts.map +1 -0
  20. package/dist/components/Menu/MenuSectionTitle.d.ts +26 -0
  21. package/dist/components/Menu/MenuSectionTitle.d.ts.map +1 -0
  22. package/dist/components/Menu/MenuSeparator.d.ts +23 -0
  23. package/dist/components/Menu/MenuSeparator.d.ts.map +1 -0
  24. package/dist/components/Menu/MenuTextItem.d.ts +30 -0
  25. package/dist/components/Menu/MenuTextItem.d.ts.map +1 -0
  26. package/dist/components/Menu/index.d.ts +7 -0
  27. package/dist/components/Menu/index.d.ts.map +1 -0
  28. package/dist/components/Menu/styles.d.ts +8 -0
  29. package/dist/components/Menu/styles.d.ts.map +1 -0
  30. package/dist/components/Select/Select.d.ts.map +1 -1
  31. package/dist/components/index.d.ts +4 -0
  32. package/dist/components/index.d.ts.map +1 -1
  33. package/dist/index.cjs +6 -6
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +6857 -6225
  38. package/dist/index.js.map +1 -1
  39. package/dist/theme/index.d.ts +0 -1
  40. package/dist/theme/index.d.ts.map +1 -1
  41. package/dist/theme/tokens/index.d.ts +30 -0
  42. package/dist/theme/tokens/index.d.ts.map +1 -1
  43. package/dist/theme/tokens/transitions.d.ts +74 -0
  44. package/dist/theme/tokens/transitions.d.ts.map +1 -0
  45. package/dist/types/index.d.ts +1 -0
  46. package/dist/types/index.d.ts.map +1 -1
  47. package/dist/types/transition.d.ts +127 -0
  48. package/dist/types/transition.d.ts.map +1 -0
  49. package/dist/util/useControllableState.d.ts +44 -0
  50. package/dist/util/useControllableState.d.ts.map +1 -0
  51. package/dist/util/useDisclosure.d.ts +44 -0
  52. package/dist/util/useDisclosure.d.ts.map +1 -0
  53. package/dist/util/useDragDelta.d.ts +58 -0
  54. package/dist/util/useDragDelta.d.ts.map +1 -0
  55. package/dist/util/useElementSize.d.ts +29 -0
  56. package/dist/util/useElementSize.d.ts.map +1 -0
  57. package/dist/util/useLatest.d.ts +24 -0
  58. package/dist/util/useLatest.d.ts.map +1 -0
  59. package/dist/util/useResizableDrawer.d.ts +69 -0
  60. package/dist/util/useResizableDrawer.d.ts.map +1 -0
  61. package/dist/voodo.css +1 -1
  62. package/package.json +2 -6
  63. package/dist/theme/mui/components.d.ts +0 -9
  64. package/dist/theme/mui/components.d.ts.map +0 -1
  65. package/dist/theme/mui/index.d.ts +0 -3
  66. package/dist/theme/mui/index.d.ts.map +0 -1
  67. package/dist/theme/mui/theme-config.d.ts +0 -31
  68. package/dist/theme/mui/theme-config.d.ts.map +0 -1
@@ -1,3 +1,2 @@
1
- export * from './mui';
2
1
  export * from './tokens';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { transitions } from './transitions';
2
+ export { transitions };
1
3
  declare const _default: {
2
4
  colors: {
3
5
  common: {
@@ -192,6 +194,34 @@ declare const _default: {
192
194
  readonly lg: "1.5rem";
193
195
  readonly xl: "2rem";
194
196
  };
197
+ transitions: {
198
+ readonly duration: {
199
+ readonly instant: "0ms";
200
+ readonly fast: "100ms";
201
+ readonly normal: "200ms";
202
+ readonly moderate: "300ms";
203
+ readonly slow: "500ms";
204
+ readonly deliberate: "700ms";
205
+ };
206
+ readonly easing: {
207
+ readonly linear: "linear";
208
+ readonly in: "cubic-bezier(0.4, 0, 1, 1)";
209
+ readonly out: "cubic-bezier(0, 0, 0.2, 1)";
210
+ readonly "in-out": "cubic-bezier(0.4, 0, 0.2, 1)";
211
+ readonly spring: "cubic-bezier(0.34, 1.56, 0.64, 1)";
212
+ readonly sharp: "cubic-bezier(0.4, 0, 0.6, 1)";
213
+ };
214
+ readonly preset: {
215
+ readonly colors: "color 200ms cubic-bezier(0.4, 0, 0.2, 1), background-color 200ms cubic-bezier(0.4, 0, 0.2, 1), border-color 200ms cubic-bezier(0.4, 0, 0.2, 1), fill 200ms cubic-bezier(0.4, 0, 0.2, 1), stroke 200ms cubic-bezier(0.4, 0, 0.2, 1)";
216
+ readonly opacity: "opacity 200ms cubic-bezier(0.4, 0, 0.2, 1)";
217
+ readonly transform: "transform 200ms cubic-bezier(0, 0, 0.2, 1)";
218
+ readonly shadow: "box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1)";
219
+ readonly menu: "opacity 100ms cubic-bezier(0, 0, 0.2, 1), transform 100ms cubic-bezier(0, 0, 0.2, 1)";
220
+ readonly panel: "transform 300ms cubic-bezier(0, 0, 0.2, 1)";
221
+ readonly overlay: "opacity 200ms cubic-bezier(0.4, 0, 0.2, 1)";
222
+ readonly all: "all 200ms cubic-bezier(0.4, 0, 0.2, 1)";
223
+ };
224
+ };
195
225
  typography: {
196
226
  readonly fontFamily: {
197
227
  readonly sans: readonly ["Palanquin", "sans-serif"];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/theme/tokens/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wBAIE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/theme/tokens/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,WAAW,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvB,wBAKE"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Transition design tokens for the VOODO design system.
3
+ *
4
+ * Three layers:
5
+ * 1. `duration` — how long a transition takes
6
+ * 2. `easing` — the timing curve (how it accelerates / decelerates)
7
+ * 3. `preset` — pre-composed shorthand values for common UI patterns
8
+ *
9
+ * These are compiled into CSS custom properties by the generate-tailwind-theme
10
+ * script and consumed through the TypeScript helpers in `src/types/transition.ts`.
11
+ */
12
+ export declare const transitions: {
13
+ /**
14
+ * Duration tokens — semantic names for how long an animation takes.
15
+ *
16
+ * instant (0ms) Use for state that should feel truly immediate.
17
+ * fast (100ms) Micro-interactions: hover highlights, icon swaps.
18
+ * normal (200ms) Default: color, border, and opacity changes.
19
+ * moderate (300ms) Slightly heavier state changes: panel reveals, tooltips.
20
+ * slow (500ms) Deliberate motion: drawers, slide-in panels.
21
+ * deliberate(700ms) Page-level or dramatic transitions.
22
+ */
23
+ readonly duration: {
24
+ readonly instant: "0ms";
25
+ readonly fast: "100ms";
26
+ readonly normal: "200ms";
27
+ readonly moderate: "300ms";
28
+ readonly slow: "500ms";
29
+ readonly deliberate: "700ms";
30
+ };
31
+ /**
32
+ * Easing (timing-function) tokens.
33
+ *
34
+ * linear Constant speed. Mechanical feel; suits progress bars/loaders.
35
+ * in Starts slow, accelerates. Best for exits / elements leaving the screen.
36
+ * out Starts fast, decelerates. Best for entrances / elements arriving.
37
+ * in-out Slow start and end. Best for general UI state changes.
38
+ * spring Slight overshoot then settles. Adds energy to interactive elements.
39
+ * sharp Quick in, gradual out. Crisp, snappy feel for menus/overlays.
40
+ */
41
+ readonly easing: {
42
+ readonly linear: "linear";
43
+ readonly in: "cubic-bezier(0.4, 0, 1, 1)";
44
+ readonly out: "cubic-bezier(0, 0, 0.2, 1)";
45
+ readonly "in-out": "cubic-bezier(0.4, 0, 0.2, 1)";
46
+ readonly spring: "cubic-bezier(0.34, 1.56, 0.64, 1)";
47
+ readonly sharp: "cubic-bezier(0.4, 0, 0.6, 1)";
48
+ };
49
+ /**
50
+ * Pre-composed transition shorthands for common UI patterns.
51
+ * These bake in the right duration + easing for each context so
52
+ * component authors pick semantics, not numbers.
53
+ *
54
+ * colors Background, text, border, fill, and stroke color changes.
55
+ * opacity Fade in/out.
56
+ * transform Scale, translate, and rotate.
57
+ * shadow Box-shadow elevation changes.
58
+ * menu Dropdown / context menu appear and disappear.
59
+ * panel Drawers and slide-in sheets.
60
+ * overlay Modal backdrop fade.
61
+ * all General-purpose catch-all.
62
+ */
63
+ readonly preset: {
64
+ readonly colors: "color 200ms cubic-bezier(0.4, 0, 0.2, 1), background-color 200ms cubic-bezier(0.4, 0, 0.2, 1), border-color 200ms cubic-bezier(0.4, 0, 0.2, 1), fill 200ms cubic-bezier(0.4, 0, 0.2, 1), stroke 200ms cubic-bezier(0.4, 0, 0.2, 1)";
65
+ readonly opacity: "opacity 200ms cubic-bezier(0.4, 0, 0.2, 1)";
66
+ readonly transform: "transform 200ms cubic-bezier(0, 0, 0.2, 1)";
67
+ readonly shadow: "box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1)";
68
+ readonly menu: "opacity 100ms cubic-bezier(0, 0, 0.2, 1), transform 100ms cubic-bezier(0, 0, 0.2, 1)";
69
+ readonly panel: "transform 300ms cubic-bezier(0, 0, 0.2, 1)";
70
+ readonly overlay: "opacity 200ms cubic-bezier(0.4, 0, 0.2, 1)";
71
+ readonly all: "all 200ms cubic-bezier(0.4, 0, 0.2, 1)";
72
+ };
73
+ };
74
+ //# sourceMappingURL=transitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../../src/theme/tokens/transitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW;IACtB;;;;;;;;;OASG;;;;;;;;;IAUH;;;;;;;;;OASG;;;;;;;;;IAUH;;;;;;;;;;;;;OAaG;;;;;;;;;;;CAYK,CAAC"}
@@ -13,5 +13,6 @@ export * from './shadow';
13
13
  export * from './size';
14
14
  export * from './spacing';
15
15
  export * from './text';
16
+ export * from './transition';
16
17
  export * from './variant';
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Transition type system for the VOODO design system.
3
+ *
4
+ * Three enums map to the three layers of CSS custom properties generated
5
+ * from `src/theme/tokens/transitions.ts`:
6
+ *
7
+ * TransitionDuration → --transition-duration-{name}
8
+ * TransitionEasing → --transition-easing-{name}
9
+ * TransitionPreset → --transition-preset-{name}
10
+ *
11
+ * The helper functions return Tailwind arbitrary-value classes that
12
+ * reference those variables, keeping component code declarative:
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * // Individual duration + easing
17
+ * <div className={cn(
18
+ * transitionDuration(TransitionDuration.Normal),
19
+ * transitionEasing(TransitionEasing.Out),
20
+ * "transition-transform"
21
+ * )} />
22
+ *
23
+ * // Pre-composed preset
24
+ * <div style={{ transition: transitionPresetValue(TransitionPreset.Panel) }} />
25
+ * ```
26
+ */
27
+ /**
28
+ * Semantic names for how long a transition takes.
29
+ * Maps to `--transition-duration-{name}` CSS variables.
30
+ */
31
+ export declare enum TransitionDuration {
32
+ /** 0ms — truly immediate, no perceivable animation. */
33
+ Instant = "instant",
34
+ /** 100ms — micro-interactions: hover highlights, icon swaps. */
35
+ Fast = "fast",
36
+ /** 200ms — default for color, border, and opacity changes. */
37
+ Normal = "normal",
38
+ /** 300ms — panel reveals, tooltips, slightly heavier state changes. */
39
+ Moderate = "moderate",
40
+ /** 500ms — drawers, slide-in sheets. */
41
+ Slow = "slow",
42
+ /** 700ms — page-level or dramatic reveal transitions. */
43
+ Deliberate = "deliberate"
44
+ }
45
+ /**
46
+ * Timing-curve tokens that control how a transition accelerates.
47
+ * Maps to `--transition-easing-{name}` CSS variables.
48
+ */
49
+ export declare enum TransitionEasing {
50
+ /** Constant speed. Suits progress bars and loaders. */
51
+ Linear = "linear",
52
+ /** Starts slow, accelerates. Best for elements *leaving* the screen. */
53
+ In = "in",
54
+ /** Starts fast, decelerates. Best for elements *arriving* on screen. */
55
+ Out = "out",
56
+ /** Slow start and end. Best for general UI state changes. */
57
+ InOut = "in-out",
58
+ /** Slight overshoot then settles. Adds energy to interactive elements. */
59
+ Spring = "spring",
60
+ /** Quick in, gradual out. Crisp, snappy feel for menus and overlays. */
61
+ Sharp = "sharp"
62
+ }
63
+ /**
64
+ * Pre-composed transition shorthands for common UI patterns.
65
+ * Bakes in the right duration + easing so component authors pick semantics,
66
+ * not numbers. Maps to `--transition-preset-{name}` CSS variables.
67
+ */
68
+ export declare enum TransitionPreset {
69
+ /** Background, text, border, fill, and stroke color changes. */
70
+ Colors = "colors",
71
+ /** Fade in / fade out. */
72
+ Opacity = "opacity",
73
+ /** Scale, translate, and rotate. */
74
+ Transform = "transform",
75
+ /** Box-shadow elevation changes. */
76
+ Shadow = "shadow",
77
+ /** Dropdown / context menu appear and disappear. */
78
+ Menu = "menu",
79
+ /** Drawers and slide-in sheets. */
80
+ Panel = "panel",
81
+ /** Modal backdrop fade. */
82
+ Overlay = "overlay",
83
+ /** General-purpose catch-all. */
84
+ All = "all"
85
+ }
86
+ /**
87
+ * Returns a Tailwind `duration-[var(...)]` class for the given duration token.
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * <div className={cn("transition-colors", transitionDuration(TransitionDuration.Fast))} />
92
+ * // → "transition-colors duration-[var(--transition-duration-fast)]"
93
+ * ```
94
+ */
95
+ export declare function transitionDuration(duration: TransitionDuration): string;
96
+ /**
97
+ * Returns a Tailwind `ease-[var(...)]` class for the given easing token.
98
+ *
99
+ * @example
100
+ * ```tsx
101
+ * <div className={cn("transition-transform", transitionEasing(TransitionEasing.Out))} />
102
+ * // → "transition-transform ease-[var(--transition-easing-out)]"
103
+ * ```
104
+ */
105
+ export declare function transitionEasing(easing: TransitionEasing): string;
106
+ /**
107
+ * Returns a Tailwind `transition-[var(...)]` class for the given preset token.
108
+ * The preset encodes both the property list, duration, and easing in one token.
109
+ *
110
+ * @example
111
+ * ```tsx
112
+ * <div className={transitionPreset(TransitionPreset.Colors)} />
113
+ * // → "transition-[var(--transition-preset-colors)]"
114
+ * ```
115
+ */
116
+ export declare function transitionPreset(preset: TransitionPreset): string;
117
+ /**
118
+ * Returns the raw CSS `var(--transition-preset-{name})` string for use in
119
+ * `style` props or inline CSS where a Tailwind class is not appropriate.
120
+ *
121
+ * @example
122
+ * ```tsx
123
+ * <div style={{ transition: transitionPresetValue(TransitionPreset.Panel) }} />
124
+ * ```
125
+ */
126
+ export declare function transitionPresetValue(preset: TransitionPreset): string;
127
+ //# sourceMappingURL=transition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../src/types/transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,uDAAuD;IACvD,OAAO,YAAY;IACnB,gEAAgE;IAChE,IAAI,SAAS;IACb,8DAA8D;IAC9D,MAAM,WAAW;IACjB,uEAAuE;IACvE,QAAQ,aAAa;IACrB,wCAAwC;IACxC,IAAI,SAAS;IACb,yDAAyD;IACzD,UAAU,eAAe;CAC1B;AAED;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,uDAAuD;IACvD,MAAM,WAAW;IACjB,wEAAwE;IACxE,EAAE,OAAO;IACT,wEAAwE;IACxE,GAAG,QAAQ;IACX,6DAA6D;IAC7D,KAAK,WAAW;IAChB,0EAA0E;IAC1E,MAAM,WAAW;IACjB,wEAAwE;IACxE,KAAK,UAAU;CAChB;AAED;;;;GAIG;AACH,oBAAY,gBAAgB;IAC1B,gEAAgE;IAChE,MAAM,WAAW;IACjB,0BAA0B;IAC1B,OAAO,YAAY;IACnB,oCAAoC;IACpC,SAAS,cAAc;IACvB,oCAAoC;IACpC,MAAM,WAAW;IACjB,oDAAoD;IACpD,IAAI,SAAS;IACb,mCAAmC;IACnC,KAAK,UAAU;IACf,2BAA2B;IAC3B,OAAO,YAAY;IACnB,iCAAiC;IACjC,GAAG,QAAQ;CACZ;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAEvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAEjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAEjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAEtE"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Props for {@link useControllableState}.
3
+ *
4
+ * A component is "controlled" when `value` is defined and "uncontrolled"
5
+ * otherwise. In uncontrolled mode the hook owns the state and seeds it with
6
+ * `initializer`; in controlled mode the consumer owns the state and is
7
+ * responsible for updating `value` in response to `onChange`.
8
+ */
9
+ export type ControllableStateProps<T> = {
10
+ /** Lazily produces the initial value used when the hook is uncontrolled. */
11
+ initializer: () => T;
12
+ /** Invoked with the next value on every change, in both controlled and uncontrolled modes. */
13
+ onChange?: (value: T) => void;
14
+ /** When defined, switches the hook into controlled mode and uses this as the resolved value. */
15
+ value?: T;
16
+ };
17
+ /**
18
+ * Tuple of `[value, onChange]` returned by {@link useControllableState}, mirroring
19
+ * the shape of `useState`.
20
+ */
21
+ export type Controllable<T> = [value: T, onChange: (value: T) => void];
22
+ /**
23
+ * Hook for implementing components that may be either controlled or
24
+ * uncontrolled, following the same convention as native form inputs.
25
+ *
26
+ * - If `value` is `undefined`, the hook manages internal state seeded by
27
+ * `initializer` and updates it on every change.
28
+ * - If `value` is defined, the hook returns `value` as-is and never mutates
29
+ * internal state; the consumer is responsible for re-rendering with the
30
+ * next value.
31
+ *
32
+ * `onChange` (when provided) fires on every change in either mode.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * const [value, setValue] = useControllableState({
37
+ * initializer: () => defaultValue,
38
+ * onChange,
39
+ * value: controlledValue,
40
+ * });
41
+ * ```
42
+ */
43
+ export declare const useControllableState: <T>({ initializer, onChange, value, }: ControllableStateProps<T>) => Controllable<T>;
44
+ //# sourceMappingURL=useControllableState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../src/util/useControllableState.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC,CAAC;IACrB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,gGAAgG;IAChG,KAAK,CAAC,EAAE,CAAC,CAAC;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,mCAIrC,sBAAsB,CAAC,CAAC,CAAC,KAAG,YAAY,CAAC,CAAC,CAmB5C,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Options for {@link useDisclosure}.
3
+ *
4
+ * Provide `defaultOpen` for an uncontrolled disclosure, or `open` (with
5
+ * `onOpenChange`) for a controlled disclosure.
6
+ */
7
+ export interface UseDisclosureOptions {
8
+ /** Initial open state when uncontrolled. Default `true`. */
9
+ defaultOpen?: boolean;
10
+ /** When defined, switches the hook into controlled mode and uses this as the resolved open state. */
11
+ open?: boolean;
12
+ /** Invoked with the next open state on every change, in both controlled and uncontrolled modes. */
13
+ onOpenChange?: (open: boolean) => void;
14
+ }
15
+ /**
16
+ * Return value of {@link useDisclosure}.
17
+ */
18
+ export interface UseDisclosureReturn {
19
+ /** Current open state. */
20
+ open: boolean;
21
+ /** Flip the open state. In controlled mode this only fires `onOpenChange` and does not update internal state. */
22
+ toggle: () => void;
23
+ /** Set the open state. In controlled mode this only fires `onOpenChange` and does not update internal state. */
24
+ setOpen: (next: boolean) => void;
25
+ }
26
+ /**
27
+ * Hook for managing a boolean "open / closed" state, suitable for popovers,
28
+ * dialogs, accordions, and other disclosures.
29
+ *
30
+ * Supports both controlled and uncontrolled usage via {@link useControllableState}:
31
+ * pass `defaultOpen` for uncontrolled, or `open` (typically alongside
32
+ * `onOpenChange`) for controlled.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * // Uncontrolled
37
+ * const { open, toggle, setOpen } = useDisclosure({ defaultOpen: false });
38
+ *
39
+ * // Controlled
40
+ * const { open, toggle } = useDisclosure({ open: isOpen, onOpenChange: setIsOpen });
41
+ * ```
42
+ */
43
+ export declare function useDisclosure({ defaultOpen, open: controlledOpen, onOpenChange, }?: UseDisclosureOptions): UseDisclosureReturn;
44
+ //# sourceMappingURL=useDisclosure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDisclosure.d.ts","sourceRoot":"","sources":["../../src/util/useDisclosure.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,4DAA4D;IAC5D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qGAAqG;IACrG,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mGAAmG;IACnG,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0BAA0B;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,iHAAiH;IACjH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,gHAAgH;IAChH,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,WAAkB,EAClB,IAAI,EAAE,cAAc,EACpB,YAAY,GACb,GAAE,oBAAyB,GAAG,mBAAmB,CAUjD"}
@@ -0,0 +1,58 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Axis along which a drag delta is measured.
4
+ *
5
+ * - `"horizontal"` reports `clientX` deltas.
6
+ * - `"vertical"` reports `clientY` deltas.
7
+ */
8
+ export type DragAxis = "horizontal" | "vertical";
9
+ /**
10
+ * Options for {@link useDragDelta}.
11
+ */
12
+ export interface UseDragDeltaOptions {
13
+ /** Axis to measure the drag along. */
14
+ axis: DragAxis;
15
+ /** Invoked once when a drag begins (on pointer-down). */
16
+ onDragStart?: () => void;
17
+ /**
18
+ * Invoked on every pointer-move during a drag with the signed pixel delta
19
+ * from the drag start position. Positive values mean right (horizontal) or
20
+ * down (vertical).
21
+ */
22
+ onDelta: (delta: number) => void;
23
+ /** Invoked once when a drag ends (on pointer-up). */
24
+ onDragEnd?: () => void;
25
+ }
26
+ /**
27
+ * Return value of {@link useDragDelta}.
28
+ */
29
+ export interface UseDragDeltaReturn {
30
+ /** `true` while a drag is in progress (between pointer-down and pointer-up). */
31
+ isDragging: boolean;
32
+ /** Props to spread onto the drag handle element. */
33
+ handleProps: {
34
+ onPointerDown: (e: React.PointerEvent<HTMLElement>) => void;
35
+ onPointerMove: (e: React.PointerEvent<HTMLElement>) => void;
36
+ onPointerUp: () => void;
37
+ };
38
+ }
39
+ /**
40
+ * Hook that tracks a single-axis pointer drag and reports the running delta
41
+ * from the drag start position.
42
+ *
43
+ * Uses pointer capture, so the drag continues correctly even if the pointer
44
+ * leaves the handle element. The supplied callbacks may be inline; the hook
45
+ * routes them through {@link useLatest} so the returned `handleProps` are
46
+ * stable across renders.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * const { isDragging, handleProps } = useDragDelta({
51
+ * axis: "horizontal",
52
+ * onDelta: (delta) => setX((x) => x + delta),
53
+ * });
54
+ * return <div {...handleProps} />;
55
+ * ```
56
+ */
57
+ export declare function useDragDelta({ axis, onDragStart, onDelta, onDragEnd, }: UseDragDeltaOptions): UseDragDeltaReturn;
58
+ //# sourceMappingURL=useDragDelta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDragDelta.d.ts","sourceRoot":"","sources":["../../src/util/useDragDelta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAI7D;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,sCAAsC;IACtC,IAAI,EAAE,QAAQ,CAAC;IACf,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;;;OAIG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,WAAW,EAAE;QACX,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;QAC5D,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;QAC5D,WAAW,EAAE,MAAM,IAAI,CAAC;KACzB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,WAAW,EACX,OAAO,EACP,SAAS,GACV,EAAE,mBAAmB,GAAG,kBAAkB,CAwC1C"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Return value of {@link useElementSize}.
3
+ */
4
+ export interface UseElementSizeReturn {
5
+ /** Callback ref to attach to the element you want to measure. */
6
+ ref: (el: HTMLElement | null) => void;
7
+ /** Current width of the observed element in pixels. `0` before the ref attaches. */
8
+ width: number;
9
+ /** Current height of the observed element in pixels. `0` before the ref attaches. */
10
+ height: number;
11
+ }
12
+ /**
13
+ * Hook that tracks the pixel dimensions of a DOM element via
14
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver | ResizeObserver}.
15
+ *
16
+ * Attach the returned `ref` callback to any element; `width` and `height`
17
+ * update on mount and on every subsequent resize. The observer is
18
+ * automatically disconnected when the element is unmounted or replaced.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * function Panel() {
23
+ * const { ref, width, height } = useElementSize();
24
+ * return <div ref={ref}>Size: {width} × {height}</div>;
25
+ * }
26
+ * ```
27
+ */
28
+ export declare function useElementSize(): UseElementSizeReturn;
29
+ //# sourceMappingURL=useElementSize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useElementSize.d.ts","sourceRoot":"","sources":["../../src/util/useElementSize.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,iEAAiE;IACjE,GAAG,EAAE,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACtC,oFAAoF;IACpF,KAAK,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CAgBrD"}
@@ -0,0 +1,24 @@
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * Hook that returns a ref whose `.current` always points to the most recent
4
+ * value passed in.
5
+ *
6
+ * Useful for letting an otherwise-stable callback (e.g. one returned by
7
+ * `useCallback` with no dependencies) read fresh values without re-subscribing
8
+ * — typically a parent-supplied handler or a frequently-changing piece of
9
+ * state. The returned ref's identity is stable across renders.
10
+ *
11
+ * The assignment happens during render. Do not read `ref.current` during the
12
+ * same render in which the value is captured; only read it from event
13
+ * handlers, effects, or other deferred work.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const onChangeRef = useLatest(onChange);
18
+ * const handler = useCallback(() => {
19
+ * onChangeRef.current?.(nextValue);
20
+ * }, []);
21
+ * ```
22
+ */
23
+ export declare function useLatest<T>(value: T): RefObject<T>;
24
+ //# sourceMappingURL=useLatest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLatest.d.ts","sourceRoot":"","sources":["../../src/util/useLatest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAInD"}
@@ -0,0 +1,69 @@
1
+ import { default as React } from 'react';
2
+ import { UseDisclosureOptions, UseDisclosureReturn } from './useDisclosure';
3
+ import { DragAxis } from './useDragDelta';
4
+ export type { DragAxis };
5
+ /**
6
+ * Options for {@link useResizableDrawer}.
7
+ *
8
+ * Extends {@link UseDisclosureOptions} so the drawer's open state can be
9
+ * controlled or uncontrolled in the same way as {@link useDisclosure}.
10
+ */
11
+ export interface UseResizableDrawerOptions extends UseDisclosureOptions {
12
+ /** Axis the drawer resizes along. `"horizontal"` for left/right drawers, `"vertical"` for top/bottom. */
13
+ axis: DragAxis;
14
+ /** Initial drawer size in pixels, also used as the restore target after closing. */
15
+ defaultSize: number;
16
+ /** Minimum drawer size in pixels while open. */
17
+ minSize: number;
18
+ /** Maximum drawer size in pixels. */
19
+ maxSize: number;
20
+ /** Size at which a drag triggers close. Defaults to 0. */
21
+ closeThreshold?: number;
22
+ /** Flip the delta sign — use for right-side and bottom-side handles. */
23
+ invert?: boolean;
24
+ /** Invoked with the new size on every drag-induced resize (not on open/close-only changes). */
25
+ onSizeChange?: (size: number) => void;
26
+ }
27
+ /**
28
+ * Return value of {@link useResizableDrawer}. Extends {@link UseDisclosureReturn}
29
+ * with size and drag state.
30
+ */
31
+ export interface UseResizableDrawerReturn extends UseDisclosureReturn {
32
+ /** Current drawer size in pixels. Reflects the last committed size even while closed. */
33
+ size: number;
34
+ /** `true` while the user is actively dragging the resize handle. */
35
+ isDragging: boolean;
36
+ /** Props to spread onto the drag handle element. */
37
+ dragHandleProps: {
38
+ onPointerDown: (e: React.PointerEvent<HTMLElement>) => void;
39
+ onPointerMove: (e: React.PointerEvent<HTMLElement>) => void;
40
+ onPointerUp: () => void;
41
+ };
42
+ }
43
+ /**
44
+ * Hook which models a drawer that can be opened, closed, and resized by
45
+ * dragging a handle.
46
+ *
47
+ * Behavior:
48
+ * - Dragging below `closeThreshold` (default `0`) closes the drawer.
49
+ * - Dragging above `closeThreshold` while closed reopens the drawer.
50
+ * - Sizes are clamped to `[minSize, maxSize]` while open.
51
+ * - `toggle()` restores the last dragged size when reopening.
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * const { open, size, toggle, dragHandleProps } = useResizableDrawer({
56
+ * axis: "horizontal",
57
+ * defaultSize: 320,
58
+ * minSize: 200,
59
+ * maxSize: 600,
60
+ * });
61
+ * return (
62
+ * <aside style={{ width: open ? size : 0 }}>
63
+ * <div {...dragHandleProps} />
64
+ * </aside>
65
+ * );
66
+ * ```
67
+ */
68
+ export declare function useResizableDrawer({ axis, defaultSize, minSize, maxSize, closeThreshold, invert, onSizeChange, ...disclosureOptions }: UseResizableDrawerOptions): UseResizableDrawerReturn;
69
+ //# sourceMappingURL=useResizableDrawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResizableDrawer.d.ts","sourceRoot":"","sources":["../../src/util/useResizableDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAGxD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE,yGAAyG;IACzG,IAAI,EAAE,QAAQ,CAAC;IACf,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+FAA+F;IAC/F,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,UAAU,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,eAAe,EAAE;QACf,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;QAC5D,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;QAC5D,WAAW,EAAE,MAAM,IAAI,CAAC;KACzB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,WAAW,EACX,OAAO,EACP,OAAO,EACP,cAAkB,EAClB,MAAc,EACd,YAAY,EACZ,GAAG,iBAAiB,EACrB,EAAE,yBAAyB,GAAG,wBAAwB,CA0EtD"}