@sybilion/uilib 1.2.5 → 1.2.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.
@@ -1,310 +0,0 @@
1
- import { useCallback, useState } from 'react';
2
-
3
- import { AppHeaderHost } from '#uilib/components/ui/AppHeader';
4
- import { DropdownMenuItem } from '#uilib/components/ui/DropdownMenu';
5
- import {
6
- AppShell,
7
- AppShellMainContent,
8
- PageContent,
9
- PageContentSection,
10
- PageHeader,
11
- } from '#uilib/components/ui/Page';
12
- import { PageFooter } from '#uilib/components/ui/Page/PageFooter/PageFooter';
13
- import { PageScroll } from '#uilib/components/ui/Page/PageScroll/PageScroll';
14
- import {
15
- Sidebar,
16
- SidebarContent,
17
- SidebarMenu,
18
- SidebarMenuButton,
19
- SidebarMenuItem,
20
- SidebarProvider,
21
- } from '#uilib/components/ui/Sidebar/Sidebar';
22
- import type { WorkspaceAppEntry } from '#uilib/components/ui/WorkspaceAppSwitcher';
23
- import {
24
- SidebarDatasetsItemsGrouped,
25
- type SidebarDatasetsItemsGroupedDataset,
26
- } from '#uilib/components/widgets/SidebarDatasetsItemsGrouped';
27
- import { SybilionAppHeader } from '#uilib/components/widgets/SybilionAppHeader';
28
- import { GearSixIcon, UserCircleIcon } from '@phosphor-icons/react';
29
- import { House } from 'lucide-react';
30
-
31
- import { AppPageHeader } from '../components/AppPageHeader/AppPageHeader';
32
- import { DocsHeaderActions } from '../docsHeaderActions';
33
- import S from './StandaloneAppLayoutPage.styl';
34
-
35
- const MOCK_DATASETS: SidebarDatasetsItemsGroupedDataset[] = [
36
- {
37
- id: 1,
38
- name: 'Acetic Acid Price - China - Dollar/MT',
39
- status: 'active',
40
- created_at: '2024-01-01',
41
- updated_at: '2024-01-02',
42
- keywords: '',
43
- category: { id: 10, name: 'Chemicals' },
44
- target_type_id: 1,
45
- target_type: { id: 1, name: 'Commodity price' },
46
- trend: 0,
47
- regular_price: '0',
48
- sale_price: '0',
49
- regions: [
50
- { id: 1, name: 'Asia' },
51
- { id: 2, name: 'China' },
52
- ],
53
- unit: { id: 1, name: 'USD/MT' },
54
- },
55
- {
56
- id: 2,
57
- name: 'Freight index — spot volume (China)',
58
- status: 'active',
59
- created_at: '2024-01-01',
60
- updated_at: '2024-01-02',
61
- keywords: '',
62
- category: { id: 10, name: 'Chemicals' },
63
- target_type_id: 2,
64
- target_type: { id: 2, name: 'Freight index' },
65
- trend: 0,
66
- regular_price: '0',
67
- sale_price: '0',
68
- regions: [
69
- { id: 1, name: 'Asia' },
70
- { id: 2, name: 'China' },
71
- ],
72
- unit: { id: 1, name: 'Index' },
73
- },
74
- {
75
- id: 3,
76
- name: 'Ethanol Price Europe Per Kg In USD',
77
- status: 'active',
78
- created_at: '2024-01-01',
79
- updated_at: '2024-01-02',
80
- keywords: '',
81
- category: { id: 11, name: 'Energy' },
82
- target_type_id: 1,
83
- target_type: { id: 1, name: 'Commodity price' },
84
- trend: 0,
85
- regular_price: '0',
86
- sale_price: '0',
87
- regions: [{ id: 5, name: 'Europe' }],
88
- unit: { id: 1, name: 'USD/kg' },
89
- },
90
- ];
91
-
92
- type PreviewPanel = 'home' | 'datasets';
93
-
94
- const TEST_HEADER_ID = 'test-header-id';
95
-
96
- const DOCS_WORKSPACE_APPS_LS_KEY = 'uilib.docs.workspaceApps';
97
-
98
- const DOCS_PREVIEW_APPS: WorkspaceAppEntry[] = [
99
- {
100
- id: 'docs-home',
101
- displayName: 'Datasets Dashboard',
102
- subtitle: 'Data analysis tools',
103
- iconKey: 'grid-four',
104
- accent: '#0d9488',
105
- accentMuted: 'rgba(13, 148, 136, 0.12)',
106
- href: '/docs-preview/home',
107
- matchPathPrefixes: ['/docs-preview/home'],
108
- },
109
- {
110
- id: 'docs-datasets',
111
- displayName: 'Datasets',
112
- subtitle: 'Dataset library',
113
- iconKey: 'package',
114
- accent: '#6366f1',
115
- accentMuted: 'rgba(99, 102, 241, 0.12)',
116
- href: '/docs-preview/datasets',
117
- matchPathPrefixes: ['/docs-preview/datasets'],
118
- },
119
- {
120
- id: 'my-custom-app',
121
- displayName: 'Custom app',
122
- subtitle: 'Slug-only app (sybilion.io/apps/…)',
123
- iconKey: 'boat',
124
- accent: '#0ea5e9',
125
- accentMuted: 'rgba(14, 165, 233, 0.12)',
126
- href: '/apps/my-custom-app',
127
- },
128
- ];
129
-
130
- function DemoAppSidebar({
131
- panel,
132
- onSelectPanel,
133
- selectedDatasetId,
134
- onSelectDatasetId,
135
- }: {
136
- panel: PreviewPanel;
137
- onSelectPanel: (p: PreviewPanel) => void;
138
- selectedDatasetId: number | undefined;
139
- onSelectDatasetId: (id: number | undefined) => void;
140
- }) {
141
- return (
142
- <Sidebar
143
- variant="inset"
144
- collapsible="offcanvas"
145
- style={{ maxHeight: '100%', height: '100%' }}
146
- >
147
- <SidebarContent>
148
- <SidebarDatasetsItemsGrouped
149
- preItems={
150
- <SidebarMenuItem>
151
- <SidebarMenuButton
152
- type="button"
153
- isActive={panel === 'home'}
154
- onClick={() => onSelectPanel('home')}
155
- >
156
- <House size={16} strokeWidth={1.75} aria-hidden />
157
- Home
158
- </SidebarMenuButton>
159
- </SidebarMenuItem>
160
- }
161
- groupBy="regions"
162
- datasets={MOCK_DATASETS}
163
- selectedDatasetId={selectedDatasetId}
164
- onDatasetClick={id => {
165
- onSelectDatasetId(id);
166
- onSelectPanel('datasets');
167
- }}
168
- />
169
- </SidebarContent>
170
- </Sidebar>
171
- );
172
- }
173
-
174
- function DemoMainBody({ panel }: { panel: PreviewPanel }) {
175
- if (panel === 'home') {
176
- return (
177
- <>
178
- <PageHeader
179
- breadcrumbs={[{ label: 'Home' }]}
180
- title="Home"
181
- subheader="Greenfield shell preview (no SDK or auth in this embed)."
182
- />
183
- <PageContent>
184
- <PageContentSection>
185
- <p style={{ margin: 0, color: 'var(--muted-foreground)' }}>
186
- Preview: greenfield shell layout only (no SDK or auth). Real SPA
187
- uses one top-level Router; this embed cannot nest MemoryRouter
188
- under docs BrowserRouter — sidebar uses local state instead of{' '}
189
- <code>NavLink</code> / <code>Routes</code>.
190
- </p>
191
- </PageContentSection>
192
- </PageContent>
193
- </>
194
- );
195
- }
196
-
197
- return (
198
- <>
199
- <PageHeader
200
- breadcrumbs={[{ label: 'Datasets' }]}
201
- title="Datasets"
202
- subheader="Sidebar + dataset list use local state (not Router)."
203
- />
204
- <PageContent>
205
- <PageContentSection>
206
- <p style={{ margin: 0, color: 'var(--muted-foreground)' }}>
207
- Use sidebar links and dataset rows; panel state stays inside this
208
- box.
209
- </p>
210
- </PageContentSection>
211
- </PageContent>
212
- </>
213
- );
214
- }
215
-
216
- function StandaloneLayoutPreview() {
217
- const [theme, setTheme] = useState<'light' | 'dark'>('light');
218
- const [panel, setPanel] = useState<PreviewPanel>('home');
219
- const [previewPath, setPreviewPath] = useState('/docs-preview/home');
220
- const [selectedDatasetId, setSelectedDatasetId] = useState<
221
- number | undefined
222
- >();
223
-
224
- const onThemeToggle = useCallback(() => {
225
- setTheme(t => (t === 'dark' ? 'light' : 'dark'));
226
- }, []);
227
-
228
- return (
229
- <div className={S.preview}>
230
- <PageScroll rootClassName={S.previewScrollRoot}>
231
- <AppShell>
232
- <DemoAppSidebar
233
- panel={panel}
234
- onSelectPanel={setPanel}
235
- selectedDatasetId={selectedDatasetId}
236
- onSelectDatasetId={setSelectedDatasetId}
237
- />
238
-
239
- <AppShellMainContent
240
- header={<AppHeaderHost anchorId={TEST_HEADER_ID} />}
241
- footer={
242
- <PageFooter
243
- versionLink="#standalone-layout-preview"
244
- versionLabel="0.0.0-preview"
245
- />
246
- }
247
- >
248
- <SybilionAppHeader
249
- pageHeaderId={TEST_HEADER_ID}
250
- pathname={previewPath}
251
- onNavigate={setPreviewPath}
252
- authenticated
253
- appsStorageKey={DOCS_WORKSPACE_APPS_LS_KEY}
254
- defaultApps={DOCS_PREVIEW_APPS}
255
- user={{
256
- name: 'Preview User',
257
- email: 'preview@example.com',
258
- avatar: '',
259
- }}
260
- theme={theme}
261
- onThemeToggle={onThemeToggle}
262
- onLogout={() => undefined}
263
- menuItems={
264
- <>
265
- <DropdownMenuItem>
266
- <UserCircleIcon />
267
- Account (preview)
268
- </DropdownMenuItem>
269
- <DropdownMenuItem>
270
- <GearSixIcon />
271
- Settings (preview)
272
- </DropdownMenuItem>
273
- </>
274
- }
275
- />
276
- <DemoMainBody panel={panel} />
277
- </AppShellMainContent>
278
- </AppShell>
279
- </PageScroll>
280
- </div>
281
- );
282
- }
283
-
284
- export default function StandaloneAppLayoutPage() {
285
- return (
286
- <>
287
- <AppPageHeader
288
- breadcrumbs={[{ label: 'Standalone app layout' }]}
289
- title="Standalone app layout"
290
- subheader={
291
- <>
292
- Live preview of AppShell + Sidebar + main column from
293
- docs/standalone-apps.md §4. <br />
294
- Full greenfield setup (deps, global CSS, SybilionAuthProvider, SDK)
295
- lives in that doc — this page is layout only.
296
- </>
297
- }
298
- actions={<DocsHeaderActions />}
299
- />
300
- <PageContentSection title="Embedded mini-app (layout preview)">
301
- <SidebarProvider
302
- sidebarWidthStorageKey="uilib.docs.standaloneLayout.sidebarWidthPx"
303
- persistSidebarWidthWithoutConsent
304
- >
305
- <StandaloneLayoutPreview />
306
- </SidebarProvider>
307
- </PageContentSection>
308
- </>
309
- );
310
- }