@shoplflow/base 0.34.0 → 0.35.1

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 CHANGED
@@ -1758,6 +1758,18 @@ var getWidthAndHeightFromSizeVar = (sizeVar) => {
1758
1758
  `;
1759
1759
  }
1760
1760
  };
1761
+ var getIconSizeFromSizeVar = (sizeVar) => {
1762
+ switch (sizeVar) {
1763
+ case "M":
1764
+ return "24px";
1765
+ case "S":
1766
+ return "20px";
1767
+ case "XS":
1768
+ return "12px";
1769
+ default:
1770
+ return "20px";
1771
+ }
1772
+ };
1761
1773
  var getStyleByStyleVar2 = (styleVar, color, isHovered) => {
1762
1774
  switch (styleVar) {
1763
1775
  case "PRIMARY":
@@ -1817,14 +1829,15 @@ var StyledIconButton = styled6__default.default.button`
1817
1829
  ${({ sizeVar }) => getWidthAndHeightFromSizeVar(sizeVar)};
1818
1830
  ${({ disabled }) => getDisabledStyle(disabled)};
1819
1831
  & > svg {
1820
- width: 20px;
1821
- height: 20px;
1832
+ width: ${({ iconSizeVar }) => getIconSizeFromSizeVar(iconSizeVar)};
1833
+ height: ${({ iconSizeVar }) => getIconSizeFromSizeVar(iconSizeVar)};
1822
1834
  }
1823
1835
  `;
1824
1836
  var IconButton = React3.forwardRef(
1825
1837
  (_a, ref) => {
1826
1838
  var _b = _a, {
1827
1839
  styleVar,
1840
+ iconSizeVar,
1828
1841
  sizeVar,
1829
1842
  disabled,
1830
1843
  children,
@@ -1835,6 +1848,7 @@ var IconButton = React3.forwardRef(
1835
1848
  type = "button"
1836
1849
  } = _b, rest = __objRest(_b, [
1837
1850
  "styleVar",
1851
+ "iconSizeVar",
1838
1852
  "sizeVar",
1839
1853
  "disabled",
1840
1854
  "children",
@@ -1857,6 +1871,7 @@ var IconButton = React3.forwardRef(
1857
1871
  StyledIconButton,
1858
1872
  __spreadProps(__spreadValues({
1859
1873
  styleVar,
1874
+ iconSizeVar,
1860
1875
  sizeVar,
1861
1876
  disabled,
1862
1877
  color,
@@ -6583,12 +6598,12 @@ var Skeleton = ({ styleVar = "rectangle", width = "50px", height = "20px" }) =>
6583
6598
  exports.Skeleton = Skeleton;
6584
6599
 
6585
6600
  // src/components/Slider/Slider.types.ts
6586
- var SLIDER_Z_INDEX = {
6601
+ exports.SLIDER_Z_INDEX = {
6587
6602
  THUMB_BUTTON: 10
6588
6603
  };
6589
6604
 
6590
6605
  // src/components/Slider/Slider.styled.ts
6591
- styled6__default.default.div`
6606
+ var SliderContainer = styled6__default.default.div`
6592
6607
  position: relative;
6593
6608
  width: 100%;
6594
6609
  padding: 0 12px;
@@ -6601,14 +6616,14 @@ styled6__default.default.div`
6601
6616
  cursor: not-allowed;
6602
6617
  `}
6603
6618
  `;
6604
- styled6__default.default.div`
6619
+ var SliderTrack = styled6__default.default.div`
6605
6620
  width: 100%; // SliderContainer의 padding 영역 내에서 100%
6606
6621
  height: 24px;
6607
6622
  position: relative;
6608
6623
  overflow: visible;
6609
6624
  margin: 0;
6610
6625
  `;
6611
- styled6__default.default.div`
6626
+ var SelectedTrack = styled6__default.default.div`
6612
6627
  position: absolute;
6613
6628
  height: 100%;
6614
6629
  border-radius: 16px;
@@ -6617,7 +6632,7 @@ styled6__default.default.div`
6617
6632
  left: ${({ startPosition }) => startPosition};
6618
6633
  width: ${({ width }) => width};
6619
6634
  `;
6620
- styled6__default.default.div`
6635
+ var StepsContainer = styled6__default.default.div`
6621
6636
  position: absolute;
6622
6637
  top: 0;
6623
6638
  left: 0;
@@ -6627,7 +6642,7 @@ styled6__default.default.div`
6627
6642
  align-items: center;
6628
6643
  pointer-events: none;
6629
6644
  `;
6630
- styled6__default.default.div`
6645
+ var Steps = styled6__default.default.div`
6631
6646
  position: absolute;
6632
6647
  width: 8px;
6633
6648
  height: 8px;
@@ -6639,16 +6654,16 @@ styled6__default.default.div`
6639
6654
  height: 16px;
6640
6655
  }
6641
6656
  `;
6642
- styled6__default.default.button`
6657
+ var ThumbButton = styled6__default.default.button`
6643
6658
  position: absolute;
6644
6659
  top: 50%;
6645
6660
  transform: translate(-50%, -50%);
6646
6661
  border: none;
6647
6662
  padding: 0;
6648
6663
  outline: none;
6649
- z-index: ${SLIDER_Z_INDEX.THUMB_BUTTON}; // thumb를 track보다 위에 위치시킴
6664
+ z-index: ${exports.SLIDER_Z_INDEX.THUMB_BUTTON}; // thumb를 track보다 위에 위치시킴
6650
6665
  `;
6651
- styled6__default.default.div`
6666
+ var ThumbCircle = styled6__default.default.div`
6652
6667
  width: 16px;
6653
6668
  height: 16px;
6654
6669
  border-radius: 50%;
@@ -6669,6 +6684,208 @@ styled6__default.default.div`
6669
6684
  }
6670
6685
  `}
6671
6686
  `;
6687
+
6688
+ // src/components/Slider/sliderUtils.ts
6689
+ var getAdjustedValue = (value, bounds, step) => {
6690
+ const { min, max } = bounds;
6691
+ const snappedValue = Math.round((value - min) / step) * step + min;
6692
+ return Math.max(min, Math.min(max, snappedValue));
6693
+ };
6694
+ var getPositionPercentage = (index, selectedRange, bounds) => {
6695
+ const { min, max } = bounds;
6696
+ return Math.trunc((selectedRange[index] - min) / (max - min) * 100);
6697
+ };
6698
+ var getValueFromPercentage = (percentage, bounds, step) => {
6699
+ const { min, max } = bounds;
6700
+ const rawValue = min + percentage / 100 * (max - min);
6701
+ return getAdjustedValue(rawValue, bounds, step);
6702
+ };
6703
+ var generateSteps = (bounds, step, maxSteps = 21) => {
6704
+ const { min, max } = bounds;
6705
+ const totalSteps = Math.floor((max - min) / step) + 1;
6706
+ const stepInterval = totalSteps > maxSteps ? Math.ceil(totalSteps / maxSteps) : 1;
6707
+ const tickValues = [];
6708
+ for (let i = 0; i < totalSteps; i += stepInterval) {
6709
+ const value = min + i * step;
6710
+ if (value <= max) {
6711
+ tickValues.push(value);
6712
+ }
6713
+ }
6714
+ if (tickValues.length > 0 && tickValues[tickValues.length - 1] !== max) {
6715
+ tickValues.push(max);
6716
+ }
6717
+ return tickValues;
6718
+ };
6719
+ var validateRange = ({
6720
+ min,
6721
+ max,
6722
+ defaultRange
6723
+ }) => {
6724
+ if (defaultRange.min < min || defaultRange.max > max) {
6725
+ throw new Error("defaultRange\uAC00 Slider\uC758 \uC804\uCCB4 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0A9\uB2C8\uB2E4.");
6726
+ }
6727
+ if (defaultRange.min > defaultRange.max) {
6728
+ throw new Error("defaultRange\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uD655\uC778\uD574\uC8FC\uC138\uC694.");
6729
+ }
6730
+ };
6731
+ var validateStep = ({ min, max, step }) => {
6732
+ if (step <= 0) {
6733
+ throw new Error("step\uC740 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4.");
6734
+ }
6735
+ if (step > max || step < min || step > max - min) {
6736
+ throw new Error("step\uC774 Slider\uC758 \uC804\uCCB4 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0A9\uB2C8\uB2E4.");
6737
+ }
6738
+ };
6739
+ var SliderSteps = ({ bounds, step, maxSteps = 21 }) => {
6740
+ const steps = generateSteps(bounds, step, maxSteps);
6741
+ const { min, max } = bounds;
6742
+ return /* @__PURE__ */ jsxRuntime.jsx(StepsContainer, { children: steps.map((stepValue) => {
6743
+ const position = (stepValue - min) / (max - min) * 100;
6744
+ return /* @__PURE__ */ jsxRuntime.jsx(
6745
+ Steps,
6746
+ {
6747
+ style: {
6748
+ left: `${position}%`
6749
+ }
6750
+ },
6751
+ stepValue
6752
+ );
6753
+ }) });
6754
+ };
6755
+ var SliderThumbs = ({
6756
+ positions,
6757
+ values,
6758
+ isDisabled,
6759
+ selectedColor,
6760
+ onMouseDown
6761
+ }) => {
6762
+ 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(
6763
+ exports.Tooltip,
6764
+ {
6765
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(ThumbCircle, { isDisabled, selectedColor }),
6766
+ popper: !isDisabled && /* @__PURE__ */ jsxRuntime.jsx(exports.Tooltip.Content, { content: Math.abs(values[index]).toString() })
6767
+ }
6768
+ ) }, index)) });
6769
+ };
6770
+ var useSlider = ({ bounds, step, defaultRange, handleRange, isDisabled = false }) => {
6771
+ const { min, max } = bounds;
6772
+ validateRange({ min, max, defaultRange });
6773
+ validateStep({ min, max, step });
6774
+ const [range, setRange] = React3.useState([defaultRange.min, defaultRange.max]);
6775
+ const trackRef = React3.useRef(null);
6776
+ const updateRange = React3.useCallback(
6777
+ (index, newValue) => {
6778
+ setRange((prev) => {
6779
+ const newRange = [...prev];
6780
+ if (index === 0) {
6781
+ newRange[0] = Math.min(newValue, newRange[1]);
6782
+ } else if (index === 1) {
6783
+ newRange[1] = Math.max(newValue, newRange[0]);
6784
+ }
6785
+ return newRange;
6786
+ });
6787
+ handleRange == null ? void 0 : handleRange({ min: range[0], max: range[1] });
6788
+ },
6789
+ [range, handleRange]
6790
+ );
6791
+ const handleMouseDown = React3.useCallback(
6792
+ (index) => (e) => {
6793
+ if (isDisabled) {
6794
+ return;
6795
+ }
6796
+ e.preventDefault();
6797
+ const handleMouseMove = (moveEvent) => {
6798
+ if (!trackRef.current) {
6799
+ return;
6800
+ }
6801
+ const rect = trackRef.current.getBoundingClientRect();
6802
+ const offsetX = moveEvent.clientX - rect.left;
6803
+ const percentage = Math.min(Math.max(offsetX / rect.width * 100, 0), 100);
6804
+ const newValue = getValueFromPercentage(percentage, { min, max }, step);
6805
+ updateRange(index, newValue);
6806
+ };
6807
+ const handleMouseUp = () => {
6808
+ document.removeEventListener("mousemove", handleMouseMove);
6809
+ document.removeEventListener("mouseup", handleMouseUp);
6810
+ };
6811
+ document.addEventListener("mousemove", handleMouseMove);
6812
+ document.addEventListener("mouseup", handleMouseUp);
6813
+ },
6814
+ [isDisabled, min, max, step, updateRange]
6815
+ );
6816
+ const handleClickTrack = React3.useCallback(
6817
+ (e) => {
6818
+ if (isDisabled || !trackRef.current) {
6819
+ return;
6820
+ }
6821
+ const rect = trackRef.current.getBoundingClientRect();
6822
+ const offsetX = e.clientX - rect.left;
6823
+ const percentage = offsetX / rect.width * 100;
6824
+ const newValue = getValueFromPercentage(percentage, { min, max }, step);
6825
+ const distanceToStart = Math.abs(getPositionPercentage(0, range, { min, max }) - percentage);
6826
+ const distanceToEnd = Math.abs(getPositionPercentage(1, range, { min, max }) - percentage);
6827
+ if (distanceToStart <= distanceToEnd) {
6828
+ updateRange(0, newValue);
6829
+ } else {
6830
+ updateRange(1, newValue);
6831
+ }
6832
+ },
6833
+ [isDisabled, min, max, step, range, updateRange]
6834
+ );
6835
+ const startPosition = getPositionPercentage(0, range, { min, max });
6836
+ const endPosition = getPositionPercentage(1, range, { min, max });
6837
+ const width = endPosition - startPosition;
6838
+ return {
6839
+ range,
6840
+ trackRef,
6841
+ handleMouseDown,
6842
+ handleClickTrack,
6843
+ positions: {
6844
+ start: startPosition,
6845
+ end: endPosition,
6846
+ width
6847
+ }
6848
+ };
6849
+ };
6850
+ var Slider = ({
6851
+ min = 0,
6852
+ max,
6853
+ step = 1,
6854
+ defaultRange = { min: 0, max: 0 },
6855
+ handleRange,
6856
+ isDisabled = false,
6857
+ selectedColor = "shopl300"
6858
+ }) => {
6859
+ const { range, trackRef, handleMouseDown, handleClickTrack, positions } = useSlider({
6860
+ bounds: { min, max },
6861
+ step,
6862
+ defaultRange,
6863
+ handleRange,
6864
+ isDisabled
6865
+ });
6866
+ return /* @__PURE__ */ jsxRuntime.jsx(SliderContainer, { isDisabled, children: /* @__PURE__ */ jsxRuntime.jsxs(SliderTrack, { ref: trackRef, onClick: handleClickTrack, children: [
6867
+ /* @__PURE__ */ jsxRuntime.jsx(SliderSteps, { bounds: { min, max }, step, range }),
6868
+ /* @__PURE__ */ jsxRuntime.jsx(
6869
+ SelectedTrack,
6870
+ {
6871
+ selectedColor,
6872
+ startPosition: `calc(${positions.start}% - 12px)`,
6873
+ width: `calc(${positions.width}% + 24px)`
6874
+ }
6875
+ ),
6876
+ /* @__PURE__ */ jsxRuntime.jsx(
6877
+ SliderThumbs,
6878
+ {
6879
+ positions: [positions.start, positions.end],
6880
+ isDisabled,
6881
+ selectedColor,
6882
+ onMouseDown: handleMouseDown,
6883
+ values: range
6884
+ }
6885
+ )
6886
+ ] }) });
6887
+ };
6888
+ exports.Slider = Slider;
6672
6889
  var SpaceMarginWrapper = styled6__default.default(framerMotion.motion.div)`
6673
6890
  position: relative;
6674
6891
  display: flex;
package/dist/index.d.cts CHANGED
@@ -201,6 +201,12 @@ interface SizeVariantProps<Size> {
201
201
  */
202
202
  sizeVar?: Size;
203
203
  }
204
+ interface IconSizeVariantProps<Size> {
205
+ /**
206
+ * 아이콘의 크기를 설정합니다.
207
+ */
208
+ iconSizeVar?: Size;
209
+ }
204
210
  interface StyleVariantProps<Style> {
205
211
  /**
206
212
  * 컴포넌트의 스타일을 설정합니다.
@@ -637,7 +643,7 @@ declare const IconButtonStyleVariants: {
637
643
  readonly GHOST: "GHOST";
638
644
  };
639
645
  declare type IconButtonStyleVariantType = $Values<typeof IconButtonStyleVariants>;
640
- declare type IconButtonOptionProps<T extends ElementType = 'button'> = Omit<ComponentPropsWithoutRef<T>, 'color' | 'disabled'> & DisableProps & SizeVariantProps<IconButtonSizeVariantType> & StyleVariantProps<IconButtonStyleVariantType> & ChildrenProps & ColorTokenProps & LoadingProps;
646
+ declare type IconButtonOptionProps<T extends ElementType = 'button'> = Omit<ComponentPropsWithoutRef<T>, 'color' | 'disabled'> & DisableProps & SizeVariantProps<IconButtonSizeVariantType> & IconSizeVariantProps<'XS' | 'S' | 'M'> & StyleVariantProps<IconButtonStyleVariantType> & ChildrenProps & ColorTokenProps & LoadingProps;
641
647
  declare type IconButtonProps<T extends ElementType = 'button'> = PolymorphicComponentProps<T, IconButtonOptionProps>;
642
648
  declare type IconButtonComponent = <T extends ElementType = 'button'>(props: IconButtonProps<T> & {
643
649
  ref?: ComponentPropsWithRef<T>['ref'];
@@ -1576,5 +1582,14 @@ interface SliderProps {
1576
1582
  */
1577
1583
  selectedColor?: ColorTokens;
1578
1584
  }
1585
+ declare type SliderBounds = {
1586
+ min: number;
1587
+ max: number;
1588
+ };
1589
+ declare const SLIDER_Z_INDEX: {
1590
+ readonly THUMB_BUTTON: 10;
1591
+ };
1592
+
1593
+ declare const Slider: React__default.FC<SliderProps>;
1579
1594
 
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 };
1595
+ 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
@@ -201,6 +201,12 @@ interface SizeVariantProps<Size> {
201
201
  */
202
202
  sizeVar?: Size;
203
203
  }
204
+ interface IconSizeVariantProps<Size> {
205
+ /**
206
+ * 아이콘의 크기를 설정합니다.
207
+ */
208
+ iconSizeVar?: Size;
209
+ }
204
210
  interface StyleVariantProps<Style> {
205
211
  /**
206
212
  * 컴포넌트의 스타일을 설정합니다.
@@ -637,7 +643,7 @@ declare const IconButtonStyleVariants: {
637
643
  readonly GHOST: "GHOST";
638
644
  };
639
645
  declare type IconButtonStyleVariantType = $Values<typeof IconButtonStyleVariants>;
640
- declare type IconButtonOptionProps<T extends ElementType = 'button'> = Omit<ComponentPropsWithoutRef<T>, 'color' | 'disabled'> & DisableProps & SizeVariantProps<IconButtonSizeVariantType> & StyleVariantProps<IconButtonStyleVariantType> & ChildrenProps & ColorTokenProps & LoadingProps;
646
+ declare type IconButtonOptionProps<T extends ElementType = 'button'> = Omit<ComponentPropsWithoutRef<T>, 'color' | 'disabled'> & DisableProps & SizeVariantProps<IconButtonSizeVariantType> & IconSizeVariantProps<'XS' | 'S' | 'M'> & StyleVariantProps<IconButtonStyleVariantType> & ChildrenProps & ColorTokenProps & LoadingProps;
641
647
  declare type IconButtonProps<T extends ElementType = 'button'> = PolymorphicComponentProps<T, IconButtonOptionProps>;
642
648
  declare type IconButtonComponent = <T extends ElementType = 'button'>(props: IconButtonProps<T> & {
643
649
  ref?: ComponentPropsWithRef<T>['ref'];
@@ -1576,5 +1582,14 @@ interface SliderProps {
1576
1582
  */
1577
1583
  selectedColor?: ColorTokens;
1578
1584
  }
1585
+ declare type SliderBounds = {
1586
+ min: number;
1587
+ max: number;
1588
+ };
1589
+ declare const SLIDER_Z_INDEX: {
1590
+ readonly THUMB_BUTTON: 10;
1591
+ };
1592
+
1593
+ declare const Slider: React__default.FC<SliderProps>;
1579
1594
 
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 };
1595
+ 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
@@ -1731,6 +1731,18 @@ var getWidthAndHeightFromSizeVar = (sizeVar) => {
1731
1731
  `;
1732
1732
  }
1733
1733
  };
1734
+ var getIconSizeFromSizeVar = (sizeVar) => {
1735
+ switch (sizeVar) {
1736
+ case "M":
1737
+ return "24px";
1738
+ case "S":
1739
+ return "20px";
1740
+ case "XS":
1741
+ return "12px";
1742
+ default:
1743
+ return "20px";
1744
+ }
1745
+ };
1734
1746
  var getStyleByStyleVar2 = (styleVar, color, isHovered) => {
1735
1747
  switch (styleVar) {
1736
1748
  case "PRIMARY":
@@ -1790,14 +1802,15 @@ var StyledIconButton = styled6.button`
1790
1802
  ${({ sizeVar }) => getWidthAndHeightFromSizeVar(sizeVar)};
1791
1803
  ${({ disabled }) => getDisabledStyle(disabled)};
1792
1804
  & > svg {
1793
- width: 20px;
1794
- height: 20px;
1805
+ width: ${({ iconSizeVar }) => getIconSizeFromSizeVar(iconSizeVar)};
1806
+ height: ${({ iconSizeVar }) => getIconSizeFromSizeVar(iconSizeVar)};
1795
1807
  }
1796
1808
  `;
1797
1809
  var IconButton = forwardRef(
1798
1810
  (_a, ref) => {
1799
1811
  var _b = _a, {
1800
1812
  styleVar,
1813
+ iconSizeVar,
1801
1814
  sizeVar,
1802
1815
  disabled,
1803
1816
  children,
@@ -1808,6 +1821,7 @@ var IconButton = forwardRef(
1808
1821
  type = "button"
1809
1822
  } = _b, rest = __objRest(_b, [
1810
1823
  "styleVar",
1824
+ "iconSizeVar",
1811
1825
  "sizeVar",
1812
1826
  "disabled",
1813
1827
  "children",
@@ -1830,6 +1844,7 @@ var IconButton = forwardRef(
1830
1844
  StyledIconButton,
1831
1845
  __spreadProps(__spreadValues({
1832
1846
  styleVar,
1847
+ iconSizeVar,
1833
1848
  sizeVar,
1834
1849
  disabled,
1835
1850
  color,
@@ -6561,7 +6576,7 @@ var SLIDER_Z_INDEX = {
6561
6576
  };
6562
6577
 
6563
6578
  // src/components/Slider/Slider.styled.ts
6564
- styled6.div`
6579
+ var SliderContainer = styled6.div`
6565
6580
  position: relative;
6566
6581
  width: 100%;
6567
6582
  padding: 0 12px;
@@ -6574,14 +6589,14 @@ styled6.div`
6574
6589
  cursor: not-allowed;
6575
6590
  `}
6576
6591
  `;
6577
- styled6.div`
6592
+ var SliderTrack = styled6.div`
6578
6593
  width: 100%; // SliderContainer의 padding 영역 내에서 100%
6579
6594
  height: 24px;
6580
6595
  position: relative;
6581
6596
  overflow: visible;
6582
6597
  margin: 0;
6583
6598
  `;
6584
- styled6.div`
6599
+ var SelectedTrack = styled6.div`
6585
6600
  position: absolute;
6586
6601
  height: 100%;
6587
6602
  border-radius: 16px;
@@ -6590,7 +6605,7 @@ styled6.div`
6590
6605
  left: ${({ startPosition }) => startPosition};
6591
6606
  width: ${({ width }) => width};
6592
6607
  `;
6593
- styled6.div`
6608
+ var StepsContainer = styled6.div`
6594
6609
  position: absolute;
6595
6610
  top: 0;
6596
6611
  left: 0;
@@ -6600,7 +6615,7 @@ styled6.div`
6600
6615
  align-items: center;
6601
6616
  pointer-events: none;
6602
6617
  `;
6603
- styled6.div`
6618
+ var Steps = styled6.div`
6604
6619
  position: absolute;
6605
6620
  width: 8px;
6606
6621
  height: 8px;
@@ -6612,7 +6627,7 @@ styled6.div`
6612
6627
  height: 16px;
6613
6628
  }
6614
6629
  `;
6615
- styled6.button`
6630
+ var ThumbButton = styled6.button`
6616
6631
  position: absolute;
6617
6632
  top: 50%;
6618
6633
  transform: translate(-50%, -50%);
@@ -6621,7 +6636,7 @@ styled6.button`
6621
6636
  outline: none;
6622
6637
  z-index: ${SLIDER_Z_INDEX.THUMB_BUTTON}; // thumb를 track보다 위에 위치시킴
6623
6638
  `;
6624
- styled6.div`
6639
+ var ThumbCircle = styled6.div`
6625
6640
  width: 16px;
6626
6641
  height: 16px;
6627
6642
  border-radius: 50%;
@@ -6642,6 +6657,208 @@ styled6.div`
6642
6657
  }
6643
6658
  `}
6644
6659
  `;
6660
+
6661
+ // src/components/Slider/sliderUtils.ts
6662
+ var getAdjustedValue = (value, bounds, step) => {
6663
+ const { min, max } = bounds;
6664
+ const snappedValue = Math.round((value - min) / step) * step + min;
6665
+ return Math.max(min, Math.min(max, snappedValue));
6666
+ };
6667
+ var getPositionPercentage = (index, selectedRange, bounds) => {
6668
+ const { min, max } = bounds;
6669
+ return Math.trunc((selectedRange[index] - min) / (max - min) * 100);
6670
+ };
6671
+ var getValueFromPercentage = (percentage, bounds, step) => {
6672
+ const { min, max } = bounds;
6673
+ const rawValue = min + percentage / 100 * (max - min);
6674
+ return getAdjustedValue(rawValue, bounds, step);
6675
+ };
6676
+ var generateSteps = (bounds, step, maxSteps = 21) => {
6677
+ const { min, max } = bounds;
6678
+ const totalSteps = Math.floor((max - min) / step) + 1;
6679
+ const stepInterval = totalSteps > maxSteps ? Math.ceil(totalSteps / maxSteps) : 1;
6680
+ const tickValues = [];
6681
+ for (let i = 0; i < totalSteps; i += stepInterval) {
6682
+ const value = min + i * step;
6683
+ if (value <= max) {
6684
+ tickValues.push(value);
6685
+ }
6686
+ }
6687
+ if (tickValues.length > 0 && tickValues[tickValues.length - 1] !== max) {
6688
+ tickValues.push(max);
6689
+ }
6690
+ return tickValues;
6691
+ };
6692
+ var validateRange = ({
6693
+ min,
6694
+ max,
6695
+ defaultRange
6696
+ }) => {
6697
+ if (defaultRange.min < min || defaultRange.max > max) {
6698
+ throw new Error("defaultRange\uAC00 Slider\uC758 \uC804\uCCB4 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0A9\uB2C8\uB2E4.");
6699
+ }
6700
+ if (defaultRange.min > defaultRange.max) {
6701
+ throw new Error("defaultRange\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uD655\uC778\uD574\uC8FC\uC138\uC694.");
6702
+ }
6703
+ };
6704
+ var validateStep = ({ min, max, step }) => {
6705
+ if (step <= 0) {
6706
+ throw new Error("step\uC740 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4.");
6707
+ }
6708
+ if (step > max || step < min || step > max - min) {
6709
+ throw new Error("step\uC774 Slider\uC758 \uC804\uCCB4 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0A9\uB2C8\uB2E4.");
6710
+ }
6711
+ };
6712
+ var SliderSteps = ({ bounds, step, maxSteps = 21 }) => {
6713
+ const steps = generateSteps(bounds, step, maxSteps);
6714
+ const { min, max } = bounds;
6715
+ return /* @__PURE__ */ jsx(StepsContainer, { children: steps.map((stepValue) => {
6716
+ const position = (stepValue - min) / (max - min) * 100;
6717
+ return /* @__PURE__ */ jsx(
6718
+ Steps,
6719
+ {
6720
+ style: {
6721
+ left: `${position}%`
6722
+ }
6723
+ },
6724
+ stepValue
6725
+ );
6726
+ }) });
6727
+ };
6728
+ var SliderThumbs = ({
6729
+ positions,
6730
+ values,
6731
+ isDisabled,
6732
+ selectedColor,
6733
+ onMouseDown
6734
+ }) => {
6735
+ return /* @__PURE__ */ jsx(Fragment, { children: positions.map((position, index) => /* @__PURE__ */ jsx(ThumbButton, { style: { left: `${position}%` }, onMouseDown: onMouseDown(index), children: /* @__PURE__ */ jsx(
6736
+ Tooltip_default,
6737
+ {
6738
+ trigger: /* @__PURE__ */ jsx(ThumbCircle, { isDisabled, selectedColor }),
6739
+ popper: !isDisabled && /* @__PURE__ */ jsx(Tooltip_default.Content, { content: Math.abs(values[index]).toString() })
6740
+ }
6741
+ ) }, index)) });
6742
+ };
6743
+ var useSlider = ({ bounds, step, defaultRange, handleRange, isDisabled = false }) => {
6744
+ const { min, max } = bounds;
6745
+ validateRange({ min, max, defaultRange });
6746
+ validateStep({ min, max, step });
6747
+ const [range, setRange] = useState([defaultRange.min, defaultRange.max]);
6748
+ const trackRef = useRef(null);
6749
+ const updateRange = useCallback(
6750
+ (index, newValue) => {
6751
+ setRange((prev) => {
6752
+ const newRange = [...prev];
6753
+ if (index === 0) {
6754
+ newRange[0] = Math.min(newValue, newRange[1]);
6755
+ } else if (index === 1) {
6756
+ newRange[1] = Math.max(newValue, newRange[0]);
6757
+ }
6758
+ return newRange;
6759
+ });
6760
+ handleRange == null ? void 0 : handleRange({ min: range[0], max: range[1] });
6761
+ },
6762
+ [range, handleRange]
6763
+ );
6764
+ const handleMouseDown = useCallback(
6765
+ (index) => (e) => {
6766
+ if (isDisabled) {
6767
+ return;
6768
+ }
6769
+ e.preventDefault();
6770
+ const handleMouseMove = (moveEvent) => {
6771
+ if (!trackRef.current) {
6772
+ return;
6773
+ }
6774
+ const rect = trackRef.current.getBoundingClientRect();
6775
+ const offsetX = moveEvent.clientX - rect.left;
6776
+ const percentage = Math.min(Math.max(offsetX / rect.width * 100, 0), 100);
6777
+ const newValue = getValueFromPercentage(percentage, { min, max }, step);
6778
+ updateRange(index, newValue);
6779
+ };
6780
+ const handleMouseUp = () => {
6781
+ document.removeEventListener("mousemove", handleMouseMove);
6782
+ document.removeEventListener("mouseup", handleMouseUp);
6783
+ };
6784
+ document.addEventListener("mousemove", handleMouseMove);
6785
+ document.addEventListener("mouseup", handleMouseUp);
6786
+ },
6787
+ [isDisabled, min, max, step, updateRange]
6788
+ );
6789
+ const handleClickTrack = useCallback(
6790
+ (e) => {
6791
+ if (isDisabled || !trackRef.current) {
6792
+ return;
6793
+ }
6794
+ const rect = trackRef.current.getBoundingClientRect();
6795
+ const offsetX = e.clientX - rect.left;
6796
+ const percentage = offsetX / rect.width * 100;
6797
+ const newValue = getValueFromPercentage(percentage, { min, max }, step);
6798
+ const distanceToStart = Math.abs(getPositionPercentage(0, range, { min, max }) - percentage);
6799
+ const distanceToEnd = Math.abs(getPositionPercentage(1, range, { min, max }) - percentage);
6800
+ if (distanceToStart <= distanceToEnd) {
6801
+ updateRange(0, newValue);
6802
+ } else {
6803
+ updateRange(1, newValue);
6804
+ }
6805
+ },
6806
+ [isDisabled, min, max, step, range, updateRange]
6807
+ );
6808
+ const startPosition = getPositionPercentage(0, range, { min, max });
6809
+ const endPosition = getPositionPercentage(1, range, { min, max });
6810
+ const width = endPosition - startPosition;
6811
+ return {
6812
+ range,
6813
+ trackRef,
6814
+ handleMouseDown,
6815
+ handleClickTrack,
6816
+ positions: {
6817
+ start: startPosition,
6818
+ end: endPosition,
6819
+ width
6820
+ }
6821
+ };
6822
+ };
6823
+ var Slider = ({
6824
+ min = 0,
6825
+ max,
6826
+ step = 1,
6827
+ defaultRange = { min: 0, max: 0 },
6828
+ handleRange,
6829
+ isDisabled = false,
6830
+ selectedColor = "shopl300"
6831
+ }) => {
6832
+ const { range, trackRef, handleMouseDown, handleClickTrack, positions } = useSlider({
6833
+ bounds: { min, max },
6834
+ step,
6835
+ defaultRange,
6836
+ handleRange,
6837
+ isDisabled
6838
+ });
6839
+ return /* @__PURE__ */ jsx(SliderContainer, { isDisabled, children: /* @__PURE__ */ jsxs(SliderTrack, { ref: trackRef, onClick: handleClickTrack, children: [
6840
+ /* @__PURE__ */ jsx(SliderSteps, { bounds: { min, max }, step, range }),
6841
+ /* @__PURE__ */ jsx(
6842
+ SelectedTrack,
6843
+ {
6844
+ selectedColor,
6845
+ startPosition: `calc(${positions.start}% - 12px)`,
6846
+ width: `calc(${positions.width}% + 24px)`
6847
+ }
6848
+ ),
6849
+ /* @__PURE__ */ jsx(
6850
+ SliderThumbs,
6851
+ {
6852
+ positions: [positions.start, positions.end],
6853
+ isDisabled,
6854
+ selectedColor,
6855
+ onMouseDown: handleMouseDown,
6856
+ values: range
6857
+ }
6858
+ )
6859
+ ] }) });
6860
+ };
6861
+ var Slider_default = Slider;
6645
6862
  var SpaceMarginWrapper = styled6(motion.div)`
6646
6863
  position: relative;
6647
6864
  display: flex;
@@ -6696,4 +6913,4 @@ classnames/index.js:
6696
6913
  *)
6697
6914
  */
6698
6915
 
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 };
6916
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoplflow/base",
3
- "version": "0.34.0",
3
+ "version": "0.35.1",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -91,7 +91,7 @@
91
91
  "react-dom": "^18.2.0",
92
92
  "simplebar-react": "^3.2.6",
93
93
  "@shoplflow/hada-assets": "^0.1.3",
94
- "@shoplflow/shopl-assets": "^0.12.2",
94
+ "@shoplflow/shopl-assets": "^0.12.3",
95
95
  "@shoplflow/utils": "^0.6.5"
96
96
  },
97
97
  "scripts": {