@yimingliao/cms 0.0.144 → 0.0.146
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/index.js +1 -73
- package/dist/export/client/pages/index.js +8 -0
- package/dist/src/client/interfaces/components/shadcn/sidebar.js +1 -1
- package/dist/src/client/interfaces/styles/constants.js +1 -3
- package/dist/types/export/client/components/index.d.ts +2 -0
- package/dist/types/export/client/components/index.d.ts.map +1 -0
- package/dist/types/export/client/index.d.ts +1 -1
- package/dist/types/export/client/index.d.ts.map +1 -1
- package/dist/types/export/client/pages/index.d.ts +2 -0
- package/dist/types/export/client/pages/index.d.ts.map +1 -0
- package/dist/types/src/client/index.d.ts +1 -1
- package/dist/types/src/client/index.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/index.d.ts +0 -2
- package/dist/types/src/client/interfaces/index.d.ts.map +1 -1
- package/package.json +11 -1
- package/dist/src/client/applications/ui/use-parent-pathname.js +0 -10
- package/dist/src/client/interfaces/components/admin-initializer.js +0 -29
- package/dist/src/client/interfaces/components/resources/file/file-card.js +0 -87
- package/dist/src/client/interfaces/components/resources/file/file-list.js +0 -159
- package/dist/src/client/interfaces/components/resources/file/is-locked-buttons.js +0 -71
- package/dist/src/client/interfaces/components/resources/file/type-buttons.js +0 -62
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js +0 -96
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js +0 -63
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/pagination.js +0 -94
- package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header-title.js +0 -26
- package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header.js +0 -74
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch-create.js +0 -33
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch.js +0 -39
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/create.js +0 -33
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/edit.js +0 -33
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/index.js +0 -48
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/show.js +0 -61
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/trash.js +0 -39
- package/dist/src/client/interfaces/components/ui/buttons/return-button.js +0 -61
- package/dist/src/client/interfaces/components/ui/cards/action-buttons-card.js +0 -82
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-status-bar.js +0 -51
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-text-content.js +0 -38
- package/dist/src/client/interfaces/components/ui/cards/resource-card/resource-card.js +0 -77
- package/dist/src/client/interfaces/components/ui/display/array-list.js +0 -69
- package/dist/src/client/interfaces/components/ui/display/badge.js +0 -41
- package/dist/src/client/interfaces/components/ui/display/html-display.js +0 -32
- package/dist/src/client/interfaces/components/ui/display/object-array-list.js +0 -75
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion-container.js +0 -31
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion-header.js +0 -34
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion.js +0 -81
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expand-bar.js +0 -39
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list-content.js +0 -49
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list.js +0 -53
- package/dist/src/client/interfaces/components/ui/features/external-link.js +0 -15
- package/dist/src/client/interfaces/components/ui/features/file/file-info/file-info.js +0 -118
- package/dist/src/client/interfaces/components/ui/features/file/file-info/file-name.js +0 -48
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-container.js +0 -74
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-placeholder.js +0 -48
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker.js +0 -109
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-list.js +0 -85
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-meta.js +0 -40
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview.js +0 -113
- package/dist/src/client/interfaces/components/ui/features/file/uploader.js +0 -101
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-body.js +0 -112
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-trigger.js +0 -97
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal.js +0 -77
- package/dist/src/client/interfaces/components/ui/features/smart-image.js +0 -57
- package/dist/src/client/interfaces/components/ui/features/tick.js +0 -27
- package/dist/src/client/interfaces/components/ui/form/containers/fields-container.js +0 -24
- package/dist/src/client/interfaces/components/ui/form/containers/main-fields.js +0 -25
- package/dist/src/client/interfaces/components/ui/form/containers/side-fields.js +0 -24
- package/dist/src/client/interfaces/components/ui/form/control-fields/built-in-fields.js +0 -9
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-display.js +0 -112
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-input.js +0 -158
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields.js +0 -59
- package/dist/src/client/interfaces/components/ui/form/field-body.js +0 -79
- package/dist/src/client/interfaces/components/ui/form/index-field.js +0 -87
- package/dist/src/client/interfaces/components/ui/form/slug-field.js +0 -82
- package/dist/src/client/interfaces/components/ui/inputs/array-input.js +0 -110
- package/dist/src/client/interfaces/components/ui/inputs/checkbox.js +0 -93
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/base-editor.js +0 -143
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/built-in-plugins.js +0 -71
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/heading.config.js +0 -41
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/image.config.js +0 -32
- package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/table.config.js +0 -15
- package/dist/src/client/interfaces/components/ui/inputs/editor/editor.js +0 -112
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/asset-manager.js +0 -24
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/use-control-asset-mamager.js +0 -26
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/upload-adapter.js +0 -84
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.js +0 -17
- package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/word-count-display.js +0 -81
- package/dist/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.js +0 -50
- package/dist/src/client/interfaces/components/ui/inputs/search-input.js +0 -61
- package/dist/src/client/interfaces/components/ui/inputs/select.js +0 -69
- package/dist/src/client/interfaces/components/ui/inputs/textarea.js +0 -62
- package/dist/src/client/interfaces/components/ui/layouts/content-container.js +0 -38
- package/dist/src/client/interfaces/components/ui/layouts/navbar/i18n-selector.js +0 -42
- package/dist/src/client/interfaces/components/ui/layouts/navbar/nav-user.js +0 -106
- package/dist/src/client/interfaces/components/ui/layouts/navbar/navbar.js +0 -84
- package/dist/src/client/interfaces/components/ui/layouts/navbar/sign-out-button.js +0 -58
- package/dist/src/client/interfaces/components/ui/layouts/navbar/theme-selector.js +0 -51
- package/dist/src/client/interfaces/components/ui/layouts/sidebar/nav-main.js +0 -99
- package/dist/src/constants/file.js +0 -27
- package/dist/src/shared/list-items.js +0 -3
- package/dist/src/shared/utils/debounce.js +0 -14
package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-meta.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import 'react';
|
|
3
|
-
import 'ua-parser-js';
|
|
4
|
-
import { cn } from '../../../../../../applications/shadcn/utils.js';
|
|
5
|
-
import 'next/navigation';
|
|
6
|
-
|
|
7
|
-
function FilePreviewMeta({
|
|
8
|
-
width,
|
|
9
|
-
height,
|
|
10
|
-
duration
|
|
11
|
-
}) {
|
|
12
|
-
if (!(width || height) && !duration) return;
|
|
13
|
-
return /* @__PURE__ */ jsxs(
|
|
14
|
-
"span",
|
|
15
|
-
{
|
|
16
|
-
className: cn(
|
|
17
|
-
"flex gap-2",
|
|
18
|
-
"rounded",
|
|
19
|
-
"px-2 py-1",
|
|
20
|
-
"text-xs font-[500] text-gray-100",
|
|
21
|
-
"bg-gray-500/50 backdrop-blur-md",
|
|
22
|
-
"truncate"
|
|
23
|
-
),
|
|
24
|
-
children: [
|
|
25
|
-
width ?? "",
|
|
26
|
-
" x ",
|
|
27
|
-
height ?? "",
|
|
28
|
-
duration ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
-
/* @__PURE__ */ jsx("span", { className: "my-auto h-4 w-px bg-gray-300" }),
|
|
30
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
31
|
-
duration.toFixed(2),
|
|
32
|
-
" ms"
|
|
33
|
-
] })
|
|
34
|
-
] }) : null
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { FilePreviewMeta };
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
4
|
-
import '../../../../../../../constants/paths/auth.js';
|
|
5
|
-
import '../../../../../../../constants/paths/main.js';
|
|
6
|
-
import '../../../../../../../constants/paths/resources.js';
|
|
7
|
-
import '../../../../../../../constants/redirect-paths.js';
|
|
8
|
-
import { IMAGE_EXTENSIONS, VIDEO_EXTENSIONS } from '../../../../../../../constants/file.js';
|
|
9
|
-
import 'mime-types';
|
|
10
|
-
import { joinUrl } from '../../../../../../../shared/utils/join-url.js';
|
|
11
|
-
import 'ua-parser-js';
|
|
12
|
-
import { cn } from '../../../../../../applications/shadcn/utils.js';
|
|
13
|
-
import 'next/navigation';
|
|
14
|
-
import '@radix-ui/react-avatar';
|
|
15
|
-
import '../../../../shadcn/badge.js';
|
|
16
|
-
import '../../../../shadcn/button.js';
|
|
17
|
-
import '@radix-ui/react-collapsible';
|
|
18
|
-
import '@radix-ui/react-dialog';
|
|
19
|
-
import 'lucide-react';
|
|
20
|
-
import '@radix-ui/react-dropdown-menu';
|
|
21
|
-
import '../../../../shadcn/input-group.js';
|
|
22
|
-
import '@radix-ui/react-label';
|
|
23
|
-
import '@radix-ui/react-select';
|
|
24
|
-
import '@radix-ui/react-separator';
|
|
25
|
-
import '../../../../shadcn/sidebar.js';
|
|
26
|
-
import { Spinner } from '../../../../shadcn/spinner.js';
|
|
27
|
-
import '@radix-ui/react-tooltip';
|
|
28
|
-
import { FilePreviewMeta } from './file-preview-meta.js';
|
|
29
|
-
|
|
30
|
-
function createFilePreview({
|
|
31
|
-
SmartImage,
|
|
32
|
-
storageUrl
|
|
33
|
-
}) {
|
|
34
|
-
return function FilePreview({
|
|
35
|
-
blobFile,
|
|
36
|
-
fileKey,
|
|
37
|
-
// Processing States
|
|
38
|
-
isLoading,
|
|
39
|
-
// Base
|
|
40
|
-
className,
|
|
41
|
-
...props
|
|
42
|
-
}) {
|
|
43
|
-
if (blobFile) fileKey = void 0;
|
|
44
|
-
const isImage = blobFile ? !!blobFile?.type.startsWith("image") : IMAGE_EXTENSIONS.some((ext) => fileKey?.toLowerCase().endsWith(ext));
|
|
45
|
-
const isVideo = blobFile ? !!blobFile?.type.startsWith("video") : VIDEO_EXTENSIONS.some((ext) => fileKey?.toLowerCase().endsWith(ext));
|
|
46
|
-
const [previewUrl, setPreviewUrl] = useState();
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (!blobFile) return;
|
|
49
|
-
const url = URL.createObjectURL(blobFile);
|
|
50
|
-
setPreviewUrl(url);
|
|
51
|
-
return () => URL.revokeObjectURL(url);
|
|
52
|
-
}, [blobFile]);
|
|
53
|
-
if (!blobFile && !fileKey) return null;
|
|
54
|
-
return /* @__PURE__ */ jsxs(
|
|
55
|
-
"div",
|
|
56
|
-
{
|
|
57
|
-
className: cn(
|
|
58
|
-
"group relative size-full",
|
|
59
|
-
"flex-center",
|
|
60
|
-
"overflow-hidden",
|
|
61
|
-
"rounded-xl",
|
|
62
|
-
"bg-secondary",
|
|
63
|
-
className
|
|
64
|
-
),
|
|
65
|
-
...props,
|
|
66
|
-
children: [
|
|
67
|
-
isLoading ? /* @__PURE__ */ jsx(Spinner, { className: "size-16" }) : isImage ? /* @__PURE__ */ jsx(
|
|
68
|
-
SmartImage,
|
|
69
|
-
{
|
|
70
|
-
fileKey,
|
|
71
|
-
src: previewUrl,
|
|
72
|
-
width: 600,
|
|
73
|
-
height: 600,
|
|
74
|
-
fill: false,
|
|
75
|
-
imageClassName: "group-hover:!object-contain"
|
|
76
|
-
}
|
|
77
|
-
) : isVideo ? /* @__PURE__ */ jsx(
|
|
78
|
-
"video",
|
|
79
|
-
{
|
|
80
|
-
src: previewUrl || joinUrl(storageUrl, fileKey ?? ""),
|
|
81
|
-
autoPlay: true,
|
|
82
|
-
loop: true,
|
|
83
|
-
muted: true,
|
|
84
|
-
controls: true,
|
|
85
|
-
className: "h-full w-full object-contain"
|
|
86
|
-
}
|
|
87
|
-
) : /* @__PURE__ */ jsx("div", { className: "scale-[3]", children: "\u{1F4C4}" }),
|
|
88
|
-
blobFile ? /* @__PURE__ */ jsx(
|
|
89
|
-
"div",
|
|
90
|
-
{
|
|
91
|
-
className: cn(
|
|
92
|
-
"max-w-[calc(100%-16px)]",
|
|
93
|
-
"absolute top-2 right-2",
|
|
94
|
-
"pointer-events-none"
|
|
95
|
-
// Prevent hover
|
|
96
|
-
),
|
|
97
|
-
children: /* @__PURE__ */ jsx(
|
|
98
|
-
FilePreviewMeta,
|
|
99
|
-
{
|
|
100
|
-
width: blobFile.width,
|
|
101
|
-
height: blobFile.height,
|
|
102
|
-
duration: blobFile.duration
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
) : null
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export { createFilePreview };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useRef, useState } 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 '../../../../../../domain/resources/admin/constants.js';
|
|
10
|
-
import { SIMPLE_UPLOAD_FOLDER_KEY } from '../../../../../../domain/resources/constants.js';
|
|
11
|
-
import 'mime-types';
|
|
12
|
-
import { getMediaInfo } from '../../../../../../shared/blob-file/get-media-info/get-media-info.js';
|
|
13
|
-
import 'ua-parser-js';
|
|
14
|
-
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
15
|
-
import 'next/navigation';
|
|
16
|
-
import { FilePickerContainer } from './file-picker/file-picker-container.js';
|
|
17
|
-
|
|
18
|
-
function createUploader({
|
|
19
|
-
useCommand,
|
|
20
|
-
fileUploadApi,
|
|
21
|
-
fileCreateAction,
|
|
22
|
-
buildTranslations,
|
|
23
|
-
queryClient
|
|
24
|
-
}) {
|
|
25
|
-
return function Uploader({
|
|
26
|
-
setPickedItems,
|
|
27
|
-
// ui states
|
|
28
|
-
isLoading = false,
|
|
29
|
-
isDisabled = false,
|
|
30
|
-
// base
|
|
31
|
-
className = "",
|
|
32
|
-
...props
|
|
33
|
-
}) {
|
|
34
|
-
const inputRef = useRef(null);
|
|
35
|
-
const [isDragOver, setIsDragOver] = useState(false);
|
|
36
|
-
const { execute: upload, isPending: isPendingUpload } = useCommand(fileUploadApi);
|
|
37
|
-
const { execute, isPending } = useCommand(
|
|
38
|
-
(formData) => {
|
|
39
|
-
return fileCreateAction({ formData });
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
onSuccess: (data) => {
|
|
43
|
-
void queryClient.invalidateQueries({
|
|
44
|
-
queryKey: [CACHE_KEYS.findListCards("file")]
|
|
45
|
-
});
|
|
46
|
-
if (setPickedItems && data) setPickedItems([data.file]);
|
|
47
|
-
},
|
|
48
|
-
clearAll: false
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
const processFiles = async (files) => {
|
|
52
|
-
if (!files || files.length === 0 || !setPickedItems) return;
|
|
53
|
-
const mediaInfo = await getMediaInfo(files[0]);
|
|
54
|
-
const response = await upload({
|
|
55
|
-
blobFile: files[0],
|
|
56
|
-
folderKey: SIMPLE_UPLOAD_FOLDER_KEY,
|
|
57
|
-
folder: null
|
|
58
|
-
});
|
|
59
|
-
if (response) {
|
|
60
|
-
const { name, size, type } = files[0];
|
|
61
|
-
await execute({
|
|
62
|
-
...response,
|
|
63
|
-
fileMeta: { name, size, type },
|
|
64
|
-
folderKey: SIMPLE_UPLOAD_FOLDER_KEY,
|
|
65
|
-
folder: null,
|
|
66
|
-
width: mediaInfo.width,
|
|
67
|
-
height: mediaInfo.height,
|
|
68
|
-
duration: mediaInfo.duration,
|
|
69
|
-
translations: buildTranslations([
|
|
70
|
-
{ key: "name", value: null },
|
|
71
|
-
{ key: "alt", value: null }
|
|
72
|
-
])
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return /* @__PURE__ */ jsx(
|
|
77
|
-
FilePickerContainer,
|
|
78
|
-
{
|
|
79
|
-
inputRef,
|
|
80
|
-
isDragOver,
|
|
81
|
-
setIsDragOver,
|
|
82
|
-
processFiles,
|
|
83
|
-
isLoading: isLoading || isPending || isPendingUpload,
|
|
84
|
-
isDisabled,
|
|
85
|
-
className: cn("size-64", className),
|
|
86
|
-
children: /* @__PURE__ */ jsx(
|
|
87
|
-
"input",
|
|
88
|
-
{
|
|
89
|
-
type: "file",
|
|
90
|
-
ref: inputRef,
|
|
91
|
-
hidden: true,
|
|
92
|
-
onChange: (e) => e.target.files && void processFiles(e.target.files),
|
|
93
|
-
...props
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export { createUploader };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useTranslator } from 'intor/react';
|
|
3
|
-
import { useState, isValidElement, cloneElement } from 'react';
|
|
4
|
-
import 'ua-parser-js';
|
|
5
|
-
import { usePickItems } from '../../../../../applications/form/use-pick-items.js';
|
|
6
|
-
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
7
|
-
import 'next/navigation';
|
|
8
|
-
import '@radix-ui/react-avatar';
|
|
9
|
-
import '../../../shadcn/badge.js';
|
|
10
|
-
import '../../../shadcn/button.js';
|
|
11
|
-
import '@radix-ui/react-collapsible';
|
|
12
|
-
import { DialogContent, DialogTitle } from '../../../shadcn/dialog.js';
|
|
13
|
-
import '@radix-ui/react-dropdown-menu';
|
|
14
|
-
import 'lucide-react';
|
|
15
|
-
import '../../../shadcn/input-group.js';
|
|
16
|
-
import '@radix-ui/react-label';
|
|
17
|
-
import '@radix-ui/react-select';
|
|
18
|
-
import '@radix-ui/react-separator';
|
|
19
|
-
import '@radix-ui/react-dialog';
|
|
20
|
-
import '../../../shadcn/sidebar.js';
|
|
21
|
-
import '@radix-ui/react-tooltip';
|
|
22
|
-
import { Button } from '../../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 { FieldBody } from '../../form/field-body.js';
|
|
29
|
-
import { SideFields } from '../../form/containers/side-fields.js';
|
|
30
|
-
import 'mime-types';
|
|
31
|
-
import { ActionButtonsCard } from '../../cards/action-buttons-card.js';
|
|
32
|
-
|
|
33
|
-
function PickModalBody({
|
|
34
|
-
// form context
|
|
35
|
-
fieldName,
|
|
36
|
-
setFormData,
|
|
37
|
-
// modal control
|
|
38
|
-
setIsOpen,
|
|
39
|
-
// pick
|
|
40
|
-
pickedItems,
|
|
41
|
-
setPickedItems,
|
|
42
|
-
isMultiPick = false,
|
|
43
|
-
// base
|
|
44
|
-
itemList,
|
|
45
|
-
aboveManagementCard
|
|
46
|
-
}) {
|
|
47
|
-
const { t } = useTranslator();
|
|
48
|
-
const [itemStates, setItemStates] = useState({
|
|
49
|
-
count: 0,
|
|
50
|
-
isFetching: false,
|
|
51
|
-
items: []
|
|
52
|
-
});
|
|
53
|
-
const { pick, multiPick } = usePickItems({
|
|
54
|
-
...setPickedItems && { setPickedItems }
|
|
55
|
-
});
|
|
56
|
-
const handleClick = (item) => isMultiPick ? multiPick(item) : pick(item);
|
|
57
|
-
const itemListElement = itemList;
|
|
58
|
-
const aboveManagementCardElement = aboveManagementCard;
|
|
59
|
-
return /* @__PURE__ */ jsxs(DialogContent, { className: "container", children: [
|
|
60
|
-
/* @__PURE__ */ jsx(DialogTitle, { className: "sr-only", children: "Dialog" }),
|
|
61
|
-
/* @__PURE__ */ jsxs("div", { className: "flex h-[80svh] w-full gap-4", children: [
|
|
62
|
-
/* @__PURE__ */ jsx("div", { className: cn("flex-1 overflow-auto p-2"), children: isValidElement(itemListElement) && cloneElement(itemListElement, {
|
|
63
|
-
setItemStates,
|
|
64
|
-
pickedItems,
|
|
65
|
-
handleClick
|
|
66
|
-
}) }),
|
|
67
|
-
/* @__PURE__ */ jsxs(SideFields, { className: "flex flex-col gap-4", children: [
|
|
68
|
-
isValidElement(aboveManagementCardElement) && cloneElement(aboveManagementCardElement, {
|
|
69
|
-
setPickedItems
|
|
70
|
-
}),
|
|
71
|
-
/* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
72
|
-
/* @__PURE__ */ jsx(FieldBody, { className: "!w-fit text-sm", children: /* @__PURE__ */ jsx("span", { className: "opacity-50", children: isMultiPick ? t("ui.modal.pick-modal.multiple.text") : t("ui.modal.pick-modal.single.text") }) }),
|
|
73
|
-
/* @__PURE__ */ jsxs(FieldBody, { className: "flex-1 text-sm", children: [
|
|
74
|
-
/* @__PURE__ */ jsxs("span", { className: "opacity-50", children: [
|
|
75
|
-
t("ui.modal.pick-modal.picked.text"),
|
|
76
|
-
"\uFF1A"
|
|
77
|
-
] }),
|
|
78
|
-
/* @__PURE__ */ jsx("span", { className: "text-success font-semibold", children: pickedItems.length ?? 0 })
|
|
79
|
-
] }),
|
|
80
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => setPickedItems?.([]), children: /* @__PURE__ */ jsx("span", { className: "text-sm", children: t("ui.modal.pick-modal.clear.text") }) })
|
|
81
|
-
] }),
|
|
82
|
-
/* @__PURE__ */ jsx(
|
|
83
|
-
ActionButtonsCard,
|
|
84
|
-
{
|
|
85
|
-
action: "confirm",
|
|
86
|
-
isInitializing: itemStates.isFetching ?? false,
|
|
87
|
-
cancelButtonProps: {
|
|
88
|
-
onClick: () => {
|
|
89
|
-
setIsOpen(false);
|
|
90
|
-
setPickedItems?.([]);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
actionButtonProps: {
|
|
94
|
-
onClick: () => {
|
|
95
|
-
if (setFormData && fieldName) {
|
|
96
|
-
setFormData((p) => ({
|
|
97
|
-
...p,
|
|
98
|
-
[fieldName]: isMultiPick ? pickedItems : pickedItems[0] ?? null
|
|
99
|
-
// Prevent using undefined
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
|
-
setIsOpen(false);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
)
|
|
107
|
-
] })
|
|
108
|
-
] })
|
|
109
|
-
] });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export { PickModalBody };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useTranslator } from 'intor/react';
|
|
3
|
-
import { MousePointerClick } from 'lucide-react';
|
|
4
|
-
import { useState, Children, isValidElement, cloneElement } from 'react';
|
|
5
|
-
import 'ua-parser-js';
|
|
6
|
-
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
7
|
-
import 'next/navigation';
|
|
8
|
-
import '@radix-ui/react-avatar';
|
|
9
|
-
import '../../../shadcn/badge.js';
|
|
10
|
-
import '../../../shadcn/button.js';
|
|
11
|
-
import '@radix-ui/react-collapsible';
|
|
12
|
-
import { DialogTrigger } from '../../../shadcn/dialog.js';
|
|
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 '@radix-ui/react-dialog';
|
|
19
|
-
import '../../../shadcn/sidebar.js';
|
|
20
|
-
import '@radix-ui/react-tooltip';
|
|
21
|
-
import { Button } from '../../buttons/button.js';
|
|
22
|
-
|
|
23
|
-
function PickModalTrigger({
|
|
24
|
-
// form context
|
|
25
|
-
fieldName,
|
|
26
|
-
formData,
|
|
27
|
-
// ui states
|
|
28
|
-
isLoading = false,
|
|
29
|
-
isDisabled = false,
|
|
30
|
-
// modal control
|
|
31
|
-
setIsOpen,
|
|
32
|
-
// pick
|
|
33
|
-
isMultiPick = false,
|
|
34
|
-
setPickedItems,
|
|
35
|
-
// base
|
|
36
|
-
pickedDisplay
|
|
37
|
-
// Can be array
|
|
38
|
-
}) {
|
|
39
|
-
const { t } = useTranslator();
|
|
40
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
41
|
-
const fieldValue = formData?.[fieldName ?? ""];
|
|
42
|
-
const isArray = Array.isArray(fieldValue);
|
|
43
|
-
const hasPickedItems = !isMultiPick && fieldValue || isMultiPick && isArray && fieldValue?.length > 0;
|
|
44
|
-
const handleClick = () => {
|
|
45
|
-
if (isDisabled || isLoading) return;
|
|
46
|
-
setIsOpen?.(true);
|
|
47
|
-
setPickedItems(isArray ? fieldValue : fieldValue ? [fieldValue] : []);
|
|
48
|
-
};
|
|
49
|
-
return /* @__PURE__ */ jsx(DialogTrigger, { asChild: true, className: cn(isDisabled && "pointer-events-none"), children: /* @__PURE__ */ jsx(
|
|
50
|
-
"div",
|
|
51
|
-
{
|
|
52
|
-
className: cn("h-max w-full justify-start"),
|
|
53
|
-
onClick: handleClick,
|
|
54
|
-
onMouseEnter: () => setIsHovered(true),
|
|
55
|
-
onMouseLeave: () => setIsHovered(false),
|
|
56
|
-
children: hasPickedItems ? /* @__PURE__ */ jsx(
|
|
57
|
-
Button,
|
|
58
|
-
{
|
|
59
|
-
variant: "outline",
|
|
60
|
-
className: cn(
|
|
61
|
-
"flex h-max w-full flex-wrap justify-start gap-3 px-3",
|
|
62
|
-
!isHovered && "hover:bg-background dark:hover:bg-input/30"
|
|
63
|
-
),
|
|
64
|
-
children: Children.toArray(pickedDisplay).map((child, i) => {
|
|
65
|
-
if (isValidElement(child)) {
|
|
66
|
-
const props = { ...child.props, openNewTab: true };
|
|
67
|
-
child = cloneElement(child, props);
|
|
68
|
-
}
|
|
69
|
-
return /* @__PURE__ */ jsx(
|
|
70
|
-
"div",
|
|
71
|
-
{
|
|
72
|
-
onMouseEnter: () => setIsHovered(false),
|
|
73
|
-
onMouseLeave: () => setIsHovered(true),
|
|
74
|
-
children: child
|
|
75
|
-
},
|
|
76
|
-
i
|
|
77
|
-
);
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
) : /* @__PURE__ */ jsxs(
|
|
81
|
-
Button,
|
|
82
|
-
{
|
|
83
|
-
variant: "outline",
|
|
84
|
-
isLoading,
|
|
85
|
-
isDisabled,
|
|
86
|
-
className: "text-muted-foreground w-full justify-start",
|
|
87
|
-
children: [
|
|
88
|
-
/* @__PURE__ */ jsx(MousePointerClick, {}),
|
|
89
|
-
/* @__PURE__ */ jsx("span", { children: t("ui.modal.pick-modal.pick.text") })
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
) });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { PickModalTrigger };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import '@radix-ui/react-avatar';
|
|
4
|
-
import 'ua-parser-js';
|
|
5
|
-
import 'clsx';
|
|
6
|
-
import 'tailwind-merge';
|
|
7
|
-
import 'next/navigation';
|
|
8
|
-
import '../../../shadcn/badge.js';
|
|
9
|
-
import '../../../shadcn/button.js';
|
|
10
|
-
import '@radix-ui/react-collapsible';
|
|
11
|
-
import { Dialog } from '../../../shadcn/dialog.js';
|
|
12
|
-
import '@radix-ui/react-dropdown-menu';
|
|
13
|
-
import 'lucide-react';
|
|
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 '@radix-ui/react-dialog';
|
|
19
|
-
import '../../../shadcn/sidebar.js';
|
|
20
|
-
import '@radix-ui/react-tooltip';
|
|
21
|
-
import { PickModalBody } from './pick-modal-body.js';
|
|
22
|
-
import { PickModalTrigger } from './pick-modal-trigger.js';
|
|
23
|
-
|
|
24
|
-
function PickModal({
|
|
25
|
-
// form context
|
|
26
|
-
fieldName,
|
|
27
|
-
formData,
|
|
28
|
-
setFormData,
|
|
29
|
-
// ui states
|
|
30
|
-
isLoading = false,
|
|
31
|
-
isDisabled = false,
|
|
32
|
-
// External Control (use in CKEditor)
|
|
33
|
-
isOpen: externalIsOpen,
|
|
34
|
-
setIsOpen: externalSetIsOpen,
|
|
35
|
-
// pick
|
|
36
|
-
isMultiPick = false,
|
|
37
|
-
// base
|
|
38
|
-
pickedDisplay,
|
|
39
|
-
// Can be array
|
|
40
|
-
itemList,
|
|
41
|
-
aboveManagementCard
|
|
42
|
-
}) {
|
|
43
|
-
const [internalIsOpen, setInternalIsOpen] = useState(false);
|
|
44
|
-
const isOpen = externalIsOpen ?? internalIsOpen;
|
|
45
|
-
const setIsOpen = externalSetIsOpen ?? setInternalIsOpen;
|
|
46
|
-
const [pickedItems, setPickedItems] = useState([]);
|
|
47
|
-
return /* @__PURE__ */ jsxs(Dialog, { open: isOpen, onOpenChange: setIsOpen, children: [
|
|
48
|
-
/* @__PURE__ */ jsx(
|
|
49
|
-
PickModalTrigger,
|
|
50
|
-
{
|
|
51
|
-
fieldName,
|
|
52
|
-
formData,
|
|
53
|
-
isLoading,
|
|
54
|
-
isDisabled,
|
|
55
|
-
setIsOpen,
|
|
56
|
-
isMultiPick,
|
|
57
|
-
setPickedItems,
|
|
58
|
-
pickedDisplay
|
|
59
|
-
}
|
|
60
|
-
),
|
|
61
|
-
/* @__PURE__ */ jsx("div", { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
|
|
62
|
-
PickModalBody,
|
|
63
|
-
{
|
|
64
|
-
setIsOpen,
|
|
65
|
-
fieldName,
|
|
66
|
-
setFormData,
|
|
67
|
-
pickedItems,
|
|
68
|
-
setPickedItems,
|
|
69
|
-
isMultiPick,
|
|
70
|
-
itemList,
|
|
71
|
-
aboveManagementCard
|
|
72
|
-
}
|
|
73
|
-
) })
|
|
74
|
-
] });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export { PickModal };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import Image from 'next/image';
|
|
3
|
-
import 'mime-types';
|
|
4
|
-
import { joinUrl } from '../../../../../shared/utils/join-url.js';
|
|
5
|
-
import 'react';
|
|
6
|
-
import 'ua-parser-js';
|
|
7
|
-
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
8
|
-
import 'next/navigation';
|
|
9
|
-
|
|
10
|
-
const BREAKPOINT = 1024;
|
|
11
|
-
function createSmartImage(storageUrl) {
|
|
12
|
-
return function SmartImage({
|
|
13
|
-
// next/image
|
|
14
|
-
sizes,
|
|
15
|
-
fill = true,
|
|
16
|
-
placeholder,
|
|
17
|
-
// image
|
|
18
|
-
src,
|
|
19
|
-
fileKey,
|
|
20
|
-
alt = "",
|
|
21
|
-
width,
|
|
22
|
-
height,
|
|
23
|
-
// base
|
|
24
|
-
className = "",
|
|
25
|
-
imageClassName = "",
|
|
26
|
-
...props
|
|
27
|
-
}) {
|
|
28
|
-
const isFixedSize = width !== void 0 && height !== void 0;
|
|
29
|
-
const resolvedSizes = typeof sizes === "string" ? sizes : sizes ? `(max-width: ${BREAKPOINT}px) ${sizes.mobile ?? sizes.desktop}, ${sizes.desktop}` : void 0;
|
|
30
|
-
const resolvedPlaceholder = placeholder ?? (typeof src === "object" ? "blur" : void 0);
|
|
31
|
-
const resolvedSrc = src ?? (fileKey ? joinUrl(storageUrl, fileKey) : void 0);
|
|
32
|
-
return /* @__PURE__ */ jsx(
|
|
33
|
-
"div",
|
|
34
|
-
{
|
|
35
|
-
className: cn(
|
|
36
|
-
fill ? "relative size-full" : "relative inline-block",
|
|
37
|
-
className
|
|
38
|
-
),
|
|
39
|
-
children: resolvedSrc && /* @__PURE__ */ jsx(
|
|
40
|
-
Image,
|
|
41
|
-
{
|
|
42
|
-
sizes: resolvedSizes,
|
|
43
|
-
fill: !isFixedSize && fill,
|
|
44
|
-
...isFixedSize && { width, height },
|
|
45
|
-
...resolvedPlaceholder && { placeholder: resolvedPlaceholder },
|
|
46
|
-
src: resolvedSrc,
|
|
47
|
-
alt,
|
|
48
|
-
className: cn("size-full object-cover", imageClassName),
|
|
49
|
-
...props
|
|
50
|
-
}
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export { createSmartImage };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { CircleCheck } from 'lucide-react';
|
|
3
|
-
import 'react';
|
|
4
|
-
import 'ua-parser-js';
|
|
5
|
-
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
6
|
-
import 'next/navigation';
|
|
7
|
-
|
|
8
|
-
function Tick({ isPicked = false, className = "" }) {
|
|
9
|
-
return /* @__PURE__ */ jsx(
|
|
10
|
-
"div",
|
|
11
|
-
{
|
|
12
|
-
className: cn(
|
|
13
|
-
className,
|
|
14
|
-
"z-20",
|
|
15
|
-
"bg-background text-success",
|
|
16
|
-
"rounded-full",
|
|
17
|
-
"shadow-xs",
|
|
18
|
-
isPicked ? "opacity-100" : "scale-0 opacity-0",
|
|
19
|
-
"pointer-events-none",
|
|
20
|
-
"transition"
|
|
21
|
-
),
|
|
22
|
-
children: /* @__PURE__ */ jsx(CircleCheck, {})
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { Tick };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import 'react';
|
|
3
|
-
import 'ua-parser-js';
|
|
4
|
-
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
5
|
-
import 'next/navigation';
|
|
6
|
-
import { FORM_MIDDLE_GAP_WIDTH } from '../../../../styles/constants.js';
|
|
7
|
-
|
|
8
|
-
function FieldsContainer({
|
|
9
|
-
className = "",
|
|
10
|
-
children,
|
|
11
|
-
...props
|
|
12
|
-
}) {
|
|
13
|
-
return /* @__PURE__ */ jsx(
|
|
14
|
-
"div",
|
|
15
|
-
{
|
|
16
|
-
className: cn("relative flex w-full", className),
|
|
17
|
-
style: { gap: FORM_MIDDLE_GAP_WIDTH },
|
|
18
|
-
...props,
|
|
19
|
-
children
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { FieldsContainer };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import 'react';
|
|
3
|
-
import 'ua-parser-js';
|
|
4
|
-
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
5
|
-
import 'next/navigation';
|
|
6
|
-
import { FORM_SIDE_FIELDS_WIDTH, FORM_MIDDLE_GAP_WIDTH } from '../../../../styles/constants.js';
|
|
7
|
-
|
|
8
|
-
function MainFields({
|
|
9
|
-
className,
|
|
10
|
-
children,
|
|
11
|
-
...props
|
|
12
|
-
}) {
|
|
13
|
-
const sideWidth = FORM_SIDE_FIELDS_WIDTH + FORM_MIDDLE_GAP_WIDTH;
|
|
14
|
-
return /* @__PURE__ */ jsx(
|
|
15
|
-
"div",
|
|
16
|
-
{
|
|
17
|
-
className: cn("relative", "flex flex-1 flex-col gap-6", className),
|
|
18
|
-
style: { maxWidth: `calc(100% - ${sideWidth}px)` },
|
|
19
|
-
...props,
|
|
20
|
-
children
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { MainFields };
|