@kalink-ui/seedly 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +12 -6
- package/src/components/box/box.css.ts +2 -2
- package/src/components/button/button.css.ts +45 -48
- package/src/components/button/button.tsx +11 -8
- package/src/components/button/index.ts +1 -1
- package/src/components/button-icon/button-icon.css.ts +90 -0
- package/src/components/button-icon/button-icon.tsx +23 -0
- package/src/components/button-icon/index.ts +1 -0
- package/src/components/card/card.tsx +7 -4
- package/src/components/card/index.ts +1 -1
- package/src/components/center/center.tsx +2 -2
- package/src/components/center/index.ts +1 -1
- package/src/components/cluster/cluster.css.ts +17 -0
- package/src/components/divider/divider.css.ts +11 -0
- package/src/components/divider/divider.tsx +11 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/form-field/form-field-context.ts +18 -0
- package/src/components/form-field/form-field-control.tsx +34 -0
- package/src/components/form-field/form-field-description.tsx +16 -0
- package/src/components/form-field/form-field-error.tsx +22 -0
- package/src/components/form-field/form-field-item-context.ts +6 -0
- package/src/components/form-field/form-field-item.tsx +28 -0
- package/src/components/form-field/form-field-label.tsx +27 -0
- package/src/components/form-field/form-field-message.tsx +33 -0
- package/src/components/form-field/form-field.css.ts +97 -0
- package/src/components/form-field/form-field.tsx +56 -0
- package/src/components/form-field/index.ts +9 -0
- package/src/components/frame/frame.css.ts +8 -8
- package/src/components/frame/frame.tsx +2 -6
- package/src/components/frame/index.ts +1 -1
- package/src/components/heading/heading.tsx +43 -8
- package/src/components/index.ts +27 -15
- package/src/components/input/index.ts +2 -0
- package/src/components/input/input-wrapper.tsx +58 -0
- package/src/components/input/input.css.ts +250 -0
- package/src/components/input/input.tsx +56 -0
- package/src/components/label/index.ts +1 -0
- package/src/components/label/label.css.ts +37 -0
- package/src/components/label/label.tsx +23 -0
- package/src/components/loader/index.ts +1 -0
- package/src/components/loader/loader.css.ts +109 -0
- package/src/components/loader/moon-loader.tsx +43 -0
- package/src/components/loader-overlay/index.ts +1 -0
- package/src/components/loader-overlay/loader-overlay.css.ts +35 -0
- package/src/components/loader-overlay/loader-overlay.tsx +28 -0
- package/src/components/menu/index.ts +2 -0
- package/src/components/menu/menu-item.css.ts +79 -0
- package/src/components/menu/menu-separator.css.ts +53 -0
- package/src/components/popover/index.ts +3 -0
- package/src/components/popover/popover-content.css.ts +107 -0
- package/src/components/popover/popover-content.tsx +78 -0
- package/src/components/popover/popover.tsx +6 -0
- package/src/components/scroll-area/index.ts +1 -0
- package/src/components/scroll-area/scroll-area.css.ts +72 -0
- package/src/components/scroll-area/scroll-area.tsx +39 -0
- package/src/components/scroll-area/scroll-bar.tsx +37 -0
- package/src/components/seed/seed.tsx +4 -4
- package/src/components/select/index.ts +5 -0
- package/src/components/select/select-content.css.ts +22 -0
- package/src/components/select/select-content.tsx +51 -0
- package/src/components/select/select-item.css.ts +24 -0
- package/src/components/select/select-item.tsx +24 -0
- package/src/components/select/select-root.tsx +14 -0
- package/src/components/select/select-trigger.css.ts +75 -0
- package/src/components/select/select-trigger.tsx +47 -0
- package/src/components/select/select.tsx +85 -0
- package/src/components/sheet/index.ts +5 -0
- package/src/components/sheet/sheet-content.css.ts +143 -0
- package/src/components/sheet/sheet-content.tsx +43 -0
- package/src/components/sheet/sheet-description.tsx +21 -0
- package/src/components/sheet/sheet-footer.tsx +15 -0
- package/src/components/sheet/sheet-header.css.ts +35 -0
- package/src/components/sheet/sheet-header.tsx +32 -0
- package/src/components/sheet/sheet-overlay.css.ts +43 -0
- package/src/components/sheet/sheet-overlay.tsx +14 -0
- package/src/components/sheet/sheet-title.tsx +31 -0
- package/src/components/sheet/sheet.tsx +8 -0
- package/src/components/stack/index.ts +1 -1
- package/src/components/stack/stack.tsx +2 -2
- package/src/components/text/index.ts +6 -0
- package/src/components/text/text.css.ts +31 -4
- package/src/components/text-field/index.ts +1 -0
- package/src/components/text-field/text-field.css.ts +3 -0
- package/src/components/text-field/text-field.tsx +64 -0
- package/src/components/textarea/index.ts +1 -0
- package/src/components/textarea/textarea-input.tsx +20 -0
- package/src/components/textarea/textarea.css.ts +10 -0
- package/src/components/textarea/textarea.tsx +69 -0
- package/src/styles/define-responsive-properties.ts +242 -0
- package/src/styles/extract-sprinkles-props.ts +29 -35
- package/src/styles/index.ts +9 -0
- package/src/styles/reset.css.ts +1 -0
- package/src/styles/visually-hidden.css.ts +21 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useFormFieldContext } from './form-field-context';
|
|
4
|
+
import { useFormFieldItemContext } from './form-field-item-context';
|
|
5
|
+
import { FormFieldMessage, FormFieldMessageProps } from './form-field-message';
|
|
6
|
+
|
|
7
|
+
export type FormFieldErrorProps = Omit<FormFieldMessageProps, 'id'>;
|
|
8
|
+
|
|
9
|
+
export function FormFieldError(props: FormFieldErrorProps) {
|
|
10
|
+
const { errors, hideErrorMessage } = useFormFieldContext();
|
|
11
|
+
const { id } = useFormFieldItemContext();
|
|
12
|
+
|
|
13
|
+
if (!errors || hideErrorMessage) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<FormFieldMessage id={`${id}-error`} error {...props}>
|
|
19
|
+
{errors}
|
|
20
|
+
</FormFieldMessage>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { PolymorphicComponentProps } from '@kalink-ui/dibbly';
|
|
4
|
+
import { ElementType, useId } from 'react';
|
|
5
|
+
|
|
6
|
+
import { useFormFieldContext } from './form-field-context';
|
|
7
|
+
import { FormFieldItemContextProvider } from './form-field-item-context';
|
|
8
|
+
import { formFieldStyle } from './form-field.css';
|
|
9
|
+
|
|
10
|
+
export type FormFieldItemProps<TUse extends ElementType = 'div'> =
|
|
11
|
+
PolymorphicComponentProps<TUse>;
|
|
12
|
+
|
|
13
|
+
export function FormFieldItem<TUse extends ElementType = 'div'>(
|
|
14
|
+
props: FormFieldItemProps<TUse>,
|
|
15
|
+
) {
|
|
16
|
+
const id = useId();
|
|
17
|
+
const { errors, disabled } = useFormFieldContext();
|
|
18
|
+
|
|
19
|
+
const { use: Comp = 'div', className, children, ...rest } = props;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<FormFieldItemContextProvider value={{ id }}>
|
|
23
|
+
<Comp className={formFieldStyle({ error: !!errors, disabled })} {...rest}>
|
|
24
|
+
{children}
|
|
25
|
+
</Comp>
|
|
26
|
+
</FormFieldItemContextProvider>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
|
|
3
|
+
import { visuallyHidden } from '../../styles';
|
|
4
|
+
import { Label, LabelProps } from '../label';
|
|
5
|
+
|
|
6
|
+
import { useFormFieldContext } from './form-field-context';
|
|
7
|
+
import { useFormFieldItemContext } from './form-field-item-context';
|
|
8
|
+
|
|
9
|
+
export function FormFieldLabel({
|
|
10
|
+
className,
|
|
11
|
+
children,
|
|
12
|
+
required,
|
|
13
|
+
...props
|
|
14
|
+
}: LabelProps) {
|
|
15
|
+
const { errors, hideLabel } = useFormFieldContext();
|
|
16
|
+
const { id } = useFormFieldItemContext();
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Label
|
|
20
|
+
className={clsx(visuallyHidden({ hidden: hideLabel }), className)}
|
|
21
|
+
htmlFor={id}
|
|
22
|
+
error={!!errors}
|
|
23
|
+
required={required}
|
|
24
|
+
{...props}
|
|
25
|
+
>{`${children}${required ? ' *' : ''}`}</Label>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { HTMLAttributes, useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
import { useFormFieldContext } from './form-field-context';
|
|
6
|
+
import { formFieldMessageStyle } from './form-field.css';
|
|
7
|
+
|
|
8
|
+
export type FormFieldMessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
9
|
+
id: string;
|
|
10
|
+
error?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function FormFieldMessage({
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
id,
|
|
17
|
+
error,
|
|
18
|
+
...props
|
|
19
|
+
}: FormFieldMessageProps) {
|
|
20
|
+
const { registerMessageId, unRegisterMessageId } = useFormFieldContext();
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
registerMessageId(id);
|
|
24
|
+
|
|
25
|
+
return () => unRegisterMessageId(id);
|
|
26
|
+
}, [id, registerMessageId, unRegisterMessageId]);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div id={id} className={formFieldMessageStyle} {...props}>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createGlobalTheme, style } from '@vanilla-extract/css';
|
|
2
|
+
import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
|
|
3
|
+
|
|
4
|
+
import { sys, typography } from '../../styles';
|
|
5
|
+
import { components } from '../../styles/layers.css';
|
|
6
|
+
|
|
7
|
+
export const formFieldVars = createGlobalTheme(':root', {
|
|
8
|
+
'@layer': components,
|
|
9
|
+
|
|
10
|
+
spacing: {
|
|
11
|
+
vertical: sys.spacing[2],
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
color: {
|
|
15
|
+
foreground: sys.color.foreground,
|
|
16
|
+
background: sys.color.background,
|
|
17
|
+
outline: sys.color.foreground,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const formFieldStyle = recipe({
|
|
22
|
+
base: {
|
|
23
|
+
'@layer': {
|
|
24
|
+
[components]: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
gap: formFieldVars.spacing.vertical,
|
|
28
|
+
|
|
29
|
+
width: '100%',
|
|
30
|
+
maxWidth: '100%',
|
|
31
|
+
|
|
32
|
+
color: formFieldVars.color.foreground,
|
|
33
|
+
|
|
34
|
+
selectors: {
|
|
35
|
+
'&:disabled, &:has(:disabled)': {
|
|
36
|
+
cursor: 'not-allowed',
|
|
37
|
+
|
|
38
|
+
vars: {
|
|
39
|
+
[formFieldVars.color.foreground]:
|
|
40
|
+
`color(from ${sys.color.foreground} srgb r g b / 0.38)`,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
'&[aria-invalid], &:has([aria-invalid])': {
|
|
45
|
+
vars: {
|
|
46
|
+
[formFieldVars.color.foreground]: 'red',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
variants: {
|
|
55
|
+
error: {
|
|
56
|
+
true: {
|
|
57
|
+
'@layer': {
|
|
58
|
+
[components]: {
|
|
59
|
+
vars: {
|
|
60
|
+
[formFieldVars.color.foreground]: 'red',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
disabled: {
|
|
68
|
+
true: {
|
|
69
|
+
'@layer': {
|
|
70
|
+
[components]: {
|
|
71
|
+
cursor: 'not-allowed',
|
|
72
|
+
|
|
73
|
+
vars: {
|
|
74
|
+
[formFieldVars.color.foreground]:
|
|
75
|
+
`color(from ${sys.color.foreground} srgb r g b / ${sys.state.muted.light})`,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const formFieldMessageStyle = style([
|
|
85
|
+
typography.body.small,
|
|
86
|
+
{
|
|
87
|
+
'@layer': {
|
|
88
|
+
[components]: {
|
|
89
|
+
display: 'block',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
export type FormFieldVariants = NonNullable<
|
|
96
|
+
RecipeVariants<typeof formFieldStyle>
|
|
97
|
+
>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
import { FormFieldContextProvider } from './form-field-context';
|
|
6
|
+
|
|
7
|
+
export interface FormFieldProps {
|
|
8
|
+
name: string;
|
|
9
|
+
label: string;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
errors?: string | null;
|
|
12
|
+
hideErrorMessage: boolean;
|
|
13
|
+
hideLabel: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function FormField({
|
|
18
|
+
name,
|
|
19
|
+
label,
|
|
20
|
+
children,
|
|
21
|
+
errors,
|
|
22
|
+
hideErrorMessage = false,
|
|
23
|
+
hideLabel = false,
|
|
24
|
+
disabled,
|
|
25
|
+
}: FormFieldProps) {
|
|
26
|
+
const [messageIds, setMessageIds] = useState<string[]>([]);
|
|
27
|
+
|
|
28
|
+
const registerMessageId = useCallback(
|
|
29
|
+
(id: string) => setMessageIds((ids) => [...new Set([...ids, id])]),
|
|
30
|
+
[setMessageIds],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const unRegisterMessageId = useCallback(
|
|
34
|
+
(id: string) =>
|
|
35
|
+
setMessageIds((ids) => ids.filter((current) => current !== id)),
|
|
36
|
+
[setMessageIds],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<FormFieldContextProvider
|
|
41
|
+
value={{
|
|
42
|
+
name,
|
|
43
|
+
registerMessageId,
|
|
44
|
+
unRegisterMessageId,
|
|
45
|
+
messageIds,
|
|
46
|
+
errors,
|
|
47
|
+
hideErrorMessage,
|
|
48
|
+
label,
|
|
49
|
+
disabled,
|
|
50
|
+
hideLabel,
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</FormFieldContextProvider>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { useFormFieldContext } from './form-field-context';
|
|
2
|
+
export { useFormFieldItemContext } from './form-field-item-context';
|
|
3
|
+
export { formFieldStyle } from './form-field.css';
|
|
4
|
+
export { FormFieldControl } from './form-field-control';
|
|
5
|
+
export { FormFieldDescription } from './form-field-description';
|
|
6
|
+
export { FormFieldError } from './form-field-error';
|
|
7
|
+
export { FormField } from './form-field';
|
|
8
|
+
export { FormFieldItem } from './form-field-item';
|
|
9
|
+
export { FormFieldLabel } from './form-field-label';
|
|
@@ -3,7 +3,7 @@ import { recipe, type RecipeVariants } from '@vanilla-extract/recipes';
|
|
|
3
3
|
|
|
4
4
|
import { components } from '../../styles/layers.css';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
export const frameRatioVar = createVar();
|
|
7
7
|
|
|
8
8
|
const baseFrame = style({
|
|
9
9
|
'@layer': {
|
|
@@ -14,7 +14,7 @@ const baseFrame = style({
|
|
|
14
14
|
|
|
15
15
|
overflow: 'hidden',
|
|
16
16
|
|
|
17
|
-
aspectRatio:
|
|
17
|
+
aspectRatio: frameRatioVar,
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
});
|
|
@@ -31,7 +31,7 @@ export const frameRecipe = recipe({
|
|
|
31
31
|
'@layer': {
|
|
32
32
|
[components]: {
|
|
33
33
|
vars: {
|
|
34
|
-
[
|
|
34
|
+
[frameRatioVar]: '1 / 1',
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
},
|
|
@@ -40,7 +40,7 @@ export const frameRecipe = recipe({
|
|
|
40
40
|
'@layer': {
|
|
41
41
|
[components]: {
|
|
42
42
|
vars: {
|
|
43
|
-
[
|
|
43
|
+
[frameRatioVar]: '3 / 2',
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
},
|
|
@@ -49,7 +49,7 @@ export const frameRecipe = recipe({
|
|
|
49
49
|
'@layer': {
|
|
50
50
|
[components]: {
|
|
51
51
|
vars: {
|
|
52
|
-
[
|
|
52
|
+
[frameRatioVar]: '2 / 3',
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
55
|
},
|
|
@@ -58,7 +58,7 @@ export const frameRecipe = recipe({
|
|
|
58
58
|
'@layer': {
|
|
59
59
|
[components]: {
|
|
60
60
|
vars: {
|
|
61
|
-
[
|
|
61
|
+
[frameRatioVar]: '4 / 3',
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
},
|
|
@@ -67,7 +67,7 @@ export const frameRecipe = recipe({
|
|
|
67
67
|
'@layer': {
|
|
68
68
|
[components]: {
|
|
69
69
|
vars: {
|
|
70
|
-
[
|
|
70
|
+
[frameRatioVar]: '16 / 9',
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
73
|
},
|
|
@@ -76,7 +76,7 @@ export const frameRecipe = recipe({
|
|
|
76
76
|
'@layer': {
|
|
77
77
|
[components]: {
|
|
78
78
|
vars: {
|
|
79
|
-
[
|
|
79
|
+
[frameRatioVar]: '9 / 16',
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
},
|
|
@@ -12,12 +12,8 @@ type FrameProps<TUse extends ElementType> = PolymorphicComponentProps<TUse> &
|
|
|
12
12
|
*
|
|
13
13
|
* https://every-layout.dev/layouts/frame
|
|
14
14
|
*/
|
|
15
|
-
export function Frame<TUse extends ElementType>({
|
|
16
|
-
ratio,
|
|
17
|
-
className,
|
|
18
|
-
...props
|
|
19
|
-
}: FrameProps<TUse>) {
|
|
20
|
-
const { use: Comp = 'div', ...rest } = props;
|
|
15
|
+
export function Frame<TUse extends ElementType>(props: FrameProps<TUse>) {
|
|
16
|
+
const { use: Comp = 'div', className, ratio, ...rest } = props;
|
|
21
17
|
|
|
22
18
|
return <Comp className={clsx(frameRecipe({ ratio }), className)} {...rest} />;
|
|
23
19
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Frame } from './frame';
|
|
2
|
-
export { frameRecipe, type FrameVariants } from './frame.css';
|
|
2
|
+
export { frameRecipe, frameRatioVar, type FrameVariants } from './frame.css';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
|
-
import { ElementType, ReactElement } from 'react';
|
|
2
|
+
import { ElementType, ReactElement, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
import { Spacing, TypographySize, TypographyVariant } from '../../styles';
|
|
5
5
|
import { ConditionalWrapper } from '../conditional-wrapper';
|
|
@@ -11,8 +11,12 @@ export type HeadingTypes = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
|
11
11
|
|
|
12
12
|
export type HeadingProps<TUse extends ElementType = 'h2'> = Omit<
|
|
13
13
|
TextProps<TUse>,
|
|
14
|
-
'variant' | 'children'
|
|
14
|
+
'variant' | 'children' | 'align'
|
|
15
15
|
> & {
|
|
16
|
+
align?: Extract<
|
|
17
|
+
Pick<TextProps<TUse>, 'align'>['align'],
|
|
18
|
+
'start' | 'center' | 'end'
|
|
19
|
+
>;
|
|
16
20
|
/**
|
|
17
21
|
* The typography used to render the text.
|
|
18
22
|
*/
|
|
@@ -36,7 +40,12 @@ export type HeadingProps<TUse extends ElementType = 'h2'> = Omit<
|
|
|
36
40
|
/**
|
|
37
41
|
* The text to render.
|
|
38
42
|
*/
|
|
39
|
-
children:
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The class to pass to the root element.
|
|
47
|
+
*/
|
|
48
|
+
rootClassName?: string;
|
|
40
49
|
};
|
|
41
50
|
|
|
42
51
|
const headingMapping: Record<
|
|
@@ -60,17 +69,21 @@ export function Heading<TUse extends HeadingTypes>({
|
|
|
60
69
|
spacing,
|
|
61
70
|
pretitle,
|
|
62
71
|
subtitle,
|
|
72
|
+
rootClassName,
|
|
73
|
+
ref,
|
|
63
74
|
...rest
|
|
64
75
|
}: HeadingProps<TUse>) {
|
|
65
76
|
return (
|
|
66
77
|
<ConditionalWrapper
|
|
78
|
+
ref={ref}
|
|
67
79
|
use={'hgroup'}
|
|
68
80
|
condition={!!pretitle || !!subtitle}
|
|
69
|
-
className={clsx(headingRoot({ align, spacing }))}
|
|
81
|
+
className={clsx(headingRoot({ align, spacing }), rootClassName)}
|
|
70
82
|
>
|
|
71
83
|
{pretitle}
|
|
72
84
|
|
|
73
85
|
<Text
|
|
86
|
+
{...(!pretitle && !subtitle && { ref })}
|
|
74
87
|
use={use}
|
|
75
88
|
align={align}
|
|
76
89
|
variant={variant ?? headingMapping[use].variant}
|
|
@@ -85,18 +98,40 @@ export function Heading<TUse extends HeadingTypes>({
|
|
|
85
98
|
);
|
|
86
99
|
}
|
|
87
100
|
|
|
101
|
+
type HeadingPretitleProps = Omit<TextProps<'p'>, 'children'> & {
|
|
102
|
+
children?: string | null;
|
|
103
|
+
};
|
|
104
|
+
|
|
88
105
|
Heading.Pretitle = function HeadingPretitle({
|
|
89
106
|
variant = 'title',
|
|
90
107
|
size = 'medium',
|
|
108
|
+
children,
|
|
91
109
|
...rest
|
|
92
|
-
}:
|
|
93
|
-
return
|
|
110
|
+
}: HeadingPretitleProps) {
|
|
111
|
+
return (
|
|
112
|
+
children && (
|
|
113
|
+
<Text use="p" variant={variant} size={size} {...rest}>
|
|
114
|
+
{children}
|
|
115
|
+
</Text>
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
type HeadingSubtitleProps = Omit<TextProps<'p'>, 'children'> & {
|
|
121
|
+
children?: string | null;
|
|
94
122
|
};
|
|
95
123
|
|
|
96
124
|
Heading.Subtitle = function HeadingSubtitle({
|
|
97
125
|
variant = 'title',
|
|
98
126
|
size = 'medium',
|
|
127
|
+
children,
|
|
99
128
|
...rest
|
|
100
|
-
}:
|
|
101
|
-
return
|
|
129
|
+
}: HeadingSubtitleProps) {
|
|
130
|
+
return (
|
|
131
|
+
children && (
|
|
132
|
+
<Text use="p" variant={variant} size={size} {...rest}>
|
|
133
|
+
{children}
|
|
134
|
+
</Text>
|
|
135
|
+
)
|
|
136
|
+
);
|
|
102
137
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
1
|
+
export * from './box';
|
|
2
|
+
export * from './button';
|
|
3
|
+
export * from './button-icon';
|
|
4
|
+
export * from './card';
|
|
5
|
+
export * from './center';
|
|
6
|
+
export * from './cluster';
|
|
7
|
+
export * from './conditional-wrapper';
|
|
8
|
+
export * from './cover';
|
|
9
|
+
export * from './divider';
|
|
10
|
+
export * from './form-field';
|
|
11
|
+
export * from './frame';
|
|
12
|
+
export * from './grid';
|
|
13
|
+
export * from './heading';
|
|
14
|
+
export * from './input';
|
|
15
|
+
export * from './label';
|
|
16
|
+
export * from './loader';
|
|
17
|
+
export * from './loader-overlay';
|
|
18
|
+
export * from './scroll-area';
|
|
19
|
+
export * from './seed';
|
|
20
|
+
export * from './select';
|
|
21
|
+
export * from './sheet';
|
|
22
|
+
export * from './sidebar';
|
|
23
|
+
export * from './stack';
|
|
24
|
+
export * from './switcher';
|
|
25
|
+
export * from './text';
|
|
26
|
+
export * from './text-field';
|
|
27
|
+
export * from './textarea';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import {
|
|
3
|
+
ComponentPropsWithRef,
|
|
4
|
+
ForwardedRef,
|
|
5
|
+
MouseEventHandler,
|
|
6
|
+
ReactNode,
|
|
7
|
+
RefObject,
|
|
8
|
+
useCallback,
|
|
9
|
+
} from 'react';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
inputAppearance,
|
|
13
|
+
InputAppearanceVariants,
|
|
14
|
+
inputWrapper,
|
|
15
|
+
} from './input.css';
|
|
16
|
+
|
|
17
|
+
export type InputWrapperProps = ComponentPropsWithRef<'div'> & {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
className?: string;
|
|
20
|
+
inputRef: RefObject<HTMLInputElement | null>;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
} & InputAppearanceVariants;
|
|
23
|
+
|
|
24
|
+
export function InputWrapper({
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
inputRef,
|
|
28
|
+
disabled,
|
|
29
|
+
variant = 'outlined',
|
|
30
|
+
size = 'md',
|
|
31
|
+
ref,
|
|
32
|
+
}: InputWrapperProps) {
|
|
33
|
+
const handleInputFocus = useCallback<MouseEventHandler<HTMLElement>>(
|
|
34
|
+
(e) => {
|
|
35
|
+
if (disabled || !inputRef?.current || e.target === inputRef.current) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
inputRef.current.click();
|
|
40
|
+
inputRef.current.focus();
|
|
41
|
+
},
|
|
42
|
+
[inputRef, disabled],
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
ref={ref as ForwardedRef<HTMLDivElement>}
|
|
48
|
+
className={clsx(
|
|
49
|
+
inputAppearance({ variant, size }),
|
|
50
|
+
inputWrapper,
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
53
|
+
onClick={handleInputFocus}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|