@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.
Files changed (196) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -1
  3. package/dist/constants.d.ts +1 -0
  4. package/dist/constants.d.ts.map +1 -1
  5. package/dist/constants.js +1 -0
  6. package/dist/constants.js.map +1 -1
  7. package/dist/features/bottom-sheet/bottomSheetMeta.d.ts +1 -1
  8. package/dist/features/card/cardMeta.d.ts +1 -1
  9. package/dist/features/card/mediaCardMeta.d.ts +1 -1
  10. package/dist/features/card/postCardMeta.d.ts +1 -1
  11. package/dist/features/form/adapters/inbound/Form.d.ts +5 -0
  12. package/dist/features/form/adapters/inbound/Form.d.ts.map +1 -0
  13. package/dist/features/form/adapters/inbound/Form.js +18 -0
  14. package/dist/features/form/adapters/inbound/Form.js.map +1 -0
  15. package/dist/{components/form → features/form/adapters/inbound}/FormActions.d.ts +1 -1
  16. package/dist/features/form/adapters/inbound/FormActions.d.ts.map +1 -0
  17. package/dist/{components/form → features/form/adapters/inbound}/FormActions.js +3 -3
  18. package/dist/features/form/adapters/inbound/FormActions.js.map +1 -0
  19. package/dist/features/form/adapters/inbound/FormError.d.ts +5 -0
  20. package/dist/features/form/adapters/inbound/FormError.d.ts.map +1 -0
  21. package/dist/features/form/adapters/inbound/FormError.js +18 -0
  22. package/dist/features/form/adapters/inbound/FormError.js.map +1 -0
  23. package/dist/features/form/adapters/inbound/FormField.d.ts +5 -0
  24. package/dist/features/form/adapters/inbound/FormField.d.ts.map +1 -0
  25. package/dist/{patterns/form-field → features/form/adapters/inbound}/FormField.js +5 -4
  26. package/dist/features/form/adapters/inbound/FormField.js.map +1 -0
  27. package/dist/features/form/formActionsMeta.d.ts +9 -0
  28. package/dist/features/form/formActionsMeta.d.ts.map +1 -0
  29. package/dist/features/form/formActionsMeta.js +9 -0
  30. package/dist/features/form/formActionsMeta.js.map +1 -0
  31. package/dist/features/form/formErrorMeta.d.ts +32 -0
  32. package/dist/features/form/formErrorMeta.d.ts.map +1 -0
  33. package/dist/features/form/formErrorMeta.js +19 -0
  34. package/dist/features/form/formErrorMeta.js.map +1 -0
  35. package/dist/{components/form/meta.d.ts → features/form/formFieldMeta.d.ts} +28 -39
  36. package/dist/features/form/formFieldMeta.d.ts.map +1 -0
  37. package/dist/features/form/formFieldMeta.js +35 -0
  38. package/dist/features/form/formFieldMeta.js.map +1 -0
  39. package/dist/features/form/formMeta.d.ts +61 -0
  40. package/dist/features/form/formMeta.d.ts.map +1 -0
  41. package/dist/features/form/formMeta.js +34 -0
  42. package/dist/features/form/formMeta.js.map +1 -0
  43. package/dist/features/form/public.d.ts +8 -0
  44. package/dist/features/form/public.d.ts.map +1 -0
  45. package/dist/features/form/public.js +7 -0
  46. package/dist/features/form/public.js.map +1 -0
  47. package/dist/{components → features}/form/useFormController.d.ts +1 -1
  48. package/dist/features/form/useFormController.d.ts.map +1 -0
  49. package/dist/{components → features}/form/useFormController.js +1 -1
  50. package/dist/features/form/useFormController.js.map +1 -0
  51. package/dist/{components/form → features/form/utils}/validation.d.ts +1 -1
  52. package/dist/features/form/utils/validation.d.ts.map +1 -0
  53. package/dist/{components/form → features/form/utils}/validation.js +2 -4
  54. package/dist/features/form/utils/validation.js.map +1 -0
  55. package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts +1 -1
  56. package/dist/features/layout/boxMeta.d.ts +1 -1
  57. package/dist/features/layout/containerMeta.d.ts +1 -1
  58. package/dist/features/layout/gridMeta.d.ts +1 -1
  59. package/dist/features/layout/stackMeta.d.ts +1 -1
  60. package/dist/features/list/flatListMeta.d.ts +1 -1
  61. package/dist/features/list/sectionListMeta.d.ts +1 -1
  62. package/dist/features/surface/surfaceMeta.d.ts +1 -1
  63. package/dist/features/uploader/adapters/inbound/Uploader.d.ts.map +1 -1
  64. package/dist/features/uploader/adapters/inbound/Uploader.js +1 -1
  65. package/dist/features/uploader/adapters/inbound/Uploader.js.map +1 -1
  66. package/dist/index.d.ts +2 -2
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/layout/screen/meta.d.ts +1 -1
  71. package/dist/layout/screen-section/meta.d.ts +1 -1
  72. package/dist/metadata/allowedChildren.d.ts +3 -3
  73. package/dist/metadata/allowedChildren.d.ts.map +1 -1
  74. package/dist/metadata/allowedChildren.js +1 -1
  75. package/dist/metadata/allowedChildren.js.map +1 -1
  76. package/dist/metadata/bindableComponentMeta.d.ts +2 -2
  77. package/dist/metadata/componentMeta.d.ts.map +1 -1
  78. package/dist/metadata/componentMeta.js +4 -1
  79. package/dist/metadata/componentMeta.js.map +1 -1
  80. package/dist/patterns/auth/AuthForm.d.ts +21 -0
  81. package/dist/patterns/auth/AuthForm.d.ts.map +1 -0
  82. package/dist/patterns/auth/AuthForm.js +19 -0
  83. package/dist/patterns/auth/AuthForm.js.map +1 -0
  84. package/dist/patterns/auth/AuthFormField.d.ts +16 -0
  85. package/dist/patterns/auth/AuthFormField.d.ts.map +1 -0
  86. package/dist/patterns/auth/AuthFormField.js +38 -0
  87. package/dist/patterns/auth/AuthFormField.js.map +1 -0
  88. package/dist/patterns/auth/ForgotPasswordForm.d.ts.map +1 -1
  89. package/dist/patterns/auth/ForgotPasswordForm.js +2 -2
  90. package/dist/patterns/auth/ForgotPasswordForm.js.map +1 -1
  91. package/dist/patterns/auth/OtpForm.d.ts.map +1 -1
  92. package/dist/patterns/auth/OtpForm.js +2 -2
  93. package/dist/patterns/auth/OtpForm.js.map +1 -1
  94. package/dist/patterns/auth/SignInForm.d.ts.map +1 -1
  95. package/dist/patterns/auth/SignInForm.js +2 -2
  96. package/dist/patterns/auth/SignInForm.js.map +1 -1
  97. package/dist/patterns/auth/SignUpForm.d.ts.map +1 -1
  98. package/dist/patterns/auth/SignUpForm.js +2 -2
  99. package/dist/patterns/auth/SignUpForm.js.map +1 -1
  100. package/dist/patterns/auth/types.d.ts +1 -1
  101. package/dist/patterns/auth/types.d.ts.map +1 -1
  102. package/dist/patterns/auth/types.js.map +1 -1
  103. package/dist/patterns/auth/utils.d.ts +1 -1
  104. package/dist/patterns/auth/utils.d.ts.map +1 -1
  105. package/dist/patterns/auth/utils.js.map +1 -1
  106. package/dist/patterns/inspector-field/InspectorField.js +1 -1
  107. package/dist/patterns/inspector-field/InspectorField.js.map +1 -1
  108. package/dist/patterns/message-bubble/meta.d.ts +1 -1
  109. package/dist/patterns/notice/meta.d.ts +1 -1
  110. package/dist/patterns/panel/meta.d.ts +1 -1
  111. package/dist/patterns/reader/meta.d.ts +2 -2
  112. package/dist/patterns/scanner/meta.d.ts +2 -2
  113. package/dist/registry.js +1 -1
  114. package/dist/registry.js.map +1 -1
  115. package/dist/{components/form/types.d.ts → types/form.d.ts} +12 -28
  116. package/dist/types/form.d.ts.map +1 -0
  117. package/dist/types/form.js +2 -0
  118. package/dist/types/form.js.map +1 -0
  119. package/package.json +2 -1
  120. package/src/audit.test.ts +2 -4
  121. package/src/constants.ts +1 -0
  122. package/src/featureManifest.test.ts +7 -0
  123. package/src/features/form/adapters/inbound/Form.tsx +39 -0
  124. package/src/{components/form → features/form/adapters/inbound}/FormActions.tsx +4 -4
  125. package/src/features/form/adapters/inbound/FormError.tsx +22 -0
  126. package/src/{patterns/form-field → features/form/adapters/inbound}/FormField.tsx +6 -4
  127. package/src/features/form/formActionsMeta.ts +9 -0
  128. package/src/features/form/formErrorMeta.ts +19 -0
  129. package/src/features/form/formFieldMeta.ts +35 -0
  130. package/src/features/form/formMeta.ts +34 -0
  131. package/src/{components/form/index.ts → features/form/public.ts} +6 -7
  132. package/src/{components → features}/form/useFormController.ts +2 -2
  133. package/src/{components/form → features/form/utils}/validation.test.ts +4 -1
  134. package/src/{components/form → features/form/utils}/validation.ts +4 -8
  135. package/src/features/uploader/adapters/inbound/Uploader.tsx +1 -1
  136. package/src/index.ts +26 -27
  137. package/src/metadata/allowedChildren.ts +1 -1
  138. package/src/metadata/componentMeta.test.ts +18 -1
  139. package/src/metadata/componentMeta.ts +4 -1
  140. package/src/patterns/auth/AuthForm.tsx +68 -0
  141. package/src/patterns/auth/AuthFormField.tsx +81 -0
  142. package/src/patterns/auth/ForgotPasswordForm.tsx +3 -2
  143. package/src/patterns/auth/OtpForm.tsx +3 -2
  144. package/src/patterns/auth/SignInForm.tsx +3 -2
  145. package/src/patterns/auth/SignUpForm.tsx +3 -2
  146. package/src/patterns/auth/types.ts +1 -1
  147. package/src/patterns/auth/utils.ts +1 -1
  148. package/src/patterns/inspector-field/InspectorField.tsx +1 -1
  149. package/src/registry.ts +1 -1
  150. package/src/theme/themeScopeStructure.test.ts +5 -7
  151. package/src/{components/form/types.ts → types/form.ts} +12 -36
  152. package/dist/components/form/Form.d.ts +0 -7
  153. package/dist/components/form/Form.d.ts.map +0 -1
  154. package/dist/components/form/Form.js +0 -34
  155. package/dist/components/form/Form.js.map +0 -1
  156. package/dist/components/form/FormActions.d.ts.map +0 -1
  157. package/dist/components/form/FormActions.js.map +0 -1
  158. package/dist/components/form/FormError.d.ts +0 -7
  159. package/dist/components/form/FormError.d.ts.map +0 -1
  160. package/dist/components/form/FormError.js +0 -21
  161. package/dist/components/form/FormError.js.map +0 -1
  162. package/dist/components/form/FormField.d.ts +0 -7
  163. package/dist/components/form/FormField.d.ts.map +0 -1
  164. package/dist/components/form/FormField.js +0 -81
  165. package/dist/components/form/FormField.js.map +0 -1
  166. package/dist/components/form/index.d.ts +0 -8
  167. package/dist/components/form/index.d.ts.map +0 -1
  168. package/dist/components/form/index.js +0 -7
  169. package/dist/components/form/index.js.map +0 -1
  170. package/dist/components/form/meta.d.ts.map +0 -1
  171. package/dist/components/form/meta.js +0 -94
  172. package/dist/components/form/meta.js.map +0 -1
  173. package/dist/components/form/types.d.ts.map +0 -1
  174. package/dist/components/form/types.js +0 -2
  175. package/dist/components/form/types.js.map +0 -1
  176. package/dist/components/form/useFormController.d.ts.map +0 -1
  177. package/dist/components/form/useFormController.js.map +0 -1
  178. package/dist/components/form/validation.d.ts.map +0 -1
  179. package/dist/components/form/validation.js.map +0 -1
  180. package/dist/patterns/form-field/FormField.d.ts +0 -4
  181. package/dist/patterns/form-field/FormField.d.ts.map +0 -1
  182. package/dist/patterns/form-field/FormField.js.map +0 -1
  183. package/dist/patterns/form-field/index.d.ts +0 -2
  184. package/dist/patterns/form-field/index.d.ts.map +0 -1
  185. package/dist/patterns/form-field/index.js +0 -2
  186. package/dist/patterns/form-field/index.js.map +0 -1
  187. package/dist/patterns/form-field/types.d.ts +0 -9
  188. package/dist/patterns/form-field/types.d.ts.map +0 -1
  189. package/dist/patterns/form-field/types.js +0 -2
  190. package/dist/patterns/form-field/types.js.map +0 -1
  191. package/src/components/form/Form.tsx +0 -74
  192. package/src/components/form/FormError.tsx +0 -34
  193. package/src/components/form/FormField.tsx +0 -157
  194. package/src/components/form/meta.ts +0 -98
  195. package/src/patterns/form-field/index.ts +0 -1
  196. package/src/patterns/form-field/types.ts +0 -16
@@ -1,20 +1,18 @@
1
1
  import type { FieldProps as SurfaceFieldProps } from '@ankhorage/surface';
2
2
  import type React from 'react';
3
3
 
4
- import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
5
- import type { TextInputProps } from '../../types/text-input';
4
+ import type { ZoraBaseProps } from '../theme/ZoraBaseProps';
5
+ import type { TextInputProps } from './text-input';
6
6
 
7
7
  export type ValidationRule =
8
8
  | { kind: 'required'; message?: string }
9
9
  | { kind: 'email'; message?: string }
10
10
  | { kind: 'minLength'; value: number; message?: string }
11
11
  | { kind: 'pattern'; value: string; message?: string };
12
-
13
12
  export type FormFieldValue = string;
14
13
  export type FormValues<TName extends string = string> = Record<TName, FormFieldValue>;
15
14
  export type FormErrors<TName extends string = string> = Partial<Record<TName, React.ReactNode>>;
16
15
  export type FormValidationErrors<TName extends string = string> = Partial<Record<TName, string>>;
17
-
18
16
  export type FormFieldInputType = 'email' | 'number' | 'otp' | 'password' | 'tel' | 'text' | 'url';
19
17
 
20
18
  export interface FormFieldConfig<TName extends string = string> {
@@ -37,7 +35,16 @@ export interface FormFieldConfig<TName extends string = string> {
37
35
  testID?: string;
38
36
  }
39
37
 
40
- interface FormFieldWrapperProps
38
+ export interface FormProps extends ZoraBaseProps {
39
+ children?: React.ReactNode;
40
+ onSubmit?: () => void | Promise<void>;
41
+ loading?: boolean;
42
+ disabled?: boolean;
43
+ submitLabel?: React.ReactNode;
44
+ actions?: React.ReactNode;
45
+ }
46
+
47
+ export interface FormFieldProps
41
48
  extends
42
49
  ZoraBaseProps,
43
50
  Pick<
@@ -49,18 +56,6 @@ interface FormFieldWrapperProps
49
56
  helperText?: React.ReactNode;
50
57
  }
51
58
 
52
- export interface FormFieldControlProps<TName extends string = string> extends ZoraBaseProps {
53
- field: FormFieldConfig<TName>;
54
- value: FormFieldValue;
55
- onChange: (name: TName, value: FormFieldValue) => void;
56
- error?: React.ReactNode;
57
- disabled?: boolean;
58
- loading?: boolean;
59
- }
60
-
61
- export type FormFieldProps<TName extends string = string> =
62
- FormFieldControlProps<TName> | FormFieldWrapperProps;
63
-
64
59
  export interface FormActionsProps extends ZoraBaseProps {
65
60
  submitLabel?: React.ReactNode;
66
61
  loading?: boolean;
@@ -68,31 +63,13 @@ export interface FormActionsProps extends ZoraBaseProps {
68
63
  onSubmit?: () => void;
69
64
  children?: React.ReactNode;
70
65
  }
71
-
72
66
  export interface FormErrorProps extends ZoraBaseProps {
73
67
  error?: React.ReactNode;
74
68
  }
75
-
76
- export interface FormProps<TName extends string = string> extends ZoraBaseProps {
77
- fields: readonly FormFieldConfig<TName>[];
78
- values: FormValues<TName>;
79
- onChange: (values: FormValues<TName>) => void;
80
- onSubmit: (values: FormValues<TName>) => void | Promise<void>;
81
- errors?: FormErrors<TName>;
82
- error?: React.ReactNode;
83
- loading?: boolean;
84
- disabled?: boolean;
85
- submitLabel?: React.ReactNode;
86
- actions?: React.ReactNode;
87
- footer?: React.ReactNode;
88
- validateOnChange?: boolean;
89
- }
90
-
91
69
  export interface FormValidationResult<TName extends string = string> {
92
70
  errors: FormValidationErrors<TName>;
93
71
  valid: boolean;
94
72
  }
95
-
96
73
  export interface UseFormControllerOptions<TName extends string = string> {
97
74
  fields: readonly FormFieldConfig<TName>[];
98
75
  initialValues?: Partial<FormValues<TName>>;
@@ -102,7 +79,6 @@ export interface UseFormControllerOptions<TName extends string = string> {
102
79
  onSubmit?: (values: FormValues<TName>) => void | Promise<void>;
103
80
  validateOnChange?: boolean;
104
81
  }
105
-
106
82
  export interface UseFormControllerResult<TName extends string = string> {
107
83
  values: FormValues<TName>;
108
84
  errors: FormErrors<TName>;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import type { FormProps } from './types';
3
- /***
4
- * Composes fields and actions into a validated form layout.
5
- */
6
- export declare const Form: <TName extends string = string>(props: FormProps<TName>) => React.ReactElement | null;
7
- //# sourceMappingURL=Form.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA+DzC;;GAEG;AACH,eAAO,MAAM,IAAI,GA/DE,KAAK,SAAS,MAAM,gEA+DU,CAAC"}
@@ -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;QACnC,MAAM;QACN,MAAM;QACN,MA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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 @@
1
- {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/form/FormField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,SAAS,mBAAmB,CAC1B,KAA4B;IAE5B,OAAO,OAAO,IAAI,KAAK,CAAC;AAC1B,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAsB;IACjD,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,YAAY,CAAC;IAC5B,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC3B,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACpD,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACzB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAsB;IACnD,IAAI,KAAK,CAAC,cAAc,EAAE,CAA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R,kBAAkB,CAAC,CAAC,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,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
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/components/form/meta.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,WAAW;IACrB,kBAAkB,EAAE,KAAK;IACzB,eAAe,EAAE,EAAE;IACnB,IAAI,EAAE,yEAAyE;IAC/E,MAAM,EAAE;QACN,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ;YACf,SAAS,EAAE,aAAa;YACxB,WAAW,EAAE,mDAAmD;YAChE,aAAa,EAAE;gBACb;oBACE,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,QAAQ;oBACf,WAAW,EAAE,4CAA4C;iBAC1D;aACF;SACF;KACF;IACD,KAAK,EAAE,EAAE;CAC2B,CAAC;AAEvC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,WAAW;IACrB,kBAAkB,EAAE,KAAK;IACzB,eAAe,EAAE,EAAE;IACnB,IAAI,EAAE,kEAAkE;IACxE,KAAK,EAAE,EAAE;CAC2B,CAAC;AAEvC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,WAAW;IACrB,kBAAkB,EAAE,KAAK;IACzB,eAAe,EAAE,EAAE;IACnB,IAAI,EAAE,kEAAkE;IACxE,KAAK,EAAE,EAAE;CAC2B,CAAC;AAEvC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,WAAW;IACrB,kBAAkB,EAAE,IAAI;IACxB,eAAe,EAAE,CAAC,WAAW,CAAC;IAC9B,SAAS,EAAE;QACT,KAAK,EAAE,YAAY;QACnB,YAAY,EAAE;YACZ,KAAK,EAAE,OAAO;SACf;KACF;IACD,KAAK,EAAE;QACL,KAAK,EAAE;YACL,IAAI,EAAE,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,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
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -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,CAAC;AAS1B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,SAAS,mBAAmB,CAC1B,MAAkC,EAClC,aAAqD;IAErD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAiC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACjF,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,aAAa,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3D,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,MAA2B,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAgC,EAC/D,MAAM,EACN,aAAa,EACb,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,cAAc,EACtB,QAAQ,EACR,QAAQ,EACR,gBAAgB,GAAG,KAAK,GACQ;IAChC,MAAM,CAAC,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAoB,GAAG,EAAE,CACjE,mBAAmB,CAAC,MAAM,EAAE,aAAa,CAAC,CAC3C,CAAC;IACF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CACxD,GAAG,EAAE,CAAC,iBAAiB,CACxB,CAAC;IACF,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAoB,EAAE,CAAC,CAAC;IAEtF,M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K,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;QAChD,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;QAE1B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAEjC,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,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,GA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I,CAAC,KAAK,cAAc,CAAC;QACpE,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAEvC,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;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,4 +0,0 @@
1
- import React from 'react';
2
- import type { FormFieldProps } from './types';
3
- export declare const FormField: (props: FormFieldProps) => React.ReactElement | null;
4
- //# sourceMappingURL=FormField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../src/patterns/form-field/FormField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAiC9C,eAAO,MAAM,SAAS,sDAAqC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/patterns/form-field/FormField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,SAAS,cAAc,CAAC,EACtB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,KAAK,EACL,WAAW,EACX,UAAU,EACV,QAAQ,EACR,GAAG,KAAK,EACO;IACf,OAAO,CACL,CAAC,KAAK,CACJ,IAAI,KAAK,CAAC,CACV,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,KAAK,CAAC,CACJ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CACb;UAAA,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CACrC;YAAA,CAAC,KAAK,CACR;UAAA,EAAE,IAAI,CACN;UAAA,CAAC,WAAW,CAAC,CAAC,CAAC,CACb,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CACxC;cAAA,CAAC,WAAW,CACd;YAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACV;QAAA,EAAE,KAAK,CACT,CAAC,CAED;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,KAAK,CAAC,CACT,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import { Field } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { Stack } from '../../features/layout/public';\nimport { Text } from '../../features/typography/public';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type { FormFieldProps } from './types';\n\nfunction FormFieldInner({\n themeId: _themeId,\n mode: _mode,\n label,\n description,\n helperText,\n children,\n ...props\n}: FormFieldProps) {\n return (\n <Field\n {...props}\n helperText={helperText}\n label={\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 {children}\n </Field>\n );\n}\n\nexport const FormField = withZoraThemeScope(FormFieldInner);\n"]}
@@ -1,2 +0,0 @@
1
- export { FormField } from './FormField';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/form-field/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -1,2 +0,0 @@
1
- export { FormField } from './FormField';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/patterns/form-field/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { FormField } from './FormField';\n"]}
@@ -1,9 +0,0 @@
1
- import type { FieldProps as SurfaceFieldProps } from '@ankhorage/surface';
2
- import type React from 'react';
3
- import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
4
- export interface FormFieldProps extends ZoraBaseProps, Pick<Omit<SurfaceFieldProps, 'mode' | 'themeId'>, 'children' | 'disabled' | 'errorText' | 'invalid' | 'readOnly' | 'required'> {
5
- label: React.ReactNode;
6
- description?: React.ReactNode;
7
- helperText?: React.ReactNode;
8
- }
9
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns/form-field/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;AAE/D,MAAM,WAAW,cACf,SACE,aAAa,EACb,IAAI,CACF,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC,EAC3C,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAC5E;IACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/patterns/form-field/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';\n\nexport interface FormFieldProps\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"]}