@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,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import '@radix-ui/react-avatar';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'ua-parser-js';
|
|
6
|
+
import 'clsx';
|
|
7
|
+
import 'tailwind-merge';
|
|
8
|
+
import 'next/navigation';
|
|
9
|
+
import '../../../shadcn/badge.js';
|
|
10
|
+
import '../../../shadcn/button.js';
|
|
11
|
+
import '@radix-ui/react-collapsible';
|
|
12
|
+
import '@radix-ui/react-dialog';
|
|
13
|
+
import 'lucide-react';
|
|
14
|
+
import '@radix-ui/react-dropdown-menu';
|
|
15
|
+
import '../../../shadcn/input-group.js';
|
|
16
|
+
import '@radix-ui/react-label';
|
|
17
|
+
import { Pagination as Pagination$1, PaginationContent, PaginationItem, PaginationPrevious, PaginationLink, PaginationEllipsis, PaginationNext } from '../../../shadcn/pagination.js';
|
|
18
|
+
import '@radix-ui/react-select';
|
|
19
|
+
import '@radix-ui/react-separator';
|
|
20
|
+
import '../../../shadcn/sidebar.js';
|
|
21
|
+
import '@radix-ui/react-tooltip';
|
|
22
|
+
|
|
23
|
+
function Pagination({
|
|
24
|
+
page,
|
|
25
|
+
setPage,
|
|
26
|
+
pageSize,
|
|
27
|
+
total = 0
|
|
28
|
+
}) {
|
|
29
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
30
|
+
const isFirst = page === 1;
|
|
31
|
+
const isLastPage = page === totalPages;
|
|
32
|
+
const handlePrev = () => {
|
|
33
|
+
if (isFirst) return;
|
|
34
|
+
setPage((prev) => prev - 1);
|
|
35
|
+
};
|
|
36
|
+
const handleNext = () => {
|
|
37
|
+
if (isLastPage) return;
|
|
38
|
+
setPage((prev) => prev + 1);
|
|
39
|
+
};
|
|
40
|
+
const siblingsCount = 2;
|
|
41
|
+
let startPage = Math.max(2, page - siblingsCount);
|
|
42
|
+
let endPage = Math.min(totalPages - 1, page + siblingsCount);
|
|
43
|
+
if (page - siblingsCount < 2) {
|
|
44
|
+
endPage = Math.min(totalPages - 1, endPage + (2 - (page - siblingsCount)));
|
|
45
|
+
}
|
|
46
|
+
if (page + siblingsCount > totalPages - 1) {
|
|
47
|
+
startPage = Math.max(
|
|
48
|
+
2,
|
|
49
|
+
startPage - (page + siblingsCount - (totalPages - 1))
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
const pages = [];
|
|
53
|
+
for (let i = startPage; i <= endPage; i++) {
|
|
54
|
+
pages.push(i);
|
|
55
|
+
}
|
|
56
|
+
const isAtFirstPage = page === 1;
|
|
57
|
+
const isAtLastPage = page === totalPages;
|
|
58
|
+
return /* @__PURE__ */ jsx(Pagination$1, { className: "flex-1", children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
|
|
59
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationPrevious, { disabled: isAtFirstPage, onClick: handlePrev }) }),
|
|
60
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(
|
|
61
|
+
PaginationLink,
|
|
62
|
+
{
|
|
63
|
+
isActive: page === 1,
|
|
64
|
+
disabled: isAtFirstPage,
|
|
65
|
+
onClick: () => setPage(1),
|
|
66
|
+
children: "1"
|
|
67
|
+
}
|
|
68
|
+
) }),
|
|
69
|
+
startPage > 2 && /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }),
|
|
70
|
+
pages.map((p) => {
|
|
71
|
+
const isThisPage = page === p;
|
|
72
|
+
return /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { isActive: isThisPage, onClick: () => setPage(p), children: p }) }, p);
|
|
73
|
+
}),
|
|
74
|
+
endPage < totalPages - 1 && /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }),
|
|
75
|
+
totalPages > 1 && /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(
|
|
76
|
+
PaginationLink,
|
|
77
|
+
{
|
|
78
|
+
isActive: page === totalPages,
|
|
79
|
+
disabled: isAtLastPage,
|
|
80
|
+
onClick: () => setPage(totalPages),
|
|
81
|
+
children: totalPages
|
|
82
|
+
}
|
|
83
|
+
) }),
|
|
84
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(
|
|
85
|
+
PaginationNext,
|
|
86
|
+
{
|
|
87
|
+
disabled: isAtLastPage || totalPages <= 1,
|
|
88
|
+
onClick: handleNext
|
|
89
|
+
}
|
|
90
|
+
) })
|
|
91
|
+
] }) });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { Pagination };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import 'ua-parser-js';
|
|
4
|
+
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
5
|
+
import 'next/navigation';
|
|
6
|
+
|
|
7
|
+
function PageHeaderTitle({
|
|
8
|
+
icon,
|
|
9
|
+
title,
|
|
10
|
+
subtitle,
|
|
11
|
+
children,
|
|
12
|
+
leftChildren,
|
|
13
|
+
className
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-3", className), children: [
|
|
16
|
+
leftChildren,
|
|
17
|
+
icon && createElement(icon),
|
|
18
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-center w-fit gap-3 whitespace-nowrap", children: [
|
|
19
|
+
subtitle && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: subtitle }),
|
|
20
|
+
/* @__PURE__ */ jsx("p", { className: "scroll-m-20 text-xl font-semibold tracking-tight", children: title })
|
|
21
|
+
] }),
|
|
22
|
+
children
|
|
23
|
+
] });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { PageHeaderTitle };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import { Files } from 'lucide-react';
|
|
5
|
+
import 'react';
|
|
6
|
+
import 'ua-parser-js';
|
|
7
|
+
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
8
|
+
import 'next/navigation';
|
|
9
|
+
import { PAGE_HEADER_HEIGHT } from '../../../../styles/constants.js';
|
|
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 { Separator } from '../../../shadcn/separator.js';
|
|
20
|
+
import '../../../shadcn/sidebar.js';
|
|
21
|
+
import '@radix-ui/react-tooltip';
|
|
22
|
+
import { PageHeaderTitle } from './page-header-title.js';
|
|
23
|
+
import { createIndexPreset } from './presets/index.js';
|
|
24
|
+
import { createBatchPreset } from './presets/batch.js';
|
|
25
|
+
import { createBatchCreatePreset } from './presets/batch-create.js';
|
|
26
|
+
import { createCreatePreset } from './presets/create.js';
|
|
27
|
+
import { createEditPreset } from './presets/edit.js';
|
|
28
|
+
import { createShowPreset } from './presets/show.js';
|
|
29
|
+
import { createTrashPreset } from './presets/trash.js';
|
|
30
|
+
|
|
31
|
+
const PRESET_BUILDERS = {
|
|
32
|
+
default: () => ({ titleProps: { icon: Files } }),
|
|
33
|
+
index: createIndexPreset,
|
|
34
|
+
create: createCreatePreset,
|
|
35
|
+
show: createShowPreset,
|
|
36
|
+
edit: createEditPreset,
|
|
37
|
+
batch: createBatchPreset,
|
|
38
|
+
"batch-create": createBatchCreatePreset,
|
|
39
|
+
trash: createTrashPreset
|
|
40
|
+
};
|
|
41
|
+
function PageHeader(props) {
|
|
42
|
+
const { t } = useTranslator();
|
|
43
|
+
const variant = props.variant ?? "default";
|
|
44
|
+
const isDefault = variant === "default";
|
|
45
|
+
const preset = PRESET_BUILDERS[variant]({ props, t });
|
|
46
|
+
const left = props.leftChildren ?? preset.left;
|
|
47
|
+
const resolvedTitleProps = { ...preset.titleProps, ...props.titleProps };
|
|
48
|
+
const right = props.rightChildren ?? preset.right;
|
|
49
|
+
return /* @__PURE__ */ jsxs("div", { style: { height: PAGE_HEADER_HEIGHT }, children: [
|
|
50
|
+
/* @__PURE__ */ jsxs(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: cn(
|
|
54
|
+
"relative h-full px-6",
|
|
55
|
+
"flex items-center justify-between gap-3"
|
|
56
|
+
),
|
|
57
|
+
children: [
|
|
58
|
+
!isDefault && left && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-3", children: left }),
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
PageHeaderTitle,
|
|
61
|
+
{
|
|
62
|
+
className: cn(!isDefault && "absolute left-1/2 -translate-x-1/2"),
|
|
63
|
+
...resolvedTitleProps
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
right && /* @__PURE__ */ jsx("div", { className: "ml-auto flex items-center gap-3", children: right })
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ jsx(Separator, {})
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { PageHeader };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { FilePlus } from 'lucide-react';
|
|
3
|
+
import 'next/navigation';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@radix-ui/react-avatar';
|
|
6
|
+
import 'ua-parser-js';
|
|
7
|
+
import 'clsx';
|
|
8
|
+
import 'tailwind-merge';
|
|
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 { ReturnButton } from '../../../buttons/return-button.js';
|
|
21
|
+
|
|
22
|
+
function createBatchCreatePreset(ctx) {
|
|
23
|
+
const { props, t } = ctx;
|
|
24
|
+
return {
|
|
25
|
+
left: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ReturnButton, { useConfirm: true, replaceParent: true, ...props.returnButtonProps }) }),
|
|
26
|
+
titleProps: {
|
|
27
|
+
icon: FilePlus,
|
|
28
|
+
subtitle: t("ui.page-header.batch-create.subtitle.text")
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { createBatchCreatePreset };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { FilePen, CopyCheck, CopyX, FileX, FilePlus } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../../buttons/button.js';
|
|
4
|
+
import { ReturnButton } from '../../../buttons/return-button.js';
|
|
5
|
+
|
|
6
|
+
function createBatchPreset(ctx) {
|
|
7
|
+
const { props, t } = ctx;
|
|
8
|
+
return {
|
|
9
|
+
left: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ReturnButton, { pushToParent: true, ...props.returnButtonProps, children: t("ui.button.exit-batch-mode.text") }) }),
|
|
10
|
+
titleProps: {
|
|
11
|
+
icon: FilePen,
|
|
12
|
+
subtitle: t("ui.page-header.batch.subtitle.text"),
|
|
13
|
+
children: /* @__PURE__ */ jsx(
|
|
14
|
+
Button,
|
|
15
|
+
{
|
|
16
|
+
variant: "success",
|
|
17
|
+
href: props.batchCreateButtonHref,
|
|
18
|
+
icon: FilePlus,
|
|
19
|
+
children: t("ui.button.batch-create.text")
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
},
|
|
23
|
+
right: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Button, { size: "icon", variant: "outline", onClick: props.selectAllFn, children: /* @__PURE__ */ jsx(CopyCheck, {}) }),
|
|
25
|
+
/* @__PURE__ */ jsx(Button, { size: "icon", variant: "outline", onClick: props.cancelAllFn, children: /* @__PURE__ */ jsx(CopyX, {}) }),
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
Button,
|
|
28
|
+
{
|
|
29
|
+
...props.destroyButtonProps,
|
|
30
|
+
variant: "destructive",
|
|
31
|
+
icon: FileX,
|
|
32
|
+
children: t("ui.button.destroy.text")
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
] })
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { createBatchPreset };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { FilePlus } from 'lucide-react';
|
|
3
|
+
import 'next/navigation';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@radix-ui/react-avatar';
|
|
6
|
+
import 'ua-parser-js';
|
|
7
|
+
import 'clsx';
|
|
8
|
+
import 'tailwind-merge';
|
|
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 { ReturnButton } from '../../../buttons/return-button.js';
|
|
21
|
+
|
|
22
|
+
function createCreatePreset(ctx) {
|
|
23
|
+
const { props, t } = ctx;
|
|
24
|
+
return {
|
|
25
|
+
left: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ReturnButton, { useConfirm: true, replaceParent: true, ...props.returnButtonProps }) }),
|
|
26
|
+
titleProps: {
|
|
27
|
+
icon: FilePlus,
|
|
28
|
+
subtitle: t("ui.page-header.create.subtitle.text")
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { createCreatePreset };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { FilePen } from 'lucide-react';
|
|
3
|
+
import 'next/navigation';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@radix-ui/react-avatar';
|
|
6
|
+
import 'ua-parser-js';
|
|
7
|
+
import 'clsx';
|
|
8
|
+
import 'tailwind-merge';
|
|
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 { ReturnButton } from '../../../buttons/return-button.js';
|
|
21
|
+
|
|
22
|
+
function createEditPreset(ctx) {
|
|
23
|
+
const { props, t } = ctx;
|
|
24
|
+
return {
|
|
25
|
+
left: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ReturnButton, { useConfirm: true, replaceParent: true, ...props.returnButtonProps }) }),
|
|
26
|
+
titleProps: {
|
|
27
|
+
icon: FilePen,
|
|
28
|
+
subtitle: t("ui.page-header.edit.subtitle.text")
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { createEditPreset };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { Files, FileStack, FolderCog, FileSpreadsheet, FilePlus } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../../buttons/button.js';
|
|
4
|
+
import { ReturnButton } from '../../../buttons/return-button.js';
|
|
5
|
+
|
|
6
|
+
function createIndexPreset(ctx) {
|
|
7
|
+
const { props, t } = ctx;
|
|
8
|
+
return {
|
|
9
|
+
left: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ReturnButton, { pushToParent: true, ...props.returnButtonProps }) }),
|
|
10
|
+
titleProps: {
|
|
11
|
+
icon: Files,
|
|
12
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13
|
+
props.settingButtonProps && props.showTopicSettingButton && /* @__PURE__ */ jsx(
|
|
14
|
+
Button,
|
|
15
|
+
{
|
|
16
|
+
...props.settingButtonProps,
|
|
17
|
+
variant: "outline",
|
|
18
|
+
icon: FolderCog,
|
|
19
|
+
isDisabled: props.settingButtonProps.isDisabled ?? props.isDisabled,
|
|
20
|
+
children: `${t("ui.button.setting.text")} ${t("resources.topic.text")}`
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
props.createCategoryButtonProps && /* @__PURE__ */ jsx(
|
|
24
|
+
Button,
|
|
25
|
+
{
|
|
26
|
+
...props.createCategoryButtonProps,
|
|
27
|
+
variant: "success",
|
|
28
|
+
icon: FileSpreadsheet,
|
|
29
|
+
isDisabled: props.createCategoryButtonProps.isDisabled ?? props.isDisabled,
|
|
30
|
+
children: t("ui.button.create.text")
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
props.createButtonProps && /* @__PURE__ */ jsx(
|
|
34
|
+
Button,
|
|
35
|
+
{
|
|
36
|
+
variant: "success",
|
|
37
|
+
icon: FilePlus,
|
|
38
|
+
...props.createButtonProps,
|
|
39
|
+
children: t("ui.button.create.text")
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
] })
|
|
43
|
+
},
|
|
44
|
+
right: props.batchButtonProps && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Button, { variant: "outline", icon: FileStack, ...props.batchButtonProps, children: /* @__PURE__ */ jsx("span", { className: "text-sm", children: t("ui.button.batch.text") }) }) })
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { createIndexPreset };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { File, FileStack, FolderSearch, FilePen, FileX, Lock } from 'lucide-react';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'ua-parser-js';
|
|
5
|
+
import { cn } from '../../../../../../applications/shadcn/utils.js';
|
|
6
|
+
import 'next/navigation';
|
|
7
|
+
import { Button } from '../../../buttons/button.js';
|
|
8
|
+
import { ReturnButton } from '../../../buttons/return-button.js';
|
|
9
|
+
|
|
10
|
+
function createShowPreset(ctx) {
|
|
11
|
+
const { props, t } = ctx;
|
|
12
|
+
return {
|
|
13
|
+
left: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ReturnButton, { pushToParent: true, ...props.returnButtonProps }) }),
|
|
14
|
+
titleProps: {
|
|
15
|
+
icon: File,
|
|
16
|
+
children: !props.isNotFound && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
17
|
+
props.showButtonProps && /* @__PURE__ */ jsx(
|
|
18
|
+
Button,
|
|
19
|
+
{
|
|
20
|
+
...props.showButtonProps,
|
|
21
|
+
variant: "outline",
|
|
22
|
+
icon: FolderSearch,
|
|
23
|
+
isDisabled: props.showButtonProps.isDisabled || props.isDisabled,
|
|
24
|
+
children: `${t("ui.button.show.text")} ${t("resources.related.text")}`
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
props.editButtonProps && /* @__PURE__ */ jsx(
|
|
28
|
+
Button,
|
|
29
|
+
{
|
|
30
|
+
...props.editButtonProps,
|
|
31
|
+
variant: "warning",
|
|
32
|
+
icon: FilePen,
|
|
33
|
+
isDisabled: props.editButtonProps.isDisabled || props.isDisabled,
|
|
34
|
+
children: t("ui.button.edit.text")
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
props.destroyButtonProps && /* @__PURE__ */ jsx(
|
|
38
|
+
Button,
|
|
39
|
+
{
|
|
40
|
+
...props.destroyButtonProps,
|
|
41
|
+
variant: "destructive",
|
|
42
|
+
icon: FileX,
|
|
43
|
+
isDisabled: props.destroyButtonProps.isDisabled || props.isDisabled,
|
|
44
|
+
children: t("ui.button.destroy.text")
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
Lock,
|
|
49
|
+
{
|
|
50
|
+
className: cn(
|
|
51
|
+
props.isLocked && !props.isDisabled ? "opacity-100" : "opacity-0"
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] })
|
|
56
|
+
},
|
|
57
|
+
right: props.batchButtonProps && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Button, { variant: "outline", icon: FileStack, ...props.batchButtonProps, children: /* @__PURE__ */ jsx("span", { className: "text-sm", children: t("ui.button.batch.text") }) }) })
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { createShowPreset };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Trash2, CopyCheck, CopyX, FileSymlink, FileX } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../../buttons/button.js';
|
|
4
|
+
import { ReturnButton } from '../../../buttons/return-button.js';
|
|
5
|
+
|
|
6
|
+
function createTrashPreset(ctx) {
|
|
7
|
+
const { props, t } = ctx;
|
|
8
|
+
return {
|
|
9
|
+
left: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ReturnButton, { pushToParent: true, ...props.returnButtonProps }) }),
|
|
10
|
+
titleProps: {
|
|
11
|
+
icon: Trash2,
|
|
12
|
+
title: t("main.trash.text")
|
|
13
|
+
},
|
|
14
|
+
right: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
15
|
+
/* @__PURE__ */ jsx(Button, { size: "icon", variant: "outline", onClick: props.selectAllFn, children: /* @__PURE__ */ jsx(CopyCheck, {}) }),
|
|
16
|
+
/* @__PURE__ */ jsx(Button, { size: "icon", variant: "outline", onClick: props.cancelAllFn, children: /* @__PURE__ */ jsx(CopyX, {}) }),
|
|
17
|
+
/* @__PURE__ */ jsx(
|
|
18
|
+
Button,
|
|
19
|
+
{
|
|
20
|
+
...props.restoreButtonProps,
|
|
21
|
+
variant: "success",
|
|
22
|
+
icon: FileSymlink,
|
|
23
|
+
children: t("ui.button.restore.text")
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
Button,
|
|
28
|
+
{
|
|
29
|
+
...props.destroyButtonProps,
|
|
30
|
+
variant: "destructive",
|
|
31
|
+
icon: FileX,
|
|
32
|
+
children: t("ui.button.destroy.text")
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
] })
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { createTrashPreset };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import { Undo2 } from 'lucide-react';
|
|
5
|
+
import { useRouter } from 'next/navigation';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'ua-parser-js';
|
|
8
|
+
import 'clsx';
|
|
9
|
+
import 'tailwind-merge';
|
|
10
|
+
import { useParentPathname } from '../../../../applications/ui/use-parent-pathname.js';
|
|
11
|
+
import { isConfirm } from '../../../../applications/ui/is-confirm.js';
|
|
12
|
+
import { Button } from './button.js';
|
|
13
|
+
|
|
14
|
+
function ReturnButton({
|
|
15
|
+
icon,
|
|
16
|
+
useIcon = true,
|
|
17
|
+
// use in create/edit page
|
|
18
|
+
useConfirm = false,
|
|
19
|
+
// navigation
|
|
20
|
+
href,
|
|
21
|
+
replace = false,
|
|
22
|
+
pushToParent = false,
|
|
23
|
+
replaceParent = false,
|
|
24
|
+
// base
|
|
25
|
+
className,
|
|
26
|
+
children,
|
|
27
|
+
...props
|
|
28
|
+
}) {
|
|
29
|
+
const { t } = useTranslator();
|
|
30
|
+
const router = useRouter();
|
|
31
|
+
const parentPath = useParentPathname();
|
|
32
|
+
const handelClick = () => {
|
|
33
|
+
if (useConfirm) {
|
|
34
|
+
if (!isConfirm(t)) return;
|
|
35
|
+
}
|
|
36
|
+
if (href) {
|
|
37
|
+
return replace ? router.replace(href) : router.push(href);
|
|
38
|
+
}
|
|
39
|
+
if (replaceParent) {
|
|
40
|
+
return router.replace(parentPath);
|
|
41
|
+
}
|
|
42
|
+
if (pushToParent) {
|
|
43
|
+
return router.push(parentPath);
|
|
44
|
+
}
|
|
45
|
+
router.back();
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
Button,
|
|
49
|
+
{
|
|
50
|
+
variant: "outline",
|
|
51
|
+
size: "sm",
|
|
52
|
+
icon: useIcon ? icon || Undo2 : void 0,
|
|
53
|
+
onClick: handelClick,
|
|
54
|
+
className,
|
|
55
|
+
...props,
|
|
56
|
+
children: children ?? t("ui.button.return.text")
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { ReturnButton };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import '@radix-ui/react-avatar';
|
|
5
|
+
import 'react';
|
|
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 { Card } from '../../shadcn/card.js';
|
|
13
|
+
import '@radix-ui/react-collapsible';
|
|
14
|
+
import '@radix-ui/react-dialog';
|
|
15
|
+
import 'lucide-react';
|
|
16
|
+
import '@radix-ui/react-dropdown-menu';
|
|
17
|
+
import '../../shadcn/input-group.js';
|
|
18
|
+
import '@radix-ui/react-label';
|
|
19
|
+
import '@radix-ui/react-select';
|
|
20
|
+
import '@radix-ui/react-separator';
|
|
21
|
+
import '../../shadcn/sidebar.js';
|
|
22
|
+
import '@radix-ui/react-tooltip';
|
|
23
|
+
import { Button } from '../buttons/button.js';
|
|
24
|
+
import { ReturnButton } from '../buttons/return-button.js';
|
|
25
|
+
|
|
26
|
+
function ActionButtonsCard({
|
|
27
|
+
action = "create",
|
|
28
|
+
// button props
|
|
29
|
+
cancelButtonProps,
|
|
30
|
+
actionButtonProps,
|
|
31
|
+
// ui states
|
|
32
|
+
isProcessing = false,
|
|
33
|
+
isInitializing = false
|
|
34
|
+
}) {
|
|
35
|
+
const { t } = useTranslator();
|
|
36
|
+
let type = "submit";
|
|
37
|
+
let variant = "success";
|
|
38
|
+
let children = t("ui.button.create.text");
|
|
39
|
+
switch (action) {
|
|
40
|
+
case "update": {
|
|
41
|
+
variant = "warning";
|
|
42
|
+
children = t("ui.button.update.text");
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case "confirm": {
|
|
46
|
+
type = "button";
|
|
47
|
+
children = t("ui.button.confirm.text");
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ jsx(Card, { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
ReturnButton,
|
|
54
|
+
{
|
|
55
|
+
type: "button",
|
|
56
|
+
size: "lg",
|
|
57
|
+
isDisabled: isInitializing,
|
|
58
|
+
useConfirm: true,
|
|
59
|
+
useIcon: false,
|
|
60
|
+
replaceParent: true,
|
|
61
|
+
className: "min-w-[128px]",
|
|
62
|
+
...cancelButtonProps,
|
|
63
|
+
children: t("ui.button.cancel.text")
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ jsx(
|
|
67
|
+
Button,
|
|
68
|
+
{
|
|
69
|
+
type,
|
|
70
|
+
size: "lg",
|
|
71
|
+
variant,
|
|
72
|
+
isLoading: isProcessing,
|
|
73
|
+
isDisabled: isInitializing,
|
|
74
|
+
className: "min-w-[126px]",
|
|
75
|
+
...actionButtonProps,
|
|
76
|
+
children
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
] }) });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { ActionButtonsCard };
|