1 line
30 KiB
JSON
1 line
30 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 React from 'react';\nimport classNames from 'classnames';\nimport RcSlider from 'rc-slider';\nimport raf from \"rc-util/es/raf\";\nimport { devUseWarning } from '../_util/warning';\nimport { ConfigContext } from '../config-provider';\nimport DisabledContext from '../config-provider/DisabledContext';\nimport SliderTooltip from './SliderTooltip';\nimport useStyle from './style';\nimport SliderInternalContext from './Context';\nimport useRafLock from './useRafLock';\nfunction getTipFormatter(tipFormatter, legacyTipFormatter) {\n if (tipFormatter || tipFormatter === null) {\n return tipFormatter;\n }\n if (legacyTipFormatter || legacyTipFormatter === null) {\n return legacyTipFormatter;\n }\n return val => typeof val === 'number' ? val.toString() : '';\n}\nconst Slider = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n prefixCls: customizePrefixCls,\n range,\n className,\n rootClassName,\n style,\n disabled,\n // Deprecated Props\n tooltipPrefixCls: legacyTooltipPrefixCls,\n tipFormatter: legacyTipFormatter,\n tooltipVisible: legacyTooltipVisible,\n getTooltipPopupContainer: legacyGetTooltipPopupContainer,\n tooltipPlacement: legacyTooltipPlacement,\n tooltip = {},\n onChangeComplete\n } = props,\n restProps = __rest(props, [\"prefixCls\", \"range\", \"className\", \"rootClassName\", \"style\", \"disabled\", \"tooltipPrefixCls\", \"tipFormatter\", \"tooltipVisible\", \"getTooltipPopupContainer\", \"tooltipPlacement\", \"tooltip\", \"onChangeComplete\"]);\n const {\n vertical\n } = props;\n const {\n direction: contextDirection,\n slider,\n getPrefixCls,\n getPopupContainer\n } = React.useContext(ConfigContext);\n const contextDisabled = React.useContext(DisabledContext);\n const mergedDisabled = disabled !== null && disabled !== void 0 ? disabled : contextDisabled;\n // ============================= Context ==============================\n const {\n handleRender: contextHandleRender,\n direction: internalContextDirection\n } = React.useContext(SliderInternalContext);\n const mergedDirection = internalContextDirection || contextDirection;\n const isRTL = mergedDirection === 'rtl';\n // =============================== Open ===============================\n const [hoverOpen, setHoverOpen] = useRafLock();\n const [focusOpen, setFocusOpen] = useRafLock();\n const tooltipProps = Object.assign({}, tooltip);\n const {\n open: tooltipOpen,\n placement: tooltipPlacement,\n getPopupContainer: getTooltipPopupContainer,\n prefixCls: customizeTooltipPrefixCls,\n formatter: tipFormatter\n } = tooltipProps;\n const lockOpen = tooltipOpen !== null && tooltipOpen !== void 0 ? tooltipOpen : legacyTooltipVisible;\n const activeOpen = (hoverOpen || focusOpen) && lockOpen !== false;\n const mergedTipFormatter = getTipFormatter(tipFormatter, legacyTipFormatter);\n // ============================= Change ==============================\n const [dragging, setDragging] = useRafLock();\n const onInternalChangeComplete = nextValues => {\n onChangeComplete === null || onChangeComplete === void 0 ? void 0 : onChangeComplete(nextValues);\n setDragging(false);\n };\n // ============================ Placement ============================\n const getTooltipPlacement = (placement, vert) => {\n if (placement) {\n return placement;\n }\n if (!vert) {\n return 'top';\n }\n return isRTL ? 'left' : 'right';\n };\n // ============================== Style ===============================\n cons
|