@neasg/design-system 0.4.11 → 0.4.12

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/tabs.js CHANGED
@@ -2,11 +2,12 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import * as TabsPrimitive from "@radix-ui/react-tabs";
5
+ import { Check } from "lucide-react";
5
6
  import { ChevronDownIcon } from "./animated-icons/chevron-down";
6
7
  import { XIcon } from "./animated-icons/x";
7
8
  import { cn } from "./lib/utils";
8
9
  import { Popover } from "./popover";
9
- import { PopoverMenuItem, PopoverMenuSection } from "./popover-menu";
10
+ import { PopoverMenuSection } from "./popover-menu";
10
11
  const TabsContext = React.createContext(null);
11
12
  const getTabValueSelector = (value) => {
12
13
  const escapedValue = typeof CSS !== "undefined" && typeof CSS.escape === "function"
@@ -40,7 +41,7 @@ TabsContent.displayName = TabsPrimitive.Content.displayName;
40
41
  function renderTabsItemLabel(label, active) {
41
42
  return typeof label === "function" ? label({ active }) : label;
42
43
  }
43
- function TabTriggerWithDropdown({ item, triggerClassName, }) {
44
+ function TabTriggerWithDropdown({ item, triggerClassName, contentClassName, }) {
44
45
  var _a, _b, _c, _d, _e;
45
46
  const [open, setOpen] = React.useState(false);
46
47
  const sections = (_a = item.sections) !== null && _a !== void 0 ? _a : [];
@@ -81,9 +82,11 @@ function TabTriggerWithDropdown({ item, triggerClassName, }) {
81
82
  setInternalActiveSection((_b = (_a = sections[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null);
82
83
  }
83
84
  }, [isTabSelected, item.activeSection, sections]);
84
- return (_jsx(Popover, { open: open, onOpenChange: setOpen, surface: "menu", align: "start", contentClassName: "min-w-[12rem]", trigger: _jsxs(TabsTrigger, { value: item.value, disabled: item.disabled, "data-state": isTabSelected ? "active" : "inactive", "data-tab-value": item.value, className: cn("flex items-center gap-1", triggerClassName), children: [renderTabsItemLabel(item.label, isTabSelected), _jsx(ChevronDownIcon, { size: 12, className: cn("transition-transform duration-200", open && "rotate-180") })] }), children: _jsx(PopoverMenuSection, { children: sections.map((section) => (_jsx(PopoverMenuItem, { active: isTabSelected && activeSection === section.id, className: "py-2 pl-2 pr-8", onClick: () => handleSectionClick(section.id), children: section.label }, section.id))) }) }));
85
+ return (_jsx(Popover, { open: open, onOpenChange: setOpen, surface: "menu", align: "start", contentClassName: cn("min-w-[12rem]", contentClassName), trigger: _jsxs(TabsTrigger, { value: item.value, disabled: item.disabled, "data-state": isTabSelected ? "active" : "inactive", "data-tab-value": item.value, className: cn("flex items-center gap-1", triggerClassName), children: [renderTabsItemLabel(item.label, isTabSelected), _jsx(ChevronDownIcon, { size: 12, className: cn("transition-transform duration-200", open && "rotate-180") })] }), children: _jsx(PopoverMenuSection, { className: "space-y-1", children: sections.map((section) => (_jsxs("button", { type: "button", className: cn("flex min-h-fit w-full cursor-pointer items-start gap-2 rounded-sm px-3 py-2 text-left text-sm font-normal leading-5 text-popover-foreground outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring", isTabSelected &&
86
+ activeSection === section.id &&
87
+ "bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground"), onClick: () => handleSectionClick(section.id), children: [_jsx("span", { className: "block min-w-0 flex-1 whitespace-normal break-words leading-5", children: section.label }), isTabSelected && activeSection === section.id ? (_jsx(Check, { "aria-hidden": "true", className: "mt-0.5 h-4 w-4 shrink-0" })) : null] }, section.id))) }) }));
85
88
  }
86
- function TabWithDropdown({ value, label, sections, disabled, scrollOffset, onSectionSelect, activeSection, className, }) {
89
+ function TabWithDropdown({ value, label, sections, disabled, scrollOffset, onSectionSelect, activeSection, className, contentClassName, }) {
87
90
  return (_jsx(TabTriggerWithDropdown, { item: {
88
91
  value,
89
92
  label,
@@ -93,7 +96,7 @@ function TabWithDropdown({ value, label, sections, disabled, scrollOffset, onSec
93
96
  scrollOffset,
94
97
  onSectionSelect,
95
98
  activeSection,
96
- }, triggerClassName: className }));
99
+ }, triggerClassName: className, contentClassName: contentClassName }));
97
100
  }
98
101
  function TabTriggerItem({ item, triggerClassName }) {
99
102
  var _a;
@@ -21,7 +21,7 @@ export interface ThemeSwitcherProps extends Omit<SwitchProps, "checked" | "defau
21
21
  useLightLabel?: string;
22
22
  className?: string;
23
23
  }
24
- declare function ThemeSwitcher({ checked, defaultChecked, onCheckedChange, isCollapsed, label, lightLabel, darkLabel, useDarkLabel, useLightLabel, className, disabled, ...props }: ThemeSwitcherProps): import("react/jsx-runtime").JSX.Element;
24
+ declare function ThemeSwitcher({ checked, defaultChecked, onCheckedChange, isCollapsed, label, lightLabel, darkLabel, useDarkLabel, useLightLabel, className, disabled, tabIndex, ...props }: ThemeSwitcherProps): import("react/jsx-runtime").JSX.Element;
25
25
  declare namespace ThemeSwitcher {
26
26
  var displayName: string;
27
27
  }
@@ -5,23 +5,21 @@ import { Moon, Sun } from "lucide-react";
5
5
  import { Button } from "./button";
6
6
  import { cn } from "./lib/utils";
7
7
  import { Switch } from "./switch";
8
- function ThemeSwitcher({ checked, defaultChecked = false, onCheckedChange, isCollapsed = false, label, lightLabel = "Light theme", darkLabel = "Dark theme", useDarkLabel = "Use dark theme", useLightLabel = "Use light theme", className, disabled, ...props }) {
8
+ function ThemeSwitcher({ checked, defaultChecked = false, onCheckedChange, isCollapsed = false, label, lightLabel = "Light theme", darkLabel = "Dark theme", useDarkLabel = "Use dark theme", useLightLabel = "Use light theme", className, disabled, tabIndex, ...props }) {
9
9
  const isControlled = checked !== undefined;
10
10
  const [uncontrolledChecked, setUncontrolledChecked] = React.useState(defaultChecked);
11
11
  const isDark = isControlled ? checked : uncontrolledChecked;
12
12
  const activeLabel = label !== null && label !== void 0 ? label : (isDark ? darkLabel : lightLabel);
13
13
  const ActiveIcon = isDark ? Moon : Sun;
14
- const CollapsedIcon = isDark ? Sun : Moon;
15
14
  const handleCheckedChange = React.useCallback((nextChecked) => {
16
15
  if (!isControlled) {
17
16
  setUncontrolledChecked(nextChecked);
18
17
  }
19
18
  onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(nextChecked);
20
19
  }, [isControlled, onCheckedChange]);
21
- if (isCollapsed) {
22
- return (_jsx("div", { "data-slot": "theme-switcher", className: cn("flex w-full justify-center py-1", className), children: _jsx(Button, { type: "button", variant: "ghost", size: "icon", disabled: disabled, "aria-label": isDark ? useLightLabel : useDarkLabel, "aria-pressed": isDark, onClick: () => handleCheckedChange(!isDark), children: _jsx(CollapsedIcon, { "aria-hidden": "true", className: "h-4 w-4" }) }) }));
23
- }
24
- return (_jsx("div", { "data-slot": "theme-switcher", className: "px-1.5 py-1", children: _jsx(Switch, { checked: isDark, onCheckedChange: handleCheckedChange, disabled: disabled, label: _jsxs("span", { className: "inline-flex min-w-0 items-center gap-2", children: [_jsx(ActiveIcon, { "aria-hidden": "true", className: "h-4 w-4 shrink-0" }), _jsx("span", { className: "truncate", children: activeLabel })] }), wrapperClassName: cn("w-full flex-row-reverse justify-between rounded-control px-3 py-2 text-muted-foreground transition-colors hover:bg-card hover:text-foreground", className), ...props }) }));
20
+ return (_jsxs("div", { "data-slot": "theme-switcher", className: cn("relative w-full overflow-hidden py-1 transition-[padding] duration-300 ease-in-out", isCollapsed ? "px-0" : "px-1.5", className), children: [_jsx(Button, { type: "button", variant: "ghost", size: "icon", disabled: disabled, "aria-hidden": isCollapsed ? undefined : true, "aria-label": isDark ? useLightLabel : useDarkLabel, "aria-pressed": isDark, tabIndex: isCollapsed ? tabIndex : -1, className: cn("absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transition-opacity duration-150", isCollapsed ? "opacity-100" : "pointer-events-none opacity-0"), onClick: () => handleCheckedChange(!isDark), children: _jsx(ActiveIcon, { "aria-hidden": "true", className: "h-4 w-4" }) }), _jsx("div", { "aria-hidden": isCollapsed ? true : undefined, className: cn("transition-[opacity,transform] duration-150", isCollapsed
21
+ ? "pointer-events-none translate-x-1 opacity-0"
22
+ : "translate-x-0 opacity-100"), children: _jsx(Switch, { checked: isDark, onCheckedChange: handleCheckedChange, disabled: disabled, tabIndex: isCollapsed ? -1 : tabIndex, label: _jsxs("span", { className: "inline-flex min-w-0 items-center gap-2", children: [_jsx(ActiveIcon, { "aria-hidden": "true", className: "h-4 w-4 shrink-0" }), _jsx("span", { className: "truncate", children: activeLabel })] }), wrapperClassName: "w-full flex-row-reverse justify-between rounded-control px-3 py-2 text-muted-foreground transition-colors hover:bg-card hover:text-foreground", ...props }) })] }));
25
23
  }
26
24
  ThemeSwitcher.displayName = "ThemeSwitcher";
27
25
  export { ThemeSwitcher };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neasg/design-system",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "description": "NEA shared design system primitives, theme tokens, and Storybook docs.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",