1 line
22 KiB
JSON
1 line
22 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport { useContext, useEffect, useRef, useState } from 'react';\nimport BarsOutlined from \"@ant-design/icons/es/icons/BarsOutlined\";\nimport LeftOutlined from \"@ant-design/icons/es/icons/LeftOutlined\";\nimport RightOutlined from \"@ant-design/icons/es/icons/RightOutlined\";\nimport classNames from 'classnames';\nimport omit from \"rc-util/es/omit\";\nimport isNumeric from '../_util/isNumeric';\nimport { ConfigContext } from '../config-provider';\nimport { LayoutContext } from './context';\nconst dimensionMaxMap = {\n xs: '479.98px',\n sm: '575.98px',\n md: '767.98px',\n lg: '991.98px',\n xl: '1199.98px',\n xxl: '1599.98px'\n};\nexport const SiderContext = /*#__PURE__*/React.createContext({});\nconst generateId = (() => {\n let i = 0;\n return function () {\n let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n i += 1;\n return `${prefix}${i}`;\n };\n})();\nconst Sider = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n prefixCls: customizePrefixCls,\n className,\n trigger,\n children,\n defaultCollapsed = false,\n theme = 'dark',\n style = {},\n collapsible = false,\n reverseArrow = false,\n width = 200,\n collapsedWidth = 80,\n zeroWidthTriggerStyle,\n breakpoint,\n onCollapse,\n onBreakpoint\n } = props,\n otherProps = __rest(props, [\"prefixCls\", \"className\", \"trigger\", \"children\", \"defaultCollapsed\", \"theme\", \"style\", \"collapsible\", \"reverseArrow\", \"width\", \"collapsedWidth\", \"zeroWidthTriggerStyle\", \"breakpoint\", \"onCollapse\", \"onBreakpoint\"]);\n const {\n siderHook\n } = useContext(LayoutContext);\n const [collapsed, setCollapsed] = useState('collapsed' in props ? props.collapsed : defaultCollapsed);\n const [below, setBelow] = useState(false);\n useEffect(() => {\n if ('collapsed' in props) {\n setCollapsed(props.collapsed);\n }\n }, [props.collapsed]);\n const handleSetCollapsed = (value, type) => {\n if (!('collapsed' in props)) {\n setCollapsed(value);\n }\n onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(value, type);\n };\n // ========================= Responsive =========================\n const responsiveHandlerRef = useRef();\n responsiveHandlerRef.current = mql => {\n setBelow(mql.matches);\n onBreakpoint === null || onBreakpoint === void 0 ? void 0 : onBreakpoint(mql.matches);\n if (collapsed !== mql.matches) {\n handleSetCollapsed(mql.matches, 'responsive');\n }\n };\n useEffect(() => {\n function responsiveHandler(mql) {\n return responsiveHandlerRef.current(mql);\n }\n let mql;\n if (typeof window !== 'undefined') {\n const {\n matchMedia\n } = window;\n if (matchMedia && breakpoint && breakpoint in dimensionMaxMap) {\n mql = matchMedia(`screen and (max-width: ${dimensionMaxMap[breakpoint]})`);\n try {\n mql.addEventListener('change', responsiveHandler);\n } catch (_a) {\n mql.addListener(responsiveHandler);\n }\n responsiveHandler(mql);\n }\n }\n return () => {\n try {\n mql === null || mql === void 0 ? void 0 : mql.removeEventListener('change', responsiveHandler);\n } catch (_a) {\n mql === null || mql === void 0 ? void 0 : mql.removeListener(responsiveHandler);\n }\n };\n }, [breakpoint]); // in order to accept dynamic 'breakpoint' property, we need to add 'breakpoint' into dependency array.\n useEffect(()
|