@marlinjai/clearify 1.6.1 → 1.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marlinjai/clearify",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "An open-source documentation site generator. Turn markdown into beautiful docs.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -189,8 +189,14 @@ export function Sidebar({ sections, open, onClose }: SidebarProps) {
189
189
  });
190
190
  };
191
191
 
192
- const handleExpandAll = () => setExpandedGroups(new Set(allGroupKeys));
193
- const handleCollapseAll = () => setExpandedGroups(new Set());
192
+ const handleExpandAll = () => {
193
+ setExpandedGroups(new Set(allGroupKeys));
194
+ window.dispatchEvent(new CustomEvent('clearify:expand-all'));
195
+ };
196
+ const handleCollapseAll = () => {
197
+ setExpandedGroups(new Set());
198
+ window.dispatchEvent(new CustomEvent('clearify:collapse-all'));
199
+ };
194
200
 
195
201
  return (
196
202
  <>
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import { OperationCard } from './OperationCard.js';
3
3
 
4
4
  interface TagGroupProps {
@@ -17,6 +17,17 @@ function operationAnchorId(tag: string, method: string, path: string): string {
17
17
  export function TagGroup({ tag, description, operations, baseUrl }: TagGroupProps) {
18
18
  const [expanded, setExpanded] = useState(true);
19
19
 
20
+ useEffect(() => {
21
+ const onExpand = () => setExpanded(true);
22
+ const onCollapse = () => setExpanded(false);
23
+ window.addEventListener('clearify:expand-all', onExpand);
24
+ window.addEventListener('clearify:collapse-all', onCollapse);
25
+ return () => {
26
+ window.removeEventListener('clearify:expand-all', onExpand);
27
+ window.removeEventListener('clearify:collapse-all', onCollapse);
28
+ };
29
+ }, []);
30
+
20
31
  return (
21
32
  <div
22
33
  id={`tag/${encodeURIComponent(tag)}`}