-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented separator form field
Closes #480
- Loading branch information
Showing
13 changed files
with
138 additions
and
7 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
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
22 changes: 22 additions & 0 deletions
22
packages/form-js-viewer/src/render/components/form-fields/Separator.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,22 @@ | ||
import { formFieldClasses } from '../Util'; | ||
|
||
const type = 'separator'; | ||
|
||
export default function Separator() { | ||
|
||
return ( | ||
<div class={ formFieldClasses(type) }> | ||
<hr /> | ||
</div> | ||
); | ||
} | ||
|
||
Separator.config = { | ||
type, | ||
keyed: false, | ||
label: 'Separator', | ||
group: 'presentation', | ||
create: (options = {}) => ({ | ||
...options | ||
}) | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/form-js-viewer/src/render/components/icons/Separator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions
10
packages/form-js-viewer/src/render/components/icons/Spacer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
69 changes: 69 additions & 0 deletions
69
packages/form-js-viewer/test/spec/render/components/form-fields/Separator.spec.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,69 @@ | ||
import { render } from '@testing-library/preact/pure'; | ||
|
||
import Separator from '../../../../../src/render/components/form-fields/Separator'; | ||
|
||
import { | ||
createFormContainer | ||
} from '../../../../TestHelper'; | ||
|
||
import { WithFormContext } from './helper'; | ||
|
||
let container; | ||
|
||
|
||
describe('Separator', function() { | ||
|
||
beforeEach(function() { | ||
container = createFormContainer(); | ||
}); | ||
|
||
afterEach(function() { | ||
container.remove(); | ||
}); | ||
|
||
it('should render', function() { | ||
|
||
// when | ||
const { container } = createSeparator(); | ||
|
||
// then | ||
const formField = container.querySelector('.fjs-form-field'); | ||
|
||
expect(formField).to.exist; | ||
expect(formField.classList.contains('fjs-form-field-separator')).to.be.true; | ||
|
||
const separator = formField.querySelector('hr'); | ||
expect(separator).to.exist; | ||
|
||
}); | ||
|
||
}); | ||
|
||
// helpers ////////// | ||
|
||
const defaultField = { | ||
type: 'separator' | ||
}; | ||
|
||
function createSeparator(options = {}) { | ||
const { | ||
data = {}, | ||
initialData = {}, | ||
properties = {}, | ||
field = defaultField | ||
} = options; | ||
|
||
return render(WithFormContext( | ||
<Separator field={ field } | ||
/>, | ||
{ | ||
...options, | ||
properties, | ||
initialData, | ||
data | ||
} | ||
), | ||
{ | ||
container: options.container || container.querySelector('.fjs-form') | ||
}); | ||
} |