@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.
- package/dist/FileUploadContext.d.ts +0 -1
- package/dist/Form.stories.js +14 -0
- package/dist/fields/stories/AnyField.stories.d.ts +2 -2
- package/dist/fields/stories/ArrayField.stories.d.ts +2 -2
- package/dist/fields/stories/ArrayField.stories.js +3 -3
- package/dist/fields/stories/BooleanField.stories.d.ts +2 -2
- package/dist/fields/stories/DateField.stories.d.ts +2 -2
- package/dist/fields/stories/FileUploadField.stories.d.ts +3 -3
- package/dist/fields/stories/FileUploadField.stories.js +1 -1
- package/dist/fields/stories/MultipleChoiceField.stories.d.ts +2 -2
- package/dist/fields/stories/MultipleChoiceField.stories.js +1 -1
- package/dist/fields/stories/NullField.stories.d.ts +2 -2
- package/dist/fields/stories/NumberField.stories.d.ts +2 -2
- package/dist/fields/stories/ObjectField.stories.d.ts +2 -2
- package/dist/fields/stories/RadioField.stories.d.ts +2 -2
- package/dist/fields/stories/SchemaField.stories.d.ts +111 -97
- package/dist/fields/stories/SchemaField.stories.js +2 -2
- package/dist/fields/stories/SearchMultiTagSelectField.stories.d.ts +2 -2
- package/dist/fields/stories/StringField.stories.d.ts +2 -2
- package/dist/fields/stories/StringField.stories.js +2 -2
- package/dist/fields/stories/TextAreaField.stories.d.ts +2 -2
- package/dist/fields/stories/ToggleField.stories.d.ts +2 -2
- package/dist/styledComponents.d.ts +197 -203
- package/dist/styledComponents.js +14 -9
- package/dist/utils/getStyle.js +2 -2
- package/dist/utils/getTitleAndDescription.d.ts +7 -7
- package/package.json +2 -1
package/dist/styledComponents.js
CHANGED
|
@@ -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 &&
|
|
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,
|
package/dist/utils/getStyle.js
CHANGED
|
@@ -8,11 +8,11 @@ export function getStyle(key) {
|
|
|
8
8
|
}
|
|
9
9
|
if (key === "twoColumns") {
|
|
10
10
|
style.display = "grid";
|
|
11
|
-
style["
|
|
11
|
+
style["gridTemplateColumns"] = "1fr 1fr";
|
|
12
12
|
}
|
|
13
13
|
if (key === "threeColumns") {
|
|
14
14
|
style.display = "grid";
|
|
15
|
-
style["
|
|
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
|
|
4
|
-
uiSchema?: UiSchema
|
|
5
|
-
schema?:
|
|
6
|
-
name?: string
|
|
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
|
|
10
|
-
uiSchema?: UiSchema
|
|
11
|
-
schema?:
|
|
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.
|
|
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",
|