@wonderflow/react-components 9.4.0 → 9.5.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"disclosure.d.ts","sourceRoot":"","sources":["../../../src/components/disclosure/disclosure.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;AAMd,oBAAY,eAAe,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,GAAG;IACxE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,UAAU;IAnCrB;;OAEG;;IAEH;;;OAGG;aACM,SAAS;IAClB;;;;OAIG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;sDAuGH,CAAA"}
1
+ {"version":3,"file":"disclosure.d.ts","sourceRoot":"","sources":["../../../src/components/disclosure/disclosure.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;AAMd,oBAAY,eAAe,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,GAAG;IACxE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,UAAU;IAnCrB;;OAEG;;IAEH;;;OAGG;aACM,SAAS;IAClB;;;;OAIG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;sDA0GH,CAAA"}
@@ -4,7 +4,7 @@ import clsx from 'clsx';
4
4
  import styles from './disclosure.module.css';
5
5
  import { Text, Icon } from '../..';
6
6
  import { domMax, LazyMotion, m } from 'framer-motion';
7
- export const Disclosure = forwardRef(({ children, open = false, padding = true, className, summary, contentMaxHeight, dimension = 'regular', iconPosition = 'left', expandable = true, style, ...otherProps }, forwardedRef) => {
7
+ export const Disclosure = forwardRef(({ children, open = false, padding = true, className, summary, contentMaxHeight, dimension = 'regular', iconPosition = 'left', expandable = true, style, onToggle, ...otherProps }, forwardedRef) => {
8
8
  const ref = useRef(forwardedRef);
9
9
  const [isOpen, setIsOpen] = useState(open);
10
10
  useEffect(() => {
@@ -13,8 +13,10 @@ export const Disclosure = forwardRef(({ children, open = false, padding = true,
13
13
  }
14
14
  }, [expandable, open]);
15
15
  const handleOpen = useCallback(() => () => {
16
- (ref.current && expandable) && setIsOpen(ref.current.open);
17
- }, [expandable]);
16
+ if (ref.current && expandable)
17
+ setIsOpen(ref.current.open);
18
+ expandable && onToggle?.(ref.current.open);
19
+ }, [expandable, onToggle]);
18
20
  const dynamicStyle = {
19
21
  '--max-height': contentMaxHeight
20
22
  };
@@ -32,7 +34,7 @@ export const Disclosure = forwardRef(({ children, open = false, padding = true,
32
34
  icon: 24
33
35
  }
34
36
  };
35
- const renderContent = useCallback(() => (_jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { className: styles.Content, "data-disclosure-padding": padding, "data-disclosure-height": Boolean(contentMaxHeight), animate: isOpen ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 }, initial: false, children: children }) })), [children, contentMaxHeight, padding, isOpen]);
36
- return (_jsxs("details", { style: { ...dynamicStyle, ...style }, className: clsx(styles.Disclosure, className), "data-disclosure-icon-position": iconPosition, "data-disclosure-dimension": dimension, "data-disclosure-expandable": expandable, onToggle: handleOpen(), "aria-expanded": isOpen ? 'true' : 'false', ref: ref, ...otherProps, children: [_jsxs(Text, { as: "summary", responsive: false, className: styles.Summary, "aria-expanded": isOpen, tabIndex: !expandable ? -1 : 0, size: dimension ? sizes[dimension].summary : undefined, weight: "bold", children: [summary, expandable && (_jsx(Icon, { className: styles.ExpandIcon, source: "chevron-right", dimension: sizes[dimension].icon }))] }), renderContent()] }));
37
+ const renderContent = useCallback(() => (_jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { className: styles.Content, "data-disclosure-padding": padding, "data-disclosure-height": Boolean(contentMaxHeight), animate: isOpen ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1, delay: 0.1 }, initial: false, children: children }) })), [children, contentMaxHeight, padding, isOpen]);
38
+ return (_jsxs("details", { style: { ...dynamicStyle, ...style }, className: clsx(styles.Disclosure, className), "data-disclosure-icon-position": iconPosition, "data-disclosure-dimension": dimension, "data-disclosure-expandable": expandable, onToggle: handleOpen(), "aria-expanded": isOpen ? 'true' : 'false', ref: ref, open: isOpen, ...otherProps, children: [_jsxs(Text, { as: "summary", responsive: false, className: styles.Summary, "aria-expanded": isOpen, tabIndex: !expandable ? -1 : 0, size: dimension ? sizes[dimension].summary : undefined, weight: "bold", children: [summary, expandable && (_jsx(Icon, { className: styles.ExpandIcon, source: "chevron-right", dimension: sizes[dimension].icon }))] }), renderContent()] }));
37
39
  });
38
40
  Disclosure.displayName = 'Disclosure';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "9.4.0",
3
+ "version": "9.5.0",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",