@anglr/datetime 6.0.0 → 6.1.0

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.
Files changed (67) hide show
  1. package/changelog.md +19 -0
  2. package/es2015/src/directives/datePickerInput/datePickerInput.directive.js +37 -0
  3. package/es2015/src/directives/datePickerInput/datePickerInput.directive.js.map +1 -0
  4. package/es2015/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js +325 -0
  5. package/es2015/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js.map +1 -0
  6. package/es2015/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js +29 -0
  7. package/es2015/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js.map +1 -0
  8. package/es2015/src/directives/index.js +4 -0
  9. package/es2015/src/directives/index.js.map +1 -1
  10. package/es2015/src/directives/withNow/withNow.directive.js +44 -0
  11. package/es2015/src/directives/withNow/withNow.directive.js.map +1 -0
  12. package/es2015/src/directives/withToday/withToday.directive.js +6 -6
  13. package/es2015/src/directives/withToday/withToday.directive.js.map +1 -1
  14. package/es2015/src/misc/utils.js +52 -0
  15. package/es2015/src/misc/utils.js.map +1 -1
  16. package/es2015/src/modules/dateTime/directives/dateTime/dateTime.directive.js +32 -12
  17. package/es2015/src/modules/dateTime/directives/dateTime/dateTime.directive.js.map +1 -1
  18. package/es2020/src/directives/datePickerInput/datePickerInput.directive.js +37 -0
  19. package/es2020/src/directives/datePickerInput/datePickerInput.directive.js.map +1 -0
  20. package/es2020/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js +322 -0
  21. package/es2020/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js.map +1 -0
  22. package/es2020/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js +29 -0
  23. package/es2020/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js.map +1 -0
  24. package/es2020/src/directives/index.js +4 -0
  25. package/es2020/src/directives/index.js.map +1 -1
  26. package/es2020/src/directives/withNow/withNow.directive.js +44 -0
  27. package/es2020/src/directives/withNow/withNow.directive.js.map +1 -0
  28. package/es2020/src/directives/withToday/withToday.directive.js +6 -6
  29. package/es2020/src/directives/withToday/withToday.directive.js.map +1 -1
  30. package/es2020/src/misc/utils.js +52 -0
  31. package/es2020/src/misc/utils.js.map +1 -1
  32. package/es2020/src/modules/dateTime/directives/dateTime/dateTime.directive.js +32 -12
  33. package/es2020/src/modules/dateTime/directives/dateTime/dateTime.directive.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/directives/datePickerInput/datePickerInput.directive.d.ts +12 -0
  36. package/src/directives/datePickerInput/datePickerInput.directive.d.ts.map +1 -0
  37. package/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.d.ts +86 -0
  38. package/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.d.ts.map +1 -0
  39. package/src/directives/dateTimePickerInput/dateTimePickerInput.directive.d.ts +11 -0
  40. package/src/directives/dateTimePickerInput/dateTimePickerInput.directive.d.ts.map +1 -0
  41. package/src/directives/index.d.ts +4 -0
  42. package/src/directives/index.d.ts.map +1 -1
  43. package/src/directives/withNow/withNow.directive.d.ts +22 -0
  44. package/src/directives/withNow/withNow.directive.d.ts.map +1 -0
  45. package/src/directives/withToday/withToday.directive.d.ts +3 -2
  46. package/src/directives/withToday/withToday.directive.d.ts.map +1 -1
  47. package/src/misc/utils.d.ts +18 -1
  48. package/src/misc/utils.d.ts.map +1 -1
  49. package/src/modules/dateTime/directives/dateTime/dateTime.directive.d.ts +19 -6
  50. package/src/modules/dateTime/directives/dateTime/dateTime.directive.d.ts.map +1 -1
  51. package/version.bak +1 -1
  52. package/es2015/src/legacy/selector/components/inputDateTime/inputDateTime.component.js +0 -488
  53. package/es2015/src/legacy/selector/components/inputDateTime/inputDateTime.component.js.map +0 -1
  54. package/es2015/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +0 -367
  55. package/es2015/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +0 -1
  56. package/es2020/src/legacy/selector/components/inputDateTime/inputDateTime.component.js +0 -488
  57. package/es2020/src/legacy/selector/components/inputDateTime/inputDateTime.component.js.map +0 -1
  58. package/es2020/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +0 -367
  59. package/es2020/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +0 -1
  60. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.css +0 -9
  61. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.d.ts +0 -1
  62. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.d.ts.map +0 -1
  63. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.html +0 -10
  64. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.css +0 -9
  65. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts +0 -1
  66. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts.map +0 -1
  67. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.html +0 -9
@@ -109,4 +109,56 @@ export function getSingleDateTimeValue(value) {
109
109
  }
110
110
  return value;
111
111
  }
112
+ /**
113
+ * Parses raw value into internal value and value
114
+ * @param rawValue - Raw value to be parsed
115
+ * @param dateApi - Date api for manipulation with date
116
+ * @param dateTimeData - Object storing information about format
117
+ * @param valueProvider - Provider used for obtaining rounded value according format
118
+ */
119
+ export function parseRawInput(rawValue, dateApi, dateTimeData, valueProvider) {
120
+ if (!rawValue) {
121
+ return [null, null];
122
+ }
123
+ const internalValue = getInternalValue(rawValue, dateApi, dateTimeData, valueProvider);
124
+ const value = formatDateTime(internalValue, dateTimeData.valueFormat, dateTimeData.customFormat);
125
+ return [internalValue, value];
126
+ }
127
+ /**
128
+ * Gets internal value and fix lowest time difference
129
+ * @param value - Value to be get as internal value
130
+ * @param dateApi - Date api for manipulation with date
131
+ * @param dateTimeData - Object storing information about format
132
+ * @param valueProvider - Provider used for obtaining rounded value according format
133
+ */
134
+ export function getInternalValue(value, dateApi, dateTimeData, valueProvider) {
135
+ let internalValue = parseDateTime(value, dateApi, null, dateTimeData.customFormat);
136
+ if (isBlank(internalValue)) {
137
+ return;
138
+ }
139
+ //update for specified format, round value
140
+ //ranged value
141
+ if (Array.isArray(internalValue)) {
142
+ const [from, to] = internalValue;
143
+ if (from) {
144
+ const val = valueProvider.getValue(from.value, dateTimeData.customFormat).from;
145
+ if (val) {
146
+ internalValue[0] = dateApi.getValue(val, dateTimeData.customFormat);
147
+ }
148
+ }
149
+ if (to) {
150
+ const val = valueProvider.getValue(to.value, dateTimeData.customFormat).to;
151
+ if (val) {
152
+ internalValue[1] = dateApi.getValue(val, dateTimeData.customFormat);
153
+ }
154
+ }
155
+ }
156
+ else {
157
+ const val = valueProvider.getValue(internalValue.value, dateTimeData.customFormat).from;
158
+ if (val) {
159
+ internalValue = dateApi.getValue(val, dateTimeData.customFormat);
160
+ }
161
+ }
162
+ return internalValue;
163
+ }
112
164
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/misc/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAIhF,OAAO,EAAC,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAG5C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAkB,KAAqD,EACrD,OAAuB,EACvB,cAAkD,EAClD,YAAmC;IAE9E,IAAG,OAAO,CAAC,KAAK,CAAC,EACjB;QACI,OAAO,KAAK,CAAC;KAChB;IAED,qBAAqB;IACrB,IAAG,SAAS,CAAC,cAAc,CAAC,EAC5B;QACI,4DAA4D;QAC5D,IAAG,cAAc,IAAI,mBAAmB,CAAC,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,EACjF;YACI,MAAM,IAAI,KAAK,CAAC,mEAAmE,C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AC,YAAY,CAAC,CAAC;KACrC;IAED,IAAG,cAAc,IAAI,mBAAmB,CAAC,aAAa,EACtD;QACI,KAAK,CAAC,aAAa,EAAE,CAAC;KACzB;IAED,OAAO,KAAK,CAAC,KAAK,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAkB,KAAc;IAE3D,OAAO,UAAU,CAAC,KAAK,CAAC;QACjB,MAAM,CAAgB,MAAM,CAAC,IAAI,KAAK;QACtC,MAAM,CAAgB,IAAI,CAAC,IAAI,KAAK,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAQ,KAAqD;IAE/F,IAAG,eAAe,CAAC,KAAK,CAAC,EACzB;QACI,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;KAC7F;IAED,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import {isBlank, isJsObject, isPresent, isString, nameof} from '@jscrpt/common';\n\nimport {DateTimeValue} from '../interfaces';\nimport {DateApi, DateApiObject, DateValue} from '../services';\nimport {DateTimeValueFormat} from './enums';\nimport {DateTimeInputOutputValue, DateTimeObjectValue} from './types';\n\n/**\n * Parses date time input output value\n * @param value - Value to be parsed\n * @param dateApi - Date api used for obtaining result\n * @param dateTimeFormat - Date time format type, optional, if not specified autodetection of format will be used\n * @param stringFormat - String format for parsing string dates, required only for string dates\n */\nexport function parseDateTime<TDate = unknown>(value: DateTimeInputOutputValue<TDate>|undefined|null,\n dateApi: DateApi<TDate>,\n dateTimeFormat: DateTimeValueFormat|undefined|null,\n stringFormat: string|undefined|null,): DateTimeObjectValue<TDate>|undefined|null\n{\n if(isBlank(value))\n {\n return value;\n }\n\n //format is specified\n if(isPresent(dateTimeFormat))\n {\n //string format required, but format string was not provided\n if(dateTimeFormat == DateTimeValueFormat.FormattedString && isBlank(stringFormat))\n {\n throw new Error('DateTime: unable to parse string date, because format is missing!');\n }\n\n //value is range\n if(isDateTimeValue(value))\n {\n //requirested format is different\n if(dateTimeFormat != DateTimeValueFormat.RangeOfDateInstances)\n {\n throw new Error('DateTime: requested datetime format is not range, but value is range!');\n }\n\n return [\n isBlank(value.from) ? null : parseDateTime(value.from, dateApi, DateTimeValueFormat.DateInstance, null) as DateApiObject<TDate>,\n isBlank(value.to) ? null : parseDateTime(value.to, dateApi, DateTimeValueFormat.DateInstance, null) as DateApiObject<TDate>,\n ];\n }\n\n //value should be date instance, or number, or string, but it is not\n if(dateTimeFormat != DateTimeValueFormat.DateInstance &&\n dateTimeFormat != DateTimeValueFormat.FormattedString &&\n dateTimeFormat != DateTimeValueFormat.UnixTimestamp)\n {\n throw new Error('DateTime: unable to get date time value, should be date instance, or string, or number!');\n }\n\n //value is string, instance of date or unix timestamp\n return dateApi.getValue(value, stringFormat ?? undefined);\n }\n\n //value is range\n if(isDateTimeValue(value))\n {\n return [\n isBlank(value.from) ? null : parseDateTime(value.from, dateApi, DateTimeValueFormat.DateInstance, null) as DateApiObject<TDate>,\n isBlank(value.to) ? null : parseDateTime(value.to, dateApi, DateTimeValueFormat.DateInstance , null) as DateApiObject<TDate>,\n ];\n }\n\n //string format, but format string was not provided\n if(isString(value) && isBlank(stringFormat))\n {\n throw new Error('DateTime: unable to parse string date, because format is missing!');\n }\n\n //value is string, instance of date or unix timestamp\n return dateApi.getValue(value, stringFormat ?? undefined);\n}\n\n/**\n * Formats value into specified format of date time\n * @param value - Value that should be converted to input output date time value\n * @param dateTimeFormat - Date time format type\n * @param stringFormat - String format for parsing string dates, required only for string dates\n */\nexport function formatDateTime<TDate = unknown>(value: DateTimeObjectValue<TDate>|undefined|null,\n dateTimeFormat: DateTimeValueFormat,\n stringFormat: string|undefined|null): DateTimeInputOutputValue<TDate>|undefined|null\n{\n if(isBlank(value))\n {\n return value;\n }\n\n //value is range\n if(Array.isArray(value))\n {\n //range is expected\n if(dateTimeFormat != DateTimeValueFormat.RangeOfDateInstances)\n {\n throw new Error('DateTime: value is array of values, but format is not range!');\n }\n\n return {\n from: value[0]?.value ?? null,\n to: value[1]?.value ?? null,\n };\n }\n\n //range is not expected\n if(dateTimeFormat == DateTimeValueFormat.RangeOfDateInstances)\n {\n throw new Error('DateTime: value is not array of values, but format is range!');\n }\n\n //string date time\n if(dateTimeFormat == DateTimeValueFormat.FormattedString)\n {\n //string format is missing for string date time\n if(isBlank(stringFormat))\n {\n throw new Error('DateTime: missing string format for string date time!');\n }\n\n return value.format(stringFormat);\n }\n\n if(dateTimeFormat == DateTimeValueFormat.UnixTimestamp)\n {\n value.unixTimestamp();\n }\n\n return value.value;\n}\n\n/**\n * Tests whether value is `DateTimeValue`\n * @param value - Value that is tested\n */\nexport function isDateTimeValue<TDate = unknown>(value: unknown): value is DateTimeValue<TDate>\n{\n return isJsObject(value) &&\n nameof<DateTimeValue>('from') in value &&\n nameof<DateTimeValue>('to') in value;\n}\n\n/**\n * Gets single date time value, use in places where ranged date time can not be used\n * @param value - Value to be examined\n */\nexport function getSingleDateTimeValue<TDate>(value: DateTimeInputOutputValue<TDate>|undefined|null): DateValue|TDate|null|undefined\n{\n if(isDateTimeValue(value))\n {\n throw new Error('DateTime: Unable to apply ranged date time input as value restriction!');\n }\n\n return value;\n}"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/misc/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAKhF,OAAO,EAAC,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAG5C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAkB,KAAqD,EACrD,OAAuB,EACvB,cAAkD,EAClD,YAAmC;IAE9E,IAAG,OAAO,CAAC,KAAK,CAAC,EACjB;QACI,OAAO,KAAK,CAAC;KAChB;IAED,qBAAqB;IACrB,IAAG,SAAS,CAAC,cAAc,CAAC,EAC5B;QACI,4DAA4D;QAC5D,IAAG,cAAc,IAAI,mBAAmB,CA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YAAY,CAAC,YAAY,CAAC,CAAC;IAEnF,IAAG,OAAO,CAAC,aAAa,CAAC,EACzB;QACI,OAAO;KACV;IAED,0CAA0C;IAE1C,cAAc;IACd,IAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAC/B;QACI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,aAAa,CAAC;QAEjC,IAAG,IAAI,EACP;YACI,MAAM,GAAG,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC;YAE/E,IAAG,GAAG,EACN;gBACI,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;aACvE;SACJ;QAED,IAAG,EAAE,EACL;YACI,MAAM,GAAG,GAAG,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;YAE3E,IAAG,GAAG,EACN;gBACI,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;aACvE;SACJ;KACJ;SAED;QACI,MAAM,GAAG,GAAG,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC;QAExF,IAAG,GAAG,EACN;YACI,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;SACpE;KACJ;IAED,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["import {isBlank, isJsObject, isPresent, isString, nameof} from '@jscrpt/common';\n\nimport {DateTimeValue} from '../interfaces';\nimport type {DateTimeSADirective} from '../modules/dateTime/directives/dateTime/dateTime.directive';\nimport {DateApi, DateApiObject, DateValue, DateValueProvider} from '../services';\nimport {DateTimeValueFormat} from './enums';\nimport {DateTimeInputOutputValue, DateTimeObjectValue} from './types';\n\n/**\n * Parses date time input output value\n * @param value - Value to be parsed\n * @param dateApi - Date api used for obtaining result\n * @param dateTimeFormat - Date time format type, optional, if not specified autodetection of format will be used\n * @param stringFormat - String format for parsing string dates, required only for string dates\n */\nexport function parseDateTime<TDate = unknown>(value: DateTimeInputOutputValue<TDate>|undefined|null,\n dateApi: DateApi<TDate>,\n dateTimeFormat: DateTimeValueFormat|undefined|null,\n stringFormat: string|undefined|null,): DateTimeObjectValue<TDate>|undefined|null\n{\n if(isBlank(value))\n {\n return value;\n }\n\n //format is specified\n if(isPresent(dateTimeFormat))\n {\n //string format required, but format string was not provided\n if(dateTimeFormat == DateTimeValueFormat.FormattedString && isBlank(stringFormat))\n {\n throw new Error('DateTime: unable to parse string date, because format is missing!');\n }\n\n //value is range\n if(isDateTimeValue(value))\n {\n //requirested format is different\n if(dateTimeFormat != DateTimeValueFormat.RangeOfDateInstances)\n {\n throw new Error('DateTime: requested datetime format is not range, but value is range!');\n }\n\n return [\n isBlank(value.from) ? null : parseDateTime(value.from, dateApi, DateTimeValueFormat.DateInstance, null) as DateApiObject<TDate>,\n isBlank(value.to) ? null : parseDateTime(value.to, dateApi, DateTimeValueFormat.DateInstance, null) as DateApiObject<TDate>,\n ];\n }\n\n //value should be date instance, or number, or string, but it is not\n if(dateTimeFormat != DateTimeValueFormat.DateInstance &&\n dateTimeFormat != DateTimeValueFormat.FormattedString &&\n dateTimeFormat != DateTimeValueFormat.UnixTimestamp)\n {\n throw new Error('DateTime: unable to get date time value, should be date instance, or string, or number!');\n }\n\n //value is string, instance of date or unix timestamp\n return dateApi.getValue(value, stringFormat ?? undefined);\n }\n\n //value is range\n if(isDateTimeValue(value))\n {\n return [\n isBlank(value.from) ? null : parseDateTime(value.from, dateApi, DateTimeValueFormat.DateInstance, null) as DateApiObject<TDate>,\n isBlank(value.to) ? null : parseDateTime(value.to, dateApi, DateTimeValueFormat.DateInstance , null) as DateApiObject<TDate>,\n ];\n }\n\n //string format, but format string was not provided\n if(isString(value) && isBlank(stringFormat))\n {\n throw new Error('DateTime: unable to parse string date, because format is missing!');\n }\n\n //value is string, instance of date or unix timestamp\n return dateApi.getValue(value, stringFormat ?? undefined);\n}\n\n/**\n * Formats value into specified format of date time\n * @param value - Value that should be converted to input output date time value\n * @param dateTimeFormat - Date time format type\n * @param stringFormat - String format for parsing string dates, required only for string dates\n */\nexport function formatDateTime<TDate = unknown>(value: DateTimeObjectValue<TDate>|undefined|null,\n dateTimeFormat: DateTimeValueFormat,\n stringFormat: string|undefined|null): DateTimeInputOutputValue<TDate>|undefined|null\n{\n if(isBlank(value))\n {\n return value;\n }\n\n //value is range\n if(Array.isArray(value))\n {\n //range is expected\n if(dateTimeFormat != DateTimeValueFormat.RangeOfDateInstances)\n {\n throw new Error('DateTime: value is array of values, but format is not range!');\n }\n\n return {\n from: value[0]?.value ?? null,\n to: value[1]?.value ?? null,\n };\n }\n\n //range is not expected\n if(dateTimeFormat == DateTimeValueFormat.RangeOfDateInstances)\n {\n throw new Error('DateTime: value is not array of values, but format is range!');\n }\n\n //string date time\n if(dateTimeFormat == DateTimeValueFormat.FormattedString)\n {\n //string format is missing for string date time\n if(isBlank(stringFormat))\n {\n throw new Error('DateTime: missing string format for string date time!');\n }\n\n return value.format(stringFormat);\n }\n\n if(dateTimeFormat == DateTimeValueFormat.UnixTimestamp)\n {\n value.unixTimestamp();\n }\n\n return value.value;\n}\n\n/**\n * Tests whether value is `DateTimeValue`\n * @param value - Value that is tested\n */\nexport function isDateTimeValue<TDate = unknown>(value: unknown): value is DateTimeValue<TDate>\n{\n return isJsObject(value) &&\n nameof<DateTimeValue>('from') in value &&\n nameof<DateTimeValue>('to') in value;\n}\n\n/**\n * Gets single date time value, use in places where ranged date time can not be used\n * @param value - Value to be examined\n */\nexport function getSingleDateTimeValue<TDate>(value: DateTimeInputOutputValue<TDate>|undefined|null): DateValue|TDate|null|undefined\n{\n if(isDateTimeValue(value))\n {\n throw new Error('DateTime: Unable to apply ranged date time input as value restriction!');\n }\n\n return value;\n}\n\n/**\n * Parses raw value into internal value and value\n * @param rawValue - Raw value to be parsed\n * @param dateApi - Date api for manipulation with date\n * @param dateTimeData - Object storing information about format\n * @param valueProvider - Provider used for obtaining rounded value according format\n */\nexport function parseRawInput<TDate>(rawValue: string, \n dateApi: DateApi<TDate>,\n dateTimeData: DateTimeSADirective<TDate>,\n valueProvider: DateValueProvider<TDate>,): [DateTimeObjectValue<TDate>|undefined|null, DateTimeInputOutputValue<TDate>|undefined|null]\n{\n if(!rawValue)\n {\n return [null, null];\n }\n\n const internalValue = getInternalValue(rawValue, dateApi, dateTimeData, valueProvider);\n const value = formatDateTime(internalValue, dateTimeData.valueFormat, dateTimeData.customFormat);\n\n return [internalValue, value];\n}\n\n/**\n * Gets internal value and fix lowest time difference\n * @param value - Value to be get as internal value\n * @param dateApi - Date api for manipulation with date\n * @param dateTimeData - Object storing information about format\n * @param valueProvider - Provider used for obtaining rounded value according format\n */\nexport function getInternalValue<TDate>(value: DateTimeInputOutputValue<TDate>|undefined|null,\n dateApi: DateApi<TDate>,\n dateTimeData: DateTimeSADirective<TDate>,\n valueProvider: DateValueProvider<TDate>,): DateTimeObjectValue<TDate>|undefined|null\n{\n let internalValue = parseDateTime(value, dateApi, null, dateTimeData.customFormat);\n\n if(isBlank(internalValue))\n {\n return;\n }\n\n //update for specified format, round value\n\n //ranged value\n if(Array.isArray(internalValue))\n {\n const [from, to] = internalValue;\n\n if(from)\n {\n const val = valueProvider.getValue(from.value, dateTimeData.customFormat).from;\n\n if(val)\n {\n internalValue[0] = dateApi.getValue(val, dateTimeData.customFormat);\n }\n }\n\n if(to)\n {\n const val = valueProvider.getValue(to.value, dateTimeData.customFormat).to;\n\n if(val)\n {\n internalValue[1] = dateApi.getValue(val, dateTimeData.customFormat);\n }\n }\n }\n else\n {\n const val = valueProvider.getValue(internalValue.value, dateTimeData.customFormat).from;\n\n if(val)\n {\n internalValue = dateApi.getValue(val, dateTimeData.customFormat);\n }\n }\n\n return internalValue;\n}"]}
@@ -21,14 +21,18 @@ export class DateTimeSADirective {
21
21
  * Subject used for emitting changes in min date time value
22
22
  */
23
23
  this.minDateTimeChangesSubject = new Subject();
24
+ /**
25
+ * Subject used for emitting changes in custom format value
26
+ */
27
+ this.customFormatChangesSubject = new Subject();
24
28
  /**
25
29
  * Date time value format which is being worked with in this date time
26
30
  */
27
- this.ɵValueFormat = DateTimeValueFormat.DateInstance;
31
+ this.ɵvalueFormat = DateTimeValueFormat.DateInstance;
28
32
  /**
29
33
  * Format of string representation of date
30
34
  */
31
- this.ɵFormat = 'date';
35
+ this.ɵformat = 'date';
32
36
  /**
33
37
  * Date api instance, used for date time manipulation
34
38
  */
@@ -40,7 +44,7 @@ export class DateTimeSADirective {
40
44
  /**
41
45
  * Custom format string representation of date
42
46
  */
43
- this.customFormat = this.dateApi.getFormat(this.formatProvider[this.ɵFormat]);
47
+ thiscustomFormat = this.dateApi.getFormat(this.formatProvider[this.ɵformat]);
44
48
  }
45
49
  //######################### public properties #########################
46
50
  /**
@@ -55,35 +59,51 @@ export class DateTimeSADirective {
55
59
  get minDateTimeChanges() {
56
60
  return this.minDateTimeChangesSubject.asObservable();
57
61
  }
62
+ /**
63
+ * Occurs when there are changes in custom format value
64
+ */
65
+ get customFormatChanges() {
66
+ return this.customFormatChangesSubject.asObservable();
67
+ }
58
68
  //######################### public properties - inputs #########################
59
69
  /**
60
70
  * Gets or sets date time value format which is being worked with in this date time
61
71
  */
62
72
  get valueFormat() {
63
- return this.ɵValueFormat;
73
+ return this.ɵvalueFormat;
64
74
  }
65
75
  set valueFormat(value) {
66
76
  if (isString(value)) {
67
- this.ɵValueFormat = DateTimeValueFormat[value];
77
+ this.ɵvalueFormat = DateTimeValueFormat[value];
68
78
  return;
69
79
  }
70
- this.ɵValueFormat = value;
80
+ this.ɵvalueFormat = value;
71
81
  }
72
82
  /**
73
83
  * Gets or sets format of string representation of date
74
84
  */
75
85
  get format() {
76
- return this.ɵFormat;
86
+ return this.ɵformat;
77
87
  }
78
88
  set format(value) {
79
- this.ɵFormat = value;
89
+ this.ɵformat = value;
80
90
  this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);
81
91
  }
92
+ /**
93
+ * Gets or sets custom format string representation of date
94
+ */
95
+ get customFormat() {
96
+ return this.ɵcustomFormat;
97
+ }
98
+ set customFormat(value) {
99
+ this.ɵcustomFormat = value;
100
+ this.customFormatChangesSubject.next();
101
+ }
82
102
  /**
83
103
  * Gets or sets max allowed date for date time
84
104
  */
85
105
  get maxDateTime() {
86
- return this.ɵMaxDateTime;
106
+ return this.ɵmaxDateTime;
87
107
  }
88
108
  set maxDateTime(value) {
89
109
  var _a;
@@ -116,7 +136,7 @@ export class DateTimeSADirective {
116
136
  * Gets or sets min allowed date for date time
117
137
  */
118
138
  get minDateTime() {
119
- return this.ɵMinDateTime;
139
+ return this.ɵminDateTime;
120
140
  }
121
141
  set minDateTime(value) {
122
142
  var _a;
@@ -162,7 +182,7 @@ export class DateTimeSADirective {
162
182
  * @param value - Value to be set
163
183
  */
164
184
  minDateSet(value) {
165
- this.ɵMinDateTime = value;
185
+ this.ɵminDateTime = value;
166
186
  this.minDateTimeChangesSubject.next();
167
187
  this.onMinDateTimeChange();
168
188
  }
@@ -171,7 +191,7 @@ export class DateTimeSADirective {
171
191
  * @param value - Value to be set
172
192
  */
173
193
  maxDateSet(value) {
174
- this.ɵMaxDateTime = value;
194
+ this.ɵmaxDateTime = value;
175
195
  this.maxDateTimeChangesSubject.next();
176
196
  this.onMaxDateTimeChange();
177
197
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dateTime.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTime/dateTime.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AAClE,OAAO,EAAU,QAAQ,EAAE,OA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AmB;kBAL/B,SAAS;mBACV;oBACI,QAAQ,EAAE,YAAY;oBACtB,UAAU,EAAE,IAAI;iBACnB;8BA+Ec,WAAW;sBADrB,KAAK;gBAqBK,MAAM;sBADhB,KAAK;gBAeC,YAAY;sBADlB,KAAK;gBAOK,WAAW;sBADrB,KAAK;gBAsDK,WAAW;sBADrB,KAAK;gBAuEI,UAAU,MAYV,UAAU","sourcesContent":["import {Directive, inject, Input, OnDestroy} from '@angular/core';\nimport {Action1, BindThis, isBlank, isString} from '@jscrpt/common';\nimport {Observable, Subject, Subscription} from 'rxjs';\n\nimport {FormatProvider} from '../../../../interfaces';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\nimport {DATE_API, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue} from '../../../../misc/types';\nimport {getSingleDateTimeValue} from '../../../../misc/utils';\nimport {DateApi, DateValue} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\n\n/**\n * Directive that holds shared data for date time, like formats, restrictions\n */\n@Directive(\n{\n selector: '[dateTime]',\n standalone: true,\n})\nexport class DateTimeSADirective<TDate = unknown> implements OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subject used for emitting changes in max date time value\n */\n protected maxDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subject used for emitting changes in min date time value\n */\n protected minDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subscription for max date instance value changes\n */\n protected maxDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Subscription for min date instance value changes\n */\n protected minDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Max allowed value of date time\n */\n protected ɵMaxDateTime: TDate|undefined|null;\n\n /**\n * Min allowed value of date time\n */\n protected ɵMinDateTime: TDate|undefined|null;\n\n /**\n * Date time value format which is being worked with in this date time\n */\n protected ɵValueFormat: DateTimeValueFormat = DateTimeValueFormat.DateInstance;\n\n /**\n * Format of string representation of date\n */\n protected ɵFormat: keyof FormatProvider = 'date';\n\n /**\n * Date api instance, used for date time manipulation\n */\n protected dateApi: DateApi<TDate> = inject(DATE_API) as DateApi<TDate>;\n\n /**\n * Provider for available formats\n */\n protected formatProvider: FormatProvider = inject(FORMAT_PROVIDER);\n\n //######################### public properties #########################\n\n /**\n * Occurs when there are changes in max date time value\n */\n public get maxDateTimeChanges(): Observable<void>\n {\n return this.maxDateTimeChangesSubject.asObservable();\n }\n\n /**\n * Occurs when there are changes in min date time value\n */\n public get minDateTimeChanges(): Observable<void>\n {\n return this.minDateTimeChangesSubject.asObservable();\n }\n\n //######################### public properties - inputs #########################\n\n /**\n * Gets or sets date time value format which is being worked with in this date time\n */\n @Input()\n public get valueFormat(): DateTimeValueFormat\n {\n return this.ɵValueFormat;\n }\n public set valueFormat(value: DateTimeValueFormat)\n {\n if(isString(value))\n {\n this.ɵValueFormat = DateTimeValueFormat[value] as unknown as DateTimeValueFormat;\n\n return;\n }\n\n this.ɵValueFormat = value;\n }\n\n /**\n * Gets or sets format of string representation of date\n */\n @Input()\n public get format(): keyof FormatProvider\n {\n return this.ɵFormat;\n }\n public set format(value: keyof FormatProvider)\n {\n this.ɵFormat = value;\n this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);\n }\n\n /**\n * Custom format string representation of date\n */\n @Input()\n public customFormat: string = this.dateApi.getFormat(this.formatProvider[this.ɵFormat]);\n\n /**\n * Gets or sets max allowed date for date time\n */\n @Input()\n public get maxDateTime(): TDate|undefined|null\n {\n return this.ɵMaxDateTime;\n }\n public set maxDateTime(value: TDate|undefined|null)\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.maxDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase<TDate>)\n {\n this.maxDateInstanceChange = value.valueChange.subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.maxDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n val = v;\n }\n \n this.setMinMaxValue(val, this.maxDateSet);\n }\n\n /**\n * Gets or sets min allowed date for date time\n */\n @Input()\n public get minDateTime(): TDate|undefined|null\n {\n return this.ɵMinDateTime;\n }\n public set minDateTime(value: TDate|undefined|null)\n {\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.minDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase<TDate>)\n {\n this.minDateInstanceChange = value.valueChange.subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.minDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.minDateSet(null);\n\n return;\n }\n\n val = v;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets min date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected minDateSet(value: TDate|undefined|null): void\n {\n this.ɵMinDateTime = value;\n this.minDateTimeChangesSubject.next();\n this.onMinDateTimeChange();\n }\n\n /**\n * Sets max date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected maxDateSet(value: TDate|undefined|null): void\n {\n this.ɵMaxDateTime = value;\n this.maxDateTimeChangesSubject.next();\n this.onMaxDateTimeChange();\n }\n\n /**\n * Sets min or max date time value\n * @param value - Value to be set\n * @param setter - Action used for setting value\n */\n protected setMinMaxValue(value: DateValue|TDate, setter: Action1<TDate|undefined|null>): void\n {\n const val = this.dateApi.getValue(value, this.customFormat);\n\n if(val.isValid())\n {\n setter(val.value);\n }\n else\n {\n setter(null);\n }\n }\n\n /**\n * Called whenever max date time restriction changes\n */\n protected onMaxDateTimeChange(): void\n {\n }\n\n /**\n * Called whenever min date time restriction changes\n */\n protected onMinDateTimeChange(): void\n {\n }\n\n //######################### ng language server #########################\n \n /**\n * Custom input type for `valueFormat` input\n */\n public static ngAcceptInputType_valueFormat: keyof typeof DateTimeValueFormat|DateTimeValueFormat;\n\n /**\n * Custom input type for `maxDateTime` input\n */\n public static ngAcceptInputType_maxDateTime: DateValue|DateTimeBase;\n\n /**\n * Custom input type for `minDateTime` input\n */\n public static ngAcceptInputType_minDateTime: DateValue|DateTimeBase;\n}"]}
1
+ {"version":3,"file":"dateTime.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTime/dateTime.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AAClE,OAAO,EAAU,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAa,OAAO,EAAe,MAAM,MAAM,CAAC;AAGvD,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAC,sBAAsB,EAAC,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;;AAE7C;;GAEG;AAMH,MAAM,OAAO,mBAAmB;IALhC;QAOI,0EAA0E;QAE1E;;WAEG;QACO,8BAAyB,GAAkB,IAAI,OAAO,EAAQ,CAAC;QAEzE;;WAEG;QACO,8BAAyB,GAAkB,I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BADrB,KAAK;gBAqBK,MAAM;sBADhB,KAAK;gBAeK,YAAY;sBADtB,KAAK;gBAeK,WAAW;sBADrB,KAAK;gBAsDK,WAAW;sBADrB,KAAK;gBAuEI,UAAU,MAYV,UAAU","sourcesContent":["import {Directive, inject, Input, OnDestroy} from '@angular/core';\nimport {Action1, BindThis, isBlank, isString} from '@jscrpt/common';\nimport {Observable, Subject, Subscription} from 'rxjs';\n\nimport {FormatProvider} from '../../../../interfaces';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\nimport {DATE_API, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue} from '../../../../misc/types';\nimport {getSingleDateTimeValue} from '../../../../misc/utils';\nimport {DateApi, DateValue} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\n\n/**\n * Directive that holds shared data for date time, like formats, restrictions\n */\n@Directive(\n{\n selector: '[dateTime]',\n standalone: true,\n})\nexport class DateTimeSADirective<TDate = unknown> implements OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subject used for emitting changes in max date time value\n */\n protected maxDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subject used for emitting changes in min date time value\n */\n protected minDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subject used for emitting changes in custom format value\n */\n protected customFormatChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subscription for max date instance value changes\n */\n protected maxDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Subscription for min date instance value changes\n */\n protected minDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Max allowed value of date time\n */\n protected ɵmaxDateTime: TDate|undefined|null;\n\n /**\n * Min allowed value of date time\n */\n protected ɵminDateTime: TDate|undefined|null;\n\n /**\n * Date time value format which is being worked with in this date time\n */\n protected ɵvalueFormat: DateTimeValueFormat = DateTimeValueFormat.DateInstance;\n\n /**\n * Format of string representation of date\n */\n protected ɵformat: keyof FormatProvider = 'date';\n\n /**\n * Date api instance, used for date time manipulation\n */\n protected dateApi: DateApi<TDate> = inject(DATE_API) as DateApi<TDate>;\n\n /**\n * Provider for available formats\n */\n protected formatProvider: FormatProvider = inject(FORMAT_PROVIDER);\n\n /**\n * Custom format string representation of date\n */\n protected ɵcustomFormat: string = this.dateApi.getFormat(this.formatProvider[this.ɵformat]);\n\n //######################### public properties #########################\n\n /**\n * Occurs when there are changes in max date time value\n */\n public get maxDateTimeChanges(): Observable<void>\n {\n return this.maxDateTimeChangesSubject.asObservable();\n }\n\n /**\n * Occurs when there are changes in min date time value\n */\n public get minDateTimeChanges(): Observable<void>\n {\n return this.minDateTimeChangesSubject.asObservable();\n }\n\n /**\n * Occurs when there are changes in custom format value\n */\n public get customFormatChanges(): Observable<void>\n {\n return this.customFormatChangesSubject.asObservable();\n }\n\n //######################### public properties - inputs #########################\n\n /**\n * Gets or sets date time value format which is being worked with in this date time\n */\n @Input()\n public get valueFormat(): DateTimeValueFormat\n {\n return this.ɵvalueFormat;\n }\n public set valueFormat(value: DateTimeValueFormat)\n {\n if(isString(value))\n {\n this.ɵvalueFormat = DateTimeValueFormat[value] as unknown as DateTimeValueFormat;\n\n return;\n }\n\n this.ɵvalueFormat = value;\n }\n\n /**\n * Gets or sets format of string representation of date\n */\n @Input()\n public get format(): keyof FormatProvider\n {\n return this.ɵformat;\n }\n public set format(value: keyof FormatProvider)\n {\n this.ɵformat = value;\n this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);\n }\n\n /**\n * Gets or sets custom format string representation of date\n */\n @Input()\n public get customFormat(): string\n {\n return this.ɵcustomFormat;\n }\n public set customFormat(value: string)\n {\n this.ɵcustomFormat = value;\n this.customFormatChangesSubject.next();\n }\n\n /**\n * Gets or sets max allowed date for date time\n */\n @Input()\n public get maxDateTime(): TDate|undefined|null\n {\n return this.ɵmaxDateTime;\n }\n public set maxDateTime(value: TDate|undefined|null)\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.maxDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase<TDate>)\n {\n this.maxDateInstanceChange = value.valueChange.subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.maxDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n val = v;\n }\n \n this.setMinMaxValue(val, this.maxDateSet);\n }\n\n /**\n * Gets or sets min allowed date for date time\n */\n @Input()\n public get minDateTime(): TDate|undefined|null\n {\n return this.ɵminDateTime;\n }\n public set minDateTime(value: TDate|undefined|null)\n {\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.minDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase<TDate>)\n {\n this.minDateInstanceChange = value.valueChange.subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.minDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.minDateSet(null);\n\n return;\n }\n\n val = v;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets min date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected minDateSet(value: TDate|undefined|null): void\n {\n this.ɵminDateTime = value;\n this.minDateTimeChangesSubject.next();\n this.onMinDateTimeChange();\n }\n\n /**\n * Sets max date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected maxDateSet(value: TDate|undefined|null): void\n {\n this.ɵmaxDateTime = value;\n this.maxDateTimeChangesSubject.next();\n this.onMaxDateTimeChange();\n }\n\n /**\n * Sets min or max date time value\n * @param value - Value to be set\n * @param setter - Action used for setting value\n */\n protected setMinMaxValue(value: DateValue|TDate, setter: Action1<TDate|undefined|null>): void\n {\n const val = this.dateApi.getValue(value, this.customFormat);\n\n if(val.isValid())\n {\n setter(val.value);\n }\n else\n {\n setter(null);\n }\n }\n\n /**\n * Called whenever max date time restriction changes\n */\n protected onMaxDateTimeChange(): void\n {\n }\n\n /**\n * Called whenever min date time restriction changes\n */\n protected onMinDateTimeChange(): void\n {\n }\n\n //######################### ng language server #########################\n \n /**\n * Custom input type for `valueFormat` input\n */\n public static ngAcceptInputType_valueFormat: keyof typeof DateTimeValueFormat|DateTimeValueFormat;\n\n /**\n * Custom input type for `maxDateTime` input\n */\n public static ngAcceptInputType_maxDateTime: DateValue|DateTimeBase;\n\n /**\n * Custom input type for `minDateTime` input\n */\n public static ngAcceptInputType_minDateTime: DateValue|DateTimeBase;\n}"]}
@@ -0,0 +1,37 @@
1
+ import { Directive } from '@angular/core';
2
+ import { DateTimeInputSADirective, DateTimePickerSADirective } from '../../modules';
3
+ import { DateTimeInputHandlerSADirective } from '../dateTimeInputHandler/dateTimeInputHandler.directive';
4
+ import * as i0 from "@angular/core";
5
+ import * as i1 from "../../modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive";
6
+ import * as i2 from "../../modules/dateTime/directives/dateTimeInput/dateTimeInput.directive";
7
+ import * as i3 from "../dateTimeInputHandler/dateTimeInputHandler.directive";
8
+ /**
9
+ * Directive that combines date picker with date input
10
+ */
11
+ export class DatePickerInputSADirective {
12
+ }
13
+ DatePickerInputSADirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: DatePickerInputSADirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
14
+ DatePickerInputSADirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: DatePickerInputSADirective, isStandalone: true, selector: "input[dateTime][datePickerInput]", hostDirectives: [{ directive: i1.DateTimePickerSADirective, inputs: ["withPickerOptions", "withPickerOptions", "pickerOptions", "pickerOptions"] }, { directive: i2.DateTimeInputSADirective }, { directive: i3.DateTimeInputHandlerSADirective }], ngImport: i0 });
15
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: DatePickerInputSADirective, decorators: [{
16
+ type: Directive,
17
+ args: [{
18
+ selector: 'input[dateTime][datePickerInput]',
19
+ standalone: true,
20
+ hostDirectives: [
21
+ {
22
+ directive: DateTimePickerSADirective,
23
+ inputs: [
24
+ 'withPickerOptions',
25
+ 'pickerOptions',
26
+ ]
27
+ },
28
+ {
29
+ directive: DateTimeInputSADirective,
30
+ },
31
+ {
32
+ directive: DateTimeInputHandlerSADirective,
33
+ },
34
+ ],
35
+ }]
36
+ }] });
37
+ //# sourceMappingURL=datePickerInput.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datePickerInput.directive.js","sourceRoot":"","sources":["../../../../src/directives/datePickerInput/datePickerInput.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC,OAAO,EAAC,wBAAwB,EAAE,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAClF,OAAO,EAAC,+BAA+B,EAAC,MAAM,wDAAwD,CAAC;;;;;AAEvG;;GAEG;AAuBH,MAAM,OAAO,0BAA0B;;uHAA1B,0BAA0B;2GAA1B,0BAA0B;2FAA1B,0BAA0B;kBAtBtC,SAAS;mBACV;oBACI,QAAQ,EAAE,kCAAkC;oBAC5C,UAAU,EAAE,IAAI;oBAChB,cAAc,EACd;wBACI;4BACI,SAAS,EAAE,yBAAyB;4BACpC,MAAM,EACN;gCACI,mBAAmB;gCACnB,eAAe;6BAClB;yBACJ;wBACD;4BACI,SAAS,EAAE,wBAAwB;yBACtC;wBACD;4BACI,SAAS,EAAE,+BAA+B;yBAC7C;qBACJ;iBACJ","sourcesContent":["import {Directive} from '@angular/core';\n\nimport {DateTimeInputSADirective, DateTimePickerSADirective} from '../../modules';\nimport {DateTimeInputHandlerSADirective} from '../dateTimeInputHandler/dateTimeInputHandler.directive';\n\n/**\n * Directive that combines date picker with date input\n */\n@Directive(\n{\n selector: 'input[dateTime][datePickerInput]',\n standalone: true,\n hostDirectives:\n [\n {\n directive: DateTimePickerSADirective,\n inputs:\n [\n 'withPickerOptions',\n 'pickerOptions',\n ]\n },\n {\n directive: DateTimeInputSADirective,\n },\n {\n directive: DateTimeInputHandlerSADirective,\n },\n ],\n})\nexport class DatePickerInputSADirective\n{\n}"]}