@regardio/react 0.6.0 → 0.7.3

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 (102) hide show
  1. package/dist/background-slideshow/index.d.mts +1 -3
  2. package/dist/blurry-gradient/index.d.mts +4 -5
  3. package/dist/button/index.d.mts +1 -1
  4. package/dist/carousel/index.d.mts +42 -8
  5. package/dist/carousel/index.mjs +11 -16
  6. package/dist/checkbox/index.d.mts +7 -16
  7. package/dist/checkbox-group/index.d.mts +3 -4
  8. package/dist/countdown/index.d.mts +1 -3
  9. package/dist/field/index.d.mts +40 -38
  10. package/dist/fieldset/index.d.mts +15 -14
  11. package/dist/form/index.d.mts +2 -3
  12. package/dist/generic-error/index.d.mts +20 -23
  13. package/dist/grid/index.d.mts +77 -1173
  14. package/dist/grid/index.mjs +5 -7
  15. package/dist/heading/index.d.mts +7 -11
  16. package/dist/heading/index.mjs +2 -3
  17. package/dist/highlight/index.d.mts +2 -3
  18. package/dist/hooks/use-current-route-data.d.mts +4 -4
  19. package/dist/hooks/use-current-route-data.mjs +3 -1
  20. package/dist/hooks/use-focus-search.mjs +2 -0
  21. package/dist/hooks/use-matches-data.d.mts +5 -5
  22. package/dist/hooks/use-matches-data.mjs +2 -0
  23. package/dist/hooks/use-media-query.d.mts +4 -4
  24. package/dist/hooks/use-media-query.mjs +2 -0
  25. package/dist/hooks/use-mobile.mjs +2 -0
  26. package/dist/hooks/use-nonce.d.mts +2 -4
  27. package/dist/hooks/use-orientation.d.mts +6 -6
  28. package/dist/hooks/use-orientation.mjs +2 -0
  29. package/dist/hooks/use-user.d.mts +23 -25
  30. package/dist/icon-button/index.d.mts +4 -5
  31. package/dist/if/index.d.mts +2 -4
  32. package/dist/if/index.mjs +4 -4
  33. package/dist/{index-Bm-tWhsb.d.mts → index-Bj5_XfEC.d.mts} +2 -3
  34. package/dist/{index-YT2CkvL6.d.mts → index-C_evL5vG.d.mts} +4 -5
  35. package/dist/input/index.d.mts +1 -1
  36. package/dist/link/index.d.mts +9 -11
  37. package/dist/link/index.mjs +3 -3
  38. package/dist/list/index.d.mts +39 -38
  39. package/dist/list/index.mjs +7 -7
  40. package/dist/markdown-container/index.d.mts +1 -1
  41. package/dist/markdown-container/index.mjs +1 -1
  42. package/dist/password-input/index.d.mts +4 -5
  43. package/dist/picture/index.d.mts +10 -10
  44. package/dist/protected-email/index.d.mts +9 -11
  45. package/dist/radio/index.d.mts +7 -16
  46. package/dist/radio-group/index.d.mts +3 -4
  47. package/dist/slider/index.d.mts +19 -41
  48. package/dist/switch/index.d.mts +7 -16
  49. package/dist/text/index.d.mts +2 -3
  50. package/dist/{text-CPlUND-Z.mjs → text-EQC4zJbE.mjs} +7 -13
  51. package/dist/toggle/index.d.mts +4 -38
  52. package/dist/utils/text/index.d.mts +5 -5
  53. package/dist/utils/text/index.mjs +1 -1
  54. package/package.json +170 -11
  55. package/src/background-slideshow/background-slideshow.tsx +1 -2
  56. package/src/blurry-gradient/blurry-gradient.tsx +1 -1
  57. package/src/button/button.stories.tsx +1 -1
  58. package/src/button/button.tsx +7 -1
  59. package/src/carousel/carousel-content.tsx +17 -14
  60. package/src/carousel/carousel-item.tsx +18 -18
  61. package/src/carousel/carousel-next.tsx +21 -16
  62. package/src/carousel/carousel-previous.tsx +21 -16
  63. package/src/carousel/carousel-root.tsx +91 -86
  64. package/src/checkbox/checkbox.tsx +14 -3
  65. package/src/checkbox-group/checkbox-group.tsx +1 -1
  66. package/src/countdown/countdown.tsx +1 -1
  67. package/src/field/field.stories.tsx +1 -1
  68. package/src/field/field.tsx +27 -6
  69. package/src/fieldset/fieldset.stories.tsx +1 -1
  70. package/src/fieldset/fieldset.tsx +14 -3
  71. package/src/form/form.stories.tsx +1 -1
  72. package/src/form/form.tsx +1 -1
  73. package/src/generic-error/generic-error.tsx +2 -3
  74. package/src/grid/grid-item.tsx +77 -36
  75. package/src/grid/grid-root.tsx +49 -22
  76. package/src/heading/heading.tsx +7 -3
  77. package/src/highlight/highlight.tsx +1 -1
  78. package/src/hooks/use-current-route-data.ts +4 -2
  79. package/src/hooks/use-focus-search.ts +3 -1
  80. package/src/hooks/use-matches-data.ts +2 -0
  81. package/src/hooks/use-media-query.ts +2 -0
  82. package/src/hooks/use-mobile.ts +3 -1
  83. package/src/hooks/use-nonce.ts +3 -3
  84. package/src/hooks/use-orientation.ts +2 -0
  85. package/src/hooks/use-user.tsx +3 -2
  86. package/src/icon-button/icon-button.tsx +1 -1
  87. package/src/if/if.tsx +3 -1
  88. package/src/input/input.stories.tsx +1 -1
  89. package/src/input/input.tsx +1 -1
  90. package/src/link/link.tsx +4 -3
  91. package/src/list/list-item.tsx +10 -13
  92. package/src/list/list-root-context.ts +3 -3
  93. package/src/list/list-root.tsx +10 -13
  94. package/src/password-input/password-input.tsx +1 -1
  95. package/src/protected-email/protected-email.tsx +6 -1
  96. package/src/radio/radio.tsx +14 -3
  97. package/src/radio-group/radio-group.tsx +5 -1
  98. package/src/slider/slider.tsx +29 -7
  99. package/src/switch/switch.tsx +14 -3
  100. package/src/text/text.tsx +6 -1
  101. package/src/toggle/toggle.tsx +3 -3
  102. package/src/utils/text/text.tsx +8 -16
@@ -51,7 +51,11 @@ export interface CheckboxIndicatorProps
51
51
  className?: string;
52
52
  }
53
53
 
54
- export const CheckboxRoot = ({ className, size = 'md', ...props }: CheckboxRootProps) => {
54
+ export const CheckboxRoot = ({
55
+ className,
56
+ size = 'md',
57
+ ...props
58
+ }: CheckboxRootProps): React.JSX.Element => {
55
59
  return (
56
60
  <BaseUICheckbox.Root
57
61
  className={checkboxRoot({
@@ -63,7 +67,11 @@ export const CheckboxRoot = ({ className, size = 'md', ...props }: CheckboxRootP
63
67
  );
64
68
  };
65
69
 
66
- export const CheckboxIndicator = ({ className, children, ...props }: CheckboxIndicatorProps) => {
70
+ export const CheckboxIndicator = ({
71
+ className,
72
+ children,
73
+ ...props
74
+ }: CheckboxIndicatorProps): React.JSX.Element => {
67
75
  return (
68
76
  <BaseUICheckbox.Indicator
69
77
  className={checkboxIndicator({ className })}
@@ -85,7 +93,10 @@ export const CheckboxIndicator = ({ className, children, ...props }: CheckboxInd
85
93
  );
86
94
  };
87
95
 
88
- export const Checkbox = {
96
+ export const Checkbox: {
97
+ Indicator: typeof CheckboxIndicator;
98
+ Root: typeof CheckboxRoot;
99
+ } = {
89
100
  Indicator: CheckboxIndicator,
90
101
  Root: CheckboxRoot,
91
102
  };
@@ -27,7 +27,7 @@ export const CheckboxGroup = ({
27
27
  className,
28
28
  orientation = 'vertical',
29
29
  ...props
30
- }: CheckboxGroupProps) => {
30
+ }: CheckboxGroupProps): React.JSX.Element => {
31
31
  return (
32
32
  <BaseUICheckboxGroup
33
33
  className={checkboxGroup({
@@ -3,7 +3,7 @@
3
3
  import { cn } from '@regardio/tailwind/utils';
4
4
  import { useEffect, useState } from 'react';
5
5
 
6
- export function Countdown() {
6
+ export function Countdown(): React.JSX.Element {
7
7
  const [timerValue, setTimerValue] = useState(0);
8
8
  const [isMounted, setIsMounted] = useState(false);
9
9
 
@@ -3,7 +3,7 @@ import { Checkbox } from '../checkbox';
3
3
  import { Input } from '../input';
4
4
  import { Field } from './field';
5
5
 
6
- const meta = {
6
+ const meta: Meta<typeof Field.Root> = {
7
7
  argTypes: {
8
8
  variant: {
9
9
  control: 'select',
@@ -93,7 +93,7 @@ export interface FieldItemProps extends ComponentProps<'div'> {
93
93
  children: ReactNode;
94
94
  }
95
95
 
96
- export const FieldRoot = ({ className, variant, ...props }: FieldRootProps) => {
96
+ export const FieldRoot = ({ className, variant, ...props }: FieldRootProps): React.JSX.Element => {
97
97
  return (
98
98
  <BaseUIField.Root
99
99
  className={fieldRoot({
@@ -105,7 +105,11 @@ export const FieldRoot = ({ className, variant, ...props }: FieldRootProps) => {
105
105
  );
106
106
  };
107
107
 
108
- export const FieldLabel = ({ className, variant, ...props }: FieldLabelProps) => {
108
+ export const FieldLabel = ({
109
+ className,
110
+ variant,
111
+ ...props
112
+ }: FieldLabelProps): React.JSX.Element => {
109
113
  return (
110
114
  <BaseUIField.Label
111
115
  className={fieldLabel({
@@ -117,7 +121,11 @@ export const FieldLabel = ({ className, variant, ...props }: FieldLabelProps) =>
117
121
  );
118
122
  };
119
123
 
120
- export const FieldDescription = ({ className, variant, ...props }: FieldDescriptionProps) => {
124
+ export const FieldDescription = ({
125
+ className,
126
+ variant,
127
+ ...props
128
+ }: FieldDescriptionProps): React.JSX.Element => {
121
129
  return (
122
130
  <BaseUIField.Description
123
131
  className={fieldDescription({
@@ -129,7 +137,7 @@ export const FieldDescription = ({ className, variant, ...props }: FieldDescript
129
137
  );
130
138
  };
131
139
 
132
- export const FieldError = ({ className, ...props }: FieldErrorProps) => {
140
+ export const FieldError = ({ className, ...props }: FieldErrorProps): React.JSX.Element => {
133
141
  return (
134
142
  <BaseUIField.Error
135
143
  className={fieldError({
@@ -140,7 +148,12 @@ export const FieldError = ({ className, ...props }: FieldErrorProps) => {
140
148
  );
141
149
  };
142
150
 
143
- export const FieldItem = ({ className, layout, children, ...props }: FieldItemProps) => {
151
+ export const FieldItem = ({
152
+ className,
153
+ layout,
154
+ children,
155
+ ...props
156
+ }: FieldItemProps): React.JSX.Element => {
144
157
  return (
145
158
  <div
146
159
  className={fieldItem({
@@ -154,7 +167,15 @@ export const FieldItem = ({ className, layout, children, ...props }: FieldItemPr
154
167
  );
155
168
  };
156
169
 
157
- export const Field = {
170
+ export const Field: {
171
+ Control: typeof BaseUIField.Control;
172
+ Description: typeof FieldDescription;
173
+ Error: typeof FieldError;
174
+ Item: typeof FieldItem;
175
+ Label: typeof FieldLabel;
176
+ Root: typeof FieldRoot;
177
+ Validity: typeof BaseUIField.Validity;
178
+ } = {
158
179
  Control: BaseUIField.Control,
159
180
  Description: FieldDescription,
160
181
  Error: FieldError,
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { Button } from '../button';
3
3
  import { Fieldset } from './fieldset';
4
4
 
5
- const meta = {
5
+ const meta: Meta<typeof Fieldset.Root> = {
6
6
  argTypes: {
7
7
  variant: {
8
8
  control: 'select',
@@ -45,7 +45,11 @@ export interface FieldsetLegendProps
45
45
  size?: FieldsetLegendSize;
46
46
  }
47
47
 
48
- export const FieldsetRoot = ({ className, variant, ...props }: FieldsetRootProps) => {
48
+ export const FieldsetRoot = ({
49
+ className,
50
+ variant,
51
+ ...props
52
+ }: FieldsetRootProps): React.JSX.Element => {
49
53
  return (
50
54
  <BaseUIFieldset.Root
51
55
  className={fieldsetRoot({
@@ -57,7 +61,11 @@ export const FieldsetRoot = ({ className, variant, ...props }: FieldsetRootProps
57
61
  );
58
62
  };
59
63
 
60
- export const FieldsetLegend = ({ className, size, ...props }: FieldsetLegendProps) => {
64
+ export const FieldsetLegend = ({
65
+ className,
66
+ size,
67
+ ...props
68
+ }: FieldsetLegendProps): React.JSX.Element => {
61
69
  return (
62
70
  <BaseUIFieldset.Legend
63
71
  className={fieldsetLegend({
@@ -69,7 +77,10 @@ export const FieldsetLegend = ({ className, size, ...props }: FieldsetLegendProp
69
77
  );
70
78
  };
71
79
 
72
- export const Fieldset = {
80
+ export const Fieldset: {
81
+ Legend: typeof FieldsetLegend;
82
+ Root: typeof FieldsetRoot;
83
+ } = {
73
84
  Legend: FieldsetLegend,
74
85
  Root: FieldsetRoot,
75
86
  };
@@ -4,7 +4,7 @@ import { Field } from '../field';
4
4
  import { Input } from '../input';
5
5
  import { Form } from './form';
6
6
 
7
- const meta = {
7
+ const meta: Meta<typeof Form> = {
8
8
  argTypes: {
9
9
  variant: {
10
10
  control: 'select',
package/src/form/form.tsx CHANGED
@@ -25,7 +25,7 @@ export interface FormProps extends Omit<ComponentProps<typeof BaseUIForm>, 'clas
25
25
  variant?: FormVariant;
26
26
  }
27
27
 
28
- export const Form = ({ className, variant, ...props }: FormProps) => {
28
+ export const Form = ({ className, variant, ...props }: FormProps): React.JSX.Element => {
29
29
  return (
30
30
  <BaseUIForm
31
31
  className={form({
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- import type { ReactElement } from 'react';
4
3
  import { isRouteErrorResponse, useRouteError } from 'react-router';
5
4
 
6
5
  /**
@@ -73,8 +72,8 @@ export function getErrorDescriptor(error: unknown): ErrorDescriptor {
73
72
  export function GenericError({
74
73
  renderMessage,
75
74
  }: {
76
- renderMessage?: (descriptor: ErrorDescriptor) => ReactElement;
77
- } = {}): ReactElement {
75
+ renderMessage?: (descriptor: ErrorDescriptor) => React.JSX.Element;
76
+ } = {}): React.JSX.Element {
78
77
  const error = useRouteError();
79
78
  const descriptor = getErrorDescriptor(error);
80
79
 
@@ -1,5 +1,40 @@
1
- import { tv, type VariantProps } from '@regardio/tailwind/utils';
2
- import { forwardRef, type HTMLAttributes } from 'react';
1
+ import { tv } from '@regardio/tailwind/utils';
2
+ import type { HTMLAttributes } from 'react';
3
+
4
+ const GRID_ITEM_VARIANTS = {
5
+ end: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 'auto'] as const,
6
+ rowSpan: [1, 2, 3, 4, 5, 6, 'full'] as const,
7
+ span: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'full'] as const,
8
+ spanLg: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'full'] as const,
9
+ spanMd: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'full'] as const,
10
+ spanSm: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'full'] as const,
11
+ spanXl: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'full'] as const,
12
+ spanXs: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'full'] as const,
13
+ start: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 'auto'] as const,
14
+ } as const;
15
+
16
+ interface GridItemVariantProps {
17
+ end?: (typeof GRID_ITEM_VARIANTS.end)[number];
18
+ rowSpan?: (typeof GRID_ITEM_VARIANTS.rowSpan)[number];
19
+ span?: (typeof GRID_ITEM_VARIANTS.span)[number];
20
+ spanLg?: (typeof GRID_ITEM_VARIANTS.spanLg)[number];
21
+ spanMd?: (typeof GRID_ITEM_VARIANTS.spanMd)[number];
22
+ spanSm?: (typeof GRID_ITEM_VARIANTS.spanSm)[number];
23
+ spanXl?: (typeof GRID_ITEM_VARIANTS.spanXl)[number];
24
+ spanXs?: (typeof GRID_ITEM_VARIANTS.spanXs)[number];
25
+ start?: (typeof GRID_ITEM_VARIANTS.start)[number];
26
+ }
27
+
28
+ interface GridItemSlotProps {
29
+ class?: string;
30
+ className?: string;
31
+ }
32
+
33
+ interface GridItemSlots {
34
+ root: (props?: GridItemSlotProps) => string;
35
+ }
36
+
37
+ type GridItemStyleFn = (props?: GridItemVariantProps) => GridItemSlots;
3
38
 
4
39
  const gridItem = tv({
5
40
  defaultVariants: {
@@ -141,48 +176,54 @@ const gridItem = tv({
141
176
  auto: { root: 'col-start-auto' },
142
177
  },
143
178
  },
144
- });
179
+ }) as GridItemStyleFn;
145
180
 
146
- export type GridItemVariants = VariantProps<typeof gridItem>;
181
+ export type GridItemVariants = GridItemVariantProps;
147
182
 
148
183
  export interface GridItemProps extends HTMLAttributes<HTMLDivElement>, GridItemVariants {
149
184
  classNames?: {
150
185
  root?: string;
151
186
  };
187
+ ref?: React.Ref<HTMLDivElement>;
152
188
  }
153
189
 
154
- export const GridItem = forwardRef<HTMLDivElement, GridItemProps>(
155
- (
156
- {
157
- children,
158
- className,
159
- classNames,
160
- span,
161
- spanXs,
162
- spanSm,
163
- spanMd,
164
- spanLg,
165
- spanXl,
166
- start,
167
- end,
168
- rowSpan,
169
- ...props
170
- },
171
- ref,
172
- ) => {
173
- const styles = gridItem({ end, rowSpan, span, spanLg, spanMd, spanSm, spanXl, spanXs, start });
190
+ export const GridItem = function GridItem({
191
+ children,
192
+ className,
193
+ classNames,
194
+ span,
195
+ spanXs,
196
+ spanSm,
197
+ spanMd,
198
+ spanLg,
199
+ spanXl,
200
+ start,
201
+ end,
202
+ rowSpan,
203
+ ref,
204
+ ...props
205
+ }: GridItemProps): React.JSX.Element {
206
+ const styles = gridItem({
207
+ end,
208
+ rowSpan,
209
+ span,
210
+ spanLg,
211
+ spanMd,
212
+ spanSm,
213
+ spanXl,
214
+ spanXs,
215
+ start,
216
+ });
174
217
 
175
- return (
176
- <div
177
- className={styles.root({ className: classNames?.root ?? className })}
178
- ref={ref}
179
- {...props}
180
- >
181
- {children}
182
- </div>
183
- );
184
- },
185
- );
186
- GridItem.displayName = 'GridItem';
218
+ return (
219
+ <div
220
+ className={styles.root({ className: classNames?.root ?? className })}
221
+ ref={ref}
222
+ {...props}
223
+ >
224
+ {children}
225
+ </div>
226
+ );
227
+ };
187
228
 
188
229
  export { gridItem };
@@ -1,5 +1,26 @@
1
- import { tv, type VariantProps } from '@regardio/tailwind/utils';
2
- import { createContext, forwardRef, type HTMLAttributes, useContext } from 'react';
1
+ import { tv } from '@regardio/tailwind/utils';
2
+ import { createContext, type HTMLAttributes, useContext } from 'react';
3
+
4
+ const GRID_VARIANTS = {
5
+ align: ['center', 'end', 'start', 'stretch'] as const,
6
+ flow: ['column', 'dense', 'row'] as const,
7
+ } as const;
8
+
9
+ interface GridVariantProps {
10
+ align?: (typeof GRID_VARIANTS.align)[number];
11
+ flow?: (typeof GRID_VARIANTS.flow)[number];
12
+ }
13
+
14
+ interface GridSlotProps {
15
+ class?: string;
16
+ className?: string;
17
+ }
18
+
19
+ interface GridSlots {
20
+ root: (props?: GridSlotProps) => string;
21
+ }
22
+
23
+ type GridStyleFn = (props?: GridVariantProps) => GridSlots;
3
24
 
4
25
  const grid = tv({
5
26
  defaultVariants: {
@@ -28,9 +49,9 @@ const grid = tv({
28
49
  row: { root: 'grid-auto-flow-row' },
29
50
  },
30
51
  },
31
- });
52
+ }) as GridStyleFn;
32
53
 
33
- type GridVariants = VariantProps<typeof grid>;
54
+ type GridVariants = GridVariantProps;
34
55
 
35
56
  interface GridContextValue {
36
57
  styles: ReturnType<typeof grid>;
@@ -38,7 +59,7 @@ interface GridContextValue {
38
59
 
39
60
  const GridContext = createContext<GridContextValue | null>(null);
40
61
 
41
- export function useGrid() {
62
+ export function useGrid(): GridContextValue {
42
63
  const context = useContext(GridContext);
43
64
  if (!context) {
44
65
  throw new Error('useGrid must be used within a <Grid.Root />');
@@ -50,23 +71,29 @@ export interface GridRootProps extends HTMLAttributes<HTMLDivElement>, GridVaria
50
71
  classNames?: {
51
72
  root?: string;
52
73
  };
74
+ ref?: React.Ref<HTMLDivElement>;
53
75
  }
54
76
 
55
- export const GridRoot = forwardRef<HTMLDivElement, GridRootProps>(
56
- ({ children, className, classNames, flow, align, ...props }, ref) => {
57
- const styles = grid({ align, flow });
77
+ export const GridRoot = function GridRoot({
78
+ children,
79
+ className,
80
+ classNames,
81
+ flow,
82
+ align,
83
+ ref,
84
+ ...props
85
+ }: GridRootProps): React.JSX.Element {
86
+ const styles = grid({ align, flow });
58
87
 
59
- return (
60
- <GridContext.Provider value={{ styles }}>
61
- <div
62
- className={styles.root({ className: classNames?.root ?? className })}
63
- ref={ref}
64
- {...props}
65
- >
66
- {children}
67
- </div>
68
- </GridContext.Provider>
69
- );
70
- },
71
- );
72
- GridRoot.displayName = 'GridRoot';
88
+ return (
89
+ <GridContext.Provider value={{ styles }}>
90
+ <div
91
+ className={styles.root({ className: classNames?.root ?? className })}
92
+ ref={ref}
93
+ {...props}
94
+ >
95
+ {children}
96
+ </div>
97
+ </GridContext.Provider>
98
+ );
99
+ };
@@ -30,7 +30,13 @@ export interface HeadingProps extends HTMLAttributes<HTMLHeadingElement> {
30
30
  locale?: string;
31
31
  }
32
32
 
33
- export const Heading = ({ as, children, className, level = 2, ...props }: HeadingProps) => {
33
+ export const Heading = function Heading({
34
+ as,
35
+ children,
36
+ className,
37
+ level = 2,
38
+ ...props
39
+ }: HeadingProps): React.JSX.Element {
34
40
  const word = lowerCaseSzett(shy(children));
35
41
  const Component: ElementType = as || `h${level}`;
36
42
 
@@ -48,5 +54,3 @@ export const Heading = ({ as, children, className, level = 2, ...props }: Headin
48
54
  </Component>
49
55
  );
50
56
  };
51
-
52
- Heading.displayName = 'Heading';
@@ -20,7 +20,7 @@ export interface HighlightProps extends ComponentProps<'mark'> {
20
20
  variant?: HighlightVariant;
21
21
  }
22
22
 
23
- export const Highlight = ({ children, className, variant }: HighlightProps) => {
23
+ export const Highlight = ({ children, className, variant }: HighlightProps): React.JSX.Element => {
24
24
  return (
25
25
  <mark
26
26
  className={highlight({
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { useMemo } from 'react';
2
4
  import { useLocation, useMatches } from 'react-router';
3
5
 
@@ -5,7 +7,7 @@ import { useLocation, useMatches } from 'react-router';
5
7
  * This base hook is used to access data related to the current route
6
8
  * @returns {JSON|undefined} The router data or undefined if not found
7
9
  */
8
- export function useCurrentRouteData<HeaderData>() {
10
+ export function useCurrentRouteData<HeaderData>(): HeaderData | undefined {
9
11
  const location = useLocation();
10
12
  const matchingRoutes = useMatches();
11
13
  const route = useMemo(() => {
@@ -14,5 +16,5 @@ export function useCurrentRouteData<HeaderData>() {
14
16
  });
15
17
  }, [matchingRoutes, location]);
16
18
 
17
- return route?.data || (undefined as HeaderData);
19
+ return (route?.loaderData as HeaderData) || undefined;
18
20
  }
@@ -1,8 +1,10 @@
1
+ 'use client';
2
+
1
3
  import type { RefObject } from 'react';
2
4
  import { useEffect } from 'react';
3
5
 
4
6
  /** Focuses on the field when user clicks cmd + k or ctrl + k */
5
- export function useFocusSearch(ref: RefObject<HTMLInputElement>) {
7
+ export function useFocusSearch(ref: RefObject<HTMLInputElement>): void {
6
8
  useEffect(() => {
7
9
  function handleKeyDown(event: KeyboardEvent) {
8
10
  if ((event.metaKey || event.ctrlKey) && event.key === 'k') {
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { useMemo } from 'react';
2
4
  import { useMatches } from 'react-router';
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { useEffect, useState } from 'react';
2
4
 
3
5
  /**
@@ -1,8 +1,10 @@
1
+ 'use client';
2
+
1
3
  import { useEffect, useState } from 'react';
2
4
 
3
5
  const MOBILE_BREAKPOINT = 768;
4
6
 
5
- export function useIsMobile() {
7
+ export function useIsMobile(): boolean {
6
8
  const [isMobile, setIsMobile] = useState<boolean | undefined>(undefined);
7
9
 
8
10
  useEffect(() => {
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { createContext, useContext } from 'react';
6
6
 
7
- export const NonceContext = createContext<string>('');
8
- export const NonceProvider = NonceContext.Provider;
7
+ export const NonceContext: React.Context<string> = createContext<string>('');
8
+ export const NonceProvider: React.Provider<string> = NonceContext.Provider;
9
9
 
10
- export const useNonce = () => useContext(NonceContext);
10
+ export const useNonce = (): string => useContext(NonceContext);
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { useEffect, useState } from 'react';
2
4
 
3
5
  /**
@@ -26,7 +26,8 @@ const defaultContextValue: UserContextType = {
26
26
  /**
27
27
  * Context for storing and accessing the current authenticated user
28
28
  */
29
- export const UserContext = createContext<UserContextType>(defaultContextValue);
29
+ export const UserContext: React.Context<UserContextType> =
30
+ createContext<UserContextType>(defaultContextValue);
30
31
 
31
32
  /**
32
33
  * Props for the UserContextProvider component
@@ -53,7 +54,7 @@ export function UserContextProvider({
53
54
  user,
54
55
  isLoading = false,
55
56
  children,
56
- }: UserContextProviderProps) {
57
+ }: UserContextProviderProps): React.JSX.Element {
57
58
  return <UserContext.Provider value={{ isLoading, user }}>{children}</UserContext.Provider>;
58
59
  }
59
60
 
@@ -36,7 +36,7 @@ export const IconButton = ({
36
36
  'aria-label': ariaLabel,
37
37
  className,
38
38
  ...props
39
- }: IconButtonProps) => {
39
+ }: IconButtonProps): React.JSX.Element => {
40
40
  // Use title for both title and aria-label if aria-label not provided
41
41
  const finalAriaLabel = ariaLabel || title;
42
42
  const finalTitle = title || ariaLabel;
package/src/if/if.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { useMemo } from 'react';
2
4
 
3
5
  type Condition<Value = unknown> = Value | false | null | undefined | 0 | '';
@@ -10,7 +12,7 @@ export function If<Value = unknown>({
10
12
  condition: Condition<Value>;
11
13
  children: React.ReactNode | ((value: Value) => React.ReactNode);
12
14
  fallback?: React.ReactNode;
13
- }>) {
15
+ }>): React.JSX.Element | null {
14
16
  return useMemo(() => {
15
17
  if (condition) {
16
18
  if (typeof children === 'function') {
@@ -1,7 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { Input } from './input';
3
3
 
4
- const meta = {
4
+ const meta: Meta<typeof Input> = {
5
5
  argTypes: {
6
6
  disabled: {
7
7
  control: 'boolean',
@@ -99,7 +99,7 @@ export interface InputProps extends Omit<ComponentProps<typeof BaseUIInput>, 'cl
99
99
  size?: InputSize;
100
100
  }
101
101
 
102
- export const Input = ({ className, variant, size, ...props }: InputProps) => {
102
+ export const Input = ({ className, variant, size, ...props }: InputProps): React.JSX.Element => {
103
103
  return (
104
104
  <BaseUIInput
105
105
  className={input({
package/src/link/link.tsx CHANGED
@@ -14,7 +14,8 @@ export type PathResolver = (routeKey: string) => string;
14
14
 
15
15
  const PathResolverContext = createContext<PathResolver | null>(null);
16
16
 
17
- export const PathResolverProvider = PathResolverContext.Provider;
17
+ export const PathResolverProvider: React.Provider<PathResolver | null> =
18
+ PathResolverContext.Provider;
18
19
 
19
20
  export function usePathResolver(): PathResolver | null {
20
21
  return useContext(PathResolverContext);
@@ -34,7 +35,7 @@ export const LinkBase = ({
34
35
  onClick,
35
36
  viewTransition = true,
36
37
  ...props
37
- }: LinkBaseProps) => {
38
+ }: LinkBaseProps): React.JSX.Element => {
38
39
  const pathResolver = usePathResolver();
39
40
 
40
41
  let path: string;
@@ -179,7 +180,7 @@ export const Link = ({
179
180
  variant,
180
181
  viewTransition,
181
182
  ...props
182
- }: LinkProps) => {
183
+ }: LinkProps): React.JSX.Element => {
183
184
  return (
184
185
  <LinkBase
185
186
  {...props}