nexstruct 1.0.0
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/AGENTS.md +122 -0
- package/LICENSE +21 -0
- package/README.md +103 -0
- package/package.json +99 -0
- package/scaffold/generator.js +409 -0
- package/scaffold/index.js +20 -0
- package/scaffold/prompts.js +108 -0
- package/templates/api/axios/src/api/axios/client.api.ts +30 -0
- package/templates/api/axios/src/api/axios/users.api.ts +15 -0
- package/templates/api/fetch/src/api/fetch/client.api.ts +68 -0
- package/templates/api/fetch/src/api/fetch/users.api.ts +15 -0
- package/templates/api/trpc/src/api/trpc/client.api.ts +4 -0
- package/templates/api/trpc/src/api/trpc/router.api.ts +15 -0
- package/templates/api/trpc/src/api/trpc/server.client.api.ts +4 -0
- package/templates/api/trpc/src/providers/trpc.provider.tsx +24 -0
- package/templates/auth/clerk/src/auth/clerk/auth.service.ts +4 -0
- package/templates/auth/clerk/src/hooks/use-auth.hook.ts +13 -0
- package/templates/auth/clerk/src/middleware.ts +7 -0
- package/templates/auth/clerk/src/providers/auth.provider.tsx +6 -0
- package/templates/auth/next-auth/src/app/api/auth/[...nextauth]/route.ts +5 -0
- package/templates/auth/next-auth/src/auth/next-auth/auth.service.ts +45 -0
- package/templates/auth/next-auth/src/hooks/use-session.hook.ts +13 -0
- package/templates/auth/next-auth/src/providers/session.provider.tsx +6 -0
- package/templates/forms/formik/src/components/forms/login-form.component.tsx +30 -0
- package/templates/forms/formik/src/forms/formik/hooks/use-form-config.hook.ts +7 -0
- package/templates/forms/formik/src/forms/formik/schemas/example.schema.ts +8 -0
- package/templates/forms/react-hook-form/src/components/forms/login-form.component.tsx +27 -0
- package/templates/forms/react-hook-form/src/forms/react-hook-form/hooks/use-form.hook.ts +13 -0
- package/templates/forms/react-hook-form/src/forms/react-hook-form/schemas/example.schema.ts +15 -0
- package/templates/nextjs-base/next.config.ts +5 -0
- package/templates/nextjs-base/postcss.config.mjs +9 -0
- package/templates/nextjs-base/src/app/_components/navbar.tsx +88 -0
- package/templates/nextjs-base/src/app/_components/sidebar.tsx +223 -0
- package/templates/nextjs-base/src/app/error.tsx +39 -0
- package/templates/nextjs-base/src/app/globals.css +71 -0
- package/templates/nextjs-base/src/app/layout.tsx +21 -0
- package/templates/nextjs-base/src/app/loading.tsx +13 -0
- package/templates/nextjs-base/src/app/not-found.tsx +22 -0
- package/templates/nextjs-base/src/app/page.tsx +10 -0
- package/templates/nextjs-base/tailwind.config.ts +69 -0
- package/templates/shared/src/components/common/theme-toggle.component.tsx +31 -0
- package/templates/shared/src/components/common/toast/custom-message.component.tsx +18 -0
- package/templates/shared/src/components/common/toast/index.ts +8 -0
- package/templates/shared/src/components/common/toast/toast-message.component.tsx +112 -0
- package/templates/shared/src/hooks/use-debounce.hook.ts +12 -0
- package/templates/shared/src/hooks/use-fetch.hook.ts +42 -0
- package/templates/shared/src/hooks/use-intersection-observer.hook.ts +39 -0
- package/templates/shared/src/hooks/use-local-storage.hook.ts +30 -0
- package/templates/shared/src/hooks/use-media-query.hook.ts +26 -0
- package/templates/shared/src/hooks/use-toggle.hook.ts +12 -0
- package/templates/shared/src/lib/utils.util.ts +361 -0
- package/templates/shared/src/providers/theme.provider.tsx +17 -0
- package/templates/shared/src/providers/toast.provider.tsx +32 -0
- package/templates/shared/src/types/common.type.ts +34 -0
- package/templates/state/context/src/store/context/auth.context.tsx +47 -0
- package/templates/state/context/src/store/context/counter.context.tsx +41 -0
- package/templates/state/context/src/store/context/index.ts +2 -0
- package/templates/state/redux/src/providers/redux.provider.tsx +7 -0
- package/templates/state/redux/src/store/redux/hooks.store.ts +5 -0
- package/templates/state/redux/src/store/redux/index.ts +4 -0
- package/templates/state/redux/src/store/redux/slices/api.slice.ts +8 -0
- package/templates/state/redux/src/store/redux/slices/counter.slice.ts +24 -0
- package/templates/state/redux/src/store/redux/store.store.ts +13 -0
- package/templates/state/zustand/src/store/zustand/counter.store.ts +15 -0
- package/templates/state/zustand/src/store/zustand/index.ts +2 -0
- package/templates/state/zustand/src/store/zustand/user.store.ts +32 -0
- package/templates/ui/antd/COMPONENT_GUIDE.md +326 -0
- package/templates/ui/antd/src/app/examples/dialog/page.tsx +205 -0
- package/templates/ui/antd/src/app/examples/form/page.tsx +160 -0
- package/templates/ui/antd/src/app/examples/layout.tsx +125 -0
- package/templates/ui/antd/src/app/examples/page.tsx +64 -0
- package/templates/ui/antd/src/app/examples/table/page.tsx +118 -0
- package/templates/ui/antd/src/app/page.tsx +283 -0
- package/templates/ui/antd/src/components/common/DynamicTable/dynamic-table.component.tsx +79 -0
- package/templates/ui/antd/src/components/common/button/action-button.component.tsx +63 -0
- package/templates/ui/antd/src/components/common/dialog/dialog-wrapper.component.tsx +63 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/check-field.component.tsx +55 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/date-picker-field.component.tsx +80 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/limit-field.component.tsx +26 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/multi-check-field.component.tsx +56 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/number-field.component.tsx +100 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/otp-field.component.tsx +63 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/password-field.component.tsx +106 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/phone-number-field.component.tsx +78 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/radio-field.component.tsx +55 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/range-date-picker.component.tsx +66 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/search-field.component.tsx +24 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/select-field.component.tsx +82 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/single-check-field.component.tsx +50 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/single-select-field.component.tsx +86 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/string-number-field.component.tsx +80 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/switch-field.component.tsx +62 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/text-area-field.component.tsx +85 -0
- package/templates/ui/antd/src/components/common/fields/assets/components/text-field.component.tsx +88 -0
- package/templates/ui/antd/src/components/common/fields/assets/interface/input-props.type.ts +233 -0
- package/templates/ui/antd/src/components/common/fields/cusInputField.component.tsx +40 -0
- package/templates/ui/antd/src/components/common/pagination/pagination.component.tsx +27 -0
- package/templates/ui/antd/src/components/ui/avatar.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/badge.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/button.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/card.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/checkbox.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/dialog.component.tsx +9 -0
- package/templates/ui/antd/src/components/ui/dropdown-menu.component.tsx +10 -0
- package/templates/ui/antd/src/components/ui/form.component.tsx +12 -0
- package/templates/ui/antd/src/components/ui/input.component.tsx +13 -0
- package/templates/ui/antd/src/components/ui/label.component.tsx +18 -0
- package/templates/ui/antd/src/components/ui/popover.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/progress.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/radio-group.component.tsx +10 -0
- package/templates/ui/antd/src/components/ui/scroll-area.component.tsx +25 -0
- package/templates/ui/antd/src/components/ui/select.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/separator.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/sheet.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/switch.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/table.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/tabs.component.tsx +8 -0
- package/templates/ui/antd/src/components/ui/textarea.component.tsx +9 -0
- package/templates/ui/antd/src/components/ui/tooltip.component.tsx +8 -0
- package/templates/ui/antd/src/lib/theme.util.ts +40 -0
- package/templates/ui/antd/src/providers/antd.provider.tsx +13 -0
- package/templates/ui/mui/src/app/examples/layout.tsx +113 -0
- package/templates/ui/mui/src/app/examples/page.tsx +716 -0
- package/templates/ui/mui/src/app/page.tsx +298 -0
- package/templates/ui/mui/src/components/common/DynamicTable/dynamic-table.component.tsx +131 -0
- package/templates/ui/mui/src/components/common/button/action-button.component.tsx +57 -0
- package/templates/ui/mui/src/components/common/dialog/dialog-wrapper.component.tsx +55 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/check-field.component.tsx +51 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/date-picker-field.component.tsx +50 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/multi-check-field.component.tsx +14 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/number-field.component.tsx +59 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/password-field.component.tsx +87 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/phone-number-field.component.tsx +48 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/radio-field.component.tsx +37 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/search-field.component.tsx +41 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/select-field.component.tsx +77 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/single-check-field.component.tsx +39 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/single-select-field.component.tsx +56 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/string-number-field.component.tsx +52 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/switch-field.component.tsx +35 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/text-area-field.component.tsx +46 -0
- package/templates/ui/mui/src/components/common/fields/assets/components/text-field.component.tsx +51 -0
- package/templates/ui/mui/src/components/common/fields/assets/interface/input-props.type.ts +193 -0
- package/templates/ui/mui/src/components/common/fields/cusInputField.component.tsx +34 -0
- package/templates/ui/mui/src/components/common/pagination/pagination.component.tsx +59 -0
- package/templates/ui/mui/src/components/ui/avatar.component.tsx +19 -0
- package/templates/ui/mui/src/components/ui/badge.component.tsx +18 -0
- package/templates/ui/mui/src/components/ui/button.component.tsx +22 -0
- package/templates/ui/mui/src/components/ui/card.component.tsx +39 -0
- package/templates/ui/mui/src/components/ui/checkbox.component.tsx +21 -0
- package/templates/ui/mui/src/components/ui/dialog.component.tsx +38 -0
- package/templates/ui/mui/src/components/ui/dropdown-menu.component.tsx +43 -0
- package/templates/ui/mui/src/components/ui/form.component.tsx +98 -0
- package/templates/ui/mui/src/components/ui/input.component.tsx +15 -0
- package/templates/ui/mui/src/components/ui/label.component.tsx +15 -0
- package/templates/ui/mui/src/components/ui/popover.component.tsx +20 -0
- package/templates/ui/mui/src/components/ui/progress.component.tsx +19 -0
- package/templates/ui/mui/src/components/ui/radio-group.component.tsx +25 -0
- package/templates/ui/mui/src/components/ui/scroll-area.component.tsx +27 -0
- package/templates/ui/mui/src/components/ui/select.component.tsx +26 -0
- package/templates/ui/mui/src/components/ui/separator.component.tsx +11 -0
- package/templates/ui/mui/src/components/ui/sheet.component.tsx +44 -0
- package/templates/ui/mui/src/components/ui/switch.component.tsx +23 -0
- package/templates/ui/mui/src/components/ui/table.component.tsx +34 -0
- package/templates/ui/mui/src/components/ui/tabs.component.tsx +38 -0
- package/templates/ui/mui/src/components/ui/textarea.component.tsx +18 -0
- package/templates/ui/mui/src/components/ui/tooltip.component.tsx +24 -0
- package/templates/ui/mui/src/lib/theme.util.ts +73 -0
- package/templates/ui/mui/src/providers/mui.provider.tsx +13 -0
- package/templates/ui/shadcn/COMPONENT_GUIDE.md +306 -0
- package/templates/ui/shadcn/src/app/examples/dialog/page.tsx +122 -0
- package/templates/ui/shadcn/src/app/examples/form/page.tsx +107 -0
- package/templates/ui/shadcn/src/app/examples/layout.tsx +24 -0
- package/templates/ui/shadcn/src/app/examples/page.tsx +30 -0
- package/templates/ui/shadcn/src/app/examples/table/page.tsx +77 -0
- package/templates/ui/shadcn/src/app/page.tsx +20 -0
- package/templates/ui/shadcn/src/components/common/DynamicTable/dynamic-table.component.tsx +136 -0
- package/templates/ui/shadcn/src/components/common/button/action-button.component.tsx +68 -0
- package/templates/ui/shadcn/src/components/common/dialog/dialog-wrapper.component.tsx +58 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/check-field.component.tsx +52 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/date-picker-field.component.tsx +62 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/dynamic-file-upload-field.component.tsx +152 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/limit-field.component.tsx +73 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/multi-check-field.component.tsx +46 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/number-field.component.tsx +124 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/otp-field.component.tsx +61 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/password-field.component.tsx +110 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/phone-number-field.component.tsx +90 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/radio-field.component.tsx +41 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/range-date-picker.component.tsx +71 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/rich-text-editor.component.tsx +91 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/search-field.component.tsx +34 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/select-field.component.tsx +231 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/single-check-field.component.tsx +42 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/single-select-field.component.tsx +82 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/string-number-field.component.tsx +68 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/switch-field.component.tsx +61 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/text-area-field.component.tsx +62 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/text-area-with-file.component.tsx +142 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/text-field.component.tsx +80 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/tiny-editor.component.tsx +51 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/upload-profile-picture.component.tsx +103 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/components/upload-video-file.component.tsx +86 -0
- package/templates/ui/shadcn/src/components/common/fields/assets/interface/input-props.type.ts +198 -0
- package/templates/ui/shadcn/src/components/common/fields/cusInputField.component.tsx +52 -0
- package/templates/ui/shadcn/src/components/common/pagination/pagination.component.tsx +68 -0
- package/templates/ui/shadcn/src/components/ui/avatar.component.tsx +37 -0
- package/templates/ui/shadcn/src/components/ui/badge.component.tsx +28 -0
- package/templates/ui/shadcn/src/components/ui/button.component.tsx +52 -0
- package/templates/ui/shadcn/src/components/ui/card.component.tsx +46 -0
- package/templates/ui/shadcn/src/components/ui/checkbox.component.tsx +25 -0
- package/templates/ui/shadcn/src/components/ui/dialog.component.tsx +98 -0
- package/templates/ui/shadcn/src/components/ui/dropdown-menu.component.tsx +163 -0
- package/templates/ui/shadcn/src/components/ui/form.component.tsx +110 -0
- package/templates/ui/shadcn/src/components/ui/input-otp.component.tsx +64 -0
- package/templates/ui/shadcn/src/components/ui/input.component.tsx +23 -0
- package/templates/ui/shadcn/src/components/ui/label.component.tsx +23 -0
- package/templates/ui/shadcn/src/components/ui/popover.component.tsx +27 -0
- package/templates/ui/shadcn/src/components/ui/progress.component.tsx +22 -0
- package/templates/ui/shadcn/src/components/ui/radio-group.component.tsx +33 -0
- package/templates/ui/shadcn/src/components/ui/scroll-area.component.tsx +37 -0
- package/templates/ui/shadcn/src/components/ui/select.component.tsx +139 -0
- package/templates/ui/shadcn/src/components/ui/separator.component.tsx +23 -0
- package/templates/ui/shadcn/src/components/ui/sheet.component.tsx +89 -0
- package/templates/ui/shadcn/src/components/ui/switch.component.tsx +26 -0
- package/templates/ui/shadcn/src/components/ui/table.component.tsx +71 -0
- package/templates/ui/shadcn/src/components/ui/tabs.component.tsx +52 -0
- package/templates/ui/shadcn/src/components/ui/textarea.component.tsx +20 -0
- package/templates/ui/shadcn/src/components/ui/tooltip.component.tsx +25 -0
package/templates/ui/antd/src/components/common/fields/assets/components/text-field.component.tsx
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Controller } from 'react-hook-form';
|
|
4
|
+
import { Input } from 'antd';
|
|
5
|
+
import type { TextInputProps } from '../../assets/interface/input-props.type';
|
|
6
|
+
|
|
7
|
+
export function Text({
|
|
8
|
+
form, name, placeholder, labelName, required = false, disabled = false,
|
|
9
|
+
viewOnly = false, customMessage, isArray = false, leftIcon, rightIcon,
|
|
10
|
+
value, setValue,
|
|
11
|
+
}: TextInputProps) {
|
|
12
|
+
const fieldName = name || labelName?.toLowerCase().replace(/\s+/g, '_') || 'text';
|
|
13
|
+
|
|
14
|
+
const labelEl = labelName ? (
|
|
15
|
+
<label className="font-semibold leading-6 text-[14px] tracking-[0.02em]" style={{ display: 'block', marginBottom: 4 }}>
|
|
16
|
+
{labelName}
|
|
17
|
+
{required && <span style={{ color: '#ff4d4f', marginLeft: 2 }}>*</span>}
|
|
18
|
+
</label>
|
|
19
|
+
) : null;
|
|
20
|
+
|
|
21
|
+
if (form) {
|
|
22
|
+
return (
|
|
23
|
+
<div style={{ marginBottom: 16 }}>
|
|
24
|
+
{labelEl}
|
|
25
|
+
{viewOnly ? (
|
|
26
|
+
<div style={{ padding: '4px 11px', border: '1px solid #d9d9d9', borderRadius: 6, minHeight: 32, background: '#fafafa' }}>
|
|
27
|
+
{form.watch(fieldName) || ''}
|
|
28
|
+
</div>
|
|
29
|
+
) : (
|
|
30
|
+
<Controller
|
|
31
|
+
name={fieldName}
|
|
32
|
+
control={form.control}
|
|
33
|
+
render={({ field, fieldState }) => {
|
|
34
|
+
const isError = !!fieldState.error;
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
<Input
|
|
38
|
+
{...field}
|
|
39
|
+
placeholder={placeholder || labelName}
|
|
40
|
+
disabled={disabled}
|
|
41
|
+
status={isError ? 'error' : undefined}
|
|
42
|
+
prefix={leftIcon}
|
|
43
|
+
suffix={rightIcon}
|
|
44
|
+
onChange={(e) => {
|
|
45
|
+
if (isArray) {
|
|
46
|
+
const arr = e.target.value.split(/[\s,]+/).map((v: string) => v.trim()).filter(Boolean);
|
|
47
|
+
form.setValue(fieldName, arr, { shouldValidate: true, shouldDirty: true });
|
|
48
|
+
}
|
|
49
|
+
field.onChange(e);
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
{isError && (
|
|
53
|
+
<div style={{ color: '#ff4d4f', fontSize: 12, marginTop: 4 }}>
|
|
54
|
+
{String(fieldState.error?.message || '')}
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
{!isError && customMessage && (
|
|
58
|
+
<div style={{ color: '#999', fontSize: 12, marginTop: 4 }}>{customMessage}</div>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div style={{ marginBottom: 16 }}>
|
|
71
|
+
{labelEl}
|
|
72
|
+
{viewOnly ? (
|
|
73
|
+
<div style={{ padding: '4px 11px', border: '1px solid #d9d9d9', borderRadius: 6, minHeight: 32, background: '#fafafa' }}>
|
|
74
|
+
{value || ''}
|
|
75
|
+
</div>
|
|
76
|
+
) : (
|
|
77
|
+
<Input
|
|
78
|
+
placeholder={placeholder || labelName}
|
|
79
|
+
value={value}
|
|
80
|
+
onChange={(e) => setValue?.(e.target.value)}
|
|
81
|
+
prefix={leftIcon}
|
|
82
|
+
suffix={rightIcon}
|
|
83
|
+
/>
|
|
84
|
+
)}
|
|
85
|
+
{customMessage && <div style={{ color: '#999', fontSize: 12, marginTop: 4 }}>{customMessage}</div>}
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface TextInputProps {
|
|
4
|
+
form?: any;
|
|
5
|
+
name?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
labelName?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
viewOnly?: boolean;
|
|
11
|
+
disableLabelFormatting?: boolean;
|
|
12
|
+
customMessage?: ReactNode;
|
|
13
|
+
isArray?: boolean;
|
|
14
|
+
leftIcon?: ReactNode;
|
|
15
|
+
rightIcon?: ReactNode;
|
|
16
|
+
value?: string;
|
|
17
|
+
setValue?: (value: string) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface TextAreaInputProps {
|
|
21
|
+
form?: any;
|
|
22
|
+
name?: string;
|
|
23
|
+
labelName?: string;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
viewOnly?: boolean;
|
|
28
|
+
rows?: number;
|
|
29
|
+
disableLabelFormatting?: boolean;
|
|
30
|
+
customMessage?: ReactNode;
|
|
31
|
+
value?: string;
|
|
32
|
+
setValue?: (value: string) => void;
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
showCount?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface NumberInputProps {
|
|
38
|
+
form?: any;
|
|
39
|
+
name?: string;
|
|
40
|
+
labelName?: string;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
required?: boolean;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
viewOnly?: boolean;
|
|
45
|
+
disableLabelFormatting?: boolean;
|
|
46
|
+
numberType?: 'float' | 'integer';
|
|
47
|
+
customMessage?: ReactNode;
|
|
48
|
+
min?: number;
|
|
49
|
+
max?: number;
|
|
50
|
+
step?: number;
|
|
51
|
+
prefix?: ReactNode;
|
|
52
|
+
suffix?: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface PasswordInputProps {
|
|
56
|
+
form?: any;
|
|
57
|
+
name?: string;
|
|
58
|
+
labelName?: string;
|
|
59
|
+
placeholder?: string;
|
|
60
|
+
required?: boolean;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
disableLabelFormatting?: boolean;
|
|
63
|
+
mode?: 'normal' | 'validate';
|
|
64
|
+
customMessage?: ReactNode;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface SingleSelectProps {
|
|
68
|
+
form?: any;
|
|
69
|
+
name?: string;
|
|
70
|
+
labelName?: string;
|
|
71
|
+
placeholder?: string;
|
|
72
|
+
required?: boolean;
|
|
73
|
+
disabled?: boolean;
|
|
74
|
+
options?: string[];
|
|
75
|
+
viewOnly?: boolean;
|
|
76
|
+
isLoading?: boolean;
|
|
77
|
+
defaultValue?: any;
|
|
78
|
+
onValueChange?: (value: any) => void;
|
|
79
|
+
disableLabelFormatting?: boolean;
|
|
80
|
+
customMessage?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface SelectFieldProps {
|
|
84
|
+
form: any;
|
|
85
|
+
name: string;
|
|
86
|
+
labelName?: string;
|
|
87
|
+
required?: boolean;
|
|
88
|
+
disabled?: boolean;
|
|
89
|
+
options?: { value: string; label: string; image?: string; flag?: string; disabled?: boolean }[] | string[];
|
|
90
|
+
placeholder?: string;
|
|
91
|
+
showSearch?: boolean;
|
|
92
|
+
type?: 'single' | 'multiple';
|
|
93
|
+
viewOnly?: boolean;
|
|
94
|
+
onValueChange?: (value: string | string[]) => void;
|
|
95
|
+
isLoading?: boolean;
|
|
96
|
+
onSearch?: (query: string) => void;
|
|
97
|
+
customMessage?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface SwitchProps {
|
|
101
|
+
form?: any;
|
|
102
|
+
name?: string;
|
|
103
|
+
labelName?: string;
|
|
104
|
+
required?: boolean;
|
|
105
|
+
disabled?: boolean;
|
|
106
|
+
viewOnly?: boolean;
|
|
107
|
+
disableLabelFormatting?: boolean;
|
|
108
|
+
customMessage?: ReactNode;
|
|
109
|
+
description?: string;
|
|
110
|
+
border?: boolean;
|
|
111
|
+
value?: boolean;
|
|
112
|
+
setValue?: (value: boolean) => void;
|
|
113
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface CheckboxProps {
|
|
117
|
+
form?: any;
|
|
118
|
+
name: string;
|
|
119
|
+
labelName?: string;
|
|
120
|
+
required?: boolean;
|
|
121
|
+
disabled?: boolean;
|
|
122
|
+
options?: { label: string; value: string }[];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface RadioProps {
|
|
126
|
+
form?: any;
|
|
127
|
+
name: string;
|
|
128
|
+
labelName?: string;
|
|
129
|
+
required?: boolean;
|
|
130
|
+
disabled?: boolean;
|
|
131
|
+
options?: { label: string; value: string }[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface DatePickerProps {
|
|
135
|
+
form?: any;
|
|
136
|
+
name?: string;
|
|
137
|
+
labelName?: string;
|
|
138
|
+
placeholder?: string;
|
|
139
|
+
required?: boolean;
|
|
140
|
+
disabled?: boolean;
|
|
141
|
+
viewOnly?: boolean;
|
|
142
|
+
disableLabelFormatting?: boolean;
|
|
143
|
+
customMessage?: string;
|
|
144
|
+
picker?: 'date' | 'week' | 'month' | 'quarter' | 'year';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface PhoneNumberProps {
|
|
148
|
+
form?: any;
|
|
149
|
+
name?: string;
|
|
150
|
+
labelName?: string;
|
|
151
|
+
placeholder?: string;
|
|
152
|
+
required?: boolean;
|
|
153
|
+
disabled?: boolean;
|
|
154
|
+
viewOnly?: boolean;
|
|
155
|
+
disableLabelFormatting?: boolean;
|
|
156
|
+
customMessage?: string;
|
|
157
|
+
onValueChange?: (value: string) => void;
|
|
158
|
+
hasPhone?: boolean;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface SearchFieldProps {
|
|
162
|
+
form?: any;
|
|
163
|
+
name?: string;
|
|
164
|
+
placeholder?: string;
|
|
165
|
+
onSearch?: (value: string) => void;
|
|
166
|
+
value?: string;
|
|
167
|
+
setValue?: (value: string) => void;
|
|
168
|
+
loading?: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface OTPProps {
|
|
172
|
+
form?: any;
|
|
173
|
+
name?: string;
|
|
174
|
+
labelName?: string;
|
|
175
|
+
required?: boolean;
|
|
176
|
+
disabled?: boolean;
|
|
177
|
+
length?: number;
|
|
178
|
+
customMessage?: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface RangeDatePickerProps {
|
|
182
|
+
form?: any;
|
|
183
|
+
name?: string;
|
|
184
|
+
labelName?: string;
|
|
185
|
+
required?: boolean;
|
|
186
|
+
disabled?: boolean;
|
|
187
|
+
customMessage?: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface LimitFieldProps {
|
|
191
|
+
limit: string;
|
|
192
|
+
setLimit: (limit: string) => void;
|
|
193
|
+
totalItems?: number;
|
|
194
|
+
options?: number[];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface InputInterface {
|
|
198
|
+
Text: TextInputProps;
|
|
199
|
+
TextArea: TextAreaInputProps;
|
|
200
|
+
Number: NumberInputProps;
|
|
201
|
+
Password: PasswordInputProps;
|
|
202
|
+
SingleSelect: SingleSelectProps;
|
|
203
|
+
PhoneNumber: PhoneNumberProps;
|
|
204
|
+
Switch: SwitchProps;
|
|
205
|
+
DatePicker: DatePickerProps;
|
|
206
|
+
Search: SearchFieldProps;
|
|
207
|
+
OTP: OTPProps;
|
|
208
|
+
RangeDatePicker: RangeDatePickerProps;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface FieldPropsInterface {
|
|
212
|
+
form?: any;
|
|
213
|
+
name: string;
|
|
214
|
+
placeholder?: string;
|
|
215
|
+
labelName?: string;
|
|
216
|
+
description?: string;
|
|
217
|
+
border?: boolean;
|
|
218
|
+
options?: string[];
|
|
219
|
+
required?: boolean;
|
|
220
|
+
disabled?: boolean;
|
|
221
|
+
isArray?: boolean;
|
|
222
|
+
style?: string;
|
|
223
|
+
defaultValue?: any;
|
|
224
|
+
viewOnly?: boolean;
|
|
225
|
+
rows?: number;
|
|
226
|
+
disableLabelFormatting?: boolean;
|
|
227
|
+
maxLength?: number;
|
|
228
|
+
suffix?: string;
|
|
229
|
+
mode?: 'normal' | 'validate';
|
|
230
|
+
customMessage?: ReactNode;
|
|
231
|
+
onValueChange?: (value: any) => void;
|
|
232
|
+
isLoading?: boolean;
|
|
233
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Text } from './assets/components/text-field.component';
|
|
2
|
+
import { TextArea } from './assets/components/text-area-field.component';
|
|
3
|
+
import { Number } from './assets/components/number-field.component';
|
|
4
|
+
import { StringNumber } from './assets/components/string-number-field.component';
|
|
5
|
+
import { Password } from './assets/components/password-field.component';
|
|
6
|
+
import { SingleSelectField } from './assets/components/single-select-field.component';
|
|
7
|
+
import { SelectField } from './assets/components/select-field.component';
|
|
8
|
+
import { SwitchField } from './assets/components/switch-field.component';
|
|
9
|
+
import { RadioField } from './assets/components/radio-field.component';
|
|
10
|
+
import { CheckField } from './assets/components/check-field.component';
|
|
11
|
+
import { MultiCheckField } from './assets/components/multi-check-field.component';
|
|
12
|
+
import { SingleCheckField } from './assets/components/single-check-field.component';
|
|
13
|
+
import { SearchField } from './assets/components/search-field.component';
|
|
14
|
+
import { DatePickerField } from './assets/components/date-picker-field.component';
|
|
15
|
+
import { PhoneNumber } from './assets/components/phone-number-field.component';
|
|
16
|
+
import { OTP } from './assets/components/otp-field.component';
|
|
17
|
+
import { RangeDatePicker } from './assets/components/range-date-picker.component';
|
|
18
|
+
import { LimitField } from './assets/components/limit-field.component';
|
|
19
|
+
|
|
20
|
+
export const CustomField = {
|
|
21
|
+
Text,
|
|
22
|
+
TextArea,
|
|
23
|
+
Number,
|
|
24
|
+
StringNumber,
|
|
25
|
+
Password,
|
|
26
|
+
SingleSelectField,
|
|
27
|
+
SelectField,
|
|
28
|
+
SwitchField,
|
|
29
|
+
RadioField,
|
|
30
|
+
CheckField,
|
|
31
|
+
MultiCheckField,
|
|
32
|
+
SingleCheckField,
|
|
33
|
+
SearchField,
|
|
34
|
+
CommonSearch: SearchField,
|
|
35
|
+
DatePickerField,
|
|
36
|
+
RangeDatePicker,
|
|
37
|
+
PhoneNumber,
|
|
38
|
+
OTP,
|
|
39
|
+
LimitField,
|
|
40
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Pagination as AntPagination } from 'antd';
|
|
4
|
+
|
|
5
|
+
interface PaginationProps {
|
|
6
|
+
currentPage: number;
|
|
7
|
+
totalPages: number;
|
|
8
|
+
setCurrentPage: (page: number) => void;
|
|
9
|
+
total?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function Pagination({ currentPage, totalPages, setCurrentPage, total }: PaginationProps) {
|
|
13
|
+
if (totalPages <= 1) return null;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 16 }}>
|
|
17
|
+
<AntPagination
|
|
18
|
+
current={currentPage}
|
|
19
|
+
total={total ?? (totalPages * 10)}
|
|
20
|
+
pageSize={1}
|
|
21
|
+
onChange={(page) => setCurrentPage(page)}
|
|
22
|
+
showSizeChanger={false}
|
|
23
|
+
showQuickJumper={false}
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Dropdown as AntDropdown, type DropdownProps as AntDropdownProps } from 'antd';
|
|
3
|
+
|
|
4
|
+
export type DropdownMenuProps = AntDropdownProps;
|
|
5
|
+
|
|
6
|
+
export function DropdownMenu(props: DropdownMenuProps) {
|
|
7
|
+
return <AntDropdown {...props} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { AntDropdown as Dropdown };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Form as AntForm, type FormProps as AntFormProps } from 'antd';
|
|
3
|
+
|
|
4
|
+
export type FormProps = AntFormProps;
|
|
5
|
+
export const FormItem = AntForm.Item;
|
|
6
|
+
export const useForm = AntForm.useForm;
|
|
7
|
+
export const FormList = AntForm.List;
|
|
8
|
+
export const FormProvider = AntForm.Provider;
|
|
9
|
+
|
|
10
|
+
export function Form(props: FormProps) {
|
|
11
|
+
return <AntForm {...props} />;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Input as AntInput, type InputProps as AntInputProps } from 'antd';
|
|
3
|
+
|
|
4
|
+
export type InputProps = AntInputProps;
|
|
5
|
+
|
|
6
|
+
export function Input(props: InputProps) {
|
|
7
|
+
return <AntInput {...props} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const TextArea = AntInput.TextArea;
|
|
11
|
+
export const InputOTP = AntInput.OTP;
|
|
12
|
+
export const InputPassword = AntInput.Password;
|
|
13
|
+
export const InputSearch = AntInput.Search;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Typography } from 'antd';
|
|
3
|
+
import type { TextProps } from 'antd/es/typography/Text';
|
|
4
|
+
|
|
5
|
+
const { Text } = Typography;
|
|
6
|
+
|
|
7
|
+
export type LabelProps = TextProps & { required?: boolean };
|
|
8
|
+
|
|
9
|
+
export function Label({ children, required, ...props }: LabelProps) {
|
|
10
|
+
return (
|
|
11
|
+
<label>
|
|
12
|
+
<Text strong {...props}>
|
|
13
|
+
{children}
|
|
14
|
+
{required && <span style={{ color: '#ff4d4f', marginLeft: 2 }}>*</span>}
|
|
15
|
+
</Text>
|
|
16
|
+
</label>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Radio as AntRadio, type RadioGroupProps as AntRadioGroupProps } from 'antd';
|
|
3
|
+
|
|
4
|
+
export type RadioGroupProps = AntRadioGroupProps;
|
|
5
|
+
|
|
6
|
+
export function RadioGroup(props: RadioGroupProps) {
|
|
7
|
+
return <AntRadio.Group {...props} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { AntRadio as Radio };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import type { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
interface ScrollAreaProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
className?: string;
|
|
8
|
+
maxHeight?: number | string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function ScrollArea({ children, style, className, maxHeight }: ScrollAreaProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
className={className}
|
|
15
|
+
style={{
|
|
16
|
+
overflowY: 'auto',
|
|
17
|
+
maxHeight: maxHeight || '100%',
|
|
18
|
+
scrollbarWidth: 'thin',
|
|
19
|
+
...style,
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Input } from 'antd';
|
|
3
|
+
import type { TextAreaProps as AntTextAreaProps } from 'antd/es/input';
|
|
4
|
+
|
|
5
|
+
export type TextareaProps = AntTextAreaProps;
|
|
6
|
+
|
|
7
|
+
export function Textarea(props: TextareaProps) {
|
|
8
|
+
return <Input.TextArea {...props} />;
|
|
9
|
+
}
|