@cdx-ui/primitives 0.0.1-alpha.35 → 0.0.1-alpha.36

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 (132) hide show
  1. package/lib/commonjs/{form-control/createFormError.js → field/createFieldError.js} +4 -4
  2. package/lib/commonjs/field/createFieldError.js.map +1 -0
  3. package/lib/commonjs/{form-control/createFormErrorIcon.js → field/createFieldErrorIcon.js} +4 -4
  4. package/lib/commonjs/field/createFieldErrorIcon.js.map +1 -0
  5. package/lib/commonjs/{form-control/createFormErrorText.js → field/createFieldErrorText.js} +4 -4
  6. package/lib/commonjs/field/createFieldErrorText.js.map +1 -0
  7. package/lib/commonjs/{form-control/createFormHelper.js → field/createFieldHelper.js} +4 -4
  8. package/lib/commonjs/field/createFieldHelper.js.map +1 -0
  9. package/lib/commonjs/{form-control/createFormHelperText.js → field/createFieldHelperText.js} +4 -4
  10. package/lib/commonjs/field/createFieldHelperText.js.map +1 -0
  11. package/lib/commonjs/{form-control/createFormLabel.js → field/createFieldLabel.js} +4 -6
  12. package/lib/commonjs/field/createFieldLabel.js.map +1 -0
  13. package/lib/commonjs/{form-control/createFormField.js → field/createFieldRoot.js} +4 -4
  14. package/lib/commonjs/field/createFieldRoot.js.map +1 -0
  15. package/lib/commonjs/field/index.js +46 -0
  16. package/lib/commonjs/field/index.js.map +1 -0
  17. package/lib/commonjs/{form-control → field}/types.js.map +1 -1
  18. package/lib/commonjs/form/createFormRoot.js.map +1 -0
  19. package/lib/commonjs/form/index.js +15 -0
  20. package/lib/commonjs/form/index.js.map +1 -0
  21. package/lib/commonjs/form/types.js +6 -0
  22. package/lib/{module/form-control → commonjs/form}/types.js.map +1 -1
  23. package/lib/commonjs/index.js +16 -4
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/module/{form-control/createFormError.js → field/createFieldError.js} +2 -2
  26. package/lib/module/field/createFieldError.js.map +1 -0
  27. package/lib/module/{form-control/createFormErrorIcon.js → field/createFieldErrorIcon.js} +2 -2
  28. package/lib/module/field/createFieldErrorIcon.js.map +1 -0
  29. package/lib/module/{form-control/createFormErrorText.js → field/createFieldErrorText.js} +2 -2
  30. package/lib/module/field/createFieldErrorText.js.map +1 -0
  31. package/lib/module/{form-control/createFormHelper.js → field/createFieldHelper.js} +2 -2
  32. package/lib/module/field/createFieldHelper.js.map +1 -0
  33. package/lib/module/{form-control/createFormHelperText.js → field/createFieldHelperText.js} +2 -2
  34. package/lib/module/field/createFieldHelperText.js.map +1 -0
  35. package/lib/module/{form-control/createFormLabel.js → field/createFieldLabel.js} +2 -4
  36. package/lib/module/field/createFieldLabel.js.map +1 -0
  37. package/lib/module/{form-control/createFormField.js → field/createFieldRoot.js} +2 -2
  38. package/lib/module/field/createFieldRoot.js.map +1 -0
  39. package/lib/module/field/index.js +42 -0
  40. package/lib/module/field/index.js.map +1 -0
  41. package/lib/module/field/types.js.map +1 -0
  42. package/lib/module/form/createFormRoot.js.map +1 -0
  43. package/lib/module/form/index.js +11 -0
  44. package/lib/module/form/index.js.map +1 -0
  45. package/lib/module/form/types.js +4 -0
  46. package/lib/module/form/types.js.map +1 -0
  47. package/lib/module/index.js +2 -1
  48. package/lib/module/index.js.map +1 -1
  49. package/lib/typescript/field/createFieldError.d.ts +5 -0
  50. package/lib/typescript/field/createFieldError.d.ts.map +1 -0
  51. package/lib/typescript/field/createFieldErrorIcon.d.ts +5 -0
  52. package/lib/typescript/field/createFieldErrorIcon.d.ts.map +1 -0
  53. package/lib/typescript/field/createFieldErrorText.d.ts +5 -0
  54. package/lib/typescript/field/createFieldErrorText.d.ts.map +1 -0
  55. package/lib/typescript/field/createFieldHelper.d.ts +5 -0
  56. package/lib/typescript/field/createFieldHelper.d.ts.map +1 -0
  57. package/lib/typescript/field/createFieldHelperText.d.ts +5 -0
  58. package/lib/typescript/field/createFieldHelperText.d.ts.map +1 -0
  59. package/lib/typescript/field/createFieldLabel.d.ts +6 -0
  60. package/lib/typescript/field/createFieldLabel.d.ts.map +1 -0
  61. package/lib/typescript/field/createFieldRoot.d.ts +6 -0
  62. package/lib/typescript/field/createFieldRoot.d.ts.map +1 -0
  63. package/lib/typescript/field/index.d.ts +13 -0
  64. package/lib/typescript/field/index.d.ts.map +1 -0
  65. package/lib/typescript/{form-control → field}/types.d.ts +14 -24
  66. package/lib/typescript/field/types.d.ts.map +1 -0
  67. package/lib/typescript/form/createFormRoot.d.ts +4 -0
  68. package/lib/typescript/form/createFormRoot.d.ts.map +1 -0
  69. package/lib/typescript/form/index.d.ts +6 -0
  70. package/lib/typescript/form/index.d.ts.map +1 -0
  71. package/lib/typescript/form/types.d.ts +14 -0
  72. package/lib/typescript/form/types.d.ts.map +1 -0
  73. package/lib/typescript/index.d.ts +2 -1
  74. package/lib/typescript/index.d.ts.map +1 -1
  75. package/package.json +2 -2
  76. package/src/{form-control/createFormError.tsx → field/createFieldError.tsx} +1 -1
  77. package/src/{form-control/createFormErrorIcon.tsx → field/createFieldErrorIcon.tsx} +1 -1
  78. package/src/{form-control/createFormErrorText.tsx → field/createFieldErrorText.tsx} +1 -1
  79. package/src/{form-control/createFormHelper.tsx → field/createFieldHelper.tsx} +1 -1
  80. package/src/{form-control/createFormHelperText.tsx → field/createFieldHelperText.tsx} +1 -1
  81. package/src/{form-control/createFormLabel.tsx → field/createFieldLabel.tsx} +3 -3
  82. package/src/{form-control/createFormField.tsx → field/createFieldRoot.tsx} +3 -3
  83. package/src/field/index.tsx +68 -0
  84. package/src/{form-control → field}/types.tsx +28 -42
  85. package/src/{form-control → form}/createFormRoot.tsx +3 -3
  86. package/src/form/index.tsx +12 -0
  87. package/src/form/types.tsx +16 -0
  88. package/src/index.ts +2 -1
  89. package/lib/commonjs/form-control/createFormError.js.map +0 -1
  90. package/lib/commonjs/form-control/createFormErrorIcon.js.map +0 -1
  91. package/lib/commonjs/form-control/createFormErrorText.js.map +0 -1
  92. package/lib/commonjs/form-control/createFormField.js.map +0 -1
  93. package/lib/commonjs/form-control/createFormHelper.js.map +0 -1
  94. package/lib/commonjs/form-control/createFormHelperText.js.map +0 -1
  95. package/lib/commonjs/form-control/createFormLabel.js.map +0 -1
  96. package/lib/commonjs/form-control/createFormRoot.js.map +0 -1
  97. package/lib/commonjs/form-control/index.js +0 -53
  98. package/lib/commonjs/form-control/index.js.map +0 -1
  99. package/lib/module/form-control/createFormError.js.map +0 -1
  100. package/lib/module/form-control/createFormErrorIcon.js.map +0 -1
  101. package/lib/module/form-control/createFormErrorText.js.map +0 -1
  102. package/lib/module/form-control/createFormField.js.map +0 -1
  103. package/lib/module/form-control/createFormHelper.js.map +0 -1
  104. package/lib/module/form-control/createFormHelperText.js.map +0 -1
  105. package/lib/module/form-control/createFormLabel.js.map +0 -1
  106. package/lib/module/form-control/createFormRoot.js.map +0 -1
  107. package/lib/module/form-control/index.js +0 -49
  108. package/lib/module/form-control/index.js.map +0 -1
  109. package/lib/typescript/form-control/createFormError.d.ts +0 -5
  110. package/lib/typescript/form-control/createFormError.d.ts.map +0 -1
  111. package/lib/typescript/form-control/createFormErrorIcon.d.ts +0 -5
  112. package/lib/typescript/form-control/createFormErrorIcon.d.ts.map +0 -1
  113. package/lib/typescript/form-control/createFormErrorText.d.ts +0 -5
  114. package/lib/typescript/form-control/createFormErrorText.d.ts.map +0 -1
  115. package/lib/typescript/form-control/createFormField.d.ts +0 -6
  116. package/lib/typescript/form-control/createFormField.d.ts.map +0 -1
  117. package/lib/typescript/form-control/createFormHelper.d.ts +0 -5
  118. package/lib/typescript/form-control/createFormHelper.d.ts.map +0 -1
  119. package/lib/typescript/form-control/createFormHelperText.d.ts +0 -5
  120. package/lib/typescript/form-control/createFormHelperText.d.ts.map +0 -1
  121. package/lib/typescript/form-control/createFormLabel.d.ts +0 -8
  122. package/lib/typescript/form-control/createFormLabel.d.ts.map +0 -1
  123. package/lib/typescript/form-control/createFormRoot.d.ts +0 -6
  124. package/lib/typescript/form-control/createFormRoot.d.ts.map +0 -1
  125. package/lib/typescript/form-control/index.d.ts +0 -14
  126. package/lib/typescript/form-control/index.d.ts.map +0 -1
  127. package/lib/typescript/form-control/types.d.ts.map +0 -1
  128. package/src/form-control/index.tsx +0 -71
  129. /package/lib/commonjs/{form-control → field}/types.js +0 -0
  130. /package/lib/commonjs/{form-control → form}/createFormRoot.js +0 -0
  131. /package/lib/module/{form-control → field}/types.js +0 -0
  132. /package/lib/module/{form-control → form}/createFormRoot.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["OverlayInsetsProvider","dataAttributes"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,SAA0BA,qBAAqB,QAAQ,WAAW;AAClE,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,YAAY;AAE1B,SAASC,cAAc,QAAQ,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["OverlayInsetsProvider","dataAttributes"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,SAA0BA,qBAAqB,QAAQ,WAAW;AAClE,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,YAAY;AAE1B,SAASC,cAAc,QAAQ,wBAAwB","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const createFieldError: <T>(BaseFormError: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldError.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldError.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,eAAe,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eACvC,KAAK,CAAC,SAAS;iCA2B9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type React from 'react';
2
+ export declare const createFieldErrorIcon: <T>(BaseFormErrorIcon: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldErrorIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldErrorIcon.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldErrorIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAG,mBAAmB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eAC/C,KAAK,CAAC,SAAS;iCAI9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type React from 'react';
2
+ export declare const createFieldErrorText: <T>(BaseFormErrorText: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldErrorText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldErrorText.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldErrorText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAG,mBAAmB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eAC/C,KAAK,CAAC,SAAS;iCAI9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const createFieldHelper: <T>(BaseFormHelper: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldHelper.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldHelper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAG,gBAAgB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eACzC,KAAK,CAAC,SAAS;iCAuB9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type React from 'react';
2
+ export declare const createFieldHelperText: <T>(BaseFormHelperText: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldHelperText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldHelperText.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldHelperText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAG,oBAAoB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eACjD,KAAK,CAAC,SAAS;iCAI9C,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ import type { IFieldLabelProps } from './types';
3
+ export declare const createFieldLabel: <T>(BaseFormLabel: React.ComponentType<T>) => React.ForwardRefExoticComponent<IFieldLabelProps & {
4
+ children?: React.ReactNode;
5
+ } & React.RefAttributes<unknown>>;
6
+ //# sourceMappingURL=createFieldLabel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldLabel.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,eAAe,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eACpB,KAAK,CAAC,SAAS;iCAsBlE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { IFieldRootProps } from './types';
3
+ export declare const createFieldRoot: <T>(BaseFormField: React.ComponentType<T>) => React.ForwardRefExoticComponent<IFieldRootProps & {
4
+ children?: React.ReactNode;
5
+ } & React.RefAttributes<unknown>>;
6
+ //# sourceMappingURL=createFieldRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldRoot.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,eAAe,GAAI,CAAC,EAAG,eAAe,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eAEb,KAAK,CAAC,SAAS;iCAmBxE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type React from 'react';
2
+ import type { IFieldComponentType } from './types';
3
+ export type { IFieldRootProps, IFieldLabelProps, IFieldHelperProps, IFieldHelperTextProps, IFieldErrorProps, IFieldErrorTextProps, IFieldErrorIconProps, IFieldComponentType, } from './types';
4
+ export declare function createField<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon>({ Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon, }: {
5
+ Root: React.ComponentType<Root>;
6
+ Label: React.ComponentType<Label>;
7
+ Helper: React.ComponentType<Helper>;
8
+ HelperText: React.ComponentType<HelperText>;
9
+ Error: React.ComponentType<Error>;
10
+ ErrorText: React.ComponentType<ErrorText>;
11
+ ErrorIcon: React.ComponentType<ErrorIcon>;
12
+ }): IFieldComponentType<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon>;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/field/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,EACxF,IAAI,EACJ,KAAK,EACL,MAAM,EACN,UAAU,EACV,KAAK,EACL,SAAS,EACT,SAAS,GACV,EAAE;IACD,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC5C,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC1C,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;CAC3C,GA6BO,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CACxF"}
@@ -1,14 +1,5 @@
1
1
  import type React from 'react';
2
2
  import type { TextProps, ViewProps } from 'react-native';
3
- /**
4
- * Props for the Form container (`<form>` on web, `<View>` on RN).
5
- * Does NOT provide field-level context — use `Form.Field` for that.
6
- *
7
- * Web-only submit props (`onSubmit`, `action`, `method`) belong in the
8
- * platform-specific base component (`FormRoot.web.tsx`), not here.
9
- */
10
- export interface IFormProps {
11
- }
12
3
  /**
13
4
  * Props for a single form field (`Form.Field`).
14
5
  * Provides field-level context (name, validation state, ids) to children.
@@ -19,7 +10,7 @@ export interface IFormProps {
19
10
  *
20
11
  * **Submit UX:** "focus first invalid on error" needs form-level validation state; not built in yet.
21
12
  */
22
- export interface IFormFieldProps extends ViewProps {
13
+ export interface IFieldRootProps extends ViewProps {
23
14
  /** Unique id for this field. Auto-generated if not provided. */
24
15
  readonly id?: string;
25
16
  /**
@@ -36,7 +27,7 @@ export interface IFormFieldProps extends ViewProps {
36
27
  /** If true, the field is read-only. */
37
28
  readonly isReadOnly?: boolean;
38
29
  }
39
- export interface IFormLabelProps extends TextProps {
30
+ export interface IFieldLabelProps extends TextProps {
40
31
  /**
41
32
  * Associates the label with a control `id` on web (`<label htmlFor>`).
42
33
  * If omitted, defaults to the same id `Input.Field` gets from form context: `fieldId + "-input"`.
@@ -49,24 +40,23 @@ export interface IFormLabelProps extends TextProps {
49
40
  */
50
41
  readonly requiredIndicator?: React.ReactNode;
51
42
  }
52
- export interface IFormHelperProps extends ViewProps {
43
+ export interface IFieldHelperProps extends ViewProps {
53
44
  }
54
- export interface IFormHelperTextProps extends TextProps {
45
+ export interface IFieldHelperTextProps extends TextProps {
55
46
  }
56
- export interface IFormErrorProps extends ViewProps {
47
+ export interface IFieldErrorProps extends ViewProps {
57
48
  }
58
- export interface IFormErrorTextProps extends TextProps {
49
+ export interface IFieldErrorTextProps extends TextProps {
59
50
  }
60
- export interface IFormErrorIconProps extends ViewProps {
51
+ export interface IFieldErrorIconProps extends ViewProps {
61
52
  }
62
- export type IFormComponentType<Root, Field, Error, ErrorText, ErrorIcon, Label, Helper, HelperText> = React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFormProps> & {
63
- Field: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Field> & IFormFieldProps>;
64
- Label: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Label> & IFormLabelProps>;
65
- Helper: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Helper> & IFormHelperProps>;
66
- HelperText: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<HelperText> & IFormHelperTextProps>;
67
- Error: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Error> & IFormErrorProps>;
68
- ErrorText: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<ErrorText> & IFormErrorTextProps>;
69
- ErrorIcon: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<ErrorIcon> & IFormErrorIconProps>;
53
+ export type IFieldComponentType<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon> = React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFieldRootProps> & {
54
+ Label: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Label> & IFieldLabelProps>;
55
+ Helper: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Helper> & IFieldHelperProps>;
56
+ HelperText: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<HelperText> & IFieldHelperTextProps>;
57
+ Error: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Error> & IFieldErrorProps>;
58
+ ErrorText: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<ErrorText> & IFieldErrorTextProps>;
59
+ ErrorIcon: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<ErrorIcon> & IFieldErrorIconProps>;
70
60
  };
71
61
  type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
72
62
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/field/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,M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B,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAC3D,CAAC;IACF,UAAU,EAAE,KAAK,CAAC,yBAAyB,CACzC,8BAA8B,CAAC,UAAU,CAAC,GAAG,qBAAqB,CACnE,CAAC;IACF,KAAK,EAAE,KAAK,CAAC,yBAAyB,CACpC,8BAA8B,CAAC,KAAK,CAAC,GAAG,gBAAgB,CACzD,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,yBAAyB,CACxC,8BAA8B,CAAC,SAAS,CAAC,GAAG,oBAAoB,CACjE,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,yBAAyB,CACxC,8BAA8B,CAAC,SAAS,CAAC,GAAG,oBAAoB,CACjE,CAAC;CACH,CAAC;AAEJ,KAAK,8BAA8B,CAAC,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IFormComponentType } from './types';
3
+ export declare const createFormRoot: <T>(BaseFormRoot: React.ComponentType<T>) => IFormComponentType<T>;
4
+ //# sourceMappingURL=createFormRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFormRoot.d.ts","sourceRoot":"","sources":["../../../src/form/createFormRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAIlE,eAAO,MAAM,cAAc,GAAI,CAAC,EAAG,cAAc,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAG,kBAAkB,CAAC,CAAC,CAO3F,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ export type { IFormRootProps, IFormComponentType } from './types';
3
+ export declare function createForm<Root>({ Root }: {
4
+ Root: React.ComponentType<Root>;
5
+ }): import("./types").IFormComponentType<Root>;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElE,wBAAgB,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;CAAE,8CAM7E"}
@@ -0,0 +1,14 @@
1
+ import type React from 'react';
2
+ /**
3
+ * Props for the Form container (`<form>` on web, `<View>` on RN).
4
+ * Does NOT provide field-level context — use `Form.Field` for that.
5
+ *
6
+ * Web-only submit props (`onSubmit`, `action`, `method`) belong in the
7
+ * platform-specific base component (`FormRoot.web.tsx`), not here.
8
+ */
9
+ export interface IFormRootProps {
10
+ }
11
+ export type IFormComponentType<Root> = React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFormRootProps>;
12
+ type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
13
+ export {};
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/form/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;CAAG;AAElC,MAAM,MAAM,kBAAkB,CAAC,IAAI,IAAI,KAAK,CAAC,yBAAyB,CACpE,8BAA8B,CAAC,IAAI,CAAC,GAAG,cAAc,CACtD,CAAC;AAEF,KAAK,8BAA8B,CAAC,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC"}
@@ -2,7 +2,8 @@ export * from './avatar';
2
2
  export * from './button';
3
3
  export * from './checkbox';
4
4
  export * from './dialog';
5
- export * from './form-control';
5
+ export * from './field';
6
+ export * from './form';
6
7
  export * from './input';
7
8
  export * from './link';
8
9
  export { type EdgeInsets, OverlayInsetsProvider } from './overlay';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,KAAK,UAAU,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACnE,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,KAAK,UAAU,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACnE,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdx-ui/primitives",
3
- "version": "0.0.1-alpha.35",
3
+ "version": "0.0.1-alpha.36",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "module": "lib/module/index.js",
6
6
  "react-native": "src/index.ts",
@@ -57,7 +57,7 @@
57
57
  "@react-native-aria/interactions": "^0.2.16",
58
58
  "@react-stately/checkbox": "3.7.4",
59
59
  "@react-stately/toggle": "3.9.4",
60
- "@cdx-ui/utils": "0.0.1-alpha.35"
60
+ "@cdx-ui/utils": "0.0.1-alpha.36"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/react": "*",
@@ -1,7 +1,7 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import { useFormControlContext } from '@cdx-ui/utils';
3
3
 
4
- export const createFormError = <T,>(BaseFormError: React.ComponentType<T>) =>
4
+ export const createFieldError = <T,>(BaseFormError: React.ComponentType<T>) =>
5
5
  forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => {
6
6
  const { isInvalid, feedbackId, setHasFeedbackText } = useFormControlContext();
7
7
 
@@ -1,7 +1,7 @@
1
1
  import type React from 'react';
2
2
  import { forwardRef } from 'react';
3
3
 
4
- export const createFormErrorIcon = <T,>(BaseFormErrorIcon: React.ComponentType<T>) =>
4
+ export const createFieldErrorIcon = <T,>(BaseFormErrorIcon: React.ComponentType<T>) =>
5
5
  forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => (
6
6
  <BaseFormErrorIcon ref={ref} {...(props as T)}>
7
7
  {children}
@@ -1,7 +1,7 @@
1
1
  import type React from 'react';
2
2
  import { forwardRef } from 'react';
3
3
 
4
- export const createFormErrorText = <T,>(BaseFormErrorText: React.ComponentType<T>) =>
4
+ export const createFieldErrorText = <T,>(BaseFormErrorText: React.ComponentType<T>) =>
5
5
  forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => (
6
6
  <BaseFormErrorText ref={ref} {...(props as T)}>
7
7
  {children}
@@ -1,7 +1,7 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import { useFormControlContext } from '@cdx-ui/utils';
3
3
 
4
- export const createFormHelper = <T,>(BaseFormHelper: React.ComponentType<T>) =>
4
+ export const createFieldHelper = <T,>(BaseFormHelper: React.ComponentType<T>) =>
5
5
  forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => {
6
6
  const { helpTextId, setHasHelpText, isInvalid } = useFormControlContext();
7
7
 
@@ -1,7 +1,7 @@
1
1
  import type React from 'react';
2
2
  import { forwardRef } from 'react';
3
3
 
4
- export const createFormHelperText = <T,>(BaseFormHelperText: React.ComponentType<T>) =>
4
+ export const createFieldHelperText = <T,>(BaseFormHelperText: React.ComponentType<T>) =>
5
5
  forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => (
6
6
  <BaseFormHelperText ref={ref} {...(props as T)}>
7
7
  {children}
@@ -2,10 +2,10 @@ import type React from 'react';
2
2
  import { forwardRef } from 'react';
3
3
  import { useFormControlContext } from '@cdx-ui/utils';
4
4
  import { dataAttributes } from '../utils/dataAttributes';
5
- import type { IFormLabelProps } from './types';
5
+ import type { IFieldLabelProps } from './types';
6
6
 
7
- export const createFormLabel = <T,>({ Label: BaseFormLabel }: { Label: React.ComponentType<T> }) =>
8
- forwardRef<unknown, IFormLabelProps & { children?: React.ReactNode }>(
7
+ export const createFieldLabel = <T,>(BaseFormLabel: React.ComponentType<T>) =>
8
+ forwardRef<unknown, IFieldLabelProps & { children?: React.ReactNode }>(
9
9
  ({ children, htmlFor: htmlForProp, requiredIndicator, ...props }, ref) => {
10
10
  const field = useFormControlContext();
11
11
  const fieldId = field.id;
@@ -1,11 +1,11 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import { useFormControlRoot, FormControlContext } from '@cdx-ui/utils';
3
3
  import { dataAttributes } from '../utils/dataAttributes';
4
- import type { IFormFieldProps } from './types';
4
+ import type { IFieldRootProps } from './types';
5
5
 
6
- export const createFormField = <T,>(BaseFormField: React.ComponentType<T>) =>
6
+ export const createFieldRoot = <T,>(BaseFormField: React.ComponentType<T>) =>
7
7
  forwardRef(
8
- ({ children, ...props }: IFormFieldProps & { children?: React.ReactNode }, ref?: unknown) => {
8
+ ({ children, ...props }: IFieldRootProps & { children?: React.ReactNode }, ref?: unknown) => {
9
9
  const { htmlProps, ...context } = useFormControlRoot(props);
10
10
 
11
11
  return (
@@ -0,0 +1,68 @@
1
+ import type React from 'react';
2
+ import { createFieldError } from './createFieldError';
3
+ import { createFieldErrorIcon } from './createFieldErrorIcon';
4
+ import { createFieldErrorText } from './createFieldErrorText';
5
+ import { createFieldRoot } from './createFieldRoot';
6
+ import { createFieldHelper } from './createFieldHelper';
7
+ import { createFieldHelperText } from './createFieldHelperText';
8
+ import { createFieldLabel } from './createFieldLabel';
9
+ import type { IFieldComponentType } from './types';
10
+
11
+ export type {
12
+ IFieldRootProps,
13
+ IFieldLabelProps,
14
+ IFieldHelperProps,
15
+ IFieldHelperTextProps,
16
+ IFieldErrorProps,
17
+ IFieldErrorTextProps,
18
+ IFieldErrorIconProps,
19
+ IFieldComponentType,
20
+ } from './types';
21
+
22
+ export function createField<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon>({
23
+ Root,
24
+ Label,
25
+ Helper,
26
+ HelperText,
27
+ Error,
28
+ ErrorText,
29
+ ErrorIcon,
30
+ }: {
31
+ Root: React.ComponentType<Root>;
32
+ Label: React.ComponentType<Label>;
33
+ Helper: React.ComponentType<Helper>;
34
+ HelperText: React.ComponentType<HelperText>;
35
+ Error: React.ComponentType<Error>;
36
+ ErrorText: React.ComponentType<ErrorText>;
37
+ ErrorIcon: React.ComponentType<ErrorIcon>;
38
+ }) {
39
+ const FieldRoot = createFieldRoot(Root);
40
+ FieldRoot.displayName = 'FieldPrimitive';
41
+
42
+ const FieldLabel = createFieldLabel(Label);
43
+ FieldLabel.displayName = 'FieldPrimitive.Label';
44
+
45
+ const FieldHelper = createFieldHelper(Helper);
46
+ FieldHelper.displayName = 'FieldPrimitive.Helper';
47
+
48
+ const FieldHelperText = createFieldHelperText(HelperText);
49
+ FieldHelperText.displayName = 'FieldPrimitive.HelperText';
50
+
51
+ const FieldError = createFieldError(Error);
52
+ FieldError.displayName = 'FieldPrimitive.Error';
53
+
54
+ const FieldErrorText = createFieldErrorText(ErrorText);
55
+ FieldErrorText.displayName = 'FieldPrimitive.ErrorText';
56
+
57
+ const FieldErrorIcon = createFieldErrorIcon(ErrorIcon);
58
+ FieldErrorIcon.displayName = 'FieldPrimitive.ErrorIcon';
59
+
60
+ return Object.assign(FieldRoot, {
61
+ Label: FieldLabel,
62
+ Helper: FieldHelper,
63
+ HelperText: FieldHelperText,
64
+ Error: FieldError,
65
+ ErrorText: FieldErrorText,
66
+ ErrorIcon: FieldErrorIcon,
67
+ }) as IFieldComponentType<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon>;
68
+ }
@@ -1,15 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type { TextProps, ViewProps } from 'react-native';
3
3
 
4
- /**
5
- * Props for the Form container (`<form>` on web, `<View>` on RN).
6
- * Does NOT provide field-level context — use `Form.Field` for that.
7
- *
8
- * Web-only submit props (`onSubmit`, `action`, `method`) belong in the
9
- * platform-specific base component (`FormRoot.web.tsx`), not here.
10
- */
11
- export interface IFormProps {}
12
-
13
4
  /**
14
5
  * Props for a single form field (`Form.Field`).
15
6
  * Provides field-level context (name, validation state, ids) to children.
@@ -20,7 +11,7 @@ export interface IFormProps {}
20
11
  *
21
12
  * **Submit UX:** "focus first invalid on error" needs form-level validation state; not built in yet.
22
13
  */
23
- export interface IFormFieldProps extends ViewProps {
14
+ export interface IFieldRootProps extends ViewProps {
24
15
  /** Unique id for this field. Auto-generated if not provided. */
25
16
  readonly id?: string;
26
17
  /**
@@ -38,7 +29,7 @@ export interface IFormFieldProps extends ViewProps {
38
29
  readonly isReadOnly?: boolean;
39
30
  }
40
31
 
41
- export interface IFormLabelProps extends TextProps {
32
+ export interface IFieldLabelProps extends TextProps {
42
33
  /**
43
34
  * Associates the label with a control `id` on web (`<label htmlFor>`).
44
35
  * If omitted, defaults to the same id `Input.Field` gets from form context: `fieldId + "-input"`.
@@ -52,41 +43,36 @@ export interface IFormLabelProps extends TextProps {
52
43
  readonly requiredIndicator?: React.ReactNode;
53
44
  }
54
45
 
55
- export interface IFormHelperProps extends ViewProps {}
46
+ export interface IFieldHelperProps extends ViewProps {}
56
47
 
57
- export interface IFormHelperTextProps extends TextProps {}
48
+ export interface IFieldHelperTextProps extends TextProps {}
58
49
 
59
- export interface IFormErrorProps extends ViewProps {}
50
+ export interface IFieldErrorProps extends ViewProps {}
60
51
 
61
- export interface IFormErrorTextProps extends TextProps {}
52
+ export interface IFieldErrorTextProps extends TextProps {}
62
53
 
63
- export interface IFormErrorIconProps extends ViewProps {}
54
+ export interface IFieldErrorIconProps extends ViewProps {}
64
55
 
65
- export type IFormComponentType<
66
- Root,
67
- Field,
68
- Error,
69
- ErrorText,
70
- ErrorIcon,
71
- Label,
72
- Helper,
73
- HelperText,
74
- > = React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFormProps> & {
75
- Field: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Field> & IFormFieldProps>;
76
- Label: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Label> & IFormLabelProps>;
77
- Helper: React.ForwardRefExoticComponent<
78
- InnerForwardRefExoticComponent<Helper> & IFormHelperProps
79
- >;
80
- HelperText: React.ForwardRefExoticComponent<
81
- InnerForwardRefExoticComponent<HelperText> & IFormHelperTextProps
82
- >;
83
- Error: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Error> & IFormErrorProps>;
84
- ErrorText: React.ForwardRefExoticComponent<
85
- InnerForwardRefExoticComponent<ErrorText> & IFormErrorTextProps
86
- >;
87
- ErrorIcon: React.ForwardRefExoticComponent<
88
- InnerForwardRefExoticComponent<ErrorIcon> & IFormErrorIconProps
89
- >;
90
- };
56
+ export type IFieldComponentType<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon> =
57
+ React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFieldRootProps> & {
58
+ Label: React.ForwardRefExoticComponent<
59
+ InnerForwardRefExoticComponent<Label> & IFieldLabelProps
60
+ >;
61
+ Helper: React.ForwardRefExoticComponent<
62
+ InnerForwardRefExoticComponent<Helper> & IFieldHelperProps
63
+ >;
64
+ HelperText: React.ForwardRefExoticComponent<
65
+ InnerForwardRefExoticComponent<HelperText> & IFieldHelperTextProps
66
+ >;
67
+ Error: React.ForwardRefExoticComponent<
68
+ InnerForwardRefExoticComponent<Error> & IFieldErrorProps
69
+ >;
70
+ ErrorText: React.ForwardRefExoticComponent<
71
+ InnerForwardRefExoticComponent<ErrorText> & IFieldErrorTextProps
72
+ >;
73
+ ErrorIcon: React.ForwardRefExoticComponent<
74
+ InnerForwardRefExoticComponent<ErrorIcon> & IFieldErrorIconProps
75
+ >;
76
+ };
91
77
 
92
78
  type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
@@ -1,11 +1,11 @@
1
1
  import React, { forwardRef } from 'react';
2
- import type { IFormProps } from './types';
2
+ import type { IFormRootProps, IFormComponentType } from './types';
3
3
 
4
4
  // TODO: Handle web submission (button type submit)
5
5
 
6
- export const createFormRoot = <T,>(BaseFormRoot: React.ComponentType<T>) =>
6
+ export const createFormRoot = <T,>(BaseFormRoot: React.ComponentType<T>): IFormComponentType<T> =>
7
7
  forwardRef(
8
- ({ children, ...props }: IFormProps & { children?: React.ReactNode }, ref?: unknown) => (
8
+ ({ children, ...props }: IFormRootProps & { children?: React.ReactNode }, ref?: unknown) => (
9
9
  <BaseFormRoot ref={ref} {...(props as T)}>
10
10
  {children}
11
11
  </BaseFormRoot>
@@ -0,0 +1,12 @@
1
+ import type React from 'react';
2
+ import { createFormRoot } from './createFormRoot';
3
+
4
+ export type { IFormRootProps, IFormComponentType } from './types';
5
+
6
+ export function createForm<Root>({ Root }: { Root: React.ComponentType<Root> }) {
7
+ const FormRoot = createFormRoot(Root);
8
+
9
+ FormRoot.displayName = 'FormPrimitive';
10
+
11
+ return FormRoot;
12
+ }
@@ -0,0 +1,16 @@
1
+ import type React from 'react';
2
+
3
+ /**
4
+ * Props for the Form container (`<form>` on web, `<View>` on RN).
5
+ * Does NOT provide field-level context — use `Form.Field` for that.
6
+ *
7
+ * Web-only submit props (`onSubmit`, `action`, `method`) belong in the
8
+ * platform-specific base component (`FormRoot.web.tsx`), not here.
9
+ */
10
+ export interface IFormRootProps {}
11
+
12
+ export type IFormComponentType<Root> = React.ForwardRefExoticComponent<
13
+ InnerForwardRefExoticComponent<Root> & IFormRootProps
14
+ >;
15
+
16
+ type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
package/src/index.ts CHANGED
@@ -2,7 +2,8 @@ export * from './avatar';
2
2
  export * from './button';
3
3
  export * from './checkbox';
4
4
  export * from './dialog';
5
- export * from './form-control';
5
+ export * from './field';
6
+ export * from './form';
6
7
  export * from './input';
7
8
  export * from './link';
8
9
  export { type EdgeInsets, OverlayInsetsProvider } from './overlay';
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_utils","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","createFormError","BaseFormError","forwardRef","children","props","ref","isInvalid","feedbackId","setHasFeedbackText","useFormControlContext","visible","Boolean","React","useEffect","undefined","jsx","id","accessibilityRole","accessibilityLiveRegion","exports"],"sourceRoot":"../../../src","sources":["form-control/createFormError.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAsD,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA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AAI,CAAC;IAC1B,OAAO,MAAM;MACXA,kBAAkB,GAAG,KAAK,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAACA,kBAAkB,EAAEE,OAAO,CAAC,CAAC;EAEjC,OAAOA,OAAO,gBACZ,IAAA9B,WAAA,CAAAmC,GAAA,EAACd,aAAa;IACZI,GAAG,EAAEA,GAAI;IAAA,GACJD,KAAK;IACVY,EAAE,EAAET,UAAW;IACfU,iBAAiB,EAAC,OAAO;IACzBC,uBAAuB,EAAC,WAAW;IAAAf,QAAA,EAElCA;EAAQ,CACI,CAAC,GACd,IAAI;AACV,CAAC,CAAC;AAACgB,OAAA,CAAAnB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_jsxRuntime","createFormErrorIcon","BaseFormErrorIcon","forwardRef","children","props","ref","jsx","exports"],"sourceRoot":"../../../src","sources":["form-control/createFormErrorIcon.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAAmC,IAAAC,WAAA,GAAAD,OAAA;AAE5B,MAAME,mBAAmB,GAAQC,iBAAyC,iBAC/E,IAAAC,iBAAU,EAA0C,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,kBAC9E,IAAAN,WAAA,CAAAO,GAAA,EAACL,iBAAiB;EAACI,GAAG,EAAEA,GAAI;EAAA,GAAMD,KAAK;EAAAD,QAAA,EACpCA;AAAQ,CACQ,CACpB,CAAC;AAACI,OAAA,CAAAP,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_jsxRuntime","createFormErrorText","BaseFormErrorText","forwardRef","children","props","ref","jsx","exports"],"sourceRoot":"../../../src","sources":["form-control/createFormErrorText.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAAmC,IAAAC,WAAA,GAAAD,OAAA;AAE5B,MAAME,mBAAmB,GAAQC,iBAAyC,iBAC/E,IAAAC,iBAAU,EAA0C,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,kBAC9E,IAAAN,WAAA,CAAAO,GAAA,EAACL,iBAAiB;EAACI,GAAG,EAAEA,GAAI;EAAA,GAAMD,KAAK;EAAAD,QAAA,EACpCA;AAAQ,CACQ,CACpB,CAAC;AAACI,OAAA,CAAAP,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_utils","_dataAttributes","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","createFormField","BaseFormField","forwardRef","children","props","ref","htmlProps","context","useFormControlRoot","jsx","FormControlContext","Provider","value","dataAttributes","disabled","isDisabled","invalid","isInvalid","required","isRequired","exports"],"sourceRoot":"../../../src","sources":["form-control/createFormField.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAAyD,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAA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"names":["_react","_interopRequireWildcard","require","_utils","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","createFormHelper","BaseFormHelper","forwardRef","children","props","ref","helpTextId","setHasHelpText","isInvalid","useFormControlContext","React","useEffect","undefined","jsx","id","exports"],"sourceRoot":"../../../src","sources":["form-control/createFormHelper.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAsD,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAE/C,MAAMkB,gBAAgB,GAAQC,cAAsC,iBACzE,IAAAC,iBAAU,EAA0C,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACnF,MAAM;IAAEC,UAAU;IAAEC,cAAc;IAAEC;EAAU,CAAC,GAAG,IAAAC,4BAAqB,EAAC,CAAC;EAEzEC,cAAK,CAACC,SAAS,CAAC,MAAM;IACpB,IAAIH,SAAS,EAAE;MACbD,cAAc,GAAG,KAAK,CAAC;MACvB,OAAOK,SAAS;IAClB;IACAL,cAAc,GAAG,IAAI,CAAC;IACtB,OAAO,MAAM;MACXA,cAAc,GAAG,KAAK,CAAC;IACzB,CAAC;EACH,CAAC,EAAE,CAACA,cAAc,EAAEC,SAAS,CAAC,CAAC;EAE/B,IAAIA,SAAS,EAAE;IACb,OAAO,IAAI;EACb;EAEA,oBACE,IAAA5B,WAAA,CAAAiC,GAAA,EAACZ,cAAc;IAACI,GAAG,EAAEA,GAAI;IAAA,GAAMD,KAAK;IAAQU,EAAE,EAAER,UAAW;IAAAH,QAAA,EACxDA;EAAQ,CACK,CAAC;AAErB,CAAC,CAAC;AAACY,OAAA,CAAAf,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_jsxRuntime","createFormHelperText","BaseFormHelperText","forwardRef","children","props","ref","jsx","exports"],"sourceRoot":"../../../src","sources":["form-control/createFormHelperText.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAAmC,IAAAC,WAAA,GAAAD,OAAA;AAE5B,MAAME,oBAAoB,GAAQC,kBAA0C,iBACjF,IAAAC,iBAAU,EAA0C,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,kBAC9E,IAAAN,WAAA,CAAAO,GAAA,EAACL,kBAAkB;EAACI,GAAG,EAAEA,GAAI;EAAA,GAAMD,KAAK;EAAAD,QAAA,EACrCA;AAAQ,CACS,CACrB,CAAC;AAACI,OAAA,CAAAP,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_utils","_dataAttributes","_jsxRuntime","createFormLabel","Label","BaseFormLabel","forwardRef","children","htmlFor","htmlForProp","requiredIndicator","props","ref","field","useFormControlContext","fieldId","id","labelId","undefined","jsxs","dataAttributes","invalid","isInvalid","required","isRequired","exports"],"sourceRoot":"../../../src","sources":["form-control/createFormLabel.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAAyD,IAAAG,WAAA,GAAAH,OAAA;AAGlD,MAAMI,eAAe,GAAGA,CAAK;EAAEC,KAAK,EAAEC;AAAiD,CAAC,kBAC7F,IAAAC,iBAAU,EACR,CAAC;EAAEC,QAAQ;EAAEC,OAAO,EAAEC,WAAW;EAAEC,iBAAiB;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACxE,MAAMC,KAAK,GAAG,IAAAC,4BAAqB,EAAC,CAAC;EACrC,MAAMC,OAAO,GAAGF,KAAK,CAACG,EAAE;EACxB,MAAMC,OAAO,GAAGJ,KAAK,CAACI,OAAO;;EAE7B;EACA,MAAMT,OAAO,GAAGC,WAAW,KAAKM,OAAO,GAAG,GAAGA,OAAO,QAAQ,GAAGG,SAAS,CAAC;EAEzE,oBACE,IAAAhB,WAAA,CAAAiB,IAAA,EAACd,aAAa;IACZO,GAAG,EAAEA,GAAI;IAAA,GACJD,KAAK;IACVK,EAAE,EAAEC,OAAQ;IACZT,OAAO,EAAEA,OAAQ;IAAA,GACb,IAAAY,8BAAc,EAAC;MAAEC,OAAO,EAAER,KAAK,CAACS,SAAS;MAAEC,QAAQ,EAAEV,KAAK,CAACW;IAAW,CAAC,CAAC;IAAAjB,QAAA,GAE3EA,QAAQ,EACRM,KAAK,CAACW,UAAU,GAAGd,iBAAiB,GAAG,IAAI;EAAA,CAC/B,CAAC;AAEpB,CACF,CAAC;AAACe,OAAA,CAAAtB,eAAA,GAAAA,eAAA","ignoreList":[]}