@springmicro/forms 0.6.3 → 0.7.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 (78) hide show
  1. package/.eslintrc.cjs +22 -22
  2. package/README.md +11 -11
  3. package/dist/index.d.ts +0 -0
  4. package/dist/index.js +0 -0
  5. package/dist/index.umd.cjs +0 -0
  6. package/package.json +3 -3
  7. package/src/builder/bottom-drawer.tsx +429 -429
  8. package/src/builder/form-builder.tsx +256 -256
  9. package/src/builder/modal.tsx +39 -39
  10. package/src/builder/nodes/node-base.tsx +94 -94
  11. package/src/builder/nodes/node-child-helpers.tsx +273 -273
  12. package/src/builder/nodes/node-parent.tsx +187 -187
  13. package/src/builder/nodes/node-types/array-node.tsx +134 -134
  14. package/src/builder/nodes/node-types/date-node.tsx +60 -60
  15. package/src/builder/nodes/node-types/file-node.tsx +67 -67
  16. package/src/builder/nodes/node-types/integer-node.tsx +60 -60
  17. package/src/builder/nodes/node-types/object-node.tsx +67 -67
  18. package/src/builder/nodes/node-types/text-node.tsx +66 -66
  19. package/src/fields/ArrayField.tsx +875 -875
  20. package/src/fields/BooleanField.tsx +110 -110
  21. package/src/fields/MultiSchemaField.tsx +236 -236
  22. package/src/fields/NullField.tsx +22 -22
  23. package/src/fields/NumberField.tsx +87 -87
  24. package/src/fields/ObjectField.tsx +338 -338
  25. package/src/fields/SchemaField.tsx +402 -402
  26. package/src/fields/StringField.tsx +67 -67
  27. package/src/fields/index.ts +24 -24
  28. package/src/index.tsx +26 -26
  29. package/src/interfaces/MessagesProps.interface.ts +5 -5
  30. package/src/interfaces/Option.interface.ts +4 -4
  31. package/src/styles/select.styles.ts +28 -28
  32. package/src/templates/ArrayFieldDescriptionTemplate.tsx +42 -42
  33. package/src/templates/ArrayFieldItemTemplate.tsx +78 -78
  34. package/src/templates/ArrayFieldTemplate.tsx +90 -90
  35. package/src/templates/ArrayFieldTitleTemplate.tsx +44 -44
  36. package/src/templates/BaseInputTemplate.tsx +94 -94
  37. package/src/templates/ButtonTemplates/AddButton.tsx +29 -29
  38. package/src/templates/ButtonTemplates/IconButton.tsx +49 -49
  39. package/src/templates/ButtonTemplates/SubmitButton.tsx +29 -29
  40. package/src/templates/ButtonTemplates/index.ts +16 -16
  41. package/src/templates/DescriptionField.tsx +29 -29
  42. package/src/templates/ErrorList.tsx +25 -25
  43. package/src/templates/FieldTemplate/FieldTemplate.tsx +39 -39
  44. package/src/templates/FieldTemplate/Label.tsx +29 -29
  45. package/src/templates/FieldTemplate/WrapIfAdditional.tsx +85 -85
  46. package/src/templates/FieldTemplate/index.ts +3 -3
  47. package/src/templates/ObjectFieldTemplate.tsx +79 -79
  48. package/src/templates/TitleField.tsx +20 -20
  49. package/src/templates/UnsupportedField.tsx +29 -29
  50. package/src/templates/index.ts +32 -32
  51. package/src/types/Message.type.ts +6 -6
  52. package/src/types/RawMessage.type.ts +15 -15
  53. package/src/types/form-builder.ts +135 -135
  54. package/src/types/utils.type.ts +1 -1
  55. package/src/utils/form-builder.ts +424 -424
  56. package/src/utils/processSelectValue.ts +50 -50
  57. package/src/widgets/AltDateTimeWidget.tsx +17 -17
  58. package/src/widgets/AltDateWidget.tsx +216 -216
  59. package/src/widgets/CheckboxWidget.tsx +80 -80
  60. package/src/widgets/CheckboxesWidget.tsx +74 -74
  61. package/src/widgets/ColorWidget.tsx +26 -26
  62. package/src/widgets/DateTimeWidget.tsx +28 -28
  63. package/src/widgets/DateWidget.tsx +36 -36
  64. package/src/widgets/EmailWidget.tsx +19 -19
  65. package/src/widgets/FileWidget.tsx +144 -144
  66. package/src/widgets/HiddenWidget.tsx +22 -22
  67. package/src/widgets/PasswordWidget.tsx +20 -20
  68. package/src/widgets/RadioWidget.tsx +87 -87
  69. package/src/widgets/RangeWidget.tsx +24 -24
  70. package/src/widgets/SelectWidget.tsx +99 -99
  71. package/src/widgets/TextWidget.tsx +19 -19
  72. package/src/widgets/TextareaWidget.tsx +64 -64
  73. package/src/widgets/URLWidget.tsx +19 -19
  74. package/src/widgets/UpDownWidget.tsx +20 -20
  75. package/src/widgets/index.ts +43 -43
  76. package/tsconfig.json +24 -24
  77. package/tsconfig.node.json +10 -10
  78. package/vite.config.ts +25 -25
@@ -1,29 +1,29 @@
1
- import React from "react";
2
- import { GenericObjectType, UnsupportedFieldProps } from "@rjsf/utils";
3
-
4
- /** The `UnsupportedField` component is used to render a field in the schema is one that is not supported by
5
- * react-jsonschema-form.
6
- *
7
- * @param props - The `FieldProps` for this template
8
- */
9
- function UnsupportedField<T = any, F extends GenericObjectType = any>(
10
- props: UnsupportedFieldProps<T, F>
11
- ) {
12
- const { schema, idSchema, reason } = props;
13
- return (
14
- <div className="unsupported-field">
15
- <p>
16
- Unsupported field schema
17
- {idSchema && idSchema.$id && (
18
- <span>
19
- {" for"} field <code>{idSchema.$id}</code>
20
- </span>
21
- )}
22
- {reason && <em>: {reason}</em>}.
23
- </p>
24
- {schema && <pre>{JSON.stringify(schema, null, 2)}</pre>}
25
- </div>
26
- );
27
- }
28
-
29
- export default UnsupportedField;
1
+ import React from "react";
2
+ import { GenericObjectType, UnsupportedFieldProps } from "@rjsf/utils";
3
+
4
+ /** The `UnsupportedField` component is used to render a field in the schema is one that is not supported by
5
+ * react-jsonschema-form.
6
+ *
7
+ * @param props - The `FieldProps` for this template
8
+ */
9
+ function UnsupportedField<T = any, F extends GenericObjectType = any>(
10
+ props: UnsupportedFieldProps<T, F>
11
+ ) {
12
+ const { schema, idSchema, reason } = props;
13
+ return (
14
+ <div className="unsupported-field">
15
+ <p>
16
+ Unsupported field schema
17
+ {idSchema && idSchema.$id && (
18
+ <span>
19
+ {" for"} field <code>{idSchema.$id}</code>
20
+ </span>
21
+ )}
22
+ {reason && <em>: {reason}</em>}.
23
+ </p>
24
+ {schema && <pre>{JSON.stringify(schema, null, 2)}</pre>}
25
+ </div>
26
+ );
27
+ }
28
+
29
+ export default UnsupportedField;
@@ -1,32 +1,32 @@
1
- import { TemplatesType } from "@rjsf/utils";
2
-
3
- import ArrayFieldDescriptionTemplate from "./ArrayFieldDescriptionTemplate";
4
- import ArrayFieldItemTemplate from "./ArrayFieldItemTemplate";
5
- import ArrayFieldTemplate from "./ArrayFieldTemplate";
6
- import ArrayFieldTitleTemplate from "./ArrayFieldTitleTemplate";
7
- import BaseInputTemplate from "./BaseInputTemplate";
8
- import ButtonTemplates from "./ButtonTemplates";
9
- import DescriptionField from "./DescriptionField";
10
- import ErrorList from "./ErrorList";
11
- import FieldTemplate from "./FieldTemplate";
12
- import ObjectFieldTemplate from "./ObjectFieldTemplate";
13
- import TitleField from "./TitleField";
14
- import UnsupportedField from "./UnsupportedField";
15
-
16
- // @ts-ignore
17
- const templates: TemplatesType = {
18
- ArrayFieldDescriptionTemplate,
19
- ArrayFieldItemTemplate,
20
- ArrayFieldTemplate,
21
- ArrayFieldTitleTemplate,
22
- ButtonTemplates,
23
- BaseInputTemplate,
24
- DescriptionFieldTemplate: DescriptionField,
25
- ErrorListTemplate: ErrorList,
26
- FieldTemplate,
27
- ObjectFieldTemplate,
28
- TitleFieldTemplate: TitleField,
29
- UnsupportedFieldTemplate: UnsupportedField,
30
- };
31
-
32
- export default templates;
1
+ import { TemplatesType } from "@rjsf/utils";
2
+
3
+ import ArrayFieldDescriptionTemplate from "./ArrayFieldDescriptionTemplate";
4
+ import ArrayFieldItemTemplate from "./ArrayFieldItemTemplate";
5
+ import ArrayFieldTemplate from "./ArrayFieldTemplate";
6
+ import ArrayFieldTitleTemplate from "./ArrayFieldTitleTemplate";
7
+ import BaseInputTemplate from "./BaseInputTemplate";
8
+ import ButtonTemplates from "./ButtonTemplates";
9
+ import DescriptionField from "./DescriptionField";
10
+ import ErrorList from "./ErrorList";
11
+ import FieldTemplate from "./FieldTemplate";
12
+ import ObjectFieldTemplate from "./ObjectFieldTemplate";
13
+ import TitleField from "./TitleField";
14
+ import UnsupportedField from "./UnsupportedField";
15
+
16
+ // @ts-ignore
17
+ const templates: TemplatesType = {
18
+ ArrayFieldDescriptionTemplate,
19
+ ArrayFieldItemTemplate,
20
+ ArrayFieldTemplate,
21
+ ArrayFieldTitleTemplate,
22
+ ButtonTemplates,
23
+ BaseInputTemplate,
24
+ DescriptionFieldTemplate: DescriptionField,
25
+ ErrorListTemplate: ErrorList,
26
+ FieldTemplate,
27
+ ObjectFieldTemplate,
28
+ TitleFieldTemplate: TitleField,
29
+ UnsupportedFieldTemplate: UnsupportedField,
30
+ };
31
+
32
+ export default templates;
@@ -1,6 +1,6 @@
1
- export type Message = {
2
- actions: string;
3
- name: string;
4
- body: string;
5
- date_created: Date;
6
- };
1
+ export type Message = {
2
+ actions: string;
3
+ name: string;
4
+ body: string;
5
+ date_created: Date;
6
+ };
@@ -1,15 +1,15 @@
1
- export type RawMessage = {
2
- sid: string;
3
- date_created: string;
4
- date_updated: string;
5
- date_sent?: string;
6
- account_sid: string;
7
- to: string;
8
- from: string;
9
- body: string;
10
- status: string;
11
- flags: string[];
12
- api_version: string;
13
- price?: string;
14
- uri: string;
15
- };
1
+ export type RawMessage = {
2
+ sid: string;
3
+ date_created: string;
4
+ date_updated: string;
5
+ date_sent?: string;
6
+ account_sid: string;
7
+ to: string;
8
+ from: string;
9
+ body: string;
10
+ status: string;
11
+ flags: string[];
12
+ api_version: string;
13
+ price?: string;
14
+ uri: string;
15
+ };
@@ -1,135 +1,135 @@
1
- import { UseStateType } from "./utils.type";
2
-
3
- export type FullFormType = {
4
- form: FormType;
5
- nodes: FormNodeType[];
6
- };
7
-
8
- export type FormType = {
9
- title?: string;
10
- description?: string;
11
- };
12
-
13
- /**
14
- * Extracts each key from @type {FormNodeTypes} exctracting the string from @param {T["type"]}
15
- * which is then mapped to @type {FormNodeKeys}
16
- */
17
- type ExtractTypes<T extends { type: string }> = T["type"];
18
- export type FormNodeKeys = ExtractTypes<FormNodeType>;
19
-
20
- export type SearchNodeTypeByKey = {
21
- [key in FormNodeKeys]: FormNodeType extends { type: infer T }
22
- ? T extends key
23
- ? FormNodeType
24
- : never
25
- : never;
26
- };
27
-
28
- export interface BaseNode {
29
- nodeId: string;
30
- propertyName?: string;
31
- title?: string;
32
- description?: string;
33
- required?: boolean;
34
- }
35
-
36
- /**
37
- * =================== NODES ===================
38
- */
39
-
40
- export type FormNodeType =
41
- | FileNode
42
- | TextNode
43
- | IntegerNode
44
- | DateNode
45
- | ArrayNode
46
- | ObjectNode;
47
-
48
- export type TextNode = BaseNode & TextNodeEmpty;
49
-
50
- export type FileNode = BaseNode & FileNodeEmpty;
51
-
52
- export type IntegerNode = BaseNode & IntegerNodeEmpty;
53
-
54
- export type DateNode = BaseNode & DateNodeEmpty;
55
-
56
- export type ArrayNode = BaseNode & ArrayNodeEmpty;
57
-
58
- export type ObjectNode = BaseNode & ObjectNodeEmpty;
59
-
60
- /**
61
- * =================== NODES ===================
62
- */
63
-
64
- export type EmptyFormNodeType =
65
- | FileNodeEmpty
66
- | TextNodeEmpty
67
- | IntegerNodeEmpty
68
- | DateNodeEmpty
69
- | ArrayNodeEmpty
70
- | ObjectNodeEmpty;
71
-
72
- export interface TextNodeEmpty {
73
- type: "string";
74
- default?: string;
75
- minLength?: number;
76
- maxLength?: number;
77
- format?: string;
78
- }
79
-
80
- export interface FileNodeEmpty {
81
- type: "file";
82
- multiple?: boolean;
83
- filetype?: string;
84
- }
85
-
86
- export interface IntegerNodeEmpty {
87
- type: "integer";
88
- }
89
-
90
- export interface DateNodeEmpty {
91
- type: "date";
92
- }
93
-
94
- export interface ArrayNodeEmpty {
95
- type: "array";
96
- child: EmptyFormNodeType;
97
- }
98
-
99
- export interface ObjectNodeEmpty {
100
- type: "object";
101
- children: FormNodeType[]; // a list of nodes
102
- }
103
-
104
- /**
105
- * ================== UTILS ==================
106
- */
107
-
108
- export type CountdownType =
109
- | undefined
110
- | number
111
- | "Saved."
112
- | "Saving..."
113
- | "Save failed.";
114
-
115
- export type EditingStateType = false | string;
116
-
117
- // The format for creating a field or checkmark inside a node.
118
- export type FieldArrayType<T> = Array<{
119
- prop: keyof T;
120
- tooltip?: string;
121
- title?: string;
122
- props?: any;
123
- }>;
124
-
125
- /**
126
- * ================== SHARED PROPS ==================
127
- */
128
-
129
- export type ChildNodeProps = {
130
- nodeState: UseStateType<FormNodeType>;
131
- updateNode: (nodeData: FormNodeType) => void;
132
- defaultFields: React.JSX.Element[];
133
- defaultChecks: React.JSX.Element[];
134
- updatePath: () => void;
135
- };
1
+ import { UseStateType } from "./utils.type";
2
+
3
+ export type FullFormType = {
4
+ form: FormType;
5
+ nodes: FormNodeType[];
6
+ };
7
+
8
+ export type FormType = {
9
+ title?: string;
10
+ description?: string;
11
+ };
12
+
13
+ /**
14
+ * Extracts each key from @type {FormNodeTypes} exctracting the string from @param {T["type"]}
15
+ * which is then mapped to @type {FormNodeKeys}
16
+ */
17
+ type ExtractTypes<T extends { type: string }> = T["type"];
18
+ export type FormNodeKeys = ExtractTypes<FormNodeType>;
19
+
20
+ export type SearchNodeTypeByKey = {
21
+ [key in FormNodeKeys]: FormNodeType extends { type: infer T }
22
+ ? T extends key
23
+ ? FormNodeType
24
+ : never
25
+ : never;
26
+ };
27
+
28
+ export interface BaseNode {
29
+ nodeId: string;
30
+ propertyName?: string;
31
+ title?: string;
32
+ description?: string;
33
+ required?: boolean;
34
+ }
35
+
36
+ /**
37
+ * =================== NODES ===================
38
+ */
39
+
40
+ export type FormNodeType =
41
+ | FileNode
42
+ | TextNode
43
+ | IntegerNode
44
+ | DateNode
45
+ | ArrayNode
46
+ | ObjectNode;
47
+
48
+ export type TextNode = BaseNode & TextNodeEmpty;
49
+
50
+ export type FileNode = BaseNode & FileNodeEmpty;
51
+
52
+ export type IntegerNode = BaseNode & IntegerNodeEmpty;
53
+
54
+ export type DateNode = BaseNode & DateNodeEmpty;
55
+
56
+ export type ArrayNode = BaseNode & ArrayNodeEmpty;
57
+
58
+ export type ObjectNode = BaseNode & ObjectNodeEmpty;
59
+
60
+ /**
61
+ * =================== NODES ===================
62
+ */
63
+
64
+ export type EmptyFormNodeType =
65
+ | FileNodeEmpty
66
+ | TextNodeEmpty
67
+ | IntegerNodeEmpty
68
+ | DateNodeEmpty
69
+ | ArrayNodeEmpty
70
+ | ObjectNodeEmpty;
71
+
72
+ export interface TextNodeEmpty {
73
+ type: "string";
74
+ default?: string;
75
+ minLength?: number;
76
+ maxLength?: number;
77
+ format?: string;
78
+ }
79
+
80
+ export interface FileNodeEmpty {
81
+ type: "file";
82
+ multiple?: boolean;
83
+ filetype?: string;
84
+ }
85
+
86
+ export interface IntegerNodeEmpty {
87
+ type: "integer";
88
+ }
89
+
90
+ export interface DateNodeEmpty {
91
+ type: "date";
92
+ }
93
+
94
+ export interface ArrayNodeEmpty {
95
+ type: "array";
96
+ child: EmptyFormNodeType;
97
+ }
98
+
99
+ export interface ObjectNodeEmpty {
100
+ type: "object";
101
+ children: FormNodeType[]; // a list of nodes
102
+ }
103
+
104
+ /**
105
+ * ================== UTILS ==================
106
+ */
107
+
108
+ export type CountdownType =
109
+ | undefined
110
+ | number
111
+ | "Saved."
112
+ | "Saving..."
113
+ | "Save failed.";
114
+
115
+ export type EditingStateType = false | string;
116
+
117
+ // The format for creating a field or checkmark inside a node.
118
+ export type FieldArrayType<T> = Array<{
119
+ prop: keyof T;
120
+ tooltip?: string;
121
+ title?: string;
122
+ props?: any;
123
+ }>;
124
+
125
+ /**
126
+ * ================== SHARED PROPS ==================
127
+ */
128
+
129
+ export type ChildNodeProps = {
130
+ nodeState: UseStateType<FormNodeType>;
131
+ updateNode: (nodeData: FormNodeType) => void;
132
+ defaultFields: React.JSX.Element[];
133
+ defaultChecks: React.JSX.Element[];
134
+ updatePath: () => void;
135
+ };
@@ -1 +1 @@
1
- export type UseStateType<T> = [T, React.Dispatch<React.SetStateAction<T>>];
1
+ export type UseStateType<T> = [T, React.Dispatch<React.SetStateAction<T>>];