-
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
- Loading branch information
Showing
9 changed files
with
178 additions
and
10 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
43 changes: 43 additions & 0 deletions
43
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,43 @@ | ||
import { get } from 'min-dash'; | ||
|
||
import { ToggleSwitchEntry, isToggleSwitchEntryEdited } 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: isToggleSwitchEntryEdited, | ||
isDefaultVisible: (field) => field.type === 'filepicker', | ||
}); | ||
|
||
return entries; | ||
} | ||
|
||
function Multiple(props) { | ||
const { editField, field, id } = props; | ||
|
||
const path = ['multiple']; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
return ToggleSwitchEntry({ | ||
element: field, | ||
getValue, | ||
id, | ||
label: 'Can upload multiple files', | ||
inline: true, | ||
setValue, | ||
}); | ||
} |
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