@addsign/moje-agenda-shared-lib 2.0.75 → 2.0.76

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.
@@ -3,9 +3,10 @@ interface CollapsibleSectionProps {
3
3
  title: string;
4
4
  expanded?: boolean;
5
5
  children: React.ReactNode;
6
+ onToggle?: (expanded: boolean) => void;
6
7
  className?: string;
7
8
  classNameEnvelope?: string;
8
9
  classNameTitle?: string;
9
10
  }
10
- declare const CollapsibleSection: ({ title, expanded, children, className, classNameEnvelope, classNameTitle, }: CollapsibleSectionProps) => import("react/jsx-runtime").JSX.Element;
11
+ declare const CollapsibleSection: ({ title, expanded, children, onToggle, className, classNameEnvelope, classNameTitle, }: CollapsibleSectionProps) => import("react/jsx-runtime").JSX.Element;
11
12
  export default CollapsibleSection;
@@ -1,16 +1,25 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState } from "react";
2
+ import { useState, useRef, useEffect } from "react";
3
3
  import { M as MdExpandLess, a as MdExpandMore } from "../../index-CrfjcbOs.js";
4
4
  import { cn } from "../../utils/utils.js";
5
5
  const CollapsibleSection = ({
6
6
  title,
7
7
  expanded = true,
8
8
  children,
9
+ onToggle,
9
10
  className,
10
11
  classNameEnvelope,
11
12
  classNameTitle
12
13
  }) => {
13
14
  const [isExpanded, setIsExpanded] = useState(expanded);
15
+ const isInitialMount = useRef(true);
16
+ useEffect(() => {
17
+ if (isInitialMount.current) {
18
+ isInitialMount.current = false;
19
+ return;
20
+ }
21
+ onToggle == null ? void 0 : onToggle(isExpanded);
22
+ }, [isExpanded, onToggle]);
14
23
  return /* @__PURE__ */ jsxs("div", { className: cn("rounded-md shadow-lg border", classNameEnvelope), children: [
15
24
  /* @__PURE__ */ jsxs(
16
25
  "div",
@@ -1 +1 @@
1
- {"version":3,"file":"CollapsibleSection.js","sources":["../../../lib/components/layout/CollapsibleSection.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { MdExpandLess, MdExpandMore } from \"react-icons/md\";\nimport { cn } from \"../../utils/utils\";\n\ninterface CollapsibleSectionProps {\n title: string;\n expanded?: boolean;\n children: React.ReactNode;\n\n className?: string;\n classNameEnvelope?: string;\n classNameTitle?: string;\n}\n\nconst CollapsibleSection = ({\n title,\n expanded = true,\n children,\n className,\n classNameEnvelope,\n classNameTitle,\n}: CollapsibleSectionProps) => {\n const [isExpanded, setIsExpanded] = useState(expanded);\n\n return (\n <div className={cn(\"rounded-md shadow-lg border\", classNameEnvelope)}>\n <div\n className={cn(\n \"w-full justify-between border-b hover:bg-muted flex py-4 px-5 items-center cursor-pointer\",\n classNameTitle\n )}\n onClick={() => setIsExpanded((prev) => !prev)}\n >\n <div className=\"font-medium text-lg\">{title}</div>\n <div>\n {isExpanded ? (\n <MdExpandLess size={\"24px\"} className=\"text-gray-600\" />\n ) : (\n <MdExpandMore size={\"24px\"} className=\"text-gray-600\" />\n )}\n </div>\n </div>\n {isExpanded && <div className={cn(\"p-5\", className)}>{children}</div>}\n </div>\n );\n};\n\nexport default CollapsibleSection;\n"],"names":[],"mappings":";;;;AAcA,MAAM,qBAAqB,CAAC;AAAA,EAC1B;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA+B;AAC7B,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,QAAQ;AAErD,8BACG,OAAI,EAAA,WAAW,GAAG,+BAA+B,iBAAiB,GACjE,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,QACA,SAAS,MAAM,cAAc,CAAC,SAAS,CAAC,IAAI;AAAA,QAE5C,UAAA;AAAA,UAAC,oBAAA,OAAA,EAAI,WAAU,uBAAuB,UAAM,OAAA;AAAA,8BAC3C,OACE,EAAA,UAAA,aACE,oBAAA,cAAA,EAAa,MAAM,QAAQ,WAAU,iBAAgB,wBAErD,cAAa,EAAA,MAAM,QAAQ,WAAU,gBAAgB,CAAA,GAE1D;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,IACC,kCAAe,OAAI,EAAA,WAAW,GAAG,OAAO,SAAS,GAAI,UAAS;AAAA,EACjE,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"CollapsibleSection.js","sources":["../../../lib/components/layout/CollapsibleSection.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { MdExpandLess, MdExpandMore } from \"react-icons/md\";\nimport { cn } from \"../../utils/utils\";\n\ninterface CollapsibleSectionProps {\n title: string;\n expanded?: boolean;\n children: React.ReactNode;\n onToggle?: (expanded: boolean) => void;\n\n className?: string;\n classNameEnvelope?: string;\n classNameTitle?: string;\n}\n\nconst CollapsibleSection = ({\n title,\n expanded = true,\n children,\n onToggle,\n className,\n classNameEnvelope,\n classNameTitle,\n}: CollapsibleSectionProps) => {\n const [isExpanded, setIsExpanded] = useState(expanded);\n const isInitialMount = useRef(true);\n\n useEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n return;\n }\n onToggle?.(isExpanded);\n }, [isExpanded, onToggle]);\n\n return (\n <div className={cn(\"rounded-md shadow-lg border\", classNameEnvelope)}>\n <div\n className={cn(\n \"w-full justify-between border-b hover:bg-muted flex py-4 px-5 items-center cursor-pointer\",\n classNameTitle\n )}\n onClick={() => setIsExpanded((prev) => !prev)}\n >\n <div className=\"font-medium text-lg\">{title}</div>\n <div>\n {isExpanded ? (\n <MdExpandLess size={\"24px\"} className=\"text-gray-600\" />\n ) : (\n <MdExpandMore size={\"24px\"} className=\"text-gray-600\" />\n )}\n </div>\n </div>\n {isExpanded && <div className={cn(\"p-5\", className)}>{children}</div>}\n </div>\n );\n};\n\nexport default CollapsibleSection;\n"],"names":[],"mappings":";;;;AAeA,MAAM,qBAAqB,CAAC;AAAA,EAC1B;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA+B;AAC7B,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,QAAQ;AAC/C,QAAA,iBAAiB,OAAO,IAAI;AAElC,YAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,qBAAe,UAAU;AACzB;AAAA,IACF;AACA,yCAAW;AAAA,EAAU,GACpB,CAAC,YAAY,QAAQ,CAAC;AAEzB,8BACG,OAAI,EAAA,WAAW,GAAG,+BAA+B,iBAAiB,GACjE,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,QACA,SAAS,MAAM,cAAc,CAAC,SAAS,CAAC,IAAI;AAAA,QAE5C,UAAA;AAAA,UAAC,oBAAA,OAAA,EAAI,WAAU,uBAAuB,UAAM,OAAA;AAAA,8BAC3C,OACE,EAAA,UAAA,aACE,oBAAA,cAAA,EAAa,MAAM,QAAQ,WAAU,iBAAgB,wBAErD,cAAa,EAAA,MAAM,QAAQ,WAAU,gBAAgB,CAAA,GAE1D;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,IACC,kCAAe,OAAI,EAAA,WAAW,GAAG,OAAO,SAAS,GAAI,UAAS;AAAA,EACjE,EAAA,CAAA;AAEJ;"}
@@ -1,4 +1,4 @@
1
- import { useState } from "react";
1
+ import { useEffect, useRef, useState } from "react";
2
2
  import { MdExpandLess, MdExpandMore } from "react-icons/md";
3
3
  import { cn } from "../../utils/utils";
4
4
 
@@ -6,6 +6,7 @@ interface CollapsibleSectionProps {
6
6
  title: string;
7
7
  expanded?: boolean;
8
8
  children: React.ReactNode;
9
+ onToggle?: (expanded: boolean) => void;
9
10
 
10
11
  className?: string;
11
12
  classNameEnvelope?: string;
@@ -16,11 +17,21 @@ const CollapsibleSection = ({
16
17
  title,
17
18
  expanded = true,
18
19
  children,
20
+ onToggle,
19
21
  className,
20
22
  classNameEnvelope,
21
23
  classNameTitle,
22
24
  }: CollapsibleSectionProps) => {
23
25
  const [isExpanded, setIsExpanded] = useState(expanded);
26
+ const isInitialMount = useRef(true);
27
+
28
+ useEffect(() => {
29
+ if (isInitialMount.current) {
30
+ isInitialMount.current = false;
31
+ return;
32
+ }
33
+ onToggle?.(isExpanded);
34
+ }, [isExpanded, onToggle]);
24
35
 
25
36
  return (
26
37
  <div className={cn("rounded-md shadow-lg border", classNameEnvelope)}>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@addsign/moje-agenda-shared-lib",
3
3
  "private": false,
4
- "version": "2.0.75",
4
+ "version": "2.0.76",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",