@yimingliao/cms 0.0.146 → 0.0.147
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/export/client/components/index.js +69 -0
- package/dist/src/client/applications/ui/use-parent-pathname.js +10 -0
- package/dist/src/client/interfaces/components/admin-initializer.js +29 -0
- package/dist/src/client/interfaces/components/resources/file/file-card.js +87 -0
- package/dist/src/client/interfaces/components/resources/file/file-list.js +159 -0
- package/dist/src/client/interfaces/components/resources/file/is-locked-buttons.js +71 -0
- package/dist/src/client/interfaces/components/resources/file/type-buttons.js +62 -0
- package/dist/src/client/interfaces/components/shadcn/sidebar.js +1 -1
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js +96 -0
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js +63 -0
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/pagination.js +94 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header-title.js +26 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header.js +74 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch-create.js +33 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch.js +39 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/create.js +33 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/edit.js +33 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/index.js +48 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/show.js +61 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/trash.js +39 -0
- package/dist/src/client/interfaces/components/ui/buttons/return-button.js +61 -0
- package/dist/src/client/interfaces/components/ui/cards/action-buttons-card.js +82 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-status-bar.js +51 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-text-content.js +38 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/resource-card.js +77 -0
- package/dist/src/client/interfaces/components/ui/display/array-list.js +69 -0
- package/dist/src/client/interfaces/components/ui/display/badge.js +41 -0
- package/dist/src/client/interfaces/components/ui/display/html-display.js +32 -0
- package/dist/src/client/interfaces/components/ui/display/object-array-list.js +75 -0
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion-container.js +31 -0
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion-header.js +34 -0
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion.js +81 -0
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expand-bar.js +39 -0
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list-content.js +49 -0
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list.js +53 -0
- package/dist/src/client/interfaces/components/ui/features/external-link.js +15 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-info/file-info.js +118 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-info/file-name.js +48 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-container.js +74 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-placeholder.js +48 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker.js +109 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-list.js +85 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-meta.js +40 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview.js +113 -0
- package/dist/src/client/interfaces/components/ui/features/file/uploader.js +101 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-body.js +112 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-trigger.js +97 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal.js +77 -0
- package/dist/src/client/interfaces/components/ui/features/smart-image.js +57 -0
- package/dist/src/client/interfaces/components/ui/features/tick.js +27 -0
- package/dist/src/client/interfaces/components/ui/form/containers/fields-container.js +24 -0
- package/dist/src/client/interfaces/components/ui/form/containers/main-fields.js +25 -0
- package/dist/src/client/interfaces/components/ui/form/containers/side-fields.js +24 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/built-in-fields.js +9 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-display.js +112 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-input.js +158 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields.js +59 -0
- package/dist/src/client/interfaces/components/ui/form/field-body.js +79 -0
- package/dist/src/client/interfaces/components/ui/form/index-field.js +87 -0
- package/dist/src/client/interfaces/components/ui/form/slug-field.js +82 -0
- package/dist/src/client/interfaces/components/ui/inputs/array-input.js +110 -0
- package/dist/src/client/interfaces/components/ui/inputs/checkbox.js +93 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/base-editor.js +143 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/built-in-plugins.js +71 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/heading.config.js +41 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/image.config.js +32 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/table.config.js +15 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/editor.js +112 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/asset-manager.js +24 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/use-control-asset-mamager.js +26 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/upload-adapter.js +84 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.js +17 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/word-count-display.js +81 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.js +50 -0
- package/dist/src/client/interfaces/components/ui/inputs/search-input.js +61 -0
- package/dist/src/client/interfaces/components/ui/inputs/select.js +69 -0
- package/dist/src/client/interfaces/components/ui/inputs/textarea.js +62 -0
- package/dist/src/client/interfaces/components/ui/layouts/content-container.js +38 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/i18n-selector.js +42 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/nav-user.js +106 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/navbar.js +84 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/sign-out-button.js +58 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/theme-selector.js +51 -0
- package/dist/src/client/interfaces/components/ui/layouts/sidebar/nav-main.js +99 -0
- package/dist/src/client/interfaces/styles/constants.js +3 -1
- package/dist/src/constants/file.js +27 -0
- package/dist/src/shared/list-items.js +3 -0
- package/dist/src/shared/utils/debounce.js +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export { createAdminInitializer } from '../../../src/client/interfaces/components/admin-initializer.js';
|
|
2
|
+
export { PageHeader } from '../../../src/client/interfaces/components/ui/blocks/page-header/page-header.js';
|
|
3
|
+
export { ListCardsContainer } from '../../../src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js';
|
|
4
|
+
export { Button } from '../../../src/client/interfaces/components/ui/buttons/button.js';
|
|
5
|
+
export { ReturnButton } from '../../../src/client/interfaces/components/ui/buttons/return-button.js';
|
|
6
|
+
export { ResourceCard } from '../../../src/client/interfaces/components/ui/cards/resource-card/resource-card.js';
|
|
7
|
+
export { ActionButtonsCard } from '../../../src/client/interfaces/components/ui/cards/action-buttons-card.js';
|
|
8
|
+
export { ArrayList } from '../../../src/client/interfaces/components/ui/display/array-list.js';
|
|
9
|
+
export { Badge } from '../../../src/client/interfaces/components/ui/display/badge.js';
|
|
10
|
+
export { HtmlDisplay } from '../../../src/client/interfaces/components/ui/display/html-display.js';
|
|
11
|
+
export { ObjectArrayList } from '../../../src/client/interfaces/components/ui/display/object-array-list.js';
|
|
12
|
+
export { Accordion } from '../../../src/client/interfaces/components/ui/features/accordion/accordion.js';
|
|
13
|
+
export { AccordionContainer } from '../../../src/client/interfaces/components/ui/features/accordion/accordion-container.js';
|
|
14
|
+
export { ExpandableList } from '../../../src/client/interfaces/components/ui/features/expandable-list/expandable-list.js';
|
|
15
|
+
export { createFileInfo } from '../../../src/client/interfaces/components/ui/features/file/file-info/file-info.js';
|
|
16
|
+
export { createFilePreview } from '../../../src/client/interfaces/components/ui/features/file/file-preview/file-preview.js';
|
|
17
|
+
export { createFilePreviewList } from '../../../src/client/interfaces/components/ui/features/file/file-preview/file-preview-list.js';
|
|
18
|
+
export { createFilePicker } from '../../../src/client/interfaces/components/ui/features/file/file-picker/file-picker.js';
|
|
19
|
+
export { createUploader } from '../../../src/client/interfaces/components/ui/features/file/uploader.js';
|
|
20
|
+
export { PickModal } from '../../../src/client/interfaces/components/ui/features/pick-modal/pick-modal.js';
|
|
21
|
+
export { ExternalLink } from '../../../src/client/interfaces/components/ui/features/external-link.js';
|
|
22
|
+
export { createSmartImage } from '../../../src/client/interfaces/components/ui/features/smart-image.js';
|
|
23
|
+
export { Tick } from '../../../src/client/interfaces/components/ui/features/tick.js';
|
|
24
|
+
export { Form } from '../../../src/client/interfaces/components/ui/form/form.js';
|
|
25
|
+
export { Field } from '../../../src/client/interfaces/components/ui/form/field.js';
|
|
26
|
+
export { FieldBody } from '../../../src/client/interfaces/components/ui/form/field-body.js';
|
|
27
|
+
export { FieldsContainer } from '../../../src/client/interfaces/components/ui/form/containers/fields-container.js';
|
|
28
|
+
export { MainFields } from '../../../src/client/interfaces/components/ui/form/containers/main-fields.js';
|
|
29
|
+
export { SideFields } from '../../../src/client/interfaces/components/ui/form/containers/side-fields.js';
|
|
30
|
+
export { IndexField } from '../../../src/client/interfaces/components/ui/form/index-field.js';
|
|
31
|
+
export { SlugField } from '../../../src/client/interfaces/components/ui/form/slug-field.js';
|
|
32
|
+
export { ControlFields } from '../../../src/client/interfaces/components/ui/form/control-fields/control-fields.js';
|
|
33
|
+
export { createEditor } from '../../../src/client/interfaces/components/ui/inputs/editor/editor.js';
|
|
34
|
+
export { createUploadAdapter } from '../../../src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/upload-adapter.js';
|
|
35
|
+
export { ArrayInput } from '../../../src/client/interfaces/components/ui/inputs/array-input.js';
|
|
36
|
+
export { Checkbox } from '../../../src/client/interfaces/components/ui/inputs/checkbox.js';
|
|
37
|
+
export { Input } from '../../../src/client/interfaces/components/ui/inputs/input.js';
|
|
38
|
+
export { PasswordInput } from '../../../src/client/interfaces/components/ui/inputs/password-input.js';
|
|
39
|
+
export { SearchInput } from '../../../src/client/interfaces/components/ui/inputs/search-input.js';
|
|
40
|
+
export { Option, Select } from '../../../src/client/interfaces/components/ui/inputs/select.js';
|
|
41
|
+
export { Textarea } from '../../../src/client/interfaces/components/ui/inputs/textarea.js';
|
|
42
|
+
export { ContentContainer } from '../../../src/client/interfaces/components/ui/layouts/content-container.js';
|
|
43
|
+
export { DashboardSkeleton } from '../../../src/client/interfaces/components/ui/layouts/dashboard-skeleton.js';
|
|
44
|
+
export { AuthSkeleton } from '../../../src/client/interfaces/components/ui/layouts/auth-skeleton.js';
|
|
45
|
+
export { NavMain } from '../../../src/client/interfaces/components/ui/layouts/sidebar/nav-main.js';
|
|
46
|
+
import 'react/jsx-runtime';
|
|
47
|
+
import '@radix-ui/react-avatar';
|
|
48
|
+
import 'react';
|
|
49
|
+
import 'ua-parser-js';
|
|
50
|
+
import 'clsx';
|
|
51
|
+
import 'tailwind-merge';
|
|
52
|
+
import 'next/navigation';
|
|
53
|
+
import '../../../src/client/interfaces/components/shadcn/badge.js';
|
|
54
|
+
import '../../../src/client/interfaces/components/shadcn/button.js';
|
|
55
|
+
import '@radix-ui/react-collapsible';
|
|
56
|
+
import '@radix-ui/react-dialog';
|
|
57
|
+
import 'lucide-react';
|
|
58
|
+
import '@radix-ui/react-dropdown-menu';
|
|
59
|
+
import '../../../src/client/interfaces/components/shadcn/input-group.js';
|
|
60
|
+
import '@radix-ui/react-label';
|
|
61
|
+
import '@radix-ui/react-select';
|
|
62
|
+
import '@radix-ui/react-separator';
|
|
63
|
+
export { Sidebar, SidebarContent, SidebarInset, SidebarProvider, useSidebar } from '../../../src/client/interfaces/components/shadcn/sidebar.js';
|
|
64
|
+
import '@radix-ui/react-tooltip';
|
|
65
|
+
export { createNavbar } from '../../../src/client/interfaces/components/ui/layouts/navbar/navbar.js';
|
|
66
|
+
export { createI18nSelector } from '../../../src/client/interfaces/components/ui/layouts/navbar/i18n-selector.js';
|
|
67
|
+
export { createSignOutButton } from '../../../src/client/interfaces/components/ui/layouts/navbar/sign-out-button.js';
|
|
68
|
+
export { createFileCard } from '../../../src/client/interfaces/components/resources/file/file-card.js';
|
|
69
|
+
export { createFileList } from '../../../src/client/interfaces/components/resources/file/file-list.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { usePathname } from 'next/navigation';
|
|
2
|
+
|
|
3
|
+
const useParentPathname = () => {
|
|
4
|
+
const pathname = usePathname();
|
|
5
|
+
if (pathname === "/") return "/";
|
|
6
|
+
const index = pathname.lastIndexOf("/");
|
|
7
|
+
return index <= 0 ? "/" : pathname.slice(0, index);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { useParentPathname };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { VERIFY_CACHE_KEY } from '../../constants.js';
|
|
4
|
+
|
|
5
|
+
function createAdminInitializer({
|
|
6
|
+
useAdmin,
|
|
7
|
+
useQuery,
|
|
8
|
+
verifyAction
|
|
9
|
+
}) {
|
|
10
|
+
return function AdminInitializer() {
|
|
11
|
+
const { admin: globalAdmin, setAdmin, setIsLoading } = useAdmin();
|
|
12
|
+
const { data: admin, isFetching } = useQuery(
|
|
13
|
+
verifyAction,
|
|
14
|
+
[VERIFY_CACHE_KEY],
|
|
15
|
+
{
|
|
16
|
+
select: (data) => data?.admin,
|
|
17
|
+
enabled: !globalAdmin
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (isFetching) return;
|
|
22
|
+
if (admin) setAdmin(admin);
|
|
23
|
+
setIsLoading(false);
|
|
24
|
+
}, [isFetching, admin, setAdmin, setIsLoading]);
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { createAdminInitializer };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import { Lock, Trash2 } from 'lucide-react';
|
|
5
|
+
import { PATHS } from '../../../../../constants/paths/index.js';
|
|
6
|
+
import '../../../../../constants/redirect-paths.js';
|
|
7
|
+
import '../../../../../domain/resources/admin/constants.js';
|
|
8
|
+
import { isFileLocked } from '../../../../../domain/resources/file/utils/is-file-locked.js';
|
|
9
|
+
import 'mime-types';
|
|
10
|
+
import { findTranslation } from '../../../../../shared/translation/find-translation.js';
|
|
11
|
+
import { joinUrl } from '../../../../../shared/utils/join-url.js';
|
|
12
|
+
import 'react';
|
|
13
|
+
import 'ua-parser-js';
|
|
14
|
+
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
15
|
+
import 'next/navigation';
|
|
16
|
+
import '@radix-ui/react-avatar';
|
|
17
|
+
import '../../shadcn/badge.js';
|
|
18
|
+
import '../../shadcn/button.js';
|
|
19
|
+
import '@radix-ui/react-collapsible';
|
|
20
|
+
import '@radix-ui/react-dialog';
|
|
21
|
+
import '@radix-ui/react-dropdown-menu';
|
|
22
|
+
import '../../shadcn/input-group.js';
|
|
23
|
+
import '@radix-ui/react-label';
|
|
24
|
+
import '@radix-ui/react-select';
|
|
25
|
+
import '@radix-ui/react-separator';
|
|
26
|
+
import '../../shadcn/sidebar.js';
|
|
27
|
+
import '@radix-ui/react-tooltip';
|
|
28
|
+
import 'next/link';
|
|
29
|
+
import { ResourceCard } from '../../ui/cards/resource-card/resource-card.js';
|
|
30
|
+
import 'next/image';
|
|
31
|
+
import 'ckeditor5';
|
|
32
|
+
import 'ckeditor5/translations/en.js';
|
|
33
|
+
import 'ckeditor5/translations/zh.js';
|
|
34
|
+
import 'sonner';
|
|
35
|
+
import '../../../../infrastructure/contexts/admin.js';
|
|
36
|
+
import 'next-themes';
|
|
37
|
+
import '@tanstack/react-query';
|
|
38
|
+
import 'intor/next';
|
|
39
|
+
|
|
40
|
+
const WIDTH = 160;
|
|
41
|
+
const HEIGHT = 160;
|
|
42
|
+
function createFileCard({
|
|
43
|
+
SmartImage,
|
|
44
|
+
storageUrl
|
|
45
|
+
}) {
|
|
46
|
+
return function FileCard({
|
|
47
|
+
file,
|
|
48
|
+
// link
|
|
49
|
+
openNewTab = false,
|
|
50
|
+
anchorProps,
|
|
51
|
+
// base
|
|
52
|
+
className = ""
|
|
53
|
+
}) {
|
|
54
|
+
const { locale } = useTranslator();
|
|
55
|
+
const isImage = file?.type === "IMAGE";
|
|
56
|
+
const isVideo = file?.type === "VIDEO";
|
|
57
|
+
const isLocked = isFileLocked(file);
|
|
58
|
+
const isTrash = file?.deletedAt;
|
|
59
|
+
const translation = findTranslation(file?.translations, locale);
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
ResourceCard,
|
|
62
|
+
{
|
|
63
|
+
className,
|
|
64
|
+
style: { width: `${WIDTH}px`, height: `${HEIGHT}px` },
|
|
65
|
+
href: `${PATHS.resources.file.path}/${file?.id}`,
|
|
66
|
+
openNewTab,
|
|
67
|
+
anchorProps,
|
|
68
|
+
cardStatusBarProps: {
|
|
69
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between", children: [
|
|
70
|
+
isLocked && /* @__PURE__ */ jsx(Lock, { className: "size-5" }),
|
|
71
|
+
isTrash && /* @__PURE__ */ jsx(Trash2, { className: "text-error size-5" })
|
|
72
|
+
] })
|
|
73
|
+
},
|
|
74
|
+
cardTextContentProps: { title: translation?.name },
|
|
75
|
+
children: /* @__PURE__ */ jsx(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: cn("flex-center flex-1", "overflow-hidden", "transition"),
|
|
79
|
+
children: isImage ? /* @__PURE__ */ jsx(SmartImage, { fileKey: file.key, width: WIDTH, height: HEIGHT }) : isVideo ? /* @__PURE__ */ jsx("video", { src: joinUrl(storageUrl, file.key), autoPlay: true, loop: true, muted: true }) : /* @__PURE__ */ jsx("span", { className: cn("scale-[3]", "transition"), children: "\u{1F4C4}" })
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { createFileCard };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
4
|
+
import '../../../../../constants/paths/auth.js';
|
|
5
|
+
import '../../../../../constants/paths/main.js';
|
|
6
|
+
import '../../../../../constants/paths/resources.js';
|
|
7
|
+
import { CACHE_KEYS } from '../../../../../constants/cache-keys.js';
|
|
8
|
+
import '../../../../../constants/redirect-paths.js';
|
|
9
|
+
import 'mime-types';
|
|
10
|
+
import { debounce } from '../../../../../shared/utils/debounce.js';
|
|
11
|
+
import { ensureArray } from '../../../../../shared/utils/ensure-array.js';
|
|
12
|
+
import { DO_NOT_FETCH_KEY } from '../../../../../shared/list-items.js';
|
|
13
|
+
import 'ua-parser-js';
|
|
14
|
+
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
15
|
+
import 'next/navigation';
|
|
16
|
+
import '@radix-ui/react-avatar';
|
|
17
|
+
import '../../shadcn/badge.js';
|
|
18
|
+
import '../../shadcn/button.js';
|
|
19
|
+
import '@radix-ui/react-collapsible';
|
|
20
|
+
import '@radix-ui/react-dialog';
|
|
21
|
+
import 'lucide-react';
|
|
22
|
+
import '@radix-ui/react-dropdown-menu';
|
|
23
|
+
import '../../shadcn/input-group.js';
|
|
24
|
+
import '@radix-ui/react-label';
|
|
25
|
+
import '@radix-ui/react-select';
|
|
26
|
+
import { Separator } from '../../shadcn/separator.js';
|
|
27
|
+
import '../../shadcn/sidebar.js';
|
|
28
|
+
import '@radix-ui/react-tooltip';
|
|
29
|
+
import 'intor/react';
|
|
30
|
+
import { ListCardsContainer } from '../../ui/blocks/list-cards-container/list-cards-container.js';
|
|
31
|
+
import 'next/link';
|
|
32
|
+
import '../../../../../domain/resources/admin/constants.js';
|
|
33
|
+
import 'next/image';
|
|
34
|
+
import { Tick } from '../../ui/features/tick.js';
|
|
35
|
+
import 'ckeditor5';
|
|
36
|
+
import 'ckeditor5/translations/en.js';
|
|
37
|
+
import 'ckeditor5/translations/zh.js';
|
|
38
|
+
import 'sonner';
|
|
39
|
+
import '../../../../infrastructure/contexts/admin.js';
|
|
40
|
+
import 'next-themes';
|
|
41
|
+
import '@tanstack/react-query';
|
|
42
|
+
import 'intor/next';
|
|
43
|
+
import { IsLockedButtons } from './is-locked-buttons.js';
|
|
44
|
+
import { TypeButtons } from './type-buttons.js';
|
|
45
|
+
|
|
46
|
+
function createFileList({
|
|
47
|
+
useQuery,
|
|
48
|
+
fileFindListCardsAction,
|
|
49
|
+
FileCard
|
|
50
|
+
}) {
|
|
51
|
+
return function FileList({
|
|
52
|
+
setItemStates,
|
|
53
|
+
// search
|
|
54
|
+
folderId,
|
|
55
|
+
// Use in File Manager, Folder page
|
|
56
|
+
isDeleted,
|
|
57
|
+
// Use in Trash Page
|
|
58
|
+
fileIds,
|
|
59
|
+
// link
|
|
60
|
+
openNewTab = false,
|
|
61
|
+
// pick
|
|
62
|
+
pickedItems,
|
|
63
|
+
handleClick
|
|
64
|
+
}) {
|
|
65
|
+
const [page, setPage] = useState(1);
|
|
66
|
+
const [pageSize, setPageSize] = useState(20);
|
|
67
|
+
const [searchString, setSearchString] = useState("");
|
|
68
|
+
const debouncedSetSearchString = useMemo(
|
|
69
|
+
() => debounce((v) => setSearchString(v), 300),
|
|
70
|
+
[]
|
|
71
|
+
);
|
|
72
|
+
const [type, setType] = useState(null);
|
|
73
|
+
const [isLocked, setIsLocked] = useState(null);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
setPage(1);
|
|
76
|
+
}, [setPage, type, isLocked]);
|
|
77
|
+
const { data, isFetching, refetch } = useQuery(
|
|
78
|
+
() => fileFindListCardsAction({
|
|
79
|
+
page,
|
|
80
|
+
pageSize,
|
|
81
|
+
searchString,
|
|
82
|
+
type,
|
|
83
|
+
isLocked,
|
|
84
|
+
...folderId && { folderId },
|
|
85
|
+
...isDeleted && { isDeleted },
|
|
86
|
+
// Use in Trash
|
|
87
|
+
...fileIds && { fileIds }
|
|
88
|
+
}),
|
|
89
|
+
[
|
|
90
|
+
CACHE_KEYS.findListCards("file"),
|
|
91
|
+
page,
|
|
92
|
+
pageSize,
|
|
93
|
+
searchString,
|
|
94
|
+
type,
|
|
95
|
+
isLocked,
|
|
96
|
+
folderId,
|
|
97
|
+
isDeleted,
|
|
98
|
+
JSON.stringify(fileIds)
|
|
99
|
+
],
|
|
100
|
+
{ enabled: folderId !== DO_NOT_FETCH_KEY }
|
|
101
|
+
// Use in File Manager
|
|
102
|
+
);
|
|
103
|
+
const files = useMemo(() => ensureArray(data?.items), [data?.items]);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
setItemStates?.({
|
|
106
|
+
items: files,
|
|
107
|
+
count: data?.total ?? 0,
|
|
108
|
+
isFetching,
|
|
109
|
+
refetch
|
|
110
|
+
});
|
|
111
|
+
}, [files, data?.total, isFetching, setItemStates]);
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
ListCardsContainer,
|
|
114
|
+
{
|
|
115
|
+
page,
|
|
116
|
+
setPage,
|
|
117
|
+
pageSize,
|
|
118
|
+
setPageSize,
|
|
119
|
+
total: data?.total ?? 0,
|
|
120
|
+
searchString,
|
|
121
|
+
setSearchString: debouncedSetSearchString,
|
|
122
|
+
isFetching,
|
|
123
|
+
headerChildren: /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
|
|
124
|
+
/* @__PURE__ */ jsx(TypeButtons, { type: type || null, setType }),
|
|
125
|
+
/* @__PURE__ */ jsx("div", { className: "py-1", children: /* @__PURE__ */ jsx(Separator, { orientation: "vertical" }) }),
|
|
126
|
+
/* @__PURE__ */ jsx(IsLockedButtons, { isLocked, setIsLocked })
|
|
127
|
+
] }),
|
|
128
|
+
children: files.map((file) => {
|
|
129
|
+
const isPicked = pickedItems?.some((item) => item.id === file.id);
|
|
130
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative w-fit", children: [
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
FileCard,
|
|
133
|
+
{
|
|
134
|
+
file,
|
|
135
|
+
openNewTab,
|
|
136
|
+
className: cn(pickedItems && !isPicked && "opacity-50"),
|
|
137
|
+
anchorProps: handleClick && {
|
|
138
|
+
onClick: (e) => {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
handleClick(file);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
pickedItems && /* @__PURE__ */ jsx(
|
|
146
|
+
Tick,
|
|
147
|
+
{
|
|
148
|
+
isPicked: isPicked ?? false,
|
|
149
|
+
className: "absolute top-2 right-2"
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] }, file.id);
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { createFileList };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useTranslator } from 'intor/react';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'ua-parser-js';
|
|
5
|
+
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
6
|
+
import 'next/navigation';
|
|
7
|
+
import 'lucide-react';
|
|
8
|
+
import '@radix-ui/react-avatar';
|
|
9
|
+
import '../../shadcn/badge.js';
|
|
10
|
+
import '../../shadcn/button.js';
|
|
11
|
+
import '@radix-ui/react-collapsible';
|
|
12
|
+
import '@radix-ui/react-dialog';
|
|
13
|
+
import '@radix-ui/react-dropdown-menu';
|
|
14
|
+
import '../../shadcn/input-group.js';
|
|
15
|
+
import '@radix-ui/react-label';
|
|
16
|
+
import '@radix-ui/react-select';
|
|
17
|
+
import '@radix-ui/react-separator';
|
|
18
|
+
import '../../shadcn/sidebar.js';
|
|
19
|
+
import '@radix-ui/react-tooltip';
|
|
20
|
+
import { Button } from '../../ui/buttons/button.js';
|
|
21
|
+
import 'next/link';
|
|
22
|
+
import '../../../../../constants/paths/auth.js';
|
|
23
|
+
import '../../../../../constants/paths/main.js';
|
|
24
|
+
import '../../../../../constants/paths/resources.js';
|
|
25
|
+
import '../../../../../constants/redirect-paths.js';
|
|
26
|
+
import 'mime-types';
|
|
27
|
+
import '../../../../../domain/resources/admin/constants.js';
|
|
28
|
+
import 'next/image';
|
|
29
|
+
import 'ckeditor5';
|
|
30
|
+
import 'ckeditor5/translations/en.js';
|
|
31
|
+
import 'ckeditor5/translations/zh.js';
|
|
32
|
+
import 'sonner';
|
|
33
|
+
import '../../../../infrastructure/contexts/admin.js';
|
|
34
|
+
import 'next-themes';
|
|
35
|
+
import '@tanstack/react-query';
|
|
36
|
+
import 'intor/next';
|
|
37
|
+
|
|
38
|
+
function IsLockedButtons({
|
|
39
|
+
isLocked,
|
|
40
|
+
setIsLocked
|
|
41
|
+
}) {
|
|
42
|
+
const { t } = useTranslator();
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-fit gap-3", children: [
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
Button,
|
|
46
|
+
{
|
|
47
|
+
type: "button",
|
|
48
|
+
size: "sm",
|
|
49
|
+
variant: "secondary",
|
|
50
|
+
onClick: () => {
|
|
51
|
+
setIsLocked(isLocked === true ? null : true);
|
|
52
|
+
},
|
|
53
|
+
className: cn(isLocked !== true ? "opacity-35" : "shadow"),
|
|
54
|
+
children: t("resources.file.locked.text")
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
/* @__PURE__ */ jsx(
|
|
58
|
+
Button,
|
|
59
|
+
{
|
|
60
|
+
type: "button",
|
|
61
|
+
size: "sm",
|
|
62
|
+
variant: "secondary",
|
|
63
|
+
onClick: () => setIsLocked(isLocked === false ? null : false),
|
|
64
|
+
className: cn(isLocked !== false ? "opacity-35" : "shadow"),
|
|
65
|
+
children: t("resources.file.not-locked.text")
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { IsLockedButtons };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useTranslator } from 'intor/react';
|
|
3
|
+
import '../../../../../domain/resources/admin/constants.js';
|
|
4
|
+
import { FILE_TYPES } from '../../../../../domain/resources/file/props.js';
|
|
5
|
+
import 'react';
|
|
6
|
+
import 'ua-parser-js';
|
|
7
|
+
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
8
|
+
import 'next/navigation';
|
|
9
|
+
import 'lucide-react';
|
|
10
|
+
import '@radix-ui/react-avatar';
|
|
11
|
+
import '../../shadcn/badge.js';
|
|
12
|
+
import '../../shadcn/button.js';
|
|
13
|
+
import '@radix-ui/react-collapsible';
|
|
14
|
+
import '@radix-ui/react-dialog';
|
|
15
|
+
import '@radix-ui/react-dropdown-menu';
|
|
16
|
+
import '../../shadcn/input-group.js';
|
|
17
|
+
import '@radix-ui/react-label';
|
|
18
|
+
import '@radix-ui/react-select';
|
|
19
|
+
import '@radix-ui/react-separator';
|
|
20
|
+
import '../../shadcn/sidebar.js';
|
|
21
|
+
import '@radix-ui/react-tooltip';
|
|
22
|
+
import { Button } from '../../ui/buttons/button.js';
|
|
23
|
+
import 'next/link';
|
|
24
|
+
import '../../../../../constants/paths/auth.js';
|
|
25
|
+
import '../../../../../constants/paths/main.js';
|
|
26
|
+
import '../../../../../constants/paths/resources.js';
|
|
27
|
+
import '../../../../../constants/redirect-paths.js';
|
|
28
|
+
import 'mime-types';
|
|
29
|
+
import 'next/image';
|
|
30
|
+
import 'ckeditor5';
|
|
31
|
+
import 'ckeditor5/translations/en.js';
|
|
32
|
+
import 'ckeditor5/translations/zh.js';
|
|
33
|
+
import 'sonner';
|
|
34
|
+
import '../../../../infrastructure/contexts/admin.js';
|
|
35
|
+
import 'next-themes';
|
|
36
|
+
import '@tanstack/react-query';
|
|
37
|
+
import 'intor/next';
|
|
38
|
+
|
|
39
|
+
function TypeButtons({ type, setType }) {
|
|
40
|
+
const { t } = useTranslator();
|
|
41
|
+
const handleClick = (fileType) => {
|
|
42
|
+
if (fileType === type) {
|
|
43
|
+
setType(null);
|
|
44
|
+
} else {
|
|
45
|
+
setType(fileType);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ jsx("div", { className: "flex h-fit gap-3", children: Object.values(FILE_TYPES).map((fileType) => /* @__PURE__ */ jsx(
|
|
49
|
+
Button,
|
|
50
|
+
{
|
|
51
|
+
type: "button",
|
|
52
|
+
size: "sm",
|
|
53
|
+
variant: "secondary",
|
|
54
|
+
onClick: () => handleClick(fileType),
|
|
55
|
+
className: cn(fileType !== type ? "opacity-35" : "shadow"),
|
|
56
|
+
children: t(`resources.file.file-type.${fileType.toLowerCase()}.text`)
|
|
57
|
+
},
|
|
58
|
+
fileType
|
|
59
|
+
)) });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { TypeButtons };
|
|
@@ -14,7 +14,7 @@ import { Input } from './input.js';
|
|
|
14
14
|
import { Separator } from './separator.js';
|
|
15
15
|
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription } from './sheet.js';
|
|
16
16
|
import { Skeleton } from './skeleton.js';
|
|
17
|
-
import { Tooltip, TooltipTrigger, TooltipContent
|
|
17
|
+
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from './tooltip.js';
|
|
18
18
|
|
|
19
19
|
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
20
20
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import '@radix-ui/react-avatar';
|
|
6
|
+
import 'ua-parser-js';
|
|
7
|
+
import 'clsx';
|
|
8
|
+
import 'tailwind-merge';
|
|
9
|
+
import 'next/navigation';
|
|
10
|
+
import '../../../shadcn/badge.js';
|
|
11
|
+
import '../../../shadcn/button.js';
|
|
12
|
+
import '@radix-ui/react-collapsible';
|
|
13
|
+
import '@radix-ui/react-dialog';
|
|
14
|
+
import 'lucide-react';
|
|
15
|
+
import '@radix-ui/react-dropdown-menu';
|
|
16
|
+
import '../../../shadcn/input-group.js';
|
|
17
|
+
import '@radix-ui/react-label';
|
|
18
|
+
import '@radix-ui/react-select';
|
|
19
|
+
import '@radix-ui/react-separator';
|
|
20
|
+
import '../../../shadcn/sidebar.js';
|
|
21
|
+
import { Spinner } from '../../../shadcn/spinner.js';
|
|
22
|
+
import '@radix-ui/react-tooltip';
|
|
23
|
+
import 'next/link';
|
|
24
|
+
import '../../../../../../constants/paths/auth.js';
|
|
25
|
+
import '../../../../../../constants/paths/main.js';
|
|
26
|
+
import '../../../../../../constants/paths/resources.js';
|
|
27
|
+
import '../../../../../../constants/redirect-paths.js';
|
|
28
|
+
import 'mime-types';
|
|
29
|
+
import '../../../../../../domain/resources/admin/constants.js';
|
|
30
|
+
import 'next/image';
|
|
31
|
+
import 'ckeditor5';
|
|
32
|
+
import 'ckeditor5/translations/en.js';
|
|
33
|
+
import 'ckeditor5/translations/zh.js';
|
|
34
|
+
import 'sonner';
|
|
35
|
+
import { SearchInput } from '../../inputs/search-input.js';
|
|
36
|
+
import { PageSizeSelector } from './page-size-selector.js';
|
|
37
|
+
import { Pagination } from './pagination.js';
|
|
38
|
+
|
|
39
|
+
function ListCardsContainer({
|
|
40
|
+
// pagination
|
|
41
|
+
page,
|
|
42
|
+
setPage,
|
|
43
|
+
pageSize,
|
|
44
|
+
setPageSize,
|
|
45
|
+
total,
|
|
46
|
+
// search string
|
|
47
|
+
searchString,
|
|
48
|
+
setSearchString,
|
|
49
|
+
// ui states
|
|
50
|
+
isFetching,
|
|
51
|
+
// base
|
|
52
|
+
children,
|
|
53
|
+
headerChildren
|
|
54
|
+
}) {
|
|
55
|
+
const { t } = useTranslator();
|
|
56
|
+
const isNotFound = total === 0;
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
setPage(1);
|
|
59
|
+
}, [searchString, setPage]);
|
|
60
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col gap-6", children: [
|
|
61
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
62
|
+
headerChildren,
|
|
63
|
+
/* @__PURE__ */ jsx("div", { className: "ml-auto w-64", children: /* @__PURE__ */ jsx(
|
|
64
|
+
SearchInput,
|
|
65
|
+
{
|
|
66
|
+
searchString,
|
|
67
|
+
setSearchString,
|
|
68
|
+
isLoading: isFetching
|
|
69
|
+
}
|
|
70
|
+
) })
|
|
71
|
+
] }),
|
|
72
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[88%] flex-1 overflow-y-auto", children: isFetching ? /* @__PURE__ */ jsx(Spinner, {}) : isNotFound ? /* @__PURE__ */ jsx("p", { className: "text-sm opacity-50", children: t("ui.no-data.text") }) : /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-4", children }) }),
|
|
73
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
74
|
+
/* @__PURE__ */ jsx("div", { className: "w-52" }),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
Pagination,
|
|
77
|
+
{
|
|
78
|
+
page,
|
|
79
|
+
setPage,
|
|
80
|
+
pageSize,
|
|
81
|
+
total
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
PageSizeSelector,
|
|
86
|
+
{
|
|
87
|
+
pageSize,
|
|
88
|
+
setPageSize,
|
|
89
|
+
setPage
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] })
|
|
93
|
+
] });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { ListCardsContainer };
|
package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'ua-parser-js';
|
|
6
|
+
import 'clsx';
|
|
7
|
+
import 'tailwind-merge';
|
|
8
|
+
import 'next/navigation';
|
|
9
|
+
import 'lucide-react';
|
|
10
|
+
import '@radix-ui/react-avatar';
|
|
11
|
+
import '../../../shadcn/badge.js';
|
|
12
|
+
import '../../../shadcn/button.js';
|
|
13
|
+
import '@radix-ui/react-collapsible';
|
|
14
|
+
import '@radix-ui/react-dialog';
|
|
15
|
+
import '@radix-ui/react-dropdown-menu';
|
|
16
|
+
import '../../../shadcn/input-group.js';
|
|
17
|
+
import '@radix-ui/react-label';
|
|
18
|
+
import '@radix-ui/react-select';
|
|
19
|
+
import '@radix-ui/react-separator';
|
|
20
|
+
import '../../../shadcn/sidebar.js';
|
|
21
|
+
import '@radix-ui/react-tooltip';
|
|
22
|
+
import 'next/link';
|
|
23
|
+
import '../../../../../../constants/paths/auth.js';
|
|
24
|
+
import '../../../../../../constants/paths/main.js';
|
|
25
|
+
import '../../../../../../constants/paths/resources.js';
|
|
26
|
+
import '../../../../../../constants/redirect-paths.js';
|
|
27
|
+
import 'mime-types';
|
|
28
|
+
import '../../../../../../domain/resources/admin/constants.js';
|
|
29
|
+
import 'next/image';
|
|
30
|
+
import 'ckeditor5';
|
|
31
|
+
import 'ckeditor5/translations/en.js';
|
|
32
|
+
import 'ckeditor5/translations/zh.js';
|
|
33
|
+
import 'sonner';
|
|
34
|
+
import { Select, Option } from '../../inputs/select.js';
|
|
35
|
+
|
|
36
|
+
function PageSizeSelector({
|
|
37
|
+
pageSize,
|
|
38
|
+
setPageSize,
|
|
39
|
+
setPage
|
|
40
|
+
}) {
|
|
41
|
+
const { t } = useTranslator();
|
|
42
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-52 items-center gap-4", children: [
|
|
43
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm whitespace-nowrap", children: t("ui.layout.item-list-container.items-per-page.text") }),
|
|
44
|
+
/* @__PURE__ */ jsxs(
|
|
45
|
+
Select,
|
|
46
|
+
{
|
|
47
|
+
value: String(pageSize),
|
|
48
|
+
onValueChange: (value) => {
|
|
49
|
+
setPageSize(Number(value ?? 20));
|
|
50
|
+
setPage(1);
|
|
51
|
+
},
|
|
52
|
+
className: "w-full",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Option, { value: String(20), children: "20" }),
|
|
55
|
+
/* @__PURE__ */ jsx(Option, { value: String(40), children: "40" }),
|
|
56
|
+
/* @__PURE__ */ jsx(Option, { value: String(80), children: "80" })
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { PageSizeSelector };
|