@shoplflow/base 0.13.3 → 0.13.5

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
@@ -208,9 +208,25 @@ var ModalProvider = ({ children }) => {
208
208
  return /* @__PURE__ */ jsxRuntime.jsx(ModalContext.Provider, { value: openedModals, children: /* @__PURE__ */ jsxRuntime.jsx(ModalHandlerContext.Provider, { value: dispatch, children }) });
209
209
  };
210
210
  var ModalProvider_default = ModalProvider;
211
+ var PopperPortal = () => {
212
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: reactDom$1.createPortal(
213
+ /* @__PURE__ */ jsxRuntime.jsx(
214
+ "div",
215
+ {
216
+ id: "popper-portal-key",
217
+ style: {
218
+ zIndex: 20001
219
+ }
220
+ }
221
+ ),
222
+ document.body
223
+ ) });
224
+ };
225
+ var PopperPortal_default = PopperPortal;
211
226
  var ShoplflowProvider = ({ children, domain = "SHOPL" }) => {
212
227
  exports.useDomain(domain);
213
228
  return /* @__PURE__ */ jsxRuntime.jsxs(ModalProvider_default, { children: [
229
+ /* @__PURE__ */ jsxRuntime.jsx(PopperPortal_default, {}),
214
230
  /* @__PURE__ */ jsxRuntime.jsx(exports.ModalProvider, {}),
215
231
  children
216
232
  ] });
@@ -1503,7 +1519,7 @@ exports.PopperPortal = React3.forwardRef(
1503
1519
  const { floatingStyles, setFloating, isOpen } = usePopper();
1504
1520
  const animation = initialAnimation != null ? initialAnimation : fadeInOut;
1505
1521
  const refs = useMergeRefs(ref, setFloating);
1506
- return /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
1522
+ return /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingPortal, { id: "popper-portal-key", children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
1507
1523
  framerMotion.motion.div,
1508
1524
  {
1509
1525
  initial: animation.initial,
@@ -1589,6 +1605,7 @@ exports.StyledDropdown = styled5__default.default.div`
1589
1605
  exports.StyledDropdownContent = styled5__default.default.div`
1590
1606
  display: flex;
1591
1607
  flex-direction: column;
1608
+ background: ${exports.colorTokens.neutral0};
1592
1609
  width: ${({ width }) => width != null ? width : "240px"};
1593
1610
  padding: 4px;
1594
1611
  border-radius: 6px;
@@ -1820,7 +1837,7 @@ var assetFunction = (iconName, domainProps) => {
1820
1837
  const ShoplIcon = ShoplAssets__namespace[iconName];
1821
1838
  return domain === "hada" ? HadaIcon : ShoplIcon;
1822
1839
  };
1823
- React3.forwardRef(
1840
+ var Input = React3.forwardRef(
1824
1841
  (_a, ref) => {
1825
1842
  var _b = _a, {
1826
1843
  onFocus,
@@ -1977,6 +1994,117 @@ React3.forwardRef(
1977
1994
  );
1978
1995
  }
1979
1996
  );
1997
+ exports.Input = Input;
1998
+ exports.StyledInputButton = styled5__default.default.button`
1999
+ display: flex;
2000
+ flex-direction: row;
2001
+ align-items: center;
2002
+ justify-content: space-between;
2003
+ width: 100%;
2004
+ gap: 4px;
2005
+ padding: 4px 4px 4px 12px;
2006
+ cursor: pointer;
2007
+ ${({ disabled }) => disabled && react.css`
2008
+ cursor: not-allowed;
2009
+ `}
2010
+ `;
2011
+ var InputButton = React3.forwardRef(
2012
+ (_a, ref) => {
2013
+ var _b = _a, {
2014
+ value,
2015
+ defaultValue,
2016
+ onChange,
2017
+ onClick,
2018
+ isSelected,
2019
+ disabled = false,
2020
+ rightSource,
2021
+ placeholder,
2022
+ onClear,
2023
+ width
2024
+ } = _b, rest = __objRest(_b, [
2025
+ "value",
2026
+ "defaultValue",
2027
+ "onChange",
2028
+ "onClick",
2029
+ "isSelected",
2030
+ "disabled",
2031
+ "rightSource",
2032
+ "placeholder",
2033
+ "onClear",
2034
+ "width"
2035
+ ]);
2036
+ const [text, setText] = React3.useState("");
2037
+ const [isHovered, setIsHovered] = React3.useState(false);
2038
+ const convertToString = React3.useCallback((value2) => {
2039
+ if (typeof value2 !== "number") {
2040
+ return typeof value2 === "string" ? value2 : value2.join("");
2041
+ }
2042
+ return String(value2);
2043
+ }, []);
2044
+ const handleOnClick = (e) => {
2045
+ if (!disabled) {
2046
+ onClick && onClick(e);
2047
+ }
2048
+ };
2049
+ const handleOnClear = () => {
2050
+ if (!disabled) {
2051
+ onClear && onClear();
2052
+ setText("");
2053
+ }
2054
+ };
2055
+ const handleOnMouseEnter = () => {
2056
+ setIsHovered(true);
2057
+ };
2058
+ const handleOnMouseLeave = () => {
2059
+ setIsHovered(false);
2060
+ };
2061
+ React3.useEffect(() => {
2062
+ if (defaultValue) {
2063
+ const convertString = convertToString(defaultValue);
2064
+ setText(convertString);
2065
+ }
2066
+ }, [convertToString, defaultValue]);
2067
+ React3.useEffect(() => {
2068
+ if (value) {
2069
+ const convertString = convertToString(value);
2070
+ setText(convertString);
2071
+ }
2072
+ }, [convertToString, value]);
2073
+ React3.useEffect(() => {
2074
+ onChange && onChange(convertToString(value != null ? value : ""));
2075
+ }, [convertToString, onChange, value]);
2076
+ return /* @__PURE__ */ jsxRuntime.jsx(
2077
+ InputWrapper,
2078
+ {
2079
+ onMouseEnter: handleOnMouseEnter,
2080
+ onMouseLeave: handleOnMouseLeave,
2081
+ "data-shoplflow": "InputButton",
2082
+ isHovered,
2083
+ isFocused: isSelected,
2084
+ disabled,
2085
+ width,
2086
+ children: /* @__PURE__ */ jsxRuntime.jsxs(exports.StyledInputButton, __spreadProps(__spreadValues({}, rest), { onClick: handleOnClick, disabled, ref, children: [
2087
+ 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 }),
2088
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Stack.Horizontal, { align: "center", children: [
2089
+ value && /* @__PURE__ */ jsxRuntime.jsx(
2090
+ exports.IconButton,
2091
+ {
2092
+ sizeVar: "S",
2093
+ onClick: handleOnClear,
2094
+ styleVar: "GHOST",
2095
+ iconSource: assetFunction("DeleteIcon"),
2096
+ color: "neutral600",
2097
+ disabled
2098
+ }
2099
+ ),
2100
+ rightSource
2101
+ ] })
2102
+ ] }))
2103
+ }
2104
+ );
2105
+ }
2106
+ );
2107
+ exports.InputButton = InputButton;
1980
2108
  var BottomElementWrapper = styled5__default.default.div`
1981
2109
  display: flex;
1982
2110
  width: 100%;