@shoplflow/base 0.24.14 → 0.24.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
@@ -644,6 +644,16 @@ var getModalBodyTopBottomPadding = (isIncludeHeader) => {
644
644
  padding-bottom: 24px;
645
645
  `;
646
646
  };
647
+ var checkMaxHeight = (height, viewport) => {
648
+ const topBottomMargin = 64;
649
+ if (height > 1200) {
650
+ return 1200 - topBottomMargin;
651
+ }
652
+ if (height > viewport) {
653
+ return viewport - topBottomMargin;
654
+ }
655
+ return height - topBottomMargin;
656
+ };
647
657
  var Container = styled5__default.default.div`
648
658
  display: flex;
649
659
  flex-direction: column;
@@ -652,7 +662,7 @@ var Container = styled5__default.default.div`
652
662
  box-shadow: ${exports.boxShadowTokens.dropShadow};
653
663
  overflow: hidden;
654
664
  flex-grow: 1;
655
- height: ${({ height }) => height ? `${height}px` : "initial"};
665
+ height: ${({ height, viewport }) => height ? `${checkMaxHeight(height, viewport)}px` : "initial"};
656
666
  min-height: 180px;
657
667
  max-height: 1200px;
658
668
  width: ${({ sizeVar }) => getModalWidthFromSize(sizeVar)}px;
@@ -674,8 +684,9 @@ var BodyContainer = styled5__default.default.div`
674
684
  overflow: hidden;
675
685
  flex-direction: column;
676
686
  background: ${exports.colorTokens.neutral0};
677
- min-height: 112px;
678
- min-height: ${({ height }) => height};
687
+ box-sizing: border-box;
688
+ min-height: ${({ minHeight }) => minHeight};
689
+ max-height: ${({ maxHeight }) => maxHeight}px;
679
690
  flex: 1;
680
691
  ${({ isIncludeHeader }) => getModalBodyTopBottomPadding(isIncludeHeader)}
681
692
  `;
@@ -685,7 +696,7 @@ var ModalBodyContainerInner = styled5__default.default.div`
685
696
  flex-direction: column;
686
697
  flex-grow: 1;
687
698
  //스크롤 생성시 하단 padding 적용하기 위한 설정
688
- height: calc(100%);
699
+ height: 100%;
689
700
  box-sizing: border-box;
690
701
  `;
691
702
  var ModalBodyContent = styled5__default.default.div`
@@ -720,9 +731,23 @@ exports.ModalSize = {
720
731
  };
721
732
  exports.MODAL_HEADER_KEY = Symbol("MODAL_HEADER");
722
733
  exports.MODAL_FOOTER_KEY = Symbol("MODAL_FOOTER");
734
+ var useViewportSizeObserver = () => {
735
+ const [size2, setSize] = React2.useState({ width: window.innerWidth, height: window.innerHeight });
736
+ React2.useEffect(() => {
737
+ const handleResize = () => {
738
+ setSize({ width: window.innerWidth, height: window.innerHeight });
739
+ };
740
+ window.addEventListener("resize", handleResize);
741
+ return () => window.removeEventListener("resize", handleResize);
742
+ }, []);
743
+ return size2;
744
+ };
723
745
  var ModalContainer = (_a) => {
724
- var _b = _a, { children, outsideClick = utils.noop } = _b, rest = __objRest(_b, ["children", "outsideClick"]);
746
+ var _b = _a, { children, height, outsideClick = utils.noop } = _b, rest = __objRest(_b, ["children", "height", "outsideClick"]);
725
747
  const ref = utils.useParentElementClick(outsideClick);
748
+ const { height: windowHeight } = useViewportSizeObserver();
749
+ const topBottomMargin = 64;
750
+ const heightWidthMargin = height ? height + topBottomMargin : void 0;
726
751
  const childrenArray = React2__namespace.default.Children.toArray(children);
727
752
  const findHeader = childrenArray.find((child) => {
728
753
  if (!React2__namespace.default.isValidElement(child)) {
@@ -748,10 +773,10 @@ var ModalContainer = (_a) => {
748
773
  isIncludeHeader: Boolean(findHeader),
749
774
  isIncludeFooter: Boolean(findFooter),
750
775
  sizeVar: rest.sizeVar,
751
- height: rest.height
776
+ height: heightWidthMargin
752
777
  });
753
778
  });
754
- return /* @__PURE__ */ jsxRuntime.jsx(Container, __spreadProps(__spreadValues({ ref }, rest), { "data-shoplflow": "Modal", children: addPropInChildren }));
779
+ return /* @__PURE__ */ jsxRuntime.jsx(Container, __spreadProps(__spreadValues({ ref }, rest), { height: heightWidthMargin, viewport: windowHeight, "data-shoplflow": "Modal", children: addPropInChildren }));
755
780
  };
756
781
  var ModalContainer_default = ModalContainer;
757
782
  var ModalFooter = ({ children }) => {
@@ -771,9 +796,7 @@ var ModalBody = ({
771
796
  sizeVar,
772
797
  height: modalContainerHeight
773
798
  }) => {
774
- const { height: windowHeight } = utils.useResizeObserver(document.body, {
775
- trackHeight: true
776
- });
799
+ const { height: windowHeight } = useViewportSizeObserver();
777
800
  const headerHeight = 64;
778
801
  const footerHeight = 64;
779
802
  const topBottomMargin = 64;
@@ -790,21 +813,44 @@ var ModalBody = ({
790
813
  const headerFooterHeight = React2.useMemo(() => getHeaderFooterHeight(), [getHeaderFooterHeight]);
791
814
  const setAutoHeightMin = () => {
792
815
  if (modalContainerHeight) {
793
- return modalContainerHeight - headerFooterHeight;
816
+ if (modalContainerHeight <= 1200) {
817
+ if (windowHeight < modalContainerHeight) {
818
+ return windowHeight - topBottomMargin - headerFooterHeight;
819
+ }
820
+ return 1200 - topBottomMargin - headerFooterHeight;
821
+ }
822
+ return modalContainerHeight - topBottomMargin - headerFooterHeight;
794
823
  } else {
795
824
  return "100%";
796
825
  }
797
826
  };
798
- const heightUnderMaxHeight = windowHeight - topBottomMargin - headerFooterHeight;
799
- const heightOverMaxHeight = 1200 - topBottomMargin - headerFooterHeight;
800
- return /* @__PURE__ */ jsxRuntime.jsx(BodyContainer, { isIncludeHeader, height: setAutoHeightMin(), children: /* @__PURE__ */ jsxRuntime.jsx(
827
+ const setAutoHeightMax = () => {
828
+ if (modalContainerHeight) {
829
+ if (modalContainerHeight > 1200) {
830
+ return 1200 - topBottomMargin - headerFooterHeight;
831
+ }
832
+ if (modalContainerHeight <= 1200) {
833
+ if (windowHeight < modalContainerHeight) {
834
+ return windowHeight - topBottomMargin - headerFooterHeight;
835
+ }
836
+ return modalContainerHeight - topBottomMargin - headerFooterHeight;
837
+ }
838
+ }
839
+ if (!modalContainerHeight) {
840
+ const heightUnderMaxHeight = windowHeight - topBottomMargin - headerFooterHeight;
841
+ const heightOverMaxHeight = 1200 - topBottomMargin - headerFooterHeight;
842
+ return windowHeight > 1200 ? heightOverMaxHeight : heightUnderMaxHeight;
843
+ }
844
+ return "100%";
845
+ };
846
+ return /* @__PURE__ */ jsxRuntime.jsx(BodyContainer, { isIncludeHeader, minHeight: setAutoHeightMin(), maxHeight: setAutoHeightMax(), children: /* @__PURE__ */ jsxRuntime.jsx(
801
847
  exports.ScrollArea,
802
848
  {
803
849
  id: `scrollbar`,
804
850
  universal: true,
805
851
  autoHeight: !modalContainerHeight,
806
852
  autoHeightMin: setAutoHeightMin(),
807
- autoHeightMax: windowHeight > 1200 ? heightOverMaxHeight : heightUnderMaxHeight,
853
+ autoHeightMax: setAutoHeightMax(),
808
854
  style: {
809
855
  height: "100%",
810
856
  overflow: "hidden"
@@ -888,12 +934,13 @@ var ModalProvider = ({ children }) => {
888
934
  };
889
935
  const dispatch = React2.useMemo(() => ({ addModal, removeModal }), []);
890
936
  React2.useEffect(() => {
891
- if (openedModals.length === 1) {
892
- document.body.style.cssText = "overflow:hidden";
893
- return () => {
894
- document.body.style.cssText = "overflow:unset";
895
- };
937
+ if (openedModals.length !== 1) {
938
+ return;
896
939
  }
940
+ document.body.style.cssText = "overflow:hidden";
941
+ return () => {
942
+ document.body.style.cssText = "overflow:unset";
943
+ };
897
944
  }, [openedModals.length]);
898
945
  return /* @__PURE__ */ jsxRuntime.jsx(exports.ModalContext.Provider, { value: openedModals, children: /* @__PURE__ */ jsxRuntime.jsx(exports.ModalHandlerContext.Provider, { value: dispatch, children }) });
899
946
  };
@@ -1146,19 +1193,19 @@ var getNextColor = (color, step = 1) => {
1146
1193
  };
1147
1194
  const sortColorToken = findColorToken.sort((a, b) => extractNumbers(a) - extractNumbers(b));
1148
1195
  const currentIndex = sortColorToken.indexOf(color);
1149
- let newIndex = currentIndex + step;
1150
- let potentialToken = sortColorToken[newIndex];
1151
- while (potentialToken.endsWith("_5") || potentialToken.includes("50")) {
1196
+ let newIndex = currentIndex;
1197
+ let stepCount = 0;
1198
+ while (stepCount < Math.abs(step)) {
1152
1199
  newIndex += Math.sign(step);
1153
- if (newIndex < 0) {
1154
- potentialToken = sortColorToken[0];
1200
+ if (newIndex < 0 || newIndex >= sortColorToken.length) {
1201
+ break;
1155
1202
  }
1156
- if (newIndex >= sortColorToken.length) {
1157
- potentialToken = sortColorToken[sortColorToken.length - 1];
1203
+ if (!sortColorToken[newIndex].endsWith("_5") && !sortColorToken[newIndex].includes("50")) {
1204
+ stepCount++;
1158
1205
  }
1159
- potentialToken = sortColorToken[newIndex];
1160
1206
  }
1161
- return potentialToken;
1207
+ newIndex = Math.max(0, Math.min(newIndex, sortColorToken.length - 1));
1208
+ return sortColorToken[newIndex];
1162
1209
  };
1163
1210
 
1164
1211
  // src/components/Chips/ChipButton/ChipButton.styled.ts
@@ -1558,7 +1605,9 @@ var StyledCallout = styled5__default.default.div`
1558
1605
  `;
1559
1606
  var StyledCalloutIcon = styled5__default.default.svg`
1560
1607
  display: flex;
1608
+ height: 20px;
1561
1609
  min-height: 20px;
1610
+ width: 20px;
1562
1611
  min-width: 20px;
1563
1612
  `;
1564
1613
  styled5__default.default.div`
@@ -1908,7 +1957,7 @@ var DropdownButton = React2.forwardRef(
1908
1957
  transition: {
1909
1958
  duration: 0.2
1910
1959
  },
1911
- children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.DownArrowSolidXsmallIcon, color: "neutral400", sizeVar: "S" })
1960
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.DownArrowSolidXsmallIcon, color: "neutral400", sizeVar: "XS" })
1912
1961
  }
1913
1962
  )
1914
1963
  ] }))