@yimingliao/cms 0.0.104 → 0.0.106

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.
@@ -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 };
@@ -1,4 +1,4 @@
1
- import { Button, Spinner, useParentPathname, cn, Separator, Label, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton, Textarea, useDeviceInfo, Card, CardHeader, CardTitle, CardContent, useCountdown, CardDescription, isConfirm } from '../chunk-FLKUBNE4.js';
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,
@@ -797,7 +896,7 @@ function Checkbox({
797
896
  isChecked && "translate-x-6",
798
897
  isLoading && "opacity-0",
799
898
  !isDisabled && "group-hover:scale-95 group-active:scale-90",
800
- "transition"
899
+ "duration-200"
801
900
  )
802
901
  }
803
902
  ),
@@ -983,6 +1082,433 @@ function SearchInput({
983
1082
  }
984
1083
  ) });
985
1084
  }
1085
+ function IndexField({
1086
+ existingIndexes,
1087
+ availableIndex = 1,
1088
+ // Min available index
1089
+ // form context
1090
+ formData,
1091
+ setFormData,
1092
+ // ui states
1093
+ isLoading = false,
1094
+ isDisabled = false,
1095
+ isError = false,
1096
+ isDisplay = false,
1097
+ // base
1098
+ id
1099
+ }) {
1100
+ isDisabled = isDisabled || isLoading || isDisplay;
1101
+ const index = formData?.["index"];
1102
+ const isIndexActive = !!formData?.["isIndexActive"];
1103
+ const toggleCheckbox = () => {
1104
+ if (!setFormData) return;
1105
+ setFormData((p) => ({ ...p, index: availableIndex }));
1106
+ };
1107
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1108
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1109
+ /* @__PURE__ */ jsx(
1110
+ Checkbox,
1111
+ {
1112
+ id: isIndexActive ? void 0 : id,
1113
+ fieldName: "isIndexActive",
1114
+ formData,
1115
+ setFormData,
1116
+ isLoading,
1117
+ isDisabled,
1118
+ onClick: toggleCheckbox
1119
+ }
1120
+ ),
1121
+ !isDisplay ? /* @__PURE__ */ jsx(
1122
+ Input,
1123
+ {
1124
+ id: isIndexActive ? id : void 0,
1125
+ fieldName: "index",
1126
+ value: index || 1,
1127
+ setFormData,
1128
+ type: "number",
1129
+ min: 1,
1130
+ required: isIndexActive,
1131
+ isDisabled: !isIndexActive || isDisabled,
1132
+ className: cn(!isIndexActive && "text-transparent"),
1133
+ inputGroupClassName: cn(
1134
+ isIndexActive ? "opacity-100" : "opacity-50 cursor-not-allowed"
1135
+ ),
1136
+ isError
1137
+ }
1138
+ ) : /* @__PURE__ */ jsx(
1139
+ FieldBody,
1140
+ {
1141
+ isEmpty: !isIndexActive,
1142
+ backgroundClassName: "!bg-base-200",
1143
+ children: index
1144
+ }
1145
+ )
1146
+ ] }),
1147
+ !isDisplay && /* @__PURE__ */ jsx("div", { className: "mx-2", children: /* @__PURE__ */ jsx(
1148
+ ExpandableList,
1149
+ {
1150
+ isDisabled: !isIndexActive,
1151
+ item: index,
1152
+ items: ensureArray(existingIndexes)
1153
+ }
1154
+ ) })
1155
+ ] });
1156
+ }
1157
+ function SlugField({
1158
+ existingSlugs,
1159
+ // form context
1160
+ formData,
1161
+ setFormData,
1162
+ // ui states
1163
+ isLoading = false,
1164
+ isDisabled = false,
1165
+ isError = false,
1166
+ isDisplay = false,
1167
+ // base
1168
+ id
1169
+ }) {
1170
+ isDisabled = isDisabled || isLoading || isDisplay;
1171
+ const slug = formData?.["slug"] || "";
1172
+ const isSlugActive = !!formData?.["isSlugActive"];
1173
+ const isUnavailable = !!existingSlugs?.includes(slug);
1174
+ const toggleCheckbox = () => {
1175
+ if (!setFormData) return;
1176
+ setFormData((p) => ({ ...p, slug: null }));
1177
+ };
1178
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1179
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
1180
+ /* @__PURE__ */ jsx(
1181
+ Checkbox,
1182
+ {
1183
+ id: isSlugActive ? void 0 : id,
1184
+ fieldName: "isSlugActive",
1185
+ formData,
1186
+ setFormData,
1187
+ isLoading,
1188
+ isDisabled,
1189
+ onClick: toggleCheckbox,
1190
+ className: "mt-2"
1191
+ }
1192
+ ),
1193
+ !isDisplay ? /* @__PURE__ */ jsx(
1194
+ Textarea2,
1195
+ {
1196
+ id: isSlugActive ? id : void 0,
1197
+ fieldName: "slug",
1198
+ value: slug,
1199
+ setFormData,
1200
+ required: isSlugActive,
1201
+ isDisabled: !isSlugActive || isDisabled,
1202
+ onKeyDown: (e) => {
1203
+ if (e.key === "Enter") return e.preventDefault();
1204
+ },
1205
+ className: cn(
1206
+ "resize-none break-all",
1207
+ !isSlugActive && "text-transparent"
1208
+ ),
1209
+ isError: isUnavailable || isError
1210
+ }
1211
+ ) : /* @__PURE__ */ jsx(FieldBody, { isEmpty: !isSlugActive, backgroundClassName: "!bg-base-200", children: slug })
1212
+ ] }),
1213
+ !isDisplay && /* @__PURE__ */ jsx("div", { className: "mx-2", children: /* @__PURE__ */ jsx(
1214
+ ExpandableList,
1215
+ {
1216
+ isDisabled: !isSlugActive,
1217
+ isUnique: true,
1218
+ item: slug,
1219
+ items: ensureArray(existingSlugs)
1220
+ }
1221
+ ) })
1222
+ ] });
1223
+ }
1224
+ function ControlFieldsDisplay({
1225
+ fields,
1226
+ // form context
1227
+ formData,
1228
+ // ui states
1229
+ isLoading = false
1230
+ }) {
1231
+ const { t } = useTranslator();
1232
+ if (!formData) return null;
1233
+ const notBuiltInFields = fields.filter(
1234
+ ({ key }) => !BUILT_IN_FIELDS.some((b) => b.key == key)
1235
+ );
1236
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1237
+ fields.find((f) => f.key === "isActive") && /* @__PURE__ */ jsx(
1238
+ Field,
1239
+ {
1240
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1241
+ /* @__PURE__ */ jsx(Eye, { className: "size-5" }),
1242
+ t("ui.field.control-fields.is-active.text")
1243
+ ] }),
1244
+ children: /* @__PURE__ */ jsx(
1245
+ Checkbox,
1246
+ {
1247
+ fieldName: "isActive",
1248
+ formData,
1249
+ isLoading,
1250
+ isDisplay: true
1251
+ }
1252
+ )
1253
+ }
1254
+ ),
1255
+ fields.find((f) => f.key === "index") && /* @__PURE__ */ jsx(
1256
+ Field,
1257
+ {
1258
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1259
+ /* @__PURE__ */ jsx(Binary, { className: "size-5" }),
1260
+ t("ui.field.control-fields.index.text")
1261
+ ] }),
1262
+ children: /* @__PURE__ */ jsx(IndexField, { formData, isLoading, isDisplay: true })
1263
+ }
1264
+ ),
1265
+ fields.find((f) => f.key === "slug") && /* @__PURE__ */ jsx(
1266
+ Field,
1267
+ {
1268
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1269
+ /* @__PURE__ */ jsx(MapPinCheckInside, { className: "size-5" }),
1270
+ t("ui.field.control-fields.slug.text")
1271
+ ] }),
1272
+ children: /* @__PURE__ */ jsx(SlugField, { formData, isLoading, isDisplay: true })
1273
+ }
1274
+ ),
1275
+ fields.find((f) => f.key === "isFeatured") && /* @__PURE__ */ jsx(
1276
+ Field,
1277
+ {
1278
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1279
+ /* @__PURE__ */ jsx(Star, { className: "size-5" }),
1280
+ t("ui.field.control-fields.is-featured.text")
1281
+ ] }),
1282
+ children: /* @__PURE__ */ jsx(
1283
+ Checkbox,
1284
+ {
1285
+ fieldName: "isFeatured",
1286
+ formData,
1287
+ isLoading,
1288
+ isDisplay: true
1289
+ }
1290
+ )
1291
+ }
1292
+ ),
1293
+ fields.find((f) => f.key === "isShownOnHome") && /* @__PURE__ */ jsx(
1294
+ Field,
1295
+ {
1296
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1297
+ /* @__PURE__ */ jsx(House, { className: "size-5" }),
1298
+ t("ui.field.control-fields.is-shown-on-home.text")
1299
+ ] }),
1300
+ children: /* @__PURE__ */ jsx(
1301
+ Checkbox,
1302
+ {
1303
+ fieldName: "isShownOnHome",
1304
+ formData,
1305
+ isLoading,
1306
+ isDisplay: true
1307
+ }
1308
+ )
1309
+ }
1310
+ ),
1311
+ notBuiltInFields.map(({ key, label }) => {
1312
+ return /* @__PURE__ */ jsx(Field, { label, children: /* @__PURE__ */ jsx(
1313
+ Checkbox,
1314
+ {
1315
+ fieldName: key,
1316
+ formData,
1317
+ isLoading,
1318
+ isDisplay: true
1319
+ }
1320
+ ) }, key);
1321
+ })
1322
+ ] });
1323
+ }
1324
+ function ControlFieldsInput({
1325
+ fields = [],
1326
+ // meta
1327
+ controlMeta = {},
1328
+ // form context
1329
+ formData,
1330
+ setFormData,
1331
+ // ui states
1332
+ isLoading = false,
1333
+ isDisabled = false,
1334
+ errors
1335
+ }) {
1336
+ const { t } = useTranslator();
1337
+ if (!(formData && setFormData)) return null;
1338
+ const {
1339
+ existingIndexes = [],
1340
+ availableIndex = 1,
1341
+ existingSlugs = []
1342
+ } = controlMeta;
1343
+ const notBuiltInFields = fields.filter(
1344
+ ({ key }) => !BUILT_IN_FIELDS.some((b) => b.key == key)
1345
+ );
1346
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1347
+ fields.find((f) => f.key === "isActive") && /* @__PURE__ */ jsx(
1348
+ Field,
1349
+ {
1350
+ htmlFor: "isActive",
1351
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1352
+ formData["isActive"] ? /* @__PURE__ */ jsx(Eye, { className: "size-5" }) : /* @__PURE__ */ jsx(EyeOff, { className: "size-5" }),
1353
+ t("ui.field.control-fields.is-active.text")
1354
+ ] }),
1355
+ children: /* @__PURE__ */ jsx(
1356
+ Checkbox,
1357
+ {
1358
+ id: "isActive",
1359
+ fieldName: "isActive",
1360
+ formData,
1361
+ setFormData,
1362
+ isLoading,
1363
+ isDisabled
1364
+ }
1365
+ )
1366
+ }
1367
+ ),
1368
+ fields.find((f) => f.key === "index") && /* @__PURE__ */ jsx(
1369
+ Field,
1370
+ {
1371
+ htmlFor: "index",
1372
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1373
+ /* @__PURE__ */ jsx(Binary, { className: "size-5" }),
1374
+ t("ui.field.control-fields.index.text")
1375
+ ] }),
1376
+ children: /* @__PURE__ */ jsx(
1377
+ IndexField,
1378
+ {
1379
+ id: "index",
1380
+ formData,
1381
+ setFormData,
1382
+ isLoading,
1383
+ isDisabled,
1384
+ existingIndexes,
1385
+ availableIndex,
1386
+ isError: errors?.includes("index")
1387
+ }
1388
+ )
1389
+ }
1390
+ ),
1391
+ fields.find((f) => f.key === "slug") && /* @__PURE__ */ jsx(
1392
+ Field,
1393
+ {
1394
+ htmlFor: "slug",
1395
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1396
+ /* @__PURE__ */ jsx(MapPinCheckInside, { className: "size-5" }),
1397
+ t("ui.field.control-fields.slug.text")
1398
+ ] }),
1399
+ children: /* @__PURE__ */ jsx(
1400
+ SlugField,
1401
+ {
1402
+ id: "slug",
1403
+ formData,
1404
+ setFormData,
1405
+ isLoading,
1406
+ isDisabled,
1407
+ existingSlugs,
1408
+ isError: errors?.includes("slug")
1409
+ }
1410
+ )
1411
+ }
1412
+ ),
1413
+ fields.find((f) => f.key === "isFeatured") && /* @__PURE__ */ jsx(
1414
+ Field,
1415
+ {
1416
+ htmlFor: "isFeatured",
1417
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1418
+ /* @__PURE__ */ jsx(Star, { className: "size-5" }),
1419
+ t("ui.field.control-fields.is-featured.text")
1420
+ ] }),
1421
+ children: /* @__PURE__ */ jsx(
1422
+ Checkbox,
1423
+ {
1424
+ id: "isFeatured",
1425
+ fieldName: "isFeatured",
1426
+ formData,
1427
+ setFormData,
1428
+ isLoading,
1429
+ isDisabled
1430
+ }
1431
+ )
1432
+ }
1433
+ ),
1434
+ fields.find((f) => f.key === "isShownOnHome") && /* @__PURE__ */ jsx(
1435
+ Field,
1436
+ {
1437
+ htmlFor: "isShownOnHome",
1438
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
1439
+ /* @__PURE__ */ jsx(House, { className: "size-5" }),
1440
+ t("ui.field.control-fields.is-shown-on-home.text")
1441
+ ] }),
1442
+ children: /* @__PURE__ */ jsx(
1443
+ Checkbox,
1444
+ {
1445
+ id: "isShownOnHome",
1446
+ fieldName: "isShownOnHome",
1447
+ formData,
1448
+ setFormData,
1449
+ isLoading,
1450
+ isDisabled
1451
+ }
1452
+ )
1453
+ }
1454
+ ),
1455
+ notBuiltInFields.map(({ key, label }) => {
1456
+ return /* @__PURE__ */ jsx(Field, { htmlFor: key, label, children: /* @__PURE__ */ jsx(
1457
+ Checkbox,
1458
+ {
1459
+ id: key,
1460
+ fieldName: key,
1461
+ formData,
1462
+ setFormData,
1463
+ isLoading,
1464
+ isDisabled
1465
+ }
1466
+ ) }, key);
1467
+ })
1468
+ ] });
1469
+ }
1470
+ var BUILT_IN_FIELDS = [
1471
+ { key: "isActive" },
1472
+ { key: "index" },
1473
+ { key: "slug" },
1474
+ { key: "isFeatured" },
1475
+ { key: "isShownOnHome" }
1476
+ ];
1477
+ function ControlFields({
1478
+ fields = [],
1479
+ // meta
1480
+ controlMeta,
1481
+ // form context
1482
+ formData,
1483
+ setFormData,
1484
+ // ui states
1485
+ isLoading = false,
1486
+ isDisabled = false,
1487
+ isDisplay = false,
1488
+ errors,
1489
+ ...props
1490
+ }) {
1491
+ if (fields.length === 0) return null;
1492
+ return /* @__PURE__ */ jsx(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), ...props, children: !isDisplay ? /* @__PURE__ */ jsx(
1493
+ ControlFieldsInput,
1494
+ {
1495
+ fields,
1496
+ formData,
1497
+ setFormData,
1498
+ controlMeta,
1499
+ isLoading,
1500
+ isDisabled,
1501
+ errors
1502
+ }
1503
+ ) : /* @__PURE__ */ jsx(
1504
+ ControlFieldsDisplay,
1505
+ {
1506
+ fields,
1507
+ formData,
1508
+ isLoading
1509
+ }
1510
+ ) });
1511
+ }
986
1512
 
987
1513
  // src/constants/keys/auth.ts
988
1514
  var AUTH_KEYS = {
@@ -1460,4 +1986,4 @@ function createChangePasswordPage({
1460
1986
  };
1461
1987
  }
1462
1988
 
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 };
1989
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",