@nolwenture/formik-jsonschema-form 0.22.1 → 0.22.3

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 (27) hide show
  1. package/dist/FileUploadContext.d.ts +0 -1
  2. package/dist/Form.stories.js +14 -0
  3. package/dist/fields/stories/AnyField.stories.d.ts +2 -2
  4. package/dist/fields/stories/ArrayField.stories.d.ts +2 -2
  5. package/dist/fields/stories/ArrayField.stories.js +3 -3
  6. package/dist/fields/stories/BooleanField.stories.d.ts +2 -2
  7. package/dist/fields/stories/DateField.stories.d.ts +2 -2
  8. package/dist/fields/stories/FileUploadField.stories.d.ts +3 -3
  9. package/dist/fields/stories/FileUploadField.stories.js +1 -1
  10. package/dist/fields/stories/MultipleChoiceField.stories.d.ts +2 -2
  11. package/dist/fields/stories/MultipleChoiceField.stories.js +1 -1
  12. package/dist/fields/stories/NullField.stories.d.ts +2 -2
  13. package/dist/fields/stories/NumberField.stories.d.ts +2 -2
  14. package/dist/fields/stories/ObjectField.stories.d.ts +2 -2
  15. package/dist/fields/stories/RadioField.stories.d.ts +2 -2
  16. package/dist/fields/stories/SchemaField.stories.d.ts +111 -97
  17. package/dist/fields/stories/SchemaField.stories.js +2 -2
  18. package/dist/fields/stories/SearchMultiTagSelectField.stories.d.ts +2 -2
  19. package/dist/fields/stories/StringField.stories.d.ts +2 -2
  20. package/dist/fields/stories/StringField.stories.js +2 -2
  21. package/dist/fields/stories/TextAreaField.stories.d.ts +2 -2
  22. package/dist/fields/stories/ToggleField.stories.d.ts +2 -2
  23. package/dist/styledComponents.d.ts +197 -203
  24. package/dist/styledComponents.js +14 -9
  25. package/dist/utils/getStyle.js +2 -2
  26. package/dist/utils/getTitleAndDescription.d.ts +7 -7
  27. package/package.json +2 -1
@@ -273,13 +273,6 @@ export const RadioButtonField = ({ label, inputProps, name, className, }) => {
273
273
  var _a, _b;
274
274
  return (_jsxs(RadioButtonFieldContainer, { className: className, children: [_jsxs(RadioButtonFieldElement, { children: [_jsx(RadioButtonFieldInput, Object.assign({}, inputProps, { name: name, type: "radio", value: "true" })), _jsx(ButtonLabelTrue, { children: (_a = label === null || label === void 0 ? void 0 : label.true) !== null && _a !== void 0 ? _a : "true" })] }), _jsxs(RadioButtonFieldElement, { children: [_jsx(RadioButtonFieldInput, Object.assign({}, inputProps, { name: name, type: "radio", value: "false" })), _jsx(ButtonLabelFalse, { children: (_b = label === null || label === void 0 ? void 0 : label.false) !== null && _b !== void 0 ? _b : "false" })] })] }));
275
275
  };
276
- const MultipleChoiceFieldContainer = styled(RadioButtonFieldContainer) ``;
277
- const MultipleChoiceFieldElement = styled(RadioButtonFieldElement) ``;
278
- const MultipleChoiceFieldInput = styled(RadioButtonFieldInput) ``;
279
- const MultipleChoiceFieldLabel = styled(ButtonLabel) ``;
280
- export const MultipleChoiceField = ({ inputProps, name, className, enums, style, }) => {
281
- return (_jsx(MultipleChoiceFieldContainer, { className: className, style: getStyle(style !== null && style !== void 0 ? style : ""), children: enums.values.map((v) => (_jsxs(MultipleChoiceFieldElement, { children: [_jsx(MultipleChoiceFieldInput, Object.assign({}, inputProps, { name: name, type: enums.type === "multiSelect" ? "checkbox" : "radio", value: typeof v === "string" || typeof v === "number" ? v : v.const })), _jsx(MultipleChoiceFieldLabel, { children: typeof v === "string" || typeof v === "number" ? v : v.title })] }, typeof v === "string" || typeof v === "number" ? v : v.const))) }));
282
- };
283
276
  RadioButtonField.styles = {
284
277
  RadioButtonFieldContainerStyle: RadioButtonFieldContainer,
285
278
  RadioButtonFieldElementStyle: RadioButtonFieldElement,
@@ -288,6 +281,18 @@ RadioButtonField.styles = {
288
281
  ButtonLabelTrueStyle: ButtonLabelTrue,
289
282
  ButtonLabelFalseStyle: ButtonLabelFalse,
290
283
  };
284
+ export const MultipleChoiceFieldContainer = styled(RadioButtonFieldContainer) ``;
285
+ export const MultipleChoiceFieldElement = styled(RadioButtonFieldElement) ``;
286
+ export const MultipleChoiceFieldInput = styled(RadioButtonFieldInput) ``;
287
+ export const MultipleChoiceFieldLabel = styled(ButtonLabel) ``;
288
+ export const MultipleChoiceField = ({ inputProps, name, className, enums, style, }) => {
289
+ return (_jsx(MultipleChoiceFieldContainer, { className: className, style: getStyle(style !== null && style !== void 0 ? style : ""), children: enums.values.map((v) => (_jsxs(MultipleChoiceFieldElement, { children: [_jsx(MultipleChoiceFieldInput, Object.assign({}, inputProps, { name: name, type: enums.type === "multiSelect" ? "checkbox" : "radio", value: typeof v === "string" || typeof v === "number" ? v : v.const })), _jsx(MultipleChoiceFieldLabel, { children: typeof v === "string" || typeof v === "number" ? v : v.title })] }, typeof v === "string" || typeof v === "number" ? v : v.const))) }));
290
+ };
291
+ MultipleChoiceField.styles = {
292
+ MultipleChoiceFieldElementStyle: MultipleChoiceFieldElement,
293
+ MultipleChoiceFieldInputStyle: MultipleChoiceFieldInput,
294
+ MultipleChoiceFieldLabelStyle: MultipleChoiceFieldLabel,
295
+ };
291
296
  // ---> SearchableMultiTagSelectField
292
297
  export const MultiSelectContainer = styled.div `
293
298
  display: flex;
@@ -510,7 +515,7 @@ export const FileInfoText = styled.span `
510
515
  `;
511
516
  export const FileUploadFieldContainer = styled.div ``;
512
517
  export const FileUploadField = ({ name, uploadedFile, handleFileUpload, value, setFieldValue, className, uploadProgress, handleRemoveFile, removeButton, uploadButtonText, infoText, }) => {
513
- var _a, _b;
518
+ var _a, _b, _c;
514
519
  const uiSchema = {};
515
520
  return (_jsxs(FileUploadFieldContainer, { className: className, children: [_jsxs("div", { children: [_jsx(FileUploadButton, { type: "button", onClick: () => { var _a; return (_a = document.getElementById(name)) === null || _a === void 0 ? void 0 : _a.click(); }, children: uploadButtonText !== null && uploadButtonText !== void 0 ? uploadButtonText : "Choose File" }), _jsx(HiddenFileInput, { id: name, name: name, type: "file", onChange: (event) => {
516
521
  const file = event.currentTarget.files[0];
@@ -518,7 +523,7 @@ export const FileUploadField = ({ name, uploadedFile, handleFileUpload, value, s
518
523
  handleFileUpload(file, setFieldValue);
519
524
  event.target.value = null;
520
525
  }
521
- } }), !value ? (_jsx(FileInfoText, { children: infoText !== null && infoText !== void 0 ? infoText : "No file chosen" })) : null] }), uploadedFile && value && (_jsx(FileItemContainer, { children: uploadProgress === 100 ? (_jsxs(_Fragment, { children: [_jsx("span", { children: uploadedFile.name }), _jsx(RemoveButton, Object.assign({ type: "button", onClick: () => handleRemoveFile(setFieldValue) }, ((_a = removeButton === null || removeButton === void 0 ? void 0 : removeButton.props) !== null && _a !== void 0 ? _a : {}), { children: (_b = removeButton === null || removeButton === void 0 ? void 0 : removeButton.content) !== null && _b !== void 0 ? _b : "X" }))] })) : (_jsxs(_Fragment, { children: [_jsx("span", { children: uploadedFile.name }), _jsxs(ProgressBarContainer, { children: [_jsx(ProgressBar, { "$progress": uploadProgress }), _jsxs(ProgressText, { children: [uploadProgress, "%"] })] })] })) }))] }));
526
+ } }), !value ? (_jsx(FileInfoText, { children: infoText !== null && infoText !== void 0 ? infoText : "No file chosen" })) : null] }), uploadedFile && value && (_jsx(FileItemContainer, { children: uploadProgress === 100 ? (_jsxs(_Fragment, { children: [_jsx("span", { children: uploadedFile.name }), _jsx(RemoveButton, Object.assign({ type: "button", onClick: () => handleRemoveFile(setFieldValue) }, removeButton === null || removeButton === void 0 ? void 0 : removeButton.props, { style: Object.assign({ color: "red", fontWeight: "bold" }, ((_b = (_a = removeButton === null || removeButton === void 0 ? void 0 : removeButton.props) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {})), children: (_c = removeButton === null || removeButton === void 0 ? void 0 : removeButton.content) !== null && _c !== void 0 ? _c : "X" }))] })) : (_jsxs(_Fragment, { children: [_jsx("span", { children: uploadedFile.name }), _jsxs(ProgressBarContainer, { children: [_jsx(ProgressBar, { "$progress": uploadProgress }), _jsxs(ProgressText, { children: [uploadProgress, "%"] })] })] })) }))] }));
522
527
  };
523
528
  FileUploadField.styles = {
524
529
  FileUploadFieldFileUploadFieldContainerStyle: FileUploadFieldContainer,
@@ -8,11 +8,11 @@ export function getStyle(key) {
8
8
  }
9
9
  if (key === "twoColumns") {
10
10
  style.display = "grid";
11
- style["grid-template-columns"] = "1fr 1fr";
11
+ style["gridTemplateColumns"] = "1fr 1fr";
12
12
  }
13
13
  if (key === "threeColumns") {
14
14
  style.display = "grid";
15
- style["grid-template-columns"] = "1fr 1fr 1fr";
15
+ style["gridTemplateColumns"] = "1fr 1fr 1fr";
16
16
  }
17
17
  return style;
18
18
  }
@@ -1,12 +1,12 @@
1
1
  import type { Schema, UiSchema } from "../types";
2
2
  export declare const getTitle: ({ title, uiSchema, schema, name, }: {
3
- title?: string | undefined;
4
- uiSchema?: UiSchema | undefined;
5
- schema?: import("json-schema").JSONSchema7 | undefined;
6
- name?: string | undefined;
3
+ title?: string;
4
+ uiSchema?: UiSchema;
5
+ schema?: Schema;
6
+ name?: string;
7
7
  }) => any;
8
8
  export declare const getDescription: ({ description, uiSchema, schema, }: {
9
- description?: string | undefined;
10
- uiSchema?: UiSchema | undefined;
11
- schema?: import("json-schema").JSONSchema7 | undefined;
9
+ description?: string;
10
+ uiSchema?: UiSchema;
11
+ schema?: Schema;
12
12
  }) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolwenture/formik-jsonschema-form",
3
- "version": "0.22.1",
3
+ "version": "0.22.3",
4
4
  "description": "Formik form generation from json schema",
5
5
  "author": "Antti Vikman <antti.vikman@nolwenture.com>",
6
6
  "contributors": [
@@ -43,6 +43,7 @@
43
43
  "yup": "^1.4.0"
44
44
  },
45
45
  "devDependencies": {
46
+ "@babel/preset-env": "^7.25.4",
46
47
  "@babel/preset-react": "^7.24.1",
47
48
  "@babel/preset-typescript": "^7.24.1",
48
49
  "@storybook/addon-essentials": "^8.0.5",