@anglr/datetime 2.0.1 → 3.0.0-beta.20220322070853
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 +86 -0
- package/date-fns/src/misc/tokens.d.ts.map +1 -1
- package/date-fns/src/services/dateFnsDateApi.service.d.ts.map +1 -1
- package/es2015/date-fns/src/misc/tokens.js +12 -1
- package/es2015/date-fns/src/misc/tokens.js.map +1 -1
- package/es2015/date-fns/src/services/dateFnsDateApi.service.js +99 -5
- package/es2015/date-fns/src/services/dateFnsDateApi.service.js.map +1 -1
- package/es2015/moment/src/misc/tokens.js +12 -1
- package/es2015/moment/src/misc/tokens.js.map +1 -1
- package/es2015/moment/src/services/momentDateApi.service.js +90 -0
- package/es2015/moment/src/services/momentDateApi.service.js.map +1 -1
- package/es2015/src/misc/datetime.interface.js.map +1 -1
- package/es2015/src/misc/tokens.js +12 -1
- package/es2015/src/misc/tokens.js.map +1 -1
- package/es2015/src/modules/datePipes.module.js +2 -7
- package/es2015/src/modules/datePipes.module.js.map +1 -1
- package/es2015/src/picker/components/clockTimePicker/clockTimePicker.component.js +14 -0
- package/es2015/src/picker/components/clockTimePicker/clockTimePicker.component.js.map +1 -0
- package/es2015/src/picker/components/clockTimePicker/clockTimePicker.interface.js +2 -0
- package/es2015/src/picker/components/clockTimePicker/clockTimePicker.interface.js.map +1 -0
- package/es2015/src/picker/components/dayPicker/dayPicker.component.js +49 -13
- package/es2015/src/picker/components/dayPicker/dayPicker.component.js.map +1 -1
- package/es2015/src/picker/components/monthPicker/monthPicker.component.js +5 -4
- package/es2015/src/picker/components/monthPicker/monthPicker.component.js.map +1 -1
- package/es2015/src/picker/components/picker/picker.component.js +3 -2
- package/es2015/src/picker/components/picker/picker.component.js.map +1 -1
- package/es2015/src/picker/components/pickerBase.component.js +15 -120
- package/es2015/src/picker/components/pickerBase.component.js.map +1 -1
- package/es2015/src/picker/components/pickerImplBase.component.js +145 -0
- package/es2015/src/picker/components/pickerImplBase.component.js.map +1 -0
- package/es2015/src/picker/components/rollerTimePicker/rollerTimePicker.component.js +144 -0
- package/es2015/src/picker/components/rollerTimePicker/rollerTimePicker.component.js.map +1 -0
- package/es2015/src/picker/components/rollerTimePicker/rollerTimePicker.data.js +341 -0
- package/es2015/src/picker/components/rollerTimePicker/rollerTimePicker.data.js.map +1 -0
- package/es2015/src/picker/components/rollerTimePicker/rollerTimePicker.interface.js +2 -0
- package/es2015/src/picker/components/rollerTimePicker/rollerTimePicker.interface.js.map +1 -0
- package/es2015/src/picker/components/yearPicker/yearPicker.component.js +5 -4
- package/es2015/src/picker/components/yearPicker/yearPicker.component.js.map +1 -1
- package/es2015/src/picker/directives/index.js +4 -0
- package/es2015/src/picker/directives/index.js.map +1 -0
- package/es2015/src/picker/directives/loopScroll/loopScroll.directive.js +200 -0
- package/es2015/src/picker/directives/loopScroll/loopScroll.directive.js.map +1 -0
- package/es2015/src/picker/directives/loopScroll/loopScroll.interface.js +3 -0
- package/es2015/src/picker/directives/loopScroll/loopScroll.interface.js.map +1 -0
- package/es2015/src/picker/directives/loopScrollData/loopScrollData.directive.js +23 -0
- package/es2015/src/picker/directives/loopScrollData/loopScrollData.directive.js.map +1 -0
- package/es2015/src/picker/misc/datetimePicker.interface.js.map +1 -1
- package/es2015/src/picker/modules/picker.module.js +21 -4
- package/es2015/src/picker/modules/picker.module.js.map +1 -1
- package/es2015/src/selector/components/inputDateTime/inputDateTime.component.js +16 -2
- package/es2015/src/selector/components/inputDateTime/inputDateTime.component.js.map +1 -1
- package/es2015/src/selector/components/selector/selector.component.js +25 -12
- package/es2015/src/selector/components/selector/selector.component.js.map +1 -1
- package/es2015/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +6 -2
- package/es2015/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +1 -1
- package/es2015/src/selector/directives/dateTimePickerRenderer/dateTimePickerRenderer.directive.js +134 -0
- package/es2015/src/selector/directives/dateTimePickerRenderer/dateTimePickerRenderer.directive.js.map +1 -0
- package/es2015/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.js.map +1 -1
- package/es2015/src/selector/misc/datetimeSelector.interface.js.map +1 -1
- package/es2015/src/selector/misc/tokens.js.map +1 -1
- package/es2015/src/selector/modules/selector.module.js +9 -4
- package/es2015/src/selector/modules/selector.module.js.map +1 -1
- package/es2015/src/services/dateApi.interface.js.map +1 -1
- package/es2015/src/services/datePositionParser.service.js +14 -0
- package/es2015/src/services/datePositionParser.service.js.map +1 -1
- package/es2015/src/services/dateTimeRelativeParser.service.js +15 -1
- package/es2015/src/services/dateTimeRelativeParser.service.js.map +1 -1
- package/es2015/src/services/dateValueProvider.service.js +10 -5
- package/es2015/src/services/dateValueProvider.service.js.map +1 -1
- package/es2015/src/services/formatProvider.interface.js.map +1 -1
- package/es2020/date-fns/src/misc/tokens.js +12 -1
- package/es2020/date-fns/src/misc/tokens.js.map +1 -1
- package/es2020/date-fns/src/services/dateFnsDateApi.service.js +99 -5
- package/es2020/date-fns/src/services/dateFnsDateApi.service.js.map +1 -1
- package/es2020/moment/src/misc/tokens.js +12 -1
- package/es2020/moment/src/misc/tokens.js.map +1 -1
- package/es2020/moment/src/services/momentDateApi.service.js +90 -0
- package/es2020/moment/src/services/momentDateApi.service.js.map +1 -1
- package/es2020/src/misc/datetime.interface.js.map +1 -1
- package/es2020/src/misc/tokens.js +12 -1
- package/es2020/src/misc/tokens.js.map +1 -1
- package/es2020/src/modules/datePipes.module.js +2 -7
- package/es2020/src/modules/datePipes.module.js.map +1 -1
- package/es2020/src/picker/components/clockTimePicker/clockTimePicker.component.js +14 -0
- package/es2020/src/picker/components/clockTimePicker/clockTimePicker.component.js.map +1 -0
- package/es2020/src/picker/components/clockTimePicker/clockTimePicker.interface.js +2 -0
- package/es2020/src/picker/components/clockTimePicker/clockTimePicker.interface.js.map +1 -0
- package/es2020/src/picker/components/dayPicker/dayPicker.component.js +49 -13
- package/es2020/src/picker/components/dayPicker/dayPicker.component.js.map +1 -1
- package/es2020/src/picker/components/monthPicker/monthPicker.component.js +5 -4
- package/es2020/src/picker/components/monthPicker/monthPicker.component.js.map +1 -1
- package/es2020/src/picker/components/picker/picker.component.js +3 -2
- package/es2020/src/picker/components/picker/picker.component.js.map +1 -1
- package/es2020/src/picker/components/pickerBase.component.js +15 -120
- package/es2020/src/picker/components/pickerBase.component.js.map +1 -1
- package/es2020/src/picker/components/pickerImplBase.component.js +145 -0
- package/es2020/src/picker/components/pickerImplBase.component.js.map +1 -0
- package/es2020/src/picker/components/rollerTimePicker/rollerTimePicker.component.js +138 -0
- package/es2020/src/picker/components/rollerTimePicker/rollerTimePicker.component.js.map +1 -0
- package/es2020/src/picker/components/rollerTimePicker/rollerTimePicker.data.js +341 -0
- package/es2020/src/picker/components/rollerTimePicker/rollerTimePicker.data.js.map +1 -0
- package/es2020/src/picker/components/rollerTimePicker/rollerTimePicker.interface.js +2 -0
- package/es2020/src/picker/components/rollerTimePicker/rollerTimePicker.interface.js.map +1 -0
- package/es2020/src/picker/components/yearPicker/yearPicker.component.js +5 -4
- package/es2020/src/picker/components/yearPicker/yearPicker.component.js.map +1 -1
- package/es2020/src/picker/directives/index.js +4 -0
- package/es2020/src/picker/directives/index.js.map +1 -0
- package/es2020/src/picker/directives/loopScroll/loopScroll.directive.js +191 -0
- package/es2020/src/picker/directives/loopScroll/loopScroll.directive.js.map +1 -0
- package/es2020/src/picker/directives/loopScroll/loopScroll.interface.js +3 -0
- package/es2020/src/picker/directives/loopScroll/loopScroll.interface.js.map +1 -0
- package/es2020/src/picker/directives/loopScrollData/loopScrollData.directive.js +23 -0
- package/es2020/src/picker/directives/loopScrollData/loopScrollData.directive.js.map +1 -0
- package/es2020/src/picker/misc/datetimePicker.interface.js.map +1 -1
- package/es2020/src/picker/modules/picker.module.js +21 -4
- package/es2020/src/picker/modules/picker.module.js.map +1 -1
- package/es2020/src/selector/components/inputDateTime/inputDateTime.component.js +16 -2
- package/es2020/src/selector/components/inputDateTime/inputDateTime.component.js.map +1 -1
- package/es2020/src/selector/components/selector/selector.component.js +22 -11
- package/es2020/src/selector/components/selector/selector.component.js.map +1 -1
- package/es2020/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +6 -2
- package/es2020/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +1 -1
- package/es2020/src/selector/directives/dateTimePickerRenderer/dateTimePickerRenderer.directive.js +133 -0
- package/es2020/src/selector/directives/dateTimePickerRenderer/dateTimePickerRenderer.directive.js.map +1 -0
- package/es2020/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.js.map +1 -1
- package/es2020/src/selector/misc/datetimeSelector.interface.js.map +1 -1
- package/es2020/src/selector/misc/tokens.js.map +1 -1
- package/es2020/src/selector/modules/selector.module.js +9 -4
- package/es2020/src/selector/modules/selector.module.js.map +1 -1
- package/es2020/src/services/dateApi.interface.js.map +1 -1
- package/es2020/src/services/datePositionParser.service.js +14 -0
- package/es2020/src/services/datePositionParser.service.js.map +1 -1
- package/es2020/src/services/dateTimeRelativeParser.service.js +15 -1
- package/es2020/src/services/dateTimeRelativeParser.service.js.map +1 -1
- package/es2020/src/services/dateValueProvider.service.js +10 -5
- package/es2020/src/services/dateValueProvider.service.js.map +1 -1
- package/es2020/src/services/formatProvider.interface.js.map +1 -1
- package/moment/src/misc/tokens.d.ts.map +1 -1
- package/moment/src/services/momentDateApi.service.d.ts.map +1 -1
- package/package.json +14 -16
- package/src/dark.scss +31 -28
- package/src/misc/datetime.interface.d.ts +1 -1
- package/src/misc/datetime.interface.d.ts.map +1 -1
- package/src/misc/tokens.d.ts.map +1 -1
- package/src/modules/datePipes.module.d.ts +3 -4
- package/src/modules/datePipes.module.d.ts.map +1 -1
- package/src/picker/components/clockTimePicker/clockTimePicker.component.css +0 -0
- package/src/picker/components/clockTimePicker/clockTimePicker.component.d.ts +9 -0
- package/src/picker/components/clockTimePicker/clockTimePicker.component.d.ts.map +1 -0
- package/src/picker/components/clockTimePicker/clockTimePicker.component.html +0 -0
- package/src/picker/components/clockTimePicker/clockTimePicker.interface.d.ts +6 -0
- package/src/picker/components/clockTimePicker/clockTimePicker.interface.d.ts.map +1 -0
- package/src/picker/components/dayPicker/dayPicker.component.d.ts +6 -0
- package/src/picker/components/dayPicker/dayPicker.component.d.ts.map +1 -1
- package/src/picker/components/dayPicker/dayPicker.component.html +11 -7
- 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/picker/picker.component.css +4 -0
- package/src/picker/components/picker/picker.component.d.ts +3 -3
- package/src/picker/components/picker/picker.component.d.ts.map +1 -1
- package/src/picker/components/pickerBase.component.d.ts +7 -97
- package/src/picker/components/pickerBase.component.d.ts.map +1 -1
- package/src/picker/components/pickerImplBase.component.d.ts +128 -0
- package/src/picker/components/pickerImplBase.component.d.ts.map +1 -0
- package/src/picker/components/rollerTimePicker/rollerTimePicker.component.css +40 -0
- package/src/picker/components/rollerTimePicker/rollerTimePicker.component.d.ts +71 -0
- package/src/picker/components/rollerTimePicker/rollerTimePicker.component.d.ts.map +1 -0
- package/src/picker/components/rollerTimePicker/rollerTimePicker.component.html +41 -0
- package/src/picker/components/rollerTimePicker/rollerTimePicker.data.d.ts +4 -0
- package/src/picker/components/rollerTimePicker/rollerTimePicker.data.d.ts.map +1 -0
- package/src/picker/components/rollerTimePicker/rollerTimePicker.interface.d.ts +6 -0
- package/src/picker/components/rollerTimePicker/rollerTimePicker.interface.d.ts.map +1 -0
- 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/directives/index.d.ts +4 -0
- package/src/picker/directives/index.d.ts.map +1 -0
- package/src/picker/directives/loopScroll/loopScroll.directive.d.ts +73 -0
- package/src/picker/directives/loopScroll/loopScroll.directive.d.ts.map +1 -0
- package/src/picker/directives/loopScroll/loopScroll.interface.d.ts +14 -0
- package/src/picker/directives/loopScroll/loopScroll.interface.d.ts.map +1 -0
- package/src/picker/directives/loopScrollData/loopScrollData.directive.d.ts +16 -0
- package/src/picker/directives/loopScrollData/loopScrollData.directive.d.ts.map +1 -0
- package/src/picker/misc/datetimePicker.interface.d.ts +14 -10
- package/src/picker/misc/datetimePicker.interface.d.ts.map +1 -1
- package/src/picker/modules/picker.module.d.ts +10 -7
- package/src/picker/modules/picker.module.d.ts.map +1 -1
- package/src/selector/components/inputDateTime/inputDateTime.component.d.ts +2 -2
- package/src/selector/components/inputDateTime/inputDateTime.component.d.ts.map +1 -1
- package/src/selector/components/inputDateTime/inputDateTime.component.html +1 -1
- package/src/selector/components/selector/selector.component.d.ts +7 -6
- package/src/selector/components/selector/selector.component.d.ts.map +1 -1
- package/src/selector/components/selector/selector.component.html +6 -5
- package/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts +1 -1
- package/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts.map +1 -1
- package/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.html +1 -1
- package/src/selector/directives/dateTimePickerRenderer/dateTimePickerRenderer.directive.d.ts +80 -0
- package/src/selector/directives/dateTimePickerRenderer/dateTimePickerRenderer.directive.d.ts.map +1 -0
- package/src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.d.ts.map +1 -1
- package/src/selector/misc/datetimeSelector.interface.d.ts +16 -3
- package/src/selector/misc/datetimeSelector.interface.d.ts.map +1 -1
- package/src/selector/misc/tokens.d.ts +1 -1
- package/src/selector/misc/tokens.d.ts.map +1 -1
- package/src/selector/modules/selector.module.d.ts +5 -4
- package/src/selector/modules/selector.module.d.ts.map +1 -1
- package/src/services/dateApi.interface.d.ts +72 -0
- package/src/services/dateApi.interface.d.ts.map +1 -1
- package/src/services/datePositionParser.service.d.ts +3 -3
- package/src/services/datePositionParser.service.d.ts.map +1 -1
- package/src/services/dateTimeRelativeParser.service.d.ts +8 -0
- package/src/services/dateTimeRelativeParser.service.d.ts.map +1 -1
- package/src/services/dateValueProvider.service.d.ts.map +1 -1
- package/src/services/formatProvider.interface.d.ts +48 -4
- package/src/services/formatProvider.interface.d.ts.map +1 -1
- package/version.bak +1 -1
- package/es2015/karma.conf.js +0 -57
- package/es2015/karma.conf.js.map +0 -1
- package/es2015/src/pipes/asRequiredType.js +0 -22
- package/es2015/src/pipes/asRequiredType.js.map +0 -1
- package/es2020/karma.conf.js +0 -57
- package/es2020/karma.conf.js.map +0 -1
- package/es2020/src/pipes/asRequiredType.js +0 -22
- package/es2020/src/pipes/asRequiredType.js.map +0 -1
- package/karma.conf.d.ts +0 -2
- package/karma.conf.d.ts.map +0 -1
- package/src/pipes/asRequiredType.d.ts +0 -21
- package/src/pipes/asRequiredType.d.ts.map +0 -1
- package/tsconfig.karma.json +0 -19
|
@@ -46,6 +46,10 @@ export class SimpleInputDateTimeSelectorComponent {
|
|
|
46
46
|
* Maximal possible value that can be picked
|
|
47
47
|
*/
|
|
48
48
|
this._maxValue = null;
|
|
49
|
+
/**
|
|
50
|
+
* Gets or sets placeholder that is displayed when there is no value selected
|
|
51
|
+
*/
|
|
52
|
+
this.placeholder = null;
|
|
49
53
|
//######################### public properties - template bindings #########################
|
|
50
54
|
/**
|
|
51
55
|
* Indication whether is input disabled
|
|
@@ -300,10 +304,10 @@ export class SimpleInputDateTimeSelectorComponent {
|
|
|
300
304
|
}
|
|
301
305
|
}
|
|
302
306
|
SimpleInputDateTimeSelectorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: SimpleInputDateTimeSelectorComponent, deps: [{ token: DATE_API }, { token: i1.DateValueProvider }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
303
|
-
SimpleInputDateTimeSelectorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: SimpleInputDateTimeSelectorComponent, selector: "simple-input-date-time-selector", viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["input"], descendants: true, static: true }], ngImport: i0, template: "<input type=\"text\"\r\n #input\r\n (focus)=\"handleFocus()\"\r\n (blur)=\"handleBlur()\"\r\n (input)=\"handleInput()\"\r\n (click)=\"handleClick()\"\r\n (keydown)=\"handleKeyboard($any($event))\"\r\n [disabled]=\"disabled\"\r\n [placeholder]=\"placeholder\">", styles: [":host\r\n{\r\n display: block;\r\n}\r\n\r\ninput\r\n{\r\n width: 100%;\r\n}"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
307
|
+
SimpleInputDateTimeSelectorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: SimpleInputDateTimeSelectorComponent, selector: "simple-input-date-time-selector", viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["input"], descendants: true, static: true }], ngImport: i0, template: "<input type=\"text\"\r\n #input\r\n (focus)=\"handleFocus()\"\r\n (blur)=\"handleBlur()\"\r\n (input)=\"handleInput()\"\r\n (click)=\"handleClick()\"\r\n (keydown)=\"handleKeyboard($any($event))\"\r\n [disabled]=\"disabled\"\r\n [placeholder]=\"placeholder ?? ''\">", styles: [":host\r\n{\r\n display: block;\r\n}\r\n\r\ninput\r\n{\r\n width: 100%;\r\n}"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
304
308
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: SimpleInputDateTimeSelectorComponent, decorators: [{
|
|
305
309
|
type: Component,
|
|
306
|
-
args: [{ selector: 'simple-input-date-time-selector', changeDetection: ChangeDetectionStrategy.OnPush, template: "<input type=\"text\"\r\n #input\r\n (focus)=\"handleFocus()\"\r\n (blur)=\"handleBlur()\"\r\n (input)=\"handleInput()\"\r\n (click)=\"handleClick()\"\r\n (keydown)=\"handleKeyboard($any($event))\"\r\n [disabled]=\"disabled\"\r\n [placeholder]=\"placeholder\">", styles: [":host\r\n{\r\n display: block;\r\n}\r\n\r\ninput\r\n{\r\n width: 100%;\r\n}"] }]
|
|
310
|
+
args: [{ selector: 'simple-input-date-time-selector', changeDetection: ChangeDetectionStrategy.OnPush, template: "<input type=\"text\"\r\n #input\r\n (focus)=\"handleFocus()\"\r\n (blur)=\"handleBlur()\"\r\n (input)=\"handleInput()\"\r\n (click)=\"handleClick()\"\r\n (keydown)=\"handleKeyboard($any($event))\"\r\n [disabled]=\"disabled\"\r\n [placeholder]=\"placeholder ?? ''\">", styles: [":host\r\n{\r\n display: block;\r\n}\r\n\r\ninput\r\n{\r\n width: 100%;\r\n}"] }]
|
|
307
311
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
308
312
|
type: Inject,
|
|
309
313
|
args: [DATE_API]
|
package/es2020/src/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleInputDateTime.component.js","sourceRoot":"","sources":["../../../../../src/selector/components/simpleInputDateTime/simpleInputDateTime.component.ts","../../../../../src/selector/components/simpleInputDateTime/simpleInputDateTime.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAa,OAAO,EAAC,MAAM,MAAM,CAAC;AAGzC,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,6CAA6C,CAAC;;;AAG9E;;GAEG;AAQH,MAAM,OAAO,oCAAoC;IAmK7C,iEAAiE;IACjE,YAAwC,QAAwB,EAC1C,cAAwC,EACxC,eAAkC;QAFhB,aAAQ,GAAR,QAAQ,CAAgB;QAC1C,mBAAc,GAAd,cAAc,CAA0B;QACxC,oBAAe,GAAf,eAAe,CAAmB;QApKxD,sEAAsE;QAEtE;;WAEG;QACO,iBAAY,GAAkB,IAAI,OAAO,EAAQ,CAAC;QAE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ewChild} from '@angular/core';\nimport {Observable, Subject} from 'rxjs';\n\nimport {DateTimeValue} from '../../../misc/datetime.interface';\nimport {DATE_API} from '../../../misc/tokens';\nimport {DateApi, DateApiObject} from '../../../services';\nimport {DateValueProvider} from '../../../services/dateValueProvider.service';\nimport {DateTimeSelector} from '../../misc/datetimeSelector.interface';\n\n/**\n * Component used as datetime selector with simple input\n */\n@Component(\n{\n selector: 'simple-input-date-time-selector',\n templateUrl: 'simpleInputDateTime.component.html',\n styleUrls: ['simpleInputDateTime.component.css'],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SimpleInputDateTimeSelectorComponent<TDate = any> implements DateTimeSelector<TDate>\n{\n //######################### protected fields #########################\n\n /**\n * Occurs when value changes\n */\n protected _valueChange: Subject<void> = new Subject<void>();\n\n /**\n * Occurs when selector is touched by user\n */\n protected _touched: Subject<void> = new Subject<void>();\n\n /**\n * Occurs when selector requires picker to be displayed or hidden\n */\n protected _pickerRequest: Subject<boolean> = new Subject<boolean>();\n\n /**\n * Currently used format for displaying data\n */\n protected _format: string = '';\n\n /**\n * Current value representation as date api wrapper\n */\n protected _dateApiValue: null|DateApiObject<TDate> = null;\n\n /**\n * Indication whether is current value valid value\n */\n protected _isValid: boolean = true;\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 DateTimeSelector #########################\n\n /**\n * Gets or sets currently used format for displaying data\n */\n public get format(): string\n {\n return this._format;\n }\n public set format(value: string)\n {\n this._format = value;\n }\n\n /**\n * Gets or sets placeholder that is displayed when there is no value selected\n */\n public placeholder: string|undefined;\n\n /**\n * Gets current value of datetime\n */\n public get value(): DateTimeValue<TDate>|null\n {\n if(!this._dateApiValue || !this._isValid)\n {\n return null;\n }\n\n return this._valueProvider.getValue(this._dateApiValue.value, this._format);\n }\n\n /**\n * Gets formatted value\n */\n public get formattedValue(): string|null\n {\n if(!this._isValid)\n {\n return null;\n }\n\n return this.currentValue;\n }\n\n /**\n * Gets indication whether is current value valid\n */\n public get valid(): boolean\n {\n return this._isValid;\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 selector is touched by user\n */\n public get touched(): Observable<void>\n {\n return this._touched.asObservable();\n }\n\n /**\n * Occurs when selector requires picker to be displayed\n */\n public get pickerRequest(): Observable<boolean>\n {\n return this._pickerRequest.asObservable();\n }\n\n //######################### public properties - template bindings #########################\n\n /**\n * Indication whether is input disabled\n * @internal\n */\n public disabled: boolean = false;\n\n //######################### public properties - children #########################\n\n /**\n * Instance of html input element\n * @internal\n */\n @ViewChild('input', {static: true})\n public inputElement?: ElementRef<HTMLInputElement>;\n\n //######################### protected properties #########################\n\n /**\n * Gets or sets string representation current of value\n */\n protected get currentValue(): string|null\n {\n return this.input.value || null;\n }\n protected set currentValue(value: string|null)\n {\n if(this.input)\n {\n this.input.value = value ?? '';\n }\n }\n\n /**\n * Gets input element used for handling date time value\n */\n protected get input(): HTMLInputElement\n {\n return this.inputElement!.nativeElement;\n }\n\n //######################### constructor #########################\n constructor(@Inject(DATE_API) protected _dateApi: DateApi<TDate>,\n protected _valueProvider: DateValueProvider<TDate>,\n protected _changeDetector: ChangeDetectorRef)\n {\n }\n\n //######################### public methods - implementation of DateTimeSelector #########################\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 }\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 }\n\n /**\n * Sets value of datetime selector\n * @param value - Value to be set to this selector\n */\n public setValue(value: DateTimeValue<TDate>|null): void\n {\n if(value?.from)\n {\n this._dateApiValue = this._dateApi.getValue(value?.from, this._format);\n this._isValid = this._dateApiValue.isValid();\n\n this._show();\n }\n else\n {\n this._clearValue();\n }\n }\n\n /**\n * Sets as 'control' disabled\n * @param disabled - Indication whether sets value as disabled, if omitted it is same as disabled set to true\n */\n public setDisabled(disabled: boolean = true): void\n {\n this.disabled = disabled;\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 - template bindings #########################\n\n /**\n * Handles gaining of focus\n * @internal\n */\n public handleFocus()\n {\n this._pickerRequest.next(true);\n\n //no value\n if(!this._dateApiValue)\n {\n this._dateApiValue = this._dateApi.now();\n this._isValid = this._dateApiValue.isValid();\n\n if(this._minMaxConstraintTest())\n {\n this._clearValue();\n }\n else\n {\n this._valueChange.next();\n }\n }\n\n if(!this._isValid)\n {\n return;\n }\n\n this._show();\n }\n\n /**\n * Handles blur on input\n * @internal\n */\n public handleBlur()\n {\n this._pickerRequest.next(false);\n }\n\n /**\n * Handles user input\n * @internal\n */\n public handleInput()\n {\n //empty value\n if(!this.currentValue)\n {\n this._clearValue();\n this._valueChange.next();\n\n return;\n }\n\n this._dateApiValue = this._dateApi.getValue(this.currentValue, this._format);\n this._isValid = this._dateApiValue.isValid();\n this._valueChange.next();\n }\n\n /**\n * Handles click event inside of input\n * @internal\n */\n public handleClick()\n {\n this._pickerRequest.next(true);\n }\n\n /**\n * Handles keyboard events\n * @param event - Keyboard event that occured\n * @param input - Html input element that holds current value and selection\n * @internal\n */\n public handleKeyboard(event: KeyboardEvent)\n {\n if(!this._dateApiValue?.isValid())\n {\n return;\n }\n\n switch(event.key)\n {\n case 'ArrowRight':\n case 'ArrowLeft':\n {\n event.preventDefault();\n event.stopPropagation();\n\n this._withMinMaxConstraint(() => event.key == 'ArrowLeft' ? this._dateApiValue!.subtractDays(1) : this._dateApiValue!.addDays(1));\n this._show();\n\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n {\n event.preventDefault();\n event.stopPropagation();\n\n this._withMinMaxConstraint(() => event.key == 'ArrowUp' ? this._dateApiValue!.subtractWeeks(1) : this._dateApiValue!.addWeeks(1));\n this._show();\n\n break;\n }\n case 'Escape':\n {\n this._pickerRequest.next(false);\n\n break;\n }\n case ' ':\n {\n if(event.ctrlKey)\n {\n this._pickerRequest.next(true);\n }\n\n break;\n }\n }\n }\n\n //######################### protected methods #########################\n\n /**\n * Clears current value\n */\n protected _clearValue()\n {\n this._dateApiValue = null;\n this._isValid = true;\n this.currentValue = null;\n }\n\n /**\n * Tests whether are min or max constraint broken, returns true if constraint is broken\n */\n protected _minMaxConstraintTest(): boolean\n {\n return (!!this._minValue && this._dateApiValue!.isBefore(this._minValue)) ||\n (!!this._maxValue && this._dateApiValue!.isAfter(this._maxValue));\n }\n\n /**\n * Runs code with check whether min max constrains was broken\n * @param code - Code that should be executed which can change current value\n */\n protected _withMinMaxConstraint(code: () => void)\n {\n this._dateApiValue!.updateOriginal();\n\n code();\n\n //min value constraint failure\n if(this._minMaxConstraintTest())\n {\n this._dateApiValue?.resetOriginal();\n\n return;\n }\n\n this._valueChange.next();\n }\n\n /**\n * Shows current value in input\n */\n protected _show()\n {\n if(this._isValid)\n {\n this.currentValue = this._dateApiValue?.format(this._format) ?? null;\n }\n }\n}","<input type=\"text\"\r\n #input\r\n (focus)=\"handleFocus()\"\r\n (blur)=\"handleBlur()\"\r\n (input)=\"handleInput()\"\r\n (click)=\"handleClick()\"\r\n (keydown)=\"handleKeyboard($any($event))\"\r\n [disabled]=\"disabled\"\r\n [placeholder]=\"placeholder\">"]}
|
|
1
|
+
{"version":3,"file":"simpleInputDateTime.component.js","sourceRoot":"","sources":["../../../../../src/selector/components/simpleInputDateTime/simpleInputDateTime.component.ts","../../../../../src/selector/components/simpleInputDateTime/simpleInputDateTime.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAa,OAAO,EA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IAAI,CAAC,QAAQ,EAChB;YACI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;SACxE;IACL,CAAC;;iIApZQ,oCAAoC,kBAoKzB,QAAQ;qHApKnB,oCAAoC,4LCnBjD,2TAQyC;2FDW5B,oCAAoC;kBAPhD,SAAS;+BAEI,iCAAiC,mBAG1B,uBAAuB,CAAC,MAAM;;0BAsKlC,MAAM;2BAAC,QAAQ;4GA5BrB,YAAY;sBADlB,SAAS;uBAAC,OAAO,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC","sourcesContent":["import {Component, ChangeDetectionStrategy, Inject, ChangeDetectorRef, ElementRef, ViewChild} from '@angular/core';\nimport {Observable, Subject} from 'rxjs';\n\nimport {DateTimeValue} from '../../../misc/datetime.interface';\nimport {DATE_API} from '../../../misc/tokens';\nimport {DateApi, DateApiObject} from '../../../services';\nimport {DateValueProvider} from '../../../services/dateValueProvider.service';\nimport {DateTimeSelector} from '../../misc/datetimeSelector.interface';\n\n/**\n * Component used as datetime selector with simple input\n */\n@Component(\n{\n selector: 'simple-input-date-time-selector',\n templateUrl: 'simpleInputDateTime.component.html',\n styleUrls: ['simpleInputDateTime.component.css'],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SimpleInputDateTimeSelectorComponent<TDate = any> implements DateTimeSelector<TDate>\n{\n //######################### protected fields #########################\n\n /**\n * Occurs when value changes\n */\n protected _valueChange: Subject<void> = new Subject<void>();\n\n /**\n * Occurs when selector is touched by user\n */\n protected _touched: Subject<void> = new Subject<void>();\n\n /**\n * Occurs when selector requires picker to be displayed or hidden\n */\n protected _pickerRequest: Subject<boolean> = new Subject<boolean>();\n\n /**\n * Currently used format for displaying data\n */\n protected _format: string = '';\n\n /**\n * Current value representation as date api wrapper\n */\n protected _dateApiValue: null|DateApiObject<TDate> = null;\n\n /**\n * Indication whether is current value valid value\n */\n protected _isValid: boolean = true;\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 DateTimeSelector #########################\n\n /**\n * Gets or sets currently used format for displaying data\n */\n public get format(): string\n {\n return this._format;\n }\n public set format(value: string)\n {\n this._format = value;\n }\n\n /**\n * Gets or sets placeholder that is displayed when there is no value selected\n */\n public placeholder: string|null = null;\n\n /**\n * Gets current value of datetime\n */\n public get value(): DateTimeValue<TDate>|null\n {\n if(!this._dateApiValue || !this._isValid)\n {\n return null;\n }\n\n return this._valueProvider.getValue(this._dateApiValue.value, this._format);\n }\n\n /**\n * Gets formatted value\n */\n public get formattedValue(): string|null\n {\n if(!this._isValid)\n {\n return null;\n }\n\n return this.currentValue;\n }\n\n /**\n * Gets indication whether is current value valid\n */\n public get valid(): boolean\n {\n return this._isValid;\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 selector is touched by user\n */\n public get touched(): Observable<void>\n {\n return this._touched.asObservable();\n }\n\n /**\n * Occurs when selector requires picker to be displayed\n */\n public get pickerRequest(): Observable<boolean>\n {\n return this._pickerRequest.asObservable();\n }\n\n //######################### public properties - template bindings #########################\n\n /**\n * Indication whether is input disabled\n * @internal\n */\n public disabled: boolean = false;\n\n //######################### public properties - children #########################\n\n /**\n * Instance of html input element\n * @internal\n */\n @ViewChild('input', {static: true})\n public inputElement?: ElementRef<HTMLInputElement>;\n\n //######################### protected properties #########################\n\n /**\n * Gets or sets string representation current of value\n */\n protected get currentValue(): string|null\n {\n return this.input.value || null;\n }\n protected set currentValue(value: string|null)\n {\n if(this.input)\n {\n this.input.value = value ?? '';\n }\n }\n\n /**\n * Gets input element used for handling date time value\n */\n protected get input(): HTMLInputElement\n {\n return this.inputElement!.nativeElement;\n }\n\n //######################### constructor #########################\n constructor(@Inject(DATE_API) protected _dateApi: DateApi<TDate>,\n protected _valueProvider: DateValueProvider<TDate>,\n protected _changeDetector: ChangeDetectorRef)\n {\n }\n\n //######################### public methods - implementation of DateTimeSelector #########################\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 }\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 }\n\n /**\n * Sets value of datetime selector\n * @param value - Value to be set to this selector\n */\n public setValue(value: DateTimeValue<TDate>|null): void\n {\n if(value?.from)\n {\n this._dateApiValue = this._dateApi.getValue(value?.from, this._format);\n this._isValid = this._dateApiValue.isValid();\n\n this._show();\n }\n else\n {\n this._clearValue();\n }\n }\n\n /**\n * Sets as 'control' disabled\n * @param disabled - Indication whether sets value as disabled, if omitted it is same as disabled set to true\n */\n public setDisabled(disabled: boolean = true): void\n {\n this.disabled = disabled;\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 - template bindings #########################\n\n /**\n * Handles gaining of focus\n * @internal\n */\n public handleFocus(): void\n {\n this._pickerRequest.next(true);\n\n //no value\n if(!this._dateApiValue)\n {\n this._dateApiValue = this._dateApi.now();\n this._isValid = this._dateApiValue.isValid();\n\n if(this._minMaxConstraintTest())\n {\n this._clearValue();\n }\n else\n {\n this._valueChange.next();\n }\n }\n\n if(!this._isValid)\n {\n return;\n }\n\n this._show();\n }\n\n /**\n * Handles blur on input\n * @internal\n */\n public handleBlur(): void\n {\n this._pickerRequest.next(false);\n }\n\n /**\n * Handles user input\n * @internal\n */\n public handleInput(): void\n {\n //empty value\n if(!this.currentValue)\n {\n this._clearValue();\n this._valueChange.next();\n\n return;\n }\n\n this._dateApiValue = this._dateApi.getValue(this.currentValue, this._format);\n this._isValid = this._dateApiValue.isValid();\n this._valueChange.next();\n }\n\n /**\n * Handles click event inside of input\n * @internal\n */\n public handleClick(): void\n {\n this._pickerRequest.next(true);\n }\n\n /**\n * Handles keyboard events\n * @param event - Keyboard event that occured\n * @param input - Html input element that holds current value and selection\n * @internal\n */\n public handleKeyboard(event: KeyboardEvent): void\n {\n if(!this._dateApiValue?.isValid())\n {\n return;\n }\n\n switch(event.key)\n {\n case 'ArrowRight':\n case 'ArrowLeft':\n {\n event.preventDefault();\n event.stopPropagation();\n\n this._withMinMaxConstraint(() => event.key == 'ArrowLeft' ? this._dateApiValue!.subtractDays(1) : this._dateApiValue!.addDays(1));\n this._show();\n\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n {\n event.preventDefault();\n event.stopPropagation();\n\n this._withMinMaxConstraint(() => event.key == 'ArrowUp' ? this._dateApiValue!.subtractWeeks(1) : this._dateApiValue!.addWeeks(1));\n this._show();\n\n break;\n }\n case 'Escape':\n {\n this._pickerRequest.next(false);\n\n break;\n }\n case ' ':\n {\n if(event.ctrlKey)\n {\n this._pickerRequest.next(true);\n }\n\n break;\n }\n }\n }\n\n //######################### protected methods #########################\n\n /**\n * Clears current value\n */\n protected _clearValue(): void\n {\n this._dateApiValue = null;\n this._isValid = true;\n this.currentValue = null;\n }\n\n /**\n * Tests whether are min or max constraint broken, returns true if constraint is broken\n */\n protected _minMaxConstraintTest(): boolean\n {\n return (!!this._minValue && this._dateApiValue!.isBefore(this._minValue)) ||\n (!!this._maxValue && this._dateApiValue!.isAfter(this._maxValue));\n }\n\n /**\n * Runs code with check whether min max constrains was broken\n * @param code - Code that should be executed which can change current value\n */\n protected _withMinMaxConstraint(code: () => void): void\n {\n this._dateApiValue!.updateOriginal();\n\n code();\n\n //min value constraint failure\n if(this._minMaxConstraintTest())\n {\n this._dateApiValue?.resetOriginal();\n\n return;\n }\n\n this._valueChange.next();\n }\n\n /**\n * Shows current value in input\n */\n protected _show(): void\n {\n if(this._isValid)\n {\n this.currentValue = this._dateApiValue?.format(this._format) ?? null;\n }\n }\n}","<input type=\"text\"\r\n #input\r\n (focus)=\"handleFocus()\"\r\n (blur)=\"handleBlur()\"\r\n (input)=\"handleInput()\"\r\n (click)=\"handleClick()\"\r\n (keydown)=\"handleKeyboard($any($event))\"\r\n [disabled]=\"disabled\"\r\n [placeholder]=\"placeholder ?? ''\">"]}
|
package/es2020/src/selector/directives/dateTimePickerRenderer/dateTimePickerRenderer.directive.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Directive, ElementRef, EventEmitter, Inject, Injector, Input, Optional, Output, ViewContainerRef } from '@angular/core';
|
|
2
|
+
import { DOCUMENT } from '@angular/common';
|
|
3
|
+
import { POSITION, applyPositionResult } from '@anglr/common';
|
|
4
|
+
import { Subscription } from 'rxjs';
|
|
5
|
+
import { DateTimePickerComponent } from '../../../picker/types';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
/**
|
|
8
|
+
* Directive for rendering datetime picker in selector
|
|
9
|
+
*/
|
|
10
|
+
export class DateTimePickerRendererDirective {
|
|
11
|
+
//######################### constructor #########################
|
|
12
|
+
constructor(_viewContainer, _injector, _position, _document) {
|
|
13
|
+
this._viewContainer = _viewContainer;
|
|
14
|
+
this._injector = _injector;
|
|
15
|
+
this._position = _position;
|
|
16
|
+
this._document = _document;
|
|
17
|
+
/**
|
|
18
|
+
* Subscriptions created during initialization
|
|
19
|
+
*/
|
|
20
|
+
this._initSubscriptions = new Subscription();
|
|
21
|
+
//######################### public properties - outputs #########################
|
|
22
|
+
/**
|
|
23
|
+
* Occurs when value changes
|
|
24
|
+
*/
|
|
25
|
+
this.valueChange = new EventEmitter();
|
|
26
|
+
}
|
|
27
|
+
//######################### protected properties #########################
|
|
28
|
+
/**
|
|
29
|
+
* Current options used by selector
|
|
30
|
+
*/
|
|
31
|
+
get _options() {
|
|
32
|
+
return this.options;
|
|
33
|
+
}
|
|
34
|
+
//######################### public methods - implementation of OnInit #########################
|
|
35
|
+
/**
|
|
36
|
+
* Initialize component
|
|
37
|
+
*/
|
|
38
|
+
ngOnInit() {
|
|
39
|
+
this._createPicker();
|
|
40
|
+
}
|
|
41
|
+
//######################### public methods - implementation of OnChanges #########################
|
|
42
|
+
/**
|
|
43
|
+
* Called when input value changes
|
|
44
|
+
*/
|
|
45
|
+
ngOnChanges() {
|
|
46
|
+
this._createPicker();
|
|
47
|
+
if (this._pickerComponent) {
|
|
48
|
+
const picker = this._pickerComponent.instance;
|
|
49
|
+
picker.value = this.value;
|
|
50
|
+
picker.minValue = this.minValue;
|
|
51
|
+
picker.maxValue = this.maxValue;
|
|
52
|
+
picker.options = this.options;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//######################### public methods - implementation of OnDestroy #########################
|
|
56
|
+
/**
|
|
57
|
+
* Called when component is destroyed
|
|
58
|
+
*/
|
|
59
|
+
ngOnDestroy() {
|
|
60
|
+
this._destroyPicker();
|
|
61
|
+
this._initSubscriptions.unsubscribe();
|
|
62
|
+
}
|
|
63
|
+
//######################### protected methods #########################
|
|
64
|
+
/**
|
|
65
|
+
* Destroys picker component
|
|
66
|
+
*/
|
|
67
|
+
_destroyPicker() {
|
|
68
|
+
if (this._pickerComponent) {
|
|
69
|
+
this._pickerComponent.destroy();
|
|
70
|
+
this._pickerComponent = undefined;
|
|
71
|
+
this._pickerElement = undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates picker component
|
|
76
|
+
*/
|
|
77
|
+
_createPicker() {
|
|
78
|
+
if (this._pickerComponent) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// 1. Create a component reference from the component
|
|
82
|
+
this._pickerComponent = this._viewContainer
|
|
83
|
+
.createComponent(DateTimePickerComponent, {
|
|
84
|
+
injector: this._injector
|
|
85
|
+
});
|
|
86
|
+
if (this._pickerComponent) {
|
|
87
|
+
this._initSubscriptions.add(this._pickerComponent.instance.valueChange.subscribe(itm => this.valueChange.next(itm)));
|
|
88
|
+
//absolutely position
|
|
89
|
+
if (this._options.pickerAbsolute && this._position) {
|
|
90
|
+
// 3. Get DOM element from component
|
|
91
|
+
this._pickerElement = this._pickerComponent.hostView
|
|
92
|
+
.rootNodes[0];
|
|
93
|
+
// 4. Append DOM element to the body
|
|
94
|
+
this._document.querySelector(this._options.pickerAbsoluteContainer)?.appendChild(this._pickerElement);
|
|
95
|
+
this._pickerElement.style.position = 'absolute';
|
|
96
|
+
this._initSubscriptions.add(this._position.placeElement(this._pickerElement, this.selectorElement.nativeElement, this._options.positionOptions).subscribe(applyPositionResult));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
DateTimePickerRendererDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: DateTimePickerRendererDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Injector }, { token: POSITION, optional: true }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Directive });
|
|
105
|
+
DateTimePickerRendererDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.3", type: DateTimePickerRendererDirective, selector: "[dateTimePicker]", inputs: { options: "options", value: ["dateTimePicker", "value"], minValue: "minValue", maxValue: "maxValue", selectorElement: "selectorElement" }, outputs: { valueChange: "valueChange" }, usesOnChanges: true, ngImport: i0 });
|
|
106
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: DateTimePickerRendererDirective, decorators: [{
|
|
107
|
+
type: Directive,
|
|
108
|
+
args: [{
|
|
109
|
+
selector: '[dateTimePicker]'
|
|
110
|
+
}]
|
|
111
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.Injector }, { type: undefined, decorators: [{
|
|
112
|
+
type: Inject,
|
|
113
|
+
args: [POSITION]
|
|
114
|
+
}, {
|
|
115
|
+
type: Optional
|
|
116
|
+
}] }, { type: Document, decorators: [{
|
|
117
|
+
type: Inject,
|
|
118
|
+
args: [DOCUMENT]
|
|
119
|
+
}] }]; }, propDecorators: { options: [{
|
|
120
|
+
type: Input
|
|
121
|
+
}], value: [{
|
|
122
|
+
type: Input,
|
|
123
|
+
args: ['dateTimePicker']
|
|
124
|
+
}], minValue: [{
|
|
125
|
+
type: Input
|
|
126
|
+
}], maxValue: [{
|
|
127
|
+
type: Input
|
|
128
|
+
}], selectorElement: [{
|
|
129
|
+
type: Input
|
|
130
|
+
}], valueChange: [{
|
|
131
|
+
type: Output
|
|
132
|
+
}] } });
|
|
133
|
+
//# sourceMappingURL=dateTimePickerRenderer.directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateTimePickerRenderer.directive.js","sourceRoot":"","sources":["../../../../../src/selector/directives/dateTimePickerRenderer/dateTimePickerRenderer.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,UAAU,EAAmB,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAgC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC5L,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAY,mBAAmB,EAAC,MAAM,eAAe,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAIlC,OAAO,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;;AAE9D;;GAEG;AAKH,MAAM,OAAO,+BAA+B;IAqExC,iEAAiE;IACjE,YAAsB,cAAgC,EAChC,SAAmB,EACW,SAAmB,EAC/B,SAAmB;QAHrC,mBAAc,GAAd,cAAc,CAAkB;QAChC,cAAS,GAAT,SAAS,CAAU;QACW,cAAS,GAAT,SAAS,CAAU;QAC/B,cAAS,GAAT,SAAS,CAAU;QA3D3D;;WAEG;QACO,uBAAkB,GAAiB,IAA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QAAQ;4CAtCrB,OAAO;sBADb,KAAK;gBAOC,KAAK;sBADX,KAAK;uBAAC,gBAAgB;gBAOhB,QAAQ;sBADd,KAAK;gBAOC,QAAQ;sBADd,KAAK;gBAOC,eAAe;sBADrB,KAAK;gBASC,WAAW;sBADjB,MAAM","sourcesContent":["import {ComponentRef, Directive, ElementRef, EmbeddedViewRef, EventEmitter, Inject, Injector, Input, OnChanges, OnDestroy, OnInit, Optional, Output, ViewContainerRef} from '@angular/core';\nimport {DOCUMENT} from '@angular/common';\nimport {POSITION, Position, applyPositionResult} from '@anglr/common';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeValue} from '../../../misc/datetime.interface';\nimport {DateTimeSelector, DateTimeSelectorOptions} from '../../interfaces';\nimport {DateTimePickerComponent} from '../../../picker/types';\n\n/**\n * Directive for rendering datetime picker in selector\n */\n@Directive(\n{\n selector: '[dateTimePicker]'\n})\nexport class DateTimePickerRendererDirective<TDate = any> implements OnInit, OnChanges, OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Instance of component used for rendering picker\n */\n protected _pickerComponent?: ComponentRef<DateTimePickerComponent>;\n\n /**\n * Instance of HTML element for picker\n */\n protected _pickerElement?: HTMLElement;\n\n /**\n * Subscriptions created during initialization\n */\n protected _initSubscriptions: Subscription = new Subscription();\n\n //######################### protected properties #########################\n\n /**\n * Current options used by selector\n */\n protected get _options(): DateTimeSelectorOptions<DateTimeSelector<TDate>>\n {\n return this.options as DateTimeSelectorOptions<DateTimeSelector<TDate>>;\n }\n\n //######################### public properties - inputs #########################\n\n /**\n * Current options used by selector\n */\n @Input()\n public options!: Partial<DateTimeSelectorOptions<DateTimeSelector<TDate>>>;\n\n /**\n * Current selected value\n */\n @Input('dateTimePicker')\n public value!: DateTimeValue<TDate>|null;\n\n /**\n * Gets or sets minimal possible value for picker, that can be picked\n */\n @Input()\n public minValue!: TDate|null;\n\n /**\n * Gets or sets maximal possible value for picker, that can be picked\n */\n @Input()\n public maxValue!: TDate|null;\n\n /**\n * Selector element which is used during absolute positioning of picker\n */\n @Input()\n public selectorElement!: ElementRef<HTMLElement>;\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(protected _viewContainer: ViewContainerRef,\n protected _injector: Injector,\n @Inject(POSITION) @Optional() protected _position: Position,\n @Inject(DOCUMENT) protected _document: Document)\n {\n }\n\n //######################### public methods - implementation of OnInit #########################\n \n /**\n * Initialize component\n */\n public ngOnInit(): void\n {\n this._createPicker();\n }\n\n //######################### public methods - implementation of OnChanges #########################\n \n /**\n * Called when input value changes\n */\n public ngOnChanges(): void\n {\n this._createPicker();\n\n if(this._pickerComponent)\n {\n const picker = this._pickerComponent.instance;\n\n picker.value = this.value;\n picker.minValue = this.minValue;\n picker.maxValue = this.maxValue;\n picker.options = this.options;\n }\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this._destroyPicker();\n this._initSubscriptions.unsubscribe();\n }\n\n //######################### protected methods #########################\n\n /**\n * Destroys picker component\n */\n protected _destroyPicker(): void\n {\n if(this._pickerComponent)\n {\n this._pickerComponent.destroy();\n this._pickerComponent = undefined;\n this._pickerElement = undefined;\n }\n }\n\n /**\n * Creates picker component\n */\n protected _createPicker(): void\n {\n if(this._pickerComponent)\n {\n return;\n }\n\n // 1. Create a component reference from the component\n this._pickerComponent = this._viewContainer\n .createComponent(DateTimePickerComponent,\n {\n injector: this._injector\n });\n\n if(this._pickerComponent)\n {\n this._initSubscriptions.add(this._pickerComponent.instance.valueChange.subscribe(itm => this.valueChange.next(itm)));\n\n //absolutely position\n if(this._options.pickerAbsolute && this._position)\n {\n // 3. Get DOM element from component\n this._pickerElement = (this._pickerComponent.hostView as EmbeddedViewRef<any>)\n .rootNodes[0] as HTMLElement;\n\n // 4. Append DOM element to the body\n this._document.querySelector(this._options.pickerAbsoluteContainer)?.appendChild(this._pickerElement);\n this._pickerElement.style.position = 'absolute';\n this._initSubscriptions.add(this._position.placeElement(this._pickerElement, this.selectorElement.nativeElement, this._options.positionOptions).subscribe(applyPositionResult));\n }\n else\n {\n return;\n }\n }\n }\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectorControlValueAccessor.directive.js","sourceRoot":"","sources":["../../../../../src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAoB,UAAU,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AACxF,OAAO,EAAC,iBAAiB,EAAuB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAC,yBAAyB,EAAC,MAAM,8CAA8C,CAAC;;;AAEvF;;GAEG;AACH,MAAM,iCAAiC,GACvC;IACI,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,oCAAoC,CAAC;IACnE,KAAK,EAAE,IAAI;CACd,CAAC;AAEF;;GAEG;AAMH,MAAM,OAAO,oCAAoC;IAuB7C,iEAAiE;IACjE,YAAsB,SAA2C;QAA3C,cAAS,GAAT,SAAS,CAAkC;QAtBjE,sEAAsE;QAEtE;;WAEG;QACO,mBAAc,GAAiB,IAAI,YAAY,EAAE,CAAC;QAE5D,gFAAgF;QAEhF;;WAEG;QAEI,UAAK,GAAY,KAAK,CAAC;QAE9B;;WAEG;QAEI,cAAS,GAAY,KAAK,CAAC;IAKlC,CAAC;IAED,kGAAkG;IAElG;;OAEG;IACI,WAAW;QAEd,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC;IACvC,CAAC;IAED,6GAA6G;IAE7G;;OAEG;IACI,UAAU,CAAC,KAA6C;QAE3D,IAAG,IAAI,CAAC,KAAK,EACb;YACI,IAAI,CA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ClB;SACJ;IACL,CAAC;;iIArHQ,oCAAoC;qHAApC,oCAAoC,8KAFlC,CAAC,iCAAiC,CAAC;2FAErC,oCAAoC;kBALhD,SAAS;mBACV;oBACI,QAAQ,EAAE,iGAAiG;oBAC3G,SAAS,EAAE,CAAC,iCAAiC,CAAC;iBACjD;gHAgBU,KAAK;sBADX,KAAK;gBAOC,SAAS;sBADf,KAAK","sourcesContent":["import {Directive, ExistingProvider, forwardRef, Input, OnDestroy} from '@angular/core';\nimport {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeValue} from '../../../misc/datetime.interface';\nimport {DateTimeSelectorComponent} from '../../components/selector/selector.component';\n\n/**\n * Value accessor provider for date time selector\n */\nconst DATE_TIME_SELECTOR_VALUE_ACCESSOR = <ExistingProvider>\n{\n provide: NG_VALUE_ACCESSOR, \n useExisting: forwardRef(() => DateTimeSelectorControlValueAccessor), \n multi: true\n};\n\n/**\n * Value accessor for getting and setting values for date time selector\n */\n@Directive(\n{\n selector: 'date-time-selector[formControlName],date-time-selector[formControl],date-time-selector[ngModel]',\n providers: [DATE_TIME_SELECTOR_VALUE_ACCESSOR]\n})\nexport class DateTimeSelectorControlValueAccessor<TDate> implements ControlValueAccessor, OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Subscriptions that are destroyed on directive destruction\n */\n protected _subscriptions: Subscription = new Subscription();\n\n //######################### public properties - inputs #########################\n\n /**\n * Indication whether value for selector is represented as range from, to\n */\n @Input()\n public range: boolean = false;\n\n /**\n * Indication whether value for selector is represented as formatted string value, if both 'formatted' and 'range' are set, 'range' takes precedence\n */\n @Input()\n public formatted: boolean = false;\n\n //######################### constructor #########################\n constructor(protected _selector: DateTimeSelectorComponent<TDate>)\n {\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy()\n {\n this._subscriptions?.unsubscribe();\n }\n\n //######################### public methods - implementation of ControlValueAccessor #########################\n\n /**\n * Sets value to datetime selector\n */\n public writeValue(value: string|DateTimeValue<TDate>|TDate|null): void\n {\n if(this.range)\n {\n this._selector.value = value as DateTimeValue<TDate>;\n }\n else if(this.formatted)\n {\n this._selector.formattedValue = value as string;\n }\n else\n {\n this._selector.value =\n {\n from: value as TDate,\n to: value as TDate\n };\n }\n }\n\n /**\n * Registers callback that is called when value of datetime selector value changes\n */\n public registerOnChange(fn: (data: string|DateTimeValue<TDate>|TDate|null) => any): void\n {\n this._subscriptions.add(this._selector.valueChange.subscribe(() => this._emitValue(fn)));\n }\n\n /**\n * Registers callback that is called when datetime selector was touched by user\n */\n public registerOnTouched(fn: () => any): void\n {\n this._subscriptions.add(this._selector.touched.subscribe(() => fn()));\n }\n\n /**\n * Used for setting control as disabled\n * @param isDisabled - disabled status to set on the element\n */\n public setDisabledState(isDisabled: boolean): void\n {\n this._selector.setDisabled(isDisabled);\n }\n\n //######################### protected methods #########################\n\n /**\n * Used for emitting value that was changed\n * @param fn - Function that is used for emitting changed value\n */\n protected _emitValue(fn: (value: string|DateTimeValue<TDate>|TDate|null) => any)\n {\n if(this.range)\n {\n fn(this._selector.value);\n }\n else if(this.formatted)\n {\n fn(this._selector.formattedValue);\n }\n else\n {\n const value = this._selector.value;\n\n if(!value)\n {\n fn(null);\n }\n else\n {\n fn(value.from);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"selectorControlValueAccessor.directive.js","sourceRoot":"","sources":["../../../../../src/selector/directives/selectorControlValueAccessor/selectorControlValueAccessor.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAoB,UAAU,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AACxF,OAAO,EAAC,iBAAiB,EAAuB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAC,yBAAyB,EAAC,MAAM,8CAA8C,CAAC;;;AAEvF;;GAEG;AACH,M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O,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,UAAmB;QAEvC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED,uEAAuE;IAEvE;;;OAGG;IACO,UAAU,CAAC,EAA0D;QAE3E,IAAG,IAAI,CAAC,KAAK,EACb;YACI,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SAC5B;aACI,IAAG,IAAI,CAAC,SAAS,EACtB;YACI,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;SACrC;aAED;YACI,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAEnC,IAAG,CAAC,KAAK,EACT;gBACI,EAAE,CAAC,IAAI,CAAC,CAAC;aACZ;iBAED;gBACI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAClB;SACJ;IACL,CAAC;;iIArHQ,oCAAoC;qHAApC,oCAAoC,8KAFlC,CAAC,iCAAiC,CAAC;2FAErC,oCAAoC;kBALhD,SAAS;mBACV;oBACI,QAAQ,EAAE,iGAAiG;oBAC3G,SAAS,EAAE,CAAC,iCAAiC,CAAC;iBACjD;gHAgBU,KAAK;sBADX,KAAK;gBAOC,SAAS;sBADf,KAAK","sourcesContent":["import {Directive, ExistingProvider, forwardRef, Input, OnDestroy} from '@angular/core';\nimport {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeValue} from '../../../misc/datetime.interface';\nimport {DateTimeSelectorComponent} from '../../components/selector/selector.component';\n\n/**\n * Value accessor provider for date time selector\n */\nconst DATE_TIME_SELECTOR_VALUE_ACCESSOR = <ExistingProvider>\n{\n provide: NG_VALUE_ACCESSOR, \n useExisting: forwardRef(() => DateTimeSelectorControlValueAccessor), \n multi: true\n};\n\n/**\n * Value accessor for getting and setting values for date time selector\n */\n@Directive(\n{\n selector: 'date-time-selector[formControlName],date-time-selector[formControl],date-time-selector[ngModel]',\n providers: [DATE_TIME_SELECTOR_VALUE_ACCESSOR]\n})\nexport class DateTimeSelectorControlValueAccessor<TDate> implements ControlValueAccessor, OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Subscriptions that are destroyed on directive destruction\n */\n protected _subscriptions: Subscription = new Subscription();\n\n //######################### public properties - inputs #########################\n\n /**\n * Indication whether value for selector is represented as range from, to\n */\n @Input()\n public range: boolean = false;\n\n /**\n * Indication whether value for selector is represented as formatted string value, if both 'formatted' and 'range' are set, 'range' takes precedence\n */\n @Input()\n public formatted: boolean = false;\n\n //######################### constructor #########################\n constructor(protected _selector: DateTimeSelectorComponent<TDate>)\n {\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this._subscriptions?.unsubscribe();\n }\n\n //######################### public methods - implementation of ControlValueAccessor #########################\n\n /**\n * Sets value to datetime selector\n */\n public writeValue(value: string|DateTimeValue<TDate>|TDate|null): void\n {\n if(this.range)\n {\n this._selector.value = value as DateTimeValue<TDate>;\n }\n else if(this.formatted)\n {\n this._selector.formattedValue = value as string;\n }\n else\n {\n this._selector.value =\n {\n from: value as TDate,\n to: value as TDate\n };\n }\n }\n\n /**\n * Registers callback that is called when value of datetime selector value changes\n */\n public registerOnChange(fn: (data: string|DateTimeValue<TDate>|TDate|null) => any): void\n {\n this._subscriptions.add(this._selector.valueChange.subscribe(() => this._emitValue(fn)));\n }\n\n /**\n * Registers callback that is called when datetime selector was touched by user\n */\n public registerOnTouched(fn: () => any): void\n {\n this._subscriptions.add(this._selector.touched.subscribe(() => fn()));\n }\n\n /**\n * Used for setting control as disabled\n * @param isDisabled - disabled status to set on the element\n */\n public setDisabledState(isDisabled: boolean): void\n {\n this._selector.setDisabled(isDisabled);\n }\n\n //######################### protected methods #########################\n\n /**\n * Used for emitting value that was changed\n * @param fn - Function that is used for emitting changed value\n */\n protected _emitValue(fn: (value: string|DateTimeValue<TDate>|TDate|null) => any): void\n {\n if(this.range)\n {\n fn(this._selector.value);\n }\n else if(this.formatted)\n {\n fn(this._selector.formattedValue);\n }\n else\n {\n const value = this._selector.value;\n\n if(!value)\n {\n fn(null);\n }\n else\n {\n fn(value.from);\n }\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetimeSelector.interface.js","sourceRoot":"","sources":["../../../../src/selector/misc/datetimeSelector.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from '@angular/core';\nimport {Observable} from 'rxjs';\n\nimport {DateTimeValue} from '../../misc/datetime.interface';\nimport {DateTimePickerOptions} from '../../picker/misc/datetimePicker.interface';\n\n/**\n * Defintion of datetime selector component options\n */\nexport interface DateTimeSelectorOptions<TSelector = any, TPicker = any> extends DateTimePickerOptions<TPicker>\n{\n /**\n * Definition of type that is used for selector\n */\n selectorComponent: Type<TSelector>;\n\n /**\n * Indication whether close picker on value selection\n */\n pickerCloseOnValueSelect
|
|
1
|
+
{"version":3,"file":"datetimeSelector.interface.js","sourceRoot":"","sources":["../../../../src/selector/misc/datetimeSelector.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from '@angular/core';\nimport {PositionOptions} from '@anglr/common';\nimport {Observable} from 'rxjs';\n\nimport {DateTimeValue} from '../../misc/datetime.interface';\nimport {DateTimePickerOptions} from '../../picker/misc/datetimePicker.interface';\n\n/**\n * Defintion of datetime selector component options\n */\nexport interface DateTimeSelectorOptions<TSelector = any, TPicker = any> extends DateTimePickerOptions<TPicker>\n{\n /**\n * Definition of type that is used for selector\n */\n selectorComponent: Type<TSelector>;\n\n /**\n * Indication whether close picker on value selection\n */\n pickerCloseOnValueSelect: boolean;\n\n /**\n * Indication whether picker is disabled\n */\n pickerDisabled: boolean;\n\n /**\n * Indication whether use absolute positioning of picker\n */\n pickerAbsolute: boolean;\n\n /**\n * Position options that are used in case of absolute picker\n */\n positionOptions: Partial<PositionOptions>;\n\n /**\n * Css selector for absolute picker container\n */\n pickerAbsoluteContainer: string;\n}\n\n/**\n * Describes datetime selector component used for displaying and selecting value\n */\nexport interface DateTimeSelector<TDate = any>\n{\n /**\n * Currently used format for displaying data\n */\n format: string;\n\n /**\n * Placeholder that is displayed when there is no value selected\n */\n placeholder: string|null;\n\n /**\n * Gets current value of datetime\n */\n readonly value: DateTimeValue<TDate>|null;\n\n /**\n * Gets formatted value\n */\n readonly formattedValue: string|null;\n\n /**\n * Gets indication whether is current value valid\n */\n readonly valid: boolean;\n\n /**\n * Occurs when value changes\n */\n readonly valueChange: Observable<void>;\n\n /**\n * Occurs when selector is touched by user\n */\n readonly touched: Observable<void>;\n\n /**\n * Occurs when selector requires picker to be displayed or hidden\n */\n readonly pickerRequest: Observable<boolean>;\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 setMinValue(value: TDate|null): void;\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 setMaxValue(value: TDate|null): void;\n\n /**\n * Sets value of datetime selector\n * @param value - Value to be set to this selector\n */\n setValue(value: DateTimeValue<TDate>|null): void;\n\n /**\n * Sets as 'control' disabled\n * @param disabled - Indication whether sets value as disabled, if omitted it is same as disabled set to true\n */\n setDisabled(disabled?: boolean): void;\n\n /**\n * Explicitly runs invalidation of content (change detection)\n */\n invalidateVisuals(): void;\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../src/selector/misc/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAI7C;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../src/selector/misc/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAI7C;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAqD,IAAI,cAAc,CAAmC,kCAAkC,CAAC,CAAC","sourcesContent":["import {InjectionToken} from '@angular/core';\n\nimport {DateTimeSelectorOptions} from './datetimeSelector.interface';\n\n/**\n * Injection token used for obtaining datetime selector configuration\n */\nexport const DATE_TIME_SELECTOR_CONFIGURATION: InjectionToken<Partial<DateTimeSelectorOptions>> = new InjectionToken<Partial<DateTimeSelectorOptions>>('DATE_TIME_SELECTOR_CONFIGURATION');"]}
|
|
@@ -8,6 +8,7 @@ import { DateTimeSelectorControlValueAccessor } from '../directives/selectorCont
|
|
|
8
8
|
import { DatetimeValidatorDirective } from '../directives/datetimeValidator/datetimeValidator.directive';
|
|
9
9
|
import { DatetimeMinValidatorDirective } from '../directives/datetimeMinValidator/datetimeMinValidator.directive';
|
|
10
10
|
import { DatetimeMaxValidatorDirective } from '../directives/datetimeMaxValidator/datetimeMaxValidator.directive';
|
|
11
|
+
import { DateTimePickerRendererDirective } from '../directives/dateTimePickerRenderer/dateTimePickerRenderer.directive';
|
|
11
12
|
import * as i0 from "@angular/core";
|
|
12
13
|
/**
|
|
13
14
|
* Angular module for date time selector components
|
|
@@ -20,13 +21,15 @@ DateTimeSelectorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0",
|
|
|
20
21
|
DateTimeSelectorControlValueAccessor,
|
|
21
22
|
DatetimeValidatorDirective,
|
|
22
23
|
DatetimeMinValidatorDirective,
|
|
23
|
-
DatetimeMaxValidatorDirective
|
|
24
|
+
DatetimeMaxValidatorDirective,
|
|
25
|
+
DateTimePickerRendererDirective], imports: [AngularCommonModule,
|
|
24
26
|
CommonDynamicModule,
|
|
25
27
|
DateTimePickerModule], exports: [DateTimeSelectorComponent,
|
|
26
28
|
DateTimeSelectorControlValueAccessor,
|
|
27
29
|
DatetimeValidatorDirective,
|
|
28
30
|
DatetimeMinValidatorDirective,
|
|
29
|
-
DatetimeMaxValidatorDirective
|
|
31
|
+
DatetimeMaxValidatorDirective,
|
|
32
|
+
DateTimePickerRendererDirective] });
|
|
30
33
|
DateTimeSelectorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: DateTimeSelectorModule, imports: [[
|
|
31
34
|
AngularCommonModule,
|
|
32
35
|
CommonDynamicModule,
|
|
@@ -46,14 +49,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImpor
|
|
|
46
49
|
DateTimeSelectorControlValueAccessor,
|
|
47
50
|
DatetimeValidatorDirective,
|
|
48
51
|
DatetimeMinValidatorDirective,
|
|
49
|
-
DatetimeMaxValidatorDirective
|
|
52
|
+
DatetimeMaxValidatorDirective,
|
|
53
|
+
DateTimePickerRendererDirective,
|
|
50
54
|
],
|
|
51
55
|
exports: [
|
|
52
56
|
DateTimeSelectorComponent,
|
|
53
57
|
DateTimeSelectorControlValueAccessor,
|
|
54
58
|
DatetimeValidatorDirective,
|
|
55
59
|
DatetimeMinValidatorDirective,
|
|
56
|
-
DatetimeMaxValidatorDirective
|
|
60
|
+
DatetimeMaxValidatorDirective,
|
|
61
|
+
DateTimePickerRendererDirective,
|
|
57
62
|
]
|
|
58
63
|
}]
|
|
59
64
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector.module.js","sourceRoot":"","sources":["../../../../src/selector/modules/selector.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAC,YAAY,IAAI,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAElD,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAC,yBAAyB,EAAC,MAAM,2CAA2C,CAAC;AACpF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AC7B,6BAA6B;QAC7B,+BAA+B;oHAG1B,sBAAsB,YAzB/B;YACI,mBAAmB;YACnB,mBAAmB;YACnB,oBAAoB;SACvB;2FAqBQ,sBAAsB;kBA5BlC,QAAQ;mBACT;oBACI,OAAO,EACP;wBACI,mBAAmB;wBACnB,mBAAmB;wBACnB,oBAAoB;qBACvB;oBACD,YAAY,EACZ;wBACI,yBAAyB;wBACzB,8BAA8B;wBAC9B,oCAAoC;wBACpC,0BAA0B;wBAC1B,6BAA6B;wBAC7B,6BAA6B;wBAC7B,+BAA+B;qBAClC;oBACD,OAAO,EACP;wBACI,yBAAyB;wBACzB,oCAAoC;wBACpC,0BAA0B;wBAC1B,6BAA6B;wBAC7B,6BAA6B;wBAC7B,+BAA+B;qBAClC;iBACJ","sourcesContent":["import {NgModule} from '@angular/core';\nimport {CommonModule as AngularCommonModule} from '@angular/common';\nimport {CommonDynamicModule} from '@anglr/common';\n\nimport {DateTimePickerModule} from '../../picker/modules/picker.module';\nimport {DateTimeSelectorComponent} from '../components/selector/selector.component';\nimport {InputDateTimeSelectorComponent} from '../components/inputDateTime/inputDateTime.component';\nimport {DateTimeSelectorControlValueAccessor} from '../directives/selectorControlValueAccessor/selectorControlValueAccessor.directive';\nimport {DatetimeValidatorDirective} from '../directives/datetimeValidator/datetimeValidator.directive';\nimport {DatetimeMinValidatorDirective} from '../directives/datetimeMinValidator/datetimeMinValidator.directive';\nimport {DatetimeMaxValidatorDirective} from '../directives/datetimeMaxValidator/datetimeMaxValidator.directive';\nimport {DateTimePickerRendererDirective} from '../directives/dateTimePickerRenderer/dateTimePickerRenderer.directive';\n\n/**\n * Angular module for date time selector components\n */\n@NgModule(\n{\n imports:\n [\n AngularCommonModule,\n CommonDynamicModule,\n DateTimePickerModule,\n ],\n declarations:\n [\n DateTimeSelectorComponent,\n InputDateTimeSelectorComponent,\n DateTimeSelectorControlValueAccessor,\n DatetimeValidatorDirective,\n DatetimeMinValidatorDirective,\n DatetimeMaxValidatorDirective,\n DateTimePickerRendererDirective,\n ],\n exports:\n [\n DateTimeSelectorComponent,\n DateTimeSelectorControlValueAccessor,\n DatetimeValidatorDirective,\n DatetimeMinValidatorDirective,\n DatetimeMaxValidatorDirective,\n DateTimePickerRendererDirective,\n ]\n})\nexport class DateTimeSelectorModule\n{\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateApi.interface.js","sourceRoot":"","sources":["../../../src/services/dateApi.interface.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Date can be represented as formatted string, timestamp or javascript Date object\n */\nexport type DateValue = Date|string|number;\n\n/**\n * Instance of object wrapping TDate, allowing manipulation with it\n */\nexport interface DateApiObject<TDate = any>\n{\n /**\n * Original value that is not changed unless 'updateOriginal' is called\n */\n readonly originalValue: TDate;\n\n /**\n * Instance of date\n */\n readonly value: TDate;\n\n /**\n * Gets indication whether provided instance of date is valid\n */\n isValid(): boolean;\n\n /**\n * Gets indication whether provided instance of date is weekend day\n */\n isWeekend(): boolean;\n\n /**\n * Formats date value\n * @param format - Format token used for creating formatted string\n */\n format(format: string): string;\n\n /**\n * Updates value to start date and time of current decade\n * @returns Itself for fluent API\n */\n startOfDecade(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current decade\n * @returns Itself for fluent API\n */\n endOfDecade(): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current year\n * @returns Itself for fluent API\n */\n startOfYear(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current year\n * @returns Itself for fluent API\n */\n endOfYear(): DateApiObject<TDate>;\n\n /**\n * Add years, if count not specified adds 1 year\n * @param count - Number of years count\n * @returns Itself for fluent API\n */\n addYears(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract years, if count not specified subtract 1 year\n * @param count - Number of years count\n * @returns Itself for fluent API\n */\n subtractYears(count?: number): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current month\n * @returns Itself for fluent API\n */\n startOfMonth(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current month\n * @returns Itself for fluent API\n */\n endOfMonth(): DateApiObject<TDate>;\n\n /**\n * Add months, if count not specified adds 1 month\n * @param count - Number of months count\n * @returns Itself for fluent API\n */\n addMonths(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract months, if count not specified subtract 1 month\n * @param count - Number of months count\n * @returns Itself for fluent API\n */\n subtractMonths(count?: number): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current week\n * @returns Itself for fluent API\n */\n startOfWeek(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current week\n * @returns Itself for fluent API\n */\n endOfWeek(): DateApiObject<TDate>;\n\n /**\n * Add weeks, if count not specified adds 1 week\n * @param count - Number of weeks count\n * @returns Itself for fluent API\n */\n addWeeks(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract weeks, if count not specified subtract 1 week\n * @param count - Number of weeks count\n * @returns Itself for fluent API\n */\n subtractWeeks(count?: number): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current day\n * @returns Itself for fluent API\n */\n startOfDay(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current day\n * @returns Itself for fluent API\n */\n endOfDay(): DateApiObject<TDate>;\n\n /**\n * Add days, if count not specified adds 1 day\n * @param count - Number of days count\n * @returns Itself for fluent API\n */\n addDays(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract days, if count not specified subtract 1 day\n * @param count - Number of days count\n * @returns Itself for fluent API\n */\n subtractDays(count?: number): DateApiObject<TDate>;\n\n /**\n * Gets number of days in month\n */\n daysInMonth(): number;\n\n /**\n * Gets year\n */\n year(): number;\n /**\n * Sets year\n * @param year - Year to be set\n */\n year(year: number): DateApiObject<TDate>;\n /**\n * Gets or sets year\n * @param year - If specified, sets year\n */\n year(year?: number): DateApiObject<TDate>|number;\n \n /**\n * Gets month\n */\n month(): number;\n /**\n * Sets month\n * @param month - Month to be set\n */\n month(month: number): DateApiObject<TDate>;\n /**\n * Gets or sets month\n * @param month - If specified, sets month\n */\n month(month?: number): DateApiObject<TDate>|number;\n\n /**\n * Gets day of month one based\n */\n dayOfMonth(): number;\n /**\n * Sets day of month one based\n * @param day - Day of month to be set\n */\n dayOfMonth(day: number): DateApiObject<TDate>;\n /**\n * Gets or sets day of month one based\n * @param day - If specified, sets day of month\n */\n dayOfMonth(day?: number): DateApiObject<TDate>|number;\n\n /**\n * Gets day of week zero based, first is monday\n */\n dayOfWeek(): number;\n /**\n * Sets day of week zero based, first is monday\n * @param day - Day of week to be set\n */\n dayOfWeek(day: number): DateApiObject<TDate>;\n /**\n * Gets or sets day of week zero based, first is monday\n * @param day - If specified, sets day of week\n */\n dayOfWeek(day?: number): number|DateApiObject<TDate>;\n\n /**\n * Gets indication whether current value is before 'date'\n * @param date - Date which is this date compared to\n */\n isBefore(date: TDate): boolean;\n\n /**\n * Gets indication whether current value is after 'date'\n * @param date - Date which is this date compared to\n */\n isAfter(date: TDate): boolean;\n\n /**\n * Gets number of days between this and provided date\n * @param date - Date which is used for computation of diff against\n */\n diffDays(date: TDate): number;\n\n /**\n * Compares whether this date is same week as provided date\n * @param date - Date which is used for comparison of same week\n */\n isSameWeek(date: TDate): boolean;\n\n /**\n * Compares whether this date is same decade as provided date\n * @param date - Date which is used for comparison of same decade\n */\n isSameDecade(date: TDate): boolean;\n\n /**\n * Compares whether this date is same year as provided date\n * @param date - Date which is used for comparison of same year\n */\n isSameYear(date: TDate): boolean;\n\n /**\n * Compares whether this date is same month as provided date\n * @param date - Date which is used for comparison of same month\n */\n isSameMonth(date: TDate): boolean;\n\n /**\n * Compares whether this date is same day as provided date\n * @param date - Date which is used for comparison of same day\n */\n isSameDay(date: TDate): boolean;\n\n /**\n * Creates clone of this instance, value and originalValue have same value and are cloned from value\n */\n clone(): DateApiObject<TDate>;\n\n /**\n * Creates clone of this instance, value and originalValue have same value and are cloned from originalValue\n */\n cloneOriginal(): DateApiObject<TDate>;\n\n /**\n * Updates originalValue, if value is not provided originalValue is set to value\n * @param value - Value to be set as original, or null (value will be used as value)\n * @returns Itself for fluent API\n */\n updateOriginal(value?: TDate): DateApiObject<TDate>;\n\n /**\n * Changes value to same value as originalValue\n * @returns Itself for fluent API\n */\n resetOriginal(): DateApiObject<TDate>;\n}\n\n/**\n * Date api abstraction, used for obtaining DateApi wrapper object\n */\nexport interface DateApi<TDate = any>\n{\n /**\n * Gets wrapping object used for manipulation\n * @param value - Value to be converted (parsed) and used for manipulation\n * @param format - Format string used for parsing string value\n */\n getValue(value: DateValue|TDate, format?: string): DateApiObject<TDate>;\n\n /**\n * Gets wrapping object used for manipulation instantiated to current date and time\n */\n now(): DateApiObject<TDate>;\n\n /**\n * Gets format string using pseudo format\n * @param pseudoFormat - Pseudo format token, used for obtaining 'date' or 'time' format string\n */\n getFormat(pseudoFormat: string): string;\n\n /**\n * Gets information \n */\n weekStartsOnMonday(): boolean;\n\n /**\n * Gets array of weekday names in short format, order of days is dependent on locale\n */\n weekdaysShort(): string[];\n}"]}
|
|
1
|
+
{"version":3,"file":"dateApi.interface.js","sourceRoot":"","sources":["../../../src/services/dateApi.interface.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Date can be represented as formatted string, timestamp or javascript Date object\n */\nexport type DateValue = Date|string|number;\n\n/**\n * Instance of object wrapping TDate, allowing manipulation with it\n */\nexport interface DateApiObject<TDate = any>\n{\n /**\n * Original value that is not changed unless 'updateOriginal' is called\n */\n readonly originalValue: TDate;\n\n /**\n * Instance of date\n */\n readonly value: TDate;\n\n /**\n * Gets indication whether provided instance of date is valid\n */\n isValid(): boolean;\n\n /**\n * Gets indication whether provided instance of date is weekend day\n */\n isWeekend(): boolean;\n\n /**\n * Formats date value\n * @param format - Format token used for creating formatted string\n */\n format(format: string): string;\n\n /**\n * Updates value to start date and time of current decade\n * @returns Itself for fluent API\n */\n startOfDecade(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current decade\n * @returns Itself for fluent API\n */\n endOfDecade(): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current year\n * @returns Itself for fluent API\n */\n startOfYear(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current year\n * @returns Itself for fluent API\n */\n endOfYear(): DateApiObject<TDate>;\n\n /**\n * Add years, if count not specified adds 1 year\n * @param count - Number of years count\n * @returns Itself for fluent API\n */\n addYears(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract years, if count not specified subtract 1 year\n * @param count - Number of years count\n * @returns Itself for fluent API\n */\n subtractYears(count?: number): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current month\n * @returns Itself for fluent API\n */\n startOfMonth(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current month\n * @returns Itself for fluent API\n */\n endOfMonth(): DateApiObject<TDate>;\n\n /**\n * Add months, if count not specified adds 1 month\n * @param count - Number of months count\n * @returns Itself for fluent API\n */\n addMonths(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract months, if count not specified subtract 1 month\n * @param count - Number of months count\n * @returns Itself for fluent API\n */\n subtractMonths(count?: number): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current week\n * @returns Itself for fluent API\n */\n startOfWeek(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current week\n * @returns Itself for fluent API\n */\n endOfWeek(): DateApiObject<TDate>;\n\n /**\n * Add weeks, if count not specified adds 1 week\n * @param count - Number of weeks count\n * @returns Itself for fluent API\n */\n addWeeks(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract weeks, if count not specified subtract 1 week\n * @param count - Number of weeks count\n * @returns Itself for fluent API\n */\n subtractWeeks(count?: number): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current day\n * @returns Itself for fluent API\n */\n startOfDay(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current day\n * @returns Itself for fluent API\n */\n endOfDay(): DateApiObject<TDate>;\n\n /**\n * Add days, if count not specified adds 1 day\n * @param count - Number of days count\n * @returns Itself for fluent API\n */\n addDays(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract days, if count not specified subtract 1 day\n * @param count - Number of days count\n * @returns Itself for fluent API\n */\n subtractDays(count?: number): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current hour\n * @returns Itself for fluent API\n */\n startOfHour(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current hour\n * @returns Itself for fluent API\n */\n endOfHour(): DateApiObject<TDate>;\n\n /**\n * Add hours, if count not specified adds 1 hour\n * @param count - Number of hours count\n * @returns Itself for fluent API\n */\n addHours(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract hours, if count not specified subtract 1 hour\n * @param count - Number of hours count\n * @returns Itself for fluent API\n */\n subtractHours(count?: number): DateApiObject<TDate>;\n\n /**\n * Updates value to start date and time of current minute\n * @returns Itself for fluent API\n */\n startOfMinute(): DateApiObject<TDate>;\n\n /**\n * Updates value to end date and time of current minute\n * @returns Itself for fluent API\n */\n endOfMinute(): DateApiObject<TDate>;\n\n /**\n * Add minutes, if count not specified adds 1 minute\n * @param count - Number of minutes count\n * @returns Itself for fluent API\n */\n addMinutes(count?: number): DateApiObject<TDate>;\n\n /**\n * Subtract minutes, if count not specified subtract 1 minute\n * @param count - Number of minutes count\n * @returns Itself for fluent API\n */\n subtractMinutes(count?: number): DateApiObject<TDate>;\n\n /**\n * Gets number of days in month\n */\n daysInMonth(): number;\n\n /**\n * Gets year\n */\n year(): number;\n /**\n * Sets year\n * @param year - Year to be set\n */\n year(year: number): DateApiObject<TDate>;\n /**\n * Gets or sets year\n * @param year - If specified, sets year\n */\n year(year?: number): DateApiObject<TDate>|number;\n\n /**\n * Gets month\n */\n month(): number;\n /**\n * Sets month\n * @param month - Month to be set\n */\n month(month: number): DateApiObject<TDate>;\n /**\n * Gets or sets month\n * @param month - If specified, sets month\n */\n month(month?: number): DateApiObject<TDate>|number;\n\n /**\n * Gets day of month one based\n */\n dayOfMonth(): number;\n /**\n * Sets day of month one based\n * @param day - Day of month to be set\n */\n dayOfMonth(day: number): DateApiObject<TDate>;\n /**\n * Gets or sets day of month one based\n * @param day - If specified, sets day of month\n */\n dayOfMonth(day?: number): DateApiObject<TDate>|number;\n\n /**\n * Gets day of week zero based, first is monday\n */\n dayOfWeek(): number;\n /**\n * Sets day of week zero based, first is monday\n * @param day - Day of week to be set\n */\n dayOfWeek(day: number): DateApiObject<TDate>;\n /**\n * Gets or sets day of week zero based, first is monday\n * @param day - If specified, sets day of week\n */\n dayOfWeek(day?: number): number|DateApiObject<TDate>;\n\n /**\n * Gets hours zero based\n */\n hour(): number;\n /**\n * Sets hours zero\n * @param hour - hour to be set\n */\n hour(hour: number): DateApiObject<TDate>;\n /**\n * Gets or sets hours zero\n * @param hour - If specified, sets hour\n */\n hour(hour?: number): DateApiObject<TDate>|number;\n\n /**\n * Gets minutes zero based\n */\n minute(): number;\n /**\n * Sets minutes zero based\n * @param minute - minutes to be set\n */\n minute(minute: number): DateApiObject<TDate>;\n /**\n * Gets or sets minutes zero based\n * @param minute - If specified, sets minutes\n */\n minute(minute?: number): DateApiObject<TDate>|number;\n\n /**\n * Gets indication whether current value is before 'date'\n * @param date - Date which is this date compared to\n */\n isBefore(date: TDate): boolean;\n\n /**\n * Gets indication whether current value is after 'date'\n * @param date - Date which is this date compared to\n */\n isAfter(date: TDate): boolean;\n\n /**\n * Gets number of days between this and provided date\n * @param date - Date which is used for computation of diff against\n */\n diffDays(date: TDate): number;\n\n /**\n * Compares whether this date is same week as provided date\n * @param date - Date which is used for comparison of same week\n */\n isSameWeek(date: TDate): boolean;\n\n /**\n * Compares whether this date is same decade as provided date\n * @param date - Date which is used for comparison of same decade\n */\n isSameDecade(date: TDate): boolean;\n\n /**\n * Compares whether this date is same year as provided date\n * @param date - Date which is used for comparison of same year\n */\n isSameYear(date: TDate): boolean;\n\n /**\n * Compares whether this date is same month as provided date\n * @param date - Date which is used for comparison of same month\n */\n isSameMonth(date: TDate): boolean;\n\n /**\n * Compares whether this date is same day as provided date\n * @param date - Date which is used for comparison of same day\n */\n isSameDay(date: TDate): boolean;\n\n /**\n * Creates clone of this instance, value and originalValue have same value and are cloned from value\n */\n clone(): DateApiObject<TDate>;\n\n /**\n * Creates clone of this instance, value and originalValue have same value and are cloned from originalValue\n */\n cloneOriginal(): DateApiObject<TDate>;\n\n /**\n * Updates originalValue, if value is not provided originalValue is set to value\n * @param value - Value to be set as original, or null (value will be used as value)\n * @returns Itself for fluent API\n */\n updateOriginal(value?: TDate): DateApiObject<TDate>;\n\n /**\n * Changes value to same value as originalValue\n * @returns Itself for fluent API\n */\n resetOriginal(): DateApiObject<TDate>;\n}\n\n/**\n * Date api abstraction, used for obtaining DateApi wrapper object\n */\nexport interface DateApi<TDate = any>\n{\n /**\n * Gets wrapping object used for manipulation\n * @param value - Value to be converted (parsed) and used for manipulation\n * @param format - Format string used for parsing string value\n */\n getValue(value: DateValue|TDate, format?: string): DateApiObject<TDate>;\n\n /**\n * Gets wrapping object used for manipulation instantiated to current date and time\n */\n now(): DateApiObject<TDate>;\n\n /**\n * Gets format string using pseudo format\n * @param pseudoFormat - Pseudo format token, used for obtaining 'date' or 'time' format string\n */\n getFormat(pseudoFormat: string): string;\n\n /**\n * Gets information\n */\n weekStartsOnMonday(): boolean;\n\n /**\n * Gets array of weekday names in short format, order of days is dependent on locale\n */\n weekdaysShort(): string[];\n}"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
|
+
import { isBlank } from '@jscrpt/common';
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
4
|
/**
|
|
4
5
|
* Service used for parsing date
|
|
@@ -48,6 +49,9 @@ export class DefaultDatePositionParser {
|
|
|
48
49
|
* @param cursorPosition - Current cursor position
|
|
49
50
|
*/
|
|
50
51
|
next(date, cursorPosition) {
|
|
52
|
+
if (isBlank(date)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
51
55
|
//non strict format
|
|
52
56
|
if (this._hasSeparator) {
|
|
53
57
|
let useNext = false;
|
|
@@ -85,6 +89,9 @@ export class DefaultDatePositionParser {
|
|
|
85
89
|
* @param cursorPosition - Current cursor position
|
|
86
90
|
*/
|
|
87
91
|
previous(date, cursorPosition) {
|
|
92
|
+
if (isBlank(date)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
88
95
|
//non strict format
|
|
89
96
|
if (this._hasSeparator) {
|
|
90
97
|
let useNext = false;
|
|
@@ -122,6 +129,13 @@ export class DefaultDatePositionParser {
|
|
|
122
129
|
* @param cursorPosition - Current cursor position
|
|
123
130
|
*/
|
|
124
131
|
parse(date, cursorPosition) {
|
|
132
|
+
if (isBlank(date)) {
|
|
133
|
+
return {
|
|
134
|
+
part: '',
|
|
135
|
+
positionFrom: 0,
|
|
136
|
+
positionTo: 0
|
|
137
|
+
};
|
|
138
|
+
}
|
|
125
139
|
//non strict format
|
|
126
140
|
if (this._hasSeparator) {
|
|
127
141
|
//fix cursor position if is clicked on separator
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datePositionParser.service.js","sourceRoot":"","sources":["../../../src/services/datePositionParser.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;;AAIzC;;GAEG;AAEH,MAAM,OAAO,yBAAyB;IAElC,oEAAoE;IAEpE;;;OAGG;IACI,YAAY,CAAC,MAAc;QAE9B,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;;sHAXQ,yBAAyB;0HAAzB,yBAAyB,cADb,MAAM;2FAClB,yBAAyB;kBADrC,UAAU;mBAAC,EAAC,UAAU,EAAE,MAAM,EAAC;;AAehC;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAmBlC,iEAAiE;IACjE,YAAsB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAlBrC,sEAAsE;QAEtE;;WAEG;QACO,kBAAa,GAAY,KAAK,CAAC;QAEzC;;WAEG;QACO,sBAAiB,GAAa,EAAE,CAAC;QAE3C;;WAEG;QACO,4BAAuB,G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EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAC3C;gBACI,WAAW;gBACX,IAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ,EAC9B;oBACI,IAAG,CAAC,GAAG,CAAC,EACR;wBACI,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;qBAClE;oBAED,SAAS,GAAG,CAAC,CAAC;oBACd,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;oBAE3B,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;wBAC/B;4BACI,MAAM,EAAE,CAAC;4BACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;yBACxB,CAAC;iBACL;aACJ;YAED,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;SACpF;IACL,CAAC;CACJ","sourcesContent":["import {Injectable} from '@angular/core';\n\nimport {DatePositionParser, DatePositionParserResult} from './datePositionParser.interface';\n\n/**\n * Service used for parsing date\n */\n@Injectable({providedIn: 'root'})\nexport class DatePositionParserService\n{\n //######################### public methods #########################\n\n /**\n * Creates parser instance for specified format\n * @param format - Format to be used for parsing date string\n */\n public createParser(format: string): DatePositionParser\n {\n return new DefaultDatePositionParser(format);\n }\n}\n\n/**\n * Default implementation of DatePositionParser\n */\nexport class DefaultDatePositionParser implements DatePositionParser\n{\n //######################### protected fields #########################\n\n /**\n * Indication whether format contains separators\n */\n protected _hasSeparator: boolean = false;\n\n /**\n * Array of date parts of parsed date format\n */\n protected _datePartsIndexes: string[] = [];\n\n /**\n * Object storing indexes for strict date parts of parsed date format\n */\n protected _strictDatePartsIndexes: {[index: number]: {part: string, length: number}} = {};\n\n //######################### constructor #########################\n constructor(protected _format: string)\n {\n this._initialize();\n }\n\n //######################### public methods - implementation of DatePositionParser #########################\n\n /**\n * Parse date as string and returns information about position and selected part of date, while moving it to next part, if it was last part returns null\n * @param date - String date to be parsed\n * @param cursorPosition - Current cursor position\n */\n public next(date: string, cursorPosition: number): null|DatePositionParserResult\n {\n //non strict format\n if(this._hasSeparator)\n {\n let useNext = false;\n\n while(true)\n {\n if(cursorPosition == date.length)\n {\n return null;\n }\n\n if(useNext && !isNaN(+date[cursorPosition]))\n {\n return this.parse(date, cursorPosition);\n }\n\n if(isNaN(+date[cursorPosition]))\n {\n useNext = true;\n }\n\n cursorPosition++;\n }\n }\n //strict format\n else\n {\n const indexes = Object.keys(this._strictDatePartsIndexes).map(itm => +itm);\n\n for(const index of indexes)\n {\n if(cursorPosition < index)\n {\n return {\n part: this._strictDatePartsIndexes[index].part,\n positionFrom: index,\n positionTo: index + this._strictDatePartsIndexes[index].length\n };\n }\n }\n }\n\n return null;\n }\n\n /**\n * Parse date as string and returns information about position and selected part of date, while moving it to previous part, if it was first part returns null\n * @param date - String date to be parsed\n * @param cursorPosition - Current cursor position\n */\n public previous(date: string, cursorPosition: number): null|DatePositionParserResult\n {\n //non strict format\n if(this._hasSeparator)\n {\n let useNext = false;\n\n while(true)\n {\n if(cursorPosition < 0)\n {\n return null;\n }\n\n if(useNext && !isNaN(+date[cursorPosition]))\n {\n return this.parse(date, cursorPosition);\n }\n\n if(isNaN(+date[cursorPosition]))\n {\n useNext = true;\n }\n\n cursorPosition--;\n }\n }\n //strict format\n else\n {\n const indexes = Object.keys(this._strictDatePartsIndexes).reverse().map(itm => +itm);\n\n for(const index of indexes)\n {\n if(cursorPosition > index)\n {\n return {\n part: this._strictDatePartsIndexes[index].part,\n positionFrom: index,\n positionTo: index + this._strictDatePartsIndexes[index].length\n };\n }\n }\n }\n\n return null;\n }\n\n /**\n * Parse date as string and returns information about positions and selected part of date\n * @param date - String date to be parsed\n * @param cursorPosition - Current cursor position\n */\n public parse(date: string, cursorPosition: number): DatePositionParserResult\n {\n //non strict format\n if(this._hasSeparator)\n {\n //fix cursor position if is clicked on separator\n if(cursorPosition != date.length &&\n /[^0-9ɵ]/.test(date[cursorPosition]) &&\n /[^0-9ɵ]/.test(date[cursorPosition - 1]))\n {\n let breakCycle = false;\n cursorPosition++;\n\n while(/[^0-9ɵ]/.test(date[cursorPosition]))\n {\n if(cursorPosition >= date.length)\n {\n if(breakCycle)\n {\n return {\n part: '',\n positionFrom: 0,\n positionTo: 0\n };\n }\n\n breakCycle = true;\n cursorPosition = 0;\n }\n\n cursorPosition++;\n }\n }\n\n const updateDate = [date.substr(0, cursorPosition), 'ɵ', date.substr(cursorPosition)].join('');\n const indexed = updateDate.replace(/[^0-9ɵ]/g, ' ').split(' ');\n let partIndex = 0;\n let startPosition = 0;\n let selectionLength = 0;\n\n for(const itm of indexed)\n {\n //this segment contains cursor\n if(itm.indexOf('ɵ') >= 0)\n {\n selectionLength = itm.length - 1;\n\n break;\n }\n\n startPosition++;\n\n //separator\n if(!itm.length)\n {\n continue;\n }\n\n partIndex++;\n startPosition += itm.length;\n }\n\n return {\n part: this._datePartsIndexes[partIndex],\n positionFrom: startPosition,\n positionTo: startPosition + selectionLength\n };\n }\n //strict format\n else\n {\n const indexes = Object.keys(this._strictDatePartsIndexes).reverse().map(itm => +itm);\n\n for(const index of indexes)\n {\n if(cursorPosition >= index)\n {\n return {\n part: this._strictDatePartsIndexes[index].part,\n positionFrom: index,\n positionTo: index + this._strictDatePartsIndexes[index].length\n };\n }\n }\n }\n\n return {\n part: '',\n positionFrom: 0,\n positionTo: 0\n };\n }\n\n /**\n * Initialize parser, process format\n */\n protected _initialize()\n {\n this._hasSeparator = /[^yqmwdhs]/i.test(this._format);\n\n //non strict format\n if(this._hasSeparator)\n {\n this._datePartsIndexes = this._format.replace(/[^yqmwdhs]+/gi, ' ')\n .split(' ')\n .filter(itm => !!itm)\n .map(itm => itm[0]);\n }\n //strict format\n else\n {\n let lastPart: string|null = null;\n let lastIndex: number = 0;\n\n for(let x = 0; x < this._format.length; x++)\n {\n //next part\n if(this._format[x] != lastPart)\n {\n if(x > 0)\n {\n this._strictDatePartsIndexes[lastIndex].length = x - lastIndex;\n }\n\n lastIndex = x;\n lastPart = this._format[x];\n\n this._strictDatePartsIndexes[x] =\n {\n length: 0,\n part: this._format[x]\n };\n }\n }\n\n this._strictDatePartsIndexes[lastIndex].length = this._format.length - lastIndex;\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"datePositionParser.service.js","sourceRoot":"","sources":["../../../src/services/datePositionParser.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;;AAIvC;;GAEG;AAEH,MAAM,OAAO,yBAAyB;IAElC,oEAAoE;IAEpE;;;OAGG;IACI,YAAY,CAAC,MAAc;QAE9B,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;;sHAXQ,yBAAyB;0HAAzB,yBAAyB,cADb,MAAM;2FAClB,yBAAyB;kBADrC,UAAU;mBAAC,EAAC,UAAU,EAAE,MAAM,EAAC;;AAehC;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAmBlC,iEAAiE;IACjE,YAAsB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAlBrC,sEAAsE;QAEtE;;WAEG;QACO,kBAAa,GAAY,KAAK,CAAC;QAEzC;;WAEG;QACO,sBAAiB,GAAa,EAAE,CAAC;QAE3C;;WAEG;QACO,4BAAuB,GAAsD,EAAE,CAAC;QAKtF,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAED,2GAA2G;IAE3G;;;;OAIG;IACI,IAAI,CAAC,IAA2B,EAAE,cAAsB;QAE3D,IAAG,OAAO,CAAC,IAAI,CAAC,EAChB;YACI,OAAO,IAAI,CAAC;SACf;QAED,mBAAmB;QACnB,IAAG,IAAI,CAAC,aAAa,EACrB;YACI,IAAI,OAAO,GAAG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AAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAC3C;gBACI,WAAW;gBACX,IAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ,EAC9B;oBACI,IAAG,CAAC,GAAG,CAAC,EACR;wBACI,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;qBAClE;oBAED,SAAS,GAAG,CAAC,CAAC;oBACd,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;oBAE3B,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;wBAC/B;4BACI,MAAM,EAAE,CAAC;4BACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;yBACxB,CAAC;iBACL;aACJ;YAED,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;SACpF;IACL,CAAC;CACJ","sourcesContent":["import {Injectable} from '@angular/core';\nimport {isBlank} from '@jscrpt/common';\n\nimport {DatePositionParser, DatePositionParserResult} from './datePositionParser.interface';\n\n/**\n * Service used for parsing date\n */\n@Injectable({providedIn: 'root'})\nexport class DatePositionParserService\n{\n //######################### public methods #########################\n\n /**\n * Creates parser instance for specified format\n * @param format - Format to be used for parsing date string\n */\n public createParser(format: string): DatePositionParser\n {\n return new DefaultDatePositionParser(format);\n }\n}\n\n/**\n * Default implementation of DatePositionParser\n */\nexport class DefaultDatePositionParser implements DatePositionParser\n{\n //######################### protected fields #########################\n\n /**\n * Indication whether format contains separators\n */\n protected _hasSeparator: boolean = false;\n\n /**\n * Array of date parts of parsed date format\n */\n protected _datePartsIndexes: string[] = [];\n\n /**\n * Object storing indexes for strict date parts of parsed date format\n */\n protected _strictDatePartsIndexes: {[index: number]: {part: string, length: number}} = {};\n\n //######################### constructor #########################\n constructor(protected _format: string)\n {\n this._initialize();\n }\n\n //######################### public methods - implementation of DatePositionParser #########################\n\n /**\n * Parse date as string and returns information about position and selected part of date, while moving it to next part, if it was last part returns null\n * @param date - String date to be parsed\n * @param cursorPosition - Current cursor position\n */\n public next(date: string|null|undefined, cursorPosition: number): null|DatePositionParserResult\n {\n if(isBlank(date))\n {\n return null;\n }\n\n //non strict format\n if(this._hasSeparator)\n {\n let useNext = false;\n\n while(true)\n {\n if(cursorPosition == date.length)\n {\n return null;\n }\n\n if(useNext && !isNaN(+date[cursorPosition]))\n {\n return this.parse(date, cursorPosition);\n }\n\n if(isNaN(+date[cursorPosition]))\n {\n useNext = true;\n }\n\n cursorPosition++;\n }\n }\n //strict format\n else\n {\n const indexes = Object.keys(this._strictDatePartsIndexes).map(itm => +itm);\n\n for(const index of indexes)\n {\n if(cursorPosition < index)\n {\n return {\n part: this._strictDatePartsIndexes[index].part,\n positionFrom: index,\n positionTo: index + this._strictDatePartsIndexes[index].length\n };\n }\n }\n }\n\n return null;\n }\n\n /**\n * Parse date as string and returns information about position and selected part of date, while moving it to previous part, if it was first part returns null\n * @param date - String date to be parsed\n * @param cursorPosition - Current cursor position\n */\n public previous(date: string|null|undefined, cursorPosition: number): null|DatePositionParserResult\n {\n if(isBlank(date))\n {\n return null;\n }\n\n //non strict format\n if(this._hasSeparator)\n {\n let useNext = false;\n\n while(true)\n {\n if(cursorPosition < 0)\n {\n return null;\n }\n\n if(useNext && !isNaN(+date[cursorPosition]))\n {\n return this.parse(date, cursorPosition);\n }\n\n if(isNaN(+date[cursorPosition]))\n {\n useNext = true;\n }\n\n cursorPosition--;\n }\n }\n //strict format\n else\n {\n const indexes = Object.keys(this._strictDatePartsIndexes).reverse().map(itm => +itm);\n\n for(const index of indexes)\n {\n if(cursorPosition > index)\n {\n return {\n part: this._strictDatePartsIndexes[index].part,\n positionFrom: index,\n positionTo: index + this._strictDatePartsIndexes[index].length\n };\n }\n }\n }\n\n return null;\n }\n\n /**\n * Parse date as string and returns information about positions and selected part of date\n * @param date - String date to be parsed\n * @param cursorPosition - Current cursor position\n */\n public parse(date: string|null|undefined, cursorPosition: number): DatePositionParserResult\n {\n if(isBlank(date))\n {\n return {\n part: '',\n positionFrom: 0,\n positionTo: 0\n };\n }\n\n //non strict format\n if(this._hasSeparator)\n {\n //fix cursor position if is clicked on separator\n if(cursorPosition != date.length &&\n /[^0-9ɵ]/.test(date[cursorPosition]) &&\n /[^0-9ɵ]/.test(date[cursorPosition - 1]))\n {\n let breakCycle = false;\n cursorPosition++;\n\n while(/[^0-9ɵ]/.test(date[cursorPosition]))\n {\n if(cursorPosition >= date.length)\n {\n if(breakCycle)\n {\n return {\n part: '',\n positionFrom: 0,\n positionTo: 0\n };\n }\n\n breakCycle = true;\n cursorPosition = 0;\n }\n\n cursorPosition++;\n }\n }\n\n const updateDate = [date.substr(0, cursorPosition), 'ɵ', date.substr(cursorPosition)].join('');\n const indexed = updateDate.replace(/[^0-9ɵ]/g, ' ').split(' ');\n let partIndex = 0;\n let startPosition = 0;\n let selectionLength = 0;\n\n for(const itm of indexed)\n {\n //this segment contains cursor\n if(itm.indexOf('ɵ') >= 0)\n {\n selectionLength = itm.length - 1;\n\n break;\n }\n\n startPosition++;\n\n //separator\n if(!itm.length)\n {\n continue;\n }\n\n partIndex++;\n startPosition += itm.length;\n }\n\n return {\n part: this._datePartsIndexes[partIndex],\n positionFrom: startPosition,\n positionTo: startPosition + selectionLength\n };\n }\n //strict format\n else\n {\n const indexes = Object.keys(this._strictDatePartsIndexes).reverse().map(itm => +itm);\n\n for(const index of indexes)\n {\n if(cursorPosition >= index)\n {\n return {\n part: this._strictDatePartsIndexes[index].part,\n positionFrom: index,\n positionTo: index + this._strictDatePartsIndexes[index].length\n };\n }\n }\n }\n\n return {\n part: '',\n positionFrom: 0,\n positionTo: 0\n };\n }\n\n /**\n * Initialize parser, process format\n */\n protected _initialize(): void\n {\n this._hasSeparator = /[^yqmwdhs]/i.test(this._format);\n\n //non strict format\n if(this._hasSeparator)\n {\n this._datePartsIndexes = this._format.replace(/[^yqmwdhs]+/gi, ' ')\n .split(' ')\n .filter(itm => !!itm)\n .map(itm => itm[0]);\n }\n //strict format\n else\n {\n let lastPart: string|null = null;\n let lastIndex: number = 0;\n\n for(let x = 0; x < this._format.length; x++)\n {\n //next part\n if(this._format[x] != lastPart)\n {\n if(x > 0)\n {\n this._strictDatePartsIndexes[lastIndex].length = x - lastIndex;\n }\n\n lastIndex = x;\n lastPart = this._format[x];\n\n this._strictDatePartsIndexes[x] =\n {\n length: 0,\n part: this._format[x]\n };\n }\n }\n\n this._strictDatePartsIndexes[lastIndex].length = this._format.length - lastIndex;\n }\n }\n}"]}
|
|
@@ -14,9 +14,17 @@ export class DateTimeRelativeParser {
|
|
|
14
14
|
/**
|
|
15
15
|
* Tries to parse relative value and returns parsed TDate, otherwise returns input value
|
|
16
16
|
* @param value - Value to be parsed
|
|
17
|
+
*
|
|
18
|
+
* @summary
|
|
19
|
+
* i - for minutes
|
|
20
|
+
* h - for hours
|
|
21
|
+
* d - for days
|
|
22
|
+
* w - for weeks
|
|
23
|
+
* m - for months
|
|
24
|
+
* y - for years
|
|
17
25
|
*/
|
|
18
26
|
parse(value) {
|
|
19
|
-
const regex = /([+-])\s*(\d+)\s*([
|
|
27
|
+
const regex = /([+-])\s*(\d+)\s*([ihdwmy])/;
|
|
20
28
|
//relative date provided
|
|
21
29
|
if (isString(value) && regex.test(value)) {
|
|
22
30
|
const matches = regex.exec(value);
|
|
@@ -26,8 +34,14 @@ export class DateTimeRelativeParser {
|
|
|
26
34
|
this._dateApi = this._dateApi ?? this._injector.get(DATE_API);
|
|
27
35
|
const now = this._dateApi.now();
|
|
28
36
|
switch (period) {
|
|
37
|
+
case 'i':
|
|
38
|
+
{
|
|
39
|
+
operation == '+' ? now.addMinutes(+amount).endOfMinute() : now.subtractMinutes(+amount).startOfMinute();
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
29
42
|
case 'h':
|
|
30
43
|
{
|
|
44
|
+
operation == '+' ? now.addHours(+amount).endOfHour() : now.subtractHours(+amount).startOfHour();
|
|
31
45
|
break;
|
|
32
46
|
}
|
|
33
47
|
case 'd':
|