@yimingliao/cms 0.0.96 → 0.0.98
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 +13 -7
- package/dist/client/index.js +77 -3
- 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;
|
|
@@ -419,7 +420,12 @@ declare function MainFields({ className, children, ...props }: ComponentProps<"d
|
|
|
419
420
|
|
|
420
421
|
declare function SideFields({ className, children, ...props }: ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
421
422
|
|
|
422
|
-
declare function PasswordInput<T>({ ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
|
|
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;
|
|
423
429
|
|
|
424
430
|
/**
|
|
425
431
|
* [Auth] sign-in
|
|
@@ -497,4 +503,4 @@ declare const cn: (...inputs: ClassValue[]) => string;
|
|
|
497
503
|
|
|
498
504
|
declare function useDeviceInfo(): DeviceInfo | null;
|
|
499
505
|
|
|
500
|
-
export { AdminProvider, Button, type ButtonProps, 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 };
|
|
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
|
@@ -306,10 +306,11 @@ function Input({
|
|
|
306
306
|
isDisabled = false,
|
|
307
307
|
isError = false,
|
|
308
308
|
// base
|
|
309
|
+
className,
|
|
309
310
|
children,
|
|
310
311
|
...props
|
|
311
312
|
}) {
|
|
312
|
-
return /* @__PURE__ */ jsxs(InputGroup, { "data-disabled": isDisabled || isLoading, children: [
|
|
313
|
+
return /* @__PURE__ */ jsxs(InputGroup, { "data-disabled": isDisabled || isLoading, className: "h-10", children: [
|
|
313
314
|
isLoading ? /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(
|
|
314
315
|
InputGroupInput,
|
|
315
316
|
{
|
|
@@ -319,6 +320,7 @@ function Input({
|
|
|
319
320
|
if (!setFormData || !fieldName) return;
|
|
320
321
|
setFormData((p) => ({ ...p, [fieldName]: e.target.value }));
|
|
321
322
|
},
|
|
323
|
+
className: cn("h-10", className),
|
|
322
324
|
...props
|
|
323
325
|
}
|
|
324
326
|
),
|
|
@@ -731,7 +733,9 @@ function SideFields({
|
|
|
731
733
|
}
|
|
732
734
|
);
|
|
733
735
|
}
|
|
734
|
-
function PasswordInput({
|
|
736
|
+
function PasswordInput({
|
|
737
|
+
...props
|
|
738
|
+
}) {
|
|
735
739
|
const [showPassword, setShowPassword] = useState(false);
|
|
736
740
|
return /* @__PURE__ */ jsx(Input, { type: showPassword ? "text" : "password", ...props, children: /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx(
|
|
737
741
|
InputGroupButton,
|
|
@@ -744,6 +748,76 @@ function PasswordInput({ ...props }) {
|
|
|
744
748
|
}
|
|
745
749
|
) }) });
|
|
746
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
|
+
}
|
|
747
821
|
|
|
748
822
|
// src/constants/keys/auth.ts
|
|
749
823
|
var AUTH_KEYS = {
|
|
@@ -1221,4 +1295,4 @@ function createChangePasswordPage({
|
|
|
1221
1295
|
};
|
|
1222
1296
|
}
|
|
1223
1297
|
|
|
1224
|
-
export { AdminProvider, Button2 as Button, Field, FieldBody, FieldsContainer, Form, Input, MainFields, PageHeader, PasswordInput, SideFields, 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 };
|