@cryptlex/web-components 6.6.6-alpha04 → 6.6.6-alpha07
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/components/data-table-filter.d.ts +3 -6
- package/dist/components/data-table.js +1 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/icons.d.ts +1 -0
- package/dist/components/icons.js +147 -147
- package/dist/components/icons.js.map +1 -1
- package/dist/components/id-search.js +1 -1
- package/dist/components/id-search.js.map +1 -1
- package/dist/components/otpfield.d.ts +7 -0
- package/dist/components/otpfield.js.map +1 -1
- package/dist/components/sidebar.d.ts +71 -0
- package/dist/components/sidebar.js.map +1 -1
- package/dist/utilities/form.d.ts +1 -1
- package/dist/utilities/form.js +1 -1
- package/dist/utilities/form.js.map +1 -1
- package/lib/index.css +236 -4
- package/package.json +18 -17
- package/lib/base.css +0 -25
- package/lib/theme.css +0 -170
- package/lib/utilities.css +0 -85
|
@@ -10,38 +10,109 @@ type SidebarContextProps = {
|
|
|
10
10
|
toggleSidebar: () => void;
|
|
11
11
|
};
|
|
12
12
|
export declare const SidebarContext: import('react').Context<SidebarContextProps | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Get the current sidebar state and controls. Must be inside SidebarProvider.
|
|
15
|
+
* @throws When used outside of SidebarProvider
|
|
16
|
+
*/
|
|
13
17
|
export declare function useSidebar(): SidebarContextProps;
|
|
18
|
+
/**
|
|
19
|
+
* Wraps your app layout and manages sidebar state. Handles keyboard shortcuts (Cmd/Ctrl + /)
|
|
20
|
+
* and mobile vs desktop behavior.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <SidebarProvider>
|
|
24
|
+
* <Sidebar>...</Sidebar>
|
|
25
|
+
* <SidebarOutlet>
|
|
26
|
+
* <main>Your app content</main>
|
|
27
|
+
* </SidebarOutlet>
|
|
28
|
+
* </SidebarProvider>
|
|
29
|
+
*/
|
|
14
30
|
export declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }: React.ComponentProps<'div'> & {
|
|
31
|
+
/** Initial open state. Defaults to true */
|
|
15
32
|
defaultOpen?: boolean;
|
|
33
|
+
/** Control the open state yourself */
|
|
16
34
|
open?: boolean;
|
|
35
|
+
/** Callback when sidebar opens/closes */
|
|
17
36
|
onOpenChange?: (open: boolean) => void;
|
|
18
37
|
}): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
/**
|
|
39
|
+
* The actual sidebar panel. On mobile it becomes a modal dialog.
|
|
40
|
+
*/
|
|
19
41
|
export declare function Sidebar({ side, variant, collapsible, className, children, ...props }: React.ComponentProps<'div'> & {
|
|
42
|
+
/** Where to dock the sidebar. Default: left */
|
|
20
43
|
side?: 'left' | 'right';
|
|
44
|
+
/** Style variant. Default: sidebar */
|
|
21
45
|
variant?: 'sidebar' | 'floating';
|
|
46
|
+
/** How it collapses. Default: offcanvas */
|
|
22
47
|
collapsible?: 'offcanvas' | 'icon' | 'none';
|
|
23
48
|
}): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* Button that toggles the sidebar. Shows arrow icons.
|
|
51
|
+
*/
|
|
24
52
|
export declare function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* Scrollable container for sidebar content
|
|
55
|
+
*/
|
|
25
56
|
export declare function SidebarContent({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
/**
|
|
58
|
+
* Groups related menu items together
|
|
59
|
+
*/
|
|
26
60
|
export declare function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
/**
|
|
62
|
+
* Label for a group.
|
|
63
|
+
*/
|
|
27
64
|
export declare function SidebarGroupLabel({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
/**
|
|
66
|
+
* Content wrapper for a group
|
|
67
|
+
*/
|
|
28
68
|
export declare function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
/**
|
|
70
|
+
* Container for menu items
|
|
71
|
+
*/
|
|
29
72
|
export declare function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>): import("react/jsx-runtime").JSX.Element;
|
|
73
|
+
/**
|
|
74
|
+
* Single menu item wrapper
|
|
75
|
+
*/
|
|
30
76
|
export declare function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>): import("react/jsx-runtime").JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* Extra action button that appears on the right side of menu items
|
|
79
|
+
*/
|
|
31
80
|
export declare function SidebarMenuAction({ className, ...props }: React.ComponentProps<'button'> & {
|
|
81
|
+
/** Only show on hover */
|
|
32
82
|
showOnHover?: boolean;
|
|
33
83
|
}): import("react/jsx-runtime").JSX.Element;
|
|
84
|
+
/**
|
|
85
|
+
* Shows a number badge on menu items. Auto-formats large numbers.
|
|
86
|
+
*/
|
|
34
87
|
export declare function SidebarMenuBadge({ className, number, ...props }: Omit<React.ComponentProps<'div'>, 'children'> & {
|
|
88
|
+
/** The count to display */
|
|
35
89
|
number: number | bigint;
|
|
36
90
|
}): import("react/jsx-runtime").JSX.Element;
|
|
91
|
+
/**
|
|
92
|
+
* Nested submenu container
|
|
93
|
+
*/
|
|
37
94
|
export declare function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>): import("react/jsx-runtime").JSX.Element;
|
|
95
|
+
/**
|
|
96
|
+
* Submenu item wrapper
|
|
97
|
+
*/
|
|
38
98
|
export declare function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>): import("react/jsx-runtime").JSX.Element;
|
|
99
|
+
/**
|
|
100
|
+
* Main menu button. Pass isActive for current page.
|
|
101
|
+
*/
|
|
39
102
|
export declare function SidebarMenuButton({ isActive, tooltip, className, ...props }: React.ComponentProps<'button'> & {
|
|
103
|
+
/** Mark as currently active page */
|
|
40
104
|
isActive?: boolean;
|
|
105
|
+
/** Tooltip when sidebar is collapsed */
|
|
41
106
|
tooltip?: React.ComponentProps<typeof Tooltip>;
|
|
42
107
|
}): import("react/jsx-runtime").JSX.Element;
|
|
108
|
+
/**
|
|
109
|
+
* Button for submenu items
|
|
110
|
+
*/
|
|
43
111
|
export declare function SidebarMenuSubButton({ isActive, className, ...props }: React.ComponentProps<'button'> & {
|
|
44
112
|
isActive?: boolean;
|
|
45
113
|
}): import("react/jsx-runtime").JSX.Element;
|
|
114
|
+
/**
|
|
115
|
+
* The main content area next to the sidebar
|
|
116
|
+
*/
|
|
46
117
|
export declare function SidebarOutlet({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
47
118
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.js","sources":["../../lib/components/sidebar.tsx"],"sourcesContent":["'use client';\nimport { createContext, use, useCallback, useEffect, useMemo, useState } from 'react';\nimport { Button } from '../components/button';\nimport { DialogContent, DialogOverlay, DialogTrigger } from '../components/dialog';\nimport { Tooltip, TooltipTrigger } from '../components/tooltip';\nimport { classNames } from '../utilities/theme';\nimport { useIsMobile } from '../utilities/use-mobile';\nimport { IcLeft, IcRight } from './icons';\n\nconst SIDEBAR_KEYBOARD_SHORTCUT = '/';\n\ntype SidebarContextProps = {\n state: 'expanded' | 'collapsed';\n open: boolean;\n setOpen: (open: boolean) => void;\n openMobile: boolean;\n setOpenMobile: (open: boolean) => void;\n isMobile: boolean;\n toggleSidebar: () => void;\n};\n\nexport const SidebarContext = createContext<SidebarContextProps | null>(null);\n\nexport function useSidebar() {\n const context = use(SidebarContext);\n if (!context) {\n throw new Error('useSidebar must be used within a SidebarProvider.');\n }\n\n return context;\n}\n\nexport function SidebarProvider({\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n className,\n style,\n children,\n ...props\n}: React.ComponentProps<'div'> & {\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}) {\n const isMobile = useIsMobile();\n const [openMobile, setOpenMobile] = useState(false);\n\n // This is the internal state of the sidebar.\n // We use openProp and setOpenProp for control from outside the component.\n const [_open, _setOpen] = useState(defaultOpen);\n const open = openProp ?? _open;\n const setOpen = useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === 'function' ? value(open) : value;\n if (setOpenProp) {\n setOpenProp(openState);\n } else {\n _setOpen(openState);\n }\n },\n [setOpenProp, open]\n );\n\n // Helper to toggle the sidebar.\n const toggleSidebar = useCallback(() => {\n return isMobile ? setOpenMobile(open => !open) : setOpen(open => !open);\n }, [isMobile, setOpen, setOpenMobile]);\n\n // Adds a keyboard shortcut to toggle the sidebar.\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {\n event.preventDefault();\n toggleSidebar();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, [toggleSidebar]);\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = open ? 'expanded' : 'collapsed';\n\n const contextValue = useMemo<SidebarContextProps>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n }),\n [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]\n );\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n className={classNames(\n 'group/sidebar-wrapper flex w-full has-[[data-variant=inset]]:bg-sidebar-background',\n className\n )}\n {...props}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n );\n}\n\nexport function Sidebar({\n side = 'left',\n variant = 'sidebar',\n collapsible = 'offcanvas',\n className,\n children,\n ...props\n}: React.ComponentProps<'div'> & {\n side?: 'left' | 'right';\n variant?: 'sidebar' | 'floating';\n collapsible?: 'offcanvas' | 'icon' | 'none';\n}) {\n const { isMobile, state, openMobile, setOpenMobile } = useSidebar();\n\n if (collapsible === 'none') {\n return (\n <div\n className={classNames(\n 'flex h-full w-[--sidebar-width] flex-col bg-sidebar-background text-sidebar-foreground',\n className\n )}\n {...props}\n >\n {children}\n </div>\n );\n }\n\n if (isMobile) {\n return (\n <DialogTrigger isOpen={openMobile} onOpenChange={setOpenMobile} {...props}>\n <DialogOverlay>\n <DialogContent\n data-sidebar=\"sidebar\"\n data-mobile=\"true\"\n className=\"w-[--sidebar-width] max-h-svh overflow-auto p-0 [&>button]:hidden\"\n side=\"left\"\n >\n {() => <>{children}</>}\n </DialogContent>\n </DialogOverlay>\n </DialogTrigger>\n );\n }\n\n return (\n <div\n className=\"group peer hidden text-sidebar-foreground md:block\"\n data-state={state}\n data-collapsible={state === 'collapsed' ? collapsible : ''}\n data-variant={variant}\n data-side={side}\n >\n {/* This is what handles the sidebar gap on desktop */}\n <div\n className={classNames(\n 'relative w-(--sidebar-width) bg-sidebar-background transition-[width] duration-200 ease-linear',\n 'group-data-[collapsible=offcanvas]:w-0',\n 'group-data-[side=right]:rotate-180',\n variant === 'floating'\n ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]'\n : 'group-data-[collapsible=icon]:w-[--sidebar-width-icon]'\n )}\n />\n <div\n className={classNames(\n 'absolute z-10 hidden w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',\n side === 'left'\n ? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'\n : 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',\n // Adjust the padding for floating variant.\n variant === 'floating'\n ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]'\n : 'group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l',\n className\n )}\n {...props}\n >\n <div\n data-sidebar=\"sidebar\"\n className=\"flex h-full w-full flex-col bg-sidebar-background group-data-[variant=floating]:border group-data-[variant=floating]:border-border\"\n >\n {children}\n </div>\n </div>\n </div>\n );\n}\n\nexport function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {\n const { toggleSidebar, open } = useSidebar();\n\n return (\n <Button\n data-sidebar=\"trigger\"\n variant=\"neutral\"\n size=\"icon\"\n className={'rounded-full'}\n onClick={event => {\n onClick?.(event);\n toggleSidebar();\n }}\n {...props}\n >\n {/* Use transition to rotate a single icon */}\n {open ? <IcLeft /> : <IcRight />}\n </Button>\n );\n}\n\nexport function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-sidebar=\"content\"\n className={classNames(\n 'flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',\n className\n )}\n {...props}\n />\n );\n}\n\nexport function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-sidebar=\"group\"\n className={classNames('relative flex w-full min-w-0 flex-col p-2', className)}\n {...props}\n />\n );\n}\n\nexport function SidebarGroupLabel({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-sidebar=\"group-label\"\n className={classNames(\n 'flex h-input shrink-0 items-center px-2 body-sm font-medium text-sidebar-foreground/70 outline-none ring-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-icon [&>svg]:shrink-0',\n 'group-data-[collapsible=icon]:-mt-input group-data-[collapsible=icon]:opacity-0',\n className\n )}\n {...props}\n />\n );\n}\n\nexport function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {\n return <div data-sidebar=\"group-content\" className={classNames('w-full body-sm', className)} {...props} />;\n}\n\nexport function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {\n return <ul data-sidebar=\"menu\" className={classNames('flex w-full min-w-0 flex-col', className)} {...props} />;\n}\n\nexport function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-sidebar=\"menu-item\"\n className={classNames('group/menu-item relative list-none', className)}\n {...props}\n />\n );\n}\n\nexport function SidebarMenuAction({\n className,\n ...props\n}: React.ComponentProps<'button'> & {\n showOnHover?: boolean;\n}) {\n return (\n <button\n data-sidebar=\"menu-action\"\n className={classNames(\n 'absolute top-0 right-0 btn btn-ghost h-input px-1',\n 'group-data-[collapsible=icon]:hidden',\n className\n )}\n {...props}\n />\n );\n}\n\nexport function SidebarMenuBadge({\n className,\n number,\n ...props\n}: Omit<React.ComponentProps<'div'>, 'children'> & {\n number: number | bigint;\n}) {\n return (\n <div\n data-sidebar=\"menu-badge\"\n className={classNames(\n 'absolute pointer-events-none top-0 right-0 font-300 h-input select-none px-2 flex items-center justify-center body-sm tabular-nums',\n 'group-data-[collapsible=icon]:hidden',\n className\n )}\n {...props}\n >\n {/* Format the number */}\n {new Intl.NumberFormat(navigator.language, { useGrouping: true }).format(number)}\n </div>\n );\n}\n\nexport function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {\n return (\n <ul\n data-sidebar=\"menu-sub\"\n className={classNames(\n 'mx-2 flex min-w-0 flex-col border-l border-border',\n 'group-data-[collapsible=icon]:hidden',\n className\n )}\n {...props}\n />\n );\n}\n\nexport function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) {\n return <li className={classNames('list-none ms-0', className)} {...props} />;\n}\n\n// Common interaction logic for SidebarMenuButton and SidebarMenuSubButton\nexport function SidebarMenuButton({\n isActive = false,\n tooltip,\n className,\n ...props\n}: React.ComponentProps<'button'> & {\n isActive?: boolean;\n tooltip?: React.ComponentProps<typeof Tooltip>;\n}) {\n const { isMobile, state } = useSidebar();\n\n const button = (\n <button\n data-sidebar=\"menu-button\"\n data-selected={isActive}\n className={classNames(\n 'peer/menu-button group-has-[[data-sidebar=menu-action]]/menu-item:pr-input group-data-[collapsible=icon]:!size-icon group-data-[collapsible=icon]:!p-2 ',\n 'btn-tab w-full',\n className\n )}\n {...props}\n />\n );\n\n if (!tooltip) {\n return button;\n }\n\n return (\n <TooltipTrigger>\n {button}\n <Tooltip hidden={state !== 'collapsed' || isMobile} {...tooltip} />\n </TooltipTrigger>\n );\n}\n\nexport function SidebarMenuSubButton({\n isActive,\n className,\n ...props\n}: React.ComponentProps<'button'> & {\n isActive?: boolean;\n}) {\n return (\n <button\n data-sidebar=\"menu-sub-button\"\n data-active={isActive}\n className={classNames(\n '-translate-x-px [&>svg]:text-accent-foreground',\n 'group-data-[collapsible=icon]:hidden',\n 'btn-tab w-full',\n className\n )}\n {...props}\n />\n );\n}\n\nexport function SidebarOutlet({ className, ...props }: React.ComponentProps<'div'>) {\n return <div className={classNames(className, 'w-full overflow-auto')} {...props} />;\n}\n"],"names":["SIDEBAR_KEYBOARD_SHORTCUT","SidebarContext","createContext","useSidebar","context","use","SidebarProvider","defaultOpen","openProp","setOpenProp","className","style","children","props","isMobile","useIsMobile","openMobile","setOpenMobile","useState","_open","_setOpen","open","setOpen","useCallback","value","openState","toggleSidebar","useEffect","handleKeyDown","event","state","contextValue","useMemo","jsx","classNames","Sidebar","side","variant","collapsible","DialogTrigger","DialogOverlay","DialogContent","jsxs","SidebarTrigger","onClick","Button","IcLeft","IcRight","SidebarContent","SidebarGroup","SidebarGroupLabel","SidebarGroupContent","SidebarMenu","SidebarMenuItem","SidebarMenuAction","SidebarMenuBadge","number","SidebarMenuSub","SidebarMenuSubItem","SidebarMenuButton","isActive","tooltip","button","TooltipTrigger","Tooltip","SidebarMenuSubButton","SidebarOutlet"],"mappings":"2nBASA,MAAMA,EAA4B,IAYrBC,EAAiBC,EAA0C,IAAI,EAErE,SAASC,GAAa,CACzB,MAAMC,EAAUC,EAAIJ,CAAc,EAClC,GAAI,CAACG,EACD,MAAM,IAAI,MAAM,mDAAmD,EAGvE,OAAOA,CACX,CAEO,SAASE,GAAgB,CAC5B,YAAAC,EAAc,GACd,KAAMC,EACN,aAAcC,EAC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ib/components/sidebar.tsx"],"sourcesContent":["'use client';\nimport { createContext, use, useCallback, useEffect, useMemo, useState } from 'react';\nimport { Button } from '../components/button';\nimport { DialogContent, DialogOverlay, DialogTrigger } from '../components/dialog';\nimport { Tooltip, TooltipTrigger } from '../components/tooltip';\nimport { classNames } from '../utilities/theme';\nimport { useIsMobile } from '../utilities/use-mobile';\nimport { IcLeft, IcRight } from './icons';\n\nconst SIDEBAR_KEYBOARD_SHORTCUT = '/';\n\ntype SidebarContextProps = {\n state: 'expanded' | 'collapsed';\n open: boolean;\n setOpen: (open: boolean) => void;\n openMobile: boolean;\n setOpenMobile: (open: boolean) => void;\n isMobile: boolean;\n toggleSidebar: () => void;\n};\n\nexport const SidebarContext = createContext<SidebarContextProps | null>(null);\n\n/**\n * Get the current sidebar state and controls. Must be inside SidebarProvider.\n * @throws When used outside of SidebarProvider\n */\nexport function useSidebar() {\n const context = use(SidebarContext);\n if (!context) {\n throw new Error('useSidebar must be used within a SidebarProvider.');\n }\n\n return context;\n}\n\n/**\n * Wraps your app layout and manages sidebar state. Handles keyboard shortcuts (Cmd/Ctrl + /)\n * and mobile vs desktop behavior.\n *\n * @example\n * <SidebarProvider>\n * <Sidebar>...</Sidebar>\n * <SidebarOutlet>\n * <main>Your app content</main>\n * </SidebarOutlet>\n * </SidebarProvider>\n */\nexport function SidebarProvider({\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n className,\n style,\n children,\n ...props\n}: React.ComponentProps<'div'> & {\n /** Initial open state. Defaults to true */\n defaultOpen?: boolean;\n /** Control the open state yourself */\n open?: boolean;\n /** Callback when sidebar opens/closes */\n onOpenChange?: (open: boolean) => void;\n}) {\n const isMobile = useIsMobile();\n const [openMobile, setOpenMobile] = useState(false);\n\n // This is the internal state of the sidebar.\n // We use openProp and setOpenProp for control from outside the component.\n const [_open, _setOpen] = useState(defaultOpen);\n const open = openProp ?? _open;\n const setOpen = useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === 'function' ? value(open) : value;\n if (setOpenProp) {\n setOpenProp(openState);\n } else {\n _setOpen(openState);\n }\n },\n [setOpenProp, open]\n );\n\n // Helper to toggle the sidebar.\n const toggleSidebar = useCallback(() => {\n return isMobile ? setOpenMobile(open => !open) : setOpen(open => !open);\n }, [isMobile, setOpen, setOpenMobile]);\n\n // Adds a keyboard shortcut to toggle the sidebar.\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {\n event.preventDefault();\n toggleSidebar();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, [toggleSidebar]);\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = open ? 'expanded' : 'collapsed';\n\n const contextValue = useMemo<SidebarContextProps>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n }),\n [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]\n );\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n className={classNames(\n 'group/sidebar-wrapper flex w-full has-[[data-variant=inset]]:bg-sidebar-background',\n className\n )}\n {...props}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n );\n}\n\n/**\n * The actual sidebar panel. On mobile it becomes a modal dialog.\n */\nexport function Sidebar({\n side = 'left',\n variant = 'sidebar',\n collapsible = 'offcanvas',\n className,\n children,\n ...props\n}: React.ComponentProps<'div'> & {\n /** Where to dock the sidebar. Default: left */\n side?: 'left' | 'right';\n /** Style variant. Default: sidebar */\n variant?: 'sidebar' | 'floating';\n /** How it collapses. Default: offcanvas */\n collapsible?: 'offcanvas' | 'icon' | 'none';\n}) {\n const { isMobile, state, openMobile, setOpenMobile } = useSidebar();\n\n if (collapsible === 'none') {\n return (\n <div\n className={classNames(\n 'flex h-full w-[--sidebar-width] flex-col bg-sidebar-background text-sidebar-foreground',\n className\n )}\n {...props}\n >\n {children}\n </div>\n );\n }\n\n if (isMobile) {\n return (\n <DialogTrigger isOpen={openMobile} onOpenChange={setOpenMobile} {...props}>\n <DialogOverlay>\n <DialogContent\n data-sidebar=\"sidebar\"\n data-mobile=\"true\"\n className=\"w-[--sidebar-width] max-h-svh overflow-auto p-0 [&>button]:hidden\"\n side=\"left\"\n >\n {() => <>{children}</>}\n </DialogContent>\n </DialogOverlay>\n </DialogTrigger>\n );\n }\n\n return (\n <div\n className=\"group peer hidden text-sidebar-foreground md:block\"\n data-state={state}\n data-collapsible={state === 'collapsed' ? collapsible : ''}\n data-variant={variant}\n data-side={side}\n >\n {/* This is what handles the sidebar gap on desktop */}\n <div\n className={classNames(\n 'relative w-(--sidebar-width) bg-sidebar-background transition-[width] duration-200 ease-linear',\n 'group-data-[collapsible=offcanvas]:w-0',\n 'group-data-[side=right]:rotate-180',\n variant === 'floating'\n ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]'\n : 'group-data-[collapsible=icon]:w-[--sidebar-width-icon]'\n )}\n />\n <div\n className={classNames(\n 'absolute z-10 hidden w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',\n side === 'left'\n ? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'\n : 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',\n // Adjust the padding for floating variant.\n variant === 'floating'\n ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]'\n : 'group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l',\n className\n )}\n {...props}\n >\n <div\n data-sidebar=\"sidebar\"\n className=\"flex h-full w-full flex-col bg-sidebar-background group-data-[variant=floating]:border group-data-[variant=floating]:border-border\"\n >\n {children}\n </div>\n </div>\n </div>\n );\n}\n\n/**\n * Button that toggles the sidebar. Shows arrow icons.\n */\nexport function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {\n const { toggleSidebar, open } = useSidebar();\n\n return (\n <Button\n data-sidebar=\"trigger\"\n variant=\"neutral\"\n size=\"icon\"\n className={'rounded-full'}\n onClick={event => {\n onClick?.(event);\n toggleSidebar();\n }}\n {...props}\n >\n {/* Use transition to rotate a single icon */}\n {open ? <IcLeft /> : <IcRight />}\n </Button>\n );\n}\n\n/**\n * Scrollable container for sidebar content\n */\nexport function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-sidebar=\"content\"\n className={classNames(\n 'flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',\n className\n )}\n {...props}\n />\n );\n}\n\n/**\n * Groups related menu items together\n */\nexport function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-sidebar=\"group\"\n className={classNames('relative flex w-full min-w-0 flex-col p-2', className)}\n {...props}\n />\n );\n}\n\n/**\n * Label for a group.\n */\nexport function SidebarGroupLabel({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-sidebar=\"group-label\"\n className={classNames(\n 'flex h-input shrink-0 items-center px-2 body-sm font-medium text-sidebar-foreground/70 outline-none ring-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-icon [&>svg]:shrink-0',\n 'group-data-[collapsible=icon]:-mt-input group-data-[collapsible=icon]:opacity-0',\n className\n )}\n {...props}\n />\n );\n}\n\n/**\n * Content wrapper for a group\n */\nexport function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {\n return <div data-sidebar=\"group-content\" className={classNames('w-full body-sm', className)} {...props} />;\n}\n\n/**\n * Container for menu items\n */\nexport function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {\n return <ul data-sidebar=\"menu\" className={classNames('flex w-full min-w-0 flex-col', className)} {...props} />;\n}\n\n/**\n * Single menu item wrapper\n */\nexport function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-sidebar=\"menu-item\"\n className={classNames('group/menu-item relative list-none', className)}\n {...props}\n />\n );\n}\n\n/**\n * Extra action button that appears on the right side of menu items\n */\nexport function SidebarMenuAction({\n className,\n ...props\n}: React.ComponentProps<'button'> & {\n /** Only show on hover */\n showOnHover?: boolean;\n}) {\n return (\n <button\n data-sidebar=\"menu-action\"\n className={classNames(\n 'absolute top-0 right-0 btn btn-ghost h-input px-1',\n 'group-data-[collapsible=icon]:hidden',\n className\n )}\n {...props}\n />\n );\n}\n\n/**\n * Shows a number badge on menu items. Auto-formats large numbers.\n */\nexport function SidebarMenuBadge({\n className,\n number,\n ...props\n}: Omit<React.ComponentProps<'div'>, 'children'> & {\n /** The count to display */\n number: number | bigint;\n}) {\n return (\n <div\n data-sidebar=\"menu-badge\"\n className={classNames(\n 'absolute pointer-events-none top-0 right-0 font-300 h-input select-none px-2 flex items-center justify-center body-sm tabular-nums',\n 'group-data-[collapsible=icon]:hidden',\n className\n )}\n {...props}\n >\n {/* Format the number */}\n {new Intl.NumberFormat(navigator.language, { useGrouping: true }).format(number)}\n </div>\n );\n}\n\n/**\n * Nested submenu container\n */\nexport function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {\n return (\n <ul\n data-sidebar=\"menu-sub\"\n className={classNames(\n 'mx-2 flex min-w-0 flex-col border-l border-border',\n 'group-data-[collapsible=icon]:hidden',\n className\n )}\n {...props}\n />\n );\n}\n\n/**\n * Submenu item wrapper\n */\nexport function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) {\n return <li className={classNames('list-none ms-0', className)} {...props} />;\n}\n\n// Common interaction logic for SidebarMenuButton and SidebarMenuSubButton\n/**\n * Main menu button. Pass isActive for current page.\n */\nexport function SidebarMenuButton({\n isActive = false,\n tooltip,\n className,\n ...props\n}: React.ComponentProps<'button'> & {\n /** Mark as currently active page */\n isActive?: boolean;\n /** Tooltip when sidebar is collapsed */\n tooltip?: React.ComponentProps<typeof Tooltip>;\n}) {\n const { isMobile, state } = useSidebar();\n\n const button = (\n <button\n data-sidebar=\"menu-button\"\n data-selected={isActive}\n className={classNames(\n 'peer/menu-button group-has-[[data-sidebar=menu-action]]/menu-item:pr-input group-data-[collapsible=icon]:!size-icon group-data-[collapsible=icon]:!p-2 ',\n 'btn-tab w-full',\n className\n )}\n {...props}\n />\n );\n\n if (!tooltip) {\n return button;\n }\n\n return (\n <TooltipTrigger>\n {button}\n <Tooltip hidden={state !== 'collapsed' || isMobile} {...tooltip} />\n </TooltipTrigger>\n );\n}\n\n/**\n * Button for submenu items\n */\nexport function SidebarMenuSubButton({\n isActive,\n className,\n ...props\n}: React.ComponentProps<'button'> & {\n isActive?: boolean;\n}) {\n return (\n <button\n data-sidebar=\"menu-sub-button\"\n data-active={isActive}\n className={classNames(\n '-translate-x-px [&>svg]:text-accent-foreground',\n 'group-data-[collapsible=icon]:hidden',\n 'btn-tab w-full',\n className\n )}\n {...props}\n />\n );\n}\n\n/**\n * The main content area next to the sidebar\n */\nexport function SidebarOutlet({ className, ...props }: React.ComponentProps<'div'>) {\n return <div className={classNames(className, 'w-full overflow-auto')} {...props} />;\n}\n"],"names":["SIDEBAR_KEYBOARD_SHORTCUT","SidebarContext","createContext","useSidebar","context","use","SidebarProvider","defaultOpen","openProp","setOpenProp","className","style","children","props","isMobile","useIsMobile","openMobile","setOpenMobile","useState","_open","_setOpen","open","setOpen","useCallback","value","openState","toggleSidebar","useEffect","handleKeyDown","event","state","contextValue","useMemo","jsx","classNames","Sidebar","side","variant","collapsible","DialogTrigger","DialogOverlay","DialogContent","jsxs","SidebarTrigger","onClick","Button","IcLeft","IcRight","SidebarContent","SidebarGroup","SidebarGroupLabel","SidebarGroupContent","SidebarMenu","SidebarMenuItem","SidebarMenuAction","SidebarMenuBadge","number","SidebarMenuSub","SidebarMenuSubItem","SidebarMenuButton","isActive","tooltip","button","TooltipTrig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A,CACG,eAAa,kBACb,cAAa2B,EACb,UAAW1B,EACP,iDACA,uCACA,iBACAxB,CAAA,EAEH,GAAGG,CAAA,CAAA,CAGhB,CAKO,SAASqD,GAAc,CAAE,UAAAxD,EAAW,GAAGG,GAAsC,CAChF,OAAOoB,EAAC,OAAI,UAAWC,EAAWxB,EAAW,sBAAsB,EAAI,GAAGG,EAAO,CACrF"}
|
package/dist/utilities/form.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ type FieldContextProps = {
|
|
|
7
7
|
* @param {boolean} disabled - The disabled prop passed to the component
|
|
8
8
|
* @returns The field context with disabled state properly managed
|
|
9
9
|
*/
|
|
10
|
-
export declare
|
|
10
|
+
export declare function useTfFieldContext<T>({ disabled }: FieldContextProps): FieldApi<any, string, T, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>;
|
|
11
11
|
/** Utility type to simplify FormApi usage */
|
|
12
12
|
export type AppFormApi<TValues> = FormApi<TValues, any, any, any, any, any, any, any, any, any>;
|
|
13
13
|
/**
|
package/dist/utilities/form.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import o from"react";import{useFieldContext as r}from"./form-context.js";import"@tanstack/react-form";
|
|
1
|
+
import o from"react";import{useFieldContext as r}from"./form-context.js";import"@tanstack/react-form";function l({disabled:e}){const t=r();return o.useEffect(()=>{t.setMeta(n=>({...n,disabled:!!e}))},[e,t]),t}function d(e){return async({formApi:t})=>{const n=i(t.state.values,t);await e({values:n,formApi:t})}}function i(e,t){const n={};for(const s in e)t.getFieldMeta(s)?.disabled||(n[s]=e[s]);return n}function m(e){return e?.state.meta.errors.map(t=>t?.message).join(",")}export{m as getFieldErrorMessage,d as tfOnSubmit,l as useTfFieldContext};
|
|
2
2
|
//# sourceMappingURL=form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.js","sources":["../../lib/utilities/form.tsx"],"sourcesContent":["import { type AnyFieldMeta, type FieldApi, type FormApi } from '@tanstack/react-form';\nimport React from 'react';\nimport { useFieldContext } from './form-context';\n\ntype FieldContextProps = {\n disabled?: boolean;\n};\n\n/**\n * Custom hook to handle disabled state for form fields\n * @param {boolean} disabled - The disabled prop passed to the component\n * @returns The field context with disabled state properly managed\n */\nexport
|
|
1
|
+
{"version":3,"file":"form.js","sources":["../../lib/utilities/form.tsx"],"sourcesContent":["import { type AnyFieldMeta, type FieldApi, type FormApi } from '@tanstack/react-form';\nimport React from 'react';\nimport { useFieldContext } from './form-context';\n\ntype FieldContextProps = {\n disabled?: boolean;\n};\n\n/**\n * Custom hook to handle disabled state for form fields\n * @param {boolean} disabled - The disabled prop passed to the component\n * @returns The field context with disabled state properly managed\n */\nexport function useTfFieldContext<T>({ disabled }: FieldContextProps) {\n const field = useFieldContext<T>();\n\n React.useEffect(() => {\n field.setMeta(meta => ({\n ...meta,\n disabled: !!disabled,\n }));\n }, [disabled, field]);\n\n return field;\n}\n\n/** Utility type to simplify FormApi usage */\nexport type AppFormApi<TValues> = FormApi<TValues, any, any, any, any, any, any, any, any, any>;\n\n/**\n * Utility function to submit a form with a handler that receives the values and the formApi.\n * @param onSubmit - The handler function to call with the values and the formApi.\n * @returns A function that can be used to submit the form. It will filter out disabled fields from the values.\n */\nexport function tfOnSubmit<TValues>(\n onSubmit: ({ values, formApi }: { values: TValues; formApi: AppFormApi<TValues> }) => Promise<any> | any\n) {\n return async ({ formApi }: { formApi: AppFormApi<TValues> }): Promise<any> => {\n const values = pickEnabledFields(formApi.state.values, formApi);\n\n await onSubmit({ values, formApi });\n };\n}\nfunction pickEnabledFields<TValues>(rawValues: TValues, formApi: AppFormApi<TValues>): TValues {\n const result: TValues = {} as TValues;\n\n //TODO: Nested objects are not supported yet\n for (const key in rawValues) {\n const meta = formApi.getFieldMeta(key) as AnyFieldMeta & {\n disabled?: boolean;\n };\n if (!meta?.disabled) {\n result[key] = rawValues[key];\n }\n }\n\n return result;\n}\n\nexport function getFieldErrorMessage(\n field: FieldApi<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>\n): string {\n return field?.state.meta.errors.map(e => e?.message).join(',');\n}\n"],"names":["useTfFieldContext","disabled","field","useFieldContext","React","meta","tfOnSubmit","onSubmit","formApi","values","pickEnabledFields","rawValues","result","key","getFieldErrorMessage","e"],"mappings":"sGAaO,SAASA,EAAqB,CAAE,SAAAC,GAA+B,CAClE,MAAMC,EAAQC,EAAA,EAEd,OAAAC,EAAM,UAAU,IAAM,CAClBF,EAAM,QAAQG,IAAS,CACnB,GAAGA,EACH,SAAU,CAAC,CAACJ,CAAA,EACd,CACN,EAAG,CAACA,EAAUC,CAAK,CAAC,EAEbA,CACX,CAUO,SAASI,EACZC,EACF,CACE,MAAO,OAAO,CAAE,QAAAC,KAA8D,CAC1E,MAAMC,EAASC,EAAkBF,EAAQ,MAAM,OAAQA,CAAO,EAE9D,MAAMD,EAAS,CAAE,OAAAE,EAAQ,QAAAD,EAAS,CACtC,CACJ,CACA,SAASE,EAA2BC,EAAoBH,EAAuC,CAC3F,MAAMI,EAAkB,CAAA,EAGxB,UAAWC,KAAOF,EACDH,EAAQ,aAAaK,CAAG,GAG1B,WACPD,EAAOC,CAAG,EAAIF,EAAUE,CAAG,GAInC,OAAOD,CACX,CAEO,SAASE,EACZZ,EACM,CACN,OAAOA,GAAO,MAAM,KAAK,OAAO,OAASa,GAAG,OAAO,EAAE,KAAK,GAAG,CACjE"}
|
package/lib/index.css
CHANGED
|
@@ -1,7 +1,239 @@
|
|
|
1
1
|
@import 'tailwindcss';
|
|
2
|
-
@import 'tw-animate-css';
|
|
3
2
|
@import './tokens.css';
|
|
4
|
-
|
|
3
|
+
/** https://tailwindcss.com/docs/theme#theme-variable-namespaces */
|
|
4
|
+
@theme inline {
|
|
5
|
+
/* Radius */
|
|
6
|
+
--radius-*: initial;
|
|
7
|
+
|
|
8
|
+
/* Text Sizes */
|
|
9
|
+
/* Reset all default text sizes */
|
|
10
|
+
--text-*: initial;
|
|
11
|
+
|
|
12
|
+
/* No shadows needed so far, just don't use them. */
|
|
13
|
+
--shadow-*: initial;
|
|
14
|
+
|
|
15
|
+
/* Colors */
|
|
16
|
+
--color-*: initial;
|
|
17
|
+
--color-primary-1: var(--primary-1);
|
|
18
|
+
--color-primary-2: var(--primary-2);
|
|
19
|
+
--color-primary-3: var(--primary-3);
|
|
20
|
+
--color-primary-4: var(--primary-4);
|
|
21
|
+
--color-primary-5: var(--primary-5);
|
|
22
|
+
--color-primary-6: var(--primary-6);
|
|
23
|
+
--color-primary-7: var(--primary-7);
|
|
24
|
+
--color-primary-8: var(--primary-8);
|
|
25
|
+
--color-primary-9: var(--primary-9);
|
|
26
|
+
--color-primary-10: var(--primary-10);
|
|
27
|
+
|
|
28
|
+
--color-secondary-1: var(--secondary-1);
|
|
29
|
+
--color-secondary-2: var(--secondary-2);
|
|
30
|
+
--color-secondary-3: var(--secondary-3);
|
|
31
|
+
--color-secondary-4: var(--secondary-4);
|
|
32
|
+
--color-secondary-5: var(--secondary-5);
|
|
33
|
+
--color-secondary-6: var(--secondary-6);
|
|
34
|
+
--color-secondary-7: var(--secondary-7);
|
|
35
|
+
--color-secondary-8: var(--secondary-8);
|
|
36
|
+
--color-secondary-9: var(--secondary-9);
|
|
37
|
+
--color-secondary-10: var(--secondary-10);
|
|
38
|
+
|
|
39
|
+
--color-neutral-1: var(--neutral-1);
|
|
40
|
+
--color-neutral-2: var(--neutral-2);
|
|
41
|
+
--color-neutral-3: var(--neutral-3);
|
|
42
|
+
--color-neutral-4: var(--neutral-4);
|
|
43
|
+
--color-neutral-5: var(--neutral-5);
|
|
44
|
+
--color-neutral-6: var(--neutral-6);
|
|
45
|
+
--color-neutral-7: var(--neutral-7);
|
|
46
|
+
--color-neutral-8: var(--neutral-8);
|
|
47
|
+
--color-neutral-9: var(--neutral-9);
|
|
48
|
+
--color-neutral-10: var(--neutral-10);
|
|
49
|
+
|
|
50
|
+
--color-destructive-1: var(--destructive-1);
|
|
51
|
+
--color-destructive-2: var(--destructive-2);
|
|
52
|
+
--color-destructive-3: var(--destructive-3);
|
|
53
|
+
--color-destructive-4: var(--destructive-4);
|
|
54
|
+
--color-destructive-5: var(--destructive-5);
|
|
55
|
+
--color-destructive-6: var(--destructive-6);
|
|
56
|
+
--color-destructive-7: var(--destructive-7);
|
|
57
|
+
--color-destructive-8: var(--destructive-8);
|
|
58
|
+
--color-destructive-9: var(--destructive-9);
|
|
59
|
+
--color-destructive-10: var(--destructive-10);
|
|
60
|
+
|
|
61
|
+
--color-success-1: var(--success-1);
|
|
62
|
+
--color-success-2: var(--success-2);
|
|
63
|
+
--color-success-3: var(--success-3);
|
|
64
|
+
--color-success-4: var(--success-4);
|
|
65
|
+
--color-success-5: var(--success-5);
|
|
66
|
+
--color-success-6: var(--success-6);
|
|
67
|
+
--color-success-7: var(--success-7);
|
|
68
|
+
--color-success-8: var(--success-8);
|
|
69
|
+
--color-success-9: var(--success-9);
|
|
70
|
+
--color-success-10: var(--success-10);
|
|
71
|
+
|
|
72
|
+
--color-background: var(--color-neutral-3);
|
|
73
|
+
--color-elevation-1: var(--color-neutral-2);
|
|
74
|
+
--color-elevation-2: var(--color-neutral-1);
|
|
75
|
+
|
|
76
|
+
--color-foreground: var(--color-neutral-8);
|
|
77
|
+
--color-card: var(--color-elevation-1);
|
|
78
|
+
--color-card-foreground: var(--color-foreground);
|
|
79
|
+
/* Assuming popovers only show up over cards ??? */
|
|
80
|
+
--color-popover: var(--color-elevation-2);
|
|
81
|
+
--color-popover-foreground: var(--color-foreground);
|
|
82
|
+
|
|
83
|
+
--color-primary: var(--color-primary-7);
|
|
84
|
+
--color-primary-foreground: var(--color-primary-2);
|
|
85
|
+
--color-secondary: var(--color-secondary-7);
|
|
86
|
+
--color-secondary-foreground: var(--color-secondary-2);
|
|
87
|
+
--color-muted: var(--color-neutral-7);
|
|
88
|
+
--color-muted-foreground: var(--color-neutral-4);
|
|
89
|
+
--color-accent: var(--color-neutral-7);
|
|
90
|
+
--color-accent-foreground: var(--color-neutral-4);
|
|
91
|
+
--color-destructive: var(--color-destructive-7);
|
|
92
|
+
--color-destructive-foreground: var(--color-destructive-2);
|
|
93
|
+
--color-success: var(--color-success-7);
|
|
94
|
+
--color-success-foreground: var(--color-success-2);
|
|
95
|
+
|
|
96
|
+
--color-border: var(--color-neutral-4);
|
|
97
|
+
--color-input: var(--color-border);
|
|
98
|
+
--color-ring: var(--color-neutral-5);
|
|
99
|
+
|
|
100
|
+
--color-chart-1: var(--color-primary-5);
|
|
101
|
+
--color-chart-2: var(--color-primary-4);
|
|
102
|
+
--color-chart-3: var(--color-secondary-5);
|
|
103
|
+
--color-chart-4: var(--color-secondary-4);
|
|
104
|
+
--color-chart-5: var(--color-secondary-2);
|
|
105
|
+
|
|
106
|
+
--color-sidebar-background: var(--color-elevation-1);
|
|
107
|
+
--color-sidebar-foreground: var(--color-foreground);
|
|
108
|
+
|
|
109
|
+
--spacing-input: --spacing(8);
|
|
110
|
+
--spacing-icon: --spacing(4);
|
|
111
|
+
--spacing-table: --spacing(100);
|
|
112
|
+
|
|
113
|
+
--sidebar-width: var(--container-3xs);
|
|
114
|
+
--sidebar-width-mobile: var(--container-2xs);
|
|
115
|
+
--sidebar-width-icon: --spacing(12);
|
|
116
|
+
|
|
117
|
+
/* Header nav */
|
|
118
|
+
--spacing-header: --spacing(12);
|
|
119
|
+
/* Helper for using sidebar with header */
|
|
120
|
+
--spacing-sidebar: calc(100svh - var(--spacing-header));
|
|
121
|
+
|
|
122
|
+
/* Minimum length for fluid grid containers */
|
|
123
|
+
--fluid-grid-min: var(--container-3xs);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@import 'tw-animate-css';
|
|
5
127
|
@import 'tw-type-css';
|
|
6
|
-
|
|
7
|
-
@
|
|
128
|
+
|
|
129
|
+
@utility link {
|
|
130
|
+
@apply text-primary/70 focus:text-primary hover:text-primary;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Fluid grid with minimum width */
|
|
134
|
+
@utility grid-fluid {
|
|
135
|
+
@apply grid grid-cols-[repeat(auto-fill,_minmax(var(--fluid-grid-min),_1fr))] gap-icon;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@utility focus-ring {
|
|
139
|
+
@apply data-[focus-visible]:outline-none focus-visible:outline-none data-[focus-visible]:ring-1 data-[focus-visible]:ring-ring data-[focus-visible]:ring-offset-2 focus-visible:outline-hidden focus-visible:ring-offset-2 focus-visible:ring-1 focus-visible:ring-ring;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@utility disabled-muted {
|
|
143
|
+
@apply disabled:cursor-not-allowed disabled:opacity-70 aria-disabled:cursor-not-allowed aria-disabled:opacity-70 data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none data-[disabled]:opacity-70;
|
|
144
|
+
}
|
|
145
|
+
@utility input {
|
|
146
|
+
@apply border border-input bg-popover px-icon py-2 body-sm placeholder:text-muted-foreground disabled-muted focus-ring;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* A base set of classes for elements that can be clicked */
|
|
150
|
+
@utility btn {
|
|
151
|
+
@apply inline-flex gap-1 data-[disabled]:pointer-events-none text-ellipsis overflow-hidden items-center justify-center font-medium transition-colors cursor-pointer ring-offset-background [&_svg:not([class*='size-'])]:size-icon shrink-0 [&_svg]:shrink-0 leading-none outline-none no-underline whitespace-nowrap select-none disabled-muted focus-ring;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@utility btn-link {
|
|
155
|
+
@apply btn-ghost underline underline-offset-2;
|
|
156
|
+
}
|
|
157
|
+
@utility btn-primary {
|
|
158
|
+
@apply border border-primary text-primary bg-primary/10 hover:bg-primary/20 data-[hovered]:bg-primary/20 focus:bg-primary/20 data-[focused]:bg-primary/20;
|
|
159
|
+
}
|
|
160
|
+
@utility btn-destructive {
|
|
161
|
+
@apply border border-destructive text-destructive bg-destructive/10 hover:bg-destructive/20 data-[hovered]:bg-destructive/20 focus:bg-destructive/20 data-[focused]:bg-destructive/20;
|
|
162
|
+
}
|
|
163
|
+
@utility btn-neutral {
|
|
164
|
+
@apply border border-input text-accent bg-accent/10 hover:bg-accent/20 data-[hovered]:bg-accent/20 focus:bg-accent/20 data-[focused]:bg-accent/20;
|
|
165
|
+
}
|
|
166
|
+
@utility btn-secondary {
|
|
167
|
+
@apply border border-secondary text-secondary bg-secondary/10 hover:bg-secondary/20 data-[hovered]:bg-secondary/20 focus:bg-secondary/20 data-[focused]:bg-secondary/20;
|
|
168
|
+
}
|
|
169
|
+
@utility btn-ghost {
|
|
170
|
+
@apply bg-transparent focus:bg-accent/20 data-[focused]:bg-accent/20 hover:bg-accent/20 data-[hovered]:bg-accent/20;
|
|
171
|
+
}
|
|
172
|
+
@utility btn-tab {
|
|
173
|
+
@apply truncate btn btn-ghost input-dim font-normal text-accent justify-start data-[selected=true]:bg-primary/20 data-[selected=true]:font-medium data-[selected=true]:text-primary;
|
|
174
|
+
}
|
|
175
|
+
/* Dimensions for a standard input */
|
|
176
|
+
@utility input-dim {
|
|
177
|
+
@apply h-input px-icon py-2 body-sm leading-none;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@utility form-column {
|
|
181
|
+
@apply flex flex-col gap-input;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@utility form-field {
|
|
185
|
+
@apply flex flex-col gap-1;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@utility steps {
|
|
189
|
+
@apply ps-0;
|
|
190
|
+
> ol {
|
|
191
|
+
counter-reset: steps-counter;
|
|
192
|
+
@apply list-none ps-0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
> ol > li {
|
|
196
|
+
counter-increment: steps-counter;
|
|
197
|
+
@apply relative ps-input pb-2 min-h-12 list-none;
|
|
198
|
+
}
|
|
199
|
+
> ol > li + li {
|
|
200
|
+
@apply mt-0;
|
|
201
|
+
}
|
|
202
|
+
> ol > li::before {
|
|
203
|
+
content: counter(steps-counter);
|
|
204
|
+
@apply absolute top-0 start-0 size-icon leading-icon bg-accent text-accent-foreground body-sm font-semibold text-center rounded-full;
|
|
205
|
+
}
|
|
206
|
+
> ol > li::after {
|
|
207
|
+
content: '';
|
|
208
|
+
@apply absolute bg-border w-[1px] top-5 h-1/2 left-2 py-1;
|
|
209
|
+
}
|
|
210
|
+
> ol > li:last-child::after {
|
|
211
|
+
@apply content-none;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@layer base {
|
|
216
|
+
* {
|
|
217
|
+
@apply border-border outline-ring/50;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
body {
|
|
221
|
+
@apply bg-background text-foreground;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.tw-prose a {
|
|
225
|
+
@apply link;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
*::-webkit-scrollbar {
|
|
229
|
+
@apply size-2;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
*::-webkit-scrollbar-track {
|
|
233
|
+
@apply bg-card rounded-none;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
*::-webkit-scrollbar-thumb {
|
|
237
|
+
@apply bg-foreground/70 hover:bg-foreground;
|
|
238
|
+
}
|
|
239
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptlex/web-components",
|
|
3
|
-
"version": "6.6.6-
|
|
3
|
+
"version": "6.6.6-alpha07",
|
|
4
4
|
"description": "React component library for Cryptlex web applications",
|
|
5
5
|
"author": "Cryptlex",
|
|
6
6
|
"type": "module",
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
"./components/*": {
|
|
10
10
|
"import": "./dist/components/*.js",
|
|
11
|
-
"types": "./dist/components/*.d.ts"
|
|
11
|
+
"types": "./dist/components/*.d.ts",
|
|
12
|
+
"default": "./dist/components/*.js"
|
|
12
13
|
},
|
|
13
14
|
"./utilities/*": {
|
|
14
15
|
"import": "./dist/utilities/*.js",
|
|
15
|
-
"types": "./dist/utilities/*.d.ts"
|
|
16
|
+
"types": "./dist/utilities/*.d.ts",
|
|
17
|
+
"default": "./dist/utilities/*.js"
|
|
16
18
|
},
|
|
17
19
|
"./*.css": "./lib/*.css"
|
|
18
20
|
},
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
"@dnd-kit/core": "6.3.1",
|
|
48
50
|
"@dnd-kit/sortable": "10.0.0",
|
|
49
51
|
"@dnd-kit/utilities": "3.2.2",
|
|
50
|
-
"@internationalized/date": "3.
|
|
52
|
+
"@internationalized/date": "3.9.0",
|
|
51
53
|
"@tanstack/react-form": "1.6.3",
|
|
52
54
|
"@tanstack/react-query": "5.62.3",
|
|
53
55
|
"@tanstack/react-table": "8.20.5",
|
|
@@ -70,12 +72,13 @@
|
|
|
70
72
|
},
|
|
71
73
|
"devDependencies": {
|
|
72
74
|
"@rollup/plugin-node-resolve": "16.0.1",
|
|
73
|
-
"@storybook/addon-a11y": "9.1.
|
|
74
|
-
"@storybook/addon-docs": "9.1.
|
|
75
|
-
"@storybook/addon-links": "9.1.
|
|
76
|
-
"@storybook/addon-onboarding": "9.1.
|
|
77
|
-
"@storybook/addon-vitest": "9.1.
|
|
78
|
-
"@storybook/react-vite": "9.1.
|
|
75
|
+
"@storybook/addon-a11y": "9.1.4",
|
|
76
|
+
"@storybook/addon-docs": "9.1.4",
|
|
77
|
+
"@storybook/addon-links": "9.1.4",
|
|
78
|
+
"@storybook/addon-onboarding": "9.1.4",
|
|
79
|
+
"@storybook/addon-vitest": "9.1.4",
|
|
80
|
+
"@storybook/react-vite": "9.1.4",
|
|
81
|
+
"@tailwindcss/cli": "4.1.12",
|
|
79
82
|
"@tailwindcss/vite": "4.1.12",
|
|
80
83
|
"@types/node": "^22.7.8",
|
|
81
84
|
"@types/react": "^19.1.0",
|
|
@@ -85,22 +88,20 @@
|
|
|
85
88
|
"@vitest/coverage-v8": "^3.2.4",
|
|
86
89
|
"husky": "^9.1.7",
|
|
87
90
|
"lint-staged": "^16.1.4",
|
|
88
|
-
"lucide-react": "0.
|
|
91
|
+
"lucide-react": "0.541.0",
|
|
89
92
|
"playwright": "^1.55.0",
|
|
90
93
|
"prettier": "3.6.2",
|
|
91
94
|
"rollup-preserve-directives": "1.1.3",
|
|
92
|
-
"sass": "1.
|
|
93
|
-
"storybook": "9.1.
|
|
94
|
-
"typescript": "5.
|
|
95
|
-
"
|
|
96
|
-
"vite": "7.0.6",
|
|
95
|
+
"sass": "1.89.2",
|
|
96
|
+
"storybook": "9.1.4",
|
|
97
|
+
"typescript": "5.9.2",
|
|
98
|
+
"vite": "7.1.4",
|
|
97
99
|
"vite-plugin-dts": "4.5.4",
|
|
98
100
|
"vite-tsconfig-paths": "5.1.4",
|
|
99
101
|
"vitest": "^3.2.4"
|
|
100
102
|
},
|
|
101
103
|
"scripts": {
|
|
102
104
|
"build": "tsc && vite build",
|
|
103
|
-
"lint": "eslint .",
|
|
104
105
|
"storybook": "storybook dev -p 6006 --no-open",
|
|
105
106
|
"build:storybook": "storybook build",
|
|
106
107
|
"build:tokens": "sass --no-source-map ./lib/tokens.scss ./lib/tokens.css",
|
package/lib/base.css
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
@layer base {
|
|
2
|
-
* {
|
|
3
|
-
@apply border-border outline-ring/50;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
body {
|
|
7
|
-
@apply bg-background text-foreground;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.tw-prose a {
|
|
11
|
-
@apply link;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
*::-webkit-scrollbar {
|
|
15
|
-
@apply size-2;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
*::-webkit-scrollbar-track {
|
|
19
|
-
@apply bg-card rounded-none;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
*::-webkit-scrollbar-thumb {
|
|
23
|
-
@apply bg-foreground/70 hover:bg-foreground;
|
|
24
|
-
}
|
|
25
|
-
}
|