@yimingliao/cms 0.0.97 → 0.0.99
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 +29 -4
- package/dist/client/index.js +191 -34
- package/package.json +1 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as _tanstack_query_core from '@tanstack/query-core';
|
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
import { c as createVerifyAction, a as createSignInAction, b as createVerifyEmailAction, d as createEmailUnverifiedAction, e as createForgotPasswordAction, f as createResetPasswordAction, g as createChangePasswordAction } from '../create-reset-password-action-D6aTuuqO.js';
|
|
8
8
|
import * as React$1 from 'react';
|
|
9
|
-
import { ReactNode, ComponentProps, HTMLAttributes, InputHTMLAttributes } from 'react';
|
|
9
|
+
import { ReactNode, ComponentProps, HTMLAttributes, InputHTMLAttributes, Dispatch, SetStateAction } from 'react';
|
|
10
10
|
import { LucideIcon } from 'lucide-react';
|
|
11
11
|
import { B as ButtonProps$1, L as LabelProps } from '../label-BF4qxS03.js';
|
|
12
12
|
import { ClassValue } from 'clsx';
|
|
@@ -368,9 +368,14 @@ interface ButtonProps extends ButtonProps$1, UIStates {
|
|
|
368
368
|
}
|
|
369
369
|
declare function Button({ icon, href, openNewTab, isDisabled, isLoading, children, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
370
370
|
|
|
371
|
-
interface
|
|
371
|
+
interface ReturnButtonProps extends ButtonProps {
|
|
372
|
+
useIcon?: boolean;
|
|
373
|
+
useConfirm?: boolean;
|
|
374
|
+
replace?: boolean;
|
|
375
|
+
pushToParent?: boolean;
|
|
376
|
+
replaceParent?: boolean;
|
|
372
377
|
}
|
|
373
|
-
declare function
|
|
378
|
+
declare function ReturnButton({ icon, useIcon, useConfirm, href, replace, pushToParent, replaceParent, className, children, ...props }: ReturnButtonProps): react_jsx_runtime.JSX.Element;
|
|
374
379
|
|
|
375
380
|
interface PageHeaderProps {
|
|
376
381
|
titleProps?: PageHeaderTitleProps;
|
|
@@ -420,6 +425,10 @@ declare function MainFields({ className, children, ...props }: ComponentProps<"d
|
|
|
420
425
|
|
|
421
426
|
declare function SideFields({ className, children, ...props }: ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
422
427
|
|
|
428
|
+
interface InputProps<T extends FormData = FormData> extends ComponentProps<"input">, FormFieldController<T> {
|
|
429
|
+
}
|
|
430
|
+
declare function Input<T extends FormData = FormData>({ fieldName, setFormData, isLoading, isDisabled, isError, className, children, ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
|
|
431
|
+
|
|
423
432
|
declare function PasswordInput<T extends FormData = FormData>({ ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
|
|
424
433
|
|
|
425
434
|
interface CheckboxProps<T extends FormData = FormData> extends InputHTMLAttributes<HTMLInputElement>, FormFieldController<T> {
|
|
@@ -427,6 +436,22 @@ interface CheckboxProps<T extends FormData = FormData> extends InputHTMLAttribut
|
|
|
427
436
|
}
|
|
428
437
|
declare function Checkbox<T extends FormData = FormData>({ fieldName, formData, setFormData, isLoading, isDisabled, isDisplay, className, ...props }: CheckboxProps<T>): react_jsx_runtime.JSX.Element;
|
|
429
438
|
|
|
439
|
+
interface TextareaProps<T extends FormData = FormData> extends ComponentProps<"textarea">, FormFieldController<T> {
|
|
440
|
+
}
|
|
441
|
+
declare function Textarea<T extends FormData = FormData>({ fieldName, setFormData, isLoading, isDisabled, isError, ...props }: TextareaProps<T>): react_jsx_runtime.JSX.Element;
|
|
442
|
+
|
|
443
|
+
interface ArrayInputProps<T extends FormData = FormData> extends ComponentProps<"textarea">, FormFieldController<T> {
|
|
444
|
+
isResizable?: boolean;
|
|
445
|
+
errors: string[];
|
|
446
|
+
}
|
|
447
|
+
declare function ArrayInput<T extends FormData = FormData>({ formData, fieldName, setFormData, isLoading, isDisabled, isResizable, errors, placeholder, ...props }: ArrayInputProps<T>): react_jsx_runtime.JSX.Element;
|
|
448
|
+
|
|
449
|
+
interface SearchInputProps extends InputProps {
|
|
450
|
+
searchString: string;
|
|
451
|
+
setSearchString: Dispatch<SetStateAction<string>>;
|
|
452
|
+
}
|
|
453
|
+
declare function SearchInput({ searchString, setSearchString, isLoading, isDisabled, ...props }: SearchInputProps): react_jsx_runtime.JSX.Element;
|
|
454
|
+
|
|
430
455
|
/**
|
|
431
456
|
* [Auth] sign-in
|
|
432
457
|
*
|
|
@@ -503,4 +528,4 @@ declare const cn: (...inputs: ClassValue[]) => string;
|
|
|
503
528
|
|
|
504
529
|
declare function useDeviceInfo(): DeviceInfo | null;
|
|
505
530
|
|
|
506
|
-
export { AdminProvider, Button, type ButtonProps, Checkbox, Field, FieldBody, FieldsContainer, Form, Input, type InputProps, MainFields, PageHeader, PasswordInput, type ShowToastOption, SideFields, cn, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin, useDeviceInfo };
|
|
531
|
+
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 };
|
package/dist/client/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Button, Spinner,
|
|
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';
|
|
2
2
|
export { cn, useDeviceInfo } from '../chunk-FLKUBNE4.js';
|
|
3
3
|
import { ensureArray } from '../chunk-OAENV763.js';
|
|
4
4
|
import { toast } from 'sonner';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
7
|
-
import { createContext, useState, useContext, useEffect, createElement } from 'react';
|
|
7
|
+
import { createContext, useState, useContext, useEffect, createElement, useRef } from 'react';
|
|
8
8
|
import { useTranslator } from 'intor/react';
|
|
9
|
-
import { Files, Asterisk, Eye, EyeOff, Mail, Trash2, CopyCheck, CopyX, FileSymlink, FileX, FilePlus, FilePen, File, FileStack, FolderSearch, Lock, FolderCog, FileSpreadsheet
|
|
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';
|
|
10
10
|
import { useRouter, useSearchParams } from 'next/navigation';
|
|
11
11
|
import Link from 'next/link';
|
|
12
12
|
|
|
@@ -297,36 +297,6 @@ function Button2({
|
|
|
297
297
|
}
|
|
298
298
|
);
|
|
299
299
|
}
|
|
300
|
-
function Input({
|
|
301
|
-
// form context
|
|
302
|
-
fieldName,
|
|
303
|
-
setFormData,
|
|
304
|
-
// ui states
|
|
305
|
-
isLoading = false,
|
|
306
|
-
isDisabled = false,
|
|
307
|
-
isError = false,
|
|
308
|
-
// base
|
|
309
|
-
className,
|
|
310
|
-
children,
|
|
311
|
-
...props
|
|
312
|
-
}) {
|
|
313
|
-
return /* @__PURE__ */ jsxs(InputGroup, { "data-disabled": isDisabled || isLoading, children: [
|
|
314
|
-
isLoading ? /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(
|
|
315
|
-
InputGroupInput,
|
|
316
|
-
{
|
|
317
|
-
disabled: isDisabled || isLoading,
|
|
318
|
-
"aria-invalid": isError,
|
|
319
|
-
onChange: (e) => {
|
|
320
|
-
if (!setFormData || !fieldName) return;
|
|
321
|
-
setFormData((p) => ({ ...p, [fieldName]: e.target.value }));
|
|
322
|
-
},
|
|
323
|
-
className: cn("h-10", className),
|
|
324
|
-
...props
|
|
325
|
-
}
|
|
326
|
-
),
|
|
327
|
-
children
|
|
328
|
-
] });
|
|
329
|
-
}
|
|
330
300
|
function ReturnButton({
|
|
331
301
|
icon,
|
|
332
302
|
useIcon = true,
|
|
@@ -733,6 +703,36 @@ function SideFields({
|
|
|
733
703
|
}
|
|
734
704
|
);
|
|
735
705
|
}
|
|
706
|
+
function Input({
|
|
707
|
+
// form context
|
|
708
|
+
fieldName,
|
|
709
|
+
setFormData,
|
|
710
|
+
// ui states
|
|
711
|
+
isLoading = false,
|
|
712
|
+
isDisabled = false,
|
|
713
|
+
isError = false,
|
|
714
|
+
// base
|
|
715
|
+
className,
|
|
716
|
+
children,
|
|
717
|
+
...props
|
|
718
|
+
}) {
|
|
719
|
+
return /* @__PURE__ */ jsxs(InputGroup, { "data-disabled": isDisabled || isLoading, className: "h-10", children: [
|
|
720
|
+
isLoading ? /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(
|
|
721
|
+
InputGroupInput,
|
|
722
|
+
{
|
|
723
|
+
disabled: isDisabled || isLoading,
|
|
724
|
+
"aria-invalid": isError,
|
|
725
|
+
onChange: (e) => {
|
|
726
|
+
if (!setFormData || !fieldName) return;
|
|
727
|
+
setFormData((p) => ({ ...p, [fieldName]: e.target.value }));
|
|
728
|
+
},
|
|
729
|
+
className: cn("h-10", className),
|
|
730
|
+
...props
|
|
731
|
+
}
|
|
732
|
+
),
|
|
733
|
+
children
|
|
734
|
+
] });
|
|
735
|
+
}
|
|
736
736
|
function PasswordInput({
|
|
737
737
|
...props
|
|
738
738
|
}) {
|
|
@@ -818,6 +818,163 @@ function Checkbox({
|
|
|
818
818
|
}
|
|
819
819
|
);
|
|
820
820
|
}
|
|
821
|
+
function Textarea2({
|
|
822
|
+
// form context
|
|
823
|
+
fieldName,
|
|
824
|
+
setFormData,
|
|
825
|
+
// ui states
|
|
826
|
+
isLoading = false,
|
|
827
|
+
isDisabled = false,
|
|
828
|
+
isError = false,
|
|
829
|
+
// base
|
|
830
|
+
...props
|
|
831
|
+
}) {
|
|
832
|
+
isDisabled = isDisabled || isLoading;
|
|
833
|
+
const textareaRef = useRef(null);
|
|
834
|
+
const resetHeight = (element) => {
|
|
835
|
+
element.style.height = "40px";
|
|
836
|
+
element.style.height = `${element.scrollHeight + 2}px`;
|
|
837
|
+
};
|
|
838
|
+
useEffect(() => {
|
|
839
|
+
if (!textareaRef.current) return;
|
|
840
|
+
resetHeight(textareaRef.current);
|
|
841
|
+
}, [props.value, isLoading]);
|
|
842
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isLoading ? /* @__PURE__ */ jsx(InputGroup, { "data-disabled": isDisabled, className: "h-10", children: /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Spinner, {}) }) }) : /* @__PURE__ */ jsx(
|
|
843
|
+
Textarea,
|
|
844
|
+
{
|
|
845
|
+
ref: textareaRef,
|
|
846
|
+
disabled: isDisabled,
|
|
847
|
+
"aria-invalid": isError,
|
|
848
|
+
value: isLoading ? "" : props.value,
|
|
849
|
+
onChange: (e) => {
|
|
850
|
+
resetHeight(e.target);
|
|
851
|
+
if (!setFormData || !fieldName) return;
|
|
852
|
+
setFormData((p) => ({ ...p, [fieldName]: e.target.value }));
|
|
853
|
+
},
|
|
854
|
+
...props
|
|
855
|
+
}
|
|
856
|
+
) });
|
|
857
|
+
}
|
|
858
|
+
function ArrayInput({
|
|
859
|
+
// form context
|
|
860
|
+
formData,
|
|
861
|
+
fieldName,
|
|
862
|
+
setFormData,
|
|
863
|
+
// ui states
|
|
864
|
+
isLoading = false,
|
|
865
|
+
isDisabled = false,
|
|
866
|
+
isResizable = false,
|
|
867
|
+
errors,
|
|
868
|
+
// base
|
|
869
|
+
placeholder = "",
|
|
870
|
+
...props
|
|
871
|
+
}) {
|
|
872
|
+
isDisabled = isDisabled || isLoading;
|
|
873
|
+
const rawValue = formData?.[fieldName ?? ""];
|
|
874
|
+
const values = Array.isArray(rawValue) && rawValue.length > 0 ? rawValue.map(String) : [""];
|
|
875
|
+
const errorIndexes = new Set(
|
|
876
|
+
errors.filter((e) => e.startsWith(fieldName ?? "")).map((e) => e.split(".").pop()).map(Number)
|
|
877
|
+
);
|
|
878
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: values.map((value, index) => {
|
|
879
|
+
const isError = errorIndexes.has(index);
|
|
880
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
881
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-center absolute top-0 left-0 z-10 h-full", children: [
|
|
882
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-10 pl-0.5 text-center text-sm opacity-50", children: Array.isArray(rawValue) && rawValue.length === 0 ? "0" : index + 1 }),
|
|
883
|
+
/* @__PURE__ */ jsx(Separator, { orientation: "vertical" })
|
|
884
|
+
] }),
|
|
885
|
+
/* @__PURE__ */ jsx(
|
|
886
|
+
Textarea2,
|
|
887
|
+
{
|
|
888
|
+
disabled: isDisabled,
|
|
889
|
+
placeholder: isLoading ? "" : placeholder,
|
|
890
|
+
value,
|
|
891
|
+
onChange: (e) => {
|
|
892
|
+
if (!setFormData || !fieldName) return;
|
|
893
|
+
const copy = [...values];
|
|
894
|
+
copy[index] = e.target.value;
|
|
895
|
+
setFormData((p) => ({ ...p, [fieldName]: copy }));
|
|
896
|
+
},
|
|
897
|
+
onKeyDown: (e) => {
|
|
898
|
+
if (e.key === "Enter" && !isResizable) {
|
|
899
|
+
e.preventDefault();
|
|
900
|
+
}
|
|
901
|
+
},
|
|
902
|
+
isError,
|
|
903
|
+
className: cn("pr-20 pl-13", !isResizable && "resize-none"),
|
|
904
|
+
...props
|
|
905
|
+
}
|
|
906
|
+
),
|
|
907
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-center absolute top-1 right-1 gap-1", children: [
|
|
908
|
+
/* @__PURE__ */ jsx(
|
|
909
|
+
Button2,
|
|
910
|
+
{
|
|
911
|
+
variant: "outline",
|
|
912
|
+
type: "button",
|
|
913
|
+
size: "icon-sm",
|
|
914
|
+
className: "rounded-sm",
|
|
915
|
+
onClick: () => {
|
|
916
|
+
if (!setFormData || !fieldName) return;
|
|
917
|
+
const copy = values.filter((_, i) => i !== index);
|
|
918
|
+
setFormData((p) => ({ ...p, [fieldName]: copy }));
|
|
919
|
+
},
|
|
920
|
+
children: /* @__PURE__ */ jsx(CircleX, { className: "text-destructive" })
|
|
921
|
+
}
|
|
922
|
+
),
|
|
923
|
+
/* @__PURE__ */ jsx(
|
|
924
|
+
Button2,
|
|
925
|
+
{
|
|
926
|
+
variant: "outline",
|
|
927
|
+
type: "button",
|
|
928
|
+
size: "icon-sm",
|
|
929
|
+
className: "rounded-sm",
|
|
930
|
+
onClick: () => {
|
|
931
|
+
if (!setFormData || !fieldName) return;
|
|
932
|
+
const copy = [...values];
|
|
933
|
+
copy.splice(index + 1, 0, "");
|
|
934
|
+
setFormData((p) => ({ ...p, [fieldName]: copy }));
|
|
935
|
+
},
|
|
936
|
+
children: /* @__PURE__ */ jsx(CirclePlus, { className: "text-success" })
|
|
937
|
+
}
|
|
938
|
+
)
|
|
939
|
+
] })
|
|
940
|
+
] }, index);
|
|
941
|
+
}) });
|
|
942
|
+
}
|
|
943
|
+
function SearchInput({
|
|
944
|
+
searchString = "",
|
|
945
|
+
setSearchString,
|
|
946
|
+
isLoading = false,
|
|
947
|
+
isDisabled = false,
|
|
948
|
+
...props
|
|
949
|
+
}) {
|
|
950
|
+
const { t } = useTranslator();
|
|
951
|
+
const isComposingRef = useRef(false);
|
|
952
|
+
const [inputValue, setInputValue] = useState(searchString);
|
|
953
|
+
const handleCompositionEnd = (e) => {
|
|
954
|
+
isComposingRef.current = false;
|
|
955
|
+
setInputValue(e.currentTarget.value);
|
|
956
|
+
setSearchString(e.currentTarget.value);
|
|
957
|
+
};
|
|
958
|
+
const handleChange = (e) => {
|
|
959
|
+
setInputValue(e.target.value);
|
|
960
|
+
if (!isComposingRef.current) setSearchString(e.target.value);
|
|
961
|
+
};
|
|
962
|
+
return /* @__PURE__ */ jsx("div", { className: "relative size-full", children: /* @__PURE__ */ jsx(
|
|
963
|
+
Input,
|
|
964
|
+
{
|
|
965
|
+
isDisabled,
|
|
966
|
+
placeholder: isLoading ? "" : t("ui.search.text"),
|
|
967
|
+
autoComplete: "off",
|
|
968
|
+
value: inputValue,
|
|
969
|
+
onChange: handleChange,
|
|
970
|
+
onCompositionStart: () => isComposingRef.current = true,
|
|
971
|
+
onCompositionEnd: handleCompositionEnd,
|
|
972
|
+
className: "w-full pr-9",
|
|
973
|
+
...props,
|
|
974
|
+
children: /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: isLoading ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(Search, {}) })
|
|
975
|
+
}
|
|
976
|
+
) });
|
|
977
|
+
}
|
|
821
978
|
|
|
822
979
|
// src/constants/keys/auth.ts
|
|
823
980
|
var AUTH_KEYS = {
|
|
@@ -1295,4 +1452,4 @@ function createChangePasswordPage({
|
|
|
1295
1452
|
};
|
|
1296
1453
|
}
|
|
1297
1454
|
|
|
1298
|
-
export { AdminProvider, Button2 as Button, Checkbox, Field, FieldBody, FieldsContainer, Form, Input, MainFields, PageHeader, PasswordInput, SideFields, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin };
|
|
1455
|
+
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 };
|