@juv/codego-react-ui 3.4.1 → 3.4.3
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/index.cjs +43 -16
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.global.js +44 -18
- package/dist/index.js +44 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -49,6 +49,7 @@ __export(index_exports, {
|
|
|
49
49
|
ChartWidget: () => ChartWidget,
|
|
50
50
|
Checkbox: () => Checkbox,
|
|
51
51
|
CircularProgress: () => CircularProgress,
|
|
52
|
+
CodegoApiProvider: () => CodegoApiProvider,
|
|
52
53
|
ColorPicker: () => ColorPicker,
|
|
53
54
|
Combobox: () => Combobox,
|
|
54
55
|
CommandPalette: () => CommandPalette,
|
|
@@ -6405,16 +6406,6 @@ var import_react_dom2 = require("react-dom");
|
|
|
6405
6406
|
var import_axios3 = __toESM(require("axios"), 1);
|
|
6406
6407
|
var import_lucide_react17 = require("lucide-react");
|
|
6407
6408
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6408
|
-
var csrfAxios = import_axios3.default.create();
|
|
6409
|
-
csrfAxios.interceptors.request.use((config) => {
|
|
6410
|
-
const method = (config.method ?? "").toUpperCase();
|
|
6411
|
-
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
|
6412
|
-
const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6413
|
-
if (!token) throw new Error('[Table] CSRF token not found. Add <meta name="csrf-token" content="..."> to your HTML <head>.');
|
|
6414
|
-
config.headers.set("X-CSRF-Token", token);
|
|
6415
|
-
}
|
|
6416
|
-
return config;
|
|
6417
|
-
});
|
|
6418
6409
|
function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
6419
6410
|
const [data, setData] = React28.useState([]);
|
|
6420
6411
|
const [columns, setColumns] = React28.useState([]);
|
|
@@ -6564,6 +6555,7 @@ function validateField(field, value) {
|
|
|
6564
6555
|
return null;
|
|
6565
6556
|
}
|
|
6566
6557
|
function FieldRenderer({ field, value, onChange }) {
|
|
6558
|
+
if (field.component) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: field.component });
|
|
6567
6559
|
if (field.render) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: field.render(value, onChange) });
|
|
6568
6560
|
const toLabelValue = (o) => {
|
|
6569
6561
|
if (typeof o === "string") return { label: o, value: o };
|
|
@@ -6710,7 +6702,7 @@ function ViewModal({
|
|
|
6710
6702
|
footer: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { variant: "outline", size: "sm", onClick: onClose, children: "Close" }),
|
|
6711
6703
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "space-y-3", children: fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { children: [
|
|
6712
6704
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs font-semibold text-muted-foreground mb-1", children: f.label }),
|
|
6713
|
-
f.render ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.render(item[f.key], () => {
|
|
6705
|
+
f.component ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.component }) : f.render ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.render(item[f.key], () => {
|
|
6714
6706
|
}) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-sm text-foreground break-words", children: item[f.key] === null || item[f.key] === void 0 || item[f.key] === "" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-muted-foreground italic", children: "\u2014" }) : String(item[f.key]) })
|
|
6715
6707
|
] }, f.key)) })
|
|
6716
6708
|
}
|
|
@@ -6753,7 +6745,29 @@ function EditModal({
|
|
|
6753
6745
|
setLoading(true);
|
|
6754
6746
|
setError(null);
|
|
6755
6747
|
try {
|
|
6756
|
-
|
|
6748
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6749
|
+
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
6750
|
+
const hasFiles = Object.values(form).some(
|
|
6751
|
+
(v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File || v instanceof File
|
|
6752
|
+
);
|
|
6753
|
+
let body;
|
|
6754
|
+
if (hasFiles) {
|
|
6755
|
+
const fd = new FormData();
|
|
6756
|
+
fd.append("_method", "PUT");
|
|
6757
|
+
Object.entries(form).forEach(([k, v]) => {
|
|
6758
|
+
if (Array.isArray(v) && v[0] instanceof File) {
|
|
6759
|
+
v.forEach((f) => fd.append(k, f));
|
|
6760
|
+
} else if (v instanceof File) {
|
|
6761
|
+
fd.append(k, v);
|
|
6762
|
+
} else if (v !== null && v !== void 0) {
|
|
6763
|
+
fd.append(k, String(v));
|
|
6764
|
+
}
|
|
6765
|
+
});
|
|
6766
|
+
body = fd;
|
|
6767
|
+
} else {
|
|
6768
|
+
body = form;
|
|
6769
|
+
}
|
|
6770
|
+
await import_axios3.default.put(`${baseUrl}/${itemId}/update`, body, { headers: { "X-CSRF-Token": csrfToken } });
|
|
6757
6771
|
const updated = { ...item, ...form };
|
|
6758
6772
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
6759
6773
|
setBanner(true);
|
|
@@ -6794,14 +6808,14 @@ function EditModal({
|
|
|
6794
6808
|
),
|
|
6795
6809
|
notif.action && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: notif.action })
|
|
6796
6810
|
] }),
|
|
6797
|
-
fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.
|
|
6811
|
+
fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
6798
6812
|
"div",
|
|
6799
6813
|
{
|
|
6800
6814
|
style: {
|
|
6801
6815
|
...f.colSpan ? { gridColumn: `span ${f.colSpan}` } : {},
|
|
6802
6816
|
...f.rowSpan ? { gridRow: `span ${f.rowSpan}` } : {}
|
|
6803
6817
|
},
|
|
6804
|
-
children: [
|
|
6818
|
+
children: f.component ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.component }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
6805
6819
|
f.type !== "checkbox" && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("label", { className: "block text-xs font-semibold text-muted-foreground mb-1", children: [
|
|
6806
6820
|
f.label,
|
|
6807
6821
|
f.required && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-danger ml-0.5", children: "*" })
|
|
@@ -6821,7 +6835,7 @@ function EditModal({
|
|
|
6821
6835
|
}
|
|
6822
6836
|
),
|
|
6823
6837
|
fieldErrors[f.key] && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-danger mt-1", children: fieldErrors[f.key] })
|
|
6824
|
-
]
|
|
6838
|
+
] })
|
|
6825
6839
|
},
|
|
6826
6840
|
f.key
|
|
6827
6841
|
)),
|
|
@@ -6844,7 +6858,9 @@ function DeleteModal({
|
|
|
6844
6858
|
setLoading(true);
|
|
6845
6859
|
setError(null);
|
|
6846
6860
|
try {
|
|
6847
|
-
|
|
6861
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6862
|
+
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
6863
|
+
await import_axios3.default.delete(`${baseUrl}/${itemId}/delete?csrfToken=${encodeURIComponent(csrfToken)}`, { headers: { "X-CSRF-Token": csrfToken } });
|
|
6848
6864
|
onSuccess?.(item);
|
|
6849
6865
|
onClose();
|
|
6850
6866
|
} catch (err) {
|
|
@@ -12865,6 +12881,9 @@ var request = async (config) => {
|
|
|
12865
12881
|
|
|
12866
12882
|
// src/lib/codego/interceptors.ts
|
|
12867
12883
|
var toastFn = null;
|
|
12884
|
+
var setToastFunction = (fn) => {
|
|
12885
|
+
toastFn = fn;
|
|
12886
|
+
};
|
|
12868
12887
|
var setupInterceptors = () => {
|
|
12869
12888
|
axiosInstance.interceptors.request.use(
|
|
12870
12889
|
(config) => {
|
|
@@ -12908,6 +12927,13 @@ var setupInterceptors = () => {
|
|
|
12908
12927
|
// src/lib/codego/provider.tsx
|
|
12909
12928
|
var React51 = __toESM(require("react"), 1);
|
|
12910
12929
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
12930
|
+
function CodegoApiProvider({ children }) {
|
|
12931
|
+
const { toast } = useToast();
|
|
12932
|
+
React51.useEffect(() => {
|
|
12933
|
+
setToastFunction(toast);
|
|
12934
|
+
}, [toast]);
|
|
12935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_jsx_runtime63.Fragment, { children });
|
|
12936
|
+
}
|
|
12911
12937
|
|
|
12912
12938
|
// src/lib/codego/index.ts
|
|
12913
12939
|
setupInterceptors();
|
|
@@ -12974,6 +13000,7 @@ function createStore(initialValue, sessionName, expireInterval) {
|
|
|
12974
13000
|
ChartWidget,
|
|
12975
13001
|
Checkbox,
|
|
12976
13002
|
CircularProgress,
|
|
13003
|
+
CodegoApiProvider,
|
|
12977
13004
|
ColorPicker,
|
|
12978
13005
|
Combobox,
|
|
12979
13006
|
CommandPalette,
|
package/dist/index.d.cts
CHANGED
|
@@ -360,6 +360,8 @@ interface ActionField {
|
|
|
360
360
|
rowSpan?: number;
|
|
361
361
|
/** Custom render — overrides built-in field renderer */
|
|
362
362
|
render?: (value: any, onChange: (v: any) => void) => React.ReactNode;
|
|
363
|
+
/** Drop-in React component — rendered as-is, bypasses label and built-in renderer. Use for fully custom fields. */
|
|
364
|
+
component?: React.ReactNode;
|
|
363
365
|
/** Hide this field from view/edit forms */
|
|
364
366
|
hidden?: boolean;
|
|
365
367
|
}
|
|
@@ -2412,6 +2414,11 @@ interface RequestConfig<T = any> extends AxiosRequestConfig, NotificationConfig
|
|
|
2412
2414
|
skipAuth?: boolean;
|
|
2413
2415
|
}
|
|
2414
2416
|
|
|
2417
|
+
/** Mount once inside ToastProvider to enable api toast notifications. */
|
|
2418
|
+
declare function CodegoApiProvider({ children }: {
|
|
2419
|
+
children: React.ReactNode;
|
|
2420
|
+
}): react_jsx_runtime.JSX.Element;
|
|
2421
|
+
|
|
2415
2422
|
declare const api: {
|
|
2416
2423
|
get: <R = any>(url: string, config?: RequestConfig) => Promise<R>;
|
|
2417
2424
|
post: <T = any, R = any>(url: string, data?: T, config?: RequestConfig<T>) => Promise<R>;
|
|
@@ -2435,4 +2442,4 @@ type StoreWrapper<T extends object> = {
|
|
|
2435
2442
|
*/
|
|
2436
2443
|
declare function createStore<T extends object>(initialValue: T, sessionName: string, expireInterval?: number): StoreWrapper<T>;
|
|
2437
2444
|
|
|
2438
|
-
export { Accordion, type AccordionItem, type AccordionProps, type AccordionVariant, type ActionField, type ActionFieldType, type AuthField, type AuthVariant, type AuthView, Authentication, type AuthenticationProps, AvatarStack, type AvatarStackProps, Badge, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, type BulletinAction, BulletinBoard, type BulletinBoardProps, type BulletinColumns, type BulletinEditField, type BulletinItem, type BulletinLayout, BulletinPreview, type BulletinPreviewProps, type BulletinPriority, type BulletinServerPaginationProp, type BulletinVariant, Button, type ButtonProps, COLOR_PALETTE, Calendar, CalendarDateRangePicker, type CalendarDateRangePickerProps, type CalendarDateRangeVariant, type CalendarEvent, type CalendarProps, type CalendarView, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChartDataPoint, ChartWidget, type ChartWidgetProps, Checkbox, type CheckboxProps, CircularProgress, type CircularProgressProps, type ClusterVariant, ColorPicker, type ColorPickerProps, type Column, Combobox, type ComboboxOption, type ComboboxProps, type CommandItem, CommandPalette, type CommandPaletteProps, ComposableWidget, type ComposableWidgetProps, type ConfirmVariant, ContextMenu, type ContextMenuItem, type ContextMenuProps, DataGrid, type DataGridColumn, type DataGridProps, DatePickerPopup, type DateRange, DateRangePicker, type DateRangePickerProps, type DefaultActionsConfig, DocsLayout, Drawer, type DrawerProps, type DrawerSide, Dropdown, DropdownItem, DropdownLabel, type DropdownProps, DropdownSeparator, EVENT_COLORS, type FileTypeValidation, FileUpload, type FileUploadProps, type FlexAlign, type FlexDirection, type FlexGap, FlexItem, type FlexItemProps, type FlexJustify, FlexLayout, type FlexLayoutProps, type FlexWrap, type FlyToOptions, type FormField, type FormFieldType, type GridAlign, type GridCols, type GridGap, GridItem, type GridItemProps, GridLayout, type GridLayoutProps, GroupNavigation, type GroupNavigationProps, type ImageEditorMode, type ImageEditorOptions, Input, type InputProps, KanbanBoard, type KanbanBoardProps, type KanbanCard, type KanbanColumn, Label, LeafletMap, type LeafletMapProps, LeftSidebar, type LeftSidebarProps, type MapLibreClusterVariant, MapLibreMap, type MapLibreMarker, type MapLibreProps, type MapLibreRoute, type MapLibreRouteType, type MapLibreStyle, type MapMarker, type MapRoute, type MarkerColor, type MetricItem, MetricRow, type MetricRowProps, Modal, ModalConfirmation, type ModalConfirmationProps, type ModalProps, ModalUnchange, type ModalUnchangeProps, ModalWithForms, type ModalWithFormsProps, type NavGroup, type NavItem, Navigation, type NavigationProps, NotificationBanner, type NotificationBannerProps, type NotificationItem, NotificationPanel, type NotificationPanelProps, type NotificationVariant, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Panel, type PanelProps, PanelSettings, type PanelSettingsProps, type PanelSettingsTab, PanelSidebarGroup, PanelSidebarItem, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressProps, type ProgressSize, type ProgressVariant, type PropRow, PropsTable, RadioGroup, type RadioGroupProps, type RadioOption, type RadioSize, type RadioVariant, RangeSlider, type RangeSliderProps, Repeater, type RepeaterProps, type RequestConfig, ResizablePanels, type ResizablePanelsProps, RichTextEditor, type RichTextEditorProps, RightSidebar, type RightSidebarProps, type RouteType, ScrollArea, type ScrollAreaProps, Section, SectionBlock, type SectionProps, type SectionVariant, Select, type SelectOption, type SelectProps, type SemanticColor, type ServerDataGridProp, type ServerPagination, type ServerPaginationLink, type ServerPaginationProp, type ServerTableResponse, Skeleton, Slider, type SliderProps, type SortDir, StatCard, type StatCardProps, type StatTrend, StatsWidget, type StatsWidgetProps, type Step, type StepStatus, Stepper, type StepperProps, type TabItem, type TabSize, type TabVariant, Table, TableOfContents, type TableProps, TableWidget, type TableWidgetProps, Tabs, type TabsProps, TagInput, type TagInputProps, Textarea, type TextareaProps, type ThemeColors, ThemeProvider, type ThemeSettings, Timeline, type TimelineItem, type TimelineProps, type TimelineVariant, type ToastItem, type ToastPosition, ToastProvider, type ToastProviderProps, type ToastVariant, type TocItem, TocProvider, ToggleSwitch, type ToggleSwitchProps, Tooltip, type TooltipProps, Topbar, type TopbarProps, type TreeNode, TreeView, type TreeViewProps, type TrendDir, type UseServerBulletinOptions, type UseServerBulletinReturn, type UseServerDataGridOptions, type UseServerDataGridReturn, type UseServerTableOptions, type UseServerTableReturn, Widget, type WidgetProps, Wizard, type WizardActionProps, type WizardLayout, type WizardProps, type WizardSize, type WizardStep, type WizardVariant, api, createStore, useServerBulletin, useServerDataGrid, useServerTable, useTheme, useToast, useToc };
|
|
2445
|
+
export { Accordion, type AccordionItem, type AccordionProps, type AccordionVariant, type ActionField, type ActionFieldType, type AuthField, type AuthVariant, type AuthView, Authentication, type AuthenticationProps, AvatarStack, type AvatarStackProps, Badge, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, type BulletinAction, BulletinBoard, type BulletinBoardProps, type BulletinColumns, type BulletinEditField, type BulletinItem, type BulletinLayout, BulletinPreview, type BulletinPreviewProps, type BulletinPriority, type BulletinServerPaginationProp, type BulletinVariant, Button, type ButtonProps, COLOR_PALETTE, Calendar, CalendarDateRangePicker, type CalendarDateRangePickerProps, type CalendarDateRangeVariant, type CalendarEvent, type CalendarProps, type CalendarView, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChartDataPoint, ChartWidget, type ChartWidgetProps, Checkbox, type CheckboxProps, CircularProgress, type CircularProgressProps, type ClusterVariant, CodegoApiProvider, ColorPicker, type ColorPickerProps, type Column, Combobox, type ComboboxOption, type ComboboxProps, type CommandItem, CommandPalette, type CommandPaletteProps, ComposableWidget, type ComposableWidgetProps, type ConfirmVariant, ContextMenu, type ContextMenuItem, type ContextMenuProps, DataGrid, type DataGridColumn, type DataGridProps, DatePickerPopup, type DateRange, DateRangePicker, type DateRangePickerProps, type DefaultActionsConfig, DocsLayout, Drawer, type DrawerProps, type DrawerSide, Dropdown, DropdownItem, DropdownLabel, type DropdownProps, DropdownSeparator, EVENT_COLORS, type FileTypeValidation, FileUpload, type FileUploadProps, type FlexAlign, type FlexDirection, type FlexGap, FlexItem, type FlexItemProps, type FlexJustify, FlexLayout, type FlexLayoutProps, type FlexWrap, type FlyToOptions, type FormField, type FormFieldType, type GridAlign, type GridCols, type GridGap, GridItem, type GridItemProps, GridLayout, type GridLayoutProps, GroupNavigation, type GroupNavigationProps, type ImageEditorMode, type ImageEditorOptions, Input, type InputProps, KanbanBoard, type KanbanBoardProps, type KanbanCard, type KanbanColumn, Label, LeafletMap, type LeafletMapProps, LeftSidebar, type LeftSidebarProps, type MapLibreClusterVariant, MapLibreMap, type MapLibreMarker, type MapLibreProps, type MapLibreRoute, type MapLibreRouteType, type MapLibreStyle, type MapMarker, type MapRoute, type MarkerColor, type MetricItem, MetricRow, type MetricRowProps, Modal, ModalConfirmation, type ModalConfirmationProps, type ModalProps, ModalUnchange, type ModalUnchangeProps, ModalWithForms, type ModalWithFormsProps, type NavGroup, type NavItem, Navigation, type NavigationProps, NotificationBanner, type NotificationBannerProps, type NotificationItem, NotificationPanel, type NotificationPanelProps, type NotificationVariant, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Panel, type PanelProps, PanelSettings, type PanelSettingsProps, type PanelSettingsTab, PanelSidebarGroup, PanelSidebarItem, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressProps, type ProgressSize, type ProgressVariant, type PropRow, PropsTable, RadioGroup, type RadioGroupProps, type RadioOption, type RadioSize, type RadioVariant, RangeSlider, type RangeSliderProps, Repeater, type RepeaterProps, type RequestConfig, ResizablePanels, type ResizablePanelsProps, RichTextEditor, type RichTextEditorProps, RightSidebar, type RightSidebarProps, type RouteType, ScrollArea, type ScrollAreaProps, Section, SectionBlock, type SectionProps, type SectionVariant, Select, type SelectOption, type SelectProps, type SemanticColor, type ServerDataGridProp, type ServerPagination, type ServerPaginationLink, type ServerPaginationProp, type ServerTableResponse, Skeleton, Slider, type SliderProps, type SortDir, StatCard, type StatCardProps, type StatTrend, StatsWidget, type StatsWidgetProps, type Step, type StepStatus, Stepper, type StepperProps, type TabItem, type TabSize, type TabVariant, Table, TableOfContents, type TableProps, TableWidget, type TableWidgetProps, Tabs, type TabsProps, TagInput, type TagInputProps, Textarea, type TextareaProps, type ThemeColors, ThemeProvider, type ThemeSettings, Timeline, type TimelineItem, type TimelineProps, type TimelineVariant, type ToastItem, type ToastPosition, ToastProvider, type ToastProviderProps, type ToastVariant, type TocItem, TocProvider, ToggleSwitch, type ToggleSwitchProps, Tooltip, type TooltipProps, Topbar, type TopbarProps, type TreeNode, TreeView, type TreeViewProps, type TrendDir, type UseServerBulletinOptions, type UseServerBulletinReturn, type UseServerDataGridOptions, type UseServerDataGridReturn, type UseServerTableOptions, type UseServerTableReturn, Widget, type WidgetProps, Wizard, type WizardActionProps, type WizardLayout, type WizardProps, type WizardSize, type WizardStep, type WizardVariant, api, createStore, useServerBulletin, useServerDataGrid, useServerTable, useTheme, useToast, useToc };
|
package/dist/index.d.ts
CHANGED
|
@@ -360,6 +360,8 @@ interface ActionField {
|
|
|
360
360
|
rowSpan?: number;
|
|
361
361
|
/** Custom render — overrides built-in field renderer */
|
|
362
362
|
render?: (value: any, onChange: (v: any) => void) => React.ReactNode;
|
|
363
|
+
/** Drop-in React component — rendered as-is, bypasses label and built-in renderer. Use for fully custom fields. */
|
|
364
|
+
component?: React.ReactNode;
|
|
363
365
|
/** Hide this field from view/edit forms */
|
|
364
366
|
hidden?: boolean;
|
|
365
367
|
}
|
|
@@ -2412,6 +2414,11 @@ interface RequestConfig<T = any> extends AxiosRequestConfig, NotificationConfig
|
|
|
2412
2414
|
skipAuth?: boolean;
|
|
2413
2415
|
}
|
|
2414
2416
|
|
|
2417
|
+
/** Mount once inside ToastProvider to enable api toast notifications. */
|
|
2418
|
+
declare function CodegoApiProvider({ children }: {
|
|
2419
|
+
children: React.ReactNode;
|
|
2420
|
+
}): react_jsx_runtime.JSX.Element;
|
|
2421
|
+
|
|
2415
2422
|
declare const api: {
|
|
2416
2423
|
get: <R = any>(url: string, config?: RequestConfig) => Promise<R>;
|
|
2417
2424
|
post: <T = any, R = any>(url: string, data?: T, config?: RequestConfig<T>) => Promise<R>;
|
|
@@ -2435,4 +2442,4 @@ type StoreWrapper<T extends object> = {
|
|
|
2435
2442
|
*/
|
|
2436
2443
|
declare function createStore<T extends object>(initialValue: T, sessionName: string, expireInterval?: number): StoreWrapper<T>;
|
|
2437
2444
|
|
|
2438
|
-
export { Accordion, type AccordionItem, type AccordionProps, type AccordionVariant, type ActionField, type ActionFieldType, type AuthField, type AuthVariant, type AuthView, Authentication, type AuthenticationProps, AvatarStack, type AvatarStackProps, Badge, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, type BulletinAction, BulletinBoard, type BulletinBoardProps, type BulletinColumns, type BulletinEditField, type BulletinItem, type BulletinLayout, BulletinPreview, type BulletinPreviewProps, type BulletinPriority, type BulletinServerPaginationProp, type BulletinVariant, Button, type ButtonProps, COLOR_PALETTE, Calendar, CalendarDateRangePicker, type CalendarDateRangePickerProps, type CalendarDateRangeVariant, type CalendarEvent, type CalendarProps, type CalendarView, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChartDataPoint, ChartWidget, type ChartWidgetProps, Checkbox, type CheckboxProps, CircularProgress, type CircularProgressProps, type ClusterVariant, ColorPicker, type ColorPickerProps, type Column, Combobox, type ComboboxOption, type ComboboxProps, type CommandItem, CommandPalette, type CommandPaletteProps, ComposableWidget, type ComposableWidgetProps, type ConfirmVariant, ContextMenu, type ContextMenuItem, type ContextMenuProps, DataGrid, type DataGridColumn, type DataGridProps, DatePickerPopup, type DateRange, DateRangePicker, type DateRangePickerProps, type DefaultActionsConfig, DocsLayout, Drawer, type DrawerProps, type DrawerSide, Dropdown, DropdownItem, DropdownLabel, type DropdownProps, DropdownSeparator, EVENT_COLORS, type FileTypeValidation, FileUpload, type FileUploadProps, type FlexAlign, type FlexDirection, type FlexGap, FlexItem, type FlexItemProps, type FlexJustify, FlexLayout, type FlexLayoutProps, type FlexWrap, type FlyToOptions, type FormField, type FormFieldType, type GridAlign, type GridCols, type GridGap, GridItem, type GridItemProps, GridLayout, type GridLayoutProps, GroupNavigation, type GroupNavigationProps, type ImageEditorMode, type ImageEditorOptions, Input, type InputProps, KanbanBoard, type KanbanBoardProps, type KanbanCard, type KanbanColumn, Label, LeafletMap, type LeafletMapProps, LeftSidebar, type LeftSidebarProps, type MapLibreClusterVariant, MapLibreMap, type MapLibreMarker, type MapLibreProps, type MapLibreRoute, type MapLibreRouteType, type MapLibreStyle, type MapMarker, type MapRoute, type MarkerColor, type MetricItem, MetricRow, type MetricRowProps, Modal, ModalConfirmation, type ModalConfirmationProps, type ModalProps, ModalUnchange, type ModalUnchangeProps, ModalWithForms, type ModalWithFormsProps, type NavGroup, type NavItem, Navigation, type NavigationProps, NotificationBanner, type NotificationBannerProps, type NotificationItem, NotificationPanel, type NotificationPanelProps, type NotificationVariant, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Panel, type PanelProps, PanelSettings, type PanelSettingsProps, type PanelSettingsTab, PanelSidebarGroup, PanelSidebarItem, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressProps, type ProgressSize, type ProgressVariant, type PropRow, PropsTable, RadioGroup, type RadioGroupProps, type RadioOption, type RadioSize, type RadioVariant, RangeSlider, type RangeSliderProps, Repeater, type RepeaterProps, type RequestConfig, ResizablePanels, type ResizablePanelsProps, RichTextEditor, type RichTextEditorProps, RightSidebar, type RightSidebarProps, type RouteType, ScrollArea, type ScrollAreaProps, Section, SectionBlock, type SectionProps, type SectionVariant, Select, type SelectOption, type SelectProps, type SemanticColor, type ServerDataGridProp, type ServerPagination, type ServerPaginationLink, type ServerPaginationProp, type ServerTableResponse, Skeleton, Slider, type SliderProps, type SortDir, StatCard, type StatCardProps, type StatTrend, StatsWidget, type StatsWidgetProps, type Step, type StepStatus, Stepper, type StepperProps, type TabItem, type TabSize, type TabVariant, Table, TableOfContents, type TableProps, TableWidget, type TableWidgetProps, Tabs, type TabsProps, TagInput, type TagInputProps, Textarea, type TextareaProps, type ThemeColors, ThemeProvider, type ThemeSettings, Timeline, type TimelineItem, type TimelineProps, type TimelineVariant, type ToastItem, type ToastPosition, ToastProvider, type ToastProviderProps, type ToastVariant, type TocItem, TocProvider, ToggleSwitch, type ToggleSwitchProps, Tooltip, type TooltipProps, Topbar, type TopbarProps, type TreeNode, TreeView, type TreeViewProps, type TrendDir, type UseServerBulletinOptions, type UseServerBulletinReturn, type UseServerDataGridOptions, type UseServerDataGridReturn, type UseServerTableOptions, type UseServerTableReturn, Widget, type WidgetProps, Wizard, type WizardActionProps, type WizardLayout, type WizardProps, type WizardSize, type WizardStep, type WizardVariant, api, createStore, useServerBulletin, useServerDataGrid, useServerTable, useTheme, useToast, useToc };
|
|
2445
|
+
export { Accordion, type AccordionItem, type AccordionProps, type AccordionVariant, type ActionField, type ActionFieldType, type AuthField, type AuthVariant, type AuthView, Authentication, type AuthenticationProps, AvatarStack, type AvatarStackProps, Badge, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, type BulletinAction, BulletinBoard, type BulletinBoardProps, type BulletinColumns, type BulletinEditField, type BulletinItem, type BulletinLayout, BulletinPreview, type BulletinPreviewProps, type BulletinPriority, type BulletinServerPaginationProp, type BulletinVariant, Button, type ButtonProps, COLOR_PALETTE, Calendar, CalendarDateRangePicker, type CalendarDateRangePickerProps, type CalendarDateRangeVariant, type CalendarEvent, type CalendarProps, type CalendarView, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChartDataPoint, ChartWidget, type ChartWidgetProps, Checkbox, type CheckboxProps, CircularProgress, type CircularProgressProps, type ClusterVariant, CodegoApiProvider, ColorPicker, type ColorPickerProps, type Column, Combobox, type ComboboxOption, type ComboboxProps, type CommandItem, CommandPalette, type CommandPaletteProps, ComposableWidget, type ComposableWidgetProps, type ConfirmVariant, ContextMenu, type ContextMenuItem, type ContextMenuProps, DataGrid, type DataGridColumn, type DataGridProps, DatePickerPopup, type DateRange, DateRangePicker, type DateRangePickerProps, type DefaultActionsConfig, DocsLayout, Drawer, type DrawerProps, type DrawerSide, Dropdown, DropdownItem, DropdownLabel, type DropdownProps, DropdownSeparator, EVENT_COLORS, type FileTypeValidation, FileUpload, type FileUploadProps, type FlexAlign, type FlexDirection, type FlexGap, FlexItem, type FlexItemProps, type FlexJustify, FlexLayout, type FlexLayoutProps, type FlexWrap, type FlyToOptions, type FormField, type FormFieldType, type GridAlign, type GridCols, type GridGap, GridItem, type GridItemProps, GridLayout, type GridLayoutProps, GroupNavigation, type GroupNavigationProps, type ImageEditorMode, type ImageEditorOptions, Input, type InputProps, KanbanBoard, type KanbanBoardProps, type KanbanCard, type KanbanColumn, Label, LeafletMap, type LeafletMapProps, LeftSidebar, type LeftSidebarProps, type MapLibreClusterVariant, MapLibreMap, type MapLibreMarker, type MapLibreProps, type MapLibreRoute, type MapLibreRouteType, type MapLibreStyle, type MapMarker, type MapRoute, type MarkerColor, type MetricItem, MetricRow, type MetricRowProps, Modal, ModalConfirmation, type ModalConfirmationProps, type ModalProps, ModalUnchange, type ModalUnchangeProps, ModalWithForms, type ModalWithFormsProps, type NavGroup, type NavItem, Navigation, type NavigationProps, NotificationBanner, type NotificationBannerProps, type NotificationItem, NotificationPanel, type NotificationPanelProps, type NotificationVariant, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Panel, type PanelProps, PanelSettings, type PanelSettingsProps, type PanelSettingsTab, PanelSidebarGroup, PanelSidebarItem, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressProps, type ProgressSize, type ProgressVariant, type PropRow, PropsTable, RadioGroup, type RadioGroupProps, type RadioOption, type RadioSize, type RadioVariant, RangeSlider, type RangeSliderProps, Repeater, type RepeaterProps, type RequestConfig, ResizablePanels, type ResizablePanelsProps, RichTextEditor, type RichTextEditorProps, RightSidebar, type RightSidebarProps, type RouteType, ScrollArea, type ScrollAreaProps, Section, SectionBlock, type SectionProps, type SectionVariant, Select, type SelectOption, type SelectProps, type SemanticColor, type ServerDataGridProp, type ServerPagination, type ServerPaginationLink, type ServerPaginationProp, type ServerTableResponse, Skeleton, Slider, type SliderProps, type SortDir, StatCard, type StatCardProps, type StatTrend, StatsWidget, type StatsWidgetProps, type Step, type StepStatus, Stepper, type StepperProps, type TabItem, type TabSize, type TabVariant, Table, TableOfContents, type TableProps, TableWidget, type TableWidgetProps, Tabs, type TabsProps, TagInput, type TagInputProps, Textarea, type TextareaProps, type ThemeColors, ThemeProvider, type ThemeSettings, Timeline, type TimelineItem, type TimelineProps, type TimelineVariant, type ToastItem, type ToastPosition, ToastProvider, type ToastProviderProps, type ToastVariant, type TocItem, TocProvider, ToggleSwitch, type ToggleSwitchProps, Tooltip, type TooltipProps, Topbar, type TopbarProps, type TreeNode, TreeView, type TreeViewProps, type TrendDir, type UseServerBulletinOptions, type UseServerBulletinReturn, type UseServerDataGridOptions, type UseServerDataGridReturn, type UseServerTableOptions, type UseServerTableReturn, Widget, type WidgetProps, Wizard, type WizardActionProps, type WizardLayout, type WizardProps, type WizardSize, type WizardStep, type WizardVariant, api, createStore, useServerBulletin, useServerDataGrid, useServerTable, useTheme, useToast, useToc };
|
package/dist/index.global.js
CHANGED
|
@@ -53652,6 +53652,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
53652
53652
|
ChartWidget: () => ChartWidget,
|
|
53653
53653
|
Checkbox: () => Checkbox,
|
|
53654
53654
|
CircularProgress: () => CircularProgress,
|
|
53655
|
+
CodegoApiProvider: () => CodegoApiProvider,
|
|
53655
53656
|
ColorPicker: () => ColorPicker,
|
|
53656
53657
|
Combobox: () => Combobox,
|
|
53657
53658
|
CommandPalette: () => CommandPalette,
|
|
@@ -63191,7 +63192,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
63191
63192
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
|
|
63192
63193
|
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }]
|
|
63193
63194
|
];
|
|
63194
|
-
var
|
|
63195
|
+
var File2 = createLucideIcon("file", __iconNode30);
|
|
63195
63196
|
|
|
63196
63197
|
// node_modules/lucide-react/dist/esm/icons/flip-horizontal.js
|
|
63197
63198
|
var __iconNode31 = [
|
|
@@ -69551,16 +69552,6 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69551
69552
|
var React28 = __toESM(require_react(), 1);
|
|
69552
69553
|
var import_react_dom2 = __toESM(require_react_dom(), 1);
|
|
69553
69554
|
var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
|
|
69554
|
-
var csrfAxios = axios_default.create();
|
|
69555
|
-
csrfAxios.interceptors.request.use((config) => {
|
|
69556
|
-
const method = (config.method ?? "").toUpperCase();
|
|
69557
|
-
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
|
69558
|
-
const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
69559
|
-
if (!token) throw new Error('[Table] CSRF token not found. Add <meta name="csrf-token" content="..."> to your HTML <head>.');
|
|
69560
|
-
config.headers.set("X-CSRF-Token", token);
|
|
69561
|
-
}
|
|
69562
|
-
return config;
|
|
69563
|
-
});
|
|
69564
69555
|
function useServerTable({ url: url2, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
69565
69556
|
const [data, setData] = React28.useState([]);
|
|
69566
69557
|
const [columns, setColumns] = React28.useState([]);
|
|
@@ -69710,6 +69701,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69710
69701
|
return null;
|
|
69711
69702
|
}
|
|
69712
69703
|
function FieldRenderer({ field, value, onChange }) {
|
|
69704
|
+
if (field.component) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: field.component });
|
|
69713
69705
|
if (field.render) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: field.render(value, onChange) });
|
|
69714
69706
|
const toLabelValue = (o) => {
|
|
69715
69707
|
if (typeof o === "string") return { label: o, value: o };
|
|
@@ -69856,7 +69848,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69856
69848
|
footer: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { variant: "outline", size: "sm", onClick: onClose, children: "Close" }),
|
|
69857
69849
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "space-y-3", children: fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { children: [
|
|
69858
69850
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs font-semibold text-muted-foreground mb-1", children: f.label }),
|
|
69859
|
-
f.render ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.render(item[f.key], () => {
|
|
69851
|
+
f.component ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.component }) : f.render ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.render(item[f.key], () => {
|
|
69860
69852
|
}) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-sm text-foreground break-words", children: item[f.key] === null || item[f.key] === void 0 || item[f.key] === "" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-muted-foreground italic", children: "\u2014" }) : String(item[f.key]) })
|
|
69861
69853
|
] }, f.key)) })
|
|
69862
69854
|
}
|
|
@@ -69899,7 +69891,29 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69899
69891
|
setLoading(true);
|
|
69900
69892
|
setError(null);
|
|
69901
69893
|
try {
|
|
69902
|
-
|
|
69894
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
69895
|
+
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
69896
|
+
const hasFiles = Object.values(form).some(
|
|
69897
|
+
(v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File || v instanceof File
|
|
69898
|
+
);
|
|
69899
|
+
let body;
|
|
69900
|
+
if (hasFiles) {
|
|
69901
|
+
const fd = new FormData();
|
|
69902
|
+
fd.append("_method", "PUT");
|
|
69903
|
+
Object.entries(form).forEach(([k, v]) => {
|
|
69904
|
+
if (Array.isArray(v) && v[0] instanceof File) {
|
|
69905
|
+
v.forEach((f) => fd.append(k, f));
|
|
69906
|
+
} else if (v instanceof File) {
|
|
69907
|
+
fd.append(k, v);
|
|
69908
|
+
} else if (v !== null && v !== void 0) {
|
|
69909
|
+
fd.append(k, String(v));
|
|
69910
|
+
}
|
|
69911
|
+
});
|
|
69912
|
+
body = fd;
|
|
69913
|
+
} else {
|
|
69914
|
+
body = form;
|
|
69915
|
+
}
|
|
69916
|
+
await axios_default.put(`${baseUrl}/${itemId}/update`, body, { headers: { "X-CSRF-Token": csrfToken } });
|
|
69903
69917
|
const updated = { ...item, ...form };
|
|
69904
69918
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
69905
69919
|
setBanner(true);
|
|
@@ -69940,14 +69954,14 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69940
69954
|
),
|
|
69941
69955
|
notif.action && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: notif.action })
|
|
69942
69956
|
] }),
|
|
69943
|
-
fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.
|
|
69957
|
+
fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
69944
69958
|
"div",
|
|
69945
69959
|
{
|
|
69946
69960
|
style: {
|
|
69947
69961
|
...f.colSpan ? { gridColumn: `span ${f.colSpan}` } : {},
|
|
69948
69962
|
...f.rowSpan ? { gridRow: `span ${f.rowSpan}` } : {}
|
|
69949
69963
|
},
|
|
69950
|
-
children: [
|
|
69964
|
+
children: f.component ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.component }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
69951
69965
|
f.type !== "checkbox" && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("label", { className: "block text-xs font-semibold text-muted-foreground mb-1", children: [
|
|
69952
69966
|
f.label,
|
|
69953
69967
|
f.required && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-danger ml-0.5", children: "*" })
|
|
@@ -69967,7 +69981,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69967
69981
|
}
|
|
69968
69982
|
),
|
|
69969
69983
|
fieldErrors[f.key] && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-danger mt-1", children: fieldErrors[f.key] })
|
|
69970
|
-
]
|
|
69984
|
+
] })
|
|
69971
69985
|
},
|
|
69972
69986
|
f.key
|
|
69973
69987
|
)),
|
|
@@ -69990,7 +70004,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69990
70004
|
setLoading(true);
|
|
69991
70005
|
setError(null);
|
|
69992
70006
|
try {
|
|
69993
|
-
|
|
70007
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
70008
|
+
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
70009
|
+
await axios_default.delete(`${baseUrl}/${itemId}/delete?csrfToken=${encodeURIComponent(csrfToken)}`, { headers: { "X-CSRF-Token": csrfToken } });
|
|
69994
70010
|
onSuccess?.(item);
|
|
69995
70011
|
onClose();
|
|
69996
70012
|
} catch (err) {
|
|
@@ -75728,7 +75744,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
75728
75744
|
const hasChildren = !!node.children?.length;
|
|
75729
75745
|
const isExpanded = expanded.includes(node.id);
|
|
75730
75746
|
const isSelected = selected.includes(node.id);
|
|
75731
|
-
const defaultIcon = hasChildren ? isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(FolderOpen, { className: "h-4 w-4 text-warning" }) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Folder, { className: "h-4 w-4 text-warning" }) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
75747
|
+
const defaultIcon = hasChildren ? isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(FolderOpen, { className: "h-4 w-4 text-warning" }) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Folder, { className: "h-4 w-4 text-warning" }) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(File2, { className: "h-4 w-4 text-muted-foreground" });
|
|
75732
75748
|
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { children: [
|
|
75733
75749
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
75734
75750
|
"div",
|
|
@@ -76421,6 +76437,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
76421
76437
|
|
|
76422
76438
|
// src/lib/codego/interceptors.ts
|
|
76423
76439
|
var toastFn = null;
|
|
76440
|
+
var setToastFunction = (fn) => {
|
|
76441
|
+
toastFn = fn;
|
|
76442
|
+
};
|
|
76424
76443
|
var setupInterceptors = () => {
|
|
76425
76444
|
axiosInstance.interceptors.request.use(
|
|
76426
76445
|
(config) => {
|
|
@@ -76464,6 +76483,13 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
76464
76483
|
// src/lib/codego/provider.tsx
|
|
76465
76484
|
var React53 = __toESM(require_react(), 1);
|
|
76466
76485
|
var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
|
|
76486
|
+
function CodegoApiProvider({ children }) {
|
|
76487
|
+
const { toast } = useToast();
|
|
76488
|
+
React53.useEffect(() => {
|
|
76489
|
+
setToastFunction(toast);
|
|
76490
|
+
}, [toast]);
|
|
76491
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_jsx_runtime63.Fragment, { children });
|
|
76492
|
+
}
|
|
76467
76493
|
|
|
76468
76494
|
// src/lib/codego/index.ts
|
|
76469
76495
|
setupInterceptors();
|
package/dist/index.js
CHANGED
|
@@ -6285,16 +6285,6 @@ import { createPortal as createPortal3 } from "react-dom";
|
|
|
6285
6285
|
import axios3 from "axios";
|
|
6286
6286
|
import { ChevronLeft as ChevronLeft6, ChevronRight as ChevronRight8, Search as Search5, Trash2 as Trash22, ChevronsUpDown, ChevronUp, ChevronDown as ChevronDown4, X as X9, Eye as Eye2, Pencil as Pencil2, Trash as Trash3, Loader2 as Loader22 } from "lucide-react";
|
|
6287
6287
|
import { Fragment as Fragment11, jsx as jsx32, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
6288
|
-
var csrfAxios = axios3.create();
|
|
6289
|
-
csrfAxios.interceptors.request.use((config) => {
|
|
6290
|
-
const method = (config.method ?? "").toUpperCase();
|
|
6291
|
-
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
|
6292
|
-
const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6293
|
-
if (!token) throw new Error('[Table] CSRF token not found. Add <meta name="csrf-token" content="..."> to your HTML <head>.');
|
|
6294
|
-
config.headers.set("X-CSRF-Token", token);
|
|
6295
|
-
}
|
|
6296
|
-
return config;
|
|
6297
|
-
});
|
|
6298
6288
|
function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
6299
6289
|
const [data, setData] = React28.useState([]);
|
|
6300
6290
|
const [columns, setColumns] = React28.useState([]);
|
|
@@ -6444,6 +6434,7 @@ function validateField(field, value) {
|
|
|
6444
6434
|
return null;
|
|
6445
6435
|
}
|
|
6446
6436
|
function FieldRenderer({ field, value, onChange }) {
|
|
6437
|
+
if (field.component) return /* @__PURE__ */ jsx32(Fragment11, { children: field.component });
|
|
6447
6438
|
if (field.render) return /* @__PURE__ */ jsx32(Fragment11, { children: field.render(value, onChange) });
|
|
6448
6439
|
const toLabelValue = (o) => {
|
|
6449
6440
|
if (typeof o === "string") return { label: o, value: o };
|
|
@@ -6590,7 +6581,7 @@ function ViewModal({
|
|
|
6590
6581
|
footer: /* @__PURE__ */ jsx32(Button, { variant: "outline", size: "sm", onClick: onClose, children: "Close" }),
|
|
6591
6582
|
children: /* @__PURE__ */ jsx32("div", { className: "space-y-3", children: fields.map((f) => /* @__PURE__ */ jsxs30("div", { children: [
|
|
6592
6583
|
/* @__PURE__ */ jsx32("p", { className: "text-xs font-semibold text-muted-foreground mb-1", children: f.label }),
|
|
6593
|
-
f.render ? /* @__PURE__ */ jsx32(Fragment11, { children: f.render(item[f.key], () => {
|
|
6584
|
+
f.component ? /* @__PURE__ */ jsx32(Fragment11, { children: f.component }) : f.render ? /* @__PURE__ */ jsx32(Fragment11, { children: f.render(item[f.key], () => {
|
|
6594
6585
|
}) }) : /* @__PURE__ */ jsx32("p", { className: "text-sm text-foreground break-words", children: item[f.key] === null || item[f.key] === void 0 || item[f.key] === "" ? /* @__PURE__ */ jsx32("span", { className: "text-muted-foreground italic", children: "\u2014" }) : String(item[f.key]) })
|
|
6595
6586
|
] }, f.key)) })
|
|
6596
6587
|
}
|
|
@@ -6633,7 +6624,29 @@ function EditModal({
|
|
|
6633
6624
|
setLoading(true);
|
|
6634
6625
|
setError(null);
|
|
6635
6626
|
try {
|
|
6636
|
-
|
|
6627
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6628
|
+
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
6629
|
+
const hasFiles = Object.values(form).some(
|
|
6630
|
+
(v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File || v instanceof File
|
|
6631
|
+
);
|
|
6632
|
+
let body;
|
|
6633
|
+
if (hasFiles) {
|
|
6634
|
+
const fd = new FormData();
|
|
6635
|
+
fd.append("_method", "PUT");
|
|
6636
|
+
Object.entries(form).forEach(([k, v]) => {
|
|
6637
|
+
if (Array.isArray(v) && v[0] instanceof File) {
|
|
6638
|
+
v.forEach((f) => fd.append(k, f));
|
|
6639
|
+
} else if (v instanceof File) {
|
|
6640
|
+
fd.append(k, v);
|
|
6641
|
+
} else if (v !== null && v !== void 0) {
|
|
6642
|
+
fd.append(k, String(v));
|
|
6643
|
+
}
|
|
6644
|
+
});
|
|
6645
|
+
body = fd;
|
|
6646
|
+
} else {
|
|
6647
|
+
body = form;
|
|
6648
|
+
}
|
|
6649
|
+
await axios3.put(`${baseUrl}/${itemId}/update`, body, { headers: { "X-CSRF-Token": csrfToken } });
|
|
6637
6650
|
const updated = { ...item, ...form };
|
|
6638
6651
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
6639
6652
|
setBanner(true);
|
|
@@ -6674,14 +6687,14 @@ function EditModal({
|
|
|
6674
6687
|
),
|
|
6675
6688
|
notif.action && /* @__PURE__ */ jsx32("div", { children: notif.action })
|
|
6676
6689
|
] }),
|
|
6677
|
-
fields.map((f) => /* @__PURE__ */
|
|
6690
|
+
fields.map((f) => /* @__PURE__ */ jsx32(
|
|
6678
6691
|
"div",
|
|
6679
6692
|
{
|
|
6680
6693
|
style: {
|
|
6681
6694
|
...f.colSpan ? { gridColumn: `span ${f.colSpan}` } : {},
|
|
6682
6695
|
...f.rowSpan ? { gridRow: `span ${f.rowSpan}` } : {}
|
|
6683
6696
|
},
|
|
6684
|
-
children: [
|
|
6697
|
+
children: f.component ? /* @__PURE__ */ jsx32(Fragment11, { children: f.component }) : /* @__PURE__ */ jsxs30(Fragment11, { children: [
|
|
6685
6698
|
f.type !== "checkbox" && /* @__PURE__ */ jsxs30("label", { className: "block text-xs font-semibold text-muted-foreground mb-1", children: [
|
|
6686
6699
|
f.label,
|
|
6687
6700
|
f.required && /* @__PURE__ */ jsx32("span", { className: "text-danger ml-0.5", children: "*" })
|
|
@@ -6701,7 +6714,7 @@ function EditModal({
|
|
|
6701
6714
|
}
|
|
6702
6715
|
),
|
|
6703
6716
|
fieldErrors[f.key] && /* @__PURE__ */ jsx32("p", { className: "text-xs text-danger mt-1", children: fieldErrors[f.key] })
|
|
6704
|
-
]
|
|
6717
|
+
] })
|
|
6705
6718
|
},
|
|
6706
6719
|
f.key
|
|
6707
6720
|
)),
|
|
@@ -6724,7 +6737,9 @@ function DeleteModal({
|
|
|
6724
6737
|
setLoading(true);
|
|
6725
6738
|
setError(null);
|
|
6726
6739
|
try {
|
|
6727
|
-
|
|
6740
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6741
|
+
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
6742
|
+
await axios3.delete(`${baseUrl}/${itemId}/delete?csrfToken=${encodeURIComponent(csrfToken)}`, { headers: { "X-CSRF-Token": csrfToken } });
|
|
6728
6743
|
onSuccess?.(item);
|
|
6729
6744
|
onClose();
|
|
6730
6745
|
} catch (err) {
|
|
@@ -12044,13 +12059,13 @@ function Timeline({ items, align = "left", className }) {
|
|
|
12044
12059
|
|
|
12045
12060
|
// src/components/ui/tree-view.tsx
|
|
12046
12061
|
import * as React48 from "react";
|
|
12047
|
-
import { ChevronRight as ChevronRight11, Folder, FolderOpen, File } from "lucide-react";
|
|
12062
|
+
import { ChevronRight as ChevronRight11, Folder, FolderOpen, File as File2 } from "lucide-react";
|
|
12048
12063
|
import { jsx as jsx60, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
12049
12064
|
function TreeNodeItem({ node, depth, selected, expanded, onToggleExpand, onSelect, multiple }) {
|
|
12050
12065
|
const hasChildren = !!node.children?.length;
|
|
12051
12066
|
const isExpanded = expanded.includes(node.id);
|
|
12052
12067
|
const isSelected = selected.includes(node.id);
|
|
12053
|
-
const defaultIcon = hasChildren ? isExpanded ? /* @__PURE__ */ jsx60(FolderOpen, { className: "h-4 w-4 text-warning" }) : /* @__PURE__ */ jsx60(Folder, { className: "h-4 w-4 text-warning" }) : /* @__PURE__ */ jsx60(
|
|
12068
|
+
const defaultIcon = hasChildren ? isExpanded ? /* @__PURE__ */ jsx60(FolderOpen, { className: "h-4 w-4 text-warning" }) : /* @__PURE__ */ jsx60(Folder, { className: "h-4 w-4 text-warning" }) : /* @__PURE__ */ jsx60(File2, { className: "h-4 w-4 text-muted-foreground" });
|
|
12054
12069
|
return /* @__PURE__ */ jsxs53("div", { children: [
|
|
12055
12070
|
/* @__PURE__ */ jsxs53(
|
|
12056
12071
|
"div",
|
|
@@ -12745,6 +12760,9 @@ var request = async (config) => {
|
|
|
12745
12760
|
|
|
12746
12761
|
// src/lib/codego/interceptors.ts
|
|
12747
12762
|
var toastFn = null;
|
|
12763
|
+
var setToastFunction = (fn) => {
|
|
12764
|
+
toastFn = fn;
|
|
12765
|
+
};
|
|
12748
12766
|
var setupInterceptors = () => {
|
|
12749
12767
|
axiosInstance.interceptors.request.use(
|
|
12750
12768
|
(config) => {
|
|
@@ -12788,6 +12806,13 @@ var setupInterceptors = () => {
|
|
|
12788
12806
|
// src/lib/codego/provider.tsx
|
|
12789
12807
|
import * as React51 from "react";
|
|
12790
12808
|
import { Fragment as Fragment21, jsx as jsx63 } from "react/jsx-runtime";
|
|
12809
|
+
function CodegoApiProvider({ children }) {
|
|
12810
|
+
const { toast } = useToast();
|
|
12811
|
+
React51.useEffect(() => {
|
|
12812
|
+
setToastFunction(toast);
|
|
12813
|
+
}, [toast]);
|
|
12814
|
+
return /* @__PURE__ */ jsx63(Fragment21, { children });
|
|
12815
|
+
}
|
|
12791
12816
|
|
|
12792
12817
|
// src/lib/codego/index.ts
|
|
12793
12818
|
setupInterceptors();
|
|
@@ -12853,6 +12878,7 @@ export {
|
|
|
12853
12878
|
ChartWidget,
|
|
12854
12879
|
Checkbox,
|
|
12855
12880
|
CircularProgress,
|
|
12881
|
+
CodegoApiProvider,
|
|
12856
12882
|
ColorPicker,
|
|
12857
12883
|
Combobox,
|
|
12858
12884
|
CommandPalette,
|