@toteat-eng/ds-react 2026.7.10-1 → 2026.7.13

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,12 +1,28 @@
1
1
  import type { ReactNode } from "react";
2
- export interface SidebarNavSectionProps {
2
+ interface SidebarNavSectionBaseProps {
3
3
  title: string;
4
4
  icon?: ReactNode;
5
5
  titleSuffix?: ReactNode;
6
- defaultOpen?: boolean;
7
6
  isActive?: boolean;
8
7
  className?: string;
9
8
  children: ReactNode;
10
9
  "data-testid"?: string;
11
10
  }
12
- export declare function SidebarNavSection({ title, icon, titleSuffix, defaultOpen, isActive, className, children, "data-testid": testId, }: SidebarNavSectionProps): import("react/jsx-runtime").JSX.Element;
11
+ interface UncontrolledSidebarNavSectionProps {
12
+ /** Initial open state (uncontrolled — the component owns open/close). */
13
+ defaultOpen?: boolean;
14
+ open?: undefined;
15
+ /** Fired on every trigger click. */
16
+ onToggle?: () => void;
17
+ }
18
+ interface ControlledSidebarNavSectionProps {
19
+ /** Controlled open state. The component renders from this and never mutates
20
+ * internal state — the parent owns open/close (e.g. a single-open accordion). */
21
+ open: boolean;
22
+ /** Required in controlled mode so the parent can react to trigger clicks. */
23
+ onToggle: () => void;
24
+ defaultOpen?: never;
25
+ }
26
+ export type SidebarNavSectionProps = SidebarNavSectionBaseProps & (ControlledSidebarNavSectionProps | UncontrolledSidebarNavSectionProps);
27
+ export declare function SidebarNavSection({ title, icon, titleSuffix, defaultOpen, open, onToggle, isActive, className, children, "data-testid": testId, }: SidebarNavSectionProps): import("react/jsx-runtime").JSX.Element;
28
+ export {};
@@ -8,4 +8,5 @@ export declare const DefaultOpen: Story;
8
8
  export declare const Active: Story;
9
9
  export declare const WithIcon: Story;
10
10
  export declare const WithTitleSuffix: Story;
11
+ export declare const ControlledAccordion: Story;
11
12
  export declare const MultipleSections: Story;
package/dist/index.es.js CHANGED
@@ -2918,18 +2918,20 @@ var Z = {
2918
2918
  };
2919
2919
  //#endregion
2920
2920
  //#region src/components/SidebarNavSection/SidebarNavSection.tsx
2921
- function qi({ title: e, icon: t, titleSuffix: n, defaultOpen: r = !1, isActive: i = !1, className: a, children: o, "data-testid": s }) {
2922
- let [c, l] = Ki(r);
2921
+ function qi({ title: e, icon: t, titleSuffix: n, defaultOpen: r = !1, open: i, onToggle: a, isActive: o = !1, className: s, children: c, "data-testid": l }) {
2922
+ let [u, p] = Ki(r), m = i !== void 0, h = m ? i : u;
2923
2923
  return /* @__PURE__ */ f("div", {
2924
- className: R(Z.section, a),
2925
- "data-testid": s,
2924
+ className: R(Z.section, s),
2925
+ "data-testid": l,
2926
2926
  children: [/* @__PURE__ */ f("button", {
2927
2927
  type: "button",
2928
2928
  className: Z.trigger,
2929
- "data-open": c || void 0,
2930
- "data-active": i || void 0,
2931
- onClick: l,
2932
- "aria-expanded": c,
2929
+ "data-open": h || void 0,
2930
+ "data-active": o || void 0,
2931
+ onClick: () => {
2932
+ m || p(), a?.();
2933
+ },
2934
+ "aria-expanded": h,
2933
2935
  children: [
2934
2936
  t && /* @__PURE__ */ d("span", {
2935
2937
  className: Z.icon,
@@ -2952,11 +2954,11 @@ function qi({ title: e, icon: t, titleSuffix: n, defaultOpen: r = !1, isActive:
2952
2954
  ]
2953
2955
  }), /* @__PURE__ */ d("div", {
2954
2956
  className: Z.content,
2955
- "data-open": c || void 0,
2956
- inert: !c || void 0,
2957
+ "data-open": h || void 0,
2958
+ inert: !h || void 0,
2957
2959
  children: /* @__PURE__ */ d("div", {
2958
2960
  className: Z.inner,
2959
- children: o
2961
+ children: c
2960
2962
  })
2961
2963
  })]
2962
2964
  });