@bolio-ui/core 1.0.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/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/avatar/index.js +901 -0
- package/dist/badge/index.js +899 -0
- package/dist/bolio-ui-provider/index.js +1883 -0
- package/dist/breadcrumbs/index.js +985 -0
- package/dist/button/index.js +1358 -0
- package/dist/button-dropdown/index.js +1111 -0
- package/dist/button-group/index.js +782 -0
- package/dist/capacity/index.js +780 -0
- package/dist/card/index.js +1275 -0
- package/dist/checkbox/index.js +1042 -0
- package/dist/code/index.js +803 -0
- package/dist/col/index.js +90 -0
- package/dist/collapse/index.js +1158 -0
- package/dist/container/index.js +444 -0
- package/dist/css-baseline/index.js +348 -0
- package/dist/description/index.js +741 -0
- package/dist/display/index.js +745 -0
- package/dist/divider/index.js +767 -0
- package/dist/dot/index.js +755 -0
- package/dist/drawer/index.js +1513 -0
- package/dist/fieldset/index.js +1089 -0
- package/dist/grid/index.js +870 -0
- package/dist/image/index.js +1094 -0
- package/dist/index.js +9970 -0
- package/dist/input/index.js +1275 -0
- package/dist/keyboard/index.js +711 -0
- package/dist/link/index.js +863 -0
- package/dist/loading/index.js +765 -0
- package/dist/mdx-widgets/index.js +438 -0
- package/dist/modal/index.js +2220 -0
- package/dist/note/index.js +773 -0
- package/dist/page/index.js +928 -0
- package/dist/pagination/index.js +1201 -0
- package/dist/popover/index.js +1502 -0
- package/dist/progress/index.js +804 -0
- package/dist/radio/index.js +1028 -0
- package/dist/rating/index.js +912 -0
- package/dist/row/index.js +442 -0
- package/dist/section/index.js +733 -0
- package/dist/select/index.js +1865 -0
- package/dist/slider/index.js +1097 -0
- package/dist/snippet/index.js +1207 -0
- package/dist/spacer/index.js +692 -0
- package/dist/spinner/index.js +763 -0
- package/dist/styled-jsx.cjs.js +766 -0
- package/dist/tabs/index.js +1125 -0
- package/dist/tag/index.js +749 -0
- package/dist/text/index.js +830 -0
- package/dist/textarea/index.js +915 -0
- package/dist/themes/index.js +319 -0
- package/dist/toggle/index.js +852 -0
- package/dist/tooltip/index.js +1353 -0
- package/dist/use-all-themes/index.js +335 -0
- package/dist/use-body-scroll/index.js +173 -0
- package/dist/use-classes/index.js +55 -0
- package/dist/use-click-away/index.js +28 -0
- package/dist/use-clipboard/index.js +188 -0
- package/dist/use-current-state/index.js +90 -0
- package/dist/use-input/index.js +129 -0
- package/dist/use-keyboard/index.js +214 -0
- package/dist/use-media-query/index.js +495 -0
- package/dist/use-modal/index.js +114 -0
- package/dist/use-scale/index.js +673 -0
- package/dist/use-tabs/index.js +112 -0
- package/dist/use-theme/index.js +333 -0
- package/dist/use-toasts/index.js +236 -0
- package/esm/avatar/avatar-group.js +29 -0
- package/esm/avatar/avatar.js +107 -0
- package/esm/avatar/avatar.skeleton.js +21 -0
- package/esm/avatar/helpers.js +16 -0
- package/esm/avatar/index.js +4 -0
- package/esm/avatar/stories.js +113 -0
- package/esm/badge/badge-anchor.js +70 -0
- package/esm/badge/badge.js +58 -0
- package/esm/badge/index.js +4 -0
- package/esm/badge/stories.js +92 -0
- package/esm/bolio-ui-provider/bolio-ui-provider.js +62 -0
- package/esm/bolio-ui-provider/index.js +2 -0
- package/esm/bolio-ui-provider/theme-provider.js +47 -0
- package/esm/breadcrumbs/breadcrumbs-item.js +49 -0
- package/esm/breadcrumbs/breadcrumbs-separator.js +25 -0
- package/esm/breadcrumbs/breadcrumbs.js +47 -0
- package/esm/breadcrumbs/index.js +6 -0
- package/esm/breadcrumbs/stories.js +51 -0
- package/esm/button/button-icon.js +29 -0
- package/esm/button/button-loading.js +17 -0
- package/esm/button/button.drip.js +57 -0
- package/esm/button/button.js +146 -0
- package/esm/button/index.js +2 -0
- package/esm/button/stories.js +221 -0
- package/esm/button/styles.js +232 -0
- package/esm/button/utils.js +46 -0
- package/esm/button-dropdown/button-dropdown-context.js +11 -0
- package/esm/button-dropdown/button-dropdown-item.js +52 -0
- package/esm/button-dropdown/button-dropdown.js +111 -0
- package/esm/button-dropdown/icon.js +30 -0
- package/esm/button-dropdown/index.js +4 -0
- package/esm/button-dropdown/stories.js +92 -0
- package/esm/button-dropdown/styles.js +60 -0
- package/esm/button-group/button-group-context.js +9 -0
- package/esm/button-group/button-group.js +75 -0
- package/esm/button-group/index.js +2 -0
- package/esm/button-group/stories.js +66 -0
- package/esm/capacity/capacity.js +52 -0
- package/esm/capacity/index.js +2 -0
- package/esm/capacity/stories.js +55 -0
- package/esm/card/card-content.js +28 -0
- package/esm/card/card-footer.js +36 -0
- package/esm/card/card.js +68 -0
- package/esm/card/index.js +8 -0
- package/esm/card/stories.js +126 -0
- package/esm/card/styles.js +45 -0
- package/esm/checkbox/checkbox-context.js +10 -0
- package/esm/checkbox/checkbox-group.js +70 -0
- package/esm/checkbox/checkbox.icon.js +50 -0
- package/esm/checkbox/checkbox.js +114 -0
- package/esm/checkbox/index.js +4 -0
- package/esm/checkbox/stories.js +84 -0
- package/esm/checkbox/styles.js +34 -0
- package/esm/code/code.js +57 -0
- package/esm/code/index.js +2 -0
- package/esm/code/stories.js +53 -0
- package/esm/col/col.js +29 -0
- package/esm/col/index.js +2 -0
- package/esm/collapse/collapse-context.js +8 -0
- package/esm/collapse/collapse-group.js +75 -0
- package/esm/collapse/collapse-icon.js +28 -0
- package/esm/collapse/collapse.js +93 -0
- package/esm/collapse/index.js +4 -0
- package/esm/collapse/stories.js +48 -0
- package/esm/container/container.js +62 -0
- package/esm/container/index.js +2 -0
- package/esm/css-baseline/css-baseline.js +18 -0
- package/esm/css-baseline/index.js +1 -0
- package/esm/description/description.js +39 -0
- package/esm/description/index.js +2 -0
- package/esm/description/stories.js +23 -0
- package/esm/display/display.js +43 -0
- package/esm/display/index.js +2 -0
- package/esm/divider/divider.js +65 -0
- package/esm/divider/index.js +2 -0
- package/esm/divider/stories.js +41 -0
- package/esm/dot/dot.js +53 -0
- package/esm/dot/index.js +2 -0
- package/esm/dot/stories.js +40 -0
- package/esm/drawer/drawer-wrapper.js +86 -0
- package/esm/drawer/drawer.js +77 -0
- package/esm/drawer/helper.js +27 -0
- package/esm/drawer/index.js +8 -0
- package/esm/drawer/stories.js +79 -0
- package/esm/fieldset/fieldset-content.js +29 -0
- package/esm/fieldset/fieldset-context.js +9 -0
- package/esm/fieldset/fieldset-footer.js +30 -0
- package/esm/fieldset/fieldset-group.js +88 -0
- package/esm/fieldset/fieldset-subtitle.js +21 -0
- package/esm/fieldset/fieldset-title.js +23 -0
- package/esm/fieldset/fieldset.js +96 -0
- package/esm/fieldset/index.js +13 -0
- package/esm/fieldset/stories.js +72 -0
- package/esm/grid/basic-item.js +96 -0
- package/esm/grid/grid-container.js +46 -0
- package/esm/grid/grid-types.js +6 -0
- package/esm/grid/grid.js +37 -0
- package/esm/grid/index.js +4 -0
- package/esm/grid/stories.js +212 -0
- package/esm/icon/stories.js +36 -0
- package/esm/image/helpers.js +16 -0
- package/esm/image/image-browser-https-icon.js +23 -0
- package/esm/image/image-browser.js +86 -0
- package/esm/image/image.js +91 -0
- package/esm/image/image.skeleton.js +21 -0
- package/esm/image/index.js +4 -0
- package/esm/image/stories.js +73 -0
- package/esm/image/styles.js +15 -0
- package/esm/index.js +69 -0
- package/esm/input/index.js +6 -0
- package/esm/input/input-block-label.js +18 -0
- package/esm/input/input-icon-clear.js +47 -0
- package/esm/input/input-icon.js +19 -0
- package/esm/input/input-label.js +18 -0
- package/esm/input/input-props.js +12 -0
- package/esm/input/input.js +179 -0
- package/esm/input/password-icon.js +30 -0
- package/esm/input/password.js +66 -0
- package/esm/input/stories.js +113 -0
- package/esm/input/styles.js +41 -0
- package/esm/keyboard/index.js +2 -0
- package/esm/keyboard/keyboard.js +48 -0
- package/esm/keyboard/stories.js +43 -0
- package/esm/link/icon.js +30 -0
- package/esm/link/index.js +2 -0
- package/esm/link/link.js +50 -0
- package/esm/link/stories.js +59 -0
- package/esm/loading/index.js +2 -0
- package/esm/loading/loading.js +63 -0
- package/esm/loading/stories.js +75 -0
- package/esm/mdx-widgets/index.js +2 -0
- package/esm/mdx-widgets/mock-page.js +37 -0
- package/esm/mdx-widgets/parsed-codes/index.js +1 -0
- package/esm/mdx-widgets/parsed-codes/wait-time.js +13 -0
- package/esm/modal/index.js +10 -0
- package/esm/modal/modal-action.js +76 -0
- package/esm/modal/modal-actions.js +39 -0
- package/esm/modal/modal-content.js +28 -0
- package/esm/modal/modal-context.js +6 -0
- package/esm/modal/modal-subtitle.js +30 -0
- package/esm/modal/modal-title.js +30 -0
- package/esm/modal/modal-wrapper.js +80 -0
- package/esm/modal/modal.js +104 -0
- package/esm/modal/stories.js +165 -0
- package/esm/note/index.js +2 -0
- package/esm/note/note.js +71 -0
- package/esm/note/stories.js +68 -0
- package/esm/page/index.js +9 -0
- package/esm/page/page-content.js +26 -0
- package/esm/page/page-footer.js +25 -0
- package/esm/page/page-header.js +33 -0
- package/esm/page/page.js +88 -0
- package/esm/page/stories.js +54 -0
- package/esm/pagination/index.js +6 -0
- package/esm/pagination/pagination-context.js +8 -0
- package/esm/pagination/pagination-ellipsis.js +73 -0
- package/esm/pagination/pagination-item.js +50 -0
- package/esm/pagination/pagination-next.js +25 -0
- package/esm/pagination/pagination-pages.js +90 -0
- package/esm/pagination/pagination-previous.js +25 -0
- package/esm/pagination/pagination.js +105 -0
- package/esm/pagination/stories.js +49 -0
- package/esm/popover/index.js +5 -0
- package/esm/popover/popover-context.js +9 -0
- package/esm/popover/popover-item.js +65 -0
- package/esm/popover/popover.js +83 -0
- package/esm/popover/stories.js +84 -0
- package/esm/progress/index.js +2 -0
- package/esm/progress/progress.js +76 -0
- package/esm/progress/stories.js +114 -0
- package/esm/radio/index.js +7 -0
- package/esm/radio/radio-context.js +9 -0
- package/esm/radio/radio-description.js +30 -0
- package/esm/radio/radio-group.js +61 -0
- package/esm/radio/radio.js +123 -0
- package/esm/radio/stories.js +98 -0
- package/esm/radio/styles.js +41 -0
- package/esm/rating/index.js +2 -0
- package/esm/rating/rating-icon.js +20 -0
- package/esm/rating/rating.js +115 -0
- package/esm/rating/stories.js +72 -0
- package/esm/row/index.js +2 -0
- package/esm/row/row.js +60 -0
- package/esm/section/index.js +2 -0
- package/esm/section/section.js +30 -0
- package/esm/select/index.js +4 -0
- package/esm/select/select-context.js +9 -0
- package/esm/select/select-dropdown.js +41 -0
- package/esm/select/select-icon-clear.js +41 -0
- package/esm/select/select-icon.js +23 -0
- package/esm/select/select-input.js +34 -0
- package/esm/select/select-multiple-value.js +23 -0
- package/esm/select/select-option.js +100 -0
- package/esm/select/select.js +244 -0
- package/esm/select/stories.js +239 -0
- package/esm/select/styles.js +48 -0
- package/esm/shared/backdrop.js +77 -0
- package/esm/shared/css-transition.js +71 -0
- package/esm/shared/dropdown.js +109 -0
- package/esm/shared/ellipsis.js +15 -0
- package/esm/shared/expand.js +95 -0
- package/esm/shared/highlight.js +47 -0
- package/esm/slider/index.js +2 -0
- package/esm/slider/slider-dot.js +27 -0
- package/esm/slider/slider-mark.js +38 -0
- package/esm/slider/slider.js +163 -0
- package/esm/slider/stories.js +134 -0
- package/esm/slider/styles.js +27 -0
- package/esm/snippet/index.js +2 -0
- package/esm/snippet/snippet-icon.js +27 -0
- package/esm/snippet/snippet.js +100 -0
- package/esm/snippet/stories.js +133 -0
- package/esm/snippet/styles.js +58 -0
- package/esm/spacer/index.js +2 -0
- package/esm/spacer/spacer.js +28 -0
- package/esm/spacer/stories.js +54 -0
- package/esm/spinner/index.js +2 -0
- package/esm/spinner/spinner.js +46 -0
- package/esm/spinner/stories.js +13 -0
- package/esm/styled-jsx-server.es.js +5 -0
- package/esm/styled-jsx.es.js +757 -0
- package/esm/tabs/index.js +5 -0
- package/esm/tabs/stories.js +92 -0
- package/esm/tabs/tabs-context.js +8 -0
- package/esm/tabs/tabs-item.js +80 -0
- package/esm/tabs/tabs.js +151 -0
- package/esm/tag/index.js +2 -0
- package/esm/tag/stories.js +58 -0
- package/esm/tag/tag.js +86 -0
- package/esm/text/child.js +78 -0
- package/esm/text/index.js +2 -0
- package/esm/text/stories.js +104 -0
- package/esm/text/text.js +94 -0
- package/esm/textarea/index.js +2 -0
- package/esm/textarea/stories.js +104 -0
- package/esm/textarea/textarea.js +116 -0
- package/esm/themes/index.js +2 -0
- package/esm/themes/presets/dark.js +67 -0
- package/esm/themes/presets/default.js +67 -0
- package/esm/themes/presets/index.js +1 -0
- package/esm/themes/presets/shared.js +42 -0
- package/esm/themes/themes.js +89 -0
- package/esm/toggle/index.js +2 -0
- package/esm/toggle/stories.js +55 -0
- package/esm/toggle/styles.js +27 -0
- package/esm/toggle/toggle.js +82 -0
- package/esm/tooltip/helper.js +21 -0
- package/esm/tooltip/index.js +2 -0
- package/esm/tooltip/placement.js +160 -0
- package/esm/tooltip/stories.js +183 -0
- package/esm/tooltip/styles.js +18 -0
- package/esm/tooltip/tooltip-content.js +83 -0
- package/esm/tooltip/tooltip-icon.js +32 -0
- package/esm/tooltip/tooltip.js +132 -0
- package/esm/use-all-themes/all-themes-context.js +9 -0
- package/esm/use-all-themes/index.js +2 -0
- package/esm/use-body-scroll/index.js +2 -0
- package/esm/use-body-scroll/use-body-scroll.js +70 -0
- package/esm/use-classes/index.js +2 -0
- package/esm/use-classes/use-classes.js +41 -0
- package/esm/use-click-away/index.js +2 -0
- package/esm/use-click-away/use-click-away.js +22 -0
- package/esm/use-clipboard/index.js +2 -0
- package/esm/use-clipboard/use-clipboard.js +46 -0
- package/esm/use-current-state/index.js +2 -0
- package/esm/use-current-state/use-current-state.js +26 -0
- package/esm/use-input/index.js +2 -0
- package/esm/use-input/use-input.js +32 -0
- package/esm/use-keyboard/codes.js +97 -0
- package/esm/use-keyboard/helper.js +26 -0
- package/esm/use-keyboard/index.js +4 -0
- package/esm/use-keyboard/use-keyboard.js +79 -0
- package/esm/use-media-query/index.js +2 -0
- package/esm/use-media-query/use-media-query.js +90 -0
- package/esm/use-modal/index.js +2 -0
- package/esm/use-modal/use-modal.js +26 -0
- package/esm/use-scale/index.js +6 -0
- package/esm/use-scale/scale-context.js +37 -0
- package/esm/use-scale/utils.js +62 -0
- package/esm/use-scale/with-scale.js +114 -0
- package/esm/use-tabs/index.js +2 -0
- package/esm/use-tabs/use-tabs.js +24 -0
- package/esm/use-theme/index.js +2 -0
- package/esm/use-theme/theme-context.js +7 -0
- package/esm/use-toasts/helpers.js +72 -0
- package/esm/use-toasts/index.js +2 -0
- package/esm/use-toasts/toast-container.js +127 -0
- package/esm/use-toasts/toast-item.js +48 -0
- package/esm/use-toasts/use-toast.js +124 -0
- package/esm/utils/calculations.js +27 -0
- package/esm/utils/collections.js +138 -0
- package/esm/utils/color.js +43 -0
- package/esm/utils/layouts.js +82 -0
- package/esm/utils/prop-types.js +22 -0
- package/esm/utils/types.js +1 -0
- package/esm/utils/use-body-scroll.js +2 -0
- package/esm/utils/use-bolio-ui-context.js +27 -0
- package/esm/utils/use-click-anywhere.js +16 -0
- package/esm/utils/use-click-away.js +2 -0
- package/esm/utils/use-clipboard.js +2 -0
- package/esm/utils/use-context-state/create-bolio-ui-context.js +57 -0
- package/esm/utils/use-context-state/use-context-state.js +44 -0
- package/esm/utils/use-current-state.js +2 -0
- package/esm/utils/use-default-props.js +22 -0
- package/esm/utils/use-dom-observer.js +28 -0
- package/esm/utils/use-drag.js +75 -0
- package/esm/utils/use-portal.js +40 -0
- package/esm/utils/use-previous.js +11 -0
- package/esm/utils/use-real-shape.js +53 -0
- package/esm/utils/use-resize.js +21 -0
- package/esm/utils/use-ssr.js +20 -0
- package/esm/utils/use-warning.js +17 -0
- package/package.json +140 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
3
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import useTheme from '../use-theme';
|
|
6
|
+
import usePortal from '../utils/use-portal';
|
|
7
|
+
import useResize from '../utils/use-resize';
|
|
8
|
+
import CssTransition from '../shared/css-transition';
|
|
9
|
+
import useClickAnyWhere from '../utils/use-click-anywhere';
|
|
10
|
+
import { getColors } from './styles';
|
|
11
|
+
import { getPosition, defaultTooltipPosition } from './placement';
|
|
12
|
+
import TooltipIcon from './tooltip-icon';
|
|
13
|
+
import useScale from '../use-scale';
|
|
14
|
+
import { getRect } from './helper';
|
|
15
|
+
import useClasses from '../use-classes';
|
|
16
|
+
|
|
17
|
+
var TooltipContent = function TooltipContent(_ref) {
|
|
18
|
+
var children = _ref.children,
|
|
19
|
+
parent = _ref.parent,
|
|
20
|
+
visible = _ref.visible,
|
|
21
|
+
offset = _ref.offset,
|
|
22
|
+
iconOffset = _ref.iconOffset,
|
|
23
|
+
placement = _ref.placement,
|
|
24
|
+
type = _ref.type,
|
|
25
|
+
className = _ref.className,
|
|
26
|
+
hideArrow = _ref.hideArrow;
|
|
27
|
+
var theme = useTheme();
|
|
28
|
+
|
|
29
|
+
var _useScale = useScale(),
|
|
30
|
+
SCALES = _useScale.SCALES;
|
|
31
|
+
|
|
32
|
+
var el = usePortal('tooltip');
|
|
33
|
+
var selfRef = useRef(null);
|
|
34
|
+
|
|
35
|
+
var _useState = useState(defaultTooltipPosition),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
rect = _useState2[0],
|
|
38
|
+
setRect = _useState2[1];
|
|
39
|
+
|
|
40
|
+
var colors = useMemo(function () {
|
|
41
|
+
return getColors(type, theme.palette);
|
|
42
|
+
}, [type, theme.palette]);
|
|
43
|
+
var hasShadow = type === 'default';
|
|
44
|
+
var classes = useClasses('tooltip-content', className);
|
|
45
|
+
if (!parent) return null;
|
|
46
|
+
|
|
47
|
+
var updateRect = function updateRect() {
|
|
48
|
+
var position = getPosition(placement, getRect(parent), offset);
|
|
49
|
+
setRect(position);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
useResize(updateRect);
|
|
53
|
+
useClickAnyWhere(function () {
|
|
54
|
+
return updateRect();
|
|
55
|
+
});
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
updateRect();
|
|
58
|
+
}, [visible]);
|
|
59
|
+
|
|
60
|
+
var preventHandler = function preventHandler(event) {
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (!el) return null;
|
|
66
|
+
return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(CssTransition, {
|
|
67
|
+
visible: visible
|
|
68
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
69
|
+
ref: selfRef,
|
|
70
|
+
onClick: preventHandler,
|
|
71
|
+
className: _JSXStyle.dynamic([["3734161695", [iconOffset.x, iconOffset.y, colors.bgColor, rect.top, rect.left, rect.transform, colors.color, theme.layout.radius, hasShadow ? theme.expressiveness.shadowMedium : 'none', SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.font(1), SCALES.pt(0.65), SCALES.pr(0.9), SCALES.pb(0.65), SCALES.pl(0.9)]]]) + " " + (classes || "")
|
|
72
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: _JSXStyle.dynamic([["3734161695", [iconOffset.x, iconOffset.y, colors.bgColor, rect.top, rect.left, rect.transform, colors.color, theme.layout.radius, hasShadow ? theme.expressiveness.shadowMedium : 'none', SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.font(1), SCALES.pt(0.65), SCALES.pr(0.9), SCALES.pb(0.65), SCALES.pl(0.9)]]]) + " " + "inner"
|
|
74
|
+
}, !hideArrow && /*#__PURE__*/React.createElement(TooltipIcon, {
|
|
75
|
+
placement: placement,
|
|
76
|
+
shadow: hasShadow
|
|
77
|
+
}), children), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
78
|
+
id: "3734161695",
|
|
79
|
+
dynamic: [iconOffset.x, iconOffset.y, colors.bgColor, rect.top, rect.left, rect.transform, colors.color, theme.layout.radius, hasShadow ? theme.expressiveness.shadowMedium : 'none', SCALES.width(1, 'auto'), SCALES.height(1, 'auto'), SCALES.font(1), SCALES.pt(0.65), SCALES.pr(0.9), SCALES.pb(0.65), SCALES.pl(0.9)]
|
|
80
|
+
}, ".tooltip-content.__jsx-style-dynamic-selector{--tooltip-icon-offset-x:".concat(iconOffset.x, ";--tooltip-icon-offset-y:").concat(iconOffset.y, ";--tooltip-content-bg:").concat(colors.bgColor, ";box-sizing:border-box;position:absolute;top:").concat(rect.top, ";left:").concat(rect.left, ";-webkit-transform:").concat(rect.transform, ";-ms-transform:").concat(rect.transform, ";transform:").concat(rect.transform, ";background-color:var(--tooltip-content-bg);color:").concat(colors.color, ";border-radius:").concat(theme.layout.radius, ";padding:0;z-index:1000;box-shadow:").concat(hasShadow ? theme.expressiveness.shadowMedium : 'none', ";width:").concat(SCALES.width(1, 'auto'), ";height:").concat(SCALES.height(1, 'auto'), ";}.inner.__jsx-style-dynamic-selector{box-sizing:border-box;position:relative;font-size:").concat(SCALES.font(1), ";padding:").concat(SCALES.pt(0.65), " ").concat(SCALES.pr(0.9), " ").concat(SCALES.pb(0.65), " ").concat(SCALES.pl(0.9), ";height:100%;}")))), el);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default TooltipContent;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { getIconPosition } from './placement';
|
|
4
|
+
import useTheme from '../use-theme';
|
|
5
|
+
|
|
6
|
+
var TooltipIcon = function TooltipIcon(_ref) {
|
|
7
|
+
var placement = _ref.placement,
|
|
8
|
+
shadow = _ref.shadow;
|
|
9
|
+
var theme = useTheme();
|
|
10
|
+
|
|
11
|
+
var _useMemo = useMemo(function () {
|
|
12
|
+
return getIconPosition(placement, 'var(--tooltip-icon-offset-x)', 'var(--tooltip-icon-offset-y)');
|
|
13
|
+
}, [placement]),
|
|
14
|
+
transform = _useMemo.transform,
|
|
15
|
+
top = _useMemo.top,
|
|
16
|
+
left = _useMemo.left,
|
|
17
|
+
right = _useMemo.right,
|
|
18
|
+
bottom = _useMemo.bottom;
|
|
19
|
+
|
|
20
|
+
var bgColorWithDark = useMemo(function () {
|
|
21
|
+
if (!shadow || theme.type !== 'dark') return 'var(--tooltip-content-bg)';
|
|
22
|
+
return theme.palette.accents_2;
|
|
23
|
+
}, [shadow, theme.type, theme.palette.accents_2]);
|
|
24
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
25
|
+
className: _JSXStyle.dynamic([["2440507693", [bgColorWithDark, left, top, right, bottom, transform]]])
|
|
26
|
+
}, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
27
|
+
id: "2440507693",
|
|
28
|
+
dynamic: [bgColorWithDark, left, top, right, bottom, transform]
|
|
29
|
+
}, "span.__jsx-style-dynamic-selector{width:0;height:0;border-style:solid;border-width:6px 7px 6px 0;border-color:transparent ".concat(bgColorWithDark, " transparent transparent;position:absolute;left:").concat(left, ";top:").concat(top, ";right:").concat(right, ";bottom:").concat(bottom, ";-webkit-transform:").concat(transform, ";-ms-transform:").concat(transform, ";transform:").concat(transform, ";}")));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default TooltipIcon;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["children", "initialVisible", "text", "offset", "placement", "portalClassName", "enterDelay", "leaveDelay", "trigger", "type", "className", "onVisibleChange", "hideArrow", "visible"];
|
|
5
|
+
import _JSXStyle from "../styled-jsx.es.js";
|
|
6
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import TooltipContent from './tooltip-content';
|
|
8
|
+
import useClickAway from '../utils/use-click-away';
|
|
9
|
+
import { withScale } from '../use-scale';
|
|
10
|
+
import { getRect } from './helper';
|
|
11
|
+
import useClasses from '../use-classes';
|
|
12
|
+
|
|
13
|
+
function TooltipComponent(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
_ref$initialVisible = _ref.initialVisible,
|
|
16
|
+
initialVisible = _ref$initialVisible === void 0 ? false : _ref$initialVisible,
|
|
17
|
+
_ref$text = _ref.text,
|
|
18
|
+
text = _ref$text === void 0 ? '' : _ref$text,
|
|
19
|
+
_ref$offset = _ref.offset,
|
|
20
|
+
offset = _ref$offset === void 0 ? 12 : _ref$offset,
|
|
21
|
+
_ref$placement = _ref.placement,
|
|
22
|
+
placement = _ref$placement === void 0 ? 'top' : _ref$placement,
|
|
23
|
+
_ref$portalClassName = _ref.portalClassName,
|
|
24
|
+
portalClassName = _ref$portalClassName === void 0 ? '' : _ref$portalClassName,
|
|
25
|
+
_ref$enterDelay = _ref.enterDelay,
|
|
26
|
+
enterDelay = _ref$enterDelay === void 0 ? 100 : _ref$enterDelay,
|
|
27
|
+
_ref$leaveDelay = _ref.leaveDelay,
|
|
28
|
+
leaveDelay = _ref$leaveDelay === void 0 ? 150 : _ref$leaveDelay,
|
|
29
|
+
_ref$trigger = _ref.trigger,
|
|
30
|
+
trigger = _ref$trigger === void 0 ? 'hover' : _ref$trigger,
|
|
31
|
+
_ref$type = _ref.type,
|
|
32
|
+
type = _ref$type === void 0 ? 'default' : _ref$type,
|
|
33
|
+
_ref$className = _ref.className,
|
|
34
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
35
|
+
_ref$onVisibleChange = _ref.onVisibleChange,
|
|
36
|
+
onVisibleChange = _ref$onVisibleChange === void 0 ? function () {} : _ref$onVisibleChange,
|
|
37
|
+
_ref$hideArrow = _ref.hideArrow,
|
|
38
|
+
hideArrow = _ref$hideArrow === void 0 ? false : _ref$hideArrow,
|
|
39
|
+
customVisible = _ref.visible,
|
|
40
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
+
|
|
42
|
+
var timer = useRef();
|
|
43
|
+
var ref = useRef(null);
|
|
44
|
+
|
|
45
|
+
var _useState = useState(initialVisible),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
visible = _useState2[0],
|
|
48
|
+
setVisible = _useState2[1];
|
|
49
|
+
|
|
50
|
+
var iconOffset = useMemo(function () {
|
|
51
|
+
if (!(ref !== null && ref !== void 0 && ref.current)) return {
|
|
52
|
+
x: '0.75em',
|
|
53
|
+
y: '0.75em'
|
|
54
|
+
};
|
|
55
|
+
var rect = getRect(ref);
|
|
56
|
+
return {
|
|
57
|
+
x: "".concat(rect.width ? rect.width / 2 : 0, "px"),
|
|
58
|
+
y: "".concat(rect.height ? rect.height / 2 : 0, "px")
|
|
59
|
+
};
|
|
60
|
+
}, [ref === null || ref === void 0 ? void 0 : ref.current]);
|
|
61
|
+
var contentProps = {
|
|
62
|
+
type: type,
|
|
63
|
+
visible: visible,
|
|
64
|
+
offset: offset,
|
|
65
|
+
placement: placement,
|
|
66
|
+
hideArrow: hideArrow,
|
|
67
|
+
iconOffset: iconOffset,
|
|
68
|
+
parent: ref,
|
|
69
|
+
className: portalClassName
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var changeVisible = function changeVisible(nextState) {
|
|
73
|
+
var clear = function clear() {
|
|
74
|
+
clearTimeout(timer.current);
|
|
75
|
+
timer.current = undefined;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var handler = function handler(nextState) {
|
|
79
|
+
setVisible(nextState);
|
|
80
|
+
onVisibleChange(nextState);
|
|
81
|
+
clear();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
clear();
|
|
85
|
+
|
|
86
|
+
if (nextState) {
|
|
87
|
+
timer.current = window.setTimeout(function () {
|
|
88
|
+
return handler(true);
|
|
89
|
+
}, enterDelay);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var leaveDelayWithoutClick = trigger === 'click' ? 0 : leaveDelay;
|
|
94
|
+
timer.current = window.setTimeout(function () {
|
|
95
|
+
return handler(false);
|
|
96
|
+
}, leaveDelayWithoutClick);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var mouseEventHandler = function mouseEventHandler(next) {
|
|
100
|
+
return trigger === 'hover' && changeVisible(next);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
var clickEventHandler = function clickEventHandler() {
|
|
104
|
+
return trigger === 'click' && changeVisible(!visible);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
useClickAway(ref, function () {
|
|
108
|
+
return trigger === 'click' && changeVisible(false);
|
|
109
|
+
});
|
|
110
|
+
useEffect(function () {
|
|
111
|
+
if (customVisible === undefined) return;
|
|
112
|
+
changeVisible(customVisible);
|
|
113
|
+
}, [customVisible]);
|
|
114
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
115
|
+
ref: ref,
|
|
116
|
+
onClick: clickEventHandler,
|
|
117
|
+
onMouseEnter: function onMouseEnter() {
|
|
118
|
+
return mouseEventHandler(true);
|
|
119
|
+
},
|
|
120
|
+
onMouseLeave: function onMouseLeave() {
|
|
121
|
+
return mouseEventHandler(false);
|
|
122
|
+
}
|
|
123
|
+
}, props, {
|
|
124
|
+
className: "jsx-418573366" + " " + (props && props.className != null && props.className || useClasses('tooltip', className) || "")
|
|
125
|
+
}), children, /*#__PURE__*/React.createElement(TooltipContent, contentProps, text), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
126
|
+
id: "418573366"
|
|
127
|
+
}, ".tooltip.jsx-418573366{width:-webkit-max-content;width:-moz-max-content;width:max-content;display:inline-block;}"));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
TooltipComponent.displayName = 'BolioUITooltip';
|
|
131
|
+
var Tooltip = withScale(TooltipComponent);
|
|
132
|
+
export default Tooltip;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Themes from '../themes/themes';
|
|
3
|
+
var defaultAllThemesConfig = {
|
|
4
|
+
themes: Themes.getPresets()
|
|
5
|
+
};
|
|
6
|
+
export var AllThemesContext = /*#__PURE__*/React.createContext(defaultAllThemesConfig);
|
|
7
|
+
export var useAllThemes = function useAllThemes() {
|
|
8
|
+
return React.useContext(AllThemesContext);
|
|
9
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
var defaultOptions = {
|
|
5
|
+
scrollLayer: false,
|
|
6
|
+
delayReset: 0
|
|
7
|
+
};
|
|
8
|
+
var elementStack = new Map();
|
|
9
|
+
|
|
10
|
+
var getOwnerPaddingRight = function getOwnerPaddingRight(element) {
|
|
11
|
+
var owner = (element === null || element === void 0 ? void 0 : element.ownerDocument) || document;
|
|
12
|
+
var view = owner.defaultView || window;
|
|
13
|
+
return Number.parseInt(view.getComputedStyle(element).paddingRight, 10) || 0;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var getOwnerScrollbarWidth = function getOwnerScrollbarWidth(element) {
|
|
17
|
+
var doc = (element === null || element === void 0 ? void 0 : element.ownerDocument) || document;
|
|
18
|
+
return Math.abs(window.innerWidth - doc.documentElement.clientWidth);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function useBodyScroll(elementRef, options) {
|
|
22
|
+
if (typeof document === 'undefined') return [false, function (t) {
|
|
23
|
+
return t;
|
|
24
|
+
}];
|
|
25
|
+
var elRef = elementRef || useRef(document.body);
|
|
26
|
+
|
|
27
|
+
var _useState = useState(false),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
hidden = _useState2[0],
|
|
30
|
+
setHidden = _useState2[1];
|
|
31
|
+
|
|
32
|
+
var safeOptions = _extends({}, defaultOptions, options || {});
|
|
33
|
+
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
if (!elRef || !elRef.current) return;
|
|
36
|
+
var lastOverflow = elRef.current.style.overflow;
|
|
37
|
+
|
|
38
|
+
if (hidden) {
|
|
39
|
+
if (elementStack.has(elRef.current)) return;
|
|
40
|
+
var paddingRight = getOwnerPaddingRight(elRef.current);
|
|
41
|
+
var scrollbarWidth = getOwnerScrollbarWidth(elRef.current);
|
|
42
|
+
elementStack.set(elRef.current, {
|
|
43
|
+
overflow: lastOverflow,
|
|
44
|
+
paddingRight: elRef.current.style.paddingRight
|
|
45
|
+
});
|
|
46
|
+
elRef.current.style.overflow = 'hidden';
|
|
47
|
+
elRef.current.style.paddingRight = "".concat(paddingRight + scrollbarWidth, "px");
|
|
48
|
+
return;
|
|
49
|
+
} // reset element overflow
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if (!elementStack.has(elRef.current)) return;
|
|
53
|
+
|
|
54
|
+
var reset = function reset(el) {
|
|
55
|
+
var store = elementStack.get(el);
|
|
56
|
+
if (!store) return;
|
|
57
|
+
el.style.overflow = store.overflow;
|
|
58
|
+
el.style.paddingRight = store.paddingRight;
|
|
59
|
+
elementStack["delete"](el);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var timer = window.setTimeout(function () {
|
|
63
|
+
reset(elRef.current);
|
|
64
|
+
window.clearTimeout(timer);
|
|
65
|
+
}, safeOptions.delayReset);
|
|
66
|
+
}, [hidden, elRef]);
|
|
67
|
+
return [hidden, setHidden];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default useBodyScroll;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
|
|
3
|
+
var classObjectToString = function classObjectToString(className) {
|
|
4
|
+
var keys = Object.keys(className);
|
|
5
|
+
var len = keys.length;
|
|
6
|
+
var str = '';
|
|
7
|
+
|
|
8
|
+
for (var index = 0; index < len; index++) {
|
|
9
|
+
var key = keys[index];
|
|
10
|
+
var val = className[keys[index]];
|
|
11
|
+
if (!val) continue;
|
|
12
|
+
str = str ? "".concat(str, " ").concat(String(key)) : String(key);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return str;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var isObjectClassName = function isObjectClassName(value) {
|
|
19
|
+
return _typeof(value) === 'object' && !Array.isArray(value);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var useClasses = function useClasses() {
|
|
23
|
+
var len = arguments.length;
|
|
24
|
+
var classes = '';
|
|
25
|
+
if (len === 0) return classes;
|
|
26
|
+
|
|
27
|
+
for (var index = 0; index < len; index++) {
|
|
28
|
+
var val = index < 0 || arguments.length <= index ? undefined : arguments[index];
|
|
29
|
+
if (!val) continue;
|
|
30
|
+
|
|
31
|
+
if (isObjectClassName(val)) {
|
|
32
|
+
classes += " ".concat(classObjectToString(val));
|
|
33
|
+
} else {
|
|
34
|
+
classes += " ".concat(String(val).trim());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return classes.trim();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default useClasses;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
var useClickAway = function useClickAway(ref, handler) {
|
|
4
|
+
var handlerRef = useRef(handler);
|
|
5
|
+
useEffect(function () {
|
|
6
|
+
handlerRef.current = handler;
|
|
7
|
+
}, [handler]);
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
var callback = function callback(event) {
|
|
10
|
+
var el = ref.current;
|
|
11
|
+
if (!event || !el || el.contains(event.target)) return;
|
|
12
|
+
handlerRef.current(event);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
document.addEventListener('click', callback);
|
|
16
|
+
return function () {
|
|
17
|
+
return document.removeEventListener('click', callback);
|
|
18
|
+
};
|
|
19
|
+
}, [ref]);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default useClickAway;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import usePortal from '../utils/use-portal';
|
|
2
|
+
import useWarning from '../utils/use-warning';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
var defaultOptions = {
|
|
5
|
+
onError: function onError() {
|
|
6
|
+
return useWarning('Failed to copy.', 'use-clipboard');
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
var useClipboard = function useClipboard() {
|
|
11
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultOptions;
|
|
12
|
+
var el = usePortal('clipboard');
|
|
13
|
+
|
|
14
|
+
var copyText = function copyText(el, text) {
|
|
15
|
+
if (!el || !text) return;
|
|
16
|
+
var selection = window.getSelection();
|
|
17
|
+
if (!selection) return;
|
|
18
|
+
el.style.whiteSpace = 'pre';
|
|
19
|
+
el.textContent = text;
|
|
20
|
+
var range = window.document.createRange();
|
|
21
|
+
selection.removeAllRanges();
|
|
22
|
+
range.selectNode(el);
|
|
23
|
+
selection.addRange(range);
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
window.document.execCommand('copy');
|
|
27
|
+
} catch (e) {
|
|
28
|
+
options.onError && options.onError();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
selection.removeAllRanges();
|
|
32
|
+
|
|
33
|
+
if (el) {
|
|
34
|
+
el.textContent = '';
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var copy = useCallback(function (text) {
|
|
39
|
+
copyText(el, text);
|
|
40
|
+
}, [el]);
|
|
41
|
+
return {
|
|
42
|
+
copy: copy
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default useClipboard;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
var useCurrentState = function useCurrentState(initialState) {
|
|
5
|
+
var _useState = useState(function () {
|
|
6
|
+
return typeof initialState === 'function' ? initialState() : initialState;
|
|
7
|
+
}),
|
|
8
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
9
|
+
state = _useState2[0],
|
|
10
|
+
setState = _useState2[1];
|
|
11
|
+
|
|
12
|
+
var ref = useRef(initialState);
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
ref.current = state;
|
|
15
|
+
}, [state]);
|
|
16
|
+
|
|
17
|
+
var setValue = function setValue(val) {
|
|
18
|
+
var result = typeof val === 'function' ? val(ref.current) : val;
|
|
19
|
+
ref.current = result;
|
|
20
|
+
setState(result);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return [state, setValue, ref];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default useCurrentState;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import useCurrentState from '../utils/use-current-state';
|
|
4
|
+
|
|
5
|
+
var useInput = function useInput(initialValue) {
|
|
6
|
+
var _useCurrentState = useCurrentState(initialValue),
|
|
7
|
+
_useCurrentState2 = _slicedToArray(_useCurrentState, 3),
|
|
8
|
+
state = _useCurrentState2[0],
|
|
9
|
+
setState = _useCurrentState2[1],
|
|
10
|
+
currentRef = _useCurrentState2[2];
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
state: state,
|
|
14
|
+
setState: setState,
|
|
15
|
+
currentRef: currentRef,
|
|
16
|
+
reset: function reset() {
|
|
17
|
+
return setState(initialValue);
|
|
18
|
+
},
|
|
19
|
+
bindings: {
|
|
20
|
+
value: state,
|
|
21
|
+
onChange: function onChange(event) {
|
|
22
|
+
if (_typeof(event) === 'object' && event.target) {
|
|
23
|
+
setState(event.target.value);
|
|
24
|
+
} else {
|
|
25
|
+
setState(event);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default useInput;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KeyBinding Codes
|
|
3
|
+
* The content of this file is based on the design of the open source project "microsoft/vscode",
|
|
4
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* We inherit the KeyMod values from "microsoft/vscode",
|
|
7
|
+
* but use the Browser's KeyboardEvent event implementation, and all values are used only as identification.
|
|
8
|
+
*/
|
|
9
|
+
export var KeyCode;
|
|
10
|
+
|
|
11
|
+
(function (KeyCode) {
|
|
12
|
+
KeyCode[KeyCode["Unknown"] = 0] = "Unknown";
|
|
13
|
+
KeyCode[KeyCode["Backspace"] = 8] = "Backspace";
|
|
14
|
+
KeyCode[KeyCode["Tab"] = 9] = "Tab";
|
|
15
|
+
KeyCode[KeyCode["Enter"] = 13] = "Enter";
|
|
16
|
+
KeyCode[KeyCode["Shift"] = 16] = "Shift";
|
|
17
|
+
KeyCode[KeyCode["Ctrl"] = 17] = "Ctrl";
|
|
18
|
+
KeyCode[KeyCode["Alt"] = 18] = "Alt";
|
|
19
|
+
KeyCode[KeyCode["PauseBreak"] = 19] = "PauseBreak";
|
|
20
|
+
KeyCode[KeyCode["CapsLock"] = 20] = "CapsLock";
|
|
21
|
+
KeyCode[KeyCode["Escape"] = 27] = "Escape";
|
|
22
|
+
KeyCode[KeyCode["Space"] = 32] = "Space";
|
|
23
|
+
KeyCode[KeyCode["PageUp"] = 33] = "PageUp";
|
|
24
|
+
KeyCode[KeyCode["PageDown"] = 34] = "PageDown";
|
|
25
|
+
KeyCode[KeyCode["End"] = 35] = "End";
|
|
26
|
+
KeyCode[KeyCode["Home"] = 36] = "Home";
|
|
27
|
+
KeyCode[KeyCode["LeftArrow"] = 37] = "LeftArrow";
|
|
28
|
+
KeyCode[KeyCode["UpArrow"] = 38] = "UpArrow";
|
|
29
|
+
KeyCode[KeyCode["RightArrow"] = 39] = "RightArrow";
|
|
30
|
+
KeyCode[KeyCode["DownArrow"] = 40] = "DownArrow";
|
|
31
|
+
KeyCode[KeyCode["Insert"] = 45] = "Insert";
|
|
32
|
+
KeyCode[KeyCode["Delete"] = 46] = "Delete";
|
|
33
|
+
KeyCode[KeyCode["KEY_0"] = 48] = "KEY_0";
|
|
34
|
+
KeyCode[KeyCode["KEY_1"] = 49] = "KEY_1";
|
|
35
|
+
KeyCode[KeyCode["KEY_2"] = 50] = "KEY_2";
|
|
36
|
+
KeyCode[KeyCode["KEY_3"] = 51] = "KEY_3";
|
|
37
|
+
KeyCode[KeyCode["KEY_4"] = 52] = "KEY_4";
|
|
38
|
+
KeyCode[KeyCode["KEY_5"] = 53] = "KEY_5";
|
|
39
|
+
KeyCode[KeyCode["KEY_6"] = 54] = "KEY_6";
|
|
40
|
+
KeyCode[KeyCode["KEY_7"] = 55] = "KEY_7";
|
|
41
|
+
KeyCode[KeyCode["KEY_8"] = 56] = "KEY_8";
|
|
42
|
+
KeyCode[KeyCode["KEY_9"] = 57] = "KEY_9";
|
|
43
|
+
KeyCode[KeyCode["KEY_A"] = 65] = "KEY_A";
|
|
44
|
+
KeyCode[KeyCode["KEY_B"] = 66] = "KEY_B";
|
|
45
|
+
KeyCode[KeyCode["KEY_C"] = 67] = "KEY_C";
|
|
46
|
+
KeyCode[KeyCode["KEY_D"] = 68] = "KEY_D";
|
|
47
|
+
KeyCode[KeyCode["KEY_E"] = 69] = "KEY_E";
|
|
48
|
+
KeyCode[KeyCode["KEY_F"] = 70] = "KEY_F";
|
|
49
|
+
KeyCode[KeyCode["KEY_G"] = 71] = "KEY_G";
|
|
50
|
+
KeyCode[KeyCode["KEY_H"] = 72] = "KEY_H";
|
|
51
|
+
KeyCode[KeyCode["KEY_I"] = 73] = "KEY_I";
|
|
52
|
+
KeyCode[KeyCode["KEY_J"] = 74] = "KEY_J";
|
|
53
|
+
KeyCode[KeyCode["KEY_K"] = 75] = "KEY_K";
|
|
54
|
+
KeyCode[KeyCode["KEY_L"] = 76] = "KEY_L";
|
|
55
|
+
KeyCode[KeyCode["KEY_M"] = 77] = "KEY_M";
|
|
56
|
+
KeyCode[KeyCode["KEY_N"] = 78] = "KEY_N";
|
|
57
|
+
KeyCode[KeyCode["KEY_O"] = 79] = "KEY_O";
|
|
58
|
+
KeyCode[KeyCode["KEY_P"] = 80] = "KEY_P";
|
|
59
|
+
KeyCode[KeyCode["KEY_Q"] = 81] = "KEY_Q";
|
|
60
|
+
KeyCode[KeyCode["KEY_R"] = 82] = "KEY_R";
|
|
61
|
+
KeyCode[KeyCode["KEY_S"] = 83] = "KEY_S";
|
|
62
|
+
KeyCode[KeyCode["KEY_T"] = 84] = "KEY_T";
|
|
63
|
+
KeyCode[KeyCode["KEY_U"] = 85] = "KEY_U";
|
|
64
|
+
KeyCode[KeyCode["KEY_V"] = 86] = "KEY_V";
|
|
65
|
+
KeyCode[KeyCode["KEY_W"] = 87] = "KEY_W";
|
|
66
|
+
KeyCode[KeyCode["KEY_X"] = 88] = "KEY_X";
|
|
67
|
+
KeyCode[KeyCode["KEY_Y"] = 89] = "KEY_Y";
|
|
68
|
+
KeyCode[KeyCode["KEY_Z"] = 90] = "KEY_Z";
|
|
69
|
+
KeyCode[KeyCode["Meta"] = 91] = "Meta";
|
|
70
|
+
KeyCode[KeyCode["F1"] = 112] = "F1";
|
|
71
|
+
KeyCode[KeyCode["F2"] = 113] = "F2";
|
|
72
|
+
KeyCode[KeyCode["F3"] = 114] = "F3";
|
|
73
|
+
KeyCode[KeyCode["F4"] = 115] = "F4";
|
|
74
|
+
KeyCode[KeyCode["F5"] = 116] = "F5";
|
|
75
|
+
KeyCode[KeyCode["F6"] = 117] = "F6";
|
|
76
|
+
KeyCode[KeyCode["F7"] = 118] = "F7";
|
|
77
|
+
KeyCode[KeyCode["F8"] = 119] = "F8";
|
|
78
|
+
KeyCode[KeyCode["F9"] = 120] = "F9";
|
|
79
|
+
KeyCode[KeyCode["F10"] = 121] = "F10";
|
|
80
|
+
KeyCode[KeyCode["F11"] = 122] = "F11";
|
|
81
|
+
KeyCode[KeyCode["F12"] = 123] = "F12";
|
|
82
|
+
KeyCode[KeyCode["NumLock"] = 144] = "NumLock";
|
|
83
|
+
KeyCode[KeyCode["ScrollLock"] = 145] = "ScrollLock";
|
|
84
|
+
KeyCode[KeyCode["Equal"] = 187] = "Equal";
|
|
85
|
+
KeyCode[KeyCode["Minus"] = 189] = "Minus";
|
|
86
|
+
KeyCode[KeyCode["Backquote"] = 192] = "Backquote";
|
|
87
|
+
KeyCode[KeyCode["Backslash"] = 220] = "Backslash";
|
|
88
|
+
})(KeyCode || (KeyCode = {}));
|
|
89
|
+
|
|
90
|
+
export var KeyMod;
|
|
91
|
+
|
|
92
|
+
(function (KeyMod) {
|
|
93
|
+
KeyMod[KeyMod["CtrlCmd"] = 2048] = "CtrlCmd";
|
|
94
|
+
KeyMod[KeyMod["Shift"] = 1024] = "Shift";
|
|
95
|
+
KeyMod[KeyMod["Alt"] = 512] = "Alt";
|
|
96
|
+
KeyMod[KeyMod["WinCtrl"] = 256] = "WinCtrl";
|
|
97
|
+
})(KeyMod || (KeyMod = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isMac } from '../utils/collections';
|
|
2
|
+
import { KeyMod } from './codes';
|
|
3
|
+
/* istanbul ignore next */
|
|
4
|
+
|
|
5
|
+
export var getCtrlKeysByPlatform = function getCtrlKeysByPlatform() {
|
|
6
|
+
return {
|
|
7
|
+
CtrlCmd: isMac() ? 'metaKey' : 'ctrlKey',
|
|
8
|
+
WinCtrl: isMac() ? 'ctrlKey' : 'metaKey'
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export var getActiveModMap = function getActiveModMap(bindings) {
|
|
12
|
+
var modBindings = bindings.filter(function (item) {
|
|
13
|
+
return !!KeyMod[item];
|
|
14
|
+
});
|
|
15
|
+
var activeModMap = {
|
|
16
|
+
CtrlCmd: false,
|
|
17
|
+
Shift: false,
|
|
18
|
+
Alt: false,
|
|
19
|
+
WinCtrl: false
|
|
20
|
+
};
|
|
21
|
+
modBindings.forEach(function (code) {
|
|
22
|
+
var modKey = KeyMod[code];
|
|
23
|
+
activeModMap[modKey] = true;
|
|
24
|
+
});
|
|
25
|
+
return activeModMap;
|
|
26
|
+
};
|