@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.
- package/dist/background-slideshow/index.d.mts +1 -3
- package/dist/blurry-gradient/index.d.mts +4 -5
- package/dist/button/index.d.mts +1 -1
- package/dist/carousel/index.d.mts +42 -8
- package/dist/carousel/index.mjs +11 -16
- package/dist/checkbox/index.d.mts +7 -16
- package/dist/checkbox-group/index.d.mts +3 -4
- package/dist/countdown/index.d.mts +1 -3
- package/dist/field/index.d.mts +40 -38
- package/dist/fieldset/index.d.mts +15 -14
- package/dist/form/index.d.mts +2 -3
- package/dist/generic-error/index.d.mts +20 -23
- package/dist/grid/index.d.mts +77 -1173
- package/dist/grid/index.mjs +5 -7
- package/dist/heading/index.d.mts +7 -11
- package/dist/heading/index.mjs +2 -3
- package/dist/highlight/index.d.mts +2 -3
- package/dist/hooks/use-current-route-data.d.mts +4 -4
- package/dist/hooks/use-current-route-data.mjs +3 -1
- package/dist/hooks/use-focus-search.mjs +2 -0
- package/dist/hooks/use-matches-data.d.mts +5 -5
- package/dist/hooks/use-matches-data.mjs +2 -0
- package/dist/hooks/use-media-query.d.mts +4 -4
- package/dist/hooks/use-media-query.mjs +2 -0
- package/dist/hooks/use-mobile.mjs +2 -0
- package/dist/hooks/use-nonce.d.mts +2 -4
- package/dist/hooks/use-orientation.d.mts +6 -6
- package/dist/hooks/use-orientation.mjs +2 -0
- package/dist/hooks/use-user.d.mts +23 -25
- package/dist/icon-button/index.d.mts +4 -5
- package/dist/if/index.d.mts +2 -4
- package/dist/if/index.mjs +4 -4
- package/dist/{index-Bm-tWhsb.d.mts → index-Bj5_XfEC.d.mts} +2 -3
- package/dist/{index-YT2CkvL6.d.mts → index-C_evL5vG.d.mts} +4 -5
- package/dist/input/index.d.mts +1 -1
- package/dist/link/index.d.mts +9 -11
- package/dist/link/index.mjs +3 -3
- package/dist/list/index.d.mts +39 -38
- package/dist/list/index.mjs +7 -7
- package/dist/markdown-container/index.d.mts +1 -1
- package/dist/markdown-container/index.mjs +1 -1
- package/dist/password-input/index.d.mts +4 -5
- package/dist/picture/index.d.mts +10 -10
- package/dist/protected-email/index.d.mts +9 -11
- package/dist/radio/index.d.mts +7 -16
- package/dist/radio-group/index.d.mts +3 -4
- package/dist/slider/index.d.mts +19 -41
- package/dist/switch/index.d.mts +7 -16
- package/dist/text/index.d.mts +2 -3
- package/dist/{text-CPlUND-Z.mjs → text-EQC4zJbE.mjs} +7 -13
- package/dist/toggle/index.d.mts +4 -38
- package/dist/utils/text/index.d.mts +5 -5
- package/dist/utils/text/index.mjs +1 -1
- package/package.json +170 -11
- package/src/background-slideshow/background-slideshow.tsx +1 -2
- package/src/blurry-gradient/blurry-gradient.tsx +1 -1
- package/src/button/button.stories.tsx +1 -1
- package/src/button/button.tsx +7 -1
- package/src/carousel/carousel-content.tsx +17 -14
- package/src/carousel/carousel-item.tsx +18 -18
- package/src/carousel/carousel-next.tsx +21 -16
- package/src/carousel/carousel-previous.tsx +21 -16
- package/src/carousel/carousel-root.tsx +91 -86
- package/src/checkbox/checkbox.tsx +14 -3
- package/src/checkbox-group/checkbox-group.tsx +1 -1
- package/src/countdown/countdown.tsx +1 -1
- package/src/field/field.stories.tsx +1 -1
- package/src/field/field.tsx +27 -6
- package/src/fieldset/fieldset.stories.tsx +1 -1
- package/src/fieldset/fieldset.tsx +14 -3
- package/src/form/form.stories.tsx +1 -1
- package/src/form/form.tsx +1 -1
- package/src/generic-error/generic-error.tsx +2 -3
- package/src/grid/grid-item.tsx +77 -36
- package/src/grid/grid-root.tsx +49 -22
- package/src/heading/heading.tsx +7 -3
- package/src/highlight/highlight.tsx +1 -1
- package/src/hooks/use-current-route-data.ts +4 -2
- package/src/hooks/use-focus-search.ts +3 -1
- package/src/hooks/use-matches-data.ts +2 -0
- package/src/hooks/use-media-query.ts +2 -0
- package/src/hooks/use-mobile.ts +3 -1
- package/src/hooks/use-nonce.ts +3 -3
- package/src/hooks/use-orientation.ts +2 -0
- package/src/hooks/use-user.tsx +3 -2
- package/src/icon-button/icon-button.tsx +1 -1
- package/src/if/if.tsx +3 -1
- package/src/input/input.stories.tsx +1 -1
- package/src/input/input.tsx +1 -1
- package/src/link/link.tsx +4 -3
- package/src/list/list-item.tsx +10 -13
- package/src/list/list-root-context.ts +3 -3
- package/src/list/list-root.tsx +10 -13
- package/src/password-input/password-input.tsx +1 -1
- package/src/protected-email/protected-email.tsx +6 -1
- package/src/radio/radio.tsx +14 -3
- package/src/radio-group/radio-group.tsx +5 -1
- package/src/slider/slider.tsx +29 -7
- package/src/switch/switch.tsx +14 -3
- package/src/text/text.tsx +6 -1
- package/src/toggle/toggle.tsx +3 -3
- 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 = ({
|
|
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 = ({
|
|
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
|
};
|
|
@@ -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
|
|
package/src/field/field.tsx
CHANGED
|
@@ -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 = ({
|
|
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 = ({
|
|
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 = ({
|
|
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,
|
|
@@ -45,7 +45,11 @@ export interface FieldsetLegendProps
|
|
|
45
45
|
size?: FieldsetLegendSize;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export const FieldsetRoot = ({
|
|
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 = ({
|
|
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
|
};
|
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) =>
|
|
77
|
-
} = {}):
|
|
75
|
+
renderMessage?: (descriptor: ErrorDescriptor) => React.JSX.Element;
|
|
76
|
+
} = {}): React.JSX.Element {
|
|
78
77
|
const error = useRouteError();
|
|
79
78
|
const descriptor = getErrorDescriptor(error);
|
|
80
79
|
|
package/src/grid/grid-item.tsx
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
|
-
import { tv
|
|
2
|
-
import {
|
|
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 =
|
|
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 =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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 };
|
package/src/grid/grid-root.tsx
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import { tv
|
|
2
|
-
import { createContext,
|
|
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 =
|
|
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 =
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
+
};
|
package/src/heading/heading.tsx
CHANGED
|
@@ -30,7 +30,13 @@ export interface HeadingProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
|
30
30
|
locale?: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export const Heading = ({
|
|
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?.
|
|
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') {
|
package/src/hooks/use-mobile.ts
CHANGED
|
@@ -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(() => {
|
package/src/hooks/use-nonce.ts
CHANGED
|
@@ -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);
|
package/src/hooks/use-user.tsx
CHANGED
|
@@ -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
|
|
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') {
|
package/src/input/input.tsx
CHANGED
|
@@ -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
|
|
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}
|