@nolwenture/formik-jsonschema-form 0.7.1 → 0.8.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 (66) hide show
  1. package/README.md +52 -1
  2. package/dist/Form.stories.d.ts +1 -0
  3. package/dist/Form.stories.js +8 -0
  4. package/dist/Form.test.d.ts +1 -1
  5. package/dist/Form.test.js +3 -1
  6. package/dist/fields/MultipleChoiceField.d.ts +3 -0
  7. package/dist/fields/MultipleChoiceField.js +15 -0
  8. package/dist/fields/ObjectField.js +3 -1
  9. package/dist/fields/StringField.js +1 -1
  10. package/dist/fields/index.d.ts +1 -0
  11. package/dist/fields/index.js +1 -0
  12. package/dist/fields/stories/AnyField.stories.d.ts +5 -0
  13. package/dist/fields/stories/AnyField.stories.js +79 -0
  14. package/dist/fields/stories/ArrayField.stories.d.ts +7 -0
  15. package/dist/fields/stories/ArrayField.stories.js +191 -0
  16. package/dist/fields/stories/BooleanField.stories.d.ts +5 -0
  17. package/dist/fields/stories/BooleanField.stories.js +36 -0
  18. package/dist/fields/stories/DateField.stories.d.ts +5 -0
  19. package/dist/fields/stories/DateField.stories.js +34 -0
  20. package/dist/fields/stories/NullField.stories.d.ts +5 -0
  21. package/dist/fields/stories/NullField.stories.js +38 -0
  22. package/dist/fields/stories/NumberField.stories.d.ts +5 -0
  23. package/dist/fields/stories/NumberField.stories.js +33 -0
  24. package/dist/fields/stories/ObjectField.stories.d.ts +5 -0
  25. package/dist/fields/stories/ObjectField.stories.js +76 -0
  26. package/dist/fields/stories/RadioField.stories.d.ts +5 -0
  27. package/dist/fields/stories/RadioField.stories.js +42 -0
  28. package/dist/fields/stories/SchemaField.stories.d.ts +1673 -0
  29. package/dist/fields/stories/SchemaField.stories.js +39 -0
  30. package/dist/fields/stories/SearchMultiTagSelectField.stories.d.ts +5 -0
  31. package/dist/fields/stories/SearchMultiTagSelectField.stories.js +58 -0
  32. package/dist/fields/stories/StringField.stories.d.ts +7 -0
  33. package/dist/fields/stories/StringField.stories.js +75 -0
  34. package/dist/fields/stories/ToggleField.stories.d.ts +5 -0
  35. package/dist/fields/stories/ToggleField.stories.js +34 -0
  36. package/dist/hooks/__tests__/useExtractUiSchema.test.d.ts +1 -0
  37. package/dist/hooks/__tests__/useExtractUiSchema.test.js +45 -0
  38. package/dist/hooks/__tests__/useSetDefault.test.d.ts +1 -0
  39. package/dist/hooks/__tests__/useSetDefault.test.js +65 -0
  40. package/dist/hooks/useExtractUiSchema.js +7 -3
  41. package/dist/sampleData/multipleChoiceSchema.d.ts +3 -0
  42. package/dist/sampleData/multipleChoiceSchema.js +112 -0
  43. package/dist/sampleData/requiredInputSchema.js +0 -5
  44. package/dist/styledComponents.d.ts +2 -1
  45. package/dist/styledComponents.js +10 -0
  46. package/dist/types.d.ts +15 -0
  47. package/dist/utils/__tests/createInitialValues.test.d.ts +1 -0
  48. package/dist/utils/__tests/createInitialValues.test.js +72 -0
  49. package/dist/utils/__tests/deepOverlap.test.d.ts +1 -0
  50. package/dist/utils/__tests/deepOverlap.test.js +41 -0
  51. package/dist/utils/__tests/getEnums.test.js +11 -16
  52. package/dist/utils/__tests/getTitleAndDescription.test.d.ts +1 -0
  53. package/dist/utils/__tests/getTitleAndDescription.test.js +53 -0
  54. package/dist/utils/__tests/getTypes.test.d.ts +1 -0
  55. package/dist/utils/__tests/getTypes.test.js +62 -0
  56. package/dist/utils/__tests/mergeSchemas.test.d.ts +1 -0
  57. package/dist/utils/__tests/mergeSchemas.test.js +40 -0
  58. package/dist/utils/__tests/resolveSchema.test.js +28 -28
  59. package/dist/utils/createInitialValues.d.ts +4 -0
  60. package/dist/utils/createInitialValues.js +27 -0
  61. package/dist/utils/getStyle.d.ts +5 -0
  62. package/dist/utils/getStyle.js +18 -0
  63. package/dist/utils/getTypes.js +1 -1
  64. package/dist/utils/index.d.ts +1 -0
  65. package/dist/utils/index.js +1 -0
  66. package/package.json +5 -2
@@ -0,0 +1,76 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { userEvent, expect } from "@storybook/test";
12
+ import { Formik, Form } from "formik";
13
+ import { ObjectField } from "./../ObjectField";
14
+ export default {
15
+ title: "Components/ObjectField",
16
+ component: ObjectField,
17
+ decorators: [
18
+ (Story) => (_jsx(Formik, { initialValues: {}, onSubmit: () => { }, children: _jsx(Form, { children: Story() }) })),
19
+ ],
20
+ };
21
+ export const Default = {
22
+ args: {
23
+ name: "object",
24
+ schema: {
25
+ type: "object",
26
+ title: "Object field test",
27
+ properties: {
28
+ string: {
29
+ type: "string",
30
+ title: "stringField",
31
+ description: "String description",
32
+ },
33
+ number: {
34
+ type: "number",
35
+ title: "numberField",
36
+ description: "Number description",
37
+ },
38
+ boolean: {
39
+ type: "boolean",
40
+ title: "booleanField",
41
+ description: "Boolean description",
42
+ default: false,
43
+ },
44
+ enum: {
45
+ type: "array",
46
+ title: "Array Enum",
47
+ description: "Array Enum description",
48
+ items: {
49
+ type: "number",
50
+ enum: [1, 2, 3, 4],
51
+ },
52
+ },
53
+ null: {
54
+ type: "null",
55
+ title: "nullField",
56
+ description: "Null description",
57
+ },
58
+ },
59
+ },
60
+ uiSchema: {},
61
+ },
62
+ play: (_a) => __awaiter(void 0, [_a], void 0, function* ({ canvasElement }) {
63
+ const stringField = canvasElement.querySelector('input[name="object.string"]');
64
+ const numberField = canvasElement.querySelector('input[name="object.number"]');
65
+ const booleanField = canvasElement.querySelector('input[name="object.boolean"]');
66
+ const enumField = canvasElement.querySelector('select[name="object.enum[0]"]');
67
+ yield userEvent.type(stringField, "string");
68
+ yield userEvent.type(numberField, "123");
69
+ yield userEvent.click(booleanField);
70
+ yield userEvent.selectOptions(enumField, "2");
71
+ expect(stringField).toHaveValue("string");
72
+ expect(numberField).toHaveValue(123);
73
+ expect(booleanField).toBeChecked();
74
+ expect(enumField).toHaveValue("2");
75
+ }),
76
+ };
@@ -0,0 +1,5 @@
1
+ import { StoryObj } from "@storybook/react";
2
+ import { RadioField } from "./../RadioField";
3
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react").ReactRenderer, import("../../types").FieldProps>;
4
+ export default _default;
5
+ export declare const Default: StoryObj<typeof RadioField>;
@@ -0,0 +1,42 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { userEvent, expect } from "@storybook/test";
12
+ import { RadioField } from "./../RadioField";
13
+ import { Formik, Form } from "formik";
14
+ export default {
15
+ title: "Components/RadioField",
16
+ component: RadioField,
17
+ decorators: [
18
+ (Story) => (_jsx(Formik, { initialValues: {}, onSubmit: () => { }, children: _jsx(Form, { children: Story() }) })),
19
+ ],
20
+ };
21
+ export const Default = {
22
+ args: {
23
+ name: "RadioField",
24
+ title: "Radio field test",
25
+ schema: {
26
+ type: "boolean",
27
+ },
28
+ uiSchema: {
29
+ "ui:label": { true: "yes", false: "no" },
30
+ },
31
+ },
32
+ play: (_a) => __awaiter(void 0, [_a], void 0, function* ({ canvasElement }) {
33
+ const radioTrue = canvasElement.querySelector('input[type="radio"][name="RadioField"][value="true"]');
34
+ const radioFalse = canvasElement.querySelector('input[type="radio"][name="RadioField"][value="false"]');
35
+ yield userEvent.click(radioTrue);
36
+ yield expect(radioTrue).toBeChecked();
37
+ yield expect(radioFalse).not.toBeChecked();
38
+ yield userEvent.click(radioFalse);
39
+ yield expect(radioFalse).toBeChecked();
40
+ yield expect(radioTrue).not.toBeChecked();
41
+ }),
42
+ };