@springmicro/forms 0.7.0 → 0.7.1

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,110 +1,110 @@
1
- import React from "react";
2
- import type {
3
- FieldProps,
4
- EnumOptionsType,
5
- RJSFSchema,
6
- GenericObjectType,
7
- } from "@rjsf/utils";
8
- import { getWidget, getUiOptions, optionsList } from "@rjsf/utils";
9
- import isObject from "lodash/isObject";
10
-
11
- /** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
12
- * two boolean values based on the various alternatives in the schema.
13
- *
14
- * @param props - The `FieldProps` for this template
15
- */
16
- function BooleanField<T = any, F extends GenericObjectType = any>(
17
- props: FieldProps<T, F>
18
- ) {
19
- const {
20
- schema,
21
- name,
22
- uiSchema,
23
- idSchema,
24
- formData,
25
- registry,
26
- required,
27
- disabled,
28
- readonly,
29
- autofocus,
30
- onChange,
31
- onFocus,
32
- onBlur,
33
- rawErrors,
34
- } = props;
35
- const { title } = schema;
36
- const { widgets, formContext } = registry;
37
- const { widget = "checkbox", ...options } = getUiOptions<T, F>(uiSchema);
38
- const Widget = getWidget(schema, widget, widgets);
39
-
40
- let enumOptions: EnumOptionsType<any>[] | undefined;
41
-
42
- if (Array.isArray(schema.oneOf)) {
43
- enumOptions = optionsList({
44
- oneOf: schema.oneOf
45
- .map((option) => {
46
- if (isObject(option)) {
47
- return {
48
- ...option,
49
- // @ts-ignore
50
- title: option.title || (option.const === true ? "Yes" : "No"),
51
- };
52
- }
53
- return undefined;
54
- })
55
- .filter((o) => o) as any[], // cast away the error that typescript can't grok is fixed
56
- }) as EnumOptionsType<any>[] | undefined;
57
- } else {
58
- // We deprecated enumNames in v5. It's intentionally omitted from RSJFSchema type, so we need to cast here.
59
- const schemaWithEnumNames = schema as RJSFSchema & { enumNames?: string[] };
60
- // @ts-ignore
61
- schema.enum = schema.enum ?? [true, false];
62
- if (
63
- !schemaWithEnumNames.enumNames &&
64
- schema.enum &&
65
- schema.enum.length === 2 &&
66
- schema.enum.every((v: any) => typeof v === "boolean")
67
- ) {
68
- enumOptions = [
69
- {
70
- value: schema.enum[0],
71
- label: schema.enum[0] ? "Yes" : "No",
72
- },
73
- {
74
- value: schema.enum[1],
75
- label: schema.enum[1] ? "Yes" : "No",
76
- },
77
- ];
78
- } else {
79
- enumOptions = optionsList({
80
- enum: schema.enum,
81
- // NOTE: enumNames is deprecated, but still supported for now.
82
- enumNames: schemaWithEnumNames.enumNames,
83
- }) as EnumOptionsType<any>[] | undefined;
84
- }
85
- }
86
-
87
- return (
88
- <Widget
89
- name={name}
90
- options={{ ...options, enumOptions }}
91
- schema={schema}
92
- uiSchema={uiSchema}
93
- id={idSchema && idSchema.$id}
94
- onChange={onChange}
95
- onFocus={onFocus}
96
- onBlur={onBlur}
97
- label={title === undefined ? name : title}
98
- value={formData}
99
- required={required}
100
- disabled={disabled}
101
- readonly={readonly}
102
- registry={registry}
103
- formContext={formContext}
104
- autofocus={autofocus}
105
- rawErrors={rawErrors}
106
- />
107
- );
108
- }
109
-
110
- export default BooleanField;
1
+ import React from "react";
2
+ import type {
3
+ FieldProps,
4
+ EnumOptionsType,
5
+ RJSFSchema,
6
+ GenericObjectType,
7
+ } from "@rjsf/utils";
8
+ import { getWidget, getUiOptions, optionsList } from "@rjsf/utils";
9
+ import isObject from "lodash/isObject";
10
+
11
+ /** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
12
+ * two boolean values based on the various alternatives in the schema.
13
+ *
14
+ * @param props - The `FieldProps` for this template
15
+ */
16
+ function BooleanField<T = any, F extends GenericObjectType = any>(
17
+ props: FieldProps<T, F>
18
+ ) {
19
+ const {
20
+ schema,
21
+ name,
22
+ uiSchema,
23
+ idSchema,
24
+ formData,
25
+ registry,
26
+ required,
27
+ disabled,
28
+ readonly,
29
+ autofocus,
30
+ onChange,
31
+ onFocus,
32
+ onBlur,
33
+ rawErrors,
34
+ } = props;
35
+ const { title } = schema;
36
+ const { widgets, formContext } = registry;
37
+ const { widget = "checkbox", ...options } = getUiOptions<T, F>(uiSchema);
38
+ const Widget = getWidget(schema, widget, widgets);
39
+
40
+ let enumOptions: EnumOptionsType<any>[] | undefined;
41
+
42
+ if (Array.isArray(schema.oneOf)) {
43
+ enumOptions = optionsList({
44
+ oneOf: schema.oneOf
45
+ .map((option) => {
46
+ if (isObject(option)) {
47
+ return {
48
+ ...option,
49
+ // @ts-ignore
50
+ title: option.title || (option.const === true ? "Yes" : "No"),
51
+ };
52
+ }
53
+ return undefined;
54
+ })
55
+ .filter((o) => o) as any[], // cast away the error that typescript can't grok is fixed
56
+ }) as EnumOptionsType<any>[] | undefined;
57
+ } else {
58
+ // We deprecated enumNames in v5. It's intentionally omitted from RSJFSchema type, so we need to cast here.
59
+ const schemaWithEnumNames = schema as RJSFSchema & { enumNames?: string[] };
60
+ // @ts-ignore
61
+ schema.enum = schema.enum ?? [true, false];
62
+ if (
63
+ !schemaWithEnumNames.enumNames &&
64
+ schema.enum &&
65
+ schema.enum.length === 2 &&
66
+ schema.enum.every((v: any) => typeof v === "boolean")
67
+ ) {
68
+ enumOptions = [
69
+ {
70
+ value: schema.enum[0],
71
+ label: schema.enum[0] ? "Yes" : "No",
72
+ },
73
+ {
74
+ value: schema.enum[1],
75
+ label: schema.enum[1] ? "Yes" : "No",
76
+ },
77
+ ];
78
+ } else {
79
+ enumOptions = optionsList({
80
+ enum: schema.enum,
81
+ // NOTE: enumNames is deprecated, but still supported for now.
82
+ enumNames: schemaWithEnumNames.enumNames,
83
+ }) as EnumOptionsType<any>[] | undefined;
84
+ }
85
+ }
86
+
87
+ return (
88
+ <Widget
89
+ name={name}
90
+ options={{ ...options, enumOptions }}
91
+ schema={schema}
92
+ uiSchema={uiSchema}
93
+ id={idSchema && idSchema.$id}
94
+ onChange={onChange}
95
+ onFocus={onFocus}
96
+ onBlur={onBlur}
97
+ label={title === undefined ? name : title}
98
+ value={formData}
99
+ required={required}
100
+ disabled={disabled}
101
+ readonly={readonly}
102
+ registry={registry}
103
+ formContext={formContext}
104
+ autofocus={autofocus}
105
+ rawErrors={rawErrors}
106
+ />
107
+ );
108
+ }
109
+
110
+ export default BooleanField;