@infomaximum/ui-kit 0.18.1 → 0.19.0
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/components/BaseSelect/components/SelectOptionList/SelectOptionList.styles.d.ts +1 -1
- package/dist/components/BaseTooltip/BaseTooltip.js +13 -4
- package/dist/components/BaseTooltip/BaseTooltip.styles.d.ts +5 -5
- package/dist/components/Collapse/Collapse.js +6 -2
- package/dist/components/Collapse/components/CollapsePanel/CollapsePanel.js +6 -4
- package/dist/components/ConfigProvider/ConfigProvider.js +7 -2
- package/dist/components/ConfigProvider/ConfigProvider.types.d.ts +1 -0
- package/dist/components/ConfigProvider/ConfigProvider.utils.d.ts +2 -0
- package/dist/components/ConfigProvider/ConfigProvider.utils.js +17 -0
- package/dist/components/ConfigProvider/contexts/ConfigContext.types.d.ts +8 -0
- package/dist/components/ConfigProvider/contexts/index.d.ts +1 -1
- package/dist/components/ConfigProvider/hooks/useComponentTokens/index.d.ts +1 -0
- package/dist/components/ConfigProvider/hooks/useComponentTokens/useComponentTokens.d.ts +2 -0
- package/dist/components/ConfigProvider/hooks/useComponentTokens/useComponentTokens.js +18 -0
- package/dist/components/ConfigProvider/hooks/useComponentTokens/useComponentTokens.types.d.ts +1 -0
- package/dist/components/ConfigProvider/hooks/useConfig/useConfig.d.ts +2 -3
- package/dist/components/ConfigProvider/hooks/useConfig/useConfig.js +1 -1
- package/dist/components/ConfigProvider/hooks/useConfig/useConfig.types.d.ts +2 -0
- package/dist/components/ConfigProvider/index.d.ts +2 -1
- package/dist/components/Slider/Slider.adapters.d.ts +3 -0
- package/dist/components/Slider/Slider.adapters.js +53 -0
- package/dist/components/Slider/Slider.d.ts +2 -0
- package/dist/components/Slider/Slider.js +13 -0
- package/dist/components/Slider/Slider.styles.d.ts +8 -0
- package/dist/components/Slider/Slider.styles.js +31 -0
- package/dist/components/Slider/Slider.tokens.d.ts +21 -0
- package/dist/components/Slider/Slider.tokens.js +17 -0
- package/dist/components/Slider/Slider.types.d.ts +54 -0
- package/dist/components/Slider/Slider.utils.d.ts +19 -0
- package/dist/components/Slider/Slider.utils.js +62 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.d.ts +2 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.js +40 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.styles.d.ts +10 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.styles.js +36 -0
- package/dist/components/Slider/components/SliderHandle/SliderHandle.types.d.ts +16 -0
- package/dist/components/Slider/components/SliderHandle/index.d.ts +1 -0
- package/dist/components/Slider/components/SliderHandleTooltip/SliderHandleTooltip.d.ts +3 -0
- package/dist/components/Slider/components/SliderHandleTooltip/SliderHandleTooltip.js +22 -0
- package/dist/components/Slider/components/SliderHandleTooltip/SliderHandleTooltip.styles.d.ts +7 -0
- package/dist/components/Slider/components/SliderHandleTooltip/SliderHandleTooltip.styles.js +10 -0
- package/dist/components/Slider/components/SliderHandleTooltip/SliderHandleTooltip.types.d.ts +9 -0
- package/dist/components/Slider/components/SliderHandleTooltip/index.d.ts +1 -0
- package/dist/components/Slider/components/SliderInternal/SliderInternal.d.ts +2 -0
- package/dist/components/Slider/components/SliderInternal/SliderInternal.js +121 -0
- package/dist/components/Slider/components/SliderInternal/SliderInternal.types.d.ts +24 -0
- package/dist/components/Slider/components/SliderInternal/SliderInternal.types.js +4 -0
- package/dist/components/Slider/components/SliderInternal/index.d.ts +1 -0
- package/dist/components/Slider/components/SliderRail/SliderRail.d.ts +3 -0
- package/dist/components/Slider/components/SliderRail/SliderRail.js +23 -0
- package/dist/components/Slider/components/SliderRail/SliderRail.styles.d.ts +8 -0
- package/dist/components/Slider/components/SliderRail/SliderRail.styles.js +15 -0
- package/dist/components/Slider/components/SliderRail/SliderRail.types.d.ts +4 -0
- package/dist/components/Slider/components/SliderRail/index.d.ts +1 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.d.ts +3 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.js +29 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.styles.d.ts +11 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.styles.js +34 -0
- package/dist/components/Slider/components/SliderTrack/SliderTrack.types.d.ts +7 -0
- package/dist/components/Slider/components/SliderTrack/index.d.ts +1 -0
- package/dist/components/Slider/hooks/useSliderDrag/index.d.ts +1 -0
- package/dist/components/Slider/hooks/useSliderDrag/useSliderDrag.d.ts +2 -0
- package/dist/components/Slider/hooks/useSliderDrag/useSliderDrag.js +148 -0
- package/dist/components/Slider/hooks/useSliderDrag/useSliderDrag.types.d.ts +30 -0
- package/dist/components/Slider/hooks/useSliderDrag/useSliderDrag.utils.d.ts +17 -0
- package/dist/components/Slider/hooks/useSliderDrag/useSliderDrag.utils.js +49 -0
- package/dist/components/Slider/hooks/useSliderInteractionState/index.d.ts +1 -0
- package/dist/components/Slider/hooks/useSliderInteractionState/useSliderInteractionState.d.ts +2 -0
- package/dist/components/Slider/hooks/useSliderInteractionState/useSliderInteractionState.js +43 -0
- package/dist/components/Slider/hooks/useSliderInteractionState/useSliderInteractionState.types.d.ts +16 -0
- package/dist/components/Slider/hooks/useSliderKeyboard/index.d.ts +1 -0
- package/dist/components/Slider/hooks/useSliderKeyboard/useSliderKeyboard.d.ts +2 -0
- package/dist/components/Slider/hooks/useSliderKeyboard/useSliderKeyboard.js +94 -0
- package/dist/components/Slider/hooks/useSliderKeyboard/useSliderKeyboard.types.d.ts +17 -0
- package/dist/components/Slider/hooks/useSliderKeyboard/useSliderKeyboard.utils.d.ts +1 -0
- package/dist/components/Slider/hooks/useSliderKeyboard/useSliderKeyboard.utils.js +16 -0
- package/dist/components/Slider/index.d.ts +3 -0
- package/dist/components/Table/features/tableRowSelection/components/CheckboxCellContentWrapper/CheckboxCellContentWrapper.utils.js +3 -1
- package/dist/components/Tabs/components/TabBar/TabBar.styles.d.ts +1 -1
- package/dist/components/Tabs/components/TabItem/TabItem.styles.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/types.d.ts +9 -1
- package/package.json +10 -9
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const getSliderTokens = (theme) => ({
|
|
2
|
+
sliderDot: theme.bgContainer,
|
|
3
|
+
sliderDefault: theme.primaryBase,
|
|
4
|
+
sliderHover: theme.primaryHover,
|
|
5
|
+
sliderDisabled: theme.textHint,
|
|
6
|
+
sliderRail: theme.bgRail,
|
|
7
|
+
sliderRailHover: theme.bgRailHover,
|
|
8
|
+
sliderBorderRadius: 100,
|
|
9
|
+
/**
|
|
10
|
+
* @local Нет в Figma — внутренняя инициатива.
|
|
11
|
+
* Отступ вокруг slider'а под зону активного handle (handle растёт до 16px при hover/active).
|
|
12
|
+
*/
|
|
13
|
+
sliderHandleSpacing: theme.x2
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
getSliderTokens
|
|
17
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Interpolation } from '@emotion/react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { Theme } from 'themes';
|
|
4
|
+
import { BaseTooltipPlacementType } from '../BaseTooltip/BaseTooltip.types';
|
|
5
|
+
import { SliderTokens } from './Slider.tokens';
|
|
6
|
+
export type GetStyle = (sliderTokens: SliderTokens, theme: Theme) => Interpolation;
|
|
7
|
+
export interface SliderTooltipProps {
|
|
8
|
+
open?: boolean;
|
|
9
|
+
placement?: BaseTooltipPlacementType;
|
|
10
|
+
formatter?: ((v: number) => ReactNode) | null;
|
|
11
|
+
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
12
|
+
}
|
|
13
|
+
export interface SliderStyles {
|
|
14
|
+
root?: GetStyle;
|
|
15
|
+
rail?: GetStyle;
|
|
16
|
+
track?: GetStyle;
|
|
17
|
+
handle?: GetStyle;
|
|
18
|
+
}
|
|
19
|
+
interface SliderCommonProps {
|
|
20
|
+
/** @default 0 */
|
|
21
|
+
min?: number;
|
|
22
|
+
/** @default 100 */
|
|
23
|
+
max?: number;
|
|
24
|
+
/** @default 1 */
|
|
25
|
+
step?: number | null;
|
|
26
|
+
/** @default false */
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/** @default "horizontal" */
|
|
29
|
+
orientation?: "horizontal" | "vertical";
|
|
30
|
+
tooltip?: SliderTooltipProps;
|
|
31
|
+
styles?: SliderStyles;
|
|
32
|
+
"test-id"?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SingleSliderProps extends SliderCommonProps {
|
|
35
|
+
/** @default false */
|
|
36
|
+
range?: false;
|
|
37
|
+
value?: number;
|
|
38
|
+
defaultValue?: number;
|
|
39
|
+
onChange?: (v: number) => void;
|
|
40
|
+
onChangeComplete?: (v: number) => void;
|
|
41
|
+
}
|
|
42
|
+
export interface RangeSliderProps extends SliderCommonProps {
|
|
43
|
+
range: true;
|
|
44
|
+
value?: [number, number];
|
|
45
|
+
defaultValue?: [number, number];
|
|
46
|
+
onChange?: (v: [number, number]) => void;
|
|
47
|
+
onChangeComplete?: (v: [number, number]) => void;
|
|
48
|
+
}
|
|
49
|
+
export type SliderProps = SingleSliderProps | RangeSliderProps;
|
|
50
|
+
export interface SliderRendererBaseProps extends Pick<SliderProps, "styles" | "test-id"> {
|
|
51
|
+
tokens: SliderTokens;
|
|
52
|
+
vertical: boolean;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HandleIndex } from './hooks/useSliderDrag/useSliderDrag.types';
|
|
2
|
+
import { SliderTooltipProps } from './Slider.types';
|
|
3
|
+
export declare const railSuffix = "_rail";
|
|
4
|
+
export declare const trackSuffix = "_track";
|
|
5
|
+
export declare const handleSuffix = "_handle_";
|
|
6
|
+
export declare const tooltipSuffix = "_tooltip_";
|
|
7
|
+
export declare const emptyTooltip: SliderTooltipProps;
|
|
8
|
+
export declare const clampToStep: (value: number, min: number, max: number, step: number) => number;
|
|
9
|
+
export declare const validateStep: (step: number | null | undefined) => number | null;
|
|
10
|
+
export declare const valueToPercent: (value: number, min: number, max: number) => number;
|
|
11
|
+
export declare const percentToValue: (percent: number, min: number, max: number, step: number) => number;
|
|
12
|
+
export declare function clampToStepRange({ nextValue, activeIndex, otherValue, min, max, step, }: {
|
|
13
|
+
nextValue: number;
|
|
14
|
+
activeIndex: HandleIndex;
|
|
15
|
+
otherValue: number;
|
|
16
|
+
min: number;
|
|
17
|
+
max: number;
|
|
18
|
+
step: number | null;
|
|
19
|
+
}): number;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { clamp } from "lodash-es";
|
|
2
|
+
const railSuffix = "_rail";
|
|
3
|
+
const trackSuffix = "_track";
|
|
4
|
+
const handleSuffix = "_handle_";
|
|
5
|
+
const tooltipSuffix = "_tooltip_";
|
|
6
|
+
const emptyTooltip = {};
|
|
7
|
+
const clampToStep = (value, min, max, step) => {
|
|
8
|
+
const clampedRaw = clamp(value, min, max);
|
|
9
|
+
const steps = Math.round((clampedRaw - min) / step);
|
|
10
|
+
return clamp(min + steps * step, min, max);
|
|
11
|
+
};
|
|
12
|
+
const validateStep = (step) => {
|
|
13
|
+
if (step === void 0) {
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
if (step === null) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (step <= 0) {
|
|
20
|
+
console.warn("[Slider] step must be greater than 0. Falling back to step=1.");
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
return step;
|
|
24
|
+
};
|
|
25
|
+
const valueToPercent = (value, min, max) => {
|
|
26
|
+
if (max === min) {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
return (value - min) / (max - min) * 100;
|
|
30
|
+
};
|
|
31
|
+
const percentToValue = (percent, min, max, step) => {
|
|
32
|
+
const raw = min + percent / 100 * (max - min);
|
|
33
|
+
return clampToStep(raw, min, max, step);
|
|
34
|
+
};
|
|
35
|
+
function clampToStepRange({
|
|
36
|
+
nextValue,
|
|
37
|
+
activeIndex,
|
|
38
|
+
otherValue,
|
|
39
|
+
min,
|
|
40
|
+
max,
|
|
41
|
+
step
|
|
42
|
+
}) {
|
|
43
|
+
const effectiveStep = step ?? 0;
|
|
44
|
+
const lowerBound = activeIndex === 0 ? min : otherValue + effectiveStep;
|
|
45
|
+
const upperBound = activeIndex === 0 ? otherValue - effectiveStep : max;
|
|
46
|
+
if (step === null) {
|
|
47
|
+
return clamp(nextValue, lowerBound, upperBound);
|
|
48
|
+
}
|
|
49
|
+
return clampToStep(nextValue, lowerBound, upperBound, step);
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
clampToStep,
|
|
53
|
+
clampToStepRange,
|
|
54
|
+
emptyTooltip,
|
|
55
|
+
handleSuffix,
|
|
56
|
+
percentToValue,
|
|
57
|
+
railSuffix,
|
|
58
|
+
tooltipSuffix,
|
|
59
|
+
trackSuffix,
|
|
60
|
+
validateStep,
|
|
61
|
+
valueToPercent
|
|
62
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { getHandleStyle } from "./SliderHandle.styles.js";
|
|
4
|
+
import { handleSuffix } from "../../Slider.utils.js";
|
|
5
|
+
import { useTheme } from "../../../../hooks/useTheme/useTheme.js";
|
|
6
|
+
const SliderHandle = forwardRef((props, ref) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const {
|
|
9
|
+
index,
|
|
10
|
+
value,
|
|
11
|
+
min,
|
|
12
|
+
max,
|
|
13
|
+
percent,
|
|
14
|
+
vertical,
|
|
15
|
+
disabled,
|
|
16
|
+
isSliderActive,
|
|
17
|
+
sizeActive,
|
|
18
|
+
tokens,
|
|
19
|
+
styles,
|
|
20
|
+
"test-id": testId,
|
|
21
|
+
interactionHandlers,
|
|
22
|
+
onKeyDown,
|
|
23
|
+
onKeyUp
|
|
24
|
+
} = props;
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
return /* @__PURE__ */ jsx("div", { ref, "test-id": `${testId ?? ""}${handleSuffix}${index}`, "data-handle-index": index, role: "slider", "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value, "aria-orientation": vertical ? "vertical" : "horizontal", "aria-disabled": disabled, tabIndex: disabled ? -1 : 0, style: vertical ? {
|
|
27
|
+
bottom: `${percent}%`
|
|
28
|
+
} : {
|
|
29
|
+
left: `${percent}%`
|
|
30
|
+
}, css: [getHandleStyle({
|
|
31
|
+
tokens,
|
|
32
|
+
vertical,
|
|
33
|
+
colorActive: isSliderActive,
|
|
34
|
+
sizeActive,
|
|
35
|
+
disabled
|
|
36
|
+
})(theme), (_a = styles == null ? void 0 : styles.handle) == null ? void 0 : _a.call(styles, tokens, theme), process.env.NODE_ENV === "production" ? "" : ";label:SliderHandle;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9idWlsZHMvZnJvbnRlbmQvbGlicy91aS1raXQvc3JjL2NvbXBvbmVudHMvU2xpZGVyL2NvbXBvbmVudHMvU2xpZGVySGFuZGxlL1NsaWRlckhhbmRsZS50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBdUNNIiwiZmlsZSI6Ii9idWlsZHMvZnJvbnRlbmQvbGlicy91aS1raXQvc3JjL2NvbXBvbmVudHMvU2xpZGVyL2NvbXBvbmVudHMvU2xpZGVySGFuZGxlL1NsaWRlckhhbmRsZS50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBmb3J3YXJkUmVmIH0gZnJvbSBcInJlYWN0XCI7XG5pbXBvcnQgeyB1c2VUaGVtZSB9IGZyb20gXCJob29rcy91c2VUaGVtZVwiO1xuaW1wb3J0IHsgZ2V0SGFuZGxlU3R5bGUgfSBmcm9tIFwiLi9TbGlkZXJIYW5kbGUuc3R5bGVzXCI7XG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cmlhLWRpc2FibGVkPXtkaXNhYmxlZH1cbiAgICAgIHRhYkluZGV4PXtkaXNhYmxlZCA/IC0xIDogMH1cbiAgICAgIHN0eWxlPXt2ZXJ0aWNhbCA/IHsgYm90dG9tOiBgJHtwZXJjZW50fSVgIH0gOiB7IGxlZnQ6IGAke3BlcmNlbnR9JWAgfX1cbiAgICAgIGNzcz17W1xuICAgICAgICBnZXRIYW5kbGVTdHlsZSh7XG4gICAgICAgICAgdG9rZW5zLFxuICAgICAgICAgIHZlcnRpY2FsLFxuICAgICAgICAgIGNvbG9yQWN0aXZlOiBpc1NsaWRlckFjdGl2ZSxcbiAgICAgICAgICBzaXplQWN0aXZlLFxuICAgICAgICAgIGRpc2FibGVkLFxuICAgICAgICB9KSh0aGVtZSksXG4gICAgICAgIHN0eWxlcz8uaGFuZGxlPy4odG9rZW5zLCB0aGVtZSksXG4gICAgICBdfVxuICAgICAgey4uLmludGVyYWN0aW9uSGFuZGxlcnN9XG4gICAgICBvbktleURvd249e29uS2V5RG93bn1cbiAgICAgIG9uS2V5VXA9e29uS2V5VXB9XG4gICAgLz5cbiAgKTtcbn0pO1xuIl19 */"], ...interactionHandlers, onKeyDown, onKeyUp });
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
SliderHandle
|
|
40
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Interpolation } from '@emotion/react';
|
|
2
|
+
import { Theme } from 'themes';
|
|
3
|
+
import { SliderTokens } from '../../Slider.tokens';
|
|
4
|
+
export declare const getHandleStyle: ({ tokens, vertical, colorActive, sizeActive, disabled, }: {
|
|
5
|
+
tokens: SliderTokens;
|
|
6
|
+
vertical: boolean;
|
|
7
|
+
colorActive: boolean;
|
|
8
|
+
sizeActive: boolean;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
}) => (theme: Theme) => Interpolation;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { hex2Rgba } from "../../../../utils/color/index.js";
|
|
2
|
+
const getHandleStyle = ({
|
|
3
|
+
tokens,
|
|
4
|
+
vertical,
|
|
5
|
+
colorActive,
|
|
6
|
+
sizeActive,
|
|
7
|
+
disabled
|
|
8
|
+
}) => (theme) => {
|
|
9
|
+
const color = disabled ? tokens.sliderDisabled : colorActive ? tokens.sliderHover : tokens.sliderDefault;
|
|
10
|
+
const size = sizeActive && !disabled ? theme.x4 : 14;
|
|
11
|
+
const outline = sizeActive && !disabled ? `2px solid ${hex2Rgba(tokens.sliderDefault, 0.2)}` : void 0;
|
|
12
|
+
return {
|
|
13
|
+
position: "absolute",
|
|
14
|
+
width: size,
|
|
15
|
+
height: size,
|
|
16
|
+
borderRadius: tokens.sliderBorderRadius,
|
|
17
|
+
background: tokens.sliderDot,
|
|
18
|
+
border: `2px solid ${color}`,
|
|
19
|
+
transform: vertical ? "translate(-50%, 50%)" : "translate(-50%, -50%)",
|
|
20
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
21
|
+
boxSizing: "border-box",
|
|
22
|
+
outline,
|
|
23
|
+
outlineOffset: 0,
|
|
24
|
+
userSelect: "none",
|
|
25
|
+
touchAction: "none",
|
|
26
|
+
WebkitUserDrag: "none",
|
|
27
|
+
...vertical ? {
|
|
28
|
+
left: "50%"
|
|
29
|
+
} : {
|
|
30
|
+
top: "50%"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
getHandleStyle
|
|
36
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequiredDivHandlers } from '../../../../types';
|
|
2
|
+
import { SliderRendererBaseProps } from '../../Slider.types';
|
|
3
|
+
import { SliderInteractionHandleHandlers } from '../../hooks/useSliderInteractionState/useSliderInteractionState.types';
|
|
4
|
+
type DivKeyHandlers = RequiredDivHandlers<"onKeyDown" | "onKeyUp">;
|
|
5
|
+
export interface SliderHandleProps extends SliderRendererBaseProps, DivKeyHandlers {
|
|
6
|
+
index: number;
|
|
7
|
+
value: number;
|
|
8
|
+
min: number;
|
|
9
|
+
max: number;
|
|
10
|
+
percent: number;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
isSliderActive: boolean;
|
|
13
|
+
sizeActive: boolean;
|
|
14
|
+
interactionHandlers: SliderInteractionHandleHandlers;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SliderHandle } from './SliderHandle';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { identity } from "lodash-es";
|
|
3
|
+
import { Tooltip } from "../../../Tooltip/Tooltip.js";
|
|
4
|
+
import { tooltipStyles } from "./SliderHandleTooltip.styles.js";
|
|
5
|
+
const SliderHandleTooltip = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
value,
|
|
8
|
+
open,
|
|
9
|
+
tooltip,
|
|
10
|
+
vertical,
|
|
11
|
+
getTargetDOMNode,
|
|
12
|
+
"test-id": testId
|
|
13
|
+
} = props;
|
|
14
|
+
if (tooltip.formatter === null) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const formatter = tooltip.formatter ?? identity;
|
|
18
|
+
return /* @__PURE__ */ jsx(Tooltip, { styles: tooltipStyles, open, title: formatter(value), placement: tooltip.placement ?? (vertical ? "right" : "top"), getTargetDOMNode, getPopupContainer: tooltip.getPopupContainer, trigger: "hover", "test-id": testId });
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
SliderHandleTooltip
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SliderHandleTooltip } from './SliderHandleTooltip';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useMemo, useCallback } from "react";
|
|
3
|
+
import { useMergeRefs } from "@floating-ui/react";
|
|
4
|
+
import { getSliderTokens } from "../../Slider.tokens.js";
|
|
5
|
+
import { getRootStyle } from "../../Slider.styles.js";
|
|
6
|
+
import { validateStep, valueToPercent, tooltipSuffix, emptyTooltip } from "../../Slider.utils.js";
|
|
7
|
+
import { useTheme } from "../../../../hooks/useTheme/useTheme.js";
|
|
8
|
+
import { useComponentTokens } from "../../../ConfigProvider/hooks/useComponentTokens/useComponentTokens.js";
|
|
9
|
+
import { useControlledState } from "../../../../hooks/useControlledState/useControlledState.js";
|
|
10
|
+
import { useSliderInteractionState } from "../../hooks/useSliderInteractionState/useSliderInteractionState.js";
|
|
11
|
+
import { useSliderDrag } from "../../hooks/useSliderDrag/useSliderDrag.js";
|
|
12
|
+
import { useSliderKeyboard } from "../../hooks/useSliderKeyboard/useSliderKeyboard.js";
|
|
13
|
+
import { SliderRail } from "../SliderRail/SliderRail.js";
|
|
14
|
+
import { SliderTrack } from "../SliderTrack/SliderTrack.js";
|
|
15
|
+
import { SliderHandle } from "../SliderHandle/SliderHandle.js";
|
|
16
|
+
import { SliderHandleTooltip } from "../SliderHandleTooltip/SliderHandleTooltip.js";
|
|
17
|
+
const SliderInternal = forwardRef((props, ref) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const {
|
|
20
|
+
range,
|
|
21
|
+
value,
|
|
22
|
+
defaultValue,
|
|
23
|
+
min = 0,
|
|
24
|
+
max = 100,
|
|
25
|
+
step: stepProp = 1,
|
|
26
|
+
disabled = false,
|
|
27
|
+
orientation = "horizontal",
|
|
28
|
+
onChange,
|
|
29
|
+
onChangeComplete,
|
|
30
|
+
tooltip = emptyTooltip,
|
|
31
|
+
styles,
|
|
32
|
+
"test-id": testId
|
|
33
|
+
} = props;
|
|
34
|
+
const vertical = orientation === "vertical";
|
|
35
|
+
const step = validateStep(stepProp);
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
const tokens = useComponentTokens("Slider", getSliderTokens(theme));
|
|
38
|
+
const containerRef = useRef(null);
|
|
39
|
+
const handleRefs = useRef([null, null]);
|
|
40
|
+
const mergedRef = useMergeRefs([containerRef, ref]);
|
|
41
|
+
const [mergedValue, setLocalValue] = useControlledState(defaultValue, value);
|
|
42
|
+
const setHandleRefs = useMemo(() => [(el) => {
|
|
43
|
+
handleRefs.current[0] = el;
|
|
44
|
+
}, (el) => {
|
|
45
|
+
handleRefs.current[1] = el;
|
|
46
|
+
}], []);
|
|
47
|
+
const getHandleNodes = useMemo(() => [() => handleRefs.current[0], () => handleRefs.current[1]], []);
|
|
48
|
+
const handleChange = useCallback((v) => {
|
|
49
|
+
setLocalValue(v);
|
|
50
|
+
onChange == null ? void 0 : onChange(v);
|
|
51
|
+
}, [setLocalValue, onChange]);
|
|
52
|
+
const {
|
|
53
|
+
state: {
|
|
54
|
+
isRootHovered,
|
|
55
|
+
hoverIndex,
|
|
56
|
+
focusIndex,
|
|
57
|
+
keyboardFocusIndex
|
|
58
|
+
},
|
|
59
|
+
rootHandlers,
|
|
60
|
+
getHandleHandlers,
|
|
61
|
+
resetKeyboardFocus,
|
|
62
|
+
setHoverIndex
|
|
63
|
+
} = useSliderInteractionState();
|
|
64
|
+
const keyboardActiveIndex = range && (focusIndex === 0 || focusIndex === 1) ? focusIndex : 0;
|
|
65
|
+
const {
|
|
66
|
+
draggingValues,
|
|
67
|
+
activeIndex,
|
|
68
|
+
dragHandlers
|
|
69
|
+
} = useSliderDrag({
|
|
70
|
+
containerRef,
|
|
71
|
+
range,
|
|
72
|
+
min,
|
|
73
|
+
max,
|
|
74
|
+
step,
|
|
75
|
+
vertical,
|
|
76
|
+
disabled,
|
|
77
|
+
value: mergedValue,
|
|
78
|
+
onChange: handleChange,
|
|
79
|
+
onChangeComplete,
|
|
80
|
+
onDragStart: (source) => {
|
|
81
|
+
if (source === "handle") {
|
|
82
|
+
resetKeyboardFocus();
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
onDragEnd: (hoveringHandleIndex) => {
|
|
86
|
+
setHoverIndex(hoveringHandleIndex);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const keyboardHandlers = useSliderKeyboard({
|
|
90
|
+
range,
|
|
91
|
+
min,
|
|
92
|
+
max,
|
|
93
|
+
step,
|
|
94
|
+
disabled,
|
|
95
|
+
value: mergedValue,
|
|
96
|
+
activeIndex: keyboardActiveIndex,
|
|
97
|
+
onChange: handleChange,
|
|
98
|
+
onChangeComplete
|
|
99
|
+
});
|
|
100
|
+
const displayValues = draggingValues ?? mergedValue;
|
|
101
|
+
const isSliderActive = isRootHovered || keyboardFocusIndex !== null || draggingValues !== null;
|
|
102
|
+
const percents = displayValues.map((v) => valueToPercent(v, min, max));
|
|
103
|
+
const trackStart = range ? percents[0] : 0;
|
|
104
|
+
const trackEnd = range ? percents[1] : percents[0];
|
|
105
|
+
return /* @__PURE__ */ jsxs("div", { ref: mergedRef, role: "group", "test-id": testId, css: [getRootStyle({
|
|
106
|
+
tokens,
|
|
107
|
+
vertical,
|
|
108
|
+
disabled
|
|
109
|
+
})(theme), (_a = styles == null ? void 0 : styles.root) == null ? void 0 : _a.call(styles, tokens, theme), process.env.NODE_ENV === "production" ? "" : ";label:SliderInternal;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9idWlsZHMvZnJvbnRlbmQvbGlicy91aS1raXQvc3JjL2NvbXBvbmVudHMvU2xpZGVyL2NvbXBvbmVudHMvU2xpZGVySW50ZXJuYWwvU2xpZGVySW50ZXJuYWwudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXVITSIsImZpbGUiOiIvYnVpbGRzL2Zyb250ZW5kL2xpYnMvdWkta2l0L3NyYy9jb21wb25lbnRzL1NsaWRlci9jb21wb25lbnRzL1NsaWRlckludGVybmFsL1NsaWRlckludGVybmFsLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGZvcndhcmRSZWYsIHVzZUNhbGxiYWNrLCB1c2VNZW1vLCB1c2VSZWYgfSBmcm9tIFwicmVhY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Y3RpdmUgJiYgIWRpc2FibGVkfVxuICAgICAgICBzdHlsZXM9e3N0eWxlc31cbiAgICAgICAgdGVzdC1pZD17dGVzdElkfVxuICAgICAgLz5cbiAgICAgIDxTbGlkZXJUcmFja1xuICAgICAgICB0b2tlbnM9e3Rva2Vuc31cbiAgICAgICAgdmVydGljYWw9e3ZlcnRpY2FsfVxuICAgICAgICBkaXNhYmxlZD17ZGlzYWJsZWR9XG4gICAgICAgIGlzQWN0aXZlPXtpc1NsaWRlckFjdGl2ZX1cbiAgICAgICAgc3RhcnRQZXJjZW50PXt0cmFja1N0YXJ0fVxuICAgICAgICBlbmRQZXJjZW50PXt0cmFja0VuZH1cbiAgICAgICAgc3R5bGVzPXtzdHlsZXN9XG4gICAgICAgIHRlc3QtaWQ9e3Rlc3RJZH1cbiAgICAgIC8+XG4gICAgICB7ZGlzcGxheVZhbHVlcy5tYXAoKHYsIGkpID0+IChcbiAgICAgICAgPFNsaWRlckhhbmRsZVxuICAgICAgICAgIGtleT17aX1cbiAgICAgICAgICByZWY9e3NldEhhbmRsZVJlZnNbaV19XG4gICAgICAgICAgaW5kZXg9e2l9XG4gICAgICAgICAgdmFsdWU9e3Z9XG4gICAgICAgICAgbWluPXttaW59XG4gICAgICAgICAgbWF4PXttYXh9XG4gICAgICAgICAgcGVyY2VudD17cGVyY2VudHNbaV19XG4gICAgICAgICAgdmVydGljYWw9e3ZlcnRpY2FsfVxuICAgICAgICAgIGRpc2FibGVkPXtkaXNhYmxlZH1cbiAgICAgICAgICBpc1NsaWRlckFjdGl2ZT17aXNTbGlkZXJBY3RpdmV9XG4gICAgICAgICAgc2l6ZUFjdGl2ZT17YWN0aXZlSW5kZXggPT09IGkgfHwgaG92ZXJJbmRleCA9PT0gaSB8fCBrZXlib2FyZEZvY3VzSW5kZXggPT09IGl9XG4gICAgICAgICAgdG9rZW5zPXt0b2tlbnN9XG4gICAgICAgICAgc3R5bGVzPXtzdHlsZXN9XG4gICAgICAgICAgdGVzdC1pZD17dGVzdElkfVxuICAgICAgICAgIGludGVyYWN0aW9uSGFuZGxlcnM9e2dldEhhbmRsZUhhbmRsZXJzKGkpfVxuICAgICAgICAgIHsuLi5rZXlib2FyZEhhbmRsZXJzfVxuICAgICAgICAvPlxuICAgICAgKSl9XG4gICAgICB7ZGlzcGxheVZhbHVlcy5tYXAoKHYsIGkpID0+IHtcbiAgICAgICAgY29uc3Qgb3BlbiA9XG4gICAgICAgICAgdG9vbHRpcC5vcGVuID8/XG4gICAgICAgICAgKGhvdmVySW5kZXggPT09IGkgfHxcbiAgICAgICAgICAgIGtleWJvYXJkRm9jdXNJbmRleCA9PT0gaSB8fFxuICAgICAgICAgICAgKGRyYWdnaW5nVmFsdWVzICE9PSBudWxsICYmIGFjdGl2ZUluZGV4ID09PSBpKSk7XG5cbiAgICAgICAgcmV0dXJuIChcbiAgICAgICAgICA8U2xpZGVySGFuZGxlVG9vbHRpcFxuICAgICAgICAgICAga2V5PXtgdG9vbHRpcC0ke2l9YH1cbiAgICAgICAgICAgIHZhbHVlPXt2fVxuICAgICAgICAgICAgb3Blbj17b3Blbn1cbiAgICAgICAgICAgIHRvb2x0aXA9e3Rvb2x0aXB9XG4gICAgICAgICAgICB2ZXJ0aWNhbD17dmVydGljYWx9XG4gICAgICAgICAgICBnZXRUYXJnZXRET01Ob2RlPXtnZXRIYW5kbGVOb2Rlc1tpXX1cbiAgICAgICAgICAgIHRlc3QtaWQ9e2Ake3Rlc3RJZH0ke3Rvb2x0aXBTdWZmaXh9JHtpfWB9XG4gICAgICAgICAgLz5cbiAgICAgICAgKTtcbiAgICAgIH0pfVxuICAgIDwvZGl2PlxuICApO1xufSk7XG4iXX0= */"], ...rootHandlers, ...dragHandlers, children: [
|
|
110
|
+
/* @__PURE__ */ jsx(SliderRail, { tokens, vertical, isActive: isSliderActive && !disabled, styles, "test-id": testId }),
|
|
111
|
+
/* @__PURE__ */ jsx(SliderTrack, { tokens, vertical, disabled, isActive: isSliderActive, startPercent: trackStart, endPercent: trackEnd, styles, "test-id": testId }),
|
|
112
|
+
displayValues.map((v, i) => /* @__PURE__ */ jsx(SliderHandle, { ref: setHandleRefs[i], index: i, value: v, min, max, percent: percents[i], vertical, disabled, isSliderActive, sizeActive: activeIndex === i || hoverIndex === i || keyboardFocusIndex === i, tokens, styles, "test-id": testId, interactionHandlers: getHandleHandlers(i), ...keyboardHandlers }, i)),
|
|
113
|
+
displayValues.map((v, i) => {
|
|
114
|
+
const open = tooltip.open ?? (hoverIndex === i || keyboardFocusIndex === i || draggingValues !== null && activeIndex === i);
|
|
115
|
+
return /* @__PURE__ */ jsx(SliderHandleTooltip, { value: v, open, tooltip, vertical, getTargetDOMNode: getHandleNodes[i], "test-id": `${testId}${tooltipSuffix}${i}` }, `tooltip-${i}`);
|
|
116
|
+
})
|
|
117
|
+
] });
|
|
118
|
+
});
|
|
119
|
+
export {
|
|
120
|
+
SliderInternal
|
|
121
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SliderStyles, SliderTooltipProps } from '../../Slider.types';
|
|
2
|
+
export type SliderValues = [number] | [number, number];
|
|
3
|
+
export declare const isRangeValues: (v: SliderValues) => v is [number, number];
|
|
4
|
+
/**
|
|
5
|
+
* Внутренний props для общей реализации Slider'а.
|
|
6
|
+
* Внешний API (`SingleSliderProps`/`RangeSliderProps`) адаптируется к этому
|
|
7
|
+
* виду в `Slider.tsx` — value/defaultValue приводятся к tuple длины 1 (single)
|
|
8
|
+
* или 2 (range), onChange/onChangeComplete оборачиваются.
|
|
9
|
+
*/
|
|
10
|
+
export interface SliderInternalProps {
|
|
11
|
+
range: boolean;
|
|
12
|
+
value?: SliderValues;
|
|
13
|
+
defaultValue: SliderValues;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
step?: number | null;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
orientation?: "horizontal" | "vertical";
|
|
19
|
+
tooltip?: SliderTooltipProps;
|
|
20
|
+
styles?: SliderStyles;
|
|
21
|
+
"test-id"?: string;
|
|
22
|
+
onChange?: (value: SliderValues) => void;
|
|
23
|
+
onChangeComplete?: (value: SliderValues) => void;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SliderInternal } from './SliderInternal';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { getRailStyle } from "./SliderRail.styles.js";
|
|
3
|
+
import { railSuffix } from "../../Slider.utils.js";
|
|
4
|
+
import { useTheme } from "../../../../hooks/useTheme/useTheme.js";
|
|
5
|
+
const SliderRail = (props) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const {
|
|
8
|
+
tokens,
|
|
9
|
+
vertical,
|
|
10
|
+
isActive,
|
|
11
|
+
styles,
|
|
12
|
+
"test-id": testId
|
|
13
|
+
} = props;
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
return /* @__PURE__ */ jsx("div", { "test-id": `${testId ?? ""}${railSuffix}`, css: [getRailStyle({
|
|
16
|
+
tokens,
|
|
17
|
+
vertical,
|
|
18
|
+
active: isActive
|
|
19
|
+
})(theme), (_a = styles == null ? void 0 : styles.rail) == null ? void 0 : _a.call(styles, tokens, theme), process.env.NODE_ENV === "production" ? "" : ";label:SliderRail;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9idWlsZHMvZnJvbnRlbmQvbGlicy91aS1raXQvc3JjL2NvbXBvbmVudHMvU2xpZGVyL2NvbXBvbmVudHMvU2xpZGVyUmFpbC9TbGlkZXJSYWlsLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFhTSIsImZpbGUiOiIvYnVpbGRzL2Zyb250ZW5kL2xpYnMvdWkta2l0L3NyYy9jb21wb25lbnRzL1NsaWRlci9jb21wb25lbnRzL1NsaWRlclJhaWwvU2xpZGVyUmFpbC50c3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IEZDIH0gZnJvbSBcInJlYWN0XCI7XG5pbXBvcnQgeyB1c2VUaGVtZSB9IGZyb20gXCJob29rcy91c2VUaGVtZVwiO1xuaW1wb3J0IHsgZ2V0UmFpbFN0eWxlIH0gZnJvbSBcIi4vU2xpZGVyUmFpbC5zdHlsZXNcIjtcbmltcG9ydCB7IHJhaWxTdWZmaXggfSBmcm9tIFwiLi4vLi4vU2xpZGVyLnV0aWxzXCI7XG5pbXBvcnQgdHlwZSB7IFNsaWRlclJhaWxQcm9wcyB9IGZyb20gXCIuL1NsaWRlclJhaWwudHlwZXNcIjtcblxuZXhwb3J0IGNvbnN0IFNsaWRlclJhaWw6IEZDPFNsaWRlclJhaWxQcm9wcz4gPSAocHJvcHMpID0+IHtcbiAgY29uc3QgeyB0b2tlbnMsIHZlcnRpY2FsLCBpc0FjdGl2ZSwgc3R5bGVzLCBcInRlc3QtaWRcIjogdGVzdElkIH0gPSBwcm9wcztcbiAgY29uc3QgdGhlbWUgPSB1c2VUaGVtZSgpO1xuXG4gIHJldHVybiAoXG4gICAgPGRpdlxuICAgICAgdGVzdC1pZD17YCR7dGVzdElkID8/IFwiXCJ9JHtyYWlsU3VmZml4fWB9XG4gICAgICBjc3M9e1tcbiAgICAgICAgZ2V0UmFpbFN0eWxlKHsgdG9rZW5zLCB2ZXJ0aWNhbCwgYWN0aXZlOiBpc0FjdGl2ZSB9KSh0aGVtZSksXG4gICAgICAgIHN0eWxlcz8ucmFpbD8uKHRva2VucywgdGhlbWUpLFxuICAgICAgXX1cbiAgICAvPlxuICApO1xufTtcbiJdfQ== */"] });
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
SliderRail
|
|
23
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Interpolation } from '@emotion/react';
|
|
2
|
+
import { Theme } from 'themes';
|
|
3
|
+
import { SliderTokens } from '../../Slider.tokens';
|
|
4
|
+
export declare const getRailStyle: ({ tokens, vertical, active }: {
|
|
5
|
+
tokens: SliderTokens;
|
|
6
|
+
vertical: boolean;
|
|
7
|
+
active: boolean;
|
|
8
|
+
}) => (theme: Theme) => Interpolation;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const getRailStyle = ({
|
|
2
|
+
tokens,
|
|
3
|
+
vertical,
|
|
4
|
+
active
|
|
5
|
+
}) => (theme) => {
|
|
6
|
+
return {
|
|
7
|
+
width: vertical ? theme.x1 : "100%",
|
|
8
|
+
height: vertical ? "100%" : theme.x1,
|
|
9
|
+
borderRadius: tokens.sliderBorderRadius,
|
|
10
|
+
background: active ? tokens.sliderRailHover : tokens.sliderRail
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
getRailStyle
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SliderRail } from './SliderRail';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { getTrackStyle } from "./SliderTrack.styles.js";
|
|
3
|
+
import { trackSuffix } from "../../Slider.utils.js";
|
|
4
|
+
import { useTheme } from "../../../../hooks/useTheme/useTheme.js";
|
|
5
|
+
const SliderTrack = (props) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const {
|
|
8
|
+
tokens,
|
|
9
|
+
vertical,
|
|
10
|
+
disabled,
|
|
11
|
+
isActive,
|
|
12
|
+
startPercent,
|
|
13
|
+
endPercent,
|
|
14
|
+
styles,
|
|
15
|
+
"test-id": testId
|
|
16
|
+
} = props;
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
return /* @__PURE__ */ jsx("div", { "test-id": `${testId ?? ""}${trackSuffix}`, css: [getTrackStyle({
|
|
19
|
+
tokens,
|
|
20
|
+
startPercent,
|
|
21
|
+
endPercent,
|
|
22
|
+
vertical,
|
|
23
|
+
disabled,
|
|
24
|
+
active: isActive
|
|
25
|
+
})(theme), (_a = styles == null ? void 0 : styles.track) == null ? void 0 : _a.call(styles, tokens, theme), process.env.NODE_ENV === "production" ? "" : ";label:SliderTrack;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9idWlsZHMvZnJvbnRlbmQvbGlicy91aS1raXQvc3JjL2NvbXBvbmVudHMvU2xpZGVyL2NvbXBvbmVudHMvU2xpZGVyVHJhY2svU2xpZGVyVHJhY2sudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXNCTSIsImZpbGUiOiIvYnVpbGRzL2Zyb250ZW5kL2xpYnMvdWkta2l0L3NyYy9jb21wb25lbnRzL1NsaWRlci9jb21wb25lbnRzL1NsaWRlclRyYWNrL1NsaWRlclRyYWNrLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRkMgfSBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCB7IHVzZVRoZW1lIH0gZnJvbSBcImhvb2tzL3VzZVRoZW1lXCI7XG5pbXBvcnQgeyBnZXRUcmFja1N0eWxlIH0gZnJvbSBcIi4vU2xpZGVyVHJhY2suc3R5bGVzXCI7XG5pbXBvcnQgeyB0cmFja1N1ZmZpeCB9IGZyb20gXCIuLi8uLi9TbGlkZXIudXRpbHNcIjtcbmltcG9ydCB0eXBlIHsgU2xpZGVyVHJhY2tQcm9wcyB9IGZyb20gXCIuL1NsaWRlclRyYWNrLnR5cGVzXCI7XG5cbmV4cG9ydCBjb25zdCBTbGlkZXJUcmFjazogRkM8U2xpZGVyVHJhY2tQcm9wcz4gPSAocHJvcHMpID0+IHtcbiAgY29uc3Qge1xuICAgIHRva2VucyxcbiAgICB2ZXJ0aWNhbCxcbiAgICBkaXNhYmxlZCxcbiAgICBpc0FjdGl2ZSxcbiAgICBzdGFydFBlcmNlbnQsXG4gICAgZW5kUGVyY2VudCxcbiAgICBzdHlsZXMsXG4gICAgXCJ0ZXN0LWlkXCI6IHRlc3RJZCxcbiAgfSA9IHByb3BzO1xuICBjb25zdCB0aGVtZSA9IHVzZVRoZW1lKCk7XG5cbiAgcmV0dXJuIChcbiAgICA8ZGl2XG4gICAgICB0ZXN0LWlkPXtgJHt0ZXN0SWQgPz8gXCJcIn0ke3RyYWNrU3VmZml4fWB9XG4gICAgICBjc3M9e1tcbiAgICAgICAgZ2V0VHJhY2tTdHlsZSh7XG4gICAgICAgICAgdG9rZW5zLFxuICAgICAgICAgIHN0YXJ0UGVyY2VudCxcbiAgICAgICAgICBlbmRQZXJjZW50LFxuICAgICAgICAgIHZlcnRpY2FsLFxuICAgICAgICAgIGRpc2FibGVkLFxuICAgICAgICAgIGFjdGl2ZTogaXNBY3RpdmUsXG4gICAgICAgIH0pKHRoZW1lKSxcbiAgICAgICAgc3R5bGVzPy50cmFjaz8uKHRva2VucywgdGhlbWUpLFxuICAgICAgXX1cbiAgICAvPlxuICApO1xufTtcbiJdfQ== */"] });
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
SliderTrack
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Interpolation } from '@emotion/react';
|
|
2
|
+
import { Theme } from 'themes';
|
|
3
|
+
import { SliderTokens } from '../../Slider.tokens';
|
|
4
|
+
export declare const getTrackStyle: ({ tokens, startPercent, endPercent, vertical, disabled, active, }: {
|
|
5
|
+
tokens: SliderTokens;
|
|
6
|
+
startPercent: number;
|
|
7
|
+
endPercent: number;
|
|
8
|
+
vertical: boolean;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
active: boolean;
|
|
11
|
+
}) => (theme: Theme) => Interpolation;
|