@beinformed/ui 1.59.3 → 1.59.4

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.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.59.3...v1.59.4) (2024-12-11)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **datetime:** improve date input value, remove time and offset tokens ([cbbeaf1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/cbbeaf1da884e622aee78254043fc25dee35da7c))
11
+
5
12
  ## [1.59.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.59.2...v1.59.3) (2024-12-11)
6
13
 
7
14
 
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
1
2
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
2
3
  import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
3
4
  import { has } from "../../utils/helpers/objects";
@@ -16,6 +17,8 @@ class DatetimeAttributeModel extends StringAttributeModel {
16
17
  */
17
18
  constructor(attribute, attributeContributions, modelOptions) {
18
19
  super(attribute, attributeContributions, modelOptions);
20
+ _defineProperty(this, "_dateInputFormat", void 0);
21
+ _defineProperty(this, "_timeInputFormat", void 0);
19
22
  this.updateInitValue();
20
23
  }
21
24
 
@@ -206,21 +209,38 @@ class DatetimeAttributeModel extends StringAttributeModel {
206
209
  /**
207
210
  */
208
211
  get dateInputFormat() {
209
- var _context7;
210
212
  if (!this.hasDate) {
211
213
  return "";
212
214
  }
213
- return this.hasTime ? _trimInstanceProperty(_context7 = this.format.replace(this.timeInputFormat, "")).call(_context7) : this.format;
215
+ if (this._dateInputFormat) {
216
+ return this._dateInputFormat;
217
+ }
218
+
219
+ // remove time and offset tokens
220
+ const charsToRemove = "HhaKmsSzXxO:";
221
+ let inputFormat = "";
222
+ let isInQuotes = false;
223
+ for (let i = 0; i < this.format.length; i++) {
224
+ const char = this.format[i];
225
+ if (char === "'") {
226
+ isInQuotes = !isInQuotes;
227
+ }
228
+ if (isInQuotes || !_includesInstanceProperty(charsToRemove).call(charsToRemove, char)) {
229
+ inputFormat += char;
230
+ }
231
+ }
232
+ this._dateInputFormat = _trimInstanceProperty(inputFormat).call(inputFormat);
233
+ return this._dateInputFormat;
214
234
  }
215
235
 
216
236
  /**
217
237
  */
218
238
  get dateReadonlyFormat() {
219
- var _context8;
239
+ var _context7;
220
240
  if (!this.hasDate) {
221
241
  return "";
222
242
  }
223
- return this.hasTime ? _trimInstanceProperty(_context8 = this.format.replace(this.timeInputFormat, "")).call(_context8) : this.format;
243
+ return this.hasTime ? _trimInstanceProperty(_context7 = this.format.replace(this.timeInputFormat, "")).call(_context7) : this.format;
224
244
  }
225
245
 
226
246
  /**
@@ -251,6 +271,9 @@ class DatetimeAttributeModel extends StringAttributeModel {
251
271
  if (!this.hasTime) {
252
272
  return "";
253
273
  }
274
+ if (this._timeInputFormat) {
275
+ return this._timeInputFormat;
276
+ }
254
277
  const format = this.format;
255
278
  let timeFormatParts = [];
256
279
  if (_includesInstanceProperty(format).call(format, "H")) {
@@ -269,9 +292,10 @@ class DatetimeAttributeModel extends StringAttributeModel {
269
292
  timeFormat = `${timeFormat}.SSS`;
270
293
  }
271
294
  if (_includesInstanceProperty(format).call(format, "a")) {
272
- return `${timeFormat} a`;
295
+ timeFormat = `${timeFormat} a`;
273
296
  }
274
- return timeFormat;
297
+ this._timeInputFormat = timeFormat;
298
+ return this._timeInputFormat;
275
299
  }
276
300
 
277
301
  /**
@@ -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","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","_context7","dateReadonlyFormat","_context8","placeholder","_placeholder","split","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 /**\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 return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\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 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 return `${timeFormat} a`;\n }\n return timeFormat;\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,OAAO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ACC,OAAO,EACZ,IAAI,CAAClC,WACP,CACF,CAAC;IACH;IAEA,OAAO4C,WAAW;EACpB;;EAEA;AACF;EACE,IAAIE,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAAC5E,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOd,eAAe,CAAC2F,KAAK;IAC9B;IAEA,OAAO3F,eAAe,CAAC4F,MAAM;EAC/B;;EAEA;AACF;EACEC,iBAAiBA,CAACC,cAA6B,EAAQ;IACrD,IAAI,CAACC,KAAK,CAAC,CAAC;IACZ,IAAID,cAAc,YAAY3F,sBAAsB,EAAE;MACpD,MAAM6F,UAAU,GAAGF,cAAc,CAAC7E,KAAK;MACvC,IAAI+E,UAAU,IAAI,IAAI,EAAE;QACtB,MAAMC,UAAU,GAAG,IAAI,CAAClF,UAAU,CAACK,QAAQ,CACzC4E,UAAU,EACV,IAAI,CAACpD,WACP,CAAC;QACD,IAAI,CAACsD,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAACnB,KAAK,CACX,qCAAqCc,cAAc,CAAChF,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAEA,eAAeX,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","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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AAG,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":[]}
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
9
9
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
10
11
  var _objects = require("../../utils/helpers/objects");
11
12
  var _DateTimeUtil = require("../../utils/datetime/DateTimeUtil");
12
13
  var _StringAttributeModel = _interopRequireDefault(require("./StringAttributeModel"));
@@ -23,6 +24,8 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
23
24
  */
24
25
  constructor(attribute, attributeContributions, modelOptions) {
25
26
  super(attribute, attributeContributions, modelOptions);
27
+ (0, _defineProperty2.default)(this, "_dateInputFormat", void 0);
28
+ (0, _defineProperty2.default)(this, "_timeInputFormat", void 0);
26
29
  this.updateInitValue();
27
30
  }
28
31
 
@@ -213,21 +216,38 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
213
216
  /**
214
217
  */
215
218
  get dateInputFormat() {
216
- var _context7;
217
219
  if (!this.hasDate) {
218
220
  return "";
219
221
  }
220
- return this.hasTime ? (0, _trim.default)(_context7 = this.format.replace(this.timeInputFormat, "")).call(_context7) : this.format;
222
+ if (this._dateInputFormat) {
223
+ return this._dateInputFormat;
224
+ }
225
+
226
+ // remove time and offset tokens
227
+ const charsToRemove = "HhaKmsSzXxO:";
228
+ let inputFormat = "";
229
+ let isInQuotes = false;
230
+ for (let i = 0; i < this.format.length; i++) {
231
+ const char = this.format[i];
232
+ if (char === "'") {
233
+ isInQuotes = !isInQuotes;
234
+ }
235
+ if (isInQuotes || !(0, _includes.default)(charsToRemove).call(charsToRemove, char)) {
236
+ inputFormat += char;
237
+ }
238
+ }
239
+ this._dateInputFormat = (0, _trim.default)(inputFormat).call(inputFormat);
240
+ return this._dateInputFormat;
221
241
  }
222
242
 
223
243
  /**
224
244
  */
225
245
  get dateReadonlyFormat() {
226
- var _context8;
246
+ var _context7;
227
247
  if (!this.hasDate) {
228
248
  return "";
229
249
  }
230
- return this.hasTime ? (0, _trim.default)(_context8 = this.format.replace(this.timeInputFormat, "")).call(_context8) : this.format;
250
+ return this.hasTime ? (0, _trim.default)(_context7 = this.format.replace(this.timeInputFormat, "")).call(_context7) : this.format;
231
251
  }
232
252
 
233
253
  /**
@@ -258,6 +278,9 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
258
278
  if (!this.hasTime) {
259
279
  return "";
260
280
  }
281
+ if (this._timeInputFormat) {
282
+ return this._timeInputFormat;
283
+ }
261
284
  const format = this.format;
262
285
  let timeFormatParts = [];
263
286
  if ((0, _includes.default)(format).call(format, "H")) {
@@ -276,9 +299,10 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
276
299
  timeFormat = `${timeFormat}.SSS`;
277
300
  }
278
301
  if ((0, _includes.default)(format).call(format, "a")) {
279
- return `${timeFormat} a`;
302
+ timeFormat = `${timeFormat} a`;
280
303
  }
281
- return timeFormat;
304
+ this._timeInputFormat = timeFormat;
305
+ return this._timeInputFormat;
282
306
  }
283
307
 
284
308
  /**
@@ -34,6 +34,9 @@ import type { OffsetInfo } from "../../utils/datetime/DateTimeUtil";
34
34
  /**
35
35
  */
36
36
  class DatetimeAttributeModel extends StringAttributeModel {
37
+ _dateInputFormat: ?string;
38
+ _timeInputFormat: ?string;
39
+
37
40
  /**
38
41
  */
39
42
  constructor(
@@ -269,9 +272,27 @@ class DatetimeAttributeModel extends StringAttributeModel {
269
272
  return "";
270
273
  }
271
274
 
272
- return this.hasTime
273
- ? this.format.replace(this.timeInputFormat, "").trim()
274
- : this.format;
275
+ if (this._dateInputFormat) {
276
+ return this._dateInputFormat;
277
+ }
278
+
279
+ // remove time and offset tokens
280
+ const charsToRemove = "HhaKmsSzXxO:";
281
+
282
+ let inputFormat = "";
283
+ let isInQuotes = false;
284
+ for (let i = 0; i < this.format.length; i++) {
285
+ const char = this.format[i];
286
+ if (char === "'") {
287
+ isInQuotes = !isInQuotes;
288
+ }
289
+ if (isInQuotes || !charsToRemove.includes(char)) {
290
+ inputFormat += char;
291
+ }
292
+ }
293
+
294
+ this._dateInputFormat = inputFormat.trim();
295
+ return this._dateInputFormat;
275
296
  }
276
297
 
277
298
  /**
@@ -318,6 +339,10 @@ class DatetimeAttributeModel extends StringAttributeModel {
318
339
  return "";
319
340
  }
320
341
 
342
+ if (this._timeInputFormat) {
343
+ return this._timeInputFormat;
344
+ }
345
+
321
346
  const format = this.format;
322
347
 
323
348
  let timeFormatParts = [];
@@ -338,9 +363,11 @@ class DatetimeAttributeModel extends StringAttributeModel {
338
363
  timeFormat = `${timeFormat}.SSS`;
339
364
  }
340
365
  if (format.includes("a")) {
341
- return `${timeFormat} a`;
366
+ timeFormat = `${timeFormat} a`;
342
367
  }
343
- return timeFormat;
368
+
369
+ this._timeInputFormat = timeFormat;
370
+ return this._timeInputFormat;
344
371
  }
345
372
 
346
373
  /**
@@ -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","updateInitValue","isApplicableModel","contributions","_context","_includes","default","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","_context7","dateReadonlyFormat","_context8","placeholder","_placeholder","split","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 /**\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 return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\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 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 return `${timeFormat} a`;\n }\n return timeFormat;\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,sBA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AC,IAAI,CAACP,mBAAmB,CAAC,CAAC,CAAC;IAE3C,IAAI,IAAI,CAACV,OAAO,IAAI,IAAI,CAACC,OAAO,EAAE;MAChCc,WAAW,CAACE,GAAG,CACb,IAAIC,+BAAsB,CACxB,IAAI,CAACxF,IAAI,EACT,IAAI,CAACsE,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAACnC,WACP,CACF,CAAC;IACH;IAEA,OAAOiD,WAAW;EACpB;;EAEA;AACF;EACE,IAAII,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAACzF,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAO0F,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,YAAY3G,sBAAsB,EAAE;MACpD,MAAM6G,UAAU,GAAGF,cAAc,CAACvF,KAAK;MACvC,IAAIyF,UAAU,IAAI,IAAI,EAAE;QACtB,MAAMC,UAAU,GAAG,IAAI,CAAChG,UAAU,CAACS,QAAQ,CACzCsF,UAAU,EACV,IAAI,CAAC5D,WACP,CAAC;QACD,IAAI,CAAC8D,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAAC1B,KAAK,CACX,qCAAqCqB,cAAc,CAAC9F,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAAC,IAAAoG,QAAA,GAAAC,OAAA,CAAAvG,OAAA,GAEcX,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","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,EAAAI,QAAA,IAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,EAAAE,IAAA,CAAAF,QAAA,EAC9CD,aAAa,CAACI,IAChB,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,UAAUA,CAAA,EAIM;IAClB,QAAQ,IAAI,CAACD,IAAI;MACf,KAAK,MAAM;QACT,OAAOE,sBAAQ;MACjB,KAAK,WAAW;QACd,OAAOC,2BAAa;MACtB,KAAK,UAAU;QACb,OAAOC,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C;IAE9CD,WAAW,CAACE,GAAG,CAAC,IAAI,CAACP,mBAAmB,CAAC,CAAC,CAAC;IAE3C,IAAI,IAAI,CAACV,OAAO,IAAI,IAAI,CAACC,OAAO,EAAE;MAChCc,WAAW,CAACE,GAAG,CACb,IAAIC,+BAAsB,CACxB,IAAI,CAAC7F,IAAI,EACT,IAAI,CAAC2E,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAACxC,WACP,CACF,CAAC;IACH;IAEA,OAAOsD,WAAW;EACpB;;EAEA;AACF;EACE,IAAII,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAAC9F,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAO+F,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,YAAYjH,sBAAsB,EAAE;MACpD,MAAMmH,UAAU,GAAGF,cAAc,CAAC5F,KAAK;MACvC,IAAI8F,UAAU,IAAI,IAAI,EAAE;QACtB,MAAMC,UAAU,GAAG,IAAI,CAACrG,UAAU,CAACS,QAAQ,CACzC2F,UAAU,EACV,IAAI,CAACjE,WACP,CAAC;QACD,IAAI,CAACmE,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAAC1B,KAAK,CACX,qCAAqCqB,cAAc,CAACnG,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAAC,IAAAyG,QAAA,GAAAC,OAAA,CAAAjH,OAAA,GAEcP,sBAAsB","ignoreList":[]}
@@ -303,4 +303,21 @@ describe("datetimeAttributeModel with offset on", () => {
303
303
  value: "+02:00",
304
304
  });
305
305
  });
306
+
307
+ it("Date format with offset info", () => {
308
+ const attribute = new DatetimeAttributeModel(
309
+ { key: "datetime", value: "1969-09-23T12:34:00+00:00" },
310
+ {
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
+ format: "dd-MM-yyyy HH:mm X",
317
+ },
318
+ );
319
+
320
+ expect(attribute.format).toBe("dd-MM-yyyy HH:mm X");
321
+ expect(attribute.errorCollection.isEmpty).toBe(true);
322
+ });
306
323
  });
@@ -81,6 +81,11 @@ describe("date time format conversion", () => {
81
81
  });
82
82
 
83
83
  test("Minute", () => {
84
+ expect(TimestampUtil.toFormat(timestamp, "m")).toBe("4");
85
+ expect(TimestampUtil.toFormat(timestamp, "mm")).toBe("04");
86
+ });
87
+
88
+ test("Seconds", () => {
84
89
  expect(TimestampUtil.toFormat(timestamp, "s")).toBe("1");
85
90
  expect(TimestampUtil.toFormat(timestamp, "ss")).toBe("01");
86
91
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.59.3",
3
+ "version": "1.59.4",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -34,6 +34,9 @@ import type { OffsetInfo } from "../../utils/datetime/DateTimeUtil";
34
34
  /**
35
35
  */
36
36
  class DatetimeAttributeModel extends StringAttributeModel {
37
+ _dateInputFormat: ?string;
38
+ _timeInputFormat: ?string;
39
+
37
40
  /**
38
41
  */
39
42
  constructor(
@@ -269,9 +272,27 @@ class DatetimeAttributeModel extends StringAttributeModel {
269
272
  return "";
270
273
  }
271
274
 
272
- return this.hasTime
273
- ? this.format.replace(this.timeInputFormat, "").trim()
274
- : this.format;
275
+ if (this._dateInputFormat) {
276
+ return this._dateInputFormat;
277
+ }
278
+
279
+ // remove time and offset tokens
280
+ const charsToRemove = "HhaKmsSzXxO:";
281
+
282
+ let inputFormat = "";
283
+ let isInQuotes = false;
284
+ for (let i = 0; i < this.format.length; i++) {
285
+ const char = this.format[i];
286
+ if (char === "'") {
287
+ isInQuotes = !isInQuotes;
288
+ }
289
+ if (isInQuotes || !charsToRemove.includes(char)) {
290
+ inputFormat += char;
291
+ }
292
+ }
293
+
294
+ this._dateInputFormat = inputFormat.trim();
295
+ return this._dateInputFormat;
275
296
  }
276
297
 
277
298
  /**
@@ -318,6 +339,10 @@ class DatetimeAttributeModel extends StringAttributeModel {
318
339
  return "";
319
340
  }
320
341
 
342
+ if (this._timeInputFormat) {
343
+ return this._timeInputFormat;
344
+ }
345
+
321
346
  const format = this.format;
322
347
 
323
348
  let timeFormatParts = [];
@@ -338,9 +363,11 @@ class DatetimeAttributeModel extends StringAttributeModel {
338
363
  timeFormat = `${timeFormat}.SSS`;
339
364
  }
340
365
  if (format.includes("a")) {
341
- return `${timeFormat} a`;
366
+ timeFormat = `${timeFormat} a`;
342
367
  }
343
- return timeFormat;
368
+
369
+ this._timeInputFormat = timeFormat;
370
+ return this._timeInputFormat;
344
371
  }
345
372
 
346
373
  /**
@@ -303,4 +303,21 @@ describe("datetimeAttributeModel with offset on", () => {
303
303
  value: "+02:00",
304
304
  });
305
305
  });
306
+
307
+ it("Date format with offset info", () => {
308
+ const attribute = new DatetimeAttributeModel(
309
+ { key: "datetime", value: "1969-09-23T12:34:00+00:00" },
310
+ {
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
+ format: "dd-MM-yyyy HH:mm X",
317
+ },
318
+ );
319
+
320
+ expect(attribute.format).toBe("dd-MM-yyyy HH:mm X");
321
+ expect(attribute.errorCollection.isEmpty).toBe(true);
322
+ });
306
323
  });
@@ -81,6 +81,11 @@ describe("date time format conversion", () => {
81
81
  });
82
82
 
83
83
  test("Minute", () => {
84
+ expect(TimestampUtil.toFormat(timestamp, "m")).toBe("4");
85
+ expect(TimestampUtil.toFormat(timestamp, "mm")).toBe("04");
86
+ });
87
+
88
+ test("Seconds", () => {
84
89
  expect(TimestampUtil.toFormat(timestamp, "s")).toBe("1");
85
90
  expect(TimestampUtil.toFormat(timestamp, "ss")).toBe("01");
86
91
  });