@san-siva/blogkit 1.1.0 → 1.1.2

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.
Files changed (55) hide show
  1. package/dist/cjs/components/BlogHeader.js +2 -2
  2. package/dist/cjs/components/BlogHeader.js.map +1 -1
  3. package/dist/cjs/components/Callout.js +2 -2
  4. package/dist/cjs/components/Callout.js.map +1 -1
  5. package/dist/cjs/components/Table.js +2 -2
  6. package/dist/cjs/components/Table.js.map +1 -1
  7. package/dist/cjs/dynamicComponents/BlogDynamic.js +22 -20
  8. package/dist/cjs/dynamicComponents/BlogDynamic.js.map +1 -1
  9. package/dist/cjs/dynamicComponents/BlogSectionDynamic.js +1 -0
  10. package/dist/cjs/dynamicComponents/BlogSectionDynamic.js.map +1 -1
  11. package/dist/cjs/index.css +1 -1
  12. package/dist/cjs/index.css.map +1 -1
  13. package/dist/cjs/staticComponents/BlogHeaderStatic.js +13 -0
  14. package/dist/cjs/staticComponents/BlogHeaderStatic.js.map +1 -0
  15. package/dist/cjs/staticComponents/CalloutStatic.js +14 -0
  16. package/dist/cjs/staticComponents/CalloutStatic.js.map +1 -0
  17. package/dist/cjs/staticComponents/TableStatic.js +18 -0
  18. package/dist/cjs/staticComponents/TableStatic.js.map +1 -0
  19. package/dist/esm/components/BlogHeader.js +1 -1
  20. package/dist/esm/components/BlogHeader.js.map +1 -1
  21. package/dist/esm/components/Callout.js +1 -1
  22. package/dist/esm/components/Callout.js.map +1 -1
  23. package/dist/esm/components/Table.js +1 -1
  24. package/dist/esm/components/Table.js.map +1 -1
  25. package/dist/esm/dynamicComponents/BlogDynamic.js +22 -20
  26. package/dist/esm/dynamicComponents/BlogDynamic.js.map +1 -1
  27. package/dist/esm/dynamicComponents/BlogSectionDynamic.js +1 -0
  28. package/dist/esm/dynamicComponents/BlogSectionDynamic.js.map +1 -1
  29. package/dist/esm/index.css +1 -1
  30. package/dist/esm/index.css.map +1 -1
  31. package/dist/esm/staticComponents/BlogHeaderStatic.js +9 -0
  32. package/dist/esm/staticComponents/BlogHeaderStatic.js.map +1 -0
  33. package/dist/esm/staticComponents/CalloutStatic.js +10 -0
  34. package/dist/esm/staticComponents/CalloutStatic.js.map +1 -0
  35. package/dist/esm/staticComponents/TableStatic.js +14 -0
  36. package/dist/esm/staticComponents/TableStatic.js.map +1 -0
  37. package/dist/types/dynamicComponents/BlogDynamic.d.ts.map +1 -1
  38. package/dist/types/dynamicComponents/BlogSectionDynamic.d.ts.map +1 -1
  39. package/dist/types/staticComponents/BlogHeaderStatic.d.ts +8 -0
  40. package/dist/types/staticComponents/BlogHeaderStatic.d.ts.map +1 -0
  41. package/dist/types/staticComponents/CalloutStatic.d.ts +10 -0
  42. package/dist/types/staticComponents/CalloutStatic.d.ts.map +1 -0
  43. package/dist/types/staticComponents/TableStatic.d.ts +10 -0
  44. package/dist/types/staticComponents/TableStatic.d.ts.map +1 -0
  45. package/package.json +1 -1
  46. package/src/components/BlogHeader.tsx +2 -2
  47. package/src/components/Callout.tsx +3 -3
  48. package/src/components/Table.tsx +2 -2
  49. package/src/dynamicComponents/BlogDynamic.tsx +57 -60
  50. package/src/dynamicComponents/BlogSectionDynamic.tsx +2 -0
  51. package/src/styles/Blog.module.scss +4 -2
  52. package/src/styles/CodeBlock.module.scss +21 -2
  53. /package/src/{dynamicComponents/BlogHeaderDynamic.tsx → staticComponents/BlogHeaderStatic.tsx} +0 -0
  54. /package/src/{dynamicComponents/CalloutDynamic.tsx → staticComponents/CalloutStatic.tsx} +0 -0
  55. /package/src/{dynamicComponents/TableDynamic.tsx → staticComponents/TableStatic.tsx} +0 -0
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
- var BlogHeaderDynamic = require('../dynamicComponents/BlogHeaderDynamic.js');
6
+ var BlogHeaderStatic = require('../staticComponents/BlogHeaderStatic.js');
7
7
 
8
8
  const BlogHeader = ({ title, desc, isDescCite = true, }) => {
9
- return (jsxRuntime.jsx(BlogHeaderDynamic.default, { title: title, desc: desc, isDescCite: isDescCite }));
9
+ return (jsxRuntime.jsx(BlogHeaderStatic.default, { title: title, desc: desc, isDescCite: isDescCite }));
10
10
  };
11
11
 
12
12
  exports.default = BlogHeader;
@@ -1 +1 @@
1
- {"version":3,"file":"BlogHeader.js","sources":["../../../src/components/BlogHeader.tsx"],"sourcesContent":["import BlogHeaderDynamic from '../dynamicComponents/BlogHeaderDynamic';\n\ninterface BlogHeaderProperties {\n\ttitle: string[];\n\tdesc: string[];\n\tisDescCite?: boolean;\n}\n\nconst BlogHeader = ({\n\ttitle,\n\tdesc,\n\tisDescCite = true,\n}: BlogHeaderProperties) => {\n\treturn (\n\t\t<BlogHeaderDynamic title={title} desc={desc} isDescCite={isDescCite} />\n\t);\n};\n\nexport default BlogHeader;\n"],"names":["_jsx","BlogHeaderDynamic"],"mappings":";;;;;;;AAQA,MAAM,UAAU,GAAG,CAAC,EACnB,KAAK,EACL,IAAI,EACJ,UAAU,GAAG,IAAI,GACK,KAAI;AAC1B,IAAA,QACCA,cAAA,CAACC,yBAAiB,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAA,CAAI;AAEzE;;;;"}
1
+ {"version":3,"file":"BlogHeader.js","sources":["../../../src/components/BlogHeader.tsx"],"sourcesContent":["import BlogHeaderStatic from '../staticComponents/BlogHeaderStatic';\n\ninterface BlogHeaderProperties {\n\ttitle: string[];\n\tdesc: string[];\n\tisDescCite?: boolean;\n}\n\nconst BlogHeader = ({\n\ttitle,\n\tdesc,\n\tisDescCite = true,\n}: BlogHeaderProperties) => {\n\treturn (\n\t\t<BlogHeaderStatic title={title} desc={desc} isDescCite={isDescCite} />\n\t);\n};\n\nexport default BlogHeader;\n"],"names":["_jsx","BlogHeaderStatic"],"mappings":";;;;;;;AAQA,MAAM,UAAU,GAAG,CAAC,EACnB,KAAK,EACL,IAAI,EACJ,UAAU,GAAG,IAAI,GACK,KAAI;AAC1B,IAAA,QACCA,cAAA,CAACC,wBAAgB,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAA,CAAI;AAExE;;;;"}
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
- var CalloutDynamic = require('../dynamicComponents/CalloutDynamic.js');
6
+ var CalloutStatic = require('../staticComponents/CalloutStatic.js');
7
7
 
8
8
  const Callout = ({ children, type = 'info', hasMarginUp = false, hasMarginDown = false, }) => {
9
- return (jsxRuntime.jsx(CalloutDynamic.default, { type: type, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown, children: children }));
9
+ return (jsxRuntime.jsx(CalloutStatic.default, { type: type, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown, children: children }));
10
10
  };
11
11
 
12
12
  exports.default = Callout;
@@ -1 +1 @@
1
- {"version":3,"file":"Callout.js","sources":["../../../src/components/Callout.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport CalloutDynamic from '../dynamicComponents/CalloutDynamic';\n\ninterface CalloutProperties {\n\tchildren?: ReactNode;\n\ttype: 'info' | 'warning' | 'error' | 'success';\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n}\n\nconst Callout = ({\n\tchildren,\n\ttype = 'info',\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: CalloutProperties) => {\n\treturn (\n\t\t<CalloutDynamic\n\t\t\ttype={type}\n\t\t\thasMarginUp={hasMarginUp}\n\t\t\thasMarginDown={hasMarginDown}\n\t\t>\n\t\t\t{children}\n\t\t</CalloutDynamic>\n\t);\n};\n\nexport default Callout;\n"],"names":["_jsx","CalloutDynamic"],"mappings":";;;;;;;AAUA,MAAM,OAAO,GAAG,CAAC,EAChB,QAAQ,EACR,IAAI,GAAG,MAAM,EACb,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,GACF,KAAI;AACvB,IAAA,QACCA,cAAA,CAACC,sBAAc,IACd,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,YAE3B,QAAQ,EAAA,CACO;AAEnB;;;;"}
1
+ {"version":3,"file":"Callout.js","sources":["../../../src/components/Callout.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport CalloutStatic from '../staticComponents/CalloutStatic';\n\ninterface CalloutProperties {\n\tchildren?: ReactNode;\n\ttype: 'info' | 'warning' | 'error' | 'success';\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n}\n\nconst Callout = ({\n\tchildren,\n\ttype = 'info',\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: CalloutProperties) => {\n\treturn (\n\t\t<CalloutStatic\n\t\t\ttype={type}\n\t\t\thasMarginUp={hasMarginUp}\n\t\t\thasMarginDown={hasMarginDown}\n\t\t>\n\t\t\t{children}\n\t\t</CalloutStatic>\n\t);\n};\n\nexport default Callout;\n"],"names":["_jsx","CalloutStatic"],"mappings":";;;;;;;AAUA,MAAM,OAAO,GAAG,CAAC,EAChB,QAAQ,EACR,IAAI,GAAG,MAAM,EACb,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,GACF,KAAI;AACvB,IAAA,QACCA,cAAA,CAACC,qBAAa,IACb,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,YAE3B,QAAQ,EAAA,CACM;AAElB;;;;"}
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
- var TableDynamic = require('../dynamicComponents/TableDynamic.js');
6
+ var TableStatic = require('../staticComponents/TableStatic.js');
7
7
 
8
8
  const Table = ({ rows = [], headers = [], hasMarginUp = false, hasMarginDown = false, }) => {
9
- return (jsxRuntime.jsx(TableDynamic.default, { rows: rows, headers: headers, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown }));
9
+ return (jsxRuntime.jsx(TableStatic.default, { rows: rows, headers: headers, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown }));
10
10
  };
11
11
 
12
12
  exports.default = Table;
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["../../../src/components/Table.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport TableDynamic from '../dynamicComponents/TableDynamic';\n\ninterface TableProperties {\n\trows?: ReactNode[][];\n\theaders?: ReactNode[];\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n}\n\nconst Table = ({\n\trows = [],\n\theaders = [],\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: TableProperties) => {\n\treturn (\n\t\t<TableDynamic\n\t\t\trows={rows}\n\t\t\theaders={headers}\n\t\t\thasMarginUp={hasMarginUp}\n\t\t\thasMarginDown={hasMarginDown}\n\t\t/>\n\t);\n};\n\nexport default Table;\n"],"names":["_jsx","TableDynamic"],"mappings":";;;;;;;AAUA,MAAM,KAAK,GAAG,CAAC,EACd,IAAI,GAAG,EAAE,EACT,OAAO,GAAG,EAAE,EACZ,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,GACJ,KAAI;IACrB,QACCA,eAACC,oBAAY,EAAA,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAAA,CAC3B;AAEJ;;;;"}
1
+ {"version":3,"file":"Table.js","sources":["../../../src/components/Table.tsx"],"sourcesContent":["import { ReactNode } from 'react';\nimport TableStatic from '../staticComponents/TableStatic';\n\ninterface TableProperties {\n\trows?: ReactNode[][];\n\theaders?: ReactNode[];\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n}\n\nconst Table = ({\n\trows = [],\n\theaders = [],\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: TableProperties) => {\n\treturn (\n\t\t<TableStatic\n\t\t\trows={rows}\n\t\t\theaders={headers}\n\t\t\thasMarginUp={hasMarginUp}\n\t\t\thasMarginDown={hasMarginDown}\n\t\t/>\n\t);\n};\n\nexport default Table;\n"],"names":["_jsx","TableStatic"],"mappings":";;;;;;;AAUA,MAAM,KAAK,GAAG,CAAC,EACd,IAAI,GAAG,EAAE,EACT,OAAO,GAAG,EAAE,EACZ,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,GACJ,KAAI;IACrB,QACCA,eAACC,mBAAW,EAAA,EACX,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAAA,CAC3B;AAEJ;;;;"}
@@ -5,23 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var react = require('react');
8
+ var web = require('@react-spring/web');
8
9
  var Blog_module = require('../styles/Blog.module.scss.js');
9
10
 
10
11
  const Blog = ({ children, title = 'In this article' }) => {
11
- const addPaddingTopTimerReference = react.useRef(null);
12
- const highlightCategoryTimerReference = react.useRef(null);
13
- const clearTimers = (addPaddingTopTimerReference_, highlightCategoryTimerReference_) => {
14
- if (addPaddingTopTimerReference_) {
15
- clearTimeout(addPaddingTopTimerReference_);
16
- }
17
- if (highlightCategoryTimerReference_) {
18
- clearTimeout(highlightCategoryTimerReference_);
19
- }
20
- };
21
12
  const sectionReferences = react.useRef(new Map());
22
13
  const [categoryTitles, setCategoryTitles] = react.useState(new Map());
23
14
  const [visibleTitle, setVisibleTitle] = react.useState(null);
15
+ const [showTOC, setShowTOC] = react.useState(false);
24
16
  const updateTimerRef = react.useRef(null);
17
+ const showTOCTimerRef = react.useRef(null);
25
18
  const sortByDomPosition = react.useCallback(([, a], [, b]) => {
26
19
  const position = a.el.compareDocumentPosition(b.el);
27
20
  if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
@@ -50,13 +43,15 @@ const Blog = ({ children, title = 'In this article' }) => {
50
43
  isSubSection,
51
44
  });
52
45
  }
53
- if (newCategoryTitles.size > 0) {
54
- setCategoryTitles(newCategoryTitles);
55
- if (!visibleTitle) {
56
- setVisibleTitle(firstSectionId);
57
- }
58
- }
59
- }, [visibleTitle, sortByDomPosition]);
46
+ if (newCategoryTitles.size === 0)
47
+ return;
48
+ setCategoryTitles(newCategoryTitles);
49
+ if (!showTOC)
50
+ setShowTOC(true);
51
+ if (visibleTitle)
52
+ return;
53
+ setVisibleTitle(firstSectionId);
54
+ }, [visibleTitle, sortByDomPosition, showTOC, setShowTOC]);
60
55
  const debounceUpdateCategoryTitles = react.useCallback(() => {
61
56
  // Clear existing timer and set a new one to batch updates
62
57
  if (updateTimerRef.current) {
@@ -64,7 +59,7 @@ const Blog = ({ children, title = 'In this article' }) => {
64
59
  }
65
60
  updateTimerRef.current = setTimeout(() => {
66
61
  updateCategoryTitles();
67
- }, 50);
62
+ }, 200);
68
63
  }, [updateCategoryTitles]);
69
64
  react.useEffect(() => {
70
65
  const observers = new Map();
@@ -91,10 +86,12 @@ const Blog = ({ children, title = 'In this article' }) => {
91
86
  }, [categoryTitles.size]);
92
87
  react.useEffect(() => {
93
88
  return () => {
94
- clearTimers(addPaddingTopTimerReference.current, highlightCategoryTimerReference.current);
95
89
  if (updateTimerRef.current) {
96
90
  clearTimeout(updateTimerRef.current);
97
91
  }
92
+ if (showTOCTimerRef.current) {
93
+ clearTimeout(showTOCTimerRef.current);
94
+ }
98
95
  };
99
96
  }, []);
100
97
  const handleSectionReference = react.useCallback((element) => {
@@ -149,13 +146,18 @@ const Blog = ({ children, title = 'In this article' }) => {
149
146
  clearTimeout(timer);
150
147
  }, 1000);
151
148
  };
149
+ const sidebarStyle = web.useSpring({
150
+ opacity: showTOC ? 1 : 0,
151
+ transform: showTOC ? 'translateX(0)' : 'translateX(80px)',
152
+ config: { tension: 280, friction: 60 },
153
+ });
152
154
  return (jsxRuntime.jsxs("div", { className: Blog_module.default.blog, children: [jsxRuntime.jsx("div", { className: Blog_module.default['blog__content'], children: react.Children.map(children, child => {
153
155
  if (!react.isValidElement(child))
154
156
  return child;
155
157
  return react.cloneElement(child, {
156
158
  ref: handleSectionReference,
157
159
  });
158
- }) }), jsxRuntime.jsxs("div", { className: Blog_module.default['blog__sidebar'], children: [jsxRuntime.jsx("p", { className: `${Blog_module.default['margin-bottom--3']} ${Blog_module.default['category__header']}`, children: title }), [...categoryTitles].map(([id, { title, isSubSection }], index, array) => {
160
+ }) }), jsxRuntime.jsxs(web.animated.div, { className: Blog_module.default['blog__sidebar'], style: sidebarStyle, children: [jsxRuntime.jsx("p", { className: `${Blog_module.default['margin-bottom--3']} ${Blog_module.default['category__header']}`, children: title }), [...categoryTitles].map(([id, { title, isSubSection }], index, array) => {
159
161
  const isNextSectionSubSection = array[index + 1]?.[1]?.isSubSection;
160
162
  return (jsxRuntime.jsx("p", { "data-idx": index, "data-id": id, className: `${Blog_module.default['category__title']} ${id === visibleTitle ? Blog_module.default['category__title--active'] : ''} ${isSubSection ? Blog_module.default['category__title--sub'] : ''} ${isSubSection && !isNextSectionSubSection
161
163
  ? Blog_module.default['margin-bottom-imp--2']
@@ -1 +1 @@
1
- {"version":3,"file":"BlogDynamic.js","sources":["../../../src/dynamicComponents/BlogDynamic.tsx"],"sourcesContent":["'use client';\n\nimport {\n\tChildren,\n\tcloneElement,\n\tisValidElement,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from 'react';\n\nimport type { MouseEvent, ReactNode, RefAttributes } from 'react';\n\nimport styles from '../styles/Blog.module.scss';\n\ninterface BlogProperties {\n\tchildren: ReactNode;\n\ttitle?: string;\n}\n\nexport interface ForwardedReference {\n\tparentRef: HTMLDivElement;\n\tchildRefs: HTMLDivElement[];\n}\n\ninterface SectionReferenceValue {\n\tel: HTMLElement;\n\ttitle: string;\n\tisSubSection: boolean;\n}\n\ntype SectionReference = Map<string, SectionReferenceValue>;\n\ninterface CategoryTitleValue extends SectionReferenceValue {\n\tlastUpdatedAt: number;\n}\n\ntype CategoryTitle = Map<string, CategoryTitleValue>;\n\ntype AddPaddingTopTimerReference = ReturnType<typeof setTimeout> | null;\n\nconst Blog = ({ children, title = 'In this article' }: BlogProperties) => {\n\tconst addPaddingTopTimerReference = useRef<AddPaddingTopTimerReference>(null);\n\tconst highlightCategoryTimerReference =\n\t\tuseRef<AddPaddingTopTimerReference>(null);\n\n\tconst clearTimers = (\n\t\taddPaddingTopTimerReference_: AddPaddingTopTimerReference,\n\t\thighlightCategoryTimerReference_: AddPaddingTopTimerReference\n\t) => {\n\t\tif (addPaddingTopTimerReference_) {\n\t\t\tclearTimeout(addPaddingTopTimerReference_);\n\t\t}\n\t\tif (highlightCategoryTimerReference_) {\n\t\t\tclearTimeout(highlightCategoryTimerReference_);\n\t\t}\n\t};\n\n\tconst sectionReferences = useRef<SectionReference>(new Map());\n\tconst [categoryTitles, setCategoryTitles] = useState<CategoryTitle>(\n\t\tnew Map()\n\t);\n\tconst [visibleTitle, setVisibleTitle] = useState<string | null>(null);\n\tconst updateTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n\tconst sortByDomPosition = useCallback(\n\t\t([, a]: [string, SectionReferenceValue], [, b]: [string, SectionReferenceValue]) => {\n\t\t\tconst position = a.el.compareDocumentPosition(b.el);\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1; // a comes before b\n\t\t\t} else if (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1; // b comes before a\n\t\t\t}\n\t\t\treturn 0;\n\t\t},\n\t\t[]\n\t);\n\n\tconst updateCategoryTitles = useCallback(() => {\n\t\tconst now = Date.now();\n\t\tconst newCategoryTitles = new Map<string, CategoryTitleValue>();\n\n\t\t// Sort sections by their DOM position to maintain correct order\n\t\tconst sectionsArray = Array.from(sectionReferences.current.entries());\n\t\tsectionsArray.sort(sortByDomPosition);\n\n\t\tlet firstSectionId: string | null = null;\n\t\tfor (const [id, { title, el, isSubSection }] of sectionsArray) {\n\t\t\tif (!firstSectionId) {\n\t\t\t\tfirstSectionId = id;\n\t\t\t}\n\t\t\tnewCategoryTitles.set(id, {\n\t\t\t\tel,\n\t\t\t\ttitle,\n\t\t\t\tlastUpdatedAt: now,\n\t\t\t\tisSubSection,\n\t\t\t});\n\t\t}\n\n\t\tif (newCategoryTitles.size > 0) {\n\t\t\tsetCategoryTitles(newCategoryTitles);\n\t\t\tif (!visibleTitle) {\n\t\t\t\tsetVisibleTitle(firstSectionId);\n\t\t\t}\n\t\t}\n\t}, [visibleTitle, sortByDomPosition]);\n\n\tconst debounceUpdateCategoryTitles = useCallback(() => {\n\t\t// Clear existing timer and set a new one to batch updates\n\t\tif (updateTimerRef.current) {\n\t\t\tclearTimeout(updateTimerRef.current);\n\t\t}\n\t\tupdateTimerRef.current = setTimeout(() => {\n\t\t\tupdateCategoryTitles();\n\t\t}, 50);\n\t}, [updateCategoryTitles]);\n\n\tuseEffect(() => {\n\t\tconst observers = new Map<string, IntersectionObserver>();\n\t\tfor (const [id, { el }] of categoryTitles) {\n\t\t\tconst observer = new IntersectionObserver(\n\t\t\t\t([entry]) => {\n\t\t\t\t\tif (!entry.isIntersecting) return;\n\t\t\t\t\tsetVisibleTitle(visibleId => {\n\t\t\t\t\t\tif (visibleId === id && !entry.isIntersecting) return null;\n\t\t\t\t\t\tif (entry.isIntersecting) return id;\n\t\t\t\t\t\treturn visibleId;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t{ threshold: 0.1 }\n\t\t\t);\n\t\t\tobservers.set(id, observer);\n\t\t\tobserver.observe(el);\n\t\t}\n\t\treturn () => {\n\t\t\tfor (const observer of observers.values()) {\n\t\t\t\tobserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [categoryTitles.size]);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tclearTimers(\n\t\t\t\taddPaddingTopTimerReference.current,\n\t\t\t\thighlightCategoryTimerReference.current\n\t\t\t);\n\t\t\tif (updateTimerRef.current) {\n\t\t\t\tclearTimeout(updateTimerRef.current);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\tconst handleSectionReference = useCallback((element: ForwardedReference) => {\n\t\tif (!element) return;\n\t\tconst { parentRef, childRefs } = element;\n\n\t\t// Add parent section reference\n\t\tif (parentRef) {\n\t\t\tconst id = parentRef.dataset.id;\n\t\t\tconst title = parentRef.dataset.title;\n\t\t\tif (id && title) {\n\t\t\t\tsectionReferences.current.set(id, {\n\t\t\t\t\tel: parentRef,\n\t\t\t\t\ttitle,\n\t\t\t\t\tisSubSection: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Add child section references\n\t\tif (Array.isArray(childRefs)) {\n\t\t\tfor (const childRef of childRefs) {\n\t\t\t\tif (!childRef) continue;\n\t\t\t\tconst id = childRef.dataset.id;\n\t\t\t\tconst title = childRef.dataset.title;\n\t\t\t\tif (id && title) {\n\t\t\t\t\tsectionReferences.current.set(id, {\n\t\t\t\t\t\tel: childRef,\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\tisSubSection: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tdebounceUpdateCategoryTitles();\n\t}, [debounceUpdateCategoryTitles]);\n\n\tconst handleClickCategoryTitle = (\n\t\terror: MouseEvent<HTMLParagraphElement>\n\t) => {\n\t\tconst id = error.currentTarget.dataset.id;\n\t\tconst index = error.currentTarget.dataset.idx;\n\t\tif (!id || !index) return;\n\n\t\tconst { el } = categoryTitles.get(id) || {};\n\t\tif (!el) return;\n\n\t\tconst top = el.getBoundingClientRect().top + document.body.scrollTop - 100;\n\t\tdocument.body.scrollTo({\n\t\t\ttop,\n\t\t\tbehavior: 'smooth',\n\t\t});\n\n\t\tconst timer = setTimeout(() => {\n\t\t\tsetVisibleTitle(id);\n\t\t\tclearTimeout(timer);\n\t\t}, 1000);\n\t};\n\n\n\treturn (\n\t\t<div className={styles.blog}>\n\t\t\t<div className={styles['blog__content']}>\n\t\t\t\t{Children.map(children, child => {\n\t\t\t\t\tif (!isValidElement(child)) return child;\n\t\t\t\t\treturn cloneElement(child, {\n\t\t\t\t\t\tref: handleSectionReference,\n\t\t\t\t\t} as RefAttributes<ForwardedReference>);\n\t\t\t\t})}\n\t\t\t</div>\n\t\t\t<div className={styles['blog__sidebar']}>\n\t\t\t\t<p\n\t\t\t\t\tclassName={`${styles['margin-bottom--3']} ${styles['category__header']}`}\n\t\t\t\t>\n\t\t\t\t\t{title}\n\t\t\t\t</p>\n\t\t\t\t{[...categoryTitles].map(\n\t\t\t\t\t([id, { title, isSubSection }], index, array) => {\n\t\t\t\t\t\tconst isNextSectionSubSection = array[index + 1]?.[1]?.isSubSection;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tkey={id}\n\t\t\t\t\t\t\t\tdata-idx={index}\n\t\t\t\t\t\t\t\tdata-id={id}\n\t\t\t\t\t\t\t\tclassName={`${styles['category__title']} ${\n\t\t\t\t\t\t\t\t\tid === visibleTitle ? styles['category__title--active'] : ''\n\t\t\t\t\t\t\t\t} ${isSubSection ? styles['category__title--sub'] : ''} ${\n\t\t\t\t\t\t\t\t\tisSubSection && !isNextSectionSubSection\n\t\t\t\t\t\t\t\t\t\t? styles['margin-bottom-imp--2']\n\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\tonClick={handleClickCategoryTitle}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{title}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default Blog;\n"],"names":["useRef","useState","useCallback","useEffect","_jsxs","styles","_jsx","Children","isValidElement","cloneElement"],"mappings":";;;;;;;;AA0CA,MAAM,IAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,G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AY;wBACnE,QACCC,kCAEW,KAAK,EAAA,SAAA,EACN,EAAE,EACX,SAAS,EAAE,CAAA,EAAGD,mBAAM,CAAC,iBAAiB,CAAC,IACtC,EAAE,KAAK,YAAY,GAAGA,mBAAM,CAAC,yBAAyB,CAAC,GAAG,EAC3D,IAAI,YAAY,GAAGA,mBAAM,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAA,CAAA,EACrD,YAAY,IAAI,CAAC;AAChB,kCAAEA,mBAAM,CAAC,sBAAsB;AAC/B,kCAAE,EACJ,CAAA,CAAE,EACF,OAAO,EAAE,wBAAwB,EAAA,QAAA,EAEhC,KAAK,EAAA,EAZD,EAAE,CAaJ;AAEN,oBAAA,CAAC,CACD,CAAA,EAAA,CACI,CAAA,EAAA,CACD;AAER;;;;"}
1
+ {"version":3,"file":"BlogDynamic.js","sources":["../../../src/dynamicComponents/BlogDynamic.tsx"],"sourcesContent":["'use client';\n\nimport {\n\tChildren,\n\tcloneElement,\n\tisValidElement,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { useSpring, animated } from '@react-spring/web';\n\nimport type { MouseEvent, ReactNode, RefAttributes } from 'react';\n\nimport styles from '../styles/Blog.module.scss';\n\ninterface BlogProperties {\n\tchildren: ReactNode;\n\ttitle?: string;\n}\n\nexport interface ForwardedReference {\n\tparentRef: HTMLDivElement;\n\tchildRefs: HTMLDivElement[];\n}\n\ninterface SectionReferenceValue {\n\tel: HTMLElement;\n\ttitle: string;\n\tisSubSection: boolean;\n}\n\ntype SectionReference = Map<string, SectionReferenceValue>;\n\ninterface CategoryTitleValue extends SectionReferenceValue {\n\tlastUpdatedAt: number;\n}\n\ntype CategoryTitle = Map<string, CategoryTitleValue>;\n\nconst Blog = ({ children, title = 'In this article' }: BlogProperties) => {\n\tconst sectionReferences = useRef<SectionReference>(new Map());\n\tconst [categoryTitles, setCategoryTitles] = useState<CategoryTitle>(\n\t\tnew Map()\n\t);\n\tconst [visibleTitle, setVisibleTitle] = useState<string | null>(null);\n\tconst [showTOC, setShowTOC] = useState(false);\n\n\tconst updateTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst showTOCTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n\tconst sortByDomPosition = useCallback(\n\t\t(\n\t\t\t[, a]: [string, SectionReferenceValue],\n\t\t\t[, b]: [string, SectionReferenceValue]\n\t\t) => {\n\t\t\tconst position = a.el.compareDocumentPosition(b.el);\n\t\t\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n\t\t\t\treturn -1; // a comes before b\n\t\t\t} else if (position & Node.DOCUMENT_POSITION_PRECEDING) {\n\t\t\t\treturn 1; // b comes before a\n\t\t\t}\n\t\t\treturn 0;\n\t\t},\n\t\t[]\n\t);\n\n\tconst updateCategoryTitles = useCallback(() => {\n\t\tconst now = Date.now();\n\t\tconst newCategoryTitles = new Map<string, CategoryTitleValue>();\n\n\t\t// Sort sections by their DOM position to maintain correct order\n\t\tconst sectionsArray = Array.from(sectionReferences.current.entries());\n\t\tsectionsArray.sort(sortByDomPosition);\n\n\t\tlet firstSectionId: string | null = null;\n\t\tfor (const [id, { title, el, isSubSection }] of sectionsArray) {\n\t\t\tif (!firstSectionId) {\n\t\t\t\tfirstSectionId = id;\n\t\t\t}\n\t\t\tnewCategoryTitles.set(id, {\n\t\t\t\tel,\n\t\t\t\ttitle,\n\t\t\t\tlastUpdatedAt: now,\n\t\t\t\tisSubSection,\n\t\t\t});\n\t\t}\n\n\t\tif (newCategoryTitles.size === 0) return;\n\n\t\tsetCategoryTitles(newCategoryTitles);\n\t\tif (!showTOC) setShowTOC(true);\n\n\t\tif (visibleTitle) return;\n\t\tsetVisibleTitle(firstSectionId);\n\t}, [visibleTitle, sortByDomPosition, showTOC, setShowTOC]);\n\n\tconst debounceUpdateCategoryTitles = useCallback(() => {\n\t\t// Clear existing timer and set a new one to batch updates\n\t\tif (updateTimerRef.current) {\n\t\t\tclearTimeout(updateTimerRef.current);\n\t\t}\n\t\tupdateTimerRef.current = setTimeout(() => {\n\t\t\tupdateCategoryTitles();\n\t\t}, 200);\n\t}, [updateCategoryTitles]);\n\n\tuseEffect(() => {\n\t\tconst observers = new Map<string, IntersectionObserver>();\n\t\tfor (const [id, { el }] of categoryTitles) {\n\t\t\tconst observer = new IntersectionObserver(\n\t\t\t\t([entry]) => {\n\t\t\t\t\tif (!entry.isIntersecting) return;\n\t\t\t\t\tsetVisibleTitle(visibleId => {\n\t\t\t\t\t\tif (visibleId === id && !entry.isIntersecting) return null;\n\t\t\t\t\t\tif (entry.isIntersecting) return id;\n\t\t\t\t\t\treturn visibleId;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t{ threshold: 0.1 }\n\t\t\t);\n\t\t\tobservers.set(id, observer);\n\t\t\tobserver.observe(el);\n\t\t}\n\t\treturn () => {\n\t\t\tfor (const observer of observers.values()) {\n\t\t\t\tobserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [categoryTitles.size]);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (updateTimerRef.current) {\n\t\t\t\tclearTimeout(updateTimerRef.current);\n\t\t\t}\n\t\t\tif (showTOCTimerRef.current) {\n\t\t\t\tclearTimeout(showTOCTimerRef.current);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\tconst handleSectionReference = useCallback(\n\t\t(element: ForwardedReference) => {\n\t\t\tif (!element) return;\n\t\t\tconst { parentRef, childRefs } = element;\n\n\t\t\t// Add parent section reference\n\t\t\tif (parentRef) {\n\t\t\t\tconst id = parentRef.dataset.id;\n\t\t\t\tconst title = parentRef.dataset.title;\n\t\t\t\tif (id && title) {\n\t\t\t\t\tsectionReferences.current.set(id, {\n\t\t\t\t\t\tel: parentRef,\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\tisSubSection: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add child section references\n\t\t\tif (Array.isArray(childRefs)) {\n\t\t\t\tfor (const childRef of childRefs) {\n\t\t\t\t\tif (!childRef) continue;\n\t\t\t\t\tconst id = childRef.dataset.id;\n\t\t\t\t\tconst title = childRef.dataset.title;\n\t\t\t\t\tif (id && title) {\n\t\t\t\t\t\tsectionReferences.current.set(id, {\n\t\t\t\t\t\t\tel: childRef,\n\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\tisSubSection: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdebounceUpdateCategoryTitles();\n\t\t},\n\t\t[debounceUpdateCategoryTitles]\n\t);\n\n\tconst handleClickCategoryTitle = (\n\t\terror: MouseEvent<HTMLParagraphElement>\n\t) => {\n\t\tconst id = error.currentTarget.dataset.id;\n\t\tconst index = error.currentTarget.dataset.idx;\n\t\tif (!id || !index) return;\n\n\t\tconst { el } = categoryTitles.get(id) || {};\n\t\tif (!el) return;\n\n\t\tconst top = el.getBoundingClientRect().top + document.body.scrollTop - 100;\n\t\tdocument.body.scrollTo({\n\t\t\ttop,\n\t\t\tbehavior: 'smooth',\n\t\t});\n\n\t\tconst timer = setTimeout(() => {\n\t\t\tsetVisibleTitle(id);\n\t\t\tclearTimeout(timer);\n\t\t}, 1000);\n\t};\n\n\tconst sidebarStyle = useSpring({\n\t\topacity: showTOC ? 1 : 0,\n\t\ttransform: showTOC ? 'translateX(0)' : 'translateX(80px)',\n\t\tconfig: { tension: 280, friction: 60 },\n\t});\n\n\treturn (\n\t\t<div className={styles.blog}>\n\t\t\t<div className={styles['blog__content']}>\n\t\t\t\t{Children.map(children, child => {\n\t\t\t\t\tif (!isValidElement(child)) return child;\n\t\t\t\t\treturn cloneElement(child, {\n\t\t\t\t\t\tref: handleSectionReference,\n\t\t\t\t\t} as RefAttributes<ForwardedReference>);\n\t\t\t\t})}\n\t\t\t</div>\n\t\t\t<animated.div className={styles['blog__sidebar']} style={sidebarStyle}>\n\t\t\t\t<p\n\t\t\t\t\tclassName={`${styles['margin-bottom--3']} ${styles['category__header']}`}\n\t\t\t\t>\n\t\t\t\t\t{title}\n\t\t\t\t</p>\n\t\t\t\t{[...categoryTitles].map(\n\t\t\t\t\t([id, { title, isSubSection }], index, array) => {\n\t\t\t\t\t\tconst isNextSectionSubSection = array[index + 1]?.[1]?.isSubSection;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tkey={id}\n\t\t\t\t\t\t\t\tdata-idx={index}\n\t\t\t\t\t\t\t\tdata-id={id}\n\t\t\t\t\t\t\t\tclassName={`${styles['category__title']} ${\n\t\t\t\t\t\t\t\t\tid === visibleTitle ? styles['category__title--active'] : ''\n\t\t\t\t\t\t\t\t} ${isSubSection ? styles['category__title--sub'] : ''} ${\n\t\t\t\t\t\t\t\t\tisSubSection && !isNextSectionSubSection\n\t\t\t\t\t\t\t\t\t\t? styles['margin-bottom-imp--2']\n\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\tonClick={handleClickCategoryTitle}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{title}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t)}\n\t\t\t</animated.div>\n\t\t</div>\n\t);\n};\n\nexport default Blog;\n"],"names":["useRef","useState","useCallback","useEffect","useSpring","_jsxs","styles","_jsx","Children","isValidElement","cloneElement","animated"],"mappings":";;;;;;;;;AAyCA,MAAM,IAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,GAAG,iBAAiB,EAAkB,KAAI;IACxE,MAAM,iBAAiB,GAAGA,YAAM,CAAmB,IAAI,GAAG,EAAE,CAAC;AAC7D,IAAA,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAGC,cAAQ,CACnD,IAAI,GAAG,EAAE,CACT;IACD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAGA,cAAQ,CAAgB,IAAI,CAAC;IACrE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AE,CAAA,EAAGD,mBAAM,CAAC,iBAAiB,CAAC,IACtC,EAAE,KAAK,YAAY,GAAGA,mBAAM,CAAC,yBAAyB,CAAC,GAAG,EAC3D,IAAI,YAAY,GAAGA,mBAAM,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAA,CAAA,EACrD,YAAY,IAAI,CAAC;AAChB,kCAAEA,mBAAM,CAAC,sBAAsB;AAC/B,kCAAE,EACJ,CAAA,CAAE,EACF,OAAO,EAAE,wBAAwB,EAAA,QAAA,EAEhC,KAAK,EAAA,EAZD,EAAE,CAaJ;AAEN,oBAAA,CAAC,CACD,CAAA,EAAA,CACa,CAAA,EAAA,CACV;AAER;;;;"}
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1 +1 @@
1
- {"version":3,"file":"BlogSectionDynamic.js","sources":["../../../src/dynamicComponents/BlogSectionDynamic.tsx"],"sourcesContent":["import {\n\tChildren,\n\tcloneElement,\n\tforwardRef,\n\tisValidElement,\n\tuseImperativeHandle,\n\tuseRef,\n} from 'react';\n\nimport type { ReactNode, RefAttributes } from 'react';\n\nimport styles from '../styles/BlogSection.module.scss';\n\nimport type { ForwardedReference } from './BlogDynamic';\nimport { generateIdForBlogTitle } from '../utils';\n\ninterface BlogProperties {\n\ttitle?: string;\n\tcategory?: string;\n\tchildren?: ReactNode;\n\tincreaseMarginBottom?: boolean;\n}\n\nconst BlogSection = forwardRef<ForwardedReference, BlogProperties>(\n\t(\n\t\t{\n\t\t\ttitle = '',\n\t\t\tcategory = '',\n\t\t\tchildren = null,\n\t\t\tincreaseMarginBottom = false,\n\t\t}: BlogProperties,\n\t\tforwardedReference\n\t) => {\n\t\tconst titleWithCategory = category ? `${category} - ${title}` : title;\n\t\tconst id = generateIdForBlogTitle(titleWithCategory);\n\n\t\tconst parentReference = useRef<ForwardedReference['parentRef']>(null);\n\t\tconst childReferences = useRef<ForwardedReference['childRefs']>([]);\n\t\tconst imperativeHandleRef = useRef<ForwardedReference | null>(null);\n\n\t\tuseImperativeHandle(forwardedReference, () => {\n\t\t\tconst handle = {\n\t\t\t\tparentRef: parentReference.current!,\n\t\t\t\tchildRefs: childReferences.current!,\n\t\t\t};\n\t\t\timperativeHandleRef.current = handle;\n\t\t\treturn handle;\n\t\t});\n\n\t\tconst handleChildReferences = (element: ForwardedReference | null) => {\n\t\t\tif (!element) return;\n\t\t\tconst { parentRef: subParentReference } = element;\n\t\t\tif (!subParentReference) return;\n\t\t\tchildReferences.current.push(subParentReference);\n\n\t\t\t// Re-trigger parent ref callback with updated children\n\t\t\tif (typeof forwardedReference === 'function' && imperativeHandleRef.current) {\n\t\t\t\tforwardedReference(imperativeHandleRef.current);\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={`${styles['blog-section']}\n\t\t\t\t\t${\n\t\t\t\t\t\tincreaseMarginBottom\n\t\t\t\t\t\t\t? styles['margin-bottom--9']\n\t\t\t\t\t\t\t: styles['margin-bottom--6']\n\t\t\t\t\t}`}\n\t\t\t\tdata-title={title}\n\t\t\t\tdata-id={id}\n\t\t\t\tref={parentReference}\n\t\t\t>\n\t\t\t\t{title ? (\n\t\t\t\t\t<h4 className={styles['blog-section__title']}>{title}</h4>\n\t\t\t\t) : null}\n\t\t\t\t{Children.map(children, child => {\n\t\t\t\t\tif (!isValidElement(child)) return child;\n\t\t\t\t\treturn cloneElement(child, {\n\t\t\t\t\t\tref: handleChildReferences,\n\t\t\t\t\t} as RefAttributes<ForwardedReference>);\n\t\t\t\t})}\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nBlogSection.displayName = 'BlogSection';\n\nexport default BlogSection;\n"],"names":["forwardRef","generateIdForBlogTitle","useRef","useImperativeHandle","_jsxs","styles","_jsx","Children","isValidElement","cloneElement"],"mappings":";;;;;;;;;AAuBA,MAAM,WAAW,GAAGA,gBAAU,CAC7B,CACC,EACC,KAAK,GAAG,EAAE,E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AAA,CAAE,EAAA,YAAA,EACS,KAAK,EAAA,SAAA,EACR,EAAE,EACX,GAAG,EAAE,eAAe,EAAA,QAAA,EAAA,CAEnB,KAAK,IACLC,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAED,0BAAM,CAAC,qBAAqB,CAAC,EAAA,QAAA,EAAG,KAAK,EAAA,CAAM,IACvD,IAAI,EACPE,cAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,IAAG;AAC/B,gBAAA,IAAI,CAACC,oBAAc,CAAC,KAAK,CAAC;AAAE,oBAAA,OAAO,KAAK;gBACxC,OAAOC,kBAAY,CAAC,KAAK,EAAE;AAC1B,oBAAA,GAAG,EAAE,qBAAqB;AACW,iBAAA,CAAC;YACxC,CAAC,CAAC,CAAA,EAAA,CACG;AAER,CAAC;AAGF,WAAW,CAAC,WAAW,GAAG,aAAa;;;;"}
1
+ {"version":3,"file":"BlogSectionDynamic.js","sources":["../../../src/dynamicComponents/BlogSectionDynamic.tsx"],"sourcesContent":["'use client';\n\nimport {\n\tChildren,\n\tcloneElement,\n\tforwardRef,\n\tisValidElement,\n\tuseImperativeHandle,\n\tuseRef,\n} from 'react';\n\nimport type { ReactNode, RefAttributes } from 'react';\n\nimport styles from '../styles/BlogSection.module.scss';\n\nimport type { ForwardedReference } from './BlogDynamic';\nimport { generateIdForBlogTitle } from '../utils';\n\ninterface BlogProperties {\n\ttitle?: string;\n\tcategory?: string;\n\tchildren?: ReactNode;\n\tincreaseMarginBottom?: boolean;\n}\n\nconst BlogSection = forwardRef<ForwardedReference, BlogProperties>(\n\t(\n\t\t{\n\t\t\ttitle = '',\n\t\t\tcategory = '',\n\t\t\tchildren = null,\n\t\t\tincreaseMarginBottom = false,\n\t\t}: BlogProperties,\n\t\tforwardedReference\n\t) => {\n\t\tconst titleWithCategory = category ? `${category} - ${title}` : title;\n\t\tconst id = generateIdForBlogTitle(titleWithCategory);\n\n\t\tconst parentReference = useRef<ForwardedReference['parentRef']>(null);\n\t\tconst childReferences = useRef<ForwardedReference['childRefs']>([]);\n\t\tconst imperativeHandleRef = useRef<ForwardedReference | null>(null);\n\n\t\tuseImperativeHandle(forwardedReference, () => {\n\t\t\tconst handle = {\n\t\t\t\tparentRef: parentReference.current!,\n\t\t\t\tchildRefs: childReferences.current!,\n\t\t\t};\n\t\t\timperativeHandleRef.current = handle;\n\t\t\treturn handle;\n\t\t});\n\n\t\tconst handleChildReferences = (element: ForwardedReference | null) => {\n\t\t\tif (!element) return;\n\t\t\tconst { parentRef: subParentReference } = element;\n\t\t\tif (!subParentReference) return;\n\t\t\tchildReferences.current.push(subParentReference);\n\n\t\t\t// Re-trigger parent ref callback with updated children\n\t\t\tif (typeof forwardedReference === 'function' && imperativeHandleRef.current) {\n\t\t\t\tforwardedReference(imperativeHandleRef.current);\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={`${styles['blog-section']}\n\t\t\t\t\t${\n\t\t\t\t\t\tincreaseMarginBottom\n\t\t\t\t\t\t\t? styles['margin-bottom--9']\n\t\t\t\t\t\t\t: styles['margin-bottom--6']\n\t\t\t\t\t}`}\n\t\t\t\tdata-title={title}\n\t\t\t\tdata-id={id}\n\t\t\t\tref={parentReference}\n\t\t\t>\n\t\t\t\t{title ? (\n\t\t\t\t\t<h4 className={styles['blog-section__title']}>{title}</h4>\n\t\t\t\t) : null}\n\t\t\t\t{Children.map(children, child => {\n\t\t\t\t\tif (!isValidElement(child)) return child;\n\t\t\t\t\treturn cloneElement(child, {\n\t\t\t\t\t\tref: handleChildReferences,\n\t\t\t\t\t} as RefAttributes<ForwardedReference>);\n\t\t\t\t})}\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nBlogSection.displayName = 'BlogSection';\n\nexport default BlogSection;\n"],"names":["forwardRef","generateIdForBlogTitle","useRef","useImperativeHandle","_jsxs","styles","_jsx","Children","isValidElement","cloneElement"],"mappings":";;;;;;;;;AAyBA,MAAM,WAAW,GAAGA,gBAAU,C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