@cdx-ui/components 0.0.1-alpha.35 → 0.0.1-alpha.37
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/lib/commonjs/components/{Form/FormLabelRoot.js → Field/FieldLabel.js} +4 -4
- package/lib/commonjs/components/Field/FieldLabel.js.map +1 -0
- package/lib/commonjs/components/{Form/FormLabelRoot.web.js → Field/FieldLabel.web.js} +9 -5
- package/lib/commonjs/components/Field/FieldLabel.web.js.map +1 -0
- package/lib/commonjs/components/Field/index.js +158 -0
- package/lib/commonjs/components/Field/index.js.map +1 -0
- package/lib/commonjs/components/Field/styles.js +16 -0
- package/lib/commonjs/components/Field/styles.js.map +1 -0
- package/lib/commonjs/components/Form/FormRoot.js.map +1 -1
- package/lib/commonjs/components/Form/index.js +6 -213
- package/lib/commonjs/components/Form/index.js.map +1 -1
- package/lib/commonjs/components/Form/styles.js +1 -49
- package/lib/commonjs/components/Form/styles.js.map +1 -1
- package/lib/commonjs/components/OtpInput/index.js +83 -0
- package/lib/commonjs/components/OtpInput/index.js.map +1 -0
- package/lib/commonjs/components/OtpInput/styles.js +48 -0
- package/lib/commonjs/components/OtpInput/styles.js.map +1 -0
- package/lib/commonjs/components/index.js +24 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/module/components/{Form/FormLabelRoot.js → Field/FieldLabel.js} +3 -3
- package/lib/module/components/Field/FieldLabel.js.map +1 -0
- package/lib/module/components/Field/FieldLabel.web.js +17 -0
- package/lib/module/components/Field/FieldLabel.web.js.map +1 -0
- package/lib/module/components/Field/index.js +155 -0
- package/lib/module/components/Field/index.js.map +1 -0
- package/lib/module/components/Field/styles.js +12 -0
- package/lib/module/components/Field/styles.js.map +1 -0
- package/lib/module/components/Form/FormRoot.js.map +1 -1
- package/lib/module/components/Form/index.js +8 -216
- package/lib/module/components/Form/index.js.map +1 -1
- package/lib/module/components/Form/styles.js +0 -48
- package/lib/module/components/Form/styles.js.map +1 -1
- package/lib/module/components/OtpInput/index.js +79 -0
- package/lib/module/components/OtpInput/index.js.map +1 -0
- package/lib/module/components/OtpInput/styles.js +44 -0
- package/lib/module/components/OtpInput/styles.js.map +1 -0
- package/lib/module/components/index.js +2 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/typescript/components/{Form/FormLabelRoot.d.ts → Field/FieldLabel.d.ts} +5 -5
- package/lib/typescript/components/Field/FieldLabel.d.ts.map +1 -0
- package/lib/typescript/components/{Form/FormLabelRoot.web.d.ts → Field/FieldLabel.web.d.ts} +3 -7
- package/lib/typescript/components/Field/FieldLabel.web.d.ts.map +1 -0
- package/lib/typescript/components/Field/index.d.ts +26 -0
- package/lib/typescript/components/Field/index.d.ts.map +1 -0
- package/lib/typescript/components/Field/styles.d.ts +16 -0
- package/lib/typescript/components/Field/styles.d.ts.map +1 -0
- package/lib/typescript/components/Form/FormRoot.d.ts +2 -0
- package/lib/typescript/components/Form/FormRoot.d.ts.map +1 -1
- package/lib/typescript/components/Form/index.d.ts +4 -61
- package/lib/typescript/components/Form/index.d.ts.map +1 -1
- package/lib/typescript/components/Form/styles.d.ts +0 -20
- package/lib/typescript/components/Form/styles.d.ts.map +1 -1
- package/lib/typescript/components/OtpInput/index.d.ts +11 -0
- package/lib/typescript/components/OtpInput/index.d.ts.map +1 -0
- package/lib/typescript/components/OtpInput/styles.d.ts +14 -0
- package/lib/typescript/components/OtpInput/styles.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/{Form/FormLabelRoot.tsx → Field/FieldLabel.tsx} +4 -4
- package/src/components/Field/FieldLabel.web.tsx +25 -0
- package/src/components/Field/index.tsx +171 -0
- package/src/components/Field/styles.ts +32 -0
- package/src/components/Form/FormRoot.tsx +1 -0
- package/src/components/Form/index.tsx +11 -245
- package/src/components/Form/styles.ts +1 -73
- package/src/components/OtpInput/index.tsx +79 -0
- package/src/components/OtpInput/styles.ts +45 -0
- package/src/components/index.ts +2 -0
- package/lib/commonjs/components/Form/FormLabelRoot.js.map +0 -1
- package/lib/commonjs/components/Form/FormLabelRoot.web.js.map +0 -1
- package/lib/module/components/Form/FormLabelRoot.js.map +0 -1
- package/lib/module/components/Form/FormLabelRoot.web.js +0 -13
- package/lib/module/components/Form/FormLabelRoot.web.js.map +0 -1
- package/lib/typescript/components/Form/FormLabelRoot.d.ts.map +0 -1
- package/lib/typescript/components/Form/FormLabelRoot.web.d.ts.map +0 -1
- package/src/components/Form/FormLabelRoot.web.tsx +0 -18
|
@@ -1,64 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { type IFormProps, type IFormFieldProps } from '@cdx-ui/primitives';
|
|
4
|
-
import { type IconProps } from '../Icon';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
5
3
|
import { type BaseFormRootProps } from './FormRoot';
|
|
6
|
-
export interface FormProps extends BaseFormRootProps
|
|
7
|
-
className?: string;
|
|
8
|
-
children?: ReactNode;
|
|
4
|
+
export interface FormProps extends BaseFormRootProps {
|
|
9
5
|
}
|
|
10
|
-
declare const
|
|
11
|
-
/**
|
|
12
|
-
* Field wrapper + context. For **initial focus**, pass `autoFocus` on `Input.Field` (not here).
|
|
13
|
-
*/
|
|
14
|
-
export interface FormFieldProps extends Omit<ViewProps, 'id' | 'name'>, IFormFieldProps {
|
|
15
|
-
className?: string;
|
|
16
|
-
children?: ReactNode;
|
|
17
|
-
size?: 'default' | 'small';
|
|
18
|
-
}
|
|
19
|
-
declare const FormField: import("react").ForwardRefExoticComponent<FormFieldProps & import("react").RefAttributes<View>>;
|
|
20
|
-
export interface FormLabelProps extends ViewProps {
|
|
21
|
-
className?: string;
|
|
22
|
-
children?: ReactNode;
|
|
23
|
-
/** @platform web — passed to `<label htmlFor>`; defaults to the field input id. */
|
|
24
|
-
htmlFor?: string;
|
|
25
|
-
}
|
|
26
|
-
declare const FormLabel: import("react").ForwardRefExoticComponent<FormLabelProps & import("react").RefAttributes<View>>;
|
|
27
|
-
export interface FormHelperProps extends ViewProps {
|
|
28
|
-
className?: string;
|
|
29
|
-
children?: ReactNode;
|
|
30
|
-
}
|
|
31
|
-
declare const FormHelper: import("react").ForwardRefExoticComponent<FormHelperProps & import("react").RefAttributes<View>>;
|
|
32
|
-
export interface FormHelperTextProps extends TextProps {
|
|
33
|
-
className?: string;
|
|
34
|
-
children?: ReactNode;
|
|
35
|
-
}
|
|
36
|
-
declare const FormHelperText: import("react").ForwardRefExoticComponent<FormHelperTextProps & import("react").RefAttributes<Text>>;
|
|
37
|
-
export interface FormErrorProps extends ViewProps {
|
|
38
|
-
className?: string;
|
|
39
|
-
children?: ReactNode;
|
|
40
|
-
}
|
|
41
|
-
declare const FormError: import("react").ForwardRefExoticComponent<FormErrorProps & import("react").RefAttributes<View>>;
|
|
42
|
-
export interface FormErrorTextProps extends TextProps {
|
|
43
|
-
className?: string;
|
|
44
|
-
children?: ReactNode;
|
|
45
|
-
}
|
|
46
|
-
declare const FormErrorText: import("react").ForwardRefExoticComponent<FormErrorTextProps & import("react").RefAttributes<Text>>;
|
|
47
|
-
export interface FormErrorIconProps extends Omit<IconProps, 'children'> {
|
|
48
|
-
}
|
|
49
|
-
declare const FormErrorIcon: {
|
|
50
|
-
({ className, style, as, ...props }: FormErrorIconProps): import("react/jsx-runtime").JSX.Element;
|
|
51
|
-
displayName: string;
|
|
52
|
-
};
|
|
53
|
-
type FormCompoundComponent = typeof FormRoot & {
|
|
54
|
-
Field: typeof FormField;
|
|
55
|
-
Label: typeof FormLabel;
|
|
56
|
-
Helper: typeof FormHelper;
|
|
57
|
-
HelperText: typeof FormHelperText;
|
|
58
|
-
Error: typeof FormError;
|
|
59
|
-
ErrorText: typeof FormErrorText;
|
|
60
|
-
ErrorIcon: typeof FormErrorIcon;
|
|
61
|
-
};
|
|
62
|
-
export declare const Form: FormCompoundComponent;
|
|
63
|
-
export {};
|
|
6
|
+
export declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<View>>;
|
|
64
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAelE,MAAM,WAAW,SAAU,SAAQ,iBAAiB;CAAG;AAkBvD,eAAO,MAAM,IAAI,wEAAW,CAAC"}
|
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
import { type VariantProps } from 'class-variance-authority';
|
|
2
1
|
export declare const formRootVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
-
export declare const formFieldVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
4
|
-
export declare const formLabelVariants: (props?: ({
|
|
5
|
-
size?: "small" | "default" | null | undefined;
|
|
6
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
-
export declare const formHelperVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
8
|
-
export declare const formHelperTextVariants: (props?: ({
|
|
9
|
-
size?: "small" | "default" | null | undefined;
|
|
10
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
-
export declare const formErrorVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
12
|
-
export declare const formErrorTextVariants: (props?: ({
|
|
13
|
-
size?: "small" | "default" | null | undefined;
|
|
14
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
|
-
export declare const formErrorIconVariants: (props?: ({
|
|
16
|
-
size?: "small" | "default" | null | undefined;
|
|
17
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
18
|
-
export type FormLabelVariantProps = VariantProps<typeof formLabelVariants>;
|
|
19
|
-
export type FormHelperTextVariantProps = VariantProps<typeof formHelperTextVariants>;
|
|
20
|
-
export type FormErrorTextVariantProps = VariantProps<typeof formErrorTextVariants>;
|
|
21
|
-
export type FormErrorIconVariantProps = VariantProps<typeof formErrorIconVariants>;
|
|
22
2
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,oFAA0B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { View } from 'react-native';
|
|
2
|
+
import { type IOtpInputRootProps } from '@cdx-ui/primitives';
|
|
3
|
+
import { type InputProps } from '../Input';
|
|
4
|
+
import { type OtpInputVariantProps } from './styles';
|
|
5
|
+
export interface OtpInputProps extends Omit<IOtpInputRootProps, 'size'>, OtpInputVariantProps {
|
|
6
|
+
variant?: NonNullable<InputProps['variant']>;
|
|
7
|
+
size?: NonNullable<InputProps['size']>;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const OtpInput: import("react").ForwardRefExoticComponent<OtpInputProps & import("react").RefAttributes<View>>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/OtpInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AA2ClB,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAAE,oBAAoB;IAC3F,OAAO,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,QAAQ,gGAcpB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
export declare const otpRootVariants: (props?: ({
|
|
3
|
+
size?: "small" | "default" | null | undefined;
|
|
4
|
+
fullWidth?: boolean | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
/** Narrow cell chrome: overrides Input root `w-full` / wide horizontal padding for one digit. */
|
|
7
|
+
export declare const otpCellVariants: (props?: ({
|
|
8
|
+
size?: "small" | "default" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
export declare const otpFieldVariants: (props?: ({
|
|
11
|
+
size?: "small" | "default" | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
|
+
export type OtpInputVariantProps = VariantProps<typeof otpRootVariants>;
|
|
14
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/OtpInput/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,eAAe;;;8EAe1B,CAAC;AAEH,iGAAiG;AACjG,eAAO,MAAM,eAAe;;8EAU1B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;8EAU3B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -7,9 +7,11 @@ export * from './Card';
|
|
|
7
7
|
export * from './Checkbox';
|
|
8
8
|
export * from './Chip';
|
|
9
9
|
export * from './Dialog';
|
|
10
|
+
export * from './Field';
|
|
10
11
|
export * from './Form';
|
|
11
12
|
export * from './Image';
|
|
12
13
|
export * from './Input';
|
|
14
|
+
export * from './OtpInput';
|
|
13
15
|
export * from './Link';
|
|
14
16
|
export * from './ProgressBar';
|
|
15
17
|
export * from './ProgressSegmented';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/components",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.37",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"@gorhom/bottom-sheet": "^5.2.6",
|
|
67
67
|
"class-variance-authority": "^0.7.1",
|
|
68
68
|
"uniwind": "1.6.1",
|
|
69
|
-
"@cdx-ui/
|
|
70
|
-
"@cdx-ui/
|
|
71
|
-
"@cdx-ui/
|
|
69
|
+
"@cdx-ui/primitives": "0.0.1-alpha.37",
|
|
70
|
+
"@cdx-ui/utils": "0.0.1-alpha.37",
|
|
71
|
+
"@cdx-ui/icons": "0.0.1-alpha.37"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/react": "*",
|
|
@@ -2,8 +2,8 @@ import { forwardRef } from 'react';
|
|
|
2
2
|
import { Text, TextProps, type GestureResponderEvent } from 'react-native';
|
|
3
3
|
import { composeEventHandlers, useFormControlContext } from '@cdx-ui/utils';
|
|
4
4
|
|
|
5
|
-
export type
|
|
6
|
-
/** @platform web — forwarded on web; ignored here (see `
|
|
5
|
+
export type BaseFieldLabelProps = TextProps & {
|
|
6
|
+
/** @platform web — forwarded on web; ignored here (see `FieldLabelRoot.web`). */
|
|
7
7
|
htmlFor?: string;
|
|
8
8
|
/** Optional; composed with label tap-to-focus on native. */
|
|
9
9
|
onPress?: ((event: GestureResponderEvent) => void) | null;
|
|
@@ -13,7 +13,7 @@ export type FormLabelRootProps = TextProps & {
|
|
|
13
13
|
* Native: `Text` label row — tap focuses the field input via form context
|
|
14
14
|
* (parity with `<label htmlFor>` on web).
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
16
|
+
export const BaseFieldLabel = forwardRef<Text, BaseFieldLabelProps>(
|
|
17
17
|
({ htmlFor: _omitHtmlFor, onPress, ...props }, ref) => {
|
|
18
18
|
void _omitHtmlFor;
|
|
19
19
|
|
|
@@ -30,4 +30,4 @@ export const FormLabelRoot = forwardRef<Text, FormLabelRootProps>(
|
|
|
30
30
|
},
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
BaseFieldLabel.displayName = 'BaseFieldLabel';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// TODO: Why does dataSet need to be decomposed into individual data attributes?
|
|
5
|
+
|
|
6
|
+
export type BaseFieldLabelProps = ViewProps & {
|
|
7
|
+
htmlFor?: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/** @platform native — ignored on DOM `<label>`; set by form primitive for Uniwind. */
|
|
10
|
+
dataSet?: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Real `<label>` so clicking the label focuses the associated control (`htmlFor` → input `id`). */
|
|
14
|
+
export const BaseFieldLabel = forwardRef<HTMLLabelElement, BaseFieldLabelProps>((props, ref) => {
|
|
15
|
+
return (
|
|
16
|
+
<label
|
|
17
|
+
ref={ref}
|
|
18
|
+
{...(props as React.LabelHTMLAttributes<HTMLLabelElement>)}
|
|
19
|
+
data-invalid={props.dataSet?.invalid}
|
|
20
|
+
data-required={props.dataSet?.required}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
BaseFieldLabel.displayName = 'BaseFieldLabel';
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import { ErrorIcon } from '@cdx-ui/icons';
|
|
4
|
+
import {
|
|
5
|
+
createField,
|
|
6
|
+
IFieldErrorProps,
|
|
7
|
+
IFieldHelperProps,
|
|
8
|
+
IFieldLabelProps,
|
|
9
|
+
type IFieldRootProps,
|
|
10
|
+
} from '@cdx-ui/primitives';
|
|
11
|
+
import { cn } from '@cdx-ui/utils';
|
|
12
|
+
import { Icon } from '../Icon';
|
|
13
|
+
import { BaseFieldLabel } from './FieldLabel';
|
|
14
|
+
import {
|
|
15
|
+
fieldErrorIconVariants,
|
|
16
|
+
fieldErrorTextVariants,
|
|
17
|
+
fieldErrorVariants,
|
|
18
|
+
fieldHelperVariants,
|
|
19
|
+
fieldHelperTextVariants,
|
|
20
|
+
fieldLabelVariants,
|
|
21
|
+
fieldRootVariants,
|
|
22
|
+
type FieldRootVariantProps,
|
|
23
|
+
type FieldLabelVariantProps,
|
|
24
|
+
type FieldHelperVariantProps,
|
|
25
|
+
type FieldErrorVariantProps,
|
|
26
|
+
} from './styles';
|
|
27
|
+
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// PRIMITIVE
|
|
30
|
+
// =============================================================================
|
|
31
|
+
|
|
32
|
+
const FieldPrimitive = createField({
|
|
33
|
+
Root: View,
|
|
34
|
+
Label: BaseFieldLabel,
|
|
35
|
+
Helper: View,
|
|
36
|
+
HelperText: Text,
|
|
37
|
+
Error: View,
|
|
38
|
+
ErrorText: Text,
|
|
39
|
+
ErrorIcon: View,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// =============================================================================
|
|
43
|
+
// FIELD ROOT
|
|
44
|
+
// =============================================================================
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Field wrapper + context. For **initial focus**, pass `autoFocus` on `Input.Field` (not here).
|
|
48
|
+
*/
|
|
49
|
+
export interface FieldRootProps extends IFieldRootProps, FieldRootVariantProps {}
|
|
50
|
+
|
|
51
|
+
const FieldRoot = forwardRef<View, FieldRootProps>(
|
|
52
|
+
({ className, children, style, ...props }, ref) => {
|
|
53
|
+
const computedClassName = cn(fieldRootVariants(), className);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<FieldPrimitive ref={ref} className={computedClassName} style={style} {...props}>
|
|
57
|
+
{children}
|
|
58
|
+
</FieldPrimitive>
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
FieldRoot.displayName = 'Field';
|
|
64
|
+
|
|
65
|
+
// =============================================================================
|
|
66
|
+
// FIELD LABEL
|
|
67
|
+
// =============================================================================
|
|
68
|
+
|
|
69
|
+
export interface FieldLabelProps extends IFieldLabelProps, FieldLabelVariantProps {}
|
|
70
|
+
|
|
71
|
+
const FieldLabel = forwardRef<View, FieldLabelProps>(
|
|
72
|
+
({ className, children, style, htmlFor, ...props }, ref) => {
|
|
73
|
+
const labelClassName = cn(fieldLabelVariants(), className);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<FieldPrimitive.Label
|
|
77
|
+
ref={ref}
|
|
78
|
+
className={labelClassName}
|
|
79
|
+
style={style}
|
|
80
|
+
htmlFor={htmlFor}
|
|
81
|
+
requiredIndicator={
|
|
82
|
+
<Text className="text-red-500" aria-hidden>
|
|
83
|
+
{' *'}
|
|
84
|
+
</Text>
|
|
85
|
+
}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
{children}
|
|
89
|
+
</FieldPrimitive.Label>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
FieldLabel.displayName = 'Field.Label';
|
|
95
|
+
|
|
96
|
+
// =============================================================================
|
|
97
|
+
// FIELD HELPER
|
|
98
|
+
// =============================================================================
|
|
99
|
+
|
|
100
|
+
export interface FieldHelperProps extends IFieldHelperProps, FieldHelperVariantProps {}
|
|
101
|
+
|
|
102
|
+
const FieldHelper = forwardRef<View, FieldHelperProps>(
|
|
103
|
+
({ className, children, style, ...props }, ref) => {
|
|
104
|
+
const containerClassName = cn(fieldHelperVariants(), className);
|
|
105
|
+
const textClassName = cn(fieldHelperTextVariants());
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<FieldPrimitive.Helper ref={ref} className={containerClassName} style={style} {...props}>
|
|
109
|
+
<FieldPrimitive.HelperText className={textClassName}>{children}</FieldPrimitive.HelperText>
|
|
110
|
+
</FieldPrimitive.Helper>
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
FieldHelper.displayName = 'Field.Helper';
|
|
116
|
+
|
|
117
|
+
// =============================================================================
|
|
118
|
+
// FIELD ERROR (internal icon + text composition)
|
|
119
|
+
// =============================================================================
|
|
120
|
+
|
|
121
|
+
const FieldErrorIcon = ({ className, style, ...props }: { className?: string; style?: any }) => {
|
|
122
|
+
const computedClassName = cn(fieldErrorIconVariants(), className);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<Icon
|
|
126
|
+
as={ErrorIcon}
|
|
127
|
+
className={computedClassName}
|
|
128
|
+
style={style}
|
|
129
|
+
aria-hidden={true}
|
|
130
|
+
{...props}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
FieldErrorIcon.displayName = 'Field.ErrorIcon';
|
|
136
|
+
|
|
137
|
+
export interface FieldErrorProps extends IFieldErrorProps, FieldErrorVariantProps {}
|
|
138
|
+
|
|
139
|
+
const FieldError = forwardRef<View, FieldErrorProps>(
|
|
140
|
+
({ className, children, style, ...props }, ref) => {
|
|
141
|
+
const containerClassName = cn(fieldErrorVariants(), className);
|
|
142
|
+
const textClassName = cn(fieldErrorTextVariants());
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<FieldPrimitive.Error ref={ref} className={containerClassName} style={style} {...props}>
|
|
146
|
+
<FieldPrimitive.ErrorIcon>
|
|
147
|
+
<FieldErrorIcon />
|
|
148
|
+
</FieldPrimitive.ErrorIcon>
|
|
149
|
+
<FieldPrimitive.ErrorText className={textClassName}>{children}</FieldPrimitive.ErrorText>
|
|
150
|
+
</FieldPrimitive.Error>
|
|
151
|
+
);
|
|
152
|
+
},
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
FieldError.displayName = 'Field.Error';
|
|
156
|
+
|
|
157
|
+
// =============================================================================
|
|
158
|
+
// COMPOUND EXPORT
|
|
159
|
+
// =============================================================================
|
|
160
|
+
|
|
161
|
+
type FieldCompoundComponent = typeof FieldRoot & {
|
|
162
|
+
Label: typeof FieldLabel;
|
|
163
|
+
Helper: typeof FieldHelper;
|
|
164
|
+
Error: typeof FieldError;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const Field = Object.assign(FieldRoot, {
|
|
168
|
+
Label: FieldLabel,
|
|
169
|
+
Helper: FieldHelper,
|
|
170
|
+
Error: FieldError,
|
|
171
|
+
}) as FieldCompoundComponent;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { DISABLED_OPACITY } from '../../styles/primitives';
|
|
3
|
+
|
|
4
|
+
export const fieldRootVariants = cva(['flex-col gap-2', 'web:last:mb-0', DISABLED_OPACITY]);
|
|
5
|
+
|
|
6
|
+
export const fieldLabelVariants = cva([
|
|
7
|
+
'body-md',
|
|
8
|
+
'font-medium',
|
|
9
|
+
'text-content-primary',
|
|
10
|
+
'flex-row items-center',
|
|
11
|
+
DISABLED_OPACITY,
|
|
12
|
+
'web:cursor-pointer',
|
|
13
|
+
'data-[invalid=true]:text-content-danger',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
export const fieldHelperVariants = cva(['flex-row items-center']);
|
|
17
|
+
|
|
18
|
+
export const fieldHelperTextVariants = cva(['body-sm', 'text-content-tertiary']);
|
|
19
|
+
|
|
20
|
+
export const fieldErrorVariants = cva(['flex-row items-center gap-1']);
|
|
21
|
+
|
|
22
|
+
export const fieldErrorTextVariants = cva(['body-sm', 'text-content-danger']);
|
|
23
|
+
|
|
24
|
+
export const fieldErrorIconVariants = cva(['size-3.5', 'text-content-danger']);
|
|
25
|
+
|
|
26
|
+
export type FieldRootVariantProps = VariantProps<typeof fieldRootVariants>;
|
|
27
|
+
export type FieldLabelVariantProps = VariantProps<typeof fieldLabelVariants>;
|
|
28
|
+
export type FieldHelperVariantProps = VariantProps<typeof fieldHelperVariants>;
|
|
29
|
+
export type FieldHelperTextVariantProps = VariantProps<typeof fieldHelperTextVariants>;
|
|
30
|
+
export type FieldErrorVariantProps = VariantProps<typeof fieldErrorVariants>;
|
|
31
|
+
export type FieldErrorTextVariantProps = VariantProps<typeof fieldErrorTextVariants>;
|
|
32
|
+
export type FieldErrorIconVariantProps = VariantProps<typeof fieldErrorIconVariants>;
|
|
@@ -5,6 +5,7 @@ export type BaseFormRootProps = ViewProps & {
|
|
|
5
5
|
onSubmit?: (e: React.SyntheticEvent) => void;
|
|
6
6
|
action?: string | ((formData: FormData) => void | Promise<void>);
|
|
7
7
|
method?: string;
|
|
8
|
+
className?: string;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
export const BaseFormRoot = forwardRef<View, BaseFormRootProps>(
|