@yimingliao/cms 0.0.119 → 0.0.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React15 from 'react';
|
|
2
|
-
import { useState, useEffect,
|
|
2
|
+
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
3
3
|
import { UAParser } from 'ua-parser-js';
|
|
4
4
|
import { clsx } from 'clsx';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -58,6 +58,76 @@ var useIsMobile = () => {
|
|
|
58
58
|
}, []);
|
|
59
59
|
return !!isMobile;
|
|
60
60
|
};
|
|
61
|
+
var usePickItems = ({ items, setPickedItems }) => {
|
|
62
|
+
const pick = useCallback(
|
|
63
|
+
(item) => {
|
|
64
|
+
if (!setPickedItems) return;
|
|
65
|
+
setPickedItems((prev) => {
|
|
66
|
+
const isSame = prev[0]?.id === item?.id;
|
|
67
|
+
if (isSame) {
|
|
68
|
+
return [];
|
|
69
|
+
} else {
|
|
70
|
+
return item ? [item] : [];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
[setPickedItems]
|
|
75
|
+
);
|
|
76
|
+
const multiPick = useCallback(
|
|
77
|
+
(item) => {
|
|
78
|
+
if (!setPickedItems) return;
|
|
79
|
+
const id = item?.id;
|
|
80
|
+
setPickedItems((prev) => {
|
|
81
|
+
const alreadyPicked = prev.some((i) => i.id === id);
|
|
82
|
+
if (alreadyPicked) {
|
|
83
|
+
return prev.filter((i) => i.id !== id);
|
|
84
|
+
} else {
|
|
85
|
+
return item ? [...prev, item] : prev;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
[setPickedItems]
|
|
90
|
+
);
|
|
91
|
+
const pickAll = useCallback(() => {
|
|
92
|
+
if (!setPickedItems || !items?.length) return;
|
|
93
|
+
setPickedItems([...items]);
|
|
94
|
+
}, [setPickedItems, items]);
|
|
95
|
+
const cancelAll = useCallback(() => {
|
|
96
|
+
if (!setPickedItems) return;
|
|
97
|
+
setPickedItems([]);
|
|
98
|
+
}, [setPickedItems]);
|
|
99
|
+
return { pick, multiPick, pickAll, cancelAll };
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/client/applications/form/get-control-meta.ts
|
|
103
|
+
var getControlMeta = ({
|
|
104
|
+
records,
|
|
105
|
+
excludeIndex,
|
|
106
|
+
excludeSlug
|
|
107
|
+
}) => {
|
|
108
|
+
const indexes = records.map((r) => r.index).filter(
|
|
109
|
+
(index) => typeof index === "number" && !Number.isNaN(index)
|
|
110
|
+
);
|
|
111
|
+
if (typeof excludeIndex === "number") {
|
|
112
|
+
const i = indexes.indexOf(excludeIndex);
|
|
113
|
+
if (i !== -1) indexes.splice(i, 1);
|
|
114
|
+
}
|
|
115
|
+
const existingIndexes = [...indexes].sort((a, b) => a - b);
|
|
116
|
+
const indexSet = new Set(existingIndexes);
|
|
117
|
+
let availableIndex = 1;
|
|
118
|
+
while (indexSet.has(availableIndex)) {
|
|
119
|
+
availableIndex++;
|
|
120
|
+
}
|
|
121
|
+
const existingSlugs = records.map((r) => r.slug?.trim()).filter(
|
|
122
|
+
(slug) => typeof slug === "string" && slug !== "" && slug !== excludeSlug && !records.some((r) => r.id === slug)
|
|
123
|
+
// exclude default slug = id
|
|
124
|
+
);
|
|
125
|
+
return {
|
|
126
|
+
existingIndexes,
|
|
127
|
+
availableIndex,
|
|
128
|
+
existingSlugs
|
|
129
|
+
};
|
|
130
|
+
};
|
|
61
131
|
var useCountdown = (initialTime) => {
|
|
62
132
|
const [timeLeft, setTimeLeft] = useState(initialTime);
|
|
63
133
|
const [isCounting, setIsCounting] = useState(false);
|
|
@@ -1764,4 +1834,4 @@ function Spinner({ className, ...props }) {
|
|
|
1764
1834
|
);
|
|
1765
1835
|
}
|
|
1766
1836
|
|
|
1767
|
-
export { Avatar, AvatarFallback, AvatarImage, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FORM_MIDDLE_GAP_WIDTH, FORM_SIDE_FIELDS_WIDTH, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label2 as Label, NAVBAR_HEIGHT, PAGE_HEADER_HEIGHT, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, SIDEBAR_COOKIE_NAME, SIDEBAR_WIDTH, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Spinner, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, buttonVariants, cn, isConfirm, useCountdown, useDeviceInfo, useParentPathname, useSidebar };
|
|
1837
|
+
export { Avatar, AvatarFallback, AvatarImage, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FORM_MIDDLE_GAP_WIDTH, FORM_SIDE_FIELDS_WIDTH, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label2 as Label, NAVBAR_HEIGHT, PAGE_HEADER_HEIGHT, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, SIDEBAR_COOKIE_NAME, SIDEBAR_WIDTH, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Spinner, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, buttonVariants, cn, getControlMeta, isConfirm, useCountdown, useDeviceInfo, useParentPathname, usePickItems, useSidebar };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Result, S as SuccessResult, d as ErrorResult, g as AdminFull, D as DeviceInfo } from '../types-BGsFazJr.js';
|
|
1
|
+
import { R as Result, S as SuccessResult, d as ErrorResult, g as AdminFull, D as DeviceInfo, M as MultiItems, y as SingleItem } from '../types-BGsFazJr.js';
|
|
2
2
|
import { Logger } from 'logry';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { QueryClient, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
@@ -619,4 +619,30 @@ declare function useDeviceInfo(): DeviceInfo | null;
|
|
|
619
619
|
|
|
620
620
|
declare const cn: (...inputs: ClassValue[]) => string;
|
|
621
621
|
|
|
622
|
-
|
|
622
|
+
interface Params {
|
|
623
|
+
items?: MultiItems;
|
|
624
|
+
setPickedItems?: Dispatch<SetStateAction<MultiItems>>;
|
|
625
|
+
}
|
|
626
|
+
declare const usePickItems: ({ items, setPickedItems }: Params) => {
|
|
627
|
+
pick: (item: SingleItem) => void;
|
|
628
|
+
multiPick: (item: SingleItem) => void;
|
|
629
|
+
pickAll: () => void;
|
|
630
|
+
cancelAll: () => void;
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
type ControlRecord = {
|
|
634
|
+
id: string;
|
|
635
|
+
index: number | null;
|
|
636
|
+
slug: string | null;
|
|
637
|
+
};
|
|
638
|
+
declare const getControlMeta: ({ records, excludeIndex, excludeSlug, }: {
|
|
639
|
+
records: ControlRecord[];
|
|
640
|
+
excludeIndex?: number | null;
|
|
641
|
+
excludeSlug?: string | null;
|
|
642
|
+
}) => {
|
|
643
|
+
existingIndexes: number[];
|
|
644
|
+
availableIndex: number;
|
|
645
|
+
existingSlugs: string[];
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
export { AdminProvider, ArrayInput, Button, type ButtonProps, Checkbox, ContentContainer, ControlFields, type ControlMeta, Field, FieldBody, FieldsContainer, Form, IndexField, Input, type InputProps, LayoutSkeleton, ListCardsContainer, MainFields, NAVBAR_HEIGHT, type NavItem, NavMain, Option, PAGE_HEADER_HEIGHT, PageHeader, PasswordInput, ReturnButton, SIDEBAR_WIDTH, SearchInput, Select, type ShowToastOption, SideFields, SlugField, Textarea, ThemeProvider, cn, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createI18nSelector, createNavbar, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSignOutButton, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, getControlMeta, handleToast, useAdmin, useDeviceInfo, usePickItems };
|
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { cn, useSidebar, Sidebar, Skeleton, SidebarInset, SIDEBAR_WIDTH, SidebarGroup, SidebarMenu, Collapsible, SidebarMenuItem, SidebarMenuButton, Separator, CollapsibleTrigger, SidebarMenuAction, CollapsibleContent, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton, Button, Spinner, useParentPathname, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, PAGE_HEADER_HEIGHT, InputGroup, InputGroupAddon, Textarea, InputGroupInput, InputGroupButton, Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, Label, FORM_MIDDLE_GAP_WIDTH, FORM_SIDE_FIELDS_WIDTH, Card, useDeviceInfo, CardHeader, CardTitle, CardContent, useCountdown, CardDescription, NAVBAR_HEIGHT, isConfirm, Avatar, AvatarImage, AvatarFallback, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuGroup, Pagination, PaginationContent, PaginationItem, PaginationPrevious, PaginationLink, PaginationEllipsis, PaginationNext } from '../chunk-
|
|
2
|
-
export { NAVBAR_HEIGHT, PAGE_HEADER_HEIGHT, SIDEBAR_WIDTH, Sidebar, SidebarContent, SidebarInset, SidebarProvider, cn, useDeviceInfo, useSidebar } from '../chunk-
|
|
1
|
+
import { cn, useSidebar, Sidebar, Skeleton, SidebarInset, SIDEBAR_WIDTH, SidebarGroup, SidebarMenu, Collapsible, SidebarMenuItem, SidebarMenuButton, Separator, CollapsibleTrigger, SidebarMenuAction, CollapsibleContent, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton, Button, Spinner, useParentPathname, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, PAGE_HEADER_HEIGHT, InputGroup, InputGroupAddon, Textarea, InputGroupInput, InputGroupButton, Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, Label, FORM_MIDDLE_GAP_WIDTH, FORM_SIDE_FIELDS_WIDTH, Card, useDeviceInfo, CardHeader, CardTitle, CardContent, useCountdown, CardDescription, NAVBAR_HEIGHT, isConfirm, Avatar, AvatarImage, AvatarFallback, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuGroup, Pagination, PaginationContent, PaginationItem, PaginationPrevious, PaginationLink, PaginationEllipsis, PaginationNext } from '../chunk-TUHPRDMA.js';
|
|
2
|
+
export { NAVBAR_HEIGHT, PAGE_HEADER_HEIGHT, SIDEBAR_WIDTH, Sidebar, SidebarContent, SidebarInset, SidebarProvider, cn, getControlMeta, useDeviceInfo, usePickItems, useSidebar } from '../chunk-TUHPRDMA.js';
|
|
3
3
|
import { ensureArray, findTranslation, joinUrl } from '../chunk-VSV6SQWC.js';
|
|
4
4
|
import { toast } from 'sonner';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Avatar, AvatarFallback, AvatarImage, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Collapsible, CollapsibleContent, CollapsibleTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, SIDEBAR_COOKIE_NAME, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Spinner, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, buttonVariants, useSidebar } from '../../chunk-
|
|
1
|
+
export { Avatar, AvatarFallback, AvatarImage, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Collapsible, CollapsibleContent, CollapsibleTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, SIDEBAR_COOKIE_NAME, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Spinner, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, buttonVariants, useSidebar } from '../../chunk-TUHPRDMA.js';
|