@adamjanicki/ui 1.6.4 → 1.6.5

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.
@@ -4,7 +4,7 @@ type Props = Omit<BoxProps, "children"> & {
4
4
  /**
5
5
  * Drawers to render as accordion sections
6
6
  */
7
- drawers: UncontrolledDrawer[] | ControlledDrawer[];
7
+ drawers: Drawer[];
8
8
  /**
9
9
  * Duration of the drawer animation (in seconds)
10
10
  */
@@ -16,7 +16,7 @@ type Props = Omit<BoxProps, "children"> & {
16
16
  hideDividers?: boolean;
17
17
  };
18
18
  declare const Accordion: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
19
- type UncontrolledDrawer = {
19
+ type Drawer = {
20
20
  /**
21
21
  * Label for the accordion drawer
22
22
  */
@@ -25,8 +25,6 @@ type UncontrolledDrawer = {
25
25
  * Content hidden within this accordion drawer
26
26
  */
27
27
  content: React.ReactNode;
28
- };
29
- type ControlledDrawer = UncontrolledDrawer & {
30
28
  /**
31
29
  * Whether the drawer is open
32
30
  */
@@ -36,4 +34,10 @@ type ControlledDrawer = UncontrolledDrawer & {
36
34
  */
37
35
  onOpenChange: (open: boolean) => void;
38
36
  };
37
+ type DrawerProps = {
38
+ item: Drawer;
39
+ duration?: number;
40
+ showDivider: boolean;
41
+ };
42
+ declare const Drawer: ({ item, duration, showDivider }: DrawerProps) => import("react/jsx-runtime").JSX.Element;
39
43
  export default Accordion;
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
24
- import React, { useState, useRef, useEffect } from "react";
24
+ import React, { useRef, useState, useEffect } from "react";
25
25
  import Box from "../Box/Box";
26
26
  import Icon from "../Icon";
27
27
  import { UnstyledButton } from "../Button";
@@ -29,19 +29,7 @@ import Animated from "../Animated";
29
29
  import { classNames } from "../../functions";
30
30
  var Accordion = React.forwardRef(function (_a, ref) {
31
31
  var drawers = _a.drawers, className = _a.className, duration = _a.duration, hideDividers = _a.hideDividers, layout = _a.layout, rest = __rest(_a, ["drawers", "className", "duration", "hideDividers", "layout"]);
32
- var _b = useState(new Set()), openIndices = _b[0], setOpenIndices = _b[1];
33
- return (_jsx(Box, __assign({ layout: __assign({ axis: "y" }, layout) }, rest, { className: classNames("aui-accordion aui-corners--rounded", className), ref: ref, children: drawers.map(function (item, i) { return (_jsx(Drawer, { item: __assign({ open: openIndices.has(i), onOpenChange: function (open) {
34
- return setOpenIndices(function (prev) {
35
- var next = new Set(prev);
36
- if (open) {
37
- next.add(i);
38
- }
39
- else {
40
- next.delete(i);
41
- }
42
- return next;
43
- });
44
- } }, item), duration: duration, showDivider: !hideDividers && i < drawers.length - 1 }, i)); }) })));
32
+ return (_jsx(Box, __assign({ layout: __assign({ axis: "y" }, layout) }, rest, { className: classNames("aui-accordion aui-corners--rounded", className), ref: ref, children: drawers.map(function (item, i) { return (_jsx(Drawer, { item: item, duration: duration, showDivider: !hideDividers && i < drawers.length - 1 }, i)); }) })));
45
33
  });
46
34
  var Drawer = function (_a) {
47
35
  var item = _a.item, duration = _a.duration, showDivider = _a.showDivider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "Basic UI components and hooks for React in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./index.js",