@yimingliao/cms 0.0.103 → 0.0.105
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/client/index.d.ts +32 -1
- package/dist/client/index.js +530 -5
- package/package.json +1 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -407,6 +407,37 @@ declare function MainFields({ className, children, ...props }: ComponentProps<"d
|
|
|
407
407
|
|
|
408
408
|
declare function SideFields({ className, children, ...props }: ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
409
409
|
|
|
410
|
+
interface IndexFieldProps<T extends FormData> extends FormFieldController<T> {
|
|
411
|
+
existingIndexes?: number[];
|
|
412
|
+
availableIndex?: number;
|
|
413
|
+
isDisplay?: boolean;
|
|
414
|
+
id?: string;
|
|
415
|
+
}
|
|
416
|
+
declare function IndexField<T extends FormData = FormData>({ existingIndexes, availableIndex, // Min available index
|
|
417
|
+
formData, setFormData, isLoading, isDisabled, isError, isDisplay, id, }: IndexFieldProps<T>): react_jsx_runtime.JSX.Element;
|
|
418
|
+
|
|
419
|
+
interface SlugFieldProps<T extends FormData> extends FormFieldController<T> {
|
|
420
|
+
existingSlugs?: string[];
|
|
421
|
+
isDisplay?: boolean;
|
|
422
|
+
id?: string;
|
|
423
|
+
}
|
|
424
|
+
declare function SlugField<T extends FormData = FormData>({ existingSlugs, formData, setFormData, isLoading, isDisabled, isError, isDisplay, id, }: SlugFieldProps<T>): react_jsx_runtime.JSX.Element;
|
|
425
|
+
|
|
426
|
+
type ControlMeta = {
|
|
427
|
+
existingIndexes?: number[];
|
|
428
|
+
availableIndex?: number;
|
|
429
|
+
existingSlugs?: string[];
|
|
430
|
+
};
|
|
431
|
+
interface ControlFieldsProps<T extends FormData> extends FormFieldController<T> {
|
|
432
|
+
fields: {
|
|
433
|
+
key: string;
|
|
434
|
+
label?: string;
|
|
435
|
+
}[];
|
|
436
|
+
controlMeta?: ControlMeta | undefined;
|
|
437
|
+
isDisplay?: boolean;
|
|
438
|
+
}
|
|
439
|
+
declare function ControlFields<T extends FormData>({ fields, controlMeta, formData, setFormData, isLoading, isDisabled, isDisplay, errors, ...props }: ControlFieldsProps<T>): react_jsx_runtime.JSX.Element | null;
|
|
440
|
+
|
|
410
441
|
interface InputProps<T extends FormData = FormData> extends ComponentProps<"input">, FormFieldController<T> {
|
|
411
442
|
inputGroupClassName?: string;
|
|
412
443
|
}
|
|
@@ -511,4 +542,4 @@ declare const cn: (...inputs: ClassValue[]) => string;
|
|
|
511
542
|
|
|
512
543
|
declare function useDeviceInfo(): DeviceInfo | null;
|
|
513
544
|
|
|
514
|
-
export { AdminProvider, ArrayInput, Button, type ButtonProps, Checkbox, Field, FieldBody, FieldsContainer, Form, Input, type InputProps, MainFields, PageHeader, PasswordInput, ReturnButton, SearchInput, type ShowToastOption, SideFields, Textarea, cn, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin, useDeviceInfo };
|
|
545
|
+
export { AdminProvider, ArrayInput, Button, type ButtonProps, Checkbox, ControlFields, type ControlMeta, Field, FieldBody, FieldsContainer, Form, IndexField, Input, type InputProps, MainFields, PageHeader, PasswordInput, ReturnButton, SearchInput, type ShowToastOption, SideFields, SlugField, Textarea, cn, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin, useDeviceInfo };
|
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Spinner, useParentPathname, cn, Separator, Label, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton, Textarea,
|
|
1
|
+
import { Button, Spinner, useParentPathname, cn, Separator, Label, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton, Textarea, Card, useDeviceInfo, CardHeader, CardTitle, CardContent, useCountdown, CardDescription, isConfirm } from '../chunk-FLKUBNE4.js';
|
|
2
2
|
export { cn, useDeviceInfo } from '../chunk-FLKUBNE4.js';
|
|
3
3
|
import { ensureArray } from '../chunk-OAENV763.js';
|
|
4
4
|
import { toast } from 'sonner';
|
|
@@ -6,7 +6,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
6
6
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
7
7
|
import { createContext, useState, useContext, useEffect, createElement, useRef } from 'react';
|
|
8
8
|
import { useTranslator } from 'intor/react';
|
|
9
|
-
import { Undo2, Files, Asterisk, Eye, EyeOff, CircleX, CirclePlus, Search, Mail, Trash2, CopyCheck, CopyX, FileSymlink, FileX, FilePlus, FilePen, File, FileStack, FolderSearch, Lock, FolderCog, FileSpreadsheet } from 'lucide-react';
|
|
9
|
+
import { Undo2, Files, Asterisk, Eye, EyeOff, CircleX, CirclePlus, Search, Mail, Trash2, CopyCheck, CopyX, FileSymlink, FileX, FilePlus, FilePen, File, FileStack, FolderSearch, Lock, FolderCog, FileSpreadsheet, Archive, Binary, MapPinCheckInside, Star, House, CircleMinus } from 'lucide-react';
|
|
10
10
|
import { useRouter, useSearchParams } from 'next/navigation';
|
|
11
11
|
import Link from 'next/link';
|
|
12
12
|
|
|
@@ -703,6 +703,105 @@ function SideFields({
|
|
|
703
703
|
}
|
|
704
704
|
);
|
|
705
705
|
}
|
|
706
|
+
function ExpandBar({ isExpand }) {
|
|
707
|
+
return /* @__PURE__ */ jsxs(
|
|
708
|
+
"div",
|
|
709
|
+
{
|
|
710
|
+
className: cn(
|
|
711
|
+
"w-full",
|
|
712
|
+
"flex-center gap-1",
|
|
713
|
+
"opacity-50 group-hover:opacity-100",
|
|
714
|
+
"transition"
|
|
715
|
+
),
|
|
716
|
+
children: [
|
|
717
|
+
/* @__PURE__ */ jsx(Separator, { className: "my-3 flex-1" }),
|
|
718
|
+
!isExpand ? /* @__PURE__ */ jsx(CirclePlus, { className: "text-base-content size-5 min-w-5" }) : /* @__PURE__ */ jsx(CircleMinus, { className: "text-base-content size-5 min-w-5" }),
|
|
719
|
+
/* @__PURE__ */ jsx(Separator, { className: "my-3 flex-1" })
|
|
720
|
+
]
|
|
721
|
+
}
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
var COLLAPSED_HEIGHT = 48;
|
|
725
|
+
function ExpandableListContent({
|
|
726
|
+
item,
|
|
727
|
+
items,
|
|
728
|
+
isExpand,
|
|
729
|
+
isDisabled,
|
|
730
|
+
isUnique,
|
|
731
|
+
onOverflowChange,
|
|
732
|
+
children
|
|
733
|
+
}) {
|
|
734
|
+
const containerRef = useRef(null);
|
|
735
|
+
useEffect(() => {
|
|
736
|
+
const el = containerRef.current;
|
|
737
|
+
if (!el) return;
|
|
738
|
+
const height = el.scrollHeight;
|
|
739
|
+
onOverflowChange?.(height > COLLAPSED_HEIGHT);
|
|
740
|
+
if (isDisabled) {
|
|
741
|
+
el.style.maxHeight = "0px";
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
el.style.maxHeight = isExpand ? `${height}px` : `${COLLAPSED_HEIGHT}px`;
|
|
745
|
+
}, [isExpand, isDisabled, items.length, children, onOverflowChange]);
|
|
746
|
+
return /* @__PURE__ */ jsxs(
|
|
747
|
+
"div",
|
|
748
|
+
{
|
|
749
|
+
ref: containerRef,
|
|
750
|
+
className: cn("overflow-hidden", "flex flex-wrap gap-1", "duration-150"),
|
|
751
|
+
children: [
|
|
752
|
+
children,
|
|
753
|
+
items.map((eachItem, idx) => {
|
|
754
|
+
const matched = isUnique && eachItem === item;
|
|
755
|
+
return /* @__PURE__ */ jsxs("span", { children: [
|
|
756
|
+
/* @__PURE__ */ jsx("span", { className: cn(matched && "text-error"), children: eachItem }),
|
|
757
|
+
idx !== items.length - 1 && ","
|
|
758
|
+
] }, `${eachItem}-${idx}`);
|
|
759
|
+
})
|
|
760
|
+
]
|
|
761
|
+
}
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
function ExpandableList({
|
|
765
|
+
item,
|
|
766
|
+
items = [],
|
|
767
|
+
isDisabled,
|
|
768
|
+
isUnique
|
|
769
|
+
}) {
|
|
770
|
+
const [isExpand, setIsExpand] = useState(false);
|
|
771
|
+
const [isListOverFlow, setIsListOverFlow] = useState(false);
|
|
772
|
+
return /* @__PURE__ */ jsxs(
|
|
773
|
+
"button",
|
|
774
|
+
{
|
|
775
|
+
type: "button",
|
|
776
|
+
onClick: () => {
|
|
777
|
+
if (!isListOverFlow) return;
|
|
778
|
+
setIsExpand((prev) => !prev);
|
|
779
|
+
},
|
|
780
|
+
className: cn(
|
|
781
|
+
"group flex w-full flex-col gap-1 text-xs text-gray-400",
|
|
782
|
+
!isListOverFlow && "pointer-events-none"
|
|
783
|
+
),
|
|
784
|
+
children: [
|
|
785
|
+
/* @__PURE__ */ jsxs(
|
|
786
|
+
ExpandableListContent,
|
|
787
|
+
{
|
|
788
|
+
item,
|
|
789
|
+
items,
|
|
790
|
+
isExpand,
|
|
791
|
+
isDisabled,
|
|
792
|
+
isUnique,
|
|
793
|
+
onOverflowChange: setIsListOverFlow,
|
|
794
|
+
children: [
|
|
795
|
+
/* @__PURE__ */ jsx(Archive, { className: "size-4" }),
|
|
796
|
+
/* @__PURE__ */ jsx("span", { children: ":" })
|
|
797
|
+
]
|
|
798
|
+
}
|
|
799
|
+
),
|
|
800
|
+
isListOverFlow && /* @__PURE__ */ jsx(ExpandBar, { isExpand })
|
|
801
|
+
]
|
|
802
|
+
}
|
|
803
|
+
);
|
|
804
|
+
}
|
|
706
805
|
function Input({
|
|
707
806
|
// form context
|
|
708
807
|
fieldName,
|
|
@@ -796,8 +895,7 @@ function Checkbox({
|
|
|
796
895
|
"shadow",
|
|
797
896
|
isChecked && "translate-x-6",
|
|
798
897
|
isLoading && "opacity-0",
|
|
799
|
-
!isDisabled && "group-hover:scale-95 group-active:scale-90"
|
|
800
|
-
"transition"
|
|
898
|
+
!isDisabled && "group-hover:scale-95 group-active:scale-90"
|
|
801
899
|
)
|
|
802
900
|
}
|
|
803
901
|
),
|
|
@@ -983,6 +1081,433 @@ function SearchInput({
|
|
|
983
1081
|
}
|
|
984
1082
|
) });
|
|
985
1083
|
}
|
|
1084
|
+
function IndexField({
|
|
1085
|
+
existingIndexes,
|
|
1086
|
+
availableIndex = 1,
|
|
1087
|
+
// Min available index
|
|
1088
|
+
// form context
|
|
1089
|
+
formData,
|
|
1090
|
+
setFormData,
|
|
1091
|
+
// ui states
|
|
1092
|
+
isLoading = false,
|
|
1093
|
+
isDisabled = false,
|
|
1094
|
+
isError = false,
|
|
1095
|
+
isDisplay = false,
|
|
1096
|
+
// base
|
|
1097
|
+
id
|
|
1098
|
+
}) {
|
|
1099
|
+
isDisabled = isDisabled || isLoading || isDisplay;
|
|
1100
|
+
const index = formData?.["index"];
|
|
1101
|
+
const isIndexActive = !!formData?.["isIndexActive"];
|
|
1102
|
+
const toggleCheckbox = () => {
|
|
1103
|
+
if (!setFormData) return;
|
|
1104
|
+
setFormData((p) => ({ ...p, index: availableIndex }));
|
|
1105
|
+
};
|
|
1106
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1107
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1108
|
+
/* @__PURE__ */ jsx(
|
|
1109
|
+
Checkbox,
|
|
1110
|
+
{
|
|
1111
|
+
id: isIndexActive ? void 0 : id,
|
|
1112
|
+
fieldName: "isIndexActive",
|
|
1113
|
+
formData,
|
|
1114
|
+
setFormData,
|
|
1115
|
+
isLoading,
|
|
1116
|
+
isDisabled,
|
|
1117
|
+
onClick: toggleCheckbox
|
|
1118
|
+
}
|
|
1119
|
+
),
|
|
1120
|
+
!isDisplay ? /* @__PURE__ */ jsx(
|
|
1121
|
+
Input,
|
|
1122
|
+
{
|
|
1123
|
+
id: isIndexActive ? id : void 0,
|
|
1124
|
+
fieldName: "index",
|
|
1125
|
+
value: index || 1,
|
|
1126
|
+
setFormData,
|
|
1127
|
+
type: "number",
|
|
1128
|
+
min: 1,
|
|
1129
|
+
required: isIndexActive,
|
|
1130
|
+
isDisabled: !isIndexActive || isDisabled,
|
|
1131
|
+
className: cn(!isIndexActive && "text-transparent"),
|
|
1132
|
+
inputGroupClassName: cn(
|
|
1133
|
+
isIndexActive ? "opacity-100" : "opacity-50 cursor-not-allowed"
|
|
1134
|
+
),
|
|
1135
|
+
isError
|
|
1136
|
+
}
|
|
1137
|
+
) : /* @__PURE__ */ jsx(
|
|
1138
|
+
FieldBody,
|
|
1139
|
+
{
|
|
1140
|
+
isEmpty: !isIndexActive,
|
|
1141
|
+
backgroundClassName: "!bg-base-200",
|
|
1142
|
+
children: index
|
|
1143
|
+
}
|
|
1144
|
+
)
|
|
1145
|
+
] }),
|
|
1146
|
+
!isDisplay && /* @__PURE__ */ jsx("div", { className: "mx-2", children: /* @__PURE__ */ jsx(
|
|
1147
|
+
ExpandableList,
|
|
1148
|
+
{
|
|
1149
|
+
isDisabled: !isIndexActive,
|
|
1150
|
+
item: index,
|
|
1151
|
+
items: ensureArray(existingIndexes)
|
|
1152
|
+
}
|
|
1153
|
+
) })
|
|
1154
|
+
] });
|
|
1155
|
+
}
|
|
1156
|
+
function SlugField({
|
|
1157
|
+
existingSlugs,
|
|
1158
|
+
// form context
|
|
1159
|
+
formData,
|
|
1160
|
+
setFormData,
|
|
1161
|
+
// ui states
|
|
1162
|
+
isLoading = false,
|
|
1163
|
+
isDisabled = false,
|
|
1164
|
+
isError = false,
|
|
1165
|
+
isDisplay = false,
|
|
1166
|
+
// base
|
|
1167
|
+
id
|
|
1168
|
+
}) {
|
|
1169
|
+
isDisabled = isDisabled || isLoading || isDisplay;
|
|
1170
|
+
const slug = formData?.["slug"] || "";
|
|
1171
|
+
const isSlugActive = !!formData?.["isSlugActive"];
|
|
1172
|
+
const isUnavailable = !!existingSlugs?.includes(slug);
|
|
1173
|
+
const toggleCheckbox = () => {
|
|
1174
|
+
if (!setFormData) return;
|
|
1175
|
+
setFormData((p) => ({ ...p, slug: null }));
|
|
1176
|
+
};
|
|
1177
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1178
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
1179
|
+
/* @__PURE__ */ jsx(
|
|
1180
|
+
Checkbox,
|
|
1181
|
+
{
|
|
1182
|
+
id: isSlugActive ? void 0 : id,
|
|
1183
|
+
fieldName: "isSlugActive",
|
|
1184
|
+
formData,
|
|
1185
|
+
setFormData,
|
|
1186
|
+
isLoading,
|
|
1187
|
+
isDisabled,
|
|
1188
|
+
onClick: toggleCheckbox,
|
|
1189
|
+
className: "mt-2"
|
|
1190
|
+
}
|
|
1191
|
+
),
|
|
1192
|
+
!isDisplay ? /* @__PURE__ */ jsx(
|
|
1193
|
+
Textarea2,
|
|
1194
|
+
{
|
|
1195
|
+
id: isSlugActive ? id : void 0,
|
|
1196
|
+
fieldName: "slug",
|
|
1197
|
+
value: slug,
|
|
1198
|
+
setFormData,
|
|
1199
|
+
required: isSlugActive,
|
|
1200
|
+
isDisabled: !isSlugActive || isDisabled,
|
|
1201
|
+
onKeyDown: (e) => {
|
|
1202
|
+
if (e.key === "Enter") return e.preventDefault();
|
|
1203
|
+
},
|
|
1204
|
+
className: cn(
|
|
1205
|
+
"resize-none break-all",
|
|
1206
|
+
!isSlugActive && "text-transparent"
|
|
1207
|
+
),
|
|
1208
|
+
isError: isUnavailable || isError
|
|
1209
|
+
}
|
|
1210
|
+
) : /* @__PURE__ */ jsx(FieldBody, { isEmpty: !isSlugActive, backgroundClassName: "!bg-base-200", children: slug })
|
|
1211
|
+
] }),
|
|
1212
|
+
!isDisplay && /* @__PURE__ */ jsx("div", { className: "mx-2", children: /* @__PURE__ */ jsx(
|
|
1213
|
+
ExpandableList,
|
|
1214
|
+
{
|
|
1215
|
+
isDisabled: !isSlugActive,
|
|
1216
|
+
isUnique: true,
|
|
1217
|
+
item: slug,
|
|
1218
|
+
items: ensureArray(existingSlugs)
|
|
1219
|
+
}
|
|
1220
|
+
) })
|
|
1221
|
+
] });
|
|
1222
|
+
}
|
|
1223
|
+
function ControlFieldsDisplay({
|
|
1224
|
+
fields,
|
|
1225
|
+
// form context
|
|
1226
|
+
formData,
|
|
1227
|
+
// ui states
|
|
1228
|
+
isLoading = false
|
|
1229
|
+
}) {
|
|
1230
|
+
const { t } = useTranslator();
|
|
1231
|
+
if (!formData) return null;
|
|
1232
|
+
const notBuiltInFields = fields.filter(
|
|
1233
|
+
({ key }) => !BUILT_IN_FIELDS.some((b) => b.key == key)
|
|
1234
|
+
);
|
|
1235
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1236
|
+
fields.find((f) => f.key === "isActive") && /* @__PURE__ */ jsx(
|
|
1237
|
+
Field,
|
|
1238
|
+
{
|
|
1239
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1240
|
+
/* @__PURE__ */ jsx(Eye, { className: "size-5" }),
|
|
1241
|
+
t("ui.field.control-fields.is-active.text")
|
|
1242
|
+
] }),
|
|
1243
|
+
children: /* @__PURE__ */ jsx(
|
|
1244
|
+
Checkbox,
|
|
1245
|
+
{
|
|
1246
|
+
fieldName: "isActive",
|
|
1247
|
+
formData,
|
|
1248
|
+
isLoading,
|
|
1249
|
+
isDisplay: true
|
|
1250
|
+
}
|
|
1251
|
+
)
|
|
1252
|
+
}
|
|
1253
|
+
),
|
|
1254
|
+
fields.find((f) => f.key === "index") && /* @__PURE__ */ jsx(
|
|
1255
|
+
Field,
|
|
1256
|
+
{
|
|
1257
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1258
|
+
/* @__PURE__ */ jsx(Binary, { className: "size-5" }),
|
|
1259
|
+
t("ui.field.control-fields.index.text")
|
|
1260
|
+
] }),
|
|
1261
|
+
children: /* @__PURE__ */ jsx(IndexField, { formData, isLoading, isDisplay: true })
|
|
1262
|
+
}
|
|
1263
|
+
),
|
|
1264
|
+
fields.find((f) => f.key === "slug") && /* @__PURE__ */ jsx(
|
|
1265
|
+
Field,
|
|
1266
|
+
{
|
|
1267
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1268
|
+
/* @__PURE__ */ jsx(MapPinCheckInside, { className: "size-5" }),
|
|
1269
|
+
t("ui.field.control-fields.slug.text")
|
|
1270
|
+
] }),
|
|
1271
|
+
children: /* @__PURE__ */ jsx(SlugField, { formData, isLoading, isDisplay: true })
|
|
1272
|
+
}
|
|
1273
|
+
),
|
|
1274
|
+
fields.find((f) => f.key === "isFeatured") && /* @__PURE__ */ jsx(
|
|
1275
|
+
Field,
|
|
1276
|
+
{
|
|
1277
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1278
|
+
/* @__PURE__ */ jsx(Star, { className: "size-5" }),
|
|
1279
|
+
t("ui.field.control-fields.is-featured.text")
|
|
1280
|
+
] }),
|
|
1281
|
+
children: /* @__PURE__ */ jsx(
|
|
1282
|
+
Checkbox,
|
|
1283
|
+
{
|
|
1284
|
+
fieldName: "isFeatured",
|
|
1285
|
+
formData,
|
|
1286
|
+
isLoading,
|
|
1287
|
+
isDisplay: true
|
|
1288
|
+
}
|
|
1289
|
+
)
|
|
1290
|
+
}
|
|
1291
|
+
),
|
|
1292
|
+
fields.find((f) => f.key === "isShownOnHome") && /* @__PURE__ */ jsx(
|
|
1293
|
+
Field,
|
|
1294
|
+
{
|
|
1295
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1296
|
+
/* @__PURE__ */ jsx(House, { className: "size-5" }),
|
|
1297
|
+
t("ui.field.control-fields.is-shown-on-home.text")
|
|
1298
|
+
] }),
|
|
1299
|
+
children: /* @__PURE__ */ jsx(
|
|
1300
|
+
Checkbox,
|
|
1301
|
+
{
|
|
1302
|
+
fieldName: "isShownOnHome",
|
|
1303
|
+
formData,
|
|
1304
|
+
isLoading,
|
|
1305
|
+
isDisplay: true
|
|
1306
|
+
}
|
|
1307
|
+
)
|
|
1308
|
+
}
|
|
1309
|
+
),
|
|
1310
|
+
notBuiltInFields.map(({ key, label }) => {
|
|
1311
|
+
return /* @__PURE__ */ jsx(Field, { label, children: /* @__PURE__ */ jsx(
|
|
1312
|
+
Checkbox,
|
|
1313
|
+
{
|
|
1314
|
+
fieldName: key,
|
|
1315
|
+
formData,
|
|
1316
|
+
isLoading,
|
|
1317
|
+
isDisplay: true
|
|
1318
|
+
}
|
|
1319
|
+
) }, key);
|
|
1320
|
+
})
|
|
1321
|
+
] });
|
|
1322
|
+
}
|
|
1323
|
+
function ControlFieldsInput({
|
|
1324
|
+
fields = [],
|
|
1325
|
+
// meta
|
|
1326
|
+
controlMeta = {},
|
|
1327
|
+
// form context
|
|
1328
|
+
formData,
|
|
1329
|
+
setFormData,
|
|
1330
|
+
// ui states
|
|
1331
|
+
isLoading = false,
|
|
1332
|
+
isDisabled = false,
|
|
1333
|
+
errors
|
|
1334
|
+
}) {
|
|
1335
|
+
const { t } = useTranslator();
|
|
1336
|
+
if (!(formData && setFormData)) return null;
|
|
1337
|
+
const {
|
|
1338
|
+
existingIndexes = [],
|
|
1339
|
+
availableIndex = 1,
|
|
1340
|
+
existingSlugs = []
|
|
1341
|
+
} = controlMeta;
|
|
1342
|
+
const notBuiltInFields = fields.filter(
|
|
1343
|
+
({ key }) => !BUILT_IN_FIELDS.some((b) => b.key == key)
|
|
1344
|
+
);
|
|
1345
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1346
|
+
fields.find((f) => f.key === "isActive") && /* @__PURE__ */ jsx(
|
|
1347
|
+
Field,
|
|
1348
|
+
{
|
|
1349
|
+
htmlFor: "isActive",
|
|
1350
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1351
|
+
formData["isActive"] ? /* @__PURE__ */ jsx(Eye, { className: "size-5" }) : /* @__PURE__ */ jsx(EyeOff, { className: "size-5" }),
|
|
1352
|
+
t("ui.field.control-fields.is-active.text")
|
|
1353
|
+
] }),
|
|
1354
|
+
children: /* @__PURE__ */ jsx(
|
|
1355
|
+
Checkbox,
|
|
1356
|
+
{
|
|
1357
|
+
id: "isActive",
|
|
1358
|
+
fieldName: "isActive",
|
|
1359
|
+
formData,
|
|
1360
|
+
setFormData,
|
|
1361
|
+
isLoading,
|
|
1362
|
+
isDisabled
|
|
1363
|
+
}
|
|
1364
|
+
)
|
|
1365
|
+
}
|
|
1366
|
+
),
|
|
1367
|
+
fields.find((f) => f.key === "index") && /* @__PURE__ */ jsx(
|
|
1368
|
+
Field,
|
|
1369
|
+
{
|
|
1370
|
+
htmlFor: "index",
|
|
1371
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1372
|
+
/* @__PURE__ */ jsx(Binary, { className: "size-5" }),
|
|
1373
|
+
t("ui.field.control-fields.index.text")
|
|
1374
|
+
] }),
|
|
1375
|
+
children: /* @__PURE__ */ jsx(
|
|
1376
|
+
IndexField,
|
|
1377
|
+
{
|
|
1378
|
+
id: "index",
|
|
1379
|
+
formData,
|
|
1380
|
+
setFormData,
|
|
1381
|
+
isLoading,
|
|
1382
|
+
isDisabled,
|
|
1383
|
+
existingIndexes,
|
|
1384
|
+
availableIndex,
|
|
1385
|
+
isError: errors?.includes("index")
|
|
1386
|
+
}
|
|
1387
|
+
)
|
|
1388
|
+
}
|
|
1389
|
+
),
|
|
1390
|
+
fields.find((f) => f.key === "slug") && /* @__PURE__ */ jsx(
|
|
1391
|
+
Field,
|
|
1392
|
+
{
|
|
1393
|
+
htmlFor: "slug",
|
|
1394
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1395
|
+
/* @__PURE__ */ jsx(MapPinCheckInside, { className: "size-5" }),
|
|
1396
|
+
t("ui.field.control-fields.slug.text")
|
|
1397
|
+
] }),
|
|
1398
|
+
children: /* @__PURE__ */ jsx(
|
|
1399
|
+
SlugField,
|
|
1400
|
+
{
|
|
1401
|
+
id: "slug",
|
|
1402
|
+
formData,
|
|
1403
|
+
setFormData,
|
|
1404
|
+
isLoading,
|
|
1405
|
+
isDisabled,
|
|
1406
|
+
existingSlugs,
|
|
1407
|
+
isError: errors?.includes("slug")
|
|
1408
|
+
}
|
|
1409
|
+
)
|
|
1410
|
+
}
|
|
1411
|
+
),
|
|
1412
|
+
fields.find((f) => f.key === "isFeatured") && /* @__PURE__ */ jsx(
|
|
1413
|
+
Field,
|
|
1414
|
+
{
|
|
1415
|
+
htmlFor: "isFeatured",
|
|
1416
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1417
|
+
/* @__PURE__ */ jsx(Star, { className: "size-5" }),
|
|
1418
|
+
t("ui.field.control-fields.is-featured.text")
|
|
1419
|
+
] }),
|
|
1420
|
+
children: /* @__PURE__ */ jsx(
|
|
1421
|
+
Checkbox,
|
|
1422
|
+
{
|
|
1423
|
+
id: "isFeatured",
|
|
1424
|
+
fieldName: "isFeatured",
|
|
1425
|
+
formData,
|
|
1426
|
+
setFormData,
|
|
1427
|
+
isLoading,
|
|
1428
|
+
isDisabled
|
|
1429
|
+
}
|
|
1430
|
+
)
|
|
1431
|
+
}
|
|
1432
|
+
),
|
|
1433
|
+
fields.find((f) => f.key === "isShownOnHome") && /* @__PURE__ */ jsx(
|
|
1434
|
+
Field,
|
|
1435
|
+
{
|
|
1436
|
+
htmlFor: "isShownOnHome",
|
|
1437
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
|
|
1438
|
+
/* @__PURE__ */ jsx(House, { className: "size-5" }),
|
|
1439
|
+
t("ui.field.control-fields.is-shown-on-home.text")
|
|
1440
|
+
] }),
|
|
1441
|
+
children: /* @__PURE__ */ jsx(
|
|
1442
|
+
Checkbox,
|
|
1443
|
+
{
|
|
1444
|
+
id: "isShownOnHome",
|
|
1445
|
+
fieldName: "isShownOnHome",
|
|
1446
|
+
formData,
|
|
1447
|
+
setFormData,
|
|
1448
|
+
isLoading,
|
|
1449
|
+
isDisabled
|
|
1450
|
+
}
|
|
1451
|
+
)
|
|
1452
|
+
}
|
|
1453
|
+
),
|
|
1454
|
+
notBuiltInFields.map(({ key, label }) => {
|
|
1455
|
+
return /* @__PURE__ */ jsx(Field, { htmlFor: key, label, children: /* @__PURE__ */ jsx(
|
|
1456
|
+
Checkbox,
|
|
1457
|
+
{
|
|
1458
|
+
id: key,
|
|
1459
|
+
fieldName: key,
|
|
1460
|
+
formData,
|
|
1461
|
+
setFormData,
|
|
1462
|
+
isLoading,
|
|
1463
|
+
isDisabled
|
|
1464
|
+
}
|
|
1465
|
+
) }, key);
|
|
1466
|
+
})
|
|
1467
|
+
] });
|
|
1468
|
+
}
|
|
1469
|
+
var BUILT_IN_FIELDS = [
|
|
1470
|
+
{ key: "isActive" },
|
|
1471
|
+
{ key: "index" },
|
|
1472
|
+
{ key: "slug" },
|
|
1473
|
+
{ key: "isFeatured" },
|
|
1474
|
+
{ key: "isShownOnHome" }
|
|
1475
|
+
];
|
|
1476
|
+
function ControlFields({
|
|
1477
|
+
fields = [],
|
|
1478
|
+
// meta
|
|
1479
|
+
controlMeta,
|
|
1480
|
+
// form context
|
|
1481
|
+
formData,
|
|
1482
|
+
setFormData,
|
|
1483
|
+
// ui states
|
|
1484
|
+
isLoading = false,
|
|
1485
|
+
isDisabled = false,
|
|
1486
|
+
isDisplay = false,
|
|
1487
|
+
errors,
|
|
1488
|
+
...props
|
|
1489
|
+
}) {
|
|
1490
|
+
if (fields.length === 0) return null;
|
|
1491
|
+
return /* @__PURE__ */ jsx(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), ...props, children: !isDisplay ? /* @__PURE__ */ jsx(
|
|
1492
|
+
ControlFieldsInput,
|
|
1493
|
+
{
|
|
1494
|
+
fields,
|
|
1495
|
+
formData,
|
|
1496
|
+
setFormData,
|
|
1497
|
+
controlMeta,
|
|
1498
|
+
isLoading,
|
|
1499
|
+
isDisabled,
|
|
1500
|
+
errors
|
|
1501
|
+
}
|
|
1502
|
+
) : /* @__PURE__ */ jsx(
|
|
1503
|
+
ControlFieldsDisplay,
|
|
1504
|
+
{
|
|
1505
|
+
fields,
|
|
1506
|
+
formData,
|
|
1507
|
+
isLoading
|
|
1508
|
+
}
|
|
1509
|
+
) });
|
|
1510
|
+
}
|
|
986
1511
|
|
|
987
1512
|
// src/constants/keys/auth.ts
|
|
988
1513
|
var AUTH_KEYS = {
|
|
@@ -1460,4 +1985,4 @@ function createChangePasswordPage({
|
|
|
1460
1985
|
};
|
|
1461
1986
|
}
|
|
1462
1987
|
|
|
1463
|
-
export { AdminProvider, ArrayInput, Button2 as Button, Checkbox, Field, FieldBody, FieldsContainer, Form, Input, MainFields, PageHeader, PasswordInput, ReturnButton, SearchInput, SideFields, Textarea2 as Textarea, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin };
|
|
1988
|
+
export { AdminProvider, ArrayInput, Button2 as Button, Checkbox, ControlFields, Field, FieldBody, FieldsContainer, Form, IndexField, Input, MainFields, PageHeader, PasswordInput, ReturnButton, SearchInput, SideFields, SlugField, Textarea2 as Textarea, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin };
|