@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
package/lib/Link.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Link.mjs","sources":["../src/Link.jsx"],"sourcesContent":["import React, {useMemo} from 'react'\nimport * as Wouter from 'wouter'\nimport { useBrowserLocation } from \"wouter/use-browser-location\"\nimport { useCallbackStable } from \"@startlibs/core\"\nimport {callIfFunction, addQueryString} from \"@startlibs/utils\";\nimport _ from 'lodash/fp'\n\nexport const Link = ({href,...props}) => _.isString(props.to) ? <Wouter.Link {...props} /> : <a {...props} href={href?.replace(\"~\",\"\")} />\n\nexport const HistoryLink = ({to,onClick,...props}) => {\n return <a onClick={(e) => {\n if (onClick && !callIfFunction(onClick,e)) { return }\n if (e.isDefaultPrevented()) { return }\n if (!to) { return }\n e.preventDefault()\n const {state,pathname,search,hash} = _.isObject(to) ? to : {pathname:to}\n const url = (pathname || \"\") + (search ? \"?\" + search.replace(/^\\?/,\"\") : \"\") + (hash ? \"#\" + hash.replace(/^#/,\"\") : \"\")\n window.history.pushState(state, '', url)\n var popStateEvent = new PopStateEvent('popstate', { state: state });\n window.dispatchEvent(popStateEvent);\n }} {...props} />\n}\n\nexport const Route = ({element,children,...props}) => <Wouter.Route {...props}>{element || children}</Wouter.Route>\nexport const Routes = Wouter.Switch\nexport const Navigate = Wouter.Redirect\nexport const useLocation = () => {\n const [path] = Wouter.useLocation()\n const [search] = Wouter.useSearchParams()\n return {pathname:path,search:search ? \"?\" + search : \"\",state:window.history.state}\n}\nexport const useAbsolutePath = () => {\n const router = Wouter.useRouter();\n const [path] = Wouter.useLocation()\n return router.base + path\n}\nexport const useAbsoluteLocation = () => {\n const router = Wouter.useRouter();\n const {pathname,search} = useLocation()\n return router.base + pathname + search\n}\nexport const useNavigate = () => Wouter.useLocation()[1]\nexport const useParams = Wouter.useParams\nexport const useSearchParams = (defaultParams) => {\n const [location, navigate] = Wouter.useLocation()\n const search = Wouter.useSearch()\n const searchParams = useMemo(() => _.assign(defaultParams,Object.fromEntries(new URLSearchParams(search).entries())), [search])\n\n let tempSearchParams = searchParams\n\n const setSearchParams = useCallbackStable((nextParams, options) => {\n tempSearchParams = _.isFunction(nextParams) ? nextParams(tempSearchParams) : _.assign(tempSearchParams, nextParams)\n const cleanParams = defaultParams\n ? _.flow(\n _.toPairs,\n _.filter(([k,v]) => defaultParams[k] !== v),\n _.fromPairs\n )(tempSearchParams)\n : tempSearchParams\n navigate(addQueryString(location, cleanParams), options)\n })\n\n return [searchParams, setSearchParams]\n}\n\nexport const Router = Wouter.Router\n\nexport {useBrowserLocation}"],"names":["Link","_ref","href","props","_objectWithoutProperties","_excluded","_isString","to","React","createElement","Wouter","_extends","replace","HistoryLink","_ref2","onClick","_excluded2","e","callIfFunction","isDefaultPrevented","preventDefault","state","pathname","search","hash","_isObject","url","window","history","pushState","popStateEvent","PopStateEvent","dispatchEvent","Route","_ref3","element","children","_excluded3","Routes","Switch","Navigate","Redirect","useLocation","path","useSearchParams","useAbsolutePath","router","useRouter","base","useAbsoluteLocation","useNavigate","useParams","defaultParams","location","navigate","useSearch","searchParams","useMemo","_assign","Object","fromEntries","URLSearchParams","entries","tempSearchParams","setSearchParams","useCallbackStable","nextParams","options","_isFunction","cleanParams","_flow","_toPairs","_filter","_ref4","k","v","_fromPairs","addQueryString","Router"],"mappings":";;;;;;;;;;;;;;;;;;;AAOO,MAAMA,IAAI,GAAGC,IAAA,IAAA;EAAA,IAAC;AAACC,MAAAA,IAAAA;AAAa,KAAC,GAAAD,IAAA;AAANE,IAAAA,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;EAAA,OAAMC,SAAA,CAAWH,KAAK,CAACI,EAAE,CAAC,gBAAGC,KAAA,CAAAC,aAAA,CAACC,MAAM,CAACV,IAAI,EAAKG,KAAQ,CAAC,gBAAGK,KAAA,CAAAC,aAAA,CAAA,GAAA,EAAAE,QAAA,CAAA,EAAA,EAAOR,KAAK,EAAA;IAAED,IAAI,EAAEA,IAAI,KAAA,IAAA,IAAJA,IAAI,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAJA,IAAI,CAAEU,OAAO,CAAC,GAAG,EAAC,EAAE,CAAA;AAAE,GAAA,CAAG,CAAC,CAAA;AAAA,EAAA;AAE9HC,MAAAA,WAAW,GAAGC,KAAA,IAA2B;EAAA,IAA1B;MAACP,EAAE;AAACQ,MAAAA,OAAAA;AAAgB,KAAC,GAAAD,KAAA;AAANX,IAAAA,KAAK,GAAAC,wBAAA,CAAAU,KAAA,EAAAE,UAAA,CAAA,CAAA;AAC9C,EAAA,oBAAOR,KAAA,CAAAC,aAAA,CAAA,GAAA,EAAAE,QAAA,CAAA;IAAGI,OAAO,EAAGE,CAAC,IAAK;M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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { getColor } from '@startlibs/utils';
|
|
3
|
+
|
|
4
|
+
const Loading = /*#__PURE__*/styled.div.withConfig({
|
|
5
|
+
displayName: "Loading",
|
|
6
|
+
componentId: "sc-5t5spc-0"
|
|
7
|
+
})(["z-index:1;--loading-color:", ";--loading-bw:", "px;width:", "px;aspect-ratio:1;flex-shrink:0;border-radius:50%;background:radial-gradient(farthest-side,var(--loading-color) 94%,#0000) top/var(--loading-bw) var(--loading-bw) no-repeat,conic-gradient(#0000 15%,var(--loading-color));-webkit-mask:radial-gradient(farthest-side,#0000 calc(100% - var(--loading-bw)),#000 0);mask:radial-gradient(farthest-side,#0000 calc(100% - var(--loading-bw)),#000 0);animation:loading-spin 0.6s infinite linear;", " @keyframes loading-spin{100%{transform:rotate(1turn)}}"], props => props.color || (props.white ? 'rgba(255,255,255,0.9)' : getColor("main")(props)), props => props.borderWidth || 4, props => props.size || 26, props => props.absolute && "\n position: absolute;\n top: 0;\n bottom: 0;\n right: 0;\n left: 0;\n margin: auto;\n ");
|
|
8
|
+
|
|
9
|
+
export { Loading };
|
|
10
|
+
//# sourceMappingURL=Loading.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loading.mjs","sources":["../src/Loading.jsx"],"sourcesContent":["import styled from 'styled-components'\nimport {getColor} from '@startlibs/utils'\n\nexport const Loading = styled.div`\n z-index:1;\n --loading-color: ${props => props.color || (props.white ? 'rgba(255,255,255,0.9)' : getColor(\"main\")(props))};\n --loading-bw: ${props => props.borderWidth || 4}px;\n width: ${props => props.size || 26}px;\n aspect-ratio: 1;\n flex-shrink: 0;\n border-radius: 50%;\n background:\n radial-gradient(farthest-side, var(--loading-color) 94%, #0000) top/var(--loading-bw) var(--loading-bw) no-repeat,\n conic-gradient(#0000 15%, var(--loading-color));\n -webkit-mask: radial-gradient(farthest-side, #0000 calc(100% - var(--loading-bw)), #000 0);\n mask: radial-gradient(farthest-side, #0000 calc(100% - var(--loading-bw)), #000 0);\n animation: loading-spin 0.6s infinite linear;\n ${props => props.absolute && `\n position: absolute;\n top: 0;\n bottom: 0;\n right: 0;\n left: 0;\n margin: auto;\n `}\n @keyframes loading-spin {\n 100% {transform: rotate(1turn)}\n }\n `\n"],"names":["Loading","styled","div","withConfig","displayName","componentId","props","color","white","getColor","borderWidth","size","absolute"],"mappings":";;;MAGaA,OAAO,gBAAGC,MAAM,CAACC,GAAG,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,SAAA;EAAAC,WAAA,EAAA,aAAA;AAAA,CAAA,CAAA,CAAA,CAAA,4BAAA,EAAA,gBAAA,EAAA,WAAA,EAAA,kbAAA,EAAA,yDAAA,CAAA,EAEVC,KAAK,IAAIA,KAAK,CAACC,KAAK,KAAKD,KAAK,CAACE,KAAK,GAAG,uBAAuB,GAAGC,QAAQ,CAAC,MAAM,CAAC,CAACH,KAAK,CAAC,CAAC,EAC5FA,KAAK,IAAIA,KAAK,CAACI,WAAW,IAAI,CAAC,EACtCJ,KAAK,IAAIA,KAAK,CAACK,IAAI,IAAI,EAAE,EAUhCL,KAAK,IAAIA,KAAK,CAACM,QAAQ,8HAOxB;;;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
+
import _isString from 'lodash/fp/isString';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { willUseFlipSwitch } from './Flip.mjs';
|
|
7
|
+
import { Loading } from './Loading.mjs';
|
|
8
|
+
import { useLazyConstant, useEnsureRef } from '@startlibs/core';
|
|
9
|
+
import { twoWayAnimation } from '@startlibs/utils';
|
|
10
|
+
|
|
11
|
+
const _excluded = ["useAnimation", "outerRef", "onEnter", "onLeave"];
|
|
12
|
+
const [loadingEnter, loadingLeave] = twoWayAnimation('opacity:0;', 'opacity:1;');
|
|
13
|
+
twoWayAnimation('opacity:0; transform:translateY(50%)', 'opacity:1;transform:translateY(0)');
|
|
14
|
+
const BlockContainer = /*#__PURE__*/styled.div.withConfig({
|
|
15
|
+
displayName: "LoadingDiv__BlockContainer",
|
|
16
|
+
componentId: "sc-1g7ljba-0"
|
|
17
|
+
})(["position:relative;"]);
|
|
18
|
+
const FlipDiv = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
useAnimation,
|
|
21
|
+
outerRef,
|
|
22
|
+
onEnter = onEnter,
|
|
23
|
+
onLeave = onLeave
|
|
24
|
+
} = _ref,
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
const ensuredRef = useEnsureRef(outerRef);
|
|
27
|
+
useAnimation(ensuredRef, onEnter, onLeave);
|
|
28
|
+
return /*#__PURE__*/React.createElement(BlockContainer, _extends({}, props, {
|
|
29
|
+
ref: ensuredRef
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
const PaddingDiv = /*#__PURE__*/styled.div.withConfig({
|
|
33
|
+
displayName: "LoadingDiv__PaddingDiv",
|
|
34
|
+
componentId: "sc-1g7ljba-1"
|
|
35
|
+
})(["padding:", " 0;"], props => props.height);
|
|
36
|
+
const LoadingDiv = _ref2 => {
|
|
37
|
+
let {
|
|
38
|
+
defaultToSuspense = true,
|
|
39
|
+
fallback,
|
|
40
|
+
isLoading,
|
|
41
|
+
className,
|
|
42
|
+
height = 12,
|
|
43
|
+
size = 32,
|
|
44
|
+
borderWidth = 5,
|
|
45
|
+
children
|
|
46
|
+
} = _ref2;
|
|
47
|
+
const flipAnimation = useLazyConstant(willUseFlipSwitch);
|
|
48
|
+
const loadingBlock = /*#__PURE__*/React.createElement(PaddingDiv, {
|
|
49
|
+
height: _isString(height) ? borderWidth : height + 'rem'
|
|
50
|
+
}, /*#__PURE__*/React.createElement(Loading, {
|
|
51
|
+
autoFocus: true,
|
|
52
|
+
absolute: true,
|
|
53
|
+
size: size,
|
|
54
|
+
borderWidth: borderWidth
|
|
55
|
+
}));
|
|
56
|
+
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
57
|
+
fallback: /*#__PURE__*/React.createElement(FlipDiv, {
|
|
58
|
+
key: "loading",
|
|
59
|
+
padded: true,
|
|
60
|
+
onEnter: loadingEnter,
|
|
61
|
+
onLeave: loadingLeave,
|
|
62
|
+
useAnimation: flipAnimation,
|
|
63
|
+
className: className
|
|
64
|
+
}, fallback, loadingBlock)
|
|
65
|
+
}, typeof isLoading === 'boolean' || defaultToSuspense ? isLoading ? /*#__PURE__*/React.createElement(FlipDiv, {
|
|
66
|
+
key: "loading",
|
|
67
|
+
padded: true,
|
|
68
|
+
onEnter: loadingEnter,
|
|
69
|
+
onLeave: loadingLeave,
|
|
70
|
+
useAnimation: flipAnimation,
|
|
71
|
+
className: className
|
|
72
|
+
}, fallback, loadingBlock) : /*#__PURE__*/React.createElement(FlipDiv, {
|
|
73
|
+
key: "loaded",
|
|
74
|
+
loaded: true,
|
|
75
|
+
onEnter: loadingEnter,
|
|
76
|
+
onLeave: loadingLeave,
|
|
77
|
+
useAnimation: flipAnimation,
|
|
78
|
+
className: className
|
|
79
|
+
}, children) : children);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { LoadingDiv };
|
|
83
|
+
//# sourceMappingURL=LoadingDiv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingDiv.mjs","sources":["../src/LoadingDiv.jsx"],"sourcesContent":["import React from 'react'\nimport _ from 'lodash/fp'\nimport styled from 'styled-components'\nimport {willUseFlipSwitch} from './Flip'\nimport {Loading} from './Loading'\nimport {useEnsureRef, useLazyConstant} from '@startlibs/core'\nimport {twoWayAnimation} from '@startlibs/utils'\n\n\nconst [loadingEnter, loadingLeave] = twoWayAnimation('opacity:0;', 'opacity:1;')\nconst [onEnter, onLeave] = twoWayAnimation('opacity:0; transform:translateY(50%)', 'opacity:1;transform:translateY(0)')\n\nconst BlockContainer = styled.div`\n position:relative;\n`\n\nconst FlipDiv = ({useAnimation, outerRef, onEnter = onEnter, onLeave = onLeave, ...props}) => {\n const ensuredRef = useEnsureRef(outerRef)\n useAnimation(ensuredRef, onEnter, onLeave)\n return <BlockContainer {...props} ref={ensuredRef}/>\n}\n\nconst PaddingDiv = styled.div`\n padding: ${props => props.height} 0;\n`\n\nexport const LoadingDiv = ({defaultToSuspense = true, fallback, isLoading, className, height = 12, size = 32, borderWidth = 5, children}) => {\n const flipAnimation = useLazyConstant(willUseFlipSwitch)\n\n const loadingBlock = <PaddingDiv height={_.isString(height) ? borderWidth : (height+'rem')}>\n <Loading autoFocus absolute size={size} borderWidth={borderWidth}/>\n </PaddingDiv>\n\n return <React.Suspense\n fallback={<FlipDiv\n key=\"loading\"\n padded\n onEnter={loadingEnter}\n onLeave={loadingLeave}\n useAnimation={flipAnimation}\n className={className}\n >\n {fallback}\n {loadingBlock}\n </FlipDiv>}\n >\n {\n (typeof isLoading === 'boolean' || defaultToSuspense)\n ? (isLoading\n ? <FlipDiv\n key=\"loading\"\n padded\n onEnter={loadingEnter}\n onLeave={loadingLeave}\n useAnimation={flipAnimation}\n className={className}\n >\n {fallback}\n {loadingBlock}\n </FlipDiv>\n : <FlipDiv\n key=\"loaded\"\n loaded\n onEnter={loadingEnter}\n onLeave={loadingLeave}\n useAnimation={flipAnimation}\n className={className}\n >\n {children}\n </FlipDiv>\n )\n : children\n }\n </React.Suspense>\n}"],"names":["loadingEnter","loadingLeave","twoWayAnimation","BlockContainer","styled","div","withConfig","displayName","componentId","FlipDiv","_ref","useAnimation","outerRef","onEnter","onLeave","props","_objectWithoutProperties","_excluded","ensuredRef","useEnsureRef","React","createElement","_extends","ref","PaddingDiv","height","LoadingDiv","_ref2","defaultToSuspense","fallback","isLoading","className","size","borderWidth","children","flipAnimation","useLazyConstant","willUseFlipSwitch","loadingBlock","_isString","Loading","autoFocus","absolute","Suspense","key","padded","loaded"],"mappings":";;;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AA,SAAS,EAAEA,SAAAA;GAEVF,EAAAA,QAAQ,EACRS,YACM,CAAC,gBACRlB,KAAA,CAAAC,aAAA,CAACZ,OAAO,EAAA;AACRmC,IAAAA,GAAG,EAAC,QAAQ;IACZE,MAAM,EAAA,IAAA;AACNjC,IAAAA,OAAO,EAAEb,YAAa;AACtBc,IAAAA,OAAO,EAAEb,YAAa;AACtBU,IAAAA,YAAY,EAAEwB,aAAc;AAC5BJ,IAAAA,SAAS,EAAEA,SAAAA;AAAU,GAAA,EAEpBG,QACM,CAAC,GAEVA,QAEQ,CAAC,CAAA;AACnB;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
+
import _isObject from 'lodash/fp/isObject';
|
|
3
|
+
import React, { useEffect, useRef } from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { willUseSharedState, useToggle, Fill } from '@startlibs/core';
|
|
6
|
+
import { oneWayAnimation, callIfFunction, getColor } from '@startlibs/utils';
|
|
7
|
+
import { useFlipAnimation } from './Flip.mjs';
|
|
8
|
+
import { Icon } from './Icon.mjs';
|
|
9
|
+
|
|
10
|
+
const NotificationContainer = /*#__PURE__*/styled.div.withConfig({
|
|
11
|
+
displayName: "Notifications__NotificationContainer",
|
|
12
|
+
componentId: "sc-naxsn6-0"
|
|
13
|
+
})(["position:fixed;top:0;height:1px;left:0;right:0;text-align:center;"]);
|
|
14
|
+
const Notification = /*#__PURE__*/styled.div.withConfig({
|
|
15
|
+
displayName: "Notifications__Notification",
|
|
16
|
+
componentId: "sc-naxsn6-1"
|
|
17
|
+
})(["padding:1rem 4.5rem 1rem 1.5rem;font-size:14px;font-weight:500;border-radius:10px;color:white;text-align:left;background:", ";box-shadow:0 2px 0px 0px rgba(0,0,0,0.1);min-width:12rem;min-height:48px;display:inline-flex;align-items:center;position:relative;top:1rem;", "{color:white;display:inline-block;background-color:rgba(0,0,0,0.1);font-size:18px;width:24px;height:24px;text-align:center;line-height:24px;border-radius:50%;cursor:pointer;position:absolute;top:50%;transform:translateY(-50%);right:1rem;&:hover{background-color:rgba(0,0,0,0.2);}}"], props => getColor(props.type)(props), Icon);
|
|
18
|
+
const [useNotification, useNotificationRef, setNotification] = willUseSharedState();
|
|
19
|
+
const willSetNotification = str => () => setNotification(str);
|
|
20
|
+
const animation = oneWayAnimation('opacity:0; transform:translateY(-20px)', 'opacity:1;transform:translate(0)');
|
|
21
|
+
const Notifications = () => {
|
|
22
|
+
const toggle = useToggle();
|
|
23
|
+
const [rawNotification, setNotification] = useNotification();
|
|
24
|
+
const {
|
|
25
|
+
msg,
|
|
26
|
+
type,
|
|
27
|
+
timeout = 5000
|
|
28
|
+
} = _isObject(rawNotification) ? rawNotification : {
|
|
29
|
+
type: "success",
|
|
30
|
+
msg: rawNotification
|
|
31
|
+
};
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (msg) {
|
|
34
|
+
toggle.open();
|
|
35
|
+
setTimeout(toggle.willCloseAfter(timeout), 100);
|
|
36
|
+
}
|
|
37
|
+
}, [msg]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!toggle.isOpen) {
|
|
40
|
+
setNotification(null);
|
|
41
|
+
}
|
|
42
|
+
}, [toggle.isOpen]);
|
|
43
|
+
return toggle.isOpen && /*#__PURE__*/React.createElement(Fill, {
|
|
44
|
+
name: "Notifications"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(FlipNotification, {
|
|
46
|
+
type: type
|
|
47
|
+
}, callIfFunction(msg, toggle.close), /*#__PURE__*/React.createElement(Icon, {
|
|
48
|
+
icon: "x",
|
|
49
|
+
onClick: toggle.close
|
|
50
|
+
})));
|
|
51
|
+
};
|
|
52
|
+
const FlipNotification = props => {
|
|
53
|
+
const ref = useRef();
|
|
54
|
+
useFlipAnimation(ref, animation);
|
|
55
|
+
return /*#__PURE__*/React.createElement(NotificationContainer, {
|
|
56
|
+
ref: ref
|
|
57
|
+
}, /*#__PURE__*/React.createElement(Notification, _extends({
|
|
58
|
+
id: "js-share-notification"
|
|
59
|
+
}, props)));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { Notifications, setNotification, useNotification, useNotificationRef, willSetNotification };
|
|
63
|
+
//# sourceMappingURL=Notifications.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notifications.mjs","sources":["../src/Notifications.jsx"],"sourcesContent":["import React, {useEffect, useRef} from 'react'\nimport _ from 'lodash/fp'\nimport styled from 'styled-components'\nimport {Fill, useToggle, willUseSharedState} from '@startlibs/core'\nimport {callIfFunction, getColor, oneWayAnimation} from '@startlibs/utils'\nimport {useFlipAnimation} from './Flip'\nimport {Icon} from './Icon'\n\nconst NotificationContainer = styled.div `\n position: fixed;\n top: 0;\n height: 1px;\n left: 0;\n right: 0;\n text-align: center;\n`\n\nconst Notification = styled.div `\n padding: 1rem 4.5rem 1rem 1.5rem;\n font-size: 14px;\n font-weight: 500;\n border-radius: 10px;\n color: white;\n text-align: left;\n background: ${props => getColor(props.type)(props)};\n box-shadow: 0 2px 0px 0px rgba(0,0,0,0.1);\n min-width: 12rem;\n min-height: 48px;\n display: inline-flex;\n align-items: center;\n position: relative;\n top: 1rem;\n ${Icon} {\n color: white;\n display: inline-block;\n background-color: rgba(0,0,0,0.1);\n font-size: 18px;\n width: 24px;\n height: 24px;\n text-align: center;\n line-height: 24px;\n border-radius: 50%;\n cursor: pointer;\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n right: 1rem;\n &:hover {\n background-color: rgba(0,0,0,0.2);\n }\n }\n`\n\nconst [useNotification, useNotificationRef,setNotification] = willUseSharedState()\nexport {useNotification, useNotificationRef, setNotification}\nexport const willSetNotification = (str) => () => setNotification(str)\n\nconst animation = oneWayAnimation('opacity:0; transform:translateY(-20px)', 'opacity:1;transform:translate(0)')\n\nexport const Notifications = () => {\n const toggle = useToggle()\n const [rawNotification,setNotification] = useNotification()\n\n const {msg,type,timeout = 5000} = _.isObject(rawNotification) ? rawNotification : {type:\"success\",msg:rawNotification}\n\n useEffect(() => {\n if (msg) {\n toggle.open()\n setTimeout(toggle.willCloseAfter(timeout), 100)\n }\n },[msg])\n useEffect(() => {\n if (!toggle.isOpen) {\n setNotification(null)\n }\n },[toggle.isOpen])\n\n return toggle.isOpen && (<Fill name=\"Notifications\">\n <FlipNotification type={type}>\n {callIfFunction(msg,toggle.close)}\n <Icon icon=\"x\" onClick={toggle.close}/>\n </FlipNotification>\n </Fill>)\n}\nconst FlipNotification = (props) => {\n const ref = useRef()\n useFlipAnimation(ref,animation)\n return <NotificationContainer ref={ref}><Notification id=\"js-share-notification\" {...props}/></NotificationContainer>\n}"],"names":["NotificationContainer","styled","div","withConfig","displayName","componentId","Notification","props","getColor","type","Icon","useNotification","useNotificationRef","setNotification","willUseSharedState","willSetNotification","str","animation","oneWayAnimation","Notifications","toggle","useToggle","rawNotification","msg","timeout","_isObject","useEffect","open","setTimeout","willCloseAfter","isOpen","React","createElement","Fill","name","FlipNotification","callIfFunction","close","icon","onClick","ref","useRef","useFlipAnimation","_extends","id"],"mappings":";;;;;;;;;AAQA,MAAMA,qBAAqB,gBAAGC,MAAM,CAACC,GAAG,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,sCAAA;EAAAC,WAAA,EAAA,aAAA;AAAA,CAOvC,CAAA,CAAA,CAAA,mEAAA,CAAA,CAAA,CAAA;AAED,MAAMC,YAAY,gBAAGL,MAAM,CAACC,GAAG,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,6BAAA;EAAAC,WAAA,EAAA,aAAA;AAAA,CAAA,CAAA,CAAA,CAAA,2HAAA,EAAA,8IAAA,EAAA,0RAAA,CAAA,EAOfE,KAAK,IAAIC,QAAQ,CAACD,KAAK,CAACE,IAAI,CAAC,CAACF,KAAK,CAAC,EAQhDG,IAAI,CAmBP,CAAA;AAEK,MAAA,CAACC,eAAe,EAAEC,kBAAkB,EAACC,eAAe,CAAC,GAAGC,kBAAkB,G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C,aAAA,CAACtB,IAAI,EAAA;AAAC4B,IAAAA,IAAI,EAAC,GAAG;IAACC,OAAO,EAAEnB,MAAM,CAACiB,KAAAA;GAAO,CACtB,CACd,CAAE,CAAA;AACV,EAAC;AACD,MAAMF,gBAAgB,GAAI5B,KAAK,IAAK;AAClC,EAAA,MAAMiC,GAAG,GAAGC,MAAM,EAAE,CAAA;AACpBC,EAAAA,gBAAgB,CAACF,GAAG,EAACvB,SAAS,CAAC,CAAA;AAC/B,EAAA,oBAAOc,KAAA,CAAAC,aAAA,CAAChC,qBAAqB,EAAA;AAACwC,IAAAA,GAAG,EAAEA,GAAAA;AAAI,GAAA,eAACT,KAAA,CAAAC,aAAA,CAAC1B,YAAY,EAAAqC,QAAA,CAAA;AAACC,IAAAA,EAAE,EAAC,uBAAA;GAA4BrC,EAAAA,KAAK,CAAE,CAAwB,CAAC,CAAA;AACvH,CAAC;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { getColor, oneWayAnimation, animationTiming } from '@startlibs/utils';
|
|
4
|
+
import { useToggle } from '@startlibs/core';
|
|
5
|
+
import { useFlipLeave } from './Flip.mjs';
|
|
6
|
+
|
|
7
|
+
const LoadingBar = /*#__PURE__*/styled.div.withConfig({
|
|
8
|
+
displayName: "PageLoader__LoadingBar",
|
|
9
|
+
componentId: "sc-96jeob-0"
|
|
10
|
+
})(["width:100%;border-radius:0 1px 1px 0;height:4px;position:fixed;background:", ";transform:translateX(-100%);", " left:0;z-index:99999;box-shadow:", ";", " ", ""], props => props.bottom ? css(["", ""], getColor('main')) : "#84D359", props => props.bottom ? "bottom:69px;" : "top: 0;", props => props.bottom ? "0 0 1px 1px rgba(0,132,214,0.2);" : "0 0 2px 0 rgba(0,0,0,0.5);", props => props.loading && "\n transform: translateX(-30%);\n transition: transform 1.5s ease;\n ", props => props.closing && "\n transform: translateX(0);\n transition: transform 0.3s ease-in;\n ");
|
|
11
|
+
const PageLoader = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
isLoading
|
|
14
|
+
} = _ref;
|
|
15
|
+
const loader = useToggle();
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (isLoading) {
|
|
18
|
+
loader.open();
|
|
19
|
+
} else {
|
|
20
|
+
loader.closeAfter(500);
|
|
21
|
+
}
|
|
22
|
+
}, [isLoading]);
|
|
23
|
+
return /*#__PURE__*/React.createElement(LoadingBar, {
|
|
24
|
+
loading: loader.isOpen,
|
|
25
|
+
closing: loader.closing
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const animation = oneWayAnimation('transform:translateX(-30%);', 'transform:translateX(0);');
|
|
29
|
+
const SuspenseLoadingBar = () => {
|
|
30
|
+
const ref = React.useRef();
|
|
31
|
+
useFlipLeave(ref, animation, {
|
|
32
|
+
reverse: false,
|
|
33
|
+
timing: animationTiming('0.3s ease-in')
|
|
34
|
+
});
|
|
35
|
+
return /*#__PURE__*/React.createElement(LoadingBar, {
|
|
36
|
+
ref: ref,
|
|
37
|
+
loading: true
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { LoadingBar, PageLoader, SuspenseLoadingBar };
|
|
42
|
+
//# sourceMappingURL=PageLoader.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageLoader.mjs","sources":["../src/PageLoader.jsx"],"sourcesContent":["import React, {useEffect} from 'react'\nimport styled, {css} from 'styled-components'\nimport {oneWayAnimation, getColor} from '@startlibs/utils'\nimport {useToggle} from '@startlibs/core'\nimport {useFlipLeave} from './Flip'\nimport {animationTiming} from '@startlibs/utils'\n\nexport const LoadingBar = styled.div`\n width: 100%;\n border-radius: 0 1px 1px 0;\n height: 4px;\n position: fixed;\n background: ${props => props.bottom ? css`${getColor('main')}`:`#84D359`};\n transform: translateX(-100%);\n ${props => props.bottom ? \"bottom:69px;\" : \"top: 0;\"}\n left: 0;\n z-index: 99999;\n box-shadow: ${props => props.bottom ? `0 0 1px 1px rgba(0,132,214,0.2);`:`0 0 2px 0 rgba(0,0,0,0.5);`};\n ${props => props.loading && `\n transform: translateX(-30%);\n transition: transform 1.5s ease;\n `}\n ${props => props.closing && `\n transform: translateX(0);\n transition: transform 0.3s ease-in;\n `}\n`\n\n\nexport const PageLoader = ({isLoading}) => {\n const loader = useToggle()\n useEffect(() => {\n if (isLoading) {\n loader.open()\n } else {\n loader.closeAfter(500)\n }\n },[isLoading])\n\n return <LoadingBar loading={loader.isOpen} closing={loader.closing}/>\n}\n\nconst animation = oneWayAnimation('transform:translateX(-30%);','transform:translateX(0);')\nexport const SuspenseLoadingBar = () => {\n const ref = React.useRef()\n useFlipLeave(ref,animation,{reverse: false,timing:animationTiming('0.3s ease-in')})\n return <LoadingBar ref={ref} loading/>\n}"],"names":["LoadingBar","styled","div","withConfig","displayName","componentId","props","bottom","css","getColor","loading","closing","PageLoader","_ref","isLoading","loader","useToggle","useEffect","open","closeAfter","React","createElement","isOpen","animation","oneWayAnimation","SuspenseLoadingBar","ref","useRef","useFlipLeave","reverse","timing","animationTiming"],"mappings":";;;;;;MAOaA,UAAU,gBAAGC,MAAM,CAACC,GAAG,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,wBAAA;EAAAC,WAAA,EAAA,aAAA;AAAA,CAKpBC,CAAAA,CAAAA,CAAAA,4EAAAA,EAAAA,+BAAAA,EAAAA,mCAAAA,EAAAA,GAAAA,EAAAA,GAAAA,EAAAA,EAAAA,CAAAA,EAAAA,KAAK,IAAIA,KAAK,CAACC,MAAM,GAAGC,GAAG,WAAGC,QAAQ,CAAC,MAAM,CAAC,CAAA,GAAA,SAAY,EAEtEH,KAAK,IAAIA,KAAK,CAACC,MAAM,GAAG,cAAc,GAAG,SAAS,EAGtCD,KAAK,IAAIA,KAAK,CAACC,MAAM,GAAkE,kCAAA,GAAA,4BAAA,EACnGD,KAAK,IAAIA,KAAK,CAACI,OAAO,IAAA,8EAGvB,EACCJ,KAAK,IAAIA,KAAK,CAACK,OAAO,kFAGvB,EACF;AAGYC,MAAAA,UAAU,GAAGC,IAAA,IAAiB;EAAA,IAAhB;AAACC,IAAAA,SAAAA;AAAS,GAAC,GAAAD,IAAA,CAAA;AACpC,EAAA,MAAME,MAAM,GAAGC,SAAS,EAAE,CAAA;AAC1BC,EAAAA,SAAS,CAAC,MAAM;AACd,IAAA,IAAIH,SAAS,EAAE;MACbC,MAAM,CAACG,IAAI,EAAE,CAAA;AACf,KAAC,MAAM;AACLH,MAAAA,MAAM,CAACI,UAAU,CAAC,GAAG,CAAC,CAAA;AACxB,KAAA;AACF,GAAC,EAAC,CAACL,SAAS,CAAC,CAAC,CAAA;AAEd,EAAA,oBAAOM,KAAA,CAAAC,aAAA,CAACrB,UAAU,EAAA;IAACU,OAAO,EAAEK,MAAM,CAACO,MAAO;IAACX,OAAO,EAAEI,MAAM,CAACJ,OAAAA;AAAQ,GAAC,CAAC,CAAA;AACvE,EAAC;AAED,MAAMY,SAAS,GAAGC,eAAe,CAAC,6BAA6B,EAAC,0BAA0B,CAAC,CAAA;AAC9EC,MAAAA,kBAAkB,GAAGA,MAAM;AACtC,EAAA,MAAMC,GAAG,GAAGN,KAAK,CAACO,MAAM,EAAE,CAAA;AAC1BC,EAAAA,YAAY,CAACF,GAAG,EAACH,SAAS,EAAC;AAACM,IAAAA,OAAO,EAAE,KAAK;IAACC,MAAM,EAACC,eAAe,CAAC,cAAc,CAAA;AAAC,GAAC,CAAC,CAAA;AACnF,EAAA,oBAAOX,KAAA,CAAAC,aAAA,CAACrB,UAAU,EAAA;AAAC0B,IAAAA,GAAG,EAAEA,GAAI;IAAChB,OAAO,EAAA,IAAA;AAAA,GAAC,CAAC,CAAA;AACxC;;;;"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
|
|
5
|
+
import _over from 'lodash/fp/over';
|
|
6
|
+
import _isString from 'lodash/fp/isString';
|
|
7
|
+
import _without from 'lodash/fp/without';
|
|
8
|
+
import _isObject from 'lodash/fp/isObject';
|
|
9
|
+
import React, { useRef } from 'react';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
import { willUseSharedState, Fill } from '@startlibs/core';
|
|
12
|
+
import { getColor, media, oneWayAnimation, printerMedia, callIfFunction } from '@startlibs/utils';
|
|
13
|
+
import { useFlipAnimation } from './Flip.mjs';
|
|
14
|
+
import { Icon } from './Icon.mjs';
|
|
15
|
+
import { transparentize, darken } from 'polished';
|
|
16
|
+
import { Button } from './Button.mjs';
|
|
17
|
+
|
|
18
|
+
const _excluded = ["content", "type", "marginTop"];
|
|
19
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
const PersistentNotification = /*#__PURE__*/styled.div.withConfig({
|
|
23
|
+
displayName: "PersistentNotifications__PersistentNotification",
|
|
24
|
+
componentId: "sc-1t7i0dh-0"
|
|
25
|
+
})(["color:", ";h4{font-size:15px;font-weight:500;margin-bottom:0.5rem;}p{font-size:13px;margin-bottom:0;}"], getColor('warning'));
|
|
26
|
+
const PersistentNotificationContent = /*#__PURE__*/styled.div.withConfig({
|
|
27
|
+
displayName: "PersistentNotifications__PersistentNotificationContent",
|
|
28
|
+
componentId: "sc-1t7i0dh-1"
|
|
29
|
+
})(["display:flex;align-items:center;padding:1.5rem;"]);
|
|
30
|
+
const PersistentNotificationIcon = /*#__PURE__*/styled(Icon).withConfig({
|
|
31
|
+
displayName: "PersistentNotifications__PersistentNotificationIcon",
|
|
32
|
+
componentId: "sc-1t7i0dh-2"
|
|
33
|
+
})(["font-size:38px;width:4rem;height:4rem;line-height:4rem;border-radius:100px;text-align:center;background:", ";margin-right:1rem;flex-shrink:0;", ""], props => transparentize(0.88, getColor("warning")(props)), props => props.icon === 'warning' && "font-size:30px;");
|
|
34
|
+
const PersistentNotificationActions = /*#__PURE__*/styled.div.withConfig({
|
|
35
|
+
displayName: "PersistentNotifications__PersistentNotificationActions",
|
|
36
|
+
componentId: "sc-1t7i0dh-3"
|
|
37
|
+
})(["display:flex;margin-top:-0.25rem;padding:0 1.5rem 1.5rem;", "{flex-grow:1;}", " ~ ", "{margin-left:0;margin-right:1rem;}", ""], Button, Button, Button, media.max(390)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n ", " {\n width: 100%;\n }\n ", " ~ ", " {\n margin-left: 0;\n margin-top: 0.75rem;\n }\n "])), Button, Button, Button));
|
|
38
|
+
const PersistentNotificationCloseIcon = /*#__PURE__*/styled(Icon).attrs({
|
|
39
|
+
icon: 'x'
|
|
40
|
+
}).withConfig({
|
|
41
|
+
displayName: "PersistentNotifications__PersistentNotificationCloseIcon",
|
|
42
|
+
componentId: "sc-1t7i0dh-4"
|
|
43
|
+
})(["position:absolute;width:30px;height:30px;font-size:20px;line-height:30px;cursor:pointer;border-radius:50%;text-align:center;z-index:1000;top:0.5rem;right:0.5rem;color:", ";background:", ";:hover{background:", ";}:active{background:", ";}"], props => props.type && props.type !== 'main' ? getColor(props.type)(props) : darken(0.1, getColor("main")(props)), props => transparentize(0.90, getColor(props.type || "main")(props)), props => transparentize(0.85, getColor(props.type || "main")(props)), props => transparentize(0.82, getColor(props.type || "main")(props)));
|
|
44
|
+
const [useNotifications,, setNotifications] = willUseSharedState([]);
|
|
45
|
+
const openPersistentNotification = notification => {
|
|
46
|
+
const newNotification = _objectSpread({
|
|
47
|
+
priority: 0,
|
|
48
|
+
type: "success"
|
|
49
|
+
}, _isObject(notification) ? notification : {
|
|
50
|
+
content: notification
|
|
51
|
+
});
|
|
52
|
+
setNotifications(list => {
|
|
53
|
+
const nextIndex = list.findIndex(n => n.priority < newNotification.priority);
|
|
54
|
+
return nextIndex < 0 ? [...list, newNotification] : [...list.slice(0, nextIndex), newNotification, ...list.slice(nextIndex)];
|
|
55
|
+
});
|
|
56
|
+
return () => setNotifications(_without([newNotification]));
|
|
57
|
+
};
|
|
58
|
+
const animation = oneWayAnimation('opacity:0; transform:translateY(-20px)', 'opacity:1;transform:translate(0)');
|
|
59
|
+
const NotificationContainer = /*#__PURE__*/styled.div.withConfig({
|
|
60
|
+
displayName: "PersistentNotifications__NotificationContainer",
|
|
61
|
+
componentId: "sc-1t7i0dh-5"
|
|
62
|
+
})(["position:fixed;top:0;height:0;right:0;z-index:20;"]);
|
|
63
|
+
const Notification = /*#__PURE__*/styled.div.withConfig({
|
|
64
|
+
displayName: "PersistentNotifications__Notification",
|
|
65
|
+
componentId: "sc-1t7i0dh-6"
|
|
66
|
+
})(["background:", ";position:relative;border-radius:19px;"], props => transparentize(0.9, getColor(props.type)(props)));
|
|
67
|
+
const NotificationWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
68
|
+
displayName: "PersistentNotifications__NotificationWrapper",
|
|
69
|
+
componentId: "sc-1t7i0dh-7"
|
|
70
|
+
})(["background:white;margin-top:", ";margin-right:0.75rem;margin-left:0.75rem;padding:5px;border-radius:22px;box-shadow:0 0 10px 0 rgba(0,0,0,0.1),0 1px 2px 1px rgba(0,0,0,0.15);max-width:364px;", " ", ""], props => props.marginTop || "3.5rem", media.mobile(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-top: ", ";\n "])), props => props.marginTop || "4rem"), printerMedia(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
71
|
+
const [useIsHiddenPersistentNotifications,, hidePersistentNotifications] = willUseSharedState(false);
|
|
72
|
+
const PersistentNotifications = () => {
|
|
73
|
+
const [notifications, setNotifications] = useNotifications();
|
|
74
|
+
const [isHidden] = useIsHiddenPersistentNotifications();
|
|
75
|
+
if (!notifications.length || isHidden) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const closeMessage = e => {
|
|
79
|
+
setNotifications(list => list.slice(1));
|
|
80
|
+
};
|
|
81
|
+
const _notifications$ = notifications[0],
|
|
82
|
+
{
|
|
83
|
+
content,
|
|
84
|
+
type,
|
|
85
|
+
marginTop
|
|
86
|
+
} = _notifications$,
|
|
87
|
+
notification = _objectWithoutProperties(_notifications$, _excluded);
|
|
88
|
+
return /*#__PURE__*/React.createElement(Fill, {
|
|
89
|
+
name: "PersistentNotifications"
|
|
90
|
+
}, /*#__PURE__*/React.createElement(FlipNotification, {
|
|
91
|
+
type: type,
|
|
92
|
+
marginTop: marginTop
|
|
93
|
+
}, content ? callIfFunction(content, closeMessage) : /*#__PURE__*/React.createElement(DefaultNotification, _extends({
|
|
94
|
+
type: type,
|
|
95
|
+
_onClose: closeMessage
|
|
96
|
+
}, notification))));
|
|
97
|
+
};
|
|
98
|
+
const DefaultNotification = _ref => {
|
|
99
|
+
let {
|
|
100
|
+
type,
|
|
101
|
+
title,
|
|
102
|
+
body,
|
|
103
|
+
actions,
|
|
104
|
+
icon,
|
|
105
|
+
skipClose,
|
|
106
|
+
_onClose,
|
|
107
|
+
onClose
|
|
108
|
+
} = _ref;
|
|
109
|
+
return /*#__PURE__*/React.createElement(PersistentNotification, null, /*#__PURE__*/React.createElement(PersistentNotificationContent, null, _isString(icon) || !icon ? /*#__PURE__*/React.createElement(PersistentNotificationIcon, {
|
|
110
|
+
icon: icon || type
|
|
111
|
+
}) : icon, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", null, title), body)), actions && /*#__PURE__*/React.createElement(PersistentNotificationActions, null, actions), !skipClose && /*#__PURE__*/React.createElement(PersistentNotificationCloseIcon, {
|
|
112
|
+
type: "warning",
|
|
113
|
+
onClick: _over([_onClose, onClose])
|
|
114
|
+
}));
|
|
115
|
+
};
|
|
116
|
+
const FlipNotification = props => {
|
|
117
|
+
const ref = useRef();
|
|
118
|
+
useFlipAnimation(ref, animation);
|
|
119
|
+
return /*#__PURE__*/React.createElement(NotificationContainer, {
|
|
120
|
+
className: "JS-fix-dialog-scroll",
|
|
121
|
+
ref: ref
|
|
122
|
+
}, /*#__PURE__*/React.createElement(NotificationWrapper, {
|
|
123
|
+
marginTop: props.marginTop
|
|
124
|
+
}, /*#__PURE__*/React.createElement(Notification, _extends({
|
|
125
|
+
id: "js-share-notification"
|
|
126
|
+
}, props))));
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export { PersistentNotification, PersistentNotificationActions, PersistentNotificationCloseIcon, PersistentNotificationContent, PersistentNotificationIcon, PersistentNotifications, hidePersistentNotifications, openPersistentNotification, useIsHiddenPersistentNotifications };
|
|
130
|
+
//# sourceMappingURL=PersistentNotifications.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PersistentNotifications.mjs","sources":["../src/PersistentNotifications.jsx"],"sourcesContent":["import React, {useRef} from 'react'\nimport _ from 'lodash/fp'\nimport styled from 'styled-components'\nimport {Fill, willUseSharedState} from '@startlibs/core'\nimport {media,getColor, callIfFunction, oneWayAnimation, printerMedia} from '@startlibs/utils'\nimport {useFlipAnimation} from './Flip'\nimport {Icon} from './Icon'\nimport {darken, transparentize } from 'polished';\nimport {Button} from './Button'\n\nexport const PersistentNotification = styled.div`\n color: ${getColor('warning')};\n h4 {\n font-size: 15px;\n font-weight: 500;\n margin-bottom: 0.5rem;\n }\n p {\n font-size: 13px;\n margin-bottom: 0;\n }\n`\n\nexport const PersistentNotificationContent = styled.div`\n display: flex;\n align-items: center;\n padding: 1.5rem;\n`\nexport const PersistentNotificationIcon = styled(Icon)`\n font-size: 38px;\n width: 4rem;\n height: 4rem;\n line-height: 4rem;\n border-radius: 100px;\n text-align: center;\n background: ${props => transparentize(0.88, getColor(\"warning\")(props))};\n margin-right: 1rem;\n flex-shrink: 0;\n ${props => props.icon === 'warning' && `font-size:30px;`}\n`\nexport const PersistentNotificationActions = styled.div`\n display: flex;\n margin-top: -0.25rem;\n padding: 0 1.5rem 1.5rem;\n ${Button} {\n flex-grow: 1;\n }\n ${Button} ~ ${Button} {\n margin-left: 0;\n margin-right: 1rem;\n }\n ${media.max(390)`\n display: block;\n ${Button} {\n width: 100%;\n }\n ${Button} ~ ${Button} {\n margin-left: 0;\n margin-top: 0.75rem;\n }\n `}\n`\nexport const PersistentNotificationCloseIcon = styled(Icon).attrs({icon: 'x'})`\n position: absolute;\n width: 30px;\n height: 30px;\n font-size: 20px;\n line-height: 30px;\n cursor: pointer;\n border-radius: 50%;\n text-align: center;\n z-index: 1000;\n top: 0.5rem;\n right: 0.5rem;\n color: ${props => props.type && props.type!== 'main' ? getColor(props.type)(props) : darken(0.1, getColor(\"main\")(props))};\n background: ${props => transparentize(0.90, getColor(props.type || \"main\")(props))};\n :hover {\n background: ${props => transparentize(0.85, getColor(props.type || \"main\")(props))};\n }\n :active {\n background: ${props => transparentize(0.82, getColor(props.type || \"main\")(props))};\n }\n `\n\n\nconst [useNotifications, ,setNotifications] = willUseSharedState([])\n\nexport const openPersistentNotification = (notification) => {\n const newNotification = {priority:0,type:\"success\",...(_.isObject(notification) ? notification : {content:notification})}\n\n setNotifications(list => {\n const nextIndex = list.findIndex(n => n.priority < newNotification.priority)\n return nextIndex < 0\n ? [...list,newNotification]\n : [...list.slice(0,nextIndex),newNotification,...list.slice(nextIndex)]\n })\n return () => setNotifications(_.without([newNotification]))\n}\n\n\nconst animation = oneWayAnimation('opacity:0; transform:translateY(-20px)', 'opacity:1;transform:translate(0)')\n\nconst NotificationContainer = styled.div `\n position: fixed;\n top: 0;\n height: 0;\n right: 0;\n z-index:20;\n`\n\nconst Notification = styled.div `\n background: ${props => transparentize(0.9, getColor(props.type)(props))};\n position: relative;\n border-radius: 19px;\n`\nconst NotificationWrapper = styled.div `\n background: white;\n margin-top: ${props => props.marginTop || \"3.5rem\"};\n margin-right: 0.75rem;\n margin-left: 0.75rem;\n padding: 5px;\n border-radius: 22px;\n box-shadow: 0 0 10px 0 rgba(0,0,0,0.1), 0 1px 2px 1px rgba(0,0,0,0.15);\n max-width: 364px;\n ${media.mobile`\n margin-top: ${props => props.marginTop || \"4rem\"};\n `}\n ${printerMedia`\n display: none;\n `}\n`\nconst [useIsHiddenPersistentNotifications,,hidePersistentNotifications] = willUseSharedState(false)\nexport {useIsHiddenPersistentNotifications, hidePersistentNotifications}\nexport const PersistentNotifications = () => {\n const [notifications,setNotifications] = useNotifications()\n const [isHidden] = useIsHiddenPersistentNotifications()\n\n if (!notifications.length || isHidden) {\n return null;\n }\n const closeMessage = (e) => {\n setNotifications((list) => list.slice(1))\n }\n\n const {content,type,marginTop,...notification} = notifications[0]\n\n return <Fill name=\"PersistentNotifications\">\n <FlipNotification type={type} marginTop={marginTop}>\n {content\n ? callIfFunction(content,closeMessage)\n : <DefaultNotification type={type} _onClose={closeMessage} {...notification} />\n }\n </FlipNotification>\n </Fill>\n}\n\nconst DefaultNotification = ({type, title,body,actions, icon, skipClose,_onClose,onClose}) => {\n return <PersistentNotification>\n <PersistentNotificationContent>\n {(_.isString(icon) || !icon) ? <PersistentNotificationIcon icon={icon || type}/> : icon}\n <div>\n <h4>{title}</h4>\n {body}\n </div>\n </PersistentNotificationContent>\n {\n actions &&\n <PersistentNotificationActions>\n {actions}\n </PersistentNotificationActions>\n }\n {!skipClose && <PersistentNotificationCloseIcon type=\"warning\" onClick={_.over([_onClose,onClose])}/>}\n </PersistentNotification>\n}\n\nconst FlipNotification = (props) => {\n const ref = useRef()\n useFlipAnimation(ref,animation)\n return <NotificationContainer className=\"JS-fix-dialog-scroll\" ref={ref}>\n <NotificationWrapper marginTop={props.marginTop}><Notification id=\"js-share-notification\" {...props}/></NotificationWrapper>\n </NotificationContainer>\n}\n"],"names":["PersistentNotification","styled","div","withConfig","displayName","componentId","getColor","PersistentNotificationContent","PersistentNotificationIcon","Icon","props","transparentize","icon","PersistentNotificationActions","Button","media","max","_templateObject","_taggedTemplateLiteral","PersistentNotificationCloseIcon","attrs","type","darken","useNotifications","setNotifications","willUseSharedState","openPersistentNotification","notification","newNotification","_objectSpread","priority","_isObject","content","list","nextIndex","findIndex","n","slice","_without","animation","oneWayAnimation","NotificationContainer","Notification","NotificationWrapper","marginTop","mobile","_templateObject2","printerMedia","_templateObject3","useIsHiddenPersistentNotifications","hidePersistentNotifications","PersistentNotifications","notifications","isHidden","length","closeMessage","e","_notifications$","_objectWithoutProperties","_excluded","React","createElement","Fill","name","FlipNotification","callIfFunction","DefaultNotification","_extends","_onClose","_ref","title","body","actions","skipClose","onClose","_isString","onClick","_over","ref","useRef","useFlipAnimation","className","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;MAUaA,sBAAsB,gBAAGC,MAAM,CAACC,GAAG,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,iDAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAAA,CAAA,CAAA,CAAA,QAAA,EAAA,6FAAA,CAAA,EACrCC,QAAQ,CAAC,SAAS,CAAC,EAU7B;MAEYC,6BAA6B,gBAAGN,MAAM,CAACC,GAAG,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,wDAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAItD,CAAA,CAAA,CAAA,iDAAA,CAAA,EAAA;AACM,MAAMG,0BAA0B,gBAAGP,MAAM,CAACQ,IAAI,CAAC,CAAAN,UAAA,CAAA;EA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,SAAAA;AAAU,GAAA,eAACgB,KAAA,CAAAC,aAAA,CAACnB,YAAY,EAAAyB,QAAA,CAAA;AAACe,IAAAA,EAAE,EAAC,uBAAA;AAAuB,GAAA,EAAKxE,KAAK,CAAE,CAAsB,CACtG,CAAC,CAAA;AAC1B,CAAC;;;;"}
|
package/lib/Popup.mjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import styled, { css } from 'styled-components';
|
|
5
|
+
import { useEnsureRef, Fill } from '@startlibs/core';
|
|
6
|
+
import { useFlipAnimation } from './Flip.mjs';
|
|
7
|
+
import { getDialogLayersSize } from './containers/DialogContainer.mjs';
|
|
8
|
+
import { usePositioning } from './containers/usePositioning.mjs';
|
|
9
|
+
import { twoWayAnimation, customTheme } from '@startlibs/utils';
|
|
10
|
+
|
|
11
|
+
const _excluded = ["slot", "skipPortal", "animation", "leaveAnimation", "animationOptions", "arrowRef", "className", "onClick", "children"];
|
|
12
|
+
const [fadeIn, fadeOut] = twoWayAnimation("opacity:0;", "opacity:1;");
|
|
13
|
+
const PopupDiv = /*#__PURE__*/styled.div.withConfig({
|
|
14
|
+
displayName: "Popup__PopupDiv",
|
|
15
|
+
componentId: "sc-sq2sfn-0"
|
|
16
|
+
})(["position:absolute;background-color:#FFF;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:8px;padding:1rem;text-align:initial;line-height:140%;font-size:14px;z-index:999;", " ", " ", ""], props => props.atTop && css(["margin-top:-0.25rem;"]), props => props.atBottom && css(["margin-top:0.25rem;"]), customTheme('Popup'));
|
|
17
|
+
const Popup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
18
|
+
let {
|
|
19
|
+
slot = 'Popup',
|
|
20
|
+
skipPortal,
|
|
21
|
+
animation = fadeIn,
|
|
22
|
+
leaveAnimation = true,
|
|
23
|
+
animationOptions,
|
|
24
|
+
arrowRef,
|
|
25
|
+
className,
|
|
26
|
+
onClick,
|
|
27
|
+
children
|
|
28
|
+
} = _ref,
|
|
29
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
const popupRef = useEnsureRef(ref);
|
|
31
|
+
const [positionInfo, placeholder, arrow] = usePositioning(popupRef, rest, arrowRef);
|
|
32
|
+
|
|
33
|
+
// leaveAnimation=false → sem animação de saída (nenhum clone no unmount): útil quando
|
|
34
|
+
// o popup é portalado num slot persistente (ex: NavbarPopup) e o dono desmonta na
|
|
35
|
+
// navegação — senão o clone da saída fica órfão no slot. Default true = comportamento atual.
|
|
36
|
+
useFlipAnimation(popupRef, animation, leaveAnimation, animationOptions);
|
|
37
|
+
const slotName = useMemo(() => getDialogLayersSize() === 0 ? slot : slot + '-' + (getDialogLayersSize() - 1), []);
|
|
38
|
+
const popupContainer = /*#__PURE__*/React.createElement(PopupDiv, _extends({}, positionInfo, {
|
|
39
|
+
onClick: onClick,
|
|
40
|
+
className: className,
|
|
41
|
+
ref: popupRef
|
|
42
|
+
}), arrow, children);
|
|
43
|
+
return skipPortal ? popupContainer : /*#__PURE__*/React.createElement(React.Fragment, null, placeholder, /*#__PURE__*/React.createElement(Fill, {
|
|
44
|
+
name: slotName
|
|
45
|
+
}, popupContainer));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export { Popup };
|
|
49
|
+
//# sourceMappingURL=Popup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popup.mjs","sources":["../src/Popup.jsx"],"sourcesContent":["import React, {useMemo} from 'react'\nimport styled, {css} from 'styled-components'\nimport {Fill, useEnsureRef} from '@startlibs/core'\nimport {useFlipAnimation} from './Flip'\nimport {getDialogLayersSize} from './containers/DialogContainer'\nimport {usePositioning} from './containers/usePositioning'\nimport {twoWayAnimation, customTheme} from '@startlibs/utils'\n\nconst [fadeIn, fadeOut] = twoWayAnimation(`opacity:0;`, `opacity:1;`)\n\nconst PopupDiv = styled.div`\n position: absolute;\n background-color: #FFF;\n 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);\n border-radius: 8px;\n padding: 1rem;\n text-align: initial;\n line-height: 140%;\n font-size: 14px;\n z-index: 999;\n ${props => props.atTop && css`\n margin-top: -0.25rem;\n `}\n ${props => props.atBottom && css`\n margin-top: 0.25rem;\n `}\n ${customTheme('Popup')}\n`\n\nexport const Popup = React.forwardRef(({slot = 'Popup',skipPortal, animation = fadeIn, leaveAnimation = true, animationOptions, arrowRef, className, onClick, children, ...rest},ref) => {\n const popupRef = useEnsureRef(ref)\n const [positionInfo, placeholder, arrow] = usePositioning(popupRef, rest, arrowRef)\n\n // leaveAnimation=false → sem animação de saída (nenhum clone no unmount): útil quando\n // o popup é portalado num slot persistente (ex: NavbarPopup) e o dono desmonta na\n // navegação — senão o clone da saída fica órfão no slot. Default true = comportamento atual.\n useFlipAnimation(popupRef, animation, leaveAnimation, animationOptions)\n const slotName = useMemo(() => getDialogLayersSize() === 0 ? slot : (slot + '-' + (getDialogLayersSize() - 1)), [])\n const popupContainer = <PopupDiv {...positionInfo} onClick={onClick} className={className} ref={popupRef}>\n {arrow}\n {children}\n </PopupDiv>\n return skipPortal ? popupContainer : <>\n {placeholder}\n <Fill name={slotName}>\n {popupContainer}\n </Fill>\n </>\n})"],"names":["fadeIn","fadeOut","twoWayAnimation","PopupDiv","styled","div","withConfig","displayName","componentId","props","atTop","css","atBottom","customTheme","Popup","React","forwardRef","_ref","ref","slot","skipPortal","animation","leaveAnimation","animationOptions","arrowRef","className","onClick","children","rest","_objectWithoutProperties","_excluded","popupRef","useEnsureRef","positionInfo","placeholder","arrow","usePositioning","useFlipAnimation","slotName","useMemo","getDialogLayersSize","popupContain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vE,MAAMe,QAAQ,GAAGC,OAAO,CAAC,MAAMC,mBAAmB,EAAE,KAAK,CAAC,GAAGrB,IAAI,GAAIA,IAAI,GAAG,GAAG,IAAIqB,mBAAmB,EAAE,GAAG,CAAC,CAAE,EAAE,EAAE,CAAC,CAAA;EACnH,MAAMC,cAAc,gBAAG1B,KAAA,CAAA2B,aAAA,CAACvC,QAAQ,EAAAwC,QAAA,CAAA,EAAA,EAAKV,YAAY,EAAA;AAAEP,IAAAA,OAAO,EAAEA,OAAQ;AAACD,IAAAA,SAAS,EAAEA,SAAU;AAACP,IAAAA,GAAG,EAAEa,QAAAA;GAC7FI,CAAAA,EAAAA,KAAK,EACLR,QACO,CAAC,CAAA;AACX,EAAA,OAAOP,UAAU,GAAGqB,cAAc,gBAAG1B,KAAA,CAAA2B,aAAA,CAAA3B,KAAA,CAAA6B,QAAA,QAClCV,WAAW,eACZnB,KAAA,CAAA2B,aAAA,CAACG,IAAI,EAAA;AAACC,IAAAA,IAAI,EAAER,QAAAA;GACTG,EAAAA,cACG,CACN,CAAC,CAAA;AACL,CAAC;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { media, getMargin } from '@startlibs/utils';
|
|
4
|
+
import styled, { css } from 'styled-components';
|
|
5
|
+
|
|
6
|
+
var _templateObject, _templateObject2;
|
|
7
|
+
const getMarginFromFieldChild = props => {
|
|
8
|
+
if (!props.last) return 0;
|
|
9
|
+
const fields = React.Children.toArray(props.children).filter(c => c.type.displayName === "Field" || c.type.displayName === "EnhancedInput");
|
|
10
|
+
if (!fields.length) return 0;
|
|
11
|
+
const lastField = fields.slice(-1)[0];
|
|
12
|
+
return '-' + getMargin(props.theme.Field.margins)(lastField.props);
|
|
13
|
+
};
|
|
14
|
+
const splitColumnMargins = {
|
|
15
|
+
small: 0.5,
|
|
16
|
+
'default': 1,
|
|
17
|
+
big: 2
|
|
18
|
+
};
|
|
19
|
+
const SplitColumnsContainer = /*#__PURE__*/styled.div.withConfig({
|
|
20
|
+
displayName: "SplitColumnsContainer",
|
|
21
|
+
componentId: "sc-1h4sw88-0"
|
|
22
|
+
})(["margin-bottom:", "rem;", " ", ""], getMarginFromFieldChild, props => css(["", ""], media.min(props.viewportMinWidth || 0)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: nowrap;\n margin-left: -", "rem;\n margin-right: -", "rem;\n margin-top: -", "rem;\n > * {\n flex-basis: 0;\n flex-grow: 1;\n margin-left: ", "rem;\n margin-right: ", "rem;\n margin-top: ", "rem;\n }\n "])), props => getMargin(splitColumnMargins)(props) / 2, props => getMargin(splitColumnMargins)(props) / 2, props => getMargin(splitColumnMargins)(props), props => getMargin(splitColumnMargins)(props) / 2, props => getMargin(splitColumnMargins)(props) / 2, props => getMargin(splitColumnMargins)(props))), props => props.twoColumnsBelowVW && css(["", ""], media.max(props.twoColumnsBelowVW)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex-wrap: wrap;\n > * {\n flex-basis: 47%;\n }\n "])))));
|
|
23
|
+
const fixDoubledLastMarginBottom = children => {
|
|
24
|
+
let last = React.Children.count(children) - 1;
|
|
25
|
+
function processChild(child, i) {
|
|
26
|
+
if (i === last && child && child.type && child.type.displayName === SplitColumnsContainer.displayName) {
|
|
27
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
28
|
+
last: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return child;
|
|
32
|
+
}
|
|
33
|
+
if (!Array.isArray(children) || children.length === 0) {
|
|
34
|
+
return processChild(children, 0);
|
|
35
|
+
}
|
|
36
|
+
while ((!children[last] || children[last] && children[last].type && children[last].type.displayName === "Errors") && last > 0) {
|
|
37
|
+
last--;
|
|
38
|
+
}
|
|
39
|
+
return React.Children.map(children, processChild);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { SplitColumnsContainer, fixDoubledLastMarginBottom };
|
|
43
|
+
//# sourceMappingURL=SplitColumnsContainer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitColumnsContainer.mjs","sources":["../src/SplitColumnsContainer.jsx"],"sourcesContent":["import React from 'react'\n\nimport {getMargin, media} from '@startlibs/utils'\nimport styled, {css} from 'styled-components'\n\nconst getMarginFromFieldChild = (props) => {\n if (!props.last) return 0;\n const fields = React.Children.toArray(props.children).filter(c => c.type.displayName === \"Field\" || c.type.displayName === \"EnhancedInput\")\n if (!fields.length) return 0\n const lastField = fields.slice(-1)[0]\n return '-' + getMargin(props.theme.Field.margins)(lastField.props)\n}\n\n\nconst splitColumnMargins = {small:0.5,'default':1, big:2}\n\nexport const SplitColumnsContainer = styled.div`\n\n margin-bottom: ${getMarginFromFieldChild}rem;\n \n ${props => css`\n ${media.min(props.viewportMinWidth || 0)`\n display: flex;\n flex-wrap: nowrap;\n margin-left: -${props=>getMargin(splitColumnMargins)(props)/2}rem;\n margin-right: -${props=>getMargin(splitColumnMargins)(props)/2}rem;\n margin-top: -${props=>getMargin(splitColumnMargins)(props)}rem;\n > * {\n flex-basis: 0;\n flex-grow: 1;\n margin-left: ${props=>getMargin(splitColumnMargins)(props)/2}rem;\n margin-right: ${props=>getMargin(splitColumnMargins)(props)/2}rem;\n margin-top: ${props=>getMargin(splitColumnMargins)(props)}rem;\n }\n `}\n `}\n ${props => props.twoColumnsBelowVW && css`\n ${media.max(props.twoColumnsBelowVW)`\n flex-wrap: wrap;\n > * {\n flex-basis: 47%;\n }\n `}\n `}\n`\n\nexport const fixDoubledLastMarginBottom = (children) => {\n let last = React.Children.count(children)-1\n\n function processChild(child, i) {\n if (i === last && child && child.type && child.type.displayName === SplitColumnsContainer.displayName) {\n return React.cloneElement(child, {last: true})\n }\n return child\n }\n if (!Array.isArray(children) || children.length===0) {\n return processChild(children,0)\n }\n while ((!children[last] || (children[last] && children[last].type && children[last].type.displayName === \"Errors\")) && last > 0) {\n last--\n }\n return React.Children.map(children,processChild)\n}\n"],"names":["getMarginFromFieldChild","props","last","fields","React","Children","toArray","children","filter","c","type","displayName","length","lastField","slice","getMargin","theme","Field","margins","splitColumnMargins","small","big","SplitColumnsContainer","styled","div","withConfig","componentId","css","media","min","viewportMinWidth","_templateObject","_taggedTemplateLiteral","twoColumnsBelowVW","max","_templateObject2","fixDoubledLastMarginBottom","count","processChild","child","i","cloneElement","Array","isArray","map"],"mappings":";;;;;;AAKA,MAAMA,uBAAuB,GAAIC,KAAK,IAAK;AACzC,EAAA,IAAI,CAACA,KAAK,CAACC,IAAI,EAAE,OAAO,CAAC,CAAA;AACzB,EAAA,MAAMC,MAAM,GAAGC,KAAK,CAACC,QAAQ,CAACC,OAAO,CAACL,KAAK,CAACM,QAAQ,CAAC,CAACC,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACC,IAAI,CAACC,WAAW,KAAK,OAAO,IAAIF,CAAC,CAACC,IAAI,CAACC,WAAW,KAAK,eAAe,CAAC,CAAA;AAC3I,EAAA,IAAI,CAACR,MAAM,CAACS,MAAM,EAAE,OAAO,CAAC,CAAA;EAC5B,MAAMC,SAAS,GAAGV,MAAM,CAACW,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACrC,EAAA,OAAO,GAAG,GAAGC,SAAS,CAACd,KAAK,CAACe,KAAK,CAACC,KAAK,CAACC,OAAO,CAAC,CAACL,SAAS,CAACZ,KAAK,CAAC,CAAA;AACpE,CAAC,CAAA;AAGD,MAAMkB,kBAAkB,GAAG;AAACC,EAAAA,KAAK,EAAC,GAAG;AAAC,EAAA,SAAS,EAAC,CAAC;AAAEC,EAAAA,GAAG,EAAC,CAAA;AAAC,CAAC,CAAA;MAE5CC,qBAAqB,gBAAGC,MAAM,CAACC,GAAG,CAAAC,UAAA,CAAA;EAAAd,WAAA,EAAA,uBAAA;EAAAe,WAAA,EAAA,cAAA;AAAA,CAE5B1B,CAAAA,CA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A,CAACC,KAAK,EAAEC,CAAC,EAAE;AAC9B,IAAA,IAAIA,CAAC,KAAKtC,IAAI,IAAIqC,KAAK,IAAIA,KAAK,CAAC7B,IAAI,IAAI6B,KAAK,CAAC7B,IAAI,CAACC,WAAW,KAAKW,qBAAqB,CAACX,WAAW,EAAE;AACrG,MAAA,oBAAOP,KAAK,CAACqC,YAAY,CAACF,KAAK,EAAE;AAACrC,QAAAA,IAAI,EAAE,IAAA;AAAI,OAAC,CAAC,CAAA;AAChD,KAAA;AACA,IAAA,OAAOqC,KAAK,CAAA;AACd,GAAA;AACA,EAAA,IAAI,CAACG,KAAK,CAACC,OAAO,CAACpC,QAAQ,CAAC,IAAIA,QAAQ,CAACK,MAAM,KAAG,CAAC,EAAE;AACnD,IAAA,OAAO0B,YAAY,CAAC/B,QAAQ,EAAC,CAAC,CAAC,CAAA;AACjC,GAAA;AACA,EAAA,OAAO,CAAC,CAACA,QAAQ,CAACL,IAAI,CAAC,IAAKK,QAAQ,CAACL,IAAI,CAAC,IAAIK,QAAQ,CAACL,IAAI,CAAC,CAACQ,IAAI,IAAIH,QAAQ,CAACL,IAAI,CAAC,CAACQ,IAAI,CAACC,WAAW,KAAK,QAAS,KAAKT,IAAI,GAAG,CAAC,EAAE;AAC/HA,IAAAA,IAAI,EAAE,CAAA;AACR,GAAA;EACA,OAAOE,KAAK,CAACC,QAAQ,CAACuC,GAAG,CAACrC,QAAQ,EAAC+B,YAAY,CAAC,CAAA;AAClD;;;;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { twoWayAnimation, oneWayAnimation, callIfFunction } from '@startlibs/utils';
|
|
5
|
+
import { willUseFlipSwitch } from './Flip.mjs';
|
|
6
|
+
import { useLazyConstant } from '@startlibs/core';
|
|
7
|
+
|
|
8
|
+
const _excluded = ["children", "className", "enterAnimation", "effect", "leaveAnimation", "skipChromeFix", "on"];
|
|
9
|
+
const BlockContainer = /*#__PURE__*/styled.div.withConfig({
|
|
10
|
+
displayName: "SwitchDiv__BlockContainer",
|
|
11
|
+
componentId: "sc-htfwpl-0"
|
|
12
|
+
})(["position:relative;"]);
|
|
13
|
+
const [fadeIn, relativeFadeout] = twoWayAnimation('opacity: 0;', 'opacity: 0;', 'opacity: 1;');
|
|
14
|
+
const absoluteOnLeave = oneWayAnimation('position: absolute;', 'position: absolute;');
|
|
15
|
+
const fadeOut = [absoluteOnLeave, relativeFadeout];
|
|
16
|
+
const SwitchDiv = /*#__PURE__*/styled(_ref => {
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
enterAnimation = fadeIn,
|
|
21
|
+
effect,
|
|
22
|
+
leaveAnimation = fadeOut,
|
|
23
|
+
skipChromeFix,
|
|
24
|
+
on
|
|
25
|
+
} = _ref;
|
|
26
|
+
_objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
const switchAnimation = useLazyConstant(willUseFlipSwitch);
|
|
28
|
+
return /*#__PURE__*/React.createElement(SwitchContainer, {
|
|
29
|
+
enterAnimation: enterAnimation,
|
|
30
|
+
effect: effect,
|
|
31
|
+
className: className,
|
|
32
|
+
leaveAnimation: leaveAnimation,
|
|
33
|
+
key: on + "",
|
|
34
|
+
switchAnimation: switchAnimation,
|
|
35
|
+
children: children
|
|
36
|
+
});
|
|
37
|
+
}).withConfig({
|
|
38
|
+
displayName: "SwitchDiv",
|
|
39
|
+
componentId: "sc-htfwpl-1"
|
|
40
|
+
})([""]);
|
|
41
|
+
const SwitchContainer = _ref2 => {
|
|
42
|
+
let {
|
|
43
|
+
children,
|
|
44
|
+
switchAnimation,
|
|
45
|
+
className,
|
|
46
|
+
effect,
|
|
47
|
+
enterAnimation,
|
|
48
|
+
leaveAnimation
|
|
49
|
+
} = _ref2;
|
|
50
|
+
const contentRef = useRef();
|
|
51
|
+
switchAnimation(contentRef, enterAnimation, leaveAnimation, {
|
|
52
|
+
effect
|
|
53
|
+
});
|
|
54
|
+
return /*#__PURE__*/React.createElement(BlockContainer, {
|
|
55
|
+
ref: contentRef,
|
|
56
|
+
className: className
|
|
57
|
+
}, callIfFunction(children));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { SwitchDiv };
|
|
61
|
+
//# sourceMappingURL=SwitchDiv.mjs.map
|