@shoplflow/base 0.32.11 → 0.32.13

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
@@ -1659,6 +1659,10 @@ var getWidthAndHeightFromSizeVar = (sizeVar) => {
1659
1659
  min-width: 40px;
1660
1660
  height: 40px;
1661
1661
  min-height: 40px;
1662
+ & > svg {
1663
+ width: 24px;
1664
+ height: 24px;
1665
+ }
1662
1666
  `;
1663
1667
  case "S":
1664
1668
  return react$1.css`
@@ -1666,6 +1670,10 @@ var getWidthAndHeightFromSizeVar = (sizeVar) => {
1666
1670
  min-width: 32px;
1667
1671
  height: 32px;
1668
1672
  min-height: 32px;
1673
+ & > svg {
1674
+ width: 20px;
1675
+ height: 20px;
1676
+ }
1669
1677
  `;
1670
1678
  case "XS":
1671
1679
  return react$1.css`
@@ -1673,6 +1681,10 @@ var getWidthAndHeightFromSizeVar = (sizeVar) => {
1673
1681
  min-width: 24px;
1674
1682
  height: 24px;
1675
1683
  min-height: 24px;
1684
+ & > svg {
1685
+ width: 12px;
1686
+ height: 12px;
1687
+ }
1676
1688
  `;
1677
1689
  default:
1678
1690
  return react$1.css`
@@ -1680,6 +1692,10 @@ var getWidthAndHeightFromSizeVar = (sizeVar) => {
1680
1692
  min-width: 40px;
1681
1693
  height: 40px;
1682
1694
  min-height: 40px;
1695
+ & > svg {
1696
+ width: 20px;
1697
+ height: 20px;
1698
+ }
1683
1699
  `;
1684
1700
  }
1685
1701
  };
@@ -1741,10 +1757,6 @@ var StyledIconButton = styled6__default.default.button`
1741
1757
  ${({ styleVar, color, isHovered }) => getStyleByStyleVar2(styleVar, color, isHovered)};
1742
1758
  ${({ sizeVar }) => getWidthAndHeightFromSizeVar(sizeVar)};
1743
1759
  ${({ disabled }) => getDisabledStyle(disabled)};
1744
- & > svg {
1745
- width: 20px;
1746
- height: 20px;
1747
- }
1748
1760
  `;
1749
1761
  var IconButton = React3.forwardRef(
1750
1762
  (_a, ref) => {
@@ -2135,7 +2147,7 @@ var InputWrapper = styled6__default.default.label`
2135
2147
  borderRadius
2136
2148
  })};
2137
2149
  justify-content: space-between;
2138
- gap: 8px;
2150
+ gap: ${({ gap }) => gap || "8px"};
2139
2151
  border: 1px solid ${(props) => getBorderColorByStatus(props)};
2140
2152
  background-color: ${exports.colorTokens.neutral0};
2141
2153
  overflow: hidden;
@@ -3035,7 +3047,7 @@ var StyledInput = styled6__default.default.input`
3035
3047
  padding: 4px 0 4px 12px;
3036
3048
  background-color: transparent;
3037
3049
  display: flex;
3038
- min-width: 64px;
3050
+ min-width: ${({ minWidth }) => minWidth || "64px"};
3039
3051
  width: 100%;
3040
3052
  border: none;
3041
3053
  box-sizing: border-box;
@@ -3128,7 +3140,12 @@ var Input = React3.forwardRef(
3128
3140
  width,
3129
3141
  borderRadius,
3130
3142
  customNumberInputHeight,
3131
- onKeyDown
3143
+ onKeyDown,
3144
+ sizeVar = "M",
3145
+ rightSource,
3146
+ minWidth,
3147
+ gap,
3148
+ initIsFocused
3132
3149
  } = _b, rest = __objRest(_b, [
3133
3150
  "onFocus",
3134
3151
  "onBlur",
@@ -3146,10 +3163,15 @@ var Input = React3.forwardRef(
3146
3163
  "width",
3147
3164
  "borderRadius",
3148
3165
  "customNumberInputHeight",
3149
- "onKeyDown"
3166
+ "onKeyDown",
3167
+ "sizeVar",
3168
+ "rightSource",
3169
+ "minWidth",
3170
+ "gap",
3171
+ "initIsFocused"
3150
3172
  ]);
3151
3173
  const [text, setText] = React3.useState("");
3152
- const [isFocused, setIsFocused] = React3.useState(false);
3174
+ const [isFocused, setIsFocused] = React3.useState(Boolean(initIsFocused));
3153
3175
  const [type, setType] = React3.useState(initialType);
3154
3176
  const [isHovered, setIsHovered] = React3.useState(false);
3155
3177
  const uniqueId = React3.useId();
@@ -3236,6 +3258,13 @@ var Input = React3.forwardRef(
3236
3258
  React3.useEffect(() => {
3237
3259
  setType(initialType);
3238
3260
  }, [initialType]);
3261
+ const height = sizeVar === "M" ? "40px" : "32px";
3262
+ React3.useEffect(() => {
3263
+ if (typeof initIsFocused === "undefined") {
3264
+ return;
3265
+ }
3266
+ setIsFocused(initIsFocused);
3267
+ }, [initIsFocused]);
3239
3268
  return /* @__PURE__ */ jsxRuntime.jsxs(
3240
3269
  InputWrapper,
3241
3270
  {
@@ -3248,11 +3277,12 @@ var Input = React3.forwardRef(
3248
3277
  onMouseLeave: handleOnMouseLeave,
3249
3278
  type,
3250
3279
  width,
3251
- height: "40px",
3252
- maxHeight: "40px",
3280
+ height,
3281
+ maxHeight: height,
3253
3282
  "data-shoplflow": "input",
3254
3283
  borderRadius,
3255
3284
  customNumberInputHeight,
3285
+ gap,
3256
3286
  children: [
3257
3287
  /* @__PURE__ */ jsxRuntime.jsx(
3258
3288
  StyledInput,
@@ -3267,6 +3297,7 @@ var Input = React3.forwardRef(
3267
3297
  type,
3268
3298
  id: uniqueId,
3269
3299
  ref: refs,
3300
+ minWidth,
3270
3301
  className: "body1_400" + (className ? ` ${className}` : "")
3271
3302
  }, rest)
3272
3303
  ),
@@ -3280,13 +3311,20 @@ var Input = React3.forwardRef(
3280
3311
  iconSource: assetFunction(type === "password" ? "ViewOffIcon" : "ViewOnIcon")
3281
3312
  }
3282
3313
  ) })
3283
- ] })
3314
+ ] }),
3315
+ rightSource && rightSource
3284
3316
  ]
3285
3317
  }
3286
3318
  );
3287
3319
  }
3288
3320
  );
3289
3321
  exports.Input = Input;
3322
+
3323
+ // src/components/Inputs/Input/Input.types.ts
3324
+ exports.InputSizeVariants = {
3325
+ S: "S",
3326
+ M: "M"
3327
+ };
3290
3328
  var StyledInputButton = styled6__default.default.div`
3291
3329
  display: flex;
3292
3330
  flex-direction: row;
@@ -3656,7 +3694,7 @@ var Tooltip = (_a) => {
3656
3694
  trigger,
3657
3695
  popper,
3658
3696
  placement = "bottom-start",
3659
- offset: offset3 = 4,
3697
+ offset: offset4 = 4,
3660
3698
  triggerRef,
3661
3699
  portalRef
3662
3700
  } = _b, popperProps = __objRest(_b, [
@@ -3682,7 +3720,7 @@ var Tooltip = (_a) => {
3682
3720
  }
3683
3721
  onOpenChange == null ? void 0 : onOpenChange(false);
3684
3722
  }, [open, onOpenChange]);
3685
- return /* @__PURE__ */ jsxRuntime.jsxs(exports.Popper, __spreadProps(__spreadValues({ offset: offset3, placement, middlewares: [core.flip(), core.shift({ padding: 5 })] }, popperProps), { children: [
3723
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Popper, __spreadProps(__spreadValues({ offset: offset4, placement, middlewares: [core.flip(), core.shift({ padding: 5 })] }, popperProps), { children: [
3686
3724
  /* @__PURE__ */ jsxRuntime.jsx(
3687
3725
  exports.Popper.Trigger,
3688
3726
  {
@@ -5778,6 +5816,176 @@ var WeekDatepicker = ({
5778
5816
  ] });
5779
5817
  };
5780
5818
  exports.WeekDatepicker = WeekDatepicker;
5819
+ var StyledNumberCombobox = styled6__default.default.div``;
5820
+ var IconWrapper2 = styled6__default.default(framerMotion.motion.div)`
5821
+ display: flex;
5822
+ width: fit-content;
5823
+ height: fit-content;
5824
+ `;
5825
+ var NumberCombobox = (_a) => {
5826
+ var _b = _a, {
5827
+ disabled,
5828
+ onSelect,
5829
+ onChange,
5830
+ value,
5831
+ width = "90px",
5832
+ onBlur,
5833
+ items,
5834
+ isError,
5835
+ sizeVar = "M",
5836
+ placeholder = "Enter",
5837
+ maxLength,
5838
+ className
5839
+ } = _b, rest = __objRest(_b, [
5840
+ "disabled",
5841
+ "onSelect",
5842
+ "onChange",
5843
+ "value",
5844
+ "width",
5845
+ "onBlur",
5846
+ "items",
5847
+ "isError",
5848
+ "sizeVar",
5849
+ "placeholder",
5850
+ "maxLength",
5851
+ "className"
5852
+ ]);
5853
+ const selector = React3.useRef(`shoplflow-${crypto.randomUUID()}-number-combobox`).current;
5854
+ const inputRef = React3.useRef(null);
5855
+ const [isOpen, setIsOpen] = utils.useOutsideClick({
5856
+ selector: `.${selector}`,
5857
+ useOutsideScroll: true
5858
+ });
5859
+ let _className = `${selector}`;
5860
+ if (className) {
5861
+ _className += ` ${className}`;
5862
+ }
5863
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledNumberCombobox, { "data-shoplflow": "NumberCombobox", color: "shopl300", className: _className, children: /* @__PURE__ */ jsxRuntime.jsxs(exports.Popper, { middlewares: [core.offset(4)], children: [
5864
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Trigger, { isOpen, className: _className, children: /* @__PURE__ */ jsxRuntime.jsx(
5865
+ exports.Input,
5866
+ __spreadValues({
5867
+ sizeVar,
5868
+ width,
5869
+ ref: inputRef,
5870
+ type: "number",
5871
+ style: { textAlign: "left", paddingRight: "0px" },
5872
+ className: _className,
5873
+ gap: "4px",
5874
+ initIsFocused: isOpen,
5875
+ value,
5876
+ onChange,
5877
+ onFocus: () => {
5878
+ setIsOpen(true);
5879
+ },
5880
+ autoCapitalize: "off",
5881
+ customNumberInputHeight: sizeVar === "S" ? "32px" : "40px",
5882
+ isError,
5883
+ minWidth: `calc(100% -32px)`,
5884
+ autoComplete: "off",
5885
+ autoCorrect: "off",
5886
+ placeholder,
5887
+ disabled,
5888
+ onKeyDown: (event) => {
5889
+ var _a2;
5890
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
5891
+ event.preventDefault();
5892
+ return;
5893
+ }
5894
+ setIsOpen(true);
5895
+ if (event.key === "Enter") {
5896
+ const currentValue = event.currentTarget.value;
5897
+ onSelect == null ? void 0 : onSelect(currentValue);
5898
+ setIsOpen(false);
5899
+ (_a2 = inputRef.current) == null ? void 0 : _a2.blur();
5900
+ return;
5901
+ }
5902
+ },
5903
+ maxLength,
5904
+ onBlur: (event) => {
5905
+ const target = event.target;
5906
+ const isNested = Boolean(target.closest(`.${_className}`));
5907
+ if (isNested) {
5908
+ return;
5909
+ }
5910
+ onBlur == null ? void 0 : onBlur(event);
5911
+ },
5912
+ rightSource: /* @__PURE__ */ jsxRuntime.jsx(exports.StackContainer.Horizontal, { padding: "0px 4px 0px 0px", children: /* @__PURE__ */ jsxRuntime.jsx(
5913
+ exports.IconButton,
5914
+ {
5915
+ sizeVar: "XS",
5916
+ styleVar: "GHOST",
5917
+ className: _className,
5918
+ onClick: () => {
5919
+ if (disabled) {
5920
+ return;
5921
+ }
5922
+ setIsOpen((prev) => !prev);
5923
+ },
5924
+ style: { cursor: disabled ? "not-allowed" : "cursor" },
5925
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5926
+ IconWrapper2,
5927
+ {
5928
+ animate: {
5929
+ rotate: isOpen ? 180 : 0,
5930
+ transition: {
5931
+ duration: 0.2
5932
+ }
5933
+ },
5934
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5935
+ exports.Icon,
5936
+ {
5937
+ iconSource: ShoplAssets.UpArrowSolidXsmallIcon,
5938
+ sizeVar: "XS",
5939
+ color: "neutral400",
5940
+ style: { cursor: disabled ? "not-allowed" : "cursor" }
5941
+ }
5942
+ )
5943
+ }
5944
+ )
5945
+ }
5946
+ ) })
5947
+ }, rest)
5948
+ ) }),
5949
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
5950
+ SimpleBarReact__default.default,
5951
+ {
5952
+ className: _className,
5953
+ style: {
5954
+ height: "128px",
5955
+ maxHeight: "128px",
5956
+ width,
5957
+ padding: "4px",
5958
+ filter: "drop-shadow(0px 8px 16px rgba(0, 0, 0, 0.12))",
5959
+ boxShadow: "0px 8px 16px rgba(0, 0, 0, 0.12)",
5960
+ borderRadius: "8px",
5961
+ backgroundColor: exports.colorTokens.neutral0
5962
+ },
5963
+ children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
5964
+ exports.Menu,
5965
+ {
5966
+ isSelected: value === item.value,
5967
+ onClick: () => {
5968
+ if (disabled) {
5969
+ return;
5970
+ }
5971
+ onSelect == null ? void 0 : onSelect(item.value);
5972
+ setIsOpen(false);
5973
+ },
5974
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_400", children: item.label })
5975
+ },
5976
+ item.value
5977
+ ))
5978
+ }
5979
+ ) })
5980
+ ] }) });
5981
+ };
5982
+ exports.NumberCombobox = NumberCombobox;
5983
+
5984
+ // src/components/Comboboxs/NumberCombobox/NumberCombobox.types.ts
5985
+ exports.NumberComboboxSizeVariants = {
5986
+ S: "S",
5987
+ M: "M"
5988
+ };
5781
5989
  var SpaceMarginWrapper = styled6__default.default(framerMotion.motion.div)`
5782
5990
  position: relative;
5783
5991
  display: flex;