@itwin/components-react 5.0.5 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -12
- package/lib/cjs/components-react/editors/DateTimeEditor.scss +0 -1
- package/lib/components-react/UiComponents.js +2 -2
- package/lib/components-react/UiComponents.js.map +1 -1
- package/lib/components-react/common/CheckBoxState.js.map +1 -1
- package/lib/components-react/common/HighlightedText.js +1 -1
- package/lib/components-react/common/HighlightedText.js.map +1 -1
- package/lib/components-react/common/ImageRenderer.js +4 -4
- package/lib/components-react/common/ImageRenderer.js.map +1 -1
- package/lib/components-react/common/Links.d.ts.map +1 -1
- package/lib/components-react/common/Links.js +0 -1
- package/lib/components-react/common/Links.js.map +1 -1
- package/lib/components-react/common/Orientation.js.map +1 -1
- package/lib/components-react/common/TimeFormat.js +1 -1
- package/lib/components-react/common/TimeFormat.js.map +1 -1
- package/lib/components-react/common/UseContextWithMandatoryProvider.js +1 -1
- package/lib/components-react/common/UseContextWithMandatoryProvider.js.map +1 -1
- package/lib/components-react/converters/DateTimeTypeConverter.d.ts.map +1 -1
- package/lib/components-react/converters/DateTimeTypeConverter.js +0 -1
- package/lib/components-react/converters/DateTimeTypeConverter.js.map +1 -1
- package/lib/components-react/converters/PointTypeConverter.d.ts.map +1 -1
- package/lib/components-react/converters/PointTypeConverter.js +0 -1
- package/lib/components-react/converters/PointTypeConverter.js.map +1 -1
- package/lib/components-react/converters/TypeConverter.d.ts.map +1 -1
- package/lib/components-react/converters/TypeConverter.js.map +1 -1
- package/lib/components-react/datepicker/DateField.js +2 -2
- package/lib/components-react/datepicker/DateField.js.map +1 -1
- package/lib/components-react/datepicker/DatePicker.js +1 -1
- package/lib/components-react/datepicker/DatePicker.js.map +1 -1
- package/lib/components-react/datepicker/DatePickerPopupButton.js +1 -1
- package/lib/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
- package/lib/components-react/datepicker/IntlFormatter.d.ts.map +1 -1
- package/lib/components-react/datepicker/TimeField.js +1 -1
- package/lib/components-react/datepicker/TimeField.js.map +1 -1
- package/lib/components-react/editors/BooleanEditor.d.ts +1 -0
- package/lib/components-react/editors/BooleanEditor.d.ts.map +1 -1
- package/lib/components-react/editors/BooleanEditor.js +1 -0
- package/lib/components-react/editors/BooleanEditor.js.map +1 -1
- package/lib/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
- package/lib/components-react/editors/CustomNumberEditor.js +2 -3
- package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/components-react/editors/DateTimeEditor.d.ts.map +1 -1
- package/lib/components-react/editors/DateTimeEditor.js +1 -1
- package/lib/components-react/editors/DateTimeEditor.js.map +1 -1
- package/lib/components-react/editors/DateTimeEditor.scss +0 -1
- package/lib/components-react/editors/EditorContainer.js +1 -1
- package/lib/components-react/editors/EditorContainer.js.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.d.ts +1 -0
- package/lib/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.js +1 -0
- package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/components-react/editors/EnumEditor.d.ts +1 -0
- package/lib/components-react/editors/EnumEditor.d.ts.map +1 -1
- package/lib/components-react/editors/EnumEditor.js +1 -0
- package/lib/components-react/editors/EnumEditor.js.map +1 -1
- package/lib/components-react/editors/IconEditor.d.ts.map +1 -1
- package/lib/components-react/editors/IconEditor.js.map +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.d.ts +1 -0
- package/lib/components-react/editors/ImageCheckBoxEditor.d.ts.map +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.js +2 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.d.ts +1 -0
- package/lib/components-react/editors/NumericInputEditor.d.ts.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.js +2 -1
- package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
- package/lib/components-react/editors/PopupButton.js +3 -3
- package/lib/components-react/editors/PopupButton.js.map +1 -1
- package/lib/components-react/editors/SliderEditor.d.ts +1 -0
- package/lib/components-react/editors/SliderEditor.d.ts.map +1 -1
- package/lib/components-react/editors/SliderEditor.js +3 -2
- package/lib/components-react/editors/SliderEditor.js.map +1 -1
- package/lib/components-react/editors/TextEditor.d.ts +1 -0
- package/lib/components-react/editors/TextEditor.d.ts.map +1 -1
- package/lib/components-react/editors/TextEditor.js +3 -2
- package/lib/components-react/editors/TextEditor.js.map +1 -1
- package/lib/components-react/editors/TextareaEditor.d.ts +1 -0
- package/lib/components-react/editors/TextareaEditor.d.ts.map +1 -1
- package/lib/components-react/editors/TextareaEditor.js +1 -0
- package/lib/components-react/editors/TextareaEditor.js.map +1 -1
- package/lib/components-react/editors/ToggleEditor.d.ts +1 -0
- package/lib/components-react/editors/ToggleEditor.d.ts.map +1 -1
- package/lib/components-react/editors/ToggleEditor.js +1 -0
- package/lib/components-react/editors/ToggleEditor.js.map +1 -1
- package/lib/components-react/favorite/FavoritePropertyList.js +1 -1
- package/lib/components-react/favorite/FavoritePropertyList.js.map +1 -1
- package/lib/components-react/filter-builder/FilterBuilderState.js +1 -1
- package/lib/components-react/filter-builder/FilterBuilderState.js.map +1 -1
- package/lib/components-react/filtering/FilteringInput.d.ts +1 -0
- package/lib/components-react/filtering/FilteringInput.d.ts.map +1 -1
- package/lib/components-react/filtering/FilteringInput.js +1 -0
- package/lib/components-react/filtering/FilteringInput.js.map +1 -1
- package/lib/components-react/filtering/ResultSelector.d.ts +1 -0
- package/lib/components-react/filtering/ResultSelector.d.ts.map +1 -1
- package/lib/components-react/filtering/ResultSelector.js +1 -0
- package/lib/components-react/filtering/ResultSelector.js.map +1 -1
- package/lib/components-react/iconpicker/IconPickerButton.js.map +1 -1
- package/lib/components-react/inputs/ParsedInput.js +1 -1
- package/lib/components-react/inputs/ParsedInput.js.map +1 -1
- package/lib/components-react/l10n/LocalizationProvider.js +2 -2
- package/lib/components-react/l10n/LocalizationProvider.js.map +1 -1
- package/lib/components-react/properties/LinkHandler.d.ts +2 -2
- package/lib/components-react/properties/LinkHandler.d.ts.map +1 -1
- package/lib/components-react/properties/LinkHandler.js +2 -2
- package/lib/components-react/properties/LinkHandler.js.map +1 -1
- package/lib/components-react/properties/renderers/PropertyView.js +1 -1
- package/lib/components-react/properties/renderers/PropertyView.js.map +1 -1
- package/lib/components-react/properties/renderers/value/WithContextStyle.d.ts.map +1 -1
- package/lib/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.js +1 -1
- package/lib/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridCommons.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyList.js.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +1 -0
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +1 -0
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.d.ts +4 -4
- package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.d.ts.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +8 -8
- package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/components-react/selectable-content/SelectableContent.js +2 -2
- package/lib/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/components-react/toolbar/InternalToolbarComponent.d.ts +1 -1
- package/lib/components-react/toolbar/InternalToolbarComponent.d.ts.map +1 -1
- package/lib/components-react/toolbar/InternalToolbarComponent.js +11 -11
- package/lib/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
- package/lib/components-react/toolbar/Item.js.map +1 -1
- package/lib/components-react/toolbar/ItemWrapper.js.map +1 -1
- package/lib/components-react/toolbar/Items.js.map +1 -1
- package/lib/components-react/toolbar/Overflow.d.ts +1 -1
- package/lib/components-react/toolbar/Overflow.d.ts.map +1 -1
- package/lib/components-react/toolbar/Overflow.js.map +1 -1
- package/lib/components-react/toolbar/OverflowPanel.js.map +1 -1
- package/lib/components-react/toolbar/PopupItem.js.map +1 -1
- package/lib/components-react/toolbar/PopupItemWithDrag.js.map +1 -1
- package/lib/components-react/toolbar/PopupItemsPanel.js +2 -2
- package/lib/components-react/toolbar/PopupItemsPanel.js.map +1 -1
- package/lib/components-react/toolbar/Toolbar.js +1 -1
- package/lib/components-react/toolbar/Toolbar.js.map +1 -1
- package/lib/components-react/toolbar/ToolbarWithOverflow.js +1 -1
- package/lib/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/components-react/toolbar/groupPanel/BackArrow.js.map +1 -1
- package/lib/components-react/toolbar/groupPanel/Column.js.map +1 -1
- package/lib/components-react/toolbar/groupPanel/Columns.js.map +1 -1
- package/lib/components-react/toolbar/groupPanel/Panel.js.map +1 -1
- package/lib/components-react/toolbar/groupPanel/Title.js.map +1 -1
- package/lib/components-react/toolbar/groupPanel/tool/Expander.js.map +1 -1
- package/lib/components-react/toolbar/groupPanel/tool/Tool.js.map +1 -1
- package/lib/components-react/toolbar/useConditionalSynchedItems.d.ts +1 -1
- package/lib/components-react/toolbar/useConditionalSynchedItems.d.ts.map +1 -1
- package/lib/components-react/toolbar/useConditionalSynchedItems.js +3 -3
- package/lib/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
- package/lib/components-react/toolbar/useDragInteraction.d.ts.map +1 -1
- package/lib/components-react/toolbar/useDragInteraction.js +1 -1
- package/lib/components-react/toolbar/useDragInteraction.js.map +1 -1
- package/lib/components-react/tree/TreeDataProvider.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/Observable.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeHooks.js +2 -2
- package/lib/components-react/tree/controlled/TreeHooks.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeModel.js +3 -3
- package/lib/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeModelSource.js +2 -2
- package/lib/components-react/tree/controlled/TreeModelSource.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeNodeLoader.js +1 -1
- package/lib/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
- package/lib/components-react/tree/controlled/component/ControlledTree.js +1 -1
- package/lib/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
- package/lib/components-react/tree/controlled/component/NodeContent.js +2 -2
- package/lib/components-react/tree/controlled/component/NodeContent.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js +3 -3
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeRenderer.js +4 -4
- package/lib/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
- package/lib/components-react.js +1 -1
- package/lib/components-react.js.map +1 -1
- package/lib/esm/components-react/editors/DateTimeEditor.scss +0 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @itwin/components-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 30 Jan 2025 09:15:23 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.1.0
|
|
6
|
+
Thu, 30 Jan 2025 09:15:23 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- cSpell fixes
|
|
4
11
|
|
|
5
12
|
## 5.0.5
|
|
6
13
|
Tue, 21 Jan 2025 11:38:58 GMT
|
|
@@ -697,7 +704,7 @@ Thu, 24 Feb 2022 15:26:55 GMT
|
|
|
697
704
|
|
|
698
705
|
### Updates
|
|
699
706
|
|
|
700
|
-
- Use ToolbarAutoHidePopupContext to monitor widgets'
|
|
707
|
+
- Use ToolbarAutoHidePopupContext to monitor widgets' autoHidden state.
|
|
701
708
|
|
|
702
709
|
## 3.0.0
|
|
703
710
|
Mon, 24 Jan 2022 14:00:52 GMT
|
|
@@ -908,7 +915,7 @@ Mon, 26 Jul 2021 12:21:25 GMT
|
|
|
908
915
|
|
|
909
916
|
- remove internal barrel-import usage
|
|
910
917
|
- Stop delivering pseudo-localized strings
|
|
911
|
-
- Add window "
|
|
918
|
+
- Add window "beforeUnload" event listener to ensure viewport is dropped from ViewManager.
|
|
912
919
|
- `MutableTreeModel`: `removeChild` method now accepts child index for the second parameter.
|
|
913
920
|
- Workaround for react-data-grid blank grid after scroll and update
|
|
914
921
|
- Add option prop to set time zone offset for date and time display in the TimelineComponent.
|
|
@@ -979,7 +986,7 @@ Mon, 28 Jun 2021 16:20:11 GMT
|
|
|
979
986
|
- Added `overflow` property for `react-grid-Cell__value` element. `zIndex` is set in `TableCellContent` style property. These updates are necessary for rendering merged cells in `Table` component.
|
|
980
987
|
- Updated `Table` component so that it would be possible to merge cells in it
|
|
981
988
|
- Update scss to remove use of slash for division to avoid SASS deprecation warnings.
|
|
982
|
-
-
|
|
989
|
+
- Public in-use APIs
|
|
983
990
|
- Refactor TimelineComponent to remove experimental milestones feature.
|
|
984
991
|
- `TreeRenderer`: Fix tree nodes being loaded repeatedly in some cases.
|
|
985
992
|
- `VirtualizedPropertyGrid`: Remove top and bottom padding.
|
|
@@ -1203,7 +1210,7 @@ Thu, 28 Jan 2021 13:39:27 GMT
|
|
|
1203
1210
|
- Added ui-core learning docs content and added Notification.md, Style.md & Tooltip.md ui-core learning doc files.
|
|
1204
1211
|
- Fix test warnings.
|
|
1205
1212
|
- Update to latest react-dnd version.
|
|
1206
|
-
- Always clone the ViewState for a ViewportComponent to avoid attaching the same ViewState to multiple
|
|
1213
|
+
- Always clone the ViewState for a ViewportComponent to avoid attaching the same ViewState to multiple viewPorts.
|
|
1207
1214
|
|
|
1208
1215
|
## 2.10.3
|
|
1209
1216
|
Fri, 08 Jan 2021 18:34:03 GMT
|
|
@@ -1231,7 +1238,7 @@ Fri, 18 Dec 2020 18:24:01 GMT
|
|
|
1231
1238
|
- Added highlightedRecordProps to [[VirtualizedPropertyGridProps]] to allow highlighting specific parts of rendered PropertyRecords.
|
|
1232
1239
|
- Updated [[FilteringInput]] component. Component's `filteringInProgress` prop was deprecated and new `status` property was introduced. This allows rendering the component in any state, including `filtering finished`, without having to cycle through other states first.
|
|
1233
1240
|
- fix but in ParsedInput control where formatted text was not updating if underlying parsed value did not change.
|
|
1234
|
-
- Refactor DialogItem and Property interfaces to make them
|
|
1241
|
+
- Refactor DialogItem and Property interfaces to make them easier to use.
|
|
1235
1242
|
- Added support for decimal point in Table numeric filter
|
|
1236
1243
|
- Enable pointer events in Toolbar items container."
|
|
1237
1244
|
- Fix issue where entries in ButtonGroup would not properly disable/enable.
|
|
@@ -1486,7 +1493,7 @@ Fri, 10 Jul 2020 17:23:14 GMT
|
|
|
1486
1493
|
- geometry clip containment
|
|
1487
1494
|
- Fix ToolbarWithOverflow to honor ToolbarOpacitySetting.Defaults
|
|
1488
1495
|
- Accessibility: Improved focus borders & indicators
|
|
1489
|
-
- Use
|
|
1496
|
+
- Use DelayedSpined in ControlledTree.
|
|
1490
1497
|
- Add support for nested property categories
|
|
1491
1498
|
- Show tooltips for property values when rendering PropertyRecords
|
|
1492
1499
|
- Changing SelectableContent component to use ThemedSelect in place of a pure HTML select element
|
|
@@ -1522,7 +1529,7 @@ Thu, 28 May 2020 22:48:59 GMT
|
|
|
1522
1529
|
- Added ability for apps to display Favorite properties in Element Tooltip & Card at Cursor
|
|
1523
1530
|
- Darken node descriptions in controlled tree
|
|
1524
1531
|
- Center align ControlledTree error message
|
|
1525
|
-
- ControlledTree: Grow virtualized nodes' container width to fit the widest node and do not shrink it to avoid
|
|
1532
|
+
- ControlledTree: Grow virtualized nodes' container width to fit the widest node and do not shrink it to avoid horizontal scrollbar appearing/disappearing
|
|
1526
1533
|
- Update version of react-select for ThemedSelect in ui-core.
|
|
1527
1534
|
- ControlledTree: Fix horizontal scrollbar appearing when tree component size changes even though nodes don't exceed width of the tree
|
|
1528
1535
|
- Only show badges on toolbar buttons if toolbar background is not transparent.
|
|
@@ -1781,7 +1788,7 @@ Mon, 01 Jul 2019 19:04:29 GMT
|
|
|
1781
1788
|
|
|
1782
1789
|
### Updates
|
|
1783
1790
|
|
|
1784
|
-
- Tree: Fix an issue
|
|
1791
|
+
- Tree: Fix an issue with multiSelection where shift-selecting nodes would not select anything.
|
|
1785
1792
|
- Tree: Add ability to check or uncheck multiple selected nodes' checkboxes all at once.
|
|
1786
1793
|
- BeInspireTree: Fix an issue with calling `updateNodesCheckboxes()` while handling `ModelLoaded` event
|
|
1787
1794
|
- Tree: Correct TreeProps.checkboxInfo documentation.
|
|
@@ -1789,8 +1796,8 @@ Mon, 01 Jul 2019 19:04:29 GMT
|
|
|
1789
1796
|
- Updated react-data-grid import statement
|
|
1790
1797
|
- Added prefixes to Dialog & ContextMenu positioning CSS classes
|
|
1791
1798
|
- Removed missing group descriptions
|
|
1792
|
-
- Call
|
|
1793
|
-
- Added
|
|
1799
|
+
- Call filterClear when the user enters an empty search string and clicks Search.
|
|
1800
|
+
- Added autoFocus to the FilteringInput component.
|
|
1794
1801
|
- Remove inner focus outline that is only displayed in Firefox.
|
|
1795
1802
|
- Update WeightPicker.
|
|
1796
1803
|
- Removed 4 dangerouslySetInnerHtml usages to help with Security audit; 3 remain on purpose.
|
|
@@ -2142,7 +2149,7 @@ Wed, 24 Oct 2018 19:20:07 GMT
|
|
|
2142
2149
|
- Tooltips, ToolAdmin.activeToolChanged support, SheetNavigationAid/SheetsModalFrontstage improvements.
|
|
2143
2150
|
- Ui Documentation
|
|
2144
2151
|
- Vertical PropertyGrid layout improvements. PropertyGrid background color. Setting the widget state.
|
|
2145
|
-
- Changed Horizontal PropertyGrid css to use grid instead of table display and modified
|
|
2152
|
+
- Changed Horizontal PropertyGrid css to use grid instead of table display and modified subComponents accordingly.
|
|
2146
2153
|
- Fixed property selection.
|
|
2147
2154
|
- Added an ability to resize label/value in PropertyRenderer.
|
|
2148
2155
|
- SelectablePropertyBlock now controls label/value ratio for every property in a category.
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
// cSpell:ignore datetime
|
|
6
5
|
|
|
7
6
|
.components-datetime-editor {
|
|
8
7
|
min-width: 100%;
|
|
@@ -25,7 +25,7 @@ export class UiComponents {
|
|
|
25
25
|
enablePatches();
|
|
26
26
|
UiComponents._localization = localization;
|
|
27
27
|
await UiComponents._localization.registerNamespace(UiComponents.localizationNamespace);
|
|
28
|
-
// eslint-disable-next-line
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
29
29
|
await UiCore.initialize(UiComponents._localization);
|
|
30
30
|
UiComponents._initialized = true;
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ export class UiComponents {
|
|
|
34
34
|
if (UiComponents._localization)
|
|
35
35
|
UiComponents._localization.unregisterNamespace(UiComponents.localizationNamespace);
|
|
36
36
|
UiComponents._localization = undefined;
|
|
37
|
-
// eslint-disable-next-line
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
38
38
|
UiCore.terminate();
|
|
39
39
|
UiComponents._initialized = false;
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,YAAY;IAIvB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,CAAC,OAAO,CACZ,YAAY,CAAC,cAAc,CAAC,cAAc,CAAC,EAC3C,wCAAwC,CACzC,CAAC;YACF,OAAO;QACT,CAAC;QAED,aAAa,EAAE,CAAC;QAChB,YAAY,CAAC,aAAa,GAAG,YAAY,CAAC;QAC1C,MAAM,YAAY,CAAC,aAAa,CAAC,iBAAiB,CAChD,YAAY,CAAC,qBAAqB,CACnC,CAAC;QAEF,
|
|
1
|
+
{"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,YAAY;IAIvB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,CAAC,OAAO,CACZ,YAAY,CAAC,cAAc,CAAC,cAAc,CAAC,EAC3C,wCAAwC,CACzC,CAAC;YACF,OAAO;QACT,CAAC;QAED,a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Y,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;IAC/C,CAAC;;AA1Ec,yBAAY,GAAG,KAAK,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 { enablePatches } from \"immer\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\nimport { UiCore } from \"@itwin/core-react\";\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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 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.getLocalizedString 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._localization) {\n Logger.logError(\n UiComponents.loggerCategory(\"UiComponents\"),\n `translate: UiComponents.initialize has not been called. Returning blank string.`\n );\n return \"\";\n }\n return UiComponents._localization.getLocalizedString(\n `${UiComponents.localizationNamespace}:${key}`\n );\n }\n\n /** @internal */\n public static loggerCategory(name: string): string {\n return `${UiComponents.packageName}.${name}`;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckBoxState.js","sourceRoot":"","sources":["../../../src/components-react/common/CheckBoxState.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQpE;;GAEG;AACH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,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 */\nimport { CheckBoxState as _CheckBoxState } from \"@itwin/core-react\";\n\n/* eslint-disable
|
|
1
|
+
{"version":3,"file":"CheckBoxState.js","sourceRoot":"","sources":["../../../src/components-react/common/CheckBoxState.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQpE;;GAEG;AACH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,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 */\nimport { CheckBoxState as _CheckBoxState } from \"@itwin/core-react\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** State of a checkbox.\n * @public\n */\nexport type CheckBoxState = _CheckBoxState;\n/** State of a checkbox.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const CheckBoxState = _CheckBoxState;\n"]}
|
|
@@ -13,7 +13,7 @@ import { HighlightingEngine } from "../tree/HighlightingEngine.js";
|
|
|
13
13
|
* Also actively highlights one matched part which is selected with 'activeMatchIndex'
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
// eslint-disable-next-line
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
17
17
|
export function HighlightedText(props) {
|
|
18
18
|
const { searchText, activeMatchIndex, text, caseSensitive } = props;
|
|
19
19
|
const chunks = useMemo(() => findChunks(text, searchText, caseSensitive), [text, searchText, caseSensitive]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightedText.js","sourceRoot":"","sources":["../../../src/components-react/common/HighlightedText.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAkBnE;;;;;GAKG;AACH,
|
|
1
|
+
{"version":3,"file":"HighlightedText.js","sourceRoot":"","sources":["../../../src/components-react/common/HighlightedText.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAkBnE;;;;;GAKG;AACH,4DAA4D;AAC5D,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IACpE,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,aAA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M,QAAQ,GAAG,CAAC,KAAK,WAAW,CAAC;QACnC,IACE,SAAS;YACT,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,KAAK;YAClC,CAAC,QAAQ;YACT,CAAC,SAAS,CAAC,QAAQ,EACnB,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;YAC/B,SAAS;QACX,CAAC;QACD,QAAQ,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;QACxD,SAAS,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACzC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAC1C,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 React, { useMemo } from \"react\";\nimport { HighlightingEngine } from \"../tree/HighlightingEngine.js\";\n\n/**\n * Properties of [[HighlightedText]]\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof HighlightedText>`\n */\nexport interface HighlightedTextProps {\n /* Filter text which we want to highlight */\n searchText: string;\n /* Index of actively highlighted part in a text */\n activeMatchIndex?: number;\n /* Full text */\n text: string;\n /** Should search be case sensitive */\n caseSensitive?: boolean;\n}\n\n/**\n * Highlighted text\n * Used for highlighting parts in the 'text' which match with 'searchText'\n * Also actively highlights one matched part which is selected with 'activeMatchIndex'\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function HighlightedText(props: HighlightedTextProps) {\n const { searchText, activeMatchIndex, text, caseSensitive } = props;\n const chunks = useMemo(\n () => findChunks(text, searchText, caseSensitive),\n [text, searchText, caseSensitive]\n );\n const markedChunks = useMemo(\n () => markChunks(text, chunks, activeMatchIndex),\n [text, chunks, activeMatchIndex]\n );\n return <>{markedChunks}</>;\n}\n\ninterface HighlightedChunk {\n start: number;\n end: number;\n}\n\nfunction findChunks(\n text: string,\n searchText: string,\n caseSensitive?: boolean\n): HighlightedChunk[] {\n const chunks: HighlightedChunk[] = [];\n const contentText = caseSensitive ? text : text.toLowerCase();\n const inputText = caseSensitive ? searchText : searchText.toLowerCase();\n let index = contentText.indexOf(inputText);\n\n while (index !== -1) {\n chunks.push({ start: index, end: index + inputText.length });\n index = contentText.indexOf(inputText, index + 1);\n }\n\n return chunks;\n}\n\nfunction markChunks(\n text: string,\n chunks: HighlightedChunk[],\n activeChunk?: number\n) {\n const markedText: React.ReactElement[] = [];\n let previousIndex = 0;\n\n const { mergedChunks, newActiveIndex } = mergeChunks(chunks, activeChunk);\n\n for (let i = 0; i < mergedChunks.length; i++) {\n const { start, end } = mergedChunks[i];\n\n // add unmarked text between previous chunk and current one\n const nonMarkedText = text.substring(previousIndex, start);\n if (nonMarkedText.length) {\n markedText.push(<span key={previousIndex}>{nonMarkedText}</span>);\n }\n\n // add marked chunk text\n markedText.push(\n <mark\n key={start}\n className={\n i === newActiveIndex\n ? HighlightingEngine.ACTIVE_CLASS_NAME\n : undefined\n }\n >\n {text.substring(start, end)}\n </mark>\n );\n previousIndex = end;\n }\n\n // add unmarked text after last chunk\n const lastNonMarkedText = text.substring(previousIndex, text.length);\n if (lastNonMarkedText.length) {\n markedText.push(<span key={previousIndex}>{lastNonMarkedText}</span>);\n }\n\n return markedText;\n}\n\nfunction mergeChunks(chunks: HighlightedChunk[], activeChunk?: number) {\n const mergedChunks: HighlightedChunk[] = [];\n let lastChunk: { isActive: boolean; info: HighlightedChunk } | undefined;\n let newActiveIndex: number | undefined;\n\n for (let i = 0; i < chunks.length; i++) {\n const chunk = chunks[i];\n const isActive = i === activeChunk;\n if (\n lastChunk &&\n lastChunk.info.end === chunk.start &&\n !isActive &&\n !lastChunk.isActive\n ) {\n lastChunk.info.end = chunk.end;\n continue;\n }\n isActive && (newActiveIndex = mergedChunks.length);\n const newChunk = { start: chunk.start, end: chunk.end };\n lastChunk = { isActive, info: newChunk };\n mergedChunks.push(newChunk);\n }\n return { mergedChunks, newActiveIndex };\n}\n"]}
|
|
@@ -62,7 +62,7 @@ export class ImageRenderer {
|
|
|
62
62
|
}
|
|
63
63
|
/** Render image as core-react icon */
|
|
64
64
|
renderCoreIcon(iconName) {
|
|
65
|
-
// eslint-disable-next-line
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
66
66
|
return React.createElement(WebFontIcon, { iconName: iconName });
|
|
67
67
|
}
|
|
68
68
|
/** Replaces the escaped instances of "\:" with ":" */
|
|
@@ -74,7 +74,7 @@ export class ImageRenderer {
|
|
|
74
74
|
* className and fontName can be escaped using \ if : is needed.
|
|
75
75
|
*/
|
|
76
76
|
extractIconClassAndName(iconName
|
|
77
|
-
// eslint-disable-next-line
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
78
78
|
) {
|
|
79
79
|
const matches = iconName.match(/(\\.|[^:])+/g);
|
|
80
80
|
if (!matches || matches.length !== 2)
|
|
@@ -93,7 +93,7 @@ export class ImageRenderer {
|
|
|
93
93
|
*/
|
|
94
94
|
renderWebfontIcon(iconName) {
|
|
95
95
|
const iconInfo = this.extractIconClassAndName(iconName);
|
|
96
|
-
// eslint-disable-next-line
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
97
97
|
return React.createElement(WebFontIcon, { ...iconInfo });
|
|
98
98
|
}
|
|
99
99
|
/** Render image from data provided by an image loader */
|
|
@@ -112,7 +112,7 @@ export class ImageRenderer {
|
|
|
112
112
|
return this.renderWebfontIcon(loadedImage.value);
|
|
113
113
|
default:
|
|
114
114
|
const unhandledSourceType = loadedImage.sourceType; // Compile time check that all cases are handled
|
|
115
|
-
// eslint-disable-next-line
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
116
116
|
throw new UiError(UiComponents.loggerCategory("ImageRenderer"), `Can't handle sourceType: "${unhandledSourceType}"`);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageRenderer.js","sourceRoot":"","sources":["../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOlD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,aAAa;IAGhB,WAAW,CAAC,SAAiB;QACnC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QAEtB,OAAO,MAAM,CAAC,IAAI,CAChB,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,WAAW,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,6BAAK,GAAG,EAAE,cAAc,MAAM,WAAW,YAAY,EAAE,EAAE,GAAG,EAAC,EAAE,GAAG,CAAC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CAAC;YAEpE;gBACE,MAAM,mBAAmB,GAAU,WAAW,CAAC,UAAU,CAAC,CAAC,gDAAgD;gBAC3G,4DAA4D;gBAC5D,MAAM,IAAI,OAAO,CACf,YAAY,CAAC,cAAc,CAAC,eAAe,CAAC,EAC5C,6BAA6B,mBAAmB,GAAG,CACpD,CAAC;QACN,CAAC;IACH,CAAC;;AAtIc,uBAAS,GAAwB,IAAI,GAAG,EAAE,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 * as React from \"react\";\nimport type { WebFontIconProps } from \"@itwin/core-react\";\nimport { Icon, WebFontIcon } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents.js\";\nimport type {\n Image,\n ImageFileFormat,\n LoadedBinaryImage,\n LoadedImage,\n} from \"./IImageLoader.js\";\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 if (!match) return \"\";\n\n return window.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 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 if (!this.isSvg(svg)) {\n return \"\";\n }\n\n const svgAsBase64 = window.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 if (undefined === svgAsDataUri) {\n svgAsDataUri = this.convertSvgToDataUri(svg.trim());\n ImageRenderer._svgCache.set(svg, svgAsDataUri);\n }\n\n return (\n <div>\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n throw new UiError(\n UiComponents.loggerCategory(\"ImageRenderer\"),\n `Can't handle sourceType: \"${unhandledSourceType}\"`\n );\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Links.d.ts","sourceRoot":"","sources":["../../../src/components-react/common/Links.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Links.d.ts","sourceRoot":"","sources":["../../../src/components-react/common/Links.ts"],"names":[],"mappings":"AAIA;;GAEG;AA0DH;;GAEG;AACH,eAAO,MAAM,UAAU,SACf,MAAM,KACX,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAmBzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAS,MAAM,SAmBnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Links.js","sourceRoot":"","sources":["../../../src/components-react/common/Links.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,
|
|
1
|
+
{"version":3,"file":"Links.js","sourceRoot":"","sources":["../../../src/components-react/common/Links.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,EAAE,SAAS,EAAE,K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M,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC/C,UAAU,EAAE,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,+HAA+H;QAC/H,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACxD,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO;IACT,CAAC;IAED,YAAY,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC,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 LinkifyIt from \"linkify-it\";\n\nconst linkify = new LinkifyIt({ fuzzyLink: false });\n\nlinkify\n .add(\"pw:\", {\n validate: (\n text: string,\n pos: number,\n self: LinkifyIt.LinkifyIt\n ): number => {\n const tail = text.slice(pos);\n\n if (!self.re.pw) {\n self.re.pw = new RegExp(\n `(//|\\\\\\\\\\\\\\\\)${self.re.src_host}:` +\n // Regex for path according to RFC 3986 standards plus the possibility to write '{}' brackets for ProjectWise monikers\n `([a-zA-Z0-9-._~!$&'()*+,;=@%{}]+/)+[a-zA-Z0-9-._~!$&'()*+,;=@%{}]*`,\n \"i\"\n );\n }\n if (self.re.pw.test(tail)) {\n const matches = tail.match(self.re.pw);\n if (matches !== null) return matches[0].length;\n }\n return 0;\n },\n })\n /* Adding a custom schema for links that start with `www.`.\n With fuzzyLink option set to true it matches text without `www.` as a prefix, which is not wanted in our case. */\n .add(\"www.\", {\n validate: (\n text: string,\n pos: number,\n self: LinkifyIt.LinkifyIt\n ): number => {\n const tail = text.slice(pos);\n\n if (!self.re.www) {\n self.re.www = new RegExp(\n `^${self.re.src_auth}${self.re.src_host_port_strict}${self.re.src_path}`,\n \"i\"\n );\n }\n if (self.re.www.test(tail)) {\n const matches = tail.match(self.re.www);\n if (matches !== null) return matches[0].length;\n }\n return 0;\n },\n normalize: (match: LinkifyIt.Match) => {\n match.schema = \"http:\";\n match.url = `http://${match.url}`;\n },\n });\n\n/** Returns a list of links from a text\n * @public\n */\nexport const matchLinks = (\n text: string\n): Array<{ index: number; lastIndex: number; schema: string; url: string }> => {\n const head = text.slice(0, 5);\n if (head === \"pw://\" || head === \"pw:\\\\\\\\\")\n return Array({\n index: 0,\n lastIndex: text.length,\n schema: \"pw:\",\n url: text,\n });\n\n const matches = linkify.match(text);\n return matches\n ? (matches as Array<{\n index: number;\n lastIndex: number;\n schema: string;\n url: string;\n }>)\n : [];\n};\n\n/**\n * @internal\n */\nexport const openLink = (url: string) => {\n if (url.startsWith(\"mailto:\")) {\n location.href = url;\n return;\n }\n\n const openAndFocus = (link: string) => {\n const windowOpen = window.open(link, \"_blank\");\n windowOpen?.focus();\n };\n\n if (url.startsWith(\"pw:\")) {\n // remove // or \\\\ from the link. Links with custom schema should use opaque path like `schema:path` instead of `schema://path`\n const validUrl = url.replace(/pw:\\/\\/|pw:\\\\\\\\/g, \"pw:\");\n openAndFocus(validUrl);\n return;\n }\n\n openAndFocus(url);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Orientation.js","sourceRoot":"","sources":["../../../src/components-react/common/Orientation.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQhE;;GAEG;AACH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,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 { Orientation as _Orientation } from \"@itwin/core-react\";\n\n/* eslint-disable
|
|
1
|
+
{"version":3,"file":"Orientation.js","sourceRoot":"","sources":["../../../src/components-react/common/Orientation.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQhE;;GAEG;AACH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,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 { Orientation as _Orientation } from \"@itwin/core-react\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Enumeration of orientation.\n * @public\n */\nexport type Orientation = _Orientation;\n/** Enumeration of orientation.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const Orientation = _Orientation;\n"]}
|
|
@@ -9,6 +9,6 @@ import { TimeFormat as _TimeFormat } from "@itwin/core-react";
|
|
|
9
9
|
/** Enumeration of time formats.
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare, @typescript-eslint/no-deprecated
|
|
13
13
|
export const TimeFormat = _TimeFormat;
|
|
14
14
|
//# sourceMappingURL=TimeFormat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeFormat.js","sourceRoot":"","sources":["../../../src/components-react/common/TimeFormat.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAO9D;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"TimeFormat.js","sourceRoot":"","sources":["../../../src/components-react/common/TimeFormat.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAO9D;;GAEG;AACH,6FAA6F;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,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 { TimeFormat as _TimeFormat } from \"@itwin/core-react\";\n\n/** Enumeration of time formats.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type TimeFormat = _TimeFormat;\n/** Enumeration of time formats.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare, @typescript-eslint/no-deprecated\nexport const TimeFormat = _TimeFormat;\n"]}
|
|
@@ -11,7 +11,7 @@ export function createContextWithMandatoryProvider(contextName) {
|
|
|
11
11
|
function useContextWithoutDefaultValue(ConsumingComponent) {
|
|
12
12
|
const value = React.useContext(context);
|
|
13
13
|
if (value === undefined) {
|
|
14
|
-
// eslint-disable-next-line
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
15
15
|
throw new UiError(UiComponents.loggerCategory("createContextWithMandatoryProvider"), `'${ConsumingComponent.displayName}' expects to be wrapped by a '${contextName}' provider.`);
|
|
16
16
|
}
|
|
17
17
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseContextWithMandatoryProvider.js","sourceRoot":"","sources":["../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,gBAAgB;AAChB,MAAM,UAAU,kCAAkC,CAChD,WAAmB;IAMnB,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAI,SAAqB,CAAC,CAAC;IAC9D,SAAS,6BAA6B,CACpC,kBAA0C;QAE1C,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,
|
|
1
|
+
{"version":3,"file":"UseContextWithMandatoryProvider.js","sourceRoot":"","sources":["../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,gBAAgB;AAChB,MAAM,UAAU,kCAAkC,CAChD,WAAmB;IAMnB,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAI,SAAqB,CAAC,CAAC;IAC9D,SAAS,6BAA6B,CACpC,kBAA0C;QAE1C,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,4DAA4D;YAC5D,MAAM,IAAI,OAAO,CACf,YAAY,CAAC,cAAc,CAAC,oCAAoC,CAAC,EACjE,IAAI,kBAAkB,CAAC,WAAW,iCAAiC,WAAW,aAAa,CAC5F,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC;AAC7E,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 *--------------------------------------------------------------------------------------------*/\nimport React from \"react\";\nimport { UiError } from \"@itwin/appui-abstract\";\nimport { UiComponents } from \"../UiComponents.js\";\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 if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n throw new UiError(\n UiComponents.loggerCategory(\"createContextWithMandatoryProvider\"),\n `'${ConsumingComponent.displayName}' 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":"DateTimeTypeConverter.d.ts","sourceRoot":"","sources":["../../../src/components-react/converters/DateTimeTypeConverter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI1E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"DateTimeTypeConverter.d.ts","sourceRoot":"","sources":["../../../src/components-react/converters/DateTimeTypeConverter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EA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Y,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,OAAO;IAI1D,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO;IAIrC,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO;IAI9C,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO;IAIxC,sBAAsB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO;CAGzD;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,yBAAyB;IACnE,SAAS,CAAC,aAAa,IAAI,UAAU;CAGtC;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,yBAAyB;IAClE,SAAS,CAAC,aAAa,IAAI,UAAU;CAGtC"}
|
|
@@ -12,7 +12,6 @@ import { adjustDateToTimezone } from "../common/DateUtils.js";
|
|
|
12
12
|
import { UiComponents } from "../UiComponents.js";
|
|
13
13
|
import { TypeConverter } from "./TypeConverter.js";
|
|
14
14
|
import { TimeFormat } from "../common/TimeFormat.js";
|
|
15
|
-
// cSpell:ignore datepicker valuetypes
|
|
16
15
|
/**
|
|
17
16
|
* DateTime Type Converter.
|
|
18
17
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeTypeConverter.js","sourceRoot":"","sources":["../../../src/components-react/converters/DateTimeTypeConverter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE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UAAU,CAAC,CAAO,EAAE,CAAO;QAChC,OAAO,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAEM,mBAAmB,CAAC,CAAO,EAAE,CAAO;QACzC,OAAO,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,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;QACrB,OAAO,UAAU,CAAC,KAAK,CAAC;IAC1B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,yBAAyB;IACxD,aAAa;QACrB,OAAO,UAAU,CAAC,IAAI,CAAC;IACzB,CAAC;CACF","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 TypeConverters\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Primitives } from \"@itwin/appui-abstract\";\nimport { AlternateDateFormats, TimeDisplay } from \"@itwin/appui-abstract\";\nimport { formatInputDate } from \"../datepicker/DateField.js\";\nimport { adjustDateToTimezone } from \"../common/DateUtils.js\";\nimport { UiComponents } from \"../UiComponents.js\";\nimport type { LessGreaterOperatorProcessor } from \"./TypeConverter.js\";\nimport { TypeConverter } from \"./TypeConverter.js\";\nimport type { ConvertedPrimitives } from \"./valuetypes/ConvertedTypes.js\";\nimport { TimeFormat } from \"../common/TimeFormat.js\";\n\n// cSpell:ignore datepicker valuetypes\n\n/**\n * DateTime Type Converter.\n * @public\n */\nexport abstract class DateTimeTypeConverterBase\n extends TypeConverter\n implements LessGreaterOperatorProcessor\n{\n public override convertToString(value?: Primitives.Value) {\n if (value === undefined) return \"\";\n\n if (typeof value === \"string\") value = new Date(value);\n\n if (value instanceof Date) {\n switch (this.getTimeFormat()) {\n case TimeFormat.Short:\n return value.toLocaleDateString();\n case TimeFormat.Long:\n return value.toLocaleString();\n }\n return value.toISOString();\n }\n\n return value.toString(); // eslint-disable-line @typescript-eslint/no-base-to-string\n }\n\n public static isValidTimeDisplay(type: TimeDisplay): boolean {\n return Object.keys(TimeDisplay).some(\n (key) => (TimeDisplay as any)[key] === type\n );\n }\n\n public static isAlternateDateFormats(type: AlternateDateFormats): boolean {\n return Object.keys(AlternateDateFormats).some(\n (key) => (AlternateDateFormats as any)[key] === type\n );\n }\n\n // supported options:\n // timeDisplay?: TimeDisplay\n // alternateDateFormat?: AlternateDateFormats\n public override convertToStringWithOptions(\n value?: Primitives.Value,\n options?: { [key: string]: any }\n ): string | Promise<string> {\n if (value === undefined) return \"\";\n\n if (options) {\n let timeDisplay: TimeDisplay | undefined =\n this.getTimeFormat() === TimeFormat.Long\n ? TimeDisplay.H12MC\n : undefined;\n let alternateDateFormat = AlternateDateFormats.None;\n\n if (\n \"alternateDateFormat\" in options &&\n DateTimeTypeConverterBase.isAlternateDateFormats(\n options.alternateDateFormat\n )\n ) {\n alternateDateFormat = options.alternateDateFormat;\n }\n\n if (this.getTimeFormat() === TimeFormat.Long) {\n if (\"timeDisplay\" in options) {\n if (alternateDateFormat) {\n Logger.logInfo(\n UiComponents.loggerCategory(\"DateTimeTypeConverterBase\"),\n `Invalid specification of timeDisplay with alternateDateFormat specification`\n );\n } else {\n if (\n DateTimeTypeConverterBase.isValidTimeDisplay(options.timeDisplay)\n )\n timeDisplay = options.timeDisplay;\n }\n }\n }\n\n if (typeof value === \"string\") {\n value = new Date(value); // this value will be based on local time zone\n if (value instanceof Date && alternateDateFormat) {\n // alternateDateFormat displays UTC time, so assume string is specifying UTC Date and Time\n value = adjustDateToTimezone(value, value.getTimezoneOffset() * -1);\n }\n }\n\n if (value instanceof Date) {\n // Ensure if alternateDateFormat is specified make sure it matches proper Long/Short format.\n if (this.getTimeFormat() === TimeFormat.Long) {\n if (alternateDateFormat === AlternateDateFormats.IsoShort)\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\n if (alternateDateFormat === AlternateDateFormats.UtcShort)\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay)\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\n } else {\n // short time format\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\n alternateDateFormat = AlternateDateFormats.IsoShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\n alternateDateFormat = AlternateDateFormats.UtcShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\n }\n\n const formattedDateTime = formatInputDate(\n value,\n timeDisplay,\n undefined,\n alternateDateFormat\n );\n if (formattedDateTime) return formattedDateTime;\n }\n }\n\n return this.convertToString(value);\n }\n\n /** Default implementation just calls convertFromString with no options */\n public override convertFromStringWithOptions(\n value: string,\n options?: { [key: string]: any }\n ):\n | ConvertedPrimitives.Value\n | undefined\n | Promise<ConvertedPrimitives.Value | undefined> {\n if (!value) return undefined;\n\n if (options) {\n let alternateDateFormat = AlternateDateFormats.None;\n\n if (\n \"alternateDateFormat\" in options &&\n DateTimeTypeConverterBase.isAlternateDateFormats(\n options.alternateDateFormat\n )\n ) {\n alternateDateFormat = options.alternateDateFormat;\n }\n\n let date = new Date(value); // this value will be based on local time zone\n if (date instanceof Date && alternateDateFormat) {\n // alternateDateFormat displays UTC time, so assume string is specifying UTC Date and Time\n date = adjustDateToTimezone(date, date.getTimezoneOffset() * -1);\n }\n }\n\n return this.convertFromString(value);\n }\n\n private isDateValid(date: Date) {\n return date instanceof Date && !isNaN(+date);\n }\n\n public override convertFromString(value: string) {\n if (!value) return undefined;\n\n const dateValue = new Date(value);\n\n if (!this.isDateValid(dateValue)) return undefined;\n\n return dateValue;\n }\n\n protected abstract getTimeFormat(): TimeFormat;\n\n public override get isLessGreaterType(): boolean {\n return true;\n }\n\n public sortCompare(\n valueA: Date,\n valueB: Date,\n _ignoreCase?: boolean\n ): number {\n return valueA.valueOf() - valueB.valueOf();\n }\n\n public override isEqualTo(valueA: Date, valueB: Date): boolean {\n return valueA.valueOf() === valueB.valueOf();\n }\n\n public override isNotEqualTo(valueA: Date, valueB: Date): boolean {\n return valueA.valueOf() !== valueB.valueOf();\n }\n\n public isLessThan(a: Date, b: Date): boolean {\n return a.valueOf() < b.valueOf();\n }\n\n public isLessThanOrEqualTo(a: Date, b: Date): boolean {\n return a.valueOf() <= b.valueOf();\n }\n\n public isGreaterThan(a: Date, b: Date): boolean {\n return a.valueOf() > b.valueOf();\n }\n\n public isGreaterThanOrEqualTo(a: Date, b: Date): boolean {\n return a.valueOf() >= b.valueOf();\n }\n}\n\n/**\n * Short Date Type Converter.\n * @public\n */\nexport class ShortDateTypeConverter extends DateTimeTypeConverterBase {\n protected getTimeFormat(): TimeFormat {\n return TimeFormat.Short;\n }\n}\n\n/**\n * Date Time Type Converter.\n * @public\n */\nexport class DateTimeTypeConverter extends DateTimeTypeConverterBase {\n protected getTimeFormat(): TimeFormat {\n return TimeFormat.Long;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DateTimeTypeConverter.js","sourceRoot":"","sources":["../../../src/components-react/converters/DateTimeTypeConverter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE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AAE,MAAY;QACrD,OAAO,MAAM,CAAC,OAAO,EAAE,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;IAC/C,CAAC;IAEM,UAAU,CAAC,CAAO,EAAE,CAAO;QAChC,OAAO,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAEM,mBAAmB,CAAC,CAAO,EAAE,CAAO;QACzC,OAAO,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,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;QACrB,OAAO,UAAU,CAAC,KAAK,CAAC;IAC1B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,yBAAyB;IACxD,aAAa;QACrB,OAAO,UAAU,CAAC,IAAI,CAAC;IACzB,CAAC;CACF","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 TypeConverters\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Primitives } from \"@itwin/appui-abstract\";\nimport { AlternateDateFormats, TimeDisplay } from \"@itwin/appui-abstract\";\nimport { formatInputDate } from \"../datepicker/DateField.js\";\nimport { adjustDateToTimezone } from \"../common/DateUtils.js\";\nimport { UiComponents } from \"../UiComponents.js\";\nimport type { LessGreaterOperatorProcessor } from \"./TypeConverter.js\";\nimport { TypeConverter } from \"./TypeConverter.js\";\nimport type { ConvertedPrimitives } from \"./valuetypes/ConvertedTypes.js\";\nimport { TimeFormat } from \"../common/TimeFormat.js\";\n\n/**\n * DateTime Type Converter.\n * @public\n */\nexport abstract class DateTimeTypeConverterBase\n extends TypeConverter\n implements LessGreaterOperatorProcessor\n{\n public override convertToString(value?: Primitives.Value) {\n if (value === undefined) return \"\";\n\n if (typeof value === \"string\") value = new Date(value);\n\n if (value instanceof Date) {\n switch (this.getTimeFormat()) {\n case TimeFormat.Short:\n return value.toLocaleDateString();\n case TimeFormat.Long:\n return value.toLocaleString();\n }\n return value.toISOString();\n }\n\n return value.toString(); // eslint-disable-line @typescript-eslint/no-base-to-string\n }\n\n public static isValidTimeDisplay(type: TimeDisplay): boolean {\n return Object.keys(TimeDisplay).some(\n (key) => (TimeDisplay as any)[key] === type\n );\n }\n\n public static isAlternateDateFormats(type: AlternateDateFormats): boolean {\n return Object.keys(AlternateDateFormats).some(\n (key) => (AlternateDateFormats as any)[key] === type\n );\n }\n\n // supported options:\n // timeDisplay?: TimeDisplay\n // alternateDateFormat?: AlternateDateFormats\n public override convertToStringWithOptions(\n value?: Primitives.Value,\n options?: { [key: string]: any }\n ): string | Promise<string> {\n if (value === undefined) return \"\";\n\n if (options) {\n let timeDisplay: TimeDisplay | undefined =\n this.getTimeFormat() === TimeFormat.Long\n ? TimeDisplay.H12MC\n : undefined;\n let alternateDateFormat = AlternateDateFormats.None;\n\n if (\n \"alternateDateFormat\" in options &&\n DateTimeTypeConverterBase.isAlternateDateFormats(\n options.alternateDateFormat\n )\n ) {\n alternateDateFormat = options.alternateDateFormat;\n }\n\n if (this.getTimeFormat() === TimeFormat.Long) {\n if (\"timeDisplay\" in options) {\n if (alternateDateFormat) {\n Logger.logInfo(\n UiComponents.loggerCategory(\"DateTimeTypeConverterBase\"),\n `Invalid specification of timeDisplay with alternateDateFormat specification`\n );\n } else {\n if (\n DateTimeTypeConverterBase.isValidTimeDisplay(options.timeDisplay)\n )\n timeDisplay = options.timeDisplay;\n }\n }\n }\n\n if (typeof value === \"string\") {\n value = new Date(value); // this value will be based on local time zone\n if (value instanceof Date && alternateDateFormat) {\n // alternateDateFormat displays UTC time, so assume string is specifying UTC Date and Time\n value = adjustDateToTimezone(value, value.getTimezoneOffset() * -1);\n }\n }\n\n if (value instanceof Date) {\n // Ensure if alternateDateFormat is specified make sure it matches proper Long/Short format.\n if (this.getTimeFormat() === TimeFormat.Long) {\n if (alternateDateFormat === AlternateDateFormats.IsoShort)\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\n if (alternateDateFormat === AlternateDateFormats.UtcShort)\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay)\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\n } else {\n // short time format\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\n alternateDateFormat = AlternateDateFormats.IsoShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\n alternateDateFormat = AlternateDateFormats.UtcShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\n }\n\n const formattedDateTime = formatInputDate(\n value,\n timeDisplay,\n undefined,\n alternateDateFormat\n );\n if (formattedDateTime) return formattedDateTime;\n }\n }\n\n return this.convertToString(value);\n }\n\n /** Default implementation just calls convertFromString with no options */\n public override convertFromStringWithOptions(\n value: string,\n options?: { [key: string]: any }\n ):\n | ConvertedPrimitives.Value\n | undefined\n | Promise<ConvertedPrimitives.Value | undefined> {\n if (!value) return undefined;\n\n if (options) {\n let alternateDateFormat = AlternateDateFormats.None;\n\n if (\n \"alternateDateFormat\" in options &&\n DateTimeTypeConverterBase.isAlternateDateFormats(\n options.alternateDateFormat\n )\n ) {\n alternateDateFormat = options.alternateDateFormat;\n }\n\n let date = new Date(value); // this value will be based on local time zone\n if (date instanceof Date && alternateDateFormat) {\n // alternateDateFormat displays UTC time, so assume string is specifying UTC Date and Time\n date = adjustDateToTimezone(date, date.getTimezoneOffset() * -1);\n }\n }\n\n return this.convertFromString(value);\n }\n\n private isDateValid(date: Date) {\n return date instanceof Date && !isNaN(+date);\n }\n\n public override convertFromString(value: string) {\n if (!value) return undefined;\n\n const dateValue = new Date(value);\n\n if (!this.isDateValid(dateValue)) return undefined;\n\n return dateValue;\n }\n\n protected abstract getTimeFormat(): TimeFormat;\n\n public override get isLessGreaterType(): boolean {\n return true;\n }\n\n public sortCompare(\n valueA: Date,\n valueB: Date,\n _ignoreCase?: boolean\n ): number {\n return valueA.valueOf() - valueB.valueOf();\n }\n\n public override isEqualTo(valueA: Date, valueB: Date): boolean {\n return valueA.valueOf() === valueB.valueOf();\n }\n\n public override isNotEqualTo(valueA: Date, valueB: Date): boolean {\n return valueA.valueOf() !== valueB.valueOf();\n }\n\n public isLessThan(a: Date, b: Date): boolean {\n return a.valueOf() < b.valueOf();\n }\n\n public isLessThanOrEqualTo(a: Date, b: Date): boolean {\n return a.valueOf() <= b.valueOf();\n }\n\n public isGreaterThan(a: Date, b: Date): boolean {\n return a.valueOf() > b.valueOf();\n }\n\n public isGreaterThanOrEqualTo(a: Date, b: Date): boolean {\n return a.valueOf() >= b.valueOf();\n }\n}\n\n/**\n * Short Date Type Converter.\n * @public\n */\nexport class ShortDateTypeConverter extends DateTimeTypeConverterBase {\n protected getTimeFormat(): TimeFormat {\n return TimeFormat.Short;\n }\n}\n\n/**\n * Date Time Type Converter.\n * @public\n */\nexport class DateTimeTypeConverter extends DateTimeTypeConverterBase {\n protected getTimeFormat(): TimeFormat {\n return TimeFormat.Long;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PointTypeConverter.d.ts","sourceRoot":"","sources":["../../../src/components-react/converters/PointTypeConverter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;A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AC,KAAK,GACvB,mBAAmB,CAAC,OAAO,GAAG,SAAS;CAQ3C;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,sBAAsB;gBAC3C,sBAAsB,CAAC,EAAE,MAAM;IAIlD,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,GAAG,MAAM,GAAG,SAAS;IAYtE,SAAS,CAAC,cAAc,CACtB,MAAM,EAAE,UAAU,CAAC,KAAK,GACvB,mBAAmB,CAAC,OAAO,GAAG,SAAS;CAc3C"}
|
|
@@ -9,7 +9,6 @@ import { StandardTypeNames } from "@itwin/appui-abstract";
|
|
|
9
9
|
import { TypeConverter } from "./TypeConverter.js";
|
|
10
10
|
import { TypeConverterManager } from "./TypeConverterManager.js";
|
|
11
11
|
import { isPromiseLike } from "../common/UseAsyncValue.js";
|
|
12
|
-
// cSpell:ignore valuetypes
|
|
13
12
|
/**
|
|
14
13
|
* Point type converter.
|
|
15
14
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PointTypeConverter.js","sourceRoot":"","sources":["../../../src/components-react/converters/PointTypeConverter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D
|
|
1
|
+
{"version":3,"file":"PointTypeConverter.js","sourceRoot":"","sources":["../../../src/components-react/converters/PointTypeConverter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,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OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,IACE,MAAM,CAAC,MAAM,KAAK,CAAC;gBACnB,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACjB,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACjB,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAEjB,OAAO,SAAS,CAAC;YACnB,OAAO,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,CAAC;QACD,MAAM,CAAC,GAAI,MAAc,CAAC,CAAC,CAAC;QAC5B,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACrC,CAAC;CACF","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 TypeConverters\n */\n\nimport type { Primitives } from \"@itwin/appui-abstract\";\nimport { StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { TypeConverter } from \"./TypeConverter.js\";\nimport { TypeConverterManager } from \"./TypeConverterManager.js\";\nimport type { ConvertedPrimitives } from \"./valuetypes/ConvertedTypes.js\";\nimport { isPromiseLike } from \"../common/UseAsyncValue.js\";\n\n/**\n * Point type converter.\n * @public\n */\nexport abstract class BasePointTypeConverter extends TypeConverter {\n public componentConverterName: string;\n\n public constructor(\n componentConverterName: string = StandardTypeNames.Double\n ) {\n super();\n this.componentConverterName = componentConverterName;\n }\n\n private formatValue(value: number | string): string | Promise<string> {\n if (typeof value === \"string\") value = parseFloat(value);\n return TypeConverterManager.getConverter(\n this.componentConverterName\n ).convertToString(value);\n }\n\n public override convertToString(\n value?: Primitives.Point\n ): string | Promise<string> {\n if (!value) return \"\";\n\n let components = new Array<string | Promise<string>>();\n if (Array.isArray(value)) {\n if (value.length === 0) return \"\";\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n components = (value as Array<string | number>).map(\n (c): string | Promise<string> => this.formatValue(c)\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n components = [this.formatValue(value.x), this.formatValue(value.y)];\n if (undefined !== (value as any).z)\n components.push(this.formatValue((value as any).z));\n }\n const hasAsyncComponents = components.some(isPromiseLike);\n if (hasAsyncComponents) {\n return Promise.all(\n components.map(async (c) => (isPromiseLike(c) ? c : Promise.resolve(c)))\n ).then((c) => c.join(\", \"));\n }\n return components.join(\", \");\n }\n\n public override convertFromString(value: string) {\n return this.constructPoint(value.split(\",\"));\n }\n protected abstract constructPoint(\n _values: Primitives.Point\n ): ConvertedPrimitives.Point | undefined;\n\n protected abstract getVectorLength(\n point: Primitives.Point\n ): number | undefined;\n\n public sortCompare(\n a: Primitives.Point,\n b: Primitives.Point,\n _ignoreCase?: boolean\n ): number {\n const aLength = this.getVectorLength(a);\n const bLength = this.getVectorLength(b);\n\n if (aLength === bLength) return 0;\n if (aLength === undefined) return -1;\n if (bLength === undefined) return 1;\n\n return aLength - bLength;\n }\n}\n\n/**\n * Point2d type converter.\n * @public\n */\nexport class Point2dTypeConverter extends BasePointTypeConverter {\n public constructor(componentConverterName?: string) {\n super(componentConverterName);\n }\n\n protected getVectorLength(point: Primitives.Point): number | undefined {\n const derivedPoint = this.constructPoint(point);\n\n if (derivedPoint === undefined) return undefined;\n\n return Math.sqrt(Math.pow(derivedPoint.x, 2) + Math.pow(derivedPoint.y, 2));\n }\n\n protected constructPoint(\n values: Primitives.Point\n ): ConvertedPrimitives.Point2d | undefined {\n if (Array.isArray(values)) {\n if (values.length !== 2 || isNaN(+values[0]) || isNaN(+values[1]))\n return undefined;\n return { x: +values[0], y: +values[1] };\n }\n return values;\n }\n}\n\n/**\n * Point3d type converter.\n * @public\n */\nexport class Point3dTypeConverter extends BasePointTypeConverter {\n public constructor(componentConverterName?: string) {\n super(componentConverterName);\n }\n\n protected getVectorLength(point: Primitives.Point): number | undefined {\n const derivedPoint = this.constructPoint(point);\n\n if (derivedPoint === undefined) return undefined;\n\n return Math.sqrt(\n Math.pow(derivedPoint.x, 2) +\n Math.pow(derivedPoint.y, 2) +\n Math.pow(derivedPoint.z, 2)\n );\n }\n\n protected constructPoint(\n values: Primitives.Point\n ): ConvertedPrimitives.Point3d | undefined {\n if (Array.isArray(values)) {\n if (\n values.length !== 3 ||\n isNaN(+values[0]) ||\n isNaN(+values[1]) ||\n isNaN(+values[2])\n )\n return undefined;\n return { x: +values[0], y: +values[1], z: +values[2] };\n }\n const z = (values as any).z;\n return { ...values, z: z ? z : 0 };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeConverter.d.ts","sourceRoot":"","sources":["../../../src/components-react/converters/TypeConverter.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"TypeConverter.d.ts","sourceRoot":"","sources":["../../../src/components-react/converters/TypeConverter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EACV,UAAU,EAEV,mBAAmB,EACnB,cAAc,EACd,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,WAAW,CACT,MAAM,EAAE,UAAU,CAAC,KAAK,EACxB,MAAM,EAAE,UAAU,CAAC,KAAK,EACxB,UAAU,CAAC,EAAE,OAAO,GACnB,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,SAAS,CAAC,CAAC,EAAE,UAAU,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