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,183 @@
|
|
|
1
|
+
// src/gui/atoms/MenuItem/MenuItem.resolver.tsx
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import MenuItem from './MenuItem';
|
|
4
|
+
import Link from '@/gui/components/atoms/Link/Link';
|
|
5
|
+
import Icon from '@/gui/Theme/Icon/Icon';
|
|
6
|
+
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
7
|
+
import ListItemText from '@mui/material/ListItemText';
|
|
8
|
+
import type { RegistryEntry, ResolveCtx } from '@/registry/types';
|
|
9
|
+
import type { SxProps, Theme } from '@mui/material/styles';
|
|
10
|
+
import type { ListItemIconProps as MuiListItemIconProps } from '@mui/material/ListItemIcon';
|
|
11
|
+
import type { ListItemTextProps as MuiListItemTextProps } from '@mui/material/ListItemText';
|
|
12
|
+
import { ensureNodeId } from '@/gui/utils/nodeID';
|
|
13
|
+
|
|
14
|
+
// Merge sx parts into a single SxProps (filters out undefined)
|
|
15
|
+
const sxJoin = (...parts: Array<SxProps<Theme> | undefined>): SxProps<Theme> =>
|
|
16
|
+
(parts.filter(Boolean) as unknown) as SxProps<Theme>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Declarative spec for MenuItem
|
|
20
|
+
*
|
|
21
|
+
* Notes
|
|
22
|
+
* - Wraps MUI's MenuItem (supports `component` polymorphism).
|
|
23
|
+
* - Declarative sugar:
|
|
24
|
+
* - `label` / `secondary` map to `<ListItemText primary/secondary />`
|
|
25
|
+
* - `startIcon` accepts a token (e.g., "mui:Settings", "lucide:mail") or a React node
|
|
26
|
+
* - Granular styling:
|
|
27
|
+
* - `sx` (root MenuItem)
|
|
28
|
+
* - `iconSx` (ListItemIcon)
|
|
29
|
+
* - `textSx` (ListItemText)
|
|
30
|
+
* - Slot props passthrough:
|
|
31
|
+
* - `ListItemIconProps`, `ListItemTextProps` (their `sx` are merged with iconSx/textSx)
|
|
32
|
+
*/
|
|
33
|
+
export type MenuItemSpec = {
|
|
34
|
+
type: 'MenuItem';
|
|
35
|
+
props?: {
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
|
|
38
|
+
// Polymorphism / routing
|
|
39
|
+
component?: any; // 'li' | 'a' | Link | custom
|
|
40
|
+
as?: any; // alias for component
|
|
41
|
+
to?: string; // router target (when component={Link})
|
|
42
|
+
href?: string; // anchor target (when component='a')
|
|
43
|
+
external?: boolean; // force external anchor
|
|
44
|
+
target?: React.HTMLAttributeAnchorTarget;
|
|
45
|
+
rel?: string;
|
|
46
|
+
|
|
47
|
+
// Sugar
|
|
48
|
+
label?: React.ReactNode | string;
|
|
49
|
+
secondary?: React.ReactNode | string;
|
|
50
|
+
startIcon?: React.ReactNode | string;
|
|
51
|
+
iconColor?: string;
|
|
52
|
+
|
|
53
|
+
// Core MenuItem props (subset; others passthrough)
|
|
54
|
+
dense?: boolean;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
divider?: boolean;
|
|
57
|
+
selected?: boolean;
|
|
58
|
+
autoFocus?: boolean;
|
|
59
|
+
|
|
60
|
+
// Granular styling
|
|
61
|
+
sx?: SxProps<Theme>; // root
|
|
62
|
+
iconSx?: SxProps<Theme>; // ListItemIcon
|
|
63
|
+
textSx?: SxProps<Theme>; // ListItemText
|
|
64
|
+
|
|
65
|
+
// Slot props passthrough
|
|
66
|
+
ListItemIconProps?: MuiListItemIconProps;
|
|
67
|
+
ListItemTextProps?: MuiListItemTextProps;
|
|
68
|
+
|
|
69
|
+
// Misc
|
|
70
|
+
id?: string;
|
|
71
|
+
className?: string;
|
|
72
|
+
'data-testid'?: string;
|
|
73
|
+
'data-gui-id'?: string;
|
|
74
|
+
|
|
75
|
+
// Allow arbitrary passthrough
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
function renderDeclarativeIcon(node: React.ReactNode | string | undefined, iconColor?: string) {
|
|
81
|
+
if (!node) return null;
|
|
82
|
+
if (typeof node === 'string') return <Icon name={node} iconColor={iconColor} fontSize={20} />;
|
|
83
|
+
return node;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function coerceComponent(comp: any) {
|
|
87
|
+
// allow declarative string token "Link" to map to our Link component
|
|
88
|
+
if (comp === 'Link') return Link;
|
|
89
|
+
return comp;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const MenuItemResolver: RegistryEntry = {
|
|
93
|
+
type: 'MenuItem',
|
|
94
|
+
resolve(spec: MenuItemSpec, _ctx?: ResolveCtx) {
|
|
95
|
+
const p = spec.props ?? {};
|
|
96
|
+
|
|
97
|
+
const providedDataGuiId = p['data-gui-id'];
|
|
98
|
+
|
|
99
|
+
// Decide polymorphic target
|
|
100
|
+
const component = coerceComponent(p.component ?? p.as ?? (p.to ? Link : p.external ? 'a' : undefined));
|
|
101
|
+
|
|
102
|
+
// Routing/anchor props
|
|
103
|
+
const routingProps =
|
|
104
|
+
component === 'a' || p.external
|
|
105
|
+
? {
|
|
106
|
+
href: p.href,
|
|
107
|
+
target: p.target ?? (p.external ? '_blank' : undefined),
|
|
108
|
+
rel: p.rel ?? (p.external ? 'noopener noreferrer' : undefined),
|
|
109
|
+
}
|
|
110
|
+
: component === Link || (p.to && !p.component)
|
|
111
|
+
? { to: p.to }
|
|
112
|
+
: {};
|
|
113
|
+
|
|
114
|
+
const {
|
|
115
|
+
children,
|
|
116
|
+
label,
|
|
117
|
+
secondary,
|
|
118
|
+
startIcon,
|
|
119
|
+
iconColor,
|
|
120
|
+
ListItemIconProps,
|
|
121
|
+
ListItemTextProps,
|
|
122
|
+
// strip resolver-only keys
|
|
123
|
+
as: _as,
|
|
124
|
+
external: _external,
|
|
125
|
+
to: _to,
|
|
126
|
+
href: _href,
|
|
127
|
+
target: _target,
|
|
128
|
+
rel: _rel,
|
|
129
|
+
'data-gui-id': _dataGuiId,
|
|
130
|
+
...rest
|
|
131
|
+
} = p;
|
|
132
|
+
|
|
133
|
+
const iconNode = renderDeclarativeIcon(startIcon, iconColor);
|
|
134
|
+
const hasTextBlock = label != null || secondary != null;
|
|
135
|
+
|
|
136
|
+
// Merge sx for ListItemIcon/Text if provided both via shorthand and slot props
|
|
137
|
+
const mergedIconSx = (p.iconSx || ListItemIconProps?.sx)
|
|
138
|
+
? sxJoin(p.iconSx, ListItemIconProps?.sx as SxProps<Theme>)
|
|
139
|
+
: undefined;
|
|
140
|
+
|
|
141
|
+
const mergedTextSx = (p.textSx || ListItemTextProps?.sx)
|
|
142
|
+
? sxJoin(p.textSx, ListItemTextProps?.sx as SxProps<Theme>)
|
|
143
|
+
: undefined;
|
|
144
|
+
|
|
145
|
+
const finalIconProps: MuiListItemIconProps | undefined = iconNode
|
|
146
|
+
? {
|
|
147
|
+
...(ListItemIconProps || {}),
|
|
148
|
+
...(mergedIconSx ? { sx: mergedIconSx } : {}),
|
|
149
|
+
}
|
|
150
|
+
: undefined;
|
|
151
|
+
|
|
152
|
+
const finalTextProps: MuiListItemTextProps | undefined = hasTextBlock
|
|
153
|
+
? {
|
|
154
|
+
...(ListItemTextProps || {}),
|
|
155
|
+
...(mergedTextSx ? { sx: mergedTextSx } : {}),
|
|
156
|
+
}
|
|
157
|
+
: undefined;
|
|
158
|
+
|
|
159
|
+
const dataGuiId = ensureNodeId('menu-item', providedDataGuiId);
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<MenuItem
|
|
163
|
+
component={component}
|
|
164
|
+
sx={p.sx}
|
|
165
|
+
id={p.id}
|
|
166
|
+
className={p.className}
|
|
167
|
+
data-testid={p['data-testid']}
|
|
168
|
+
data-gui-id={dataGuiId}
|
|
169
|
+
{...routingProps}
|
|
170
|
+
{...rest}
|
|
171
|
+
>
|
|
172
|
+
{iconNode ? <ListItemIcon {...finalIconProps}>{iconNode}</ListItemIcon> : null}
|
|
173
|
+
{hasTextBlock ? (
|
|
174
|
+
<ListItemText primary={label} secondary={secondary} {...finalTextProps} />
|
|
175
|
+
) : (
|
|
176
|
+
children
|
|
177
|
+
)}
|
|
178
|
+
</MenuItem>
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export default MenuItemResolver;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import MenuItem from './MenuItem';
|
|
4
|
+
import Menu from '@/gui/components/atoms/Menu/Menu';
|
|
5
|
+
import Button from '@mui/material/Button';
|
|
6
|
+
import Icon from '@/gui/Theme/Icon/Icon';
|
|
7
|
+
const meta: Meta<typeof MenuItem> = {
|
|
8
|
+
title: 'Atoms/Navigation/MenuItem',
|
|
9
|
+
component: MenuItem,
|
|
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 **MenuItem** atom is a thin wrapper around MUI's \`MuiMenuItem\`.
|
|
23
|
+
|
|
24
|
+
In **declarative** mode (registry), the resolver supports:
|
|
25
|
+
- \`label\` / \`secondary\` → maps to \`<ListItemText primary/secondary />\`
|
|
26
|
+
- \`startIcon\` → token (e.g., \`"mui:Settings"\`, \`"lucide:mail"\`) or React node → renders inside \`<ListItemIcon />\`
|
|
27
|
+
- Granular styling via:
|
|
28
|
+
- \`sx\` (root)
|
|
29
|
+
- \`iconSx\` (ListItemIcon)
|
|
30
|
+
- \`textSx\` (ListItemText)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
## Declarative JSON / Resolver
|
|
34
|
+
~~~json
|
|
35
|
+
{
|
|
36
|
+
"type": "MenuItem",
|
|
37
|
+
"props": {
|
|
38
|
+
"startIcon": "mui:Settings",
|
|
39
|
+
"label": "Settings",
|
|
40
|
+
"secondary": "Manage your preferences",
|
|
41
|
+
"sx": { "py": 1 },
|
|
42
|
+
"iconSx": { "minWidth": 36 },
|
|
43
|
+
"textSx": { "my": 0 }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
~~~
|
|
47
|
+
`,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
controls: {
|
|
51
|
+
exclude: ['component'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
argTypes: {
|
|
55
|
+
dense: { control: 'boolean' },
|
|
56
|
+
divider: { control: 'boolean' },
|
|
57
|
+
disabled: { control: 'boolean' },
|
|
58
|
+
selected: { control: 'boolean' },
|
|
59
|
+
sx: { control: 'object' },
|
|
60
|
+
},
|
|
61
|
+
args: {
|
|
62
|
+
dense: false,
|
|
63
|
+
divider: false,
|
|
64
|
+
disabled: false,
|
|
65
|
+
selected: false,
|
|
66
|
+
sx: {},
|
|
67
|
+
children: 'Menu item',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default meta;
|
|
72
|
+
type Story = StoryObj<typeof MenuItem>;
|
|
73
|
+
|
|
74
|
+
// Reusable demo wrapper that controls open/close
|
|
75
|
+
const DemoMenu: React.FC<{ children?: React.ReactNode }> = ({ children }) => {
|
|
76
|
+
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
77
|
+
const open = Boolean(anchorEl);
|
|
78
|
+
const handleOpen = (e: React.MouseEvent<HTMLButtonElement>) => setAnchorEl(e.currentTarget);
|
|
79
|
+
const handleClose = () => setAnchorEl(null);
|
|
80
|
+
return (
|
|
81
|
+
<>
|
|
82
|
+
<Button variant="outlined" onClick={handleOpen} data-testid="open-menu">
|
|
83
|
+
Open Menu
|
|
84
|
+
</Button>
|
|
85
|
+
<Menu open={open} anchorEl={anchorEl} onClose={handleClose} onClick={handleClose}>
|
|
86
|
+
{children ?? (
|
|
87
|
+
<>
|
|
88
|
+
<MenuItem onClick={handleClose}>Profile</MenuItem>
|
|
89
|
+
<MenuItem onClick={handleClose} selected dense>
|
|
90
|
+
<Icon name="settings" weight={400} fill={0} style={{ marginRight: 8 }} />
|
|
91
|
+
Settings
|
|
92
|
+
</MenuItem>
|
|
93
|
+
<MenuItem onClick={handleClose} disabled>
|
|
94
|
+
Disabled
|
|
95
|
+
</MenuItem>
|
|
96
|
+
</>
|
|
97
|
+
)}
|
|
98
|
+
</Menu>
|
|
99
|
+
</>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// ======================= Stories =======================
|
|
104
|
+
export const Playground: Story = {
|
|
105
|
+
render: (args) => (
|
|
106
|
+
<DemoMenu>
|
|
107
|
+
<MenuItem {...args} />
|
|
108
|
+
</DemoMenu>
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const States: Story = {
|
|
113
|
+
render: () => (
|
|
114
|
+
<DemoMenu>
|
|
115
|
+
<MenuItem>Default</MenuItem>
|
|
116
|
+
<MenuItem selected>Selected</MenuItem>
|
|
117
|
+
<MenuItem disabled>Disabled</MenuItem>
|
|
118
|
+
<MenuItem dense>Dense</MenuItem>
|
|
119
|
+
</DemoMenu>
|
|
120
|
+
),
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const WithCustomChildren: Story = {
|
|
124
|
+
render: () => (
|
|
125
|
+
<DemoMenu>
|
|
126
|
+
<MenuItem>
|
|
127
|
+
<strong>Custom node as children</strong>
|
|
128
|
+
</MenuItem>
|
|
129
|
+
<MenuItem>
|
|
130
|
+
<span style={{ opacity: 0.75 }}>With inline styling</span>
|
|
131
|
+
</MenuItem>
|
|
132
|
+
</DemoMenu>
|
|
133
|
+
),
|
|
134
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This.GUI — MenuItem
|
|
3
|
+
* Thin wrapper that preserves MUI's own typing and API.
|
|
4
|
+
* Examples:
|
|
5
|
+
* <MenuItem onClick={...}>Profile</MenuItem>
|
|
6
|
+
* <MenuItem selected dense>Settings</MenuItem>
|
|
7
|
+
*/
|
|
8
|
+
import MuiMenuItem from '@mui/material/MenuItem';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
// Re-export using MUI's own component type to keep full typing
|
|
11
|
+
const MenuItem = MuiMenuItem;
|
|
12
|
+
export type MenuItemProps = React.ComponentProps<typeof MenuItem>;
|
|
13
|
+
(MenuItem as any).displayName = 'Gui.MenuItem';
|
|
14
|
+
export default MenuItem;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// src/gui/atoms/Paper/Paper.resolver.tsx
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Paper from './Paper';
|
|
4
|
+
import Link from '@/gui/components/atoms/Link/Link';
|
|
5
|
+
import type { RegistryEntry, ResolveCtx } from '@/registry/types';
|
|
6
|
+
import { ensureNodeId } from '@/gui/utils/nodeID';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Declarative spec for Paper (polymorphic container)
|
|
10
|
+
*
|
|
11
|
+
* Notes
|
|
12
|
+
* - You can choose the rendered element via `component` (e.g. 'div', 'section', 'a')
|
|
13
|
+
* - If `to` is provided (and no explicit component), the resolver will default to This.GUI `Link`.
|
|
14
|
+
* - If `external` is true (and no explicit component), it will default to an anchor (`'a'`) and apply
|
|
15
|
+
* safe `target`/`rel` defaults.
|
|
16
|
+
* - Supports `sx` and arbitrary system props passthrough.
|
|
17
|
+
*/
|
|
18
|
+
export type PaperSpec = {
|
|
19
|
+
type: 'Paper';
|
|
20
|
+
props?: {
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
|
|
23
|
+
// Polymorphism / routing
|
|
24
|
+
component?: any; // 'div' | 'section' | 'article' | 'a' | Link | custom
|
|
25
|
+
as?: any; // alias for component
|
|
26
|
+
to?: string; // router target (when component={Link})
|
|
27
|
+
href?: string; // anchor target (when component='a')
|
|
28
|
+
external?: boolean; // force external anchor
|
|
29
|
+
target?: React.HTMLAttributeAnchorTarget;
|
|
30
|
+
rel?: string;
|
|
31
|
+
|
|
32
|
+
// MUI Paper core props (subset; rest is passthrough)
|
|
33
|
+
elevation?: number;
|
|
34
|
+
square?: boolean;
|
|
35
|
+
variant?: 'elevation' | 'outlined';
|
|
36
|
+
|
|
37
|
+
// Styling & misc
|
|
38
|
+
sx?: any;
|
|
39
|
+
className?: string;
|
|
40
|
+
id?: string;
|
|
41
|
+
'data-testid'?: string;
|
|
42
|
+
|
|
43
|
+
// Allow system props / arbitrary passthrough (p, m, display, etc.)
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const PaperResolver: RegistryEntry = {
|
|
49
|
+
type: 'Paper',
|
|
50
|
+
resolve(spec: PaperSpec, _ctx?: ResolveCtx) {
|
|
51
|
+
const p = spec.props ?? {};
|
|
52
|
+
const nodeId = ensureNodeId('Paper', p.id);
|
|
53
|
+
|
|
54
|
+
// Decide polymorphic target
|
|
55
|
+
const component = p.component ?? p.as ?? (p.to ? Link : p.external ? 'a' : undefined);
|
|
56
|
+
|
|
57
|
+
// Routing/anchor props
|
|
58
|
+
const routingProps =
|
|
59
|
+
component === 'a' || p.external
|
|
60
|
+
? {
|
|
61
|
+
href: p.href,
|
|
62
|
+
target: p.target ?? (p.external ? '_blank' : undefined),
|
|
63
|
+
rel: p.rel ?? (p.external ? 'noopener noreferrer' : undefined),
|
|
64
|
+
}
|
|
65
|
+
: component === Link || (p.to && !p.component)
|
|
66
|
+
? { to: p.to }
|
|
67
|
+
: {};
|
|
68
|
+
|
|
69
|
+
// Collect common props and avoid leaking resolver-only keys
|
|
70
|
+
const {
|
|
71
|
+
children,
|
|
72
|
+
// remove resolver-only keys so they don't end up as DOM attributes
|
|
73
|
+
as: _as,
|
|
74
|
+
external: _external,
|
|
75
|
+
to: _to,
|
|
76
|
+
href: _href,
|
|
77
|
+
target: _target,
|
|
78
|
+
rel: _rel,
|
|
79
|
+
...rest
|
|
80
|
+
} = p;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Paper
|
|
84
|
+
component={component}
|
|
85
|
+
sx={p.sx}
|
|
86
|
+
id={nodeId}
|
|
87
|
+
className={p.className}
|
|
88
|
+
data-testid={p['data-testid']}
|
|
89
|
+
{...routingProps}
|
|
90
|
+
{...rest}
|
|
91
|
+
>
|
|
92
|
+
{children}
|
|
93
|
+
</Paper>
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default PaperResolver;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Paper from './Paper';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Paper> = {
|
|
5
|
+
title: 'Atoms/Containers/Paper',
|
|
6
|
+
component: Paper,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
decorators: [
|
|
9
|
+
(Story) => (
|
|
10
|
+
<div style={{ padding: 16, minHeight: 240, background: 'var(--mui-palette-background-default)' }}>
|
|
11
|
+
<Story />
|
|
12
|
+
</div>
|
|
13
|
+
),
|
|
14
|
+
],
|
|
15
|
+
parameters: {
|
|
16
|
+
docs: {
|
|
17
|
+
description: {
|
|
18
|
+
component: `
|
|
19
|
+
The **Paper** atom is a thin wrapper around MUI's \`MuiPaper\` that preserves **polymorphism** via the \`component\` prop and passes through all MUI props.
|
|
20
|
+
It integrates with **This.GUI** theming and supports **declarative specs** through the Paper resolver.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
## Features
|
|
24
|
+
- Variants: \`elevation\`, \`outlined\`
|
|
25
|
+
- Elevation: \`0..24\`
|
|
26
|
+
- \`square\` boolean
|
|
27
|
+
- **Polymorphic** via \`component\` (e.g., \`'div'\`, \`'section'\`, \`'a'\`)
|
|
28
|
+
- **Routing default** in declarative mode: if \`to\` is provided (and no explicit \`component\`), resolver renders This.GUI \`Link\`
|
|
29
|
+
- Full **system props** passthrough via \`sx\` (and regular MUI system props)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
## Basic usage
|
|
33
|
+
~~~jsx
|
|
34
|
+
import Paper from '@/gui/atoms/Paper/Paper';
|
|
35
|
+
|
|
36
|
+
<Paper elevation={2} sx={{ p: 2, borderRadius: 2 }}>
|
|
37
|
+
Content
|
|
38
|
+
</Paper>
|
|
39
|
+
~~~
|
|
40
|
+
|
|
41
|
+
## Polymorphic
|
|
42
|
+
~~~jsx
|
|
43
|
+
<Paper component="section" variant="outlined" sx={{ p: 2 }}>
|
|
44
|
+
I'm a <section>
|
|
45
|
+
</Paper>
|
|
46
|
+
|
|
47
|
+
<Paper component="a" href="/docs" sx={{ p: 2, textDecoration: 'none' }}>
|
|
48
|
+
Go to docs
|
|
49
|
+
</Paper>
|
|
50
|
+
~~~
|
|
51
|
+
|
|
52
|
+
*Note:* The \`component\` prop is demonstrated via dedicated stories (not Controls) because Storybook's args typing for MUI OverridableComponent can incorrectly narrow props and flag \`component\` as invalid in the Controls panel.
|
|
53
|
+
|
|
54
|
+
## Declarative JSON / Resolver
|
|
55
|
+
When using the registry-driven renderer, a Paper spec like this:
|
|
56
|
+
|
|
57
|
+
~~~json
|
|
58
|
+
{
|
|
59
|
+
"type": "Paper",
|
|
60
|
+
"props": {
|
|
61
|
+
"variant": "outlined",
|
|
62
|
+
"elevation": 0,
|
|
63
|
+
"component": "section",
|
|
64
|
+
"sx": { "p": 2, "borderRadius": 2 },
|
|
65
|
+
"children": "Content"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
~~~
|
|
69
|
+
|
|
70
|
+
**Routing (declarative default)** — If you provide \`to\` (and **omit** \`component\`), the resolver will render using This.GUI \`Link\`:
|
|
71
|
+
|
|
72
|
+
~~~json
|
|
73
|
+
{
|
|
74
|
+
"type": "Paper",
|
|
75
|
+
"props": {
|
|
76
|
+
"to": "/docs",
|
|
77
|
+
"sx": { "p": 2 },
|
|
78
|
+
"children": "Go to docs"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
~~~
|
|
82
|
+
|
|
83
|
+
The resolver:
|
|
84
|
+
- Chooses \`component\` by priority: explicit \`component\` → \`as\` → (\`to\` ⇒ This.GUI \`Link\`) → (\`external\` ⇒ \`'a'\`)
|
|
85
|
+
- For \`external: true\`, applies safe defaults: \`target="_blank"\`, \`rel="noopener noreferrer"\`
|
|
86
|
+
- Cleans resolver-only keys so they don't leak into the DOM
|
|
87
|
+
`,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
controls: {
|
|
91
|
+
exclude: ['component'],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
argTypes: {
|
|
95
|
+
variant: {
|
|
96
|
+
control: { type: 'radio' },
|
|
97
|
+
options: ['elevation', 'outlined'],
|
|
98
|
+
},
|
|
99
|
+
elevation: {
|
|
100
|
+
control: { type: 'range', min: 0, max: 24, step: 1 },
|
|
101
|
+
},
|
|
102
|
+
square: {
|
|
103
|
+
control: 'boolean',
|
|
104
|
+
},
|
|
105
|
+
sx: {
|
|
106
|
+
control: 'object',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
args: {
|
|
110
|
+
variant: 'elevation',
|
|
111
|
+
elevation: 1,
|
|
112
|
+
square: false,
|
|
113
|
+
children: 'Paper content',
|
|
114
|
+
sx: { p: 2 },
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default meta;
|
|
119
|
+
type Story = StoryObj<typeof Paper>;
|
|
120
|
+
|
|
121
|
+
// ======================= Stories =======================
|
|
122
|
+
export const Playground: Story = {};
|
|
123
|
+
|
|
124
|
+
export const Variants: Story = {
|
|
125
|
+
render: (args) => (
|
|
126
|
+
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
|
|
127
|
+
<Paper {...args} variant="elevation">Elevation (default)</Paper>
|
|
128
|
+
<Paper {...args} variant="outlined">Outlined</Paper>
|
|
129
|
+
</div>
|
|
130
|
+
),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const Elevations: Story = {
|
|
134
|
+
args: { variant: 'elevation' },
|
|
135
|
+
render: (args) => {
|
|
136
|
+
const levels = [0, 1, 2, 3, 4, 6, 8, 12, 16, 24];
|
|
137
|
+
return (
|
|
138
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(140px, 1fr))', gap: 12 }}>
|
|
139
|
+
{levels.map((e) => (
|
|
140
|
+
<Paper key={e} {...args} elevation={e} sx={{ p: 2 }}>
|
|
141
|
+
elevation={e}
|
|
142
|
+
</Paper>
|
|
143
|
+
))}
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const PolymorphicSection: Story = {
|
|
150
|
+
args: { variant: 'outlined', children: 'I render as <section>' },
|
|
151
|
+
render: (args) => (
|
|
152
|
+
<Paper {...args} component="section">
|
|
153
|
+
{args.children}
|
|
154
|
+
</Paper>
|
|
155
|
+
),
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const PolymorphicAnchor: Story = {
|
|
159
|
+
args: { children: 'I render as <a href="/docs">', sx: { p: 2, textDecoration: 'none' } },
|
|
160
|
+
render: (args) => (
|
|
161
|
+
<Paper component="a" href="/docs" sx={args.sx}>
|
|
162
|
+
{args.children}
|
|
163
|
+
</Paper>
|
|
164
|
+
),
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const WithSystemProps: Story = {
|
|
168
|
+
name: 'With system props',
|
|
169
|
+
args: { variant: 'outlined' },
|
|
170
|
+
render: (args) => (
|
|
171
|
+
<Paper {...args} sx={{ p: 2, m: 1, display: 'inline-block', borderRadius: 2 }}>
|
|
172
|
+
Padding, margin, display via system props.
|
|
173
|
+
</Paper>
|
|
174
|
+
),
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const WithSx: Story = {
|
|
178
|
+
args: { variant: 'outlined' },
|
|
179
|
+
render: (args) => (
|
|
180
|
+
<Paper {...args} sx={{ p: 2, borderRadius: 2, borderStyle: 'dashed' }}>
|
|
181
|
+
Custom \`sx\` styling (dashed outline).
|
|
182
|
+
</Paper>
|
|
183
|
+
),
|
|
184
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This.GUI — Paper (polymorphic)
|
|
3
|
+
* Thin wrapper that preserves MUI's own typing and `component` API.
|
|
4
|
+
* Examples:
|
|
5
|
+
* <Paper elevation={3} />
|
|
6
|
+
* <Paper component="section" square variant="outlined" />
|
|
7
|
+
* <Paper component="a" href="/docs" />
|
|
8
|
+
*/
|
|
9
|
+
import MuiPaper from '@mui/material/Paper';
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
// Re-export using MUI's own component type to keep polymorphism and full typing
|
|
12
|
+
const Paper = MuiPaper;
|
|
13
|
+
export type PaperProps = React.ComponentProps<typeof Paper>;
|
|
14
|
+
(Paper as any).displayName = 'Gui.Paper';
|
|
15
|
+
export default Paper;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Section from './Section';
|
|
2
|
+
import type { SectionProps } from './Section.types';
|
|
3
|
+
|
|
4
|
+
export const SectionResolver = {
|
|
5
|
+
type: 'Section',
|
|
6
|
+
component: Section,
|
|
7
|
+
resolve: (props: SectionProps) => <Section {...props} />,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default SectionResolver;
|