@glyphui/ui 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/data-table.js +2 -2
- package/dist/{field-DXZD0l8w.js → field-CCecIzdq.js} +1 -1
- package/dist/{field-context-B8cYheXz.js → field-context-B6WOcK5m.js} +99 -99
- package/dist/form.js +2 -2
- package/dist/index.d.ts +2743 -93
- package/dist/index.js +2748 -111
- package/dist/{states-BxPjCUxz.js → states-Rp8wZ_jH.js} +1 -1
- package/package.json +4 -2
- package/src/components/accordion/accordion.styles.ts +41 -0
- package/src/components/accordion/accordion.tsx +86 -0
- package/src/components/accordion/index.ts +8 -0
- package/src/components/alert/alert-icons.tsx +66 -0
- package/src/components/alert/alert.styles.ts +57 -0
- package/src/components/alert/alert.tsx +86 -0
- package/src/components/alert/index.ts +2 -0
- package/src/components/alert-dialog/alert-dialog.styles.ts +24 -0
- package/src/components/alert-dialog/alert-dialog.tsx +118 -0
- package/src/components/alert-dialog/confirm.tsx +111 -0
- package/src/components/alert-dialog/index.ts +15 -0
- package/src/components/aspect-ratio/aspect-ratio.tsx +40 -0
- package/src/components/aspect-ratio/index.ts +1 -0
- package/src/components/badge/badge.styles.ts +1 -1
- package/src/components/banner/banner.styles.ts +40 -0
- package/src/components/banner/banner.tsx +101 -0
- package/src/components/banner/index.ts +2 -0
- package/src/components/blockquote/blockquote.tsx +59 -0
- package/src/components/blockquote/index.ts +1 -0
- package/src/components/breadcrumb/breadcrumb.styles.ts +20 -0
- package/src/components/breadcrumb/breadcrumb.tsx +135 -0
- package/src/components/breadcrumb/index.ts +12 -0
- package/src/components/button/button.tsx +11 -8
- package/src/components/code/code.styles.ts +33 -0
- package/src/components/code/code.tsx +96 -0
- package/src/components/code/index.ts +2 -0
- package/src/components/combobox/combobox.styles.ts +50 -0
- package/src/components/combobox/combobox.tsx +203 -0
- package/src/components/combobox/index.ts +2 -0
- package/src/components/command-menu/command-menu.styles.ts +41 -0
- package/src/components/command-menu/command-menu.tsx +217 -0
- package/src/components/command-menu/index.ts +14 -0
- package/src/components/description-list/description-list.styles.ts +31 -0
- package/src/components/description-list/description-list.tsx +56 -0
- package/src/components/description-list/index.ts +7 -0
- package/src/components/dialog/close-icon.tsx +22 -0
- package/src/components/dialog/dialog.styles.ts +41 -0
- package/src/components/dialog/dialog.tsx +111 -0
- package/src/components/dialog/index.ts +13 -0
- package/src/components/dropdown-menu/dropdown-menu.styles.ts +45 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +230 -0
- package/src/components/dropdown-menu/index.ts +19 -0
- package/src/components/grid/grid.tsx +144 -0
- package/src/components/grid/index.ts +1 -0
- package/src/components/link/index.ts +2 -0
- package/src/components/link/link.styles.ts +39 -0
- package/src/components/link/link.tsx +62 -0
- package/src/components/pagination/index.ts +3 -0
- package/src/components/pagination/pagination-range.ts +35 -0
- package/src/components/pagination/pagination.styles.ts +41 -0
- package/src/components/pagination/pagination.tsx +130 -0
- package/src/components/popover/index.ts +9 -0
- package/src/components/popover/popover.tsx +66 -0
- package/src/components/progress/index.ts +7 -0
- package/src/components/progress/progress.styles.ts +68 -0
- package/src/components/progress/progress.tsx +158 -0
- package/src/components/prose/index.ts +1 -0
- package/src/components/prose/prose.tsx +82 -0
- package/src/components/radio-group/index.ts +7 -0
- package/src/components/radio-group/radio-group.styles.ts +64 -0
- package/src/components/radio-group/radio-group.tsx +128 -0
- package/src/components/scroll-area/index.ts +1 -0
- package/src/components/scroll-area/scroll-area.tsx +68 -0
- package/src/components/sheet/index.ts +13 -0
- package/src/components/sheet/sheet.styles.ts +60 -0
- package/src/components/sheet/sheet.tsx +108 -0
- package/src/components/slider/index.ts +2 -0
- package/src/components/slider/slider.styles.ts +32 -0
- package/src/components/slider/slider.tsx +131 -0
- package/src/components/stat-card/index.ts +2 -0
- package/src/components/stat-card/stat-card.styles.ts +24 -0
- package/src/components/stat-card/stat-card.tsx +108 -0
- package/src/components/toast/index.ts +1 -0
- package/src/components/toast/toast.tsx +91 -0
- package/src/index.ts +25 -0
- package/src/provider/glyph-provider.tsx +16 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Toaster, type ToasterProps, toast, toastStyles } from './toast'
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react'
|
|
2
|
+
import { Toaster as Sonner, toast } from 'sonner'
|
|
3
|
+
import { useComponentConfig } from '../../hooks/use-component-config'
|
|
4
|
+
import type { StylesEntry } from '../../utils/registry'
|
|
5
|
+
import { focusRing, themedBorder, transition } from '../../utils/styles'
|
|
6
|
+
import { tv } from '../../utils/tv'
|
|
7
|
+
|
|
8
|
+
export const toastStyles = tv({
|
|
9
|
+
slots: {
|
|
10
|
+
toast: [
|
|
11
|
+
'group flex w-(--width) items-start gap-3 rounded-lg border-border bg-raised p-4 text-small text-foreground shadow-lg',
|
|
12
|
+
themedBorder,
|
|
13
|
+
],
|
|
14
|
+
content: 'flex min-w-0 flex-1 flex-col gap-0.5',
|
|
15
|
+
title: 'font-medium text-foreground',
|
|
16
|
+
description: 'text-muted-foreground',
|
|
17
|
+
icon: 'mt-0.5 flex size-4 shrink-0 items-center justify-center [&>svg]:size-4',
|
|
18
|
+
actionButton: [
|
|
19
|
+
'inline-flex h-7 shrink-0 cursor-pointer items-center rounded-sm bg-primary px-2.5 text-caption font-medium text-primary-foreground hover:bg-primary/88',
|
|
20
|
+
transition,
|
|
21
|
+
focusRing,
|
|
22
|
+
],
|
|
23
|
+
cancelButton: [
|
|
24
|
+
'inline-flex h-7 shrink-0 cursor-pointer items-center rounded-sm bg-muted px-2.5 text-caption font-medium text-muted-foreground hover:text-foreground',
|
|
25
|
+
transition,
|
|
26
|
+
focusRing,
|
|
27
|
+
],
|
|
28
|
+
closeButton: [
|
|
29
|
+
'absolute -top-2 -left-2 flex size-5 cursor-pointer items-center justify-center rounded-pill border-border bg-raised text-muted-foreground shadow-xs hover:text-foreground [&>svg]:size-3',
|
|
30
|
+
themedBorder,
|
|
31
|
+
focusRing,
|
|
32
|
+
],
|
|
33
|
+
success: '[&_[data-icon]]:text-success',
|
|
34
|
+
error: '[&_[data-icon]]:text-danger',
|
|
35
|
+
warning: '[&_[data-icon]]:text-warning',
|
|
36
|
+
info: '[&_[data-icon]]:text-info',
|
|
37
|
+
loading: '[&_[data-icon]]:text-muted-foreground',
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
declare module '@glyphui/tokens' {
|
|
42
|
+
interface GlyphComponentRegistry {
|
|
43
|
+
Toast: StylesEntry<typeof toastStyles>
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type ToasterProps = ComponentProps<typeof Sonner>
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Renders toasts sent with `toast()`. Mount once near the root. Styled entirely by the
|
|
51
|
+
* theme's tokens, so it follows the theme and color mode automatically.
|
|
52
|
+
*
|
|
53
|
+
* ```tsx
|
|
54
|
+
* toast.success('Saved')
|
|
55
|
+
* toast.promise(save(), { loading: 'Saving…', success: 'Saved', error: 'Couldn’t save' })
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function Toaster(inProps: ToasterProps) {
|
|
59
|
+
const [props, slots] = useComponentConfig('Toast', inProps)
|
|
60
|
+
const { toastOptions, position = 'bottom-right', ...rest } = props
|
|
61
|
+
const s = toastStyles()
|
|
62
|
+
const classNames = toastOptions?.classNames ?? {}
|
|
63
|
+
return (
|
|
64
|
+
<Sonner
|
|
65
|
+
position={position}
|
|
66
|
+
gap={10}
|
|
67
|
+
{...rest}
|
|
68
|
+
toastOptions={{
|
|
69
|
+
...toastOptions,
|
|
70
|
+
unstyled: true,
|
|
71
|
+
classNames: {
|
|
72
|
+
toast: s.toast({ class: [slots.toast, classNames.toast] }),
|
|
73
|
+
content: s.content({ class: [slots.content, classNames.content] }),
|
|
74
|
+
title: s.title({ class: [slots.title, classNames.title] }),
|
|
75
|
+
description: s.description({ class: [slots.description, classNames.description] }),
|
|
76
|
+
icon: s.icon({ class: [slots.icon, classNames.icon] }),
|
|
77
|
+
actionButton: s.actionButton({ class: [slots.actionButton, classNames.actionButton] }),
|
|
78
|
+
cancelButton: s.cancelButton({ class: [slots.cancelButton, classNames.cancelButton] }),
|
|
79
|
+
closeButton: s.closeButton({ class: [slots.closeButton, classNames.closeButton] }),
|
|
80
|
+
success: s.success({ class: [slots.success, classNames.success] }),
|
|
81
|
+
error: s.error({ class: [slots.error, classNames.error] }),
|
|
82
|
+
warning: s.warning({ class: [slots.warning, classNames.warning] }),
|
|
83
|
+
info: s.info({ class: [slots.info, classNames.info] }),
|
|
84
|
+
loading: s.loading({ class: [slots.loading, classNames.loading] }),
|
|
85
|
+
},
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { toast }
|
package/src/index.ts
CHANGED
|
@@ -16,30 +16,55 @@ export {
|
|
|
16
16
|
tokenVar,
|
|
17
17
|
} from '@glyphui/tokens'
|
|
18
18
|
// Components
|
|
19
|
+
export * from './components/accordion'
|
|
20
|
+
export * from './components/alert'
|
|
21
|
+
export * from './components/alert-dialog'
|
|
22
|
+
export * from './components/aspect-ratio'
|
|
19
23
|
export * from './components/avatar'
|
|
20
24
|
export * from './components/badge'
|
|
25
|
+
export * from './components/banner'
|
|
26
|
+
export * from './components/blockquote'
|
|
27
|
+
export * from './components/breadcrumb'
|
|
21
28
|
export * from './components/button'
|
|
22
29
|
export * from './components/card'
|
|
23
30
|
export * from './components/checkbox'
|
|
31
|
+
export * from './components/code'
|
|
32
|
+
export * from './components/combobox'
|
|
33
|
+
export * from './components/command-menu'
|
|
24
34
|
export * from './components/container'
|
|
35
|
+
export * from './components/description-list'
|
|
36
|
+
export * from './components/dialog'
|
|
37
|
+
export * from './components/dropdown-menu'
|
|
25
38
|
export * from './components/eyebrow'
|
|
26
39
|
export * from './components/field'
|
|
40
|
+
export * from './components/grid'
|
|
27
41
|
export * from './components/heading'
|
|
28
42
|
export * from './components/input'
|
|
29
43
|
export * from './components/kbd'
|
|
30
44
|
export * from './components/label'
|
|
45
|
+
export * from './components/link'
|
|
46
|
+
export * from './components/pagination'
|
|
47
|
+
export * from './components/popover'
|
|
48
|
+
export * from './components/progress'
|
|
49
|
+
export * from './components/prose'
|
|
50
|
+
export * from './components/radio-group'
|
|
51
|
+
export * from './components/scroll-area'
|
|
31
52
|
export * from './components/section'
|
|
32
53
|
export * from './components/segmented-control'
|
|
33
54
|
export * from './components/select'
|
|
34
55
|
export * from './components/separator'
|
|
56
|
+
export * from './components/sheet'
|
|
35
57
|
export * from './components/skeleton'
|
|
58
|
+
export * from './components/slider'
|
|
36
59
|
export * from './components/spinner'
|
|
37
60
|
export * from './components/stack'
|
|
61
|
+
export * from './components/stat-card'
|
|
38
62
|
export * from './components/switch'
|
|
39
63
|
export * from './components/table'
|
|
40
64
|
export * from './components/tabs'
|
|
41
65
|
export * from './components/text'
|
|
42
66
|
export * from './components/textarea'
|
|
67
|
+
export * from './components/toast'
|
|
43
68
|
export * from './components/tooltip'
|
|
44
69
|
export * from './hooks'
|
|
45
70
|
// Patterns
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Theme } from '@glyphui/tokens'
|
|
2
2
|
import { Tooltip } from 'radix-ui'
|
|
3
3
|
import { type ReactNode, useMemo } from 'react'
|
|
4
|
+
import { ConfirmProvider } from '../components/alert-dialog/confirm'
|
|
5
|
+
import { Toaster, type ToasterProps } from '../components/toast/toast'
|
|
4
6
|
import { glyph } from '../themes'
|
|
5
7
|
import { type ColorModePreference, ColorModeProvider } from './color-mode'
|
|
6
8
|
import { GlyphContext, type LinkComponent } from './glyph-context'
|
|
@@ -16,15 +18,21 @@ export interface GlyphProviderProps {
|
|
|
16
18
|
storageKey?: string | null
|
|
17
19
|
/** Your router's link, used by Navbar, Sidebar and other navigation components. */
|
|
18
20
|
linkComponent?: LinkComponent
|
|
21
|
+
/**
|
|
22
|
+
* Mounts a themed `<Toaster />` so `toast()` works anywhere. `true` for defaults, or pass
|
|
23
|
+
* Toaster props (e.g. `{ position: 'top-center' }`). Off by default.
|
|
24
|
+
*/
|
|
25
|
+
toaster?: boolean | ToasterProps
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
/** Provides the theme, color mode and
|
|
28
|
+
/** Provides the theme, color mode, tooltips, `useConfirm()` and (optionally) toasts. Render once at the root. */
|
|
22
29
|
export function GlyphProvider({
|
|
23
30
|
children,
|
|
24
31
|
theme = glyph,
|
|
25
32
|
defaultMode,
|
|
26
33
|
storageKey,
|
|
27
34
|
linkComponent = 'a',
|
|
35
|
+
toaster = false,
|
|
28
36
|
}: GlyphProviderProps) {
|
|
29
37
|
const value = useMemo(() => ({ theme, linkComponent }), [theme, linkComponent])
|
|
30
38
|
return (
|
|
@@ -34,7 +42,13 @@ export function GlyphProvider({
|
|
|
34
42
|
>
|
|
35
43
|
<GlyphContext.Provider value={value}>
|
|
36
44
|
<ThemeStyle theme={theme} />
|
|
37
|
-
<Tooltip.Provider delayDuration={300}>
|
|
45
|
+
<Tooltip.Provider delayDuration={300}>
|
|
46
|
+
{/* useConfirm() works anywhere without setup; the dialog only mounts while open. */}
|
|
47
|
+
<ConfirmProvider>
|
|
48
|
+
{children}
|
|
49
|
+
{toaster && <Toaster {...(toaster === true ? {} : toaster)} />}
|
|
50
|
+
</ConfirmProvider>
|
|
51
|
+
</Tooltip.Provider>
|
|
38
52
|
</GlyphContext.Provider>
|
|
39
53
|
</ColorModeProvider>
|
|
40
54
|
)
|