@alfakit/react 0.1.1 → 0.1.6
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/CHANGELOG.md +16 -0
- package/dist/components/actions/action-button.d.ts.map +1 -1
- package/dist/components/actions/action-button.js +5 -4
- package/dist/components/actions/action-button.js.map +1 -1
- package/dist/components/actions/action-modals.d.ts.map +1 -1
- package/dist/components/actions/action-modals.js +6 -5
- package/dist/components/actions/action-modals.js.map +1 -1
- package/dist/components/ai/copilot.d.ts +3 -1
- package/dist/components/ai/copilot.d.ts.map +1 -1
- package/dist/components/ai/copilot.js +4 -1
- package/dist/components/ai/copilot.js.map +1 -1
- package/dist/components/cms/live-preview.js +3 -2
- package/dist/components/cms/live-preview.js.map +1 -1
- package/dist/components/cms/page.js +1 -1
- package/dist/components/fields/builder.js +15 -6
- package/dist/components/fields/builder.js.map +1 -1
- package/dist/components/fields/color-picker.js +1 -0
- package/dist/components/fields/color-picker.js.map +1 -1
- package/dist/components/fields/file-upload.js +11 -10
- package/dist/components/fields/file-upload.js.map +1 -1
- package/dist/components/fields/image-editor-dialog.js +4 -2
- package/dist/components/fields/image-editor-dialog.js.map +1 -1
- package/dist/components/fields/item-actions.js +10 -10
- package/dist/components/fields/item-actions.js.map +1 -1
- package/dist/components/fields/key-value.d.ts.map +1 -1
- package/dist/components/fields/key-value.js +3 -3
- package/dist/components/fields/key-value.js.map +1 -1
- package/dist/components/fields/modal-table-select.js +6 -5
- package/dist/components/fields/modal-table-select.js.map +1 -1
- package/dist/components/fields/one-time-code-input.js +1 -1
- package/dist/components/fields/one-time-code-input.js.map +1 -1
- package/dist/components/fields/repeater-table.js +12 -1
- package/dist/components/fields/repeater-table.js.map +1 -1
- package/dist/components/fields/repeater.js +2 -2
- package/dist/components/fields/repeater.js.map +1 -1
- package/dist/components/fields/rich-editor.js +2 -1
- package/dist/components/fields/rich-editor.js.map +1 -1
- package/dist/components/fields/select.js +3 -3
- package/dist/components/fields/select.js.map +1 -1
- package/dist/components/file-manager/file-manager.js +1 -1
- package/dist/components/file-manager/file-manager.js.map +1 -1
- package/dist/components/form/form-block.d.ts.map +1 -1
- package/dist/components/form/form-block.js +14 -2
- package/dist/components/form/form-block.js.map +1 -1
- package/dist/components/form/form-context.js +7 -3
- package/dist/components/form/form-context.js.map +1 -1
- package/dist/components/kanban/kanban.js +4 -3
- package/dist/components/kanban/kanban.js.map +1 -1
- package/dist/components/layout/fused-group.js +1 -0
- package/dist/components/layout/fused-group.js.map +1 -1
- package/dist/components/layout/section.js +2 -2
- package/dist/components/layout/section.js.map +1 -1
- package/dist/components/layout/tabs.d.ts.map +1 -1
- package/dist/components/layout/tabs.js +54 -15
- package/dist/components/layout/tabs.js.map +1 -1
- package/dist/components/panel/app-sidebar.d.ts +2 -3
- package/dist/components/panel/app-sidebar.d.ts.map +1 -1
- package/dist/components/panel/app-sidebar.js +1 -24
- package/dist/components/panel/app-sidebar.js.map +1 -1
- package/dist/components/panel/brand.d.ts +10 -0
- package/dist/components/panel/brand.d.ts.map +1 -0
- package/dist/components/panel/brand.js +37 -0
- package/dist/components/panel/brand.js.map +1 -0
- package/dist/components/panel/global-search.js +1 -0
- package/dist/components/panel/global-search.js.map +1 -1
- package/dist/components/panel/index.d.ts +2 -1
- package/dist/components/panel/shortcut-keys.js +1 -0
- package/dist/components/panel/shortcut-keys.js.map +1 -1
- package/dist/components/panel/tenant-menu.js +2 -2
- package/dist/components/panel/tenant-menu.js.map +1 -1
- package/dist/components/panel/topbar.js +1 -1
- package/dist/components/realtime/live-records-pill.d.ts.map +1 -1
- package/dist/components/realtime/live-records-pill.js +6 -3
- package/dist/components/realtime/live-records-pill.js.map +1 -1
- package/dist/components/table/cells.d.ts +6 -0
- package/dist/components/table/cells.d.ts.map +1 -1
- package/dist/components/table/cells.js +15 -3
- package/dist/components/table/cells.js.map +1 -1
- package/dist/components/table/column-manager.js +8 -7
- package/dist/components/table/column-manager.js.map +1 -1
- package/dist/components/table/content-layout.js +2 -1
- package/dist/components/table/content-layout.js.map +1 -1
- package/dist/components/table/grouping.js +11 -1
- package/dist/components/table/grouping.js.map +1 -1
- package/dist/components/table/pagination.js +16 -13
- package/dist/components/table/pagination.js.map +1 -1
- package/dist/components/table/table-block.js +14 -4
- package/dist/components/table/table-block.js.map +1 -1
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.js +3 -1
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +3 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.js +3 -1
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/tooltip.js +3 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/components.css +347 -0
- package/dist/context.d.ts +5 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +5 -1
- package/dist/context.js.map +1 -1
- package/dist/create-alfakit.d.ts.map +1 -1
- package/dist/create-alfakit.js +8 -5
- package/dist/create-alfakit.js.map +1 -1
- package/dist/eject-manifest.json +16 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +24 -21
- package/dist/layouts/app-layout.d.ts.map +1 -1
- package/dist/layouts/app-layout.js +2 -29
- package/dist/layouts/app-layout.js.map +1 -1
- package/dist/layouts/auth-layout.js +2 -2
- package/dist/layouts/auth-layout.js.map +1 -1
- package/dist/layouts/fullscreen-layout.js +1 -1
- package/dist/layouts/fullscreen-layout.js.map +1 -1
- package/dist/layouts/lazy-layouts.js +15 -0
- package/dist/layouts/lazy-layouts.js.map +1 -0
- package/dist/layouts/max-widths.js +34 -0
- package/dist/layouts/max-widths.js.map +1 -0
- package/dist/layouts/panel-layouts.d.ts +10 -0
- package/dist/layouts/panel-layouts.d.ts.map +1 -0
- package/dist/layouts/panel-layouts.js +20 -0
- package/dist/layouts/panel-layouts.js.map +1 -0
- package/dist/layouts/top-nav-layout.js +2 -2
- package/dist/layouts/top-nav-layout.js.map +1 -1
- package/dist/pages/page.d.ts.map +1 -1
- package/dist/pages/page.js +12 -7
- package/dist/pages/page.js.map +1 -1
- package/dist/standalone/alfakit-component.js +11 -6
- package/dist/standalone/alfakit-component.js.map +1 -1
- package/dist/standalone/alfakit-toaster.d.ts.map +1 -1
- package/dist/standalone/alfakit-toaster.js +8 -1
- package/dist/standalone/alfakit-toaster.js.map +1 -1
- package/dist/standalone.css +54 -0
- package/dist/starter-kit/dashboard-widgets.d.ts +33 -0
- package/dist/starter-kit/dashboard-widgets.d.ts.map +1 -0
- package/dist/starter-kit/dashboard-widgets.js +53 -0
- package/dist/starter-kit/dashboard-widgets.js.map +1 -0
- package/dist/starter-kit/impersonation-banner.js +34 -0
- package/dist/starter-kit/impersonation-banner.js.map +1 -0
- package/dist/starter-kit/index.d.ts +3 -2
- package/dist/starter-kit/index.js +3 -2
- package/dist/starter-kit/starter-kit.d.ts +6 -0
- package/dist/starter-kit/starter-kit.d.ts.map +1 -1
- package/dist/starter-kit/starter-kit.js +18 -7
- package/dist/starter-kit/starter-kit.js.map +1 -1
- package/dist/starter-kit/widgets-loaded.js +21 -5
- package/dist/starter-kit/widgets-loaded.js.map +1 -1
- package/dist/starter-kit/widgets-triggers.js +35 -3
- package/dist/starter-kit/widgets-triggers.js.map +1 -1
- package/dist/starter-kit/widgets.d.ts +13 -5
- package/dist/starter-kit/widgets.d.ts.map +1 -1
- package/dist/starter-kit/widgets.js +56 -18
- package/dist/starter-kit/widgets.js.map +1 -1
- package/dist/styles.css +15 -2
- package/dist/themes.css +8 -335
- package/package.json +2 -2
- package/src/components/actions/action-button.tsx +7 -4
- package/src/components/actions/action-modals.tsx +13 -1
- package/src/components/ai/copilot.tsx +14 -1
- package/src/components/cms/live-preview.tsx +5 -2
- package/src/components/fields/builder.tsx +14 -5
- package/src/components/fields/color-picker.tsx +1 -0
- package/src/components/fields/file-upload.tsx +21 -10
- package/src/components/fields/image-editor-dialog.tsx +7 -2
- package/src/components/fields/item-actions.tsx +32 -9
- package/src/components/fields/key-value.tsx +3 -2
- package/src/components/fields/modal-table-select.tsx +8 -3
- package/src/components/fields/one-time-code-input.tsx +1 -1
- package/src/components/fields/repeater-table.tsx +12 -1
- package/src/components/fields/repeater.tsx +2 -3
- package/src/components/fields/rich-editor.tsx +3 -0
- package/src/components/fields/select.tsx +7 -3
- package/src/components/file-manager/file-manager.tsx +1 -1
- package/src/components/form/form-block.tsx +26 -1
- package/src/components/form/form-context.tsx +3 -6
- package/src/components/kanban/kanban.tsx +16 -3
- package/src/components/layout/fused-group.tsx +5 -1
- package/src/components/layout/section.tsx +2 -2
- package/src/components/layout/tabs.tsx +72 -17
- package/src/components/panel/app-sidebar.tsx +2 -38
- package/src/components/panel/brand.tsx +46 -0
- package/src/components/panel/global-search.tsx +1 -1
- package/src/components/panel/shortcut-keys.tsx +4 -1
- package/src/components/panel/tenant-menu.tsx +2 -2
- package/src/components/realtime/live-records-pill.tsx +4 -3
- package/src/components/table/cells.tsx +27 -5
- package/src/components/table/column-manager.tsx +12 -10
- package/src/components/table/content-layout.tsx +5 -1
- package/src/components/table/grouping.tsx +15 -1
- package/src/components/table/pagination.tsx +16 -9
- package/src/components/table/table-block.tsx +25 -12
- package/src/components/ui/dialog.tsx +5 -1
- package/src/components/ui/popover.tsx +5 -1
- package/src/components/ui/sheet.tsx +5 -1
- package/src/components/ui/tooltip.tsx +5 -1
- package/src/context.tsx +10 -0
- package/src/create-alfakit.tsx +11 -2
- package/src/index.ts +2 -0
- package/src/layouts/app-layout.tsx +4 -28
- package/src/layouts/auth-layout.tsx +2 -2
- package/src/layouts/fullscreen-layout.tsx +1 -1
- package/src/layouts/lazy-layouts.ts +14 -0
- package/src/layouts/max-widths.ts +29 -0
- package/src/layouts/panel-layouts.ts +17 -0
- package/src/layouts/top-nav-layout.tsx +2 -2
- package/src/pages/page.tsx +21 -12
- package/src/standalone/alfakit-component.tsx +18 -7
- package/src/standalone/alfakit-toaster.tsx +21 -2
- package/src/starter-kit/dashboard-widgets.tsx +78 -0
- package/src/starter-kit/impersonation-banner.tsx +48 -0
- package/src/starter-kit/index.ts +2 -0
- package/src/starter-kit/starter-kit.tsx +31 -4
- package/src/starter-kit/widgets-loaded.tsx +23 -1
- package/src/starter-kit/widgets-triggers.tsx +37 -2
- package/src/starter-kit/widgets.tsx +95 -20
- package/src/styles.css +15 -2
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
isAlfakitPage,
|
|
3
|
+
starterKitWidgets,
|
|
4
|
+
type StarterKitWidgets,
|
|
5
|
+
type StarterKitWidgetsSchema,
|
|
6
|
+
} from '@alfakit/core'
|
|
2
7
|
import { usePage } from '@inertiajs/react'
|
|
8
|
+
import { lazy, Suspense } from 'react'
|
|
3
9
|
import { lazyComponent } from '../lib/lazy'
|
|
4
10
|
import {
|
|
11
|
+
CopilotTrigger,
|
|
5
12
|
NotificationsTrigger,
|
|
6
13
|
SearchTrigger,
|
|
7
14
|
TenantSwitcherTrigger,
|
|
@@ -16,14 +23,15 @@ import {
|
|
|
16
23
|
* (in the browser, never during SSR).
|
|
17
24
|
*
|
|
18
25
|
* ```tsx
|
|
19
|
-
* import { AlfakitNotifications, AlfakitSearch } from '@alfakit/react'
|
|
26
|
+
* import { AlfakitCopilot, AlfakitNotifications, AlfakitSearch } from '@alfakit/react'
|
|
20
27
|
*
|
|
21
28
|
* <AlfakitSearch />
|
|
22
29
|
* <AlfakitNotifications />
|
|
30
|
+
* <AlfakitCopilot />
|
|
23
31
|
* ```
|
|
24
32
|
*/
|
|
25
33
|
export interface AlfakitHeaderWidgetProps {
|
|
26
|
-
/** The `starterKit()` panel to use (the first one
|
|
34
|
+
/** The `starterKit()` panel to use (by default the open AlfaKit page's panel, else the first one that has this component). */
|
|
27
35
|
panel?: string
|
|
28
36
|
}
|
|
29
37
|
|
|
@@ -48,8 +56,37 @@ const LoadedTenantSwitcher = lazyComponent<WidgetProps>(
|
|
|
48
56
|
(props) => <TenantSwitcherTrigger {...props} />,
|
|
49
57
|
)
|
|
50
58
|
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
const LoadedCopilot = lazyComponent<WidgetProps>(
|
|
60
|
+
() => load().then((module) => module.LoadedCopilot),
|
|
61
|
+
(props) => <CopilotTrigger {...props} onLoad={preloadCopilot} />,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
function preloadCopilot() {
|
|
65
|
+
void LoadedCopilot.preload()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Only needed while impersonating: its code loads then (and never on AlfaKit pages).
|
|
69
|
+
const LazyImpersonationBanner = lazy(() => import('./impersonation-banner'))
|
|
70
|
+
|
|
71
|
+
/** While impersonating, the first header component shows the banner on host pages. */
|
|
72
|
+
function StarterKitImpersonationBanner({ source }: { source: StarterKitWidgets | null }) {
|
|
73
|
+
const props = usePage().props
|
|
74
|
+
const impersonation = source?.widgets.impersonation
|
|
75
|
+
|
|
76
|
+
if (!impersonation || isAlfakitPage(props)) return null
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Suspense fallback={null}>
|
|
80
|
+
<LazyImpersonationBanner impersonation={impersonation} />
|
|
81
|
+
</Suspense>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function useWidgets(
|
|
86
|
+
panelId: string | undefined,
|
|
87
|
+
part: keyof StarterKitWidgetsSchema,
|
|
88
|
+
): StarterKitWidgets | null {
|
|
89
|
+
return starterKitWidgets(usePage().props, panelId, part)
|
|
53
90
|
}
|
|
54
91
|
|
|
55
92
|
/**
|
|
@@ -58,14 +95,19 @@ function useWidgets(panelId: string | undefined): StarterKitWidgets | null {
|
|
|
58
95
|
* nothing for guests or without global search and a command palette.
|
|
59
96
|
*/
|
|
60
97
|
export function AlfakitSearch({ panel }: AlfakitHeaderWidgetProps = {}) {
|
|
61
|
-
const source = useWidgets(panel)
|
|
98
|
+
const source = useWidgets(panel, 'search')
|
|
62
99
|
|
|
63
|
-
|
|
100
|
+
const banner = <StarterKitImpersonationBanner source={source} />
|
|
101
|
+
|
|
102
|
+
if (!source?.widgets.search) return banner
|
|
64
103
|
|
|
65
104
|
return (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
105
|
+
<>
|
|
106
|
+
{banner}
|
|
107
|
+
<span data-slot="starter-kit-search" className="inline-flex">
|
|
108
|
+
<LoadedSearch source={source} />
|
|
109
|
+
</span>
|
|
110
|
+
</>
|
|
69
111
|
)
|
|
70
112
|
}
|
|
71
113
|
|
|
@@ -75,14 +117,19 @@ export function AlfakitSearch({ panel }: AlfakitHeaderWidgetProps = {}) {
|
|
|
75
117
|
* notifications.
|
|
76
118
|
*/
|
|
77
119
|
export function AlfakitNotifications({ panel }: AlfakitHeaderWidgetProps = {}) {
|
|
78
|
-
const source = useWidgets(panel)
|
|
120
|
+
const source = useWidgets(panel, 'notifications')
|
|
121
|
+
|
|
122
|
+
const banner = <StarterKitImpersonationBanner source={source} />
|
|
79
123
|
|
|
80
|
-
if (!source?.widgets.notifications) return
|
|
124
|
+
if (!source?.widgets.notifications) return banner
|
|
81
125
|
|
|
82
126
|
return (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
127
|
+
<>
|
|
128
|
+
{banner}
|
|
129
|
+
<span data-slot="starter-kit-notifications" className="inline-flex">
|
|
130
|
+
<LoadedNotifications source={source} />
|
|
131
|
+
</span>
|
|
132
|
+
</>
|
|
86
133
|
)
|
|
87
134
|
}
|
|
88
135
|
|
|
@@ -91,13 +138,41 @@ export function AlfakitNotifications({ panel }: AlfakitHeaderWidgetProps = {}) {
|
|
|
91
138
|
* to choose one on the host's own pages. Renders nothing for guests or other panels.
|
|
92
139
|
*/
|
|
93
140
|
export function AlfakitTenantSwitcher({ panel }: AlfakitHeaderWidgetProps = {}) {
|
|
94
|
-
const source = useWidgets(panel)
|
|
141
|
+
const source = useWidgets(panel, 'tenancy')
|
|
142
|
+
|
|
143
|
+
const banner = <StarterKitImpersonationBanner source={source} />
|
|
144
|
+
|
|
145
|
+
if (!source?.widgets.tenancy) return banner
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<>
|
|
149
|
+
{banner}
|
|
150
|
+
<span data-slot="starter-kit-tenant-switcher" className="inline-flex">
|
|
151
|
+
<LoadedTenantSwitcher source={source} />
|
|
152
|
+
</span>
|
|
153
|
+
</>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The AI copilot of alfasix/alfakit-ai (`AiPlugin::copilot()`): its button and chat
|
|
159
|
+
* slide-over, opened with its key bindings (`mod+j`) from any page. Renders nothing for
|
|
160
|
+
* guests, without the plugin's copilot, for users who may not use it and (tenancy panels)
|
|
161
|
+
* outside a tenant.
|
|
162
|
+
*/
|
|
163
|
+
export function AlfakitCopilot({ panel }: AlfakitHeaderWidgetProps = {}) {
|
|
164
|
+
const source = useWidgets(panel, 'copilot')
|
|
165
|
+
|
|
166
|
+
const banner = <StarterKitImpersonationBanner source={source} />
|
|
95
167
|
|
|
96
|
-
if (!source?.widgets.
|
|
168
|
+
if (!source?.widgets.copilot) return banner
|
|
97
169
|
|
|
98
170
|
return (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
171
|
+
<>
|
|
172
|
+
{banner}
|
|
173
|
+
<span data-slot="starter-kit-copilot" className="inline-flex">
|
|
174
|
+
<LoadedCopilot source={source} />
|
|
175
|
+
</span>
|
|
176
|
+
</>
|
|
102
177
|
)
|
|
103
178
|
}
|
package/src/styles.css
CHANGED
|
@@ -11,8 +11,21 @@
|
|
|
11
11
|
/* Built-in themes (alfakit, minimal, soft, corporate, filament); neutral is below. */
|
|
12
12
|
@import './themes.css';
|
|
13
13
|
|
|
14
|
+
/*
|
|
15
|
+
* Toast styles, as in the Vue renderer. Sonner also injects them at runtime, which a
|
|
16
|
+
* nonce-based Content Security Policy blocks; from the stylesheet they always apply.
|
|
17
|
+
*/
|
|
18
|
+
@import 'sonner/dist/styles.css';
|
|
19
|
+
|
|
14
20
|
@custom-variant dark (&:is(.dark *));
|
|
15
21
|
|
|
22
|
+
/*
|
|
23
|
+
* Class lists that live in @alfakit/core (stacked-on-mobile tables, filter and column manager
|
|
24
|
+
* widths in `table.ts`, …): scan core's build too. Relative to this file in
|
|
25
|
+
* node_modules/@alfakit/<renderer>/dist, next to node_modules/@alfakit/core.
|
|
26
|
+
*/
|
|
27
|
+
@source '../../core/dist';
|
|
28
|
+
|
|
16
29
|
/*
|
|
17
30
|
* Grid classes are composed at runtime from schema breakpoints (`columns`, `columnSpan`),
|
|
18
31
|
* so force Tailwind to generate every variant the renderers can produce.
|
|
@@ -116,10 +129,10 @@
|
|
|
116
129
|
--secondary: oklch(0.97 0 0);
|
|
117
130
|
--secondary-foreground: oklch(0.205 0 0);
|
|
118
131
|
--muted: oklch(0.97 0 0);
|
|
119
|
-
--muted-foreground: oklch(0.
|
|
132
|
+
--muted-foreground: oklch(0.54 0 0);
|
|
120
133
|
--accent: oklch(0.97 0 0);
|
|
121
134
|
--accent-foreground: oklch(0.205 0 0);
|
|
122
|
-
--destructive: var(--alfakit-danger, oklch(0.
|
|
135
|
+
--destructive: var(--alfakit-danger, oklch(0.5 0.245 27.325));
|
|
123
136
|
--destructive-foreground: var(--alfakit-danger-foreground, oklch(0.985 0 0));
|
|
124
137
|
--border: oklch(0.922 0 0);
|
|
125
138
|
--input: oklch(0.64 0 0);
|