guestbell-forms 3.0.39 → 3.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.bat +1 -0
- package/.eslintrc.json +21 -14
- package/build/components/base/input/BaseInput.d.ts +99 -99
- package/build/components/base/input/BaseInput.js +4 -0
- package/build/components/base/input/BaseInput.js.map +1 -1
- package/build/components/base/input/index.d.ts +1 -1
- package/build/components/bookingCalendar/BookingCalendar.d.ts +47 -46
- package/build/components/bookingCalendar/BookingCalendar.js +38 -14
- package/build/components/bookingCalendar/BookingCalendar.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.d.ts +17 -17
- package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.js +12 -12
- package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarControls/classes.d.ts +9 -9
- package/build/components/bookingCalendar/bookingCalendarControls/index.d.ts +2 -2
- package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.d.ts +13 -13
- package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.js +3 -3
- package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarDatePicker/classes.d.ts +5 -5
- package/build/components/bookingCalendar/bookingCalendarDatePicker/index.d.ts +2 -2
- package/build/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.d.ts +10 -10
- package/build/components/bookingCalendar/bookingCalendarGrid/classes.d.ts +5 -5
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.d.ts +57 -57
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js +2 -1
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/classes.d.ts +4 -4
- package/build/components/bookingCalendar/bookingCalendarItem/index.d.ts +2 -2
- package/build/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.d.ts +16 -16
- package/build/components/bookingCalendar/bookingCalendarLane/classes.d.ts +4 -4
- package/build/components/bookingCalendar/bookingCalendarLane/index.d.ts +2 -2
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/BookingCalendarLaneHeader.d.ts +7 -7
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/classes.d.ts +4 -4
- package/build/components/bookingCalendar/bookingCalendarLaneHeader/index.d.ts +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.d.ts +11 -11
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.js +3 -3
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.d.ts +4 -5
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/classes.d.ts +5 -5
- package/build/components/bookingCalendar/bookingCalendarLanesHeader/index.d.ts +2 -2
- package/build/components/bookingCalendar/bookingCalendarRenderItem/BookingCalendarRenderItem.d.ts +9 -9
- package/build/components/bookingCalendar/bookingCalendarRenderItem/classes.d.ts +6 -6
- package/build/components/bookingCalendar/bookingCalendarRenderItem/index.d.ts +1 -1
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.d.ts +38 -37
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js +7 -4
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarSelection/classes.d.ts +5 -0
- package/build/components/bookingCalendar/bookingCalendarSelection/classes.js +12 -0
- package/build/components/bookingCalendar/bookingCalendarSelection/classes.js.map +1 -0
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/BookingCalendarTimeAxis.d.ts +11 -11
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/classes.d.ts +5 -5
- package/build/components/bookingCalendar/classes.d.ts +11 -11
- package/build/components/bookingCalendar/common.d.ts +24 -23
- package/build/components/bookingCalendar/common.js +3 -4
- package/build/components/bookingCalendar/common.js.map +1 -1
- package/build/components/bookingCalendar/index.d.ts +3 -3
- package/build/components/bookingCalendar/utils.d.ts +55 -50
- package/build/components/bookingCalendar/utils.js +2 -1
- package/build/components/bookingCalendar/utils.js.map +1 -1
- package/build/components/button/Button.d.ts +81 -81
- package/build/components/button/Button.js +1 -0
- package/build/components/button/Button.js.map +1 -1
- package/build/components/button/index.d.ts +2 -2
- package/build/components/checkbox/Checkbox.d.ts +23 -23
- package/build/components/checkbox/index.d.ts +2 -2
- package/build/components/dropdown/Dropdown.d.ts +44 -44
- package/build/components/dropdown/index.d.ts +2 -2
- package/build/components/dynamicSubmit/DynamicSubmit.d.ts +54 -54
- package/build/components/dynamicSubmit/DynamicSubmit.js.map +1 -1
- package/build/components/dynamicSubmit/index.d.ts +2 -2
- package/build/components/externalValidationComponent/ExternalValidationComponent.d.ts +15 -15
- package/build/components/externalValidationComponent/index.d.ts +2 -2
- package/build/components/form/Form.d.ts +47 -47
- package/build/components/form/FormContext.d.ts +30 -30
- package/build/components/form/FormValidationSummary.d.ts +38 -38
- package/build/components/form/FormValidationSummary.js.map +1 -1
- package/build/components/form/index.d.ts +5 -5
- package/build/components/form/withFormContext.d.ts +3 -3
- package/build/components/inputGroup/InputGroup.d.ts +15 -17
- package/build/components/inputGroup/index.d.ts +2 -2
- package/build/components/inputHeader/InputHeader.d.ts +97 -97
- package/build/components/inputHeader/InputHeader.js.map +1 -1
- package/build/components/inputHeader/InputHeaderContext.d.ts +24 -24
- package/build/components/inputHeader/index.d.ts +2 -2
- package/build/components/inputHeader/withInputHeaderContext.d.ts +3 -3
- package/build/components/money/Money.d.ts +78 -78
- package/build/components/money/Money.js.map +1 -1
- package/build/components/money/index.d.ts +2 -2
- package/build/components/numberInput/NumberInput.d.ts +28 -28
- package/build/components/numberInput/index.d.ts +2 -2
- package/build/components/openingHours/openingHoursDay/OpeningHoursDay.d.ts +84 -84
- package/build/components/openingHours/openingHoursDay/OpeningHoursDay.js +3 -3
- package/build/components/openingHours/openingHoursDay/OpeningHoursDay.js.map +1 -1
- package/build/components/openingHours/openingHoursDay/index.d.ts +2 -2
- package/build/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.d.ts +92 -90
- package/build/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.js.map +1 -1
- package/build/components/openingHours/openingHoursSpecial/index.d.ts +2 -2
- package/build/components/openingHours/openingHoursWeek/OpeningHoursWeek.d.ts +109 -109
- package/build/components/openingHours/openingHoursWeek/index.d.ts +2 -2
- package/build/components/openingHours/utils/OpeningHoursUtil.d.ts +21 -21
- package/build/components/radio/Radio.d.ts +20 -20
- package/build/components/radio/index.d.ts +2 -2
- package/build/components/radioContainer/RadioContainer.d.ts +17 -16
- package/build/components/radioContainer/RadioContainer.js.map +1 -1
- package/build/components/radioContainer/index.d.ts +2 -2
- package/build/components/select/Select.d.ts +79 -79
- package/build/components/select/index.d.ts +2 -2
- package/build/components/submit/Submit.d.ts +137 -137
- package/build/components/submit/index.d.ts +2 -2
- package/build/components/submit/subComponents/SubmitValidationSummary.d.ts +5 -5
- package/build/components/tags/Tags.d.ts +92 -92
- package/build/components/tags/Tags.js +2 -0
- package/build/components/tags/Tags.js.map +1 -1
- package/build/components/tags/index.d.ts +2 -2
- package/build/components/tags/subComponents/TagsSuggestions.d.ts +34 -34
- package/build/components/tags/subComponents/TagsSuggestions.js +2 -2
- package/build/components/tags/subComponents/TagsSuggestions.js.map +1 -1
- package/build/components/text/Text.d.ts +31 -31
- package/build/components/text/index.d.ts +2 -2
- package/build/components/textArea/TextArea.d.ts +28 -28
- package/build/components/textArea/TextArea.js +1 -0
- package/build/components/textArea/TextArea.js.map +1 -1
- package/build/components/textArea/index.d.ts +2 -2
- package/build/components/themeProvider/ThemeContext.d.ts +9 -9
- package/build/components/themeProvider/ThemeProvider.d.ts +8 -7
- package/build/components/themeProvider/ThemeProvider.js.map +1 -1
- package/build/components/themeProvider/index.d.ts +4 -4
- package/build/components/themeProvider/withThemeContext.d.ts +4 -4
- package/build/components/time/Time.d.ts +32 -32
- package/build/components/time/Time.js +3 -3
- package/build/components/time/Time.js.map +1 -1
- package/build/components/time/index.d.ts +2 -2
- package/build/components/timeSpan/TimeSpan.d.ts +46 -46
- package/build/components/timeSpan/TimeSpan.js +6 -6
- package/build/components/timeSpan/TimeSpan.js.map +1 -1
- package/build/components/timeSpan/index.d.ts +2 -2
- package/build/components/utils/Guid.d.ts +2 -2
- package/build/components/utils/ShallowEqual.d.ts +16 -16
- package/build/components/utils/TimeUtil.d.ts +6 -6
- package/build/components/utils/Typescript.d.ts +5 -5
- package/build/dist/guestbell-forms.css +154 -170
- package/build/dist/guestbell-forms.css.map +1 -1
- package/build/dist/guestbell-forms.js +15 -24
- package/build/dist/guestbell-forms.js.map +1 -1
- package/build/dist/guestbell-forms.min.css +1 -1
- package/build/dist/guestbell-forms.min.js +1 -1
- package/build/dist/guestbell-forms.min.js.map +1 -1
- package/build/dist/report.html +3 -3
- package/build/index.d.ts +24 -24
- package/build/scss/components/bookingCalendar/bookingCalendar.scss +32 -7
- package/build/types/ElementOverrideProp.d.ts +3 -3
- package/build/types/Theme.d.ts +4 -4
- package/build/types/ThemeOverrides.d.ts +45 -45
- package/build/validators/EmailValidator.d.ts +4 -4
- package/build/validators/LatitudeValidator.d.ts +4 -4
- package/build/validators/LongitudeValidator.d.ts +4 -4
- package/build/validators/NumberValidator.d.ts +12 -12
- package/build/validators/NumberValidator.js +1 -0
- package/build/validators/NumberValidator.js.map +1 -1
- package/build/validators/UrlValidator.d.ts +4 -4
- package/build/validators/base.d.ts +4 -4
- package/build/validators/index.d.ts +6 -6
- package/package.json +130 -136
- package/src/lib/components/base/input/BaseInput.tsx +526 -0
- package/src/lib/components/base/input/index.tsx +1 -0
- package/src/lib/components/bookingCalendar/BookingCalendar.tsx +399 -0
- package/src/lib/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.tsx +249 -0
- package/src/lib/components/bookingCalendar/bookingCalendarControls/classes.ts +20 -0
- package/src/lib/components/bookingCalendar/bookingCalendarControls/index.ts +2 -0
- package/src/lib/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.tsx +104 -0
- package/src/lib/components/bookingCalendar/bookingCalendarDatePicker/classes.ts +9 -0
- package/src/lib/components/bookingCalendar/bookingCalendarDatePicker/index.ts +2 -0
- package/src/lib/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.tsx +56 -0
- package/src/lib/components/bookingCalendar/bookingCalendarGrid/classes.ts +9 -0
- package/src/lib/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.tsx +98 -0
- package/src/lib/components/bookingCalendar/bookingCalendarItem/classes.ts +7 -0
- package/src/lib/components/bookingCalendar/bookingCalendarItem/index.ts +2 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.tsx +69 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLane/classes.ts +7 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLane/index.ts +2 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLaneHeader/BookingCalendarLaneHeader.tsx +28 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLaneHeader/classes.ts +7 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLaneHeader/index.ts +1 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.tsx +57 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.tsx +53 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLanesHeader/classes.ts +9 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLanesHeader/index.ts +2 -0
- package/src/lib/components/bookingCalendar/bookingCalendarRenderItem/BookingCalendarRenderItem.tsx +57 -0
- package/src/lib/components/bookingCalendar/bookingCalendarRenderItem/classes.ts +11 -0
- package/src/lib/components/bookingCalendar/bookingCalendarRenderItem/index.ts +1 -0
- package/src/lib/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.tsx +225 -0
- package/src/lib/components/bookingCalendar/bookingCalendarSelection/classes.ts +10 -0
- package/src/lib/components/bookingCalendar/bookingCalendarTimeAxis/BookingCalendarTimeAxis.tsx +53 -0
- package/src/lib/components/bookingCalendar/bookingCalendarTimeAxis/classes.ts +9 -0
- package/src/lib/components/bookingCalendar/classes.ts +21 -0
- package/src/lib/components/bookingCalendar/common.ts +62 -0
- package/src/lib/components/bookingCalendar/index.ts +3 -0
- package/src/lib/components/bookingCalendar/utils.ts +350 -0
- package/src/lib/components/button/Button.tsx +193 -0
- package/src/lib/components/button/index.tsx +2 -0
- package/src/lib/components/checkbox/Checkbox.tsx +178 -0
- package/src/lib/components/checkbox/index.tsx +2 -0
- package/src/lib/components/dropdown/Dropdown.tsx +135 -0
- package/src/lib/components/dropdown/index.tsx +2 -0
- package/src/lib/components/dynamicSubmit/DynamicSubmit.tsx +153 -0
- package/src/lib/components/dynamicSubmit/index.tsx +2 -0
- package/src/lib/components/externalValidationComponent/ExternalValidationComponent.tsx +78 -0
- package/src/lib/components/externalValidationComponent/index.tsx +2 -0
- package/src/lib/components/form/Form.tsx +276 -0
- package/src/lib/components/form/FormContext.ts +49 -0
- package/src/lib/components/form/FormValidationSummary.tsx +122 -0
- package/src/lib/components/form/index.tsx +5 -0
- package/src/lib/components/form/withFormContext.tsx +20 -0
- package/src/lib/components/inputGroup/InputGroup.tsx +60 -0
- package/src/lib/components/inputGroup/index.tsx +2 -0
- package/src/lib/components/inputHeader/InputHeader.tsx +448 -0
- package/src/lib/components/inputHeader/InputHeaderContext.ts +42 -0
- package/src/lib/components/inputHeader/index.tsx +2 -0
- package/src/lib/components/inputHeader/withInputHeaderContext.tsx +24 -0
- package/src/lib/components/money/Money.tsx +298 -0
- package/src/lib/components/money/index.tsx +2 -0
- package/src/lib/components/numberInput/NumberInput.tsx +186 -0
- package/src/lib/components/numberInput/index.tsx +2 -0
- package/src/lib/components/openingHours/openingHoursDay/OpeningHoursDay.tsx +394 -0
- package/src/lib/components/openingHours/openingHoursDay/index.tsx +2 -0
- package/src/lib/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.tsx +227 -0
- package/src/lib/components/openingHours/openingHoursSpecial/index.tsx +2 -0
- package/src/lib/components/openingHours/openingHoursWeek/OpeningHoursWeek.tsx +283 -0
- package/src/lib/components/openingHours/openingHoursWeek/index.tsx +2 -0
- package/src/lib/components/openingHours/utils/OpeningHoursUtil.tsx +111 -0
- package/src/lib/components/radio/Radio.tsx +87 -0
- package/src/lib/components/radio/index.tsx +2 -0
- package/src/lib/components/radioContainer/RadioContainer.tsx +50 -0
- package/src/lib/components/radioContainer/index.tsx +2 -0
- package/src/lib/components/select/Select.tsx +335 -0
- package/src/lib/components/select/index.tsx +2 -0
- package/src/lib/components/submit/Submit.tsx +117 -0
- package/src/lib/components/submit/index.tsx +2 -0
- package/src/lib/components/submit/subComponents/SubmitValidationSummary.tsx +55 -0
- package/src/lib/components/tags/Tags.tsx +702 -0
- package/src/lib/components/tags/index.tsx +2 -0
- package/src/lib/components/tags/subComponents/TagsSuggestions.tsx +150 -0
- package/src/lib/components/text/Text.tsx +200 -0
- package/src/lib/components/text/index.tsx +2 -0
- package/src/lib/components/textArea/TextArea.tsx +109 -0
- package/src/lib/components/textArea/index.tsx +2 -0
- package/src/lib/components/themeProvider/ThemeContext.ts +16 -0
- package/src/lib/components/themeProvider/ThemeProvider.tsx +21 -0
- package/src/lib/components/themeProvider/index.tsx +4 -0
- package/src/lib/components/themeProvider/withThemeContext.tsx +30 -0
- package/src/lib/components/time/Time.tsx +296 -0
- package/src/lib/components/time/index.tsx +2 -0
- package/src/lib/components/timeSpan/TimeSpan.tsx +378 -0
- package/src/lib/components/timeSpan/index.tsx +2 -0
- package/src/lib/components/utils/Guid.ts +9 -0
- package/src/lib/components/utils/ShallowEqual.ts +75 -0
- package/src/lib/components/utils/TimeUtil.ts +22 -0
- package/src/lib/components/utils/Typescript.ts +11 -0
- package/src/lib/declarations/import.d.ts +1 -0
- package/src/lib/index.ts +24 -0
- package/src/lib/scss/components/base/index.scss +1 -0
- package/src/lib/scss/components/base/input/index.scss +1 -0
- package/src/lib/scss/components/base/input/input.scss +237 -0
- package/src/lib/scss/components/bookingCalendar/bookingCalendar.scss +274 -0
- package/src/lib/scss/components/bookingCalendar/index.scss +1 -0
- package/src/lib/scss/components/button/buttons.scss +161 -0
- package/src/lib/scss/components/button/index.scss +1 -0
- package/src/lib/scss/components/checkbox/checkbox.scss +115 -0
- package/src/lib/scss/components/checkbox/index.scss +1 -0
- package/src/lib/scss/components/dropdown/dropdown.scss +111 -0
- package/src/lib/scss/components/dropdown/index.scss +1 -0
- package/src/lib/scss/components/dynamicSubmit/dynamicSubmit.scss +1 -0
- package/src/lib/scss/components/dynamicSubmit/index.scss +1 -0
- package/src/lib/scss/components/form/form.scss +1 -0
- package/src/lib/scss/components/form/formValidationSummary.scss +55 -0
- package/src/lib/scss/components/form/index.scss +2 -0
- package/src/lib/scss/components/index.scss +21 -0
- package/src/lib/scss/components/inputGroup/index.scss +1 -0
- package/src/lib/scss/components/inputGroup/inputGroup.scss +67 -0
- package/src/lib/scss/components/inputHeader/index.scss +1 -0
- package/src/lib/scss/components/inputHeader/inputHeader.scss +132 -0
- package/src/lib/scss/components/money/index.scss +1 -0
- package/src/lib/scss/components/money/money.scss +51 -0
- package/src/lib/scss/components/numberInput/index.scss +1 -0
- package/src/lib/scss/components/numberInput/numberInput.scss +116 -0
- package/src/lib/scss/components/openingHours/index.scss +3 -0
- package/src/lib/scss/components/openingHours/openingHoursDay/index.scss +1 -0
- package/src/lib/scss/components/openingHours/openingHoursDay/openingHoursDay.scss +127 -0
- package/src/lib/scss/components/openingHours/openingHoursSpecial/index.scss +1 -0
- package/src/lib/scss/components/openingHours/openingHoursSpecial/openingHoursSpecial.scss +93 -0
- package/src/lib/scss/components/openingHours/openingHoursWeek/index.scss +1 -0
- package/src/lib/scss/components/openingHours/openingHoursWeek/openingHoursWeek.scss +23 -0
- package/src/lib/scss/components/radio/index.scss +1 -0
- package/src/lib/scss/components/radio/radio.scss +68 -0
- package/src/lib/scss/components/radioContainer/index.scss +1 -0
- package/src/lib/scss/components/radioContainer/radioContainer.scss +15 -0
- package/src/lib/scss/components/select/index.scss +1 -0
- package/src/lib/scss/components/select/select.scss +64 -0
- package/src/lib/scss/components/submit/index.scss +1 -0
- package/src/lib/scss/components/submit/submitValidationSummary.scss +35 -0
- package/src/lib/scss/components/tags/index.scss +1 -0
- package/src/lib/scss/components/tags/tags.scss +128 -0
- package/src/lib/scss/components/text/index.scss +1 -0
- package/src/lib/scss/components/text/text.scss +42 -0
- package/src/lib/scss/components/textArea/index.scss +1 -0
- package/src/lib/scss/components/textArea/textArea.scss +32 -0
- package/src/lib/scss/components/time/index.scss +1 -0
- package/src/lib/scss/components/time/time.scss +111 -0
- package/src/lib/scss/components/timeSpan/index.scss +1 -0
- package/src/lib/scss/components/timeSpan/timeSpan.scss +115 -0
- package/src/lib/scss/index.scss +8 -0
- package/src/lib/scss/styles/base.scss +7 -0
- package/src/lib/scss/styles/index.scss +2 -0
- package/src/lib/scss/styles/react-tippy.scss +4 -0
- package/src/lib/scss/variables/_buttons.scss +6 -0
- package/src/lib/scss/variables/_colors.scss +1 -0
- package/src/lib/scss/variables/_common.scss +12 -0
- package/src/lib/tsconfig.json +19 -0
- package/src/lib/types/ElementOverrideProp.ts +3 -0
- package/src/lib/types/Theme.ts +5 -0
- package/src/lib/types/ThemeOverrides.ts +46 -0
- package/src/lib/validators/EmailValidator.ts +15 -0
- package/src/lib/validators/LatitudeValidator.ts +25 -0
- package/src/lib/validators/LongitudeValidator.ts +25 -0
- package/src/lib/validators/NumberValidator.ts +50 -0
- package/src/lib/validators/UrlValidator.ts +20 -0
- package/src/lib/validators/base.ts +15 -0
- package/src/lib/validators/index.ts +6 -0
- package/src/stories/Basic.stories.ts +17 -0
- package/src/stories/Basic.tsx +1065 -0
- package/src/stories/Schedule.stories.ts +16 -0
- package/src/stories/Schedule.tsx +85 -0
- package/src/stories/ValidationPage.tsx +417 -0
- package/tsconfig.json +9 -22
- package/typedoc.json +6 -0
- package/webpack/webpack.config.base.js +139 -0
- package/webpack/webpack.config.dev.js +78 -0
- package/webpack/webpack.config.gh-pages.js +78 -0
- package/webpack/webpack.config.js +21 -0
- package/webpack/webpack.config.min.js +100 -0
- package/.vscode/launch.json +0 -15
- package/.vscode/settings.json +0 -27
- package/.vscode/tasks.json +0 -12
@@ -0,0 +1,526 @@
|
|
1
|
+
// Libs
|
2
|
+
import * as React from 'react';
|
3
|
+
import * as ReactDOM from 'react-dom';
|
4
|
+
import type { TippyProps } from '@tippy.js/react';
|
5
|
+
|
6
|
+
// Misc
|
7
|
+
import * as Validators from '../../../validators';
|
8
|
+
import guid from '../../utils/Guid';
|
9
|
+
import { FormContextProps } from '../../form/FormContext';
|
10
|
+
import { shallowEqual } from '../../utils/ShallowEqual';
|
11
|
+
import { Theme } from '../../../types/Theme';
|
12
|
+
import classNames from 'classnames';
|
13
|
+
|
14
|
+
export interface ComponentApi {
|
15
|
+
focus: () => void;
|
16
|
+
touch: () => void;
|
17
|
+
unTouch: () => void;
|
18
|
+
enableComponent: () => void;
|
19
|
+
disableComponent: () => void;
|
20
|
+
scrollTo: () => void;
|
21
|
+
}
|
22
|
+
|
23
|
+
export type ValidationError = string | JSX.Element;
|
24
|
+
|
25
|
+
export type AllowedHtmlElements =
|
26
|
+
| HTMLInputElement
|
27
|
+
| HTMLSelectElement
|
28
|
+
| HTMLTextAreaElement;
|
29
|
+
|
30
|
+
export const defaultBaseTranslations = {
|
31
|
+
required: 'Required',
|
32
|
+
};
|
33
|
+
|
34
|
+
export type BaseTranslations = Partial<typeof defaultBaseTranslations>;
|
35
|
+
|
36
|
+
export type BaseInputProps<
|
37
|
+
HTMLType extends AllowedHtmlElements,
|
38
|
+
TranslationsT extends BaseTranslations = BaseTranslations
|
39
|
+
> = {
|
40
|
+
theme?: Theme;
|
41
|
+
id?: string;
|
42
|
+
disabled?: boolean;
|
43
|
+
className?: string;
|
44
|
+
label?: string | JSX.Element;
|
45
|
+
tooltip?: string | JSX.Element;
|
46
|
+
tooltipProps?: TippyProps;
|
47
|
+
value?: string;
|
48
|
+
onChange?: (e: React.ChangeEvent<HTMLType>, isValid: boolean) => void;
|
49
|
+
required?: boolean;
|
50
|
+
customValidators?: Validators.IBaseValidator[];
|
51
|
+
validators?: Validators.ValidatorTypes[];
|
52
|
+
noValidate?: boolean;
|
53
|
+
validationName?: string;
|
54
|
+
touchOn?: 'focus' | 'blur';
|
55
|
+
ignoreContext?: boolean;
|
56
|
+
onTheFlightValidate?: (value: string) => boolean;
|
57
|
+
onFocus?: () => void;
|
58
|
+
onBlur?: () => void;
|
59
|
+
onSuggestionsClosed?: () => void;
|
60
|
+
onSuggestionsOpened?: () => void;
|
61
|
+
onClick?: (e: React.MouseEvent) => void;
|
62
|
+
title?: string | JSX.Element;
|
63
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;
|
64
|
+
errors?: ValidationError[];
|
65
|
+
onErrorsChanged?: (errors: ValidationError[]) => void;
|
66
|
+
showValidation?: boolean;
|
67
|
+
reRendersWhenContextChanges?: boolean;
|
68
|
+
defaultTouched?: boolean;
|
69
|
+
translations?: TranslationsT;
|
70
|
+
inputGroupClassName?: string;
|
71
|
+
infoText?: string | JSX.Element;
|
72
|
+
} & FormContextProps;
|
73
|
+
|
74
|
+
export interface BaseInputState {
|
75
|
+
isValid: boolean;
|
76
|
+
value: string;
|
77
|
+
errors: ValidationError[];
|
78
|
+
validator: undefined;
|
79
|
+
touched: boolean;
|
80
|
+
disabled: boolean;
|
81
|
+
focused: boolean;
|
82
|
+
handleValueChangeEnabled: boolean;
|
83
|
+
}
|
84
|
+
|
85
|
+
export class BaseInput<
|
86
|
+
P extends BaseInputProps<HTMLType, TranslationsT>,
|
87
|
+
S extends BaseInputState,
|
88
|
+
HTMLType extends AllowedHtmlElements,
|
89
|
+
TranslationsT extends BaseTranslations = BaseTranslations
|
90
|
+
>
|
91
|
+
extends React.Component<P, S>
|
92
|
+
implements ComponentApi
|
93
|
+
{
|
94
|
+
public static defaultProps: BaseInputProps<never> = {
|
95
|
+
className: undefined,
|
96
|
+
required: false,
|
97
|
+
label: undefined,
|
98
|
+
disabled: false,
|
99
|
+
touchOn: 'focus',
|
100
|
+
ignoreContext: false,
|
101
|
+
showValidation: true,
|
102
|
+
formContext: undefined,
|
103
|
+
reRendersWhenContextChanges: false,
|
104
|
+
};
|
105
|
+
|
106
|
+
public componentId = guid();
|
107
|
+
|
108
|
+
public inputRef: React.RefObject<HTMLType>;
|
109
|
+
|
110
|
+
protected containerRef: React.RefObject<HTMLDivElement>;
|
111
|
+
|
112
|
+
private lastValidation: JSX.Element[];
|
113
|
+
|
114
|
+
private lastInfoText: JSX.Element[];
|
115
|
+
|
116
|
+
constructor(props: P, subscribe: boolean = true) {
|
117
|
+
super(props);
|
118
|
+
const res = this.handleValueChange(this.props.value, true, [], props, true);
|
119
|
+
this.state = {
|
120
|
+
isValid: res.isValid,
|
121
|
+
errors: res.errors,
|
122
|
+
value: props.value ? props.value : '',
|
123
|
+
touched: props.defaultTouched,
|
124
|
+
disabled: false,
|
125
|
+
focused: false,
|
126
|
+
handleValueChangeEnabled: true,
|
127
|
+
} as S;
|
128
|
+
this.containerRef = React.createRef<HTMLDivElement>();
|
129
|
+
this.inputRef = React.createRef<HTMLType>();
|
130
|
+
this.handleChange = this.handleChange.bind(this);
|
131
|
+
this.handleBlur = this.handleBlur.bind(this);
|
132
|
+
this.handleFocus = this.handleFocus.bind(this);
|
133
|
+
this.setValid = this.setValid.bind(this);
|
134
|
+
this.focus = this.focus.bind(this);
|
135
|
+
this.scrollTo = this.scrollTo.bind(this);
|
136
|
+
this.setInvalid = this.setInvalid.bind(this);
|
137
|
+
this.disableComponent = this.disableComponent.bind(this);
|
138
|
+
this.enableComponent = this.enableComponent.bind(this);
|
139
|
+
this.touch = this.touch.bind(this);
|
140
|
+
this.unTouch = this.unTouch.bind(this);
|
141
|
+
if (subscribe) {
|
142
|
+
this.subscribeSelf(props);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
public componentWillUnmount() {
|
147
|
+
if (!this.props.ignoreContext) {
|
148
|
+
this.props.formContext &&
|
149
|
+
this.props.formContext.unSubscribe(this.componentId);
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
public componentDidUpdate(oldProps: P, oldState: S) {
|
154
|
+
if (
|
155
|
+
oldProps.value !== this.props.value ||
|
156
|
+
oldProps.validators !== this.props.validators ||
|
157
|
+
oldProps.customValidators !== this.props.customValidators ||
|
158
|
+
oldProps.required !== this.props.required
|
159
|
+
) {
|
160
|
+
this.handleValueChange(this.props.value, true, [], this.props);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
public scrollTo() {
|
165
|
+
const domNode: HTMLDivElement = ReactDOM.findDOMNode(
|
166
|
+
(this.containerRef as React.RefObject<HTMLDivElement>).current
|
167
|
+
) as HTMLDivElement;
|
168
|
+
domNode && domNode.scrollIntoView({ behavior: 'smooth' });
|
169
|
+
}
|
170
|
+
|
171
|
+
public touch() {
|
172
|
+
this.setState({ touched: true });
|
173
|
+
this.handleValueChange(this.state.value || '');
|
174
|
+
}
|
175
|
+
|
176
|
+
public unTouch() {
|
177
|
+
this.setState({ touched: false });
|
178
|
+
}
|
179
|
+
|
180
|
+
public disableComponent() {
|
181
|
+
this.setState({ disabled: true });
|
182
|
+
}
|
183
|
+
|
184
|
+
public enableComponent() {
|
185
|
+
this.setState({ disabled: false });
|
186
|
+
}
|
187
|
+
|
188
|
+
public focus() {
|
189
|
+
if (this.inputRef) {
|
190
|
+
const domNode: HTMLElement = ReactDOM.findDOMNode(
|
191
|
+
(this.inputRef as React.RefObject<HTMLElement>).current
|
192
|
+
) as HTMLElement;
|
193
|
+
domNode && domNode.focus();
|
194
|
+
}
|
195
|
+
this.props.onFocus?.();
|
196
|
+
this.touch();
|
197
|
+
}
|
198
|
+
|
199
|
+
public shouldComponentUpdate(nextProps: P, nextState: S) {
|
200
|
+
let shouldUpdate =
|
201
|
+
!shallowEqual(
|
202
|
+
this.props,
|
203
|
+
nextProps,
|
204
|
+
!this.props.reRendersWhenContextChanges ? 'formContext' : undefined
|
205
|
+
) || !shallowEqual(this.state, nextState);
|
206
|
+
return shouldUpdate;
|
207
|
+
}
|
208
|
+
|
209
|
+
protected getValidationClass(extraErrors?: ValidationError[]) {
|
210
|
+
if (!this.props.showValidation || !this.state.touched) {
|
211
|
+
return 'validation__success';
|
212
|
+
}
|
213
|
+
return this.state.isValid &&
|
214
|
+
(!this.props.errors || this.props.errors.length === 0) &&
|
215
|
+
(!this.state.errors || this.state.errors.length === 0) &&
|
216
|
+
(!extraErrors || extraErrors.length === 0)
|
217
|
+
? 'validation__success'
|
218
|
+
: 'validation__error';
|
219
|
+
}
|
220
|
+
|
221
|
+
protected renderDefaultValidation(extraErrors?: ValidationError[]) {
|
222
|
+
if (this.props.disabled) {
|
223
|
+
return null;
|
224
|
+
}
|
225
|
+
if (!this.props.showValidation) {
|
226
|
+
return null;
|
227
|
+
}
|
228
|
+
let finalErrors: ValidationError[] = (this.state.errors ?? [])
|
229
|
+
.concat(extraErrors ?? [])
|
230
|
+
.concat(this.props.errors ?? [])
|
231
|
+
.filter((i) => i);
|
232
|
+
if (finalErrors.length > 0) {
|
233
|
+
this.lastValidation = finalErrors.map((item, index) => (
|
234
|
+
<li key={index} className="validation__item">
|
235
|
+
{item}
|
236
|
+
</li>
|
237
|
+
));
|
238
|
+
}
|
239
|
+
if (this.props.infoText && this.state.isValid) {
|
240
|
+
this.lastInfoText = [
|
241
|
+
<li key={1} className="info-text__item">
|
242
|
+
{this.props.infoText}
|
243
|
+
</li>,
|
244
|
+
];
|
245
|
+
}
|
246
|
+
return (
|
247
|
+
<>
|
248
|
+
<div className="validation__container">
|
249
|
+
<ul className="validation__ul">{this.lastValidation}</ul>
|
250
|
+
</div>
|
251
|
+
<div className="info-text__container">
|
252
|
+
<ul className="info-text__ul">{this.lastInfoText}</ul>
|
253
|
+
</div>
|
254
|
+
</>
|
255
|
+
);
|
256
|
+
}
|
257
|
+
|
258
|
+
protected handleChange(
|
259
|
+
event: React.ChangeEvent<HTMLType>,
|
260
|
+
isValid?: boolean,
|
261
|
+
errors: ValidationError[] = []
|
262
|
+
) {
|
263
|
+
let value = event.target.value;
|
264
|
+
if (
|
265
|
+
!this.props.onTheFlightValidate ||
|
266
|
+
(this.props.onTheFlightValidate && this.props.onTheFlightValidate(value))
|
267
|
+
) {
|
268
|
+
const res = this.handleValueChange(value, isValid, errors);
|
269
|
+
if (this.props.onChange) {
|
270
|
+
this.props.onChange(event, res.isValid);
|
271
|
+
}
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
protected subscribeSelf(props: P) {
|
276
|
+
if (!props.ignoreContext && props.formContext) {
|
277
|
+
props.formContext.subscribe(this.componentId, {
|
278
|
+
componentApi: {
|
279
|
+
disableComponent: this.disableComponent,
|
280
|
+
enableComponent: this.enableComponent,
|
281
|
+
touch: this.touch,
|
282
|
+
unTouch: this.unTouch,
|
283
|
+
scrollTo: this.scrollTo,
|
284
|
+
focus: this.focus,
|
285
|
+
},
|
286
|
+
validation: {
|
287
|
+
isValid: this.state.isValid,
|
288
|
+
errors: this.state.errors,
|
289
|
+
name: this.props.validationName
|
290
|
+
? this.props.validationName
|
291
|
+
: this.props.title
|
292
|
+
? this.props.title
|
293
|
+
: this.props.label,
|
294
|
+
},
|
295
|
+
});
|
296
|
+
}
|
297
|
+
}
|
298
|
+
|
299
|
+
protected handleBlur() {
|
300
|
+
this.props.onBlur?.();
|
301
|
+
let state = { focused: false };
|
302
|
+
if (!this.state.touched && this.props.touchOn === 'blur') {
|
303
|
+
state = Object.assign(state, { touched: true });
|
304
|
+
this.handleValueChange(this.state.value);
|
305
|
+
}
|
306
|
+
this.setState(state);
|
307
|
+
}
|
308
|
+
|
309
|
+
protected handleFocus() {
|
310
|
+
if (!this.props.disabled) {
|
311
|
+
this.props.onFocus?.();
|
312
|
+
let state = { focused: true };
|
313
|
+
if (!this.state.touched && this.props.touchOn === 'focus') {
|
314
|
+
state = Object.assign(state, { touched: true });
|
315
|
+
this.handleValueChange(this.state.value);
|
316
|
+
}
|
317
|
+
this.setState(state);
|
318
|
+
}
|
319
|
+
}
|
320
|
+
|
321
|
+
protected getDisabled() {
|
322
|
+
return this.state.disabled ? this.state.disabled : this.props.disabled;
|
323
|
+
}
|
324
|
+
|
325
|
+
protected setValid() {
|
326
|
+
this.setState(
|
327
|
+
() => ({ isValid: true, errors: [] }),
|
328
|
+
() => {
|
329
|
+
if (!this.props.ignoreContext) {
|
330
|
+
this.props.formContext &&
|
331
|
+
this.props.formContext.updateCallback(this.componentId, {
|
332
|
+
validation: {
|
333
|
+
isValid: true,
|
334
|
+
errors: [],
|
335
|
+
},
|
336
|
+
});
|
337
|
+
}
|
338
|
+
}
|
339
|
+
);
|
340
|
+
}
|
341
|
+
|
342
|
+
protected setInvalid(errors: ValidationError[] = []) {
|
343
|
+
this.setState(
|
344
|
+
() => ({ isValid: false, errors }),
|
345
|
+
() => {
|
346
|
+
if (!this.props.ignoreContext) {
|
347
|
+
this.props.formContext &&
|
348
|
+
this.props.formContext.updateCallback(this.componentId, {
|
349
|
+
validation: {
|
350
|
+
isValid: false,
|
351
|
+
errors: errors,
|
352
|
+
},
|
353
|
+
});
|
354
|
+
}
|
355
|
+
}
|
356
|
+
);
|
357
|
+
}
|
358
|
+
|
359
|
+
protected renderLabel(touchable: boolean = false) {
|
360
|
+
if (!this.props.tooltip || (this.props.tooltip && this.props.title)) {
|
361
|
+
return (
|
362
|
+
<span
|
363
|
+
className={classNames('w-100', { 'label--no-touch': !touchable })}
|
364
|
+
>
|
365
|
+
{this.props.label}
|
366
|
+
</span>
|
367
|
+
);
|
368
|
+
}
|
369
|
+
return (
|
370
|
+
<React.Fragment>
|
371
|
+
<span className={touchable ? '' : 'label--no-touch'}>
|
372
|
+
{this.props.label}
|
373
|
+
</span>
|
374
|
+
{this.renderTooltip()}
|
375
|
+
</React.Fragment>
|
376
|
+
);
|
377
|
+
}
|
378
|
+
|
379
|
+
protected renderTitle() {
|
380
|
+
if (!this.props.tooltip) {
|
381
|
+
return this.props.title;
|
382
|
+
}
|
383
|
+
return (
|
384
|
+
<React.Fragment>
|
385
|
+
{this.props.title}
|
386
|
+
{this.renderTooltip()}
|
387
|
+
</React.Fragment>
|
388
|
+
);
|
389
|
+
}
|
390
|
+
|
391
|
+
protected handleValueChange(
|
392
|
+
value: string,
|
393
|
+
isValid: boolean = true,
|
394
|
+
errors: ValidationError[] = [],
|
395
|
+
props: P = this.props,
|
396
|
+
initializing: boolean = false
|
397
|
+
): {
|
398
|
+
isValid: boolean;
|
399
|
+
errors: ValidationError[];
|
400
|
+
} {
|
401
|
+
if (!initializing && !this.state.handleValueChangeEnabled) {
|
402
|
+
return { isValid, errors: [] };
|
403
|
+
}
|
404
|
+
if (props.required && !value) {
|
405
|
+
const translations = this.getTranslations(defaultBaseTranslations);
|
406
|
+
errors.push(translations.required);
|
407
|
+
isValid = false;
|
408
|
+
} else {
|
409
|
+
if (!props.required && !value) {
|
410
|
+
isValid = true;
|
411
|
+
} else {
|
412
|
+
if (props.validators) {
|
413
|
+
isValid = true;
|
414
|
+
props.validators.forEach((validator) => {
|
415
|
+
let validInner = false;
|
416
|
+
switch (validator) {
|
417
|
+
case 'email':
|
418
|
+
validInner = new Validators.EmailValidator().Validate(
|
419
|
+
value,
|
420
|
+
props.required,
|
421
|
+
(error) => errors.push(error)
|
422
|
+
);
|
423
|
+
break;
|
424
|
+
case 'number':
|
425
|
+
validInner = new Validators.NumberValidator().Validate(
|
426
|
+
value,
|
427
|
+
props.required,
|
428
|
+
(error) => errors.push(error)
|
429
|
+
);
|
430
|
+
break;
|
431
|
+
case 'latitude':
|
432
|
+
validInner = new Validators.LatitudeValidator().Validate(
|
433
|
+
value,
|
434
|
+
props.required,
|
435
|
+
(error) => errors.push(error)
|
436
|
+
);
|
437
|
+
break;
|
438
|
+
case 'longitude':
|
439
|
+
validInner = new Validators.LongitudeValidator().Validate(
|
440
|
+
value,
|
441
|
+
props.required,
|
442
|
+
(error) => errors.push(error)
|
443
|
+
);
|
444
|
+
break;
|
445
|
+
case 'url':
|
446
|
+
validInner = new Validators.UrlValidator().Validate(
|
447
|
+
value,
|
448
|
+
props.required,
|
449
|
+
(error) => errors.push(error)
|
450
|
+
);
|
451
|
+
break;
|
452
|
+
default:
|
453
|
+
throw new Error(`Validator ${validator} not implemented`);
|
454
|
+
}
|
455
|
+
if (isValid && !validInner) {
|
456
|
+
isValid = validInner;
|
457
|
+
}
|
458
|
+
});
|
459
|
+
}
|
460
|
+
if (props.customValidators) {
|
461
|
+
props.customValidators.forEach((customValidator) => {
|
462
|
+
let validInner = false;
|
463
|
+
validInner = customValidator.Validate(
|
464
|
+
value,
|
465
|
+
props.required,
|
466
|
+
(error) => errors.push(error)
|
467
|
+
);
|
468
|
+
if (isValid && !validInner) {
|
469
|
+
isValid = validInner;
|
470
|
+
}
|
471
|
+
});
|
472
|
+
}
|
473
|
+
}
|
474
|
+
}
|
475
|
+
props.onErrorsChanged && props.onErrorsChanged(errors);
|
476
|
+
if (!initializing) {
|
477
|
+
this.setState({ value, isValid, errors });
|
478
|
+
if (!props.ignoreContext) {
|
479
|
+
props.formContext &&
|
480
|
+
props.formContext.updateCallback(this.componentId, {
|
481
|
+
validation: {
|
482
|
+
isValid: isValid,
|
483
|
+
errors: errors,
|
484
|
+
},
|
485
|
+
});
|
486
|
+
}
|
487
|
+
}
|
488
|
+
return { isValid, errors };
|
489
|
+
}
|
490
|
+
|
491
|
+
protected renderTooltip(
|
492
|
+
content: JSX.Element = <span className="label--help-icon">?</span>
|
493
|
+
) {
|
494
|
+
if (this.props.tooltip) {
|
495
|
+
const Tippy = require('@tippy.js/react').default;
|
496
|
+
return (
|
497
|
+
<Tippy
|
498
|
+
content={this.props.tooltip}
|
499
|
+
placement="bottom"
|
500
|
+
animation="scale-subtle"
|
501
|
+
arrow={false}
|
502
|
+
duration={200}
|
503
|
+
delay={[75, 0]}
|
504
|
+
distance={8}
|
505
|
+
interactive={true}
|
506
|
+
appendTo={document?.body}
|
507
|
+
trigger="mouseenter focus"
|
508
|
+
{...this.props.tooltipProps}
|
509
|
+
>
|
510
|
+
{content}
|
511
|
+
</Tippy>
|
512
|
+
);
|
513
|
+
}
|
514
|
+
return content;
|
515
|
+
}
|
516
|
+
|
517
|
+
protected getTranslations(
|
518
|
+
_defaultTranslations: BaseTranslations
|
519
|
+
): TranslationsT {
|
520
|
+
return {
|
521
|
+
..._defaultTranslations,
|
522
|
+
...this.props.translations,
|
523
|
+
};
|
524
|
+
}
|
525
|
+
}
|
526
|
+
export default BaseInput;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './BaseInput';
|