@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
package/src/list/list-item.tsx
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
type ComponentPropsWithoutRef,
|
|
5
|
-
type ElementType,
|
|
6
|
-
type ForwardedRef,
|
|
7
|
-
forwardRef,
|
|
8
|
-
type ReactNode,
|
|
9
|
-
} from 'react';
|
|
3
|
+
import type { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
|
|
10
4
|
import { useListRootContext } from './list-root-context';
|
|
11
5
|
|
|
12
6
|
type ListItemElement = 'li' | 'dd' | 'dt' | 'div' | 'span';
|
|
@@ -24,15 +18,18 @@ export type ListItemProps<T extends ListItemElement = 'li'> = Omit<
|
|
|
24
18
|
* The content of the list item.
|
|
25
19
|
*/
|
|
26
20
|
children?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Ref to the root element.
|
|
23
|
+
*/
|
|
24
|
+
ref?: React.Ref<HTMLElement>;
|
|
27
25
|
};
|
|
28
26
|
|
|
29
27
|
function ListItemImpl<T extends ListItemElement = 'li'>(
|
|
30
28
|
props: ListItemProps<T>,
|
|
31
|
-
|
|
32
|
-
) {
|
|
29
|
+
): React.JSX.Element {
|
|
33
30
|
const context = useListRootContext();
|
|
34
31
|
|
|
35
|
-
const { render, children, className, ...elementProps } = props;
|
|
32
|
+
const { render, children, className, ref, ...elementProps } = props;
|
|
36
33
|
|
|
37
34
|
const resolvedElement = render ?? context?.defaultItemElement ?? 'li';
|
|
38
35
|
const resolvedClassName = context?.defaultItemClassName
|
|
@@ -54,9 +51,9 @@ function ListItemImpl<T extends ListItemElement = 'li'>(
|
|
|
54
51
|
);
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
export const ListItem =
|
|
58
|
-
props: ListItemProps<T
|
|
59
|
-
) =>
|
|
54
|
+
export const ListItem = ListItemImpl as <T extends ListItemElement = 'li'>(
|
|
55
|
+
props: ListItemProps<T>,
|
|
56
|
+
) => React.JSX.Element;
|
|
60
57
|
|
|
61
58
|
export namespace ListItem {
|
|
62
59
|
export type Props<T extends ListItemElement = 'li'> = ListItemProps<T>;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
1
|
import { createContext, useContext } from 'react';
|
|
4
2
|
|
|
5
3
|
export interface ListRootContextValue {
|
|
@@ -14,7 +12,9 @@ export interface ListRootContextValue {
|
|
|
14
12
|
defaultItemClassName?: string;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
export const ListRootContext
|
|
15
|
+
export const ListRootContext: React.Context<ListRootContextValue | undefined> = createContext<
|
|
16
|
+
ListRootContextValue | undefined
|
|
17
|
+
>(undefined);
|
|
18
18
|
|
|
19
19
|
export function useListRootContext(): ListRootContextValue | undefined {
|
|
20
20
|
return useContext(ListRootContext);
|
package/src/list/list-root.tsx
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
type ComponentPropsWithoutRef,
|
|
5
|
-
type ElementType,
|
|
6
|
-
type ForwardedRef,
|
|
7
|
-
forwardRef,
|
|
8
|
-
type ReactNode,
|
|
9
|
-
useMemo,
|
|
10
|
-
} from 'react';
|
|
3
|
+
import { type ComponentPropsWithoutRef, type ElementType, type ReactNode, useMemo } from 'react';
|
|
11
4
|
import { ListRootContext, type ListRootContextValue } from './list-root-context';
|
|
12
5
|
|
|
13
6
|
type ListRootElement = 'ul' | 'ol' | 'dl' | 'div' | 'menu' | 'nav';
|
|
@@ -34,17 +27,21 @@ export type ListRootProps<T extends ListRootElement = 'ul'> = Omit<
|
|
|
34
27
|
* Default className to apply to all list items.
|
|
35
28
|
*/
|
|
36
29
|
defaultItemClassName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Ref to the root element.
|
|
32
|
+
*/
|
|
33
|
+
ref?: React.Ref<HTMLElement>;
|
|
37
34
|
};
|
|
38
35
|
|
|
39
36
|
function ListRootImpl<T extends ListRootElement = 'ul'>(
|
|
40
37
|
props: ListRootProps<T>,
|
|
41
|
-
|
|
42
|
-
) {
|
|
38
|
+
): React.JSX.Element {
|
|
43
39
|
const {
|
|
44
40
|
render = 'ul' as T,
|
|
45
41
|
children,
|
|
46
42
|
defaultItemElement,
|
|
47
43
|
defaultItemClassName,
|
|
44
|
+
ref,
|
|
48
45
|
...elementProps
|
|
49
46
|
} = props;
|
|
50
47
|
|
|
@@ -72,9 +69,9 @@ function ListRootImpl<T extends ListRootElement = 'ul'>(
|
|
|
72
69
|
);
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
export const ListRoot =
|
|
76
|
-
props: ListRootProps<T
|
|
77
|
-
) =>
|
|
72
|
+
export const ListRoot = ListRootImpl as <T extends ListRootElement = 'ul'>(
|
|
73
|
+
props: ListRootProps<T>,
|
|
74
|
+
) => React.JSX.Element;
|
|
78
75
|
|
|
79
76
|
export namespace ListRoot {
|
|
80
77
|
export type Props<T extends ListRootElement = 'ul'> = ListRootProps<T>;
|
|
@@ -60,7 +60,7 @@ export const PasswordInput = ({
|
|
|
60
60
|
inputVariant = 'default',
|
|
61
61
|
showToggle = true,
|
|
62
62
|
...props
|
|
63
|
-
}: PasswordInputProps) => {
|
|
63
|
+
}: PasswordInputProps): React.JSX.Element => {
|
|
64
64
|
const [showPassword, setShowPassword] = useState(false);
|
|
65
65
|
|
|
66
66
|
const togglePasswordVisibility = () => {
|
|
@@ -18,7 +18,12 @@ export interface ProtectedEmailProps {
|
|
|
18
18
|
* @param text - Optional display text (defaults to username(at)domain)
|
|
19
19
|
* @param className - Optional CSS class name
|
|
20
20
|
*/
|
|
21
|
-
export function ProtectedEmail({
|
|
21
|
+
export function ProtectedEmail({
|
|
22
|
+
username,
|
|
23
|
+
domain,
|
|
24
|
+
text,
|
|
25
|
+
className,
|
|
26
|
+
}: ProtectedEmailProps): React.JSX.Element {
|
|
22
27
|
const [mounted, setMounted] = useState(false);
|
|
23
28
|
|
|
24
29
|
// Only assemble the email on the client side
|
package/src/radio/radio.tsx
CHANGED
|
@@ -50,7 +50,11 @@ export interface RadioIndicatorProps
|
|
|
50
50
|
className?: string;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export const RadioRoot = ({
|
|
53
|
+
export const RadioRoot = ({
|
|
54
|
+
className,
|
|
55
|
+
size = 'md',
|
|
56
|
+
...props
|
|
57
|
+
}: RadioRootProps): React.JSX.Element => {
|
|
54
58
|
return (
|
|
55
59
|
<BaseUIRadio.Root
|
|
56
60
|
className={radioRoot({
|
|
@@ -62,7 +66,11 @@ export const RadioRoot = ({ className, size = 'md', ...props }: RadioRootProps)
|
|
|
62
66
|
);
|
|
63
67
|
};
|
|
64
68
|
|
|
65
|
-
export const RadioIndicator = ({
|
|
69
|
+
export const RadioIndicator = ({
|
|
70
|
+
className,
|
|
71
|
+
children,
|
|
72
|
+
...props
|
|
73
|
+
}: RadioIndicatorProps): React.JSX.Element => {
|
|
66
74
|
return (
|
|
67
75
|
<BaseUIRadio.Indicator
|
|
68
76
|
className={radioIndicator({ className })}
|
|
@@ -86,7 +94,10 @@ export const RadioIndicator = ({ className, children, ...props }: RadioIndicator
|
|
|
86
94
|
);
|
|
87
95
|
};
|
|
88
96
|
|
|
89
|
-
export const Radio
|
|
97
|
+
export const Radio: {
|
|
98
|
+
Indicator: typeof RadioIndicator;
|
|
99
|
+
Root: typeof RadioRoot;
|
|
100
|
+
} = {
|
|
90
101
|
Indicator: RadioIndicator,
|
|
91
102
|
Root: RadioRoot,
|
|
92
103
|
};
|
|
@@ -23,7 +23,11 @@ export interface RadioGroupProps
|
|
|
23
23
|
orientation?: RadioGroupOrientation;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const RadioGroup = ({
|
|
26
|
+
export const RadioGroup = ({
|
|
27
|
+
className,
|
|
28
|
+
orientation = 'vertical',
|
|
29
|
+
...props
|
|
30
|
+
}: RadioGroupProps): React.JSX.Element => {
|
|
27
31
|
return (
|
|
28
32
|
<BaseUIRadioGroup
|
|
29
33
|
className={radioGroup({
|
package/src/slider/slider.tsx
CHANGED
|
@@ -106,7 +106,11 @@ export interface SliderValueProps
|
|
|
106
106
|
className?: string;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export const SliderRoot = ({
|
|
109
|
+
export const SliderRoot = ({
|
|
110
|
+
className,
|
|
111
|
+
size = 'md',
|
|
112
|
+
...props
|
|
113
|
+
}: SliderRootProps): React.JSX.Element => {
|
|
110
114
|
return (
|
|
111
115
|
<BaseUISlider.Root
|
|
112
116
|
className={sliderRoot({
|
|
@@ -118,7 +122,7 @@ export const SliderRoot = ({ className, size = 'md', ...props }: SliderRootProps
|
|
|
118
122
|
);
|
|
119
123
|
};
|
|
120
124
|
|
|
121
|
-
export const SliderControl = ({ className, ...props }: SliderControlProps) => {
|
|
125
|
+
export const SliderControl = ({ className, ...props }: SliderControlProps): React.JSX.Element => {
|
|
122
126
|
return (
|
|
123
127
|
<BaseUISlider.Control
|
|
124
128
|
className={sliderControl({ className })}
|
|
@@ -127,7 +131,11 @@ export const SliderControl = ({ className, ...props }: SliderControlProps) => {
|
|
|
127
131
|
);
|
|
128
132
|
};
|
|
129
133
|
|
|
130
|
-
export const SliderTrack = ({
|
|
134
|
+
export const SliderTrack = ({
|
|
135
|
+
className,
|
|
136
|
+
size = 'md',
|
|
137
|
+
...props
|
|
138
|
+
}: SliderTrackProps): React.JSX.Element => {
|
|
131
139
|
return (
|
|
132
140
|
<BaseUISlider.Track
|
|
133
141
|
className={sliderTrack({
|
|
@@ -139,7 +147,10 @@ export const SliderTrack = ({ className, size = 'md', ...props }: SliderTrackPro
|
|
|
139
147
|
);
|
|
140
148
|
};
|
|
141
149
|
|
|
142
|
-
export const SliderIndicator = ({
|
|
150
|
+
export const SliderIndicator = ({
|
|
151
|
+
className,
|
|
152
|
+
...props
|
|
153
|
+
}: SliderIndicatorProps): React.JSX.Element => {
|
|
143
154
|
return (
|
|
144
155
|
<BaseUISlider.Indicator
|
|
145
156
|
className={sliderIndicator({ className })}
|
|
@@ -148,7 +159,11 @@ export const SliderIndicator = ({ className, ...props }: SliderIndicatorProps) =
|
|
|
148
159
|
);
|
|
149
160
|
};
|
|
150
161
|
|
|
151
|
-
export const SliderThumb = ({
|
|
162
|
+
export const SliderThumb = ({
|
|
163
|
+
className,
|
|
164
|
+
size = 'md',
|
|
165
|
+
...props
|
|
166
|
+
}: SliderThumbProps): React.JSX.Element => {
|
|
152
167
|
return (
|
|
153
168
|
<BaseUISlider.Thumb
|
|
154
169
|
className={sliderThumb({
|
|
@@ -160,7 +175,7 @@ export const SliderThumb = ({ className, size = 'md', ...props }: SliderThumbPro
|
|
|
160
175
|
);
|
|
161
176
|
};
|
|
162
177
|
|
|
163
|
-
export const SliderValue = ({ className, ...props }: SliderValueProps) => {
|
|
178
|
+
export const SliderValue = ({ className, ...props }: SliderValueProps): React.JSX.Element => {
|
|
164
179
|
return (
|
|
165
180
|
<BaseUISlider.Value
|
|
166
181
|
className={sliderValue({ className })}
|
|
@@ -169,7 +184,14 @@ export const SliderValue = ({ className, ...props }: SliderValueProps) => {
|
|
|
169
184
|
);
|
|
170
185
|
};
|
|
171
186
|
|
|
172
|
-
export const Slider
|
|
187
|
+
export const Slider: {
|
|
188
|
+
Control: typeof SliderControl;
|
|
189
|
+
Indicator: typeof SliderIndicator;
|
|
190
|
+
Root: typeof SliderRoot;
|
|
191
|
+
Thumb: typeof SliderThumb;
|
|
192
|
+
Track: typeof SliderTrack;
|
|
193
|
+
Value: typeof SliderValue;
|
|
194
|
+
} = {
|
|
173
195
|
Control: SliderControl,
|
|
174
196
|
Indicator: SliderIndicator,
|
|
175
197
|
Root: SliderRoot,
|
package/src/switch/switch.tsx
CHANGED
|
@@ -71,7 +71,11 @@ export interface SwitchThumbProps
|
|
|
71
71
|
size?: SwitchSize;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export const SwitchRoot = ({
|
|
74
|
+
export const SwitchRoot = ({
|
|
75
|
+
className,
|
|
76
|
+
size = 'md',
|
|
77
|
+
...props
|
|
78
|
+
}: SwitchRootProps): React.JSX.Element => {
|
|
75
79
|
return (
|
|
76
80
|
<BaseUISwitch.Root
|
|
77
81
|
className={switchRoot({
|
|
@@ -83,7 +87,11 @@ export const SwitchRoot = ({ className, size = 'md', ...props }: SwitchRootProps
|
|
|
83
87
|
);
|
|
84
88
|
};
|
|
85
89
|
|
|
86
|
-
export const SwitchThumb = ({
|
|
90
|
+
export const SwitchThumb = ({
|
|
91
|
+
className,
|
|
92
|
+
size = 'md',
|
|
93
|
+
...props
|
|
94
|
+
}: SwitchThumbProps): React.JSX.Element => {
|
|
87
95
|
return (
|
|
88
96
|
<BaseUISwitch.Thumb
|
|
89
97
|
className={switchThumb({
|
|
@@ -95,7 +103,10 @@ export const SwitchThumb = ({ className, size = 'md', ...props }: SwitchThumbPro
|
|
|
95
103
|
);
|
|
96
104
|
};
|
|
97
105
|
|
|
98
|
-
export const Switch
|
|
106
|
+
export const Switch: {
|
|
107
|
+
Root: typeof SwitchRoot;
|
|
108
|
+
Thumb: typeof SwitchThumb;
|
|
109
|
+
} = {
|
|
99
110
|
Root: SwitchRoot,
|
|
100
111
|
Thumb: SwitchThumb,
|
|
101
112
|
};
|
package/src/text/text.tsx
CHANGED
|
@@ -31,7 +31,12 @@ export interface TextProps extends ComponentProps<'p'> {
|
|
|
31
31
|
variant?: TextVariant;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export const Text = ({
|
|
34
|
+
export const Text = ({
|
|
35
|
+
children,
|
|
36
|
+
className,
|
|
37
|
+
variant,
|
|
38
|
+
themeColor,
|
|
39
|
+
}: TextProps): React.JSX.Element => {
|
|
35
40
|
return (
|
|
36
41
|
<div
|
|
37
42
|
className={text({
|
package/src/toggle/toggle.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { Toggle as BaseUIToggle } from '@base-ui/react/toggle';
|
|
|
2
2
|
import { tv } from '@regardio/tailwind/utils';
|
|
3
3
|
import type { ComponentProps, ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
-
const toggle = tv({
|
|
5
|
+
const toggle: ReturnType<typeof tv> = tv({
|
|
6
6
|
base: [
|
|
7
7
|
'inline-flex',
|
|
8
8
|
'items-center',
|
|
@@ -51,7 +51,7 @@ const toggle = tv({
|
|
|
51
51
|
],
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
|
-
});
|
|
54
|
+
} as const);
|
|
55
55
|
|
|
56
56
|
export type ToggleVariant = keyof typeof toggle.variants.variant;
|
|
57
57
|
export type ToggleSize = keyof typeof toggle.variants.size;
|
|
@@ -71,7 +71,7 @@ export const Toggle = ({
|
|
|
71
71
|
title,
|
|
72
72
|
children,
|
|
73
73
|
...props
|
|
74
|
-
}: ToggleProps) => {
|
|
74
|
+
}: ToggleProps): React.JSX.Element => {
|
|
75
75
|
return (
|
|
76
76
|
<BaseUIToggle
|
|
77
77
|
className={toggle({
|
package/src/utils/text/text.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { replaceShyInString, splitIntoSentences, typographicQuotes } from '@regardio/js/text';
|
|
2
|
-
import
|
|
2
|
+
import { cloneElement, Fragment, isValidElement, type ReactElement, type ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
export const lowerCaseSzett = (text: ReactNode | string, _returnType?: 'string'): ReactNode => {
|
|
5
5
|
// Helper function to process strings
|
|
@@ -24,21 +24,18 @@ export const lowerCaseSzett = (text: ReactNode | string, _returnType?: 'string')
|
|
|
24
24
|
return processString(text);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// Handle valid React elements
|
|
27
|
+
// Handle valid React elements
|
|
28
28
|
if (isValidElement(text)) {
|
|
29
29
|
const element = text as ReactElement<{ children?: ReactNode }>;
|
|
30
|
-
const { children
|
|
30
|
+
const { children } = element.props;
|
|
31
31
|
|
|
32
|
-
return cloneElement(element,
|
|
33
|
-
...props,
|
|
34
|
-
children: lowerCaseSzett(children),
|
|
35
|
-
});
|
|
32
|
+
return cloneElement(element, element.props, lowerCaseSzett(children));
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
// Handle arrays
|
|
39
36
|
if (Array.isArray(text)) {
|
|
40
37
|
return text.map((child, index) => (
|
|
41
|
-
<
|
|
38
|
+
<Fragment key={index.toString()}>{lowerCaseSzett(child as ReactNode)}</Fragment>
|
|
42
39
|
));
|
|
43
40
|
}
|
|
44
41
|
|
|
@@ -55,19 +52,14 @@ function replaceShyInReactNode(node: ReactNode): ReactNode {
|
|
|
55
52
|
|
|
56
53
|
if (isValidElement(node)) {
|
|
57
54
|
const element = node as ReactElement<{ children?: ReactNode }>;
|
|
58
|
-
const { children
|
|
55
|
+
const { children } = element.props;
|
|
59
56
|
|
|
60
|
-
return cloneElement(element,
|
|
61
|
-
...props,
|
|
62
|
-
children: replaceShyInReactNode(children),
|
|
63
|
-
});
|
|
57
|
+
return cloneElement(element, element.props, replaceShyInReactNode(children));
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
if (Array.isArray(node)) {
|
|
67
61
|
return node.map((child, index) => (
|
|
68
|
-
<
|
|
69
|
-
{replaceShyInReactNode(child as ReactNode)}
|
|
70
|
-
</React.Fragment>
|
|
62
|
+
<Fragment key={index.toString()}>{replaceShyInReactNode(child as ReactNode)}</Fragment>
|
|
71
63
|
));
|
|
72
64
|
}
|
|
73
65
|
|