@modern-admin/react 0.1.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/dist/action-guard.d.ts +13 -0
- package/dist/action-guard.d.ts.map +1 -0
- package/dist/action-guard.js +15 -0
- package/dist/action-guard.js.map +1 -0
- package/dist/action-menu.d.ts +17 -0
- package/dist/action-menu.d.ts.map +1 -0
- package/dist/action-menu.jsx +80 -0
- package/dist/action-menu.jsx.map +1 -0
- package/dist/admin-app.d.ts +23 -0
- package/dist/admin-app.d.ts.map +1 -0
- package/dist/admin-app.jsx +407 -0
- package/dist/admin-app.jsx.map +1 -0
- package/dist/admin-router.d.ts +29 -0
- package/dist/admin-router.d.ts.map +1 -0
- package/dist/admin-router.jsx +215 -0
- package/dist/admin-router.jsx.map +1 -0
- package/dist/breadcrumbs.d.ts +17 -0
- package/dist/breadcrumbs.d.ts.map +1 -0
- package/dist/breadcrumbs.jsx +40 -0
- package/dist/breadcrumbs.jsx.map +1 -0
- package/dist/client.d.ts +526 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +582 -0
- package/dist/client.js.map +1 -0
- package/dist/component-loader.d.ts +10 -0
- package/dist/component-loader.d.ts.map +1 -0
- package/dist/component-loader.js +23 -0
- package/dist/component-loader.js.map +1 -0
- package/dist/components/ai-assistant-widget.d.ts +3 -0
- package/dist/components/ai-assistant-widget.d.ts.map +1 -0
- package/dist/components/ai-assistant-widget.jsx +390 -0
- package/dist/components/ai-assistant-widget.jsx.map +1 -0
- package/dist/components/ai-fill-dialog.d.ts +9 -0
- package/dist/components/ai-fill-dialog.d.ts.map +1 -0
- package/dist/components/ai-fill-dialog.jsx +105 -0
- package/dist/components/ai-fill-dialog.jsx.map +1 -0
- package/dist/components/chart-builder-dialog.d.ts +10 -0
- package/dist/components/chart-builder-dialog.d.ts.map +1 -0
- package/dist/components/chart-builder-dialog.jsx +433 -0
- package/dist/components/chart-builder-dialog.jsx.map +1 -0
- package/dist/components/chart-widget.d.ts +12 -0
- package/dist/components/chart-widget.d.ts.map +1 -0
- package/dist/components/chart-widget.jsx +365 -0
- package/dist/components/chart-widget.jsx.map +1 -0
- package/dist/components/global-search-dialog.d.ts +7 -0
- package/dist/components/global-search-dialog.d.ts.map +1 -0
- package/dist/components/global-search-dialog.jsx +187 -0
- package/dist/components/global-search-dialog.jsx.map +1 -0
- package/dist/components/group-settings-dialog.d.ts +13 -0
- package/dist/components/group-settings-dialog.d.ts.map +1 -0
- package/dist/components/group-settings-dialog.jsx +53 -0
- package/dist/components/group-settings-dialog.jsx.map +1 -0
- package/dist/components/move-chart-dialog.d.ts +18 -0
- package/dist/components/move-chart-dialog.d.ts.map +1 -0
- package/dist/components/move-chart-dialog.jsx +68 -0
- package/dist/components/move-chart-dialog.jsx.map +1 -0
- package/dist/components/reference-multi-table-dialog.d.ts +12 -0
- package/dist/components/reference-multi-table-dialog.d.ts.map +1 -0
- package/dist/components/reference-multi-table-dialog.jsx +126 -0
- package/dist/components/reference-multi-table-dialog.jsx.map +1 -0
- package/dist/components/related-records-tabs.d.ts +8 -0
- package/dist/components/related-records-tabs.d.ts.map +1 -0
- package/dist/components/related-records-tabs.jsx +75 -0
- package/dist/components/related-records-tabs.jsx.map +1 -0
- package/dist/components/revisions-button.d.ts +7 -0
- package/dist/components/revisions-button.d.ts.map +1 -0
- package/dist/components/revisions-button.jsx +152 -0
- package/dist/components/revisions-button.jsx.map +1 -0
- package/dist/components/wizard-form.d.ts +43 -0
- package/dist/components/wizard-form.d.ts.map +1 -0
- package/dist/components/wizard-form.jsx +136 -0
- package/dist/components/wizard-form.jsx.map +1 -0
- package/dist/dashboard/time-series.d.ts +20 -0
- package/dist/dashboard/time-series.d.ts.map +1 -0
- package/dist/dashboard/time-series.js +108 -0
- package/dist/dashboard/time-series.js.map +1 -0
- package/dist/dialogs.d.ts +35 -0
- package/dist/dialogs.d.ts.map +1 -0
- package/dist/dialogs.jsx +152 -0
- package/dist/dialogs.jsx.map +1 -0
- package/dist/export.d.ts +39 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +114 -0
- package/dist/export.js.map +1 -0
- package/dist/extension-registry.d.ts +122 -0
- package/dist/extension-registry.d.ts.map +1 -0
- package/dist/extension-registry.js +93 -0
- package/dist/extension-registry.js.map +1 -0
- package/dist/header-controls.d.ts +4 -0
- package/dist/header-controls.d.ts.map +1 -0
- package/dist/header-controls.jsx +70 -0
- package/dist/header-controls.jsx.map +1 -0
- package/dist/hooks.d.ts +104 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +374 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hotkey-help.d.ts +3 -0
- package/dist/hotkey-help.d.ts.map +1 -0
- package/dist/hotkey-help.jsx +32 -0
- package/dist/hotkey-help.jsx.map +1 -0
- package/dist/hotkey-registry.d.ts +18 -0
- package/dist/hotkey-registry.d.ts.map +1 -0
- package/dist/hotkey-registry.jsx +34 -0
- package/dist/hotkey-registry.jsx.map +1 -0
- package/dist/i18n.d.ts +74 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.jsx +127 -0
- package/dist/i18n.jsx.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/notify.d.ts +41 -0
- package/dist/notify.d.ts.map +1 -0
- package/dist/notify.jsx +58 -0
- package/dist/notify.jsx.map +1 -0
- package/dist/pages/ai-assistant-settings-section.d.ts +3 -0
- package/dist/pages/ai-assistant-settings-section.d.ts.map +1 -0
- package/dist/pages/ai-assistant-settings-section.jsx +126 -0
- package/dist/pages/ai-assistant-settings-section.jsx.map +1 -0
- package/dist/pages/audit-log-page.d.ts +3 -0
- package/dist/pages/audit-log-page.d.ts.map +1 -0
- package/dist/pages/audit-log-page.jsx +354 -0
- package/dist/pages/audit-log-page.jsx.map +1 -0
- package/dist/pages/edit-page.d.ts +7 -0
- package/dist/pages/edit-page.d.ts.map +1 -0
- package/dist/pages/edit-page.jsx +614 -0
- package/dist/pages/edit-page.jsx.map +1 -0
- package/dist/pages/export-dialog.d.ts +11 -0
- package/dist/pages/export-dialog.d.ts.map +1 -0
- package/dist/pages/export-dialog.jsx +102 -0
- package/dist/pages/export-dialog.jsx.map +1 -0
- package/dist/pages/home-page.d.ts +3 -0
- package/dist/pages/home-page.d.ts.map +1 -0
- package/dist/pages/home-page.jsx +211 -0
- package/dist/pages/home-page.jsx.map +1 -0
- package/dist/pages/list-page.d.ts +42 -0
- package/dist/pages/list-page.d.ts.map +1 -0
- package/dist/pages/list-page.jsx +1596 -0
- package/dist/pages/list-page.jsx.map +1 -0
- package/dist/pages/login-page.d.ts +11 -0
- package/dist/pages/login-page.d.ts.map +1 -0
- package/dist/pages/login-page.jsx +157 -0
- package/dist/pages/login-page.jsx.map +1 -0
- package/dist/pages/settings-page.d.ts +5 -0
- package/dist/pages/settings-page.d.ts.map +1 -0
- package/dist/pages/settings-page.jsx +787 -0
- package/dist/pages/settings-page.jsx.map +1 -0
- package/dist/pages/settings-shared.d.ts +51 -0
- package/dist/pages/settings-shared.d.ts.map +1 -0
- package/dist/pages/settings-shared.jsx +66 -0
- package/dist/pages/settings-shared.jsx.map +1 -0
- package/dist/pages/show-page.d.ts +7 -0
- package/dist/pages/show-page.d.ts.map +1 -0
- package/dist/pages/show-page.jsx +147 -0
- package/dist/pages/show-page.jsx.map +1 -0
- package/dist/pages/wizard-create-page.d.ts +14 -0
- package/dist/pages/wizard-create-page.d.ts.map +1 -0
- package/dist/pages/wizard-create-page.jsx +106 -0
- package/dist/pages/wizard-create-page.jsx.map +1 -0
- package/dist/property-renderer.d.ts +8 -0
- package/dist/property-renderer.d.ts.map +1 -0
- package/dist/property-renderer.jsx +690 -0
- package/dist/property-renderer.jsx.map +1 -0
- package/dist/provider.d.ts +20 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.jsx +32 -0
- package/dist/provider.jsx.map +1 -0
- package/dist/realtime.d.ts +22 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +38 -0
- package/dist/realtime.js.map +1 -0
- package/dist/reference.d.ts +52 -0
- package/dist/reference.d.ts.map +1 -0
- package/dist/reference.jsx +224 -0
- package/dist/reference.jsx.map +1 -0
- package/dist/relations.d.ts +11 -0
- package/dist/relations.d.ts.map +1 -0
- package/dist/relations.js +36 -0
- package/dist/relations.js.map +1 -0
- package/dist/router.d.ts +82 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.jsx +187 -0
- package/dist/router.jsx.map +1 -0
- package/dist/show-when.d.ts +7 -0
- package/dist/show-when.d.ts.map +1 -0
- package/dist/show-when.js +77 -0
- package/dist/show-when.js.map +1 -0
- package/dist/types.d.ts +194 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/dist/types.js.map +1 -0
- package/dist/use-dashboard-charts.d.ts +93 -0
- package/dist/use-dashboard-charts.d.ts.map +1 -0
- package/dist/use-dashboard-charts.js +263 -0
- package/dist/use-dashboard-charts.js.map +1 -0
- package/dist/use-hotkey.d.ts +17 -0
- package/dist/use-hotkey.d.ts.map +1 -0
- package/dist/use-hotkey.js +103 -0
- package/dist/use-hotkey.js.map +1 -0
- package/dist/user-directory.d.ts +18 -0
- package/dist/user-directory.d.ts.map +1 -0
- package/dist/user-directory.js +51 -0
- package/dist/user-directory.js.map +1 -0
- package/dist/validation.d.ts +22 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +338 -0
- package/dist/validation.js.map +1 -0
- package/package.json +59 -0
- package/src/action-guard.ts +20 -0
- package/src/action-menu.tsx +161 -0
- package/src/admin-app.tsx +630 -0
- package/src/admin-router.tsx +273 -0
- package/src/breadcrumbs.tsx +75 -0
- package/src/client.ts +1093 -0
- package/src/component-loader.ts +33 -0
- package/src/components/ai-assistant-widget.tsx +565 -0
- package/src/components/ai-fill-dialog.tsx +143 -0
- package/src/components/chart-builder-dialog.tsx +618 -0
- package/src/components/chart-widget.tsx +654 -0
- package/src/components/global-search-dialog.tsx +272 -0
- package/src/components/group-settings-dialog.tsx +93 -0
- package/src/components/move-chart-dialog.tsx +130 -0
- package/src/components/reference-multi-table-dialog.tsx +196 -0
- package/src/components/related-records-tabs.tsx +130 -0
- package/src/components/revisions-button.tsx +237 -0
- package/src/components/wizard-form.tsx +302 -0
- package/src/dashboard/time-series.ts +125 -0
- package/src/dialogs.tsx +265 -0
- package/src/export.ts +140 -0
- package/src/extension-registry.ts +195 -0
- package/src/header-controls.tsx +125 -0
- package/src/hooks.ts +509 -0
- package/src/hotkey-help.tsx +56 -0
- package/src/hotkey-registry.tsx +60 -0
- package/src/i18n.tsx +267 -0
- package/src/index.ts +192 -0
- package/src/notify.tsx +94 -0
- package/src/pages/ai-assistant-settings-section.tsx +167 -0
- package/src/pages/audit-log-page.tsx +580 -0
- package/src/pages/edit-page.tsx +743 -0
- package/src/pages/export-dialog.tsx +154 -0
- package/src/pages/home-page.tsx +318 -0
- package/src/pages/list-page.tsx +2645 -0
- package/src/pages/login-page.tsx +242 -0
- package/src/pages/settings-page.tsx +1143 -0
- package/src/pages/settings-shared.tsx +134 -0
- package/src/pages/show-page.tsx +223 -0
- package/src/pages/wizard-create-page.tsx +164 -0
- package/src/property-renderer.tsx +1143 -0
- package/src/provider.tsx +70 -0
- package/src/realtime.ts +55 -0
- package/src/reference.tsx +386 -0
- package/src/relations.ts +55 -0
- package/src/router.tsx +211 -0
- package/src/show-when.ts +76 -0
- package/src/types.ts +198 -0
- package/src/use-dashboard-charts.ts +362 -0
- package/src/use-hotkey.ts +128 -0
- package/src/user-directory.ts +56 -0
- package/src/validation.ts +361 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type Control, type UseFormTrigger } from 'react-hook-form';
|
|
3
|
+
import type { PropertyJSON } from '../types.js';
|
|
4
|
+
export interface WizardStep {
|
|
5
|
+
/** Short label shown in the step indicator circles */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Optional longer description rendered below the step indicator */
|
|
8
|
+
description?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Property paths (from the resource) to show in this step.
|
|
11
|
+
* If omitted on exactly one step, that step receives all properties not
|
|
12
|
+
* claimed by the other steps (catch-all).
|
|
13
|
+
*/
|
|
14
|
+
properties?: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface WizardFormLabels {
|
|
17
|
+
back?: string;
|
|
18
|
+
next?: string;
|
|
19
|
+
submit?: string;
|
|
20
|
+
cancel?: string;
|
|
21
|
+
/** Template: 'Step {current} of {total}' — shown only on mobile */
|
|
22
|
+
stepOf?: string;
|
|
23
|
+
}
|
|
24
|
+
type FormValues = Record<string, unknown>;
|
|
25
|
+
export interface WizardFormProps {
|
|
26
|
+
steps: WizardStep[];
|
|
27
|
+
/** All editable properties of the resource. */
|
|
28
|
+
properties: PropertyJSON[];
|
|
29
|
+
resourceId: string;
|
|
30
|
+
control: Control<FormValues>;
|
|
31
|
+
trigger: UseFormTrigger<FormValues>;
|
|
32
|
+
onSubmit: () => void;
|
|
33
|
+
onCancel: () => void;
|
|
34
|
+
isSubmitting?: boolean;
|
|
35
|
+
submitError?: string | null;
|
|
36
|
+
labels?: WizardFormLabels;
|
|
37
|
+
}
|
|
38
|
+
export declare function WizardForm({ steps, properties, resourceId, control, trigger, onSubmit, onCancel, isSubmitting, submitError, labels, }: WizardFormProps): React.ReactElement;
|
|
39
|
+
export declare namespace WizardForm {
|
|
40
|
+
var displayName: string;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=wizard-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wizard-form.d.ts","sourceRoot":"","sources":["../../src/components/wizard-form.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAY,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAa7E,OAAO,KAAK,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
2
|
+
// resource's editable properties. Clicking "Next" validates only the current
|
|
3
|
+
// step's fields before advancing; "Back" never re-validates. "Create" on the
|
|
4
|
+
// final step triggers the caller-supplied submit handler.
|
|
5
|
+
//
|
|
6
|
+
// The component is i18n-unaware: all visible strings are passed via the
|
|
7
|
+
// `labels` prop with English defaults. The ResourceWizardCreatePage calls
|
|
8
|
+
// t() and wires the results in.
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { useWatch } from 'react-hook-form';
|
|
11
|
+
import { Button, Field, FieldError, FieldLabel, FormField, InfoTooltip, cn, } from '@modern-admin/ui';
|
|
12
|
+
import { Check, ChevronLeft, ChevronRight, Plus, X } from 'lucide-react';
|
|
13
|
+
import { PropertyEditor } from '../property-renderer.js';
|
|
14
|
+
import { evaluateShowWhen } from '../show-when.js';
|
|
15
|
+
// ── WizardForm ────────────────────────────────────────────────────────────────
|
|
16
|
+
export function WizardForm({ steps, properties, resourceId, control, trigger, onSubmit, onCancel, isSubmitting = false, submitError, labels = {}, }) {
|
|
17
|
+
const backLabel = labels.back ?? 'Back';
|
|
18
|
+
const nextLabel = labels.next ?? 'Next';
|
|
19
|
+
const submitLabel = labels.submit ?? 'Create';
|
|
20
|
+
const cancelLabel = labels.cancel ?? 'Cancel';
|
|
21
|
+
const stepOfTemplate = labels.stepOf ?? 'Step {current} of {total}';
|
|
22
|
+
const [currentStep, setCurrentStep] = React.useState(0);
|
|
23
|
+
// ── Distribute properties across steps ───────────────────────────────────
|
|
24
|
+
const stepProperties = React.useMemo(() => {
|
|
25
|
+
const claimedPaths = new Set(steps.flatMap((s) => s.properties ?? []));
|
|
26
|
+
const unclaimed = properties.filter((p) => !claimedPaths.has(p.path));
|
|
27
|
+
return steps.map((step) => {
|
|
28
|
+
if (step.properties) {
|
|
29
|
+
return step.properties
|
|
30
|
+
.map((path) => properties.find((p) => p.path === path))
|
|
31
|
+
.filter((p) => p != null);
|
|
32
|
+
}
|
|
33
|
+
return unclaimed;
|
|
34
|
+
});
|
|
35
|
+
}, [steps, properties]);
|
|
36
|
+
const totalSteps = steps.length;
|
|
37
|
+
const isFirst = currentStep === 0;
|
|
38
|
+
const isLast = currentStep === totalSteps - 1;
|
|
39
|
+
const handleNext = async () => {
|
|
40
|
+
const paths = (stepProperties[currentStep] ?? []).map((p) => p.path);
|
|
41
|
+
// When the step has no properties, advance without validation.
|
|
42
|
+
const valid = paths.length === 0 ||
|
|
43
|
+
(await trigger(paths));
|
|
44
|
+
if (valid)
|
|
45
|
+
setCurrentStep((s) => Math.min(s + 1, totalSteps - 1));
|
|
46
|
+
};
|
|
47
|
+
const currentStepDef = steps[currentStep];
|
|
48
|
+
const currentProperties = stepProperties[currentStep] ?? [];
|
|
49
|
+
const stepOfLabel = stepOfTemplate
|
|
50
|
+
.replace('{current}', String(currentStep + 1))
|
|
51
|
+
.replace('{total}', String(totalSteps));
|
|
52
|
+
return (<div>
|
|
53
|
+
{/* ── Step indicator ──────────────────────────────────────────── */}
|
|
54
|
+
<div className="px-6 pt-6 pb-5">
|
|
55
|
+
<div className="flex w-full max-w-xl items-start mx-auto">
|
|
56
|
+
{steps.map((step, index) => (<React.Fragment key={index}>
|
|
57
|
+
{/* Step node */}
|
|
58
|
+
<div className="flex shrink-0 flex-col items-center">
|
|
59
|
+
<div className={cn('flex h-8 w-8 items-center justify-center rounded-full border-2 text-sm font-semibold transition-colors', index < currentStep &&
|
|
60
|
+
'border-primary bg-primary text-primary-foreground', index === currentStep &&
|
|
61
|
+
'border-primary bg-background text-primary', index > currentStep &&
|
|
62
|
+
'border-border bg-background text-muted-foreground')}>
|
|
63
|
+
{index < currentStep ? (<Check className="size-3.5"/>) : (index + 1)}
|
|
64
|
+
</div>
|
|
65
|
+
<span className={cn('mt-1.5 hidden max-w-[6rem] text-center text-xs leading-tight sm:block', index === currentStep
|
|
66
|
+
? 'font-medium text-foreground'
|
|
67
|
+
: index < currentStep
|
|
68
|
+
? 'text-primary'
|
|
69
|
+
: 'text-muted-foreground')}>
|
|
70
|
+
{step.label}
|
|
71
|
+
</span>
|
|
72
|
+
</div>
|
|
73
|
+
{/* Connector line between nodes */}
|
|
74
|
+
{index < steps.length - 1 && (<div className={cn('mx-2 mt-3.5 h-0.5 flex-1 transition-colors', index < currentStep ? 'bg-primary' : 'bg-border')}/>)}
|
|
75
|
+
</React.Fragment>))}
|
|
76
|
+
</div>
|
|
77
|
+
{/* Mobile: compact "Step N of M · Label" summary */}
|
|
78
|
+
<p className="mt-2 text-center text-xs text-muted-foreground sm:hidden">
|
|
79
|
+
{stepOfLabel}
|
|
80
|
+
{currentStepDef.label ? ` · ${currentStepDef.label}` : ''}
|
|
81
|
+
</p>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
{/* ── Step description ────────────────────────────────────────── */}
|
|
85
|
+
{currentStepDef.description && (<p className="px-6 pb-2 text-sm text-muted-foreground">
|
|
86
|
+
{currentStepDef.description}
|
|
87
|
+
</p>)}
|
|
88
|
+
|
|
89
|
+
{/* ── Fields ──────────────────────────────────────────────────── */}
|
|
90
|
+
<div className="gap-4 px-6 pb-4 [column-fill:_balance] md:columns-2">
|
|
91
|
+
{currentProperties.map((property) => (<WizardConditionalField key={property.path} control={control} property={property}>
|
|
92
|
+
<FormField control={control} name={property.path} render={({ field, fieldState }) => (<Field data-invalid={fieldState.error ? true : undefined} className="mb-8 break-inside-avoid">
|
|
93
|
+
<FieldLabel htmlFor={field.name}>
|
|
94
|
+
{property.label}
|
|
95
|
+
{property.description ? (<InfoTooltip content={property.description} ariaLabel={property.description}/>) : null}
|
|
96
|
+
{property.isRequired && (<span className="ml-1 text-destructive">*</span>)}
|
|
97
|
+
</FieldLabel>
|
|
98
|
+
<PropertyEditor property={property} value={field.value} onChange={field.onChange} disabled={isSubmitting} resourceId={resourceId}/>
|
|
99
|
+
{fieldState.error?.message && (<FieldError>{fieldState.error.message}</FieldError>)}
|
|
100
|
+
</Field>)}/>
|
|
101
|
+
</WizardConditionalField>))}
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
{/* ── Navigation footer ───────────────────────────────────────── */}
|
|
105
|
+
<div className="flex items-center justify-between border-t border-border px-6 py-4">
|
|
106
|
+
<div>
|
|
107
|
+
{submitError && (<span className="text-sm text-destructive">{submitError}</span>)}
|
|
108
|
+
</div>
|
|
109
|
+
<div className="flex gap-2">
|
|
110
|
+
{isFirst ? (<Button type="button" variant="ghost" onClick={onCancel} disabled={isSubmitting}>
|
|
111
|
+
<X className="size-4"/>
|
|
112
|
+
{cancelLabel}
|
|
113
|
+
</Button>) : (<Button type="button" variant="outline" onClick={() => setCurrentStep((s) => s - 1)} disabled={isSubmitting}>
|
|
114
|
+
<ChevronLeft className="size-4"/>
|
|
115
|
+
{backLabel}
|
|
116
|
+
</Button>)}
|
|
117
|
+
{isLast ? (<Button type="button" onClick={onSubmit} disabled={isSubmitting}>
|
|
118
|
+
<Plus className="size-4"/>
|
|
119
|
+
{submitLabel}
|
|
120
|
+
</Button>) : (<Button type="button" onClick={() => void handleNext()} disabled={isSubmitting}>
|
|
121
|
+
{nextLabel}
|
|
122
|
+
<ChevronRight className="size-4"/>
|
|
123
|
+
</Button>)}
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>);
|
|
127
|
+
}
|
|
128
|
+
WizardForm.displayName = 'WizardForm';
|
|
129
|
+
function WizardConditionalField({ control, property, children, }) {
|
|
130
|
+
const rule = property.showWhen;
|
|
131
|
+
const watched = useWatch({ control, name: rule?.field ?? property.path });
|
|
132
|
+
if (!rule)
|
|
133
|
+
return <>{children}</>;
|
|
134
|
+
return evaluateShowWhen(rule, { [rule.field]: watched }) ? <>{children}</> : null;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=wizard-form.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wizard-form.jsx","sourceRoot":"","sources":["../../src/components/wizard-form.tsx"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,6EAA6E;AAC7E,6EAA6E;AAC7E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AI,CAAC,SAAS,CAAC,QAAQ,EACxB;cAAA,CAAC,WAAW,CACd;YAAA,EAAE,MAAM,CAAC,CACV,CAAC,CAAC,CAAC,CACF,CAAC,MAAM,CACL,IAAI,CAAC,QAAQ,CACb,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,UAAU,EAAE,CAAC,CACjC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAEvB;cAAA,CAAC,SAAS,CACV;cAAA,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,EAClC;YAAA,EAAE,MAAM,CAAC,CACV,CACH;QAAA,EAAE,GAAG,CACP;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,GAAG,CAAC,CACP,CAAA;AACH,CAAC;AAED,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;AAWrC,SAAS,sBAAsB,CAAC,EAC9B,OAAO,EACP,QAAQ,EACR,QAAQ,GACoB;IAC5B,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAA;IAC9B,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IACzE,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAA;IACjC,OAAO,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AACnF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TimeSeriesSeries, TimeSeriesStep } from '../client.js';
|
|
2
|
+
/** Generate a continuous sequence of `YYYY-MM-DD` bucket keys spanning [from, to]. */
|
|
3
|
+
export declare function generateBuckets(fromIso: string, toIso: string, step: TimeSeriesStep): string[];
|
|
4
|
+
/**
|
|
5
|
+
* Zero-fill every series so each one has a value for every bucket in the
|
|
6
|
+
* resolved date range. Missing buckets become `value: 0` rather than gaps,
|
|
7
|
+
* which Recharts renders as flat segments instead of breaks.
|
|
8
|
+
*/
|
|
9
|
+
export declare function fillTimeSeries(series: TimeSeriesSeries[], fromIso: string, toIso: string, step: TimeSeriesStep): TimeSeriesSeries[];
|
|
10
|
+
/**
|
|
11
|
+
* X-axis tick formatter — short label format depending on bucket size.
|
|
12
|
+
* day/week → DD.MM, month → MM.YYYY, year → YYYY.
|
|
13
|
+
*/
|
|
14
|
+
export declare function makeTickFormatter(step: TimeSeriesStep, locale?: string): (iso: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Tooltip label formatter — long, human-friendly form. For week buckets
|
|
17
|
+
* we render `Mon DD – Sun DD` (the bucket plus 6 days).
|
|
18
|
+
*/
|
|
19
|
+
export declare function makeLabelFormatter(step: TimeSeriesStep, locale?: string): (iso: string) => string;
|
|
20
|
+
//# sourceMappingURL=time-series.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-series.d.ts","sourceRoot":"","sources":["../../src/dashboard/time-series.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAA;AAErB,sFAAsF;AACtF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,cAAc,GACnB,MAAM,EAAE,CAUV;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,gBAAgB,EAAE,EAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,cAAc,GACnB,gBAAgB,EAAE,CAUpB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,cAAc,EACpB,MAAM,SAAU,GACf,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAUzB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,cAAc,EACpB,MAAM,SAAU,GACf,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAoBzB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Time-series UI helpers — bucket fill, tick formatting, label formatting.
|
|
2
|
+
// All zero-fill happens here on the client side (req: "Заполнение нулями
|
|
3
|
+
// должно быть только в ui, вне зависимости от адаптеров"). Adapters return
|
|
4
|
+
// only buckets that have data; the UI fabricates the rest at value 0 so
|
|
5
|
+
// charts don't have visual gaps.
|
|
6
|
+
/** Generate a continuous sequence of `YYYY-MM-DD` bucket keys spanning [from, to]. */
|
|
7
|
+
export function generateBuckets(fromIso, toIso, step) {
|
|
8
|
+
if (step === 'all')
|
|
9
|
+
return [fromIso.slice(0, 10)];
|
|
10
|
+
const out = [];
|
|
11
|
+
const cur = startOf(new Date(fromIso), step);
|
|
12
|
+
const end = startOf(new Date(toIso), step);
|
|
13
|
+
while (cur.getTime() <= end.getTime()) {
|
|
14
|
+
out.push(ymd(cur));
|
|
15
|
+
advance(cur, step);
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Zero-fill every series so each one has a value for every bucket in the
|
|
21
|
+
* resolved date range. Missing buckets become `value: 0` rather than gaps,
|
|
22
|
+
* which Recharts renders as flat segments instead of breaks.
|
|
23
|
+
*/
|
|
24
|
+
export function fillTimeSeries(series, fromIso, toIso, step) {
|
|
25
|
+
const buckets = generateBuckets(fromIso, toIso, step);
|
|
26
|
+
return series.map((s) => {
|
|
27
|
+
const map = new Map(s.points.map((p) => [p.date, p.value]));
|
|
28
|
+
const points = buckets.map((date) => ({
|
|
29
|
+
date,
|
|
30
|
+
value: map.get(date) ?? 0,
|
|
31
|
+
}));
|
|
32
|
+
return { key: s.key, points };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* X-axis tick formatter — short label format depending on bucket size.
|
|
37
|
+
* day/week → DD.MM, month → MM.YYYY, year → YYYY.
|
|
38
|
+
*/
|
|
39
|
+
export function makeTickFormatter(step, locale = 'en-US') {
|
|
40
|
+
const dayMonth = new Intl.DateTimeFormat(locale, { day: '2-digit', month: '2-digit' });
|
|
41
|
+
const monthYear = new Intl.DateTimeFormat(locale, { month: '2-digit', year: 'numeric' });
|
|
42
|
+
const year = new Intl.DateTimeFormat(locale, { year: 'numeric' });
|
|
43
|
+
return (iso) => {
|
|
44
|
+
const d = new Date(iso);
|
|
45
|
+
if (step === 'year')
|
|
46
|
+
return year.format(d);
|
|
47
|
+
if (step === 'month')
|
|
48
|
+
return monthYear.format(d);
|
|
49
|
+
return dayMonth.format(d);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Tooltip label formatter — long, human-friendly form. For week buckets
|
|
54
|
+
* we render `Mon DD – Sun DD` (the bucket plus 6 days).
|
|
55
|
+
*/
|
|
56
|
+
export function makeLabelFormatter(step, locale = 'en-US') {
|
|
57
|
+
const fullDay = new Intl.DateTimeFormat(locale, {
|
|
58
|
+
day: '2-digit',
|
|
59
|
+
month: 'long',
|
|
60
|
+
year: 'numeric',
|
|
61
|
+
});
|
|
62
|
+
const monthYear = new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' });
|
|
63
|
+
const year = new Intl.DateTimeFormat(locale, { year: 'numeric' });
|
|
64
|
+
const shortDay = new Intl.DateTimeFormat(locale, { day: '2-digit', month: 'short' });
|
|
65
|
+
return (iso) => {
|
|
66
|
+
const d = new Date(iso);
|
|
67
|
+
if (step === 'year')
|
|
68
|
+
return year.format(d);
|
|
69
|
+
if (step === 'month')
|
|
70
|
+
return monthYear.format(d);
|
|
71
|
+
if (step === 'week') {
|
|
72
|
+
const end = new Date(d);
|
|
73
|
+
end.setDate(end.getDate() + 6);
|
|
74
|
+
return `${shortDay.format(d)} – ${shortDay.format(end)}`;
|
|
75
|
+
}
|
|
76
|
+
return fullDay.format(d);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// ─── Internals ────────────────────────────────────────────────────────────
|
|
80
|
+
function ymd(d) {
|
|
81
|
+
return d.toISOString().slice(0, 10);
|
|
82
|
+
}
|
|
83
|
+
function startOf(d, step) {
|
|
84
|
+
const out = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
|
|
85
|
+
if (step === 'week') {
|
|
86
|
+
// Monday-anchored week.
|
|
87
|
+
const dow = (out.getUTCDay() + 6) % 7;
|
|
88
|
+
out.setUTCDate(out.getUTCDate() - dow);
|
|
89
|
+
}
|
|
90
|
+
else if (step === 'month') {
|
|
91
|
+
out.setUTCDate(1);
|
|
92
|
+
}
|
|
93
|
+
else if (step === 'year') {
|
|
94
|
+
out.setUTCMonth(0, 1);
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
function advance(d, step) {
|
|
99
|
+
if (step === 'day')
|
|
100
|
+
d.setUTCDate(d.getUTCDate() + 1);
|
|
101
|
+
else if (step === 'week')
|
|
102
|
+
d.setUTCDate(d.getUTCDate() + 7);
|
|
103
|
+
else if (step === 'month')
|
|
104
|
+
d.setUTCMonth(d.getUTCMonth() + 1);
|
|
105
|
+
else if (step === 'year')
|
|
106
|
+
d.setUTCFullYear(d.getUTCFullYear() + 1);
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=time-series.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-series.js","sourceRoot":"","sources":["../../src/dashboard/time-series.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,wEAAwE;AACxE,iCAAiC;AAQjC,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,KAAa,EACb,IAAoB;IAEpB,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE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AAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;QACrC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,GAAG,CAAC,CAAA;IACxC,CAAC;SAAM,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACvB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,OAAO,CAAC,CAAO,EAAE,IAAoB;IAC5C,IAAI,IAAI,KAAK,KAAK;QAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;SAC/C,IAAI,IAAI,KAAK,MAAM;QAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;SACrD,IAAI,IAAI,KAAK,OAAO;QAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAA;SACxD,IAAI,IAAI,KAAK,MAAM;QAAE,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface ConfirmOptions {
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
confirmLabel?: string;
|
|
6
|
+
cancelLabel?: string;
|
|
7
|
+
/** Style the confirm button as destructive (red). Useful for delete dialogs. */
|
|
8
|
+
destructive?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface AlertOptions {
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
okLabel?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface OpenOptions<T> {
|
|
16
|
+
render: (api: {
|
|
17
|
+
close: (value?: T) => void;
|
|
18
|
+
}) => React.ReactNode;
|
|
19
|
+
/** Optional max-width override; defaults to `sm:max-w-lg`. */
|
|
20
|
+
className?: string;
|
|
21
|
+
/** Disable closing on overlay click + Esc. */
|
|
22
|
+
modal?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface DialogsApi {
|
|
25
|
+
confirm(opts?: ConfirmOptions): Promise<boolean>;
|
|
26
|
+
alert(opts?: AlertOptions): Promise<void>;
|
|
27
|
+
open<T = unknown>(opts: OpenOptions<T>): Promise<T | undefined>;
|
|
28
|
+
}
|
|
29
|
+
export interface DialogsProviderProps {
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
export declare function DialogsProvider({ children }: DialogsProviderProps): React.ReactElement;
|
|
33
|
+
/** Imperative dialog API. Falls back to a no-op when no provider is mounted. */
|
|
34
|
+
export declare function useDialogs(): DialogsApi;
|
|
35
|
+
//# sourceMappingURL=dialogs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogs.d.ts","sourceRoot":"","sources":["../src/dialogs.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAe9B,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gFAAgF;IAChF,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,MAAM,EAAE,CAAC,GAAG,EAAE;QAAE,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAA;IAChE,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAChD,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzC,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;CAChE;AA+BD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAuJtF;AAED,gFAAgF;AAChF,wBAAgB,UAAU,IAAI,UAAU,CAiBvC"}
|
package/dist/dialogs.jsx
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Imperative modal dialogs.
|
|
2
|
+
//
|
|
3
|
+
// `<DialogsProvider>` owns a small stack of active dialogs and renders them
|
|
4
|
+
// through shadcn's purpose-built primitives: `<AlertDialog>` for confirm/alert
|
|
5
|
+
// (focus trap + Esc-to-cancel + accessible role), and `<Dialog>` for arbitrary
|
|
6
|
+
// content opened via `open()`. `useDialogs()` exposes a promise-flavoured API
|
|
7
|
+
// (`confirm`, `alert`, `open`) so callers can `await` user choices instead of
|
|
8
|
+
// weaving open/close state through their components. All built-in dialogs go
|
|
9
|
+
// through `useI18n()` for labels — captions stay localized without callers
|
|
10
|
+
// writing translations on the call site.
|
|
11
|
+
//
|
|
12
|
+
// Custom dialogs use `open({ render })`, where `render` receives a `close`
|
|
13
|
+
// callback. The promise resolves with whatever value the caller passes to
|
|
14
|
+
// `close`, defaulting to `undefined` when the user dismisses the dialog
|
|
15
|
+
// (Esc / overlay click).
|
|
16
|
+
import * as React from 'react';
|
|
17
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Dialog, DialogContent, } from '@modern-admin/ui';
|
|
18
|
+
import { useI18n } from './i18n.js';
|
|
19
|
+
const DialogsContext = React.createContext(null);
|
|
20
|
+
let nextId = 1;
|
|
21
|
+
export function DialogsProvider({ children }) {
|
|
22
|
+
const [entries, setEntries] = React.useState([]);
|
|
23
|
+
const { t } = useI18n();
|
|
24
|
+
const removeEntry = React.useCallback((id) => {
|
|
25
|
+
setEntries((prev) => prev.filter((e) => e.id !== id));
|
|
26
|
+
}, []);
|
|
27
|
+
const closeEntry = React.useCallback((id, value) => {
|
|
28
|
+
setEntries((prev) => {
|
|
29
|
+
const target = prev.find((e) => e.id === id);
|
|
30
|
+
if (target)
|
|
31
|
+
target.resolve(value);
|
|
32
|
+
// Mark closed so Radix can play the leave animation, then remove.
|
|
33
|
+
return prev.map((e) => (e.id === id ? { ...e, open: false } : e));
|
|
34
|
+
});
|
|
35
|
+
// Cleanup after the close animation ~200ms.
|
|
36
|
+
window.setTimeout(() => removeEntry(id), 250);
|
|
37
|
+
}, [removeEntry]);
|
|
38
|
+
const api = React.useMemo(() => {
|
|
39
|
+
const push = (build) => new Promise((resolve) => {
|
|
40
|
+
const id = nextId++;
|
|
41
|
+
const entry = build(id, resolve);
|
|
42
|
+
setEntries((prev) => [...prev, entry]);
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
confirm: (opts = {}) => push((id, resolve) => ({
|
|
46
|
+
kind: 'confirm',
|
|
47
|
+
id,
|
|
48
|
+
open: true,
|
|
49
|
+
opts,
|
|
50
|
+
resolve: (value) => resolve(value),
|
|
51
|
+
})).then((v) => v === true),
|
|
52
|
+
alert: (opts = {}) => push((id, resolve) => ({
|
|
53
|
+
kind: 'alert',
|
|
54
|
+
id,
|
|
55
|
+
open: true,
|
|
56
|
+
opts,
|
|
57
|
+
resolve: () => resolve(undefined),
|
|
58
|
+
})).then(() => undefined),
|
|
59
|
+
open: (opts) => push((id, resolve) => ({
|
|
60
|
+
kind: 'custom',
|
|
61
|
+
id,
|
|
62
|
+
open: true,
|
|
63
|
+
className: opts.className,
|
|
64
|
+
modal: opts.modal,
|
|
65
|
+
render: ({ close }) => opts.render({ close: (value) => close(value) }),
|
|
66
|
+
resolve: (value) => resolve(value),
|
|
67
|
+
})),
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
return (<DialogsContext.Provider value={api}>
|
|
71
|
+
{children}
|
|
72
|
+
{entries.map((entry) => {
|
|
73
|
+
if (entry.kind === 'confirm') {
|
|
74
|
+
const title = entry.opts.title ?? t('common:confirmDelete');
|
|
75
|
+
const confirmLabel = entry.opts.confirmLabel ?? t(entry.opts.destructive ? 'common:delete' : 'common:save');
|
|
76
|
+
const cancelLabel = entry.opts.cancelLabel ?? t('common:cancel');
|
|
77
|
+
return (<AlertDialog key={entry.id} open={entry.open} onOpenChange={(next) => {
|
|
78
|
+
if (!next)
|
|
79
|
+
closeEntry(entry.id, false);
|
|
80
|
+
}}>
|
|
81
|
+
<AlertDialogContent>
|
|
82
|
+
<AlertDialogHeader>
|
|
83
|
+
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
84
|
+
{entry.opts.description && (<AlertDialogDescription>{entry.opts.description}</AlertDialogDescription>)}
|
|
85
|
+
</AlertDialogHeader>
|
|
86
|
+
<AlertDialogFooter>
|
|
87
|
+
<AlertDialogCancel onClick={() => closeEntry(entry.id, false)}>
|
|
88
|
+
{cancelLabel}
|
|
89
|
+
</AlertDialogCancel>
|
|
90
|
+
<AlertDialogAction variant={entry.opts.destructive ? 'destructive' : 'default'} onClick={() => closeEntry(entry.id, true)}>
|
|
91
|
+
{confirmLabel}
|
|
92
|
+
</AlertDialogAction>
|
|
93
|
+
</AlertDialogFooter>
|
|
94
|
+
</AlertDialogContent>
|
|
95
|
+
</AlertDialog>);
|
|
96
|
+
}
|
|
97
|
+
if (entry.kind === 'alert') {
|
|
98
|
+
return (<AlertDialog key={entry.id} open={entry.open} onOpenChange={(next) => {
|
|
99
|
+
if (!next)
|
|
100
|
+
closeEntry(entry.id, undefined);
|
|
101
|
+
}}>
|
|
102
|
+
<AlertDialogContent>
|
|
103
|
+
<AlertDialogHeader>
|
|
104
|
+
<AlertDialogTitle>{entry.opts.title ?? ''}</AlertDialogTitle>
|
|
105
|
+
{entry.opts.description && (<AlertDialogDescription>{entry.opts.description}</AlertDialogDescription>)}
|
|
106
|
+
</AlertDialogHeader>
|
|
107
|
+
<AlertDialogFooter>
|
|
108
|
+
<AlertDialogAction onClick={() => closeEntry(entry.id, undefined)}>
|
|
109
|
+
{entry.opts.okLabel ?? t('common:ok')}
|
|
110
|
+
</AlertDialogAction>
|
|
111
|
+
</AlertDialogFooter>
|
|
112
|
+
</AlertDialogContent>
|
|
113
|
+
</AlertDialog>);
|
|
114
|
+
}
|
|
115
|
+
// custom
|
|
116
|
+
return (<Dialog key={entry.id} open={entry.open} onOpenChange={(next) => {
|
|
117
|
+
if (!next)
|
|
118
|
+
closeEntry(entry.id, undefined);
|
|
119
|
+
}}>
|
|
120
|
+
<DialogContent className={entry.className} onInteractOutside={(e) => {
|
|
121
|
+
if (entry.modal)
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
}} onEscapeKeyDown={(e) => {
|
|
124
|
+
if (entry.modal)
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
}}>
|
|
127
|
+
{entry.render({ close: (value) => closeEntry(entry.id, value) })}
|
|
128
|
+
</DialogContent>
|
|
129
|
+
</Dialog>);
|
|
130
|
+
})}
|
|
131
|
+
</DialogsContext.Provider>);
|
|
132
|
+
}
|
|
133
|
+
/** Imperative dialog API. Falls back to a no-op when no provider is mounted. */
|
|
134
|
+
export function useDialogs() {
|
|
135
|
+
const ctx = React.useContext(DialogsContext);
|
|
136
|
+
if (ctx)
|
|
137
|
+
return ctx;
|
|
138
|
+
// No provider — fall back to native confirm/alert so basic flows still work
|
|
139
|
+
// when a host app forgets to mount <DialogsProvider>.
|
|
140
|
+
return {
|
|
141
|
+
confirm: async (opts) => typeof window === 'undefined'
|
|
142
|
+
? false
|
|
143
|
+
: window.confirm([opts?.title, opts?.description].filter(Boolean).join('\n\n') || ''),
|
|
144
|
+
alert: async (opts) => {
|
|
145
|
+
if (typeof window !== 'undefined') {
|
|
146
|
+
window.alert([opts?.title, opts?.description].filter(Boolean).join('\n\n') || '');
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
open: async () => undefined,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=dialogs.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogs.jsx","sourceRoot":"","sources":["../src/dialogs.tsx"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,2EAA2E;AAC3E,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,yBAAyB;AAEzB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,EACN,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAwDnC,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,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AS;KAC5B,CAAA;AACH,CAAC"}
|
package/dist/export.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AdminClient } from './client.js';
|
|
2
|
+
import type { ListQuery, PropertyJSON, RecordJSON } from './types.js';
|
|
3
|
+
export type ExportFormat = 'csv' | 'json';
|
|
4
|
+
export interface FetchAllOptions {
|
|
5
|
+
/** Page size used for each list request. */
|
|
6
|
+
batchSize?: number;
|
|
7
|
+
/** Optional progress callback: `(loaded, total)`. */
|
|
8
|
+
onProgress?(loaded: number, total: number): void;
|
|
9
|
+
/** AbortSignal — drop pagination loop on cancel. */
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Page through `client.list()` until exhausted, returning every record that
|
|
14
|
+
* matches the same filters/sorting as the current list view. `query.page`
|
|
15
|
+
* and `query.perPage` are overwritten — pass the user's filters/sorting only.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fetchAllRecords(client: AdminClient, resourceId: string, query: ListQuery | undefined, opts?: FetchAllOptions): Promise<RecordJSON[]>;
|
|
18
|
+
/** Escape a single CSV field per RFC 4180 (wrap in quotes when needed). */
|
|
19
|
+
export declare function csvEscape(value: unknown): string;
|
|
20
|
+
export interface SerializeOptions {
|
|
21
|
+
/** Properties to export in this order. Defaults to union of keys in `records`. */
|
|
22
|
+
properties?: PropertyJSON[];
|
|
23
|
+
/** When provided, the active list query is embedded as a comment at the top
|
|
24
|
+
* of the exported file so the export is self-documenting:
|
|
25
|
+
* – CSV: `# Query: {...}` line before the header row
|
|
26
|
+
* – JSON: `// Query: {...}` line before the JSON array */
|
|
27
|
+
query?: ListQuery;
|
|
28
|
+
}
|
|
29
|
+
/** Build a CSV document for the given records. UTF-8 BOM for Excel friendliness. */
|
|
30
|
+
export declare function recordsToCsv(records: RecordJSON[], opts?: SerializeOptions): string;
|
|
31
|
+
/** Build a pretty-printed JSON document for the given records.
|
|
32
|
+
* When `opts.query` is set, a `// Query: ...` comment is prepended so the
|
|
33
|
+
* export is self-documenting (JSONC — understood by VS Code, TypeScript, etc.) */
|
|
34
|
+
export declare function recordsToJson(records: RecordJSON[], opts?: SerializeOptions): string;
|
|
35
|
+
/** Trigger a browser download for the given text payload. */
|
|
36
|
+
export declare function downloadText(filename: string, mime: string, body: string): void;
|
|
37
|
+
/** Build a stable filename like `users-20260506-143015.csv`. */
|
|
38
|
+
export declare function exportFilename(resourceId: string, format: ExportFormat, now?: Date): string;
|
|
39
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAErE,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,CAAA;AAEzC,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qDAAqD;IACrD,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAChD,oDAAoD;IACpD,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,GAAG,SAAS,EAC5B,IAAI,GAAE,eAAoB,GACzB,OAAO,CAAC,UAAU,EAAE,CAAC,CAgBvB;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAYhD;AAED,MAAM,WAAW,gBAAgB;IAC/B,kFAAkF;IAClF,UAAU,CAAC,EAAE,YAAY,EAAE,CAAA;IAC3B;;;gEAG4D;IAC5D,KAAK,C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