@yimingliao/cms 0.0.95 → 0.0.97
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 +19 -7
- package/dist/client/index.js +124 -2
- 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 } from 'react';
|
|
9
|
+
import { ReactNode, ComponentProps, HTMLAttributes, InputHTMLAttributes } 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';
|
|
@@ -30,7 +30,8 @@ interface UIStates {
|
|
|
30
30
|
isDisabled?: boolean | undefined;
|
|
31
31
|
isError?: boolean | undefined;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
type FormData = Record<string, unknown>;
|
|
34
|
+
interface FormContext<T extends FormData = FormData> {
|
|
34
35
|
formData?: T | undefined;
|
|
35
36
|
setFormData?: React$1.Dispatch<React$1.SetStateAction<T>> | undefined;
|
|
36
37
|
}
|
|
@@ -39,7 +40,7 @@ interface FieldContext {
|
|
|
39
40
|
translations?: Translation[] | undefined;
|
|
40
41
|
errors?: string[] | undefined;
|
|
41
42
|
}
|
|
42
|
-
interface FormFieldController<T =
|
|
43
|
+
interface FormFieldController<T extends FormData = FormData> extends UIStates, FormContext<T>, FieldContext {
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
interface FetchContext {
|
|
@@ -367,9 +368,9 @@ interface ButtonProps extends ButtonProps$1, UIStates {
|
|
|
367
368
|
}
|
|
368
369
|
declare function Button({ icon, href, openNewTab, isDisabled, isLoading, children, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
369
370
|
|
|
370
|
-
interface InputProps<T =
|
|
371
|
+
interface InputProps<T extends FormData = FormData> extends ComponentProps<"input">, FormFieldController<T> {
|
|
371
372
|
}
|
|
372
|
-
declare function Input<T>({ fieldName, setFormData, isLoading, isDisabled, isError, children, ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
|
|
373
|
+
declare function Input<T extends FormData = FormData>({ fieldName, setFormData, isLoading, isDisabled, isError, className, children, ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
|
|
373
374
|
|
|
374
375
|
interface PageHeaderProps {
|
|
375
376
|
titleProps?: PageHeaderTitleProps;
|
|
@@ -413,7 +414,18 @@ interface FieldBodyProps extends HTMLAttributes<HTMLDivElement>, UIStates {
|
|
|
413
414
|
}
|
|
414
415
|
declare function FieldBody({ isLoading, isDisabled, isEmpty, className, backgroundClassName, childrenClassName, children, ...props }: FieldBodyProps): react_jsx_runtime.JSX.Element;
|
|
415
416
|
|
|
416
|
-
declare function
|
|
417
|
+
declare function FieldsContainer({ className, children, ...props }: ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
418
|
+
|
|
419
|
+
declare function MainFields({ className, children, ...props }: ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
420
|
+
|
|
421
|
+
declare function SideFields({ className, children, ...props }: ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
422
|
+
|
|
423
|
+
declare function PasswordInput<T extends FormData = FormData>({ ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
|
|
424
|
+
|
|
425
|
+
interface CheckboxProps<T extends FormData = FormData> extends InputHTMLAttributes<HTMLInputElement>, FormFieldController<T> {
|
|
426
|
+
isDisplay?: boolean;
|
|
427
|
+
}
|
|
428
|
+
declare function Checkbox<T extends FormData = FormData>({ fieldName, formData, setFormData, isLoading, isDisabled, isDisplay, className, ...props }: CheckboxProps<T>): react_jsx_runtime.JSX.Element;
|
|
417
429
|
|
|
418
430
|
/**
|
|
419
431
|
* [Auth] sign-in
|
|
@@ -491,4 +503,4 @@ declare const cn: (...inputs: ClassValue[]) => string;
|
|
|
491
503
|
|
|
492
504
|
declare function useDeviceInfo(): DeviceInfo | null;
|
|
493
505
|
|
|
494
|
-
export { AdminProvider, Button, type ButtonProps, Field, FieldBody, Form, Input, type InputProps, PageHeader, PasswordInput, type ShowToastOption, cn, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin, useDeviceInfo };
|
|
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 };
|
package/dist/client/index.js
CHANGED
|
@@ -243,6 +243,8 @@ function createAdminInitializer({
|
|
|
243
243
|
|
|
244
244
|
// src/client/interfaces/styles/constants.ts
|
|
245
245
|
var PAGE_HEADER_HEIGHT = 56;
|
|
246
|
+
var FORM_SIDE_FIELDS_WIDTH = 320;
|
|
247
|
+
var FORM_MIDDLE_GAP_WIDTH = 24;
|
|
246
248
|
function PageHeaderTitle({
|
|
247
249
|
icon,
|
|
248
250
|
title,
|
|
@@ -304,6 +306,7 @@ function Input({
|
|
|
304
306
|
isDisabled = false,
|
|
305
307
|
isError = false,
|
|
306
308
|
// base
|
|
309
|
+
className,
|
|
307
310
|
children,
|
|
308
311
|
...props
|
|
309
312
|
}) {
|
|
@@ -317,6 +320,7 @@ function Input({
|
|
|
317
320
|
if (!setFormData || !fieldName) return;
|
|
318
321
|
setFormData((p) => ({ ...p, [fieldName]: e.target.value }));
|
|
319
322
|
},
|
|
323
|
+
className: cn("h-10", className),
|
|
320
324
|
...props
|
|
321
325
|
}
|
|
322
326
|
),
|
|
@@ -683,7 +687,55 @@ function FieldBody({
|
|
|
683
687
|
}
|
|
684
688
|
);
|
|
685
689
|
}
|
|
686
|
-
function
|
|
690
|
+
function FieldsContainer({
|
|
691
|
+
className = "",
|
|
692
|
+
children,
|
|
693
|
+
...props
|
|
694
|
+
}) {
|
|
695
|
+
return /* @__PURE__ */ jsx(
|
|
696
|
+
"div",
|
|
697
|
+
{
|
|
698
|
+
className: cn("relative flex w-full", className),
|
|
699
|
+
style: { gap: FORM_MIDDLE_GAP_WIDTH },
|
|
700
|
+
...props,
|
|
701
|
+
children
|
|
702
|
+
}
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
function MainFields({
|
|
706
|
+
className,
|
|
707
|
+
children,
|
|
708
|
+
...props
|
|
709
|
+
}) {
|
|
710
|
+
const sideWidth = FORM_SIDE_FIELDS_WIDTH + FORM_MIDDLE_GAP_WIDTH;
|
|
711
|
+
return /* @__PURE__ */ jsx(
|
|
712
|
+
"div",
|
|
713
|
+
{
|
|
714
|
+
className: cn("relative", "flex flex-1 flex-col gap-6", className),
|
|
715
|
+
style: { maxWidth: `calc(100% - ${sideWidth}px)` },
|
|
716
|
+
...props,
|
|
717
|
+
children
|
|
718
|
+
}
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
function SideFields({
|
|
722
|
+
className,
|
|
723
|
+
children,
|
|
724
|
+
...props
|
|
725
|
+
}) {
|
|
726
|
+
return /* @__PURE__ */ jsx(
|
|
727
|
+
"div",
|
|
728
|
+
{
|
|
729
|
+
className: cn("relative", "min-h-full", className),
|
|
730
|
+
style: { width: `${FORM_SIDE_FIELDS_WIDTH}px` },
|
|
731
|
+
...props,
|
|
732
|
+
children: /* @__PURE__ */ jsx("div", { className: cn("sticky top-24", "flex flex-col gap-6"), children })
|
|
733
|
+
}
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
function PasswordInput({
|
|
737
|
+
...props
|
|
738
|
+
}) {
|
|
687
739
|
const [showPassword, setShowPassword] = useState(false);
|
|
688
740
|
return /* @__PURE__ */ jsx(Input, { type: showPassword ? "text" : "password", ...props, children: /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx(
|
|
689
741
|
InputGroupButton,
|
|
@@ -696,6 +748,76 @@ function PasswordInput({ ...props }) {
|
|
|
696
748
|
}
|
|
697
749
|
) }) });
|
|
698
750
|
}
|
|
751
|
+
function Checkbox({
|
|
752
|
+
// form context
|
|
753
|
+
fieldName,
|
|
754
|
+
formData,
|
|
755
|
+
setFormData,
|
|
756
|
+
// ui states
|
|
757
|
+
isLoading = false,
|
|
758
|
+
isDisabled = false,
|
|
759
|
+
// base
|
|
760
|
+
isDisplay = false,
|
|
761
|
+
className = "",
|
|
762
|
+
...props
|
|
763
|
+
}) {
|
|
764
|
+
isDisabled = isDisabled || isLoading || isDisplay;
|
|
765
|
+
const isChecked = !!formData?.[fieldName ?? ""];
|
|
766
|
+
return /* @__PURE__ */ jsxs(
|
|
767
|
+
"div",
|
|
768
|
+
{
|
|
769
|
+
className: cn(
|
|
770
|
+
className,
|
|
771
|
+
"group relative",
|
|
772
|
+
"h-6 w-12 min-w-12",
|
|
773
|
+
"p-1",
|
|
774
|
+
"rounded-full",
|
|
775
|
+
"overflow-hidden",
|
|
776
|
+
"shadow-inner",
|
|
777
|
+
!isChecked || isLoading ? "bg-secondary" : "bg-success",
|
|
778
|
+
"transition"
|
|
779
|
+
),
|
|
780
|
+
children: [
|
|
781
|
+
/* @__PURE__ */ jsx(
|
|
782
|
+
"div",
|
|
783
|
+
{
|
|
784
|
+
className: cn(
|
|
785
|
+
"size-4",
|
|
786
|
+
"rounded-full",
|
|
787
|
+
"bg-white",
|
|
788
|
+
"shadow",
|
|
789
|
+
isChecked && "translate-x-6",
|
|
790
|
+
isLoading && "opacity-0",
|
|
791
|
+
!isDisabled && "group-hover:scale-95 group-active:scale-90",
|
|
792
|
+
"transition"
|
|
793
|
+
)
|
|
794
|
+
}
|
|
795
|
+
),
|
|
796
|
+
isLoading && /* @__PURE__ */ jsx("span", { className: "absolute top-1 left-1", children: /* @__PURE__ */ jsx(Spinner, {}) }),
|
|
797
|
+
/* @__PURE__ */ jsx(
|
|
798
|
+
"input",
|
|
799
|
+
{
|
|
800
|
+
type: "checkbox",
|
|
801
|
+
onChange: (e) => {
|
|
802
|
+
if (!setFormData || !fieldName) return;
|
|
803
|
+
setFormData((p) => ({ ...p, [fieldName]: e.target.checked }));
|
|
804
|
+
},
|
|
805
|
+
checked: isChecked,
|
|
806
|
+
disabled: isDisabled,
|
|
807
|
+
className: cn(
|
|
808
|
+
"absolute top-0 left-0",
|
|
809
|
+
"h-full w-full",
|
|
810
|
+
"rounded-full",
|
|
811
|
+
"opacity-0",
|
|
812
|
+
isDisabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
813
|
+
),
|
|
814
|
+
...props
|
|
815
|
+
}
|
|
816
|
+
)
|
|
817
|
+
]
|
|
818
|
+
}
|
|
819
|
+
);
|
|
820
|
+
}
|
|
699
821
|
|
|
700
822
|
// src/constants/keys/auth.ts
|
|
701
823
|
var AUTH_KEYS = {
|
|
@@ -1173,4 +1295,4 @@ function createChangePasswordPage({
|
|
|
1173
1295
|
};
|
|
1174
1296
|
}
|
|
1175
1297
|
|
|
1176
|
-
export { AdminProvider, Button2 as Button, Field, FieldBody, Form, Input, PageHeader, PasswordInput, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin };
|
|
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 };
|