@anglr/datetime 2.0.0-beta.20220221103100 → 2.0.1
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/changelog.md +19 -0
- package/date-fns/package.json +7 -7
- package/date-fns/src/{date-fns.d.ts → index.d.ts} +4 -4
- package/date-fns/src/index.d.ts.map +1 -0
- package/date-fns/src/misc/tokens.d.ts +10 -10
- package/date-fns/src/services/dateFnsDateApi.service.d.ts +36 -33
- package/date-fns/src/services/dateFnsDateApi.service.d.ts.map +1 -1
- package/date-fns/src/services/dateFnsLocale.service.d.ts +10 -10
- package/es2015/date-fns/src/index.js +4 -0
- package/es2015/date-fns/src/index.js.map +1 -0
- package/es2015/date-fns/src/misc/tokens.js +20 -0
- package/es2015/date-fns/src/misc/tokens.js.map +1 -0
- package/es2015/date-fns/src/services/dateFnsDateApi.service.js +438 -0
- package/es2015/date-fns/src/services/dateFnsDateApi.service.js.map +1 -0
- package/es2015/date-fns/src/services/dateFnsLocale.service.js +2 -0
- package/es2015/date-fns/src/services/dateFnsLocale.service.js.map +1 -0
- package/es2015/karma.conf.js +57 -0
- package/es2015/karma.conf.js.map +1 -0
- package/{moment/src/moment.d.ts → es2015/moment/src/index.js} +3 -3
- package/es2015/moment/src/index.js.map +1 -0
- package/es2015/moment/src/misc/tokens.js +15 -0
- package/es2015/moment/src/misc/tokens.js.map +1 -0
- package/es2015/moment/src/services/momentDateApi.service.js +398 -0
- package/es2015/moment/src/services/momentDateApi.service.js.map +1 -0
- package/{src/datetime.d.ts → es2015/src/index.js} +19 -19
- package/es2015/src/index.js.map +1 -0
- package/es2015/src/misc/constants.js +33 -0
- package/es2015/src/misc/constants.js.map +1 -0
- package/es2015/src/misc/datetime.interface.js +2 -0
- package/es2015/src/misc/datetime.interface.js.map +1 -0
- package/es2015/src/misc/tokens.js +19 -0
- package/es2015/src/misc/tokens.js.map +1 -0
- package/es2015/src/misc/validators.js +58 -0
- package/es2015/src/misc/validators.js.map +1 -0
- package/es2015/src/modules/datePipes.module.js +33 -0
- package/es2015/src/modules/datePipes.module.js.map +1 -0
- package/es2015/src/picker/components/dayPicker/dayPicker.component.js +172 -0
- package/es2015/src/picker/components/dayPicker/dayPicker.component.js.map +1 -0
- package/es2015/src/picker/components/dayPicker/dayPicker.interfaces.js +2 -0
- package/es2015/src/picker/components/dayPicker/dayPicker.interfaces.js.map +1 -0
- package/es2015/src/picker/components/monthPicker/monthPicker.component.js +114 -0
- package/es2015/src/picker/components/monthPicker/monthPicker.component.js.map +1 -0
- package/es2015/src/picker/components/monthPicker/monthPicker.interfaces.js +2 -0
- package/es2015/src/picker/components/monthPicker/monthPicker.interfaces.js.map +1 -0
- package/es2015/src/picker/components/picker/picker.component.animations.js +71 -0
- package/es2015/src/picker/components/picker/picker.component.animations.js.map +1 -0
- package/es2015/src/picker/components/picker/picker.component.js +241 -0
- package/es2015/src/picker/components/picker/picker.component.js.map +1 -0
- package/es2015/src/picker/components/pickerBase.component.js +243 -0
- package/es2015/src/picker/components/pickerBase.component.js.map +1 -0
- package/es2015/src/picker/components/yearPicker/yearPicker.component.js +126 -0
- package/es2015/src/picker/components/yearPicker/yearPicker.component.js.map +1 -0
- package/es2015/src/picker/components/yearPicker/yearPicker.interfaces.js +2 -0
- package/es2015/src/picker/components/yearPicker/yearPicker.interfaces.js.map +1 -0
- package/es2015/src/picker/interfaces.js +5 -0
- package/es2015/src/picker/interfaces.js.map +1 -0
- package/es2015/src/picker/misc/datetimePicker.interface.js +2 -0
- package/es2015/src/picker/misc/datetimePicker.interface.js.map +1 -0
- package/es2015/src/picker/misc/tokens.js +6 -0
- package/es2015/src/picker/misc/tokens.js.map +1 -0
- package/es2015/src/picker/modules/picker.module.js +46 -0
- package/es2015/src/picker/modules/picker.module.js.map +1 -0
- package/es2015/src/picker/types.js +8 -0
- package/es2015/src/picker/types.js.map +1 -0
- package/es2015/src/pipes/asRequiredType.js +22 -0
- package/es2015/src/pipes/asRequiredType.js.map +1 -0
- package/es2015/src/pipes/dateConvert.pipe.js +35 -0
- package/es2015/src/pipes/dateConvert.pipe.js.map +1 -0
- package/es2015/src/pipes/dateFormat.pipe.js +45 -0
- package/es2015/src/pipes/dateFormat.pipe.js.map +1 -0
- package/es2015/src/selector/components/inputDateTime/inputDateTime.component.js +421 -0
- package/es2015/src/selector/components/inputDateTime/inputDateTime.component.js.map +1 -0
- package/es2015/src/selector/components/selector/selector.component.animations.js +15 -0
- package/es2015/src/selector/components/selector/selector.component.animations.js.map +1 -0
- package/es2015/src/selector/components/selector/selector.component.js +344 -0
- package/es2015/src/selector/components/selector/selector.component.js.map +1 -0
- package/es2015/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +317 -0
- package/es2015/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +1 -0
- package/es2015/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.js +51 -0
- package/es2015/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.js.map +1 -0
- package/es2015/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.js +51 -0
- package/es2015/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.js.map +1 -0
- package/es2015/src/selector/directives/datetimeValidator/datetimeValidator.directive.js +47 -0
- package/es2015/src/selector/directives/datetimeValidator/datetimeValidator.directive.js.map +1 -0
- package/es2015/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.js +119 -0
- package/es2015/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.js.map +1 -0
- package/es2015/src/selector/interfaces.js +2 -0
- package/es2015/src/selector/interfaces.js.map +1 -0
- package/es2015/src/selector/misc/datetimeSelector.interface.js +2 -0
- package/es2015/src/selector/misc/datetimeSelector.interface.js.map +1 -0
- package/es2015/src/selector/misc/tokens.js +6 -0
- package/es2015/src/selector/misc/tokens.js.map +1 -0
- package/es2015/src/selector/modules/basicSelector.module.js +20 -0
- package/es2015/src/selector/modules/basicSelector.module.js.map +1 -0
- package/es2015/src/selector/modules/selector.module.js +60 -0
- package/es2015/src/selector/modules/selector.module.js.map +1 -0
- package/es2015/src/selector/types.js +10 -0
- package/es2015/src/selector/types.js.map +1 -0
- package/es2015/src/services/dateApi.interface.js +2 -0
- package/es2015/src/services/dateApi.interface.js.map +1 -0
- package/es2015/src/services/datePositionParser.interface.js +2 -0
- package/es2015/src/services/datePositionParser.interface.js.map +1 -0
- package/es2015/src/services/datePositionParser.service.js +227 -0
- package/es2015/src/services/datePositionParser.service.js.map +1 -0
- package/es2015/src/services/dateTimeRelativeParser.service.js +66 -0
- package/es2015/src/services/dateTimeRelativeParser.service.js.map +1 -0
- package/es2015/src/services/dateValueProvider.service.js +58 -0
- package/es2015/src/services/dateValueProvider.service.js.map +1 -0
- package/es2015/src/services/formatProvider.interface.js +2 -0
- package/es2015/src/services/formatProvider.interface.js.map +1 -0
- package/es2015/src/services/index.js +4 -0
- package/es2015/src/services/index.js.map +1 -0
- package/es2020/date-fns/src/index.js +4 -0
- package/es2020/date-fns/src/index.js.map +1 -0
- package/es2020/date-fns/src/misc/tokens.js +20 -0
- package/es2020/date-fns/src/misc/tokens.js.map +1 -0
- package/es2020/date-fns/src/services/dateFnsDateApi.service.js +437 -0
- package/es2020/date-fns/src/services/dateFnsDateApi.service.js.map +1 -0
- package/es2020/date-fns/src/services/dateFnsLocale.service.js +2 -0
- package/es2020/date-fns/src/services/dateFnsLocale.service.js.map +1 -0
- package/es2020/karma.conf.js +57 -0
- package/es2020/karma.conf.js.map +1 -0
- package/es2020/moment/src/index.js +3 -0
- package/es2020/moment/src/index.js.map +1 -0
- package/es2020/moment/src/misc/tokens.js +15 -0
- package/es2020/moment/src/misc/tokens.js.map +1 -0
- package/es2020/moment/src/services/momentDateApi.service.js +398 -0
- package/es2020/moment/src/services/momentDateApi.service.js.map +1 -0
- package/es2020/src/index.js +19 -0
- package/es2020/src/index.js.map +1 -0
- package/es2020/src/misc/constants.js +33 -0
- package/es2020/src/misc/constants.js.map +1 -0
- package/es2020/src/misc/datetime.interface.js +2 -0
- package/es2020/src/misc/datetime.interface.js.map +1 -0
- package/es2020/src/misc/tokens.js +19 -0
- package/es2020/src/misc/tokens.js.map +1 -0
- package/es2020/src/misc/validators.js +58 -0
- package/es2020/src/misc/validators.js.map +1 -0
- package/es2020/src/modules/datePipes.module.js +33 -0
- package/es2020/src/modules/datePipes.module.js.map +1 -0
- package/es2020/src/picker/components/dayPicker/dayPicker.component.js +172 -0
- package/es2020/src/picker/components/dayPicker/dayPicker.component.js.map +1 -0
- package/es2020/src/picker/components/dayPicker/dayPicker.interfaces.js +2 -0
- package/es2020/src/picker/components/dayPicker/dayPicker.interfaces.js.map +1 -0
- package/es2020/src/picker/components/monthPicker/monthPicker.component.js +114 -0
- package/es2020/src/picker/components/monthPicker/monthPicker.component.js.map +1 -0
- package/es2020/src/picker/components/monthPicker/monthPicker.interfaces.js +2 -0
- package/es2020/src/picker/components/monthPicker/monthPicker.interfaces.js.map +1 -0
- package/es2020/src/picker/components/picker/picker.component.animations.js +71 -0
- package/es2020/src/picker/components/picker/picker.component.animations.js.map +1 -0
- package/es2020/src/picker/components/picker/picker.component.js +236 -0
- package/es2020/src/picker/components/picker/picker.component.js.map +1 -0
- package/es2020/src/picker/components/pickerBase.component.js +243 -0
- package/es2020/src/picker/components/pickerBase.component.js.map +1 -0
- package/es2020/src/picker/components/yearPicker/yearPicker.component.js +126 -0
- package/es2020/src/picker/components/yearPicker/yearPicker.component.js.map +1 -0
- package/es2020/src/picker/components/yearPicker/yearPicker.interfaces.js +2 -0
- package/es2020/src/picker/components/yearPicker/yearPicker.interfaces.js.map +1 -0
- package/es2020/src/picker/interfaces.js +5 -0
- package/es2020/src/picker/interfaces.js.map +1 -0
- package/es2020/src/picker/misc/datetimePicker.interface.js +2 -0
- package/es2020/src/picker/misc/datetimePicker.interface.js.map +1 -0
- package/es2020/src/picker/misc/tokens.js +6 -0
- package/es2020/src/picker/misc/tokens.js.map +1 -0
- package/es2020/src/picker/modules/picker.module.js +46 -0
- package/es2020/src/picker/modules/picker.module.js.map +1 -0
- package/es2020/src/picker/types.js +8 -0
- package/es2020/src/picker/types.js.map +1 -0
- package/es2020/src/pipes/asRequiredType.js +22 -0
- package/es2020/src/pipes/asRequiredType.js.map +1 -0
- package/es2020/src/pipes/dateConvert.pipe.js +35 -0
- package/es2020/src/pipes/dateConvert.pipe.js.map +1 -0
- package/es2020/src/pipes/dateFormat.pipe.js +45 -0
- package/es2020/src/pipes/dateFormat.pipe.js.map +1 -0
- package/es2020/src/selector/components/inputDateTime/inputDateTime.component.js +417 -0
- package/es2020/src/selector/components/inputDateTime/inputDateTime.component.js.map +1 -0
- package/es2020/src/selector/components/selector/selector.component.animations.js +15 -0
- package/es2020/src/selector/components/selector/selector.component.animations.js.map +1 -0
- package/es2020/src/selector/components/selector/selector.component.js +334 -0
- package/es2020/src/selector/components/selector/selector.component.js.map +1 -0
- package/es2020/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +314 -0
- package/es2020/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +1 -0
- package/es2020/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.js +51 -0
- package/es2020/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.js.map +1 -0
- package/es2020/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.js +51 -0
- package/es2020/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.js.map +1 -0
- package/es2020/src/selector/directives/datetimeValidator/datetimeValidator.directive.js +47 -0
- package/es2020/src/selector/directives/datetimeValidator/datetimeValidator.directive.js.map +1 -0
- package/es2020/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.js +118 -0
- package/es2020/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.js.map +1 -0
- package/es2020/src/selector/interfaces.js +2 -0
- package/es2020/src/selector/interfaces.js.map +1 -0
- package/es2020/src/selector/misc/datetimeSelector.interface.js +2 -0
- package/es2020/src/selector/misc/datetimeSelector.interface.js.map +1 -0
- package/es2020/src/selector/misc/tokens.js +6 -0
- package/es2020/src/selector/misc/tokens.js.map +1 -0
- package/es2020/src/selector/modules/basicSelector.module.js +20 -0
- package/es2020/src/selector/modules/basicSelector.module.js.map +1 -0
- package/es2020/src/selector/modules/selector.module.js +60 -0
- package/es2020/src/selector/modules/selector.module.js.map +1 -0
- package/es2020/src/selector/types.js +10 -0
- package/es2020/src/selector/types.js.map +1 -0
- package/es2020/src/services/dateApi.interface.js +2 -0
- package/es2020/src/services/dateApi.interface.js.map +1 -0
- package/es2020/src/services/datePositionParser.interface.js +2 -0
- package/es2020/src/services/datePositionParser.interface.js.map +1 -0
- package/es2020/src/services/datePositionParser.service.js +227 -0
- package/es2020/src/services/datePositionParser.service.js.map +1 -0
- package/es2020/src/services/dateTimeRelativeParser.service.js +65 -0
- package/es2020/src/services/dateTimeRelativeParser.service.js.map +1 -0
- package/es2020/src/services/dateValueProvider.service.js +58 -0
- package/es2020/src/services/dateValueProvider.service.js.map +1 -0
- package/es2020/src/services/formatProvider.interface.js +2 -0
- package/es2020/src/services/formatProvider.interface.js.map +1 -0
- package/es2020/src/services/index.js +4 -0
- package/es2020/src/services/index.js.map +1 -0
- package/karma.conf.d.ts +2 -0
- package/karma.conf.d.ts.map +1 -0
- package/moment/package.json +7 -7
- package/moment/src/index.d.ts +3 -0
- package/moment/src/index.d.ts.map +1 -0
- package/moment/src/misc/tokens.d.ts +5 -5
- package/moment/src/services/momentDateApi.service.d.ts +35 -32
- package/moment/src/services/momentDateApi.service.d.ts.map +1 -1
- package/package.json +100 -48
- package/src/index.d.ts +19 -0
- package/src/index.d.ts.map +1 -0
- package/src/misc/constants.d.ts +32 -32
- package/src/misc/datetime.interface.d.ts +34 -34
- package/src/misc/tokens.d.ts +10 -10
- package/src/misc/validators.d.ts +25 -25
- package/src/modules/datePipes.module.d.ts +12 -5
- package/src/modules/datePipes.module.d.ts.map +1 -1
- package/src/picker/components/dayPicker/dayPicker.component.d.ts +68 -65
- package/src/picker/components/dayPicker/dayPicker.component.d.ts.map +1 -1
- package/src/picker/components/dayPicker/dayPicker.component.html +7 -7
- package/src/picker/components/dayPicker/dayPicker.interfaces.d.ts +10 -10
- package/src/picker/components/monthPicker/monthPicker.component.d.ts +52 -49
- package/src/picker/components/monthPicker/monthPicker.component.d.ts.map +1 -1
- package/src/picker/components/monthPicker/monthPicker.component.html +6 -6
- package/src/picker/components/monthPicker/monthPicker.interfaces.d.ts +6 -6
- package/src/picker/components/picker/picker.component.animations.d.ts +4 -4
- package/src/picker/components/picker/picker.component.d.ts +104 -101
- package/src/picker/components/picker/picker.component.d.ts.map +1 -1
- package/src/picker/components/pickerBase.component.d.ts +169 -166
- package/src/picker/components/pickerBase.component.d.ts.map +1 -1
- package/src/picker/components/yearPicker/yearPicker.component.d.ts +57 -54
- package/src/picker/components/yearPicker/yearPicker.component.d.ts.map +1 -1
- package/src/picker/components/yearPicker/yearPicker.component.html +6 -6
- package/src/picker/components/yearPicker/yearPicker.interfaces.d.ts +6 -6
- package/src/picker/interfaces.d.ts +4 -4
- package/src/picker/misc/datetimePicker.interface.d.ts +188 -188
- package/src/picker/misc/tokens.d.ts +6 -6
- package/src/picker/modules/picker.module.d.ts +16 -5
- package/src/picker/modules/picker.module.d.ts.map +1 -1
- package/src/picker/types.d.ts +7 -7
- package/src/pipes/asRequiredType.d.ts +21 -0
- package/src/pipes/asRequiredType.d.ts.map +1 -0
- package/src/pipes/dateConvert.pipe.d.ts +18 -15
- package/src/pipes/dateConvert.pipe.d.ts.map +1 -1
- package/src/pipes/dateFormat.pipe.d.ts +20 -17
- package/src/pipes/dateFormat.pipe.d.ts.map +1 -1
- package/src/selector/components/inputDateTime/inputDateTime.component.d.ts +187 -184
- package/src/selector/components/inputDateTime/inputDateTime.component.d.ts.map +1 -1
- package/src/selector/components/selector/selector.component.animations.d.ts +4 -4
- package/src/selector/components/selector/selector.component.d.ts +155 -152
- package/src/selector/components/selector/selector.component.d.ts.map +1 -1
- package/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts +170 -167
- package/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts.map +1 -1
- package/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.d.ts +22 -19
- package/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.d.ts.map +1 -1
- package/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.d.ts +22 -19
- package/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.d.ts.map +1 -1
- package/src/selector/directives/datetimeValidator/datetimeValidator.directive.d.ts +21 -18
- package/src/selector/directives/datetimeValidator/datetimeValidator.directive.d.ts.map +1 -1
- package/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.d.ts +53 -50
- package/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.d.ts.map +1 -1
- package/src/selector/interfaces.d.ts +1 -1
- package/src/selector/misc/datetimeSelector.interface.d.ts +82 -82
- package/src/selector/misc/tokens.d.ts +6 -6
- package/src/selector/modules/basicSelector.module.d.ts +10 -5
- package/src/selector/modules/basicSelector.module.d.ts.map +1 -1
- package/src/selector/modules/selector.module.d.ts +18 -5
- package/src/selector/modules/selector.module.d.ts.map +1 -1
- package/src/selector/types.d.ts +9 -9
- package/src/services/dateApi.interface.d.ts +275 -275
- package/src/services/datePositionParser.interface.d.ts +40 -40
- package/src/services/datePositionParser.service.d.ts +60 -57
- package/src/services/datePositionParser.service.d.ts.map +1 -1
- package/src/services/dateTimeRelativeParser.service.d.ts +21 -18
- package/src/services/dateTimeRelativeParser.service.d.ts.map +1 -1
- package/src/services/dateValueProvider.service.d.ts +18 -15
- package/src/services/dateValueProvider.service.d.ts.map +1 -1
- package/src/services/formatProvider.interface.d.ts +17 -17
- package/src/services/index.d.ts +3 -3
- package/tsconfig.karma.json +5 -6
- package/version.bak +1 -1
- package/appveyor.yml +0 -70
- package/date-fns/dist/es2015/date-fns/index.js +0 -10
- package/date-fns/dist/es2015/date-fns/public_api.js +0 -7
- package/date-fns/dist/es2015/date-fns/src/date-fns.js +0 -9
- package/date-fns/dist/es2015/date-fns/src/misc/tokens.js +0 -32
- package/date-fns/dist/es2015/date-fns/src/services/dateFnsDateApi.service.js +0 -512
- package/date-fns/dist/es2015/date-fns/src/services/dateFnsLocale.service.js +0 -18
- package/date-fns/dist/es5/date-fns/index.js +0 -10
- package/date-fns/dist/es5/date-fns/public_api.js +0 -7
- package/date-fns/dist/es5/date-fns/src/date-fns.js +0 -9
- package/date-fns/dist/es5/date-fns/src/misc/tokens.js +0 -32
- package/date-fns/dist/es5/date-fns/src/services/dateFnsDateApi.service.js +0 -902
- package/date-fns/dist/es5/date-fns/src/services/dateFnsLocale.service.js +0 -18
- package/date-fns/index.d.ts +0 -5
- package/date-fns/index.d.ts.map +0 -1
- package/date-fns/index.metadata.json +0 -1
- package/date-fns/public_api.d.ts +0 -2
- package/date-fns/public_api.d.ts.map +0 -1
- package/date-fns/src/date-fns.d.ts.map +0 -1
- package/date-fns/src/services/dateFnsDateApi.service.ngfactory.d.ts.map +0 -1
- package/datetime.d.ts +0 -7
- package/datetime.d.ts.map +0 -1
- package/datetime.metadata.json +0 -1
- package/dist/es2015/datetime.js +0 -10
- package/dist/es2015/public_api.js +0 -7
- package/dist/es2015/src/datetime.js +0 -24
- package/dist/es2015/src/misc/constants.js +0 -46
- package/dist/es2015/src/misc/datetime.interface.js +0 -52
- package/dist/es2015/src/misc/tokens.js +0 -29
- package/dist/es2015/src/misc/validators.js +0 -80
- package/dist/es2015/src/modules/datePipes.module.js +0 -26
- package/dist/es2015/src/picker/components/dayPicker/dayPicker.component.js +0 -215
- package/dist/es2015/src/picker/components/dayPicker/dayPicker.interfaces.js +0 -18
- package/dist/es2015/src/picker/components/monthPicker/monthPicker.component.js +0 -138
- package/dist/es2015/src/picker/components/monthPicker/monthPicker.interfaces.js +0 -11
- package/dist/es2015/src/picker/components/picker/picker.component.animations.js +0 -77
- package/dist/es2015/src/picker/components/picker/picker.component.js +0 -386
- package/dist/es2015/src/picker/components/pickerBase.component.js +0 -406
- package/dist/es2015/src/picker/components/yearPicker/yearPicker.component.js +0 -158
- package/dist/es2015/src/picker/components/yearPicker/yearPicker.interfaces.js +0 -11
- package/dist/es2015/src/picker/interfaces.js +0 -10
- package/dist/es2015/src/picker/misc/datetimePicker.interface.js +0 -245
- package/dist/es2015/src/picker/misc/tokens.js +0 -12
- package/dist/es2015/src/picker/modules/picker.module.js +0 -35
- package/dist/es2015/src/picker/types.js +0 -13
- package/dist/es2015/src/pipes/dateConvert.pipe.js +0 -50
- package/dist/es2015/src/pipes/dateFormat.pipe.js +0 -64
- package/dist/es2015/src/selector/components/inputDateTime/inputDateTime.component.js +0 -588
- package/dist/es2015/src/selector/components/selector/selector.component.animations.js +0 -21
- package/dist/es2015/src/selector/components/selector/selector.component.js +0 -514
- package/dist/es2015/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +0 -456
- package/dist/es2015/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.js +0 -73
- package/dist/es2015/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.js +0 -73
- package/dist/es2015/src/selector/directives/datetimeValidator/datetimeValidator.directive.js +0 -70
- package/dist/es2015/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.js +0 -171
- package/dist/es2015/src/selector/interfaces.js +0 -7
- package/dist/es2015/src/selector/misc/datetimeSelector.interface.js +0 -106
- package/dist/es2015/src/selector/misc/tokens.js +0 -12
- package/dist/es2015/src/selector/modules/basicSelector.module.js +0 -20
- package/dist/es2015/src/selector/modules/selector.module.js +0 -45
- package/dist/es2015/src/selector/types.js +0 -15
- package/dist/es2015/src/services/dateApi.interface.js +0 -316
- package/dist/es2015/src/services/datePositionParser.interface.js +0 -56
- package/dist/es2015/src/services/datePositionParser.service.js +0 -297
- package/dist/es2015/src/services/dateTimeRelativeParser.service.js +0 -97
- package/dist/es2015/src/services/dateValueProvider.service.js +0 -79
- package/dist/es2015/src/services/formatProvider.interface.js +0 -28
- package/dist/es2015/src/services/index.js +0 -9
- package/dist/es5/datetime.js +0 -10
- package/dist/es5/public_api.js +0 -7
- package/dist/es5/src/datetime.js +0 -24
- package/dist/es5/src/misc/constants.js +0 -46
- package/dist/es5/src/misc/datetime.interface.js +0 -52
- package/dist/es5/src/misc/tokens.js +0 -29
- package/dist/es5/src/misc/validators.js +0 -124
- package/dist/es5/src/modules/datePipes.module.js +0 -30
- package/dist/es5/src/picker/components/dayPicker/dayPicker.component.js +0 -323
- package/dist/es5/src/picker/components/dayPicker/dayPicker.interfaces.js +0 -18
- package/dist/es5/src/picker/components/monthPicker/monthPicker.component.js +0 -233
- package/dist/es5/src/picker/components/monthPicker/monthPicker.interfaces.js +0 -11
- package/dist/es5/src/picker/components/picker/picker.component.animations.js +0 -77
- package/dist/es5/src/picker/components/picker/picker.component.js +0 -460
- package/dist/es5/src/picker/components/pickerBase.component.js +0 -561
- package/dist/es5/src/picker/components/yearPicker/yearPicker.component.js +0 -253
- package/dist/es5/src/picker/components/yearPicker/yearPicker.interfaces.js +0 -11
- package/dist/es5/src/picker/interfaces.js +0 -10
- package/dist/es5/src/picker/misc/datetimePicker.interface.js +0 -245
- package/dist/es5/src/picker/misc/tokens.js +0 -12
- package/dist/es5/src/picker/modules/picker.module.js +0 -39
- package/dist/es5/src/picker/types.js +0 -13
- package/dist/es5/src/pipes/dateConvert.pipe.js +0 -63
- package/dist/es5/src/pipes/dateFormat.pipe.js +0 -79
- package/dist/es5/src/selector/components/inputDateTime/inputDateTime.component.js +0 -808
- package/dist/es5/src/selector/components/selector/selector.component.animations.js +0 -21
- package/dist/es5/src/selector/components/selector/selector.component.js +0 -653
- package/dist/es5/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +0 -656
- package/dist/es5/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.js +0 -84
- package/dist/es5/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.js +0 -84
- package/dist/es5/src/selector/directives/datetimeValidator/datetimeValidator.directive.js +0 -82
- package/dist/es5/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.js +0 -230
- package/dist/es5/src/selector/interfaces.js +0 -7
- package/dist/es5/src/selector/misc/datetimeSelector.interface.js +0 -106
- package/dist/es5/src/selector/misc/tokens.js +0 -12
- package/dist/es5/src/selector/modules/basicSelector.module.js +0 -24
- package/dist/es5/src/selector/modules/selector.module.js +0 -49
- package/dist/es5/src/selector/types.js +0 -15
- package/dist/es5/src/services/dateApi.interface.js +0 -316
- package/dist/es5/src/services/datePositionParser.interface.js +0 -56
- package/dist/es5/src/services/datePositionParser.service.js +0 -366
- package/dist/es5/src/services/dateTimeRelativeParser.service.js +0 -108
- package/dist/es5/src/services/dateValueProvider.service.js +0 -92
- package/dist/es5/src/services/formatProvider.interface.js +0 -28
- package/dist/es5/src/services/index.js +0 -9
- package/moment/dist/es2015/moment/index.js +0 -10
- package/moment/dist/es2015/moment/public_api.js +0 -7
- package/moment/dist/es2015/moment/src/misc/tokens.js +0 -26
- package/moment/dist/es2015/moment/src/moment.js +0 -8
- package/moment/dist/es2015/moment/src/services/momentDateApi.service.js +0 -466
- package/moment/dist/es5/moment/index.js +0 -10
- package/moment/dist/es5/moment/public_api.js +0 -7
- package/moment/dist/es5/moment/src/misc/tokens.js +0 -26
- package/moment/dist/es5/moment/src/moment.js +0 -8
- package/moment/dist/es5/moment/src/services/momentDateApi.service.js +0 -858
- package/moment/index.d.ts +0 -5
- package/moment/index.d.ts.map +0 -1
- package/moment/index.metadata.json +0 -1
- package/moment/public_api.d.ts +0 -2
- package/moment/public_api.d.ts.map +0 -1
- package/moment/src/moment.d.ts.map +0 -1
- package/moment/src/services/momentDateApi.service.ngfactory.d.ts.map +0 -1
- package/public_api.d.ts +0 -2
- package/public_api.d.ts.map +0 -1
- package/src/datetime.d.ts.map +0 -1
- package/src/modules/datePipes.module.ngfactory.d.ts.map +0 -1
- package/src/picker/components/dayPicker/dayPicker.component.css.shim.ngstyle.d.ts.map +0 -1
- package/src/picker/components/dayPicker/dayPicker.component.ngfactory.d.ts.map +0 -1
- package/src/picker/components/monthPicker/monthPicker.component.css.shim.ngstyle.d.ts.map +0 -1
- package/src/picker/components/monthPicker/monthPicker.component.ngfactory.d.ts.map +0 -1
- package/src/picker/components/picker/picker.component.ngfactory.d.ts.map +0 -1
- package/src/picker/components/yearPicker/yearPicker.component.css.shim.ngstyle.d.ts.map +0 -1
- package/src/picker/components/yearPicker/yearPicker.component.ngfactory.d.ts.map +0 -1
- package/src/picker/modules/picker.module.ngfactory.d.ts.map +0 -1
- package/src/pipes/dateConvert.pipe.ngfactory.d.ts.map +0 -1
- package/src/pipes/dateFormat.pipe.ngfactory.d.ts.map +0 -1
- package/src/selector/components/inputDateTime/inputDateTime.component.css.shim.ngstyle.d.ts.map +0 -1
- package/src/selector/components/inputDateTime/inputDateTime.component.ngfactory.d.ts.map +0 -1
- package/src/selector/components/selector/selector.component.css.shim.ngstyle.d.ts.map +0 -1
- package/src/selector/components/selector/selector.component.ngfactory.d.ts.map +0 -1
- package/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.css.shim.ngstyle.d.ts.map +0 -1
- package/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.ngfactory.d.ts.map +0 -1
- package/src/selector/directives/datetimeMaxValidator/datetimeMaxValidator.directive.ngfactory.d.ts.map +0 -1
- package/src/selector/directives/datetimeMinValidator/datetimeMinValidator.directive.ngfactory.d.ts.map +0 -1
- package/src/selector/directives/datetimeValidator/datetimeValidator.directive.ngfactory.d.ts.map +0 -1
- package/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.ngfactory.d.ts.map +0 -1
- package/src/selector/modules/basicSelector.module.ngfactory.d.ts.map +0 -1
- package/src/selector/modules/selector.module.ngfactory.d.ts.map +0 -1
- package/src/services/datePositionParser.service.ngfactory.d.ts.map +0 -1
- package/src/services/dateTimeRelativeParser.service.ngfactory.d.ts.map +0 -1
- package/src/services/dateValueProvider.service.ngfactory.d.ts.map +0 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Component, ChangeDetectionStrategy, Optional, Inject, Input, EventEmitter, Output, ChangeDetectorRef } from '@angular/core';
|
|
2
|
+
import { extend } from '@jscrpt/common';
|
|
3
|
+
import { Subscription } from 'rxjs';
|
|
4
|
+
import { DATE_API } from '../../../misc/tokens';
|
|
5
|
+
import { DATE_TIME_PICKER_CONFIGURATION } from '../../misc/tokens';
|
|
6
|
+
import { DateTimeDayPickerComponent } from '../dayPicker/dayPicker.component';
|
|
7
|
+
import { DateTimeMonthPickerComponent } from '../monthPicker/monthPicker.component';
|
|
8
|
+
import { DateTimeYearPickerComponent } from '../yearPicker/yearPicker.component';
|
|
9
|
+
import { scaleUpDownTrigger } from './picker.component.animations';
|
|
10
|
+
import * as i0 from "@angular/core";
|
|
11
|
+
import * as i1 from "@anglr/common";
|
|
12
|
+
//TODO - merge options
|
|
13
|
+
/**
|
|
14
|
+
* Default configuration for picker
|
|
15
|
+
*/
|
|
16
|
+
const defaultConfiguration = {
|
|
17
|
+
defaultPeriod: 'day',
|
|
18
|
+
pickerPeriodsDefinition: {
|
|
19
|
+
'day': DateTimeDayPickerComponent,
|
|
20
|
+
'month': DateTimeMonthPickerComponent,
|
|
21
|
+
'year': DateTimeYearPickerComponent
|
|
22
|
+
},
|
|
23
|
+
cssClasses: {}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Component used for displaying date time picker
|
|
27
|
+
*/
|
|
28
|
+
export class DateTimePickerComponent {
|
|
29
|
+
//######################### constructor #########################
|
|
30
|
+
constructor(configuration, _dateApi, _changeDetector) {
|
|
31
|
+
this._dateApi = _dateApi;
|
|
32
|
+
this._changeDetector = _changeDetector;
|
|
33
|
+
/**
|
|
34
|
+
* Array of available picker names
|
|
35
|
+
*/
|
|
36
|
+
this._pickerNames = [];
|
|
37
|
+
/**
|
|
38
|
+
* Current selected value
|
|
39
|
+
*/
|
|
40
|
+
this._value = null;
|
|
41
|
+
/**
|
|
42
|
+
* All subscriptions for active picker
|
|
43
|
+
*/
|
|
44
|
+
this._activePickerSubscriptions = new Subscription();
|
|
45
|
+
/**
|
|
46
|
+
* Minimal possible value that can be picked
|
|
47
|
+
*/
|
|
48
|
+
this._minValue = null;
|
|
49
|
+
/**
|
|
50
|
+
* Maximal possible value that can be picked
|
|
51
|
+
*/
|
|
52
|
+
this._maxValue = null;
|
|
53
|
+
/**
|
|
54
|
+
* Active picker index
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
this.activePickerIndex = 0;
|
|
58
|
+
//######################### public properties - outputs #########################
|
|
59
|
+
/**
|
|
60
|
+
* Occurs when value changes
|
|
61
|
+
*/
|
|
62
|
+
this.valueChange = new EventEmitter();
|
|
63
|
+
this._options = extend(true, {}, defaultConfiguration, configuration);
|
|
64
|
+
// without deep-copy for this attribute
|
|
65
|
+
if (configuration?.pickerPeriodsDefinition) {
|
|
66
|
+
this._options.pickerPeriodsDefinition = configuration.pickerPeriodsDefinition;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//######################### public properties - inputs #########################
|
|
70
|
+
/**
|
|
71
|
+
* Current options used by picker
|
|
72
|
+
*/
|
|
73
|
+
get options() {
|
|
74
|
+
return this._options;
|
|
75
|
+
}
|
|
76
|
+
set options(value) {
|
|
77
|
+
this._options = extend(true, this._options, value);
|
|
78
|
+
// without deep-copy for this attribute
|
|
79
|
+
if (value?.pickerPeriodsDefinition) {
|
|
80
|
+
this._options.pickerPeriodsDefinition = value.pickerPeriodsDefinition;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Current selected value
|
|
85
|
+
*/
|
|
86
|
+
get value() {
|
|
87
|
+
return this._value;
|
|
88
|
+
}
|
|
89
|
+
set value(value) {
|
|
90
|
+
this._value = value;
|
|
91
|
+
this._activePicker?.setValue(value);
|
|
92
|
+
this._activePicker?.invalidateVisuals();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets or sets minimal possible value for picker, that can be picked
|
|
96
|
+
*/
|
|
97
|
+
get minValue() {
|
|
98
|
+
return this._minValue;
|
|
99
|
+
}
|
|
100
|
+
set minValue(value) {
|
|
101
|
+
this._minValue = value;
|
|
102
|
+
this._activePicker?.setMinValue(this._minValue);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Gets or sets maximal possible value for picker, that can be picked
|
|
106
|
+
*/
|
|
107
|
+
get maxValue() {
|
|
108
|
+
return this._maxValue;
|
|
109
|
+
}
|
|
110
|
+
set maxValue(value) {
|
|
111
|
+
this._maxValue = value;
|
|
112
|
+
this._activePicker?.setMaxValue(this._maxValue);
|
|
113
|
+
}
|
|
114
|
+
//######################### public methods - implementation of OnInit #########################
|
|
115
|
+
/**
|
|
116
|
+
* Initialize component
|
|
117
|
+
*/
|
|
118
|
+
ngOnInit() {
|
|
119
|
+
if (this._options.pickerPeriodsOrder) {
|
|
120
|
+
if (Array.isArray(this._options.pickerPeriodsOrder)) {
|
|
121
|
+
this._pickerNames = this._options.pickerPeriodsOrder;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this._pickerNames = this._options.pickerPeriodsOrder.split(',')
|
|
125
|
+
.map(x => x.trim())
|
|
126
|
+
.filter(x => x);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (this._pickerNames && this._pickerNames.length > 0) {
|
|
130
|
+
this._pickerNames.forEach(x => {
|
|
131
|
+
if (!this._options.pickerPeriodsDefinition[x]) {
|
|
132
|
+
throw new Error(`There is no period '${x}' in picker options`);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this._pickerNames = Object.keys(this._options.pickerPeriodsDefinition);
|
|
138
|
+
}
|
|
139
|
+
if (this._pickerNames.findIndex(x => x == this._options.defaultPeriod) < 0) {
|
|
140
|
+
throw new Error(`There is no period '${this._options.defaultPeriod}' in picker options`);
|
|
141
|
+
}
|
|
142
|
+
this.activePickerComponent = this._options.pickerPeriodsDefinition[this._options.defaultPeriod];
|
|
143
|
+
this._activePickerName = this._options.defaultPeriod;
|
|
144
|
+
this.activePickerIndex = this._pickerNames.indexOf(this._activePickerName);
|
|
145
|
+
}
|
|
146
|
+
//######################### public methods - implementation of OnDestroy #########################
|
|
147
|
+
/**
|
|
148
|
+
* Called when component is destroyed
|
|
149
|
+
*/
|
|
150
|
+
ngOnDestroy() {
|
|
151
|
+
this._display = undefined;
|
|
152
|
+
this._activePickerSubscriptions.unsubscribe();
|
|
153
|
+
}
|
|
154
|
+
//######################### public methods - template bindings #########################
|
|
155
|
+
/**
|
|
156
|
+
* Handles created or destroyed date time picker instance
|
|
157
|
+
* @param picker - Instance of picker or null
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
pickerCreated(picker) {
|
|
161
|
+
if (picker == this._activePicker) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this._activePicker = picker;
|
|
165
|
+
this._activePickerSubscriptions.unsubscribe();
|
|
166
|
+
this._activePickerSubscriptions = new Subscription();
|
|
167
|
+
if (!this._activePicker) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
this._activePickerSubscriptions.add(picker.valueChange.subscribe(() => {
|
|
171
|
+
this._value = picker.value;
|
|
172
|
+
this.valueChange.emit(this._value);
|
|
173
|
+
}));
|
|
174
|
+
this._activePickerSubscriptions.add(picker.scaleUp.subscribe(display => {
|
|
175
|
+
this._display = display;
|
|
176
|
+
const index = this._pickerNames.indexOf(this._activePickerName) + 1;
|
|
177
|
+
this._activePickerName = this._pickerNames[index];
|
|
178
|
+
this.activePickerIndex = this._pickerNames.indexOf(this._activePickerName);
|
|
179
|
+
this.activePickerComponent = this._options.pickerPeriodsDefinition[this._activePickerName];
|
|
180
|
+
}));
|
|
181
|
+
this._activePickerSubscriptions.add(picker.scaleDown.subscribe(display => {
|
|
182
|
+
this._display = display;
|
|
183
|
+
const index = this._pickerNames.indexOf(this._activePickerName) - 1;
|
|
184
|
+
this._activePickerName = this._pickerNames[index];
|
|
185
|
+
this.activePickerIndex = this._pickerNames.indexOf(this._activePickerName);
|
|
186
|
+
this.activePickerComponent = this._options.pickerPeriodsDefinition[this._activePickerName];
|
|
187
|
+
}));
|
|
188
|
+
picker.setCanGoDown(this._pickerNames.indexOf(this._activePickerName) > 0);
|
|
189
|
+
picker.setCanGoUp(this._pickerNames.indexOf(this._activePickerName) < this._pickerNames.length - 1);
|
|
190
|
+
this._setPickerCssClasses();
|
|
191
|
+
picker.setValue(this._value);
|
|
192
|
+
picker.setMinValue(this._minValue);
|
|
193
|
+
picker.setMaxValue(this._maxValue);
|
|
194
|
+
picker.display(this._display ? this._dateApi.getValue(this._display) : this._dateApi.getValue(this._value?.from ?? this._dateApi.now().value));
|
|
195
|
+
picker.invalidateVisuals();
|
|
196
|
+
}
|
|
197
|
+
//######################### protected methods #########################
|
|
198
|
+
/**
|
|
199
|
+
* Sets picker css classes
|
|
200
|
+
*/
|
|
201
|
+
_setPickerCssClasses() {
|
|
202
|
+
if (!this._activePicker) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
//sets shared css
|
|
206
|
+
this._activePicker.setCssClasses(this._options?.cssClasses?.pickerShared ?? {});
|
|
207
|
+
if (this._options?.cssClasses?.pickerCustom && this._options?.cssClasses?.pickerCustom[this._activePickerName]) {
|
|
208
|
+
this._activePicker.setCssClasses(this._options?.cssClasses?.pickerCustom[this._activePickerName]);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
DateTimePickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: DateTimePickerComponent, deps: [{ token: DATE_TIME_PICKER_CONFIGURATION, optional: true }, { token: DATE_API }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
213
|
+
DateTimePickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: DateTimePickerComponent, selector: "date-time-picker", inputs: { options: "options", value: "value", minValue: "minValue", maxValue: "maxValue" }, outputs: { valueChange: "valueChange" }, ngImport: i0, template: "<div [@scaleUpDown]=\"activePickerIndex\">\r\n <ng-template [ngComponentOutletEx]=\"activePickerComponent\" (ngComponentOutletExCreated)=\"pickerCreated($event)\"></ng-template>\r\n</div>", directives: [{ type: i1.NgComponentOutletEx, selector: "[ngComponentOutletEx]", inputs: ["ngComponentOutletEx", "ngComponentOutletExInjector", "ngComponentOutletExContent"], outputs: ["ngComponentOutletExCreated"], exportAs: ["ngComponentOutletEx"] }], animations: [scaleUpDownTrigger], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
214
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: DateTimePickerComponent, decorators: [{
|
|
215
|
+
type: Component,
|
|
216
|
+
args: [{ selector: 'date-time-picker', animations: [scaleUpDownTrigger], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [@scaleUpDown]=\"activePickerIndex\">\r\n <ng-template [ngComponentOutletEx]=\"activePickerComponent\" (ngComponentOutletExCreated)=\"pickerCreated($event)\"></ng-template>\r\n</div>" }]
|
|
217
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
218
|
+
type: Optional
|
|
219
|
+
}, {
|
|
220
|
+
type: Inject,
|
|
221
|
+
args: [DATE_TIME_PICKER_CONFIGURATION]
|
|
222
|
+
}] }, { type: undefined, decorators: [{
|
|
223
|
+
type: Inject,
|
|
224
|
+
args: [DATE_API]
|
|
225
|
+
}] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
|
|
226
|
+
type: Input
|
|
227
|
+
}], value: [{
|
|
228
|
+
type: Input
|
|
229
|
+
}], minValue: [{
|
|
230
|
+
type: Input
|
|
231
|
+
}], maxValue: [{
|
|
232
|
+
type: Input
|
|
233
|
+
}], valueChange: [{
|
|
234
|
+
type: Output
|
|
235
|
+
}] } });
|
|
236
|
+
//# sourceMappingURL=picker.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker.component.js","sourceRoot":"","sources":["../../../../../src/picker/components/picker/picker.component.ts","../../../../../src/picker/components/picker/picker.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAgB,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAY,MAAM,eAAe,CAAC;AAC5J,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAC,8BAA8B,EAAC,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAC,0BAA0B,EAAC,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAC,4BAA4B,EAAC,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAC,2BAA2B,EAAC,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;;;AAEjE,sBAAsB;AAEtB;;GAEG;AACH,MAAM,oBAAoB,GAC1B;IACI,aAAa,EAAE,KAAK;IACpB,uBAAuB,EACvB;QACI,KAAK,EAAE,0BAA0B;QACjC,OAAO,EAAE,4BAA4B;QACrC,MAAM,EAAE,2BAA2B;KACtC;IACD,UAAU,EACV,EACC;CACJ,CAAC;AAEF;;GAEG;AASH,MAAM,OAAO,uBAAuB;IAwIhC,iEAAiE;IACjE,YAAgE,aAA2D,EACnF,QAAwB,EAC1C,eAAkC;QADhB,aAAQ,GAAR,QAAQ,CAAgB;QAC1C,oBAAe,GAAf,eAAe,CAAmB;QA7HxD;;WAEG;QACO,iBAAY,GAAa,EAAE,CAAC;QAEtC;;WAEG;QACO,W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;YACI,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;SACrG;IACL,CAAC;;oHA5RQ,uBAAuB,kBAyIA,8BAA8B,6BAC1C,QAAQ;wGA1InB,uBAAuB,6LC5CpC,gMAEM,2QDuCU,CAAC,kBAAkB,CAAC;2FAGvB,uBAAuB;kBARnC,SAAS;+BAEI,kBAAkB,cAGhB,CAAC,kBAAkB,CAAC,mBACf,uBAAuB,CAAC,MAAM;;0BA2IlC,QAAQ;;0BAAI,MAAM;2BAAC,8BAA8B;;0BACjD,MAAM;2BAAC,QAAQ;4EArEjB,OAAO;sBADjB,KAAK;gBAoBK,KAAK;sBADf,KAAK;gBAiBK,QAAQ;sBADlB,KAAK;gBAeK,QAAQ;sBADlB,KAAK;gBAiBC,WAAW;sBADjB,MAAM","sourcesContent":["import {Component, ChangeDetectionStrategy, Optional, Inject, Input, Type, OnInit, EventEmitter, Output, ChangeDetectorRef, OnDestroy} from '@angular/core';\nimport {extend} from '@jscrpt/common';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeValue} from '../../../misc/datetime.interface';\nimport {DATE_API} from '../../../misc/tokens';\nimport {DateApi} from '../../../services';\nimport {DateTimePicker, DateTimePickerOptions} from '../../misc/datetimePicker.interface';\nimport {DATE_TIME_PICKER_CONFIGURATION} from '../../misc/tokens';\nimport {DateTimeDayPickerComponent} from '../dayPicker/dayPicker.component';\nimport {DateTimeMonthPickerComponent} from '../monthPicker/monthPicker.component';\nimport {DateTimeYearPickerComponent} from '../yearPicker/yearPicker.component';\nimport {scaleUpDownTrigger} from './picker.component.animations';\n\n//TODO - merge options\n\n/**\n * Default configuration for picker\n */\nconst defaultConfiguration: DateTimePickerOptions<DateTimePicker> =\n{\n defaultPeriod: 'day',\n pickerPeriodsDefinition:\n {\n 'day': DateTimeDayPickerComponent,\n 'month': DateTimeMonthPickerComponent,\n 'year': DateTimeYearPickerComponent\n },\n cssClasses:\n {\n }\n};\n\n/**\n * Component used for displaying date time picker\n */\n@Component(\n{\n selector: 'date-time-picker',\n templateUrl: 'picker.component.html',\n // styleUrls: ['picker.component.scss'],\n animations: [scaleUpDownTrigger],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class DateTimePickerComponent<TDate = any> implements OnInit, OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Instance of active date time picker\n */\n protected _activePicker?: DateTimePicker<TDate>;\n\n /**\n * Name, id of displayed picker\n */\n protected _activePickerName!: string;\n\n /**\n * Array of available picker names\n */\n protected _pickerNames: string[] = [];\n\n /**\n * Current selected value\n */\n protected _value: DateTimeValue<TDate>|null = null;\n\n /**\n * All subscriptions for active picker\n */\n protected _activePickerSubscriptions: Subscription = new Subscription();\n\n /**\n * Date that should be displayed in picker, used when moving up or down in periods\n */\n protected _display?: TDate;\n\n /**\n * Minimal possible value that can be picked\n */\n protected _minValue: TDate|null = null;\n\n /**\n * Maximal possible value that can be picked\n */\n protected _maxValue: TDate|null = null;\n\n /**\n * Current options used by picker\n */\n protected _options: DateTimePickerOptions<DateTimePicker<TDate>>;\n\n //######################### public properties - template bindings #########################\n\n /**\n * Currently active date time picker component type\n * @internal\n */\n public activePickerComponent?: Type<DateTimePicker<TDate>>;\n\n /**\n * Active picker index\n * @internal\n */\n public activePickerIndex: number = 0;\n\n //######################### public properties - inputs #########################\n\n /**\n * Current options used by picker\n */\n @Input()\n public get options(): DateTimePickerOptions<DateTimePicker<TDate>>\n {\n return this._options;\n }\n public set options(value: DateTimePickerOptions<DateTimePicker<TDate>>)\n {\n this._options = extend(true, this._options, value);\n\n // without deep-copy for this attribute\n if (value?.pickerPeriodsDefinition)\n {\n this._options.pickerPeriodsDefinition = value.pickerPeriodsDefinition;\n }\n }\n\n /**\n * Current selected value\n */\n @Input()\n public get value(): DateTimeValue<TDate>|null\n {\n return this._value;\n }\n public set value(value: DateTimeValue<TDate>|null)\n {\n this._value = value;\n\n this._activePicker?.setValue(value);\n this._activePicker?.invalidateVisuals();\n }\n\n /**\n * Gets or sets minimal possible value for picker, that can be picked\n */\n @Input()\n public get minValue(): TDate|null\n {\n return this._minValue;\n }\n public set minValue(value: TDate|null)\n {\n this._minValue = value;\n this._activePicker?.setMinValue(this._minValue);\n }\n\n /**\n * Gets or sets maximal possible value for picker, that can be picked\n */\n @Input()\n public get maxValue(): TDate|null\n {\n return this._maxValue;\n }\n public set maxValue(value: TDate|null)\n {\n this._maxValue = value;\n this._activePicker?.setMaxValue(this._maxValue);\n }\n\n //######################### public properties - outputs #########################\n\n /**\n * Occurs when value changes\n */\n @Output()\n public valueChange: EventEmitter<DateTimeValue<TDate>> = new EventEmitter<DateTimeValue<TDate>>();\n\n //######################### constructor #########################\n constructor(@Optional() @Inject(DATE_TIME_PICKER_CONFIGURATION) configuration: DateTimePickerOptions<DateTimePicker<TDate>>,\n @Inject(DATE_API) protected _dateApi: DateApi<TDate>,\n protected _changeDetector: ChangeDetectorRef)\n {\n this._options = extend(true, {}, defaultConfiguration, configuration);\n // without deep-copy for this attribute\n if (configuration?.pickerPeriodsDefinition)\n {\n this._options.pickerPeriodsDefinition = configuration.pickerPeriodsDefinition;\n }\n }\n\n //######################### public methods - implementation of OnInit #########################\n\n /**\n * Initialize component\n */\n public ngOnInit()\n {\n if (this._options.pickerPeriodsOrder)\n {\n if (Array.isArray(this._options.pickerPeriodsOrder))\n {\n this._pickerNames = this._options.pickerPeriodsOrder;\n }\n else\n {\n this._pickerNames = this._options.pickerPeriodsOrder.split(',')\n .map(x => x.trim())\n .filter(x => x);\n }\n }\n if (this._pickerNames && this._pickerNames.length > 0)\n {\n this._pickerNames.forEach(x => \n {\n if(!this._options.pickerPeriodsDefinition![x!])\n {\n throw new Error(`There is no period '${x}' in picker options`);\n }\n });\n }\n else\n {\n this._pickerNames = Object.keys(this._options.pickerPeriodsDefinition!);\n }\n\n if(this._pickerNames.findIndex(x => x == this._options.defaultPeriod) < 0)\n {\n throw new Error(`There is no period '${this._options.defaultPeriod}' in picker options`);\n }\n\n this.activePickerComponent = this._options.pickerPeriodsDefinition![this._options.defaultPeriod!];\n this._activePickerName = this._options.defaultPeriod!;\n this.activePickerIndex = this._pickerNames.indexOf(this._activePickerName);\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n\n /**\n * Called when component is destroyed\n */\n public ngOnDestroy()\n {\n this._display = undefined;\n this._activePickerSubscriptions.unsubscribe();\n }\n\n //######################### public methods - template bindings #########################\n\n /**\n * Handles created or destroyed date time picker instance\n * @param picker - Instance of picker or null\n * @internal\n */\n public pickerCreated(picker: DateTimePicker<TDate>)\n {\n if(picker == this._activePicker)\n {\n return;\n }\n\n this._activePicker = picker;\n\n this._activePickerSubscriptions.unsubscribe();\n this._activePickerSubscriptions = new Subscription();\n\n if(!this._activePicker)\n {\n return;\n }\n\n this._activePickerSubscriptions.add(picker.valueChange.subscribe(() =>\n {\n this._value = picker.value;\n this.valueChange.emit(this._value!);\n }));\n\n this._activePickerSubscriptions.add(picker.scaleUp.subscribe(display =>\n {\n this._display = display;\n const index = this._pickerNames.indexOf(this._activePickerName) + 1;\n this._activePickerName = this._pickerNames[index];\n this.activePickerIndex = this._pickerNames.indexOf(this._activePickerName);\n this.activePickerComponent = this._options.pickerPeriodsDefinition![this._activePickerName];\n }));\n\n this._activePickerSubscriptions.add(picker.scaleDown.subscribe(display =>\n {\n this._display = display;\n const index = this._pickerNames.indexOf(this._activePickerName) - 1;\n this._activePickerName = this._pickerNames[index];\n this.activePickerIndex = this._pickerNames.indexOf(this._activePickerName);\n this.activePickerComponent = this._options.pickerPeriodsDefinition![this._activePickerName];\n }));\n\n picker.setCanGoDown(this._pickerNames.indexOf(this._activePickerName) > 0);\n picker.setCanGoUp(this._pickerNames.indexOf(this._activePickerName) < this._pickerNames.length - 1);\n\n this._setPickerCssClasses();\n picker.setValue(this._value);\n picker.setMinValue(this._minValue);\n picker.setMaxValue(this._maxValue);\n picker.display(this._display ? this._dateApi.getValue(this._display) : this._dateApi.getValue(this._value?.from ?? this._dateApi.now().value));\n\n picker.invalidateVisuals();\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets picker css classes\n */\n protected _setPickerCssClasses()\n {\n if(!this._activePicker)\n {\n return;\n }\n\n //sets shared css\n this._activePicker.setCssClasses(this._options?.cssClasses?.pickerShared ?? {});\n\n if(this._options?.cssClasses?.pickerCustom && this._options?.cssClasses?.pickerCustom[this._activePickerName])\n {\n this._activePicker.setCssClasses(this._options?.cssClasses?.pickerCustom[this._activePickerName]);\n }\n }\n}\n","<div [@scaleUpDown]=\"activePickerIndex\">\r\n <ng-template [ngComponentOutletEx]=\"activePickerComponent\" (ngComponentOutletExCreated)=\"pickerCreated($event)\"></ng-template>\r\n</div>"]}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Directive, HostListener, Inject } from '@angular/core';
|
|
2
|
+
import { extend } from '@jscrpt/common';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { DATE_API } from '../../misc/tokens';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* Base class used as base for picker
|
|
8
|
+
*/
|
|
9
|
+
export class PickerBaseComponent {
|
|
10
|
+
//######################### constructor #########################
|
|
11
|
+
constructor(_dateApi, _changeDetector) {
|
|
12
|
+
this._dateApi = _dateApi;
|
|
13
|
+
this._changeDetector = _changeDetector;
|
|
14
|
+
//######################### protected fields #########################
|
|
15
|
+
/**
|
|
16
|
+
* Current value of datetime
|
|
17
|
+
*/
|
|
18
|
+
this._value = null;
|
|
19
|
+
/**
|
|
20
|
+
* Occurs when value changes
|
|
21
|
+
*/
|
|
22
|
+
this._valueChange = new Subject();
|
|
23
|
+
/**
|
|
24
|
+
* Occurs when user scales up
|
|
25
|
+
*/
|
|
26
|
+
this._scaleUp = new Subject();
|
|
27
|
+
/**
|
|
28
|
+
* Occurs when user scales down
|
|
29
|
+
*/
|
|
30
|
+
this._scaleDown = new Subject();
|
|
31
|
+
/**
|
|
32
|
+
* Minimal possible value that can be picked
|
|
33
|
+
*/
|
|
34
|
+
this._minValue = null;
|
|
35
|
+
/**
|
|
36
|
+
* Maximal possible value that can be picked
|
|
37
|
+
*/
|
|
38
|
+
this._maxValue = null;
|
|
39
|
+
//######################### public properties - template bindings #########################
|
|
40
|
+
/**
|
|
41
|
+
* Date api instance for displayed date
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
this.displayDate = null;
|
|
45
|
+
/**
|
|
46
|
+
* Indication whether can go up in period
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
this.canGoUp = false;
|
|
50
|
+
/**
|
|
51
|
+
* Indication whether can go down in period
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
this.canGoDown = false;
|
|
55
|
+
/**
|
|
56
|
+
* Array of period data to be displayed
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
this.periodData = [];
|
|
60
|
+
}
|
|
61
|
+
//######################### public properties - implementation of DateTimePicker #########################
|
|
62
|
+
/**
|
|
63
|
+
* Gets current value of datetime
|
|
64
|
+
*/
|
|
65
|
+
get value() {
|
|
66
|
+
return this._value;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Occurs when value changes
|
|
70
|
+
*/
|
|
71
|
+
get valueChange() {
|
|
72
|
+
return this._valueChange.asObservable();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Occurs when user scales up
|
|
76
|
+
*/
|
|
77
|
+
get scaleUp() {
|
|
78
|
+
return this._scaleUp.asObservable();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Occurs when user scales down
|
|
82
|
+
*/
|
|
83
|
+
get scaleDown() {
|
|
84
|
+
return this._scaleDown.asObservable();
|
|
85
|
+
}
|
|
86
|
+
//######################### public methods - template bindings #########################
|
|
87
|
+
/**
|
|
88
|
+
* Changes displayed period to "higher" period
|
|
89
|
+
* @param event - Event that occured
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
goUp(event) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
if (!this.canGoUp) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this._scaleUp.next(this.displayDate.value);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Selects period
|
|
101
|
+
* @param event - Event that occured
|
|
102
|
+
* @param period - Selected period
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
select(event, period) {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
if (period.disabled) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
//handle selection of value
|
|
111
|
+
if (!this.canGoDown) {
|
|
112
|
+
this._setPeriod(period);
|
|
113
|
+
this._value =
|
|
114
|
+
{
|
|
115
|
+
from: period.date,
|
|
116
|
+
to: this._endOfPeriod(period)
|
|
117
|
+
};
|
|
118
|
+
this._valueChange.next();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this._scaleDown.next(period.date);
|
|
122
|
+
}
|
|
123
|
+
//######################### public methods - implementation of DateTimePicker #########################
|
|
124
|
+
/**
|
|
125
|
+
* Sets css classes for picker, allowing to override defaults
|
|
126
|
+
* @param cssClasses - Css classes to be set for picker
|
|
127
|
+
*/
|
|
128
|
+
setCssClasses(cssClasses) {
|
|
129
|
+
this.cssClasses = extend(true, {}, this.cssClasses, cssClasses);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Sets minimal possible value for picker, that can be picked
|
|
133
|
+
* @param value - Minimal possible value that can be picked
|
|
134
|
+
*/
|
|
135
|
+
setMinValue(value) {
|
|
136
|
+
this._minValue = value;
|
|
137
|
+
this._updateMinMax();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Sets maximal possible value for picker, that can be picked
|
|
141
|
+
* @param value - Maximal possible value that can be picked
|
|
142
|
+
*/
|
|
143
|
+
setMaxValue(value) {
|
|
144
|
+
this._maxValue = value;
|
|
145
|
+
this._updateMinMax();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Sets value of datetime picker
|
|
149
|
+
* @param value - Value to be set to this picker
|
|
150
|
+
*/
|
|
151
|
+
setValue(value) {
|
|
152
|
+
this._value = value;
|
|
153
|
+
//value is present
|
|
154
|
+
if (this._value && this.displayDate) {
|
|
155
|
+
const val = this._dateApi.getValue(this._value.from);
|
|
156
|
+
//change picker to value
|
|
157
|
+
if (!this._isSamePeriodAsDisplayed(val)) {
|
|
158
|
+
this.display(val);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const period = this._getPeriodData(val);
|
|
162
|
+
//was initialized
|
|
163
|
+
if (period) {
|
|
164
|
+
this._setPeriod(period);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Sets indication whether can go down
|
|
170
|
+
* @param value - Indication whether can go down in period
|
|
171
|
+
*/
|
|
172
|
+
setCanGoDown(value) {
|
|
173
|
+
this.canGoDown = value;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Sets indication whether can go up
|
|
177
|
+
* @param value - Indication whether can go up in period
|
|
178
|
+
*/
|
|
179
|
+
setCanGoUp(value) {
|
|
180
|
+
this.canGoUp = value;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Explicitly runs invalidation of content (change detection)
|
|
184
|
+
*/
|
|
185
|
+
invalidateVisuals() {
|
|
186
|
+
this._changeDetector.detectChanges();
|
|
187
|
+
}
|
|
188
|
+
//######################### public methods - host #########################
|
|
189
|
+
/**
|
|
190
|
+
* Handles click anyway in picker, that blocks blur
|
|
191
|
+
* @param event - Event that occured
|
|
192
|
+
* @internal
|
|
193
|
+
*/
|
|
194
|
+
handleClick(event) {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
}
|
|
197
|
+
//######################### protected methods #########################
|
|
198
|
+
/**
|
|
199
|
+
* Sets period as active
|
|
200
|
+
* @param period - Period to be set as active
|
|
201
|
+
*/
|
|
202
|
+
_setPeriod(period) {
|
|
203
|
+
this.periodData.forEach(itm => itm.active = false);
|
|
204
|
+
period.active = true;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Updates minimal and maximal value for picker
|
|
208
|
+
*/
|
|
209
|
+
_updateMinMax() {
|
|
210
|
+
if (!this.periodData.length) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
//no min, no max
|
|
214
|
+
if (!this._minValue && !this._maxValue) {
|
|
215
|
+
this.periodData.forEach(itm => itm.disabled = false);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const minDateApi = this._minValue ? this._dateApi.getValue(this._minValue) : null;
|
|
219
|
+
const maxDateApi = this._maxValue ? this._dateApi.getValue(this._maxValue) : null;
|
|
220
|
+
let restAfter = false;
|
|
221
|
+
this.periodData.forEach(period => {
|
|
222
|
+
if (!!minDateApi && minDateApi.isAfter(period.date) && !this._isSamePeriod(minDateApi, period.date)) {
|
|
223
|
+
period.disabled = true;
|
|
224
|
+
}
|
|
225
|
+
if (restAfter || (!!maxDateApi && maxDateApi.isBefore(period.date) && !this._isSamePeriod(maxDateApi, period.date))) {
|
|
226
|
+
restAfter = true;
|
|
227
|
+
period.disabled = true;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
PickerBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: PickerBaseComponent, deps: [{ token: DATE_API }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
233
|
+
PickerBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: PickerBaseComponent, host: { listeners: { "mousedown": "handleClick($event)" } }, ngImport: i0 });
|
|
234
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: PickerBaseComponent, decorators: [{
|
|
235
|
+
type: Directive
|
|
236
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
237
|
+
type: Inject,
|
|
238
|
+
args: [DATE_API]
|
|
239
|
+
}] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { handleClick: [{
|
|
240
|
+
type: HostListener,
|
|
241
|
+
args: ['mousedown', ['$event']]
|
|
242
|
+
}] } });
|
|
243
|
+
//# sourceMappingURL=pickerBase.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickerBase.component.js","sourceRoot":"","sources":["../../../../src/picker/components/pickerBase.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACjF,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAa,OAAO,EAAC,MAAM,MAAM,CAAC;AAGzC,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;;AAI3C;;GAEG;AAEH,MAAM,OAAgB,mBAAmB;IAoGrC,iEAAiE;IACjE,YAAwC,QAAwB,EAC1C,eAAkC;QADhB,aAAQ,GAAR,QAAQ,CAAgB;QAC1C,oBAAe,GAAf,eAAe,CAAmB;QApGxD,sEAAsE;QAEtE;;WAEG;QACO,WAAM,GAA8B,IAAI,CAAC;QAEnD;;WAEG;QACO,iBAAY,GAAkB,IAAI,OAAO,EAAQ,CAAC;QAE5D;;WAEG;QACO,aAAQ,GAAmB,IAAI,OAAO,EAAS,CAAC;QAE1D;;WAEG;QACO,eAAU,GAAmB,IAAI,OAAO,EAAS,CAAC;QAE5D;;WAEG;QACO,cAAS,GAAe,IAAI,CAAC;QAEvC;;WAEG;QACO,cAAS,GAAe,IAAI,CAAC;QAoCvC,2FAA2F;QAE3F;;;WAGG;QACI,gBAAW,GAA8B,IAAI,CAAC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AI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,EAClG;gBACI,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;aAC1B;YAED,IAAG,SAAS,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,EAClH;gBACI,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;aAC1B;QACL,CAAC,CAAC,CAAC;IACP,CAAC;;gHA1TiB,mBAAmB,kBAqGjB,QAAQ;oGArGV,mBAAmB;2FAAnB,mBAAmB;kBADxC,SAAS;;0BAsGO,MAAM;2BAAC,QAAQ;4EAgKrB,WAAW;sBADjB,YAAY;uBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["import {ChangeDetectorRef, Directive, HostListener, Inject} from '@angular/core';\nimport {extend} from '@jscrpt/common';\nimport {Observable, Subject} from 'rxjs';\n\nimport {DateTimeValue} from '../../misc/datetime.interface';\nimport {DATE_API} from '../../misc/tokens';\nimport {DateApi, DateApiObject} from '../../services/dateApi.interface';\nimport {DateTimePicker, PeriodData} from '../misc/datetimePicker.interface';\n\n/**\n * Base class used as base for picker\n */\n@Directive()\nexport abstract class PickerBaseComponent<TDate = any, TDateData extends PeriodData<TDate> = any, TCssClasses = object> implements DateTimePicker<TDate, TCssClasses>\n{\n //######################### protected fields #########################\n\n /**\n * Current value of datetime\n */\n protected _value: DateTimeValue<TDate>|null = null;\n\n /**\n * Occurs when value changes\n */\n protected _valueChange: Subject<void> = new Subject<void>();\n \n /**\n * Occurs when user scales up\n */\n protected _scaleUp: Subject<TDate> = new Subject<TDate>();\n\n /**\n * Occurs when user scales down\n */\n protected _scaleDown: Subject<TDate> = new Subject<TDate>();\n\n /**\n * Minimal possible value that can be picked\n */\n protected _minValue: TDate|null = null;\n\n /**\n * Maximal possible value that can be picked\n */\n protected _maxValue: TDate|null = null;\n\n //######################### public properties - implementation of DateTimePicker #########################\n\n /**\n * Gets current value of datetime\n */\n public get value(): DateTimeValue<TDate>|null\n {\n return this._value;\n }\n\n /**\n * Occurs when value changes\n */\n public get valueChange(): Observable<void>\n {\n return this._valueChange.asObservable();\n }\n\n /**\n * Occurs when user scales up\n */\n public get scaleUp(): Observable<TDate>\n {\n return this._scaleUp.asObservable();\n }\n\n /**\n * Occurs when user scales down\n */\n public get scaleDown(): Observable<TDate>\n {\n return this._scaleDown.asObservable();\n }\n\n //######################### public properties - template bindings #########################\n\n /**\n * Date api instance for displayed date\n * @internal\n */\n public displayDate: DateApiObject<TDate>|null = null;\n\n /**\n * Indication whether can go up in period\n * @internal\n */\n public canGoUp: boolean = false;\n\n /**\n * Indication whether can go down in period\n * @internal\n */\n public canGoDown: boolean = false;\n\n /**\n * Array of period data to be displayed\n * @internal\n */\n public periodData: TDateData[] = [];\n\n /**\n * Css classes that are used within picker\n * @internal\n */\n public cssClasses!: TCssClasses;\n\n //######################### constructor #########################\n constructor(@Inject(DATE_API) protected _dateApi: DateApi<TDate>,\n protected _changeDetector: ChangeDetectorRef)\n {\n }\n\n //######################### public methods - template bindings #########################\n\n /**\n * Changes displayed period to \"higher\" period\n * @param event - Event that occured\n * @internal\n */\n public goUp(event: Event)\n {\n event.preventDefault();\n\n if(!this.canGoUp)\n {\n return;\n }\n\n this._scaleUp.next(this.displayDate!.value);\n }\n\n /**\n * Selects period\n * @param event - Event that occured\n * @param period - Selected period\n * @internal\n */\n public select(event: Event, period: PeriodData<TDate>)\n {\n event.preventDefault();\n\n if(period.disabled)\n {\n return;\n }\n\n //handle selection of value\n if(!this.canGoDown)\n {\n this._setPeriod(period);\n\n this._value =\n {\n from: period.date,\n to: this._endOfPeriod(period)\n };\n\n this._valueChange.next();\n\n return;\n }\n\n this._scaleDown.next(period.date);\n }\n\n //######################### public methods - implementation of DateTimePicker #########################\n\n /**\n * Sets css classes for picker, allowing to override defaults\n * @param cssClasses - Css classes to be set for picker\n */\n public setCssClasses(cssClasses: TCssClasses): void\n {\n this.cssClasses = extend(true, {}, this.cssClasses, cssClasses);\n }\n\n /**\n * Sets minimal possible value for picker, that can be picked\n * @param value - Minimal possible value that can be picked\n */\n public setMinValue(value: TDate|null): void\n {\n this._minValue = value;\n this._updateMinMax();\n }\n\n /**\n * Sets maximal possible value for picker, that can be picked\n * @param value - Maximal possible value that can be picked\n */\n public setMaxValue(value: TDate|null): void\n {\n this._maxValue = value;\n this._updateMinMax();\n }\n\n /**\n * Sets value of datetime picker\n * @param value - Value to be set to this picker\n */\n public setValue(value: DateTimeValue<TDate>|null): void\n {\n this._value = value;\n\n //value is present\n if(this._value && this.displayDate)\n {\n const val = this._dateApi.getValue(this._value.from);\n\n //change picker to value\n if(!this._isSamePeriodAsDisplayed(val))\n {\n this.display(val);\n\n return;\n }\n\n const period = this._getPeriodData(val);\n\n //was initialized\n if(period)\n {\n this._setPeriod(period);\n }\n }\n }\n\n /**\n * Set displays date to be displayed\n * @param value - Value that identifies period that is going to be displayed\n */\n public abstract display(value: DateApiObject<TDate>): void;\n\n /**\n * Sets indication whether can go down\n * @param value - Indication whether can go down in period\n */\n public setCanGoDown(value: boolean): void\n {\n this.canGoDown = value;\n }\n\n /**\n * Sets indication whether can go up\n * @param value - Indication whether can go up in period\n */\n public setCanGoUp(value: boolean): void\n {\n this.canGoUp = value;\n }\n\n /**\n * Explicitly runs invalidation of content (change detection)\n */\n public invalidateVisuals(): void\n {\n this._changeDetector.detectChanges();\n }\n\n //######################### public methods - host #########################\n\n /**\n * Handles click anyway in picker, that blocks blur\n * @param event - Event that occured\n * @internal\n */\n @HostListener('mousedown', ['$event'])\n public handleClick(event: Event)\n {\n event.preventDefault();\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets period as active\n * @param period - Period to be set as active\n */\n protected _setPeriod(period: PeriodData<TDate>)\n {\n this.periodData.forEach(itm => itm.active = false);\n\n period.active = true;\n }\n\n /**\n * Updates minimal and maximal value for picker\n */\n protected _updateMinMax()\n {\n if(!this.periodData.length)\n {\n return;\n }\n\n //no min, no max\n if(!this._minValue && !this._maxValue)\n {\n this.periodData.forEach(itm => itm.disabled = false);\n\n return;\n }\n\n const minDateApi = this._minValue ? this._dateApi.getValue(this._minValue) : null;\n const maxDateApi = this._maxValue ? this._dateApi.getValue(this._maxValue) : null;\n let restAfter = false;\n\n this.periodData.forEach(period =>\n {\n if(!!minDateApi && minDateApi.isAfter(period.date) && !this._isSamePeriod(minDateApi, period.date))\n {\n period.disabled = true;\n }\n\n if(restAfter || (!!maxDateApi && maxDateApi.isBefore(period.date) && !this._isSamePeriod(maxDateApi, period.date)))\n {\n restAfter = true;\n period.disabled = true;\n }\n });\n }\n\n /**\n * Obtains end of period\n * @param period - Period for which should be end obtained\n */\n protected abstract _endOfPeriod(period: PeriodData<TDate>): TDate;\n\n /**\n * Tests whether provided value is in same period as displayed picker\n * @param val - Tested value for same period as displayed picker\n */\n protected abstract _isSamePeriodAsDisplayed(val: DateApiObject<TDate>): boolean;\n\n /**\n * Tests whether provided value is in same period target value\n * @param val - Tested value\n * @param target - Target value to be tested against\n */\n protected abstract _isSamePeriod(val: DateApiObject<TDate>, target: TDate): boolean;\n\n /**\n * Gets period data for specified value\n * @param val - Value for which is period data obtained\n */\n protected abstract _getPeriodData(val: DateApiObject<TDate>): PeriodData<TDate>;\n}"]}
|