@chayns-ui/layout 0.6.3 → 0.8.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.
Files changed (50) hide show
  1. package/dist/app-layout.css +13 -8
  2. package/dist/components/app-layout/AppLayout.d.ts +7 -4
  3. package/dist/components/app-layout/AppLayout.d.ts.map +1 -1
  4. package/dist/components/app-layout/AppLayout.js +14 -5
  5. package/dist/components/app-layout/AppLayout.js.map +1 -1
  6. package/dist/components/app-layout/AppLayout.types.d.ts +8 -3
  7. package/dist/components/app-layout/AppLayout.types.d.ts.map +1 -1
  8. package/dist/components/app-layout/app-layout-icon/AppLayoutIcon.d.ts.map +1 -1
  9. package/dist/components/app-layout/app-layout-icon/AppLayoutIcon.js +1 -0
  10. package/dist/components/app-layout/app-layout-icon/AppLayoutIcon.js.map +1 -1
  11. package/dist/components/tabs/Tabs.d.ts +2 -2
  12. package/dist/components/tabs/Tabs.d.ts.map +1 -1
  13. package/dist/components/tabs/Tabs.js +118 -58
  14. package/dist/components/tabs/Tabs.js.map +1 -1
  15. package/dist/components/tabs/Tabs.types.d.ts +13 -1
  16. package/dist/components/tabs/Tabs.types.d.ts.map +1 -1
  17. package/dist/components/tabs/Tabs.types.js +12 -0
  18. package/dist/components/tabs/Tabs.types.js.map +1 -0
  19. package/dist/components/tabs/TabsContext.d.ts +16 -0
  20. package/dist/components/tabs/TabsContext.d.ts.map +1 -0
  21. package/dist/components/tabs/TabsContext.js +12 -0
  22. package/dist/components/tabs/TabsContext.js.map +1 -0
  23. package/dist/components/tabs/TabsList.d.ts +3 -0
  24. package/dist/components/tabs/TabsList.d.ts.map +1 -0
  25. package/dist/components/tabs/TabsList.js +28 -0
  26. package/dist/components/tabs/TabsList.js.map +1 -0
  27. package/dist/components/tabs/TabsPanel.d.ts +4 -0
  28. package/dist/components/tabs/TabsPanel.d.ts.map +1 -0
  29. package/dist/components/tabs/TabsPanel.js +47 -0
  30. package/dist/components/tabs/TabsPanel.js.map +1 -0
  31. package/dist/components/tabs/hooks/useElementRef.d.ts +4 -0
  32. package/dist/components/tabs/hooks/useElementRef.d.ts.map +1 -0
  33. package/dist/components/tabs/hooks/useElementRef.js +14 -0
  34. package/dist/components/tabs/hooks/useElementRef.js.map +1 -0
  35. package/dist/components/tabs/hooks/usePanelMotion.d.ts +4 -0
  36. package/dist/components/tabs/hooks/usePanelMotion.d.ts.map +1 -0
  37. package/dist/components/tabs/hooks/usePanelMotion.js +55 -0
  38. package/dist/components/tabs/hooks/usePanelMotion.js.map +1 -0
  39. package/dist/components/tabs/hooks/useUnderlineIndicator.d.ts +5 -0
  40. package/dist/components/tabs/hooks/useUnderlineIndicator.d.ts.map +1 -0
  41. package/dist/components/tabs/hooks/useUnderlineIndicator.js +103 -0
  42. package/dist/components/tabs/hooks/useUnderlineIndicator.js.map +1 -0
  43. package/dist/components/tabs/tabs-icon/TabsIcon.d.ts.map +1 -1
  44. package/dist/components/tabs/tabs-icon/TabsIcon.js +18 -0
  45. package/dist/components/tabs/tabs-icon/TabsIcon.js.map +1 -0
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +2 -1
  49. package/dist/tabs.css +172 -4
  50. package/package.json +3 -3
@@ -187,6 +187,7 @@
187
187
  }
188
188
 
189
189
  .chayns-app-layout__icon {
190
+ pointer-events: none;
190
191
  display: inline-flex;
191
192
  flex: none;
192
193
  align-items: center;
@@ -209,20 +210,24 @@
209
210
  }
210
211
 
211
212
  :where(
212
- .chayns-app-layout__action:hover,
213
- .chayns-app-layout__action:focus-visible,
214
- .chayns-app-layout__disclosure:hover,
215
- .chayns-app-layout__collapse:hover
213
+ .chayns-app-layout__action:active:not(:disabled),
214
+ .chayns-app-layout__action:hover:not(:disabled),
215
+ .chayns-app-layout__disclosure:active:not(:disabled),
216
+ .chayns-app-layout__disclosure:hover:not(:disabled),
217
+ .chayns-app-layout__collapse:active:not(:disabled),
218
+ .chayns-app-layout__collapse:hover:not(:disabled)
216
219
  )
217
220
  .chayns-app-layout__weight:not(.chayns-app-layout__weight--active) {
218
221
  display: none;
219
222
  }
220
223
 
221
224
  :where(
222
- .chayns-app-layout__action:hover,
223
- .chayns-app-layout__action:focus-visible,
224
- .chayns-app-layout__disclosure:hover,
225
- .chayns-app-layout__collapse:hover
225
+ .chayns-app-layout__action:active:not(:disabled),
226
+ .chayns-app-layout__action:hover:not(:disabled),
227
+ .chayns-app-layout__disclosure:active:not(:disabled),
228
+ .chayns-app-layout__disclosure:hover:not(:disabled),
229
+ .chayns-app-layout__collapse:active:not(:disabled),
230
+ .chayns-app-layout__collapse:hover:not(:disabled)
226
231
  )
227
232
  .chayns-app-layout__weight--active {
228
233
  display: inline-flex;
@@ -1,13 +1,16 @@
1
- import type { AppLayoutCollapseToggleProps, AppLayoutNavigationItemProps, AppLayoutProps } from './AppLayout.types.js';
2
- declare function NavigationItem({ children, className, href, icon, isActive, label, ...props }: AppLayoutNavigationItemProps): import("react").JSX.Element;
1
+ import type { AppLayoutCollapseToggleProps, AppLayoutProps } from './AppLayout.types.js';
3
2
  export declare const AppLayout: import("react").ForwardRefExoticComponent<Omit<AppLayoutProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
4
3
  CollapseToggle: import("react").ForwardRefExoticComponent<Omit<AppLayoutCollapseToggleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
5
4
  Content: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
6
5
  Header: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
7
6
  Logo: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & import("react").RefAttributes<HTMLImageElement>>;
8
7
  Navigation: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>> & {
9
- Item: typeof NavigationItem;
8
+ Item: import("react").ForwardRefExoticComponent<(Omit<import("./AppLayout.types.js").NavigationItemContent & Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "children"> & {
9
+ href: string;
10
+ }, "ref"> | Omit<import("./AppLayout.types.js").NavigationItemContent & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "children" | "type"> & {
11
+ href?: undefined;
12
+ type?: never;
13
+ }, "ref">) & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
10
14
  };
11
15
  };
12
- export {};
13
16
  //# sourceMappingURL=AppLayout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppLayout.d.ts","sourceRoot":"","sources":["../../../src/components/app-layout/AppLayout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,4BAA4B,EAI5B,4BAA4B,EAE5B,cAAc,EACf,MAAM,sBAAsB,CAAC;AA6D9B,iBAAS,cAAc,CAAC,EACtB,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,QAAgB,EAChB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,4BAA4B,+BAgE9B;AAgED,eAAO,MAAM,SAAS;;;;;;;;CAMpB,CAAC"}
1
+ {"version":3,"file":"AppLayout.d.ts","sourceRoot":"","sources":["../../../src/components/app-layout/AppLayout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,4BAA4B,EAM5B,cAAc,EACf,MAAM,sBAAsB,CAAC;AA6M9B,eAAO,MAAM,SAAS;;;;;;;;;;;;;CAMpB,CAAC"}
@@ -42,13 +42,14 @@ var Navigation = forwardRef(function Navigation({ children, className, ...props
42
42
  })
43
43
  });
44
44
  });
45
- function NavigationItem({ children, className, href, icon, isActive = false, label, ...props }) {
45
+ var NavigationItem = forwardRef(function NavigationItem({ children, className, href, icon, isActive = false, label, ...props }, ref) {
46
46
  if (!useContext(NavigationContext)) throw new Error("AppLayout.Navigation.Item must be rendered within AppLayout.Navigation.");
47
47
  const { collapsed } = useLayout("Navigation.Item");
48
48
  const [expanded, setExpanded] = useState(false);
49
49
  const childrenId = useId();
50
50
  const hasChildren = children !== void 0;
51
51
  const content = /* @__PURE__ */ jsx("span", {
52
+ id: `${childrenId}-label`,
52
53
  className: `chayns-app-layout__label${collapsed ? " chayns-app-layout__label--hidden" : ""}`,
53
54
  children: label
54
55
  });
@@ -57,20 +58,21 @@ function NavigationItem({ children, className, href, icon, isActive = false, lab
57
58
  className: `chayns-app-layout__item${isActive ? " chayns-app-layout__item--active" : ""}`,
58
59
  children: [/* @__PURE__ */ jsxs("div", {
59
60
  className: "chayns-app-layout__row",
60
- children: [href ? /* @__PURE__ */ jsxs("a", {
61
+ children: [href !== void 0 ? /* @__PURE__ */ jsxs("a", {
61
62
  ...props,
62
63
  "aria-current": isActive ? "page" : void 0,
63
64
  className: actionClass,
64
65
  href,
66
+ ref,
65
67
  children: [icon ? /* @__PURE__ */ jsx(AppLayoutIcon, { icon }) : null, content]
66
68
  }) : /* @__PURE__ */ jsxs("button", {
67
69
  ...props,
68
- "aria-current": isActive ? "page" : void 0,
70
+ ref,
69
71
  className: actionClass,
70
72
  type: "button",
71
73
  children: [icon ? /* @__PURE__ */ jsx(AppLayoutIcon, { icon }) : null, content]
72
74
  }), hasChildren && !collapsed ? /* @__PURE__ */ jsx("button", {
73
- "aria-label": typeof label === "string" ? label : void 0,
75
+ "aria-labelledby": `${childrenId}-label`,
74
76
  "aria-controls": childrenId,
75
77
  "aria-expanded": expanded,
76
78
  className: "chayns-app-layout__disclosure",
@@ -89,7 +91,7 @@ function NavigationItem({ children, className, href, icon, isActive = false, lab
89
91
  })
90
92
  }) : null]
91
93
  });
92
- }
94
+ });
93
95
  var Content = forwardRef(function Content({ children, className, ...props }, ref) {
94
96
  useLayout("Content");
95
97
  return /* @__PURE__ */ jsx("main", {
@@ -139,6 +141,13 @@ var Root = forwardRef(function Root({ children, className, collapsed, defaultCol
139
141
  })
140
142
  });
141
143
  });
144
+ Header.displayName = "AppLayout.Header";
145
+ Logo.displayName = "AppLayout.Logo";
146
+ Navigation.displayName = "AppLayout.Navigation";
147
+ Object.assign(NavigationItem, { displayName: "AppLayout.Navigation.Item" });
148
+ Content.displayName = "AppLayout.Content";
149
+ CollapseToggle.displayName = "AppLayout.CollapseToggle";
150
+ Root.displayName = "AppLayout";
142
151
  var AppLayout = Object.assign(Root, {
143
152
  CollapseToggle,
144
153
  Content,
@@ -1 +1 @@
1
- {"version":3,"file":"AppLayout.js","names":[],"sources":["../../../src/components/app-layout/AppLayout.tsx"],"sourcesContent":["import { createContext, forwardRef, useContext, useId, useState } from 'react';\nimport type { ComponentPropsWithRef } from 'react';\nimport type {\n AppLayoutCollapseToggleProps,\n AppLayoutContentProps,\n AppLayoutHeaderProps,\n AppLayoutLogoProps,\n AppLayoutNavigationItemProps,\n AppLayoutNavigationProps,\n AppLayoutProps,\n} from './AppLayout.types.js';\nimport AppLayoutIcon from './app-layout-icon/AppLayoutIcon.js';\n\ninterface LayoutState {\n collapsed: boolean;\n toggle: () => void;\n}\nconst LayoutContext = createContext<LayoutState | null>(null);\nconst NavigationContext = createContext(false);\nfunction useLayout(part: string) {\n const context = useContext(LayoutContext);\n if (context === null) throw new Error(`AppLayout.${part} must be rendered within AppLayout.`);\n return context;\n}\n\nconst Header = forwardRef<HTMLElement, AppLayoutHeaderProps>(function Header(\n { children, className, ...props },\n ref,\n) {\n useLayout('Header');\n return (\n <header\n {...props}\n className={['chayns-app-layout__header', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n {children}\n </header>\n );\n});\nconst Logo = forwardRef<HTMLImageElement, AppLayoutLogoProps>(function Logo(\n { alt = '', className, ...props },\n ref,\n) {\n useLayout('Logo');\n return (\n <img\n {...props}\n alt={alt}\n className={['chayns-app-layout__logo', className].filter(Boolean).join(' ')}\n ref={ref}\n />\n );\n});\nconst Navigation = forwardRef<HTMLElement, AppLayoutNavigationProps>(function Navigation(\n { children, className, ...props },\n ref,\n) {\n useLayout('Navigation');\n return (\n <NavigationContext.Provider value>\n <nav\n {...props}\n className={['chayns-app-layout__navigation', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n <ul className=\"chayns-app-layout__list\">{children}</ul>\n </nav>\n </NavigationContext.Provider>\n );\n});\nfunction NavigationItem({\n children,\n className,\n href,\n icon,\n isActive = false,\n label,\n ...props\n}: AppLayoutNavigationItemProps) {\n if (!useContext(NavigationContext))\n throw new Error('AppLayout.Navigation.Item must be rendered within AppLayout.Navigation.');\n const { collapsed } = useLayout('Navigation.Item');\n const [expanded, setExpanded] = useState(false);\n const childrenId = useId();\n const hasChildren = children !== undefined;\n const content = (\n <span\n className={`chayns-app-layout__label${collapsed ? ' chayns-app-layout__label--hidden' : ''}`}\n >\n {label}\n </span>\n );\n const actionClass = ['chayns-app-layout__action', className].filter(Boolean).join(' ');\n return (\n <li className={`chayns-app-layout__item${isActive ? ' chayns-app-layout__item--active' : ''}`}>\n <div className=\"chayns-app-layout__row\">\n {href ? (\n <a\n {...(props as ComponentPropsWithRef<'a'>)}\n aria-current={isActive ? 'page' : undefined}\n className={actionClass}\n href={href}\n >\n {icon ? <AppLayoutIcon icon={icon} /> : null}\n {content}\n </a>\n ) : (\n <button\n {...props}\n aria-current={isActive ? 'page' : undefined}\n className={actionClass}\n type=\"button\"\n >\n {icon ? <AppLayoutIcon icon={icon} /> : null}\n {content}\n </button>\n )}\n {hasChildren && !collapsed ? (\n <button\n aria-label={typeof label === 'string' ? label : undefined}\n aria-controls={childrenId}\n aria-expanded={expanded}\n className=\"chayns-app-layout__disclosure\"\n onClick={() => setExpanded((current) => !current)}\n type=\"button\"\n >\n <AppLayoutIcon icon=\"fa-chevron-down\" />\n </button>\n ) : null}\n </div>\n {hasChildren && !collapsed ? (\n <div\n aria-hidden={!expanded}\n className={`chayns-app-layout__children${expanded ? ' chayns-app-layout__children--open' : ''}`}\n id={childrenId}\n inert={!expanded}\n >\n <ul className=\"chayns-app-layout__list\">{children}</ul>\n </div>\n ) : null}\n </li>\n );\n}\nconst Content = forwardRef<HTMLElement, AppLayoutContentProps>(function Content(\n { children, className, ...props },\n ref,\n) {\n useLayout('Content');\n return (\n <main\n {...props}\n className={['chayns-app-layout__content', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n {children}\n </main>\n );\n});\nconst CollapseToggle = forwardRef<HTMLButtonElement, AppLayoutCollapseToggleProps>(\n function CollapseToggle(\n { children, className, collapseLabel, expandLabel, onClick, ...props },\n ref,\n ) {\n const layout = useLayout('CollapseToggle');\n return (\n <button\n {...props}\n aria-label={layout.collapsed ? expandLabel : collapseLabel}\n className={['chayns-app-layout__collapse', className].filter(Boolean).join(' ')}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) layout.toggle();\n }}\n ref={ref}\n type=\"button\"\n >\n {children ?? <AppLayoutIcon icon=\"fa-sidebar\" />}\n </button>\n );\n },\n);\nconst Root = forwardRef<HTMLDivElement, AppLayoutProps>(function Root(\n { children, className, collapsed, defaultCollapsed = false, onCollapsedChange, ...props },\n ref,\n) {\n const [internal, setInternal] = useState(defaultCollapsed);\n const isCollapsed = collapsed ?? internal;\n const toggle = () => {\n const next = !isCollapsed;\n if (collapsed === undefined) setInternal(next);\n onCollapsedChange?.(next);\n };\n return (\n <LayoutContext.Provider value={{ collapsed: isCollapsed, toggle }}>\n <div\n {...props}\n className={['chayns-app-layout', isCollapsed && 'chayns-app-layout--collapsed', className]\n .filter(Boolean)\n .join(' ')}\n ref={ref}\n >\n {children}\n </div>\n </LayoutContext.Provider>\n );\n});\nexport const AppLayout = Object.assign(Root, {\n CollapseToggle,\n Content,\n Header,\n Logo,\n Navigation: Object.assign(Navigation, { Item: NavigationItem }),\n});\n"],"m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AO,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,CAAC"}
1
+ {"version":3,"file":"AppLayout.js","names":[],"sources":["../../../src/components/app-layout/AppLayout.tsx"],"sourcesContent":["import { createContext, forwardRef, useContext, useId, useState } from 'react';\nimport type { ComponentPropsWithRef, Ref } from 'react';\nimport type {\n AppLayoutCollapseToggleProps,\n AppLayoutContentProps,\n AppLayoutHeaderProps,\n AppLayoutLogoProps,\n AppLayoutNavigationItemProps,\n AppLayoutNavigationProps,\n AppLayoutProps,\n} from './AppLayout.types.js';\nimport AppLayoutIcon from './app-layout-icon/AppLayoutIcon.js';\n\ninterface LayoutState {\n collapsed: boolean;\n toggle: () => void;\n}\nconst LayoutContext = createContext<LayoutState | null>(null);\nconst NavigationContext = createContext(false);\nfunction useLayout(part: string) {\n const context = useContext(LayoutContext);\n if (context === null) throw new Error(`AppLayout.${part} must be rendered within AppLayout.`);\n return context;\n}\n\nconst Header = forwardRef<HTMLElement, AppLayoutHeaderProps>(function Header(\n { children, className, ...props },\n ref,\n) {\n useLayout('Header');\n return (\n <header\n {...props}\n className={['chayns-app-layout__header', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n {children}\n </header>\n );\n});\nconst Logo = forwardRef<HTMLImageElement, AppLayoutLogoProps>(function Logo(\n { alt = '', className, ...props },\n ref,\n) {\n useLayout('Logo');\n return (\n <img\n {...props}\n alt={alt}\n className={['chayns-app-layout__logo', className].filter(Boolean).join(' ')}\n ref={ref}\n />\n );\n});\nconst Navigation = forwardRef<HTMLElement, AppLayoutNavigationProps>(function Navigation(\n { children, className, ...props },\n ref,\n) {\n useLayout('Navigation');\n return (\n <NavigationContext.Provider value>\n <nav\n {...props}\n className={['chayns-app-layout__navigation', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n <ul className=\"chayns-app-layout__list\">{children}</ul>\n </nav>\n </NavigationContext.Provider>\n );\n});\nconst NavigationItem = forwardRef<\n HTMLAnchorElement | HTMLButtonElement,\n AppLayoutNavigationItemProps\n>(function NavigationItem(\n { children, className, href, icon, isActive = false, label, ...props },\n ref,\n) {\n if (!useContext(NavigationContext))\n throw new Error('AppLayout.Navigation.Item must be rendered within AppLayout.Navigation.');\n const { collapsed } = useLayout('Navigation.Item');\n const [expanded, setExpanded] = useState(false);\n const childrenId = useId();\n const hasChildren = children !== undefined;\n const content = (\n <span\n id={`${childrenId}-label`}\n className={`chayns-app-layout__label${collapsed ? ' chayns-app-layout__label--hidden' : ''}`}\n >\n {label}\n </span>\n );\n const actionClass = ['chayns-app-layout__action', className].filter(Boolean).join(' ');\n return (\n <li className={`chayns-app-layout__item${isActive ? ' chayns-app-layout__item--active' : ''}`}>\n <div className=\"chayns-app-layout__row\">\n {href !== undefined ? (\n <a\n {...(props as ComponentPropsWithRef<'a'>)}\n aria-current={isActive ? 'page' : undefined}\n className={actionClass}\n href={href}\n ref={ref as Ref<HTMLAnchorElement>}\n >\n {icon ? <AppLayoutIcon icon={icon} /> : null}\n {content}\n </a>\n ) : (\n <button\n {...(props as ComponentPropsWithRef<'button'>)}\n ref={ref as Ref<HTMLButtonElement>}\n className={actionClass}\n type=\"button\"\n >\n {icon ? <AppLayoutIcon icon={icon} /> : null}\n {content}\n </button>\n )}\n {hasChildren && !collapsed ? (\n <button\n aria-labelledby={`${childrenId}-label`}\n aria-controls={childrenId}\n aria-expanded={expanded}\n className=\"chayns-app-layout__disclosure\"\n onClick={() => setExpanded((current) => !current)}\n type=\"button\"\n >\n <AppLayoutIcon icon=\"fa-chevron-down\" />\n </button>\n ) : null}\n </div>\n {hasChildren && !collapsed ? (\n <div\n aria-hidden={!expanded}\n className={`chayns-app-layout__children${expanded ? ' chayns-app-layout__children--open' : ''}`}\n id={childrenId}\n inert={!expanded}\n >\n <ul className=\"chayns-app-layout__list\">{children}</ul>\n </div>\n ) : null}\n </li>\n );\n});\nconst Content = forwardRef<HTMLElement, AppLayoutContentProps>(function Content(\n { children, className, ...props },\n ref,\n) {\n useLayout('Content');\n return (\n <main\n {...props}\n className={['chayns-app-layout__content', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n {children}\n </main>\n );\n});\nconst CollapseToggle = forwardRef<HTMLButtonElement, AppLayoutCollapseToggleProps>(\n function CollapseToggle(\n { children, className, collapseLabel, expandLabel, onClick, ...props },\n ref,\n ) {\n const layout = useLayout('CollapseToggle');\n return (\n <button\n {...props}\n aria-label={layout.collapsed ? expandLabel : collapseLabel}\n className={['chayns-app-layout__collapse', className].filter(Boolean).join(' ')}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) layout.toggle();\n }}\n ref={ref}\n type=\"button\"\n >\n {children ?? <AppLayoutIcon icon=\"fa-sidebar\" />}\n </button>\n );\n },\n);\nconst Root = forwardRef<HTMLDivElement, AppLayoutProps>(function Root(\n { children, className, collapsed, defaultCollapsed = false, onCollapsedChange, ...props },\n ref,\n) {\n const [internal, setInternal] = useState(defaultCollapsed);\n const isCollapsed = collapsed ?? internal;\n const toggle = () => {\n const next = !isCollapsed;\n if (collapsed === undefined) setInternal(next);\n onCollapsedChange?.(next);\n };\n return (\n <LayoutContext.Provider value={{ collapsed: isCollapsed, toggle }}>\n <div\n {...props}\n className={['chayns-app-layout', isCollapsed && 'chayns-app-layout--collapsed', className]\n .filter(Boolean)\n .join(' ')}\n ref={ref}\n >\n {children}\n </div>\n </LayoutContext.Provider>\n );\n});\nHeader.displayName = 'AppLayout.Header';\nLogo.displayName = 'AppLayout.Logo';\nNavigation.displayName = 'AppLayout.Navigation';\nObject.assign(NavigationItem, { displayName: 'AppLayout.Navigation.Item' });\nContent.displayName = 'AppLayout.Content';\nCollapseToggle.displayName = 'AppLayout.CollapseToggle';\nRoot.displayName = 'AppLayout';\n\nexport const AppLayout = Object.assign(Root, {\n CollapseToggle,\n Content,\n Header,\n Logo,\n Navigation: Object.assign(Navigation, { Item: NavigationItem }),\n});\n"],"mappings":";;;;AAiBA,IAAM,gBAAgB,cAAkC,IAAI;AAC5D,IAAM,oBAAoB,cAAc,KAAK;AAC7C,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ACtB,eAAe,cAAc;AAC7B,KAAK,cAAc;AAEnB,IAAa,YAAY,OAAO,OAAO,MAAM;CAC3C;CACA;CACA;CACA;CACA,YAAY,OAAO,OAAO,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,CAAC"}
@@ -8,14 +8,19 @@ export interface AppLayoutProps extends Omit<ComponentPropsWithRef<'div'>, 'chil
8
8
  export type AppLayoutHeaderProps = ComponentPropsWithRef<'header'>;
9
9
  export type AppLayoutLogoProps = ComponentPropsWithRef<'img'>;
10
10
  export type AppLayoutNavigationProps = ComponentPropsWithRef<'nav'>;
11
- export interface AppLayoutNavigationItemProps extends Omit<ComponentPropsWithRef<'button'>, 'children' | 'ref' | 'type'> {
12
- /** FontAwesome icon restored from the pre-compound navigation contract. */
11
+ export interface NavigationItemContent {
12
+ /** Leading FontAwesome icon; content and routing remain application-owned. */
13
13
  icon?: `fa-${string}`;
14
14
  label: ReactNode;
15
15
  children?: ReactNode;
16
- href?: string;
17
16
  isActive?: boolean;
18
17
  }
18
+ export type AppLayoutNavigationItemProps = NavigationItemContent & ((Omit<ComponentPropsWithRef<'a'>, 'children'> & {
19
+ href: string;
20
+ }) | (Omit<ComponentPropsWithRef<'button'>, 'children' | 'type'> & {
21
+ href?: undefined;
22
+ type?: never;
23
+ }));
19
24
  export type AppLayoutContentProps = ComponentPropsWithRef<'main'>;
20
25
  export interface AppLayoutCollapseToggleProps extends Omit<ComponentPropsWithRef<'button'>, 'children' | 'type' | 'aria-label'> {
21
26
  collapseLabel: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AppLayout.types.d.ts","sourceRoot":"","sources":["../../../src/components/app-layout/AppLayout.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACpF,QAAQ,EAAE,SAAS,CAAC;I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ourceRoot":"","sources":["../../../../src/components/app-layout/app-layout-icon/AppLayoutIcon.tsx"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG,MAAM,MAAM,EAAE,CAAC;AAExC,QAAA,MAAM,aAAa,GAAI,UAAU;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,gCAS3D,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"AppLayoutIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/app-layout/app-layout-icon/AppLayoutIcon.tsx"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG,MAAM,MAAM,EAAE,CAAC;AAExC,QAAA,MAAM,aAAa,GAAI,UAAU;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,gCAS3D,CAAC;AAIF,eAAe,aAAa,CAAC"}
@@ -11,6 +11,7 @@ var AppLayoutIcon = ({ icon }) => /* @__PURE__ */ jsxs("span", {
11
11
  children: /* @__PURE__ */ jsx("i", { className: `fas ${icon}` })
12
12
  })]
13
13
  });
14
+ Object.assign(AppLayoutIcon, { displayName: "AppLayoutIcon" });
14
15
  //#endregion
15
16
  export { AppLayoutIcon as default };
16
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"AppLayoutIcon.js","names":[],"sources":["../../../../src/components/app-layout/app-layout-icon/AppLayoutIcon.tsx"],"sourcesContent":["type AppLayoutIconName = `fa-${string}`;\n\nconst AppLayoutIcon = ({ icon }: { icon: AppLayoutIconName }) => (\n <span aria-hidden=\"true\" className=\"chayns-app-layout__icon\">\n <span className=\"chayns-app-layout__weight\">\n <i className={`far ${icon}`} />\n </span>\n <span className=\"chayns-app-layout__weight chayns-app-layout__weight--active\">\n <i className={`fas ${icon}`} />\n </span>\n </span>\n);\n\nexport default AppLayoutIcon;\n"],"mappings":";;AAEA,IAAM,iBAAiB,EAAE,WACvB,qBAAC,QAAD;CAAM,eAAY;CAAO,WAAU;CAAnC,UAAA,CACE,oBAAC,QAAD;EAAM,WAAU;EACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;CAC1B,CAAA,GACN,oBAAC,QAAD;EAAM,WAAU;EACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;CAC1B,CAAA,CACF"}
1
+ {"version":3,"file":"AppLayoutIcon.js","names":[],"sources":["../../../../src/components/app-layout/app-layout-icon/AppLayoutIcon.tsx"],"sourcesContent":["type AppLayoutIconName = `fa-${string}`;\n\nconst AppLayoutIcon = ({ icon }: { icon: AppLayoutIconName }) => (\n <span aria-hidden=\"true\" className=\"chayns-app-layout__icon\">\n <span className=\"chayns-app-layout__weight\">\n <i className={`far ${icon}`} />\n </span>\n <span className=\"chayns-app-layout__weight chayns-app-layout__weight--active\">\n <i className={`fas ${icon}`} />\n </span>\n </span>\n);\n\nObject.assign(AppLayoutIcon, { displayName: 'AppLayoutIcon' });\n\nexport default AppLayoutIcon;\n"],"mappings":";;AAEA,IAAM,iBAAiB,EAAE,WACvB,qBAAC,QAAD;CAAM,eAAY;CAAO,WAAU;CAAnC,UAAA,CACE,oBAAC,QAAD;EAAM,WAAU;EACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;CAC1B,CAAA,GACN,oBAAC,QAAD;EAAM,WAAU;EACd,UAAA,oBAAC,KAAD,EAAG,WAAW,OAAO,OAAS,CAAA;CAC1B,CAAA,CACF;;AAGR,OAAO,OAAO,eAAe,EAAE,aAAa,gBAAgB,CAAC"}
@@ -1,8 +1,8 @@
1
- import type { TabsPanelProps, TabsProps, TabsTabProps } from './Tabs.types.js';
1
+ import type { TabsProps, TabsTabProps } from './Tabs.types.js';
2
2
  export declare const Tabs: import("react").ForwardRefExoticComponent<Omit<TabsProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
3
3
  Add: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
4
4
  List: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
5
- Panel: import("react").ForwardRefExoticComponent<Omit<TabsPanelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
5
+ Panel: import("react").ForwardRefExoticComponent<Omit<import("./Tabs.types.js").TabsPanelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
6
6
  Tab: import("react").ForwardRefExoticComponent<Omit<TabsTabProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
7
7
  };
8
8
  //# sourceMappingURL=Tabs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,cAAc,EACd,SAAS,EACT,YAAY,EACb,MAAM,iBAAiB,CAAC;AAmKzB,eAAO,MAAM,IAAI;;;;;CAAiD,CAAC"}
1
+ {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tabs.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAgB,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA8M7E,eAAO,MAAM,IAAI;;;;;CAAiD,CAAC"}
@@ -1,22 +1,11 @@
1
- import { createContext, forwardRef, useContext, useId, useState } from "react";
1
+ import { TabsContext, useTabs } from "./TabsContext.js";
2
+ import useElementRef from "./hooks/useElementRef.js";
3
+ import List from "./TabsList.js";
4
+ import Panel from "./TabsPanel.js";
5
+ import TabsIcon from "./tabs-icon/TabsIcon.js";
6
+ import { forwardRef, useCallback, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
2
7
  import { jsx, jsxs } from "react/jsx-runtime";
3
8
  //#region src/components/tabs/Tabs.tsx
4
- var TabsContext = createContext(null);
5
- function useTabs(part) {
6
- const context = useContext(TabsContext);
7
- if (context === null) throw new Error(`Tabs.${part} must be rendered within Tabs.`);
8
- return context;
9
- }
10
- var List = forwardRef(function List({ children, className, ...props }, ref) {
11
- useTabs("List");
12
- return /* @__PURE__ */ jsx("div", {
13
- ...props,
14
- className: ["chayns-tabs__list", className].filter(Boolean).join(" "),
15
- ref,
16
- role: "tablist",
17
- children
18
- });
19
- });
20
9
  var Tab = forwardRef(function Tab({ children, className, onKeyDown, onRemove, onClick, value, ...props }, ref) {
21
10
  const tabs = useTabs("Tab");
22
11
  const selected = tabs.value === value;
@@ -27,27 +16,37 @@ var Tab = forwardRef(function Tab({ children, className, onKeyDown, onRemove, on
27
16
  if (event.defaultPrevented) return;
28
17
  if ((event.key === "Delete" || event.key === "Backspace") && onRemove) {
29
18
  event.preventDefault();
30
- onRemove();
19
+ onRemove(value);
31
20
  return;
32
21
  }
33
- const values = [...tabs.tabs.keys()];
22
+ const values = [...tabs.tabs.entries()].filter(([, element]) => !element.disabled).sort(([, first], [, second]) => first.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1).map(([tabValue]) => tabValue);
34
23
  const index = values.indexOf(value);
35
- const nextIndex = event.key === "Home" ? 0 : event.key === "End" ? values.length - 1 : event.key === "ArrowRight" || event.key === "ArrowDown" ? (index + 1) % values.length : event.key === "ArrowLeft" || event.key === "ArrowUp" ? (index - 1 + values.length) % values.length : -1;
24
+ let nextIndex = -1;
25
+ if (event.key === "Home") nextIndex = 0;
26
+ else if (event.key === "End") nextIndex = values.length - 1;
27
+ else if (event.key === "ArrowRight" || event.key === "ArrowDown") nextIndex = (index + 1) % values.length;
28
+ else if (event.key === "ArrowLeft" || event.key === "ArrowUp") nextIndex = (index - 1 + values.length) % values.length;
36
29
  if (nextIndex >= 0) {
37
30
  event.preventDefault();
38
31
  const next = values[nextIndex];
39
- if (next) {
32
+ if (next !== void 0) {
40
33
  tabs.select(next);
41
34
  tabs.tabs.get(next)?.focus();
42
35
  }
43
36
  }
44
37
  }
45
- function setRef(node) {
46
- if (node) tabs.tabs.set(value, node);
47
- else tabs.tabs.delete(value);
48
- if (typeof ref === "function") ref(node);
49
- else if (ref) ref.current = node;
50
- }
38
+ const register = tabs.register;
39
+ const notify = tabs.notify;
40
+ const [, setElement] = useElementRef(ref);
41
+ const setRef = useCallback((node) => {
42
+ register(value, node);
43
+ setElement(node);
44
+ }, [
45
+ register,
46
+ setElement,
47
+ value
48
+ ]);
49
+ useLayoutEffect(() => notify(), [notify, props.disabled]);
51
50
  return /* @__PURE__ */ jsxs("button", {
52
51
  ...props,
53
52
  "aria-controls": panelId,
@@ -59,40 +58,24 @@ var Tab = forwardRef(function Tab({ children, className, onKeyDown, onRemove, on
59
58
  ].filter(Boolean).join(" "),
60
59
  id: tabId,
61
60
  onClick: (event) => {
62
- if (event.target.closest("[data-tabs-remove]")) {
63
- onRemove?.();
64
- return;
65
- }
66
61
  onClick?.(event);
67
- if (!event.defaultPrevented) tabs.select(value);
62
+ if (event.defaultPrevented) return;
63
+ if (event.target instanceof Element && event.target.closest("[data-tabs-remove]")) onRemove?.(value);
64
+ else tabs.select(value);
68
65
  },
69
66
  onKeyDown: handleKeyDown,
70
67
  ref: setRef,
71
68
  role: "tab",
72
- tabIndex: selected ? 0 : -1,
69
+ tabIndex: tabs.entryValue === value ? 0 : -1,
73
70
  type: "button",
74
71
  children: [children, onRemove ? /* @__PURE__ */ jsx("span", {
75
72
  "aria-hidden": "true",
76
73
  className: "chayns-tabs__remove",
77
74
  "data-tabs-remove": true,
78
- children: /* @__PURE__ */ jsx("i", { className: "far fa-xmark" })
75
+ children: /* @__PURE__ */ jsx(TabsIcon, { icon: "fa-xmark" })
79
76
  }) : null]
80
77
  });
81
78
  });
82
- var Panel = forwardRef(function Panel({ children, className, value, ...props }, ref) {
83
- const tabs = useTabs("Panel");
84
- if (tabs.value !== value) return null;
85
- return /* @__PURE__ */ jsx("div", {
86
- ...props,
87
- "aria-labelledby": `${tabs.baseId}-tab-${value}`,
88
- className: ["chayns-tabs__panel", className].filter(Boolean).join(" "),
89
- id: `${tabs.baseId}-panel-${value}`,
90
- ref,
91
- role: "tabpanel",
92
- tabIndex: 0,
93
- children
94
- });
95
- });
96
79
  var Add = forwardRef(function Add({ children, className, ...props }, ref) {
97
80
  useTabs("Add");
98
81
  return /* @__PURE__ */ jsx("button", {
@@ -103,30 +86,107 @@ var Add = forwardRef(function Add({ children, className, ...props }, ref) {
103
86
  children
104
87
  });
105
88
  });
106
- var Root = forwardRef(function Root({ children, className, defaultValue, onValueChange, value, ...props }, ref) {
89
+ var Root = forwardRef(function Root({ appearance = "attached", children, className, defaultValue, onValueChange, value, ...props }, ref) {
107
90
  const baseId = useId();
108
91
  const [internalValue, setInternalValue] = useState(defaultValue);
109
92
  const [tabMap] = useState(() => /* @__PURE__ */ new Map());
93
+ const [registryVersion, setRegistryVersion] = useState(0);
94
+ const [selection, setSelection] = useState({
95
+ valid: true,
96
+ entry: value ?? defaultValue
97
+ });
98
+ const lastProposal = useRef(void 0);
110
99
  const selectedValue = value ?? internalValue;
111
- const select = (next) => {
100
+ const select = useCallback((next) => {
112
101
  if (value === void 0) setInternalValue(next);
113
102
  onValueChange?.(next);
114
- };
103
+ }, [onValueChange, value]);
104
+ const notify = useCallback(() => setRegistryVersion((current) => current + 1), []);
105
+ const register = useCallback((tabValue, node) => {
106
+ if (node) tabMap.set(tabValue, node);
107
+ else tabMap.delete(tabValue);
108
+ notify();
109
+ }, [notify, tabMap]);
110
+ useLayoutEffect(() => {
111
+ const enabled = [...tabMap.entries()].filter(([, element]) => !element.disabled).sort(([, first], [, second]) => first.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
112
+ const valid = enabled.some(([tabValue]) => tabValue === selectedValue);
113
+ const next = valid ? selectedValue : enabled[0]?.[0];
114
+ setSelection((current) => current.valid === valid && current.entry === next ? current : {
115
+ valid,
116
+ entry: next
117
+ });
118
+ if (valid || next === void 0) {
119
+ lastProposal.current = void 0;
120
+ return;
121
+ }
122
+ if (lastProposal.current?.value === selectedValue && lastProposal.current?.next === next) return;
123
+ lastProposal.current = {
124
+ value: selectedValue,
125
+ next
126
+ };
127
+ select(next);
128
+ }, [
129
+ children,
130
+ registryVersion,
131
+ select,
132
+ selectedValue,
133
+ tabMap
134
+ ]);
135
+ const panelValue = selection.valid ? selectedValue : void 0;
136
+ const [views, setViews] = useState({
137
+ current: panelValue,
138
+ exiting: void 0
139
+ });
140
+ if (views.current !== panelValue) setViews({
141
+ current: panelValue,
142
+ exiting: selection.valid ? views.current : void 0
143
+ });
144
+ const finishExit = useCallback((exiting) => {
145
+ setViews((current) => current.exiting === exiting ? {
146
+ current: current.current,
147
+ exiting: void 0
148
+ } : current);
149
+ }, []);
150
+ const context = useMemo(() => ({
151
+ baseId,
152
+ appearance,
153
+ exitingValue: views.exiting,
154
+ finishExit,
155
+ select,
156
+ tabs: tabMap,
157
+ register,
158
+ notify,
159
+ entryValue: selection.entry,
160
+ value: selection.valid ? selectedValue : void 0
161
+ }), [
162
+ appearance,
163
+ baseId,
164
+ finishExit,
165
+ notify,
166
+ register,
167
+ select,
168
+ selectedValue,
169
+ selection,
170
+ tabMap,
171
+ views.exiting
172
+ ]);
115
173
  return /* @__PURE__ */ jsx(TabsContext.Provider, {
116
- value: {
117
- baseId,
118
- select,
119
- tabs: tabMap,
120
- value: selectedValue
121
- },
174
+ value: context,
122
175
  children: /* @__PURE__ */ jsx("div", {
123
176
  ...props,
124
- className: ["chayns-tabs", className].filter(Boolean).join(" "),
177
+ className: [
178
+ "chayns-tabs",
179
+ `chayns-tabs--${appearance}`,
180
+ className
181
+ ].filter(Boolean).join(" "),
125
182
  ref,
126
183
  children
127
184
  })
128
185
  });
129
186
  });
187
+ Tab.displayName = "Tabs.Tab";
188
+ Add.displayName = "Tabs.Add";
189
+ Root.displayName = "Tabs";
130
190
  var Tabs = Object.assign(Root, {
131
191
  Add,
132
192
  List,
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["import { createContext, forwardRef, useContext, useId, useState } from 'react';\nimport type { KeyboardEvent } from 'react';\nimport type {\n TabsAddProps,\n TabsListProps,\n TabsPanelProps,\n TabsProps,\n TabsTabProps,\n} from './Tabs.types.js';\n\ninterface TabsContextValue {\n baseId: string;\n select: (value: string) => void;\n tabs: Map<string, HTMLButtonElement>;\n value: string | undefined;\n}\nconst TabsContext = createContext<TabsContextValue | null>(null);\nfunction useTabs(part: string) {\n const context = useContext(TabsContext);\n if (context === null) throw new Error(`Tabs.${part} must be rendered within Tabs.`);\n return context;\n}\n\nconst List = forwardRef<HTMLDivElement, TabsListProps>(function List(\n { children, className, ...props },\n ref,\n) {\n useTabs('List');\n return (\n <div\n {...props}\n className={['chayns-tabs__list', className].filter(Boolean).join(' ')}\n ref={ref}\n role=\"tablist\"\n >\n {children}\n </div>\n );\n});\nconst Tab = forwardRef<HTMLButtonElement, TabsTabProps>(function Tab(\n { children, className, onKeyDown, onRemove, onClick, value, ...props },\n ref,\n) {\n const tabs = useTabs('Tab');\n const selected = tabs.value === value;\n const tabId = `${tabs.baseId}-tab-${value}`;\n const panelId = `${tabs.baseId}-panel-${value}`;\n function handleKeyDown(event: KeyboardEvent<HTMLButtonElement>) {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n\n if ((event.key === 'Delete' || event.key === 'Backspace') && onRemove) {\n event.preventDefault();\n onRemove();\n return;\n }\n const values = [...tabs.tabs.keys()];\n const index = values.indexOf(value);\n const nextIndex =\n event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? values.length - 1\n : event.key === 'ArrowRight' || event.key === 'ArrowDown'\n ? (index + 1) % values.length\n : event.key === 'ArrowLeft' || event.key === 'ArrowUp'\n ? (index - 1 + values.length) % values.length\n : -1;\n if (nextIndex >= 0) {\n event.preventDefault();\n const next = values[nextIndex];\n if (next) {\n tabs.select(next);\n tabs.tabs.get(next)?.focus();\n }\n }\n }\n function setRef(node: HTMLButtonElement | null) {\n if (node) tabs.tabs.set(value, node);\n else tabs.tabs.delete(value);\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }\n return (\n <button\n {...props}\n aria-controls={panelId}\n aria-selected={selected}\n className={['chayns-tabs__tab', selected && 'chayns-tabs__tab--active', className]\n .filter(Boolean)\n .join(' ')}\n id={tabId}\n onClick={(event) => {\n if ((event.target as HTMLElement).closest('[data-tabs-remove]')) {\n onRemove?.();\n return;\n }\n onClick?.(event);\n if (!event.defaultPrevented) tabs.select(value);\n }}\n onKeyDown={handleKeyDown}\n ref={setRef}\n role=\"tab\"\n tabIndex={selected ? 0 : -1}\n type=\"button\"\n >\n {children}\n {onRemove ? (\n <span aria-hidden=\"true\" className=\"chayns-tabs__remove\" data-tabs-remove>\n <i className=\"far fa-xmark\" />\n </span>\n ) : null}\n </button>\n );\n});\nconst Panel = forwardRef<HTMLDivElement, TabsPanelProps>(function Panel(\n { children, className, value, ...props },\n ref,\n) {\n const tabs = useTabs('Panel');\n if (tabs.value !== value) return null;\n return (\n <div\n {...props}\n aria-labelledby={`${tabs.baseId}-tab-${value}`}\n className={['chayns-tabs__panel', className].filter(Boolean).join(' ')}\n id={`${tabs.baseId}-panel-${value}`}\n ref={ref}\n role=\"tabpanel\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n});\nconst Add = forwardRef<HTMLButtonElement, TabsAddProps>(function Add(\n { children, className, ...props },\n ref,\n) {\n useTabs('Add');\n return (\n <button\n {...props}\n className={['chayns-tabs__add', className].filter(Boolean).join(' ')}\n ref={ref}\n type=\"button\"\n >\n {children}\n </button>\n );\n});\nconst Root = forwardRef<HTMLDivElement, TabsProps>(function Root(\n { children, className, defaultValue, onValueChange, value, ...props },\n ref,\n) {\n const baseId = useId();\n const [internalValue, setInternalValue] = useState(defaultValue);\n const [tabMap] = useState(() => new Map<string, HTMLButtonElement>());\n const selectedValue = value ?? internalValue;\n const select = (next: string) => {\n if (value === undefined) setInternalValue(next);\n onValueChange?.(next);\n };\n return (\n <TabsContext.Provider value={{ baseId, select, tabs: tabMap, value: selectedValue }}>\n <div {...props} className={['chayns-tabs', className].filter(Boolean).join(' ')} ref={ref}>\n {children}\n </div>\n </TabsContext.Provider>\n );\n});\nexport const Tabs = Object.assign(Root, { Add, List, Panel, Tab });\n"],"mappings":";;;AAgBA,IAAM,cAAc,cAAuC,IAAI;AAC/D,SAAS,QAAQ,MAAc;CAC7B,MAAM,UAAU,WAAW,WAAW;CACtC,IAAI,YAAY,MAAM,MAAM,IAAI,MAAM,QAAQ,KAAK,+BAA+B;CAClF,OAAO;AACT;AAEA,IAAM,OAAO,WAA0C,SAAS,KAC9D,EAAE,UAAU,WAAW,GAAG,SAC1B,KACA;CACA,QAAQ,MAAM;CACd,OACE,oBAAC,OAAD;EACE,GAAI;EACJ,WAAW,CAAC,qBAAqB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC/D;EACL,MAAK;EAEJ;CACE,CAAA;AAET,CAAC;AACD,IAAM,MAAM,WAA4C,SAAS,IAC/D,EAAE,UAAU,WAAW,WAAW,UAAU,SAAS,OAAO,GAAG,SAC/D,KACA;CACA,MAAM,OAAO,QAAQ,KAAK;CAC1B,MAAM,WAAW,KAAK,UAAU;CAChC,MAAM,QAAQ,GAAG,KAAK,OAAO,OAAO;CACpC,MAAM,UAAU,GAAG,KAAK,OAAO,SAAS;CACxC,SAAS,cAAc,OAAyC;EAC9D,YAAY,KAAK;EACjB,IAAI,MAAM,kBAAkB;EAE5B,KAAK,MAAM,QAAQ,YAAY,MAAM,QAAQ,gBAAgB,UAAU;GACrE,MAAM,eAAe;GACrB,SAAS;GACT;EACF;EACA,MAAM,SAAS,CAAC,GAAG,KAAK,KAAK,KAAK,CAAC;EACnC,MAAM,QAAQ,OAAO,QAAQ,KAAK;EAClC,MAAM,YACJ,MAAM,QAAQ,SACV,IACA,MAAM,QAAQ,QACZ,OAAO,SAAS,IAChB,MAAM,QAAQ,gBA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iB,GAAG,KAAK,OAAO,OAAO;EACvC,WAAW,CAAC,sBAAsB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACrE,IAAI,GAAG,KAAK,OAAO,SAAS;EACvB;EACL,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AACD,IAAM,MAAM,WAA4C,SAAS,IAC/D,EAAE,UAAU,WAAW,GAAG,SAC1B,KACA;CACA,QAAQ,KAAK;CACb,OACE,oBAAC,UAAD;EACE,GAAI;EACJ,WAAW,CAAC,oBAAoB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC9D;EACL,MAAK;EAEJ;CACK,CAAA;AAEZ,CAAC;AACD,IAAM,OAAO,WAAsC,SAAS,KAC1D,EAAE,UAAU,WAAW,cAAc,eAAe,OAAO,GAAG,SAC9D,KACA;CACA,MAAM,SAAS,MAAM;CACrB,MAAM,CAAC,eAAe,oBAAoB,SAAS,YAAY;CAC/D,MAAM,CAAC,UAAU,+BAAe,IAAI,IAA+B,CAAC;CACpE,MAAM,gBAAgB,SAAS;CAC/B,MAAM,UAAU,SAAiB;EAC/B,IAAI,UAAU,KAAA,GAAW,iBAAiB,IAAI;EAC9C,gBAAgB,IAAI;CACtB;CACA,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;GAAE;GAAQ;GAAQ,MAAM;GAAQ,OAAO;EAAc;EAChF,UAAA,oBAAC,OAAD;GAAK,GAAI;GAAO,WAAW,CAAC,eAAe,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAAQ;GACnF;EACE,CAAA;CACe,CAAA;AAE1B,CAAC;AACD,IAAa,OAAO,OAAO,OAAO,MAAM;CAAE;CAAK;CAAM;CAAO;AAAI,CAAC"}
1
+ {"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["import List from './TabsList.js';\nimport Panel from './TabsPanel.js';\nimport { TabsContext, useTabs } from './TabsContext.js';\nimport useElementRef from './hooks/useElementRef.js';\nimport TabsIcon from './tabs-icon/TabsIcon.js';\nimport { forwardRef, useCallback, useId, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport type { KeyboardEvent } from 'react';\nimport type { TabsAddProps, TabsProps, TabsTabProps } from './Tabs.types.js';\n\nconst Tab = forwardRef<HTMLButtonElement, TabsTabProps>(function Tab(\n { children, className, onKeyDown, onRemove, onClick, value, ...props },\n ref,\n) {\n const tabs = useTabs('Tab');\n const selected = tabs.value === value;\n const tabId = `${tabs.baseId}-tab-${value}`;\n const panelId = `${tabs.baseId}-panel-${value}`;\n function handleKeyDown(event: KeyboardEvent<HTMLButtonElement>) {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n\n if ((event.key === 'Delete' || event.key === 'Backspace') && onRemove) {\n event.preventDefault();\n onRemove(value);\n return;\n }\n const values = [...tabs.tabs.entries()]\n .filter(([, element]) => !element.disabled)\n .sort(([, first], [, second]) =>\n first.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n )\n .map(([tabValue]) => tabValue);\n const index = values.indexOf(value);\n let nextIndex = -1;\n if (event.key === 'Home') nextIndex = 0;\n else if (event.key === 'End') nextIndex = values.length - 1;\n else if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {\n nextIndex = (index + 1) % values.length;\n } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {\n nextIndex = (index - 1 + values.length) % values.length;\n }\n if (nextIndex >= 0) {\n event.preventDefault();\n const next = values[nextIndex];\n if (next !== undefined) {\n tabs.select(next);\n tabs.tabs.get(next)?.focus();\n }\n }\n }\n const register = tabs.register;\n const notify = tabs.notify;\n const [, setElement] = useElementRef(ref);\n const setRef = useCallback(\n (node: HTMLButtonElement | null) => {\n register(value, node);\n setElement(node);\n },\n [register, setElement, value],\n );\n useLayoutEffect(() => notify(), [notify, props.disabled]);\n return (\n <button\n {...props}\n aria-controls={panelId}\n aria-selected={selected}\n className={['chayns-tabs__tab', selected && 'chayns-tabs__tab--active', className]\n .filter(Boolean)\n .join(' ')}\n id={tabId}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (event.target instanceof Element && event.target.closest('[data-tabs-remove]')) {\n onRemove?.(value);\n } else tabs.select(value);\n }}\n onKeyDown={handleKeyDown}\n ref={setRef}\n role=\"tab\"\n tabIndex={tabs.entryValue === value ? 0 : -1}\n type=\"button\"\n >\n {children}\n {onRemove ? (\n <span aria-hidden=\"true\" className=\"chayns-tabs__remove\" data-tabs-remove>\n <TabsIcon icon=\"fa-xmark\" />\n </span>\n ) : null}\n </button>\n );\n});\nconst Add = forwardRef<HTMLButtonElement, TabsAddProps>(function Add(\n { children, className, ...props },\n ref,\n) {\n useTabs('Add');\n return (\n <button\n {...props}\n className={['chayns-tabs__add', className].filter(Boolean).join(' ')}\n ref={ref}\n type=\"button\"\n >\n {children}\n </button>\n );\n});\nconst Root = forwardRef<HTMLDivElement, TabsProps>(function Root(\n { appearance = 'attached', children, className, defaultValue, onValueChange, value, ...props },\n ref,\n) {\n const baseId = useId();\n const [internalValue, setInternalValue] = useState(defaultValue);\n const [tabMap] = useState(() => new Map<string, HTMLButtonElement>());\n const [registryVersion, setRegistryVersion] = useState(0);\n const [selection, setSelection] = useState({ valid: true, entry: value ?? defaultValue });\n const lastProposal = useRef<{ value: string | undefined; next: string } | undefined>(undefined);\n const selectedValue = value ?? internalValue;\n const select = useCallback(\n (next: string) => {\n if (value === undefined) setInternalValue(next);\n onValueChange?.(next);\n },\n [onValueChange, value],\n );\n const notify = useCallback(() => setRegistryVersion((current) => current + 1), []);\n const register = useCallback(\n (tabValue: string, node: HTMLButtonElement | null) => {\n if (node) tabMap.set(tabValue, node);\n else tabMap.delete(tabValue);\n notify();\n },\n [notify, tabMap],\n );\n useLayoutEffect(() => {\n const enabled = [...tabMap.entries()]\n .filter(([, element]) => !element.disabled)\n .sort(([, first], [, second]) =>\n first.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n );\n const valid = enabled.some(([tabValue]) => tabValue === selectedValue);\n const next = valid ? selectedValue : enabled[0]?.[0];\n // Reconcile committed DOM order/disabled state before paint; unchanged state is retained.\n setSelection((current) =>\n current.valid === valid && current.entry === next ? current : { valid, entry: next },\n );\n if (valid || next === undefined) {\n lastProposal.current = undefined;\n return;\n }\n if (lastProposal.current?.value === selectedValue && lastProposal.current?.next === next)\n return;\n lastProposal.current = { value: selectedValue, next };\n select(next);\n }, [children, registryVersion, select, selectedValue, tabMap]);\n const panelValue = selection.valid ? selectedValue : undefined;\n const [views, setViews] = useState<{ current: string | undefined; exiting: string | undefined }>({\n current: panelValue,\n exiting: undefined,\n });\n if (views.current !== panelValue) {\n setViews({ current: panelValue, exiting: selection.valid ? views.current : undefined });\n }\n const finishExit = useCallback((exiting: string) => {\n setViews((current) =>\n current.exiting === exiting ? { current: current.current, exiting: undefined } : current,\n );\n }, []);\n const context = useMemo(\n () => ({\n baseId,\n appearance,\n exitingValue: views.exiting,\n finishExit,\n select,\n tabs: tabMap,\n register,\n notify,\n entryValue: selection.entry,\n value: selection.valid ? selectedValue : undefined,\n }),\n [\n appearance,\n baseId,\n finishExit,\n notify,\n register,\n select,\n selectedValue,\n selection,\n tabMap,\n views.exiting,\n ],\n );\n return (\n <TabsContext.Provider value={context}>\n <div\n {...props}\n className={['chayns-tabs', `chayns-tabs--${appearance}`, className]\n .filter(Boolean)\n .join(' ')}\n ref={ref}\n >\n {children}\n </div>\n </TabsContext.Provider>\n );\n});\nTab.displayName = 'Tabs.Tab';\nAdd.displayName = 'Tabs.Add';\nRoot.displayName = 'Tabs';\n\nexport const Tabs = Object.assign(Root, { Add, List, Panel, Tab });\n"],"mappings":";;;;;;;;AASA,IAAM,MAAM,WAA4C,SAAS,IAC/D,EAAE,UAAU,WAAW,WAAW,UAAU,SAAS,OAAO,GAAG,SAC/D,KACA;CACA,MAAM,OAAO,QAAQ,KAAK;C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AM,YAAY,YACpB,SAAS;EAAE,SAAS;EAAY,SAAS,UAAU,QAAQ,MAAM,UAAU,KAAA;CAAU,CAAC;CAExF,MAAM,aAAa,aAAa,YAAoB;EAClD,UAAU,YACR,QAAQ,YAAY,UAAU;GAAE,SAAS,QAAQ;GAAS,SAAS,KAAA;EAAU,IAAI,OACnF;CACF,GAAG,CAAC,CAAC;CACL,MAAM,UAAU,eACP;EACL;EACA;EACA,cAAc,MAAM;EACpB;EACA;EACA,MAAM;EACN;EACA;EACA,YAAY,UAAU;EACtB,OAAO,UAAU,QAAQ,gBAAgB,KAAA;CAC3C,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;CACR,CACF;CACA,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,OAAD;GACE,GAAI;GACJ,WAAW;IAAC;IAAe,gBAAgB;IAAc;GAAS,CAAC,CAChE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;GACN;GAEJ;EACE,CAAA;CACe,CAAA;AAE1B,CAAC;AACD,IAAI,cAAc;AAClB,IAAI,cAAc;AAClB,KAAK,cAAc;AAEnB,IAAa,OAAO,OAAO,OAAO,MAAM;CAAE;CAAK;CAAM;CAAO;AAAI,CAAC"}
@@ -1,6 +1,16 @@
1
1
  import type { ComponentPropsWithRef, ReactNode } from 'react';
2
+ /** Named configuration values; existing literal props and value lists remain supported. */
3
+ export declare enum TabsAppearances {
4
+ Attached = "attached",
5
+ Underline = "underline"
6
+ }
7
+ export declare const TABS_APPEARANCES: readonly ["attached", "underline"];
8
+ export type TabsAppearance = (typeof TABS_APPEARANCES)[number];
9
+ /** Peer content views; use navigation links for routes and SegmentedControl for settings. */
2
10
  export interface TabsProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
3
11
  children: ReactNode;
12
+ /** attached joins a panel surface; underline switches peer views on one shared surface. */
13
+ appearance?: TabsAppearance;
4
14
  value?: string;
5
15
  defaultValue?: string;
6
16
  onValueChange?: (value: string) => void;
@@ -9,11 +19,13 @@ export type TabsListProps = ComponentPropsWithRef<'div'>;
9
19
  export interface TabsTabProps extends Omit<ComponentPropsWithRef<'button'>, 'aria-controls' | 'aria-selected' | 'children' | 'role' | 'tabIndex' | 'type'> {
10
20
  value: string;
11
21
  children: ReactNode;
12
- onRemove?: () => void;
22
+ /** Omit for a fixed tab. Receives removal requests; the consumer owns the tab/panel entries. */
23
+ onRemove?: (value: string) => void;
13
24
  }
14
25
  export interface TabsPanelProps extends Omit<ComponentPropsWithRef<'div'>, 'aria-labelledby' | 'children' | 'role'> {
15
26
  value: string;
16
27
  children: ReactNode;
17
28
  }
29
+ /** Optional add action: compose with onClick and a localized name, or omit to keep the list fixed. */
18
30
  export type TabsAddProps = ComponentPropsWithRef<'button'>;
19
31
  //# sourceMappingURL=Tabs.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.types.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tabs.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC/E,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AACD,MAAM,MAAM,aAAa,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;AACzD,MAAM,WAAW,YAAa,SAAQ,IAAI,CACxC,qBAAqB,CAAC,QAAQ,CAAC,EAC/B,eAAe,GAAG,eAAe,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAC9E;IACC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,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ACd,QAAQ,EAAE,SAAS,CAAC;IACpB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AACD,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,qBAAqB,CAAC,KAAK,CAAC,EAC5B,iBAAiB,GAAG,UAAU,GAAG,MAAM,CACxC;IACC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB;AACD,sGAAsG;AACtG,MAAM,MAAM,YAAY,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ //#region src/components/tabs/Tabs.types.ts
2
+ /** Named configuration values; existing literal props and value lists remain supported. */
3
+ var TabsAppearances = /* @__PURE__ */ function(TabsAppearances) {
4
+ TabsAppearances["Attached"] = "attached";
5
+ TabsAppearances["Underline"] = "underline";
6
+ return TabsAppearances;
7
+ }({});
8
+ var TABS_APPEARANCES = ["attached", "underline"];
9
+ //#endregion
10
+ export { TABS_APPEARANCES, TabsAppearances };
11
+
12
+ //# sourceMappingURL=Tabs.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tabs.types.js","names":[],"sources":["../../../src/components/tabs/Tabs.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from 'react';\n\n/** Named configuration values; existing literal props and value lists remain supported. */\nexport enum TabsAppearances {\n Attached = 'attached',\n Underline = 'underline',\n}\n\nexport const TABS_APPEARANCES = ['attached', 'underline'] as const;\nexport type TabsAppearance = (typeof TABS_APPEARANCES)[number];\n\n/** Peer content views; use navigation links for routes and SegmentedControl for settings. */\nexport interface TabsProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {\n children: ReactNode;\n /** attached joins a panel surface; underline switches peer views on one shared surface. */\n appearance?: TabsAppearance;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n}\nexport type TabsListProps = ComponentPropsWithRef<'div'>;\nexport interface TabsTabProps extends Omit<\n ComponentPropsWithRef<'button'>,\n 'aria-controls' | 'aria-selected' | 'children' | 'role' | 'tabIndex' | 'type'\n> {\n value: string;\n children: ReactNode;\n /** Omit for a fixed tab. Receives removal requests; the consumer owns the tab/panel entries. */\n onRemove?: (value: string) => void;\n}\nexport interface TabsPanelProps extends Omit<\n ComponentPropsWithRef<'div'>,\n 'aria-labelledby' | 'children' | 'role'\n> {\n value: string;\n children: ReactNode;\n}\n/** Optional add action: compose with onClick and a localized name, or omit to keep the list fixed. */\nexport type TabsAddProps = ComponentPropsWithRef<'button'>;\n"],"mappings":";;AAGA,IAAY,kBAAL,yBAAA,iBAAA;CACL,gBAAA,cAAA;CACA,gBAAA,eAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAa,mBAAmB,CAAC,YAAY,WAAW"}
@@ -0,0 +1,16 @@
1
+ import type { TabsAppearance } from './Tabs.types.js';
2
+ export interface TabsContextValue {
3
+ baseId: string;
4
+ appearance: TabsAppearance;
5
+ exitingValue: string | undefined;
6
+ finishExit: (value: string) => void;
7
+ select: (value: string) => void;
8
+ tabs: Map<string, HTMLButtonElement>;
9
+ entryValue: string | undefined;
10
+ register: (value: string, node: HTMLButtonElement | null) => void;
11
+ notify: () => void;
12
+ value: string | undefined;
13
+ }
14
+ export declare const TabsContext: import("react").Context<TabsContextValue | null>;
15
+ export declare function useTabs(part: string): TabsContextValue;
16
+ //# sourceMappingURL=TabsContext.d.ts.map