@chayns-ui/layout 0.10.0 → 0.10.1

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 +1 @@
1
- {"version":3,"file":"AppLayout.d.ts","sourceRoot":"","sources":["../../../src/components/app-layout/AppLayout.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,4BAA4B,EAO5B,cAAc,EACf,MAAM,sBAAsB,CAAC;AAgP9B,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CAOpB,CAAC"}
1
+ {"version":3,"file":"AppLayout.d.ts","sourceRoot":"","sources":["../../../src/components/app-layout/AppLayout.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,4BAA4B,EAO5B,cAAc,EACf,MAAM,sBAAsB,CAAC;AA+O9B,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CAOpB,CAAC"}
@@ -136,7 +136,7 @@ var Root = forwardRef(function Root({ children, className, collapsed, defaultCol
136
136
  const childParts = Children.toArray(children);
137
137
  const sidebarParts = childParts.filter((child) => isValidElement(child) && (child.type === Navigation || child.type === Footer || child.type === CollapseToggle));
138
138
  const sidebarPartSet = new Set(sidebarParts);
139
- let sidebarRendered = false;
139
+ const firstSidebar = childParts.find((child) => sidebarPartSet.has(child));
140
140
  return /* @__PURE__ */ jsx(LayoutContext.Provider, {
141
141
  value: {
142
142
  collapsed: isCollapsed,
@@ -152,8 +152,7 @@ var Root = forwardRef(function Root({ children, className, collapsed, defaultCol
152
152
  ref,
153
153
  children: childParts.map((child) => {
154
154
  if (sidebarPartSet.has(child)) {
155
- if (sidebarRendered) return null;
156
- sidebarRendered = true;
155
+ if (child !== firstSidebar) return null;
157
156
  return /* @__PURE__ */ jsx("aside", {
158
157
  className: "chayns-app-layout__sidebar",
159
158
  children: sidebarParts
@@ -1 +1 @@
1
- {"version":3,"file":"AppLayout.js","names":[],"sources":["../../../src/components/app-layout/AppLayout.tsx"],"sourcesContent":["import {\n Children,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n useId,\n useState,\n} from 'react';\nimport type { ComponentPropsWithRef, Ref } from 'react';\nimport type {\n AppLayoutCollapseToggleProps,\n AppLayoutContentProps,\n AppLayoutFooterProps,\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 Footer = forwardRef<HTMLElement, AppLayoutFooterProps>(function Footer(\n { children, className, ...props },\n ref,\n) {\n useLayout('Footer');\n return (\n <footer\n {...props}\n className={['chayns-app-layout__footer', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n {children}\n </footer>\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 const childParts = Children.toArray(children);\n const sidebarParts = childParts.filter(\n (child) =>\n isValidElement(child) &&\n (child.type === Navigation || child.type === Footer || child.type === CollapseToggle),\n );\n const sidebarPartSet = new Set(sidebarParts);\n let sidebarRendered = false;\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 {childParts.map((child) => {\n if (sidebarPartSet.has(child)) {\n if (sidebarRendered) return null;\n sidebarRendered = true;\n return (\n <aside className=\"chayns-app-layout__sidebar\" key=\"sidebar\">\n {sidebarParts}\n </aside>\n );\n }\n return child;\n })}\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';\nFooter.displayName = 'AppLayout.Footer';\nCollapseToggle.displayName = 'AppLayout.CollapseToggle';\nRoot.displayName = 'AppLayout';\n\nexport const AppLayout = Object.assign(Root, {\n CollapseToggle,\n Content,\n Footer,\n Header,\n Logo,\n Navigation: Object.assign(Navigation, { Item: NavigationItem }),\n});\n"],"mappings":";;;;AA0BA,IAAM,gBAAgB,cAAkC,IAAI;AAC5D,IAAM,oBAAoB,cAAc,KAAK;AAC7C,SAAS,UAAU,MAAc;CAC/B,MAAM,UAAU,WAAW,aAAa;CACxC,IAAI,YAAY,MAAM,MAAM,IAAI,MAAM,aAAa,KAAK,oCAAoC;CAC5F,OAAO;AACT;AAEA,IAAM,SAAS,WAA8C,SAAS,OACpE,EAAE,UAAU,WAAW,GAAG,SAC1B,KACA;CACA,UAAU,QAAQ;CAClB,OACE,oBAAC,UAAD;EACE,GAAI;EACJ,WAAW,CAAC,6BAA6B,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACvE;EAEJ;CACK,CAAA;AAEZ,CAAC;AACD,IAAM,OAAO,WAAiD,SAAS,KACrE,EAAE,MAAM,IAAI,WAAW,GAAG,SAC1B,KACA;CACA,UAAU,MAAM;CAChB,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,WAAW,CAAC,2BAA2B,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACrE;CACN,CAAA;AAEL,CAAC;AACD,IAAM,aAAa,WAAkD,SAAS,WAC5E,EAAE,UAAU,WAAW,GAAG,SAC1B,KACA;CACA,UAAU,YAAY;CACtB,OACE,oBAAC,kBAAkB,UAAnB;EAA4B,OAAA;EAC1B,UAAA,oBAAC,OAAD;GACE,GAAI;GACJ,WAAW,CAAC,iCAAiC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C;AAChE,CAAC"}
1
+ {"version":3,"file":"AppLayout.js","names":[],"sources":["../../../src/components/app-layout/AppLayout.tsx"],"sourcesContent":["import {\n Children,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n useId,\n useState,\n} from 'react';\nimport type { ComponentPropsWithRef, Ref } from 'react';\nimport type {\n AppLayoutCollapseToggleProps,\n AppLayoutContentProps,\n AppLayoutFooterProps,\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 Footer = forwardRef<HTMLElement, AppLayoutFooterProps>(function Footer(\n { children, className, ...props },\n ref,\n) {\n useLayout('Footer');\n return (\n <footer\n {...props}\n className={['chayns-app-layout__footer', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n {children}\n </footer>\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 const childParts = Children.toArray(children);\n const sidebarParts = childParts.filter(\n (child) =>\n isValidElement(child) &&\n (child.type === Navigation || child.type === Footer || child.type === CollapseToggle),\n );\n const sidebarPartSet = new Set(sidebarParts);\n const firstSidebar = childParts.find((child) => sidebarPartSet.has(child));\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 {childParts.map((child) => {\n if (sidebarPartSet.has(child)) {\n if (child !== firstSidebar) return null;\n return (\n <aside className=\"chayns-app-layout__sidebar\" key=\"sidebar\">\n {sidebarParts}\n </aside>\n );\n }\n return child;\n })}\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';\nFooter.displayName = 'AppLayout.Footer';\nCollapseToggle.displayName = 'AppLayout.CollapseToggle';\nRoot.displayName = 'AppLayout';\n\nexport const AppLayout = Object.assign(Root, {\n CollapseToggle,\n Content,\n Footer,\n Header,\n Logo,\n Navigation: Object.assign(Navigation, { Item: NavigationItem }),\n});\n"],"mappings":";;;;AA0BA,IAAM,gBAAgB,cAAkC,IAAI;AAC5D,IAAM,oBAAoB,cAAc,KAAK;AAC7C,SAAS,UAAU,MAAc;CAC/B,MAAM,UAAU,WAAW,aAAa;CACxC,IAAI,YAAY,MAAM,MAAM,IAAI,MAAM,aAAa,KAAK,oCAAoC;CAC5F,OAAO;AACT;AAEA,IAAM,SAAS,WAA8C,SAAS,OACpE,EAAE,UAAU,WAAW,GAAG,SAC1B,KACA;CACA,UAAU,QAAQ;CAClB,OACE,oBAAC,UAAD;EACE,GAAI;EACJ,WAAW,CAAC,6BAA6B,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACvE;EAEJ;CACK,CAAA;AAEZ,CAAC;AACD,IAAM,OAAO,WAAiD,SAAS,KACrE,EAAE,MAAM,IAAI,WAAW,GAAG,SAC1B,KACA;CACA,UAAU,MAAM;CAChB,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,WAAW,CAAC,2BAA2B,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACrE;CACN,CAAA;AAEL,CAAC;AACD,IAAM,aAAa,WAAkD,SAAS,WAC5E,EAAE,UAAU,WAAW,GAAG,SAC1B,KACA;CACA,UAA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eAAe,cAAc;AAC7B,KAAK,cAAc;AAEnB,IAAa,YAAY,OAAO,OAAO,MAAM;CAC3C;CACA;CACA;CACA;CACA;CACA,YAAY,OAAO,OAAO,YAAY,EAAE,MAAM,eAAe,CAAC;AAChE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-ui/layout",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Accessible application layout components for chayns UI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,11 +28,11 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "peerDependencies": {
31
- "@chayns-ui/core": ">=0.13.0",
31
+ "@chayns-ui/core": ">=0.15.0",
32
32
  "react": ">=19 <20"
33
33
  },
34
34
  "devDependencies": {
35
- "@chayns-ui/core": "0.13.0"
35
+ "@chayns-ui/core": "0.15.0"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=18"