@itwin/components-react 3.0.0-dev.98 → 3.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/components-react/converters/DateTimeTypeConverter.d.ts.map +1 -1
- package/lib/cjs/components-react/converters/DateTimeTypeConverter.js +3 -3
- package/lib/cjs/components-react/converters/DateTimeTypeConverter.js.map +1 -1
- package/lib/cjs/components-react/datepicker/DateField.js +1 -1
- package/lib/cjs/components-react/datepicker/DateField.js.map +1 -1
- package/lib/cjs/components-react/datepicker/TimeField.d.ts +1 -1
- package/lib/cjs/components-react/datepicker/TimeField.js +5 -5
- package/lib/cjs/components-react/datepicker/TimeField.js.map +1 -1
- package/lib/cjs/components-react/editors/CustomNumberEditor.d.ts +2 -1
- package/lib/cjs/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/CustomNumberEditor.js +20 -10
- package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/EnumEditor.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/EnumEditor.js +1 -2
- package/lib/cjs/components-react/editors/EnumEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/IconEditor.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/IconEditor.js +1 -0
- package/lib/cjs/components-react/editors/IconEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/TextEditor.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/TextEditor.js +1 -1
- package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
- package/lib/cjs/components-react/filtering/FilteringInput.d.ts.map +1 -1
- package/lib/cjs/components-react/filtering/FilteringInput.js +1 -1
- package/lib/cjs/components-react/filtering/FilteringInput.js.map +1 -1
- package/lib/cjs/components-react/iconpicker/IconPickerButton.d.ts +2 -2
- package/lib/cjs/components-react/iconpicker/IconPickerButton.d.ts.map +1 -1
- package/lib/cjs/components-react/iconpicker/IconPickerButton.js +3 -2
- package/lib/cjs/components-react/iconpicker/IconPickerButton.js.map +1 -1
- package/lib/cjs/components-react/inputs/ParsedInput.js +1 -1
- package/lib/cjs/components-react/inputs/ParsedInput.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.d.ts.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGrid.scss +0 -3
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.scss +0 -3
- package/lib/cjs/components-react/selectable-content/SelectableContent.d.ts.map +1 -1
- package/lib/cjs/components-react/selectable-content/SelectableContent.js +11 -8
- package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/cjs/components-react/selectable-content/SelectableContent.scss +2 -1
- package/lib/cjs/components-react/table/component/Table.d.ts +3 -3
- package/lib/cjs/components-react/table/component/Table.d.ts.map +1 -1
- package/lib/cjs/components-react/table/component/Table.js +11 -12
- package/lib/cjs/components-react/table/component/Table.js.map +1 -1
- package/lib/cjs/components-react/toolbar/PopupItem.d.ts +4 -0
- package/lib/cjs/components-react/toolbar/PopupItem.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/PopupItem.js +1 -1
- package/lib/cjs/components-react/toolbar/PopupItem.js.map +1 -1
- package/lib/cjs/components-react/toolbar/Toolbar.js.map +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.d.ts +6 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js +9 -4
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/cjs/components-react.d.ts +0 -8
- package/lib/cjs/components-react.d.ts.map +1 -1
- package/lib/cjs/components-react.js +0 -8
- package/lib/cjs/components-react.js.map +1 -1
- package/lib/esm/components-react/converters/DateTimeTypeConverter.d.ts.map +1 -1
- package/lib/esm/components-react/converters/DateTimeTypeConverter.js +1 -1
- package/lib/esm/components-react/converters/DateTimeTypeConverter.js.map +1 -1
- package/lib/esm/components-react/datepicker/DateField.js +1 -1
- package/lib/esm/components-react/datepicker/DateField.js.map +1 -1
- package/lib/esm/components-react/datepicker/TimeField.d.ts +1 -1
- package/lib/esm/components-react/datepicker/TimeField.js +5 -5
- package/lib/esm/components-react/datepicker/TimeField.js.map +1 -1
- package/lib/esm/components-react/editors/CustomNumberEditor.d.ts +2 -1
- package/lib/esm/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
- package/lib/esm/components-react/editors/CustomNumberEditor.js +21 -11
- package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/esm/components-react/editors/EnumEditor.d.ts.map +1 -1
- package/lib/esm/components-react/editors/EnumEditor.js +1 -2
- package/lib/esm/components-react/editors/EnumEditor.js.map +1 -1
- package/lib/esm/components-react/editors/IconEditor.d.ts.map +1 -1
- package/lib/esm/components-react/editors/IconEditor.js +1 -0
- package/lib/esm/components-react/editors/IconEditor.js.map +1 -1
- package/lib/esm/components-react/editors/TextEditor.d.ts.map +1 -1
- package/lib/esm/components-react/editors/TextEditor.js +1 -1
- package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
- package/lib/esm/components-react/filtering/FilteringInput.d.ts.map +1 -1
- package/lib/esm/components-react/filtering/FilteringInput.js +1 -1
- package/lib/esm/components-react/filtering/FilteringInput.js.map +1 -1
- package/lib/esm/components-react/iconpicker/IconPickerButton.d.ts +2 -2
- package/lib/esm/components-react/iconpicker/IconPickerButton.d.ts.map +1 -1
- package/lib/esm/components-react/iconpicker/IconPickerButton.js +3 -2
- package/lib/esm/components-react/iconpicker/IconPickerButton.js.map +1 -1
- package/lib/esm/components-react/inputs/ParsedInput.js +1 -1
- package/lib/esm/components-react/inputs/ParsedInput.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.d.ts.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGrid.scss +0 -3
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.scss +0 -3
- package/lib/esm/components-react/selectable-content/SelectableContent.d.ts.map +1 -1
- package/lib/esm/components-react/selectable-content/SelectableContent.js +11 -8
- package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/esm/components-react/selectable-content/SelectableContent.scss +2 -1
- package/lib/esm/components-react/table/component/Table.d.ts +3 -3
- package/lib/esm/components-react/table/component/Table.d.ts.map +1 -1
- package/lib/esm/components-react/table/component/Table.js +12 -13
- package/lib/esm/components-react/table/component/Table.js.map +1 -1
- package/lib/esm/components-react/toolbar/PopupItem.d.ts +4 -0
- package/lib/esm/components-react/toolbar/PopupItem.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/PopupItem.js +1 -1
- package/lib/esm/components-react/toolbar/PopupItem.js.map +1 -1
- package/lib/esm/components-react/toolbar/Toolbar.js.map +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.d.ts +6 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js +9 -4
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/esm/components-react.d.ts +0 -8
- package/lib/esm/components-react.d.ts.map +1 -1
- package/lib/esm/components-react.js +0 -8
- package/lib/esm/components-react.js.map +1 -1
- package/package.json +22 -26
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Logger } from "@itwin/core-bentley";
|
|
2
1
|
/*---------------------------------------------------------------------------------------------
|
|
3
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -6,6 +5,7 @@ import { Logger } from "@itwin/core-bentley";
|
|
|
6
5
|
/** @packageDocumentation
|
|
7
6
|
* @module TypeConverters
|
|
8
7
|
*/
|
|
8
|
+
import { Logger } from "@itwin/core-bentley";
|
|
9
9
|
import { AlternateDateFormats, StandardTypeNames, TimeDisplay } from "@itwin/appui-abstract";
|
|
10
10
|
import { TimeFormat } from "@itwin/core-react";
|
|
11
11
|
import { formatInputDate } from "../datepicker/DateField";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeTypeConverter.js","sourceRoot":"","sources":["../../../../src/components-react/converters/DateTimeTypeConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAc,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAgC,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,sCAAsC;AAEtC;;;GAGG;AACH,MAAM,OAAgB,yBAA0B,SAAQ,aAAa;IACnD,eAAe,CAAC,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AAC,OAAO,EAAE,CAAC;IACpC,CAAC;IAEM,aAAa,CAAC,CAAO,EAAE,CAAO;QACnC,OAAO,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAEM,sBAAsB,CAAC,CAAO,EAAE,CAAO;QAC5C,OAAO,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,yBAAyB;IACzD,aAAa,KAAiB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;CACnE;AACD,oBAAoB,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAE5F;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,yBAAyB;IACxD,aAAa,KAAiB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;CAClE;AACD,oBAAoB,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { Logger } from \"@itwin/core-bentley\";\r\n/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module TypeConverters\r\n */\r\n\r\nimport { AlternateDateFormats, Primitives, StandardTypeNames, TimeDisplay } from \"@itwin/appui-abstract\";\r\nimport { TimeFormat } from \"@itwin/core-react\";\r\nimport { formatInputDate } from \"../datepicker/DateField\";\r\nimport { adjustDateToTimezone } from \"../common/DateUtils\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { LessGreaterOperatorProcessor, TypeConverter } from \"./TypeConverter\";\r\nimport { TypeConverterManager } from \"./TypeConverterManager\";\r\nimport { ConvertedPrimitives } from \"./valuetypes/ConvertedTypes\";\r\n\r\n// cSpell:ignore datepicker valuetypes\r\n\r\n/**\r\n * DateTime Type Converter.\r\n * @public\r\n */\r\nexport abstract class DateTimeTypeConverterBase extends TypeConverter implements LessGreaterOperatorProcessor {\r\n public override convertToString(value?: Primitives.Value) {\r\n if (value === undefined)\r\n return \"\";\r\n\r\n if (typeof value === \"string\")\r\n value = new Date(value);\r\n\r\n // istanbul ignore else\r\n if (value instanceof Date) {\r\n switch (this.getTimeFormat()) {\r\n case TimeFormat.Short: return value.toLocaleDateString();\r\n case TimeFormat.Long: return value.toLocaleString();\r\n }\r\n return value.toISOString();\r\n }\r\n\r\n // istanbul ignore next\r\n return value.toString();\r\n }\r\n\r\n public static isValidTimeDisplay(type: TimeDisplay): boolean {\r\n return Object.keys(TimeDisplay).some((key) => (TimeDisplay as any)[key] === type);\r\n }\r\n\r\n public static isAlternateDateFormats(type: AlternateDateFormats): boolean {\r\n return Object.keys(AlternateDateFormats).some((key) => (AlternateDateFormats as any)[key] === type);\r\n }\r\n\r\n // supported options:\r\n // timeDisplay?: TimeDisplay\r\n // alternateDateFormat?: AlternateDateFormats\r\n public override convertToStringWithOptions(value?: Primitives.Value, options?: { [key: string]: any }): string | Promise<string> {\r\n if (value === undefined)\r\n return \"\";\r\n\r\n if (options) {\r\n let timeDisplay: TimeDisplay | undefined = (this.getTimeFormat() === TimeFormat.Long) ? TimeDisplay.H12MC : undefined;\r\n let alternateDateFormat = AlternateDateFormats.None;\r\n\r\n // istanbul ignore else\r\n if (\"alternateDateFormat\" in options && DateTimeTypeConverterBase.isAlternateDateFormats(options.alternateDateFormat)) {\r\n alternateDateFormat = options.alternateDateFormat;\r\n }\r\n\r\n if (this.getTimeFormat() === TimeFormat.Long) {\r\n // istanbul ignore else\r\n if (\"timeDisplay\" in options) {\r\n // istanbul ignore if\r\n if (alternateDateFormat) {\r\n Logger.logInfo(UiComponents.loggerCategory(this), `Invalid specification of timeDisplay with alternateDateFormat specification`);\r\n } else {\r\n // istanbul ignore else\r\n if (DateTimeTypeConverterBase.isValidTimeDisplay(options.timeDisplay))\r\n timeDisplay = options.timeDisplay;\r\n }\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (typeof value === \"string\") {\r\n value = new Date(value); // this value will be based on local time zone\r\n // istanbul ignore else\r\n if (value instanceof Date && alternateDateFormat) {\r\n // alternateDateFormat displays UTC time, so assume string is specifying UTC Date and Time\r\n value = adjustDateToTimezone(value, value.getTimezoneOffset() * -1);\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (value instanceof Date) {\r\n // Ensure if alternateDateFormat is specified make sure it matches proper Long/Short format.\r\n if (this.getTimeFormat() === TimeFormat.Long) {\r\n if (alternateDateFormat === AlternateDateFormats.IsoShort)\r\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\r\n if (alternateDateFormat === AlternateDateFormats.UtcShort)\r\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\r\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay)\r\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\r\n } else {\r\n // short time format\r\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\r\n alternateDateFormat = AlternateDateFormats.IsoShort;\r\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\r\n alternateDateFormat = AlternateDateFormats.UtcShort;\r\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\r\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\r\n }\r\n\r\n const formattedDateTime = formatInputDate(value, timeDisplay, undefined, alternateDateFormat);\r\n // istanbul ignore else\r\n if (formattedDateTime)\r\n return formattedDateTime;\r\n }\r\n }\r\n\r\n return this.convertToString(value);\r\n }\r\n\r\n /** Default implementation just calls convertFromString with no options */\r\n public override convertFromStringWithOptions(value: string, options?: { [key: string]: any }): ConvertedPrimitives.Value | undefined | Promise<ConvertedPrimitives.Value | undefined> {\r\n if (!value)\r\n return undefined;\r\n\r\n if (options) {\r\n let alternateDateFormat = AlternateDateFormats.None;\r\n\r\n // istanbul ignore else\r\n if (\"alternateDateFormat\" in options && DateTimeTypeConverterBase.isAlternateDateFormats(options.alternateDateFormat)) {\r\n alternateDateFormat = options.alternateDateFormat;\r\n }\r\n\r\n // istanbul ignore else\r\n let date = new Date(value); // this value will be based on local time zone\r\n // istanbul ignore else\r\n if (date instanceof Date && alternateDateFormat) {\r\n // alternateDateFormat displays UTC time, so assume string is specifying UTC Date and Time\r\n date = adjustDateToTimezone(date, date.getTimezoneOffset() * -1);\r\n }\r\n }\r\n\r\n return this.convertFromString(value);\r\n }\r\n\r\n private isDateValid(date: Date) {\r\n return date instanceof Date && !isNaN(+date);\r\n }\r\n\r\n public override convertFromString(value: string) {\r\n if (!value)\r\n return undefined;\r\n\r\n const dateValue = new Date(value);\r\n\r\n if (!this.isDateValid(dateValue))\r\n return undefined;\r\n\r\n return dateValue;\r\n }\r\n\r\n protected abstract getTimeFormat(): TimeFormat;\r\n\r\n public override get isLessGreaterType(): boolean { return true; }\r\n\r\n public sortCompare(valueA: Date, valueB: Date, _ignoreCase?: boolean): number {\r\n return valueA.valueOf() - valueB.valueOf();\r\n }\r\n\r\n public override isEqualTo(valueA: Date, valueB: Date): boolean {\r\n return valueA.valueOf() === valueB.valueOf();\r\n }\r\n\r\n public override isNotEqualTo(valueA: Date, valueB: Date): boolean {\r\n return valueA.valueOf() !== valueB.valueOf();\r\n }\r\n\r\n public isLessThan(a: Date, b: Date): boolean {\r\n return a.valueOf() < b.valueOf();\r\n }\r\n\r\n public isLessThanOrEqualTo(a: Date, b: Date): boolean {\r\n return a.valueOf() <= b.valueOf();\r\n }\r\n\r\n public isGreaterThan(a: Date, b: Date): boolean {\r\n return a.valueOf() > b.valueOf();\r\n }\r\n\r\n public isGreaterThanOrEqualTo(a: Date, b: Date): boolean {\r\n return a.valueOf() >= b.valueOf();\r\n }\r\n}\r\n\r\n/**\r\n * Short Date Type Converter.\r\n * @public\r\n */\r\nexport class ShortDateTypeConverter extends DateTimeTypeConverterBase {\r\n protected getTimeFormat(): TimeFormat { return TimeFormat.Short; }\r\n}\r\nTypeConverterManager.registerConverter(StandardTypeNames.ShortDate, ShortDateTypeConverter);\r\n\r\n/**\r\n * Date Time Type Converter.\r\n * @public\r\n */\r\nexport class DateTimeTypeConverter extends DateTimeTypeConverterBase {\r\n protected getTimeFormat(): TimeFormat { return TimeFormat.Long; }\r\n}\r\nTypeConverterManager.registerConverter(StandardTypeNames.DateTime, DateTimeTypeConverter);\r\n"]}
|
|
1
|
+
{"version":3,"file":"DateTimeTypeConverter.js","sourceRoot":"","sources":["../../../../src/components-react/converters/DateTimeTypeConverter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAc,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAgC,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,sCAAsC;AAEtC;;;GAGG;AACH,MAAM,OAAgB,yBAA0B,SAAQ,aAAa;IACnD,eAAe,CAAC,KAAwB;QACtD,IAAI,KAAK,KAAK,SAAS;YACrB,OAAO,EAAE,CAAC;QAEZ,IAAI,OAAO,KAAK,KAAK,QAAQ;YAC3B,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAE1B,uBAAuB;QACvB,IAAI,KAAK,YAAY,IAAI,EAAE;YACzB,QAAQ,IAAI,CAAC,aAAa,EAAE,EAAE;gBAC5B,KAAK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AC;IACpC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,yBAAyB;IACzD,aAAa,KAAiB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;CACnE;AACD,oBAAoB,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAE5F;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,yBAAyB;IACxD,aAAa,KAAiB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;CAClE;AACD,oBAAoB,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module TypeConverters\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { AlternateDateFormats, Primitives, StandardTypeNames, TimeDisplay } from \"@itwin/appui-abstract\";\r\nimport { TimeFormat } from \"@itwin/core-react\";\r\nimport { formatInputDate } from \"../datepicker/DateField\";\r\nimport { adjustDateToTimezone } from \"../common/DateUtils\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { LessGreaterOperatorProcessor, TypeConverter } from \"./TypeConverter\";\r\nimport { TypeConverterManager } from \"./TypeConverterManager\";\r\nimport { ConvertedPrimitives } from \"./valuetypes/ConvertedTypes\";\r\n\r\n// cSpell:ignore datepicker valuetypes\r\n\r\n/**\r\n * DateTime Type Converter.\r\n * @public\r\n */\r\nexport abstract class DateTimeTypeConverterBase extends TypeConverter implements LessGreaterOperatorProcessor {\r\n public override convertToString(value?: Primitives.Value) {\r\n if (value === undefined)\r\n return \"\";\r\n\r\n if (typeof value === \"string\")\r\n value = new Date(value);\r\n\r\n // istanbul ignore else\r\n if (value instanceof Date) {\r\n switch (this.getTimeFormat()) {\r\n case TimeFormat.Short: return value.toLocaleDateString();\r\n case TimeFormat.Long: return value.toLocaleString();\r\n }\r\n return value.toISOString();\r\n }\r\n\r\n // istanbul ignore next\r\n return value.toString();\r\n }\r\n\r\n public static isValidTimeDisplay(type: TimeDisplay): boolean {\r\n return Object.keys(TimeDisplay).some((key) => (TimeDisplay as any)[key] === type);\r\n }\r\n\r\n public static isAlternateDateFormats(type: AlternateDateFormats): boolean {\r\n return Object.keys(AlternateDateFormats).some((key) => (AlternateDateFormats as any)[key] === type);\r\n }\r\n\r\n // supported options:\r\n // timeDisplay?: TimeDisplay\r\n // alternateDateFormat?: AlternateDateFormats\r\n public override convertToStringWithOptions(value?: Primitives.Value, options?: { [key: string]: any }): string | Promise<string> {\r\n if (value === undefined)\r\n return \"\";\r\n\r\n if (options) {\r\n let timeDisplay: TimeDisplay | undefined = (this.getTimeFormat() === TimeFormat.Long) ? TimeDisplay.H12MC : undefined;\r\n let alternateDateFormat = AlternateDateFormats.None;\r\n\r\n // istanbul ignore else\r\n if (\"alternateDateFormat\" in options && DateTimeTypeConverterBase.isAlternateDateFormats(options.alternateDateFormat)) {\r\n alternateDateFormat = options.alternateDateFormat;\r\n }\r\n\r\n if (this.getTimeFormat() === TimeFormat.Long) {\r\n // istanbul ignore else\r\n if (\"timeDisplay\" in options) {\r\n // istanbul ignore if\r\n if (alternateDateFormat) {\r\n Logger.logInfo(UiComponents.loggerCategory(this), `Invalid specification of timeDisplay with alternateDateFormat specification`);\r\n } else {\r\n // istanbul ignore else\r\n if (DateTimeTypeConverterBase.isValidTimeDisplay(options.timeDisplay))\r\n timeDisplay = options.timeDisplay;\r\n }\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (typeof value === \"string\") {\r\n value = new Date(value); // this value will be based on local time zone\r\n // istanbul ignore else\r\n if (value instanceof Date && alternateDateFormat) {\r\n // alternateDateFormat displays UTC time, so assume string is specifying UTC Date and Time\r\n value = adjustDateToTimezone(value, value.getTimezoneOffset() * -1);\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (value instanceof Date) {\r\n // Ensure if alternateDateFormat is specified make sure it matches proper Long/Short format.\r\n if (this.getTimeFormat() === TimeFormat.Long) {\r\n if (alternateDateFormat === AlternateDateFormats.IsoShort)\r\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\r\n if (alternateDateFormat === AlternateDateFormats.UtcShort)\r\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\r\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay)\r\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\r\n } else {\r\n // short time format\r\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\r\n alternateDateFormat = AlternateDateFormats.IsoShort;\r\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\r\n alternateDateFormat = AlternateDateFormats.UtcShort;\r\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\r\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\r\n }\r\n\r\n const formattedDateTime = formatInputDate(value, timeDisplay, undefined, alternateDateFormat);\r\n // istanbul ignore else\r\n if (formattedDateTime)\r\n return formattedDateTime;\r\n }\r\n }\r\n\r\n return this.convertToString(value);\r\n }\r\n\r\n /** Default implementation just calls convertFromString with no options */\r\n public override convertFromStringWithOptions(value: string, options?: { [key: string]: any }): ConvertedPrimitives.Value | undefined | Promise<ConvertedPrimitives.Value | undefined> {\r\n if (!value)\r\n return undefined;\r\n\r\n if (options) {\r\n let alternateDateFormat = AlternateDateFormats.None;\r\n\r\n // istanbul ignore else\r\n if (\"alternateDateFormat\" in options && DateTimeTypeConverterBase.isAlternateDateFormats(options.alternateDateFormat)) {\r\n alternateDateFormat = options.alternateDateFormat;\r\n }\r\n\r\n // istanbul ignore else\r\n let date = new Date(value); // this value will be based on local time zone\r\n // istanbul ignore else\r\n if (date instanceof Date && alternateDateFormat) {\r\n // alternateDateFormat displays UTC time, so assume string is specifying UTC Date and Time\r\n date = adjustDateToTimezone(date, date.getTimezoneOffset() * -1);\r\n }\r\n }\r\n\r\n return this.convertFromString(value);\r\n }\r\n\r\n private isDateValid(date: Date) {\r\n return date instanceof Date && !isNaN(+date);\r\n }\r\n\r\n public override convertFromString(value: string) {\r\n if (!value)\r\n return undefined;\r\n\r\n const dateValue = new Date(value);\r\n\r\n if (!this.isDateValid(dateValue))\r\n return undefined;\r\n\r\n return dateValue;\r\n }\r\n\r\n protected abstract getTimeFormat(): TimeFormat;\r\n\r\n public override get isLessGreaterType(): boolean { return true; }\r\n\r\n public sortCompare(valueA: Date, valueB: Date, _ignoreCase?: boolean): number {\r\n return valueA.valueOf() - valueB.valueOf();\r\n }\r\n\r\n public override isEqualTo(valueA: Date, valueB: Date): boolean {\r\n return valueA.valueOf() === valueB.valueOf();\r\n }\r\n\r\n public override isNotEqualTo(valueA: Date, valueB: Date): boolean {\r\n return valueA.valueOf() !== valueB.valueOf();\r\n }\r\n\r\n public isLessThan(a: Date, b: Date): boolean {\r\n return a.valueOf() < b.valueOf();\r\n }\r\n\r\n public isLessThanOrEqualTo(a: Date, b: Date): boolean {\r\n return a.valueOf() <= b.valueOf();\r\n }\r\n\r\n public isGreaterThan(a: Date, b: Date): boolean {\r\n return a.valueOf() > b.valueOf();\r\n }\r\n\r\n public isGreaterThanOrEqualTo(a: Date, b: Date): boolean {\r\n return a.valueOf() >= b.valueOf();\r\n }\r\n}\r\n\r\n/**\r\n * Short Date Type Converter.\r\n * @public\r\n */\r\nexport class ShortDateTypeConverter extends DateTimeTypeConverterBase {\r\n protected getTimeFormat(): TimeFormat { return TimeFormat.Short; }\r\n}\r\nTypeConverterManager.registerConverter(StandardTypeNames.ShortDate, ShortDateTypeConverter);\r\n\r\n/**\r\n * Date Time Type Converter.\r\n * @public\r\n */\r\nexport class DateTimeTypeConverter extends DateTimeTypeConverterBase {\r\n protected getTimeFormat(): TimeFormat { return TimeFormat.Long; }\r\n}\r\nTypeConverterManager.registerConverter(StandardTypeNames.DateTime, DateTimeTypeConverter);\r\n"]}
|
|
@@ -125,6 +125,6 @@ export function DateField({ initialDate, onDateChange, readOnly, dateFormatter,
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
const classNames = classnames(className, "components-date-input", hasBadInput && "components-date-has-error");
|
|
128
|
-
return React.createElement(Input, { "data-testid": "components-date-input", style: style, className: classNames, onKeyDown: onInputKeyDown, onBlur: handleOnBlur, onChange: handleInputChange, value: inputValue, disabled: readOnly || (dateFormatter && !(dateFormatter.parseDate)) });
|
|
128
|
+
return React.createElement(Input, { "data-testid": "components-date-input", style: style, className: classNames, onKeyDown: onInputKeyDown, onBlur: handleOnBlur, onChange: handleInputChange, value: inputValue, disabled: readOnly || (dateFormatter && !(dateFormatter.parseDate)), size: "small" });
|
|
129
129
|
}
|
|
130
130
|
//# sourceMappingURL=DateField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DateField.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAiB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzF,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAmB7C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,SAAe,EAAE,WAAyB,EAAE,eAA+B,EAAE,mBAA0C;IACrJ,IAAI,eAAe,EAAE;QACnB,OAAO,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;KAC/C;IAED,IAAI,mBAAmB,EAAE;QACvB,QAAQ,mBAAmB,EAAE;YAC3B,KAAK,oBAAoB,CAAC,WAAW;gBACnC,OA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IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;gBACvC,YAAY,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtC,cAAc,CAAC,KAAK,CAAC,CAAC;aACvB;iBAAM;gBACL,cAAc,CAAC,IAAI,CAAC,CAAC;aACtB;SACF;QAAC,OAAO,MAAM,EAAE;YACf,uBAAuB;YACvB,cAAc,CAAC,IAAI,CAAC,CAAC;SACtB;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAE9B,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAyC,EAAE,EAAE;QACnF,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,SAAS,cAAc,CAAC,KAA4C;QAClE,uBAAuB;QACvB,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE;YACzB,eAAe,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC3C,KAAK,CAAC,cAAc,EAAE,CAAC;SACxB;IACH,CAAC;IACD,MAAM,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,uBAAuB,EAAE,WAAW,IAAI,2BAA2B,CAAC,CAAC;IAC9G,OAAO,oBAAC,KAAK,mBAAa,uBAAuB,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EACpI,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAI,CAAC;AAC5H,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Date\r\n */\r\n\r\nimport \"./DateField.scss\";\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { AlternateDateFormats, DateFormatter, TimeDisplay } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Input } from \"@itwin/itwinui-react\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\n\r\n/** Props for [[DateField]] Component.\r\n * @internal\r\n */\r\nexport interface DateFieldProps extends CommonProps {\r\n /** Defines initial date and time for component. */\r\n initialDate: Date;\r\n /** Function to call when the date or time is changed. */\r\n onDateChange?: (day: Date) => void;\r\n /** Optional value to define if edit field allows editing. If a DateFormatter is provided\r\n * it must provide a parseData function or the field will be read only no matter the setting of this value. */\r\n readOnly?: boolean;\r\n /** Optional date formatter that produces an explicit date display */\r\n dateFormatter?: DateFormatter;\r\n /** This property has two purposes, the first is specify that the display of time is desired and the second is to define the format of the time display. */\r\n timeDisplay?: TimeDisplay;\r\n}\r\n\r\n/** Function to format a Date object that is used in control, type editor, and type converter\r\n * to produce a consistent formatted Date string.\r\n * @internal\r\n */\r\nexport function formatInputDate(inputDate: Date, timeDisplay?: TimeDisplay, customFormatter?: DateFormatter, alternateDateFormat?: AlternateDateFormats): string | undefined {\r\n if (customFormatter) {\r\n return customFormatter.formateDate(inputDate);\r\n }\r\n\r\n if (alternateDateFormat) {\r\n switch (alternateDateFormat) {\r\n case AlternateDateFormats.IsoDateTime:\r\n return inputDate.toISOString();\r\n case AlternateDateFormats.IsoShort:\r\n return inputDate.toISOString().slice(0, 10);\r\n case AlternateDateFormats.UtcDateTime:\r\n return inputDate.toUTCString().slice(5);\r\n case AlternateDateFormats.UtcShort:\r\n return inputDate.toUTCString().slice(5, 16);\r\n case AlternateDateFormats.UtcDateTimeWithDay:\r\n return inputDate.toUTCString();\r\n case AlternateDateFormats.UtcShortWithDay:\r\n return inputDate.toUTCString().slice(0, 16);\r\n }\r\n } else {\r\n const dateString = inputDate.toLocaleDateString(undefined, { day: \"2-digit\", month: \"2-digit\", year: \"numeric\" });\r\n let timeString: string = \"\";\r\n\r\n if (timeDisplay) {\r\n switch (timeDisplay) {\r\n case TimeDisplay.H12MC:\r\n timeString = inputDate.toLocaleTimeString(undefined, { hour12: true, hour: \"2-digit\", minute: \"2-digit\" });\r\n break;\r\n case TimeDisplay.H12MSC:\r\n timeString = (inputDate.toLocaleTimeString(undefined, { hour12: true, hour: \"2-digit\", minute: \"2-digit\", second: \"2-digit\" }));\r\n break;\r\n case TimeDisplay.H24M:\r\n timeString = (inputDate.toLocaleTimeString(undefined, { hour12: false, hour: \"2-digit\", minute: \"2-digit\" }));\r\n // istanbul ignore next\r\n if (timeString === \"24:00\")\r\n timeString = \"00:00\";\r\n break;\r\n case TimeDisplay.H24MS:\r\n timeString = (inputDate.toLocaleTimeString(undefined, { hour12: false, hour: \"2-digit\", minute: \"2-digit\", second: \"2-digit\" }));\r\n // istanbul ignore next\r\n if (timeString === \"24:00:00\")\r\n timeString = \"00:00:00\";\r\n break;\r\n }\r\n }\r\n return timeString.length ? `${dateString}, ${timeString}` : dateString;\r\n }\r\n}\r\n\r\n/** Date input component. This component is typically used by the [[DatePickerPopupButton]] to display and edit date and time.\r\n * @internal\r\n */\r\nexport function DateField({ initialDate, onDateChange, readOnly, dateFormatter, timeDisplay, style, className }: DateFieldProps) {\r\n const initialDateRef = React.useRef(initialDate);\r\n const [hasBadInput, setHasBadInput] = React.useState(false);\r\n const [inputValue, setInputValue] = React.useState(formatInputDate(initialDate, timeDisplay, dateFormatter));\r\n\r\n // See if new initialDate props have changed since component mounted\r\n React.useEffect(() => {\r\n // istanbul ignore else\r\n if (initialDate.getTime() !== initialDateRef.current.getTime()) {\r\n initialDateRef.current = initialDate;\r\n }\r\n setInputValue(formatInputDate(initialDate, timeDisplay, dateFormatter));\r\n }, [initialDate, dateFormatter, timeDisplay]);\r\n\r\n const handleInputChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setInputValue(event.currentTarget.value);\r\n }, []);\r\n\r\n const parseDate = React.useCallback((dateString: string) => {\r\n try {\r\n if (dateFormatter && dateFormatter.parseDate)\r\n return dateFormatter.parseDate(dateString);\r\n\r\n const newDateValue = Date.parse(dateString);\r\n // istanbul ignore else\r\n if (newDateValue)\r\n return new Date(newDateValue);\r\n } catch (_error) /* istanbul ignore next */ {\r\n Logger.logInfo(\"DateField\", `Encountered error parsing input value '${dateString}' as a date.`);\r\n return undefined;\r\n }\r\n // istanbul ignore next\r\n return undefined;\r\n }, [dateFormatter]);\r\n\r\n const updateInputDate = React.useCallback((dateString: string) => {\r\n try {\r\n const newDateValue = parseDate(dateString);\r\n if (newDateValue) {\r\n const newDate = new Date(newDateValue);\r\n onDateChange && onDateChange(newDate);\r\n setHasBadInput(false);\r\n } else {\r\n setHasBadInput(true);\r\n }\r\n } catch (_error) {\r\n // istanbul ignore next\r\n setHasBadInput(true);\r\n }\r\n }, [onDateChange, parseDate]);\r\n\r\n const handleOnBlur = React.useCallback((event: React.FocusEvent<HTMLInputElement>) => {\r\n updateInputDate(event.target.value);\r\n }, [updateInputDate]);\r\n\r\n function onInputKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {\r\n // istanbul ignore else\r\n if (event.key === \"Enter\") {\r\n updateInputDate(event.currentTarget.value);\r\n event.preventDefault();\r\n }\r\n }\r\n const classNames = classnames(className, \"components-date-input\", hasBadInput && \"components-date-has-error\");\r\n return <Input data-testid=\"components-date-input\" style={style} className={classNames} onKeyDown={onInputKeyDown} onBlur={handleOnBlur}\r\n onChange={handleInputChange} value={inputValue} disabled={readOnly || (dateFormatter && !(dateFormatter.parseDate))} />;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DateField.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KA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M,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,uBAAuB,EAAE,WAAW,IAAI,2BAA2B,CAAC,CAAC;IAC9G,OAAO,oBAAC,KAAK,mBAAa,uBAAuB,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EACpI,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAC,OAAO,GAAG,CAAC;AACzI,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Date\r\n */\r\n\r\nimport \"./DateField.scss\";\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { AlternateDateFormats, DateFormatter, TimeDisplay } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Input } from \"@itwin/itwinui-react\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\n\r\n/** Props for [[DateField]] Component.\r\n * @internal\r\n */\r\nexport interface DateFieldProps extends CommonProps {\r\n /** Defines initial date and time for component. */\r\n initialDate: Date;\r\n /** Function to call when the date or time is changed. */\r\n onDateChange?: (day: Date) => void;\r\n /** Optional value to define if edit field allows editing. If a DateFormatter is provided\r\n * it must provide a parseData function or the field will be read only no matter the setting of this value. */\r\n readOnly?: boolean;\r\n /** Optional date formatter that produces an explicit date display */\r\n dateFormatter?: DateFormatter;\r\n /** This property has two purposes, the first is specify that the display of time is desired and the second is to define the format of the time display. */\r\n timeDisplay?: TimeDisplay;\r\n}\r\n\r\n/** Function to format a Date object that is used in control, type editor, and type converter\r\n * to produce a consistent formatted Date string.\r\n * @internal\r\n */\r\nexport function formatInputDate(inputDate: Date, timeDisplay?: TimeDisplay, customFormatter?: DateFormatter, alternateDateFormat?: AlternateDateFormats): string | undefined {\r\n if (customFormatter) {\r\n return customFormatter.formateDate(inputDate);\r\n }\r\n\r\n if (alternateDateFormat) {\r\n switch (alternateDateFormat) {\r\n case AlternateDateFormats.IsoDateTime:\r\n return inputDate.toISOString();\r\n case AlternateDateFormats.IsoShort:\r\n return inputDate.toISOString().slice(0, 10);\r\n case AlternateDateFormats.UtcDateTime:\r\n return inputDate.toUTCString().slice(5);\r\n case AlternateDateFormats.UtcShort:\r\n return inputDate.toUTCString().slice(5, 16);\r\n case AlternateDateFormats.UtcDateTimeWithDay:\r\n return inputDate.toUTCString();\r\n case AlternateDateFormats.UtcShortWithDay:\r\n return inputDate.toUTCString().slice(0, 16);\r\n }\r\n } else {\r\n const dateString = inputDate.toLocaleDateString(undefined, { day: \"2-digit\", month: \"2-digit\", year: \"numeric\" });\r\n let timeString: string = \"\";\r\n\r\n if (timeDisplay) {\r\n switch (timeDisplay) {\r\n case TimeDisplay.H12MC:\r\n timeString = inputDate.toLocaleTimeString(undefined, { hour12: true, hour: \"2-digit\", minute: \"2-digit\" });\r\n break;\r\n case TimeDisplay.H12MSC:\r\n timeString = (inputDate.toLocaleTimeString(undefined, { hour12: true, hour: \"2-digit\", minute: \"2-digit\", second: \"2-digit\" }));\r\n break;\r\n case TimeDisplay.H24M:\r\n timeString = (inputDate.toLocaleTimeString(undefined, { hour12: false, hour: \"2-digit\", minute: \"2-digit\" }));\r\n // istanbul ignore next\r\n if (timeString === \"24:00\")\r\n timeString = \"00:00\";\r\n break;\r\n case TimeDisplay.H24MS:\r\n timeString = (inputDate.toLocaleTimeString(undefined, { hour12: false, hour: \"2-digit\", minute: \"2-digit\", second: \"2-digit\" }));\r\n // istanbul ignore next\r\n if (timeString === \"24:00:00\")\r\n timeString = \"00:00:00\";\r\n break;\r\n }\r\n }\r\n return timeString.length ? `${dateString}, ${timeString}` : dateString;\r\n }\r\n}\r\n\r\n/** Date input component. This component is typically used by the [[DatePickerPopupButton]] to display and edit date and time.\r\n * @internal\r\n */\r\nexport function DateField({ initialDate, onDateChange, readOnly, dateFormatter, timeDisplay, style, className }: DateFieldProps) {\r\n const initialDateRef = React.useRef(initialDate);\r\n const [hasBadInput, setHasBadInput] = React.useState(false);\r\n const [inputValue, setInputValue] = React.useState(formatInputDate(initialDate, timeDisplay, dateFormatter));\r\n\r\n // See if new initialDate props have changed since component mounted\r\n React.useEffect(() => {\r\n // istanbul ignore else\r\n if (initialDate.getTime() !== initialDateRef.current.getTime()) {\r\n initialDateRef.current = initialDate;\r\n }\r\n setInputValue(formatInputDate(initialDate, timeDisplay, dateFormatter));\r\n }, [initialDate, dateFormatter, timeDisplay]);\r\n\r\n const handleInputChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setInputValue(event.currentTarget.value);\r\n }, []);\r\n\r\n const parseDate = React.useCallback((dateString: string) => {\r\n try {\r\n if (dateFormatter && dateFormatter.parseDate)\r\n return dateFormatter.parseDate(dateString);\r\n\r\n const newDateValue = Date.parse(dateString);\r\n // istanbul ignore else\r\n if (newDateValue)\r\n return new Date(newDateValue);\r\n } catch (_error) /* istanbul ignore next */ {\r\n Logger.logInfo(\"DateField\", `Encountered error parsing input value '${dateString}' as a date.`);\r\n return undefined;\r\n }\r\n // istanbul ignore next\r\n return undefined;\r\n }, [dateFormatter]);\r\n\r\n const updateInputDate = React.useCallback((dateString: string) => {\r\n try {\r\n const newDateValue = parseDate(dateString);\r\n if (newDateValue) {\r\n const newDate = new Date(newDateValue);\r\n onDateChange && onDateChange(newDate);\r\n setHasBadInput(false);\r\n } else {\r\n setHasBadInput(true);\r\n }\r\n } catch (_error) {\r\n // istanbul ignore next\r\n setHasBadInput(true);\r\n }\r\n }, [onDateChange, parseDate]);\r\n\r\n const handleOnBlur = React.useCallback((event: React.FocusEvent<HTMLInputElement>) => {\r\n updateInputDate(event.target.value);\r\n }, [updateInputDate]);\r\n\r\n function onInputKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {\r\n // istanbul ignore else\r\n if (event.key === \"Enter\") {\r\n updateInputDate(event.currentTarget.value);\r\n event.preventDefault();\r\n }\r\n }\r\n const classNames = classnames(className, \"components-date-input\", hasBadInput && \"components-date-has-error\");\r\n return <Input data-testid=\"components-date-input\" style={style} className={classNames} onKeyDown={onInputKeyDown} onBlur={handleOnBlur}\r\n onChange={handleInputChange} value={inputValue} disabled={readOnly || (dateFormatter && !(dateFormatter.parseDate))} size=\"small\" />;\r\n}\r\n"]}
|
|
@@ -22,7 +22,7 @@ export interface TimeFieldProps {
|
|
|
22
22
|
onTimeChange?: (time: TimeSpec) => void;
|
|
23
23
|
readOnly?: boolean;
|
|
24
24
|
}
|
|
25
|
-
/** Field used to set the Hour:Minutes:Seconds in the [[
|
|
25
|
+
/** Field used to set the Hour:Minutes:Seconds in the [[DatePicker]] Popup panel. The user may key-in the value or use up/down keys to
|
|
26
26
|
* change the time.
|
|
27
27
|
* @internal
|
|
28
28
|
*/
|
|
@@ -25,7 +25,7 @@ function getValidInt(intText, min, max, defaultValue) {
|
|
|
25
25
|
function isSameTime(a, b) {
|
|
26
26
|
return a.hours === b.hours && a.minutes === b.minutes && a.seconds === b.seconds;
|
|
27
27
|
}
|
|
28
|
-
/** Field used to set the Hour:Minutes:Seconds in the [[
|
|
28
|
+
/** Field used to set the Hour:Minutes:Seconds in the [[DatePicker]] Popup panel. The user may key-in the value or use up/down keys to
|
|
29
29
|
* change the time.
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
@@ -213,14 +213,14 @@ export function TimeField({ time, timeDisplay, readOnly, onTimeChange }) {
|
|
|
213
213
|
}, [dayPeriodText, hours, timeSpec, updateTimeSpec]);
|
|
214
214
|
const showSeconds = -1 !== timeDisplay.search(":ss");
|
|
215
215
|
return React.createElement("div", { "data-testid": "components-time-input", className: "components-time" },
|
|
216
|
-
React.createElement(Input, { className: "components-time-input", onKeyDown: handleHoursOnKeyDown, onBlur: handleHoursOnBlur, onChange: handleHoursChange, value: hoursText, disabled: readOnly }),
|
|
216
|
+
React.createElement(Input, { className: "components-time-input", onKeyDown: handleHoursOnKeyDown, onBlur: handleHoursOnBlur, onChange: handleHoursChange, value: hoursText, disabled: readOnly, size: "small" }),
|
|
217
217
|
React.createElement("span", { className: "component-time-separator" }, ":"),
|
|
218
|
-
React.createElement(Input, { className: "components-time-input", onKeyDown: handleMinutesOnKeyDown, onBlur: handleMinutesOnBlur, onChange: handleMinutesChange, value: minutesText, disabled: readOnly }),
|
|
218
|
+
React.createElement(Input, { className: "components-time-input", onKeyDown: handleMinutesOnKeyDown, onBlur: handleMinutesOnBlur, onChange: handleMinutesChange, value: minutesText, disabled: readOnly, size: "small" }),
|
|
219
219
|
showSeconds &&
|
|
220
220
|
React.createElement(React.Fragment, null,
|
|
221
221
|
React.createElement("span", { className: "component-time-separator" }, ":"),
|
|
222
|
-
React.createElement(Input, { className: "components-time-input", onKeyDown: handleSecondsOnKeyDown, onBlur: handleSecondsOnBlur, onChange: handleSecondsChange, value: secondsText, disabled: readOnly })),
|
|
222
|
+
React.createElement(Input, { className: "components-time-input", onKeyDown: handleSecondsOnKeyDown, onBlur: handleSecondsOnBlur, onChange: handleSecondsChange, value: secondsText, disabled: readOnly, size: "small" })),
|
|
223
223
|
dayPeriodText &&
|
|
224
|
-
React.createElement(Input, { className: "components-time-period-input", onKeyDown: handleDayPeriodOnKeyDown, onBlur: handleDayPeriodOnBlur, onChange: handleDayPeriodChange, value: dayPeriodText, disabled: readOnly }));
|
|
224
|
+
React.createElement(Input, { className: "components-time-period-input", onKeyDown: handleDayPeriodOnKeyDown, onBlur: handleDayPeriodOnBlur, onChange: handleDayPeriodChange, value: dayPeriodText, disabled: readOnly, size: "small" }));
|
|
225
225
|
}
|
|
226
226
|
//# sourceMappingURL=TimeField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.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AmB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,GAAI;QACjL,WAAW;YACV;gBACE,8BAAM,SAAS,EAAC,0BAA0B,QAAS;gBACnD,oBAAC,KAAK,IAAC,SAAS,EAAC,uBAAuB,EAAC,SAAS,EAAE,sBAAsB,EAAE,MAAM,EAAE,mBAAmB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,GAAI,CACjL;QAEJ,aAAa;YACZ,oBAAC,KAAK,IAAC,SAAS,EAAC,8BAA8B,EAAC,SAAS,EAAE,wBAAwB,EAAE,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAE/L,CAAC;AACT,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Date\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { Input } from \"@itwin/itwinui-react\";\r\nimport { SpecialKey, TimeDisplay } from \"@itwin/appui-abstract\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport \"./TimeField.scss\";\r\n\r\n/** Interface used to hold 24 hour time in\r\n * hours, minutes, and seconds.\r\n * @internal\r\n */\r\nexport interface TimeSpec {\r\n hours: number;\r\n minutes: number;\r\n seconds: number;\r\n}\r\n\r\n/** Interface for props used by [[TimeField]] component.\r\n * @internal\r\n */\r\nexport interface TimeFieldProps {\r\n time: TimeSpec;\r\n timeDisplay: TimeDisplay;\r\n onTimeChange?: (time: TimeSpec) => void;\r\n readOnly?: boolean;\r\n}\r\n\r\nfunction getValidInt(intText: string, min: number, max: number, defaultValue: number) {\r\n try {\r\n const newValue = parseInt(intText, 10);\r\n if (newValue >= min && newValue <= max)\r\n return newValue;\r\n } catch (_e) {\r\n // istanbul ignore next\r\n return defaultValue;\r\n }\r\n return defaultValue;\r\n}\r\n\r\nfunction isSameTime(a: TimeSpec, b: TimeSpec) {\r\n return a.hours === b.hours && a.minutes === b.minutes && a.seconds === b.seconds;\r\n}\r\n\r\n/** Field used to set the Hour:Minutes:Seconds in the [[DataPicker]] Popup panel. The user may key-in the value or use up/down keys to\r\n * change the time.\r\n * @internal\r\n */\r\nexport function TimeField({ time, timeDisplay, readOnly, onTimeChange }: TimeFieldProps) {\r\n const initialDateRef = React.useRef(time);\r\n const amLabelRef = React.useRef(UiComponents.translate(\"timepicker.day-period-am\"));\r\n const pmLabelRef = React.useRef(UiComponents.translate(\"timepicker.day-period-pm\"));\r\n const [timeSpec, setTimeSpec] = React.useState(time);\r\n const { hours, minutes, seconds } = timeSpec;\r\n const showDayPeriod = -1 !== (timeDisplay as string).search(\"aa\");\r\n\r\n const getDisplayHours = React.useCallback((timeHours: number) => {\r\n if (!showDayPeriod) {\r\n return timeHours;\r\n }\r\n const outHours = (0 === timeHours) ? 12 : timeHours > 12 ? timeHours - 12 : timeHours;\r\n return outHours;\r\n }, [showDayPeriod]);\r\n\r\n // See if new initialDate props have changed since component mounted\r\n React.useEffect(() => {\r\n if (!isSameTime(time, initialDateRef.current)) {\r\n setTimeSpec(time);\r\n initialDateRef.current = time;\r\n }\r\n }, [time]);\r\n\r\n const displayHour = getDisplayHours(hours);\r\n const [dayPeriodText, setDayPeriodText] = React.useState(showDayPeriod ? (hours >= 12 ? pmLabelRef.current : amLabelRef.current) : undefined);\r\n const [hoursText, setHoursText] = React.useState(displayHour.toString().padStart(2, \"0\"));\r\n const [minutesText, setMinutesText] = React.useState(minutes.toString().padStart(2, \"0\"));\r\n const [secondsText, setSecondsText] = React.useState(seconds.toString().padStart(2, \"0\"));\r\n\r\n const updateTimeSpec = React.useCallback((newTime: TimeSpec) => {\r\n if (newTime.hours !== timeSpec.hours || newTime.minutes !== timeSpec.minutes || newTime.seconds !== timeSpec.seconds) {\r\n setTimeSpec(newTime);\r\n onTimeChange && onTimeChange(newTime);\r\n }\r\n }, [onTimeChange, timeSpec.hours, timeSpec.minutes, timeSpec.seconds]);\r\n\r\n const handleHoursChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setHoursText(event.currentTarget.value);\r\n }, []);\r\n\r\n const handleMinutesChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setMinutesText(event.currentTarget.value);\r\n }, []);\r\n const handleSecondsChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setSecondsText(event.currentTarget.value);\r\n }, []);\r\n const handleDayPeriodChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setDayPeriodText(event.currentTarget.value);\r\n }, []);\r\n\r\n const handleHoursOnBlur = React.useCallback(() => {\r\n const newHours = getValidInt(hoursText, 0, 24, hours);\r\n setHoursText(getDisplayHours(newHours).toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, hours: newHours });\r\n showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);\r\n }, [getDisplayHours, hours, hoursText, showDayPeriod, timeSpec, updateTimeSpec]);\r\n const handleMinutesOnBlur = React.useCallback(() => {\r\n const newMinutes = getValidInt(minutesText, 0, 59, minutes);\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n }, [minutes, minutesText, timeSpec, updateTimeSpec]);\r\n const handleSecondsOnBlur = React.useCallback(() => {\r\n const newSeconds = getValidInt(secondsText, 0, 59, seconds);\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n }, [seconds, secondsText, timeSpec, updateTimeSpec]);\r\n const handleDayPeriodOnBlur = React.useCallback(() => {\r\n let newPeriodText: string | undefined;\r\n // istanbul ignore else\r\n if (dayPeriodText === \"AM\" || dayPeriodText === \"am\" || dayPeriodText === amLabelRef.current)\r\n newPeriodText = amLabelRef.current;\r\n else if (dayPeriodText === \"PM\" || dayPeriodText === \"pm\" || dayPeriodText === pmLabelRef.current)\r\n newPeriodText = pmLabelRef.current;\r\n\r\n // istanbul ignore else\r\n if (undefined !== newPeriodText) {\r\n setDayPeriodText(newPeriodText);\r\n if (newPeriodText === amLabelRef.current && hours > 12) {\r\n updateTimeSpec({ ...timeSpec, hours: hours - 12 });\r\n } else if (newPeriodText === pmLabelRef.current && hours <= 11) {\r\n updateTimeSpec({ ...timeSpec, hours: hours + 12 });\r\n }\r\n }\r\n\r\n }, [dayPeriodText, hours, timeSpec, updateTimeSpec]);\r\n\r\n const handleHoursOnKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (event.key === SpecialKey.ArrowDown || event.key === SpecialKey.ArrowUp) {\r\n let newHours = hours + (event.key === SpecialKey.ArrowDown ? -1 : 1);\r\n if (newHours < 0) newHours = 24;\r\n if (newHours > 24 || (newHours > 23 && ((minutes + seconds) > 0))) newHours = 0;\r\n setHoursText(getDisplayHours(newHours).toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, hours: newHours });\r\n showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Enter) {\r\n const newHours = getValidInt(hoursText, 0, 24, hours);\r\n setHoursText(getDisplayHours(newHours).toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, hours: newHours });\r\n showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);\r\n event.preventDefault();\r\n }\r\n }, [getDisplayHours, hours, hoursText, minutes, seconds, showDayPeriod, timeSpec, updateTimeSpec]);\r\n\r\n const handleMinutesOnKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (event.key === SpecialKey.ArrowDown) {\r\n const newMinutes = minutes === 0 ? 59 : minutes - 1;\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowUp) {\r\n const newMinutes = minutes === 59 ? 0 : minutes + 1;\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Home || event.key === SpecialKey.End) {\r\n const newMinutes = event.key === SpecialKey.Home ? 0 : 59;\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n event.preventDefault();\r\n } else /* istanbul ignore next */ if (event.key === SpecialKey.Enter) {\r\n const newMinutes = getValidInt(minutesText, 0, 59, minutes);\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n event.preventDefault();\r\n }\r\n }, [minutesText, minutes, timeSpec, updateTimeSpec]);\r\n\r\n const handleSecondsOnKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (event.key === SpecialKey.ArrowDown) {\r\n const newSeconds = seconds === 0 ? 59 : seconds - 1;\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowUp) {\r\n const newSeconds = seconds === 59 ? 0 : seconds + 1;\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Home || event.key === SpecialKey.End) {\r\n const newSeconds = event.key === SpecialKey.Home ? 0 : 59;\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Enter) {\r\n const newSeconds = getValidInt(secondsText, 0, 59, seconds);\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n event.preventDefault();\r\n }\r\n }, [seconds, secondsText, timeSpec, updateTimeSpec]);\r\n\r\n const handleDayPeriodOnKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n let newPeriodText: string | undefined;\r\n // istanbul ignore else\r\n if (event.key === SpecialKey.ArrowDown || event.key === SpecialKey.Home || event.key === \"a\" || event.key === \"A\") {\r\n newPeriodText = amLabelRef.current;\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowUp || event.key === SpecialKey.End || event.key === \"p\" || event.key === \"P\") {\r\n newPeriodText = pmLabelRef.current;\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Enter) {\r\n if (dayPeriodText === \"AM\" || dayPeriodText === \"am\" || dayPeriodText === amLabelRef.current)\r\n newPeriodText = amLabelRef.current;\r\n else if (dayPeriodText === \"PM\" || dayPeriodText === \"pm\" || dayPeriodText === pmLabelRef.current)\r\n newPeriodText = pmLabelRef.current;\r\n event.preventDefault();\r\n }\r\n // istanbul ignore else\r\n if (undefined !== newPeriodText) {\r\n setDayPeriodText(newPeriodText);\r\n /* istanbul ignore else */\r\n if (newPeriodText === amLabelRef.current && hours > 12) {\r\n updateTimeSpec({ ...timeSpec, hours: hours - 12 });\r\n } else if (newPeriodText === pmLabelRef.current && hours <= 11) {\r\n updateTimeSpec({ ...timeSpec, hours: hours + 12 });\r\n }\r\n }\r\n }, [dayPeriodText, hours, timeSpec, updateTimeSpec]);\r\n\r\n const showSeconds = -1 !== (timeDisplay as string).search(\":ss\");\r\n\r\n return <div data-testid=\"components-time-input\" className=\"components-time\">\r\n <Input className=\"components-time-input\" onKeyDown={handleHoursOnKeyDown} onBlur={handleHoursOnBlur} onChange={handleHoursChange} value={hoursText} disabled={readOnly} />\r\n <span className=\"component-time-separator\">:</span>\r\n <Input className=\"components-time-input\" onKeyDown={handleMinutesOnKeyDown} onBlur={handleMinutesOnBlur} onChange={handleMinutesChange} value={minutesText} disabled={readOnly} />\r\n {showSeconds &&\r\n <>\r\n <span className=\"component-time-separator\">:</span>\r\n <Input className=\"components-time-input\" onKeyDown={handleSecondsOnKeyDown} onBlur={handleSecondsOnBlur} onChange={handleSecondsChange} value={secondsText} disabled={readOnly} />\r\n </>\r\n }\r\n {dayPeriodText &&\r\n <Input className=\"components-time-period-input\" onKeyDown={handleDayPeriodOnKeyDown} onBlur={handleDayPeriodOnBlur} onChange={handleDayPeriodChange} value={dayPeriodText} disabled={readOnly} />\r\n }\r\n </div>;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TimeField.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/TimeField.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,kBAAkB,CAAC;AAsB1B,SAAS,WAAW,CAAC,OAAe,EAAE,GAAW,EAAE,GAAW,EAAE,YAAoB;IAClF,IAAI;QACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACvC,IAAI,QAAQ,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG;YACpC,OAAO,QAAQ,CAAC;KACnB;IAAC,OAAO,EAAE,EAAE;QACX,uBAAuB;QACvB,OAAO,YAAY,CAAC;KACrB;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,CAAW,EAAE,CAAW;IA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Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Date\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { Input } from \"@itwin/itwinui-react\";\r\nimport { SpecialKey, TimeDisplay } from \"@itwin/appui-abstract\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport \"./TimeField.scss\";\r\n\r\n/** Interface used to hold 24 hour time in\r\n * hours, minutes, and seconds.\r\n * @internal\r\n */\r\nexport interface TimeSpec {\r\n hours: number;\r\n minutes: number;\r\n seconds: number;\r\n}\r\n\r\n/** Interface for props used by [[TimeField]] component.\r\n * @internal\r\n */\r\nexport interface TimeFieldProps {\r\n time: TimeSpec;\r\n timeDisplay: TimeDisplay;\r\n onTimeChange?: (time: TimeSpec) => void;\r\n readOnly?: boolean;\r\n}\r\n\r\nfunction getValidInt(intText: string, min: number, max: number, defaultValue: number) {\r\n try {\r\n const newValue = parseInt(intText, 10);\r\n if (newValue >= min && newValue <= max)\r\n return newValue;\r\n } catch (_e) {\r\n // istanbul ignore next\r\n return defaultValue;\r\n }\r\n return defaultValue;\r\n}\r\n\r\nfunction isSameTime(a: TimeSpec, b: TimeSpec) {\r\n return a.hours === b.hours && a.minutes === b.minutes && a.seconds === b.seconds;\r\n}\r\n\r\n/** Field used to set the Hour:Minutes:Seconds in the [[DatePicker]] Popup panel. The user may key-in the value or use up/down keys to\r\n * change the time.\r\n * @internal\r\n */\r\nexport function TimeField({ time, timeDisplay, readOnly, onTimeChange }: TimeFieldProps) {\r\n const initialDateRef = React.useRef(time);\r\n const amLabelRef = React.useRef(UiComponents.translate(\"timepicker.day-period-am\"));\r\n const pmLabelRef = React.useRef(UiComponents.translate(\"timepicker.day-period-pm\"));\r\n const [timeSpec, setTimeSpec] = React.useState(time);\r\n const { hours, minutes, seconds } = timeSpec;\r\n const showDayPeriod = -1 !== (timeDisplay as string).search(\"aa\");\r\n\r\n const getDisplayHours = React.useCallback((timeHours: number) => {\r\n if (!showDayPeriod) {\r\n return timeHours;\r\n }\r\n const outHours = (0 === timeHours) ? 12 : timeHours > 12 ? timeHours - 12 : timeHours;\r\n return outHours;\r\n }, [showDayPeriod]);\r\n\r\n // See if new initialDate props have changed since component mounted\r\n React.useEffect(() => {\r\n if (!isSameTime(time, initialDateRef.current)) {\r\n setTimeSpec(time);\r\n initialDateRef.current = time;\r\n }\r\n }, [time]);\r\n\r\n const displayHour = getDisplayHours(hours);\r\n const [dayPeriodText, setDayPeriodText] = React.useState(showDayPeriod ? (hours >= 12 ? pmLabelRef.current : amLabelRef.current) : undefined);\r\n const [hoursText, setHoursText] = React.useState(displayHour.toString().padStart(2, \"0\"));\r\n const [minutesText, setMinutesText] = React.useState(minutes.toString().padStart(2, \"0\"));\r\n const [secondsText, setSecondsText] = React.useState(seconds.toString().padStart(2, \"0\"));\r\n\r\n const updateTimeSpec = React.useCallback((newTime: TimeSpec) => {\r\n if (newTime.hours !== timeSpec.hours || newTime.minutes !== timeSpec.minutes || newTime.seconds !== timeSpec.seconds) {\r\n setTimeSpec(newTime);\r\n onTimeChange && onTimeChange(newTime);\r\n }\r\n }, [onTimeChange, timeSpec.hours, timeSpec.minutes, timeSpec.seconds]);\r\n\r\n const handleHoursChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setHoursText(event.currentTarget.value);\r\n }, []);\r\n\r\n const handleMinutesChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setMinutesText(event.currentTarget.value);\r\n }, []);\r\n const handleSecondsChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setSecondsText(event.currentTarget.value);\r\n }, []);\r\n const handleDayPeriodChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setDayPeriodText(event.currentTarget.value);\r\n }, []);\r\n\r\n const handleHoursOnBlur = React.useCallback(() => {\r\n const newHours = getValidInt(hoursText, 0, 24, hours);\r\n setHoursText(getDisplayHours(newHours).toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, hours: newHours });\r\n showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);\r\n }, [getDisplayHours, hours, hoursText, showDayPeriod, timeSpec, updateTimeSpec]);\r\n const handleMinutesOnBlur = React.useCallback(() => {\r\n const newMinutes = getValidInt(minutesText, 0, 59, minutes);\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n }, [minutes, minutesText, timeSpec, updateTimeSpec]);\r\n const handleSecondsOnBlur = React.useCallback(() => {\r\n const newSeconds = getValidInt(secondsText, 0, 59, seconds);\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n }, [seconds, secondsText, timeSpec, updateTimeSpec]);\r\n const handleDayPeriodOnBlur = React.useCallback(() => {\r\n let newPeriodText: string | undefined;\r\n // istanbul ignore else\r\n if (dayPeriodText === \"AM\" || dayPeriodText === \"am\" || dayPeriodText === amLabelRef.current)\r\n newPeriodText = amLabelRef.current;\r\n else if (dayPeriodText === \"PM\" || dayPeriodText === \"pm\" || dayPeriodText === pmLabelRef.current)\r\n newPeriodText = pmLabelRef.current;\r\n\r\n // istanbul ignore else\r\n if (undefined !== newPeriodText) {\r\n setDayPeriodText(newPeriodText);\r\n if (newPeriodText === amLabelRef.current && hours > 12) {\r\n updateTimeSpec({ ...timeSpec, hours: hours - 12 });\r\n } else if (newPeriodText === pmLabelRef.current && hours <= 11) {\r\n updateTimeSpec({ ...timeSpec, hours: hours + 12 });\r\n }\r\n }\r\n\r\n }, [dayPeriodText, hours, timeSpec, updateTimeSpec]);\r\n\r\n const handleHoursOnKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (event.key === SpecialKey.ArrowDown || event.key === SpecialKey.ArrowUp) {\r\n let newHours = hours + (event.key === SpecialKey.ArrowDown ? -1 : 1);\r\n if (newHours < 0) newHours = 24;\r\n if (newHours > 24 || (newHours > 23 && ((minutes + seconds) > 0))) newHours = 0;\r\n setHoursText(getDisplayHours(newHours).toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, hours: newHours });\r\n showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Enter) {\r\n const newHours = getValidInt(hoursText, 0, 24, hours);\r\n setHoursText(getDisplayHours(newHours).toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, hours: newHours });\r\n showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);\r\n event.preventDefault();\r\n }\r\n }, [getDisplayHours, hours, hoursText, minutes, seconds, showDayPeriod, timeSpec, updateTimeSpec]);\r\n\r\n const handleMinutesOnKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (event.key === SpecialKey.ArrowDown) {\r\n const newMinutes = minutes === 0 ? 59 : minutes - 1;\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowUp) {\r\n const newMinutes = minutes === 59 ? 0 : minutes + 1;\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Home || event.key === SpecialKey.End) {\r\n const newMinutes = event.key === SpecialKey.Home ? 0 : 59;\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n event.preventDefault();\r\n } else /* istanbul ignore next */ if (event.key === SpecialKey.Enter) {\r\n const newMinutes = getValidInt(minutesText, 0, 59, minutes);\r\n setMinutesText(newMinutes.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, minutes: newMinutes });\r\n event.preventDefault();\r\n }\r\n }, [minutesText, minutes, timeSpec, updateTimeSpec]);\r\n\r\n const handleSecondsOnKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (event.key === SpecialKey.ArrowDown) {\r\n const newSeconds = seconds === 0 ? 59 : seconds - 1;\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowUp) {\r\n const newSeconds = seconds === 59 ? 0 : seconds + 1;\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Home || event.key === SpecialKey.End) {\r\n const newSeconds = event.key === SpecialKey.Home ? 0 : 59;\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Enter) {\r\n const newSeconds = getValidInt(secondsText, 0, 59, seconds);\r\n setSecondsText(newSeconds.toString().padStart(2, \"0\"));\r\n updateTimeSpec({ ...timeSpec, seconds: newSeconds });\r\n event.preventDefault();\r\n }\r\n }, [seconds, secondsText, timeSpec, updateTimeSpec]);\r\n\r\n const handleDayPeriodOnKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n let newPeriodText: string | undefined;\r\n // istanbul ignore else\r\n if (event.key === SpecialKey.ArrowDown || event.key === SpecialKey.Home || event.key === \"a\" || event.key === \"A\") {\r\n newPeriodText = amLabelRef.current;\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowUp || event.key === SpecialKey.End || event.key === \"p\" || event.key === \"P\") {\r\n newPeriodText = pmLabelRef.current;\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Enter) {\r\n if (dayPeriodText === \"AM\" || dayPeriodText === \"am\" || dayPeriodText === amLabelRef.current)\r\n newPeriodText = amLabelRef.current;\r\n else if (dayPeriodText === \"PM\" || dayPeriodText === \"pm\" || dayPeriodText === pmLabelRef.current)\r\n newPeriodText = pmLabelRef.current;\r\n event.preventDefault();\r\n }\r\n // istanbul ignore else\r\n if (undefined !== newPeriodText) {\r\n setDayPeriodText(newPeriodText);\r\n /* istanbul ignore else */\r\n if (newPeriodText === amLabelRef.current && hours > 12) {\r\n updateTimeSpec({ ...timeSpec, hours: hours - 12 });\r\n } else if (newPeriodText === pmLabelRef.current && hours <= 11) {\r\n updateTimeSpec({ ...timeSpec, hours: hours + 12 });\r\n }\r\n }\r\n }, [dayPeriodText, hours, timeSpec, updateTimeSpec]);\r\n\r\n const showSeconds = -1 !== (timeDisplay as string).search(\":ss\");\r\n\r\n return <div data-testid=\"components-time-input\" className=\"components-time\">\r\n <Input className=\"components-time-input\" onKeyDown={handleHoursOnKeyDown} onBlur={handleHoursOnBlur} onChange={handleHoursChange} value={hoursText} disabled={readOnly} size=\"small\" />\r\n <span className=\"component-time-separator\">:</span>\r\n <Input className=\"components-time-input\" onKeyDown={handleMinutesOnKeyDown} onBlur={handleMinutesOnBlur} onChange={handleMinutesChange} value={minutesText} disabled={readOnly} size=\"small\" />\r\n {showSeconds &&\r\n <>\r\n <span className=\"component-time-separator\">:</span>\r\n <Input className=\"components-time-input\" onKeyDown={handleSecondsOnKeyDown} onBlur={handleSecondsOnBlur} onChange={handleSecondsChange} value={secondsText} disabled={readOnly} size=\"small\" />\r\n </>\r\n }\r\n {dayPeriodText &&\r\n <Input className=\"components-time-period-input\" onKeyDown={handleDayPeriodOnKeyDown} onBlur={handleDayPeriodOnBlur} onChange={handleDayPeriodChange} value={dayPeriodText} disabled={readOnly} size=\"small\" />\r\n }\r\n </div>;\r\n}\r\n"]}
|
|
@@ -20,6 +20,7 @@ export declare class CustomNumberEditor extends React.PureComponent<PropertyEdit
|
|
|
20
20
|
private _isMounted;
|
|
21
21
|
private _formatParams;
|
|
22
22
|
private _inputElement;
|
|
23
|
+
private _lastValidValue;
|
|
23
24
|
/** @internal */
|
|
24
25
|
readonly state: Readonly<CustomNumberEditorState>;
|
|
25
26
|
getPropertyValue(): Promise<PropertyValue | undefined>;
|
|
@@ -36,7 +37,7 @@ export declare class CustomNumberEditor extends React.PureComponent<PropertyEdit
|
|
|
36
37
|
componentDidUpdate(prevProps: PropertyEditorProps): void;
|
|
37
38
|
private _getInitialDisplayValue;
|
|
38
39
|
private setStateFromProps;
|
|
39
|
-
private
|
|
40
|
+
private _resetToLastValidDisplayValue;
|
|
40
41
|
private _onKeyPress;
|
|
41
42
|
private _onFocus;
|
|
42
43
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomNumberEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,2BAA2B,CAAC;AAEnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEW,aAAa,EAC9B,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomNumberEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,2BAA2B,CAAC;AAEnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEW,aAAa,EAC9B,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAyB,MAAM,yBAAyB,CAAC;AAEpF,gBAAgB;AAChB,UAAU,uBAAuB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,uBAAuB,CAAE,YAAW,UAAU;IAC7H,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAA0C;IAC/D,OAAO,CAAC,aAAa,CAAuC;IAC5D,OAAO,CAAC,eAAe,CAA4B;IAEnD,gBAAgB;IAChB,SAAyB,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAE/D;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAiDnE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,iBAAiB,CAEvB;IAEF,gBAAgB;IACA,iBAAiB;IAKjC,gBAAgB;IACA,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;IAMjE,OAAO,CAAC,uBAAuB;YAqBjB,iBAAiB;IAuD/B,OAAO,CAAC,6BAA6B;IAKrC,OAAO,CAAC,WAAW,CAmBjB;IAGF,OAAO,CAAC,QAAQ,CAEd;IAEF,gBAAgB;IACA,MAAM,IAAI,KAAK,CAAC,SAAS;CAqD1C;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;IACD,IAAoB,sBAAsB,IAAI,OAAO,CAEpD;CACF"}
|
|
@@ -11,7 +11,8 @@ import classnames from "classnames";
|
|
|
11
11
|
import * as React from "react";
|
|
12
12
|
import { Logger } from "@itwin/core-bentley";
|
|
13
13
|
import { MessageSeverity, PropertyEditorParamTypes, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAdmin, } from "@itwin/appui-abstract";
|
|
14
|
-
import { Icon, IconInput
|
|
14
|
+
import { Icon, IconInput } from "@itwin/core-react";
|
|
15
|
+
import { Input } from "@itwin/itwinui-react";
|
|
15
16
|
import { UiComponents } from "../UiComponents";
|
|
16
17
|
import { PropertyEditorBase, PropertyEditorManager } from "./PropertyEditorManager";
|
|
17
18
|
/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.
|
|
@@ -30,13 +31,14 @@ export class CustomNumberEditor extends React.PureComponent {
|
|
|
30
31
|
this._applyUpdatedValue(e.target.value);
|
|
31
32
|
};
|
|
32
33
|
this._onKeyPress = (e) => {
|
|
34
|
+
var _a;
|
|
33
35
|
// istanbul ignore else
|
|
34
36
|
if (e.key === SpecialKey.Escape) {
|
|
35
|
-
const initialDisplayValue = this._getInitialDisplayValue();
|
|
37
|
+
const initialDisplayValue = (_a = (this._lastValidValue && this._lastValidValue.displayValue)) !== null && _a !== void 0 ? _a : this._getInitialDisplayValue();
|
|
36
38
|
if (initialDisplayValue !== this.state.inputValue) {
|
|
37
39
|
e.preventDefault();
|
|
38
40
|
e.stopPropagation();
|
|
39
|
-
this.
|
|
41
|
+
this._resetToLastValidDisplayValue();
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
42
44
|
// istanbul ignore else
|
|
@@ -74,6 +76,7 @@ export class CustomNumberEditor extends React.PureComponent {
|
|
|
74
76
|
value: parseResults.value,
|
|
75
77
|
displayValue: newDisplayValue,
|
|
76
78
|
};
|
|
79
|
+
this._lastValidValue = { ...propertyValue };
|
|
77
80
|
// make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6"
|
|
78
81
|
// istanbul ignore else
|
|
79
82
|
if (newDisplayValue !== this.state.inputValue) {
|
|
@@ -82,12 +85,15 @@ export class CustomNumberEditor extends React.PureComponent {
|
|
|
82
85
|
}
|
|
83
86
|
else {
|
|
84
87
|
// istanbul ignore else
|
|
85
|
-
if (this.htmlElement)
|
|
88
|
+
if (this.htmlElement) {
|
|
86
89
|
UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate("errors.unable-to-parse-quantity"));
|
|
87
|
-
|
|
90
|
+
this.htmlElement.focus();
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
88
93
|
UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate("errors.unable-to-parse-quantity"));
|
|
94
|
+
}
|
|
89
95
|
const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ this._formatParams.formatFunction(record.value.value);
|
|
90
|
-
propertyValue = {
|
|
96
|
+
propertyValue = this._lastValidValue ? { ...this._lastValidValue } : {
|
|
91
97
|
valueFormat: PropertyValueFormat.Primitive,
|
|
92
98
|
value: record.value.value,
|
|
93
99
|
displayValue,
|
|
@@ -176,6 +182,11 @@ export class CustomNumberEditor extends React.PureComponent {
|
|
|
176
182
|
return;
|
|
177
183
|
}
|
|
178
184
|
const initialDisplayValue = this._getInitialDisplayValue();
|
|
185
|
+
this._lastValidValue = {
|
|
186
|
+
valueFormat: PropertyValueFormat.Primitive,
|
|
187
|
+
value: record.value.value,
|
|
188
|
+
displayValue: initialDisplayValue,
|
|
189
|
+
};
|
|
179
190
|
let size;
|
|
180
191
|
let maxLength;
|
|
181
192
|
let iconSpec;
|
|
@@ -200,8 +211,9 @@ export class CustomNumberEditor extends React.PureComponent {
|
|
|
200
211
|
if (this._isMounted)
|
|
201
212
|
this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });
|
|
202
213
|
}
|
|
203
|
-
|
|
204
|
-
|
|
214
|
+
_resetToLastValidDisplayValue() {
|
|
215
|
+
var _a;
|
|
216
|
+
const initialDisplayValue = (_a = (this._lastValidValue && this._lastValidValue.displayValue)) !== null && _a !== void 0 ? _a : this._getInitialDisplayValue();
|
|
205
217
|
this.setState({ inputValue: initialDisplayValue });
|
|
206
218
|
}
|
|
207
219
|
/** @internal */
|
|
@@ -236,9 +248,7 @@ export class CustomNumberEditor extends React.PureComponent {
|
|
|
236
248
|
}
|
|
237
249
|
else {
|
|
238
250
|
// NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop
|
|
239
|
-
reactNode = (
|
|
240
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
241
|
-
React.createElement(Input, { ...inputProps, ref: this._inputElement, "data-testid": "components-customnumber-editor" }));
|
|
251
|
+
reactNode = (React.createElement(Input, { ...inputProps, ref: this._inputElement, "data-testid": "components-customnumber-editor", size: "small" }));
|
|
242
252
|
}
|
|
243
253
|
return reactNode;
|
|
244
254
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,oCAAoC;AAEpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACiE,eAAe,EAAwC,wBAAwB,EACtH,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,GAChH,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAUpF;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK,CAAC,aAA2D;IAAzG;;QACU,eAAU,GAAG,KAAK,CAAC;QAEnB,kBAAa,G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W;SAC5B,CAAC;QAEF,IAAI,SAA0B,CAAC;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,MAAM,IAAI,GAAG,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,gCAAgC,GAC5C,CACH,CAAC;SACH;aAAM;YACL,uFAAuF;YACvF,SAAS,GAAG;YACV,mDAAmD;YACnD,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,GAC5C,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\n// cSpell:ignore customnumber testid\r\n\r\nimport \"./CustomNumberEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CustomFormattedNumberParams, IconEditorParams, InputEditorSizeParams, MessageSeverity, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes,\r\n PropertyRecord, PropertyValue, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAdmin,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon, IconInput, Input, InputProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** @internal */\r\ninterface CustomNumberEditorState {\r\n inputValue: string;\r\n size?: number;\r\n maxLength?: number;\r\n iconSpec?: string;\r\n}\r\n\r\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\r\n * @alpha\r\n */\r\nexport class CustomNumberEditor extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState> implements TypeEditor {\r\n private _isMounted = false;\r\n private _formatParams: CustomFormattedNumberParams | undefined;\r\n private _inputElement = React.createRef<HTMLInputElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<CustomNumberEditorState> = {\r\n inputValue: \"\",\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n if (record.isReadonly) {\r\n return {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: (record.value as PrimitiveValue).value,\r\n displayValue: (record.value as PrimitiveValue).displayValue,\r\n };\r\n }\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const parseResults = (this._formatParams as CustomFormattedNumberParams).parseFunction(this.state.inputValue);\r\n if (!parseResults.parseError && undefined !== parseResults.value) {\r\n const newDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(parseResults.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: parseResults.value,\r\n displayValue: newDisplayValue,\r\n };\r\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\r\n // istanbul ignore else\r\n if (newDisplayValue !== this.state.inputValue) {\r\n this.setState({ inputValue: newDisplayValue });\r\n }\r\n } else {\r\n // istanbul ignore else\r\n if (this.htmlElement)\r\n UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n else\r\n UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n\r\n const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ (this._formatParams as CustomFormattedNumberParams).formatFunction(record.value.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: record.value.value,\r\n displayValue,\r\n };\r\n }\r\n }\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._inputElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n return document.activeElement === this._inputElement.current;\r\n }\r\n\r\n private shouldSetFocus(): boolean {\r\n if (!this.props.setFocus)\r\n return false;\r\n\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n\r\n return (!disabled && !readonly);\r\n }\r\n\r\n private _applyUpdatedValue(userInput: string) {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n\r\n if (readonly || disabled)\r\n return;\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({\r\n inputValue: userInput,\r\n });\r\n }\r\n\r\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\r\n this._applyUpdatedValue(e.target.value);\r\n };\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n this._isMounted = false;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private _getInitialDisplayValue(): string {\r\n const record = this.props.propertyRecord;\r\n let initialDisplayValue = \"\";\r\n let numberValue = 0;\r\n // istanbul ignore else\r\n if (record) {\r\n // istanbul ignore else\r\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = record.value;\r\n numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : /* istanbul ignore next */ 0;\r\n // istanbul ignore else\r\n if (primitiveValue.displayValue)\r\n initialDisplayValue = primitiveValue.displayValue;\r\n else\r\n initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue);\r\n }\r\n }\r\n\r\n return initialDisplayValue;\r\n }\r\n\r\n private async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n // istanbul ignore next\r\n if (!record || !record.property) {\r\n Logger.logError(UiComponents.loggerCategory(this), \"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n // eslint-disable-next-line no-console\r\n // console.log(\"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n return;\r\n }\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n this._formatParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CustomFormattedNumber) as CustomFormattedNumberParams;\r\n }\r\n\r\n if (!this._formatParams) {\r\n Logger.logError(UiComponents.loggerCategory(this), `CustomFormattedNumberParams must be defined for property ${record.property.name}`);\r\n // eslint-disable-next-line no-console\r\n // console.log(`CustomFormattedNumberParams must be defined for property ${record!.property!.name}`);\r\n return;\r\n }\r\n\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n let size: number | undefined;\r\n let maxLength: number | undefined;\r\n let iconSpec: string | undefined;\r\n\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n const editorSizeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.InputEditorSize) as InputEditorSizeParams;\r\n // istanbul ignore else\r\n if (editorSizeParams) {\r\n // istanbul ignore else\r\n if (editorSizeParams.size)\r\n size = editorSizeParams.size;\r\n // istanbul ignore else\r\n if (editorSizeParams.maxLength)\r\n maxLength = editorSizeParams.maxLength;\r\n }\r\n\r\n const iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\r\n if (iconParams) {\r\n iconSpec = iconParams.definition.iconSpec;\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });\r\n }\r\n\r\n private _resetToOriginalValue() {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n\r\n this.setState({ inputValue: initialDisplayValue });\r\n }\r\n\r\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Escape) {\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n if (initialDisplayValue !== this.state.inputValue) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n this._resetToOriginalValue();\r\n } else {\r\n // istanbul ignore else\r\n if (this.props.onCancel)\r\n this.props.onCancel();\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (e.key !== SpecialKey.Enter) {\r\n UiAdmin.messagePresenter.closeInputFieldMessage();\r\n }\r\n };\r\n\r\n // istanbul ignore next\r\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\r\n e.target.select();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const minSize = this.state.size ? this.state.size : 8;\r\n const minWidthStyle: React.CSSProperties = {\r\n minWidth: `${minSize * 0.75}em`,\r\n };\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n if (!record || !this._formatParams)\r\n return null;\r\n\r\n const readOnly = !record.isReadonly ? false : true;\r\n const disabled = !record.isDisabled ? false : true;\r\n\r\n const className = classnames(\"components-cell-editor\", \"components-customnumber-editor\", this.props.className);\r\n\r\n const inputProps: Omit<InputProps, \"size\"> = { // eslint-disable-line deprecation/deprecation\r\n className,\r\n style: this.props.style ? this.props.style : minWidthStyle,\r\n readOnly,\r\n disabled,\r\n maxLength: this.state.maxLength,\r\n value: this.state.inputValue,\r\n onChange: this._updateInputValue,\r\n onBlur: this.props.onBlur,\r\n onFocus: this._onFocus,\r\n setFocus: this.shouldSetFocus(),\r\n onKeyDown: this._onKeyPress,\r\n };\r\n\r\n let reactNode: React.ReactNode;\r\n if (this.state.iconSpec) {\r\n const icon = <Icon iconSpec={this.state.iconSpec} />;\r\n reactNode = (\r\n <IconInput\r\n {...inputProps}\r\n ref={this._inputElement}\r\n icon={icon}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n } else {\r\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\r\n reactNode = (\r\n // eslint-disable-next-line deprecation/deprecation\r\n <Input\r\n {...inputProps}\r\n ref={this._inputElement}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n }\r\n\r\n return reactNode;\r\n }\r\n}\r\n\r\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\r\n * It uses the [[CustomNumberEditor]] React component.\r\n * @alpha\r\n */\r\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <CustomNumberEditor />;\r\n }\r\n public override get containerHandlesEscape(): boolean {\r\n return false;\r\n }\r\n}\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom);\r\n"]}
|
|
1
|
+
{"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,oCAAoC;AAEpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACiE,eAAe,EAAwC,wBAAwB,EACtH,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,GAChH,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAc,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAUpF;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK,CAAC,aAA2D;IAAzG;;QACU,eAAU,GAAG,KAAK,CAAC;QAEnB,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAG5D,gBAAgB;QACS,UAAK,GAAsC;YAClE,UAAU,EAAE,EAAE;SACf,CAAC;QAqFM,sBAAiB,GAAG,CAAC,CAAsC,EAAE,EAAE;YACrE,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC;QAqGM,gBAAW,GAAG,CAAC,CAAwC,EAAE,EAAE;;YACjE,uBAAuB;YACvB,IAAI,CAAC,CAAC,GAAG,KAAK,UAAU,CAAC,MAAM,EAAE;gBAC/B,MAAM,mBAAmB,GAAG,MAAA,CAAC,IAAI,CAAC,eAAe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,MAAM;YACzB,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE;YAC/B,SAAS,EAAE,IAAI,CAAC,WAAW;SAC5B,CAAC;QAEF,IAAI,SAA0B,CAAC;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,MAAM,IAAI,GAAG,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,gCAAgC,GAC5C,CACH,CAAC;SACH;aAAM;YACL,uFAAuF;YACvF,SAAS,GAAG,CACV,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,EAC5C,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\n// cSpell:ignore customnumber testid\r\n\r\nimport \"./CustomNumberEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n CustomFormattedNumberParams, IconEditorParams, InputEditorSizeParams, MessageSeverity, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes,\r\n PropertyRecord, PropertyValue, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAdmin,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon, IconInput } from \"@itwin/core-react\";\r\nimport { Input, InputProps } from \"@itwin/itwinui-react\";\r\n\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n/** @internal */\r\ninterface CustomNumberEditorState {\r\n inputValue: string;\r\n size?: number;\r\n maxLength?: number;\r\n iconSpec?: string;\r\n}\r\n\r\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\r\n * @alpha\r\n */\r\nexport class CustomNumberEditor extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState> implements TypeEditor {\r\n private _isMounted = false;\r\n private _formatParams: CustomFormattedNumberParams | undefined;\r\n private _inputElement = React.createRef<HTMLInputElement>();\r\n private _lastValidValue: PropertyValue | undefined;\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<CustomNumberEditorState> = {\r\n inputValue: \"\",\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n if (record.isReadonly) {\r\n return {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: (record.value as PrimitiveValue).value,\r\n displayValue: (record.value as PrimitiveValue).displayValue,\r\n };\r\n }\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const parseResults = (this._formatParams as CustomFormattedNumberParams).parseFunction(this.state.inputValue);\r\n if (!parseResults.parseError && undefined !== parseResults.value) {\r\n const newDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(parseResults.value as number);\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: parseResults.value,\r\n displayValue: newDisplayValue,\r\n };\r\n this._lastValidValue = { ...propertyValue };\r\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\r\n // istanbul ignore else\r\n if (newDisplayValue !== this.state.inputValue) {\r\n this.setState({ inputValue: newDisplayValue });\r\n }\r\n } else {\r\n // istanbul ignore else\r\n if (this.htmlElement) {\r\n UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n this.htmlElement.focus();\r\n } else {\r\n UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\r\n }\r\n\r\n const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ (this._formatParams as CustomFormattedNumberParams).formatFunction(record.value.value as number);\r\n propertyValue = this._lastValidValue ? { ...this._lastValidValue } : {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: record.value.value,\r\n displayValue,\r\n };\r\n }\r\n }\r\n\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._inputElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n return document.activeElement === this._inputElement.current;\r\n }\r\n\r\n private shouldSetFocus(): boolean {\r\n if (!this.props.setFocus)\r\n return false;\r\n\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n\r\n return (!disabled && !readonly);\r\n }\r\n\r\n private _applyUpdatedValue(userInput: string) {\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n const readonly = (record && !record.isReadonly) ? false : true;\r\n const disabled = (record && !record.isDisabled) ? false : true;\r\n\r\n if (readonly || disabled)\r\n return;\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({\r\n inputValue: userInput,\r\n });\r\n }\r\n\r\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\r\n this._applyUpdatedValue(e.target.value);\r\n };\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n this._isMounted = false;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private _getInitialDisplayValue(): string {\r\n const record = this.props.propertyRecord;\r\n let initialDisplayValue = \"\";\r\n let numberValue = 0;\r\n // istanbul ignore else\r\n if (record) {\r\n // istanbul ignore else\r\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = record.value;\r\n numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : /* istanbul ignore next */ 0;\r\n // istanbul ignore else\r\n if (primitiveValue.displayValue)\r\n initialDisplayValue = primitiveValue.displayValue;\r\n else\r\n initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue);\r\n }\r\n }\r\n\r\n return initialDisplayValue;\r\n }\r\n\r\n private async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n // istanbul ignore next\r\n if (!record || !record.property) {\r\n Logger.logError(UiComponents.loggerCategory(this), \"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n // eslint-disable-next-line no-console\r\n // console.log(\"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\r\n return;\r\n }\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n this._formatParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CustomFormattedNumber) as CustomFormattedNumberParams;\r\n }\r\n\r\n if (!this._formatParams) {\r\n Logger.logError(UiComponents.loggerCategory(this), `CustomFormattedNumberParams must be defined for property ${record.property.name}`);\r\n // eslint-disable-next-line no-console\r\n // console.log(`CustomFormattedNumberParams must be defined for property ${record!.property!.name}`);\r\n return;\r\n }\r\n\r\n const initialDisplayValue = this._getInitialDisplayValue();\r\n this._lastValidValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: (record.value as PrimitiveValue).value,\r\n displayValue: initialDisplayValue,\r\n };\r\n let size: number | undefined;\r\n let maxLength: number | undefined;\r\n let iconSpec: string | undefined;\r\n\r\n // istanbul ignore else\r\n if (record.property && record.property.editor && record.property.editor.params) {\r\n const editorSizeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.InputEditorSize) as InputEditorSizeParams;\r\n // istanbul ignore else\r\n if (editorSizeParams) {\r\n // istanbul ignore else\r\n if (editorSizeParams.size)\r\n size = editorSizeParams.size;\r\n // istanbul ignore else\r\n if (editorSizeParams.maxLength)\r\n maxLength = editorSizeParams.maxLength;\r\n }\r\n\r\n const iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\r\n if (iconParams) {\r\n iconSpec = iconParams.definition.iconSpec;\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });\r\n }\r\n\r\n private _resetToLastValidDisplayValue() {\r\n const initialDisplayValue = (this._lastValidValue && (this._lastValidValue as PrimitiveValue).displayValue) ?? this._getInitialDisplayValue();\r\n this.setState({ inputValue: initialDisplayValue });\r\n }\r\n\r\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Escape) {\r\n const initialDisplayValue = (this._lastValidValue && (this._lastValidValue as PrimitiveValue).displayValue) ?? this._getInitialDisplayValue();\r\n if (initialDisplayValue !== this.state.inputValue) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n this._resetToLastValidDisplayValue();\r\n } else {\r\n // istanbul ignore else\r\n if (this.props.onCancel)\r\n this.props.onCancel();\r\n }\r\n }\r\n\r\n // istanbul ignore else\r\n if (e.key !== SpecialKey.Enter) {\r\n UiAdmin.messagePresenter.closeInputFieldMessage();\r\n }\r\n };\r\n\r\n // istanbul ignore next\r\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\r\n e.target.select();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const minSize = this.state.size ? this.state.size : 8;\r\n const minWidthStyle: React.CSSProperties = {\r\n minWidth: `${minSize * 0.75}em`,\r\n };\r\n const record = this.props.propertyRecord as PropertyRecord;\r\n if (!record || !this._formatParams)\r\n return null;\r\n\r\n const readOnly = !record.isReadonly ? false : true;\r\n const disabled = !record.isDisabled ? false : true;\r\n\r\n const className = classnames(\"components-cell-editor\", \"components-customnumber-editor\", this.props.className);\r\n\r\n const inputProps: Omit<InputProps, \"size\"> = { // eslint-disable-line deprecation/deprecation\r\n className,\r\n style: this.props.style ? this.props.style : minWidthStyle,\r\n readOnly,\r\n disabled,\r\n maxLength: this.state.maxLength,\r\n value: this.state.inputValue,\r\n onChange: this._updateInputValue,\r\n onBlur: this.props.onBlur,\r\n onFocus: this._onFocus,\r\n setFocus: this.shouldSetFocus(),\r\n onKeyDown: this._onKeyPress,\r\n };\r\n\r\n let reactNode: React.ReactNode;\r\n if (this.state.iconSpec) {\r\n const icon = <Icon iconSpec={this.state.iconSpec} />;\r\n reactNode = (\r\n <IconInput\r\n {...inputProps}\r\n ref={this._inputElement}\r\n icon={icon}\r\n data-testid=\"components-customnumber-editor\"\r\n />\r\n );\r\n } else {\r\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\r\n reactNode = (\r\n <Input\r\n {...inputProps}\r\n ref={this._inputElement}\r\n data-testid=\"components-customnumber-editor\"\r\n size=\"small\"\r\n />\r\n );\r\n }\r\n\r\n return reactNode;\r\n }\r\n}\r\n\r\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\r\n * It uses the [[CustomNumberEditor]] React component.\r\n * @alpha\r\n */\r\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <CustomNumberEditor />;\r\n }\r\n public override get containerHandlesEscape(): boolean {\r\n return false;\r\n }\r\n}\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom);\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAE3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAqB,aAAa,EAA0C,MAAM,uBAAuB,CAAC;AACjH,OAAO,EAAU,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAyB,MAAM,yBAAyB,CAAC;AAGpF,gBAAgB;AAChB,UAAU,eAAe;IACvB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED;;IAEI;AACJ,qBAAa,UAAW,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,eAAe,CAAE,YAAW,UAAU;IAC7G,OAAO,CAAC,U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IAC3B,OAAO,CAAC,UAAU,CAAyC;IAC3D,OAAO,CAAC,WAAW,CAAqC;IAExD,gBAAgB;IAChB,SAAyB,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,CAKvD;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAiBnE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAGD,IAAW,QAAQ,IAAI,OAAO,CAM7B;IAED,OAAO,CAAC,kBAAkB,CAwBxB;IAEF,gBAAgB;IACA,iBAAiB;IAKjC,gBAAgB;IACA,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAwC/B,gBAAgB;IACA,MAAM;CA0BvB;AAED;;;IAGI;AACJ,qBAAa,kBAAmB,SAAQ,kBAAkB;IAExD,IAAoB,qBAAqB,IAAI,OAAO,CAEnD;IACD,IAAoB,gCAAgC,IAAI,OAAO,CAE9D;IAED,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;CACF"}
|
|
@@ -138,9 +138,8 @@ export class EnumEditor extends React.PureComponent {
|
|
|
138
138
|
};
|
|
139
139
|
// The iTwinUI-react Select onBlur still does not work properly, so it cannot be used yet. NEEDSWORK
|
|
140
140
|
// onBlur={this.props.onBlur}
|
|
141
|
-
/* The following popoverProps are required for the popup to properly show in floating widgets because this makes it work similar to a portal */
|
|
142
141
|
return (React.createElement("div", { ref: this._divElement },
|
|
143
|
-
React.createElement(Select, { className: className, style: this.props.style ? this.props.style : minWidthStyle, value: selectValue,
|
|
142
|
+
React.createElement(Select, { className: className, style: this.props.style ? this.props.style : minWidthStyle, value: selectValue, onChange: this._updateSelectValue, "data-testid": "components-select-editor", options: this.state.options, setFocus: this.props.setFocus, "aria-label": this._ariaLabel, size: "small" })));
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
145
|
/** Enum Property Button Group Editor registered for the "enum" type name.
|