@rio-cloud/rio-uikit 0.16.1 → 0.16.2-beta.11
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/.DS_Store +0 -0
- package/ColorScheme.d.ts +4 -0
- package/ColorScheme.js +2 -0
- package/Colors.js +1 -1
- package/TruckLayer.js +1 -1
- package/components/.DS_Store +0 -0
- package/components/applicationHeader/AppMenu.js +6 -3
- package/components/applicationHeader/AppMenuDropdown.js +6 -2
- package/components/applicationHeader/ApplicationHeader.js +10 -5
- package/components/applicationHeader/MobileAppMenu.js +8 -4
- package/components/assetTree/Tree.js +1 -1
- package/components/autosuggest/AutoSuggest.js +2 -2
- package/components/charts/chartHelper.js +1 -1
- package/components/clearableInput/ClearableInput.js +2 -1
- package/components/datepicker/DatePicker.js +8 -4
- package/components/filepicker/FilePicker.js +5 -4
- package/components/map/.DS_Store +0 -0
- package/components/map/assets/icon_map_settings_maptype_night_active.svg +12 -0
- package/components/map/assets/icon_map_settings_maptype_night_inactive.svg +12 -0
- package/components/map/components/.DS_Store +0 -0
- package/components/map/components/Map.js +167 -140
- package/components/map/components/constants.js +1 -0
- package/components/map/components/features/Route.js +6 -7
- package/components/map/components/features/basics/Polyline.js +10 -5
- package/components/map/components/features/layers/RoadRestrictionLayer.js +27 -0
- package/components/map/components/features/layers/TrafficLayer.js +19 -5
- package/components/map/components/features/layers/baselayers/DefaultRasterLayer.js +19 -0
- package/components/map/components/features/layers/baselayers/DefaultVectorLayer.js +15 -0
- package/components/map/components/features/layers/baselayers/FleetStyleLayer.js +13 -17
- package/components/map/components/features/layers/baselayers/NightLayer.js +17 -0
- package/components/map/components/features/layers/baselayers/SatelliteLayer.js +13 -17
- package/components/map/components/features/layers/baselayers/TerrainLayer.js +13 -17
- package/components/map/components/features/layers/baselayers/useBaseLayer.js +53 -0
- package/components/map/components/features/settings/builtinSettings/MapClusterSettings.js +1 -1
- package/components/map/components/features/settings/builtinSettings/MapTypeSettings.js +9 -3
- package/components/map/components/mapUtils.js +44 -8
- package/components/map/icons/MapIcon.js +64 -0
- package/components/mapMarker/ClusterMapMarker.js +2 -2
- package/components/mapMarker/SingleMapMarker.js +8 -2
- package/components/numberControl/NumberControl.js +43 -14
- package/components/numberInput/NumberInput.js +75 -55
- package/components/sidebars/Sidebar.js +2 -2
- package/hooks/useDarkMode.js +30 -0
- package/hooks/useElementSize.js +1 -1
- package/hooks/useFullscreen.js +37 -41
- package/hooks/useHereMap.ts +23 -0
- package/hooks/useMutationObserver.js +38 -0
- package/hooks/useScripts.ts +52 -0
- package/hooks/useScrollPosition.js +72 -0
- package/index.js +6 -1
- package/lib/.DS_Store +0 -0
- package/lib/es/.DS_Store +0 -0
- package/lib/es/ColorScheme.d.ts +4 -0
- package/lib/es/ColorScheme.js +18 -0
- package/lib/es/Colors.js +1 -1
- package/lib/es/TruckLayer.js +2 -2
- package/lib/es/components/.DS_Store +0 -0
- package/lib/es/components/applicationHeader/AppMenu.js +6 -3
- package/lib/es/components/applicationHeader/AppMenuDropdown.js +6 -2
- package/lib/es/components/applicationHeader/ApplicationHeader.js +10 -5
- package/lib/es/components/applicationHeader/MobileAppMenu.js +8 -4
- package/lib/es/components/assetTree/Tree.js +1 -1
- package/lib/es/components/autosuggest/AutoSuggest.js +2 -2
- package/lib/es/components/charts/chartHelper.js +1 -1
- package/lib/es/components/clearableInput/ClearableInput.js +2 -1
- package/lib/es/components/datepicker/DatePicker.js +7 -3
- package/lib/es/components/filepicker/FilePicker.js +5 -4
- package/lib/es/components/map/assets/icon_map_settings_maptype_night_active.svg +12 -0
- package/lib/es/components/map/assets/icon_map_settings_maptype_night_inactive.svg +12 -0
- package/lib/es/components/map/components/Map.js +165 -135
- package/lib/es/components/map/components/constants.js +3 -1
- package/lib/es/components/map/components/features/Route.js +6 -7
- package/lib/es/components/map/components/features/basics/Polyline.js +10 -7
- package/lib/es/components/map/components/features/layers/RoadRestrictionLayer.js +35 -0
- package/lib/es/components/map/components/features/layers/TrafficLayer.js +18 -5
- package/lib/es/components/map/components/features/layers/baselayers/DefaultRasterLayer.js +25 -0
- package/lib/es/components/map/components/features/layers/baselayers/DefaultVectorLayer.js +22 -0
- package/lib/es/components/map/components/features/layers/baselayers/FleetStyleLayer.js +12 -17
- package/lib/es/components/map/components/features/layers/baselayers/NightLayer.js +23 -0
- package/lib/es/components/map/components/features/layers/baselayers/SatelliteLayer.js +12 -17
- package/lib/es/components/map/components/features/layers/baselayers/TerrainLayer.js +12 -17
- package/lib/es/components/map/components/features/layers/baselayers/useBaseLayer.js +61 -0
- package/lib/es/components/map/components/features/settings/builtinSettings/MapClusterSettings.js +1 -1
- package/lib/es/components/map/components/features/settings/builtinSettings/MapTypeSettings.js +7 -1
- package/lib/es/components/map/components/mapUtils.js +44 -10
- package/lib/es/components/map/icons/MapIcon.js +67 -1
- package/lib/es/components/mapMarker/ClusterMapMarker.js +2 -2
- package/lib/es/components/mapMarker/SingleMapMarker.js +8 -2
- package/lib/es/components/numberControl/NumberControl.js +42 -13
- package/lib/es/components/numberInput/NumberInput.js +75 -55
- package/lib/es/components/sidebars/Sidebar.js +2 -2
- package/lib/es/hooks/useDarkMode.js +38 -0
- package/lib/es/hooks/useElementSize.js +1 -1
- package/lib/es/hooks/useFullscreen.js +37 -41
- package/lib/es/hooks/useHereMap.ts +23 -0
- package/lib/es/hooks/useMutationObserver.js +46 -0
- package/lib/es/hooks/useScripts.ts +52 -0
- package/lib/es/hooks/useScrollPosition.js +80 -0
- package/lib/es/index.js +40 -1
- package/lib/es/mapIndex.js +2 -2
- package/lib/es/styles/.DS_Store +0 -0
- package/lib/es/styles/components/Activity.less +9 -10
- package/lib/es/styles/components/ApplicationHeader.less +24 -29
- package/lib/es/styles/components/ApplicationLayout.less +7 -7
- package/lib/es/styles/components/AssetTree.less +30 -28
- package/lib/es/styles/components/AutoSuggest.less +2 -2
- package/lib/es/styles/components/BottomSheet.less +1 -2
- package/lib/es/styles/components/Carousel.less +13 -9
- package/lib/es/styles/components/Checkbox.less +15 -16
- package/lib/es/styles/components/ClearableInput.less +3 -3
- package/lib/es/styles/components/Counter.less +12 -12
- package/lib/es/styles/components/DataTabs.less +2 -2
- package/lib/es/styles/components/DatePicker.less +27 -27
- package/lib/es/styles/components/Dialog.less +15 -11
- package/lib/es/styles/components/Dropdown.less +11 -11
- package/lib/es/styles/components/Expander.less +7 -7
- package/lib/es/styles/components/ListMenu.less +8 -8
- package/lib/es/styles/components/MapHere.less +3 -2
- package/lib/es/styles/components/MapMarker.less +16 -17
- package/lib/es/styles/components/MapSettings.less +5 -5
- package/lib/es/styles/components/NoData.less +1 -1
- package/lib/es/styles/components/Notification.less +12 -12
- package/lib/es/styles/components/RadioButton.less +11 -12
- package/lib/es/styles/components/Resizer.less +1 -1
- package/lib/es/styles/components/Select.less +16 -26
- package/lib/es/styles/components/Sidebar.less +29 -21
- package/lib/es/styles/components/Slider.less +18 -18
- package/lib/es/styles/components/Spinner.less +6 -6
- package/lib/es/styles/components/StatsWidget.less +5 -5
- package/lib/es/styles/components/SteppedProgressBar.less +32 -29
- package/lib/es/styles/components/SupportMarker.less +1 -1
- package/lib/es/styles/components/Switch.less +8 -8
- package/lib/es/styles/components/TableSettingsDialog.less +7 -7
- package/lib/es/styles/components/TableToolbar.less +1 -1
- package/lib/es/styles/components/Tag.less +10 -10
- package/lib/es/styles/components/Timeline.less +3 -3
- package/lib/es/styles/components/Tooltip.less +10 -10
- package/lib/es/styles/design/badges.less +10 -10
- package/lib/es/styles/design/border.less +1 -1
- package/lib/es/styles/design/breadcrumbs.less +2 -2
- package/lib/es/styles/design/button-groups.less +25 -1
- package/lib/es/styles/design/buttons.less +53 -109
- package/lib/es/styles/design/callouts.less +3 -3
- package/lib/es/styles/design/code.less +4 -6
- package/lib/es/styles/design/colors.less +20 -20
- package/lib/es/styles/design/form-input-groups.less +4 -4
- package/lib/es/styles/design/form-inputs.less +33 -31
- package/lib/es/styles/design/images.less +2 -2
- package/lib/es/styles/design/labels.less +11 -11
- package/lib/es/styles/design/list-group.less +14 -12
- package/lib/es/styles/design/navs.less +27 -27
- package/lib/es/styles/design/normalize.less +0 -9
- package/lib/es/styles/design/pagination.less +10 -10
- package/lib/es/styles/design/panels.less +10 -10
- package/lib/es/styles/design/popovers.less +8 -8
- package/lib/es/styles/design/progress-bars.less +8 -8
- package/lib/es/styles/design/shadows.less +14 -7
- package/lib/es/styles/design/tables.less +68 -106
- package/lib/es/styles/design/text.less +5 -19
- package/lib/es/styles/design/theme.less +10 -10
- package/lib/es/styles/design/thumbnails.less +2 -2
- package/lib/es/styles/design/type.less +4 -4
- package/lib/es/styles/design/wells.less +1 -1
- package/lib/es/styles/mapping/color-map.less +76 -75
- package/lib/es/styles/mixins/_imports.less +14 -0
- package/lib/es/styles/mixins/buttons.less +24 -56
- package/lib/es/styles/mixins/forms.less +19 -55
- package/lib/es/styles/mixins/hsl.less +19 -0
- package/lib/es/styles/mixins/panels.less +2 -2
- package/lib/es/styles/print/print.less +7 -7
- package/lib/es/styles/rio-uikit-core.less +2 -2
- package/lib/es/styles/rio-uikit-print-utilities.less +2 -2
- package/lib/es/styles/rio-uikit-responsive-utilities.less +2 -2
- package/lib/es/styles/variables/_index.less +196 -0
- package/lib/es/styles/variables/colors.json +67 -0
- package/lib/es/styles/variables/concated_css_variables.less +66 -0
- package/lib/es/styles/variables/dark_colors.less +88 -0
- package/lib/es/styles/variables/dark_css_variables.less +28 -0
- package/lib/es/styles/variables/dark_css_variables_map.less +96 -0
- package/lib/es/styles/variables/light_colors.less +92 -0
- package/lib/es/styles/variables/light_css_variables.less +17 -0
- package/lib/es/styles/variables/light_css_variables_map.less +100 -0
- package/lib/es/styles/variables/screens.less +7 -0
- package/lib/es/styles/variables/text.less +23 -0
- package/lib/es/themes/.DS_Store +0 -0
- package/lib/es/themes/BuyButton/styles/rio-buyButton.less +13 -8
- package/lib/es/themes/MAN/styles/man-uikit.less +3 -0
- package/lib/es/themes/SCANIA/styles/scania-uikit.less +3 -0
- package/lib/es/themes/Volkswagen/styles/vw-uikit.less +21 -30
- package/lib/es/themes/Website/styles/rio-website.less +154 -124
- package/lib/es/themes/Xmas/styles/rio-xmas.less +59 -29
- package/lib/es/types.ts +30 -5
- package/lib/es/useDarkMode.d.ts +4 -0
- package/lib/es/useDarkMode.js +13 -0
- package/lib/es/useMutationObserver.d.ts +4 -0
- package/lib/es/useMutationObserver.js +13 -0
- package/lib/es/useScrollPosition.d.ts +4 -0
- package/lib/es/useScrollPosition.js +13 -0
- package/lib/es/utils/colorScheme.js +69 -0
- package/lib/es/utils/init.js +34 -34
- package/lib/es/version.json +1 -1
- package/mapIndex.js +1 -1
- package/package.json +34 -33
- package/styles/.DS_Store +0 -0
- package/styles/components/Activity.less +9 -10
- package/styles/components/ApplicationHeader.less +24 -29
- package/styles/components/ApplicationLayout.less +7 -7
- package/styles/components/AssetTree.less +30 -28
- package/styles/components/AutoSuggest.less +2 -2
- package/styles/components/BottomSheet.less +1 -2
- package/styles/components/Carousel.less +13 -9
- package/styles/components/Checkbox.less +15 -16
- package/styles/components/ClearableInput.less +3 -3
- package/styles/components/Counter.less +12 -12
- package/styles/components/DataTabs.less +2 -2
- package/styles/components/DatePicker.less +27 -27
- package/styles/components/Dialog.less +15 -11
- package/styles/components/Dropdown.less +11 -11
- package/styles/components/Expander.less +7 -7
- package/styles/components/ListMenu.less +8 -8
- package/styles/components/MapHere.less +3 -2
- package/styles/components/MapMarker.less +16 -17
- package/styles/components/MapSettings.less +5 -5
- package/styles/components/NoData.less +1 -1
- package/styles/components/Notification.less +12 -12
- package/styles/components/RadioButton.less +11 -12
- package/styles/components/Resizer.less +1 -1
- package/styles/components/Select.less +16 -26
- package/styles/components/Sidebar.less +29 -21
- package/styles/components/Slider.less +18 -18
- package/styles/components/Spinner.less +6 -6
- package/styles/components/StatsWidget.less +5 -5
- package/styles/components/SteppedProgressBar.less +32 -29
- package/styles/components/SupportMarker.less +1 -1
- package/styles/components/Switch.less +8 -8
- package/styles/components/TableSettingsDialog.less +7 -7
- package/styles/components/TableToolbar.less +1 -1
- package/styles/components/Tag.less +10 -10
- package/styles/components/Timeline.less +3 -3
- package/styles/components/Tooltip.less +10 -10
- package/styles/design/badges.less +10 -10
- package/styles/design/border.less +1 -1
- package/styles/design/breadcrumbs.less +2 -2
- package/styles/design/button-groups.less +25 -1
- package/styles/design/buttons.less +53 -109
- package/styles/design/callouts.less +3 -3
- package/styles/design/code.less +4 -6
- package/styles/design/colors.less +20 -20
- package/styles/design/form-input-groups.less +4 -4
- package/styles/design/form-inputs.less +33 -31
- package/styles/design/images.less +2 -2
- package/styles/design/labels.less +11 -11
- package/styles/design/list-group.less +14 -12
- package/styles/design/navs.less +27 -27
- package/styles/design/normalize.less +0 -9
- package/styles/design/pagination.less +10 -10
- package/styles/design/panels.less +10 -10
- package/styles/design/popovers.less +8 -8
- package/styles/design/progress-bars.less +8 -8
- package/styles/design/shadows.less +14 -7
- package/styles/design/tables.less +68 -106
- package/styles/design/text.less +5 -19
- package/styles/design/theme.less +10 -10
- package/styles/design/thumbnails.less +2 -2
- package/styles/design/type.less +4 -4
- package/styles/design/wells.less +1 -1
- package/styles/mapping/color-map.less +76 -75
- package/styles/mixins/_imports.less +14 -0
- package/styles/mixins/buttons.less +24 -56
- package/styles/mixins/forms.less +19 -55
- package/styles/mixins/hsl.less +19 -0
- package/styles/mixins/panels.less +2 -2
- package/styles/print/print.less +7 -7
- package/styles/rio-uikit-core.less +2 -2
- package/styles/rio-uikit-print-utilities.less +2 -2
- package/styles/rio-uikit-responsive-utilities.less +2 -2
- package/styles/variables/_index.less +196 -0
- package/styles/variables/colors.json +67 -0
- package/styles/variables/concated_css_variables.less +66 -0
- package/styles/variables/dark_colors.less +88 -0
- package/styles/variables/dark_css_variables.less +28 -0
- package/styles/variables/dark_css_variables_map.less +96 -0
- package/styles/variables/light_colors.less +92 -0
- package/styles/variables/light_css_variables.less +17 -0
- package/styles/variables/light_css_variables_map.less +100 -0
- package/styles/variables/screens.less +7 -0
- package/styles/variables/text.less +23 -0
- package/themes/.DS_Store +0 -0
- package/themes/BuyButton/styles/rio-buyButton.less +13 -8
- package/themes/MAN/styles/man-uikit.less +3 -0
- package/themes/SCANIA/styles/scania-uikit.less +3 -0
- package/themes/Volkswagen/.DS_Store +0 -0
- package/themes/Volkswagen/styles/vw-uikit.less +21 -30
- package/themes/Website/.DS_Store +0 -0
- package/themes/Website/styles/rio-website.less +154 -124
- package/themes/Xmas/styles/rio-xmas.less +59 -29
- package/types.ts +30 -5
- package/useDarkMode.d.ts +4 -0
- package/useDarkMode.js +2 -0
- package/useMutationObserver.d.ts +4 -0
- package/useMutationObserver.js +2 -0
- package/useScrollPosition.d.ts +4 -0
- package/useScrollPosition.js +2 -0
- package/utils/colorScheme.js +55 -0
- package/utils/init.js +34 -34
- package/version.json +1 -1
|
@@ -13,20 +13,21 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
15
|
var _NumberInput = _interopRequireWildcard(require("../numberInput/NumberInput"));
|
|
16
|
-
var _excluded = ["min", "max", "step", "value", "onValueChanged", "disabled", "bsSize", "className", "unit", "inputAddon"];
|
|
16
|
+
var _excluded = ["min", "max", "step", "value", "onChange", "onValueChanged", "disabled", "bsSize", "className", "unit", "inputAddon", "digitPrecision", "placeholder"];
|
|
17
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
var INITIAL_TICK = 700;
|
|
20
20
|
var TICK_TIME = 50;
|
|
21
|
-
var
|
|
21
|
+
var DEFAULT_DIGIT_PRECISION = 3;
|
|
22
|
+
var NumberControl = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
22
23
|
var _props$min = props.min,
|
|
23
24
|
min = _props$min === void 0 ? _NumberInput.defaultProps.min : _props$min,
|
|
24
25
|
_props$max = props.max,
|
|
25
26
|
max = _props$max === void 0 ? _NumberInput.defaultProps.max : _props$max,
|
|
26
27
|
_props$step = props.step,
|
|
27
28
|
step = _props$step === void 0 ? _NumberInput.defaultProps.step : _props$step,
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
value = props.value,
|
|
30
|
+
onChange = props.onChange,
|
|
30
31
|
_props$onValueChanged = props.onValueChanged,
|
|
31
32
|
onValueChanged = _props$onValueChanged === void 0 ? function () {} : _props$onValueChanged,
|
|
32
33
|
disabled = props.disabled,
|
|
@@ -34,7 +35,13 @@ var NumberControl = function NumberControl(props) {
|
|
|
34
35
|
className = props.className,
|
|
35
36
|
unit = props.unit,
|
|
36
37
|
inputAddon = props.inputAddon,
|
|
38
|
+
_props$digitPrecision = props.digitPrecision,
|
|
39
|
+
digitPrecision = _props$digitPrecision === void 0 ? DEFAULT_DIGIT_PRECISION : _props$digitPrecision,
|
|
40
|
+
placeholder = props.placeholder,
|
|
37
41
|
remainingProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
42
|
+
|
|
43
|
+
// Note, "onChange" should replace "onValueChanged" in the future but it's widely used
|
|
44
|
+
var callback = onChange || onValueChanged;
|
|
38
45
|
var timeout = (0, _react.useRef)();
|
|
39
46
|
var _useState = (0, _react.useState)(false),
|
|
40
47
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -59,6 +66,20 @@ var NumberControl = function NumberControl(props) {
|
|
|
59
66
|
callback();
|
|
60
67
|
}, TICK_TIME);
|
|
61
68
|
};
|
|
69
|
+
|
|
70
|
+
// Update internal state if external value has changed
|
|
71
|
+
(0, _react.useEffect)(function () {
|
|
72
|
+
if (internalValue !== value) {
|
|
73
|
+
setInternalValue(value);
|
|
74
|
+
}
|
|
75
|
+
}, [value]);
|
|
76
|
+
|
|
77
|
+
// Notify external component if internal value has changed
|
|
78
|
+
(0, _react.useEffect)(function () {
|
|
79
|
+
if (internalValue !== value) {
|
|
80
|
+
callback(internalValue);
|
|
81
|
+
}
|
|
82
|
+
}, [internalValue]);
|
|
62
83
|
(0, _react.useEffect)(function () {
|
|
63
84
|
// Call increment function for a loop when button is holding down
|
|
64
85
|
if (isHoldingDownInc && !disabled) {
|
|
@@ -73,15 +94,17 @@ var NumberControl = function NumberControl(props) {
|
|
|
73
94
|
var incrementInternalValue = function incrementInternalValue() {
|
|
74
95
|
setInternalValue(function (val) {
|
|
75
96
|
var currentValue = (0, _NumberInput.convertNonIntegerToDefault)(val);
|
|
76
|
-
var newValue = currentValue + step;
|
|
77
|
-
|
|
97
|
+
var newValue = Number((currentValue + step).toFixed(digitPrecision));
|
|
98
|
+
var newValueLimited = newValue <= max ? newValue : val;
|
|
99
|
+
return newValueLimited;
|
|
78
100
|
});
|
|
79
101
|
};
|
|
80
102
|
var decrementInternalValue = function decrementInternalValue() {
|
|
81
103
|
setInternalValue(function (val) {
|
|
82
104
|
var currentValue = (0, _NumberInput.convertNonIntegerToDefault)(val);
|
|
83
|
-
var newValue = currentValue - step;
|
|
84
|
-
|
|
105
|
+
var newValue = Number((currentValue - step).toFixed(digitPrecision));
|
|
106
|
+
var newValueLimited = newValue >= min ? newValue : val;
|
|
107
|
+
return newValueLimited;
|
|
85
108
|
});
|
|
86
109
|
};
|
|
87
110
|
var incrementRecusively = function incrementRecusively() {
|
|
@@ -120,10 +143,10 @@ var NumberControl = function NumberControl(props) {
|
|
|
120
143
|
// for instance the user has typed in a number manually and to
|
|
121
144
|
// use this number as base to increase or decrease from.
|
|
122
145
|
// Ignore empty value in case the user has removed it
|
|
123
|
-
if (value && (
|
|
146
|
+
if (value !== undefined && !(isHoldingDownDec && isHoldingDownInc)) {
|
|
124
147
|
setInternalValue(Number(value));
|
|
125
148
|
}
|
|
126
|
-
|
|
149
|
+
callback(value);
|
|
127
150
|
};
|
|
128
151
|
var classes = (0, _classnames["default"])('NumberControl', 'form-group', className);
|
|
129
152
|
var inputGroupClassNames = (0, _classnames["default"])('input-group', bsSize === 'sm' && 'input-group-sm', bsSize === 'lg' && 'input-group-lg');
|
|
@@ -136,12 +159,15 @@ var NumberControl = function NumberControl(props) {
|
|
|
136
159
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
137
160
|
className: inputAddon
|
|
138
161
|
})), /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
|
|
162
|
+
ref: ref,
|
|
139
163
|
min: min,
|
|
140
164
|
max: max,
|
|
141
165
|
value: internalValue,
|
|
142
166
|
step: step,
|
|
143
167
|
disabled: disabled,
|
|
144
|
-
|
|
168
|
+
onChange: handleUpdatedNumberInputValue,
|
|
169
|
+
digitPrecision: digitPrecision,
|
|
170
|
+
placeholder: placeholder
|
|
145
171
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
146
172
|
className: 'input-group-addon'
|
|
147
173
|
}, unit && /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -163,18 +189,21 @@ var NumberControl = function NumberControl(props) {
|
|
|
163
189
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
164
190
|
className: 'rioglyph rioglyph-plus scale-90'
|
|
165
191
|
})))));
|
|
166
|
-
};
|
|
192
|
+
});
|
|
167
193
|
NumberControl.propTypes = {
|
|
168
194
|
min: _propTypes["default"].number,
|
|
169
195
|
max: _propTypes["default"].number,
|
|
170
196
|
value: _propTypes["default"].number,
|
|
171
197
|
step: _propTypes["default"].number,
|
|
172
198
|
disabled: _propTypes["default"].bool,
|
|
199
|
+
onChange: _propTypes["default"].func,
|
|
173
200
|
onValueChanged: _propTypes["default"].func,
|
|
174
201
|
bsSize: _propTypes["default"].string,
|
|
175
202
|
className: _propTypes["default"].string,
|
|
176
203
|
unit: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]),
|
|
177
|
-
inputAddon: _propTypes["default"].string
|
|
204
|
+
inputAddon: _propTypes["default"].string,
|
|
205
|
+
digitPrecision: _propTypes["default"].number,
|
|
206
|
+
placeholder: _propTypes["default"].string
|
|
178
207
|
};
|
|
179
208
|
var _default = NumberControl;
|
|
180
209
|
exports["default"] = _default;
|
|
@@ -13,21 +13,29 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
15
|
var _useAfterMount = _interopRequireDefault(require("../../hooks/useAfterMount"));
|
|
16
|
-
var _excluded = ["unit", "inputAddon", "className", "bsSize", "disabled", "onValueChanged", "min", "max", "value", "step", "
|
|
16
|
+
var _excluded = ["unit", "inputAddon", "className", "bsSize", "disabled", "onChange", "onValueChanged", "min", "max", "value", "step", "digitPrecision", "placeholder"];
|
|
17
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
var DEFAULT_DIGIT_PRECISION = 3;
|
|
20
|
+
var DEFAULT_VALUE = 0;
|
|
21
|
+
var DEFAULT_STEP = 1;
|
|
22
|
+
|
|
23
|
+
// Note: even if limits are set and input type is number, many browsers allow to enter invalid data
|
|
24
|
+
// like entering characters or values outside the boundaries, hence we have to check the input here
|
|
25
|
+
// See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
|
|
26
|
+
|
|
19
27
|
var defaultProps = {
|
|
20
28
|
min: 0,
|
|
21
29
|
max: Number.MAX_VALUE,
|
|
22
|
-
|
|
23
|
-
step: 1
|
|
30
|
+
step: DEFAULT_STEP
|
|
24
31
|
};
|
|
25
32
|
exports.defaultProps = defaultProps;
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
var getValueFromProps = function getValueFromProps(val, min, max, placeholder) {
|
|
34
|
+
// Show placeholders if given instead of 0
|
|
35
|
+
if (val === undefined && placeholder) {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
return clampNumber(Number(val), min, max) || DEFAULT_VALUE;
|
|
31
39
|
};
|
|
32
40
|
var clampNumber = function clampNumber(value, min, max) {
|
|
33
41
|
if (value < min) {
|
|
@@ -37,13 +45,10 @@ var clampNumber = function clampNumber(value, min, max) {
|
|
|
37
45
|
}
|
|
38
46
|
return value;
|
|
39
47
|
};
|
|
40
|
-
var
|
|
41
|
-
return /^(-)?([1-9]\d*)?$/.test(value) || value === '0';
|
|
42
|
-
};
|
|
43
|
-
var convertNonIntegerToDefault = function convertNonIntegerToDefault(value, min) {
|
|
48
|
+
var convertNonIntegerToDefault = function convertNonIntegerToDefault(value) {
|
|
44
49
|
var currentValue = value;
|
|
45
|
-
if (!Number.
|
|
46
|
-
currentValue =
|
|
50
|
+
if (!Number.isFinite(currentValue)) {
|
|
51
|
+
currentValue = DEFAULT_VALUE;
|
|
47
52
|
}
|
|
48
53
|
return currentValue;
|
|
49
54
|
};
|
|
@@ -54,21 +59,24 @@ var NumberInput = /*#__PURE__*/_react["default"].forwardRef(function (props, ref
|
|
|
54
59
|
className = props.className,
|
|
55
60
|
bsSize = props.bsSize,
|
|
56
61
|
disabled = props.disabled,
|
|
62
|
+
onChange = props.onChange,
|
|
57
63
|
_props$onValueChanged = props.onValueChanged,
|
|
58
64
|
onValueChanged = _props$onValueChanged === void 0 ? function () {} : _props$onValueChanged,
|
|
59
65
|
propMin = props.min,
|
|
60
66
|
propMax = props.max,
|
|
61
67
|
propValue = props.value,
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
_props$step = props.step,
|
|
69
|
+
step = _props$step === void 0 ? DEFAULT_STEP : _props$step,
|
|
70
|
+
_props$digitPrecision = props.digitPrecision,
|
|
71
|
+
digitPrecision = _props$digitPrecision === void 0 ? DEFAULT_DIGIT_PRECISION : _props$digitPrecision,
|
|
72
|
+
placeholder = props.placeholder,
|
|
64
73
|
remainingProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
65
74
|
|
|
66
|
-
//
|
|
67
|
-
var
|
|
68
|
-
var min = Number.
|
|
69
|
-
var max = Number.
|
|
70
|
-
var value = getValueFromProps(propValue, min, max,
|
|
71
|
-
var step = getStepFromProps(propStep, defaultProps.step, max, min);
|
|
75
|
+
// Note, "onChange" should replace "onValueChanged" in the future but it's widely used
|
|
76
|
+
var callback = onChange || onValueChanged;
|
|
77
|
+
var min = Number.isFinite(propMin) ? propMin : defaultProps.min;
|
|
78
|
+
var max = Number.isFinite(propMax) ? propMax : defaultProps.max;
|
|
79
|
+
var value = getValueFromProps(propValue, min, max, placeholder);
|
|
72
80
|
|
|
73
81
|
// Define local state and define initial values
|
|
74
82
|
var _useState = (0, _react.useState)({
|
|
@@ -83,57 +91,62 @@ var NumberInput = /*#__PURE__*/_react["default"].forwardRef(function (props, ref
|
|
|
83
91
|
// Update internal value whenever the value prop from outside changes
|
|
84
92
|
(0, _useAfterMount["default"])(function () {
|
|
85
93
|
setState({
|
|
86
|
-
value: getValueFromProps(propValue, min, max,
|
|
94
|
+
value: getValueFromProps(propValue, min, max, placeholder),
|
|
87
95
|
enteredValue: value,
|
|
88
96
|
isValid: true
|
|
89
97
|
});
|
|
90
98
|
}, [propValue, clampNumber]);
|
|
91
99
|
var applyValue = function applyValue(newValue) {
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
} else {
|
|
100
|
-
var enteredValue = Number(newValue);
|
|
101
|
-
var isValid = enteredValue >= min && enteredValue <= max;
|
|
102
|
-
var newValidValue = clampNumber(enteredValue, min, max);
|
|
103
|
-
setState({
|
|
104
|
-
value: newValidValue,
|
|
105
|
-
enteredValue: enteredValue,
|
|
106
|
-
isValid: isValid
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Only call back the caller for valid values
|
|
110
|
-
isValid && onValueChanged(newValidValue);
|
|
111
|
-
}
|
|
100
|
+
if (newValue === '-' || newValue === '') {
|
|
101
|
+
setState({
|
|
102
|
+
value: newValue,
|
|
103
|
+
enteredValue: newValue,
|
|
104
|
+
isValid: true
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
112
107
|
}
|
|
108
|
+
var enteredValue = Number(newValue);
|
|
109
|
+
var isValid = !isNaN(enteredValue) && enteredValue >= min && enteredValue <= max;
|
|
110
|
+
var newValidValue = clampNumber(enteredValue, min, max);
|
|
111
|
+
setState({
|
|
112
|
+
value: newValidValue,
|
|
113
|
+
enteredValue: enteredValue,
|
|
114
|
+
isValid: isValid
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Only call back the caller for valid values
|
|
118
|
+
isValid && callback(newValidValue);
|
|
113
119
|
};
|
|
114
120
|
var handleOnChange = function handleOnChange(event) {
|
|
115
|
-
|
|
121
|
+
applyValue(event.target.value);
|
|
116
122
|
};
|
|
117
|
-
var handleBlur = function handleBlur(event) {
|
|
118
|
-
// console.log({enteredValue: state.enteredValue, event: Number(event.target.value)});
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
// Prevent entering exponent to avoide side effects
|
|
125
|
+
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1398528
|
|
126
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
127
|
+
if (event.key === 'e' || event.key === 'E') {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var handleBlur = function handleBlur(event) {
|
|
132
|
+
// When the value is removed, keep the input empty but trigger the outside callback
|
|
121
133
|
// since the user has finished his input
|
|
122
134
|
var lastEnteredValue = state.enteredValue;
|
|
123
135
|
if (lastEnteredValue === '') {
|
|
124
|
-
|
|
136
|
+
callback(lastEnteredValue);
|
|
125
137
|
return;
|
|
126
138
|
}
|
|
127
139
|
|
|
128
|
-
// Otherwise, validate the input
|
|
129
|
-
|
|
130
|
-
var
|
|
140
|
+
// Otherwise, validate the input, round it according to digitPrecision,
|
|
141
|
+
// and clamp the value if the entered value exeeds the limitations
|
|
142
|
+
var convertedEnteredValue = convertNonIntegerToDefault(Number(lastEnteredValue));
|
|
143
|
+
var validNumber = clampNumber(Number(convertedEnteredValue).toFixed(digitPrecision), min, max);
|
|
131
144
|
applyValue(validNumber);
|
|
132
145
|
};
|
|
133
146
|
var inputGroupClassNames = (0, _classnames["default"])('input-group', bsSize === 'sm' && 'input-group-sm', bsSize === 'lg' && 'input-group-lg');
|
|
134
147
|
var inputClassNames = (0, _classnames["default"])('form-control', 'no-controls', bsSize === 'sm' && 'input-sm', bsSize === 'lg' && 'input-lg', className);
|
|
135
148
|
var input = /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({}, remainingProps, {
|
|
136
|
-
type:
|
|
149
|
+
type: "number",
|
|
137
150
|
step: step,
|
|
138
151
|
min: min,
|
|
139
152
|
max: max,
|
|
@@ -142,8 +155,13 @@ var NumberInput = /*#__PURE__*/_react["default"].forwardRef(function (props, ref
|
|
|
142
155
|
disabled: disabled,
|
|
143
156
|
onBlur: handleBlur,
|
|
144
157
|
onChange: handleOnChange,
|
|
158
|
+
onKeyDown: handleKeyDown,
|
|
145
159
|
ref: ref,
|
|
146
|
-
"aria-label":
|
|
160
|
+
"aria-label": "number-input",
|
|
161
|
+
placeholder: placeholder,
|
|
162
|
+
onWheel: function onWheel(event) {
|
|
163
|
+
return event.target.blur();
|
|
164
|
+
}
|
|
147
165
|
}));
|
|
148
166
|
return unit || inputAddon ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
149
167
|
className: inputGroupClassNames
|
|
@@ -160,13 +178,15 @@ NumberInput.propTypes = {
|
|
|
160
178
|
max: _propTypes["default"].number,
|
|
161
179
|
value: _propTypes["default"].number,
|
|
162
180
|
step: _propTypes["default"].number,
|
|
163
|
-
type: _propTypes["default"].string,
|
|
164
181
|
disabled: _propTypes["default"].bool,
|
|
182
|
+
onChange: _propTypes["default"].func,
|
|
165
183
|
onValueChanged: _propTypes["default"].func,
|
|
166
184
|
bsSize: _propTypes["default"].oneOf(['sm', 'lg', 'small', 'large']),
|
|
167
185
|
className: _propTypes["default"].string,
|
|
168
186
|
unit: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]),
|
|
169
|
-
inputAddon: _propTypes["default"].string
|
|
187
|
+
inputAddon: _propTypes["default"].string,
|
|
188
|
+
digitPrecision: _propTypes["default"].number,
|
|
189
|
+
placeholder: _propTypes["default"].string
|
|
170
190
|
};
|
|
171
191
|
var _default = NumberInput;
|
|
172
192
|
exports["default"] = _default;
|
|
@@ -243,7 +243,7 @@ var Sidebar = /*#__PURE__*/function (_Component) {
|
|
|
243
243
|
var headerClassNames = (0, _classnames["default"])('SidebarHeader', headerClassName && headerClassName, showHeaderBorder && 'show-border');
|
|
244
244
|
var titleClassNames = (0, _classnames["default"])('SidebarTitle', titleClassName && titleClassName);
|
|
245
245
|
var bodyClassNames = (0, _classnames["default"])('SidebarBody', bodyClassName && bodyClassName);
|
|
246
|
-
var backdropClassNames = (0, _classnames["default"])('SidebarBackdrop', makeBackdropVisible && '
|
|
246
|
+
var backdropClassNames = (0, _classnames["default"])('SidebarBackdrop', makeBackdropVisible && 'sidebar-backdrop-bg', backdropClassName && backdropClassName);
|
|
247
247
|
var fullscreenIconClasses = (0, _classnames["default"])('rioglyph', isFullscreen ? 'rioglyph-resize-small' : 'rioglyph-resize-full');
|
|
248
248
|
var resizeLimitClasses = (0, _classnames["default"])('SidebarResizeLimit', isResize && 'display-block');
|
|
249
249
|
var isRight = position === Sidebar.RIGHT;
|
|
@@ -368,7 +368,7 @@ Sidebar.propTypes = {
|
|
|
368
368
|
makeBackdropVisible: _propTypes["default"].bool,
|
|
369
369
|
onBackdropClick: _propTypes["default"].func,
|
|
370
370
|
backdropClassName: _propTypes["default"].string,
|
|
371
|
-
bodyRef: _propTypes["default"].
|
|
371
|
+
bodyRef: _propTypes["default"].object,
|
|
372
372
|
headerButtons: _propTypes["default"].node
|
|
373
373
|
};
|
|
374
374
|
var _default = Sidebar;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _colorScheme = require("./../utils/colorScheme");
|
|
11
|
+
var _useMutationObserver = _interopRequireDefault(require("./useMutationObserver"));
|
|
12
|
+
var useDarkMode = function useDarkMode() {
|
|
13
|
+
var _useState = (0, _react.useState)(false),
|
|
14
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
15
|
+
isDarkMode = _useState2[0],
|
|
16
|
+
setIsDarkMode = _useState2[1];
|
|
17
|
+
var handleMutation = (0, _react.useCallback)(function (mutationList) {
|
|
18
|
+
mutationList.map(function (mutation) {
|
|
19
|
+
if (mutation.type === 'attributes' && mutation.attributeName === _colorScheme.THEME_DATA_ATTRIBUTE) {
|
|
20
|
+
var _mutation$target$attr;
|
|
21
|
+
var scheme = (_mutation$target$attr = mutation.target.attributes[_colorScheme.THEME_DATA_ATTRIBUTE]) === null || _mutation$target$attr === void 0 ? void 0 : _mutation$target$attr.value;
|
|
22
|
+
setIsDarkMode(scheme === _colorScheme.THEME_DARK);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// if (mutation.type === 'classList') {
|
|
26
|
+
// console.log({ classList: mutation });
|
|
27
|
+
// }
|
|
28
|
+
});
|
|
29
|
+
}, []);
|
|
30
|
+
(0, _useMutationObserver["default"])(document.documentElement, handleMutation, {
|
|
31
|
+
attributes: true,
|
|
32
|
+
childList: false,
|
|
33
|
+
subtree: false
|
|
34
|
+
});
|
|
35
|
+
return isDarkMode;
|
|
36
|
+
};
|
|
37
|
+
var _default = useDarkMode;
|
|
38
|
+
exports["default"] = _default;
|
|
@@ -9,7 +9,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
11
11
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
13
|
function useElementSize(elementRef) {
|
|
14
14
|
var _useState = (0, _react.useState)(),
|
|
15
15
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -120,25 +120,23 @@ var useFullscreen = function useFullscreen() {
|
|
|
120
120
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(newTargetElement) {
|
|
121
121
|
var isHtmlElement, target;
|
|
122
122
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
123
|
-
while (1) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return _context.stop();
|
|
141
|
-
}
|
|
123
|
+
while (1) switch (_context.prev = _context.next) {
|
|
124
|
+
case 0:
|
|
125
|
+
// check whether the new target element is a real DOm node or just a function
|
|
126
|
+
isHtmlElement = newTargetElement instanceof HTMLElement;
|
|
127
|
+
_context.prev = 1;
|
|
128
|
+
target = newTargetElement && isHtmlElement ? newTargetElement : defaultFullscreenElement;
|
|
129
|
+
_context.next = 5;
|
|
130
|
+
return target[getRequestFunctionName(target)](requestFullscreenOptions);
|
|
131
|
+
case 5:
|
|
132
|
+
return _context.abrupt("return", _context.sent);
|
|
133
|
+
case 8:
|
|
134
|
+
_context.prev = 8;
|
|
135
|
+
_context.t0 = _context["catch"](1);
|
|
136
|
+
console.log(_context.t0);
|
|
137
|
+
case 11:
|
|
138
|
+
case "end":
|
|
139
|
+
return _context.stop();
|
|
142
140
|
}
|
|
143
141
|
}, _callee, null, [[1, 8]]);
|
|
144
142
|
}));
|
|
@@ -148,29 +146,27 @@ var useFullscreen = function useFullscreen() {
|
|
|
148
146
|
}(), []);
|
|
149
147
|
var exitFullscreen = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
150
148
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
151
|
-
while (1) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
_context2.next = 5;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
_context2.next = 4;
|
|
160
|
-
return document[getExitFunctionName()]();
|
|
161
|
-
case 4:
|
|
162
|
-
return _context2.abrupt("return", _context2.sent);
|
|
163
|
-
case 5:
|
|
164
|
-
_context2.next = 10;
|
|
149
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
_context2.prev = 0;
|
|
152
|
+
if (!fullscreenElement) {
|
|
153
|
+
_context2.next = 5;
|
|
165
154
|
break;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
155
|
+
}
|
|
156
|
+
_context2.next = 4;
|
|
157
|
+
return document[getExitFunctionName()]();
|
|
158
|
+
case 4:
|
|
159
|
+
return _context2.abrupt("return", _context2.sent);
|
|
160
|
+
case 5:
|
|
161
|
+
_context2.next = 10;
|
|
162
|
+
break;
|
|
163
|
+
case 7:
|
|
164
|
+
_context2.prev = 7;
|
|
165
|
+
_context2.t0 = _context2["catch"](0);
|
|
166
|
+
console.warn(_context2.t0);
|
|
167
|
+
case 10:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context2.stop();
|
|
174
170
|
}
|
|
175
171
|
}, _callee2, null, [[0, 7]]);
|
|
176
172
|
})), [fullscreenElement]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useScripts } from './useScripts';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_BASE_URL = 'https://js.api.here.com/v3/3.1.20.0/';
|
|
4
|
+
|
|
5
|
+
const HERE_EXTERNALS = [
|
|
6
|
+
'mapsjs-core.js',
|
|
7
|
+
'mapsjs-core-legacy.js',
|
|
8
|
+
'mapsjs-service.js',
|
|
9
|
+
'mapsjs-service-legacy.js',
|
|
10
|
+
'mapsjs-mapevents.js',
|
|
11
|
+
'mapsjs-ui.js',
|
|
12
|
+
'mapsjs-clustering.js',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const getExternals = (scriptList: string[], baseUrl: string): string[] =>
|
|
16
|
+
scriptList.map((script) => `${baseUrl}${script}`);
|
|
17
|
+
|
|
18
|
+
const sanitizeBaseUrl = (url: string) => (url.endsWith('/') ? url : `${url}/`);
|
|
19
|
+
|
|
20
|
+
export const useHereMap = (baseUrl?: string) => {
|
|
21
|
+
const hereScripts = getExternals(HERE_EXTERNALS, sanitizeBaseUrl(baseUrl || DEFAULT_BASE_URL));
|
|
22
|
+
return useScripts(hereScripts, false);
|
|
23
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var isRef = function isRef(obj) {
|
|
11
|
+
return obj !== null && (0, _typeof2["default"])(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current');
|
|
12
|
+
};
|
|
13
|
+
var unRef = function unRef(target) {
|
|
14
|
+
return isRef(target) ? target.current : target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Options for the observer (which mutations to observe)
|
|
18
|
+
var DEFAULT_OPTIONS = {
|
|
19
|
+
attributes: true,
|
|
20
|
+
childList: false,
|
|
21
|
+
subtree: false
|
|
22
|
+
};
|
|
23
|
+
var useMutationObserver = function useMutationObserver(target) {
|
|
24
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
|
|
25
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_OPTIONS;
|
|
26
|
+
var observer = (0, _react.useRef)(null);
|
|
27
|
+
var disconnect = (0, _react.useCallback)(function () {
|
|
28
|
+
var _observer$current;
|
|
29
|
+
return (_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
|
|
30
|
+
}, []);
|
|
31
|
+
var observe = (0, _react.useCallback)(function () {
|
|
32
|
+
var targetElement = unRef(target);
|
|
33
|
+
observer.current = new MutationObserver(callback);
|
|
34
|
+
if (targetElement) {
|
|
35
|
+
observer.current.observe(targetElement, options);
|
|
36
|
+
}
|
|
37
|
+
}, [target]);
|
|
38
|
+
(0, _react.useLayoutEffect)(function () {
|
|
39
|
+
observe();
|
|
40
|
+
return function () {
|
|
41
|
+
return disconnect();
|
|
42
|
+
};
|
|
43
|
+
}, [disconnect, observe]);
|
|
44
|
+
};
|
|
45
|
+
var _default = useMutationObserver;
|
|
46
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const hasScriptsInHead = (src: string) => document.head.querySelectorAll(`script[src*="${src}"]`).length > 0;
|
|
4
|
+
|
|
5
|
+
export const useScripts = (scripts: string[], loadAsync: boolean = false) => {
|
|
6
|
+
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
7
|
+
const [hasLoaded, setHasLoaded] = useState<boolean>(false);
|
|
8
|
+
const [error, setError] = useState<Error | undefined>();
|
|
9
|
+
|
|
10
|
+
const promises = new Set();
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const [firstScript] = scripts;
|
|
14
|
+
|
|
15
|
+
if (hasScriptsInHead(firstScript)) {
|
|
16
|
+
setHasLoaded(true);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setIsLoading(true);
|
|
21
|
+
|
|
22
|
+
scripts.map((external) => {
|
|
23
|
+
promises.add(
|
|
24
|
+
new Promise<void>((resolve, reject) => {
|
|
25
|
+
const script = document.createElement('script');
|
|
26
|
+
script.async = loadAsync;
|
|
27
|
+
script.src = external;
|
|
28
|
+
|
|
29
|
+
script.onload = () => {
|
|
30
|
+
console.debug(`loaded ${external}`);
|
|
31
|
+
resolve();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
script.onerror = () => {
|
|
35
|
+
console.debug(`failed to load ${external}`);
|
|
36
|
+
setError(new Error(`failed to load ${external}`));
|
|
37
|
+
reject();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
document.head.appendChild(script);
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
Promise.all([...promises]).then(() => {
|
|
46
|
+
setIsLoading(false);
|
|
47
|
+
setHasLoaded(true);
|
|
48
|
+
});
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
return { isLoading, error, hasLoaded };
|
|
52
|
+
};
|