@shoplflow/base 0.45.14 → 0.45.16

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
@@ -799,7 +799,9 @@ var Container = styled6__default.default.div`
799
799
  ${({ hasChangeAnimation }) => hasChangeAnimation && react$1.css`
800
800
  transition:
801
801
  width 0.3s ease-in-out,
802
- max-width 0.3s ease-in-out;
802
+ max-width 0.3s ease-in-out,
803
+ height 0.3s ease-in-out,
804
+ max-height 0.3s ease-in-out;
803
805
  `}
804
806
  display: flex;
805
807
  flex-direction: column;
@@ -903,22 +905,33 @@ var useViewportSizeObserver = () => {
903
905
  return size2;
904
906
  };
905
907
  var ModalOptionContext = React3.createContext({
906
- heightToDeduct: 0,
907
- setHeightToDeduct: utils.noop,
908
- clearHeightToDeduct: utils.noop
908
+ topHeight: 0,
909
+ bottomHeight: 0,
910
+ setTopHeight: utils.noop,
911
+ setBottomHeight: utils.noop,
912
+ clearTopHeight: utils.noop,
913
+ clearBottomHeight: utils.noop
909
914
  });
910
915
  var ModalOptionContextProvider = ({ children }) => {
911
- const [heightToDeduct, setHeightToDeduct] = React3.useState(0);
912
- const controlHeightToDeduct = React3.useCallback((heightToAdd) => {
913
- setHeightToDeduct((prev) => prev + heightToAdd);
916
+ const [topHeight, setTopHeight] = React3.useState(0);
917
+ const [bottomHeight, setBottomHeight] = React3.useState(0);
918
+ const clearTopHeight = React3.useCallback(() => {
919
+ setTopHeight(0);
914
920
  }, []);
915
- const clearHeightToDeduct = React3.useCallback(() => {
916
- setHeightToDeduct(0);
921
+ const clearBottomHeight = React3.useCallback(() => {
922
+ setBottomHeight(0);
917
923
  }, []);
918
924
  return /* @__PURE__ */ jsxRuntime.jsx(
919
925
  ModalOptionContext.Provider,
920
926
  {
921
- value: { heightToDeduct, setHeightToDeduct: controlHeightToDeduct, clearHeightToDeduct },
927
+ value: {
928
+ topHeight,
929
+ bottomHeight,
930
+ setTopHeight,
931
+ setBottomHeight,
932
+ clearTopHeight,
933
+ clearBottomHeight
934
+ },
922
935
  children
923
936
  }
924
937
  );
@@ -1010,7 +1023,8 @@ var ModalBody = ({
1010
1023
  padding
1011
1024
  }) => {
1012
1025
  const { height: windowHeight } = useViewportSizeObserver();
1013
- const { heightToDeduct } = useModalOption();
1026
+ const { topHeight, bottomHeight } = useModalOption();
1027
+ const heightToDeduct = topHeight + bottomHeight;
1014
1028
  const headerHeight = 64;
1015
1029
  const footerHeight = 72;
1016
1030
  const topBottomMargin = 64;
@@ -1108,29 +1122,45 @@ ModalHeader[exports.MODAL_HEADER_KEY] = true;
1108
1122
  var ModalHeader_default = ModalHeader;
1109
1123
  var ModalTop = ({ children }) => {
1110
1124
  const [topRef, setTopRef] = React3.useState(null);
1111
- const { setHeightToDeduct, clearHeightToDeduct } = useModalOption();
1125
+ const { setTopHeight, clearTopHeight } = useModalOption();
1112
1126
  React3.useEffect(() => {
1113
- if (!topRef) {
1127
+ if (!topRef || !setTopHeight) {
1114
1128
  return;
1115
1129
  }
1116
- const { height } = topRef.getBoundingClientRect();
1117
- setHeightToDeduct == null ? void 0 : setHeightToDeduct(height);
1118
- return () => clearHeightToDeduct();
1119
- }, [topRef, setHeightToDeduct, clearHeightToDeduct]);
1130
+ const updateHeight = () => {
1131
+ const { height } = topRef.getBoundingClientRect();
1132
+ setTopHeight(height);
1133
+ };
1134
+ updateHeight();
1135
+ const resizeObserver = new ResizeObserver(updateHeight);
1136
+ resizeObserver.observe(topRef);
1137
+ return () => {
1138
+ resizeObserver.disconnect();
1139
+ clearTopHeight();
1140
+ };
1141
+ }, [topRef, setTopHeight, clearTopHeight]);
1120
1142
  return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setTopRef, children });
1121
1143
  };
1122
1144
  var ModalTop_default = ModalTop;
1123
1145
  var ModalBottom = ({ children }) => {
1124
1146
  const [bottomRef, setBottomRef] = React3.useState(null);
1125
- const { setHeightToDeduct, clearHeightToDeduct } = useModalOption();
1147
+ const { setBottomHeight, clearBottomHeight } = useModalOption();
1126
1148
  React3.useEffect(() => {
1127
- if (!bottomRef) {
1149
+ if (!bottomRef || !setBottomHeight) {
1128
1150
  return;
1129
1151
  }
1130
- const { height } = bottomRef.getBoundingClientRect();
1131
- setHeightToDeduct == null ? void 0 : setHeightToDeduct(height);
1132
- return () => clearHeightToDeduct();
1133
- }, [bottomRef, setHeightToDeduct, clearHeightToDeduct]);
1152
+ const updateHeight = () => {
1153
+ const { height } = bottomRef.getBoundingClientRect();
1154
+ setBottomHeight(height);
1155
+ };
1156
+ updateHeight();
1157
+ const resizeObserver = new ResizeObserver(updateHeight);
1158
+ resizeObserver.observe(bottomRef);
1159
+ return () => {
1160
+ resizeObserver.disconnect();
1161
+ clearBottomHeight();
1162
+ };
1163
+ }, [bottomRef, setBottomHeight, clearBottomHeight]);
1134
1164
  return /* @__PURE__ */ jsxRuntime.jsx(BottomContainer, { ref: setBottomRef, children });
1135
1165
  };
1136
1166
  exports.ModalHandlerContext = React3.createContext({
@@ -3670,6 +3700,12 @@ var StyledInput = styled6__default.default.input`
3670
3700
  box-sizing: inherit;
3671
3701
  }
3672
3702
  `;
3703
+ var LeftElementWrapper2 = styled6__default.default.div`
3704
+ padding: ${({ sizeVar }) => sizeVar === "S" ? "0 0 0 8px" : "0 0 0 12px"};
3705
+ display: flex;
3706
+ flex-direction: row;
3707
+ align-items: center;
3708
+ `;
3673
3709
  var RightElementWrapper2 = styled6__default.default.div`
3674
3710
  padding: ${({ sizeVar, type, initialType }) => {
3675
3711
  if (initialType === "password" || type === "password") {
@@ -3828,7 +3864,8 @@ var Input = React3.forwardRef(
3828
3864
  minWidth,
3829
3865
  gap,
3830
3866
  initIsFocused,
3831
- rightSourceStyle
3867
+ rightSourceStyle,
3868
+ leftSource
3832
3869
  } = _b, rest = __objRest(_b, [
3833
3870
  "onFocus",
3834
3871
  "onBlur",
@@ -3852,7 +3889,8 @@ var Input = React3.forwardRef(
3852
3889
  "minWidth",
3853
3890
  "gap",
3854
3891
  "initIsFocused",
3855
- "rightSourceStyle"
3892
+ "rightSourceStyle",
3893
+ "leftSource"
3856
3894
  ]);
3857
3895
  const [text, setText] = React3.useState("");
3858
3896
  const [isFocused, setIsFocused] = React3.useState(Boolean(initIsFocused));
@@ -3969,6 +4007,7 @@ var Input = React3.forwardRef(
3969
4007
  gap,
3970
4008
  sizeVar,
3971
4009
  children: [
4010
+ leftSource && /* @__PURE__ */ jsxRuntime.jsx(LeftElementWrapper2, { sizeVar, initialType, style: rightSourceStyle, children: leftSource }),
3972
4011
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative", width: "100%" }, children: [
3973
4012
  /* @__PURE__ */ jsxRuntime.jsx(
3974
4013
  StyledInput,
package/dist/index.d.cts CHANGED
@@ -1100,7 +1100,7 @@ declare const InputSizeVariants: {
1100
1100
  readonly M: "M";
1101
1101
  };
1102
1102
  declare type InputSizeVariantType = $Values<typeof InputSizeVariants>;
1103
- interface InputProps extends InputOptionProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'width'>, DisableProps, RightElementProps {
1103
+ interface InputProps extends InputOptionProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'width'>, DisableProps, LeftElementProps, RightElementProps {
1104
1104
  }
1105
1105
  interface InputOptionProps extends ErrorProps, SizeVariantProps<InputSizeVariantType> {
1106
1106
  width?: string;
package/dist/index.d.ts CHANGED
@@ -1100,7 +1100,7 @@ declare const InputSizeVariants: {
1100
1100
  readonly M: "M";
1101
1101
  };
1102
1102
  declare type InputSizeVariantType = $Values<typeof InputSizeVariants>;
1103
- interface InputProps extends InputOptionProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'width'>, DisableProps, RightElementProps {
1103
+ interface InputProps extends InputOptionProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'width'>, DisableProps, LeftElementProps, RightElementProps {
1104
1104
  }
1105
1105
  interface InputOptionProps extends ErrorProps, SizeVariantProps<InputSizeVariantType> {
1106
1106
  width?: string;
package/dist/index.js CHANGED
@@ -772,7 +772,9 @@ var Container = styled6.div`
772
772
  ${({ hasChangeAnimation }) => hasChangeAnimation && css`
773
773
  transition:
774
774
  width 0.3s ease-in-out,
775
- max-width 0.3s ease-in-out;
775
+ max-width 0.3s ease-in-out,
776
+ height 0.3s ease-in-out,
777
+ max-height 0.3s ease-in-out;
776
778
  `}
777
779
  display: flex;
778
780
  flex-direction: column;
@@ -876,22 +878,33 @@ var useViewportSizeObserver = () => {
876
878
  return size2;
877
879
  };
878
880
  var ModalOptionContext = createContext({
879
- heightToDeduct: 0,
880
- setHeightToDeduct: noop,
881
- clearHeightToDeduct: noop
881
+ topHeight: 0,
882
+ bottomHeight: 0,
883
+ setTopHeight: noop,
884
+ setBottomHeight: noop,
885
+ clearTopHeight: noop,
886
+ clearBottomHeight: noop
882
887
  });
883
888
  var ModalOptionContextProvider = ({ children }) => {
884
- const [heightToDeduct, setHeightToDeduct] = useState(0);
885
- const controlHeightToDeduct = useCallback((heightToAdd) => {
886
- setHeightToDeduct((prev) => prev + heightToAdd);
889
+ const [topHeight, setTopHeight] = useState(0);
890
+ const [bottomHeight, setBottomHeight] = useState(0);
891
+ const clearTopHeight = useCallback(() => {
892
+ setTopHeight(0);
887
893
  }, []);
888
- const clearHeightToDeduct = useCallback(() => {
889
- setHeightToDeduct(0);
894
+ const clearBottomHeight = useCallback(() => {
895
+ setBottomHeight(0);
890
896
  }, []);
891
897
  return /* @__PURE__ */ jsx(
892
898
  ModalOptionContext.Provider,
893
899
  {
894
- value: { heightToDeduct, setHeightToDeduct: controlHeightToDeduct, clearHeightToDeduct },
900
+ value: {
901
+ topHeight,
902
+ bottomHeight,
903
+ setTopHeight,
904
+ setBottomHeight,
905
+ clearTopHeight,
906
+ clearBottomHeight
907
+ },
895
908
  children
896
909
  }
897
910
  );
@@ -983,7 +996,8 @@ var ModalBody = ({
983
996
  padding
984
997
  }) => {
985
998
  const { height: windowHeight } = useViewportSizeObserver();
986
- const { heightToDeduct } = useModalOption();
999
+ const { topHeight, bottomHeight } = useModalOption();
1000
+ const heightToDeduct = topHeight + bottomHeight;
987
1001
  const headerHeight = 64;
988
1002
  const footerHeight = 72;
989
1003
  const topBottomMargin = 64;
@@ -1081,29 +1095,45 @@ ModalHeader[MODAL_HEADER_KEY] = true;
1081
1095
  var ModalHeader_default = ModalHeader;
1082
1096
  var ModalTop = ({ children }) => {
1083
1097
  const [topRef, setTopRef] = useState(null);
1084
- const { setHeightToDeduct, clearHeightToDeduct } = useModalOption();
1098
+ const { setTopHeight, clearTopHeight } = useModalOption();
1085
1099
  useEffect(() => {
1086
- if (!topRef) {
1100
+ if (!topRef || !setTopHeight) {
1087
1101
  return;
1088
1102
  }
1089
- const { height } = topRef.getBoundingClientRect();
1090
- setHeightToDeduct == null ? void 0 : setHeightToDeduct(height);
1091
- return () => clearHeightToDeduct();
1092
- }, [topRef, setHeightToDeduct, clearHeightToDeduct]);
1103
+ const updateHeight = () => {
1104
+ const { height } = topRef.getBoundingClientRect();
1105
+ setTopHeight(height);
1106
+ };
1107
+ updateHeight();
1108
+ const resizeObserver = new ResizeObserver(updateHeight);
1109
+ resizeObserver.observe(topRef);
1110
+ return () => {
1111
+ resizeObserver.disconnect();
1112
+ clearTopHeight();
1113
+ };
1114
+ }, [topRef, setTopHeight, clearTopHeight]);
1093
1115
  return /* @__PURE__ */ jsx("div", { ref: setTopRef, children });
1094
1116
  };
1095
1117
  var ModalTop_default = ModalTop;
1096
1118
  var ModalBottom = ({ children }) => {
1097
1119
  const [bottomRef, setBottomRef] = useState(null);
1098
- const { setHeightToDeduct, clearHeightToDeduct } = useModalOption();
1120
+ const { setBottomHeight, clearBottomHeight } = useModalOption();
1099
1121
  useEffect(() => {
1100
- if (!bottomRef) {
1122
+ if (!bottomRef || !setBottomHeight) {
1101
1123
  return;
1102
1124
  }
1103
- const { height } = bottomRef.getBoundingClientRect();
1104
- setHeightToDeduct == null ? void 0 : setHeightToDeduct(height);
1105
- return () => clearHeightToDeduct();
1106
- }, [bottomRef, setHeightToDeduct, clearHeightToDeduct]);
1125
+ const updateHeight = () => {
1126
+ const { height } = bottomRef.getBoundingClientRect();
1127
+ setBottomHeight(height);
1128
+ };
1129
+ updateHeight();
1130
+ const resizeObserver = new ResizeObserver(updateHeight);
1131
+ resizeObserver.observe(bottomRef);
1132
+ return () => {
1133
+ resizeObserver.disconnect();
1134
+ clearBottomHeight();
1135
+ };
1136
+ }, [bottomRef, setBottomHeight, clearBottomHeight]);
1107
1137
  return /* @__PURE__ */ jsx(BottomContainer, { ref: setBottomRef, children });
1108
1138
  };
1109
1139
  var ModalHandlerContext = createContext({
@@ -3643,6 +3673,12 @@ var StyledInput = styled6.input`
3643
3673
  box-sizing: inherit;
3644
3674
  }
3645
3675
  `;
3676
+ var LeftElementWrapper2 = styled6.div`
3677
+ padding: ${({ sizeVar }) => sizeVar === "S" ? "0 0 0 8px" : "0 0 0 12px"};
3678
+ display: flex;
3679
+ flex-direction: row;
3680
+ align-items: center;
3681
+ `;
3646
3682
  var RightElementWrapper2 = styled6.div`
3647
3683
  padding: ${({ sizeVar, type, initialType }) => {
3648
3684
  if (initialType === "password" || type === "password") {
@@ -3801,7 +3837,8 @@ var Input = forwardRef(
3801
3837
  minWidth,
3802
3838
  gap,
3803
3839
  initIsFocused,
3804
- rightSourceStyle
3840
+ rightSourceStyle,
3841
+ leftSource
3805
3842
  } = _b, rest = __objRest(_b, [
3806
3843
  "onFocus",
3807
3844
  "onBlur",
@@ -3825,7 +3862,8 @@ var Input = forwardRef(
3825
3862
  "minWidth",
3826
3863
  "gap",
3827
3864
  "initIsFocused",
3828
- "rightSourceStyle"
3865
+ "rightSourceStyle",
3866
+ "leftSource"
3829
3867
  ]);
3830
3868
  const [text, setText] = useState("");
3831
3869
  const [isFocused, setIsFocused] = useState(Boolean(initIsFocused));
@@ -3942,6 +3980,7 @@ var Input = forwardRef(
3942
3980
  gap,
3943
3981
  sizeVar,
3944
3982
  children: [
3983
+ leftSource && /* @__PURE__ */ jsx(LeftElementWrapper2, { sizeVar, initialType, style: rightSourceStyle, children: leftSource }),
3945
3984
  /* @__PURE__ */ jsxs("div", { style: { position: "relative", width: "100%" }, children: [
3946
3985
  /* @__PURE__ */ jsx(
3947
3986
  StyledInput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoplflow/base",
3
- "version": "0.45.14",
3
+ "version": "0.45.16",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -99,8 +99,8 @@
99
99
  "react-dom": "^18.2.0",
100
100
  "simplebar-react": "^3.2.6",
101
101
  "@shoplflow/hada-assets": "^0.1.10",
102
- "@shoplflow/utils": "^0.7.2",
103
- "@shoplflow/shopl-assets": "^0.12.33"
102
+ "@shoplflow/shopl-assets": "^0.12.35",
103
+ "@shoplflow/utils": "^0.7.2"
104
104
  },
105
105
  "homepage": "https://github.com/shopl/shoplflow#readme",
106
106
  "scripts": {