@ankhorage/zora 9.0.1 → 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 +17 -0
- package/README.md +2 -2
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -1
- 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/adapters/inbound/KeyboardAvoidingView.d.ts +5 -0
- package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.d.ts.map +1 -0
- package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.js +10 -0
- package/dist/features/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.js.map +1 -0
- package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts +36 -0
- package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts.map +1 -0
- package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.js +37 -0
- package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.js.map +1 -0
- package/dist/features/keyboard-avoiding-view/public.d.ts +3 -0
- package/dist/features/keyboard-avoiding-view/public.d.ts.map +1 -0
- package/dist/features/keyboard-avoiding-view/public.js +3 -0
- package/dist/features/keyboard-avoiding-view/public.js.map +1 -0
- 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 +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- 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 +2 -2
- 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 +6 -3
- 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 +3 -3
- 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/dist/types/keyboard-avoiding-view.d.ts +6 -0
- package/dist/types/keyboard-avoiding-view.d.ts.map +1 -0
- package/dist/types/keyboard-avoiding-view.js +2 -0
- package/dist/types/keyboard-avoiding-view.js.map +1 -0
- package/package.json +3 -2
- package/src/audit.test.ts +2 -4
- package/src/constants.ts +2 -1
- 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/keyboard-avoiding-view/adapters/inbound/KeyboardAvoidingView.tsx +18 -0
- package/src/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.ts +38 -0
- package/src/features/keyboard-avoiding-view/public.ts +5 -0
- package/src/features/uploader/adapters/inbound/Uploader.tsx +1 -1
- package/src/index.ts +31 -29
- package/src/metadata/allowedChildren.ts +2 -2
- package/src/metadata/componentMeta.test.ts +32 -2
- package/src/metadata/componentMeta.ts +6 -3
- 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/platformAcceptance.test.ts +1 -1
- package/src/registry.ts +3 -3
- package/src/showcaseCoverage.test.ts +1 -0
- package/src/theme/themeScopeStructure.test.ts +5 -7
- package/src/{components/form/types.ts → types/form.ts} +12 -36
- package/src/types/keyboard-avoiding-view.ts +10 -0
- 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/features/splash-screen/adapters/inbound/SplashScreen.d.ts +0 -11
- package/dist/features/splash-screen/adapters/inbound/SplashScreen.d.ts.map +0 -1
- package/dist/features/splash-screen/adapters/inbound/SplashScreen.js +0 -55
- package/dist/features/splash-screen/adapters/inbound/SplashScreen.js.map +0 -1
- package/dist/features/splash-screen/public.d.ts +0 -3
- package/dist/features/splash-screen/public.d.ts.map +0 -1
- package/dist/features/splash-screen/public.js +0 -2
- package/dist/features/splash-screen/public.js.map +0 -1
- package/dist/features/splash-screen/splashScreenMeta.d.ts +0 -39
- package/dist/features/splash-screen/splashScreenMeta.d.ts.map +0 -1
- package/dist/features/splash-screen/splashScreenMeta.js +0 -40
- package/dist/features/splash-screen/splashScreenMeta.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/dist/types/splash-screen.d.ts +0 -16
- package/dist/types/splash-screen.d.ts.map +0 -1
- package/dist/types/splash-screen.js +0 -2
- package/dist/types/splash-screen.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/features/splash-screen/adapters/inbound/SplashScreen.tsx +0 -98
- package/src/features/splash-screen/public.ts +0 -2
- package/src/features/splash-screen/splashScreenMeta.ts +0 -41
- package/src/patterns/form-field/index.ts +0 -1
- package/src/patterns/form-field/types.ts +0 -16
- package/src/types/splash-screen.ts +0 -18
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Stack } from '../../features/layout/public';
|
|
3
|
-
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
4
|
-
import { FormActions } from './FormActions';
|
|
5
|
-
import { FormError } from './FormError';
|
|
6
|
-
import { FormField } from './FormField';
|
|
7
|
-
import { useFormController } from './useFormController';
|
|
8
|
-
function FormInner({ themeId: _themeId, mode: _mode, fields, values, onChange, onSubmit, errors, error, loading = false, disabled = false, submitLabel = 'Submit', actions, footer, validateOnChange = false, testID, interactionPolicy, }) {
|
|
9
|
-
const controller = useFormController({
|
|
10
|
-
fields,
|
|
11
|
-
values,
|
|
12
|
-
errors,
|
|
13
|
-
onChange,
|
|
14
|
-
onSubmit,
|
|
15
|
-
validateOnChange,
|
|
16
|
-
});
|
|
17
|
-
return (<Stack gap="m" testID={testID}>
|
|
18
|
-
<FormError error={error}/>
|
|
19
|
-
{fields.map((field) => (<FormField key={field.name} disabled={disabled} error={controller.errors[field.name]} field={field} interactionPolicy={interactionPolicy} loading={loading} onChange={controller.setFieldValue} value={values[field.name]}/>))}
|
|
20
|
-
<FormActions disabled={disabled} interactionPolicy={interactionPolicy} loading={loading} onSubmit={() => {
|
|
21
|
-
if (interactionPolicy === 'passive')
|
|
22
|
-
return;
|
|
23
|
-
void controller.handleSubmit();
|
|
24
|
-
}} submitLabel={submitLabel}>
|
|
25
|
-
{actions}
|
|
26
|
-
</FormActions>
|
|
27
|
-
{footer ? <Box>{footer}</Box> : null}
|
|
28
|
-
</Stack>);
|
|
29
|
-
}
|
|
30
|
-
/***
|
|
31
|
-
* Composes fields and actions into a validated form layout.
|
|
32
|
-
*/
|
|
33
|
-
export const Form = withZoraThemeScope(FormInner);
|
|
34
|
-
//# sourceMappingURL=Form.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sourceRoot":"","sources":["../../../src/components/form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,SAAS,SAAS,CAAgC,EAChD,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,WAAW,GAAG,QAAQ,EACtB,OAAO,EACP,MAAM,EACN,gBAAgB,GAAG,KAAK,EACxB,MAAM,EACN,iBAAiB,GACA;IACjB,MAAM,UAAU,GAAG,iBAAiB,CAAC;Q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EAAE,KAAK,CAAC,CACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport { Box, Stack } from '../../features/layout/public';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport { FormActions } from './FormActions';\nimport { FormError } from './FormError';\nimport { FormField } from './FormField';\nimport type { FormProps } from './types';\nimport { useFormController } from './useFormController';\n\nfunction FormInner<TName extends string = string>({\n themeId: _themeId,\n mode: _mode,\n fields,\n values,\n onChange,\n onSubmit,\n errors,\n error,\n loading = false,\n disabled = false,\n submitLabel = 'Submit',\n actions,\n footer,\n validateOnChange = false,\n testID,\n interactionPolicy,\n}: FormProps<TName>) {\n const controller = useFormController({\n fields,\n values,\n errors,\n onChange,\n onSubmit,\n validateOnChange,\n });\n\n return (\n <Stack gap=\"m\" testID={testID}>\n <FormError error={error} />\n {fields.map((field) => (\n <FormField\n key={field.name}\n disabled={disabled}\n error={controller.errors[field.name]}\n field={field}\n interactionPolicy={interactionPolicy}\n loading={loading}\n onChange={controller.setFieldValue}\n value={values[field.name]}\n />\n ))}\n <FormActions\n disabled={disabled}\n interactionPolicy={interactionPolicy}\n loading={loading}\n onSubmit={() => {\n if (interactionPolicy === 'passive') return;\n\n void controller.handleSubmit();\n }}\n submitLabel={submitLabel}\n >\n {actions}\n </FormActions>\n {footer ? <Box>{footer}</Box> : null}\n </Stack>\n );\n}\n\n/***\n * Composes fields and actions into a validated form layout.\n */\nexport const Form = withZoraThemeScope(FormInner);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA6BhD;;GAEG;AACH,eAAO,MAAM,WAAW,wDAAuC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormActions.js","sourceRoot":"","sources":["../../../src/components/form/FormActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,SAAS,gBAAgB,CAAC,EACxB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,WAAW,GAAG,QAAQ,EACtB,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,iBAAiB,GACA;IACjB,OAAO,CACL,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAC5B;MAAA,CAAC,MAAM,CACL,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,SAAS,CACT,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,OAAO,CAAC,CAAC,QAAQ,CAAC,CAElB;QAAA,CAAC,WAAW,CACd;MAAA,EAAE,MAAM,CACR;MAAA,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAC1C;IAAA,EAAE,KAAK,CAAC,CACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport { Button } from '../../features/button/public';\nimport { Box, Stack } from '../../features/layout/public';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type { FormActionsProps } from './types';\n\nfunction FormActionsInner({\n themeId: _themeId,\n mode: _mode,\n submitLabel = 'Submit',\n loading = false,\n disabled = false,\n onSubmit,\n children,\n testID,\n interactionPolicy,\n}: FormActionsProps) {\n return (\n <Stack gap=\"s\" testID={testID}>\n <Button\n disabled={disabled}\n fullWidth\n interactionPolicy={interactionPolicy}\n loading={loading}\n onPress={onSubmit}\n >\n {submitLabel}\n </Button>\n {children ? <Box>{children}</Box> : null}\n </Stack>\n );\n}\n\n/***\n * Standard submit/action area for forms.\n */\nexport const FormActions = withZoraThemeScope(FormActionsInner);\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { FormErrorProps } from './types';
|
|
3
|
-
/***
|
|
4
|
-
* Displays a form-level validation or submission error message.
|
|
5
|
-
*/
|
|
6
|
-
export declare const FormError: (props: FormErrorProps) => React.ReactElement | null;
|
|
7
|
-
//# sourceMappingURL=FormError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormError.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormError.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAwB9C;;GAEG;AACH,eAAO,MAAM,SAAS,sDAAqC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box } from '../../features/layout/public';
|
|
3
|
-
import { Text } from '../../features/typography/public';
|
|
4
|
-
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
5
|
-
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
6
|
-
function FormErrorInner({ themeId: _themeId, mode: _mode, error, testID, interactionPolicy: _interactionPolicy, }) {
|
|
7
|
-
const { theme } = useZoraTheme();
|
|
8
|
-
if (!error) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return (<Box borderColor={theme.colors.error} borderWidth={1} p="s" radius="m" testID={testID}>
|
|
12
|
-
<Text color="error" variant="bodySmall">
|
|
13
|
-
{error}
|
|
14
|
-
</Text>
|
|
15
|
-
</Box>);
|
|
16
|
-
}
|
|
17
|
-
/***
|
|
18
|
-
* Displays a form-level validation or submission error message.
|
|
19
|
-
*/
|
|
20
|
-
export const FormError = withZoraThemeScope(FormErrorInner);
|
|
21
|
-
//# sourceMappingURL=FormError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormError.js","sourceRoot":"","sources":["../../../src/components/form/FormError.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,SAAS,cAAc,CAAC,EACtB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,KAAK,EACL,MAAM,EACN,iBAAiB,EAAE,kBAAkB,GACtB;IACf,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,CAAC;IAEjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CACpF;MAAA,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CACrC;QAAA,CAAC,KAAK,CACR;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport { Box } from '../../features/layout/public';\nimport { Text } from '../../features/typography/public';\nimport { useZoraTheme } from '../../theme/useZoraTheme';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type { FormErrorProps } from './types';\n\nfunction FormErrorInner({\n themeId: _themeId,\n mode: _mode,\n error,\n testID,\n interactionPolicy: _interactionPolicy,\n}: FormErrorProps) {\n const { theme } = useZoraTheme();\n\n if (!error) {\n return null;\n }\n\n return (\n <Box borderColor={theme.colors.error} borderWidth={1} p=\"s\" radius=\"m\" testID={testID}>\n <Text color=\"error\" variant=\"bodySmall\">\n {error}\n </Text>\n </Box>\n );\n}\n\n/***\n * Displays a form-level validation or submission error message.\n */\nexport const FormError = withZoraThemeScope(FormErrorInner);\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { FormFieldProps } from './types';
|
|
3
|
-
/***
|
|
4
|
-
* Connects a controlled form value to a labeled input field with error handling.
|
|
5
|
-
*/
|
|
6
|
-
export declare const FormField: <TName extends string = string>(props: FormFieldProps<TName>) => React.ReactElement | null;
|
|
7
|
-
//# sourceMappingURL=FormField.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAA0C,cAAc,EAAE,MAAM,SAAS,CAAC;AAkJtF;;GAEG;AACH,eAAO,MAAM,SAAS,GArEE,KAAK,SAAS,MAAM,qEAqEe,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Field } from '@ankhorage/surface';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { TextInput } from '../../features/form/text-input/public';
|
|
4
|
-
import { Stack } from '../../features/layout/public';
|
|
5
|
-
import { Text } from '../../features/typography/public';
|
|
6
|
-
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
7
|
-
import { hasRequiredRule } from './validation';
|
|
8
|
-
function isControlFieldProps(props) {
|
|
9
|
-
return 'field' in props;
|
|
10
|
-
}
|
|
11
|
-
function resolveKeyboardType(field) {
|
|
12
|
-
if (field.keyboardType) {
|
|
13
|
-
return field.keyboardType;
|
|
14
|
-
}
|
|
15
|
-
if (field.type === 'email') {
|
|
16
|
-
return 'email-address';
|
|
17
|
-
}
|
|
18
|
-
if (field.type === 'number' || field.type === 'otp') {
|
|
19
|
-
return 'number-pad';
|
|
20
|
-
}
|
|
21
|
-
if (field.type === 'tel') {
|
|
22
|
-
return 'phone-pad';
|
|
23
|
-
}
|
|
24
|
-
if (field.type === 'url') {
|
|
25
|
-
return 'url';
|
|
26
|
-
}
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
function resolveAutoCapitalize(field) {
|
|
30
|
-
if (field.autoCapitalize) {
|
|
31
|
-
return field.autoCapitalize;
|
|
32
|
-
}
|
|
33
|
-
if (['email', 'password', 'url'].includes(field.type ?? 'text')) {
|
|
34
|
-
return 'none';
|
|
35
|
-
}
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
function resolveTextContentType(field) {
|
|
39
|
-
if (field.textContentType) {
|
|
40
|
-
return field.textContentType;
|
|
41
|
-
}
|
|
42
|
-
if (field.type === 'email') {
|
|
43
|
-
return 'emailAddress';
|
|
44
|
-
}
|
|
45
|
-
if (field.type === 'password') {
|
|
46
|
-
return 'password';
|
|
47
|
-
}
|
|
48
|
-
if (field.type === 'otp') {
|
|
49
|
-
return 'oneTimeCode';
|
|
50
|
-
}
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
function renderLabel(label, description) {
|
|
54
|
-
return (<Stack gap="xs">
|
|
55
|
-
<Text variant="label" weight="semiBold">
|
|
56
|
-
{label}
|
|
57
|
-
</Text>
|
|
58
|
-
{description ? (<Text emphasis="muted" variant="bodySmall">
|
|
59
|
-
{description}
|
|
60
|
-
</Text>) : null}
|
|
61
|
-
</Stack>);
|
|
62
|
-
}
|
|
63
|
-
function FormFieldInner(props) {
|
|
64
|
-
if (!isControlFieldProps(props)) {
|
|
65
|
-
const { themeId: _themeId, mode: _mode, label, description, helperText, children, interactionPolicy: _interactionPolicy, ...fieldProps } = props;
|
|
66
|
-
return (<Field {...fieldProps} helperText={helperText} label={renderLabel(label, description)}>
|
|
67
|
-
{children}
|
|
68
|
-
</Field>);
|
|
69
|
-
}
|
|
70
|
-
const { themeId: _themeId, mode: _mode, field, value, error, disabled = false, loading = false, onChange, testID, interactionPolicy, } = props;
|
|
71
|
-
const fieldDisabled = disabled || loading || field.disabled;
|
|
72
|
-
const required = field.required ?? hasRequiredRule(field.rules);
|
|
73
|
-
return (<Field disabled={fieldDisabled} errorText={error} helperText={field.helperText} invalid={Boolean(error)} label={renderLabel(field.label, field.description)} readOnly={field.readOnly} required={required} testID={testID ?? field.testID}>
|
|
74
|
-
<TextInput accessibilityLabel={typeof field.label === 'string' ? field.label : undefined} autoCapitalize={resolveAutoCapitalize(field)} autoComplete={field.autoComplete} disabled={fieldDisabled} interactionPolicy={interactionPolicy} invalid={Boolean(error)} keyboardType={resolveKeyboardType(field)} maxLength={field.maxLength} onChangeText={(nextValue) => onChange(field.name, nextValue)} placeholder={field.placeholder} readOnly={field.readOnly} secureTextEntry={field.secureTextEntry ?? field.type === 'password'} textContentType={resolveTextContentType(field)} value={value}/>
|
|
75
|
-
</Field>);
|
|
76
|
-
}
|
|
77
|
-
/***
|
|
78
|
-
* Connects a controlled form value to a labeled input field with error handling.
|
|
79
|
-
*/
|
|
80
|
-
export const FormField = withZoraThemeScope(FormFieldInner);
|
|
81
|
-
//# sourceMappingURL=FormField.js.map
|
|
@@ -1 +0,0 @@
|
|
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AC,CAAC,CAAC,SAAS,CAAC,CAC9E,cAAc,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAC7C,YAAY,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CACjC,QAAQ,CAAC,CAAC,aAAa,CAAC,CACxB,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CACxB,YAAY,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CACzC,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAC3B,YAAY,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAC7D,WAAW,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAC/B,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CACzB,eAAe,CAAC,CAAC,KAAK,CAAC,eAAe,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CACpE,eAAe,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAC/C,KAAK,CAAC,CAAC,KAAK,CAAC,EAEjB;IAAA,EAAE,KAAK,CAAC,CACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import { Field } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { TextInput } from '../../features/form/text-input/public';\nimport { Stack } from '../../features/layout/public';\nimport { Text } from '../../features/typography/public';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type { FormFieldConfig, FormFieldControlProps, FormFieldProps } from './types';\nimport { hasRequiredRule } from './validation';\n\nfunction isControlFieldProps<TName extends string>(\n props: FormFieldProps<TName>,\n): props is FormFieldControlProps<TName> {\n return 'field' in props;\n}\n\nfunction resolveKeyboardType(field: FormFieldConfig) {\n if (field.keyboardType) {\n return field.keyboardType;\n }\n\n if (field.type === 'email') {\n return 'email-address';\n }\n\n if (field.type === 'number' || field.type === 'otp') {\n return 'number-pad';\n }\n\n if (field.type === 'tel') {\n return 'phone-pad';\n }\n\n if (field.type === 'url') {\n return 'url';\n }\n\n return undefined;\n}\n\nfunction resolveAutoCapitalize(field: FormFieldConfig) {\n if (field.autoCapitalize) {\n return field.autoCapitalize;\n }\n\n if (['email', 'password', 'url'].includes(field.type ?? 'text')) {\n return 'none';\n }\n\n return undefined;\n}\n\nfunction resolveTextContentType(field: FormFieldConfig) {\n if (field.textContentType) {\n return field.textContentType;\n }\n\n if (field.type === 'email') {\n return 'emailAddress';\n }\n\n if (field.type === 'password') {\n return 'password';\n }\n\n if (field.type === 'otp') {\n return 'oneTimeCode';\n }\n\n return undefined;\n}\n\nfunction renderLabel(label: React.ReactNode, description: React.ReactNode | undefined) {\n return (\n <Stack gap=\"xs\">\n <Text variant=\"label\" weight=\"semiBold\">\n {label}\n </Text>\n {description ? (\n <Text emphasis=\"muted\" variant=\"bodySmall\">\n {description}\n </Text>\n ) : null}\n </Stack>\n );\n}\n\nfunction FormFieldInner<TName extends string = string>(props: FormFieldProps<TName>) {\n if (!isControlFieldProps(props)) {\n const {\n themeId: _themeId,\n mode: _mode,\n label,\n description,\n helperText,\n children,\n interactionPolicy: _interactionPolicy,\n ...fieldProps\n } = props;\n\n return (\n <Field {...fieldProps} helperText={helperText} label={renderLabel(label, description)}>\n {children}\n </Field>\n );\n }\n\n const {\n themeId: _themeId,\n mode: _mode,\n field,\n value,\n error,\n disabled = false,\n loading = false,\n onChange,\n testID,\n interactionPolicy,\n } = props;\n const fieldDisabled = disabled || loading || field.disabled;\n const required = field.required ?? hasRequiredRule(field.rules);\n\n return (\n <Field\n disabled={fieldDisabled}\n errorText={error}\n helperText={field.helperText}\n invalid={Boolean(error)}\n label={renderLabel(field.label, field.description)}\n readOnly={field.readOnly}\n required={required}\n testID={testID ?? field.testID}\n >\n <TextInput\n accessibilityLabel={typeof field.label === 'string' ? field.label : undefined}\n autoCapitalize={resolveAutoCapitalize(field)}\n autoComplete={field.autoComplete}\n disabled={fieldDisabled}\n interactionPolicy={interactionPolicy}\n invalid={Boolean(error)}\n keyboardType={resolveKeyboardType(field)}\n maxLength={field.maxLength}\n onChangeText={(nextValue) => onChange(field.name, nextValue)}\n placeholder={field.placeholder}\n readOnly={field.readOnly}\n secureTextEntry={field.secureTextEntry ?? field.type === 'password'}\n textContentType={resolveTextContentType(field)}\n value={value}\n />\n </Field>\n );\n}\n\n/***\n * Connects a controlled form value to a labeled input field with error handling.\n */\nexport const FormField = withZoraThemeScope(FormFieldInner);\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { Form } from './Form';
|
|
2
|
-
export { FormActions } from './FormActions';
|
|
3
|
-
export { FormError } from './FormError';
|
|
4
|
-
export { FormField } from './FormField';
|
|
5
|
-
export type { FormActionsProps, FormErrorProps, FormErrors, FormFieldConfig, FormFieldControlProps, FormFieldInputType, FormFieldProps, FormProps, FormValidationErrors, FormValidationResult, FormValues, UseFormControllerOptions, UseFormControllerResult, ValidationRule, } from './types';
|
|
6
|
-
export { useFormController } from './useFormController';
|
|
7
|
-
export { hasRequiredRule, validateField, validateFields, validateValue } from './validation';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACV,wBAAwB,EACxB,uBAAuB,EACvB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { Form } from './Form';
|
|
2
|
-
export { FormActions } from './FormActions';
|
|
3
|
-
export { FormError } from './FormError';
|
|
4
|
-
export { FormField } from './FormField';
|
|
5
|
-
export { useFormController } from './useFormController';
|
|
6
|
-
export { hasRequiredRule, validateField, validateFields, validateValue } from './validation';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAiBxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { Form } from './Form';\nexport { FormActions } from './FormActions';\nexport { FormError } from './FormError';\nexport { FormField } from './FormField';\nexport type {\n FormActionsProps,\n FormErrorProps,\n FormErrors,\n FormFieldConfig,\n FormFieldControlProps,\n FormFieldInputType,\n FormFieldProps,\n FormProps,\n FormValidationErrors,\n FormValidationResult,\n FormValues,\n UseFormControllerOptions,\n UseFormControllerResult,\n ValidationRule,\n} from './types';\nexport { useFormController } from './useFormController';\nexport { hasRequiredRule, validateField, validateFields, validateValue } from './validation';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/components/form/meta.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;CAsBiB,CAAC;AAEvC,eAAO,MAAM,eAAe;;;;;;;CAOU,CAAC;AAEvC,eAAO,MAAM,aAAa;;;;;;;CAOY,CAAC;AAEvC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDY,CAAC"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
export const formMeta = {
|
|
2
|
-
name: 'Form',
|
|
3
|
-
category: 'component',
|
|
4
|
-
directManifestNode: false,
|
|
5
|
-
allowedChildren: [],
|
|
6
|
-
note: 'Form orchestration component; not represented as a manifest node in v1.',
|
|
7
|
-
events: {
|
|
8
|
-
submit: {
|
|
9
|
-
label: 'Submit',
|
|
10
|
-
eventType: 'form.submit',
|
|
11
|
-
description: 'Emitted when the form submits its current values.',
|
|
12
|
-
payloadFields: [
|
|
13
|
-
{
|
|
14
|
-
path: 'payload.values',
|
|
15
|
-
type: 'record',
|
|
16
|
-
label: 'Values',
|
|
17
|
-
description: 'Submitted form values keyed by field name.',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
props: {},
|
|
23
|
-
};
|
|
24
|
-
export const formActionsMeta = {
|
|
25
|
-
name: 'FormActions',
|
|
26
|
-
category: 'component',
|
|
27
|
-
directManifestNode: false,
|
|
28
|
-
allowedChildren: [],
|
|
29
|
-
note: 'Form helper component; not represented as a manifest node in v1.',
|
|
30
|
-
props: {},
|
|
31
|
-
};
|
|
32
|
-
export const formErrorMeta = {
|
|
33
|
-
name: 'FormError',
|
|
34
|
-
category: 'component',
|
|
35
|
-
directManifestNode: false,
|
|
36
|
-
allowedChildren: [],
|
|
37
|
-
note: 'Form helper component; not represented as a manifest node in v1.',
|
|
38
|
-
props: {},
|
|
39
|
-
};
|
|
40
|
-
export const formFieldMeta = {
|
|
41
|
-
name: 'FormField',
|
|
42
|
-
category: 'component',
|
|
43
|
-
directManifestNode: true,
|
|
44
|
-
allowedChildren: ['TextInput'],
|
|
45
|
-
blueprint: {
|
|
46
|
-
label: 'Form field',
|
|
47
|
-
defaultProps: {
|
|
48
|
-
label: 'Label',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
props: {
|
|
52
|
-
label: {
|
|
53
|
-
type: 'string',
|
|
54
|
-
category: 'Content',
|
|
55
|
-
label: 'Label',
|
|
56
|
-
default: 'Label',
|
|
57
|
-
},
|
|
58
|
-
description: {
|
|
59
|
-
type: 'string',
|
|
60
|
-
category: 'Content',
|
|
61
|
-
label: 'Description',
|
|
62
|
-
},
|
|
63
|
-
helperText: {
|
|
64
|
-
type: 'string',
|
|
65
|
-
category: 'Content',
|
|
66
|
-
label: 'Helper text',
|
|
67
|
-
},
|
|
68
|
-
required: {
|
|
69
|
-
type: 'boolean',
|
|
70
|
-
category: 'Validation',
|
|
71
|
-
label: 'Required',
|
|
72
|
-
default: false,
|
|
73
|
-
},
|
|
74
|
-
invalid: {
|
|
75
|
-
type: 'boolean',
|
|
76
|
-
category: 'Validation',
|
|
77
|
-
label: 'Invalid',
|
|
78
|
-
default: false,
|
|
79
|
-
},
|
|
80
|
-
disabled: {
|
|
81
|
-
type: 'boolean',
|
|
82
|
-
category: 'State',
|
|
83
|
-
label: 'Disabled',
|
|
84
|
-
default: false,
|
|
85
|
-
},
|
|
86
|
-
readOnly: {
|
|
87
|
-
type: 'boolean',
|
|
88
|
-
category: 'State',
|
|
89
|
-
label: 'Read-only',
|
|
90
|
-
default: false,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
//# sourceMappingURL=meta.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1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QAAQ;YACd,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,OAAO;SACjB;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,aAAa;SACrB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,aAAa;SACrB;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,YAAY;YACtB,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,KAAK;SACf;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,YAAY;YACtB,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,KAAK;SACf;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,KAAK;SACf;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,KAAK;SACf;KACF;CACmC,CAAC","sourcesContent":["import type { ZoraComponentMeta } from '../../metadata';\n\nexport const formMeta = {\n name: 'Form',\n category: 'component',\n directManifestNode: false,\n allowedChildren: [],\n note: 'Form orchestration component; not represented as a manifest node in v1.',\n events: {\n submit: {\n label: 'Submit',\n eventType: 'form.submit',\n description: 'Emitted when the form submits its current values.',\n payloadFields: [\n {\n path: 'payload.values',\n type: 'record',\n label: 'Values',\n description: 'Submitted form values keyed by field name.',\n },\n ],\n },\n },\n props: {},\n} as const satisfies ZoraComponentMeta;\n\nexport const formActionsMeta = {\n name: 'FormActions',\n category: 'component',\n directManifestNode: false,\n allowedChildren: [],\n note: 'Form helper component; not represented as a manifest node in v1.',\n props: {},\n} as const satisfies ZoraComponentMeta;\n\nexport const formErrorMeta = {\n name: 'FormError',\n category: 'component',\n directManifestNode: false,\n allowedChildren: [],\n note: 'Form helper component; not represented as a manifest node in v1.',\n props: {},\n} as const satisfies ZoraComponentMeta;\n\nexport const formFieldMeta = {\n name: 'FormField',\n category: 'component',\n directManifestNode: true,\n allowedChildren: ['TextInput'],\n blueprint: {\n label: 'Form field',\n defaultProps: {\n label: 'Label',\n },\n },\n props: {\n label: {\n type: 'string',\n category: 'Content',\n label: 'Label',\n default: 'Label',\n },\n description: {\n type: 'string',\n category: 'Content',\n label: 'Description',\n },\n helperText: {\n type: 'string',\n category: 'Content',\n label: 'Helper text',\n },\n required: {\n type: 'boolean',\n category: 'Validation',\n label: 'Required',\n default: false,\n },\n invalid: {\n type: 'boolean',\n category: 'Validation',\n label: 'Invalid',\n default: false,\n },\n disabled: {\n type: 'boolean',\n category: 'State',\n label: 'Disabled',\n default: false,\n },\n readOnly: {\n type: 'boolean',\n category: 'State',\n label: 'Read-only',\n default: false,\n },\n },\n} as const satisfies ZoraComponentMeta;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/form/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAA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EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IACpE,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC/C,aAAa,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5D,QAAQ,EAAE,MAAM,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC5C,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/form/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { FieldProps as SurfaceFieldProps } from '@ankhorage/surface';\nimport type React from 'react';\n\nimport type { ZoraBaseProps } from '../../theme/ZoraBaseProps';\nimport type { TextInputProps } from '../../types/text-input';\n\nexport type ValidationRule =\n | { kind: 'required'; message?: string }\n | { kind: 'email'; message?: string }\n | { kind: 'minLength'; value: number; message?: string }\n | { kind: 'pattern'; value: string; message?: string };\n\nexport type FormFieldValue = string;\nexport type FormValues<TName extends string = string> = Record<TName, FormFieldValue>;\nexport type FormErrors<TName extends string = string> = Partial<Record<TName, React.ReactNode>>;\nexport type FormValidationErrors<TName extends string = string> = Partial<Record<TName, string>>;\n\nexport type FormFieldInputType = 'email' | 'number' | 'otp' | 'password' | 'tel' | 'text' | 'url';\n\nexport interface FormFieldConfig<TName extends string = string> {\n name: TName;\n label: React.ReactNode;\n description?: React.ReactNode;\n helperText?: React.ReactNode;\n type?: FormFieldInputType;\n placeholder?: string;\n rules?: readonly ValidationRule[];\n autoCapitalize?: TextInputProps['autoCapitalize'];\n autoComplete?: TextInputProps['autoComplete'];\n keyboardType?: TextInputProps['keyboardType'];\n maxLength?: TextInputProps['maxLength'];\n readOnly?: boolean;\n required?: boolean;\n secureTextEntry?: boolean;\n textContentType?: TextInputProps['textContentType'];\n disabled?: boolean;\n testID?: string;\n}\n\ninterface FormFieldWrapperProps\n extends\n ZoraBaseProps,\n Pick<\n Omit<SurfaceFieldProps, 'mode' | 'themeId'>,\n 'children' | 'disabled' | 'errorText' | 'invalid' | 'readOnly' | 'required'\n > {\n label: React.ReactNode;\n description?: React.ReactNode;\n helperText?: React.ReactNode;\n}\n\nexport interface FormFieldControlProps<TName extends string = string> extends ZoraBaseProps {\n field: FormFieldConfig<TName>;\n value: FormFieldValue;\n onChange: (name: TName, value: FormFieldValue) => void;\n error?: React.ReactNode;\n disabled?: boolean;\n loading?: boolean;\n}\n\nexport type FormFieldProps<TName extends string = string> =\n FormFieldControlProps<TName> | FormFieldWrapperProps;\n\nexport interface FormActionsProps extends ZoraBaseProps {\n submitLabel?: React.ReactNode;\n loading?: boolean;\n disabled?: boolean;\n onSubmit?: () => void;\n children?: React.ReactNode;\n}\n\nexport interface FormErrorProps extends ZoraBaseProps {\n error?: React.ReactNode;\n}\n\nexport interface FormProps<TName extends string = string> extends ZoraBaseProps {\n fields: readonly FormFieldConfig<TName>[];\n values: FormValues<TName>;\n onChange: (values: FormValues<TName>) => void;\n onSubmit: (values: FormValues<TName>) => void | Promise<void>;\n errors?: FormErrors<TName>;\n error?: React.ReactNode;\n loading?: boolean;\n disabled?: boolean;\n submitLabel?: React.ReactNode;\n actions?: React.ReactNode;\n footer?: React.ReactNode;\n validateOnChange?: boolean;\n}\n\nexport interface FormValidationResult<TName extends string = string> {\n errors: FormValidationErrors<TName>;\n valid: boolean;\n}\n\nexport interface UseFormControllerOptions<TName extends string = string> {\n fields: readonly FormFieldConfig<TName>[];\n initialValues?: Partial<FormValues<TName>>;\n values?: FormValues<TName>;\n errors?: FormErrors<TName>;\n onChange?: (values: FormValues<TName>) => void;\n onSubmit?: (values: FormValues<TName>) => void | Promise<void>;\n validateOnChange?: boolean;\n}\n\nexport interface UseFormControllerResult<TName extends string = string> {\n values: FormValues<TName>;\n errors: FormErrors<TName>;\n setValues: (values: FormValues<TName>) => void;\n setFieldValue: (name: TName, value: FormFieldValue) => void;\n validate: () => FormValidationResult<TName>;\n handleSubmit: () => Promise<void>;\n reset: () => void;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFormController.d.ts","sourceRoot":"","sources":["../../../src/components/form/useFormController.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAejB,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,EAC/D,MAAM,EACN,aAAa,EACb,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,cAAc,EACtB,QAAQ,EACR,QAAQ,EACR,gBAAwB,GACzB,EAAE,wBAAwB,CAAC,KAAK,CAAC,GAAG,uBAAuB,CAAC,KAAK,CAAC,CA4ElE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFormController.js","sourceRoot":"","sources":["../../../src/components/form/useFormController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO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W,CAAC,GAAG,EAAE;QACnC,mBAAmB,CAAC,EAAE,CAAC,CAAC;QACxB,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC/B,CAAC,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;IAEnC,OAAO;QACL,MAAM;QACN,MAAM;QACN,SAAS;QACT,aAAa;QACb,QAAQ;QACR,YAAY;QACZ,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport type {\n FormErrors,\n FormFieldValue,\n FormValues,\n UseFormControllerOptions,\n UseFormControllerResult,\n} from './types';\nimport { validateFields } from './validation';\n\nfunction createInitialValues<TName extends string>(\n fields: readonly { name: TName }[],\n initialValues: Partial<FormValues<TName>> | undefined,\n): FormValues<TName> {\n const values = fields.reduce<Record<string, FormFieldValue>>((nextValues, field) => {\n nextValues[field.name] = initialValues?.[field.name] ?? '';\n return nextValues;\n }, {});\n\n return values as FormValues<TName>;\n}\n\nexport function useFormController<TName extends string = string>({\n fields,\n initialValues,\n values: controlledValues,\n errors: externalErrors,\n onChange,\n onSubmit,\n validateOnChange = false,\n}: UseFormControllerOptions<TName>): UseFormControllerResult<TName> {\n const [initialFormValues] = React.useState<FormValues<TName>>(() =>\n createInitialValues(fields, initialValues),\n );\n const [internalValues, setInternalValues] = React.useState<FormValues<TName>>(\n () => initialFormValues,\n );\n const [validationErrors, setValidationErrors] = React.useState<FormErrors<TName>>({});\n\n const values = controlledValues ?? internalValues;\n const errors = React.useMemo(\n () => ({\n ...validationErrors,\n ...externalErrors,\n }),\n [externalErrors, validationErrors],\n );\n\n const setValues = React.useCallback(\n (nextValues: FormValues<TName>) => {\n if (!controlledValues) {\n setInternalValues(nextValues);\n }\n\n onChange?.(nextValues);\n },\n [controlledValues, onChange],\n );\n\n const validate = React.useCallback(() => {\n const result = validateFields(fields, values);\n setValidationErrors(result.errors);\n return result;\n }, [fields, values]);\n\n const setFieldValue = React.useCallback(\n (name: TName, value: FormFieldValue) => {\n const nextValues = {\n ...values,\n [name]: value,\n };\n\n setValues(nextValues);\n\n if (validateOnChange) {\n const result = validateFields(fields, nextValues);\n setValidationErrors(result.errors);\n }\n },\n [fields, setValues, validateOnChange, values],\n );\n\n const handleSubmit = React.useCallback(async () => {\n const result = validate();\n\n if (!result.valid) {\n return;\n }\n\n await onSubmit?.(values);\n }, [onSubmit, validate, values]);\n\n const reset = React.useCallback(() => {\n setValidationErrors({});\n setValues(initialFormValues);\n }, [initialFormValues, setValues]);\n\n return {\n values,\n errors,\n setValues,\n setFieldValue,\n validate,\n handleSubmit,\n reset,\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/components/form/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAEf,oBAAoB,EACpB,UAAU,EACV,cAAc,EACf,MAAM,SAAS,CAAC;AAIjB,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,GAAG,OAAO,CAErF;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,GAC3C,MAAM,GAAG,SAAS,CAsCpB;AAED,wBAAgB,aAAa,CAAC,KAAK,SAAS,MAAM,EAChD,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,EAC7B,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,GACxB,MAAM,GAAG,SAAS,CAEpB;AAED,wBAAgB,cAAc,CAAC,KAAK,SAAS,MAAM,EACjD,MAAM,EAAE,SAAS,eAAe,CAAC,KAAK,CAAC,EAAE,EACzC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,GACxB,oBAAoB,CAAC,KAAK,CAAC,CAe7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/components/form/validation.ts"],"names":[],"mappings":"AA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oBACvD,OAAO,IAAI,CAAC,OAAO,IAAI,sBAAsB,CAAC;gBAChD,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC,OAAO,IAAI,sBAAsB,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,KAA6B,EAC7B,MAAyB;IAEzB,OAAO,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAyC,EACzC,MAAyB;IAEzB,MAAM,MAAM,GAAgC,EAAE,CAAC;IAE/C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE3C,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;KACxC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n FormFieldConfig,\n FormValidationErrors,\n FormValidationResult,\n FormValues,\n ValidationRule,\n} from './types';\n\nconst emailPattern = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nexport function hasRequiredRule(rules: readonly ValidationRule[] | undefined): boolean {\n return rules?.some((rule) => rule.kind === 'required') ?? false;\n}\n\nexport function validateValue(\n value: string,\n rules: readonly ValidationRule[] | undefined,\n): string | undefined {\n if (!rules?.length) {\n return undefined;\n }\n\n for (const rule of rules) {\n const normalizedValue = value.trim();\n\n if (rule.kind === 'required' && normalizedValue.length === 0) {\n return rule.message ?? 'This field is required.';\n }\n\n if (\n rule.kind === 'email' &&\n normalizedValue.length > 0 &&\n !emailPattern.test(normalizedValue)\n ) {\n return rule.message ?? 'Enter a valid email address.';\n }\n\n if (rule.kind === 'minLength' && value.length < rule.value) {\n return rule.message ?? `Enter at least ${rule.value} characters.`;\n }\n\n if (rule.kind === 'pattern') {\n try {\n const pattern = new RegExp(rule.value);\n\n if (normalizedValue.length > 0 && !pattern.test(value)) {\n return rule.message ?? 'Enter a valid value.';\n }\n } catch {\n return rule.message ?? 'Enter a valid value.';\n }\n }\n }\n\n return undefined;\n}\n\nexport function validateField<TName extends string>(\n field: FormFieldConfig<TName>,\n values: FormValues<TName>,\n): string | undefined {\n return validateValue(values[field.name], field.rules);\n}\n\nexport function validateFields<TName extends string>(\n fields: readonly FormFieldConfig<TName>[],\n values: FormValues<TName>,\n): FormValidationResult<TName> {\n const errors: FormValidationErrors<TName> = {};\n\n for (const field of fields) {\n const error = validateField(field, values);\n\n if (error) {\n errors[field.name] = error;\n }\n }\n\n return {\n errors,\n valid: Object.keys(errors).length === 0,\n };\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { SplashScreenProps } from '../../../../types/splash-screen';
|
|
3
|
-
/***
|
|
4
|
-
* Branded launch/loading surface for previews, web fallbacks, and app bootstrap states.
|
|
5
|
-
*
|
|
6
|
-
* `SplashScreen` is a React-rendered component. It intentionally does not manage
|
|
7
|
-
* Expo's native splash screen lifecycle or replace generated `expo-splash-screen`
|
|
8
|
-
* configuration.
|
|
9
|
-
*/
|
|
10
|
-
export declare const SplashScreen: (props: SplashScreenProps) => React.ReactElement | null;
|
|
11
|
-
//# sourceMappingURL=SplashScreen.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SplashScreen.d.ts","sourceRoot":"","sources":["../../../../../src/features/splash-screen/adapters/inbound/SplashScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,EAAyB,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIhG;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,yDAAwC,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Center } from '../../../../foundation';
|
|
3
|
-
import { useZoraTheme } from '../../../../theme/useZoraTheme';
|
|
4
|
-
import { withZoraThemeScope } from '../../../../theme/withZoraThemeScope';
|
|
5
|
-
import { Box, Stack } from '../../../layout/public';
|
|
6
|
-
import { Heading } from '../../../typography/public';
|
|
7
|
-
import { Text } from '../../../typography/public';
|
|
8
|
-
/***
|
|
9
|
-
* Branded launch/loading surface for previews, web fallbacks, and app bootstrap states.
|
|
10
|
-
*
|
|
11
|
-
* `SplashScreen` is a React-rendered component. It intentionally does not manage
|
|
12
|
-
* Expo's native splash screen lifecycle or replace generated `expo-splash-screen`
|
|
13
|
-
* configuration.
|
|
14
|
-
*/
|
|
15
|
-
export const SplashScreen = withZoraThemeScope(SplashScreenInner);
|
|
16
|
-
function resolveLogoRadius(shape) {
|
|
17
|
-
switch (shape) {
|
|
18
|
-
case 'circle':
|
|
19
|
-
return 9999;
|
|
20
|
-
case 'square':
|
|
21
|
-
return 0;
|
|
22
|
-
case 'rounded':
|
|
23
|
-
default:
|
|
24
|
-
return 28;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function PlaceholderLogo({ label, shape, size }) {
|
|
28
|
-
const { theme } = useZoraTheme();
|
|
29
|
-
const radius = resolveLogoRadius(shape);
|
|
30
|
-
return (<Center accessibilityLabel={label} bg={theme.semantics.action.primary.base} height={size} width={size} style={{ borderRadius: radius }}>
|
|
31
|
-
<Text emphasis="inverse" variant="eyebrow" weight="bold">
|
|
32
|
-
{label.slice(0, 2).toUpperCase()}
|
|
33
|
-
</Text>
|
|
34
|
-
</Center>);
|
|
35
|
-
}
|
|
36
|
-
function SplashScreenInner({ themeId: _themeId, mode: _mode, logo, title, subtitle, children, minHeight = '100%', backgroundColor, logoSize = 96, logoLabel = 'ZORA', logoShape = 'rounded', testID, }) {
|
|
37
|
-
const { theme } = useZoraTheme();
|
|
38
|
-
const background = backgroundColor ?? theme.semantics.neutral.surface;
|
|
39
|
-
const renderedLogo = logo ?? (<PlaceholderLogo label={logoLabel} shape={logoShape} size={logoSize}/>);
|
|
40
|
-
return (<Center bg={background} minHeight={minHeight} p="xl" testID={testID} width="100%">
|
|
41
|
-
<Stack align="center" gap="l" style={{ maxWidth: 360 }}>
|
|
42
|
-
{renderedLogo}
|
|
43
|
-
{title || subtitle ? (<Stack align="center" gap="xs">
|
|
44
|
-
{title ? (<Heading align="center" level={1} size="h1">
|
|
45
|
-
{title}
|
|
46
|
-
</Heading>) : null}
|
|
47
|
-
{subtitle ? (<Text align="center" emphasis="muted" variant="bodySmall">
|
|
48
|
-
{subtitle}
|
|
49
|
-
</Text>) : null}
|
|
50
|
-
</Stack>) : null}
|
|
51
|
-
{children ? <Box width="100%">{children}</Box> : null}
|
|
52
|
-
</Stack>
|
|
53
|
-
</Center>);
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=SplashScreen.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SplashScreen.js","sourceRoot":"","sources":["../../../../../src/features/splash-screen/adapters/inbound/SplashScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD;;;;;;GAMG;AACH,MAAM,CAAC,M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AAI,CACV;UAAA,EAAE,KAAK,CAAC,CACT,CAAC,CAAC,CAAC,IAAI,CACR;QAAA,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CACvD;MAAA,EAAE,KAAK,CACT;IAAA,EAAE,MAAM,CAAC,CACV,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport { Center } from '../../../../foundation';\nimport { useZoraTheme } from '../../../../theme/useZoraTheme';\nimport { withZoraThemeScope } from '../../../../theme/withZoraThemeScope';\nimport type { SplashScreenLogoShape, SplashScreenProps } from '../../../../types/splash-screen';\nimport { Box, Stack } from '../../../layout/public';\nimport { Heading } from '../../../typography/public';\nimport { Text } from '../../../typography/public';\n/***\n * Branded launch/loading surface for previews, web fallbacks, and app bootstrap states.\n *\n * `SplashScreen` is a React-rendered component. It intentionally does not manage\n * Expo's native splash screen lifecycle or replace generated `expo-splash-screen`\n * configuration.\n */\nexport const SplashScreen = withZoraThemeScope(SplashScreenInner);\n\ninterface PlaceholderLogoProps {\n label: string;\n shape: SplashScreenLogoShape;\n size: number;\n}\n\nfunction resolveLogoRadius(shape: SplashScreenLogoShape): number {\n switch (shape) {\n case 'circle':\n return 9999;\n case 'square':\n return 0;\n case 'rounded':\n default:\n return 28;\n }\n}\n\nfunction PlaceholderLogo({ label, shape, size }: PlaceholderLogoProps) {\n const { theme } = useZoraTheme();\n const radius = resolveLogoRadius(shape);\n\n return (\n <Center\n accessibilityLabel={label}\n bg={theme.semantics.action.primary.base}\n height={size}\n width={size}\n style={{ borderRadius: radius }}\n >\n <Text emphasis=\"inverse\" variant=\"eyebrow\" weight=\"bold\">\n {label.slice(0, 2).toUpperCase()}\n </Text>\n </Center>\n );\n}\n\nfunction SplashScreenInner({\n themeId: _themeId,\n mode: _mode,\n logo,\n title,\n subtitle,\n children,\n minHeight = '100%',\n backgroundColor,\n logoSize = 96,\n logoLabel = 'ZORA',\n logoShape = 'rounded',\n testID,\n}: SplashScreenProps) {\n const { theme } = useZoraTheme();\n const background = backgroundColor ?? theme.semantics.neutral.surface;\n const renderedLogo = logo ?? (\n <PlaceholderLogo label={logoLabel} shape={logoShape} size={logoSize} />\n );\n\n return (\n <Center bg={background} minHeight={minHeight} p=\"xl\" testID={testID} width=\"100%\">\n <Stack align=\"center\" gap=\"l\" style={{ maxWidth: 360 }}>\n {renderedLogo}\n {title || subtitle ? (\n <Stack align=\"center\" gap=\"xs\">\n {title ? (\n <Heading align=\"center\" level={1} size=\"h1\">\n {title}\n </Heading>\n ) : null}\n {subtitle ? (\n <Text align=\"center\" emphasis=\"muted\" variant=\"bodySmall\">\n {subtitle}\n </Text>\n ) : null}\n </Stack>\n ) : null}\n {children ? <Box width=\"100%\">{children}</Box> : null}\n </Stack>\n </Center>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/features/splash-screen/public.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/features/splash-screen/public.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export type { SplashScreenLogoShape, SplashScreenProps } from '../../types/splash-screen';\nexport { SplashScreen } from './adapters/inbound/SplashScreen';\n"]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export declare const splashScreenMeta: {
|
|
2
|
-
readonly name: "SplashScreen";
|
|
3
|
-
readonly category: "component";
|
|
4
|
-
readonly directManifestNode: true;
|
|
5
|
-
readonly allowedChildren: readonly ["ActivityIndicator", "Surface", "Avatar", "AvatarGroup", "Badge", "MediaCard", "MetricCard", "Chip", "ChipGroup", "DataTable", "IconButton", "SplashScreen", "Uploader", "FlatList", "SectionList", "BottomSheet", "ProductCard", "Box", "Stack", "Grid", "Container", "Divider", "Text", "Heading", "Icon", "Image", "Button", "ButtonGroup", "RadioGroup", "ThemeModeToggle", "TextInput", "FormField", "Card", "Panel", "Notice", "EmptyState", "SectionHeader", "SettingsRow", "PostCard", "ChatListItem", "MessageBubble", "ProgressRing", "ReaderSurface", "ContentRail", "MissingElement"];
|
|
6
|
-
readonly description: "App content splash presentation; does not control the native launch screen.";
|
|
7
|
-
readonly props: {
|
|
8
|
-
readonly title: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly category: "Content";
|
|
11
|
-
};
|
|
12
|
-
readonly subtitle: {
|
|
13
|
-
readonly type: "string";
|
|
14
|
-
readonly category: "Content";
|
|
15
|
-
};
|
|
16
|
-
readonly minHeight: {
|
|
17
|
-
readonly type: "number";
|
|
18
|
-
readonly category: "Layout";
|
|
19
|
-
};
|
|
20
|
-
readonly backgroundColor: {
|
|
21
|
-
readonly type: "color";
|
|
22
|
-
readonly category: "Style";
|
|
23
|
-
};
|
|
24
|
-
readonly logoSize: {
|
|
25
|
-
readonly type: "number";
|
|
26
|
-
readonly category: "Layout";
|
|
27
|
-
};
|
|
28
|
-
readonly logoLabel: {
|
|
29
|
-
readonly type: "string";
|
|
30
|
-
readonly category: "Accessibility";
|
|
31
|
-
};
|
|
32
|
-
readonly logoShape: {
|
|
33
|
-
readonly type: "enum";
|
|
34
|
-
readonly category: "Style";
|
|
35
|
-
readonly enum: readonly ["circle", "square", "rounded"];
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=splashScreenMeta.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"splashScreenMeta.d.ts","sourceRoot":"","sources":["../../../src/features/splash-screen/splashScreenMeta.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCS,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { CONTAINER_ALLOWED_CHILDREN } from '../../metadata/allowedChildren';
|
|
2
|
-
export const splashScreenMeta = {
|
|
3
|
-
name: 'SplashScreen',
|
|
4
|
-
category: 'component',
|
|
5
|
-
directManifestNode: true,
|
|
6
|
-
allowedChildren: [...CONTAINER_ALLOWED_CHILDREN],
|
|
7
|
-
description: 'App content splash presentation; does not control the native launch screen.',
|
|
8
|
-
props: {
|
|
9
|
-
title: {
|
|
10
|
-
type: 'string',
|
|
11
|
-
category: 'Content',
|
|
12
|
-
},
|
|
13
|
-
subtitle: {
|
|
14
|
-
type: 'string',
|
|
15
|
-
category: 'Content',
|
|
16
|
-
},
|
|
17
|
-
minHeight: {
|
|
18
|
-
type: 'number',
|
|
19
|
-
category: 'Layout',
|
|
20
|
-
},
|
|
21
|
-
backgroundColor: {
|
|
22
|
-
type: 'color',
|
|
23
|
-
category: 'Style',
|
|
24
|
-
},
|
|
25
|
-
logoSize: {
|
|
26
|
-
type: 'number',
|
|
27
|
-
category: 'Layout',
|
|
28
|
-
},
|
|
29
|
-
logoLabel: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
category: 'Accessibility',
|
|
32
|
-
},
|
|
33
|
-
logoShape: {
|
|
34
|
-
type: 'enum',
|
|
35
|
-
category: 'Style',
|
|
36
|
-
enum: ['circle', 'square', 'rounded'],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=splashScreenMeta.js.map
|