sea-react-components 1.3.16 → 1.3.18

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.
@@ -16,7 +16,7 @@ const ConfirmModal = ({ options, onClose, }) => {
16
16
  };
17
17
  return (_jsx("div", { className: `fixed inset-0 z-[9999] flex items-center justify-center bg-black/40 transition-opacity duration-200 ${show ? "opacity-100" : "opacity-0"}`, children: _jsxs("div", { className: `bg-white rounded-xl shadow-lg w-[90%] max-w-sm p-5 transform transition-all duration-200 ${show ? "scale-100" : "scale-95"}`, children: [options.title && (_jsx("h2", { className: "text-lg font-semibold mb-2", children: options.title })), _jsx("p", { className: "text-gray-700 mb-4", children: options.message }), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx(Button, { onClick: () => handleClose(false), variant: "secondary", children: options.cancelText || "Cancel" }), _jsx(Button, { onClick: () => handleClose(true), children: options.confirmText || "Confirm" })] })] }) }));
18
18
  };
19
- let isOpen = false;
19
+ let isOpen = true;
20
20
  export default function showConfirm(messageOrOptions) {
21
21
  const options = typeof messageOrOptions === "string"
22
22
  ? { message: messageOrOptions }
@@ -27,10 +27,10 @@ export default function showConfirm(messageOrOptions) {
27
27
  document.body.appendChild(div);
28
28
  }
29
29
  const root = ReactDOM.createRoot(div);
30
- isOpen = true;
30
+ isOpen = false;
31
31
  return new Promise((resolve) => {
32
32
  const handleClose = (result) => {
33
- isOpen = false;
33
+ isOpen = true;
34
34
  root.unmount();
35
35
  div.remove();
36
36
  resolve(result);
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  export type Placement = "top" | "left" | "right" | "bottom";
3
+ export type DrawerSize = "sm" | "md" | "lg" | "xl";
3
4
  export type Props = {
4
5
  isOpen: boolean;
5
6
  onClose: () => void;
@@ -7,6 +8,7 @@ export type Props = {
7
8
  overlay?: boolean;
8
9
  className?: string;
9
10
  children: React.ReactNode;
11
+ size?: DrawerSize;
10
12
  };
11
- export default function Drawer({ isOpen, onClose, placement, overlay, className, children, }: Props): import("react/jsx-runtime").JSX.Element;
13
+ export default function Drawer({ isOpen, onClose, placement, overlay, className, children, size, }: Props): import("react/jsx-runtime").JSX.Element;
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/drawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE5D,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,MAAM,EACN,OAAO,EACP,SAAmB,EACnB,OAAc,EACd,SAAS,EACT,QAAQ,GACT,EAAE,KAAK,2CAoDP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/drawer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC5D,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AASF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,MAAM,EACN,OAAO,EACP,SAAmB,EACnB,OAAc,EACd,SAAS,EACT,QAAQ,EACR,IAAW,GACZ,EAAE,KAAK,2CAyDP"}
@@ -1,15 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import clsx from "clsx";
3
3
  import { Icon } from "@iconify/react";
4
- export default function Drawer({ isOpen, onClose, placement = "right", overlay = true, className, children, }) {
4
+ const sizeClass = {
5
+ sm: "w-[320px] md:w-[320px]",
6
+ md: "sm:w-[85%] xl:w-[25%] lg:w-[40%] md:w-[40%]",
7
+ lg: "sm:w-[95%] md:w-[60%]",
8
+ xl: "sm:w-full md:w-[80%]",
9
+ };
10
+ export default function Drawer({ isOpen, onClose, placement = "right", overlay = true, className, children, size = "md", // NEW
11
+ }) {
12
+ // Only apply width for left/right placements
13
+ const widthClass = placement === "left" || placement === "right" ? sizeClass[size] : "";
5
14
  return (_jsxs(_Fragment, { children: [overlay && isOpen && (_jsx("div", { className: clsx("fixed z-50 inset-0 bg-black bg-opacity-50 transition-opacity duration-300", { "opacity-0 pointer-events-none": !isOpen }), onClick: onClose })), _jsxs("div", { className: clsx("fixed bg-white shadow-lg z-50 transition-transform duration-300 py-7 px-2 max-h-screen overflow-y-auto", {
6
15
  "top-0 left-0 w-full h-auto transform -translate-y-full": placement === "top" && !isOpen,
7
16
  "top-0 left-0 w-full h-auto translate-y-0": placement === "top" && isOpen,
8
- "top-0 right-0 max-h-screen h-full transform translate-x-full w-[85%] md:w-[40%]": placement === "right" && !isOpen,
9
- "top-0 right-0 max-h-screen h-full translate-x-0 w-[85%] md:w-[40%]": placement === "right" && isOpen,
10
- "top-0 left-0 max-h-screen h-full transform -translate-x-full w-[85%] md:w-[40%]": placement === "left" && !isOpen,
11
- "top-0 left-0 max-h-screen h-full translate-x-0 w-[85%] md:w-[40%]": placement === "left" && isOpen,
17
+ "top-0 right-0 max-h-screen h-full transform translate-x-full": placement === "right" && !isOpen,
18
+ "top-0 right-0 max-h-screen h-full translate-x-0": placement === "right" && isOpen,
19
+ "top-0 left-0 max-h-screen h-full transform -translate-x-full": placement === "left" && !isOpen,
20
+ "top-0 left-0 max-h-screen h-full translate-x-0": placement === "left" && isOpen,
12
21
  "bottom-0 left-0 w-full h-auto transform translate-y-full": placement === "bottom" && !isOpen,
13
22
  "bottom-0 left-0 w-full h-auto translate-y-0": placement === "bottom" && isOpen,
14
- }, className), children: [_jsx("button", { onClick: onClose, className: "absolute top-2 right-2 text-secondary-dark", children: _jsx(Icon, { icon: "line-md:close-small", className: "h-5 w-5 hover:scale-110 transition-all duration-300 ease-in-out" }) }), children] })] }));
23
+ }, widthClass, className), children: [_jsx("button", { onClick: onClose, className: "absolute top-2 right-2 text-secondary-dark", children: _jsx(Icon, { icon: "line-md:close-small", className: "h-5 w-5 hover:scale-110 transition-all duration-300 ease-in-out" }) }), children] })] }));
15
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/expandable-text/index.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,IAAI,EACJ,QAAY,EACZ,SAAS,EACT,cAAqB,EACrB,YAA0B,EAC1B,YAA0B,GAC3B,EAAE,KAAK,2CAoDP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/expandable-text/index.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,IAAI,EACJ,QAAY,EACZ,SAAS,EACT,cAAqB,EACrB,YAA0B,EAC1B,YAA0B,GAC3B,EAAE,KAAK,2CAuDP"}
@@ -1,33 +1,34 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useState, useRef, useEffect } from "react";
3
+ import { useState, useRef, useLayoutEffect } from "react";
4
4
  import clsx from "clsx";
5
5
  export default function ExpandableText({ text, maxLines = 2, className, showMoreButton = true, showMoreText = "Show more", showLessText = "Show less", }) {
6
- var _a;
7
6
  const [expanded, setExpanded] = useState(false);
8
7
  const [truncated, setTruncated] = useState(false);
9
8
  const [collapsedHeight, setCollapsedHeight] = useState(0);
9
+ const [expandedHeight, setExpandedHeight] = useState(0);
10
10
  const textRef = useRef(null);
11
- // Measure collapsed height (max lines)
12
- useEffect(() => {
13
- if (textRef.current) {
14
- const lineHeight = parseFloat(getComputedStyle(textRef.current).lineHeight || "16");
15
- setCollapsedHeight(lineHeight * maxLines);
16
- if (textRef.current.scrollHeight > lineHeight * maxLines) {
17
- setTruncated(true);
18
- }
19
- else {
20
- setTruncated(false);
21
- }
22
- }
11
+ useLayoutEffect(() => {
12
+ if (!textRef.current)
13
+ return;
14
+ const el = textRef.current;
15
+ const lineHeight = parseFloat(getComputedStyle(el).lineHeight || "16");
16
+ const maxHeight = lineHeight * maxLines;
17
+ // Temporarily remove clamping to measure full height
18
+ el.style.webkitLineClamp = "unset";
19
+ el.style.maxHeight = "none";
20
+ const fullHeight = el.scrollHeight;
21
+ setExpandedHeight(fullHeight);
22
+ setCollapsedHeight(maxHeight);
23
+ setTruncated(fullHeight > maxHeight);
24
+ // Reapply clamping
25
+ el.style.webkitLineClamp = String(maxLines);
23
26
  }, [text, maxLines]);
24
- const toggleExpanded = () => {
25
- setExpanded((prev) => !prev);
26
- };
27
- return (_jsxs("div", { className: clsx("relative", className), children: [_jsx("div", { ref: textRef, className: "overflow-hidden transition-all duration-300 ease-in-out", style: {
28
- maxHeight: expanded ? (_a = textRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight : collapsedHeight,
27
+ const toggleExpanded = () => setExpanded((prev) => !prev);
28
+ return (_jsxs("div", { className: clsx("relative", className), children: [_jsx("div", { ref: textRef, className: "overflow-hidden transition-[max-height] duration-300 ease-in-out", style: {
29
+ maxHeight: expanded ? expandedHeight : collapsedHeight,
29
30
  display: "-webkit-box",
30
31
  WebkitBoxOrient: "vertical",
31
- WebkitLineClamp: !expanded ? maxLines : "unset",
32
+ WebkitLineClamp: expanded ? "unset" : String(maxLines),
32
33
  }, children: text }), truncated && showMoreButton && (_jsx("button", { type: "button", onClick: toggleExpanded, className: "mt-1 text-primary hover:underline text-sm font-medium", children: expanded ? showLessText : showMoreText }))] }));
33
34
  }
@@ -5,7 +5,8 @@ export type Props = {
5
5
  start?: React.ReactNode | null;
6
6
  end?: React.ReactNode | null;
7
7
  label?: string;
8
+ showErrorMessage?: boolean;
8
9
  containerClassName?: string;
9
10
  } & React.InputHTMLAttributes<HTMLInputElement>;
10
- export default function Input({ errorMessage, containerClassName, className, start, end, ref, type, label, required, ...props }: Props): import("react/jsx-runtime").JSX.Element;
11
+ export default function Input({ errorMessage, containerClassName, className, start, end, ref, type, label, required, showErrorMessage, ...props }: Props): import("react/jsx-runtime").JSX.Element;
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAC/B,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,KAAY,EACZ,GAAU,EACV,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAgB,EAChB,GAAG,KAAK,EACT,EAAE,KAAK,2CAmEP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAC/B,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,KAAY,EACZ,GAAU,EACV,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAgB,EAChB,gBAAuB,EACvB,GAAG,KAAK,EACT,EAAE,KAAK,2CAmEP"}
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Icon } from "@iconify/react";
4
4
  import clsx from "clsx";
5
5
  import { useState } from "react";
6
- export default function Input({ errorMessage, containerClassName, className, start = null, end = null, ref, type, label, required = false, ...props }) {
6
+ export default function Input({ errorMessage, containerClassName, className, start = null, end = null, ref, type, label, required = false, showErrorMessage = true, ...props }) {
7
7
  const [isFocused, setIsFocused] = useState(false);
8
8
  const [currentType, setCurrentType] = useState(type);
9
9
  if (type === "password") {
@@ -17,5 +17,5 @@ export default function Input({ errorMessage, containerClassName, className, sta
17
17
  ? "border-error"
18
18
  : isFocused
19
19
  ? "border-primary"
20
- : "border-gray-200", containerClassName), children: [start, _jsx("input", { ref: ref, id: props.id, type: currentType, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), "aria-invalid": !!errorMessage || undefined, className: clsx("outline-none text-text flex-1 bg-white", className), ...props }), end] }), errorMessage && (_jsx("p", { className: "pl-1 text-sm text-error", children: typeof errorMessage === "string" ? errorMessage : "Invalid value" }))] }));
20
+ : "border-gray-200", containerClassName), children: [start, _jsx("input", { ref: ref, id: props.id, type: currentType, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), "aria-invalid": !!errorMessage || undefined, className: clsx("outline-none text-text flex-1 bg-white", className), ...props }), end] }), showErrorMessage && errorMessage && (_jsx("p", { className: "pl-1 text-sm text-error", children: typeof errorMessage === "string" ? errorMessage : "Invalid value" }))] }));
21
21
  }
@@ -1,5 +1,7 @@
1
1
  import React from "react";
2
2
  import { MenuProps } from "@szhsin/react-menu";
3
+ import "@szhsin/react-menu/dist/index.css";
4
+ import "@szhsin/react-menu/dist/transitions/zoom.css";
3
5
  export type Props = {
4
6
  menuButton: React.ReactNode;
5
7
  children: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/menu/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA6B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG1E,MAAM,MAAM,KAAK,GAAG;IAClB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,GAAG,SAAS,CAAC;AACd,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,UAAU,EACV,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,2CAQP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/menu/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA6B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,mCAAmC,CAAC;AAC3C,OAAO,8CAA8C,CAAC;AAEtD,MAAM,MAAM,KAAK,GAAG;IAClB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,GAAG,SAAS,CAAC;AACd,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,UAAU,EACV,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,2CAUP"}
@@ -2,6 +2,8 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Menu as SMenu, MenuButton } from "@szhsin/react-menu";
4
4
  import clsx from "clsx";
5
+ import "@szhsin/react-menu/dist/index.css";
6
+ import "@szhsin/react-menu/dist/transitions/zoom.css";
5
7
  export default function Menu({ menuButton, children, className, ...props }) {
6
- return (_jsx(SMenu, { menuButton: _jsx(MenuButton, { children: menuButton }), ...props, children: _jsx("div", { className: clsx("bg-white rounded-xl shadow-lg", className), children: children }) }));
8
+ return (_jsx(SMenu, { menuButton: _jsx(MenuButton, { children: menuButton }), transition: true, ...props, children: _jsx("div", { className: clsx(className), children: children }) }));
7
9
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sea-react-components",
3
3
  "description": "SEA react components library",
4
- "version": "1.3.16",
4
+ "version": "1.3.18",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc --build && npx postcss src/styles.css -o dist/styles.css && npx postcss src/components/text-editor/style.css -o dist/components/text-editor/style.css",
@@ -48,7 +48,7 @@
48
48
  "jwt-decode": "^4.0.0",
49
49
  "lowlight": "^3.3.0",
50
50
  "react-dom": "^18.3.1",
51
- "sea-platform-helpers": "^1.5.13",
51
+ "sea-platform-helpers": "^1.5.16",
52
52
  "sea-react-components": "file:",
53
53
  "uuid": "^13.0.0",
54
54
  "yup": "^1.5.0"