@activecollab/components 2.0.443 → 2.0.445
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/dist/cjs/components/Menu/Menu.js +43 -5
- package/dist/cjs/components/Menu/Menu.js.map +1 -1
- package/dist/cjs/components/Sheet/Sheet.js +29 -40
- package/dist/cjs/components/Sheet/Sheet.js.map +1 -1
- package/dist/cjs/components/Sheet/Styles.js +20 -25
- package/dist/cjs/components/Sheet/Styles.js.map +1 -1
- package/dist/esm/components/Menu/Menu.d.ts.map +1 -1
- package/dist/esm/components/Menu/Menu.js +41 -5
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/esm/components/Sheet/Sheet.js +27 -36
- package/dist/esm/components/Sheet/Sheet.js.map +1 -1
- package/dist/esm/components/Sheet/Styles.d.ts +3 -10
- package/dist/esm/components/Sheet/Styles.d.ts.map +1 -1
- package/dist/esm/components/Sheet/Styles.js +17 -14
- package/dist/esm/components/Sheet/Styles.js.map +1 -1
- package/dist/index.js +90 -68
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -46,6 +46,16 @@ export const Menu = _ref => {
|
|
|
46
46
|
setChildNode = _useState3[1];
|
|
47
47
|
const elementRef = useRef(null);
|
|
48
48
|
const isOpenAtLeastOnce = useRef(false);
|
|
49
|
+
const wasOpen = useRef(open);
|
|
50
|
+
const focusBeforeOpen = useRef(null);
|
|
51
|
+
const returnFocusTo = useRef(null);
|
|
52
|
+
const popperRef = useRef(null);
|
|
53
|
+
|
|
54
|
+
// Read on the render that opens the menu, before the focus lock moves the focus inside it.
|
|
55
|
+
if (open && !wasOpen.current && typeof document !== "undefined") {
|
|
56
|
+
focusBeforeOpen.current = document.activeElement;
|
|
57
|
+
}
|
|
58
|
+
wasOpen.current = open;
|
|
49
59
|
useEffect(() => {
|
|
50
60
|
setOpen(defaultOpen);
|
|
51
61
|
}, [defaultOpen]);
|
|
@@ -83,17 +93,39 @@ export const Menu = _ref => {
|
|
|
83
93
|
if (open) {
|
|
84
94
|
isOpenAtLeastOnce.current = true;
|
|
85
95
|
} else if (!open && isOpenAtLeastOnce.current) {
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
const previous = focusBeforeOpen.current;
|
|
97
|
+
const returnTo = previous instanceof HTMLElement && previous.isConnected ? previous : elementRef.current;
|
|
98
|
+
returnFocusTo.current = returnTo;
|
|
99
|
+
returnTo == null || returnTo.focus();
|
|
88
100
|
isOpenAtLeastOnce.current = false;
|
|
89
101
|
}
|
|
90
102
|
}, [open]);
|
|
103
|
+
|
|
104
|
+
// A fading menu is already closed. Its content can still reach for the focus, and would take it away
|
|
105
|
+
// with it when it unmounts, so the focus goes straight back to where the menu returned it.
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (open || exited) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const keepFocusOut = event => {
|
|
111
|
+
var _popperRef$current;
|
|
112
|
+
if ((_popperRef$current = popperRef.current) != null && _popperRef$current.contains(event.target)) {
|
|
113
|
+
var _returnFocusTo$curren;
|
|
114
|
+
(_returnFocusTo$curren = returnFocusTo.current) == null || _returnFocusTo$curren.focus();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
document.addEventListener("focusin", keepFocusOut, true);
|
|
118
|
+
return () => document.removeEventListener("focusin", keepFocusOut, true);
|
|
119
|
+
}, [open, exited]);
|
|
91
120
|
return /*#__PURE__*/React.createElement(React.Fragment, null, target && /*#__PURE__*/React.cloneElement(target, targetProps), open || !exited ? /*#__PURE__*/React.createElement(Window, {
|
|
92
121
|
onClose: handleClose,
|
|
93
122
|
disableScrollLock: !handleScroll
|
|
94
|
-
//
|
|
123
|
+
// The menu returns the focus itself at once, so a late returnFocus cannot undo a caller's move.
|
|
124
|
+
,
|
|
125
|
+
disableFocusLock: disableFocusLock || !open
|
|
126
|
+
// A fading menu is already closed, so an escape pressed meanwhile belongs to the page behind it.
|
|
95
127
|
,
|
|
96
|
-
|
|
128
|
+
disableCloseOnEsc: !open,
|
|
97
129
|
style: {
|
|
98
130
|
position: windowAbsolutelyPositioned ? "absolute" : "fixed"
|
|
99
131
|
}
|
|
@@ -103,6 +135,7 @@ export const Menu = _ref => {
|
|
|
103
135
|
tabIndex: -1,
|
|
104
136
|
disableBackgroundColor: true
|
|
105
137
|
}) : null, /*#__PURE__*/React.createElement(Popper, {
|
|
138
|
+
ref: popperRef,
|
|
106
139
|
anchorEl: childNode,
|
|
107
140
|
open: childNode ? open : false,
|
|
108
141
|
placement: position,
|
|
@@ -124,7 +157,10 @@ export const Menu = _ref => {
|
|
|
124
157
|
}, /*#__PURE__*/React.createElement(StyledMenu, {
|
|
125
158
|
className: classnames("c-simple-menu__paper", "c-simple-menu__" + mode, menuClassName, className),
|
|
126
159
|
$mode: mode,
|
|
127
|
-
onMouseDown: onMenuClick
|
|
160
|
+
onMouseDown: onMenuClick,
|
|
161
|
+
style: open ? undefined : {
|
|
162
|
+
pointerEvents: "none"
|
|
163
|
+
}
|
|
128
164
|
}, /*#__PURE__*/React.createElement(MenuContextProvider, {
|
|
129
165
|
value: {
|
|
130
166
|
open,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","names":["React","useRef","useState","useCallback","useEffect","classnames","MenuContextProvider","StyledMenu","useForkRef","Overlay","Popper","Grow","Window","Menu","_ref","children","_ref$disableFocusLock","disableFocusLock","onMenuClick","_ref$handleScroll","handleScroll","_ref$mode","mode","_ref$open","open","defaultOpen","onOpen","onClose","onBeforeClose","_ref$position","position","target","className","menuClassName","popperClassName","backgroundElementClass","_ref$windowAbsolutely","windowAbsolutelyPositioned","onPopperOpen","_useState","setOpen","_useState2","exited","setExited","_useState3","childNode","setChildNode","elementRef","isOpenAtLeastOnce","handleRefRef","ref","undefined","handleRef","handleOpen","event","_target$props","preventDefault","stopPropagation","props","onClick","handleClose","childProps","forceClose","targetProps","current","_elementRef$current","focus","createElement","Fragment","cloneElement","disableScrollLock","style","tabIndex","disableBackgroundColor","anchorEl","placement","afterWrite","transition","_ref2","transitionProps","in","onEnter","onExited","$mode","onMouseDown","value","displayName"],"sources":["../../../../src/components/Menu/Menu.tsx"],"sourcesContent":["import React, {\n useRef,\n FC,\n ReactNode,\n MouseEvent,\n useState,\n useCallback,\n useEffect,\n ReactElement,\n Ref,\n} from \"react\";\n\nimport { Placement } from \"@popperjs/core\";\nimport classnames from \"classnames\";\n\nimport { MenuContextProvider } from \"./context\";\nimport { StyledMenu } from \"./Styles\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { Overlay } from \"../Overlay\";\nimport { Popper } from \"../Popper\";\nimport { Grow } from \"../Transitions\";\nimport { Window } from \"../Window\";\n\ninterface ElementWithRef<T> extends ReactElement {\n ref?: Ref<T>;\n}\n\n// source: https://twitter.com/mattpocockuk/status/1671908303918473217/photo/1\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type MenuMode = \"normal\" | \"wider\" | \"tiny\" | \"widest\";\n\nexport interface IMenu {\n /** Menu content */\n children:\n | ReactNode\n | ((childProps: { forceClose: () => void }) => JSX.Element);\n /** On menu element click */\n onMenuClick?: (event: MouseEvent<HTMLElement>) => void;\n /** Handle scroll bar */\n handleScroll?: boolean;\n /** Disable Focus Lock */\n disableFocusLock?: boolean;\n /** Menu width mode */\n mode?: MenuMode;\n /** Should menu be open when it's mounted */\n open?: boolean;\n /** Callback triggered when modal has been opened */\n onOpen?: () => void;\n /** Callback triggered when modal has been closed */\n onClose?: () => void;\n /** Before close callback */\n onBeforeClose?: () => boolean;\n /** Position Menu */\n position?: Placement;\n /** Target element */\n target?: ElementWithRef<Element>;\n className?: string;\n /** Menu classes */\n menuClassName?: string;\n /** Popper class name*/\n popperClassName?: string;\n /** Background style for clickable element after the menu is open (opacity, color, etc...) */\n backgroundElementClass?: string;\n /** Should Window be positioned absolutely */\n windowAbsolutelyPositioned?: boolean;\n /** Popper on open */\n onPopperOpen?: (...args) => void;\n}\n\nexport const Menu: FC<IMenu> = ({\n children,\n disableFocusLock = false,\n onMenuClick,\n handleScroll = true,\n mode = \"normal\",\n open: defaultOpen = false,\n onOpen,\n onClose,\n onBeforeClose,\n position = \"bottom-start\",\n target,\n className,\n menuClassName,\n popperClassName,\n backgroundElementClass,\n windowAbsolutelyPositioned = false,\n onPopperOpen,\n}) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(!defaultOpen);\n const [childNode, setChildNode] = useState<Element | null>();\n const elementRef = useRef<HTMLElement | null>(null);\n const isOpenAtLeastOnce = useRef(false);\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n useEffect(() => {\n if (open) {\n setExited(false);\n }\n }, [open]);\n\n const handleRefRef = useForkRef(\n target ? target.ref : undefined,\n setChildNode\n );\n const handleRef = useForkRef(handleRefRef, elementRef);\n\n const handleOpen = useCallback(\n (\n event: Pick<MouseEvent<Element>, \"preventDefault\" | \"stopPropagation\">\n ) => {\n event?.preventDefault();\n event?.stopPropagation();\n setOpen(true);\n typeof onOpen === \"function\" && onOpen();\n typeof target?.props?.onClick === \"function\" &&\n target.props.onClick(event);\n },\n [onOpen, target?.props]\n );\n\n const handleClose = useCallback(() => {\n if (typeof onBeforeClose === \"function\" && !onBeforeClose()) {\n return;\n }\n setOpen(false);\n typeof onClose === \"function\" && onClose();\n }, [onClose, onBeforeClose]);\n\n const childProps = {\n forceClose: handleClose,\n };\n\n const targetProps = {\n open,\n ref: handleRef,\n onClick: handleOpen,\n };\n\n useEffect(() => {\n if (open) {\n isOpenAtLeastOnce.current = true;\n } else if (!open && isOpenAtLeastOnce.current) {\n elementRef.current?.focus();\n isOpenAtLeastOnce.current = false;\n }\n }, [open]);\n\n return (\n <>\n {target && React.cloneElement(target, targetProps)}\n {open || !exited ? (\n <Window\n onClose={handleClose}\n disableScrollLock={!handleScroll}\n // A closing menu hands the focus back at once, it does not hold it for the length of the fade.\n disableFocusLock={disableFocusLock || !open}\n style={{\n position: windowAbsolutelyPositioned ? \"absolute\" : \"fixed\",\n }}\n >\n {/* A closing menu must not swallow the click that lands while it fades out. */}\n {open ? (\n <Overlay\n className={backgroundElementClass}\n onClick={handleClose}\n tabIndex={-1}\n disableBackgroundColor\n />\n ) : null}\n <Popper\n anchorEl={childNode}\n open={childNode ? open : false}\n placement={position}\n className={popperClassName}\n tabIndex={-1}\n afterWrite={onPopperOpen}\n transition\n >\n {({ placement, transitionProps }) => (\n <Grow\n placement={placement}\n in={transitionProps?.in}\n onEnter={transitionProps?.onEnter}\n onExited={() => {\n setExited(true);\n transitionProps?.onExited?.();\n }}\n >\n <StyledMenu\n className={classnames(\n \"c-simple-menu__paper\",\n `c-simple-menu__${mode}`,\n menuClassName,\n className\n )}\n $mode={mode}\n onMouseDown={onMenuClick}\n >\n <MenuContextProvider value={{ open, setOpen }}>\n {typeof children === \"function\"\n ? children(childProps)\n : children}\n </MenuContextProvider>\n </StyledMenu>\n </Grow>\n )}\n </Popper>\n </Window>\n ) : null}\n </>\n );\n};\n\nMenu.displayName = \"Menu\";\n"],"mappings":"AAAA,OAAOA,KAAK,IACVC,MAAM,EAINC,QAAQ,EACRC,WAAW,EACXC,SAAS,QAGJ,OAAO;AAGd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,SAASC,UAAU,QAAQ,UAAU;AACrC,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,MAAM,QAAQ,WAAW;;AAMlC;AACA;;AAyCA,OAAO,MAAMC,IAAe,GAAGC,IAAA,IAkBzB;EAAA,IAjBJC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAAC,qBAAA,GAAAF,IAAA,CACRG,gBAAgB;IAAhBA,gB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useCallback","useEffect","classnames","MenuContextProvider","StyledMenu","useForkRef","Overlay","Popper","Grow","Window","Menu","_ref","children","_ref$disableFocusLock","disableFocusLock","onMenuClick","_ref$handleScroll","handleScroll","_ref$mode","mode","_ref$open","open","defaultOpen","onOpen","onClose","onBeforeClose","_ref$position","position","target","className","menuClassName","popperClassName","backgroundElementClass","_ref$windowAbsolutely","windowAbsolutelyPositioned","onPopperOpen","_useState","setOpen","_useState2","exited","setExited","_useState3","childNode","setChildNode","elementRef","isOpenAtLeastOnce","wasOpen","focusBeforeOpen","returnFocusTo","popperRef","current","document","activeElement","handleRefRef","ref","undefined","handleRef","handleOpen","event","_target$props","preventDefault","stopPropagation","props","onClick","handleClose","childProps","forceClose","targetProps","previous","returnTo","HTMLElement","isConnected","focus","keepFocusOut","_popperRef$current","contains","_returnFocusTo$curren","addEventListener","removeEventListener","createElement","Fragment","cloneElement","disableScrollLock","disableCloseOnEsc","style","tabIndex","disableBackgroundColor","anchorEl","placement","afterWrite","transition","_ref2","transitionProps","in","onEnter","onExited","$mode","onMouseDown","pointerEvents","value","displayName"],"sources":["../../../../src/components/Menu/Menu.tsx"],"sourcesContent":["import React, {\n useRef,\n FC,\n ReactNode,\n MouseEvent,\n useState,\n useCallback,\n useEffect,\n ReactElement,\n Ref,\n} from \"react\";\n\nimport { Placement } from \"@popperjs/core\";\nimport classnames from \"classnames\";\n\nimport { MenuContextProvider } from \"./context\";\nimport { StyledMenu } from \"./Styles\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { Overlay } from \"../Overlay\";\nimport { Popper } from \"../Popper\";\nimport { Grow } from \"../Transitions\";\nimport { Window } from \"../Window\";\n\ninterface ElementWithRef<T> extends ReactElement {\n ref?: Ref<T>;\n}\n\n// source: https://twitter.com/mattpocockuk/status/1671908303918473217/photo/1\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type MenuMode = \"normal\" | \"wider\" | \"tiny\" | \"widest\";\n\nexport interface IMenu {\n /** Menu content */\n children:\n | ReactNode\n | ((childProps: { forceClose: () => void }) => JSX.Element);\n /** On menu element click */\n onMenuClick?: (event: MouseEvent<HTMLElement>) => void;\n /** Handle scroll bar */\n handleScroll?: boolean;\n /** Disable Focus Lock */\n disableFocusLock?: boolean;\n /** Menu width mode */\n mode?: MenuMode;\n /** Should menu be open when it's mounted */\n open?: boolean;\n /** Callback triggered when modal has been opened */\n onOpen?: () => void;\n /** Callback triggered when modal has been closed */\n onClose?: () => void;\n /** Before close callback */\n onBeforeClose?: () => boolean;\n /** Position Menu */\n position?: Placement;\n /** Target element */\n target?: ElementWithRef<Element>;\n className?: string;\n /** Menu classes */\n menuClassName?: string;\n /** Popper class name*/\n popperClassName?: string;\n /** Background style for clickable element after the menu is open (opacity, color, etc...) */\n backgroundElementClass?: string;\n /** Should Window be positioned absolutely */\n windowAbsolutelyPositioned?: boolean;\n /** Popper on open */\n onPopperOpen?: (...args) => void;\n}\n\nexport const Menu: FC<IMenu> = ({\n children,\n disableFocusLock = false,\n onMenuClick,\n handleScroll = true,\n mode = \"normal\",\n open: defaultOpen = false,\n onOpen,\n onClose,\n onBeforeClose,\n position = \"bottom-start\",\n target,\n className,\n menuClassName,\n popperClassName,\n backgroundElementClass,\n windowAbsolutelyPositioned = false,\n onPopperOpen,\n}) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(!defaultOpen);\n const [childNode, setChildNode] = useState<Element | null>();\n const elementRef = useRef<HTMLElement | null>(null);\n const isOpenAtLeastOnce = useRef(false);\n const wasOpen = useRef(open);\n const focusBeforeOpen = useRef<Element | null>(null);\n const returnFocusTo = useRef<HTMLElement | null>(null);\n const popperRef = useRef<HTMLDivElement | null>(null);\n\n // Read on the render that opens the menu, before the focus lock moves the focus inside it.\n if (open && !wasOpen.current && typeof document !== \"undefined\") {\n focusBeforeOpen.current = document.activeElement;\n }\n wasOpen.current = open;\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n useEffect(() => {\n if (open) {\n setExited(false);\n }\n }, [open]);\n\n const handleRefRef = useForkRef(\n target ? target.ref : undefined,\n setChildNode\n );\n const handleRef = useForkRef(handleRefRef, elementRef);\n\n const handleOpen = useCallback(\n (\n event: Pick<MouseEvent<Element>, \"preventDefault\" | \"stopPropagation\">\n ) => {\n event?.preventDefault();\n event?.stopPropagation();\n setOpen(true);\n typeof onOpen === \"function\" && onOpen();\n typeof target?.props?.onClick === \"function\" &&\n target.props.onClick(event);\n },\n [onOpen, target?.props]\n );\n\n const handleClose = useCallback(() => {\n if (typeof onBeforeClose === \"function\" && !onBeforeClose()) {\n return;\n }\n setOpen(false);\n typeof onClose === \"function\" && onClose();\n }, [onClose, onBeforeClose]);\n\n const childProps = {\n forceClose: handleClose,\n };\n\n const targetProps = {\n open,\n ref: handleRef,\n onClick: handleOpen,\n };\n\n useEffect(() => {\n if (open) {\n isOpenAtLeastOnce.current = true;\n } else if (!open && isOpenAtLeastOnce.current) {\n const previous = focusBeforeOpen.current;\n const returnTo =\n previous instanceof HTMLElement && previous.isConnected\n ? previous\n : elementRef.current;\n\n returnFocusTo.current = returnTo;\n returnTo?.focus();\n isOpenAtLeastOnce.current = false;\n }\n }, [open]);\n\n // A fading menu is already closed. Its content can still reach for the focus, and would take it away\n // with it when it unmounts, so the focus goes straight back to where the menu returned it.\n useEffect(() => {\n if (open || exited) {\n return undefined;\n }\n\n const keepFocusOut = (event: FocusEvent) => {\n if (popperRef.current?.contains(event.target as Node)) {\n returnFocusTo.current?.focus();\n }\n };\n\n document.addEventListener(\"focusin\", keepFocusOut, true);\n\n return () => document.removeEventListener(\"focusin\", keepFocusOut, true);\n }, [open, exited]);\n\n return (\n <>\n {target && React.cloneElement(target, targetProps)}\n {open || !exited ? (\n <Window\n onClose={handleClose}\n disableScrollLock={!handleScroll}\n // The menu returns the focus itself at once, so a late returnFocus cannot undo a caller's move.\n disableFocusLock={disableFocusLock || !open}\n // A fading menu is already closed, so an escape pressed meanwhile belongs to the page behind it.\n disableCloseOnEsc={!open}\n style={{\n position: windowAbsolutelyPositioned ? \"absolute\" : \"fixed\",\n }}\n >\n {/* A closing menu must not swallow the click that lands while it fades out. */}\n {open ? (\n <Overlay\n className={backgroundElementClass}\n onClick={handleClose}\n tabIndex={-1}\n disableBackgroundColor\n />\n ) : null}\n <Popper\n ref={popperRef}\n anchorEl={childNode}\n open={childNode ? open : false}\n placement={position}\n className={popperClassName}\n tabIndex={-1}\n afterWrite={onPopperOpen}\n transition\n >\n {({ placement, transitionProps }) => (\n <Grow\n placement={placement}\n in={transitionProps?.in}\n onEnter={transitionProps?.onEnter}\n onExited={() => {\n setExited(true);\n transitionProps?.onExited?.();\n }}\n >\n <StyledMenu\n className={classnames(\n \"c-simple-menu__paper\",\n `c-simple-menu__${mode}`,\n menuClassName,\n className\n )}\n $mode={mode}\n onMouseDown={onMenuClick}\n style={open ? undefined : { pointerEvents: \"none\" }}\n >\n <MenuContextProvider value={{ open, setOpen }}>\n {typeof children === \"function\"\n ? children(childProps)\n : children}\n </MenuContextProvider>\n </StyledMenu>\n </Grow>\n )}\n </Popper>\n </Window>\n ) : null}\n </>\n );\n};\n\nMenu.displayName = \"Menu\";\n"],"mappings":"AAAA,OAAOA,KAAK,IACVC,MAAM,EAINC,QAAQ,EACRC,WAAW,EACXC,SAAS,QAGJ,OAAO;AAGd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,SAASC,UAAU,QAAQ,UAAU;AACrC,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,MAAM,QAAQ,WAAW;;AAMlC;AACA;;AAyCA,OAAO,MAAMC,IAAe,GAAGC,IAAA,IAkBzB;EAAA,IAjBJC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAAC,qBAAA,GAAAF,IAAA,CACRG,gBAAgB;IAAhBA,gBAAg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AEP,CAAC;AAEDF,IAAI,CAAC0F,WAAW,GAAG,MAAM","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../../../../src/components/Sheet/Sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,aAAa,EAGd,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../../../../src/components/Sheet/Sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,aAAa,EAGd,MAAM,OAAO,CAAC;AAuBf,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAChD,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACvC,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID,eAAO,MAAM,KAAK,oHAiKjB,CAAC"}
|
|
@@ -2,12 +2,12 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["children", "onClose", "controls", "open", "animation", "position", "mode", "disableFocusLock", "disableScrollLock", "disableBackgroundColor", "bodyStyle", "bodyClassName", "disableBackgroundClick"];
|
|
4
4
|
import React, { useCallback, useEffect, forwardRef, useState, useImperativeHandle } from "react";
|
|
5
|
-
import { Transition } from "react-transition-group";
|
|
6
5
|
import classnames from "classnames";
|
|
7
|
-
import { StyledAnimatedSpan, StyledCssTransition, StyledHeader, StyledIconsWrapperSmall, StyledListSeparator, StyledSheetIcons, StyledSheetWrapper, StyledSheetWrapperPaper } from "./Styles";
|
|
6
|
+
import { StyledAnimatedSpan, StyledCssTransition, StyledHeader, StyledIconsWrapperSmall, StyledListSeparator, StyledSheetIcons, StyledSheetWrapper, SHEET_ENTER_MS, SHEET_EXIT_MS, StyledSheetSurface, StyledSheetWrapperPaper } from "./Styles";
|
|
8
7
|
import { IconButton } from "../IconButton";
|
|
9
8
|
import { Overlay } from "../Overlay";
|
|
10
9
|
import { Tooltip } from "../Tooltip";
|
|
10
|
+
import { Fade } from "../Transitions";
|
|
11
11
|
import { Window } from "../Window";
|
|
12
12
|
export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
13
13
|
let children = _ref.children,
|
|
@@ -68,53 +68,44 @@ export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
68
68
|
onClose: handleClose,
|
|
69
69
|
disableFocusLock: disableFocusLock,
|
|
70
70
|
disableScrollLock: disableScrollLock
|
|
71
|
-
}),
|
|
71
|
+
}), /*#__PURE__*/React.createElement(Fade, {
|
|
72
|
+
in: open,
|
|
73
|
+
timeout: open ? SHEET_ENTER_MS : SHEET_EXIT_MS
|
|
74
|
+
}, /*#__PURE__*/React.createElement(Overlay, {
|
|
72
75
|
onClick: handleBackgroundClick,
|
|
73
|
-
disableBackgroundColor: disableBackgroundColor
|
|
74
|
-
|
|
76
|
+
disableBackgroundColor: disableBackgroundColor,
|
|
77
|
+
style: {
|
|
78
|
+
pointerEvents: open ? undefined : "none"
|
|
79
|
+
}
|
|
80
|
+
})), /*#__PURE__*/React.createElement(StyledSheetWrapper, {
|
|
75
81
|
className: classnames("c-sheet__wrapper", bodyClassName),
|
|
76
82
|
style: bodyStyle,
|
|
77
83
|
$position: position,
|
|
78
84
|
$mode: mode
|
|
79
|
-
},
|
|
85
|
+
}, /*#__PURE__*/React.createElement(StyledCssTransition, {
|
|
86
|
+
appear: true,
|
|
87
|
+
in: open,
|
|
88
|
+
timeout: SHEET_ENTER_MS,
|
|
89
|
+
classNames: "c-sheet__animation",
|
|
90
|
+
$direction: animation,
|
|
91
|
+
onEnter: handleEnter,
|
|
92
|
+
onExited: handleExited
|
|
93
|
+
}, /*#__PURE__*/React.createElement(StyledSheetSurface, null, controls.length > 0 && /*#__PURE__*/React.createElement(StyledSheetIcons, null, controls.map((_ref2, index) => {
|
|
80
94
|
let IconComponent = _ref2.icon,
|
|
81
95
|
tooltip = _ref2.tooltip,
|
|
82
96
|
onClick = _ref2.onClick,
|
|
83
97
|
disabled = _ref2.disabled,
|
|
84
98
|
className = _ref2.className;
|
|
85
|
-
|
|
86
|
-
const maxDurationOut = 2;
|
|
87
|
-
const control = index + 1;
|
|
88
|
-
const durationOut = Math.max(0, maxDurationOut - control);
|
|
89
|
-
const durationIn = Math.min(control, maxDurationIn);
|
|
90
|
-
return /*#__PURE__*/React.createElement(Transition, {
|
|
91
|
-
appear: true,
|
|
92
|
-
in: open,
|
|
93
|
-
timeout: maxDurationIn * 100,
|
|
94
|
-
key: "c-sheet-control-" + index
|
|
95
|
-
}, state => /*#__PURE__*/React.createElement(Tooltip, {
|
|
99
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
96
100
|
title: tooltip,
|
|
97
|
-
disable: !tooltip || disabled
|
|
101
|
+
disable: !tooltip || disabled,
|
|
102
|
+
key: "c-sheet-control-" + index
|
|
98
103
|
}, /*#__PURE__*/React.createElement(StyledAnimatedSpan, {
|
|
99
104
|
onClick: onClick,
|
|
100
105
|
$disabled: disabled,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
$maxDurationIn: maxDurationIn / 10,
|
|
105
|
-
$maxDurationOut: maxDurationOut / 10,
|
|
106
|
-
$durationOut: durationOut / 10,
|
|
107
|
-
$durationIn: durationIn / 10
|
|
108
|
-
}, IconComponent)));
|
|
109
|
-
})), /*#__PURE__*/React.createElement(StyledCssTransition, {
|
|
110
|
-
appear: true,
|
|
111
|
-
in: open,
|
|
112
|
-
timeout: 400,
|
|
113
|
-
classNames: "c-sheet__animation",
|
|
114
|
-
$direction: animation,
|
|
115
|
-
onEnter: handleEnter,
|
|
116
|
-
onExited: handleExited
|
|
117
|
-
}, /*#__PURE__*/React.createElement(StyledSheetWrapperPaper, {
|
|
106
|
+
className: className
|
|
107
|
+
}, IconComponent));
|
|
108
|
+
})), /*#__PURE__*/React.createElement(StyledSheetWrapperPaper, {
|
|
118
109
|
paperClass: "c-sheet__wrapper__paper"
|
|
119
110
|
}, controls.length > 0 && /*#__PURE__*/React.createElement(StyledHeader, null, /*#__PURE__*/React.createElement(StyledIconsWrapperSmall, null, controls.map((_ref3, index) => {
|
|
120
111
|
let IconComponent = _ref3.icon,
|
|
@@ -132,7 +123,7 @@ export const Sheet = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
132
123
|
className: className,
|
|
133
124
|
variant: "text gray"
|
|
134
125
|
}, IconComponent));
|
|
135
|
-
})), /*#__PURE__*/React.createElement(StyledListSeparator, null)), children))));
|
|
126
|
+
})), /*#__PURE__*/React.createElement(StyledListSeparator, null)), children)))));
|
|
136
127
|
});
|
|
137
128
|
Sheet.displayName = "Sheet";
|
|
138
129
|
//# sourceMappingURL=Sheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.js","names":["React","useCallback","useEffect","forwardRef","useState","useImperativeHandle","Transition","classnames","StyledAnimatedSpan","StyledCssTransition","StyledHeader","StyledIconsWrapperSmall","StyledListSeparator","StyledSheetIcons","StyledSheetWrapper","StyledSheetWrapperPaper","IconButton","Overlay","Tooltip","Window","Sheet","_ref","ref","children","onClose","_ref$controls","controls","_ref$open","open","defaultOpen","_ref$animation","animation","_ref$position","position","_ref$mode","mode","_ref$disableFocusLock","disableFocusLock","_ref$disableScrollLoc","disableScrollLock","_ref$disableBackgroun","disableBackgroundColor","bodyStyle","bodyClassName","_ref$disableBackgroun2","disableBackgroundClick","rest","_objectWithoutPropertiesLoose","_excluded","_useState","setOpen","_useState2","exited","setExited","handleEnter","handleExited","handleClose","handleBackgroundClick","event","preventDefault","close","createElement","_extends","onClick","className","style","$position","$mode","length","map","_ref2","index","IconComponent","icon","tooltip","disabled","maxDurationIn","maxDurationOut","control","durationOut","Math","max","durationIn","min","appear","in","timeout","key","state","title","disable","$disabled","$state","$maxDurationIn","$maxDurationOut","$durationOut","$durationIn","classNames","$direction","onEnter","onExited","paperClass","_ref3","variant","displayName"],"sources":["../../../../src/components/Sheet/Sheet.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n forwardRef,\n HTMLAttributes,\n useState,\n CSSProperties,\n MouseEvent,\n useImperativeHandle,\n} from \"react\";\nimport { Transition } from \"react-transition-group\";\n\nimport classnames from \"classnames\";\n\nimport {\n StyledAnimatedSpan,\n StyledCssTransition,\n StyledHeader,\n StyledIconsWrapperSmall,\n StyledListSeparator,\n StyledSheetIcons,\n StyledSheetWrapper,\n StyledSheetWrapperPaper,\n} from \"./Styles\";\nimport { IconButton } from \"../IconButton\";\nimport { Overlay } from \"../Overlay\";\nimport { Tooltip } from \"../Tooltip\";\nimport { Window } from \"../Window\";\n\ninterface ControlProps {\n onClick: () => void;\n icon: React.ReactElement;\n tooltip: string;\n disabled: boolean;\n className: string;\n}\n\ninterface ISheet {\n onClose?: () => void;\n controls?: ControlProps[];\n open?: boolean;\n animation?: \"top\" | \"bottom\" | \"left\" | \"right\";\n position?: \"center\" | \"left\" | \"right\";\n mode?: \"normal\" | \"stretch\";\n disableFocusLock?: boolean;\n disableScrollLock?: boolean;\n disableBackgroundColor?: boolean;\n bodyStyle?: CSSProperties;\n bodyClassName?: string;\n disableBackgroundClick?: boolean;\n}\n\nexport interface SheetMethods {\n close: () => void;\n}\n\ntype SheetProps = ISheet & HTMLAttributes<HTMLDivElement>;\n\nexport const Sheet = forwardRef<SheetMethods, SheetProps>(\n (\n {\n children,\n onClose,\n controls = [],\n open: defaultOpen = false,\n animation = \"top\",\n position = \"center\",\n mode = \"normal\",\n disableFocusLock = false,\n disableScrollLock = false,\n disableBackgroundColor = false,\n bodyStyle,\n bodyClassName,\n disableBackgroundClick = false,\n ...rest\n },\n ref\n ) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(true);\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n const handleEnter = useCallback(() => {\n setExited(false);\n }, []);\n\n const handleExited = useCallback(() => {\n setExited(true);\n onClose?.();\n }, [onClose]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n }, []);\n\n const handleBackgroundClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (!disableBackgroundClick) {\n event.preventDefault();\n handleClose();\n }\n },\n [disableBackgroundClick, handleClose]\n );\n\n useImperativeHandle(ref, () => ({\n close: handleClose,\n }));\n\n if (!open && exited) {\n return null;\n }\n\n return (\n <Window\n {...rest}\n onClose={handleClose}\n disableFocusLock={disableFocusLock}\n disableScrollLock={disableScrollLock}\n >\n {open && (\n <Overlay\n onClick={handleBackgroundClick}\n disableBackgroundColor={disableBackgroundColor}\n />\n )}\n <StyledSheetWrapper\n className={classnames(\"c-sheet__wrapper\", bodyClassName)}\n style={bodyStyle}\n $position={position}\n $mode={mode}\n >\n {controls.length > 0 && (\n <StyledSheetIcons>\n {controls.map(\n (\n {\n icon: IconComponent,\n tooltip,\n onClick,\n disabled,\n className,\n },\n index\n ) => {\n const maxDurationIn = 4;\n const maxDurationOut = 2;\n const control = index + 1;\n const durationOut = Math.max(0, maxDurationOut - control);\n const durationIn = Math.min(control, maxDurationIn);\n\n return (\n <Transition\n appear\n in={open}\n timeout={maxDurationIn * 100}\n key={`c-sheet-control-${index}`}\n >\n {(state) => (\n <Tooltip title={tooltip} disable={!tooltip || disabled}>\n <StyledAnimatedSpan\n onClick={onClick}\n $disabled={disabled}\n $mode={mode}\n $state={state}\n className={className}\n $maxDurationIn={maxDurationIn / 10}\n $maxDurationOut={maxDurationOut / 10}\n $durationOut={durationOut / 10}\n $durationIn={durationIn / 10}\n >\n {IconComponent}\n </StyledAnimatedSpan>\n </Tooltip>\n )}\n </Transition>\n );\n }\n )}\n </StyledSheetIcons>\n )}\n <StyledCssTransition\n appear\n in={open}\n timeout={400}\n classNames=\"c-sheet__animation\"\n $direction={animation}\n onEnter={handleEnter}\n onExited={handleExited}\n >\n <StyledSheetWrapperPaper paperClass=\"c-sheet__wrapper__paper\">\n {controls.length > 0 && (\n <StyledHeader>\n <StyledIconsWrapperSmall>\n {controls.map(\n (\n {\n icon: IconComponent,\n tooltip,\n onClick,\n disabled,\n className,\n },\n index\n ) => (\n <Tooltip\n title={tooltip}\n disable={!tooltip || disabled}\n key={index}\n >\n <IconButton\n onClick={onClick}\n disabled={disabled}\n className={className}\n variant=\"text gray\"\n >\n {IconComponent}\n </IconButton>\n </Tooltip>\n )\n )}\n </StyledIconsWrapperSmall>\n <StyledListSeparator />\n </StyledHeader>\n )}\n {children}\n </StyledSheetWrapperPaper>\n </StyledCssTransition>\n </StyledSheetWrapper>\n </Window>\n );\n }\n);\n\nSheet.displayName = \"Sheet\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,UAAU,EAEVC,QAAQ,EAGRC,mBAAmB,QACd,OAAO;AACd,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I;MACJC,OAAO,GAAA4B,KAAA,CAAP5B,OAAO;MACPX,OAAO,GAAAuC,KAAA,CAAPvC,OAAO;MACPY,QAAQ,GAAA2B,KAAA,CAAR3B,QAAQ;MACRX,SAAS,GAAAsC,KAAA,CAATtC,SAAS;IAAA,oBAIXhE,KAAA,CAAA6D,aAAA,CAAC3C,OAAO;MACNuE,KAAK,EAAEf,OAAQ;MACfgB,OAAO,EAAE,CAAChB,OAAO,IAAIC,QAAS;MAC9BY,GAAG,EAAEhB;IAAM,gBAEXvE,KAAA,CAAA6D,aAAA,CAAC7C,UAAU;MACT+C,OAAO,EAAEA,OAAQ;MACjBY,QAAQ,EAAEA,QAAS;MACnBX,SAAS,EAAEA,SAAU;MACrBuC,OAAO,EAAC;IAAW,GAElB/B,aACS,CACL,CAAC;EAAA,CAEd,CACuB,CAAC,eAC1BxE,KAAA,CAAA6D,aAAA,CAACjD,mBAAmB,MAAE,CACV,CACf,EACAW,QACsB,CACN,CACH,CACd,CAAC;AAEb,CACF,CAAC;AAEDH,KAAK,CAACoF,WAAW,GAAG,OAAO","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Sheet.js","names":["React","useCallback","useEffect","forwardRef","useState","useImperativeHandle","classnames","StyledAnimatedSpan","StyledCssTransition","StyledHeader","StyledIconsWrapperSmall","StyledListSeparator","StyledSheetIcons","StyledSheetWrapper","SHEET_ENTER_MS","SHEET_EXIT_MS","StyledSheetSurface","StyledSheetWrapperPaper","IconButton","Overlay","Tooltip","Fade","Window","Sheet","_ref","ref","children","onClose","_ref$controls","controls","_ref$open","open","defaultOpen","_ref$animation","animation","_ref$position","position","_ref$mode","mode","_ref$disableFocusLock","disableFocusLock","_ref$disableScrollLoc","disableScrollLock","_ref$disableBackgroun","disableBackgroundColor","bodyStyle","bodyClassName","_ref$disableBackgroun2","disableBackgroundClick","rest","_objectWithoutPropertiesLoose","_excluded","_useState","setOpen","_useState2","exited","setExited","handleEnter","handleExited","handleClose","handleBackgroundClick","event","preventDefault","close","createElement","_extends","in","timeout","onClick","style","pointerEvents","undefined","className","$position","$mode","appear","classNames","$direction","onEnter","onExited","length","map","_ref2","index","IconComponent","icon","tooltip","disabled","title","disable","key","$disabled","paperClass","_ref3","variant","displayName"],"sources":["../../../../src/components/Sheet/Sheet.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n forwardRef,\n HTMLAttributes,\n useState,\n CSSProperties,\n MouseEvent,\n useImperativeHandle,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport {\n StyledAnimatedSpan,\n StyledCssTransition,\n StyledHeader,\n StyledIconsWrapperSmall,\n StyledListSeparator,\n StyledSheetIcons,\n StyledSheetWrapper,\n SHEET_ENTER_MS,\n SHEET_EXIT_MS,\n StyledSheetSurface,\n StyledSheetWrapperPaper,\n} from \"./Styles\";\nimport { IconButton } from \"../IconButton\";\nimport { Overlay } from \"../Overlay\";\nimport { Tooltip } from \"../Tooltip\";\nimport { Fade } from \"../Transitions\";\nimport { Window } from \"../Window\";\n\ninterface ControlProps {\n onClick: () => void;\n icon: React.ReactElement;\n tooltip: string;\n disabled: boolean;\n className: string;\n}\n\ninterface ISheet {\n onClose?: () => void;\n controls?: ControlProps[];\n open?: boolean;\n animation?: \"top\" | \"bottom\" | \"left\" | \"right\";\n position?: \"center\" | \"left\" | \"right\";\n mode?: \"normal\" | \"stretch\";\n disableFocusLock?: boolean;\n disableScrollLock?: boolean;\n disableBackgroundColor?: boolean;\n bodyStyle?: CSSProperties;\n bodyClassName?: string;\n disableBackgroundClick?: boolean;\n}\n\nexport interface SheetMethods {\n close: () => void;\n}\n\ntype SheetProps = ISheet & HTMLAttributes<HTMLDivElement>;\n\nexport const Sheet = forwardRef<SheetMethods, SheetProps>(\n (\n {\n children,\n onClose,\n controls = [],\n open: defaultOpen = false,\n animation = \"top\",\n position = \"center\",\n mode = \"normal\",\n disableFocusLock = false,\n disableScrollLock = false,\n disableBackgroundColor = false,\n bodyStyle,\n bodyClassName,\n disableBackgroundClick = false,\n ...rest\n },\n ref\n ) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(true);\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n const handleEnter = useCallback(() => {\n setExited(false);\n }, []);\n\n const handleExited = useCallback(() => {\n setExited(true);\n onClose?.();\n }, [onClose]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n }, []);\n\n const handleBackgroundClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (!disableBackgroundClick) {\n event.preventDefault();\n handleClose();\n }\n },\n [disableBackgroundClick, handleClose]\n );\n\n useImperativeHandle(ref, () => ({\n close: handleClose,\n }));\n\n if (!open && exited) {\n return null;\n }\n\n return (\n <Window\n {...rest}\n onClose={handleClose}\n disableFocusLock={disableFocusLock}\n disableScrollLock={disableScrollLock}\n >\n <Fade in={open} timeout={open ? SHEET_ENTER_MS : SHEET_EXIT_MS}>\n <Overlay\n onClick={handleBackgroundClick}\n disableBackgroundColor={disableBackgroundColor}\n style={{ pointerEvents: open ? undefined : \"none\" }}\n />\n </Fade>\n <StyledSheetWrapper\n className={classnames(\"c-sheet__wrapper\", bodyClassName)}\n style={bodyStyle}\n $position={position}\n $mode={mode}\n >\n <StyledCssTransition\n appear\n in={open}\n timeout={SHEET_ENTER_MS}\n classNames=\"c-sheet__animation\"\n $direction={animation}\n onEnter={handleEnter}\n onExited={handleExited}\n >\n <StyledSheetSurface>\n {controls.length > 0 && (\n <StyledSheetIcons>\n {controls.map(\n (\n {\n icon: IconComponent,\n tooltip,\n onClick,\n disabled,\n className,\n },\n index\n ) => (\n <Tooltip\n title={tooltip}\n disable={!tooltip || disabled}\n key={`c-sheet-control-${index}`}\n >\n <StyledAnimatedSpan\n onClick={onClick}\n $disabled={disabled}\n className={className}\n >\n {IconComponent}\n </StyledAnimatedSpan>\n </Tooltip>\n )\n )}\n </StyledSheetIcons>\n )}\n <StyledSheetWrapperPaper paperClass=\"c-sheet__wrapper__paper\">\n {controls.length > 0 && (\n <StyledHeader>\n <StyledIconsWrapperSmall>\n {controls.map(\n (\n {\n icon: IconComponent,\n tooltip,\n onClick,\n disabled,\n className,\n },\n index\n ) => (\n <Tooltip\n title={tooltip}\n disable={!tooltip || disabled}\n key={index}\n >\n <IconButton\n onClick={onClick}\n disabled={disabled}\n className={className}\n variant=\"text gray\"\n >\n {IconComponent}\n </IconButton>\n </Tooltip>\n )\n )}\n </StyledIconsWrapperSmall>\n <StyledListSeparator />\n </StyledHeader>\n )}\n {children}\n </StyledSheetWrapperPaper>\n </StyledSheetSurface>\n </StyledCssTransition>\n </StyledSheetWrapper>\n </Window>\n );\n }\n);\n\nSheet.displayName = \"Sheet\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,UAAU,EAEVC,QAAQ,EAGRC,mBAAmB,QACd,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,YAAY,EACZC,uBAAuB,EACvBC,mBAAmB,EACnBC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,EACdC,aAAa,EACbC,kBAAkB,EAClBC,uBAAuB,QAClB,UAAU;AACjB,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,MAAM,QAAQ,WAAW;AA+BlC,OAAO,MAAMC,KAAK,gBAAGpB,UAAU,CAC7B,CAAAqB,IAAA,EAiBEC,GAAG,KACA;EAAA,IAhBDC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IAAAC,aAAA,GAAAJ,IAAA,CACPK,QAAQ;IAARA,QAAQ,GAAAD,aAAA,cAAG,EAAE,GAAAA,aAAA;IAAAE,SAAA,GAAAN,IAAA,CACbO,IAAI;IAAEC,WAAW,GAAAF,S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F,KAAA,CAAAgE,aAAA,CAACvD,YAAY,qBACXT,KAAA,CAAAgE,aAAA,CAACtD,uBAAuB,QACrBmB,QAAQ,CAACoD,GAAG,CACX,CAAAY,KAAA,EAQEV,KAAK;IAAA,IANGC,aAAa,GAAAS,KAAA,CAAnBR,IAAI;MACJC,OAAO,GAAAO,KAAA,CAAPP,OAAO;MACPlB,OAAO,GAAAyB,KAAA,CAAPzB,OAAO;MACPmB,QAAQ,GAAAM,KAAA,CAARN,QAAQ;MACRf,SAAS,GAAAqB,KAAA,CAATrB,SAAS;IAAA,oBAIXxE,KAAA,CAAAgE,aAAA,CAAC5C,OAAO;MACNoE,KAAK,EAAEF,OAAQ;MACfG,OAAO,EAAE,CAACH,OAAO,IAAIC,QAAS;MAC9BG,GAAG,EAAEP;IAAM,gBAEXnF,KAAA,CAAAgE,aAAA,CAAC9C,UAAU;MACTkD,OAAO,EAAEA,OAAQ;MACjBmB,QAAQ,EAAEA,QAAS;MACnBf,SAAS,EAAEA,SAAU;MACrBsB,OAAO,EAAC;IAAW,GAElBV,aACS,CACL,CAAC;EAAA,CAEd,CACuB,CAAC,eAC1BpF,KAAA,CAAAgE,aAAA,CAACrD,mBAAmB,MAAE,CACV,CACf,EACAe,QACsB,CACP,CACD,CACH,CACd,CAAC;AAEb,CACF,CAAC;AAEDH,KAAK,CAACwE,WAAW,GAAG,OAAO","ignoreList":[]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CSSTransition } from "react-transition-group";
|
|
2
|
+
export declare const SHEET_ENTER_MS = 400;
|
|
3
|
+
export declare const SHEET_EXIT_MS = 200;
|
|
2
4
|
export declare const StyledSheetIcons: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
5
|
interface IStyledSheetWrapper {
|
|
4
6
|
$position?: "center" | "left" | "right";
|
|
@@ -8,18 +10,9 @@ export declare const StyledSheetWrapper: import("styled-components").StyledCompo
|
|
|
8
10
|
interface IStyledSheetWrapperPaper {
|
|
9
11
|
paperClass?: string;
|
|
10
12
|
}
|
|
13
|
+
export declare const StyledSheetSurface: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
14
|
export declare const StyledSheetWrapperPaper: import("styled-components").StyledComponent<"div", any, IStyledSheetWrapperPaper, never>;
|
|
12
|
-
export declare const StyledSheetControlsTop: import("styled-components").Keyframes;
|
|
13
|
-
export declare const StyledSheetControlsBottom: import("styled-components").Keyframes;
|
|
14
|
-
export declare const StyledSheetControlsCenterIn: import("styled-components").Keyframes;
|
|
15
|
-
export declare const StyledSheetControlsCenterOut: import("styled-components").Keyframes;
|
|
16
15
|
interface IStyledAnimatedSpan {
|
|
17
|
-
$mode: string;
|
|
18
|
-
$state?: string;
|
|
19
|
-
$maxDurationIn: number;
|
|
20
|
-
$maxDurationOut: number;
|
|
21
|
-
$durationOut: number;
|
|
22
|
-
$durationIn: number;
|
|
23
16
|
$disabled?: boolean;
|
|
24
17
|
}
|
|
25
18
|
export declare const StyledAnimatedSpan: import("styled-components").StyledComponent<"span", any, IStyledAnimatedSpan, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Sheet/Styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AASvD,eAAO,MAAM,gBAAgB,oEA2B5B,CAAC;AAIF,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACxC,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B;AAED,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Sheet/Styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AASvD,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,eAAO,MAAM,gBAAgB,oEA2B5B,CAAC;AAIF,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACxC,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B;AAED,eAAO,MAAM,kBAAkB,qFAiG9B,CAAC;AAIF,UAAU,wBAAwB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,oEAM9B,CAAC;AAIF,eAAO,MAAM,uBAAuB,0FAkBnC,CAAC;AAIF,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,sFAc9B,CAAC;AAIF,eAAO,MAAM,mBAAmB;gBAClB,MAAM;SA6HnB,CAAC;AAIF,eAAO,MAAM,mBAAmB;;;kBAE/B,CAAC;AAIF,eAAO,MAAM,uBAAuB,oEASnC,CAAC;AAIF,eAAO,MAAM,YAAY,oEAIxB,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { CSSTransition } from "react-transition-group";
|
|
2
|
-
import styled, { css
|
|
2
|
+
import styled, { css } from "styled-components";
|
|
3
3
|
import { BoxSizingStyle } from "../BoxSizingStyle";
|
|
4
4
|
import { FontStyle } from "../FontStyle";
|
|
5
5
|
import { ListSeparator } from "../List";
|
|
6
|
+
export const SHEET_ENTER_MS = 400;
|
|
7
|
+
export const SHEET_EXIT_MS = 200;
|
|
6
8
|
export const StyledSheetIcons = styled.div.withConfig({
|
|
7
9
|
displayName: "Styles__StyledSheetIcons",
|
|
8
10
|
componentId: "sc-144eyxd-0"
|
|
@@ -11,7 +13,7 @@ StyledSheetIcons.displayName = "StyledSheetIcons";
|
|
|
11
13
|
export const StyledSheetWrapper = styled.div.withConfig({
|
|
12
14
|
displayName: "Styles__StyledSheetWrapper",
|
|
13
15
|
componentId: "sc-144eyxd-1"
|
|
14
|
-
})(["", " ", " position:relative;max-width:95vw;display:flex;flex-direction:row;", " ", " ", " ", " ", " ", " ", ""], BoxSizingStyle, FontStyle, props => props.$mode === "stretch" ? css(["margin-top:8px;height:calc(100vh - 16px);width:calc(100vw - 100px);max-width:1000px;", "{flex-direction:column;width:0;height:calc(100vh - 32px);& > *{margin-bottom:8px;
|
|
16
|
+
})(["", " ", " position:relative;max-width:95vw;display:flex;flex-direction:row;", " ", " ", " ", " ", " ", " ", ""], BoxSizingStyle, FontStyle, props => props.$mode === "stretch" ? css(["margin-top:8px;height:calc(100vh - 16px);width:calc(100vw - 100px);max-width:1000px;", "{flex-direction:column;width:0;height:calc(100vh - 32px);& > *{margin-bottom:8px;}span{top:8px;}}"], StyledSheetIcons) : css(["max-height:calc(100vh - 156px);margin-top:126px;margin-bottom:30px;width:540px;flex-direction:column;", "{flex-direction:row-reverse;& > *{margin-left:8px;}span{top:-48px;right:8px;}}"], StyledSheetIcons), props => props.$mode === "stretch" && css(["@media (max-width:640px){width:100%;height:100%;}"]), props => props.$position === "center" && css(["", ""], {
|
|
15
17
|
"marginLeft": "auto",
|
|
16
18
|
"marginRight": "auto"
|
|
17
19
|
}), props => props.$position === "left" && css(["", ""], {
|
|
@@ -22,42 +24,43 @@ export const StyledSheetWrapper = styled.div.withConfig({
|
|
|
22
24
|
"marginRight": "0.5rem"
|
|
23
25
|
}), props => props.$mode === "stretch" && props.$position !== "left" && css(["", "{span{right:48px;}}"], StyledSheetIcons), props => props.$mode === "stretch" && props.$position === "left" && css(["flex-direction:row-reverse;", "{span{right:-8px;}}"], StyledSheetIcons));
|
|
24
26
|
StyledSheetWrapper.displayName = "StyledSheetWrapper";
|
|
27
|
+
export const StyledSheetSurface = styled.div.withConfig({
|
|
28
|
+
displayName: "Styles__StyledSheetSurface",
|
|
29
|
+
componentId: "sc-144eyxd-2"
|
|
30
|
+
})(["display:flex;flex-direction:inherit;flex:1 1 auto;min-width:0;min-height:0;"]);
|
|
31
|
+
StyledSheetSurface.displayName = "StyledSheetSurface";
|
|
25
32
|
export const StyledSheetWrapperPaper = styled.div.attrs(props => ({
|
|
26
33
|
className: props.paperClass
|
|
27
34
|
})).withConfig({
|
|
28
35
|
displayName: "Styles__StyledSheetWrapperPaper",
|
|
29
|
-
componentId: "sc-144eyxd-
|
|
36
|
+
componentId: "sc-144eyxd-3"
|
|
30
37
|
})(["background-color:var(--page-paper-main);color:var(--color-theme-900);box-shadow:var(--shadow-primary);border-radius:6px;overflow:auto;animation:0.3s linear ease-out;transform:translateZ(0);contain:paint;overscroll-behavior:contain;", ""], {
|
|
31
38
|
"flex": "1 1 auto"
|
|
32
39
|
});
|
|
33
40
|
StyledSheetWrapperPaper.displayName = "StyledSheetWrapperPaper";
|
|
34
|
-
export const StyledSheetControlsTop = keyframes(["0%{opacity:0;transform:translateY(-200px);}100%{opacity:1;transform:translateY(0);}"]);
|
|
35
|
-
export const StyledSheetControlsBottom = keyframes(["0%{opacity:1;transform:translateY(0);}100%{opacity:0;transform:translateY(-200px);}"]);
|
|
36
|
-
export const StyledSheetControlsCenterIn = keyframes(["0%{transform:translateY(-150px);opacity:0;}100%{transform:translateY(0);opacity:1;}"]);
|
|
37
|
-
export const StyledSheetControlsCenterOut = keyframes(["0%{transform:translateY(0);opacity:1;}100%{transform:translateY(-150px);opacity:0;}"]);
|
|
38
41
|
export const StyledAnimatedSpan = styled.span.withConfig({
|
|
39
42
|
displayName: "Styles__StyledAnimatedSpan",
|
|
40
|
-
componentId: "sc-144eyxd-
|
|
41
|
-
})(["&:hover svg{fill:var(--color-primary);}", "
|
|
43
|
+
componentId: "sc-144eyxd-4"
|
|
44
|
+
})(["&:hover svg{fill:var(--color-primary);}", ""], props => props.$disabled && css(["pointer-events:none;svg{opacity:0.5;}"]));
|
|
42
45
|
StyledAnimatedSpan.displayName = "StyledAnimatedSpan";
|
|
43
46
|
export const StyledCssTransition = styled(CSSTransition).withConfig({
|
|
44
47
|
displayName: "Styles__StyledCssTransition",
|
|
45
|
-
componentId: "sc-144eyxd-
|
|
46
|
-
})(["", " ", " ", " ", ""], props => props.$direction === "top" && css(["&.c-sheet__animation-enter{opacity:0;transform:translateY(-100%);}&.c-sheet__animation-enter-active{opacity:1;transform:translateY(0);transition:opacity
|
|
48
|
+
componentId: "sc-144eyxd-5"
|
|
49
|
+
})(["", " ", " ", " ", ""], props => props.$direction === "top" && css(["&.c-sheet__animation-enter{opacity:0;transform:translateY(-100%);}&.c-sheet__animation-enter-active{opacity:1;transform:translateY(0);transition:opacity ", "ms,transform ", "ms;}&.c-sheet__animation-appear{opacity:0;transform:translateY(-100%);}&.c-sheet__animation-appear-active{opacity:1;transform:translateY(0);transition:opacity ", "ms,transform ", "ms;}&.c-sheet__animation-exit{opacity:1;}&.c-sheet__animation-exit-active{opacity:0;transform:translateY(-100%);transition:opacity ", "ms,transform ", "ms;}"], SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_EXIT_MS, SHEET_EXIT_MS), props => props.$direction === "bottom" && css(["&.c-sheet__animation-enter{opacity:0;transform:translateY(100%);}&.c-sheet__animation-enter-active{opacity:1;transform:translateY(0);transition:opacity ", "ms,transform ", "ms;}&.c-sheet__animation-appear{opacity:0;transform:translateY(100%);}&.c-sheet__animation-appear-active{opacity:1;transform:translateY(0);transition:opacity ", "ms,transform ", "ms;}&.c-sheet__animation-exit{opacity:1;}&.c-sheet__animation-exit-active{opacity:0;transform:translateY(100%);transition:opacity ", "ms,transform ", "ms;}"], SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_EXIT_MS, SHEET_EXIT_MS), props => props.$direction === "left" && css(["&.c-sheet__animation-enter{opacity:0;transform:translateX(-100%);}&.c-sheet__animation-enter-active{opacity:1;transform:translateX(0);transition:opacity ", "ms,transform ", "ms;}&.c-sheet__animation-appear{opacity:0;transform:translateX(-100%);}&.c-sheet__animation-appear-active{opacity:1;transform:translateX(0);transition:opacity ", "ms,transform ", "ms;}&.c-sheet__animation-exit{opacity:1;}&.c-sheet__animation-exit-active{opacity:0;transform:translateX(-100%);transition:opacity ", "ms,transform ", "ms;}"], SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_EXIT_MS, SHEET_EXIT_MS), props => props.$direction === "right" && css(["&.c-sheet__animation-enter{opacity:0;transform:translateX(100%);}&.c-sheet__animation-enter-active{opacity:1;transform:translateX(0);transition:opacity ", "ms,transform ", "ms;}&.c-sheet__animation-appear{opacity:0;transform:translateX(100%);}&.c-sheet__animation-appear-active{opacity:1;transform:translateX(0);transition:opacity ", "ms,transform ", "ms;}&.c-sheet__animation-exit{opacity:1;}&.c-sheet__animation-exit-active{opacity:0;transform:translateX(100%);transition:opacity ", "ms,transform ", "ms;}"], SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_ENTER_MS, SHEET_EXIT_MS, SHEET_EXIT_MS));
|
|
47
50
|
StyledCssTransition.displayName = "StyledCssTransition";
|
|
48
51
|
export const StyledListSeparator = styled(ListSeparator).withConfig({
|
|
49
52
|
displayName: "Styles__StyledListSeparator",
|
|
50
|
-
componentId: "sc-144eyxd-
|
|
53
|
+
componentId: "sc-144eyxd-6"
|
|
51
54
|
})(["margin:0;"]);
|
|
52
55
|
StyledListSeparator.displayName = "StyledListSeparator";
|
|
53
56
|
export const StyledIconsWrapperSmall = styled.div.withConfig({
|
|
54
57
|
displayName: "Styles__StyledIconsWrapperSmall",
|
|
55
|
-
componentId: "sc-144eyxd-
|
|
58
|
+
componentId: "sc-144eyxd-7"
|
|
56
59
|
})(["height:40px;display:flex;gap:8px;padding-left:16px;padding-right:16px;align-items:center;place-content:end;flex-direction:row-reverse;"]);
|
|
57
60
|
StyledIconsWrapperSmall.displayName = "StyledIconsWrapperSmall";
|
|
58
61
|
export const StyledHeader = styled.div.withConfig({
|
|
59
62
|
displayName: "Styles__StyledHeader",
|
|
60
|
-
componentId: "sc-144eyxd-
|
|
63
|
+
componentId: "sc-144eyxd-8"
|
|
61
64
|
})(["@media (min-width:640px){display:none;}"]);
|
|
62
65
|
StyledHeader.displayName = "StyledHeader";
|
|
63
66
|
//# sourceMappingURL=Styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["CSSTransition","styled","css","keyframes","BoxSizingStyle","FontStyle","ListSeparator","StyledSheetIcons","div","withConfig","displayName","componentId","StyledSheetWrapper","props","$mode","$position","StyledSheetWrapperPaper","attrs","className","paperClass","StyledSheetControlsTop","StyledSheetControlsBottom","StyledSheetControlsCenterIn","StyledSheetControlsCenterOut","StyledAnimatedSpan","span","$state","$durationIn","$maxDurationIn","$disabled","$durationOut","$maxDurationOut","StyledCssTransition","$direction","StyledListSeparator","StyledIconsWrapperSmall","StyledHeader"],"sources":["../../../../src/components/Sheet/Styles.ts"],"sourcesContent":["import { CSSTransition } from \"react-transition-group\";\n\nimport styled, { css, keyframes } from \"styled-components\";\nimport tw from \"twin.macro\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { FontStyle } from \"../FontStyle\";\nimport { ListSeparator } from \"../List\";\n\nexport const StyledSheetIcons = styled.div`\n display: flex;\n height: 0;\n position: relative;\n\n span {\n position: relative;\n background-color: var(--page-paper-main);\n box-shadow: var(--shadow-secondary);\n cursor: pointer;\n border-radius: 100%;\n width: 40px;\n height: 40px;\n display: flex;\n justify-content: center;\n align-items: center;\n & > * {\n height: 40px;\n width: 40px;\n padding: 8px;\n fill: var(--color-theme-600);\n }\n }\n\n @media (max-width: 640px) {\n display: none;\n }\n`;\n\nStyledSheetIcons.displayName = \"StyledSheetIcons\";\n\ninterface IStyledSheetWrapper {\n $position?: \"center\" | \"left\" | \"right\";\n $mode?: \"normal\" | \"stretch\";\n}\n\nexport const StyledSheetWrapper = styled.div<IStyledSheetWrapper>`\n ${BoxSizingStyle}\n ${FontStyle}\n\n position: relative;\n max-width: 95vw;\n display: flex;\n flex-direction: row;\n\n ${(props) =>\n props.$mode === \"stretch\"\n ? css`\n margin-top: 8px;\n height: calc(100vh - 16px);\n width: calc(100vw - 100px);\n max-width: 1000px;\n ${StyledSheetIcons} {\n flex-direction: column;\n width: 0;\n height: calc(100vh - 32px);\n & > * {\n margin-bottom: 8px;\n animation-fill-mode: both;\n }\n span {\n top: 8px;\n }\n }\n `\n : css`\n max-height: calc(100vh - 156px);\n margin-top: 126px;\n margin-bottom: 30px;\n width: 540px;\n flex-direction: column;\n\n ${StyledSheetIcons} {\n flex-direction: row-reverse;\n & > * {\n margin-left: 8px;\n animation-fill-mode: both;\n }\n span {\n top: -48px;\n right: 8px;\n }\n }\n `}\n\n ${(props) =>\n props.$mode === \"stretch\" &&\n css`\n @media (max-width: 640px) {\n width: 100%;\n height: 100%;\n }\n `}\n\n ${(props) =>\n props.$position === \"center\" &&\n css`\n ${tw`tw-mx-auto`}\n `}\n\n ${(props) =>\n props.$position === \"left\" &&\n css`\n ${tw`tw-ml-2 tw-mr-auto`}\n `}\n\n ${(props) =>\n props.$position === \"right\" &&\n css`\n ${tw`tw-mr-2 tw-ml-auto`}\n `}\n\n ${(props) =>\n props.$mode === \"stretch\" &&\n props.$position !== \"left\" &&\n css`\n ${StyledSheetIcons} {\n span {\n right: 48px;\n }\n }\n `}\n\n ${(props) =>\n props.$mode === \"stretch\" &&\n props.$position === \"left\" &&\n css`\n flex-direction: row-reverse;\n\n ${StyledSheetIcons} {\n span {\n right: -8px;\n }\n }\n `}\n`;\n\nStyledSheetWrapper.displayName = \"StyledSheetWrapper\";\n\ninterface IStyledSheetWrapperPaper {\n paperClass?: string;\n}\n\nexport const StyledSheetWrapperPaper = styled.div.attrs<IStyledSheetWrapperPaper>(\n (props) => ({\n className: props.paperClass,\n })\n)<IStyledSheetWrapperPaper>`\n background-color: var(--page-paper-main);\n color: var(--color-theme-900);\n box-shadow: var(--shadow-primary);\n border-radius: 6px;\n overflow: auto;\n animation: 0.3s linear ease-out;\n /* Scrolling here must not dirty the blurred overlays below, which already clip to this box. */\n transform: translateZ(0);\n contain: paint;\n /* A scroll that runs off the end must stop here. Chained to the page, it moves what the blur samples. */\n overscroll-behavior: contain;\n\n ${tw`tw-flex-auto`}\n`;\n\nStyledSheetWrapperPaper.displayName = \"StyledSheetWrapperPaper\";\n\nexport const StyledSheetControlsTop = keyframes`\n 0% {\n opacity: 0;\n transform: translateY(-200px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n`;\n\nexport const StyledSheetControlsBottom = keyframes`\n 0% {\n opacity: 1;\n transform: translateY(0);\n }\n 100% {\n opacity: 0;\n transform: translateY(-200px);\n}\n`;\n\nexport const StyledSheetControlsCenterIn = keyframes`\n 0% {\n transform: translateY(-150px);\n opacity: 0;\n }\n 100% {\n transform: translateY(0);\n opacity: 1;\n }\n`;\n\nexport const StyledSheetControlsCenterOut = keyframes`\n 0% {\n transform: translateY(0);\n opacity: 1;\n }\n 100% {\n transform: translateY(-150px);\n opacity: 0;\n }\n`;\n\ninterface IStyledAnimatedSpan {\n $mode: string;\n $state?: string;\n $maxDurationIn: number;\n $maxDurationOut: number;\n $durationOut: number;\n $durationIn: number;\n $disabled?: boolean;\n}\n\nexport const StyledAnimatedSpan = styled.span<IStyledAnimatedSpan>`\n &:hover svg {\n fill: var(--color-primary);\n }\n ${(props) =>\n props.$state === \"entering\" &&\n css`\n opacity: 1;\n\n ${props.$mode === \"stretch\"\n ? css`\n animation-name: ${StyledSheetControlsTop};\n animation-duration: ${`${props.$durationIn}s`};\n animation-delay: ${`${props.$durationIn}s`};\n `\n : css`\n animation-name: ${StyledSheetControlsCenterIn};\n animation-duration: ${`${props.$maxDurationIn}s`};\n animation-delay: 0s;\n `}\n `}\n\n ${(props) =>\n props.$state === \"entered\" &&\n css`\n opacity: 1;\n `}\n\n ${(props) =>\n props.$disabled &&\n css`\n pointer-events: none;\n\n svg {\n opacity: 0.5;\n }\n `}\n\n ${(props) =>\n props.$state === \"exiting\" &&\n css`\n opacity: 0;\n\n ${props.$mode === \"stretch\"\n ? css`\n animation-name: ${StyledSheetControlsBottom};\n animation-duration: ${`${props.$durationOut}s`};\n animation-delay: ${`${props.$durationOut}s`};\n `\n : css`\n animation-name: ${StyledSheetControlsCenterOut};\n animation-duration: ${`${props.$maxDurationOut}s`};\n animation-delay: 0;\n `}\n `}\n\n ${(props) =>\n props.$state === \"exited\" &&\n css`\n opacity: 0;\n `}\n`;\n\nStyledAnimatedSpan.displayName = \"StyledAnimatedSpan\";\n\nexport const StyledCssTransition = styled(CSSTransition)<{\n $direction: string;\n}>`\n ${(props) =>\n props.$direction === \"top\" &&\n css`\n &.c-sheet__animation-enter {\n opacity: 0;\n transform: translateY(-100%);\n }\n &.c-sheet__animation-enter-active {\n opacity: 1;\n transform: translateY(0);\n transition: opacity 400ms, transform 400ms;\n }\n &.c-sheet__animation-appear {\n opacity: 0;\n transform: translateY(-100%);\n }\n &.c-sheet__animation-appear-active {\n opacity: 1;\n transform: translateY(0);\n transition: opacity 400ms, transform 400ms;\n }\n &.c-sheet__animation-exit {\n opacity: 1;\n }\n &.c-sheet__animation-exit-active {\n opacity: 0;\n transform: translateY(-100%);\n transition: opacity 200ms, transform 200ms;\n }\n `}\n\n ${(props) =>\n props.$direction === \"bottom\" &&\n css`\n &.c-sheet__animation-enter {\n opacity: 0;\n transform: translateY(100%);\n }\n &.c-sheet__animation-enter-active {\n opacity: 1;\n transform: translateY(0);\n transition: opacity 400ms, transform 400ms;\n }\n &.c-sheet__animation-appear {\n opacity: 0;\n transform: translateY(100%);\n }\n &.c-sheet__animation-appear-active {\n opacity: 1;\n transform: translateY(0);\n transition: opacity 400ms, transform 400ms;\n }\n &.c-sheet__animation-exit {\n opacity: 1;\n }\n &.c-sheet__animation-exit-active {\n opacity: 0;\n transform: translateY(100%);\n transition: opacity 200ms, transform 200ms;\n }\n `}\n\n ${(props) =>\n props.$direction === \"left\" &&\n css`\n &.c-sheet__animation-enter {\n opacity: 0;\n transform: translateX(-100%);\n }\n &.c-sheet__animation-enter-active {\n opacity: 1;\n transform: translateX(0);\n transition: opacity 400ms, transform 400ms;\n }\n &.c-sheet__animation-appear {\n opacity: 0;\n transform: translateX(-100%);\n }\n &.c-sheet__animation-appear-active {\n opacity: 1;\n transform: translateX(0);\n transition: opacity 400ms, transform 400ms;\n }\n &.c-sheet__animation-exit {\n opacity: 1;\n }\n &.c-sheet__animation-exit-active {\n opacity: 0;\n transform: translateX(-100%);\n transition: opacity 200ms, transform 200ms;\n }\n `}\n\n ${(props) =>\n props.$direction === \"right\" &&\n css`\n &.c-sheet__animation-enter {\n opacity: 0;\n transform: translateX(100%);\n }\n &.c-sheet__animation-enter-active {\n opacity: 1;\n transform: translateX(0);\n transition: opacity 400ms, transform 400ms;\n }\n &.c-sheet__animation-appear {\n opacity: 0;\n transform: translateX(100%);\n }\n &.c-sheet__animation-appear-active {\n opacity: 1;\n transform: translateX(0);\n transition: opacity 400ms, transform 400ms;\n }\n &.c-sheet__animation-exit {\n opacity: 1;\n }\n &.c-sheet__animation-exit-active {\n opacity: 0;\n transform: translateX(100%);\n transition: opacity 200ms, transform 200ms;\n }\n `}\n`;\n\nStyledCssTransition.displayName = \"StyledCssTransition\";\n\nexport const StyledListSeparator = styled(ListSeparator)`\n margin: 0;\n`;\n\nStyledListSeparator.displayName = \"StyledListSeparator\";\n\nexport const StyledIconsWrapperSmall = styled.div`\n height: 40px;\n display: flex;\n gap: 8px;\n padding-left: 16px;\n padding-right: 16px;\n align-items: center;\n place-content: end;\n flex-direction: row-reverse;\n`;\n\nStyledIconsWrapperSmall.displayName = \"StyledIconsWrapperSmall\";\n\nexport const StyledHeader = styled.div`\n @media (min-width: 640px) {\n display: none;\n }\n`;\n\nStyledHeader.displayName = \"StyledHeader\";\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,wBAAwB;AAEtD,OAAOC,MAAM,IAAIC,GAAG,EAAEC,SAAS,QAAQ,mBAAmB;AAG1D,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,SAAS,QAAQ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sB,mBAAmB,GAAG/B,MAAM,CAACD,aAAa,CAAC,CAAAS,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,4BAGnDE,KAAK,IACNA,KAAK,CAACoB,UAAU,KAAK,KAAK,IAC1B/B,GAAG,8fA2BF,EAEAW,KAAK,IACNA,KAAK,CAACoB,UAAU,KAAK,QAAQ,IAC7B/B,GAAG,2fA2BF,EAEAW,KAAK,IACNA,KAAK,CAACoB,UAAU,KAAK,MAAM,IAC3B/B,GAAG,8fA2BF,EAEAW,KAAK,IACNA,KAAK,CAACoB,UAAU,KAAK,OAAO,IAC5B/B,GAAG,2fA2BF,CACJ;AAED8B,mBAAmB,CAACtB,WAAW,GAAG,qBAAqB;AAEvD,OAAO,MAAMwB,mBAAmB,GAAGjC,MAAM,CAACK,aAAa,CAAC,CAAAG,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,iBAEvD;AAEDuB,mBAAmB,CAACxB,WAAW,GAAG,qBAAqB;AAEvD,OAAO,MAAMyB,uBAAuB,GAAGlC,MAAM,CAACO,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,8IAShD;AAEDwB,uBAAuB,CAACzB,WAAW,GAAG,yBAAyB;AAE/D,OAAO,MAAM0B,YAAY,GAAGnC,MAAM,CAACO,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,+CAIrC;AAEDyB,YAAY,CAAC1B,WAAW,GAAG,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["CSSTransition","styled","css","BoxSizingStyle","FontStyle","ListSeparator","SHEET_ENTER_MS","SHEET_EXIT_MS","StyledSheetIcons","div","withConfig","displayName","componentId","StyledSheetWrapper","props","$mode","$position","StyledSheetSurface","StyledSheetWrapperPaper","attrs","className","paperClass","StyledAnimatedSpan","span","$disabled","StyledCssTransition","$direction","StyledListSeparator","StyledIconsWrapperSmall","StyledHeader"],"sources":["../../../../src/components/Sheet/Styles.ts"],"sourcesContent":["import { CSSTransition } from \"react-transition-group\";\n\nimport styled, { css } from \"styled-components\";\nimport tw from \"twin.macro\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { FontStyle } from \"../FontStyle\";\nimport { ListSeparator } from \"../List\";\n\nexport const SHEET_ENTER_MS = 400;\nexport const SHEET_EXIT_MS = 200;\n\nexport const StyledSheetIcons = styled.div`\n display: flex;\n height: 0;\n position: relative;\n\n span {\n position: relative;\n background-color: var(--page-paper-main);\n box-shadow: var(--shadow-secondary);\n cursor: pointer;\n border-radius: 100%;\n width: 40px;\n height: 40px;\n display: flex;\n justify-content: center;\n align-items: center;\n & > * {\n height: 40px;\n width: 40px;\n padding: 8px;\n fill: var(--color-theme-600);\n }\n }\n\n @media (max-width: 640px) {\n display: none;\n }\n`;\n\nStyledSheetIcons.displayName = \"StyledSheetIcons\";\n\ninterface IStyledSheetWrapper {\n $position?: \"center\" | \"left\" | \"right\";\n $mode?: \"normal\" | \"stretch\";\n}\n\nexport const StyledSheetWrapper = styled.div<IStyledSheetWrapper>`\n ${BoxSizingStyle}\n ${FontStyle}\n\n position: relative;\n max-width: 95vw;\n display: flex;\n flex-direction: row;\n\n ${(props) =>\n props.$mode === \"stretch\"\n ? css`\n margin-top: 8px;\n height: calc(100vh - 16px);\n width: calc(100vw - 100px);\n max-width: 1000px;\n ${StyledSheetIcons} {\n flex-direction: column;\n width: 0;\n height: calc(100vh - 32px);\n & > * {\n margin-bottom: 8px;\n }\n span {\n top: 8px;\n }\n }\n `\n : css`\n max-height: calc(100vh - 156px);\n margin-top: 126px;\n margin-bottom: 30px;\n width: 540px;\n flex-direction: column;\n\n ${StyledSheetIcons} {\n flex-direction: row-reverse;\n & > * {\n margin-left: 8px;\n }\n span {\n top: -48px;\n right: 8px;\n }\n }\n `}\n\n ${(props) =>\n props.$mode === \"stretch\" &&\n css`\n @media (max-width: 640px) {\n width: 100%;\n height: 100%;\n }\n `}\n\n ${(props) =>\n props.$position === \"center\" &&\n css`\n ${tw`tw-mx-auto`}\n `}\n\n ${(props) =>\n props.$position === \"left\" &&\n css`\n ${tw`tw-ml-2 tw-mr-auto`}\n `}\n\n ${(props) =>\n props.$position === \"right\" &&\n css`\n ${tw`tw-mr-2 tw-ml-auto`}\n `}\n\n ${(props) =>\n props.$mode === \"stretch\" &&\n props.$position !== \"left\" &&\n css`\n ${StyledSheetIcons} {\n span {\n right: 48px;\n }\n }\n `}\n\n ${(props) =>\n props.$mode === \"stretch\" &&\n props.$position === \"left\" &&\n css`\n flex-direction: row-reverse;\n\n ${StyledSheetIcons} {\n span {\n right: -8px;\n }\n }\n `}\n`;\n\nStyledSheetWrapper.displayName = \"StyledSheetWrapper\";\n\ninterface IStyledSheetWrapperPaper {\n paperClass?: string;\n}\n\nexport const StyledSheetSurface = styled.div`\n display: flex;\n flex-direction: inherit;\n flex: 1 1 auto;\n min-width: 0;\n min-height: 0;\n`;\n\nStyledSheetSurface.displayName = \"StyledSheetSurface\";\n\nexport const StyledSheetWrapperPaper = styled.div.attrs<IStyledSheetWrapperPaper>(\n (props) => ({\n className: props.paperClass,\n })\n)<IStyledSheetWrapperPaper>`\n background-color: var(--page-paper-main);\n color: var(--color-theme-900);\n box-shadow: var(--shadow-primary);\n border-radius: 6px;\n overflow: auto;\n animation: 0.3s linear ease-out;\n /* Scrolling here must not dirty the blurred overlays below, which already clip to this box. */\n transform: translateZ(0);\n contain: paint;\n /* A scroll that runs off the end must stop here. Chained to the page, it moves what the blur samples. */\n overscroll-behavior: contain;\n\n ${tw`tw-flex-auto`}\n`;\n\nStyledSheetWrapperPaper.displayName = \"StyledSheetWrapperPaper\";\n\ninterface IStyledAnimatedSpan {\n $disabled?: boolean;\n}\n\nexport const StyledAnimatedSpan = styled.span<IStyledAnimatedSpan>`\n &:hover svg {\n fill: var(--color-primary);\n }\n\n ${(props) =>\n props.$disabled &&\n css`\n pointer-events: none;\n\n svg {\n opacity: 0.5;\n }\n `}\n`;\n\nStyledAnimatedSpan.displayName = \"StyledAnimatedSpan\";\n\nexport const StyledCssTransition = styled(CSSTransition)<{\n $direction: string;\n}>`\n ${(props) =>\n props.$direction === \"top\" &&\n css`\n &.c-sheet__animation-enter {\n opacity: 0;\n transform: translateY(-100%);\n }\n &.c-sheet__animation-enter-active {\n opacity: 1;\n transform: translateY(0);\n transition: opacity ${SHEET_ENTER_MS}ms, transform ${SHEET_ENTER_MS}ms;\n }\n &.c-sheet__animation-appear {\n opacity: 0;\n transform: translateY(-100%);\n }\n &.c-sheet__animation-appear-active {\n opacity: 1;\n transform: translateY(0);\n transition: opacity ${SHEET_ENTER_MS}ms, transform ${SHEET_ENTER_MS}ms;\n }\n &.c-sheet__animation-exit {\n opacity: 1;\n }\n &.c-sheet__animation-exit-active {\n opacity: 0;\n transform: translateY(-100%);\n transition: opacity ${SHEET_EXIT_MS}ms, transform ${SHEET_EXIT_MS}ms;\n }\n `}\n\n ${(props) =>\n props.$direction === \"bottom\" &&\n css`\n &.c-sheet__animation-enter {\n opacity: 0;\n transform: translateY(100%);\n }\n &.c-sheet__animation-enter-active {\n opacity: 1;\n transform: translateY(0);\n transition: opacity ${SHEET_ENTER_MS}ms, transform ${SHEET_ENTER_MS}ms;\n }\n &.c-sheet__animation-appear {\n opacity: 0;\n transform: translateY(100%);\n }\n &.c-sheet__animation-appear-active {\n opacity: 1;\n transform: translateY(0);\n transition: opacity ${SHEET_ENTER_MS}ms, transform ${SHEET_ENTER_MS}ms;\n }\n &.c-sheet__animation-exit {\n opacity: 1;\n }\n &.c-sheet__animation-exit-active {\n opacity: 0;\n transform: translateY(100%);\n transition: opacity ${SHEET_EXIT_MS}ms, transform ${SHEET_EXIT_MS}ms;\n }\n `}\n\n ${(props) =>\n props.$direction === \"left\" &&\n css`\n &.c-sheet__animation-enter {\n opacity: 0;\n transform: translateX(-100%);\n }\n &.c-sheet__animation-enter-active {\n opacity: 1;\n transform: translateX(0);\n transition: opacity ${SHEET_ENTER_MS}ms, transform ${SHEET_ENTER_MS}ms;\n }\n &.c-sheet__animation-appear {\n opacity: 0;\n transform: translateX(-100%);\n }\n &.c-sheet__animation-appear-active {\n opacity: 1;\n transform: translateX(0);\n transition: opacity ${SHEET_ENTER_MS}ms, transform ${SHEET_ENTER_MS}ms;\n }\n &.c-sheet__animation-exit {\n opacity: 1;\n }\n &.c-sheet__animation-exit-active {\n opacity: 0;\n transform: translateX(-100%);\n transition: opacity ${SHEET_EXIT_MS}ms, transform ${SHEET_EXIT_MS}ms;\n }\n `}\n\n ${(props) =>\n props.$direction === \"right\" &&\n css`\n &.c-sheet__animation-enter {\n opacity: 0;\n transform: translateX(100%);\n }\n &.c-sheet__animation-enter-active {\n opacity: 1;\n transform: translateX(0);\n transition: opacity ${SHEET_ENTER_MS}ms, transform ${SHEET_ENTER_MS}ms;\n }\n &.c-sheet__animation-appear {\n opacity: 0;\n transform: translateX(100%);\n }\n &.c-sheet__animation-appear-active {\n opacity: 1;\n transform: translateX(0);\n transition: opacity ${SHEET_ENTER_MS}ms, transform ${SHEET_ENTER_MS}ms;\n }\n &.c-sheet__animation-exit {\n opacity: 1;\n }\n &.c-sheet__animation-exit-active {\n opacity: 0;\n transform: translateX(100%);\n transition: opacity ${SHEET_EXIT_MS}ms, transform ${SHEET_EXIT_MS}ms;\n }\n `}\n`;\n\nStyledCssTransition.displayName = \"StyledCssTransition\";\n\nexport const StyledListSeparator = styled(ListSeparator)`\n margin: 0;\n`;\n\nStyledListSeparator.displayName = \"StyledListSeparator\";\n\nexport const StyledIconsWrapperSmall = styled.div`\n height: 40px;\n display: flex;\n gap: 8px;\n padding-left: 16px;\n padding-right: 16px;\n align-items: center;\n place-content: end;\n flex-direction: row-reverse;\n`;\n\nStyledIconsWrapperSmall.displayName = \"StyledIconsWrapperSmall\";\n\nexport const StyledHeader = styled.div`\n @media (min-width: 640px) {\n display: none;\n }\n`;\n\nStyledHeader.displayName = \"StyledHeader\";\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,wBAAwB;AAEtD,OAAOC,MAAM,I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