@shoplflow/base 0.34.0 → 0.35.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/index.cjs +211 -9
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +210 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6583,12 +6583,12 @@ var Skeleton = ({ styleVar = "rectangle", width = "50px", height = "20px" }) =>
|
|
|
6583
6583
|
exports.Skeleton = Skeleton;
|
|
6584
6584
|
|
|
6585
6585
|
// src/components/Slider/Slider.types.ts
|
|
6586
|
-
|
|
6586
|
+
exports.SLIDER_Z_INDEX = {
|
|
6587
6587
|
THUMB_BUTTON: 10
|
|
6588
6588
|
};
|
|
6589
6589
|
|
|
6590
6590
|
// src/components/Slider/Slider.styled.ts
|
|
6591
|
-
styled6__default.default.div`
|
|
6591
|
+
var SliderContainer = styled6__default.default.div`
|
|
6592
6592
|
position: relative;
|
|
6593
6593
|
width: 100%;
|
|
6594
6594
|
padding: 0 12px;
|
|
@@ -6601,14 +6601,14 @@ styled6__default.default.div`
|
|
|
6601
6601
|
cursor: not-allowed;
|
|
6602
6602
|
`}
|
|
6603
6603
|
`;
|
|
6604
|
-
styled6__default.default.div`
|
|
6604
|
+
var SliderTrack = styled6__default.default.div`
|
|
6605
6605
|
width: 100%; // SliderContainer의 padding 영역 내에서 100%
|
|
6606
6606
|
height: 24px;
|
|
6607
6607
|
position: relative;
|
|
6608
6608
|
overflow: visible;
|
|
6609
6609
|
margin: 0;
|
|
6610
6610
|
`;
|
|
6611
|
-
styled6__default.default.div`
|
|
6611
|
+
var SelectedTrack = styled6__default.default.div`
|
|
6612
6612
|
position: absolute;
|
|
6613
6613
|
height: 100%;
|
|
6614
6614
|
border-radius: 16px;
|
|
@@ -6617,7 +6617,7 @@ styled6__default.default.div`
|
|
|
6617
6617
|
left: ${({ startPosition }) => startPosition};
|
|
6618
6618
|
width: ${({ width }) => width};
|
|
6619
6619
|
`;
|
|
6620
|
-
styled6__default.default.div`
|
|
6620
|
+
var StepsContainer = styled6__default.default.div`
|
|
6621
6621
|
position: absolute;
|
|
6622
6622
|
top: 0;
|
|
6623
6623
|
left: 0;
|
|
@@ -6627,7 +6627,7 @@ styled6__default.default.div`
|
|
|
6627
6627
|
align-items: center;
|
|
6628
6628
|
pointer-events: none;
|
|
6629
6629
|
`;
|
|
6630
|
-
styled6__default.default.div`
|
|
6630
|
+
var Steps = styled6__default.default.div`
|
|
6631
6631
|
position: absolute;
|
|
6632
6632
|
width: 8px;
|
|
6633
6633
|
height: 8px;
|
|
@@ -6639,16 +6639,16 @@ styled6__default.default.div`
|
|
|
6639
6639
|
height: 16px;
|
|
6640
6640
|
}
|
|
6641
6641
|
`;
|
|
6642
|
-
styled6__default.default.button`
|
|
6642
|
+
var ThumbButton = styled6__default.default.button`
|
|
6643
6643
|
position: absolute;
|
|
6644
6644
|
top: 50%;
|
|
6645
6645
|
transform: translate(-50%, -50%);
|
|
6646
6646
|
border: none;
|
|
6647
6647
|
padding: 0;
|
|
6648
6648
|
outline: none;
|
|
6649
|
-
z-index: ${SLIDER_Z_INDEX.THUMB_BUTTON}; // thumb를 track보다 위에 위치시킴
|
|
6649
|
+
z-index: ${exports.SLIDER_Z_INDEX.THUMB_BUTTON}; // thumb를 track보다 위에 위치시킴
|
|
6650
6650
|
`;
|
|
6651
|
-
styled6__default.default.div`
|
|
6651
|
+
var ThumbCircle = styled6__default.default.div`
|
|
6652
6652
|
width: 16px;
|
|
6653
6653
|
height: 16px;
|
|
6654
6654
|
border-radius: 50%;
|
|
@@ -6669,6 +6669,208 @@ styled6__default.default.div`
|
|
|
6669
6669
|
}
|
|
6670
6670
|
`}
|
|
6671
6671
|
`;
|
|
6672
|
+
|
|
6673
|
+
// src/components/Slider/sliderUtils.ts
|
|
6674
|
+
var getAdjustedValue = (value, bounds, step) => {
|
|
6675
|
+
const { min, max } = bounds;
|
|
6676
|
+
const snappedValue = Math.round((value - min) / step) * step + min;
|
|
6677
|
+
return Math.max(min, Math.min(max, snappedValue));
|
|
6678
|
+
};
|
|
6679
|
+
var getPositionPercentage = (index, selectedRange, bounds) => {
|
|
6680
|
+
const { min, max } = bounds;
|
|
6681
|
+
return Math.trunc((selectedRange[index] - min) / (max - min) * 100);
|
|
6682
|
+
};
|
|
6683
|
+
var getValueFromPercentage = (percentage, bounds, step) => {
|
|
6684
|
+
const { min, max } = bounds;
|
|
6685
|
+
const rawValue = min + percentage / 100 * (max - min);
|
|
6686
|
+
return getAdjustedValue(rawValue, bounds, step);
|
|
6687
|
+
};
|
|
6688
|
+
var generateSteps = (bounds, step, maxSteps = 21) => {
|
|
6689
|
+
const { min, max } = bounds;
|
|
6690
|
+
const totalSteps = Math.floor((max - min) / step) + 1;
|
|
6691
|
+
const stepInterval = totalSteps > maxSteps ? Math.ceil(totalSteps / maxSteps) : 1;
|
|
6692
|
+
const tickValues = [];
|
|
6693
|
+
for (let i = 0; i < totalSteps; i += stepInterval) {
|
|
6694
|
+
const value = min + i * step;
|
|
6695
|
+
if (value <= max) {
|
|
6696
|
+
tickValues.push(value);
|
|
6697
|
+
}
|
|
6698
|
+
}
|
|
6699
|
+
if (tickValues.length > 0 && tickValues[tickValues.length - 1] !== max) {
|
|
6700
|
+
tickValues.push(max);
|
|
6701
|
+
}
|
|
6702
|
+
return tickValues;
|
|
6703
|
+
};
|
|
6704
|
+
var validateRange = ({
|
|
6705
|
+
min,
|
|
6706
|
+
max,
|
|
6707
|
+
defaultRange
|
|
6708
|
+
}) => {
|
|
6709
|
+
if (defaultRange.min < min || defaultRange.max > max) {
|
|
6710
|
+
throw new Error("defaultRange\uAC00 Slider\uC758 \uC804\uCCB4 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0A9\uB2C8\uB2E4.");
|
|
6711
|
+
}
|
|
6712
|
+
if (defaultRange.min > defaultRange.max) {
|
|
6713
|
+
throw new Error("defaultRange\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uD655\uC778\uD574\uC8FC\uC138\uC694.");
|
|
6714
|
+
}
|
|
6715
|
+
};
|
|
6716
|
+
var validateStep = ({ min, max, step }) => {
|
|
6717
|
+
if (step <= 0) {
|
|
6718
|
+
throw new Error("step\uC740 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4.");
|
|
6719
|
+
}
|
|
6720
|
+
if (step > max || step < min || step > max - min) {
|
|
6721
|
+
throw new Error("step\uC774 Slider\uC758 \uC804\uCCB4 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0A9\uB2C8\uB2E4.");
|
|
6722
|
+
}
|
|
6723
|
+
};
|
|
6724
|
+
var SliderSteps = ({ bounds, step, maxSteps = 21 }) => {
|
|
6725
|
+
const steps = generateSteps(bounds, step, maxSteps);
|
|
6726
|
+
const { min, max } = bounds;
|
|
6727
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StepsContainer, { children: steps.map((stepValue) => {
|
|
6728
|
+
const position = (stepValue - min) / (max - min) * 100;
|
|
6729
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6730
|
+
Steps,
|
|
6731
|
+
{
|
|
6732
|
+
style: {
|
|
6733
|
+
left: `${position}%`
|
|
6734
|
+
}
|
|
6735
|
+
},
|
|
6736
|
+
stepValue
|
|
6737
|
+
);
|
|
6738
|
+
}) });
|
|
6739
|
+
};
|
|
6740
|
+
var SliderThumbs = ({
|
|
6741
|
+
positions,
|
|
6742
|
+
values,
|
|
6743
|
+
isDisabled,
|
|
6744
|
+
selectedColor,
|
|
6745
|
+
onMouseDown
|
|
6746
|
+
}) => {
|
|
6747
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: positions.map((position, index) => /* @__PURE__ */ jsxRuntime.jsx(ThumbButton, { style: { left: `${position}%` }, onMouseDown: onMouseDown(index), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6748
|
+
exports.Tooltip,
|
|
6749
|
+
{
|
|
6750
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(ThumbCircle, { isDisabled, selectedColor }),
|
|
6751
|
+
popper: !isDisabled && /* @__PURE__ */ jsxRuntime.jsx(exports.Tooltip.Content, { content: Math.abs(values[index]).toString() })
|
|
6752
|
+
}
|
|
6753
|
+
) }, index)) });
|
|
6754
|
+
};
|
|
6755
|
+
var useSlider = ({ bounds, step, defaultRange, handleRange, isDisabled = false }) => {
|
|
6756
|
+
const { min, max } = bounds;
|
|
6757
|
+
validateRange({ min, max, defaultRange });
|
|
6758
|
+
validateStep({ min, max, step });
|
|
6759
|
+
const [range, setRange] = React3.useState([defaultRange.min, defaultRange.max]);
|
|
6760
|
+
const trackRef = React3.useRef(null);
|
|
6761
|
+
const updateRange = React3.useCallback(
|
|
6762
|
+
(index, newValue) => {
|
|
6763
|
+
setRange((prev) => {
|
|
6764
|
+
const newRange = [...prev];
|
|
6765
|
+
if (index === 0) {
|
|
6766
|
+
newRange[0] = Math.min(newValue, newRange[1]);
|
|
6767
|
+
} else if (index === 1) {
|
|
6768
|
+
newRange[1] = Math.max(newValue, newRange[0]);
|
|
6769
|
+
}
|
|
6770
|
+
return newRange;
|
|
6771
|
+
});
|
|
6772
|
+
handleRange == null ? void 0 : handleRange({ min: range[0], max: range[1] });
|
|
6773
|
+
},
|
|
6774
|
+
[range, handleRange]
|
|
6775
|
+
);
|
|
6776
|
+
const handleMouseDown = React3.useCallback(
|
|
6777
|
+
(index) => (e) => {
|
|
6778
|
+
if (isDisabled) {
|
|
6779
|
+
return;
|
|
6780
|
+
}
|
|
6781
|
+
e.preventDefault();
|
|
6782
|
+
const handleMouseMove = (moveEvent) => {
|
|
6783
|
+
if (!trackRef.current) {
|
|
6784
|
+
return;
|
|
6785
|
+
}
|
|
6786
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
6787
|
+
const offsetX = moveEvent.clientX - rect.left;
|
|
6788
|
+
const percentage = Math.min(Math.max(offsetX / rect.width * 100, 0), 100);
|
|
6789
|
+
const newValue = getValueFromPercentage(percentage, { min, max }, step);
|
|
6790
|
+
updateRange(index, newValue);
|
|
6791
|
+
};
|
|
6792
|
+
const handleMouseUp = () => {
|
|
6793
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
6794
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
6795
|
+
};
|
|
6796
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
6797
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
6798
|
+
},
|
|
6799
|
+
[isDisabled, min, max, step, updateRange]
|
|
6800
|
+
);
|
|
6801
|
+
const handleClickTrack = React3.useCallback(
|
|
6802
|
+
(e) => {
|
|
6803
|
+
if (isDisabled || !trackRef.current) {
|
|
6804
|
+
return;
|
|
6805
|
+
}
|
|
6806
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
6807
|
+
const offsetX = e.clientX - rect.left;
|
|
6808
|
+
const percentage = offsetX / rect.width * 100;
|
|
6809
|
+
const newValue = getValueFromPercentage(percentage, { min, max }, step);
|
|
6810
|
+
const distanceToStart = Math.abs(getPositionPercentage(0, range, { min, max }) - percentage);
|
|
6811
|
+
const distanceToEnd = Math.abs(getPositionPercentage(1, range, { min, max }) - percentage);
|
|
6812
|
+
if (distanceToStart <= distanceToEnd) {
|
|
6813
|
+
updateRange(0, newValue);
|
|
6814
|
+
} else {
|
|
6815
|
+
updateRange(1, newValue);
|
|
6816
|
+
}
|
|
6817
|
+
},
|
|
6818
|
+
[isDisabled, min, max, step, range, updateRange]
|
|
6819
|
+
);
|
|
6820
|
+
const startPosition = getPositionPercentage(0, range, { min, max });
|
|
6821
|
+
const endPosition = getPositionPercentage(1, range, { min, max });
|
|
6822
|
+
const width = endPosition - startPosition;
|
|
6823
|
+
return {
|
|
6824
|
+
range,
|
|
6825
|
+
trackRef,
|
|
6826
|
+
handleMouseDown,
|
|
6827
|
+
handleClickTrack,
|
|
6828
|
+
positions: {
|
|
6829
|
+
start: startPosition,
|
|
6830
|
+
end: endPosition,
|
|
6831
|
+
width
|
|
6832
|
+
}
|
|
6833
|
+
};
|
|
6834
|
+
};
|
|
6835
|
+
var Slider = ({
|
|
6836
|
+
min = 0,
|
|
6837
|
+
max,
|
|
6838
|
+
step = 1,
|
|
6839
|
+
defaultRange = { min: 0, max: 0 },
|
|
6840
|
+
handleRange,
|
|
6841
|
+
isDisabled = false,
|
|
6842
|
+
selectedColor = "shopl300"
|
|
6843
|
+
}) => {
|
|
6844
|
+
const { range, trackRef, handleMouseDown, handleClickTrack, positions } = useSlider({
|
|
6845
|
+
bounds: { min, max },
|
|
6846
|
+
step,
|
|
6847
|
+
defaultRange,
|
|
6848
|
+
handleRange,
|
|
6849
|
+
isDisabled
|
|
6850
|
+
});
|
|
6851
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SliderContainer, { isDisabled, children: /* @__PURE__ */ jsxRuntime.jsxs(SliderTrack, { ref: trackRef, onClick: handleClickTrack, children: [
|
|
6852
|
+
/* @__PURE__ */ jsxRuntime.jsx(SliderSteps, { bounds: { min, max }, step, range }),
|
|
6853
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6854
|
+
SelectedTrack,
|
|
6855
|
+
{
|
|
6856
|
+
selectedColor,
|
|
6857
|
+
startPosition: `calc(${positions.start}% - 12px)`,
|
|
6858
|
+
width: `calc(${positions.width}% + 24px)`
|
|
6859
|
+
}
|
|
6860
|
+
),
|
|
6861
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6862
|
+
SliderThumbs,
|
|
6863
|
+
{
|
|
6864
|
+
positions: [positions.start, positions.end],
|
|
6865
|
+
isDisabled,
|
|
6866
|
+
selectedColor,
|
|
6867
|
+
onMouseDown: handleMouseDown,
|
|
6868
|
+
values: range
|
|
6869
|
+
}
|
|
6870
|
+
)
|
|
6871
|
+
] }) });
|
|
6872
|
+
};
|
|
6873
|
+
exports.Slider = Slider;
|
|
6672
6874
|
var SpaceMarginWrapper = styled6__default.default(framerMotion.motion.div)`
|
|
6673
6875
|
position: relative;
|
|
6674
6876
|
display: flex;
|
package/dist/index.d.cts
CHANGED
|
@@ -1576,5 +1576,14 @@ interface SliderProps {
|
|
|
1576
1576
|
*/
|
|
1577
1577
|
selectedColor?: ColorTokens;
|
|
1578
1578
|
}
|
|
1579
|
+
declare type SliderBounds = {
|
|
1580
|
+
min: number;
|
|
1581
|
+
max: number;
|
|
1582
|
+
};
|
|
1583
|
+
declare const SLIDER_Z_INDEX: {
|
|
1584
|
+
readonly THUMB_BUTTON: 10;
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
declare const Slider: React__default.FC<SliderProps>;
|
|
1579
1588
|
|
|
1580
|
-
export { AnnualDatepicker, AnnualDatepickerProps, AsProp, Avatar, AvatarOptionProps, AvatarProps, AvatarSizeVariantType, AvatarSizeVariants, BackDropOptionProps, BackDropProps, BorderRadiusTokens, BoxShadowTokens, Button, ButtonComponent, ButtonOptionProps, ButtonProps, ButtonSizeVariantType, ButtonSizeVariants, ButtonStyleVariantType, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout, CalloutOptionProps, CalloutProps, CalloutType, CalloutTypes, Checkbox, CheckboxOptionProps, CheckboxProps, CheckboxStyleVariantType, CheckboxStyleVariants, ChipButton, ChipButtonOptionProps, ChipButtonProps, ChipButtonSizeVariantType, ChipButtonSizeVariants, ChipButtonStyleVariantType, ChipButtonStyleVariants, ChipToggle, ChipToggleOptionProps, ChipToggleProps, ChipToggleSizeVariantType, ChipToggleSizeVariants, ChipToggleStyleVariantType, ChipToggleStyleVariants, ColorTokens, DangerouslySetInnerHTML, DayCalendarType, DayDatepicker, DayDatepickerHeaderCustomProps, DayDatepickerOptionProps, DayDatepickerProps, DayDatepickerSizeVariantType, DayDatepickerSizeVariants, DomainType, Dropdown, DropdownButton, DropdownButtonContext, DropdownButtonContextType, DropdownButtonOptionProps, DropdownButtonProps, DropdownButtonSizeVariantType, DropdownButtonSizeVariants, DropdownButtonStyleVariantType, DropdownButtonStyleVariants, DropdownContentProps, DropdownOptionProps, DropdownOptionVariantType, DropdownOptionVariants, DropdownProps, DropdownSizeVariantType, DropdownTriggerButtonProps, FontWeightTokens, Icon, IconButton, IconButtonComponent, IconButtonOptionProps, IconButtonProps, IconButtonSizeVariantType, IconButtonSizeVariants, IconButtonStyleVariantType, IconButtonStyleVariants, IconOptionProps, IconProps, IconSizeVariants, IconSizeVariantsType, Input, InputButton, InputButtonOptionProps, InputButtonProps, InputOptionProps, InputProps, InputSizeVariantType, InputSizeVariants, List, ListContent2ColumnsProps, ListOptionProps, ListProps, ListText2RowsProps, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu, MenuOptionProps, MenuProps, MenuSizeVariantType, MenuSizeVariants, MinusBoxOptionProps, MinusBoxProps, MinusButton, Modal, ModalBodyOptionProps, ModalBodyProps, ModalBottomProps, ModalContainerOptionProps, ModalContainerProps, ModalContext, ModalFooterOptionProps, ModalFooterProps, ModalFooterType, ModalHandlerContext, ModalHeaderOptionProps, ModalHeaderProps, ModalHeaderType, ModalPortal as ModalProvider, ModalSize, ModalSizeType, ModalStateType, ModalTopProps, MonthClickDateInfo, MonthDatepicker, MonthDatepickerProps, MonthDatepickerStyleType, MotionStack, MotionStackComponentType, MotionStackContainer, MotionStackContainerComponentType, NumberCombobox, NumberComboboxErrorType, NumberComboboxInputType, NumberComboboxOptionProps, NumberComboboxProps, NumberComboboxSizeVariantType, NumberComboboxSizeVariants, Pagination, PaginationOptionProps, PaginationProps, PaginationSizeSelectorProps, PolymorphicComponentProps, PolymorphicRef, Popper, PopperOptionProps, PopperPortal, PopperPortalProps, PopperProps, PopperTrigger, PopperTriggerProps, RADIO_SYMBOL_KEY, Radio, RadioOptionProps, RadioProps, RemoveModalProps, ScrollArea, ScrollAreaOptionProps, ScrollAreaProps, ScrollbarRefType, SelectInputButton, SelectInputButtonOptionProps, SelectInputButtonProps, ShoplflowProvider, ShoplflowProviderProps, Skeleton, SkeletonProps, SliderProps, SpacingTokens, SplitButton, SplitButtonContext, SplitButtonContextType, SplitButtonOptionProps, SplitButtonProps, SplitButtonSizeVariantType, SplitButtonSizeVariants, SplitButtonStyleVariantType, SplitButtonStyleVariants, Stack, StackComponentType, StackContainer, StackContainerComponentType, StackContainerGenericProps, StackContainerOptionProps, StackContainerProps, StackGenericProps, StackOptionProps, StackProps, StyledIcon, StyledStack, StyledStackContainer, Switch, SwitchOptionProps, SwitchProps, TREE_SYMBOL_KEY, TabOptionProps, TabProps, TabSizeVariantType, TabSizeVariants, TabStyleVariantType, TabStyleVariants, TabStyledProps, TabTextStyledProps, Tabs, TabsContext, TabsContextType, TabsOptionProps, TabsProps, Tag, TagOptionProps, TagProps, TagSizeVariantType, TagSizeVariants, TagStyleVariantType, TagStyleVariants, Text, Text2Rows, TextArea, TextAreaOptionProps, TextAreaProps, TextOptionProps, TextProps, ToggleButton, ToggleButtonInnerRadioOptionProps, ToggleButtonInnerRadioProps, ToggleButtonOptionProps, ToggleButtonProps, ToggleButtonSizeVariantType, ToggleButtonSizeVariants, Tooltip, TooltipContentProps, TooltipOptionProps, TooltipProps, Tree, TreeItem, TreeItemOptionProps, TreeItemProps, TreeOptionProps, TreeProps, TypographyTokens, WeekClickDateInfo, WeekDatepicker, WeekDatepickerProps, WeekDatepickerStyleType, YearSelectProps, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|
|
1589
|
+
export { AnnualDatepicker, AnnualDatepickerProps, AsProp, Avatar, AvatarOptionProps, AvatarProps, AvatarSizeVariantType, AvatarSizeVariants, BackDropOptionProps, BackDropProps, BorderRadiusTokens, BoxShadowTokens, Button, ButtonComponent, ButtonOptionProps, ButtonProps, ButtonSizeVariantType, ButtonSizeVariants, ButtonStyleVariantType, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout, CalloutOptionProps, CalloutProps, CalloutType, CalloutTypes, Checkbox, CheckboxOptionProps, CheckboxProps, CheckboxStyleVariantType, CheckboxStyleVariants, ChipButton, ChipButtonOptionProps, ChipButtonProps, ChipButtonSizeVariantType, ChipButtonSizeVariants, ChipButtonStyleVariantType, ChipButtonStyleVariants, ChipToggle, ChipToggleOptionProps, ChipToggleProps, ChipToggleSizeVariantType, ChipToggleSizeVariants, ChipToggleStyleVariantType, ChipToggleStyleVariants, ColorTokens, DangerouslySetInnerHTML, DayCalendarType, DayDatepicker, DayDatepickerHeaderCustomProps, DayDatepickerOptionProps, DayDatepickerProps, DayDatepickerSizeVariantType, DayDatepickerSizeVariants, DomainType, Dropdown, DropdownButton, DropdownButtonContext, DropdownButtonContextType, DropdownButtonOptionProps, DropdownButtonProps, DropdownButtonSizeVariantType, DropdownButtonSizeVariants, DropdownButtonStyleVariantType, DropdownButtonStyleVariants, DropdownContentProps, DropdownOptionProps, DropdownOptionVariantType, DropdownOptionVariants, DropdownProps, DropdownSizeVariantType, DropdownTriggerButtonProps, FontWeightTokens, Icon, IconButton, IconButtonComponent, IconButtonOptionProps, IconButtonProps, IconButtonSizeVariantType, IconButtonSizeVariants, IconButtonStyleVariantType, IconButtonStyleVariants, IconOptionProps, IconProps, IconSizeVariants, IconSizeVariantsType, Input, InputButton, InputButtonOptionProps, InputButtonProps, InputOptionProps, InputProps, InputSizeVariantType, InputSizeVariants, List, ListContent2ColumnsProps, ListOptionProps, ListProps, ListText2RowsProps, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu, MenuOptionProps, MenuProps, MenuSizeVariantType, MenuSizeVariants, MinusBoxOptionProps, MinusBoxProps, MinusButton, Modal, ModalBodyOptionProps, ModalBodyProps, ModalBottomProps, ModalContainerOptionProps, ModalContainerProps, ModalContext, ModalFooterOptionProps, ModalFooterProps, ModalFooterType, ModalHandlerContext, ModalHeaderOptionProps, ModalHeaderProps, ModalHeaderType, ModalPortal as ModalProvider, ModalSize, ModalSizeType, ModalStateType, ModalTopProps, MonthClickDateInfo, MonthDatepicker, MonthDatepickerProps, MonthDatepickerStyleType, MotionStack, MotionStackComponentType, MotionStackContainer, MotionStackContainerComponentType, NumberCombobox, NumberComboboxErrorType, NumberComboboxInputType, NumberComboboxOptionProps, NumberComboboxProps, NumberComboboxSizeVariantType, NumberComboboxSizeVariants, Pagination, PaginationOptionProps, PaginationProps, PaginationSizeSelectorProps, PolymorphicComponentProps, PolymorphicRef, Popper, PopperOptionProps, PopperPortal, PopperPortalProps, PopperProps, PopperTrigger, PopperTriggerProps, RADIO_SYMBOL_KEY, Radio, RadioOptionProps, RadioProps, RemoveModalProps, SLIDER_Z_INDEX, ScrollArea, ScrollAreaOptionProps, ScrollAreaProps, ScrollbarRefType, SelectInputButton, SelectInputButtonOptionProps, SelectInputButtonProps, ShoplflowProvider, ShoplflowProviderProps, Skeleton, SkeletonProps, Slider, SliderBounds, SliderProps, SpacingTokens, SplitButton, SplitButtonContext, SplitButtonContextType, SplitButtonOptionProps, SplitButtonProps, SplitButtonSizeVariantType, SplitButtonSizeVariants, SplitButtonStyleVariantType, SplitButtonStyleVariants, Stack, StackComponentType, StackContainer, StackContainerComponentType, StackContainerGenericProps, StackContainerOptionProps, StackContainerProps, StackGenericProps, StackOptionProps, StackProps, StyledIcon, StyledStack, StyledStackContainer, Switch, SwitchOptionProps, SwitchProps, TREE_SYMBOL_KEY, TabOptionProps, TabProps, TabSizeVariantType, TabSizeVariants, TabStyleVariantType, TabStyleVariants, TabStyledProps, TabTextStyledProps, Tabs, TabsContext, TabsContextType, TabsOptionProps, TabsProps, Tag, TagOptionProps, TagProps, TagSizeVariantType, TagSizeVariants, TagStyleVariantType, TagStyleVariants, Text, Text2Rows, TextArea, TextAreaOptionProps, TextAreaProps, TextOptionProps, TextProps, ToggleButton, ToggleButtonInnerRadioOptionProps, ToggleButtonInnerRadioProps, ToggleButtonOptionProps, ToggleButtonProps, ToggleButtonSizeVariantType, ToggleButtonSizeVariants, Tooltip, TooltipContentProps, TooltipOptionProps, TooltipProps, Tree, TreeItem, TreeItemOptionProps, TreeItemProps, TreeOptionProps, TreeProps, TypographyTokens, WeekClickDateInfo, WeekDatepicker, WeekDatepickerProps, WeekDatepickerStyleType, YearSelectProps, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1576,5 +1576,14 @@ interface SliderProps {
|
|
|
1576
1576
|
*/
|
|
1577
1577
|
selectedColor?: ColorTokens;
|
|
1578
1578
|
}
|
|
1579
|
+
declare type SliderBounds = {
|
|
1580
|
+
min: number;
|
|
1581
|
+
max: number;
|
|
1582
|
+
};
|
|
1583
|
+
declare const SLIDER_Z_INDEX: {
|
|
1584
|
+
readonly THUMB_BUTTON: 10;
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
declare const Slider: React__default.FC<SliderProps>;
|
|
1579
1588
|
|
|
1580
|
-
export { AnnualDatepicker, AnnualDatepickerProps, AsProp, Avatar, AvatarOptionProps, AvatarProps, AvatarSizeVariantType, AvatarSizeVariants, BackDropOptionProps, BackDropProps, BorderRadiusTokens, BoxShadowTokens, Button, ButtonComponent, ButtonOptionProps, ButtonProps, ButtonSizeVariantType, ButtonSizeVariants, ButtonStyleVariantType, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout, CalloutOptionProps, CalloutProps, CalloutType, CalloutTypes, Checkbox, CheckboxOptionProps, CheckboxProps, CheckboxStyleVariantType, CheckboxStyleVariants, ChipButton, ChipButtonOptionProps, ChipButtonProps, ChipButtonSizeVariantType, ChipButtonSizeVariants, ChipButtonStyleVariantType, ChipButtonStyleVariants, ChipToggle, ChipToggleOptionProps, ChipToggleProps, ChipToggleSizeVariantType, ChipToggleSizeVariants, ChipToggleStyleVariantType, ChipToggleStyleVariants, ColorTokens, DangerouslySetInnerHTML, DayCalendarType, DayDatepicker, DayDatepickerHeaderCustomProps, DayDatepickerOptionProps, DayDatepickerProps, DayDatepickerSizeVariantType, DayDatepickerSizeVariants, DomainType, Dropdown, DropdownButton, DropdownButtonContext, DropdownButtonContextType, DropdownButtonOptionProps, DropdownButtonProps, DropdownButtonSizeVariantType, DropdownButtonSizeVariants, DropdownButtonStyleVariantType, DropdownButtonStyleVariants, DropdownContentProps, DropdownOptionProps, DropdownOptionVariantType, DropdownOptionVariants, DropdownProps, DropdownSizeVariantType, DropdownTriggerButtonProps, FontWeightTokens, Icon, IconButton, IconButtonComponent, IconButtonOptionProps, IconButtonProps, IconButtonSizeVariantType, IconButtonSizeVariants, IconButtonStyleVariantType, IconButtonStyleVariants, IconOptionProps, IconProps, IconSizeVariants, IconSizeVariantsType, Input, InputButton, InputButtonOptionProps, InputButtonProps, InputOptionProps, InputProps, InputSizeVariantType, InputSizeVariants, List, ListContent2ColumnsProps, ListOptionProps, ListProps, ListText2RowsProps, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu, MenuOptionProps, MenuProps, MenuSizeVariantType, MenuSizeVariants, MinusBoxOptionProps, MinusBoxProps, MinusButton, Modal, ModalBodyOptionProps, ModalBodyProps, ModalBottomProps, ModalContainerOptionProps, ModalContainerProps, ModalContext, ModalFooterOptionProps, ModalFooterProps, ModalFooterType, ModalHandlerContext, ModalHeaderOptionProps, ModalHeaderProps, ModalHeaderType, ModalPortal as ModalProvider, ModalSize, ModalSizeType, ModalStateType, ModalTopProps, MonthClickDateInfo, MonthDatepicker, MonthDatepickerProps, MonthDatepickerStyleType, MotionStack, MotionStackComponentType, MotionStackContainer, MotionStackContainerComponentType, NumberCombobox, NumberComboboxErrorType, NumberComboboxInputType, NumberComboboxOptionProps, NumberComboboxProps, NumberComboboxSizeVariantType, NumberComboboxSizeVariants, Pagination, PaginationOptionProps, PaginationProps, PaginationSizeSelectorProps, PolymorphicComponentProps, PolymorphicRef, Popper, PopperOptionProps, PopperPortal, PopperPortalProps, PopperProps, PopperTrigger, PopperTriggerProps, RADIO_SYMBOL_KEY, Radio, RadioOptionProps, RadioProps, RemoveModalProps, ScrollArea, ScrollAreaOptionProps, ScrollAreaProps, ScrollbarRefType, SelectInputButton, SelectInputButtonOptionProps, SelectInputButtonProps, ShoplflowProvider, ShoplflowProviderProps, Skeleton, SkeletonProps, SliderProps, SpacingTokens, SplitButton, SplitButtonContext, SplitButtonContextType, SplitButtonOptionProps, SplitButtonProps, SplitButtonSizeVariantType, SplitButtonSizeVariants, SplitButtonStyleVariantType, SplitButtonStyleVariants, Stack, StackComponentType, StackContainer, StackContainerComponentType, StackContainerGenericProps, StackContainerOptionProps, StackContainerProps, StackGenericProps, StackOptionProps, StackProps, StyledIcon, StyledStack, StyledStackContainer, Switch, SwitchOptionProps, SwitchProps, TREE_SYMBOL_KEY, TabOptionProps, TabProps, TabSizeVariantType, TabSizeVariants, TabStyleVariantType, TabStyleVariants, TabStyledProps, TabTextStyledProps, Tabs, TabsContext, TabsContextType, TabsOptionProps, TabsProps, Tag, TagOptionProps, TagProps, TagSizeVariantType, TagSizeVariants, TagStyleVariantType, TagStyleVariants, Text, Text2Rows, TextArea, TextAreaOptionProps, TextAreaProps, TextOptionProps, TextProps, ToggleButton, ToggleButtonInnerRadioOptionProps, ToggleButtonInnerRadioProps, ToggleButtonOptionProps, ToggleButtonProps, ToggleButtonSizeVariantType, ToggleButtonSizeVariants, Tooltip, TooltipContentProps, TooltipOptionProps, TooltipProps, Tree, TreeItem, TreeItemOptionProps, TreeItemProps, TreeOptionProps, TreeProps, TypographyTokens, WeekClickDateInfo, WeekDatepicker, WeekDatepickerProps, WeekDatepickerStyleType, YearSelectProps, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|
|
1589
|
+
export { AnnualDatepicker, AnnualDatepickerProps, AsProp, Avatar, AvatarOptionProps, AvatarProps, AvatarSizeVariantType, AvatarSizeVariants, BackDropOptionProps, BackDropProps, BorderRadiusTokens, BoxShadowTokens, Button, ButtonComponent, ButtonOptionProps, ButtonProps, ButtonSizeVariantType, ButtonSizeVariants, ButtonStyleVariantType, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout, CalloutOptionProps, CalloutProps, CalloutType, CalloutTypes, Checkbox, CheckboxOptionProps, CheckboxProps, CheckboxStyleVariantType, CheckboxStyleVariants, ChipButton, ChipButtonOptionProps, ChipButtonProps, ChipButtonSizeVariantType, ChipButtonSizeVariants, ChipButtonStyleVariantType, ChipButtonStyleVariants, ChipToggle, ChipToggleOptionProps, ChipToggleProps, ChipToggleSizeVariantType, ChipToggleSizeVariants, ChipToggleStyleVariantType, ChipToggleStyleVariants, ColorTokens, DangerouslySetInnerHTML, DayCalendarType, DayDatepicker, DayDatepickerHeaderCustomProps, DayDatepickerOptionProps, DayDatepickerProps, DayDatepickerSizeVariantType, DayDatepickerSizeVariants, DomainType, Dropdown, DropdownButton, DropdownButtonContext, DropdownButtonContextType, DropdownButtonOptionProps, DropdownButtonProps, DropdownButtonSizeVariantType, DropdownButtonSizeVariants, DropdownButtonStyleVariantType, DropdownButtonStyleVariants, DropdownContentProps, DropdownOptionProps, DropdownOptionVariantType, DropdownOptionVariants, DropdownProps, DropdownSizeVariantType, DropdownTriggerButtonProps, FontWeightTokens, Icon, IconButton, IconButtonComponent, IconButtonOptionProps, IconButtonProps, IconButtonSizeVariantType, IconButtonSizeVariants, IconButtonStyleVariantType, IconButtonStyleVariants, IconOptionProps, IconProps, IconSizeVariants, IconSizeVariantsType, Input, InputButton, InputButtonOptionProps, InputButtonProps, InputOptionProps, InputProps, InputSizeVariantType, InputSizeVariants, List, ListContent2ColumnsProps, ListOptionProps, ListProps, ListText2RowsProps, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu, MenuOptionProps, MenuProps, MenuSizeVariantType, MenuSizeVariants, MinusBoxOptionProps, MinusBoxProps, MinusButton, Modal, ModalBodyOptionProps, ModalBodyProps, ModalBottomProps, ModalContainerOptionProps, ModalContainerProps, ModalContext, ModalFooterOptionProps, ModalFooterProps, ModalFooterType, ModalHandlerContext, ModalHeaderOptionProps, ModalHeaderProps, ModalHeaderType, ModalPortal as ModalProvider, ModalSize, ModalSizeType, ModalStateType, ModalTopProps, MonthClickDateInfo, MonthDatepicker, MonthDatepickerProps, MonthDatepickerStyleType, MotionStack, MotionStackComponentType, MotionStackContainer, MotionStackContainerComponentType, NumberCombobox, NumberComboboxErrorType, NumberComboboxInputType, NumberComboboxOptionProps, NumberComboboxProps, NumberComboboxSizeVariantType, NumberComboboxSizeVariants, Pagination, PaginationOptionProps, PaginationProps, PaginationSizeSelectorProps, PolymorphicComponentProps, PolymorphicRef, Popper, PopperOptionProps, PopperPortal, PopperPortalProps, PopperProps, PopperTrigger, PopperTriggerProps, RADIO_SYMBOL_KEY, Radio, RadioOptionProps, RadioProps, RemoveModalProps, SLIDER_Z_INDEX, ScrollArea, ScrollAreaOptionProps, ScrollAreaProps, ScrollbarRefType, SelectInputButton, SelectInputButtonOptionProps, SelectInputButtonProps, ShoplflowProvider, ShoplflowProviderProps, Skeleton, SkeletonProps, Slider, SliderBounds, SliderProps, SpacingTokens, SplitButton, SplitButtonContext, SplitButtonContextType, SplitButtonOptionProps, SplitButtonProps, SplitButtonSizeVariantType, SplitButtonSizeVariants, SplitButtonStyleVariantType, SplitButtonStyleVariants, Stack, StackComponentType, StackContainer, StackContainerComponentType, StackContainerGenericProps, StackContainerOptionProps, StackContainerProps, StackGenericProps, StackOptionProps, StackProps, StyledIcon, StyledStack, StyledStackContainer, Switch, SwitchOptionProps, SwitchProps, TREE_SYMBOL_KEY, TabOptionProps, TabProps, TabSizeVariantType, TabSizeVariants, TabStyleVariantType, TabStyleVariants, TabStyledProps, TabTextStyledProps, Tabs, TabsContext, TabsContextType, TabsOptionProps, TabsProps, Tag, TagOptionProps, TagProps, TagSizeVariantType, TagSizeVariants, TagStyleVariantType, TagStyleVariants, Text, Text2Rows, TextArea, TextAreaOptionProps, TextAreaProps, TextOptionProps, TextProps, ToggleButton, ToggleButtonInnerRadioOptionProps, ToggleButtonInnerRadioProps, ToggleButtonOptionProps, ToggleButtonProps, ToggleButtonSizeVariantType, ToggleButtonSizeVariants, Tooltip, TooltipContentProps, TooltipOptionProps, TooltipProps, Tree, TreeItem, TreeItemOptionProps, TreeItemProps, TreeOptionProps, TreeProps, TypographyTokens, WeekClickDateInfo, WeekDatepicker, WeekDatepickerProps, WeekDatepickerStyleType, YearSelectProps, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|
package/dist/index.js
CHANGED
|
@@ -6561,7 +6561,7 @@ var SLIDER_Z_INDEX = {
|
|
|
6561
6561
|
};
|
|
6562
6562
|
|
|
6563
6563
|
// src/components/Slider/Slider.styled.ts
|
|
6564
|
-
styled6.div`
|
|
6564
|
+
var SliderContainer = styled6.div`
|
|
6565
6565
|
position: relative;
|
|
6566
6566
|
width: 100%;
|
|
6567
6567
|
padding: 0 12px;
|
|
@@ -6574,14 +6574,14 @@ styled6.div`
|
|
|
6574
6574
|
cursor: not-allowed;
|
|
6575
6575
|
`}
|
|
6576
6576
|
`;
|
|
6577
|
-
styled6.div`
|
|
6577
|
+
var SliderTrack = styled6.div`
|
|
6578
6578
|
width: 100%; // SliderContainer의 padding 영역 내에서 100%
|
|
6579
6579
|
height: 24px;
|
|
6580
6580
|
position: relative;
|
|
6581
6581
|
overflow: visible;
|
|
6582
6582
|
margin: 0;
|
|
6583
6583
|
`;
|
|
6584
|
-
styled6.div`
|
|
6584
|
+
var SelectedTrack = styled6.div`
|
|
6585
6585
|
position: absolute;
|
|
6586
6586
|
height: 100%;
|
|
6587
6587
|
border-radius: 16px;
|
|
@@ -6590,7 +6590,7 @@ styled6.div`
|
|
|
6590
6590
|
left: ${({ startPosition }) => startPosition};
|
|
6591
6591
|
width: ${({ width }) => width};
|
|
6592
6592
|
`;
|
|
6593
|
-
styled6.div`
|
|
6593
|
+
var StepsContainer = styled6.div`
|
|
6594
6594
|
position: absolute;
|
|
6595
6595
|
top: 0;
|
|
6596
6596
|
left: 0;
|
|
@@ -6600,7 +6600,7 @@ styled6.div`
|
|
|
6600
6600
|
align-items: center;
|
|
6601
6601
|
pointer-events: none;
|
|
6602
6602
|
`;
|
|
6603
|
-
styled6.div`
|
|
6603
|
+
var Steps = styled6.div`
|
|
6604
6604
|
position: absolute;
|
|
6605
6605
|
width: 8px;
|
|
6606
6606
|
height: 8px;
|
|
@@ -6612,7 +6612,7 @@ styled6.div`
|
|
|
6612
6612
|
height: 16px;
|
|
6613
6613
|
}
|
|
6614
6614
|
`;
|
|
6615
|
-
styled6.button`
|
|
6615
|
+
var ThumbButton = styled6.button`
|
|
6616
6616
|
position: absolute;
|
|
6617
6617
|
top: 50%;
|
|
6618
6618
|
transform: translate(-50%, -50%);
|
|
@@ -6621,7 +6621,7 @@ styled6.button`
|
|
|
6621
6621
|
outline: none;
|
|
6622
6622
|
z-index: ${SLIDER_Z_INDEX.THUMB_BUTTON}; // thumb를 track보다 위에 위치시킴
|
|
6623
6623
|
`;
|
|
6624
|
-
styled6.div`
|
|
6624
|
+
var ThumbCircle = styled6.div`
|
|
6625
6625
|
width: 16px;
|
|
6626
6626
|
height: 16px;
|
|
6627
6627
|
border-radius: 50%;
|
|
@@ -6642,6 +6642,208 @@ styled6.div`
|
|
|
6642
6642
|
}
|
|
6643
6643
|
`}
|
|
6644
6644
|
`;
|
|
6645
|
+
|
|
6646
|
+
// src/components/Slider/sliderUtils.ts
|
|
6647
|
+
var getAdjustedValue = (value, bounds, step) => {
|
|
6648
|
+
const { min, max } = bounds;
|
|
6649
|
+
const snappedValue = Math.round((value - min) / step) * step + min;
|
|
6650
|
+
return Math.max(min, Math.min(max, snappedValue));
|
|
6651
|
+
};
|
|
6652
|
+
var getPositionPercentage = (index, selectedRange, bounds) => {
|
|
6653
|
+
const { min, max } = bounds;
|
|
6654
|
+
return Math.trunc((selectedRange[index] - min) / (max - min) * 100);
|
|
6655
|
+
};
|
|
6656
|
+
var getValueFromPercentage = (percentage, bounds, step) => {
|
|
6657
|
+
const { min, max } = bounds;
|
|
6658
|
+
const rawValue = min + percentage / 100 * (max - min);
|
|
6659
|
+
return getAdjustedValue(rawValue, bounds, step);
|
|
6660
|
+
};
|
|
6661
|
+
var generateSteps = (bounds, step, maxSteps = 21) => {
|
|
6662
|
+
const { min, max } = bounds;
|
|
6663
|
+
const totalSteps = Math.floor((max - min) / step) + 1;
|
|
6664
|
+
const stepInterval = totalSteps > maxSteps ? Math.ceil(totalSteps / maxSteps) : 1;
|
|
6665
|
+
const tickValues = [];
|
|
6666
|
+
for (let i = 0; i < totalSteps; i += stepInterval) {
|
|
6667
|
+
const value = min + i * step;
|
|
6668
|
+
if (value <= max) {
|
|
6669
|
+
tickValues.push(value);
|
|
6670
|
+
}
|
|
6671
|
+
}
|
|
6672
|
+
if (tickValues.length > 0 && tickValues[tickValues.length - 1] !== max) {
|
|
6673
|
+
tickValues.push(max);
|
|
6674
|
+
}
|
|
6675
|
+
return tickValues;
|
|
6676
|
+
};
|
|
6677
|
+
var validateRange = ({
|
|
6678
|
+
min,
|
|
6679
|
+
max,
|
|
6680
|
+
defaultRange
|
|
6681
|
+
}) => {
|
|
6682
|
+
if (defaultRange.min < min || defaultRange.max > max) {
|
|
6683
|
+
throw new Error("defaultRange\uAC00 Slider\uC758 \uC804\uCCB4 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0A9\uB2C8\uB2E4.");
|
|
6684
|
+
}
|
|
6685
|
+
if (defaultRange.min > defaultRange.max) {
|
|
6686
|
+
throw new Error("defaultRange\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uD655\uC778\uD574\uC8FC\uC138\uC694.");
|
|
6687
|
+
}
|
|
6688
|
+
};
|
|
6689
|
+
var validateStep = ({ min, max, step }) => {
|
|
6690
|
+
if (step <= 0) {
|
|
6691
|
+
throw new Error("step\uC740 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4.");
|
|
6692
|
+
}
|
|
6693
|
+
if (step > max || step < min || step > max - min) {
|
|
6694
|
+
throw new Error("step\uC774 Slider\uC758 \uC804\uCCB4 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0A9\uB2C8\uB2E4.");
|
|
6695
|
+
}
|
|
6696
|
+
};
|
|
6697
|
+
var SliderSteps = ({ bounds, step, maxSteps = 21 }) => {
|
|
6698
|
+
const steps = generateSteps(bounds, step, maxSteps);
|
|
6699
|
+
const { min, max } = bounds;
|
|
6700
|
+
return /* @__PURE__ */ jsx(StepsContainer, { children: steps.map((stepValue) => {
|
|
6701
|
+
const position = (stepValue - min) / (max - min) * 100;
|
|
6702
|
+
return /* @__PURE__ */ jsx(
|
|
6703
|
+
Steps,
|
|
6704
|
+
{
|
|
6705
|
+
style: {
|
|
6706
|
+
left: `${position}%`
|
|
6707
|
+
}
|
|
6708
|
+
},
|
|
6709
|
+
stepValue
|
|
6710
|
+
);
|
|
6711
|
+
}) });
|
|
6712
|
+
};
|
|
6713
|
+
var SliderThumbs = ({
|
|
6714
|
+
positions,
|
|
6715
|
+
values,
|
|
6716
|
+
isDisabled,
|
|
6717
|
+
selectedColor,
|
|
6718
|
+
onMouseDown
|
|
6719
|
+
}) => {
|
|
6720
|
+
return /* @__PURE__ */ jsx(Fragment, { children: positions.map((position, index) => /* @__PURE__ */ jsx(ThumbButton, { style: { left: `${position}%` }, onMouseDown: onMouseDown(index), children: /* @__PURE__ */ jsx(
|
|
6721
|
+
Tooltip_default,
|
|
6722
|
+
{
|
|
6723
|
+
trigger: /* @__PURE__ */ jsx(ThumbCircle, { isDisabled, selectedColor }),
|
|
6724
|
+
popper: !isDisabled && /* @__PURE__ */ jsx(Tooltip_default.Content, { content: Math.abs(values[index]).toString() })
|
|
6725
|
+
}
|
|
6726
|
+
) }, index)) });
|
|
6727
|
+
};
|
|
6728
|
+
var useSlider = ({ bounds, step, defaultRange, handleRange, isDisabled = false }) => {
|
|
6729
|
+
const { min, max } = bounds;
|
|
6730
|
+
validateRange({ min, max, defaultRange });
|
|
6731
|
+
validateStep({ min, max, step });
|
|
6732
|
+
const [range, setRange] = useState([defaultRange.min, defaultRange.max]);
|
|
6733
|
+
const trackRef = useRef(null);
|
|
6734
|
+
const updateRange = useCallback(
|
|
6735
|
+
(index, newValue) => {
|
|
6736
|
+
setRange((prev) => {
|
|
6737
|
+
const newRange = [...prev];
|
|
6738
|
+
if (index === 0) {
|
|
6739
|
+
newRange[0] = Math.min(newValue, newRange[1]);
|
|
6740
|
+
} else if (index === 1) {
|
|
6741
|
+
newRange[1] = Math.max(newValue, newRange[0]);
|
|
6742
|
+
}
|
|
6743
|
+
return newRange;
|
|
6744
|
+
});
|
|
6745
|
+
handleRange == null ? void 0 : handleRange({ min: range[0], max: range[1] });
|
|
6746
|
+
},
|
|
6747
|
+
[range, handleRange]
|
|
6748
|
+
);
|
|
6749
|
+
const handleMouseDown = useCallback(
|
|
6750
|
+
(index) => (e) => {
|
|
6751
|
+
if (isDisabled) {
|
|
6752
|
+
return;
|
|
6753
|
+
}
|
|
6754
|
+
e.preventDefault();
|
|
6755
|
+
const handleMouseMove = (moveEvent) => {
|
|
6756
|
+
if (!trackRef.current) {
|
|
6757
|
+
return;
|
|
6758
|
+
}
|
|
6759
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
6760
|
+
const offsetX = moveEvent.clientX - rect.left;
|
|
6761
|
+
const percentage = Math.min(Math.max(offsetX / rect.width * 100, 0), 100);
|
|
6762
|
+
const newValue = getValueFromPercentage(percentage, { min, max }, step);
|
|
6763
|
+
updateRange(index, newValue);
|
|
6764
|
+
};
|
|
6765
|
+
const handleMouseUp = () => {
|
|
6766
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
6767
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
6768
|
+
};
|
|
6769
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
6770
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
6771
|
+
},
|
|
6772
|
+
[isDisabled, min, max, step, updateRange]
|
|
6773
|
+
);
|
|
6774
|
+
const handleClickTrack = useCallback(
|
|
6775
|
+
(e) => {
|
|
6776
|
+
if (isDisabled || !trackRef.current) {
|
|
6777
|
+
return;
|
|
6778
|
+
}
|
|
6779
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
6780
|
+
const offsetX = e.clientX - rect.left;
|
|
6781
|
+
const percentage = offsetX / rect.width * 100;
|
|
6782
|
+
const newValue = getValueFromPercentage(percentage, { min, max }, step);
|
|
6783
|
+
const distanceToStart = Math.abs(getPositionPercentage(0, range, { min, max }) - percentage);
|
|
6784
|
+
const distanceToEnd = Math.abs(getPositionPercentage(1, range, { min, max }) - percentage);
|
|
6785
|
+
if (distanceToStart <= distanceToEnd) {
|
|
6786
|
+
updateRange(0, newValue);
|
|
6787
|
+
} else {
|
|
6788
|
+
updateRange(1, newValue);
|
|
6789
|
+
}
|
|
6790
|
+
},
|
|
6791
|
+
[isDisabled, min, max, step, range, updateRange]
|
|
6792
|
+
);
|
|
6793
|
+
const startPosition = getPositionPercentage(0, range, { min, max });
|
|
6794
|
+
const endPosition = getPositionPercentage(1, range, { min, max });
|
|
6795
|
+
const width = endPosition - startPosition;
|
|
6796
|
+
return {
|
|
6797
|
+
range,
|
|
6798
|
+
trackRef,
|
|
6799
|
+
handleMouseDown,
|
|
6800
|
+
handleClickTrack,
|
|
6801
|
+
positions: {
|
|
6802
|
+
start: startPosition,
|
|
6803
|
+
end: endPosition,
|
|
6804
|
+
width
|
|
6805
|
+
}
|
|
6806
|
+
};
|
|
6807
|
+
};
|
|
6808
|
+
var Slider = ({
|
|
6809
|
+
min = 0,
|
|
6810
|
+
max,
|
|
6811
|
+
step = 1,
|
|
6812
|
+
defaultRange = { min: 0, max: 0 },
|
|
6813
|
+
handleRange,
|
|
6814
|
+
isDisabled = false,
|
|
6815
|
+
selectedColor = "shopl300"
|
|
6816
|
+
}) => {
|
|
6817
|
+
const { range, trackRef, handleMouseDown, handleClickTrack, positions } = useSlider({
|
|
6818
|
+
bounds: { min, max },
|
|
6819
|
+
step,
|
|
6820
|
+
defaultRange,
|
|
6821
|
+
handleRange,
|
|
6822
|
+
isDisabled
|
|
6823
|
+
});
|
|
6824
|
+
return /* @__PURE__ */ jsx(SliderContainer, { isDisabled, children: /* @__PURE__ */ jsxs(SliderTrack, { ref: trackRef, onClick: handleClickTrack, children: [
|
|
6825
|
+
/* @__PURE__ */ jsx(SliderSteps, { bounds: { min, max }, step, range }),
|
|
6826
|
+
/* @__PURE__ */ jsx(
|
|
6827
|
+
SelectedTrack,
|
|
6828
|
+
{
|
|
6829
|
+
selectedColor,
|
|
6830
|
+
startPosition: `calc(${positions.start}% - 12px)`,
|
|
6831
|
+
width: `calc(${positions.width}% + 24px)`
|
|
6832
|
+
}
|
|
6833
|
+
),
|
|
6834
|
+
/* @__PURE__ */ jsx(
|
|
6835
|
+
SliderThumbs,
|
|
6836
|
+
{
|
|
6837
|
+
positions: [positions.start, positions.end],
|
|
6838
|
+
isDisabled,
|
|
6839
|
+
selectedColor,
|
|
6840
|
+
onMouseDown: handleMouseDown,
|
|
6841
|
+
values: range
|
|
6842
|
+
}
|
|
6843
|
+
)
|
|
6844
|
+
] }) });
|
|
6845
|
+
};
|
|
6846
|
+
var Slider_default = Slider;
|
|
6645
6847
|
var SpaceMarginWrapper = styled6(motion.div)`
|
|
6646
6848
|
position: relative;
|
|
6647
6849
|
display: flex;
|
|
@@ -6696,4 +6898,4 @@ classnames/index.js:
|
|
|
6696
6898
|
*)
|
|
6697
6899
|
*/
|
|
6698
6900
|
|
|
6699
|
-
export { AnnualDatepicker_default as AnnualDatepicker, Avatar_default as Avatar, AvatarSizeVariants, Button_default as Button, ButtonSizeVariants, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout_default as Callout, CalloutTypes, Checkbox_default as Checkbox, CheckboxStyleVariants, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, DayDatepicker_default as DayDatepicker, DayDatepickerSizeVariants, Dropdown_default as Dropdown, DropdownButton_default as DropdownButton, DropdownButtonContext, DropdownButtonSizeVariants, DropdownButtonStyleVariants, DropdownOptionVariants, Icon_default as Icon, IconButton_default as IconButton, IconButtonSizeVariants, IconButtonStyleVariants, IconSizeVariants, Input_default as Input, InputButton_default as InputButton, InputSizeVariants, List_default as List, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu_default as Menu, MenuSizeVariants, MinusButton_default as MinusButton, Modal, ModalContext, ModalHandlerContext, ModalPortal_default as ModalProvider, ModalSize, MonthDatepicker_default as MonthDatepicker, MotionStack, MotionStackContainer, NumberCombobox_default as NumberCombobox, NumberComboboxSizeVariants, Pagination_default as Pagination, Popper_default as Popper, PopperPortal, PopperTrigger, RADIO_SYMBOL_KEY, Radio_default as Radio, ScrollArea_default as ScrollArea, SelectInputButton_default as SelectInputButton, ShoplflowProvider_default as ShoplflowProvider, Skeleton_default as Skeleton, SplitButton_default as SplitButton, SplitButtonContext, SplitButtonSizeVariants, SplitButtonStyleVariants, Stack_default as Stack, StackContainer_default as StackContainer, StyledIcon, StyledStack, StyledStackContainer, Switch_default as Switch, TREE_SYMBOL_KEY, TabSizeVariants, TabStyleVariants, Tabs_default as Tabs, TabsContext, Tag_default as Tag, TagSizeVariants, TagStyleVariants, Text_default as Text, Text2Rows, TextArea_default as TextArea, ToggleButton_default as ToggleButton, ToggleButtonSizeVariants, Tooltip_default as Tooltip, Tree_default as Tree, TreeItem, WeekDatepicker_default as WeekDatepicker, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|
|
6901
|
+
export { AnnualDatepicker_default as AnnualDatepicker, Avatar_default as Avatar, AvatarSizeVariants, Button_default as Button, ButtonSizeVariants, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout_default as Callout, CalloutTypes, Checkbox_default as Checkbox, CheckboxStyleVariants, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, DayDatepicker_default as DayDatepicker, DayDatepickerSizeVariants, Dropdown_default as Dropdown, DropdownButton_default as DropdownButton, DropdownButtonContext, DropdownButtonSizeVariants, DropdownButtonStyleVariants, DropdownOptionVariants, Icon_default as Icon, IconButton_default as IconButton, IconButtonSizeVariants, IconButtonStyleVariants, IconSizeVariants, Input_default as Input, InputButton_default as InputButton, InputSizeVariants, List_default as List, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu_default as Menu, MenuSizeVariants, MinusButton_default as MinusButton, Modal, ModalContext, ModalHandlerContext, ModalPortal_default as ModalProvider, ModalSize, MonthDatepicker_default as MonthDatepicker, MotionStack, MotionStackContainer, NumberCombobox_default as NumberCombobox, NumberComboboxSizeVariants, Pagination_default as Pagination, Popper_default as Popper, PopperPortal, PopperTrigger, RADIO_SYMBOL_KEY, Radio_default as Radio, SLIDER_Z_INDEX, ScrollArea_default as ScrollArea, SelectInputButton_default as SelectInputButton, ShoplflowProvider_default as ShoplflowProvider, Skeleton_default as Skeleton, Slider_default as Slider, SplitButton_default as SplitButton, SplitButtonContext, SplitButtonSizeVariants, SplitButtonStyleVariants, Stack_default as Stack, StackContainer_default as StackContainer, StyledIcon, StyledStack, StyledStackContainer, Switch_default as Switch, TREE_SYMBOL_KEY, TabSizeVariants, TabStyleVariants, Tabs_default as Tabs, TabsContext, Tag_default as Tag, TagSizeVariants, TagStyleVariants, Text_default as Text, Text2Rows, TextArea_default as TextArea, ToggleButton_default as ToggleButton, ToggleButtonSizeVariants, Tooltip_default as Tooltip, Tree_default as Tree, TreeItem, WeekDatepicker_default as WeekDatepicker, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|