this.gui 1.3.22 → 1.3.26
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/this-gui.es.js +0 -1
- package/dist/this-gui.umd.js +65 -65
- package/index.ts +3 -2
- package/init/index.html +4 -5
- package/init/package-lock.json +2 -2
- package/init/package.json +1 -1
- package/init/src/App.tsx +24 -0
- package/init/src/index.css +16 -0
- package/init/src/main.tsx +14 -0
- package/init/src/router/DerivableRouter.tsx +36 -0
- package/package.json +1 -1
- package/src/GUI.tsx +15 -0
- package/src/components/generics/Cards/Gridme.jsx +52 -0
- package/src/components/generics/Cards/LilBox.jsx +65 -0
- package/src/components/generics/Cards/ModuleCard.jsx +106 -0
- package/src/components/generics/Chats/FullChatBot.jsx +223 -0
- package/src/components/generics/Code/CodeBlock.jsx +33 -0
- package/src/components/generics/Feedback/Callout.jsx +92 -0
- package/src/components/generics/Layout/GridX.jsx +29 -0
- package/src/components/generics/Layout/Hero2.jsx +132 -0
- package/src/components/generics/Layout/PageContainer.jsx +29 -0
- package/src/components/generics/Layout/PageDivider.jsx +20 -0
- package/src/components/generics/Layout/Section.jsx +43 -0
- package/src/components/generics/Layout/SectionHeader.jsx +21 -0
- package/src/components/generics/Media/Img.jsx +58 -0
- package/src/components/generics/Media/VideoEmbed.jsx +51 -0
- package/src/components/generics/Organization/TableOfContents.jsx +51 -0
- package/src/components/generics/Organization/Tabs.jsx +45 -0
- package/src/components/generics/Text/TextList.jsx +41 -0
- package/src/components/generics/Text/TextParagraph.jsx +28 -0
- package/src/components/generics/Text/TextQuote.jsx +23 -0
- package/src/components/generics/Text/TextTitle.jsx +44 -0
- package/src/gui/Layouts/ResponsiveUI/Content/Content.resolver.tsx +0 -0
- package/src/gui/Layouts/ResponsiveUI/Content/Content.stories.tsx +88 -0
- package/src/gui/Layouts/ResponsiveUI/Content/Content.tsx +53 -0
- package/src/gui/Layouts/ResponsiveUI/Content/Content.types.tsx +40 -0
- package/src/gui/Layouts/ResponsiveUI/Footer/Footer.resolver.tsx +45 -0
- package/src/gui/Layouts/ResponsiveUI/Footer/Footer.stories.tsx +209 -0
- package/src/gui/Layouts/ResponsiveUI/Footer/Footer.tsx +337 -0
- package/src/gui/Layouts/ResponsiveUI/Footer/Footer.types.ts +40 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/Layout.resolver.tsx +37 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/Layout.stories.tsx +290 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/Layout.tsx +112 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/Layout.types.ts +56 -0
- package/src/gui/Layouts/ResponsiveUI/Layout/useLayoutBreakpoints.ts +9 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/LeftSidebar.resolver.tsx +87 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/LeftSidebar.stories.tsx +199 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/LeftSidebar.tsx +311 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/LeftSidebar.types.ts +41 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/SidebarToggleButton.tsx +53 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarAction/LeftSidebarAction.resolver.tsx +19 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarAction/LeftSidebarAction.tsx +107 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarLink/LeftSidebarLink.resolver.tsx +0 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarLink/LeftSidebarLink.tsx +122 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarLink/LeftSidebarLink.types.ts +13 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarMenu/LeftSidebarMenu.tsx +142 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/LeftSidebar/components/LeftSidebarToggleButton/LeftSidebarToggleButton.tsx +23 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/RightSidebar.resolver.tsx +35 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/RightSidebar.stories.tsx +240 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/RightSidebar.tsx +319 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/RightSidebar.types.ts +17 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/components/RightSidebarAction/RightSidebarAction.tsx +102 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/components/RightSidebarLink/RightSidebarLink.tsx +132 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/components/RightSidebarMenu/RightSidebarMenu.tsx +140 -0
- package/src/gui/Layouts/ResponsiveUI/Sidebars/RightSidebar/components/RightSidebarToggleButton/RightSidebarToggleButton.tsx +22 -0
- package/src/gui/Layouts/ResponsiveUI/StickyOptions/StickyOptionsTop.stories.tsx +469 -0
- package/src/gui/Layouts/ResponsiveUI/StickyOptions/StickyOptionsTop.tsx +489 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/TopBar.resolver.tsx +86 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/TopBar.stories.tsx +350 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/TopBar.tsx +281 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/TopBar.types.ts +39 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarAction/TopBarAction.stories.tsx +83 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarAction/TopBarAction.tsx +18 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarAction/TopBarAction.types.ts +4 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarLink/TopBarLink.stories.tsx +189 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarLink/TopBarLink.tsx +30 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarLink/TopBarLink.types.ts +9 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarMenu/TopBarMenu.resolver.tsx +14 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarMenu/TopBarMenu.stories.tsx +56 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarMenu/TopBarMenu.tsx +123 -0
- package/src/gui/Layouts/ResponsiveUI/TopBar/components/TopBarMenu/TopBarMenu.types.ts +44 -0
- package/src/gui/Theme/GuiProvider.tsx +125 -0
- package/src/gui/Theme/Icon/Icon.resolver.tsx +29 -0
- package/src/gui/Theme/Icon/Icon.tsx +43 -0
- package/src/gui/Theme/catalog/CherryByte/CherryByte.png +0 -0
- package/src/gui/Theme/catalog/CherryByte/dark.tokens.ts +47 -0
- package/src/gui/Theme/catalog/CherryByte/light.tokens.ts +47 -0
- package/src/gui/Theme/catalog/CherryByte/manifest.ts +24 -0
- package/src/gui/Theme/catalog/GhostShell/dark.tokens.ts +43 -0
- package/src/gui/Theme/catalog/GhostShell/ghost.png +0 -0
- package/src/gui/Theme/catalog/GhostShell/light.tokens.ts +39 -0
- package/src/gui/Theme/catalog/GhostShell/manifest.ts +24 -0
- package/src/gui/Theme/catalog/LunaHex/LunaHex.png +0 -0
- package/src/gui/Theme/catalog/LunaHex/dark.tokens.ts +34 -0
- package/src/gui/Theme/catalog/LunaHex/light.tokens.ts +74 -0
- package/src/gui/Theme/catalog/LunaHex/manifest.ts +24 -0
- package/src/gui/Theme/catalog/MUI/MUI.png +0 -0
- package/src/gui/Theme/catalog/MUI/dark.tokens.ts +58 -0
- package/src/gui/Theme/catalog/MUI/light.tokens.ts +74 -0
- package/src/gui/Theme/catalog/MUI/manifest.ts +24 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/dark.tokens.ts +48 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/light.tokens.ts +47 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/manifest.ts +24 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/prince.png +0 -0
- package/src/gui/Theme/catalog/PrinceOfDarkness/princeOfDarkness.png +0 -0
- package/src/gui/Theme/catalog/Seafoam/dark.tokens.ts +49 -0
- package/src/gui/Theme/catalog/Seafoam/light.tokens.ts +47 -0
- package/src/gui/Theme/catalog/Seafoam/manifest.ts +24 -0
- package/src/gui/Theme/catalog/Seafoam/seaFoam.png +0 -0
- package/src/gui/Theme/catalog/neurons/dark.tokens.ts +58 -0
- package/src/gui/Theme/catalog/neurons/light.tokens.ts +74 -0
- package/src/gui/Theme/catalog/neurons/manifest.ts +24 -0
- package/src/gui/Theme/catalog/neurons/neurons.me.png +0 -0
- package/src/gui/Theme/fromTokens.ts +273 -0
- package/src/gui/Theme/gui.css +31 -0
- package/src/gui/Theme/index.ts +17 -0
- package/src/gui/Theme/styles/buildShadows.ts +83 -0
- package/src/gui/Theme/styles/theme.tokens.ts +108 -0
- package/src/gui/Theme/utils/catalog.ts +61 -0
- package/src/gui/Theme/utils/persistence.ts +66 -0
- package/src/gui/Theme/utils/themeUtils.ts +34 -0
- package/src/gui/apis/codegen.api.ts +38 -0
- package/src/gui/components/atoms/AppBar/AppBar.resolver.tsx +41 -0
- package/src/gui/components/atoms/AppBar/AppBar.stories.tsx +225 -0
- package/src/gui/components/atoms/AppBar/AppBar.tsx +8 -0
- package/src/gui/components/atoms/AppBar/AppBar.types.ts +28 -0
- package/src/gui/components/atoms/Avatar/Avatar.resolver.tsx +61 -0
- package/src/gui/components/atoms/Avatar/Avatar.stories.tsx +36 -0
- package/src/gui/components/atoms/Avatar/Avatar.tsx +14 -0
- package/src/gui/components/atoms/Box/Box.resolver.tsx +171 -0
- package/src/gui/components/atoms/Box/Box.stories.tsx +263 -0
- package/src/gui/components/atoms/Box/Box.tsx +15 -0
- package/src/gui/components/atoms/Button/Button.resolver.tsx +103 -0
- package/src/gui/components/atoms/Button/Button.stories.tsx +219 -0
- package/src/gui/components/atoms/Button/Button.tsx +40 -0
- package/src/gui/components/atoms/Card/Card.resolver.tsx +63 -0
- package/src/gui/components/atoms/Card/Card.stories.tsx +54 -0
- package/src/gui/components/atoms/Card/Card.tsx +13 -0
- package/src/gui/components/atoms/CardActions/CardActions.resolver.tsx +59 -0
- package/src/gui/components/atoms/CardActions/CardActions.stories.tsx +32 -0
- package/src/gui/components/atoms/CardActions/CardActions.tsx +14 -0
- package/src/gui/components/atoms/CardContent/CardContent.resolver.tsx +60 -0
- package/src/gui/components/atoms/CardContent/CardContent.stories.tsx +34 -0
- package/src/gui/components/atoms/CardContent/CardContent.tsx +13 -0
- package/src/gui/components/atoms/CardHeader/CardHeader.resolver.tsx +68 -0
- package/src/gui/components/atoms/CardHeader/CardHeader.stories.tsx +40 -0
- package/src/gui/components/atoms/CardHeader/CardHeader.tsx +12 -0
- package/src/gui/components/atoms/Collapse/Collapse.resolver.tsx +85 -0
- package/src/gui/components/atoms/Collapse/Collapse.stories.tsx +130 -0
- package/src/gui/components/atoms/Collapse/Collapse.tsx +17 -0
- package/src/gui/components/atoms/Divider/Divider.resolver.tsx +95 -0
- package/src/gui/components/atoms/Divider/Divider.stories.tsx +108 -0
- package/src/gui/components/atoms/Divider/Divider.tsx +14 -0
- package/src/gui/components/atoms/Drawer/Drawer.resolver.tsx +116 -0
- package/src/gui/components/atoms/Drawer/Drawer.stories.tsx +223 -0
- package/src/gui/components/atoms/Drawer/Drawer.tsx +25 -0
- package/src/gui/components/atoms/Grid/Grid.resolver.tsx +33 -0
- package/src/gui/components/atoms/Grid/Grid.stories.tsx +136 -0
- package/src/gui/components/atoms/Grid/Grid.tsx +15 -0
- package/src/gui/components/atoms/Grid/Grid.types.ts +9 -0
- package/src/gui/components/atoms/IconButton/IconButton.resolver.tsx +137 -0
- package/src/gui/components/atoms/IconButton/IconButton.stories.tsx +134 -0
- package/src/gui/components/atoms/IconButton/IconButton.tsx +22 -0
- package/src/gui/components/atoms/Link/Link.resolver.tsx +74 -0
- package/src/gui/components/atoms/Link/Link.stories.tsx +157 -0
- package/src/gui/components/atoms/Link/Link.tsx +36 -0
- package/src/gui/components/atoms/List/List.resolver.tsx +94 -0
- package/src/gui/components/atoms/List/List.stories.tsx +137 -0
- package/src/gui/components/atoms/List/List.tsx +20 -0
- package/src/gui/components/atoms/ListItem/ListItem.resolver.tsx +88 -0
- package/src/gui/components/atoms/ListItem/ListItem.stories.tsx +151 -0
- package/src/gui/components/atoms/ListItem/ListItem.tsx +19 -0
- package/src/gui/components/atoms/ListItemButton/ListItemButton.resolver.tsx +214 -0
- package/src/gui/components/atoms/ListItemButton/ListItemButton.stories.tsx +155 -0
- package/src/gui/components/atoms/ListItemButton/ListItemButton.tsx +15 -0
- package/src/gui/components/atoms/ListItemIcon/ListItemIcon.resolver.tsx +102 -0
- package/src/gui/components/atoms/ListItemIcon/ListItemIcon.stories.tsx +132 -0
- package/src/gui/components/atoms/ListItemIcon/ListItemIcon.tsx +11 -0
- package/src/gui/components/atoms/ListItemText/ListItemText.resolver.tsx +112 -0
- package/src/gui/components/atoms/ListItemText/ListItemText.stories.tsx +156 -0
- package/src/gui/components/atoms/ListItemText/ListItemText.tsx +15 -0
- package/src/gui/components/atoms/Menu/Menu.resolver.tsx +112 -0
- package/src/gui/components/atoms/Menu/Menu.stories.tsx +162 -0
- package/src/gui/components/atoms/Menu/Menu.tsx +17 -0
- package/src/gui/components/atoms/MenuItem/MenuItem.resolver.tsx +183 -0
- package/src/gui/components/atoms/MenuItem/MenuItem.stories.tsx +134 -0
- package/src/gui/components/atoms/MenuItem/MenuItem.tsx +14 -0
- package/src/gui/components/atoms/Paper/Paper.resolver.tsx +98 -0
- package/src/gui/components/atoms/Paper/Paper.stories.tsx +184 -0
- package/src/gui/components/atoms/Paper/Paper.tsx +15 -0
- package/src/gui/components/atoms/Section/Section.resolver.tsx +10 -0
- package/src/gui/components/atoms/Section/Section.stories.tsx +189 -0
- package/src/gui/components/atoms/Section/Section.tsx +76 -0
- package/src/gui/components/atoms/Section/Section.types.tsx +24 -0
- package/src/gui/components/atoms/Stack/Stack.resolver.tsx +94 -0
- package/src/gui/components/atoms/Stack/Stack.stories.tsx +160 -0
- package/src/gui/components/atoms/Stack/Stack.tsx +15 -0
- package/src/gui/components/atoms/Surface/Surface.resolver.tsx +37 -0
- package/src/gui/components/atoms/Surface/Surface.tsx +49 -0
- package/src/gui/components/atoms/Surface/Surface.types.ts +20 -0
- package/src/gui/components/atoms/Switch/Switch.resolver.tsx +53 -0
- package/src/gui/components/atoms/Switch/Switch.stories.tsx +236 -0
- package/src/gui/components/atoms/Switch/Switch.tsx +22 -0
- package/src/gui/components/atoms/TextField/TextField.stories.tsx +28 -0
- package/src/gui/components/atoms/TextField/TextField.tsx +15 -0
- package/src/gui/components/atoms/Toolbar/Toolbar.resolver.tsx +60 -0
- package/src/gui/components/atoms/Toolbar/Toolbar.stories.tsx +155 -0
- package/src/gui/components/atoms/Toolbar/Toolbar.tsx +16 -0
- package/src/gui/components/atoms/Tooltip/Tooltip.resolver.tsx +142 -0
- package/src/gui/components/atoms/Tooltip/Tooltip.stories.tsx +117 -0
- package/src/gui/components/atoms/Tooltip/Tooltip.tsx +70 -0
- package/src/gui/components/atoms/Typography/Typography.resolver.tsx +158 -0
- package/src/gui/components/atoms/Typography/Typography.stories.tsx +222 -0
- package/src/gui/components/atoms/Typography/Typography.tsx +27 -0
- package/src/gui/components/atoms.tsx +138 -0
- package/src/gui/components/molecules/Dialog/Dialog.stories.tsx +18 -0
- package/src/gui/components/molecules/Dialog/Dialog.tsx +5 -0
- package/src/gui/components/molecules/HeroSection/HeroSection.stories.tsx +141 -0
- package/src/gui/components/molecules/HeroSection/HeroSection.tsx +152 -0
- package/src/gui/components/molecules/HeroSection/HeroSection.types.tsx +18 -0
- package/src/gui/components/molecules/ModalBox/ModalBox.resolver.tsx +38 -0
- package/src/gui/components/molecules/ModalBox/ModalBox.stories.tsx +82 -0
- package/src/gui/components/molecules/ModalBox/ModalBox.tsx +106 -0
- package/src/gui/components/molecules/ModalBox/ModalBox.types.ts +29 -0
- package/src/gui/components/molecules/Page/Page.stories.tsx +135 -0
- package/src/gui/components/molecules/Page/Page.tsx +94 -0
- package/src/gui/components/molecules/Theme/ThemeModeToggle/ThemeModeToggle.resolver.tsx +58 -0
- package/src/gui/components/molecules/Theme/ThemeModeToggle/ThemeModeToggle.stories.tsx +133 -0
- package/src/gui/components/molecules/Theme/ThemeModeToggle/ThemeModeToggle.tsx +101 -0
- package/src/gui/components/molecules/Theme/ThemeModeToggle/ThemeModeToggle.types.ts +29 -0
- package/src/gui/components/molecules/Theme/ThemesCatalog/ThemesCatalog.resolver.tsx +15 -0
- package/src/gui/components/molecules/Theme/ThemesCatalog/ThemesCatalog.stories.tsx +88 -0
- package/src/gui/components/molecules/Theme/ThemesCatalog/ThemesCatalog.tsx +167 -0
- package/src/gui/components/molecules/Theme/ThemesCatalog/ThemesCatalog.types.ts +34 -0
- package/src/gui/components/organism/ChatGPTInterface/ChatGPTInterface.stories.tsx +17 -0
- package/src/gui/components/organism/ChatGPTInterface/ChatGPTInterface.tsx +71 -0
- package/src/gui/components/organism/RootDomain/RootDomain.stories.tsx +31 -0
- package/src/gui/components/organism/RootDomain/RootDomain.tsx +100 -0
- package/src/gui/components/organism/RootDomain/staticServices.ts +66 -0
- package/src/gui/components/window/Nodes/node.ts +0 -0
- package/src/gui/components/window/code/block/node.tsx +0 -0
- package/src/gui/components/window/code/hugging.face.api.ts +11 -0
- package/src/gui/components/window/connectors/index.ts +19 -0
- package/src/gui/components/window/window.stories.tsx +20 -0
- package/src/gui/components/window/window.tsx +633 -0
- package/src/gui/contexts/InsetsContext.tsx +38 -0
- package/src/gui/contexts/LeftSidebarContext.tsx +20 -0
- package/src/gui/contexts/RightSidebarContext.tsx +25 -0
- package/src/gui/contexts/ThemeContext.ts +34 -0
- package/src/gui/contexts/index.ts +4 -0
- package/src/gui/hooks/index.ts +11 -0
- package/src/gui/hooks/resolveColorToken.ts +39 -0
- package/src/gui/hooks/useCodeGen.ts +12 -0
- package/src/gui/hooks/useGuiMediaQuery.ts +18 -0
- package/src/gui/hooks/useGuiTheme.ts +18 -0
- package/src/gui/hooks/useInsets.ts +26 -0
- package/src/gui/hooks/useIsMobile.ts +13 -0
- package/src/gui/hooks/useIsTouchDevice.ts +25 -0
- package/src/gui/hooks/useLeftSidebar.ts +10 -0
- package/src/gui/hooks/useRightSidebar.ts +12 -0
- package/src/gui/hooks/useViewportKey.ts +19 -0
- package/src/gui/hooks/useViewportProp.ts +17 -0
- package/src/gui/me/Logic.tsx +31 -0
- package/src/gui/me/Me.stories.tsx +8 -0
- package/src/gui/me/Me.tsx +197 -0
- package/src/gui/me/fundamentals/verbs/verbs.tsx +94 -0
- package/src/gui/me/modificators/Adjectives.ts +0 -0
- package/src/gui/me/modificators/Adverbs.ts +0 -0
- package/src/gui/me/modificators/Complements.ts +27 -0
- package/src/gui/me/utils/Context.tsx +14 -0
- package/src/gui/me/utils/hooks/useMe.js +37 -0
- package/src/gui/utils/nodeID.ts +11 -0
- package/src/registry/GuiRegistry.ts +19 -0
- package/src/registry/factory.ts +12 -0
- package/src/registry/index.ts +3 -0
- package/src/registry/types.ts +6 -0
- package/src/stories/01.Home.mdx +22 -0
- package/src/stories/02.Understanding.This.GUI.mdx +149 -0
- package/src/stories/Theme/Palette.stories.tsx +86 -0
- package/src/stories/Theme/ThemeViewer.stories.tsx +91 -0
- package/src/stories/Theme/Typography.stories.jsx +211 -0
- package/src/types/gui.d.ts +67 -0
- package/src/types/theme.d.ts +191 -0
- package/src/types/viewport.ts +132 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// src/gui/atoms/ListItemText/ListItemText.resolver.tsx
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import ListItemText from './ListItemText';
|
|
4
|
+
import type { RegistryEntry, ResolveCtx } from '@/registry/types';
|
|
5
|
+
import type { SxProps, Theme } from '@mui/material/styles';
|
|
6
|
+
import { ensureNodeId } from '@/gui/utils/nodeID';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Declarative spec for ListItemText
|
|
10
|
+
*
|
|
11
|
+
* Goals
|
|
12
|
+
* - Be faithful to MUI's API: pass through native props like `primary`, `secondary`,
|
|
13
|
+
* `inset`, `disableTypography`, `primaryTypographyProps`, `secondaryTypographyProps`, etc.
|
|
14
|
+
* - Add **granular styling** sugar for slots:
|
|
15
|
+
* - `sx` → root container
|
|
16
|
+
* - `primarySx` → merged into `primaryTypographyProps.sx`
|
|
17
|
+
* - `secondarySx` → merged into `secondaryTypographyProps.sx`
|
|
18
|
+
*
|
|
19
|
+
* Notes
|
|
20
|
+
* - Not a routing component; we simply respect optional `component` (or `as`) for polymorphism.
|
|
21
|
+
* - We avoid inserting `undefined` inside `sx` arrays; we compute merged values safely.
|
|
22
|
+
*/
|
|
23
|
+
export type ListItemTextSpec = {
|
|
24
|
+
type: 'ListItemText';
|
|
25
|
+
props?: {
|
|
26
|
+
// MUI core props (subset; the rest are forwarded)
|
|
27
|
+
primary?: React.ReactNode;
|
|
28
|
+
secondary?: React.ReactNode;
|
|
29
|
+
inset?: boolean;
|
|
30
|
+
disableTypography?: boolean;
|
|
31
|
+
primaryTypographyProps?: any;
|
|
32
|
+
secondaryTypographyProps?: any;
|
|
33
|
+
|
|
34
|
+
// Polymorphism
|
|
35
|
+
component?: any;
|
|
36
|
+
as?: any; // alias of component
|
|
37
|
+
|
|
38
|
+
// Granular styling
|
|
39
|
+
sx?: SxProps<Theme>; // root
|
|
40
|
+
primarySx?: SxProps<Theme>; // Typography for primary
|
|
41
|
+
secondarySx?: SxProps<Theme>; // Typography for secondary
|
|
42
|
+
|
|
43
|
+
// Misc
|
|
44
|
+
id?: string;
|
|
45
|
+
className?: string;
|
|
46
|
+
'data-testid'?: string;
|
|
47
|
+
'data-gui-id'?: string;
|
|
48
|
+
|
|
49
|
+
// Allow arbitrary passthrough (Typography props, etc.)
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const ListItemTextResolver: RegistryEntry = {
|
|
55
|
+
type: 'ListItemText',
|
|
56
|
+
resolve(spec: ListItemTextSpec, _ctx?: ResolveCtx) {
|
|
57
|
+
const p = spec.props ?? {};
|
|
58
|
+
|
|
59
|
+
const dataGuiId = ensureNodeId('list-item-text', (p as any)['data-gui-id']);
|
|
60
|
+
|
|
61
|
+
// Determine component target (no routing here)
|
|
62
|
+
const component = p.component ?? p.as;
|
|
63
|
+
|
|
64
|
+
const {
|
|
65
|
+
// extract slot style sugar and slot props to merge
|
|
66
|
+
primarySx,
|
|
67
|
+
secondarySx,
|
|
68
|
+
primaryTypographyProps,
|
|
69
|
+
secondaryTypographyProps,
|
|
70
|
+
// strip resolver-only alias
|
|
71
|
+
as: _as,
|
|
72
|
+
"data-gui-id": dataGuiIdProp,
|
|
73
|
+
// keep the rest (includes primary/secondary/sx/etc.)
|
|
74
|
+
...rest
|
|
75
|
+
} = p;
|
|
76
|
+
|
|
77
|
+
// Merge sx into Typography slot props without introducing undefined in arrays
|
|
78
|
+
const mergedPrimarySx =
|
|
79
|
+
primarySx != null && primaryTypographyProps?.sx != null
|
|
80
|
+
? [primarySx, primaryTypographyProps.sx]
|
|
81
|
+
: primarySx ?? primaryTypographyProps?.sx;
|
|
82
|
+
|
|
83
|
+
const mergedSecondarySx =
|
|
84
|
+
secondarySx != null && secondaryTypographyProps?.sx != null
|
|
85
|
+
? [secondarySx, secondaryTypographyProps.sx]
|
|
86
|
+
: secondarySx ?? secondaryTypographyProps?.sx;
|
|
87
|
+
|
|
88
|
+
const finalPrimaryTypographyProps = primaryTypographyProps
|
|
89
|
+
? { ...primaryTypographyProps, sx: mergedPrimarySx }
|
|
90
|
+
: mergedPrimarySx != null
|
|
91
|
+
? { sx: mergedPrimarySx }
|
|
92
|
+
: undefined;
|
|
93
|
+
|
|
94
|
+
const finalSecondaryTypographyProps = secondaryTypographyProps
|
|
95
|
+
? { ...secondaryTypographyProps, sx: mergedSecondarySx }
|
|
96
|
+
: mergedSecondarySx != null
|
|
97
|
+
? { sx: mergedSecondarySx }
|
|
98
|
+
: undefined;
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<ListItemText
|
|
102
|
+
component={component}
|
|
103
|
+
primaryTypographyProps={finalPrimaryTypographyProps}
|
|
104
|
+
secondaryTypographyProps={finalSecondaryTypographyProps}
|
|
105
|
+
data-gui-id={dataGuiId}
|
|
106
|
+
{...rest}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export default ListItemTextResolver;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import ListItemText from './ListItemText';
|
|
4
|
+
import List from '@mui/material/List';
|
|
5
|
+
import ListItem from '@mui/material/ListItem';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof ListItemText> = {
|
|
8
|
+
title: 'Atoms/Organization/ListItemText',
|
|
9
|
+
component: ListItemText,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story) => (
|
|
13
|
+
<div style={{ padding: 16, minHeight: 260, maxWidth: 520 }}>
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
),
|
|
17
|
+
],
|
|
18
|
+
parameters: {
|
|
19
|
+
docs: {
|
|
20
|
+
description: {
|
|
21
|
+
component: `
|
|
22
|
+
The **ListItemText** atom is a thin wrapper around MUI's \`MuiListItemText\`.
|
|
23
|
+
It preserves MUI props and typing (faithful to the original), and fits naturally into This.GUI's declarative/resolver pattern.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
## Basic usage
|
|
27
|
+
~~~jsx
|
|
28
|
+
<List>
|
|
29
|
+
<ListItem>
|
|
30
|
+
<ListItemText primary="Single line" />
|
|
31
|
+
</ListItem>
|
|
32
|
+
<ListItem>
|
|
33
|
+
<ListItemText primary="Primary" secondary="Secondary description" />
|
|
34
|
+
</ListItem>
|
|
35
|
+
</List>
|
|
36
|
+
~~~
|
|
37
|
+
|
|
38
|
+
## Typography control
|
|
39
|
+
~~~jsx
|
|
40
|
+
<List>
|
|
41
|
+
<ListItem>
|
|
42
|
+
<ListItemText
|
|
43
|
+
primary="Custom primary"
|
|
44
|
+
primaryTypographyProps={{ variant: 'subtitle1', sx: { fontWeight: 600 } }}
|
|
45
|
+
/>
|
|
46
|
+
</ListItem>
|
|
47
|
+
<ListItem>
|
|
48
|
+
<ListItemText
|
|
49
|
+
primary="Primary"
|
|
50
|
+
secondary="Secondary"
|
|
51
|
+
secondaryTypographyProps={{ color: 'text.secondary', sx: { fontStyle: 'italic' } }}
|
|
52
|
+
/>
|
|
53
|
+
</ListItem>
|
|
54
|
+
</List>
|
|
55
|
+
~~~
|
|
56
|
+
|
|
57
|
+
## Declarative JSON / Resolver
|
|
58
|
+
~~~json
|
|
59
|
+
{
|
|
60
|
+
"type": "ListItemText",
|
|
61
|
+
"props": {
|
|
62
|
+
"primary": "Primary",
|
|
63
|
+
"secondary": "Secondary",
|
|
64
|
+
"primarySx": { "fontWeight": 600 },
|
|
65
|
+
"secondarySx": { "color": "text.secondary", "fontStyle": "italic" }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
~~~
|
|
69
|
+
|
|
70
|
+
*Note:* In React usage, use \`primaryTypographyProps.sx\` / \`secondaryTypographyProps.sx\`.
|
|
71
|
+
In declarative mode, you can also use \`primarySx\` / \`secondarySx\` and the resolver will merge them into the Typography slot props.
|
|
72
|
+
`,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
controls: {
|
|
76
|
+
exclude: ['component', 'primaryTypographyProps', 'secondaryTypographyProps'],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
argTypes: {
|
|
80
|
+
primary: { control: 'text' },
|
|
81
|
+
secondary: { control: 'text' },
|
|
82
|
+
inset: { control: 'boolean' },
|
|
83
|
+
disableTypography: { control: 'boolean' },
|
|
84
|
+
sx: { control: 'object' },
|
|
85
|
+
},
|
|
86
|
+
args: {
|
|
87
|
+
primary: 'Primary',
|
|
88
|
+
secondary: 'Secondary',
|
|
89
|
+
inset: false,
|
|
90
|
+
disableTypography: false,
|
|
91
|
+
sx: {},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default meta;
|
|
96
|
+
type Story = StoryObj<typeof ListItemText>;
|
|
97
|
+
|
|
98
|
+
const DemoList: React.FC<{ children?: React.ReactNode }> = ({ children }) => (
|
|
99
|
+
<List dense>
|
|
100
|
+
<ListItem>{children}</ListItem>
|
|
101
|
+
</List>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// ======================= Stories =======================
|
|
105
|
+
export const Playground: Story = {
|
|
106
|
+
render: (args) => (
|
|
107
|
+
<DemoList>
|
|
108
|
+
<ListItemText {...args} />
|
|
109
|
+
</DemoList>
|
|
110
|
+
),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const PrimaryOnly: Story = {
|
|
114
|
+
args: { secondary: '' },
|
|
115
|
+
render: (args) => (
|
|
116
|
+
<DemoList>
|
|
117
|
+
<ListItemText {...args} />
|
|
118
|
+
</DemoList>
|
|
119
|
+
),
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const WithTypographyProps: Story = {
|
|
123
|
+
render: () => (
|
|
124
|
+
<List>
|
|
125
|
+
<ListItem>
|
|
126
|
+
<ListItemText
|
|
127
|
+
primary="Custom primary"
|
|
128
|
+
primaryTypographyProps={{ variant: 'subtitle1', sx: { fontWeight: 600 } }}
|
|
129
|
+
/>
|
|
130
|
+
</ListItem>
|
|
131
|
+
<ListItem>
|
|
132
|
+
<ListItemText
|
|
133
|
+
primary="Primary"
|
|
134
|
+
secondary="Secondary"
|
|
135
|
+
secondaryTypographyProps={{ color: 'text.secondary', sx: { fontStyle: 'italic' } }}
|
|
136
|
+
/>
|
|
137
|
+
</ListItem>
|
|
138
|
+
</List>
|
|
139
|
+
),
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const InsetAndDisabledTypography: Story = {
|
|
143
|
+
render: () => (
|
|
144
|
+
<List>
|
|
145
|
+
<ListItem>
|
|
146
|
+
<ListItemText primary="Inset item" inset />
|
|
147
|
+
</ListItem>
|
|
148
|
+
<ListItem>
|
|
149
|
+
<ListItemText
|
|
150
|
+
primary={<strong>Disable Typography wrapper</strong>}
|
|
151
|
+
disableTypography
|
|
152
|
+
/>
|
|
153
|
+
</ListItem>
|
|
154
|
+
</List>
|
|
155
|
+
),
|
|
156
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This component is a thin wrapper around MUI’s ListItemText.
|
|
3
|
+
* It preserves MUI’s own props and typing.
|
|
4
|
+
* It is kept polymorphic in line with MUI’s design.
|
|
5
|
+
* This wrapper enables consistency with This.GUI’s declarative/resolver pattern.
|
|
6
|
+
*
|
|
7
|
+
* It is faithful to MUI because it re-exports MuiListItemText directly,
|
|
8
|
+
* keeping props intact and typing consistent.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import MuiListItemText from '@mui/material/ListItemText';
|
|
12
|
+
const ListItemText = MuiListItemText;
|
|
13
|
+
export type ListItemTextProps = React.ComponentProps<typeof ListItemText>;
|
|
14
|
+
(ListItemText as any).displayName = 'Gui.ListItemText';
|
|
15
|
+
export default ListItemText;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// src/gui/atoms/Menu/Menu.resolver.tsx
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Menu from './Menu';
|
|
4
|
+
import type { RegistryEntry, ResolveCtx } from '@/registry/types';
|
|
5
|
+
import type { SxProps, Theme } from '@mui/material/styles';
|
|
6
|
+
import type { PopoverOrigin } from '@mui/material/Popover';
|
|
7
|
+
import { ensureNodeId } from '@/gui/utils/nodeID';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Declarative spec for Menu
|
|
11
|
+
*
|
|
12
|
+
* Notes
|
|
13
|
+
* - Wraps MUI's Menu. Not polymorphic.
|
|
14
|
+
* - Supports granular styling via:
|
|
15
|
+
* - `sx` (root Popover/Menu container)
|
|
16
|
+
* - `paperSx` (Paper slot)
|
|
17
|
+
* - `listSx` (MenuList slot)
|
|
18
|
+
* - You can also pass through `PaperProps` and `MenuListProps`; their `sx` will be merged with `paperSx`/`listSx`.
|
|
19
|
+
* - Supports `"data-gui-id"` for editor instrumentation.
|
|
20
|
+
*/
|
|
21
|
+
export type MenuSpec = {
|
|
22
|
+
type: 'Menu';
|
|
23
|
+
props?: {
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
|
|
26
|
+
// Core Menu props (subset; rest is passthrough)
|
|
27
|
+
open?: boolean;
|
|
28
|
+
anchorEl?: Element | null;
|
|
29
|
+
onClose?: (...args: any[]) => void;
|
|
30
|
+
onClick?: (...args: any[]) => void;
|
|
31
|
+
keepMounted?: boolean;
|
|
32
|
+
elevation?: number;
|
|
33
|
+
variant?: 'menu' | 'selectedMenu';
|
|
34
|
+
anchorOrigin?: PopoverOrigin;
|
|
35
|
+
transformOrigin?: PopoverOrigin;
|
|
36
|
+
TransitionProps?: any;
|
|
37
|
+
|
|
38
|
+
// Granular styling
|
|
39
|
+
sx?: SxProps<Theme>; // root (Popover)
|
|
40
|
+
paperSx?: SxProps<Theme>; // Paper slot
|
|
41
|
+
listSx?: SxProps<Theme>; // MenuList slot
|
|
42
|
+
|
|
43
|
+
// Slot props passthrough
|
|
44
|
+
PaperProps?: any;
|
|
45
|
+
MenuListProps?: any;
|
|
46
|
+
|
|
47
|
+
// Misc passthrough
|
|
48
|
+
id?: string;
|
|
49
|
+
className?: string;
|
|
50
|
+
'data-testid'?: string;
|
|
51
|
+
"data-gui-id"?: string;
|
|
52
|
+
|
|
53
|
+
// Allow arbitrary passthrough
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const MenuResolver: RegistryEntry = {
|
|
59
|
+
type: 'Menu',
|
|
60
|
+
resolve(spec: MenuSpec, _ctx?: ResolveCtx) {
|
|
61
|
+
const p = spec.props ?? {};
|
|
62
|
+
|
|
63
|
+
// Extract resolver-only style helpers and children
|
|
64
|
+
const {
|
|
65
|
+
sx,
|
|
66
|
+
id,
|
|
67
|
+
className,
|
|
68
|
+
paperSx,
|
|
69
|
+
listSx,
|
|
70
|
+
PaperProps,
|
|
71
|
+
MenuListProps,
|
|
72
|
+
open,
|
|
73
|
+
"data-gui-id": dataGuiId,
|
|
74
|
+
// keep other props in `rest`
|
|
75
|
+
...rest
|
|
76
|
+
} = p;
|
|
77
|
+
|
|
78
|
+
const guiId = ensureNodeId('menu', dataGuiId);
|
|
79
|
+
|
|
80
|
+
// Merge sx for Paper/MenuList without inserting `undefined` inside arrays
|
|
81
|
+
const mergedPaperSx =
|
|
82
|
+
paperSx != null && PaperProps?.sx != null
|
|
83
|
+
? [paperSx, PaperProps.sx]
|
|
84
|
+
: paperSx ?? PaperProps?.sx;
|
|
85
|
+
|
|
86
|
+
const mergedListSx =
|
|
87
|
+
listSx != null && MenuListProps?.sx != null
|
|
88
|
+
? [listSx, MenuListProps.sx]
|
|
89
|
+
: listSx ?? MenuListProps?.sx;
|
|
90
|
+
|
|
91
|
+
const finalPaperProps = PaperProps ? { ...PaperProps, sx: mergedPaperSx } : (mergedPaperSx != null ? { sx: mergedPaperSx } : undefined);
|
|
92
|
+
const finalMenuListProps = MenuListProps ? { ...MenuListProps, sx: mergedListSx } : (mergedListSx != null ? { sx: mergedListSx } : undefined);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Menu
|
|
96
|
+
open={!!open}
|
|
97
|
+
sx={sx}
|
|
98
|
+
id={id}
|
|
99
|
+
className={className}
|
|
100
|
+
data-testid={p['data-testid']}
|
|
101
|
+
data-gui-id={guiId}
|
|
102
|
+
{...rest}
|
|
103
|
+
PaperProps={finalPaperProps}
|
|
104
|
+
MenuListProps={finalMenuListProps}
|
|
105
|
+
>
|
|
106
|
+
{p.children}
|
|
107
|
+
</Menu>
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export default MenuResolver;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import Menu from './Menu';
|
|
4
|
+
import Button from '@mui/material/Button';
|
|
5
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Menu> = {
|
|
8
|
+
title: 'Atoms/Navigation/Menu',
|
|
9
|
+
component: Menu,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story) => (
|
|
13
|
+
<div style={{ padding: 16, minHeight: 260 }}>
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
),
|
|
17
|
+
],
|
|
18
|
+
parameters: {
|
|
19
|
+
docs: {
|
|
20
|
+
description: {
|
|
21
|
+
component: `
|
|
22
|
+
The **Menu** atom is a thin wrapper around MUI's \`MuiMenu\`. It supports **granular styling** via:
|
|
23
|
+
- \`sx\` — root popover/menu container
|
|
24
|
+
- \`paperSx\` — Paper slot
|
|
25
|
+
- \`listSx\` — MenuList slot
|
|
26
|
+
|
|
27
|
+
You can also pass \`PaperProps\` and \`MenuListProps\`; their \`sx\` are **merged** with \`paperSx\`/\`listSx\`.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
## Basic usage
|
|
31
|
+
~~~jsx
|
|
32
|
+
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
33
|
+
const open = Boolean(anchorEl);
|
|
34
|
+
|
|
35
|
+
<Button onClick={(e) => setAnchorEl(e.currentTarget)}>Open menu</Button>
|
|
36
|
+
<Menu open={open} anchorEl={anchorEl} onClose={() => setAnchorEl(null)}>
|
|
37
|
+
<MenuItem onClick={() => setAnchorEl(null)}>Profile</MenuItem>
|
|
38
|
+
<MenuItem onClick={() => setAnchorEl(null)}>Settings</MenuItem>
|
|
39
|
+
</Menu>
|
|
40
|
+
~~~
|
|
41
|
+
|
|
42
|
+
## Granular styling
|
|
43
|
+
~~~jsx
|
|
44
|
+
<Menu
|
|
45
|
+
open={open}
|
|
46
|
+
anchorEl={anchorEl}
|
|
47
|
+
onClose={handleClose}
|
|
48
|
+
sx={{ mt: 1 }}
|
|
49
|
+
paperSx={{ borderRadius: 10 }}
|
|
50
|
+
listSx={{ py: 0.5 }}
|
|
51
|
+
PaperProps={{ elevation: 3 }}
|
|
52
|
+
/>
|
|
53
|
+
~~~
|
|
54
|
+
|
|
55
|
+
## Declarative JSON / Resolver
|
|
56
|
+
~~~json
|
|
57
|
+
{
|
|
58
|
+
"type": "Menu",
|
|
59
|
+
"props": {
|
|
60
|
+
"open": true,
|
|
61
|
+
"sx": { "mt": 1 },
|
|
62
|
+
"paperSx": { "borderRadius": 10 },
|
|
63
|
+
"listSx": { "py": 0.5 },
|
|
64
|
+
"PaperProps": { "elevation": 3 },
|
|
65
|
+
"children": [
|
|
66
|
+
{ "type": "MenuItem", "props": { "children": "Profile" } },
|
|
67
|
+
{ "type": "MenuItem", "props": { "children": "Settings" } }
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
~~~
|
|
72
|
+
|
|
73
|
+
*Note:* \`anchorEl\` is a runtime element reference and is typically provided by the renderer/context in declarative mode.
|
|
74
|
+
`,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
controls: {
|
|
78
|
+
exclude: ['anchorEl', 'PaperProps', 'MenuListProps'],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
argTypes: {
|
|
82
|
+
open: { control: 'boolean' },
|
|
83
|
+
keepMounted: { control: 'boolean' },
|
|
84
|
+
variant: { control: { type: 'radio' }, options: ['menu', 'selectedMenu'] },
|
|
85
|
+
elevation: { control: { type: 'number', min: 0, max: 24, step: 1 } },
|
|
86
|
+
sx: { control: 'object' },
|
|
87
|
+
},
|
|
88
|
+
args: {
|
|
89
|
+
open: false, // controlled within each story with local state
|
|
90
|
+
keepMounted: false,
|
|
91
|
+
variant: 'menu',
|
|
92
|
+
elevation: 1,
|
|
93
|
+
sx: {},
|
|
94
|
+
children: undefined,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default meta;
|
|
99
|
+
type Story = StoryObj<typeof Menu>;
|
|
100
|
+
|
|
101
|
+
// Reusable demo component that owns anchor state but forwards args
|
|
102
|
+
const DemoMenu: React.FC<React.ComponentProps<typeof Menu>> = (props) => {
|
|
103
|
+
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
104
|
+
const open = Boolean(anchorEl);
|
|
105
|
+
const handleOpen = (e: React.MouseEvent<HTMLButtonElement>) => setAnchorEl(e.currentTarget);
|
|
106
|
+
const handleClose = () => setAnchorEl(null);
|
|
107
|
+
return (
|
|
108
|
+
<>
|
|
109
|
+
<Button variant="outlined" onClick={handleOpen} data-testid="open-menu">
|
|
110
|
+
Open Menu
|
|
111
|
+
</Button>
|
|
112
|
+
<Menu
|
|
113
|
+
{...props}
|
|
114
|
+
open={open}
|
|
115
|
+
anchorEl={anchorEl}
|
|
116
|
+
onClose={handleClose}
|
|
117
|
+
onClick={handleClose}
|
|
118
|
+
>
|
|
119
|
+
{props.children ?? (
|
|
120
|
+
<>
|
|
121
|
+
<MenuItem onClick={handleClose}>Profile</MenuItem>
|
|
122
|
+
<MenuItem onClick={handleClose}>My account</MenuItem>
|
|
123
|
+
<MenuItem onClick={handleClose}>Logout</MenuItem>
|
|
124
|
+
</>
|
|
125
|
+
)}
|
|
126
|
+
</Menu>
|
|
127
|
+
</>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// ======================= Stories =======================
|
|
132
|
+
export const Playground: Story = {
|
|
133
|
+
render: (args) => <DemoMenu {...args} />,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const WithPaperAndListSx: Story = {
|
|
137
|
+
args: {
|
|
138
|
+
sx: { mt: 1 },
|
|
139
|
+
},
|
|
140
|
+
render: (args) => (
|
|
141
|
+
<DemoMenu
|
|
142
|
+
{...args}
|
|
143
|
+
PaperProps={{ elevation: 2, sx: { borderRadius: 2 } }}
|
|
144
|
+
MenuListProps={{ sx: { py: 0.5 } }}
|
|
145
|
+
/>
|
|
146
|
+
),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const KeepMounted: Story = {
|
|
150
|
+
args: { keepMounted: true },
|
|
151
|
+
render: (args) => <DemoMenu {...args} />,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const CustomOrigins: Story = {
|
|
155
|
+
args: {
|
|
156
|
+
sx: { mt: 1 },
|
|
157
|
+
// Showcase custom anchor/transform origins
|
|
158
|
+
anchorOrigin: { vertical: 'bottom', horizontal: 'left' },
|
|
159
|
+
transformOrigin: { vertical: 'top', horizontal: 'left' },
|
|
160
|
+
},
|
|
161
|
+
render: (args) => <DemoMenu {...args} />,
|
|
162
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This.GUI — Menu
|
|
3
|
+
* Thin wrapper that preserves MUI's own typing and API.
|
|
4
|
+
* Examples:
|
|
5
|
+
* <Menu open={open} onClose={handleClose} anchorEl={anchorEl}>
|
|
6
|
+
* {children}
|
|
7
|
+
* </Menu>
|
|
8
|
+
*/
|
|
9
|
+
import MuiMenu from '@mui/material/Menu';
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
|
|
12
|
+
// Re-export using MUI's own component type to keep full typing
|
|
13
|
+
const Menu = MuiMenu;
|
|
14
|
+
export type MenuProps = React.ComponentProps<typeof Menu>;
|
|
15
|
+
|
|
16
|
+
(Menu as any).displayName = 'Gui.Menu';
|
|
17
|
+
export default Menu;
|