@itwin/components-react 4.6.3 → 4.7.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 +17 -1
- package/lib/cjs/components-react/UiComponents.d.ts.map +1 -1
- package/lib/cjs/components-react/UiComponents.js +3 -2
- package/lib/cjs/components-react/UiComponents.js.map +1 -1
- package/lib/cjs/components-react/common/ImageRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/common/ImageRenderer.js +2 -3
- package/lib/cjs/components-react/common/ImageRenderer.js.map +1 -1
- package/lib/cjs/components-react/common/UseAsyncValue.d.ts.map +1 -1
- package/lib/cjs/components-react/common/UseAsyncValue.js +7 -17
- package/lib/cjs/components-react/common/UseAsyncValue.js.map +1 -1
- package/lib/cjs/components-react/common/UseContextWithMandatoryProvider.d.ts.map +1 -1
- package/lib/cjs/components-react/common/UseContextWithMandatoryProvider.js +2 -1
- package/lib/cjs/components-react/common/UseContextWithMandatoryProvider.js.map +1 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.d.ts.map +1 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +22 -16
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
- package/lib/cjs/components-react/datepicker/DatePicker.d.ts.map +1 -1
- package/lib/cjs/components-react/datepicker/DatePicker.js +6 -6
- package/lib/cjs/components-react/datepicker/DatePicker.js.map +1 -1
- package/lib/cjs/components-react/datepicker/DatePickerPopupButton.js +1 -1
- package/lib/cjs/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
- package/lib/cjs/components-react/datepicker/TimeField.d.ts.map +1 -1
- package/lib/cjs/components-react/datepicker/TimeField.js +19 -22
- package/lib/cjs/components-react/datepicker/TimeField.js.map +1 -1
- package/lib/cjs/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/CustomNumberEditor.js +3 -2
- package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/EditorContainer.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/EditorContainer.js +4 -3
- package/lib/cjs/components-react/editors/EditorContainer.js.map +1 -1
- package/lib/cjs/components-react/editors/EnumButtonGroupEditor.d.ts +0 -1
- package/lib/cjs/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js +1 -2
- package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/PopupButton.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/PopupButton.js +4 -3
- package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
- package/lib/cjs/components-react/filtering/FilteringInput.d.ts.map +1 -1
- package/lib/cjs/components-react/filtering/FilteringInput.js +2 -2
- package/lib/cjs/components-react/filtering/FilteringInput.js.map +1 -1
- package/lib/cjs/components-react/filtering/ResultSelector.js +2 -2
- package/lib/cjs/components-react/filtering/ResultSelector.js.map +1 -1
- package/lib/cjs/components-react/inputs/ParsedInput.d.ts.map +1 -1
- package/lib/cjs/components-react/inputs/ParsedInput.js +3 -3
- package/lib/cjs/components-react/inputs/ParsedInput.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/Common.d.ts +4 -0
- package/lib/cjs/components-react/properties/renderers/value/Common.d.ts.map +1 -0
- package/lib/cjs/components-react/properties/renderers/value/Common.js +12 -0
- package/lib/cjs/components-react/properties/renderers/value/Common.js.map +1 -0
- package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +2 -8
- package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +2 -5
- package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +2 -8
- package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.js +10 -2
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventHandler.d.ts +2 -0
- package/lib/cjs/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventHandler.js +2 -0
- package/lib/cjs/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEvents.d.ts +2 -0
- package/lib/cjs/components-react/tree/controlled/TreeEvents.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEvents.js.map +1 -1
- package/lib/esm/components-react/UiComponents.d.ts.map +1 -1
- package/lib/esm/components-react/UiComponents.js +3 -2
- package/lib/esm/components-react/UiComponents.js.map +1 -1
- package/lib/esm/components-react/common/ImageRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/common/ImageRenderer.js +2 -3
- package/lib/esm/components-react/common/ImageRenderer.js.map +1 -1
- package/lib/esm/components-react/common/UseAsyncValue.d.ts.map +1 -1
- package/lib/esm/components-react/common/UseAsyncValue.js +9 -19
- package/lib/esm/components-react/common/UseAsyncValue.js.map +1 -1
- package/lib/esm/components-react/common/UseContextWithMandatoryProvider.d.ts.map +1 -1
- package/lib/esm/components-react/common/UseContextWithMandatoryProvider.js +3 -2
- package/lib/esm/components-react/common/UseContextWithMandatoryProvider.js.map +1 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.d.ts.map +1 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +23 -17
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
- package/lib/esm/components-react/datepicker/DatePicker.d.ts.map +1 -1
- package/lib/esm/components-react/datepicker/DatePicker.js +6 -6
- package/lib/esm/components-react/datepicker/DatePicker.js.map +1 -1
- package/lib/esm/components-react/datepicker/DatePickerPopupButton.js +2 -2
- package/lib/esm/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
- package/lib/esm/components-react/datepicker/TimeField.d.ts.map +1 -1
- package/lib/esm/components-react/datepicker/TimeField.js +19 -22
- package/lib/esm/components-react/datepicker/TimeField.js.map +1 -1
- package/lib/esm/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
- package/lib/esm/components-react/editors/CustomNumberEditor.js +4 -3
- package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/esm/components-react/editors/EditorContainer.d.ts.map +1 -1
- package/lib/esm/components-react/editors/EditorContainer.js +5 -4
- package/lib/esm/components-react/editors/EditorContainer.js.map +1 -1
- package/lib/esm/components-react/editors/EnumButtonGroupEditor.d.ts +0 -1
- package/lib/esm/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
- package/lib/esm/components-react/editors/EnumButtonGroupEditor.js +2 -3
- package/lib/esm/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/esm/components-react/editors/PopupButton.d.ts.map +1 -1
- package/lib/esm/components-react/editors/PopupButton.js +5 -4
- package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
- package/lib/esm/components-react/filtering/FilteringInput.d.ts.map +1 -1
- package/lib/esm/components-react/filtering/FilteringInput.js +2 -2
- package/lib/esm/components-react/filtering/FilteringInput.js.map +1 -1
- package/lib/esm/components-react/filtering/ResultSelector.js +2 -2
- package/lib/esm/components-react/filtering/ResultSelector.js.map +1 -1
- package/lib/esm/components-react/inputs/ParsedInput.d.ts.map +1 -1
- package/lib/esm/components-react/inputs/ParsedInput.js +3 -3
- package/lib/esm/components-react/inputs/ParsedInput.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/Common.d.ts +4 -0
- package/lib/esm/components-react/properties/renderers/value/Common.d.ts.map +1 -0
- package/lib/esm/components-react/properties/renderers/value/Common.js +8 -0
- package/lib/esm/components-react/properties/renderers/value/Common.js.map +1 -0
- package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -7
- package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +2 -5
- package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -7
- package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.js +10 -2
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventHandler.d.ts +2 -0
- package/lib/esm/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventHandler.js +2 -0
- package/lib/esm/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEvents.d.ts +2 -0
- package/lib/esm/components-react/tree/controlled/TreeEvents.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEvents.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# Change Log - @itwin/components-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 01 Dec 2023 20:01:16 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.7.0
|
|
6
|
+
Fri, 01 Dec 2023 20:01:16 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Add support for double-clicking tree nodes.
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- Fix bug where multiline value renderer would not support certain properties.
|
|
15
|
+
|
|
16
|
+
### Updates
|
|
17
|
+
|
|
18
|
+
- No longer consume deprecated appui-abstract types: getObjectClassName, SpecialKey; use icon path directly instead of IconSpecUtilities
|
|
19
|
+
- Fixed `useAsyncValue` hook to work in React 18 strict mode.
|
|
4
20
|
|
|
5
21
|
## 4.6.3
|
|
6
22
|
Wed, 25 Oct 2023 09:39:22 GMT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBzE,0DAA0D;WAC5C,SAAS;IAWvB,sDAAsD;IACtD,WAAkB,WAAW,IAAI,OAAO,CAEvC;IAED;;OAEG;IACH,WAAkB,YAAY,IAAI,YAAY,CAO7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAavD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
|
|
@@ -10,8 +10,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.UiComponents = void 0;
|
|
11
11
|
const immer_1 = require("immer");
|
|
12
12
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
-
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
14
13
|
const core_react_1 = require("@itwin/core-react");
|
|
14
|
+
const core_react_2 = require("@itwin/core-react");
|
|
15
|
+
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
15
16
|
/**
|
|
16
17
|
* Manages the localization service for the components-react package.
|
|
17
18
|
* @public
|
|
@@ -74,7 +75,7 @@ class UiComponents {
|
|
|
74
75
|
}
|
|
75
76
|
/** @internal */
|
|
76
77
|
static loggerCategory(obj) {
|
|
77
|
-
const className = (0,
|
|
78
|
+
const className = (0, core_react_2.getObjectClassName)(obj);
|
|
78
79
|
const category = UiComponents.packageName + (className ? `.${className}` : "");
|
|
79
80
|
return category;
|
|
80
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAAsC;AACtC,sDAA6C;AAE7C,
|
|
1
|
+
{"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAAsC;AACtC,sDAA6C;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gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;YAC7B,qBAAM,CAAC,QAAQ,CACb,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EACjC,iFAAiF,CAClF,CAAC;YACF,OAAO,EAAE,CAAC;SACX;QACD,OAAO,YAAY,CAAC,YAAY,CAAC,kBAAkB,CAAC,GAAG,EAAE;YACvD,EAAE,EAAE,YAAY,CAAC,qBAAqB;SACvC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,QAAQ,GACZ,YAAY,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAChE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAvFc,yBAAY,GAAG,KAAK,CAAC;AADzB,oCAAY","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Common\n */\n\nimport { enablePatches } from \"immer\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\nimport { UiCore } from \"@itwin/core-react\";\nimport { getObjectClassName } from \"@itwin/core-react\";\nimport { UiError } from \"@itwin/appui-abstract\";\n\n/**\n * Manages the localization service for the components-react package.\n * @public\n */\nexport class UiComponents {\n private static _initialized = false;\n private static _localization?: Localization;\n\n /**\n * Registers the localization service namespace for UiComponents. Also initializes UiCore.\n * @param localization The internationalization service created by the host application.\n */\n public static async initialize(localization: Localization): Promise<void> {\n if (UiComponents._initialized) {\n Logger.logInfo(\n UiComponents.loggerCategory(UiComponents),\n `UiComponents.initialize already called`\n );\n return;\n }\n\n enablePatches();\n UiComponents._localization = localization;\n await UiComponents._localization.registerNamespace(\n UiComponents.localizationNamespace\n );\n\n await UiCore.initialize(UiComponents._localization);\n UiComponents._initialized = true;\n }\n\n /** Unregisters the UiComponents localization namespace */\n public static terminate() {\n if (UiComponents._localization)\n UiComponents._localization.unregisterNamespace(\n UiComponents.localizationNamespace\n );\n UiComponents._localization = undefined;\n\n UiCore.terminate();\n UiComponents._initialized = false;\n }\n\n /** Determines if UiComponents has been initialized */\n public static get initialized(): boolean {\n return UiComponents._initialized;\n }\n\n /** The internationalization service created by the host application.\n * @internal\n */\n public static get localization(): Localization {\n if (!UiComponents._localization)\n throw new UiError(\n UiComponents.loggerCategory(this),\n \"_localization: UiComponents.initialize has not been called. Unable to return Localization object.\"\n );\n return UiComponents._localization;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiComponents\";\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"components-react\";\n }\n\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiComponents\" namespace. Do NOT include the namespace in the key.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiComponents.initialized) {\n Logger.logError(\n UiComponents.loggerCategory(this),\n `translate: UiComponents.initialize has not been called. Returning blank string.`\n );\n return \"\";\n }\n return UiComponents.localization.getLocalizedString(key, {\n ns: UiComponents.localizationNamespace,\n });\n }\n\n /** @internal */\n public static loggerCategory(obj: any): string {\n const className = getObjectClassName(obj);\n const category =\n UiComponents.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ImageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EACV,KAAK,EAIN,MAAM,gBAAgB,CAAC;AAGxB;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAE1D,OAAO,CAAC,WAAW;IAenB,8BAA8B;IAC9B,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,KAAK;IAcb,OAAO,CAAC,mBAAmB;IAW3B,iCAAiC;IACjC,OAAO,CAAC,SAAS;IAejB,+BAA+B;IAC/B,OAAO,CAAC,SAAS;IAIjB,sCAAsC;IACtC,OAAO,CAAC,cAAc;IAItB,sDAAsD;IACtD,OAAO,CAAC,0BAA0B;IAIlC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAgB/B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAKzB,yDAAyD;IAClD,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,KAAK,CAAC,SAAS;CA0BnD"}
|
|
@@ -32,9 +32,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.ImageRenderer = void 0;
|
|
34
34
|
const React = __importStar(require("react"));
|
|
35
|
-
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
36
35
|
const core_react_1 = require("@itwin/core-react");
|
|
37
36
|
const UiComponents_1 = require("../UiComponents");
|
|
37
|
+
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
38
38
|
/** A class that renders images from data provided by an image loader
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
|
@@ -85,9 +85,8 @@ class ImageRenderer {
|
|
|
85
85
|
svgAsDataUri = this.convertSvgToDataUri(svg.trim());
|
|
86
86
|
ImageRenderer._svgCache.set(svg, svgAsDataUri);
|
|
87
87
|
}
|
|
88
|
-
const iconSpec = appui_abstract_1.IconSpecUtilities.createWebComponentIconSpec(svgAsDataUri);
|
|
89
88
|
return (React.createElement("div", null,
|
|
90
|
-
React.createElement(core_react_1.Icon, { iconSpec:
|
|
89
|
+
React.createElement(core_react_1.Icon, { iconSpec: svgAsDataUri })));
|
|
91
90
|
}
|
|
92
91
|
/** Render image from an url */
|
|
93
92
|
renderUrl(url) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;
|
|
1
|
+
{"version":3,"file":"ImageRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,kDAAsD;AACtD,kDAA+C;AAO/C,0DAAgD;AAEhD;;GAEG;AACH,MAAa,aAAa;IAGhB,WAAW,CAAC,SAAiB;QACnC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACxC,uBAAuB;QACvB,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QAEtB,mDAAmD;QACnD,OAAO,IAAI,CACT,KAAK;aACF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CACZ,CAAC;IACJ,CAAC;IAED,8BAA8B;IACtB,YAAY,CAAC,IAAY,EAAE,MAAuB;QACxD,2BAA2B;QAC3B,MAAM,YAAY,GAAG,IAAI,CAAC,WA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AAS,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAE5D,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC,SAAS,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAE5D,KAAK,WAAW;gBACd,OAAO,IAAI,CAAC,cAAc,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAEjE,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,iBAAiB,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAEpE;gBACE,MAAM,mBAAmB,GAAU,WAAW,CAAC,UAAU,CAAC,CAAC,gDAAgD;gBAC3G,MAAM,IAAI,wBAAO,CACf,2BAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EACjC,6BAA6B,mBAAmB,GAAG,CACpD,CAAC;SACL;IACH,CAAC;;AAvIc,uBAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;AAD/C,sCAAa","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Common\n */\n\nimport * as React from \"react\";\nimport type { WebFontIconProps } from \"@itwin/core-react\";\nimport { Icon, WebFontIcon } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport type {\n Image,\n ImageFileFormat,\n LoadedBinaryImage,\n LoadedImage,\n} from \"./IImageLoader\";\nimport { UiError } from \"@itwin/appui-abstract\";\n\n/** A class that renders images from data provided by an image loader\n * @internal\n */\nexport class ImageRenderer {\n private static _svgCache: Map<string, string> = new Map();\n\n private hexToBase64(hexstring: string) {\n const match = hexstring.match(/\\w{2}/g);\n // istanbul ignore next\n if (!match) return \"\";\n\n // eslint-disable-next-line deprecation/deprecation\n return btoa(\n match\n .map((a) => {\n return String.fromCharCode(parseInt(a, 16));\n })\n .join(\"\")\n );\n }\n\n /** Render raw binary image */\n private renderBinary(data: string, format: ImageFileFormat) {\n // Convert binary to base64\n const dataAsBase64 = this.hexToBase64(data);\n return <img src={`data:image/${format};base64,${dataAsBase64}`} alt=\"\" />;\n }\n\n private isSvg(input: string): boolean {\n const parser = new DOMParser();\n const doc = parser.parseFromString(input, \"application/xml\");\n\n const errorNode = doc.querySelector(\"parsererror\");\n // istanbul ignore if\n if (errorNode) {\n return false;\n }\n\n const rootNode = doc.documentElement.nodeName.toLowerCase();\n return \"svg\" === rootNode;\n }\n\n private convertSvgToDataUri(svg: string) {\n // istanbul ignore if\n if (!this.isSvg(svg)) {\n return \"\";\n }\n\n // eslint-disable-next-line deprecation/deprecation\n const svgAsBase64 = btoa(svg);\n return `data:image/svg+xml;base64,${svgAsBase64}`;\n }\n\n /** Render svg string into JSX */\n private renderSvg(svg: string) {\n let svgAsDataUri = ImageRenderer._svgCache.get(svg);\n // istanbul ignore else\n if (undefined === svgAsDataUri) {\n svgAsDataUri = this.convertSvgToDataUri(svg.trim());\n ImageRenderer._svgCache.set(svg, svgAsDataUri);\n }\n\n return (\n <div>\n <Icon iconSpec={svgAsDataUri} />\n </div>\n );\n }\n\n /** Render image from an url */\n private renderUrl(url: string) {\n return <img src={url} alt=\"\" />;\n }\n\n /** Render image as core-react icon */\n private renderCoreIcon(iconName: string) {\n return <WebFontIcon iconName={iconName} />;\n }\n\n /** Replaces the escaped instances of \"\\:\" with \":\" */\n private normalizeEscapedIconString(escapedIconString: string) {\n return escapedIconString.replace(/\\\\:/g, \":\");\n }\n\n /**\n * Extract class and name from icon name, if the name follows format \"{className}:{fontName}\".\n * className and fontName can be escaped using \\ if : is needed.\n */\n private extractIconClassAndName(\n iconName: string\n ): Pick<WebFontIconProps, \"iconClassName\" | \"iconName\"> {\n const matches = iconName.match(/(\\\\.|[^:])+/g);\n if (!matches || matches.length !== 2)\n return {\n iconClassName: undefined,\n iconName,\n };\n\n return {\n iconClassName: this.normalizeEscapedIconString(matches[0]),\n iconName: this.normalizeEscapedIconString(matches[1]),\n };\n }\n\n /**\n * Render image as provided webfont icon.\n * Defaults to core-react icon if iconName does not contain className.\n */\n private renderWebfontIcon(iconName: string) {\n const iconInfo = this.extractIconClassAndName(iconName);\n return <WebFontIcon {...iconInfo} />;\n }\n\n /** Render image from data provided by an image loader */\n public render(loadedImage: Image): React.ReactNode {\n switch (loadedImage.sourceType) {\n case \"binary\":\n const image = loadedImage as LoadedBinaryImage;\n return this.renderBinary(image.value, image.fileFormat);\n\n case \"url\":\n return this.renderUrl((loadedImage as LoadedImage).value);\n\n case \"svg\":\n return this.renderSvg((loadedImage as LoadedImage).value);\n\n case \"core-icon\":\n return this.renderCoreIcon((loadedImage as LoadedImage).value);\n\n case \"webfont-icon\":\n return this.renderWebfontIcon((loadedImage as LoadedImage).value);\n\n default:\n const unhandledSourceType: never = loadedImage.sourceType; // Compile time check that all cases are handled\n throw new UiError(\n UiComponents.loggerCategory(this),\n `Can't handle sourceType: \"${unhandledSourceType}\"`\n );\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseAsyncValue.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"UseAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseAsyncValue.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAqBzE"}
|
|
@@ -39,32 +39,22 @@ const core_react_1 = require("@itwin/core-react");
|
|
|
39
39
|
* @public
|
|
40
40
|
*/
|
|
41
41
|
function useAsyncValue(value) {
|
|
42
|
-
const cancelled = React.useMemo(() => new rxjs_1.Subject(), []);
|
|
43
|
-
// cancel any pending promises on unmount
|
|
44
|
-
React.useEffect(() => () => cancelled.next(), [cancelled]);
|
|
45
42
|
const [result, setResult] = React.useState(() => {
|
|
46
43
|
if ((0, core_react_1.isPromiseLike)(value)) {
|
|
47
|
-
(0, rxjs_1.from)(value)
|
|
48
|
-
.pipe((0, rxjs_1.takeUntil)(cancelled))
|
|
49
|
-
.subscribe({ next: (resolvedValue) => setResult(resolvedValue) });
|
|
50
44
|
return undefined;
|
|
51
45
|
}
|
|
52
46
|
return value;
|
|
53
47
|
});
|
|
54
|
-
|
|
55
|
-
const updateValue = (newValue) => {
|
|
56
|
-
cancelled.next();
|
|
57
|
-
setResult(newValue);
|
|
58
|
-
};
|
|
48
|
+
React.useEffect(() => {
|
|
59
49
|
if ((0, core_react_1.isPromiseLike)(value)) {
|
|
60
|
-
const subscription = (0, rxjs_1.from)(value)
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
const subscription = (0, rxjs_1.from)(value).subscribe({
|
|
51
|
+
next: (resolvedValue) => setResult(resolvedValue),
|
|
52
|
+
});
|
|
63
53
|
return () => subscription.unsubscribe();
|
|
64
54
|
}
|
|
65
|
-
|
|
66
|
-
return
|
|
67
|
-
}, [value
|
|
55
|
+
setResult(value);
|
|
56
|
+
return;
|
|
57
|
+
}, [value]);
|
|
68
58
|
return result;
|
|
69
59
|
}
|
|
70
60
|
exports.useAsyncValue = useAsyncValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseAsyncValue.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,+
|
|
1
|
+
{"version":3,"file":"UseAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseAsyncValue.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,+BAA4B;AAC5B,kDAAkD;AAElD;;;GAGG;AACH,SAAgB,aAAa,CAAI,KAAyB;IACxD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;QAC9C,IAAI,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE;YACxB,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE;YACxB,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,KAAK,CAAC,CAAC,SAAS,CAAC;gBACzC,IAAI,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC;aAClD,CAAC,CAAC;YACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;SACzC;QAED,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO;IACT,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,MAAM,CAAC;AAChB,CAAC;AArBD,sCAqBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Common\n */\n\nimport * as React from \"react\";\nimport { from } from \"rxjs\";\nimport { isPromiseLike } from \"@itwin/core-react\";\n\n/**\n * Custom hook for working with possibly async values.\n * @public\n */\nexport function useAsyncValue<T>(value: T | PromiseLike<T>): T | undefined {\n const [result, setResult] = React.useState(() => {\n if (isPromiseLike(value)) {\n return undefined;\n }\n return value;\n });\n\n React.useEffect(() => {\n if (isPromiseLike(value)) {\n const subscription = from(value).subscribe({\n next: (resolvedValue) => setResult(resolvedValue),\n });\n return () => subscription.unsubscribe();\n }\n\n setResult(value);\n return;\n }, [value]);\n\n return result;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseContextWithMandatoryProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UseContextWithMandatoryProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,gBAAgB;AAChB,wBAAgB,kCAAkC,CAAC,CAAC,EAClD,WAAW,EAAE,MAAM,GAClB;IACD,KAAK,CAAC,uBAAuB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACrD,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;CAC5C,CAkBA"}
|
|
@@ -9,6 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.createContextWithMandatoryProvider = void 0;
|
|
11
11
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
12
|
+
const core_react_1 = require("@itwin/core-react");
|
|
12
13
|
const UiComponents_1 = require("../UiComponents");
|
|
13
14
|
const react_1 = __importDefault(require("react"));
|
|
14
15
|
/** @internal */
|
|
@@ -18,7 +19,7 @@ function createContextWithMandatoryProvider(contextName) {
|
|
|
18
19
|
const value = react_1.default.useContext(context);
|
|
19
20
|
/* istanbul ignore if */
|
|
20
21
|
if (value === undefined) {
|
|
21
|
-
throw new appui_abstract_1.UiError(UiComponents_1.UiComponents.loggerCategory(ConsumingComponent), `'${(0,
|
|
22
|
+
throw new appui_abstract_1.UiError(UiComponents_1.UiComponents.loggerCategory(ConsumingComponent), `'${(0, core_react_1.getObjectClassName)(ConsumingComponent)}' expects to be wrapped by a '${contextName}' provider.`);
|
|
22
23
|
}
|
|
23
24
|
return value;
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseContextWithMandatoryProvider.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;AAEhG,
|
|
1
|
+
{"version":3,"file":"UseContextWithMandatoryProvider.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;AAEhG,0DAAgD;AAChD,kDAAuD;AACvD,kDAA+C;AAC/C,kDAA0B;AAE1B,gBAAgB;AAChB,SAAgB,kCAAkC,CAChD,WAAmB;IAMnB,MAAM,OAAO,GAAG,eAAK,CAAC,aAAa,CAAI,SAAqB,CAAC,CAAC;IAC9D,SAAS,6BAA6B,CACpC,kBAA0C;QAE1C,MAAM,KAAK,GAAG,eAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,wBAAwB;QACxB,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,MAAM,IAAI,wBAAO,CACf,2BAAY,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAC/C,IAAI,IAAA,+BAAkB,EACpB,kBAAkB,CACnB,iCAAiC,WAAW,aAAa,CAC3D,CAAC;SACH;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC;AAC7E,CAAC;AAxBD,gFAwBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { UiError } from \"@itwin/appui-abstract\";\nimport { getObjectClassName } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport React from \"react\";\n\n/** @internal */\nexport function createContextWithMandatoryProvider<T>(\n contextName: string\n): [\n React.ProviderExoticComponent<React.ProviderProps<T>>,\n React.ExoticComponent<React.ConsumerProps<T>>,\n <P>(component: React.ComponentType<P>) => T\n] {\n const context = React.createContext<T>(undefined as any as T);\n function useContextWithoutDefaultValue<P>(\n ConsumingComponent: React.ComponentType<P>\n ) {\n const value = React.useContext(context);\n /* istanbul ignore if */\n if (value === undefined) {\n throw new UiError(\n UiComponents.loggerCategory(ConsumingComponent),\n `'${getObjectClassName(\n ConsumingComponent\n )}' expects to be wrapped by a '${contextName}' provider.`\n );\n }\n return value;\n }\n return [context.Provider, context.Consumer, useContextWithoutDefaultValue];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseDebouncedAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAIA;;GAEG;AASH;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAC5C,iBAAiB,EAAE,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;
|
|
1
|
+
{"version":3,"file":"UseDebouncedAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAIA;;GAEG;AASH;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAC5C,iBAAiB,EAAE,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;EAuDxD"}
|
|
@@ -21,20 +21,20 @@ const SubscriptionScheduler_1 = require("./SubscriptionScheduler");
|
|
|
21
21
|
* @beta
|
|
22
22
|
*/
|
|
23
23
|
function useDebouncedAsyncValue(valueToBeResolved) {
|
|
24
|
-
const scheduler = (0, react_1.
|
|
25
|
-
const [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
error: undefined,
|
|
29
|
-
hasError: false,
|
|
24
|
+
const [scheduler] = (0, react_1.useState)(() => new SubscriptionScheduler_1.SubscriptionScheduler());
|
|
25
|
+
const [{ result, inProgress }, setState] = (0, react_1.useState)({
|
|
26
|
+
result: undefined,
|
|
27
|
+
inProgress: false,
|
|
30
28
|
});
|
|
31
29
|
(0, react_1.useEffect)(() => {
|
|
32
30
|
if (!valueToBeResolved) {
|
|
33
|
-
|
|
34
|
-
setInProgress(false);
|
|
31
|
+
setState((prev) => ({ ...prev, result: undefined, inProgress: false }));
|
|
35
32
|
return;
|
|
36
33
|
}
|
|
37
|
-
|
|
34
|
+
setState((prev) => ({
|
|
35
|
+
...prev,
|
|
36
|
+
inProgress: true,
|
|
37
|
+
}));
|
|
38
38
|
// schedule and subscribe to the observable emitting value from valueToBeResolved promise
|
|
39
39
|
const subscription = (0, rxjs_1.defer)(valueToBeResolved)
|
|
40
40
|
.pipe((0, rxjs_1.share)({
|
|
@@ -44,21 +44,27 @@ function useDebouncedAsyncValue(valueToBeResolved) {
|
|
|
44
44
|
}), (0, SubscriptionScheduler_1.scheduleSubscription)(scheduler))
|
|
45
45
|
.subscribe({
|
|
46
46
|
next: (data) => {
|
|
47
|
-
|
|
48
|
-
setInProgress(false);
|
|
47
|
+
setState((prev) => ({ ...prev, result: data, inProgress: false }));
|
|
49
48
|
},
|
|
50
49
|
error: (err) => {
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
setState((prev) => ({
|
|
51
|
+
...prev,
|
|
52
|
+
result: { error: err, hasError: true },
|
|
53
|
+
inProgress: false,
|
|
54
|
+
}));
|
|
53
55
|
},
|
|
54
56
|
});
|
|
55
57
|
return () => {
|
|
56
58
|
subscription.unsubscribe();
|
|
57
59
|
};
|
|
58
60
|
}, [valueToBeResolved, scheduler]);
|
|
59
|
-
if (
|
|
60
|
-
throw
|
|
61
|
-
|
|
61
|
+
if (isErrorResult(result)) {
|
|
62
|
+
throw result.error ?? new Error("Exception in `useDebouncedAsyncValue`");
|
|
63
|
+
}
|
|
64
|
+
return { value: result, inProgress };
|
|
62
65
|
}
|
|
63
66
|
exports.useDebouncedAsyncValue = useDebouncedAsyncValue;
|
|
67
|
+
function isErrorResult(obj) {
|
|
68
|
+
return obj !== undefined && obj.hasError;
|
|
69
|
+
}
|
|
64
70
|
//# sourceMappingURL=UseDebouncedAsyncValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAA4C;AAC5C,+BAAoC;AACpC,mEAGiC;AAEjC;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,iBAAuD;IAEvD,MAAM,CAAC,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,IAAI,6CAAqB,EAAW,CAAC,CAAC;IAEzE,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAGhD;QACD,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,iBAAiB,EAAE;YACtB,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YACxE,OAAO;SACR;QA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O,GAAG,KAAK,SAAS,IAAK,GAAmB,CAAC,QAAQ,CAAC;AAC5D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Common\n */\n\nimport { useEffect, useState } from \"react\";\nimport { defer, share } from \"rxjs\";\nimport {\n scheduleSubscription,\n SubscriptionScheduler,\n} from \"./SubscriptionScheduler\";\n\n/**\n * Custom hook for working with promise values.\n * Promises are debounced using trailing and leading edge.\n * The first promise will always be executed.\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\n * Once the first promise finishes resolving, the last passed promise starts resolving.\n * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\n * @beta\n */\nexport function useDebouncedAsyncValue<TReturn>(\n valueToBeResolved: undefined | (() => Promise<TReturn>)\n) {\n const [scheduler] = useState(() => new SubscriptionScheduler<TReturn>());\n\n const [{ result, inProgress }, setState] = useState<{\n result: TReturn | ErrorResult | undefined;\n inProgress: boolean;\n }>({\n result: undefined,\n inProgress: false,\n });\n\n useEffect(() => {\n if (!valueToBeResolved) {\n setState((prev) => ({ ...prev, result: undefined, inProgress: false }));\n return;\n }\n\n setState((prev) => ({\n ...prev,\n inProgress: true,\n }));\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\n const subscription = defer(valueToBeResolved)\n .pipe(\n share({\n resetOnError: false,\n resetOnComplete: false,\n resetOnRefCountZero: true,\n }),\n scheduleSubscription(scheduler)\n )\n .subscribe({\n next: (data) => {\n setState((prev) => ({ ...prev, result: data, inProgress: false }));\n },\n error: (err) => {\n setState((prev) => ({\n ...prev,\n result: { error: err, hasError: true },\n inProgress: false,\n }));\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [valueToBeResolved, scheduler]);\n\n if (isErrorResult(result)) {\n throw result.error ?? new Error(\"Exception in `useDebouncedAsyncValue`\");\n }\n\n return { value: result, inProgress };\n}\n\ninterface ErrorResult {\n error: Error | undefined;\n hasError: boolean;\n}\n\nfunction isErrorResult<TResult>(\n obj?: TResult | ErrorResult\n): obj is ErrorResult {\n return obj !== undefined && (obj as ErrorResult).hasError;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.tsx"],"names":[],"mappings":"AAIA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAQH,OAAO,mBAAmB,CAAC;AAY3B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,QAAQ,EAAE,IAAI,CAAC;IACf,qDAAqD;IACrD,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA4ThD"}
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.DatePicker = void 0;
|
|
37
37
|
const React = __importStar(require("react"));
|
|
38
38
|
const classnames_1 = __importDefault(require("classnames"));
|
|
39
|
-
const
|
|
39
|
+
const ts_key_enum_1 = require("ts-key-enum");
|
|
40
40
|
const UiComponents_1 = require("../UiComponents");
|
|
41
41
|
const core_react_1 = require("@itwin/core-react");
|
|
42
42
|
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
@@ -148,7 +148,7 @@ function DatePicker(props) {
|
|
|
148
148
|
props.onDateChange && props.onDateChange(day);
|
|
149
149
|
}, [props]);
|
|
150
150
|
const handleCalendarKeyDown = React.useCallback((event) => {
|
|
151
|
-
if (event.key ===
|
|
151
|
+
if (event.key === ts_key_enum_1.Key.ArrowDown) {
|
|
152
152
|
const focusedDayIndex = days.findIndex((day) => isSameDay(day, focusedDay));
|
|
153
153
|
if (focusedDayIndex + 7 > 41)
|
|
154
154
|
setFocusedDay(days[focusedDayIndex % 7]);
|
|
@@ -156,7 +156,7 @@ function DatePicker(props) {
|
|
|
156
156
|
setFocusedDay(days[focusedDayIndex + 7]);
|
|
157
157
|
event.preventDefault();
|
|
158
158
|
}
|
|
159
|
-
if (event.key ===
|
|
159
|
+
if (event.key === ts_key_enum_1.Key.ArrowUp) {
|
|
160
160
|
const focusedDayIndex = days.findIndex((day) => isSameDay(day, focusedDay));
|
|
161
161
|
if (focusedDayIndex - 7 < 0)
|
|
162
162
|
setFocusedDay(days[(focusedDayIndex % 7) + 35]);
|
|
@@ -164,21 +164,21 @@ function DatePicker(props) {
|
|
|
164
164
|
setFocusedDay(days[focusedDayIndex - 7]);
|
|
165
165
|
event.preventDefault();
|
|
166
166
|
}
|
|
167
|
-
if (event.key ===
|
|
167
|
+
if (event.key === ts_key_enum_1.Key.ArrowLeft) {
|
|
168
168
|
const focusedDayIndex = days.findIndex((day) => isSameDay(day, focusedDay));
|
|
169
169
|
// istanbul ignore else
|
|
170
170
|
if (focusedDayIndex - 1 >= 0)
|
|
171
171
|
setFocusedDay(days[focusedDayIndex - 1]);
|
|
172
172
|
event.preventDefault();
|
|
173
173
|
}
|
|
174
|
-
if (event.key ===
|
|
174
|
+
if (event.key === ts_key_enum_1.Key.ArrowRight) {
|
|
175
175
|
const focusedDayIndex = days.findIndex((day) => isSameDay(day, focusedDay));
|
|
176
176
|
// istanbul ignore else
|
|
177
177
|
if (focusedDayIndex + 1 <= 41)
|
|
178
178
|
setFocusedDay(days[focusedDayIndex + 1]);
|
|
179
179
|
event.preventDefault();
|
|
180
180
|
}
|
|
181
|
-
if (event.key ===
|
|
181
|
+
if (event.key === ts_key_enum_1.Key.Enter || event.key === " ") {
|
|
182
182
|
handleOnDayChange(focusedDay)(); // NB: immediately call returned handler function
|
|
183
183
|
event.preventDefault();
|
|
184
184
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,4DAAoC;AACpC,0DAAmD;AACnD,kDAA+C;AAC/C,kDAAyC;AACzC,oEAA6E;AAE7E,6BAA2B;AAE3B,SAAS,SAAS,CAAC,CAAO,EAAE,CAAO;IACjC,OAAO,CACL,CAAC;QACD,CAAC;QACD,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE;QACnC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE;QAC7B,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAC5B,CAAC;AACJ,CAAC;AAeD;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAsB;IAC/C,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CACrC,2BAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,uCAAuC,CACxC,CACF,CAAC;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CACjC,2BAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,mCAAmC,CACpC,CACF,CAAC;IACF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;QAC9B,2BAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,iCAAiC,CAClC;QACD,2BAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,kCAAkC,CACnC;QACD,2BAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,+BAA+B,CAChC;QACD,2BAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,+BAA+B,CAChC;QACD,2BAAY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,EAAE,QAAQ,SAAS,EAAE,IACrC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAS,EAAE,QAAgB,EAAE,EAAE;YAC5C,MAAM,QAAQ,GACZ,WAAW,IAAI,GAAG,IAAI,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;YACpD,MAAM,SAAS,GACb,UAAU;gBACV,GAAG;gBACH,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC;gBAC1B,KAAK,CAAC,gBAAgB,CAAC;YACzB,MAAM,cAAc,GAAG,GAAG,CAAC,QAAQ,EAAE,KAAK,mBAAmB,CAAC;YAC9D,MAAM,UAAU,GAAG,IAAA,oBAAU,EAC3B,qCAAqC,EACrC,QAAQ,IAAI,UAAU,EACtB,CAAC,cAAc,IAAI,iBAAiB,EACpC,SAAS,IAAI,SAAS,CACvB,CAAC;YACF,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;YAChC,OAAO;YACL,oEAAoE;YACpE,4BACE,SAAS,EAAE,UAAU,EACrB,GAAG,EAAE,GAAG,aAAa,IAAI,mBAAmB,QAAQ,QAAQ,EAAE,EAC9D,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC/B,IAAI,EAAC,QAAQ,mBACE,QAAQ,gBACX,GAAG,CAAC,OAAO,EAAE;gBAEzB,kCAAO,SAAS,CAAQ,CACrB,CACN,CAAC;QACJ,CAAC,CAAC,CACa,CAClB,CAAC,CACC,CACD,CACP,CAAC;AACJ,CAAC;AA5TD,gCA4TC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Date\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\nimport { UiComponents } from \"../UiComponents\";\nimport { Icon } from \"@itwin/core-react\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\n\nimport \"./DatePicker.scss\";\n\nfunction isSameDay(a: Date, b: Date) {\n return (\n a &&\n b &&\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n );\n}\n\n/**\n * Props for [[DatePicker]] component.\n * @alpha\n */\nexport interface DatePickerProps {\n /** defines both date and time */\n selected: Date;\n /** function to call when date or time has changed */\n onDateChange?: (day: Date) => void;\n /** show focus outlines, useful for keyboard navigation */\n showFocusOutline?: boolean;\n}\n\n/** DatePicker component. Show a month selector and a day calendar to select a specific date.\n * @alpha\n */\nexport function DatePicker(props: DatePickerProps) {\n const previousMonthLabel = React.useRef(\n UiComponents.localization.getLocalizedString(\n \"UiComponents:datepicker.previousMonth\"\n )\n );\n const nextMonthLabel = React.useRef(\n UiComponents.localization.getLocalizedString(\n \"UiComponents:datepicker.nextMonth\"\n )\n );\n const monthsLong = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.january\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.february\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.march\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.april\"\n ),\n UiComponents.localization.getLocalizedString(\"UiComponents:month.long.may\"),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.june\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.july\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.august\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.september\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.october\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.november\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.december\"\n ),\n ]);\n\n const daysLong = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.sunday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.monday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.tuesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.wednesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.thursday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.friday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.saturday\"\n ),\n ]);\n\n const daysShort = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.sunday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.monday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.tuesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.wednesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.thursday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.friday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.saturday\"\n ),\n ]);\n\n const [selectedDay, setSelectedDay] = React.useState(\n new Date(props.selected.getTime())\n );\n const [displayedMonthIndex, setDisplayedMonthIndex] = React.useState(\n selectedDay.getMonth()\n );\n const [displayedYear, setDisplayedYear] = React.useState(\n selectedDay.getFullYear()\n );\n const [focusedDay, setFocusedDay] = React.useState(selectedDay);\n React.useEffect(() => {\n const newSelectedDay = new Date(props.selected);\n setSelectedDay(new Date(props.selected));\n setDisplayedMonthIndex(newSelectedDay.getMonth());\n setDisplayedYear(newSelectedDay.getFullYear());\n setFocusedDay(newSelectedDay);\n }, [props.selected]);\n const days = React.useMemo(() => {\n const msFirstDayOfMonth = new Date(\n displayedYear,\n displayedMonthIndex,\n 1\n ).getTime();\n let offsetToFirst = new Date(msFirstDayOfMonth).getDay();\n if (0 === offsetToFirst) offsetToFirst = 7;\n\n const daysInMonth: Date[] = [];\n // generate 6 weeks of dates\n for (let i = 0; i < 42; i++) {\n const adjustedDay = 1 + i - offsetToFirst;\n daysInMonth.push(\n new Date(displayedYear, displayedMonthIndex, adjustedDay)\n );\n }\n return daysInMonth;\n }, [displayedMonthIndex, displayedYear]);\n\n const weeks = React.useMemo(() => {\n const weeksInMonth = [];\n const weekCount = Math.ceil(days.length / 7);\n for (let i = 0; i < weekCount; i++) {\n weeksInMonth.push(days.slice(i * 7, (i + 1) * 7));\n }\n return weeksInMonth;\n }, [days]);\n\n const setMonthAndYear = React.useCallback(\n (newMonth: number, newYear: number) => {\n setDisplayedMonthIndex(newMonth);\n setDisplayedYear(newYear);\n if (\n selectedDay.getFullYear() === newYear &&\n selectedDay.getMonth() === newMonth\n ) {\n setFocusedDay(new Date(selectedDay.getTime()));\n } else {\n const newFocusDay = new Date(focusedDay.getTime());\n newFocusDay.setFullYear(newYear, newMonth, 1);\n setFocusedDay(newFocusDay);\n }\n },\n [focusedDay, selectedDay]\n );\n\n const handleMoveToPreviousMonth = React.useCallback(() => {\n const newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;\n const newYear =\n displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;\n setMonthAndYear(newMonth, newYear);\n }, [displayedMonthIndex, displayedYear, setMonthAndYear]);\n\n const handleMoveToNextMonth = React.useCallback(() => {\n const newMonth = displayedMonthIndex !== 11 ? displayedMonthIndex + 1 : 0;\n const newYear =\n displayedMonthIndex !== 11 ? displayedYear : displayedYear + 1;\n setMonthAndYear(newMonth, newYear);\n }, [displayedMonthIndex, displayedYear, setMonthAndYear]);\n\n // when invoked, it will return another function which can be used for the onClick React listener.\n const handleOnDayChange = React.useCallback(\n (day: Date) => () => {\n setSelectedDay(day);\n setFocusedDay(day);\n props.onDateChange && props.onDateChange(day);\n },\n [props]\n );\n\n const handleCalendarKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (event.key === SpecialKey.ArrowDown) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n if (focusedDayIndex + 7 > 41) setFocusedDay(days[focusedDayIndex % 7]);\n else setFocusedDay(days[focusedDayIndex + 7]);\n event.preventDefault();\n }\n if (event.key === SpecialKey.ArrowUp) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n if (focusedDayIndex - 7 < 0)\n setFocusedDay(days[(focusedDayIndex % 7) + 35]);\n else setFocusedDay(days[focusedDayIndex - 7]);\n event.preventDefault();\n }\n if (event.key === SpecialKey.ArrowLeft) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n // istanbul ignore else\n if (focusedDayIndex - 1 >= 0) setFocusedDay(days[focusedDayIndex - 1]);\n event.preventDefault();\n }\n if (event.key === SpecialKey.ArrowRight) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n // istanbul ignore else\n if (focusedDayIndex + 1 <= 41) setFocusedDay(days[focusedDayIndex + 1]);\n event.preventDefault();\n }\n if (event.key === SpecialKey.Enter || event.key === SpecialKey.Space) {\n handleOnDayChange(focusedDay)(); // NB: immediately call returned handler function\n event.preventDefault();\n }\n },\n [days, focusedDay, handleOnDayChange]\n );\n\n const previousButtonClass = classnames(\n \"components-previous-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n const nextButtonClass = classnames(\n \"components-next-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n const calendarClass = classnames(\n \"components-date-picker-calendar-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n\n return (\n <div className=\"components-date-picker-calendar\">\n <div className=\"components-date-picker-calendar-header-months\">\n <button\n className={previousButtonClass}\n title={previousMonthLabel.current}\n onClick={handleMoveToPreviousMonth}\n >\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n <span className=\"components-month-year\">\n {monthsLong.current[displayedMonthIndex]} {displayedYear}\n </span>\n <button\n className={nextButtonClass}\n title={nextMonthLabel.current}\n onClick={handleMoveToNextMonth}\n >\n <Icon iconSpec={<SvgChevronRight />} />\n </button>\n </div>\n <div className=\"components-date-picker-calendar-header-weekdays\">\n {[0, 1, 2, 3, 4, 5, 6].map((dayOfWeek) => (\n <div\n key={`day-${dayOfWeek}`}\n className=\"components-date-picker-calendar-header-day-short\"\n title={daysLong.current[dayOfWeek]}\n >\n <span>{daysShort.current[dayOfWeek]}</span>\n </div>\n ))}\n </div>\n <ul\n tabIndex={0}\n onKeyDown={handleCalendarKeyDown}\n data-testid=\"components-date-picker-calendar-list\"\n className={calendarClass}\n role=\"listbox\"\n >\n {weeks.map((weekdays, weekIndex) => (\n <React.Fragment key={`week-${weekIndex}`}>\n {weekdays.map((day: Date, dayIndex: number) => {\n const isActive =\n selectedDay && day && isSameDay(selectedDay, day);\n const isFocused =\n focusedDay &&\n day &&\n isSameDay(focusedDay, day) &&\n props.showFocusOutline;\n const isCurrentMonth = day.getMonth() === displayedMonthIndex;\n const classNames = classnames(\n \"components-date-picker-calendar-day\",\n isActive && \"selected\",\n !isCurrentMonth && \"notCurrentMonth\",\n isFocused && \"focused\"\n );\n const dateValue = day.getDate();\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */\n <li\n className={classNames}\n key={`${displayedYear}.${displayedMonthIndex}.day.${dayIndex}`}\n onClick={handleOnDayChange(day)}\n role=\"option\"\n aria-selected={isActive}\n data-value={day.getTime()}\n >\n <span>{dateValue}</span>\n </li>\n );\n })}\n </React.Fragment>\n ))}\n </ul>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,4DAAoC;AACpC,6CAAkC;AAClC,kDAA+C;AAC/C,kDAAyC;AACzC,oEAA6E;AAC7E,6BAA2B;AAE3B,SAAS,SAAS,CAAC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A,oBAAU,EAC3B,qCAAqC,EACrC,QAAQ,IAAI,UAAU,EACtB,CAAC,cAAc,IAAI,iBAAiB,EACpC,SAAS,IAAI,SAAS,CACvB,CAAC;YACF,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;YAChC,OAAO;YACL,oEAAoE;YACpE,4BACE,SAAS,EAAE,UAAU,EACrB,GAAG,EAAE,GAAG,aAAa,IAAI,mBAAmB,QAAQ,QAAQ,EAAE,EAC9D,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC/B,IAAI,EAAC,QAAQ,mBACE,QAAQ,gBACX,GAAG,CAAC,OAAO,EAAE;gBAEzB,kCAAO,SAAS,CAAQ,CACrB,CACN,CAAC;QACJ,CAAC,CAAC,CACa,CAClB,CAAC,CACC,CACD,CACP,CAAC;AACJ,CAAC;AA5TD,gCA4TC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Date\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { Key } from \"ts-key-enum\";\nimport { UiComponents } from \"../UiComponents\";\nimport { Icon } from \"@itwin/core-react\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\nimport \"./DatePicker.scss\";\n\nfunction isSameDay(a: Date, b: Date) {\n return (\n a &&\n b &&\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n );\n}\n\n/**\n * Props for [[DatePicker]] component.\n * @alpha\n */\nexport interface DatePickerProps {\n /** defines both date and time */\n selected: Date;\n /** function to call when date or time has changed */\n onDateChange?: (day: Date) => void;\n /** show focus outlines, useful for keyboard navigation */\n showFocusOutline?: boolean;\n}\n\n/** DatePicker component. Show a month selector and a day calendar to select a specific date.\n * @alpha\n */\nexport function DatePicker(props: DatePickerProps) {\n const previousMonthLabel = React.useRef(\n UiComponents.localization.getLocalizedString(\n \"UiComponents:datepicker.previousMonth\"\n )\n );\n const nextMonthLabel = React.useRef(\n UiComponents.localization.getLocalizedString(\n \"UiComponents:datepicker.nextMonth\"\n )\n );\n const monthsLong = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.january\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.february\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.march\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.april\"\n ),\n UiComponents.localization.getLocalizedString(\"UiComponents:month.long.may\"),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.june\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.july\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.august\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.september\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.october\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.november\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.december\"\n ),\n ]);\n\n const daysLong = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.sunday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.monday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.tuesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.wednesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.thursday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.friday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.saturday\"\n ),\n ]);\n\n const daysShort = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.sunday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.monday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.tuesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.wednesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.thursday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.friday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.saturday\"\n ),\n ]);\n\n const [selectedDay, setSelectedDay] = React.useState(\n new Date(props.selected.getTime())\n );\n const [displayedMonthIndex, setDisplayedMonthIndex] = React.useState(\n selectedDay.getMonth()\n );\n const [displayedYear, setDisplayedYear] = React.useState(\n selectedDay.getFullYear()\n );\n const [focusedDay, setFocusedDay] = React.useState(selectedDay);\n React.useEffect(() => {\n const newSelectedDay = new Date(props.selected);\n setSelectedDay(new Date(props.selected));\n setDisplayedMonthIndex(newSelectedDay.getMonth());\n setDisplayedYear(newSelectedDay.getFullYear());\n setFocusedDay(newSelectedDay);\n }, [props.selected]);\n const days = React.useMemo(() => {\n const msFirstDayOfMonth = new Date(\n displayedYear,\n displayedMonthIndex,\n 1\n ).getTime();\n let offsetToFirst = new Date(msFirstDayOfMonth).getDay();\n if (0 === offsetToFirst) offsetToFirst = 7;\n\n const daysInMonth: Date[] = [];\n // generate 6 weeks of dates\n for (let i = 0; i < 42; i++) {\n const adjustedDay = 1 + i - offsetToFirst;\n daysInMonth.push(\n new Date(displayedYear, displayedMonthIndex, adjustedDay)\n );\n }\n return daysInMonth;\n }, [displayedMonthIndex, displayedYear]);\n\n const weeks = React.useMemo(() => {\n const weeksInMonth = [];\n const weekCount = Math.ceil(days.length / 7);\n for (let i = 0; i < weekCount; i++) {\n weeksInMonth.push(days.slice(i * 7, (i + 1) * 7));\n }\n return weeksInMonth;\n }, [days]);\n\n const setMonthAndYear = React.useCallback(\n (newMonth: number, newYear: number) => {\n setDisplayedMonthIndex(newMonth);\n setDisplayedYear(newYear);\n if (\n selectedDay.getFullYear() === newYear &&\n selectedDay.getMonth() === newMonth\n ) {\n setFocusedDay(new Date(selectedDay.getTime()));\n } else {\n const newFocusDay = new Date(focusedDay.getTime());\n newFocusDay.setFullYear(newYear, newMonth, 1);\n setFocusedDay(newFocusDay);\n }\n },\n [focusedDay, selectedDay]\n );\n\n const handleMoveToPreviousMonth = React.useCallback(() => {\n const newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;\n const newYear =\n displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;\n setMonthAndYear(newMonth, newYear);\n }, [displayedMonthIndex, displayedYear, setMonthAndYear]);\n\n const handleMoveToNextMonth = React.useCallback(() => {\n const newMonth = displayedMonthIndex !== 11 ? displayedMonthIndex + 1 : 0;\n const newYear =\n displayedMonthIndex !== 11 ? displayedYear : displayedYear + 1;\n setMonthAndYear(newMonth, newYear);\n }, [displayedMonthIndex, displayedYear, setMonthAndYear]);\n\n // when invoked, it will return another function which can be used for the onClick React listener.\n const handleOnDayChange = React.useCallback(\n (day: Date) => () => {\n setSelectedDay(day);\n setFocusedDay(day);\n props.onDateChange && props.onDateChange(day);\n },\n [props]\n );\n\n const handleCalendarKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (event.key === Key.ArrowDown) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n if (focusedDayIndex + 7 > 41) setFocusedDay(days[focusedDayIndex % 7]);\n else setFocusedDay(days[focusedDayIndex + 7]);\n event.preventDefault();\n }\n if (event.key === Key.ArrowUp) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n if (focusedDayIndex - 7 < 0)\n setFocusedDay(days[(focusedDayIndex % 7) + 35]);\n else setFocusedDay(days[focusedDayIndex - 7]);\n event.preventDefault();\n }\n if (event.key === Key.ArrowLeft) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n // istanbul ignore else\n if (focusedDayIndex - 1 >= 0) setFocusedDay(days[focusedDayIndex - 1]);\n event.preventDefault();\n }\n if (event.key === Key.ArrowRight) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n // istanbul ignore else\n if (focusedDayIndex + 1 <= 41) setFocusedDay(days[focusedDayIndex + 1]);\n event.preventDefault();\n }\n if (event.key === Key.Enter || event.key === \" \") {\n handleOnDayChange(focusedDay)(); // NB: immediately call returned handler function\n event.preventDefault();\n }\n },\n [days, focusedDay, handleOnDayChange]\n );\n\n const previousButtonClass = classnames(\n \"components-previous-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n const nextButtonClass = classnames(\n \"components-next-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n const calendarClass = classnames(\n \"components-date-picker-calendar-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n\n return (\n <div className=\"components-date-picker-calendar\">\n <div className=\"components-date-picker-calendar-header-months\">\n <button\n className={previousButtonClass}\n title={previousMonthLabel.current}\n onClick={handleMoveToPreviousMonth}\n >\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n <span className=\"components-month-year\">\n {monthsLong.current[displayedMonthIndex]} {displayedYear}\n </span>\n <button\n className={nextButtonClass}\n title={nextMonthLabel.current}\n onClick={handleMoveToNextMonth}\n >\n <Icon iconSpec={<SvgChevronRight />} />\n </button>\n </div>\n <div className=\"components-date-picker-calendar-header-weekdays\">\n {[0, 1, 2, 3, 4, 5, 6].map((dayOfWeek) => (\n <div\n key={`day-${dayOfWeek}`}\n className=\"components-date-picker-calendar-header-day-short\"\n title={daysLong.current[dayOfWeek]}\n >\n <span>{daysShort.current[dayOfWeek]}</span>\n </div>\n ))}\n </div>\n <ul\n tabIndex={0}\n onKeyDown={handleCalendarKeyDown}\n data-testid=\"components-date-picker-calendar-list\"\n className={calendarClass}\n role=\"listbox\"\n >\n {weeks.map((weekdays, weekIndex) => (\n <React.Fragment key={`week-${weekIndex}`}>\n {weekdays.map((day: Date, dayIndex: number) => {\n const isActive =\n selectedDay && day && isSameDay(selectedDay, day);\n const isFocused =\n focusedDay &&\n day &&\n isSameDay(focusedDay, day) &&\n props.showFocusOutline;\n const isCurrentMonth = day.getMonth() === displayedMonthIndex;\n const classNames = classnames(\n \"components-date-picker-calendar-day\",\n isActive && \"selected\",\n !isCurrentMonth && \"notCurrentMonth\",\n isFocused && \"focused\"\n );\n const dateValue = day.getDate();\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */\n <li\n className={classNames}\n key={`${displayedYear}.${displayedMonthIndex}.day.${dayIndex}`}\n onClick={handleOnDayChange(day)}\n role=\"option\"\n aria-selected={isActive}\n data-value={day.getTime()}\n >\n <span>{dateValue}</span>\n </li>\n );\n })}\n </React.Fragment>\n ))}\n </ul>\n </div>\n );\n}\n"]}
|
|
@@ -80,7 +80,7 @@ function DatePickerPopupButton({ displayEditField, timeDisplay, selected, onDate
|
|
|
80
80
|
const [showFocusOutline, setShowFocusOutline] = React.useState(false);
|
|
81
81
|
const handlePopupKeyDown = React.useCallback((event) => {
|
|
82
82
|
// istanbul ignore else
|
|
83
|
-
if (event.key ===
|
|
83
|
+
if (event.key === " ") {
|
|
84
84
|
setShowFocusOutline(true);
|
|
85
85
|
setIsSettingsOpen(true);
|
|
86
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerPopupButton.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePickerPopupButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,0DAAqE;AAErE,kDAA0C;AAC1C,wDAA4C;AAC5C,kDAA+C;AAC/C,6CAA0C;AAC1C,2CAAwC;AAExC,2CAAwC;AACxC,wCAAsC;AAwBtC;;KAEK;AACL,SAAgB,qBAAqB,CAAC,EACpC,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,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AAK,EAAE,UAAU,EACjB,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,mBAAmB,GACjC,CACH,CACA,CACJ,CAAC;AACJ,CAAC;AA9ID,sDA8IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Date\n */\n\nimport * as React from \"react\";\nimport type { DateFormatter, TimeDisplay } from \"@itwin/appui-abstract\";\nimport { RelativePosition, SpecialKey } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Popup } from \"@itwin/core-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport { DatePicker } from \"./DatePicker\";\nimport { DateField } from \"./DateField\";\nimport type { TimeSpec } from \"./TimeField\";\nimport { TimeField } from \"./TimeField\";\nimport \"./DatePickerPopupButton.scss\";\n\n/** Props used by [[DatePickerPopupButton]] component.\n * @alpha */\nexport interface DatePickerPopupButtonProps extends CommonProps {\n /** Date to be shown as the selected date. */\n selected: Date;\n /** If true show the date (and optionally time) edit field next to button */\n displayEditField?: boolean;\n // If defined show time in popup and also display time if input field is shown\n timeDisplay?: TimeDisplay;\n /** Function called when Date changes. */\n onDateChange?: (day: Date) => void;\n /** Optional tooltip */\n buttonToolTip?: string;\n /* Custom date formatter. WARNING: if used values will only be shown in specified format and will not be based on locale.\n * If used the existence of a parseDate function will determine if the edit field allows editing. */\n dateFormatter?: DateFormatter;\n /** User defined class name for edit field. */\n fieldClassName?: string;\n /** User defined style for edit field. */\n fieldStyle?: React.CSSProperties;\n}\n\n/** Component that displays a button used to pick a date and optionally a time.\n * @alpha\n * */\nexport function DatePickerPopupButton({\n displayEditField,\n timeDisplay,\n selected,\n onDateChange,\n dateFormatter,\n buttonToolTip,\n fieldStyle,\n fieldClassName,\n style,\n}: DatePickerPopupButtonProps) {\n const [workingDate, setWorkingDate] = React.useState(\n new Date(selected.getTime())\n );\n const [isSettingsOpen, setIsSettingsOpen] = React.useState(false);\n const timeLabelRef = React.useRef(UiComponents.translate(\"datepicker.time\"));\n const toolTipLabelRef = React.useRef(\n UiComponents.translate(\"datepicker.selectDate\")\n );\n const toolTipLabel = React.useMemo(\n () => (buttonToolTip ? buttonToolTip : toolTipLabelRef.current),\n [buttonToolTip]\n );\n\n // See if props have changed since component mounted\n React.useEffect(() => {\n const newWorkingDate = new Date(selected.getTime());\n setWorkingDate(newWorkingDate);\n }, [selected]);\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const togglePopupDisplay = React.useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n event.preventDefault();\n setShowFocusOutline(false);\n setIsSettingsOpen((prev) => !prev);\n },\n [setIsSettingsOpen]\n );\n\n const handleCloseSetting = React.useCallback(() => {\n setIsSettingsOpen(false);\n }, [setIsSettingsOpen]);\n\n const handleOnDateChanged = (day: Date) => {\n // combine current time into selected Date\n const newWorkingDate = new Date(day.getTime());\n newWorkingDate.setHours(\n workingDate.getHours(),\n workingDate.getMinutes(),\n workingDate.getSeconds()\n );\n onDateChange && onDateChange(newWorkingDate);\n !timeDisplay && setIsSettingsOpen(false);\n };\n\n const handleOnTimeChanged = (time: TimeSpec) => {\n // Combine new time into selected Date\n const newWorkingDate = new Date(workingDate.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n setWorkingDate(newWorkingDate);\n onDateChange && onDateChange(newWorkingDate);\n };\n\n const [showFocusOutline, setShowFocusOutline] = React.useState(false);\n const handlePopupKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n // istanbul ignore else\n if (event.key === SpecialKey.Space) {\n setShowFocusOutline(true);\n setIsSettingsOpen(true);\n }\n },\n []\n );\n\n const timeSpec: TimeSpec = {\n hours: workingDate.getHours(),\n minutes: workingDate.getMinutes(),\n seconds: workingDate.getSeconds(),\n };\n return (\n <>\n <button\n title={toolTipLabel}\n style={style}\n className=\"components-date-picker-calendar-popup-button\"\n onKeyDown={handlePopupKeyDown}\n data-testid=\"components-date-picker-calendar-popup-button\"\n onPointerDown={togglePopupDisplay}\n ref={buttonRef}\n >\n <div className=\"datepicker-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M13,13H9V10h4ZM16,3V15a1,1,0,0,1-1,1H1a1,1,0,0,1-1-1V3A1,1,0,0,1,1,2H3V0H4V2h8V0h1V2h2A1,1,0,0,1,16,3ZM15,6H1v9H15Z\" />\n </svg>\n </div>\n </button>\n <Popup\n isOpen={isSettingsOpen}\n position={RelativePosition.BottomLeft}\n onClose={handleCloseSetting}\n target={buttonRef.current}\n closeOnEnter={false}\n moveFocus={showFocusOutline}\n closeOnNestedPopupOutsideClick\n >\n <div\n className=\"components-date-picker-calendar-popup-panel\"\n data-testid=\"components-date-picker-calendar-popup-panel\"\n >\n <DatePicker\n selected={workingDate}\n onDateChange={handleOnDateChanged}\n showFocusOutline={showFocusOutline}\n />\n {timeDisplay && (\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">\n {timeLabelRef.current}\n </Text>\n <TimeField\n time={timeSpec}\n timeDisplay={timeDisplay}\n onTimeChange={handleOnTimeChanged}\n />\n </div>\n )}\n </div>\n </Popup>\n {!!displayEditField && (\n <DateField\n style={fieldStyle}\n className={fieldClassName}\n initialDate={workingDate}\n timeDisplay={timeDisplay}\n dateFormatter={dateFormatter}\n onDateChange={handleOnDateChanged}\n />\n )}\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DatePickerPopupButton.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePickerPopupButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;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AAC,MAAM,EAAC,SAAS,EAAC,YAAY,IACxC,YAAY,CAAC,OAAO,CAChB;oBACP,oBAAC,qBAAS,IACR,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,mBAAmB,GACjC,CACE,CACP,CACG,CACA;QACP,CAAC,CAAC,gBAAgB,IAAI,CACrB,oBAAC,qBAAS,IACR,KAAK,EAAE,UAAU,EACjB,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,mBAAmB,GACjC,CACH,CACA,CACJ,CAAC;AACJ,CAAC;AA9ID,sDA8IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Date\n */\n\nimport * as React from \"react\";\nimport type { DateFormatter, TimeDisplay } from \"@itwin/appui-abstract\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Popup } from \"@itwin/core-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport { DatePicker } from \"./DatePicker\";\nimport { DateField } from \"./DateField\";\nimport type { TimeSpec } from \"./TimeField\";\nimport { TimeField } from \"./TimeField\";\nimport \"./DatePickerPopupButton.scss\";\n\n/** Props used by [[DatePickerPopupButton]] component.\n * @alpha */\nexport interface DatePickerPopupButtonProps extends CommonProps {\n /** Date to be shown as the selected date. */\n selected: Date;\n /** If true show the date (and optionally time) edit field next to button */\n displayEditField?: boolean;\n // If defined show time in popup and also display time if input field is shown\n timeDisplay?: TimeDisplay;\n /** Function called when Date changes. */\n onDateChange?: (day: Date) => void;\n /** Optional tooltip */\n buttonToolTip?: string;\n /* Custom date formatter. WARNING: if used values will only be shown in specified format and will not be based on locale.\n * If used the existence of a parseDate function will determine if the edit field allows editing. */\n dateFormatter?: DateFormatter;\n /** User defined class name for edit field. */\n fieldClassName?: string;\n /** User defined style for edit field. */\n fieldStyle?: React.CSSProperties;\n}\n\n/** Component that displays a button used to pick a date and optionally a time.\n * @alpha\n * */\nexport function DatePickerPopupButton({\n displayEditField,\n timeDisplay,\n selected,\n onDateChange,\n dateFormatter,\n buttonToolTip,\n fieldStyle,\n fieldClassName,\n style,\n}: DatePickerPopupButtonProps) {\n const [workingDate, setWorkingDate] = React.useState(\n new Date(selected.getTime())\n );\n const [isSettingsOpen, setIsSettingsOpen] = React.useState(false);\n const timeLabelRef = React.useRef(UiComponents.translate(\"datepicker.time\"));\n const toolTipLabelRef = React.useRef(\n UiComponents.translate(\"datepicker.selectDate\")\n );\n const toolTipLabel = React.useMemo(\n () => (buttonToolTip ? buttonToolTip : toolTipLabelRef.current),\n [buttonToolTip]\n );\n\n // See if props have changed since component mounted\n React.useEffect(() => {\n const newWorkingDate = new Date(selected.getTime());\n setWorkingDate(newWorkingDate);\n }, [selected]);\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const togglePopupDisplay = React.useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n event.preventDefault();\n setShowFocusOutline(false);\n setIsSettingsOpen((prev) => !prev);\n },\n [setIsSettingsOpen]\n );\n\n const handleCloseSetting = React.useCallback(() => {\n setIsSettingsOpen(false);\n }, [setIsSettingsOpen]);\n\n const handleOnDateChanged = (day: Date) => {\n // combine current time into selected Date\n const newWorkingDate = new Date(day.getTime());\n newWorkingDate.setHours(\n workingDate.getHours(),\n workingDate.getMinutes(),\n workingDate.getSeconds()\n );\n onDateChange && onDateChange(newWorkingDate);\n !timeDisplay && setIsSettingsOpen(false);\n };\n\n const handleOnTimeChanged = (time: TimeSpec) => {\n // Combine new time into selected Date\n const newWorkingDate = new Date(workingDate.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n setWorkingDate(newWorkingDate);\n onDateChange && onDateChange(newWorkingDate);\n };\n\n const [showFocusOutline, setShowFocusOutline] = React.useState(false);\n const handlePopupKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n // istanbul ignore else\n if (event.key === \" \") {\n setShowFocusOutline(true);\n setIsSettingsOpen(true);\n }\n },\n []\n );\n\n const timeSpec: TimeSpec = {\n hours: workingDate.getHours(),\n minutes: workingDate.getMinutes(),\n seconds: workingDate.getSeconds(),\n };\n return (\n <>\n <button\n title={toolTipLabel}\n style={style}\n className=\"components-date-picker-calendar-popup-button\"\n onKeyDown={handlePopupKeyDown}\n data-testid=\"components-date-picker-calendar-popup-button\"\n onPointerDown={togglePopupDisplay}\n ref={buttonRef}\n >\n <div className=\"datepicker-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M13,13H9V10h4ZM16,3V15a1,1,0,0,1-1,1H1a1,1,0,0,1-1-1V3A1,1,0,0,1,1,2H3V0H4V2h8V0h1V2h2A1,1,0,0,1,16,3ZM15,6H1v9H15Z\" />\n </svg>\n </div>\n </button>\n <Popup\n isOpen={isSettingsOpen}\n position={RelativePosition.BottomLeft}\n onClose={handleCloseSetting}\n target={buttonRef.current}\n closeOnEnter={false}\n moveFocus={showFocusOutline}\n closeOnNestedPopupOutsideClick\n >\n <div\n className=\"components-date-picker-calendar-popup-panel\"\n data-testid=\"components-date-picker-calendar-popup-panel\"\n >\n <DatePicker\n selected={workingDate}\n onDateChange={handleOnDateChanged}\n showFocusOutline={showFocusOutline}\n />\n {timeDisplay && (\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">\n {timeLabelRef.current}\n </Text>\n <TimeField\n time={timeSpec}\n timeDisplay={timeDisplay}\n onTimeChange={handleOnTimeChanged}\n />\n </div>\n )}\n </div>\n </Popup>\n {!!displayEditField && (\n <DateField\n style={fieldStyle}\n className={fieldClassName}\n initialDate={workingDate}\n timeDisplay={timeDisplay}\n dateFormatter={dateFormatter}\n onDateChange={handleOnDateChanged}\n />\n )}\n </>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/TimeField.tsx"],"names":[],"mappings":"AAIA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"TimeField.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/TimeField.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAwBD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,YAAY,GACb,EAAE,cAAc,eAgVhB"}
|