@invana/ui 0.0.16 → 0.0.18

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/dist/index.cjs CHANGED
@@ -3155,6 +3155,110 @@ function PanelContent({
3155
3155
  footerContent ? /* @__PURE__ */ jsxRuntime.jsx(CardFooter, { className: footerClassName, children: footerContent }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
3156
3156
  ] }) });
3157
3157
  }
3158
+ function PanelStack({
3159
+ sections,
3160
+ headerHeight = 35,
3161
+ withHandle = false,
3162
+ className,
3163
+ headerClassName,
3164
+ bodyClassName
3165
+ }) {
3166
+ const refs = React23__namespace.useRef({});
3167
+ const [collapsed, setCollapsed] = React23__namespace.useState(
3168
+ () => Object.fromEntries(sections.map((s) => [s.id, !!s.defaultCollapsed]))
3169
+ );
3170
+ const didInit = React23__namespace.useRef(false);
3171
+ React23__namespace.useLayoutEffect(() => {
3172
+ if (didInit.current) return;
3173
+ didInit.current = true;
3174
+ for (const section of sections) {
3175
+ if (section.defaultCollapsed) refs.current[section.id]?.collapse();
3176
+ }
3177
+ }, []);
3178
+ const toggle = (id) => {
3179
+ const ref = refs.current[id];
3180
+ if (!ref) return;
3181
+ if (ref.isCollapsed()) ref.expand();
3182
+ else ref.collapse();
3183
+ };
3184
+ return /* @__PURE__ */ jsxRuntime.jsx(
3185
+ ResizablePanelGroup,
3186
+ {
3187
+ orientation: "vertical",
3188
+ className: cn("h-full w-full", className),
3189
+ children: sections.map((section, index) => {
3190
+ const Icon = section.icon;
3191
+ const isCollapsed = collapsed[section.id];
3192
+ return /* @__PURE__ */ jsxRuntime.jsxs(React23__namespace.Fragment, { children: [
3193
+ index > 0 && /* @__PURE__ */ jsxRuntime.jsx(ResizableHandle, { withHandle }),
3194
+ /* @__PURE__ */ jsxRuntime.jsxs(
3195
+ ResizablePanel,
3196
+ {
3197
+ collapsible: true,
3198
+ collapsedSize: `${headerHeight}px`,
3199
+ minSize: section.minSize ?? `${headerHeight + 64}px`,
3200
+ defaultSize: section.defaultSize,
3201
+ panelRef: (ref) => {
3202
+ refs.current[section.id] = ref;
3203
+ },
3204
+ onResize: (size) => {
3205
+ const next = size.inPixels <= headerHeight + 1;
3206
+ setCollapsed(
3207
+ (prev) => prev[section.id] === next ? prev : { ...prev, [section.id]: next }
3208
+ );
3209
+ },
3210
+ className: "flex flex-col overflow-hidden",
3211
+ children: [
3212
+ /* @__PURE__ */ jsxRuntime.jsxs(
3213
+ "div",
3214
+ {
3215
+ style: { height: headerHeight },
3216
+ className: cn(
3217
+ "flex shrink-0 items-center pr-2 text-muted-foreground",
3218
+ headerClassName
3219
+ ),
3220
+ children: [
3221
+ /* @__PURE__ */ jsxRuntime.jsxs(
3222
+ "button",
3223
+ {
3224
+ type: "button",
3225
+ onClick: () => toggle(section.id),
3226
+ "aria-expanded": !isCollapsed,
3227
+ className: cn(
3228
+ "flex h-full min-w-0 flex-1 items-center gap-1 pl-2 text-left",
3229
+ "transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
3230
+ ),
3231
+ children: [
3232
+ isCollapsed ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 shrink-0" }),
3233
+ Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "h-3.5 w-3.5 shrink-0" }),
3234
+ typeof section.title === "string" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs font-semibold uppercase tracking-wide", children: section.title }) : (
3235
+ // Custom node: rendered as-is so the consumer owns the
3236
+ // styling (icon, casing, colour, badges…).
3237
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex min-w-0 flex-1 items-center", children: section.title })
3238
+ )
3239
+ ]
3240
+ }
3241
+ ),
3242
+ section.actions && !isCollapsed && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1 pl-2", children: section.actions })
3243
+ ]
3244
+ }
3245
+ ),
3246
+ /* @__PURE__ */ jsxRuntime.jsx(
3247
+ "div",
3248
+ {
3249
+ className: cn("min-h-0 flex-1 overflow-auto", bodyClassName),
3250
+ hidden: isCollapsed,
3251
+ children: section.content
3252
+ }
3253
+ )
3254
+ ]
3255
+ }
3256
+ )
3257
+ ] }, section.id);
3258
+ })
3259
+ }
3260
+ );
3261
+ }
3158
3262
  function OptionRow({ option }) {
3159
3263
  const Icon = option.icon;
3160
3264
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
@@ -4077,6 +4181,7 @@ exports.PaginationLink = PaginationLink;
4077
4181
  exports.PaginationNext = PaginationNext;
4078
4182
  exports.PaginationPrevious = PaginationPrevious;
4079
4183
  exports.PanelContent = PanelContent;
4184
+ exports.PanelStack = PanelStack;
4080
4185
  exports.Popover = Popover;
4081
4186
  exports.PopoverContent = PopoverContent;
4082
4187
  exports.PopoverTrigger = PopoverTrigger;