-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add min and max date for Modus Date Input #1738
Add min and max date for Modus Date Input #1738
Conversation
update main branch
update main
…r-min-max # Conflicts: # angular-workspace/projects/trimble-oss/modus-angular-components/src/lib/stencil-generated/components.ts # stencil-workspace/src/components/modus-date-input/modus-date-input.e2e.ts
✅ Deploy Preview for modus-webcomponents ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@Method() | ||
async validate(): Promise<void> { | ||
this.validateInput(this._dateDisplay); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public method to validate the input. For example, if the date range is fine and you clear the error message, but one of the fields is out of the min-max range you call it to check the validation on the input itself.
min: this._formatter.parseIsoToDate(this.min), | ||
max: this._formatter.parseIsoToDate(this.max), | ||
minMessage: messages.min, | ||
maxMessage: messages.max, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The calendar doesn't know anything about the format, but the tooltip message of the disabled date should be the same as the input one. Send them to the calendar with the min and max values.
stencil-workspace/src/components/modus-date-input/utils/modus-date-input.formatter.tsx
Show resolved
Hide resolved
stencil-workspace/src/components/modus-date-picker/utils/modus-date-picker.state.tsx
Show resolved
Hide resolved
allowedCharsRegex: '.', | ||
helperText: 'mmm dd, yyyy', | ||
label: 'Single Date', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one more template with a picker and default min and max values.
/** Handlers */ | ||
handleCalendarClick(): void { | ||
this.calendarIconClicked.emit({ | ||
value: this.value, | ||
type: this.type, | ||
inputString: this._dateDisplay, | ||
min: this._formatter.parseIsoToDate(this.min), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest not parsing to Date objects because of timezone differences when emitting events, and I think we don't have to pass min and max because the Date picker has a state object that contains a reference to the date input node, we can directly consume date input properties in that. Passing the type only matters here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would have been better to pass a reference to the element instead of its type and value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll try that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yevhenkravets Are we working on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yevhenkravets Are we working on this?
Yes, I'll provide changes soon
stencil-workspace/src/components/modus-date-input/modus-date-input.tsx
Outdated
Show resolved
Hide resolved
stencil-workspace/src/components/modus-date-input/modus-date-input.tsx
Outdated
Show resolved
Hide resolved
@yevhenkravets, I have multiple PRs. If @cjwinsor can review and approve, that would be fine too👍🏼 |
5b53fdc
to
db07ca8
Compare
# Conflicts: # stencil-workspace/src/components/modus-date-picker/utils/modus-date-picker.state.tsx
1d5023c
to
b181711
Compare
stencil-workspace/src/components/modus-date-picker/modus-date-picker.tsx
Outdated
Show resolved
Hide resolved
stencil-workspace/src/components/modus-date-picker/utils/modus-date-picker.state.tsx
Show resolved
Hide resolved
...orkspace/storybook/stories/components/modus-date-picker/modus-date-picker-storybook-docs.mdx
Show resolved
Hide resolved
stencil-workspace/src/components/modus-date-picker/utils/modus-date-picker.state.tsx
Outdated
Show resolved
Hide resolved
stencil-workspace/src/components/modus-date-input/modus-date-input.e2e.ts
Outdated
Show resolved
Hide resolved
stencil-workspace/src/components/modus-date-picker/modus-date-picker.tsx
Show resolved
Hide resolved
# Conflicts: # stencil-workspace/src/components/modus-date-input/modus-date-input.e2e.ts
4049ae2
Description
References #1075
Type of change
How Has This Been Tested?
Provide min and/or max attr value for the input in the storybook and check manual typing or pasting. Also, check with the date picker.
Added related integration tests for the input and picker components
Checklist