@drivy/cobalt 1.3.0 → 1.3.1

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.
@@ -7,9 +7,7 @@ const MultiStepModal = ({ stepData = null, close, steps, onHidden, useMidSizeHei
7
7
  const [currentStep, setCurrentStep] = useState(0);
8
8
  useEffect(() => {
9
9
  var _a, _b;
10
- (_b = (_a = bodyScrollContentRef.current) === null || _a === void 0 ? void 0 : _a.children.item(currentStep)) === null || _b === void 0 ? void 0 : _b.scrollIntoView({
11
- behavior: "smooth",
12
- });
10
+ (_b = (_a = bodyScrollContentRef.current) === null || _a === void 0 ? void 0 : _a.children.item(currentStep)) === null || _b === void 0 ? void 0 : _b.scrollIntoView();
13
11
  }, [currentStep]);
14
12
  const handleNextStep = () => {
15
13
  setCurrentStep(currentStep >= steps.length - 1 ? currentStep : currentStep + 1);
@@ -32,7 +30,7 @@ const MultiStepModal = ({ stepData = null, close, steps, onHidden, useMidSizeHei
32
30
  ? "c-opacity-0 c-grid-rows-[0.5fr]"
33
31
  : "c-opacity-0 c-grid-rows-[0fr]";
34
32
  return (React.createElement(Modal, { ...modalProps, title: React.createElement(CurrentStepComponents.title, { ...stepProps }), close: close, onHidden: onModalClosed },
35
- React.createElement("div", { className: "c-w-full c-overflow-x-hidden" },
33
+ React.createElement("div", { className: "c-w-full c-overflow-x-hidden c-scroll-smooth" },
36
34
  React.createElement("div", { className: "c-py-sm", ref: bodyScrollContentRef, style: { width: `${steps.length * 100}%` } }, steps.map((StepComponents, index) => {
37
35
  return (React.createElement("div", { key: "modal_step_" + index, className: cx("c-inline-grid c-align-top c-transition-all c-duration-500", {
38
36
  "c-opacity-100 c-grid-rows-[1fr]": index === currentStep,
@@ -1 +1 @@
1
- {"version":3,"file":"MultiStepModal.js","sources":["../../../src/components/Modal/MultiStepModal.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\"\nimport cx from \"classnames\"\nimport Modal, { ModalPropsType } from \".\"\n\ntype StepComponentType<T> = (props: {\n navigation: {\n nextStep: () => void\n previousStep: () => void\n closeModal: () => void\n }\n data: T\n}) => React.ReactNode\n\nexport type ModalStepType<T> = {\n title: StepComponentType<T>\n content: StepComponentType<T>\n footer?: StepComponentType<T>\n}\n\ntype MultiStepsModalProps<T = null> = {\n stepData?: T\n close: () => void\n onHidden?: (currentStepIndex: number) => void\n steps: ModalStepType<T>[]\n useMidSizeHeight?: boolean\n} & Omit<ModalPropsType, \"children\" | \"onHidden\" | \"close\">\n\nconst MultiStepModal = <T,>({\n stepData = null as T,\n close,\n steps,\n onHidden,\n useMidSizeHeight = true,\n ...modalProps\n}: MultiStepsModalProps<T>) => {\n const bodyScrollContentRef = useRef<HTMLDivElement>(null)\n const [currentStep, setCurrentStep] = useState(0)\n\n useEffect(() => {\n bodyScrollContentRef.current?.children.item(currentStep)?.scrollIntoView({\n behavior: \"smooth\",\n })\n }, [currentStep])\n\n const handleNextStep = () => {\n setCurrentStep(\n currentStep >= steps.length - 1 ? currentStep : currentStep + 1\n )\n }\n\n const handlePreviousStep = () => {\n setCurrentStep(currentStep <= 0 ? 0 : currentStep - 1)\n }\n\n const onModalClosed = () => {\n onHidden?.(currentStep)\n setCurrentStep(0)\n }\n\n const navigation = {\n nextStep: handleNextStep,\n previousStep: handlePreviousStep,\n closeModal: close,\n }\n\n const CurrentStepComponents = steps[currentStep]\n const stepProps = { data: stepData, navigation }\n\n const minimumScale = useMidSizeHeight\n ? \"c-opacity-0 c-grid-rows-[0.5fr]\"\n : \"c-opacity-0 c-grid-rows-[0fr]\"\n\n return (\n <Modal\n {...modalProps}\n title={<CurrentStepComponents.title {...stepProps} />}\n close={close}\n onHidden={onModalClosed}\n >\n <div className=\"c-w-full c-overflow-x-hidden\">\n <div\n className=\"c-py-sm\"\n ref={bodyScrollContentRef}\n style={{ width: `${steps.length * 100}%` }}\n >\n {steps.map((StepComponents, index) => {\n return (\n <div\n key={\"modal_step_\" + index}\n className={cx(\n \"c-inline-grid c-align-top c-transition-all c-duration-500\",\n {\n \"c-opacity-100 c-grid-rows-[1fr]\": index === currentStep,\n [minimumScale]: index !== currentStep,\n }\n )}\n style={{ width: `${100 / steps.length}%` }}\n >\n <div className=\"c-overflow-hidden\">\n <StepComponents.content {...stepProps} />\n </div>\n </div>\n )\n })}\n </div>\n </div>\n {CurrentStepComponents.footer && (\n <Modal.Footer>\n <CurrentStepComponents.footer {...stepProps} />\n </Modal.Footer>\n )}\n </Modal>\n )\n}\n\nexport default MultiStepModal\n"],"names":[],"mappings":";;;;AA2BM,MAAA,cAAc,GAAG,CAAK,EAC1B,QAAQ,GAAG,IAAS,EACpB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,gBAAgB,GAAG,IAAI,EACvB,GAAG,UAAU,EACW,KAAI;AAC5B,IAAA,MAAM,oBAAoB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IACzD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAEjD,SAAS,CAAC,MAAK;;AACb,QAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,oBAAoB,CAAC,OAAO,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,cAAc,CAAC;AACvE,YAAA,QAAQ,EAAE,QAAQ;AACnB,SAAA,CAAC,CAAA;AACJ,KAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAEjB,MAAM,cAAc,GAAG,MAAK;AAC1B,QAAA,cAAc,CACZ,WAAW,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,WAAW,GAAG,WAAW,GAAG,CAAC,CAChE,CAAA;AACH,KAAC,CAAA;IAED,MAAM,kBAAkB,GAAG,MAAK;AA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GAAG,EAAE,aAAa,GAAG,KAAK,EAC1B,SAAS,EAAE,EAAE,CACX,2DAA2D,EAC3D;wBACE,iCAAiC,EAAE,KAAK,KAAK,WAAW;AACxD,wBAAA,CAAC,YAAY,GAAG,KAAK,KAAK,WAAW;AACtC,qBAAA,CACF,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,CAAG,EAAA,GAAG,GAAG,KAAK,CAAC,MAAM,GAAG,EAAE,EAAA;oBAE1C,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,mBAAmB,EAAA;wBAChC,KAAC,CAAA,aAAA,CAAA,cAAc,CAAC,OAAO,EAAA,EAAA,GAAK,SAAS,EAAI,CAAA,CACrC,CACF,EACP;aACF,CAAC,CACE,CACF;AACL,QAAA,qBAAqB,CAAC,MAAM,KAC3B,KAAC,CAAA,aAAA,CAAA,KAAK,CAAC,MAAM,EAAA,IAAA;YACX,KAAC,CAAA,aAAA,CAAA,qBAAqB,CAAC,MAAM,EAAK,EAAA,GAAA,SAAS,GAAI,CAClC,CAChB,CACK,EACT;AACH;;;;"}
1
+ {"version":3,"file":"MultiStepModal.js","sources":["../../../src/components/Modal/MultiStepModal.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\"\nimport cx from \"classnames\"\nimport Modal, { ModalPropsType } from \".\"\n\ntype StepComponentType<T> = (props: {\n navigation: {\n nextStep: () => void\n previousStep: () => void\n closeModal: () => void\n }\n data: T\n}) => React.ReactNode\n\nexport type ModalStepType<T> = {\n title: StepComponentType<T>\n content: StepComponentType<T>\n footer?: StepComponentType<T>\n}\n\ntype MultiStepsModalProps<T = null> = {\n stepData?: T\n close: () => void\n onHidden?: (currentStepIndex: number) => void\n steps: ModalStepType<T>[]\n useMidSizeHeight?: boolean\n} & Omit<ModalPropsType, \"children\" | \"onHidden\" | \"close\">\n\nconst MultiStepModal = <T,>({\n stepData = null as T,\n close,\n steps,\n onHidden,\n useMidSizeHeight = true,\n ...modalProps\n}: MultiStepsModalProps<T>) => {\n const bodyScrollContentRef = useRef<HTMLDivElement>(null)\n const [currentStep, setCurrentStep] = useState(0)\n\n useEffect(() => {\n bodyScrollContentRef.current?.children.item(currentStep)?.scrollIntoView()\n }, [currentStep])\n\n const handleNextStep = () => {\n setCurrentStep(\n currentStep >= steps.length - 1 ? currentStep : currentStep + 1\n )\n }\n\n const handlePreviousStep = () => {\n setCurrentStep(currentStep <= 0 ? 0 : currentStep - 1)\n }\n\n const onModalClosed = () => {\n onHidden?.(currentStep)\n setCurrentStep(0)\n }\n\n const navigation = {\n nextStep: handleNextStep,\n previousStep: handlePreviousStep,\n closeModal: close,\n }\n\n const CurrentStepComponents = steps[currentStep]\n const stepProps = { data: stepData, navigation }\n\n const minimumScale = useMidSizeHeight\n ? \"c-opacity-0 c-grid-rows-[0.5fr]\"\n : \"c-opacity-0 c-grid-rows-[0fr]\"\n\n return (\n <Modal\n {...modalProps}\n title={<CurrentStepComponents.title {...stepProps} />}\n close={close}\n onHidden={onModalClosed}\n >\n <div className=\"c-w-full c-overflow-x-hidden c-scroll-smooth\">\n <div\n className=\"c-py-sm\"\n ref={bodyScrollContentRef}\n style={{ width: `${steps.length * 100}%` }}\n >\n {steps.map((StepComponents, index) => {\n return (\n <div\n key={\"modal_step_\" + index}\n className={cx(\n \"c-inline-grid c-align-top c-transition-all c-duration-500\",\n {\n \"c-opacity-100 c-grid-rows-[1fr]\": index === currentStep,\n [minimumScale]: index !== currentStep,\n }\n )}\n style={{ width: `${100 / steps.length}%` }}\n >\n <div className=\"c-overflow-hidden\">\n <StepComponents.content {...stepProps} />\n </div>\n </div>\n )\n })}\n </div>\n </div>\n {CurrentStepComponents.footer && (\n <Modal.Footer>\n <CurrentStepComponents.footer {...stepProps} />\n </Modal.Footer>\n )}\n </Modal>\n )\n}\n\nexport default MultiStepModal\n"],"names":[],"mappings":";;;;AA2BM,MAAA,cAAc,GAAG,CAAK,EAC1B,QAAQ,GAAG,IAAS,EACpB,KAAK,EACL,KAA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KAAK,CAAC,MAAM,EAAA,IAAA;YACX,KAAC,CAAA,aAAA,CAAA,qBAAqB,CAAC,MAAM,EAAK,EAAA,GAAA,SAAS,GAAI,CAClC,CAChB,CACK,EACT;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drivy/cobalt",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Opinionated design system for Drivy's projects.",
5
5
  "main": "src/index.js",
6
6
  "types": "types/src/index.d.ts",