@beinformed/ui 1.59.5 → 1.59.6

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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.59.6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.59.5...v1.59.6) (2024-12-11)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **datetime:** improve date input format for timestamps ([d250b03](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d250b03cffefd59ba9a45c0708e1f44f7c343031))
11
+
5
12
  ## [1.59.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.59.4...v1.59.5) (2024-12-11)
6
13
 
7
14
 
@@ -215,17 +215,24 @@ class DatetimeAttributeModel extends StringAttributeModel {
215
215
  if (this._dateInputFormat) {
216
216
  return this._dateInputFormat;
217
217
  }
218
-
219
- // remove time and offset tokens
220
- const charsToRemove = "HhaKmsSzXxO:";
218
+ const dateEraChars = "yMLdQDEewGu";
219
+ const timeOffsetChars = "HhaKmsSZzXxO";
220
+ const format = this.format;
221
221
  let inputFormat = "";
222
222
  let isInQuotes = false;
223
- for (let i = 0; i < this.format.length; i++) {
224
- const char = this.format[i];
223
+ let isInDate = false;
224
+ for (let i = 0; i < format.length; i++) {
225
+ const char = format[i];
225
226
  if (char === "'") {
226
- isInQuotes = !isInQuotes;
227
+ const prevChar = i > 0 ? format[i - 1] : "";
228
+ const nextChar = format[i + 1];
229
+ isInQuotes = prevChar === "'" || nextChar === "'" ? true : !isInQuotes;
230
+ } else if (!isInQuotes && _includesInstanceProperty(dateEraChars).call(dateEraChars, char)) {
231
+ isInDate = true;
232
+ } else if (!isInQuotes && _includesInstanceProperty(timeOffsetChars).call(timeOffsetChars, char)) {
233
+ isInDate = false;
227
234
  }
228
- if (isInQuotes || !_includesInstanceProperty(charsToRemove).call(charsToRemove, char)) {
235
+ if (isInDate) {
229
236
  inputFormat += char;
230
237
  }
231
238
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DatetimeAttributeModel.js","names":["has","DateUtil","DateTimeUtil","TimeUtil","TimestampUtil","StringAttributeModel","ConstraintCollection","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","DateBoundaryConstraint","isIncludeTimeOffsetInDateTimes","ATTRIBUTE_WIDTH","DATETIME_OFFSET_FORMAT","ISO_DATE_FORMAT","DatetimeAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty","updateInitValue","isApplicableModel","contributions","_context","_includesInstanceProperty","call","type","formatUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","oldOffset","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trimInstanceProperty","_dateInputFormat","charsToRemove","isInQuotes","i","char","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","_errorCollection","getFormatConstraint","addConstraints","constraints","add","readonlyWidth","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type,\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\n\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormatWithoutOffset(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (this._dateInputFormat) {\n return this._dateInputFormat;\n }\n\n // remove time and offset tokens\n const charsToRemove = \"HhaKmsSzXxO:\";\n\n let inputFormat = \"\";\n let isInQuotes = false;\n for (let i = 0; i < this.format.length; i++) {\n const char = this.format[i];\n if (char === \"'\") {\n isInQuotes = !isInQuotes;\n }\n if (isInQuotes || !charsToRemove.includes(char)) {\n inputFormat += char;\n }\n }\n\n this._dateInputFormat = inputFormat.trim();\n return this._dateInputFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n * return attribute placeholder or return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n if (this._timeInputFormat) {\n return this._timeInputFormat;\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n /**\n * format value in readonly rendering\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel,\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel,\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel,\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat,\n ),\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n\n /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,SACEC,QAAQ,EACRC,YAAY,EACZC,QAAQ,EACRC,aAAa,QACR,mCAAmC;AAE1C,OAAOC,oBAAoB,MAAM,wBAAwB;AAEzD,OAAOC,oBAAoB,MAAM,0CAA0C;AAC3E,OAAOC,4BAA4B,MAAM,kDAAkD;AAC3F,OAAOC,4BAA4B,MAAM,kDAAkD;AAC3F,OAAOC,wBAAwB,MAAM,8CAA8C;AACnF,OAAOC,sBAAsB,MAAM,4CAA4C;AAE/E,SACEC,8BAA8B,EAC9BC,eAAe,EACfC,sBAAsB,EACtBC,eAAe,QACV,iBAAiB;AAUxB;AACA;AACA,MAAMC,sBAAsB,SAASV,oBAAoB,CAAC;EAIxD;AACF;EACEW,WAAWA,CACTC,SAAiB,EACjBC,sBAA8B,EAC9BC,YAA2B,EAC3B;IACA,KAAK,CAACF,SAAS,EAAEC,sBAAsB,EAAEC,YAAY,CAAC;IAACC,eAAA;IAAAA,eAAA;IAEvD,IAAI,CAACC,eAAe,CAAC,CAAC;EACxB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,aAAqB,EAAW;IAAA,IAAAC,QAAA;IACvD,OAAOC,yBAAA,CAAAD,QAAA,IAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,EAAAE,IAAA,CAAAF,QAAA,EAC9CD,aAAa,CAACI,IAChB,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,UAAU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xB,IAAI,CAACiB,IAAI,EACT,IAAI,CAACoE,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAACvC,WACP,CACF,CAAC;IACH;IAEA,OAAOiD,WAAW;EACpB;;EAEA;AACF;EACE,IAAIE,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAACjF,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOf,eAAe,CAACiG,KAAK;IAC9B;IAEA,OAAOjG,eAAe,CAACkG,MAAM;EAC/B;;EAEA;AACF;EACEC,iBAAiBA,CAACC,cAA6B,EAAQ;IACrD,IAAI,CAACC,KAAK,CAAC,CAAC;IACZ,IAAID,cAAc,YAAYjG,sBAAsB,EAAE;MACpD,MAAMmG,UAAU,GAAGF,cAAc,CAAClF,KAAK;MACvC,IAAIoF,UAAU,IAAI,IAAI,EAAE;QACtB,MAAMC,UAAU,GAAG,IAAI,CAACvF,UAAU,CAACK,QAAQ,CACzCiF,UAAU,EACV,IAAI,CAACzD,WACP,CAAC;QACD,IAAI,CAAC2D,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAACnB,KAAK,CACX,qCAAqCc,cAAc,CAACrF,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAEA,eAAeZ,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"DatetimeAttributeModel.js","names":["has","DateUtil","DateTimeUtil","TimeUtil","TimestampUtil","StringAttributeModel","ConstraintCollection","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","DateBoundaryConstraint","isIncludeTimeOffsetInDateTimes","ATTRIBUTE_WIDTH","DATETIME_OFFSET_FORMAT","ISO_DATE_FORMAT","DatetimeAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty","updateInitValue","isApplicableModel","contributions","_context","_includesInstanceProperty","call","type","formatUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","oldOffset","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trimInstanceProperty","_dateInputFormat","dateEraChars","timeOffsetChars","isInQuotes","isInDate","i","char","prevChar","nextChar","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","_errorCollection","getFormatConstraint","addConstraints","constraints","add","readonlyWidth","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type,\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\n\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormatWithoutOffset(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (this._dateInputFormat) {\n return this._dateInputFormat;\n }\n\n const dateEraChars = \"yMLdQDEewGu\";\n const timeOffsetChars = \"HhaKmsSZzXxO\";\n\n const format = this.format;\n let inputFormat = \"\";\n\n let isInQuotes = false;\n let isInDate = false;\n\n for (let i = 0; i < format.length; i++) {\n const char = format[i];\n if (char === \"'\") {\n const prevChar = i > 0 ? format[i - 1] : \"\";\n const nextChar = format[i + 1];\n isInQuotes = prevChar === \"'\" || nextChar === \"'\" ? true : !isInQuotes;\n } else if (!isInQuotes && dateEraChars.includes(char)) {\n isInDate = true;\n } else if (!isInQuotes && timeOffsetChars.includes(char)) {\n isInDate = false;\n }\n\n if (isInDate) {\n inputFormat += char;\n }\n }\n\n this._dateInputFormat = inputFormat.trim();\n return this._dateInputFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n * return attribute placeholder or return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n if (this._timeInputFormat) {\n return this._timeInputFormat;\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n /**\n * format value in readonly rendering\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel,\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel,\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel,\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat,\n ),\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n\n /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n}\n\nexport default Datetim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MC,WAAW,GAAG,IAAIxG,oBAAoB,CAAC,CAAC;IAE9CwG,WAAW,CAACC,GAAG,CAAC,IAAI,CAACH,mBAAmB,CAAC,CAAC,CAAC;IAE3C,IAAI,IAAI,CAACT,OAAO,IAAI,IAAI,CAACC,OAAO,EAAE;MAChCU,WAAW,CAACC,GAAG,CACb,IAAIrG,sBAAsB,CACxB,IAAI,CAACiB,IAAI,EACT,IAAI,CAACwE,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAAC3C,WACP,CACF,CAAC;IACH;IAEA,OAAOqD,WAAW;EACpB;;EAEA;AACF;EACE,IAAIE,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAACrF,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOf,eAAe,CAACqG,KAAK;IAC9B;IAEA,OAAOrG,eAAe,CAACsG,MAAM;EAC/B;;EAEA;AACF;EACEC,iBAAiBA,CAACC,cAA6B,EAAQ;IACrD,IAAI,CAACC,KAAK,CAAC,CAAC;IACZ,IAAID,cAAc,YAAYrG,sBAAsB,EAAE;MACpD,MAAMuG,UAAU,GAAGF,cAAc,CAACtF,KAAK;MACvC,IAAIwF,UAAU,IAAI,IAAI,EAAE;QACtB,MAAMC,UAAU,GAAG,IAAI,CAAC3F,UAAU,CAACK,QAAQ,CACzCqF,UAAU,EACV,IAAI,CAAC7D,WACP,CAAC;QACD,IAAI,CAAC+D,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAACnB,KAAK,CACX,qCAAqCc,cAAc,CAACzF,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAEA,eAAeZ,sBAAsB","ignoreList":[]}
@@ -222,17 +222,24 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
222
222
  if (this._dateInputFormat) {
223
223
  return this._dateInputFormat;
224
224
  }
225
-
226
- // remove time and offset tokens
227
- const charsToRemove = "HhaKmsSzXxO:";
225
+ const dateEraChars = "yMLdQDEewGu";
226
+ const timeOffsetChars = "HhaKmsSZzXxO";
227
+ const format = this.format;
228
228
  let inputFormat = "";
229
229
  let isInQuotes = false;
230
- for (let i = 0; i < this.format.length; i++) {
231
- const char = this.format[i];
230
+ let isInDate = false;
231
+ for (let i = 0; i < format.length; i++) {
232
+ const char = format[i];
232
233
  if (char === "'") {
233
- isInQuotes = !isInQuotes;
234
+ const prevChar = i > 0 ? format[i - 1] : "";
235
+ const nextChar = format[i + 1];
236
+ isInQuotes = prevChar === "'" || nextChar === "'" ? true : !isInQuotes;
237
+ } else if (!isInQuotes && (0, _includes.default)(dateEraChars).call(dateEraChars, char)) {
238
+ isInDate = true;
239
+ } else if (!isInQuotes && (0, _includes.default)(timeOffsetChars).call(timeOffsetChars, char)) {
240
+ isInDate = false;
234
241
  }
235
- if (isInQuotes || !(0, _includes.default)(charsToRemove).call(charsToRemove, char)) {
242
+ if (isInDate) {
236
243
  inputFormat += char;
237
244
  }
238
245
  }
@@ -276,17 +276,28 @@ class DatetimeAttributeModel extends StringAttributeModel {
276
276
  return this._dateInputFormat;
277
277
  }
278
278
 
279
- // remove time and offset tokens
280
- const charsToRemove = "HhaKmsSzXxO:";
279
+ const dateEraChars = "yMLdQDEewGu";
280
+ const timeOffsetChars = "HhaKmsSZzXxO";
281
281
 
282
+ const format = this.format;
282
283
  let inputFormat = "";
284
+
283
285
  let isInQuotes = false;
284
- for (let i = 0; i < this.format.length; i++) {
285
- const char = this.format[i];
286
+ let isInDate = false;
287
+
288
+ for (let i = 0; i < format.length; i++) {
289
+ const char = format[i];
286
290
  if (char === "'") {
287
- isInQuotes = !isInQuotes;
291
+ const prevChar = i > 0 ? format[i - 1] : "";
292
+ const nextChar = format[i + 1];
293
+ isInQuotes = prevChar === "'" || nextChar === "'" ? true : !isInQuotes;
294
+ } else if (!isInQuotes && dateEraChars.includes(char)) {
295
+ isInDate = true;
296
+ } else if (!isInQuotes && timeOffsetChars.includes(char)) {
297
+ isInDate = false;
288
298
  }
289
- if (isInQuotes || !charsToRemove.includes(char)) {
299
+
300
+ if (isInDate) {
290
301
  inputFormat += char;
291
302
  }
292
303
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DatetimeAttributeModel.js","names":["_objects","require","_DateTimeUtil","_StringAttributeModel","_interopRequireDefault","_ConstraintCollection","_DateTimeDateFormatConstraint","_DateTimeTimeFormatConstraint","_DatetimeFormatConstraint","_DateBoundaryConstraint","_constants","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty2","default","updateInitValue","isApplicableModel","contributions","_context","_includes","call","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","isIncludeTimeOffsetInDateTimes","oldOffset","DATETIME_OFFSET_FORMAT","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trim","_dateInputFormat","charsToRemove","isInQuotes","i","char","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","has","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console","_default","exports"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type,\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\n\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormatWithoutOffset(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (this._dateInputFormat) {\n return this._dateInputFormat;\n }\n\n // remove time and offset tokens\n const charsToRemove = \"HhaKmsSzXxO:\";\n\n let inputFormat = \"\";\n let isInQuotes = false;\n for (let i = 0; i < this.format.length; i++) {\n const char = this.format[i];\n if (char === \"'\") {\n isInQuotes = !isInQuotes;\n }\n if (isInQuotes || !charsToRemove.includes(char)) {\n inputFormat += char;\n }\n }\n\n this._dateInputFormat = inputFormat.trim();\n return this._dateInputFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n * return attribute placeholder or return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n if (this._timeInputFormat) {\n return this._timeInputFormat;\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n /**\n * format value in readonly rendering\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel,\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel,\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel,\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat,\n ),\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n\n /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAOA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,qBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,6BAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,6BAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,yBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,uBAAA,GAAAL,sBAAA,CAAAH,OAAA;AAEA,IAAAS,UAAA,GAAAT,OAAA;AAeA;AACA;AACA,MAAMU,sBAAsB,SAASC,6BAAoB,CAAC;EAIxD;AACF;EACEC,WAAWA,CACTC,SAAiB,EACjBC,sBAA8B,EAC9BC,YAA2B,EAC3B;IACA,KAAK,CAACF,SAAS,EAAEC,sBAAsB,EAAEC,YAAY,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEvD,IAAI,CAACC,eAAe,CAAC,CAAC;EACxB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,aAAqB,EAAW;IAAA,IAAAC,QAAA;IACvD,OAAO,IAAAC,SAAA,CAAAL,OAAA,EA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AAC1B,KAAK,CACX,qCAAqCqB,cAAc,CAACnG,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAAC,IAAAyG,QAAA,GAAAC,OAAA,CAAAjH,OAAA,GAEcP,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"DatetimeAttributeModel.js","names":["_objects","require","_DateTimeUtil","_StringAttributeModel","_interopRequireDefault","_ConstraintCollection","_DateTimeDateFormatConstraint","_DateTimeTimeFormatConstraint","_DatetimeFormatConstraint","_DateBoundaryConstraint","_constants","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty2","default","updateInitValue","isApplicableModel","contributions","_context","_includes","call","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","isIncludeTimeOffsetInDateTimes","oldOffset","DATETIME_OFFSET_FORMAT","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trim","_dateInputFormat","dateEraChars","timeOffsetChars","isInQuotes","isInDate","i","char","prevChar","nextChar","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","has","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console","_default","exports"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type,\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\n\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormatWithoutOffset(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (this._dateInputFormat) {\n return this._dateInputFormat;\n }\n\n const dateEraChars = \"yMLdQDEewGu\";\n const timeOffsetChars = \"HhaKmsSZzXxO\";\n\n const format = this.format;\n let inputFormat = \"\";\n\n let isInQuotes = false;\n let isInDate = false;\n\n for (let i = 0; i < format.length; i++) {\n const char = format[i];\n if (char === \"'\") {\n const prevChar = i > 0 ? format[i - 1] : \"\";\n const nextChar = format[i + 1];\n isInQuotes = prevChar === \"'\" || nextChar === \"'\" ? true : !isInQuotes;\n } else if (!isInQuotes && dateEraChars.includes(char)) {\n isInDate = true;\n } else if (!isInQuotes && timeOffsetChars.includes(char)) {\n isInDate = false;\n }\n\n if (isInDate) {\n inputFormat += char;\n }\n }\n\n this._dateInputFormat = inputFormat.trim();\n return this._dateInputFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n * return attribute placeholder or return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n if (this._timeInputFormat) {\n return this._timeInputFormat;\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n /**\n * format value in readonly rendering\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel,\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel,\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel,\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat,\n ),\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n\n /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAOA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,qBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,6BAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,6BAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,yBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,uBAAA,GAAAL,sBAAA,CAAAH,OAAA;AAEA,IAAAS,UAAA,GAAAT,OAAA;AAeA;AACA;AACA,MAAMU,sBAAsB,SAASC,6BAAoB,CAAC;EAIxD;AACF;EACEC,WAAWA,CACTC,SAAiB,EACjBC,sBAA8B,EAC9BC,YAA2B,EAC3B;IACA,KAAK,CAACF,SAAS,EA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AO,EAAE;MAChCc,WAAW,CAACE,GAAG,CACb,IAAIC,+BAAsB,CACxB,IAAI,CAACjG,IAAI,EACT,IAAI,CAAC+E,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAAC5C,WACP,CACF,CAAC;IACH;IAEA,OAAO0D,WAAW;EACpB;;EAEA;AACF;EACE,IAAII,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAAClG,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOmG,0BAAe,CAACC,KAAK;IAC9B;IAEA,OAAOD,0BAAe,CAACE,MAAM;EAC/B;;EAEA;AACF;EACEC,iBAAiBA,CAACC,cAA6B,EAAQ;IACrD,IAAI,CAACC,KAAK,CAAC,CAAC;IACZ,IAAID,cAAc,YAAYrH,sBAAsB,EAAE;MACpD,MAAMuH,UAAU,GAAGF,cAAc,CAAChG,KAAK;MACvC,IAAIkG,UAAU,IAAI,IAAI,EAAE;QACtB,MAAMC,UAAU,GAAG,IAAI,CAACzG,UAAU,CAACS,QAAQ,CACzC+F,UAAU,EACV,IAAI,CAACrE,WACP,CAAC;QACD,IAAI,CAACuE,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAAC1B,KAAK,CACX,qCAAqCqB,cAAc,CAACvG,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAAC,IAAA6G,QAAA,GAAAC,OAAA,CAAArH,OAAA,GAEcP,sBAAsB","ignoreList":[]}
@@ -304,20 +304,42 @@ describe("datetimeAttributeModel with offset on", () => {
304
304
  });
305
305
  });
306
306
 
307
- it("Date format with offset info", () => {
308
- const attribute = new DatetimeAttributeModel(
307
+ it("Date formats", () => {
308
+ const datetime = new DatetimeAttributeModel(
309
309
  { key: "datetime", value: "1969-09-23T12:34:00+00:00" },
310
310
  {
311
311
  type: "datetime",
312
- label: "Start date and time at company",
313
- mandatory: false,
314
- formatlabel: "dd-mm-yyyy hh:mm",
315
- assistant: "The date and time of the first working day",
316
312
  format: "dd-MM-yyyy HH:mm X",
317
313
  },
318
314
  );
319
315
 
320
- expect(attribute.format).toBe("dd-MM-yyyy HH:mm X");
321
- expect(attribute.errorCollection.isEmpty).toBe(true);
316
+ expect(datetime.format).toBe("dd-MM-yyyy HH:mm X");
317
+ expect(datetime.dateInputFormat).toBe("dd-MM-yyyy");
318
+ expect(datetime.timeInputFormat).toBe("HH:mm");
319
+ expect(datetime.errorCollection.isEmpty).toBe(true);
320
+
321
+ const timestamp = new DatetimeAttributeModel(
322
+ { key: "timestamp", value: "1969-09-23T12:34:00.010+00:00" },
323
+ {
324
+ type: "timestamp",
325
+ format: "dd-MM-yyyy HH:mm:ss.SSS X",
326
+ },
327
+ );
328
+
329
+ expect(timestamp.format).toBe("dd-MM-yyyy HH:mm:ss.SSS X");
330
+ expect(timestamp.dateInputFormat).toBe("dd-MM-yyyy");
331
+ expect(timestamp.timeInputFormat).toBe("HH:mm:ss.SSS");
332
+
333
+ const special = new DatetimeAttributeModel(
334
+ { key: "timestamp", value: "1969-09-23T12:34:00.010+00:00" },
335
+ {
336
+ type: "timestamp",
337
+ format: "'special' do 'de' MMMM yyyy h 'o''clock'",
338
+ },
339
+ );
340
+
341
+ expect(special.format).toBe("'special' do 'de' MMMM yyyy h 'o''clock'");
342
+ expect(special.dateInputFormat).toBe("do 'de' MMMM yyyy");
343
+ // expect(special.timeInputFormat).toBe("HH:mm:ss.SSS");
322
344
  });
323
345
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.59.5",
3
+ "version": "1.59.6",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -276,17 +276,28 @@ class DatetimeAttributeModel extends StringAttributeModel {
276
276
  return this._dateInputFormat;
277
277
  }
278
278
 
279
- // remove time and offset tokens
280
- const charsToRemove = "HhaKmsSzXxO:";
279
+ const dateEraChars = "yMLdQDEewGu";
280
+ const timeOffsetChars = "HhaKmsSZzXxO";
281
281
 
282
+ const format = this.format;
282
283
  let inputFormat = "";
284
+
283
285
  let isInQuotes = false;
284
- for (let i = 0; i < this.format.length; i++) {
285
- const char = this.format[i];
286
+ let isInDate = false;
287
+
288
+ for (let i = 0; i < format.length; i++) {
289
+ const char = format[i];
286
290
  if (char === "'") {
287
- isInQuotes = !isInQuotes;
291
+ const prevChar = i > 0 ? format[i - 1] : "";
292
+ const nextChar = format[i + 1];
293
+ isInQuotes = prevChar === "'" || nextChar === "'" ? true : !isInQuotes;
294
+ } else if (!isInQuotes && dateEraChars.includes(char)) {
295
+ isInDate = true;
296
+ } else if (!isInQuotes && timeOffsetChars.includes(char)) {
297
+ isInDate = false;
288
298
  }
289
- if (isInQuotes || !charsToRemove.includes(char)) {
299
+
300
+ if (isInDate) {
290
301
  inputFormat += char;
291
302
  }
292
303
  }
@@ -304,20 +304,42 @@ describe("datetimeAttributeModel with offset on", () => {
304
304
  });
305
305
  });
306
306
 
307
- it("Date format with offset info", () => {
308
- const attribute = new DatetimeAttributeModel(
307
+ it("Date formats", () => {
308
+ const datetime = new DatetimeAttributeModel(
309
309
  { key: "datetime", value: "1969-09-23T12:34:00+00:00" },
310
310
  {
311
311
  type: "datetime",
312
- label: "Start date and time at company",
313
- mandatory: false,
314
- formatlabel: "dd-mm-yyyy hh:mm",
315
- assistant: "The date and time of the first working day",
316
312
  format: "dd-MM-yyyy HH:mm X",
317
313
  },
318
314
  );
319
315
 
320
- expect(attribute.format).toBe("dd-MM-yyyy HH:mm X");
321
- expect(attribute.errorCollection.isEmpty).toBe(true);
316
+ expect(datetime.format).toBe("dd-MM-yyyy HH:mm X");
317
+ expect(datetime.dateInputFormat).toBe("dd-MM-yyyy");
318
+ expect(datetime.timeInputFormat).toBe("HH:mm");
319
+ expect(datetime.errorCollection.isEmpty).toBe(true);
320
+
321
+ const timestamp = new DatetimeAttributeModel(
322
+ { key: "timestamp", value: "1969-09-23T12:34:00.010+00:00" },
323
+ {
324
+ type: "timestamp",
325
+ format: "dd-MM-yyyy HH:mm:ss.SSS X",
326
+ },
327
+ );
328
+
329
+ expect(timestamp.format).toBe("dd-MM-yyyy HH:mm:ss.SSS X");
330
+ expect(timestamp.dateInputFormat).toBe("dd-MM-yyyy");
331
+ expect(timestamp.timeInputFormat).toBe("HH:mm:ss.SSS");
332
+
333
+ const special = new DatetimeAttributeModel(
334
+ { key: "timestamp", value: "1969-09-23T12:34:00.010+00:00" },
335
+ {
336
+ type: "timestamp",
337
+ format: "'special' do 'de' MMMM yyyy h 'o''clock'",
338
+ },
339
+ );
340
+
341
+ expect(special.format).toBe("'special' do 'de' MMMM yyyy h 'o''clock'");
342
+ expect(special.dateInputFormat).toBe("do 'de' MMMM yyyy");
343
+ // expect(special.timeInputFormat).toBe("HH:mm:ss.SSS");
322
344
  });
323
345
  });