@startlibs/components 1.0.4 → 1.1.1
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/lib/BasicBulletList.mjs +9 -0
- package/lib/BasicBulletList.mjs.map +1 -0
- package/lib/Button.mjs +95 -0
- package/lib/Button.mjs.map +1 -0
- package/lib/ContextMenu.mjs +452 -0
- package/lib/ContextMenu.mjs.map +1 -0
- package/lib/Dialog.mjs +232 -0
- package/lib/Dialog.mjs.map +1 -0
- package/lib/Draggable.mjs +880 -0
- package/lib/Draggable.mjs.map +1 -0
- package/lib/ErrorBoundary.mjs +108 -0
- package/lib/ErrorBoundary.mjs.map +1 -0
- package/lib/FillLastLineResizer.mjs +238 -0
- package/lib/FillLastLineResizer.mjs.map +1 -0
- package/lib/Flip.mjs +604 -0
- package/lib/Flip.mjs.map +1 -0
- package/lib/FlipList.mjs +186 -0
- package/lib/FlipList.mjs.map +1 -0
- package/lib/FormatDate.mjs +25 -0
- package/lib/FormatDate.mjs.map +1 -0
- package/lib/Icon.mjs +50 -0
- package/lib/Icon.mjs.map +1 -0
- package/lib/Image.mjs +41 -0
- package/lib/Image.mjs.map +1 -0
- package/lib/Link.mjs +116 -0
- package/lib/Link.mjs.map +1 -0
- package/lib/Loading.mjs +10 -0
- package/lib/Loading.mjs.map +1 -0
- package/lib/LoadingDiv.mjs +83 -0
- package/lib/LoadingDiv.mjs.map +1 -0
- package/lib/Notifications.mjs +63 -0
- package/lib/Notifications.mjs.map +1 -0
- package/lib/PageLoader.mjs +42 -0
- package/lib/PageLoader.mjs.map +1 -0
- package/lib/PersistentNotifications.mjs +130 -0
- package/lib/PersistentNotifications.mjs.map +1 -0
- package/lib/Popup.mjs +49 -0
- package/lib/Popup.mjs.map +1 -0
- package/lib/SplitColumnsContainer.mjs +43 -0
- package/lib/SplitColumnsContainer.mjs.map +1 -0
- package/lib/SwitchDiv.mjs +61 -0
- package/lib/SwitchDiv.mjs.map +1 -0
- package/lib/TextButton.mjs +41 -0
- package/lib/TextButton.mjs.map +1 -0
- package/lib/ToastNotifications.mjs +215 -0
- package/lib/ToastNotifications.mjs.map +1 -0
- package/lib/Tooltip.mjs +160 -0
- package/lib/Tooltip.mjs.map +1 -0
- package/lib/TransitionDiv.mjs +56 -0
- package/lib/TransitionDiv.mjs.map +1 -0
- package/lib/WarningDialog.mjs +84 -0
- package/lib/WarningDialog.mjs.map +1 -0
- package/lib/alt/buttons/OnClickLoadingButton.mjs +36 -0
- package/lib/alt/buttons/OnClickLoadingButton.mjs.map +1 -0
- package/lib/alt/dialogs/DialogWithImageHeader.mjs +14 -0
- package/lib/alt/dialogs/DialogWithImageHeader.mjs.map +1 -0
- package/lib/alt/dialogs/DialogWithSidebar.mjs +106 -0
- package/lib/alt/dialogs/DialogWithSidebar.mjs.map +1 -0
- package/lib/alt/dialogs/MobileBubbleDialog.mjs +49 -0
- package/lib/alt/dialogs/MobileBubbleDialog.mjs.map +1 -0
- package/lib/containers/DialogContainer.mjs +413 -0
- package/lib/containers/DialogContainer.mjs.map +1 -0
- package/lib/containers/Reposition.mjs +35 -0
- package/lib/containers/Reposition.mjs.map +1 -0
- package/lib/containers/usePositioning.mjs +294 -0
- package/lib/containers/usePositioning.mjs.map +1 -0
- package/lib/index.cjs +5000 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.mjs +37 -0
- package/lib/index.mjs.map +1 -0
- package/lib/useDialogWithToggle.mjs +18 -0
- package/lib/useDialogWithToggle.mjs.map +1 -0
- package/lib/willUseIsSticky.mjs +123 -0
- package/lib/willUseIsSticky.mjs.map +1 -0
- package/package.json +47 -30
- package/src/BasicBulletList.jsx +21 -0
- package/src/Button.jsx +288 -0
- package/src/ContextMenu.jsx +621 -0
- package/src/Dialog.jsx +413 -0
- package/src/Draggable.jsx +801 -0
- package/src/ErrorBoundary.jsx +75 -0
- package/src/FillLastLineResizer.jsx +226 -0
- package/src/Flip.jsx +560 -0
- package/src/FlipList.jsx +136 -0
- package/src/FormatDate.jsx +9 -0
- package/src/Icon.jsx +49 -0
- package/src/Image.jsx +23 -0
- package/src/Link.jsx +68 -0
- package/src/Loading.jsx +29 -0
- package/src/LoadingDiv.jsx +75 -0
- package/src/Notifications.jsx +89 -0
- package/src/PageLoader.jsx +48 -0
- package/src/PersistentNotifications.jsx +182 -0
- package/src/Popup.jsx +49 -0
- package/src/SplitColumnsContainer.jsx +63 -0
- package/src/SwitchDiv.jsx +30 -0
- package/src/TextButton.jsx +34 -0
- package/src/ToastNotifications.jsx +298 -0
- package/src/Tooltip.jsx +158 -0
- package/src/TransitionDiv.jsx +34 -0
- package/src/WarningDialog.jsx +70 -0
- package/src/alt/buttons/OnClickLoadingButton.jsx +16 -0
- package/src/alt/dialogs/DialogWithImageHeader.jsx +42 -0
- package/src/alt/dialogs/DialogWithSidebar.jsx +135 -0
- package/src/alt/dialogs/MobileBubbleDialog.jsx +56 -0
- package/src/containers/DialogContainer.jsx +423 -0
- package/src/containers/Reposition.jsx +24 -0
- package/src/containers/usePositioning.jsx +305 -0
- package/src/index.js +35 -0
- package/src/useDialogWithToggle.jsx +12 -0
- package/src/willUseIsSticky.jsx +113 -0
- package/.babelrc +0 -27
- package/lib/index.js +0 -5429
- package/rollup.config.js +0 -52
- package/yarn-error.log +0 -3724
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const BasicBulletList = /*#__PURE__*/styled.ul.withConfig({
|
|
4
|
+
displayName: "BasicBulletList",
|
|
5
|
+
componentId: "sc-1u3hhup-0"
|
|
6
|
+
})(["margin-bottom:0;font-size:13px;li{margin-top:4px;padding-left:1rem;position:relative;:before{content:'\u2022';font-size:17px;line-height:0;position:absolute;left:0;top:7px;}}"]);
|
|
7
|
+
|
|
8
|
+
export { BasicBulletList };
|
|
9
|
+
//# sourceMappingURL=BasicBulletList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasicBulletList.mjs","sources":["../src/BasicBulletList.jsx"],"sourcesContent":["import styled from 'styled-components'\n\nexport const BasicBulletList = styled.ul`\n margin-bottom: 0;\n font-size: 13px;\n\n li {\n margin-top: 4px;\n padding-left: 1rem;\n position: relative;\n\n :before {\n content: '•';\n font-size: 17px;\n line-height: 0;\n position: absolute;\n left: 0;\n top: 7px;\n }\n }\n`"],"names":["BasicBulletList","styled","ul","withConfig","displayName","componentId"],"mappings":";;MAEaA,eAAe,gBAAGC,MAAM,CAACC,EAAE,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,iBAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAkBvC,CAAA,CAAA,CAAA,gLAAA,CAAA;;;;"}
|
package/lib/Button.mjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { styledExtend, getColor, media, customTheme } from '@startlibs/utils';
|
|
6
|
+
import { darken, transparentize } from 'polished';
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { Icon } from './Icon.mjs';
|
|
9
|
+
import { Link } from './Link.mjs';
|
|
10
|
+
import { Loading } from './Loading.mjs';
|
|
11
|
+
|
|
12
|
+
const _excluded = ["type", "locked", "color", "alpha", "success", "alert", "warning", "highlight", "light", "hover", "white", "icon", "onlyIcon", "small", "withDropdown", "onlyDropdown", "outline", "dashed", "textOnly", "isLoading", "isLoadingIcon", "dark", "innerAs", "className", "children", "rounded", "tabIndex", "focused", "noFocus", "colorSet", "concealed", "concealedModule", "buttonRef"];
|
|
13
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
14
|
+
const DropdownIcon = styledExtend(Icon)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 51%;\n transform: translateY(-50%);\n right: 1rem;\n font-size: 12px;\n"])));
|
|
15
|
+
const LockIcon = /*#__PURE__*/styled(Icon).withConfig({
|
|
16
|
+
displayName: "Button__LockIcon",
|
|
17
|
+
componentId: "sc-qe54pl-0"
|
|
18
|
+
})(["position:absolute;bottom:10px;right:.75rem;left:auto;top:auto;font-size:18px;"]);
|
|
19
|
+
const focus = /*#__PURE__*/css([":after{content:'';pointer-events:none;position:absolute;top:-3px;right:-3px;left:-3px;bottom:-3px;border-radius:", ";border:2px solid rgba(0,0,0,0.15);}"], props => props.rounded ? '100px' : '11px');
|
|
20
|
+
const Button = /*#__PURE__*/styled(/*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
21
|
+
let {
|
|
22
|
+
type = "button",
|
|
23
|
+
locked,
|
|
24
|
+
color,
|
|
25
|
+
alpha,
|
|
26
|
+
success,
|
|
27
|
+
alert,
|
|
28
|
+
warning,
|
|
29
|
+
highlight,
|
|
30
|
+
light,
|
|
31
|
+
hover,
|
|
32
|
+
white,
|
|
33
|
+
icon,
|
|
34
|
+
onlyIcon,
|
|
35
|
+
small,
|
|
36
|
+
withDropdown,
|
|
37
|
+
onlyDropdown,
|
|
38
|
+
outline,
|
|
39
|
+
dashed,
|
|
40
|
+
textOnly,
|
|
41
|
+
isLoading,
|
|
42
|
+
isLoadingIcon,
|
|
43
|
+
dark,
|
|
44
|
+
innerAs: Wrapper = 'button',
|
|
45
|
+
className,
|
|
46
|
+
children,
|
|
47
|
+
rounded,
|
|
48
|
+
tabIndex = 1,
|
|
49
|
+
focused,
|
|
50
|
+
noFocus,
|
|
51
|
+
colorSet,
|
|
52
|
+
concealed,
|
|
53
|
+
concealedModule,
|
|
54
|
+
buttonRef
|
|
55
|
+
} = _ref,
|
|
56
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
57
|
+
return /*#__PURE__*/React.createElement(Wrapper, _extends({
|
|
58
|
+
ref: ref || buttonRef,
|
|
59
|
+
tabIndex: tabIndex,
|
|
60
|
+
className: className + ' styled-button' + (color || success || alert || warning || highlight || dark || hover || outline || dashed || textOnly || white || alpha || props.lightAlert || props.lightWarning ? ' styled-button-colored' : ''),
|
|
61
|
+
type: Wrapper === 'button' ? type : ''
|
|
62
|
+
}, props), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
63
|
+
icon: icon,
|
|
64
|
+
"aria-hidden": "true"
|
|
65
|
+
}), isLoadingIcon && /*#__PURE__*/React.createElement(Loading, {
|
|
66
|
+
white: !light && !outline && !dashed && !white,
|
|
67
|
+
size: small ? '10' : '18',
|
|
68
|
+
borderWidth: small ? '2' : '3'
|
|
69
|
+
}), (withDropdown || onlyDropdown) && !locked && /*#__PURE__*/React.createElement(DropdownIcon, {
|
|
70
|
+
icon: "arrow-down",
|
|
71
|
+
"aria-hidden": "true"
|
|
72
|
+
}), locked && /*#__PURE__*/React.createElement(LockIcon, {
|
|
73
|
+
icon: "lock",
|
|
74
|
+
"aria-hidden": "true"
|
|
75
|
+
}), children, isLoading && /*#__PURE__*/React.createElement(Loading, {
|
|
76
|
+
white: !light && !outline && !dashed && !white,
|
|
77
|
+
absolute: true,
|
|
78
|
+
size: small && '16',
|
|
79
|
+
borderWidth: small && '3'
|
|
80
|
+
}));
|
|
81
|
+
})).withConfig({
|
|
82
|
+
displayName: "Button",
|
|
83
|
+
componentId: "sc-qe54pl-1"
|
|
84
|
+
})(["vertical-align:top;border:0;font-size:13px;border-radius:", ";background:", ";color:white;min-width:8rem;font-weight:600;display:inline-block;text-align:center;padding:10px 1.25rem;outline:none;cursor:pointer;position:relative;text-decoration:none;user-select:none;flex-shrink:0;:hover{background:", ";}:active{background:", ";}", " ", " & + &{margin-left:1rem;}", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ""], props => props.rounded ? '100px' : '8px', getColor, props => darken(0.05, getColor(props, true)), props => darken(0.08, getColor(props, true)), props => props.nowrap && "\n white-space: nowrap;\n ", props => !props.noFocus && !props.isLoading && css([":focus{", "}", ""], focus, props => props.focused && focus), props => props.hasErrors && css([":after{content:'';pointer-events:none;position:absolute;top:-4px;right:-4px;left:-4px;bottom:-4px;border-radius:", ";border:3px solid ", ";}"], props => props.rounded ? '100px' : '11px', props => transparentize(0.7, getColor("alert")(props))), props => props.icon && css(["display:inline-flex;align-items:center;justify-content:center;min-width:3rem;min-height:3rem;", "{font-size:23px;margin-left:-4px;margin-right:8px;pointer-events:none;line-height:0;}"], Icon), props => props.onlyIcon && css(["padding:0;", "{margin:0;}"], Icon), props => props.small && css(["font-size:13px;padding:3px 1rem;min-width:2rem;min-height:2rem;font-weight:550;", " ", ""], props.icon && css(["", "{font-size:18px;margin-left:-5px;margin-right:5px;line-height:0.9;}"], Icon), props.onlyIcon && css(["padding:0;", "{margin:0;}"], Icon)), props => props.big && css(["font-size:14px;padding:13px 1.75rem;min-height:42px;"]), props => props.withDropdown && css(["padding-right:2.25rem;text-align:left;"]), props => props.onlyDropdown && css(["", "{right:50%;transform:translate(50%,-50%);}"], DropdownIcon), props => props.light && css(["background:", ";color:", ";:hover{background:", ";}:active{background:", ";}"], getColor('bluishGray'), getColor('gray90'), props => darken(0.05, getColor('bluishGray')(props)), props => darken(0.08, getColor('bluishGray')(props))), props => props.lightAlert && css(["background:", ";color:", ";:hover{background:", ";}:active{background:", ";}"], props => transparentize(0.86, getColor("alert")(props)), getColor('alert'), props => transparentize(0.83, getColor("alert")(props)), props => transparentize(0.80, getColor("alert")(props))), props => props.lightWarning && css(["background:", ";color:", ";:hover{background:", ";}:active{background:", ";}"], props => transparentize(0.84, darken(0.05, getColor('warning')(props))), props => darken(0.05, getColor('warning')(props)), props => transparentize(0.78, darken(0.05, getColor('warning')(props))), props => transparentize(0.76, darken(0.05, getColor('warning')(props)))), props => (props.outline || props.dashed || props.textOnly) && css(["color:", ";background:none;", ",", "{color:", ";}:before{content:'';border:1px ", " ", ";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:", ";pointer-events:none;}:hover{background-color:rgba(0,0,0,0.05);}:active{background-color:rgba(0,0,0,0.08);}:focus{:before{box-shadow:0 0 0 2px rgba(0,0,0,0.1);", "}:after{content:none;}}"], props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.6)', Icon, DropdownIcon, props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.5)', props.outline ? 'solid' : props.dashed ? 'dashed' : '', props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.35)', props.rounded ? '100px' : '8px', props.textOnly && 'content: none;'), props => props.alpha && css(["background:rgba(0,0,0,0.45);:hover{background:rgba(0,0,0,0.50);}:active{background:rgba(0,0,0,0.55);}"]), props => props.white && !props.outline && !props.dashed && css(["color:", ";background:#FFFFFF;:hover{background:", ";}:active{background:", ";}"], getColor('main'), darken(0.05, '#FFFFFF'), darken(0.08, '#FFFFFF')), props => props.isLoading && css(["color:transparent !important;pointer-events:none;", "{visibility:hidden;}"], Icon), props => props.isLoadingIcon && css(["pointer-events:none;", "{visibility:hidden;}", "{left:10px;position:absolute;}"], Icon, Loading), media.mobile(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n ", "\n ", "\n "])), props => !props.small && !props.onlyIcon && css(["padding:13px 1.5rem;font-size:14px;"]), props => !props.small && props.onlyIcon && css(["min-width:3.5rem;min-height:3.5rem;"]), props => props.withDropdown && css(["padding-right:2.5rem;", "{right:14px;}"], DropdownIcon)), media.max(359)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n "])), props => !props.small && !props.onlyIcon && !props.onlyDropdown && css(["min-width:0;"])), props => props.fullwidth && "\n width: 100%;\n ", customTheme("Button"));
|
|
85
|
+
Button.a = props => /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
|
86
|
+
className: props.className,
|
|
87
|
+
innerAs: "a"
|
|
88
|
+
}));
|
|
89
|
+
Button.Link = props => /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
|
90
|
+
className: props.className,
|
|
91
|
+
innerAs: Link
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
export { Button, DropdownIcon, Button as default };
|
|
95
|
+
//# sourceMappingURL=Button.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../src/Button.jsx"],"sourcesContent":["import React from 'react'\n\nimport {customTheme, getColor, media, styledExtend} from '@startlibs/utils'\nimport {darken, transparentize} from 'polished'\nimport styled, {css} from 'styled-components'\n\nimport {Icon} from './Icon'\nimport {Link} from './Link'\nimport {Loading} from './Loading'\n\nexport const DropdownIcon = styledExtend(Icon)`\n position: absolute;\n top: 51%;\n transform: translateY(-50%);\n right: 1rem;\n font-size: 12px;\n`\nconst LockIcon = styled(Icon)`\n position:absolute;\n bottom: 10px;\n right: .75rem;\n left: auto;\n top: auto;\n font-size: 18px;\n`\n\nconst focus = css`\n:after{\n content: '';\n pointer-events: none;\n position: absolute;\n top: -3px;\n right: -3px;\n left: -3px;\n bottom: -3px;\n border-radius: ${props => props.rounded ? '100px' : '11px'};\n border: 2px solid rgba(0, 0, 0, 0.15);\n}\n`\n\nexport const Button = styled(React.forwardRef(({\n type = \"button\", locked, color, alpha, success, alert, warning, highlight, light, hover, white, icon, onlyIcon, small, withDropdown, onlyDropdown, outline, dashed, textOnly, isLoading, isLoadingIcon, dark,\n innerAs: Wrapper = 'button', className, children, rounded, tabIndex = 1, focused, noFocus,\n colorSet, concealed, concealedModule, buttonRef, ...props\n },ref) =>\n <Wrapper ref={ref || buttonRef} tabIndex={tabIndex} className={className + ' styled-button' + ((color || success || alert || warning || highlight || dark || hover || outline || dashed || textOnly || white || alpha || props.lightAlert || props.lightWarning) ? ' styled-button-colored' : '')} type={Wrapper === 'button' ? type : ''} {...props}>\n {icon && <Icon icon={icon} aria-hidden=\"true\"/>}\n {isLoadingIcon && <Loading white={!light && !outline && !dashed && !white} size={small ? '10' : '18'} borderWidth={small ? '2' : '3'}/>}\n {(withDropdown || onlyDropdown) && !locked && <DropdownIcon icon='arrow-down' aria-hidden=\"true\"/>}\n {locked && <LockIcon icon=\"lock\" aria-hidden=\"true\"/>}\n {children}\n {isLoading && <Loading white={!light && !outline && !dashed && !white} absolute size={small && '16'} borderWidth={small && '3'} />}\n </Wrapper>))`\n vertical-align: top;\n border: 0;\n font-size: 13px;\n border-radius: ${props => props.rounded ? '100px' : '8px'};\n background: ${getColor};\n color: white;\n min-width: 8rem;\n font-weight: 600;\n display: inline-block;\n // line-height: 16px;\n text-align: center;\n padding: 10px 1.25rem;\n outline: none;\n cursor: pointer;\n position: relative;\n text-decoration: none;\n user-select: none;\n flex-shrink: 0;\n :hover {\n background: ${props => darken(0.05, getColor(props, true))};\n }\n :active {\n background: ${props => darken(0.08, getColor(props, true))};\n }\n ${props => props.nowrap && `\n white-space: nowrap;\n `}\n ${props => !props.noFocus && !props.isLoading && css`\n :focus {\n ${focus}\n }\n ${props => props.focused && focus}\n `}\n & + & {\n margin-left: 1rem;\n }\n \n ${props => props.hasErrors && css`\n :after {\n content: '';\n pointer-events: none;\n position: absolute;\n top: -4px;\n right: -4px;\n left: -4px;\n bottom: -4px;\n border-radius: ${props => props.rounded ? '100px' : '11px'};\n border: 3px solid ${props => transparentize(0.7, getColor(\"alert\")(props))};\n }\n `}\n ${props => props.icon && css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 3rem;\n min-height: 3rem;\n ${Icon} {\n font-size: 23px;\n margin-left: -4px;\n margin-right: 8px;\n pointer-events: none;\n line-height: 0;\n }\n `}\n ${props => props.onlyIcon && css`\n padding: 0;\n ${Icon} {\n margin: 0;\n }\n `}\n ${props => props.small && css`\n font-size: 13px;\n padding: 3px 1rem;\n min-width: 2rem;\n min-height: 2rem;\n font-weight: 550;\n ${props.icon && css`\n ${Icon} {\n font-size: 18px;\n margin-left: -5px;\n margin-right: 5px;\n line-height: 0.9;\n }\n `}\n ${props.onlyIcon && css`\n padding: 0;\n ${Icon} {\n margin: 0;\n }\n `}\n `}\n ${props => props.big && css`\n font-size: 14px;\n padding: 13px 1.75rem;\n min-height: 42px;\n `}\n ${props => props.withDropdown && css`\n padding-right: 2.25rem;\n text-align: left;\n `}\n ${props => props.onlyDropdown && css`\n ${DropdownIcon} {\n right: 50%;\n transform: translate(50%,-50%);\n }\n `}\n ${props => props.light && css`\n background: ${getColor('bluishGray')};\n color: ${getColor('gray90')};\n :hover {\n background: ${props => darken(0.05, getColor('bluishGray')(props))};\n }\n :active {\n background: ${props => darken(0.08, getColor('bluishGray')(props))};\n }\n `}\n ${props => props.lightAlert && css`\n background: ${props => transparentize(0.86, getColor(\"alert\")(props))};\n color: ${getColor('alert')};\n :hover {\n background: ${props => transparentize(0.83, getColor(\"alert\")(props))};\n }\n :active {\n background: ${props => transparentize(0.80, getColor(\"alert\")(props))};\n }\n `}\n ${props => props.lightWarning && css`\n background: ${props => transparentize(0.84, darken(0.05, getColor('warning')(props)))};\n color: ${props => darken(0.05, getColor('warning')(props))};\n :hover {\n background: ${props => transparentize(0.78, darken(0.05, getColor('warning')(props)))};\n }\n :active {\n background: ${props => transparentize(0.76, darken(0.05, getColor('warning')(props)))};\n }\n `}\n ${props => (props.outline || props.dashed || props.textOnly) && css`\n color: ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.6)'};\n background: none;\n ${Icon}, ${DropdownIcon} {\n color: ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.5)'};\n }\n :before {\n content: '';\n border: 1px ${props.outline ? 'solid' : props.dashed ? 'dashed' : ''} ${props.white ? 'white' : props.highlight ? getColor('main') : 'rgba(0,0,0,0.35)'};\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n border-radius: ${props.rounded ? '100px' : '8px'};\n pointer-events: none;\n }\n :hover {\n background-color: rgba(0,0,0,0.05);\n }\n :active {\n background-color: rgba(0,0,0,0.08);\n }\n :focus {\n :before {\n box-shadow: 0 0 0 2px rgba(0,0,0,0.1);\n ${props.textOnly && 'content: none;'}\n }\n :after {\n content: none;\n }\n }\n `}\n ${props => props.alpha && css`\n background: rgba(0,0,0,0.45);\n :hover {\n background: rgba(0,0,0,0.50);\n }\n :active {\n background: rgba(0,0,0,0.55);\n }\n `}\n ${props => props.white && !props.outline && !props.dashed && css`\n color: ${getColor('main')};\n background: #FFFFFF;\n :hover {\n background: ${darken(0.05, '#FFFFFF')};\n }\n :active {\n background: ${darken(0.08, '#FFFFFF')};\n }\n `}\n ${props => props.isLoading && css`\n color: transparent !important;\n pointer-events: none;\n ${Icon} {\n visibility: hidden;\n }\n `}\n ${props => props.isLoadingIcon && css`\n pointer-events: none;\n ${Icon} {\n visibility: hidden;\n }\n ${Loading} {\n left: 10px;\n position: absolute;\n }\n `}\n ${media.mobile`\n ${props => !props.small && !props.onlyIcon && css`\n padding: 13px 1.5rem;\n font-size: 14px;\n `}\n ${props => !props.small && props.onlyIcon && css`\n min-width: 3.5rem;\n min-height: 3.5rem;\n `}\n ${props => props.withDropdown && css`\n padding-right: 2.5rem;\n ${DropdownIcon} {\n right: 14px;\n }\n `}\n `}\n ${media.max(359)`\n ${props => !props.small && !props.onlyIcon && !props.onlyDropdown && css`\n min-width: 0;\n `}\n `}\n ${props => props.fullwidth && `\n width: 100%;\n `}\n ${customTheme(\"Button\")}\n`\n\nButton.a = (props) => <Button {...props} className={props.className} innerAs=\"a\"/>\nButton.Link = (props) => <Button {...props} className={props.className} innerAs={Link}/>\nexport default Button\n"],"names":["DropdownIcon","styledExtend","Icon","_templateObject","_taggedTemplateLiteral","LockIcon","styled","withConfig","displayName","componentId","focus","css","props","rounded","Button","React","forwardRef","_ref","ref","type","locked","color","alpha","success","alert","warning","highlight","light","hover","white","icon","onlyIcon","small","withDropdown","onlyDropdown","outline","dashed","textOnly","isLoading","isLoadingIcon","dark","innerAs","Wrapper","className","children","tabIndex","focused","noFocus","colorSet","concealed","concealedModule","buttonRef","_objectWithoutProperties","_excluded","createElement","_extends","lightAlert","lightWarning","Loading","size","borderWidth","absolute","getColor","darken","n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AA,CAAAuC,aAAA,CAACxC,MAAM,EAAAyC,QAAA,KAAK3C,KAAK,EAAA;EAAE+B,SAAS,EAAE/B,KAAK,CAAC+B,SAAU;AAACF,EAAAA,OAAO,EAAEmC,IAAAA;AAAK,CAAA,CAAC,CAAC;;;;"}
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
|
|
5
|
+
import React, { useRef, useEffect, forwardRef, useState, useMemo } from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
import styled, { css, isStyledComponent } from 'styled-components';
|
|
8
|
+
import { useEnsureRef, useToggle, useRefState, willUseLayers, willUseSharedState, Fill } from '@startlibs/core';
|
|
9
|
+
import { transparentize, darken } from 'polished';
|
|
10
|
+
import { isMemo } from 'react-is';
|
|
11
|
+
import { oneWayAnimation, animationTiming, media, ifProp, getColor, customTheme, styledExtend, isMobile, callIfFunction, createPressAndMoveEvent, stopPropagation } from '@startlibs/utils';
|
|
12
|
+
import mitt from 'mitt';
|
|
13
|
+
import { Button } from './Button.mjs';
|
|
14
|
+
import { useFlipEnter, useFlipLeave } from './Flip.mjs';
|
|
15
|
+
import { Icon } from './Icon.mjs';
|
|
16
|
+
import { Link } from './Link.mjs';
|
|
17
|
+
import { getDialogLayersSize } from './containers/DialogContainer.mjs';
|
|
18
|
+
import { usePositioning } from './containers/usePositioning.mjs';
|
|
19
|
+
|
|
20
|
+
const _excluded = ["label", "layerIndex", "href", "linkTo", "prefixWith", "subMenu", "icon", "children"],
|
|
21
|
+
_excluded2 = ["emitter", "index", "menuSlot", "keepOpen", "hover", "layerIndex", "hoverCursor", "passTouchThrough", "children", "setCursorOnHover", "onClick", "prefixWith", "linkTo", "icon", "label", "descText", "helpText", "target", "href"],
|
|
22
|
+
_excluded3 = ["children", "sub", "hoverIndex", "autoHover", "menuSlot", "withoutIcons", "onClose", "onHover", "fill", "onClick"],
|
|
23
|
+
_excluded4 = ["slot", "sub", "withoutIcons", "children"];
|
|
24
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
25
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
|
+
const fadeIn = oneWayAnimation('opacity: 0', 'opacity: 1');
|
|
28
|
+
const slideDown = oneWayAnimation('transform: translateY(-10px); pointer-events: none', 'transform: translateY(0); pointer-events: none');
|
|
29
|
+
const slideUpOnTop = oneWayAnimation('transform: translateY(10px); pointer-events: none', 'transform: translateY(0); pointer-events: none');
|
|
30
|
+
const slideRight = oneWayAnimation('transform: translateX(-10px)', 'transform: none;');
|
|
31
|
+
const slideLeftOnLeft = oneWayAnimation('transform: translateX(10px); pointer-events: none', 'transform: translateX(0px); pointer-events: none');
|
|
32
|
+
animationTiming('0.2s ease-out');
|
|
33
|
+
const areComponentsEqual = (a, b) => a === b;
|
|
34
|
+
const ListItem = /*#__PURE__*/styled.li.withConfig({
|
|
35
|
+
displayName: "ContextMenu__ListItem",
|
|
36
|
+
componentId: "sc-13y1vvt-0"
|
|
37
|
+
})(["position:relative;font-size:13px;& > *{padding:11px 1.5rem 11px 3.5rem;display:block;}", " ", ",.icon{font-size:", "px;position:absolute;padding-left:0.25rem;left:0;top:50%;transform:translateY(-50%);width:3.5rem;text-align:center;}", " & > a{color:inherit;font-weight:inherit;text-decoration:inherit;}& > a,& > label{cursor:pointer;}", " ", " input[type=\"radio\"]{display:none;}", " ", " ", " ", ""], props => props.hasSubmenu && "\n & > * {\n padding-right: 3rem;\n }\n ", Icon, props => props.iconSize || 23, media.mobile(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size: 15px;\n & > * {\n padding-top: 15px;\n padding-bottom: 15px;\n }\n ", ", .icon {\n font-size: ", "px;\n }\n "])), Icon, props => (props.iconSize || 23) + 2), ifProp('hover', css(["& > a,& > label{background:", ";color:", ";}"], props => transparentize(0.88, getColor("main")(props)), props => darken(0.03, getColor("main")(props)))), ifProp('highlight', css(["color:", ";"], getColor('main'))), ifProp('noActions', "\n max-width: 17rem;\n color: rgba(0,0,0,0.4);\n pointer-events: none;\n text-align: center;\n white-space: normal;\n "), ifProp('withButton', css(["padding:0.25rem 1rem;", "{width:100%;color:white;font-weight:500;padding:10px 1.25rem;", "}"], Button, media.mobile(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 13px 1.25rem;\n "]))))), ifProp('smallPaddingRight', css(["& > *{padding-right:1.5rem;}"])), customTheme('ListItem'));
|
|
38
|
+
const ListItemDescText = /*#__PURE__*/styled.div.withConfig({
|
|
39
|
+
displayName: "ContextMenu__ListItemDescText",
|
|
40
|
+
componentId: "sc-13y1vvt-1"
|
|
41
|
+
})(["font-size:11px;margin-top:0.25rem;opacity:0.6;", ""], media.mobile(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 12px;\n "]))));
|
|
42
|
+
const ListItemHelpText = /*#__PURE__*/styled.span.withConfig({
|
|
43
|
+
displayName: "ContextMenu__ListItemHelpText",
|
|
44
|
+
componentId: "sc-13y1vvt-2"
|
|
45
|
+
})(["opacity:0.5;"]);
|
|
46
|
+
const ListMenu = /*#__PURE__*/styled.ul.withConfig({
|
|
47
|
+
displayName: "ContextMenu__ListMenu",
|
|
48
|
+
componentId: "sc-13y1vvt-3"
|
|
49
|
+
})(["padding:0.5rem 0;cursor:default;overflowY:auto;text-align:left;color:inherit;user-select:none;"]);
|
|
50
|
+
const ContextListMenu = /*#__PURE__*/styled(ListMenu).withConfig({
|
|
51
|
+
displayName: "ContextMenu__ContextListMenu",
|
|
52
|
+
componentId: "sc-13y1vvt-4"
|
|
53
|
+
})(["position:absolute;z-index:999;background-color:white;backdrop-filter:blur(20px);background-color:rgb(255 255 255 / 80%);box-shadow:0 2px 2px 0 rgba(0,0,0,0.14),0 3px 10px -2px rgba(0,0,0,0.15),0 0px 2px 0px rgba(0,0,0,0.2);border-radius:12px;margin-bottom:0.5rem;overflow:auto;max-height:100vh;max-height:100dvh;max-width:100vw;max-width:100dvw;", " ", " ", ""], props => props.withoutIcons && "\n ".concat(ListItem, " > * {\n padding-left: 1.5rem;\n }\n "), ifProp('sub', css(["", " ", ""], props => props.fullHeight ? '' : props.atTop ? 'margin-top: -0.5rem;' : 'margin-top: 0.5rem;', ifProp('atRight', "\n margin-left: -4px;\n ", "\n margin-left: 4px;\n "))), customTheme('ContextMenu'));
|
|
54
|
+
const StickyContainer = /*#__PURE__*/styled.div.withConfig({
|
|
55
|
+
displayName: "ContextMenu__StickyContainer",
|
|
56
|
+
componentId: "sc-13y1vvt-5"
|
|
57
|
+
})(["position:sticky;background:white;", " ", ""], props => props.atBottom && "\n bottom: -0.5rem;\n padding-bottom: 0.5rem;\n margin-bottom: -0.5rem;\n ", props => props.atTop && "\n top: -0.5rem;\n padding-top: 0.5rem;\n margin-top: -0.5rem;\n ");
|
|
58
|
+
const ListSeparator = /*#__PURE__*/styled.li.withConfig({
|
|
59
|
+
displayName: "ContextMenu__ListSeparator",
|
|
60
|
+
componentId: "sc-13y1vvt-6"
|
|
61
|
+
})(["border-bottom:1px solid rgba(0,0,0,0.1);margin-top:0.5rem;margin-bottom:0.5rem;cursor:default;height:0;", ""], ifProp('lighten', css(["border-color:rgba(255,255,255,0.15);"])));
|
|
62
|
+
const ListHeading = /*#__PURE__*/styled.li.withConfig({
|
|
63
|
+
displayName: "ContextMenu__ListHeading",
|
|
64
|
+
componentId: "sc-13y1vvt-7"
|
|
65
|
+
})(["display:flex;align-items:center;padding:.5rem 1rem;color:rgba(0,0,0,0.4);font-size:12px;text-transform:uppercase;:after{content:'';flex-grow:1;margin-left:0.75rem;height:1px;background:rgba(0,0,0,0.15);}"]);
|
|
66
|
+
const SubmenuArrowIcon = styledExtend(Icon)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-size: 13px;\n position: absolute;\n right: 0;\n top: 50%;\n transform: translateY(-50%);\n width: 3rem;\n text-align: center;\n"])));
|
|
67
|
+
class SimpleLi extends React.Component {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(...arguments);
|
|
70
|
+
this.scrollToVisibility = () => {
|
|
71
|
+
const el = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode(this);
|
|
72
|
+
const list = el.parentNode;
|
|
73
|
+
if (el.offsetTop < list.scrollTop) {
|
|
74
|
+
list.scrollTop = el.offsetTop;
|
|
75
|
+
} else if (el.offsetTop + el.offsetHeight > list.scrollTop + list.offsetHeight) {
|
|
76
|
+
list.scrollTop = el.offsetTop + el.offsetHeight - list.offsetHeight;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
this.confirm = () => {
|
|
80
|
+
if (this.props.hover) {
|
|
81
|
+
const node = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode(this);
|
|
82
|
+
node.click();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
this.onMouseEnter = () => this.props.setCursorOnHover && this.props.setCursorOnHover(this.props.index);
|
|
86
|
+
this.onMouseOut = () => this.props.setCursorOnHover && this.props.setCursorOnHover(-1);
|
|
87
|
+
this.touchEnd = e => {
|
|
88
|
+
if (this.props.children) {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
if (!this.props.hover) this.onMouseEnter();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
this.onClick = e => {
|
|
94
|
+
this.props.onClick && this.props.onClick();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
componentWillUnmount() {
|
|
98
|
+
this.props.emitter.off('confirm', this.confirm);
|
|
99
|
+
}
|
|
100
|
+
componentDidUpdate() {
|
|
101
|
+
if (this.props.hover) {
|
|
102
|
+
this.scrollToVisibility();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
componentDidMount() {
|
|
106
|
+
this.props.emitter.on('confirm', this.confirm);
|
|
107
|
+
if (this.props.selected && this.props.setCursorOnHover) {
|
|
108
|
+
this.props.setCursorOnHover(this.props.index);
|
|
109
|
+
const el = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode(this);
|
|
110
|
+
const list = el.parentNode;
|
|
111
|
+
list.scrollTop = el.offsetTop + el.offsetHeight / 2 - list.offsetHeight / 2;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
render() {
|
|
115
|
+
const _this$props = this.props,
|
|
116
|
+
{
|
|
117
|
+
label,
|
|
118
|
+
layerIndex,
|
|
119
|
+
href,
|
|
120
|
+
linkTo,
|
|
121
|
+
prefixWith,
|
|
122
|
+
subMenu,
|
|
123
|
+
icon,
|
|
124
|
+
children
|
|
125
|
+
} = _this$props,
|
|
126
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
127
|
+
const Tag = linkTo ? Link : 'a';
|
|
128
|
+
return /*#__PURE__*/React.createElement(ListItem, _extends({}, rest, {
|
|
129
|
+
onClick: this.onClick,
|
|
130
|
+
onMouseLeave: this.onMouseOut,
|
|
131
|
+
onMouseEnter: this.onMouseEnter,
|
|
132
|
+
onTouchEnd: this.touchEnd
|
|
133
|
+
}), /*#__PURE__*/React.createElement(Tag, {
|
|
134
|
+
href: href,
|
|
135
|
+
to: linkTo
|
|
136
|
+
}, prefixWith, icon && /*#__PURE__*/React.createElement(Icon, {
|
|
137
|
+
icon: icon
|
|
138
|
+
}), label));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
SimpleLi.isKeyboardNavigable = true;
|
|
142
|
+
SimpleLi.defaultProps = {
|
|
143
|
+
emitter: mitt()
|
|
144
|
+
};
|
|
145
|
+
const Li = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
146
|
+
let {
|
|
147
|
+
emitter = mitt(),
|
|
148
|
+
index,
|
|
149
|
+
menuSlot,
|
|
150
|
+
keepOpen,
|
|
151
|
+
hover,
|
|
152
|
+
layerIndex,
|
|
153
|
+
hoverCursor,
|
|
154
|
+
passTouchThrough,
|
|
155
|
+
children,
|
|
156
|
+
setCursorOnHover,
|
|
157
|
+
onClick,
|
|
158
|
+
prefixWith,
|
|
159
|
+
linkTo,
|
|
160
|
+
icon,
|
|
161
|
+
label,
|
|
162
|
+
descText,
|
|
163
|
+
helpText,
|
|
164
|
+
target,
|
|
165
|
+
href
|
|
166
|
+
} = _ref,
|
|
167
|
+
rest = _objectWithoutProperties(_ref, _excluded2);
|
|
168
|
+
const nodeRef = useEnsureRef(ref);
|
|
169
|
+
const tagRef = useRef();
|
|
170
|
+
const subMenu = useToggle();
|
|
171
|
+
const subPrevented = useRefState(false);
|
|
172
|
+
const onOpenSub = () => {
|
|
173
|
+
subPrevented.set(false);
|
|
174
|
+
if (hover && children) {
|
|
175
|
+
subMenu.open();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const onPreventSub = subIndex => {
|
|
179
|
+
if (index !== subIndex) subMenu.close();
|
|
180
|
+
subPrevented.set(true);
|
|
181
|
+
};
|
|
182
|
+
const confirm = () => {
|
|
183
|
+
if (hover) {
|
|
184
|
+
nodeRef.current.click();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
if (hover) {
|
|
189
|
+
try {
|
|
190
|
+
const el = nodeRef.current;
|
|
191
|
+
const parent = el.parentElement;
|
|
192
|
+
const stickyContainer = parent.lastChild;
|
|
193
|
+
const stickyContainerHeight = stickyContainer && stickyContainer.tagName === "DIV" && stickyContainer.offsetTop - parent.scrollTop < parent.offsetHeight ? stickyContainer.offsetHeight : 0;
|
|
194
|
+
if (el.offsetTop > parent.offsetHeight + parent.scrollTop - stickyContainerHeight - el.offsetHeight) {
|
|
195
|
+
parent.scroll(0, el.offsetTop - parent.offsetHeight + el.offsetHeight + stickyContainerHeight);
|
|
196
|
+
} else if (el.offsetTop < parent.scrollTop) {
|
|
197
|
+
parent.scroll(0, el.offsetTop);
|
|
198
|
+
}
|
|
199
|
+
} catch (e) {}
|
|
200
|
+
}
|
|
201
|
+
emitter.on('confirm', confirm);
|
|
202
|
+
emitter.on('preventSub', onPreventSub);
|
|
203
|
+
emitter.on('openSub', onOpenSub);
|
|
204
|
+
return () => {
|
|
205
|
+
emitter.off('confirm', confirm);
|
|
206
|
+
emitter.off('preventSub', onPreventSub);
|
|
207
|
+
emitter.off('openSub', onOpenSub);
|
|
208
|
+
};
|
|
209
|
+
}, [hover]);
|
|
210
|
+
useEffect(() => () => subMenu.close(), []);
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
if (children && !isMobile()) {
|
|
213
|
+
if (hover) {
|
|
214
|
+
if (!subMenu.isOpen || subMenu.closing || !subPrevented.get()) {
|
|
215
|
+
subMenu.open();
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
if (subMenu.isOpen) {
|
|
219
|
+
if (hoverCursor === -1) {
|
|
220
|
+
// Mouse saiu de todos os itens — provavelmente indo até o submenu (que
|
|
221
|
+
// abre ao lado, com um pequeno gap). Janela generosa; ao alcançá-lo, o
|
|
222
|
+
// onMouseEnter/onMouseMove do submenu chama subMenu.open e cancela.
|
|
223
|
+
subMenu.closeAfter(450);
|
|
224
|
+
} else {
|
|
225
|
+
// Mouse foi para outro item do menu — mantém os 200ms originais.
|
|
226
|
+
subMenu.closeAfter(200);
|
|
227
|
+
}
|
|
228
|
+
emitter.emit('preventSub', index);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}, [hoverCursor]);
|
|
233
|
+
const onMouseMove = e => {
|
|
234
|
+
if (!hover) {
|
|
235
|
+
callIfFunction(setCursorOnHover, index);
|
|
236
|
+
}
|
|
237
|
+
e === null || e === void 0 || e.stopPropagation();
|
|
238
|
+
};
|
|
239
|
+
const onMouseOut = e => {
|
|
240
|
+
callIfFunction(setCursorOnHover, -1);
|
|
241
|
+
e === null || e === void 0 || e.stopPropagation();
|
|
242
|
+
};
|
|
243
|
+
const onClickHandler = e => {
|
|
244
|
+
if (children || keepOpen) {
|
|
245
|
+
e.stopPropagation();
|
|
246
|
+
}
|
|
247
|
+
if (children) {
|
|
248
|
+
if (hover) {
|
|
249
|
+
subMenu.toggle();
|
|
250
|
+
} else {
|
|
251
|
+
onMouseMove();
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
callIfFunction(onClick, e);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const onCloseSub = () => emitter.emit('openSub');
|
|
258
|
+
const addProps = children => React.Children.map(children, c => /*#__PURE__*/React.cloneElement(c, {
|
|
259
|
+
fixed: rest.fixedPosition,
|
|
260
|
+
closing: subMenu.closing,
|
|
261
|
+
onMouseMove: subMenu.open,
|
|
262
|
+
// onMouseEnter não borbulha, então não é barrado pelo stopPropagation dos itens
|
|
263
|
+
// do submenu (linha onMouseMove do Li). Garante que alcançar o submenu sempre
|
|
264
|
+
// cancele o fechamento agendado por closeAfter(200), mantendo-o aberto.
|
|
265
|
+
onMouseEnter: subMenu.open,
|
|
266
|
+
onClose: onCloseSub,
|
|
267
|
+
sub: true,
|
|
268
|
+
slot: c.props.slot || menuSlot
|
|
269
|
+
}));
|
|
270
|
+
const content = /*#__PURE__*/React.createElement(React.Fragment, null, prefixWith, icon && /*#__PURE__*/React.createElement(Icon, {
|
|
271
|
+
icon: icon
|
|
272
|
+
}), label, " ", helpText && /*#__PURE__*/React.createElement(ListItemHelpText, null, "(", helpText, ")"), descText && /*#__PURE__*/React.createElement(ListItemDescText, null, descText), children && /*#__PURE__*/React.createElement(SubmenuArrowIcon, {
|
|
273
|
+
icon: "arrow-right"
|
|
274
|
+
}));
|
|
275
|
+
const Tag = linkTo ? Link : 'a';
|
|
276
|
+
return /*#__PURE__*/React.createElement(ListItem, _extends({
|
|
277
|
+
ref: nodeRef
|
|
278
|
+
}, rest, {
|
|
279
|
+
hover: hover,
|
|
280
|
+
onClick: onClickHandler,
|
|
281
|
+
onMouseLeave: onMouseOut,
|
|
282
|
+
onMouseMove: onMouseMove,
|
|
283
|
+
hasSubmenu: children
|
|
284
|
+
}), rest.withButton || rest.noActions ? content : /*#__PURE__*/React.createElement(Tag, {
|
|
285
|
+
href: href,
|
|
286
|
+
target: target,
|
|
287
|
+
to: linkTo,
|
|
288
|
+
ref: tagRef,
|
|
289
|
+
onMouseEnter: onMouseMove
|
|
290
|
+
}, content), subMenu.isOpen && addProps(children));
|
|
291
|
+
});
|
|
292
|
+
Li.isKeyboardNavigable;
|
|
293
|
+
Li.Simple = SimpleLi;
|
|
294
|
+
const [useContextMenuLayers, contextMenuLayersSize] = willUseLayers();
|
|
295
|
+
const contextMenuLayersQuantity = contextMenuLayersSize;
|
|
296
|
+
const [useContextMenuSharedState] = willUseSharedState();
|
|
297
|
+
const ContextMenuComponent = /*#__PURE__*/forwardRef((_ref2, unesuredRef) => {
|
|
298
|
+
let {
|
|
299
|
+
children,
|
|
300
|
+
sub,
|
|
301
|
+
hoverIndex,
|
|
302
|
+
autoHover,
|
|
303
|
+
menuSlot,
|
|
304
|
+
withoutIcons,
|
|
305
|
+
onClose,
|
|
306
|
+
onHover = () => 0,
|
|
307
|
+
fill,
|
|
308
|
+
onClick
|
|
309
|
+
} = _ref2,
|
|
310
|
+
props = _objectWithoutProperties(_ref2, _excluded3);
|
|
311
|
+
const ref = useEnsureRef(unesuredRef);
|
|
312
|
+
const [hoverCursor, setHoverCursor] = useState(autoHover || sub ? 0 : -1);
|
|
313
|
+
const [layerCursor, setLayerCursor] = useContextMenuSharedState(0);
|
|
314
|
+
const [layerIndex, {
|
|
315
|
+
getSize
|
|
316
|
+
}] = useContextMenuLayers();
|
|
317
|
+
const itemsEmitter = useMemo(() => mitt(), []);
|
|
318
|
+
useEffect(() => {
|
|
319
|
+
window.addEventListener('keydown', keydown);
|
|
320
|
+
return () => {
|
|
321
|
+
callIfFunction(onClose);
|
|
322
|
+
window.removeEventListener('keydown', keydown);
|
|
323
|
+
};
|
|
324
|
+
}, [layerIndex, layerCursor, hoverCursor]);
|
|
325
|
+
useEffect(() => {
|
|
326
|
+
if (hoverIndex !== undefined) {
|
|
327
|
+
setHoverCursor(Math.min(Math.max(hoverIndex, -1), getTotalKeyboardItems(children) + 1));
|
|
328
|
+
}
|
|
329
|
+
}, [hoverIndex !== hoverCursor]);
|
|
330
|
+
const keydown = e => {
|
|
331
|
+
if (e.keyCode === 37 || e.keyCode === 39) {
|
|
332
|
+
if (!e.defaultPrevented) {
|
|
333
|
+
const layers = getSize();
|
|
334
|
+
const direction = e.keyCode - 38;
|
|
335
|
+
setLayerCursor((layerCursor + direction + layers) % layers);
|
|
336
|
+
}
|
|
337
|
+
e.preventDefault();
|
|
338
|
+
}
|
|
339
|
+
if (layerIndex !== layerCursor) return;
|
|
340
|
+
if (e.keyCode === 27 && ref.current) {
|
|
341
|
+
ref.current.click();
|
|
342
|
+
}
|
|
343
|
+
if (e.keyCode === 13 || e.keyCode === 32 && hoverCursor >= 0) {
|
|
344
|
+
// enter
|
|
345
|
+
e.preventDefault();
|
|
346
|
+
itemsEmitter.emit('confirm');
|
|
347
|
+
}
|
|
348
|
+
if (e.keyCode === 38 || e.keyCode === 40) {
|
|
349
|
+
// up down
|
|
350
|
+
e.preventDefault();
|
|
351
|
+
const direction = e.keyCode - 39;
|
|
352
|
+
const max = getTotalKeyboardItems(children);
|
|
353
|
+
const newIndex = (hoverCursor + direction + max) % max;
|
|
354
|
+
setHoverCursor(newIndex);
|
|
355
|
+
onHover(newIndex);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const getTotalKeyboardItems = children => {
|
|
359
|
+
let sum = 0;
|
|
360
|
+
React.Children.forEach(children, child => {
|
|
361
|
+
if (child && !child.props.disabled && !child.props.readOnly) {
|
|
362
|
+
if (!isStyledComponent(child.type) && child.type === Li || child.type.isKeyboardNavigable) {
|
|
363
|
+
sum += 1;
|
|
364
|
+
}
|
|
365
|
+
if (areComponentsEqual(child.type, StickyContainer) || child.props.nested) {
|
|
366
|
+
sum += getTotalKeyboardItems(child.props.children);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
return sum;
|
|
371
|
+
};
|
|
372
|
+
const setCursorOnHover = index => {
|
|
373
|
+
setLayerCursor(layerIndex);
|
|
374
|
+
setHoverCursor(index);
|
|
375
|
+
onHover(index);
|
|
376
|
+
};
|
|
377
|
+
const formatChildren = function (children) {
|
|
378
|
+
let indexRef = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
379
|
+
current: 0
|
|
380
|
+
};
|
|
381
|
+
return React.Children.map(children, (child, j) => child && !child.props.disabled && !child.props.readOnly ? child.props.nested ? /*#__PURE__*/React.cloneElement(child, child.props, formatChildren(child.props.children, indexRef)) : !isStyledComponent(child.type) && !isMemo(child.type) && areComponentsEqual(child.type, Li) || child.type.isKeyboardNavigable ? /*#__PURE__*/React.cloneElement(child, {
|
|
382
|
+
fixedPosition: props.fixed,
|
|
383
|
+
hover: hoverCursor === indexRef.current && layerIndex === layerCursor,
|
|
384
|
+
hoverCursor: hoverCursor,
|
|
385
|
+
index: indexRef.current++,
|
|
386
|
+
setCursorOnHover,
|
|
387
|
+
emitter: itemsEmitter,
|
|
388
|
+
layerIndex: layerIndex,
|
|
389
|
+
menuSlot
|
|
390
|
+
}) : areComponentsEqual(child.type, StickyContainer) ? /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
|
|
391
|
+
children: formatChildren(child.props.children, indexRef)
|
|
392
|
+
})) : child : child);
|
|
393
|
+
};
|
|
394
|
+
const touchStart = createPressAndMoveEvent((e, prevPos) => {
|
|
395
|
+
// e.preventDefault()
|
|
396
|
+
e.stopPropagation();
|
|
397
|
+
e.target.dispatchEvent(new MouseEvent('mousemove', {
|
|
398
|
+
bubbles: true
|
|
399
|
+
}));
|
|
400
|
+
return (e, nextPos) => {
|
|
401
|
+
const delta = prevPos.clientY - nextPos.clientY;
|
|
402
|
+
if (Math.abs(delta) > 10) {
|
|
403
|
+
setCursorOnHover(-1);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
});
|
|
407
|
+
return /*#__PURE__*/React.createElement(ContextListMenu, _extends({
|
|
408
|
+
"data-drag": false,
|
|
409
|
+
ref: ref,
|
|
410
|
+
sub: sub,
|
|
411
|
+
onWheel: e => e.stopPropagation(),
|
|
412
|
+
onTouchStart: touchStart,
|
|
413
|
+
withoutIcons: withoutIcons,
|
|
414
|
+
onMouseDown: stopPropagation()
|
|
415
|
+
}, props), formatChildren(children));
|
|
416
|
+
});
|
|
417
|
+
const ContextMenu = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
418
|
+
let {
|
|
419
|
+
slot = 'Popup',
|
|
420
|
+
sub,
|
|
421
|
+
withoutIcons,
|
|
422
|
+
children
|
|
423
|
+
} = _ref3,
|
|
424
|
+
rest = _objectWithoutProperties(_ref3, _excluded4);
|
|
425
|
+
const contextMenuRef = useEnsureRef(ref);
|
|
426
|
+
const [positionInfo, placeholder, arrow] = usePositioning(contextMenuRef, rest);
|
|
427
|
+
const {
|
|
428
|
+
atRight,
|
|
429
|
+
atBottom
|
|
430
|
+
} = _objectSpread({}, positionInfo);
|
|
431
|
+
const slotName = useMemo(() => getDialogLayersSize() === 0 ? slot : slot + '-' + (getDialogLayersSize() - 1), []);
|
|
432
|
+
const enterAnimation = useMemo(() => [fadeIn, sub ? atRight ? slideRight : slideLeftOnLeft : atBottom ? slideDown : slideUpOnTop], [atRight, atBottom]);
|
|
433
|
+
useFlipEnter(contextMenuRef, !!positionInfo && enterAnimation);
|
|
434
|
+
useFlipLeave(contextMenuRef, !!positionInfo && enterAnimation, sub && {
|
|
435
|
+
events: {
|
|
436
|
+
mouseover: rest.onMouseMove
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, placeholder, /*#__PURE__*/React.createElement(Fill, {
|
|
440
|
+
name: slotName
|
|
441
|
+
}, /*#__PURE__*/React.createElement(ContextMenuComponent, _extends({}, rest, {
|
|
442
|
+
menuSlot: slot,
|
|
443
|
+
sub: sub
|
|
444
|
+
}, positionInfo, {
|
|
445
|
+
ref: contextMenuRef,
|
|
446
|
+
withoutIcons: withoutIcons
|
|
447
|
+
}), arrow, children)));
|
|
448
|
+
});
|
|
449
|
+
ContextMenu.ListItem = ListItem;
|
|
450
|
+
|
|
451
|
+
export { ContextListMenu, ContextMenu, ContextMenuComponent, Li, ListHeading, ListItem, ListMenu, ListSeparator, SimpleLi, StickyContainer, contextMenuLayersQuantity };
|
|
452
|
+
//# sourceMappingURL=ContextMenu.mjs.map
|