diff --git a/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-chromium-linux.png b/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-chromium-linux.png index 888c7626c..db8dfab46 100644 Binary files a/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-chromium-linux.png and b/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-chromium-linux.png differ diff --git a/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-firefox-linux.png b/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-firefox-linux.png index f59ae110a..3b02ccaa3 100644 Binary files a/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-firefox-linux.png and b/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-firefox-linux.png differ diff --git a/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-webkit-linux.png b/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-webkit-linux.png index 683fb9edc..624c66e83 100644 Binary files a/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-webkit-linux.png and b/e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-webkit-linux.png differ diff --git a/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-chromium-linux.png b/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-chromium-linux.png index f690dcec4..bfab42f37 100644 Binary files a/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-chromium-linux.png and b/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-chromium-linux.png differ diff --git a/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-firefox-linux.png b/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-firefox-linux.png index a4690d464..6df9500e5 100644 Binary files a/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-firefox-linux.png and b/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-firefox-linux.png differ diff --git a/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-webkit-linux.png b/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-webkit-linux.png index 777ac0eca..890702285 100644 Binary files a/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-webkit-linux.png and b/e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-webkit-linux.png differ diff --git a/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-chromium-linux.png b/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-chromium-linux.png index 4b1a4ac60..140d22cbc 100644 Binary files a/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-chromium-linux.png and b/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-chromium-linux.png differ diff --git a/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-firefox-linux.png b/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-firefox-linux.png index 2d5797ac0..a6c43bef2 100644 Binary files a/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-firefox-linux.png and b/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-firefox-linux.png differ diff --git a/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-webkit-linux.png b/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-webkit-linux.png index 1cb7963f2..17aa27590 100644 Binary files a/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-webkit-linux.png and b/e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-webkit-linux.png differ diff --git a/e2e/visual/theming.spec.js-snapshots/theming---editor-1-chromium-linux.png b/e2e/visual/theming.spec.js-snapshots/theming---editor-1-chromium-linux.png index 9184ac83f..e3124395a 100644 Binary files a/e2e/visual/theming.spec.js-snapshots/theming---editor-1-chromium-linux.png and b/e2e/visual/theming.spec.js-snapshots/theming---editor-1-chromium-linux.png differ diff --git a/e2e/visual/theming.spec.js-snapshots/theming---editor-1-firefox-linux.png b/e2e/visual/theming.spec.js-snapshots/theming---editor-1-firefox-linux.png index 89e953888..9fdd9d956 100644 Binary files a/e2e/visual/theming.spec.js-snapshots/theming---editor-1-firefox-linux.png and b/e2e/visual/theming.spec.js-snapshots/theming---editor-1-firefox-linux.png differ diff --git a/e2e/visual/theming.spec.js-snapshots/theming---editor-1-webkit-linux.png b/e2e/visual/theming.spec.js-snapshots/theming---editor-1-webkit-linux.png index 2ef3ff2ee..00b27f4da 100644 Binary files a/e2e/visual/theming.spec.js-snapshots/theming---editor-1-webkit-linux.png and b/e2e/visual/theming.spec.js-snapshots/theming---editor-1-webkit-linux.png differ diff --git a/packages/form-js-viewer/src/render/components/form-fields/FilePicker.js b/packages/form-js-viewer/src/render/components/form-fields/FilePicker.js new file mode 100644 index 000000000..3db489a64 --- /dev/null +++ b/packages/form-js-viewer/src/render/components/form-fields/FilePicker.js @@ -0,0 +1,18 @@ +/** + * @returns {import("preact").JSX.Element} + */ +export function FilePicker() { + return null; +} + +FilePicker.config = { + type: 'filepicker', + keyed: true, + label: 'File picker', + group: 'basic-input', + emptyValue: null, + sanitizeValue: ({ value }) => { + return value; + }, + create: (options = {}) => ({ ...options }), +}; diff --git a/packages/form-js-viewer/src/render/components/icons/FilePicker.svg b/packages/form-js-viewer/src/render/components/icons/FilePicker.svg new file mode 100644 index 000000000..7cd733f13 --- /dev/null +++ b/packages/form-js-viewer/src/render/components/icons/FilePicker.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/form-js-viewer/src/render/components/icons/index.js b/packages/form-js-viewer/src/render/components/icons/index.js index e1729d27f..7896d8201 100644 --- a/packages/form-js-viewer/src/render/components/icons/index.js +++ b/packages/form-js-viewer/src/render/components/icons/index.js @@ -20,6 +20,7 @@ import IFrameIcon from './IFrame.svg'; import ImageIcon from './Image.svg'; import GroupIcon from './Group.svg'; import TableIcon from './Table.svg'; +import FilePickerIcon from './FilePicker.svg'; export const iconsByType = (type) => { return { @@ -44,6 +45,7 @@ export const iconsByType = (type) => { textfield: TextfieldIcon, textarea: TextareaIcon, table: TableIcon, + filepicker: FilePickerIcon, default: FormIcon, }[type]; }; diff --git a/packages/form-js-viewer/src/render/components/index.js b/packages/form-js-viewer/src/render/components/index.js index 0256d2dab..6446b5abe 100644 --- a/packages/form-js-viewer/src/render/components/index.js +++ b/packages/form-js-viewer/src/render/components/index.js @@ -19,6 +19,7 @@ import { ExpressionField } from './form-fields/ExpressionField'; import { Textfield } from './form-fields/Textfield'; import { Textarea } from './form-fields/Textarea'; import { Table } from './form-fields/Table'; +import { FilePicker } from './form-fields/FilePicker'; import { Label } from './Label'; import { Description } from './Description'; @@ -52,6 +53,7 @@ export { Textfield, Textarea, Table, + FilePicker, }; export const formFields = [ @@ -61,6 +63,7 @@ export const formFields = [ Numberfield, Datetime, ExpressionField, + FilePicker, /* Selection */ Checkbox, diff --git a/packages/form-json-schema/src/defs/component.json b/packages/form-json-schema/src/defs/component.json index faadabc9c..12e694feb 100644 --- a/packages/form-json-schema/src/defs/component.json +++ b/packages/form-json-schema/src/defs/component.json @@ -262,6 +262,16 @@ "$id": "#/component/content", "description": "The content of a custom component.", "type": "string" + }, + "accept": { + "$id": "#/component/accept", + "description": "Define the accepted file types.", + "type": "string" + }, + "multiple": { + "$id": "#/component/multiple", + "description": "Allow multiple files to be selected.", + "type": "boolean" } }, "required": ["type"] diff --git a/packages/form-json-schema/src/defs/field-types/inputs.json b/packages/form-json-schema/src/defs/field-types/inputs.json index 14d871981..4fbb5f1f3 100644 --- a/packages/form-json-schema/src/defs/field-types/inputs.json +++ b/packages/form-json-schema/src/defs/field-types/inputs.json @@ -11,7 +11,8 @@ "taglist", "textfield", "textarea", - "expression" + "expression", + "filepicker" ] } }, diff --git a/packages/form-json-schema/src/defs/rules/rules-allowed-properties.json b/packages/form-json-schema/src/defs/rules/rules-allowed-properties.json index f64233bfa..c0e02a43f 100644 --- a/packages/form-json-schema/src/defs/rules/rules-allowed-properties.json +++ b/packages/form-json-schema/src/defs/rules/rules-allowed-properties.json @@ -397,6 +397,24 @@ "content": false } } + }, + { + "if": { + "not": { + "properties": { + "type": { + "const": "filepicker" + } + }, + "required": ["type"] + } + }, + "then": { + "properties": { + "accept": false, + "multiple": false + } + } } ] } diff --git a/packages/form-json-schema/src/defs/type.json b/packages/form-json-schema/src/defs/type.json index 77d840553..e7587befc 100644 --- a/packages/form-json-schema/src/defs/type.json +++ b/packages/form-json-schema/src/defs/type.json @@ -22,6 +22,7 @@ "separator", "table", "iframe", - "expression" + "expression", + "filepicker" ] } diff --git a/packages/form-json-schema/test/fixtures/accept-not-allowed.js b/packages/form-json-schema/test/fixtures/accept-not-allowed.js new file mode 100644 index 000000000..f9e6423be --- /dev/null +++ b/packages/form-json-schema/test/fixtures/accept-not-allowed.js @@ -0,0 +1,27 @@ +export const form = { + type: 'default', + components: [ + { + type: 'textfield', + key: 'textfield_g35o3e', + accept: '.png,.jpg', + }, + ], +}; + +export const errors = [ + { + instancePath: '/components/0/accept', + keyword: 'false schema', + message: 'boolean schema is false', + params: {}, + schemaPath: '#/properties/components/items/allOf/1/allOf/20/then/properties/accept/false schema', + }, + { + instancePath: '/components/0', + schemaPath: '#/properties/components/items/allOf/1/allOf/20/if', + keyword: 'if', + params: { failingKeyword: 'then' }, + message: 'must match "then" schema', + }, +]; diff --git a/packages/form-json-schema/test/fixtures/filepicker.js b/packages/form-json-schema/test/fixtures/filepicker.js new file mode 100644 index 000000000..44d3893d7 --- /dev/null +++ b/packages/form-json-schema/test/fixtures/filepicker.js @@ -0,0 +1,13 @@ +export const form = { + type: 'default', + components: [ + { + type: 'filepicker', + key: 'filepicker', + accept: '.png,.jpg', + multiple: true, + }, + ], +}; + +export const errors = null; diff --git a/packages/form-json-schema/test/fixtures/multiple-not-allowed.js b/packages/form-json-schema/test/fixtures/multiple-not-allowed.js new file mode 100644 index 000000000..634dab41f --- /dev/null +++ b/packages/form-json-schema/test/fixtures/multiple-not-allowed.js @@ -0,0 +1,27 @@ +export const form = { + type: 'default', + components: [ + { + type: 'textfield', + key: 'textfield_g35o3e', + multiple: true, + }, + ], +}; + +export const errors = [ + { + instancePath: '/components/0/multiple', + keyword: 'false schema', + message: 'boolean schema is false', + params: {}, + schemaPath: '#/properties/components/items/allOf/1/allOf/20/then/properties/multiple/false schema', + }, + { + instancePath: '/components/0', + schemaPath: '#/properties/components/items/allOf/1/allOf/20/if', + keyword: 'if', + params: { failingKeyword: 'then' }, + message: 'must match "then" schema', + }, +]; diff --git a/packages/form-json-schema/test/spec/validation.spec.js b/packages/form-json-schema/test/spec/validation.spec.js index 6e0fe7f08..5b9d2766e 100644 --- a/packages/form-json-schema/test/spec/validation.spec.js +++ b/packages/form-json-schema/test/spec/validation.spec.js @@ -174,6 +174,12 @@ describe('validation', function () { testForm('dataSource-not-allowed'); testForm('columns-columnsExpression-exclusive'); + + testForm('filepicker'); + + testForm('accept-not-allowed'); + + testForm('multiple-not-allowed'); }); describe('rules - default', function () {