@shoplflow/base 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1938,6 +1938,17 @@ var StyledInput = styled5__default.default.input`
1938
1938
  &::placeholder {
1939
1939
  color: ${exports.colorTokens.neutral350};
1940
1940
  }
1941
+ &::-webkit-outer-spin-button,
1942
+ &::-webkit-inner-spin-button {
1943
+ -webkit-appearance: none;
1944
+ margin: 0;
1945
+ }
1946
+ /* Firefox */
1947
+ &[type='number'] {
1948
+ padding: 4px 8px;
1949
+ text-align: center;
1950
+ -moz-appearance: textfield;
1951
+ }
1941
1952
  `;
1942
1953
  var RightElementWrapper = styled5__default.default.div`
1943
1954
  display: flex;
@@ -1986,6 +1997,8 @@ var Input = React3.forwardRef(
1986
1997
  disabled,
1987
1998
  type: initialType,
1988
1999
  maxLength,
2000
+ min,
2001
+ max,
1989
2002
  className,
1990
2003
  width
1991
2004
  } = _b, rest = __objRest(_b, [
@@ -1999,6 +2012,8 @@ var Input = React3.forwardRef(
1999
2012
  "disabled",
2000
2013
  "type",
2001
2014
  "maxLength",
2015
+ "min",
2016
+ "max",
2002
2017
  "className",
2003
2018
  "width"
2004
2019
  ]);
@@ -2024,6 +2039,18 @@ var Input = React3.forwardRef(
2024
2039
  },
2025
2040
  [maxLength]
2026
2041
  );
2042
+ const limitRange = React3.useCallback(
2043
+ (value2) => {
2044
+ if (min && Number(value2) < min) {
2045
+ return String(min);
2046
+ }
2047
+ if (max && Number(value2) > max) {
2048
+ return String(max);
2049
+ }
2050
+ return value2;
2051
+ },
2052
+ [max, min]
2053
+ );
2027
2054
  const handleOnMouseEnter = () => {
2028
2055
  setIsHovered(true);
2029
2056
  };
@@ -2041,8 +2068,20 @@ var Input = React3.forwardRef(
2041
2068
  const handleOnChange = (event) => {
2042
2069
  onChange && onChange(event);
2043
2070
  const slicedText = sliceText(event.target.value);
2071
+ if (type === "number") {
2072
+ const limitedText = limitRange(slicedText);
2073
+ setText(limitedText);
2074
+ return;
2075
+ }
2044
2076
  setText(slicedText);
2045
2077
  };
2078
+ const getWidth = () => {
2079
+ if (type === "number") {
2080
+ return "64px";
2081
+ } else {
2082
+ return width;
2083
+ }
2084
+ };
2046
2085
  const handleOnClear = () => {
2047
2086
  onClear && onClear();
2048
2087
  if (inputRef.current) {
@@ -2058,16 +2097,18 @@ var Input = React3.forwardRef(
2058
2097
  }
2059
2098
  };
2060
2099
  React3.useEffect(() => {
2061
- if (defaultValue) {
2100
+ if (defaultValue !== void 0) {
2062
2101
  const convertString = convertToString(defaultValue);
2063
2102
  const slicedText = sliceText(convertString);
2064
2103
  setText(slicedText);
2065
2104
  }
2066
2105
  }, [convertToString, defaultValue, maxLength, sliceText]);
2067
2106
  React3.useEffect(() => {
2068
- if (value) {
2107
+ var _a2;
2108
+ if (value !== void 0) {
2069
2109
  const convertString = convertToString(value);
2070
2110
  const slicedText = sliceText(convertString);
2111
+ ((_a2 = inputRef.current) == null ? void 0 : _a2.value) && (inputRef.current.value = slicedText);
2071
2112
  setText(slicedText);
2072
2113
  }
2073
2114
  }, [convertToString, maxLength, sliceText, value]);
@@ -2084,7 +2125,7 @@ var Input = React3.forwardRef(
2084
2125
  isHovered,
2085
2126
  onMouseEnter: handleOnMouseEnter,
2086
2127
  onMouseLeave: handleOnMouseLeave,
2087
- width,
2128
+ width: getWidth(),
2088
2129
  "data-shoplflow": "input",
2089
2130
  children: [
2090
2131
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2102,7 +2143,7 @@ var Input = React3.forwardRef(
2102
2143
  className: "body1_400" + (className ? ` ${className}` : "")
2103
2144
  }, rest)
2104
2145
  ),
2105
- /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
2146
+ !(type === "number") && /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
2106
2147
  maxLength && isFocused && /* @__PURE__ */ jsxRuntime.jsx(TextCounter_default, { currentLength: String(text).length, maxLength }),
2107
2148
  isFocused && Boolean(String(text).length > 0) && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleOnClear, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: assetFunction("DeleteIcon"), color: "neutral600" }) }),
2108
2149
  initialType === "password" && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleTogglePasswordType, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2403,6 +2444,7 @@ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
2403
2444
  fill: ${exports.colorTokens.neutral0};
2404
2445
  }
2405
2446
  ${isHovered && react$1.css`
2447
+ border: 1.5px solid ${exports.colorTokens.primary400};
2406
2448
  background: ${exports.colorTokens.primary400};
2407
2449
  `}
2408
2450
  `;
@@ -2412,6 +2454,7 @@ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
2412
2454
  border: 1.5px solid ${exports.colorTokens.neutral200};
2413
2455
  border-radius: 4px;
2414
2456
  ${isHovered && react$1.css`
2457
+ border: 1.5px solid ${exports.colorTokens.neutral300};
2415
2458
  background: ${exports.colorTokens.neutral300};
2416
2459
  `}
2417
2460
 
@@ -2578,6 +2621,7 @@ var Container4 = styled5__default.default.button`
2578
2621
  display: flex;
2579
2622
  align-items: center;
2580
2623
  justify-content: center;
2624
+ background: transparent;
2581
2625
  padding: 4px;
2582
2626
  width: fit-content;
2583
2627
  height: fit-content;