-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add filepicker properties panel (#1244)
* feat: add filepicker properties panel * refactor: rework filepicker properties panel
- Loading branch information
Showing
12 changed files
with
197 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/form-js-editor/src/features/properties-panel/entries/AcceptEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { get } from 'min-dash'; | ||
|
||
import { useService, useVariables } from '../hooks'; | ||
|
||
import { FeelTemplatingEntry, isFeelEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
export function AcceptEntry(props) { | ||
const { editField, field } = props; | ||
|
||
const entries = []; | ||
|
||
entries.push({ | ||
id: 'accept', | ||
component: Accept, | ||
editField: editField, | ||
field: field, | ||
isEdited: isFeelEntryEdited, | ||
isDefaultVisible: (field) => field.type === 'filepicker', | ||
}); | ||
|
||
return entries; | ||
} | ||
|
||
function Accept(props) { | ||
const { editField, field, id } = props; | ||
|
||
const debounce = useService('debounce'); | ||
|
||
const variables = useVariables().map((name) => ({ name })); | ||
|
||
const path = ['accept']; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
return FeelTemplatingEntry({ | ||
debounce, | ||
element: field, | ||
getValue, | ||
id, | ||
label: 'Supported file formats', | ||
singleLine: true, | ||
setValue, | ||
variables, | ||
description, | ||
}); | ||
} | ||
|
||
// helpers ////////// | ||
|
||
const description = ( | ||
<> | ||
A comma-separated list of{' '} | ||
<a | ||
href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers" | ||
target="_blank"> | ||
file type specifiers | ||
</a> | ||
</> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/form-js-editor/src/features/properties-panel/entries/MultipleEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { get } from 'min-dash'; | ||
|
||
import { useService, useVariables } from '../hooks'; | ||
|
||
import { FeelToggleSwitchEntry, isFeelEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
export function MultipleEntry(props) { | ||
const { editField, field } = props; | ||
|
||
const entries = []; | ||
|
||
entries.push({ | ||
id: 'multiple', | ||
component: Multiple, | ||
editField: editField, | ||
field: field, | ||
isEdited: isFeelEntryEdited, | ||
isDefaultVisible: (field) => field.type === 'filepicker', | ||
}); | ||
|
||
return entries; | ||
} | ||
|
||
function Multiple(props) { | ||
const { editField, field, id } = props; | ||
|
||
const debounce = useService('debounce'); | ||
|
||
const variables = useVariables().map((name) => ({ name })); | ||
|
||
const path = ['multiple']; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
return FeelToggleSwitchEntry({ | ||
debounce, | ||
element: field, | ||
feel: 'optional', | ||
getValue, | ||
id, | ||
label: 'Upload multiple files', | ||
inline: true, | ||
setValue, | ||
variables, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters