-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for input types date, datetime-local and time (#20)
- Loading branch information
1 parent
0a83e03
commit d2fed45
Showing
14 changed files
with
173 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
describe('Date and Time', () => { | ||
beforeEach(() => { | ||
cy.visit('/#/e2e/date-and-time') | ||
}) | ||
|
||
it('Displays a date field with min and max values', () => { | ||
cy | ||
.get('#phormal-field-input-date') | ||
.should('have.attr', 'min', '2023-01-01') | ||
.should('have.attr', 'max', '2023-12-31') | ||
}) | ||
|
||
it('Displays a datetime field with min and max values', () => { | ||
cy | ||
.get('#phormal-field-input-datetimeLocal') | ||
.should('have.attr', 'min', '2023-01-01T00:00') | ||
.should('have.attr', 'max', '2023-03-20T00:00') | ||
}) | ||
|
||
it('Displays a time field with min and max values', () => { | ||
cy | ||
.get('#phormal-field-input-time') | ||
.should('have.attr', 'min', '01:00') | ||
.should('have.attr', 'max', '23:00') | ||
}) | ||
}) |
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,53 @@ | ||
import {defineComponent, h} from "vue"; | ||
import {Phormal, useRequired} from "../../packages/core/src"; | ||
import CodeElement from "../components/code-element"; | ||
|
||
export default defineComponent({ | ||
name: "DateAndTimeTests", | ||
|
||
data() { | ||
return { | ||
form: undefined as undefined|Phormal, | ||
|
||
formFields: { | ||
date: { | ||
type: 'date', | ||
label: 'Date', | ||
min: '2023-01-01', | ||
max: '2023-12-31', | ||
}, | ||
datetimeLocal: { | ||
type: 'datetime-local', | ||
label: 'Datetime', | ||
hooks: [useRequired()], | ||
value: '2023-01-01T00:00', | ||
min: '2023-01-01T00:00', | ||
max: '2023-03-20T00:00', | ||
}, | ||
time: { | ||
type: 'time', | ||
label: 'Time', | ||
hooks: [useRequired()], | ||
min: '01:00', | ||
max: '23:00', | ||
}, | ||
}, | ||
|
||
formValues: {} as Record<string, any>|undefined, | ||
} | ||
}, | ||
|
||
mounted() { | ||
this.form = new Phormal(this.formFields, { el: '#phormal' }) | ||
}, | ||
|
||
render() { | ||
const phormal = h('div', { id: 'phormal' }) | ||
|
||
return h("div",[ | ||
phormal, | ||
h(CodeElement, { code: this.formValues || {} }), | ||
h('button', { onClick: () => this.form!.$values(), id: 'getValues' }, 'Get values') | ||
]) | ||
} | ||
}) |
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