@shoplflow/base 0.24.26 → 0.24.28

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
@@ -1859,30 +1859,45 @@ var getBorderColorByStatus = ({ isFocused, isError, isHovered, disabled }) => {
1859
1859
  }
1860
1860
  return exports.colorTokens.neutral300;
1861
1861
  };
1862
+ var getStyleByType = ({
1863
+ type,
1864
+ height,
1865
+ minHeight,
1866
+ maxHeight,
1867
+ width,
1868
+ minWidth,
1869
+ maxWidth
1870
+ }) => {
1871
+ if (type === "number") {
1872
+ return react$1.css`
1873
+ width: 64px;
1874
+ height: 32px;
1875
+ `;
1876
+ }
1877
+ if (type === "text" || type === "password") {
1878
+ return react$1.css`
1879
+ width: ${width != null ? width : "100%"};
1880
+ min-width: ${minWidth != null ? minWidth : "initial"};
1881
+ max-width: ${maxWidth != null ? maxWidth : "initial"};
1882
+ height: ${height != null ? height : "initial"};
1883
+ min-height: ${minHeight != null ? minHeight : "initial"};
1884
+ max-height: ${maxHeight != null ? maxHeight : "initial"};
1885
+ `;
1886
+ }
1887
+ return react$1.css`
1888
+ width: 64px;
1889
+ height: 32px;
1890
+ `;
1891
+ };
1862
1892
  var InputWrapper = styled5__default.default.label`
1893
+ position: relative;
1863
1894
  display: flex;
1864
1895
  align-items: center;
1865
- width: ${({ width }) => {
1866
- var _a;
1867
- return (_a = `calc(${width} - 2px)`) != null ? _a : "calc(100% - 2px)";
1868
- }};
1869
- min-width: ${({ minWidth }) => {
1870
- var _a;
1871
- return (_a = `calc(${minWidth} - 2px)`) != null ? _a : "fit-content";
1872
- }};
1873
- height: ${({ height }) => {
1874
- var _a;
1875
- return (_a = `calc(${height} - 2px)`) != null ? _a : "fit-content";
1876
- }};
1877
1896
  flex-direction: ${({ direction }) => direction || "row"};
1897
+ ${({ type, height, minHeight, maxHeight, width, maxWidth, minWidth }) => getStyleByType({ type, height, minHeight, maxHeight, width, maxWidth, minWidth })};
1878
1898
  justify-content: space-between;
1879
- min-height: ${({ minHeight }) => {
1880
- var _a;
1881
- return (_a = `calc(${minHeight} - 2px)`) != null ? _a : "fit-content";
1882
- }};
1883
- margin: 1px;
1884
1899
  gap: 8px;
1885
- box-shadow: 0 0 0 1px ${(props) => getBorderColorByStatus(props)};
1900
+ border: 1px solid ${(props) => getBorderColorByStatus(props)};
1886
1901
  border-radius: 6px;
1887
1902
  background-color: ${exports.colorTokens.neutral0};
1888
1903
  overflow: hidden;
@@ -2614,7 +2629,8 @@ exports.TagSizeVariants = {
2614
2629
  var StyledInput = styled5__default.default.input`
2615
2630
  padding: 4px 0 4px 12px;
2616
2631
  background-color: transparent;
2617
- width: 100%;
2632
+ display: flex;
2633
+ min-width: 64px;
2618
2634
  border: none;
2619
2635
  box-sizing: border-box;
2620
2636
  &::placeholder {
@@ -2635,6 +2651,12 @@ var StyledInput = styled5__default.default.input`
2635
2651
  text-align: center;
2636
2652
  -moz-appearance: textfield;
2637
2653
  }
2654
+
2655
+ *,
2656
+ *:before,
2657
+ *:after {
2658
+ box-sizing: inherit;
2659
+ }
2638
2660
  `;
2639
2661
  var RightElementWrapper = styled5__default.default.div`
2640
2662
  display: flex;
@@ -2670,6 +2692,17 @@ var assetFunction = (iconName, domainProps) => {
2670
2692
  const ShoplIcon = ShoplAssets__namespace[iconName];
2671
2693
  return domain === "hada" ? HadaIcon : ShoplIcon;
2672
2694
  };
2695
+
2696
+ // src/components/Inputs/Input/utils/getNumberLimiteRange.ts
2697
+ var getNumberLimitRange = (value, min, max) => {
2698
+ if (min && value < min) {
2699
+ return String(min);
2700
+ }
2701
+ if (max && value > max) {
2702
+ return String(max);
2703
+ }
2704
+ return String(value);
2705
+ };
2673
2706
  var Input = React2.forwardRef(
2674
2707
  (_a, ref) => {
2675
2708
  var _b = _a, {
@@ -2686,7 +2719,7 @@ var Input = React2.forwardRef(
2686
2719
  min,
2687
2720
  max,
2688
2721
  className,
2689
- width = "100%"
2722
+ width
2690
2723
  } = _b, rest = __objRest(_b, [
2691
2724
  "onFocus",
2692
2725
  "onBlur",
@@ -2705,7 +2738,7 @@ var Input = React2.forwardRef(
2705
2738
  ]);
2706
2739
  const [text, setText] = React2.useState("");
2707
2740
  const [isFocused, setIsFocused] = React2.useState(false);
2708
- const [type, setType] = React2.useState("text");
2741
+ const [type, setType] = React2.useState(void 0);
2709
2742
  const [isHovered, setIsHovered] = React2.useState(false);
2710
2743
  const uniqueId = React2.useId();
2711
2744
  const inputRef = React2__namespace.default.useRef(null);
@@ -2725,18 +2758,6 @@ var Input = React2.forwardRef(
2725
2758
  },
2726
2759
  [maxLength]
2727
2760
  );
2728
- const limitRange = React2.useCallback(
2729
- (value2) => {
2730
- if (min && Number(value2) < Number(min)) {
2731
- return String(min);
2732
- }
2733
- if (max && Number(value2) > Number(max)) {
2734
- return String(max);
2735
- }
2736
- return value2;
2737
- },
2738
- [max, min]
2739
- );
2740
2761
  const handleOnMouseEnter = () => {
2741
2762
  setIsHovered(true);
2742
2763
  };
@@ -2755,19 +2776,15 @@ var Input = React2.forwardRef(
2755
2776
  onChange && onChange(event);
2756
2777
  const slicedText = sliceText(event.target.value);
2757
2778
  if (type === "number") {
2758
- const limitedText = limitRange(slicedText);
2779
+ const numberValue = Number(slicedText);
2780
+ const numberMin = Number(min);
2781
+ const numberMax = Number(max);
2782
+ const limitedText = getNumberLimitRange(numberValue, numberMin, numberMax);
2759
2783
  setText(limitedText);
2760
2784
  return;
2761
2785
  }
2762
2786
  setText(slicedText);
2763
2787
  };
2764
- const getWidth = () => {
2765
- if (type === "number") {
2766
- return "64px";
2767
- } else {
2768
- return width;
2769
- }
2770
- };
2771
2788
  const handleOnClear = () => {
2772
2789
  onClear && onClear();
2773
2790
  if (inputRef.current) {
@@ -2811,8 +2828,10 @@ var Input = React2.forwardRef(
2811
2828
  isHovered,
2812
2829
  onMouseEnter: handleOnMouseEnter,
2813
2830
  onMouseLeave: handleOnMouseLeave,
2814
- width: getWidth(),
2815
- height: type === "number" ? "32px" : "40px",
2831
+ type,
2832
+ width,
2833
+ height: "40px",
2834
+ maxHeight: "40px",
2816
2835
  "data-shoplflow": "input",
2817
2836
  children: [
2818
2837
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2952,6 +2971,7 @@ var InputButton = React2.forwardRef(
2952
2971
  isFocused: isSelected,
2953
2972
  disabled,
2954
2973
  minHeight: "40px",
2974
+ maxHeight: "40px",
2955
2975
  width,
2956
2976
  children: /* @__PURE__ */ jsxRuntime.jsxs(exports.StyledInputButton, { onClick: handleOnClick, disabled, children: [
2957
2977
  /* @__PURE__ */ jsxRuntime.jsx(exports.StyledInputButtonContent, __spreadValues({ className: "body1_400", defaultValue: text, ref }, rest)),