@ankhorage/zora 10.0.0 → 11.0.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 +10 -0
- package/README.md +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/features/bottom-sheet/bottomSheetMeta.d.ts +1 -1
- package/dist/features/card/cardMeta.d.ts +1 -1
- package/dist/features/card/mediaCardMeta.d.ts +1 -1
- package/dist/features/card/postCardMeta.d.ts +1 -1
- package/dist/features/form/adapters/inbound/Form.d.ts +5 -0
- package/dist/features/form/adapters/inbound/Form.d.ts.map +1 -0
- package/dist/features/form/adapters/inbound/Form.js +18 -0
- package/dist/features/form/adapters/inbound/Form.js.map +1 -0
- package/dist/{components/form → features/form/adapters/inbound}/FormActions.d.ts +1 -1
- package/dist/features/form/adapters/inbound/FormActions.d.ts.map +1 -0
- package/dist/{components/form → features/form/adapters/inbound}/FormActions.js +3 -3
- package/dist/features/form/adapters/inbound/FormActions.js.map +1 -0
- package/dist/features/form/adapters/inbound/FormError.d.ts +5 -0
- package/dist/features/form/adapters/inbound/FormError.d.ts.map +1 -0
- package/dist/features/form/adapters/inbound/FormError.js +18 -0
- package/dist/features/form/adapters/inbound/FormError.js.map +1 -0
- package/dist/features/form/adapters/inbound/FormField.d.ts +5 -0
- package/dist/features/form/adapters/inbound/FormField.d.ts.map +1 -0
- package/dist/{patterns/form-field → features/form/adapters/inbound}/FormField.js +5 -4
- package/dist/features/form/adapters/inbound/FormField.js.map +1 -0
- package/dist/features/form/formActionsMeta.d.ts +9 -0
- package/dist/features/form/formActionsMeta.d.ts.map +1 -0
- package/dist/features/form/formActionsMeta.js +9 -0
- package/dist/features/form/formActionsMeta.js.map +1 -0
- package/dist/features/form/formErrorMeta.d.ts +32 -0
- package/dist/features/form/formErrorMeta.d.ts.map +1 -0
- package/dist/features/form/formErrorMeta.js +19 -0
- package/dist/features/form/formErrorMeta.js.map +1 -0
- package/dist/{components/form/meta.d.ts → features/form/formFieldMeta.d.ts} +28 -39
- package/dist/features/form/formFieldMeta.d.ts.map +1 -0
- package/dist/features/form/formFieldMeta.js +35 -0
- package/dist/features/form/formFieldMeta.js.map +1 -0
- package/dist/features/form/formMeta.d.ts +61 -0
- package/dist/features/form/formMeta.d.ts.map +1 -0
- package/dist/features/form/formMeta.js +34 -0
- package/dist/features/form/formMeta.js.map +1 -0
- package/dist/features/form/public.d.ts +8 -0
- package/dist/features/form/public.d.ts.map +1 -0
- package/dist/features/form/public.js +7 -0
- package/dist/features/form/public.js.map +1 -0
- package/dist/{components → features}/form/useFormController.d.ts +1 -1
- package/dist/features/form/useFormController.d.ts.map +1 -0
- package/dist/{components → features}/form/useFormController.js +1 -1
- package/dist/features/form/useFormController.js.map +1 -0
- package/dist/{components/form → features/form/utils}/validation.d.ts +1 -1
- package/dist/features/form/utils/validation.d.ts.map +1 -0
- package/dist/{components/form → features/form/utils}/validation.js +2 -4
- package/dist/features/form/utils/validation.js.map +1 -0
- package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts +1 -1
- package/dist/features/layout/boxMeta.d.ts +1 -1
- package/dist/features/layout/containerMeta.d.ts +1 -1
- package/dist/features/layout/gridMeta.d.ts +1 -1
- package/dist/features/layout/stackMeta.d.ts +1 -1
- package/dist/features/list/flatListMeta.d.ts +1 -1
- package/dist/features/list/sectionListMeta.d.ts +1 -1
- package/dist/features/surface/surfaceMeta.d.ts +1 -1
- package/dist/features/uploader/adapters/inbound/Uploader.d.ts.map +1 -1
- package/dist/features/uploader/adapters/inbound/Uploader.js +1 -1
- package/dist/features/uploader/adapters/inbound/Uploader.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/screen/meta.d.ts +1 -1
- package/dist/layout/screen-section/meta.d.ts +1 -1
- package/dist/metadata/allowedChildren.d.ts +3 -3
- package/dist/metadata/allowedChildren.d.ts.map +1 -1
- package/dist/metadata/allowedChildren.js +1 -1
- package/dist/metadata/allowedChildren.js.map +1 -1
- package/dist/metadata/bindableComponentMeta.d.ts +2 -2
- package/dist/metadata/componentMeta.d.ts.map +1 -1
- package/dist/metadata/componentMeta.js +4 -1
- package/dist/metadata/componentMeta.js.map +1 -1
- package/dist/patterns/auth/AuthForm.d.ts +21 -0
- package/dist/patterns/auth/AuthForm.d.ts.map +1 -0
- package/dist/patterns/auth/AuthForm.js +19 -0
- package/dist/patterns/auth/AuthForm.js.map +1 -0
- package/dist/patterns/auth/AuthFormField.d.ts +16 -0
- package/dist/patterns/auth/AuthFormField.d.ts.map +1 -0
- package/dist/patterns/auth/AuthFormField.js +38 -0
- package/dist/patterns/auth/AuthFormField.js.map +1 -0
- package/dist/patterns/auth/ForgotPasswordForm.d.ts.map +1 -1
- package/dist/patterns/auth/ForgotPasswordForm.js +2 -2
- package/dist/patterns/auth/ForgotPasswordForm.js.map +1 -1
- package/dist/patterns/auth/OtpForm.d.ts.map +1 -1
- package/dist/patterns/auth/OtpForm.js +2 -2
- package/dist/patterns/auth/OtpForm.js.map +1 -1
- package/dist/patterns/auth/SignInForm.d.ts.map +1 -1
- package/dist/patterns/auth/SignInForm.js +2 -2
- package/dist/patterns/auth/SignInForm.js.map +1 -1
- package/dist/patterns/auth/SignUpForm.d.ts.map +1 -1
- package/dist/patterns/auth/SignUpForm.js +2 -2
- package/dist/patterns/auth/SignUpForm.js.map +1 -1
- package/dist/patterns/auth/types.d.ts +1 -1
- package/dist/patterns/auth/types.d.ts.map +1 -1
- package/dist/patterns/auth/types.js.map +1 -1
- package/dist/patterns/auth/utils.d.ts +1 -1
- package/dist/patterns/auth/utils.d.ts.map +1 -1
- package/dist/patterns/auth/utils.js.map +1 -1
- package/dist/patterns/inspector-field/InspectorField.js +1 -1
- package/dist/patterns/inspector-field/InspectorField.js.map +1 -1
- package/dist/patterns/message-bubble/meta.d.ts +1 -1
- package/dist/patterns/notice/meta.d.ts +1 -1
- package/dist/patterns/panel/meta.d.ts +1 -1
- package/dist/patterns/reader/meta.d.ts +2 -2
- package/dist/patterns/scanner/meta.d.ts +2 -2
- package/dist/registry.js +1 -1
- package/dist/registry.js.map +1 -1
- package/dist/{components/form/types.d.ts → types/form.d.ts} +12 -28
- package/dist/types/form.d.ts.map +1 -0
- package/dist/types/form.js +2 -0
- package/dist/types/form.js.map +1 -0
- package/package.json +2 -1
- package/src/audit.test.ts +2 -4
- package/src/constants.ts +1 -0
- package/src/featureManifest.test.ts +7 -0
- package/src/features/form/adapters/inbound/Form.tsx +39 -0
- package/src/{components/form → features/form/adapters/inbound}/FormActions.tsx +4 -4
- package/src/features/form/adapters/inbound/FormError.tsx +22 -0
- package/src/{patterns/form-field → features/form/adapters/inbound}/FormField.tsx +6 -4
- package/src/features/form/formActionsMeta.ts +9 -0
- package/src/features/form/formErrorMeta.ts +19 -0
- package/src/features/form/formFieldMeta.ts +35 -0
- package/src/features/form/formMeta.ts +34 -0
- package/src/{components/form/index.ts → features/form/public.ts} +6 -7
- package/src/{components → features}/form/useFormController.ts +2 -2
- package/src/{components/form → features/form/utils}/validation.test.ts +4 -1
- package/src/{components/form → features/form/utils}/validation.ts +4 -8
- package/src/features/uploader/adapters/inbound/Uploader.tsx +1 -1
- package/src/index.ts +26 -27
- package/src/metadata/allowedChildren.ts +1 -1
- package/src/metadata/componentMeta.test.ts +18 -1
- package/src/metadata/componentMeta.ts +4 -1
- package/src/patterns/auth/AuthForm.tsx +68 -0
- package/src/patterns/auth/AuthFormField.tsx +81 -0
- package/src/patterns/auth/ForgotPasswordForm.tsx +3 -2
- package/src/patterns/auth/OtpForm.tsx +3 -2
- package/src/patterns/auth/SignInForm.tsx +3 -2
- package/src/patterns/auth/SignUpForm.tsx +3 -2
- package/src/patterns/auth/types.ts +1 -1
- package/src/patterns/auth/utils.ts +1 -1
- package/src/patterns/inspector-field/InspectorField.tsx +1 -1
- package/src/registry.ts +1 -1
- package/src/theme/themeScopeStructure.test.ts +5 -7
- package/src/{components/form/types.ts → types/form.ts} +12 -36
- package/dist/components/form/Form.d.ts +0 -7
- package/dist/components/form/Form.d.ts.map +0 -1
- package/dist/components/form/Form.js +0 -34
- package/dist/components/form/Form.js.map +0 -1
- package/dist/components/form/FormActions.d.ts.map +0 -1
- package/dist/components/form/FormActions.js.map +0 -1
- package/dist/components/form/FormError.d.ts +0 -7
- package/dist/components/form/FormError.d.ts.map +0 -1
- package/dist/components/form/FormError.js +0 -21
- package/dist/components/form/FormError.js.map +0 -1
- package/dist/components/form/FormField.d.ts +0 -7
- package/dist/components/form/FormField.d.ts.map +0 -1
- package/dist/components/form/FormField.js +0 -81
- package/dist/components/form/FormField.js.map +0 -1
- package/dist/components/form/index.d.ts +0 -8
- package/dist/components/form/index.d.ts.map +0 -1
- package/dist/components/form/index.js +0 -7
- package/dist/components/form/index.js.map +0 -1
- package/dist/components/form/meta.d.ts.map +0 -1
- package/dist/components/form/meta.js +0 -94
- package/dist/components/form/meta.js.map +0 -1
- package/dist/components/form/types.d.ts.map +0 -1
- package/dist/components/form/types.js +0 -2
- package/dist/components/form/types.js.map +0 -1
- package/dist/components/form/useFormController.d.ts.map +0 -1
- package/dist/components/form/useFormController.js.map +0 -1
- package/dist/components/form/validation.d.ts.map +0 -1
- package/dist/components/form/validation.js.map +0 -1
- package/dist/patterns/form-field/FormField.d.ts +0 -4
- package/dist/patterns/form-field/FormField.d.ts.map +0 -1
- package/dist/patterns/form-field/FormField.js.map +0 -1
- package/dist/patterns/form-field/index.d.ts +0 -2
- package/dist/patterns/form-field/index.d.ts.map +0 -1
- package/dist/patterns/form-field/index.js +0 -2
- package/dist/patterns/form-field/index.js.map +0 -1
- package/dist/patterns/form-field/types.d.ts +0 -9
- package/dist/patterns/form-field/types.d.ts.map +0 -1
- package/dist/patterns/form-field/types.js +0 -2
- package/dist/patterns/form-field/types.js.map +0 -1
- package/src/components/form/Form.tsx +0 -74
- package/src/components/form/FormError.tsx +0 -34
- package/src/components/form/FormField.tsx +0 -157
- package/src/components/form/meta.ts +0 -98
- package/src/patterns/form-field/index.ts +0 -1
- package/src/patterns/form-field/types.ts +0 -16
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Box, Stack } from '../../features/layout/public';
|
|
4
|
-
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
5
|
-
import { FormActions } from './FormActions';
|
|
6
|
-
import { FormError } from './FormError';
|
|
7
|
-
import { FormField } from './FormField';
|
|
8
|
-
import type { FormProps } from './types';
|
|
9
|
-
import { useFormController } from './useFormController';
|
|
10
|
-
|
|
11
|
-
function FormInner<TName extends string = string>({
|
|
12
|
-
themeId: _themeId,
|
|
13
|
-
mode: _mode,
|
|
14
|
-
fields,
|
|
15
|
-
values,
|
|
16
|
-
onChange,
|
|
17
|
-
onSubmit,
|
|
18
|
-
errors,
|
|
19
|
-
error,
|
|
20
|
-
loading = false,
|
|
21
|
-
disabled = false,
|
|
22
|
-
submitLabel = 'Submit',
|
|
23
|
-
actions,
|
|
24
|
-
footer,
|
|
25
|
-
validateOnChange = false,
|
|
26
|
-
testID,
|
|
27
|
-
interactionPolicy,
|
|
28
|
-
}: FormProps<TName>) {
|
|
29
|
-
const controller = useFormController({
|
|
30
|
-
fields,
|
|
31
|
-
values,
|
|
32
|
-
errors,
|
|
33
|
-
onChange,
|
|
34
|
-
onSubmit,
|
|
35
|
-
validateOnChange,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<Stack gap="m" testID={testID}>
|
|
40
|
-
<FormError error={error} />
|
|
41
|
-
{fields.map((field) => (
|
|
42
|
-
<FormField
|
|
43
|
-
key={field.name}
|
|
44
|
-
disabled={disabled}
|
|
45
|
-
error={controller.errors[field.name]}
|
|
46
|
-
field={field}
|
|
47
|
-
interactionPolicy={interactionPolicy}
|
|
48
|
-
loading={loading}
|
|
49
|
-
onChange={controller.setFieldValue}
|
|
50
|
-
value={values[field.name]}
|
|
51
|
-
/>
|
|
52
|
-
))}
|
|
53
|
-
<FormActions
|
|
54
|
-
disabled={disabled}
|
|
55
|
-
interactionPolicy={interactionPolicy}
|
|
56
|
-
loading={loading}
|
|
57
|
-
onSubmit={() => {
|
|
58
|
-
if (interactionPolicy === 'passive') return;
|
|
59
|
-
|
|
60
|
-
void controller.handleSubmit();
|
|
61
|
-
}}
|
|
62
|
-
submitLabel={submitLabel}
|
|
63
|
-
>
|
|
64
|
-
{actions}
|
|
65
|
-
</FormActions>
|
|
66
|
-
{footer ? <Box>{footer}</Box> : null}
|
|
67
|
-
</Stack>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/***
|
|
72
|
-
* Composes fields and actions into a validated form layout.
|
|
73
|
-
*/
|
|
74
|
-
export const Form = withZoraThemeScope(FormInner);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Box } from '../../features/layout/public';
|
|
4
|
-
import { Text } from '../../features/typography/public';
|
|
5
|
-
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
6
|
-
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
7
|
-
import type { FormErrorProps } from './types';
|
|
8
|
-
|
|
9
|
-
function FormErrorInner({
|
|
10
|
-
themeId: _themeId,
|
|
11
|
-
mode: _mode,
|
|
12
|
-
error,
|
|
13
|
-
testID,
|
|
14
|
-
interactionPolicy: _interactionPolicy,
|
|
15
|
-
}: FormErrorProps) {
|
|
16
|
-
const { theme } = useZoraTheme();
|
|
17
|
-
|
|
18
|
-
if (!error) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Box borderColor={theme.colors.error} borderWidth={1} p="s" radius="m" testID={testID}>
|
|
24
|
-
<Text color="error" variant="bodySmall">
|
|
25
|
-
{error}
|
|
26
|
-
</Text>
|
|
27
|
-
</Box>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/***
|
|
32
|
-
* Displays a form-level validation or submission error message.
|
|
33
|
-
*/
|
|
34
|
-
export const FormError = withZoraThemeScope(FormErrorInner);
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { Field } from '@ankhorage/surface';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { TextInput } from '../../features/form/text-input/public';
|
|
5
|
-
import { Stack } from '../../features/layout/public';
|
|
6
|
-
import { Text } from '../../features/typography/public';
|
|
7
|
-
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
8
|
-
import type { FormFieldConfig, FormFieldControlProps, FormFieldProps } from './types';
|
|
9
|
-
import { hasRequiredRule } from './validation';
|
|
10
|
-
|
|
11
|
-
function isControlFieldProps<TName extends string>(
|
|
12
|
-
props: FormFieldProps<TName>,
|
|
13
|
-
): props is FormFieldControlProps<TName> {
|
|
14
|
-
return 'field' in props;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function resolveKeyboardType(field: FormFieldConfig) {
|
|
18
|
-
if (field.keyboardType) {
|
|
19
|
-
return field.keyboardType;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (field.type === 'email') {
|
|
23
|
-
return 'email-address';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (field.type === 'number' || field.type === 'otp') {
|
|
27
|
-
return 'number-pad';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (field.type === 'tel') {
|
|
31
|
-
return 'phone-pad';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (field.type === 'url') {
|
|
35
|
-
return 'url';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function resolveAutoCapitalize(field: FormFieldConfig) {
|
|
42
|
-
if (field.autoCapitalize) {
|
|
43
|
-
return field.autoCapitalize;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (['email', 'password', 'url'].includes(field.type ?? 'text')) {
|
|
47
|
-
return 'none';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function resolveTextContentType(field: FormFieldConfig) {
|
|
54
|
-
if (field.textContentType) {
|
|
55
|
-
return field.textContentType;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (field.type === 'email') {
|
|
59
|
-
return 'emailAddress';
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (field.type === 'password') {
|
|
63
|
-
return 'password';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (field.type === 'otp') {
|
|
67
|
-
return 'oneTimeCode';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function renderLabel(label: React.ReactNode, description: React.ReactNode | undefined) {
|
|
74
|
-
return (
|
|
75
|
-
<Stack gap="xs">
|
|
76
|
-
<Text variant="label" weight="semiBold">
|
|
77
|
-
{label}
|
|
78
|
-
</Text>
|
|
79
|
-
{description ? (
|
|
80
|
-
<Text emphasis="muted" variant="bodySmall">
|
|
81
|
-
{description}
|
|
82
|
-
</Text>
|
|
83
|
-
) : null}
|
|
84
|
-
</Stack>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function FormFieldInner<TName extends string = string>(props: FormFieldProps<TName>) {
|
|
89
|
-
if (!isControlFieldProps(props)) {
|
|
90
|
-
const {
|
|
91
|
-
themeId: _themeId,
|
|
92
|
-
mode: _mode,
|
|
93
|
-
label,
|
|
94
|
-
description,
|
|
95
|
-
helperText,
|
|
96
|
-
children,
|
|
97
|
-
interactionPolicy: _interactionPolicy,
|
|
98
|
-
...fieldProps
|
|
99
|
-
} = props;
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<Field {...fieldProps} helperText={helperText} label={renderLabel(label, description)}>
|
|
103
|
-
{children}
|
|
104
|
-
</Field>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const {
|
|
109
|
-
themeId: _themeId,
|
|
110
|
-
mode: _mode,
|
|
111
|
-
field,
|
|
112
|
-
value,
|
|
113
|
-
error,
|
|
114
|
-
disabled = false,
|
|
115
|
-
loading = false,
|
|
116
|
-
onChange,
|
|
117
|
-
testID,
|
|
118
|
-
interactionPolicy,
|
|
119
|
-
} = props;
|
|
120
|
-
const fieldDisabled = disabled || loading || field.disabled;
|
|
121
|
-
const required = field.required ?? hasRequiredRule(field.rules);
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<Field
|
|
125
|
-
disabled={fieldDisabled}
|
|
126
|
-
errorText={error}
|
|
127
|
-
helperText={field.helperText}
|
|
128
|
-
invalid={Boolean(error)}
|
|
129
|
-
label={renderLabel(field.label, field.description)}
|
|
130
|
-
readOnly={field.readOnly}
|
|
131
|
-
required={required}
|
|
132
|
-
testID={testID ?? field.testID}
|
|
133
|
-
>
|
|
134
|
-
<TextInput
|
|
135
|
-
accessibilityLabel={typeof field.label === 'string' ? field.label : undefined}
|
|
136
|
-
autoCapitalize={resolveAutoCapitalize(field)}
|
|
137
|
-
autoComplete={field.autoComplete}
|
|
138
|
-
disabled={fieldDisabled}
|
|
139
|
-
interactionPolicy={interactionPolicy}
|
|
140
|
-
invalid={Boolean(error)}
|
|
141
|
-
keyboardType={resolveKeyboardType(field)}
|
|
142
|
-
maxLength={field.maxLength}
|
|
143
|
-
onChangeText={(nextValue) => onChange(field.name, nextValue)}
|
|
144
|
-
placeholder={field.placeholder}
|
|
145
|
-
readOnly={field.readOnly}
|
|
146
|
-
secureTextEntry={field.secureTextEntry ?? field.type === 'password'}
|
|
147
|
-
textContentType={resolveTextContentType(field)}
|
|
148
|
-
value={value}
|
|
149
|
-
/>
|
|
150
|
-
</Field>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/***
|
|
155
|
-
* Connects a controlled form value to a labeled input field with error handling.
|
|
156
|
-
*/
|
|
157
|
-
export const FormField = withZoraThemeScope(FormFieldInner);
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import type { ZoraComponentMeta } from '../../metadata';
|
|
2
|
-
|
|
3
|
-
export const formMeta = {
|
|
4
|
-
name: 'Form',
|
|
5
|
-
category: 'component',
|
|
6
|
-
directManifestNode: false,
|
|
7
|
-
allowedChildren: [],
|
|
8
|
-
note: 'Form orchestration component; not represented as a manifest node in v1.',
|
|
9
|
-
events: {
|
|
10
|
-
submit: {
|
|
11
|
-
label: 'Submit',
|
|
12
|
-
eventType: 'form.submit',
|
|
13
|
-
description: 'Emitted when the form submits its current values.',
|
|
14
|
-
payloadFields: [
|
|
15
|
-
{
|
|
16
|
-
path: 'payload.values',
|
|
17
|
-
type: 'record',
|
|
18
|
-
label: 'Values',
|
|
19
|
-
description: 'Submitted form values keyed by field name.',
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
props: {},
|
|
25
|
-
} as const satisfies ZoraComponentMeta;
|
|
26
|
-
|
|
27
|
-
export const formActionsMeta = {
|
|
28
|
-
name: 'FormActions',
|
|
29
|
-
category: 'component',
|
|
30
|
-
directManifestNode: false,
|
|
31
|
-
allowedChildren: [],
|
|
32
|
-
note: 'Form helper component; not represented as a manifest node in v1.',
|
|
33
|
-
props: {},
|
|
34
|
-
} as const satisfies ZoraComponentMeta;
|
|
35
|
-
|
|
36
|
-
export const formErrorMeta = {
|
|
37
|
-
name: 'FormError',
|
|
38
|
-
category: 'component',
|
|
39
|
-
directManifestNode: false,
|
|
40
|
-
allowedChildren: [],
|
|
41
|
-
note: 'Form helper component; not represented as a manifest node in v1.',
|
|
42
|
-
props: {},
|
|
43
|
-
} as const satisfies ZoraComponentMeta;
|
|
44
|
-
|
|
45
|
-
export const formFieldMeta = {
|
|
46
|
-
name: 'FormField',
|
|
47
|
-
category: 'component',
|
|
48
|
-
directManifestNode: true,
|
|
49
|
-
allowedChildren: ['TextInput'],
|
|
50
|
-
blueprint: {
|
|
51
|
-
label: 'Form field',
|
|
52
|
-
defaultProps: {
|
|
53
|
-
label: 'Label',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
props: {
|
|
57
|
-
label: {
|
|
58
|
-
type: 'string',
|
|
59
|
-
category: 'Content',
|
|
60
|
-
label: 'Label',
|
|
61
|
-
default: 'Label',
|
|
62
|
-
},
|
|
63
|
-
description: {
|
|
64
|
-
type: 'string',
|
|
65
|
-
category: 'Content',
|
|
66
|
-
label: 'Description',
|
|
67
|
-
},
|
|
68
|
-
helperText: {
|
|
69
|
-
type: 'string',
|
|
70
|
-
category: 'Content',
|
|
71
|
-
label: 'Helper text',
|
|
72
|
-
},
|
|
73
|
-
required: {
|
|
74
|
-
type: 'boolean',
|
|
75
|
-
category: 'Validation',
|
|
76
|
-
label: 'Required',
|
|
77
|
-
default: false,
|
|
78
|
-
},
|
|
79
|
-
invalid: {
|
|
80
|
-
type: 'boolean',
|
|
81
|
-
category: 'Validation',
|
|
82
|
-
label: 'Invalid',
|
|
83
|
-
default: false,
|
|
84
|
-
},
|
|
85
|
-
disabled: {
|
|
86
|
-
type: 'boolean',
|
|
87
|
-
category: 'State',
|
|
88
|
-
label: 'Disabled',
|
|
89
|
-
default: false,
|
|
90
|
-
},
|
|
91
|
-
readOnly: {
|
|
92
|
-
type: 'boolean',
|
|
93
|
-
category: 'State',
|
|
94
|
-
label: 'Read-only',
|
|
95
|
-
default: false,
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
} as const satisfies ZoraComponentMeta;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { FormField } from './FormField';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { FieldProps as SurfaceFieldProps } from '@ankhorage/surface';
|
|
2
|
-
import type React from 'react';
|
|
3
|
-
|
|
4
|
-
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
5
|
-
|
|
6
|
-
export interface FormFieldProps
|
|
7
|
-
extends
|
|
8
|
-
ZoraBaseProps,
|
|
9
|
-
Pick<
|
|
10
|
-
Omit<SurfaceFieldProps, 'mode' | 'themeId'>,
|
|
11
|
-
'children' | 'disabled' | 'errorText' | 'invalid' | 'readOnly' | 'required'
|
|
12
|
-
> {
|
|
13
|
-
label: React.ReactNode;
|
|
14
|
-
description?: React.ReactNode;
|
|
15
|
-
helperText?: React.ReactNode;
|
|
16
|
-
}
|