@shoplflow/base 0.13.3 → 0.13.4

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
@@ -1820,7 +1820,7 @@ var assetFunction = (iconName, domainProps) => {
1820
1820
  const ShoplIcon = ShoplAssets__namespace[iconName];
1821
1821
  return domain === "hada" ? HadaIcon : ShoplIcon;
1822
1822
  };
1823
- React3.forwardRef(
1823
+ var Input = React3.forwardRef(
1824
1824
  (_a, ref) => {
1825
1825
  var _b = _a, {
1826
1826
  onFocus,
@@ -1977,6 +1977,117 @@ React3.forwardRef(
1977
1977
  );
1978
1978
  }
1979
1979
  );
1980
+ exports.Input = Input;
1981
+ exports.StyledInputButton = styled5__default.default.button`
1982
+ display: flex;
1983
+ flex-direction: row;
1984
+ align-items: center;
1985
+ justify-content: space-between;
1986
+ width: 100%;
1987
+ gap: 4px;
1988
+ padding: 4px 4px 4px 12px;
1989
+ cursor: pointer;
1990
+ ${({ disabled }) => disabled && react.css`
1991
+ cursor: not-allowed;
1992
+ `}
1993
+ `;
1994
+ var InputButton = React3.forwardRef(
1995
+ (_a, ref) => {
1996
+ var _b = _a, {
1997
+ value,
1998
+ defaultValue,
1999
+ onChange,
2000
+ onClick,
2001
+ isSelected,
2002
+ disabled = false,
2003
+ rightSource,
2004
+ placeholder,
2005
+ onClear,
2006
+ width
2007
+ } = _b, rest = __objRest(_b, [
2008
+ "value",
2009
+ "defaultValue",
2010
+ "onChange",
2011
+ "onClick",
2012
+ "isSelected",
2013
+ "disabled",
2014
+ "rightSource",
2015
+ "placeholder",
2016
+ "onClear",
2017
+ "width"
2018
+ ]);
2019
+ const [text, setText] = React3.useState("");
2020
+ const [isHovered, setIsHovered] = React3.useState(false);
2021
+ const convertToString = React3.useCallback((value2) => {
2022
+ if (typeof value2 !== "number") {
2023
+ return typeof value2 === "string" ? value2 : value2.join("");
2024
+ }
2025
+ return String(value2);
2026
+ }, []);
2027
+ const handleOnClick = (e) => {
2028
+ if (!disabled) {
2029
+ onClick && onClick(e);
2030
+ }
2031
+ };
2032
+ const handleOnClear = () => {
2033
+ if (!disabled) {
2034
+ onClear && onClear();
2035
+ setText("");
2036
+ }
2037
+ };
2038
+ const handleOnMouseEnter = () => {
2039
+ setIsHovered(true);
2040
+ };
2041
+ const handleOnMouseLeave = () => {
2042
+ setIsHovered(false);
2043
+ };
2044
+ React3.useEffect(() => {
2045
+ if (defaultValue) {
2046
+ const convertString = convertToString(defaultValue);
2047
+ setText(convertString);
2048
+ }
2049
+ }, [convertToString, defaultValue]);
2050
+ React3.useEffect(() => {
2051
+ if (value) {
2052
+ const convertString = convertToString(value);
2053
+ setText(convertString);
2054
+ }
2055
+ }, [convertToString, value]);
2056
+ React3.useEffect(() => {
2057
+ onChange && onChange(convertToString(value != null ? value : ""));
2058
+ }, [convertToString, onChange, value]);
2059
+ return /* @__PURE__ */ jsxRuntime.jsx(
2060
+ InputWrapper,
2061
+ {
2062
+ onMouseEnter: handleOnMouseEnter,
2063
+ onMouseLeave: handleOnMouseLeave,
2064
+ "data-shoplflow": "InputButton",
2065
+ isHovered,
2066
+ isFocused: isSelected,
2067
+ disabled,
2068
+ width,
2069
+ children: /* @__PURE__ */ jsxRuntime.jsxs(exports.StyledInputButton, __spreadProps(__spreadValues({}, rest), { onClick: handleOnClick, disabled, ref, children: [
2070
+ text && text.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_400", color: "neutral700", textOverflow: "ellipsis", lineClamp: 1, children: text }) : /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_400", color: "neutral350", textOverflow: "ellipsis", lineClamp: 1, children: placeholder }),
2071
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Stack.Horizontal, { align: "center", children: [
2072
+ value && /* @__PURE__ */ jsxRuntime.jsx(
2073
+ exports.IconButton,
2074
+ {
2075
+ sizeVar: "S",
2076
+ onClick: handleOnClear,
2077
+ styleVar: "GHOST",
2078
+ iconSource: assetFunction("DeleteIcon"),
2079
+ color: "neutral600",
2080
+ disabled
2081
+ }
2082
+ ),
2083
+ rightSource
2084
+ ] })
2085
+ ] }))
2086
+ }
2087
+ );
2088
+ }
2089
+ );
2090
+ exports.InputButton = InputButton;
1980
2091
  var BottomElementWrapper = styled5__default.default.div`
1981
2092
  display: flex;
1982
2093
  width: 100%;