@sonamu-kit/react-components 0.1.7 → 0.1.9
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/components/index.d.ts +6 -5
- package/dist/components/ui/select/enum-select.d.ts +15 -0
- package/dist/components/ui/select/id-async-select.d.ts +25 -0
- package/dist/components/ui/select/select.d.ts +66 -0
- package/dist/contexts/index.d.ts +1 -1
- package/dist/contexts/sonamu-context.d.ts +14 -5
- package/dist/lib/form-helpers.d.ts +13 -1
- package/dist/react-components.es.js +13116 -14240
- package/dist/react-components.es.js.map +1 -1
- package/package.json +4 -2
- package/dist/components/ui/async-select.d.ts +0 -36
- package/dist/components/ui/multi-select.d.ts +0 -225
- package/dist/components/ui/select.d.ts +0 -20
|
@@ -4,8 +4,6 @@ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from '.
|
|
|
4
4
|
export { Alert, AlertDescription, AlertTitle } from './ui/alert';
|
|
5
5
|
export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, } from './ui/alert-dialog';
|
|
6
6
|
export { AspectRatio } from './ui/aspect-ratio';
|
|
7
|
-
export type { AsyncSelectOption, AsyncSelectProps } from './ui/async-select';
|
|
8
|
-
export { AsyncSelect } from './ui/async-select';
|
|
9
7
|
export { Avatar, AvatarFallback, AvatarImage } from './ui/avatar';
|
|
10
8
|
export { Badge, badgeVariants } from './ui/badge';
|
|
11
9
|
export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from './ui/breadcrumb';
|
|
@@ -37,8 +35,6 @@ export { Label } from './ui/label';
|
|
|
37
35
|
export { Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, } from './ui/menubar';
|
|
38
36
|
export type { MonthPickerValue } from './ui/month-picker-multiple';
|
|
39
37
|
export { MonthPickerMultiple } from './ui/month-picker-multiple';
|
|
40
|
-
export type { MultiSelectOption, MultiSelectProps, MultiSelectRef, } from './ui/multi-select';
|
|
41
|
-
export { MultiSelect } from './ui/multi-select';
|
|
42
38
|
export { NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, navigationMenuTriggerStyle, } from './ui/navigation-menu';
|
|
43
39
|
export { Pagination } from './ui/pagination';
|
|
44
40
|
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger, } from './ui/popover';
|
|
@@ -46,7 +42,12 @@ export { Progress } from './ui/progress';
|
|
|
46
42
|
export { RadioGroup, RadioGroupItem } from './ui/radio-group';
|
|
47
43
|
export { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from './ui/resizable';
|
|
48
44
|
export { ScrollArea, ScrollBar } from './ui/scroll-area';
|
|
49
|
-
export {
|
|
45
|
+
export type { EnumSelectProps } from './ui/select/enum-select';
|
|
46
|
+
export { EnumSelect } from './ui/select/enum-select';
|
|
47
|
+
export type { AsyncIdConfig, IdAsyncSelectProps } from './ui/select/id-async-select';
|
|
48
|
+
export { IdAsyncSelect } from './ui/select/id-async-select';
|
|
49
|
+
export type { ExtractValue, SelectItemDef, SelectProps } from './ui/select/select';
|
|
50
|
+
export { Select } from './ui/select/select';
|
|
50
51
|
export { Separator } from './ui/separator';
|
|
51
52
|
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, } from './ui/sheet';
|
|
52
53
|
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, } from './ui/sidebar';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type EnumSelectProps<TValue extends string = string> = {
|
|
2
|
+
enum: {
|
|
3
|
+
options: readonly TValue[];
|
|
4
|
+
};
|
|
5
|
+
labels: Record<TValue, string>;
|
|
6
|
+
value?: TValue | TValue[] | "";
|
|
7
|
+
onValueChange?: (value: TValue | TValue[] | "" | null | undefined) => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
textPrefix?: string;
|
|
10
|
+
clearable?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
multiple?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function EnumSelect<TValue extends string = string>({ enum: zodEnum, labels, value, onValueChange, placeholder, textPrefix, clearable, disabled, className, multiple, }: EnumSelectProps<TValue>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
export type AsyncIdConfig<TSubsetKey extends string = string, _TSubsetMapping = Record<string, unknown>> = {
|
|
3
|
+
placeholderKey: string;
|
|
4
|
+
useList: <T extends TSubsetKey>(subset: T, params?: any, options?: {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
}) => UseQueryResult<Record<string, unknown>, Error>;
|
|
7
|
+
};
|
|
8
|
+
type OnRowChangeType<TSubsetKey extends string, TSubsetMapping> = TSubsetKey extends keyof TSubsetMapping ? TSubsetMapping[TSubsetKey] | TSubsetMapping[TSubsetKey][] | undefined : unknown;
|
|
9
|
+
export type IdAsyncSelectProps<TSubsetKey extends string = string, TSubsetMapping = Record<string, unknown>, TValue extends string | number = string> = {
|
|
10
|
+
config: AsyncIdConfig<TSubsetKey, TSubsetMapping>;
|
|
11
|
+
subset: TSubsetKey;
|
|
12
|
+
baseListParams?: Record<string, unknown>;
|
|
13
|
+
displayField?: string;
|
|
14
|
+
valueField?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
clearable?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
value?: TValue | TValue[] | null;
|
|
21
|
+
onValueChange?: (value: TValue | TValue[] | undefined) => void;
|
|
22
|
+
onRowChange?: (row: OnRowChangeType<TSubsetKey, TSubsetMapping>) => void;
|
|
23
|
+
};
|
|
24
|
+
export declare function IdAsyncSelect<TSubsetKey extends string = string, TSubsetMapping = Record<string, unknown>, TValue extends string | number = string>({ config, subset, baseListParams, displayField, valueField, placeholder, clearable, disabled, className, multiple, value, onValueChange, onRowChange, }: IdAsyncSelectProps<TSubsetKey, TSubsetMapping, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type ExtractValue<Item> = Item extends {
|
|
3
|
+
value: infer V;
|
|
4
|
+
} ? V : Item;
|
|
5
|
+
type SelectItemDef<V> = V | {
|
|
6
|
+
value: V;
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
interface SelectPropsBase<Item> {
|
|
11
|
+
items: Item[];
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
contentClassName?: string;
|
|
17
|
+
renderItem?: (value: ExtractValue<Item>) => React.ReactNode;
|
|
18
|
+
name?: string;
|
|
19
|
+
onBlur?: React.FocusEventHandler<HTMLSelectElement>;
|
|
20
|
+
}
|
|
21
|
+
type SelectPropsWithValueKey<Item> = ExtractValue<Item> extends string | number ? {
|
|
22
|
+
valueKey?: (value: ExtractValue<Item>) => string;
|
|
23
|
+
} : {
|
|
24
|
+
valueKey: (value: ExtractValue<Item>) => string;
|
|
25
|
+
};
|
|
26
|
+
interface SingleSyncProps<Item> {
|
|
27
|
+
multiple?: false;
|
|
28
|
+
async?: false;
|
|
29
|
+
value?: ExtractValue<Item>;
|
|
30
|
+
onValueChange?: (value: ExtractValue<Item> | undefined) => void;
|
|
31
|
+
searchable?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface SingleAsyncProps<Item> {
|
|
34
|
+
multiple?: false;
|
|
35
|
+
async: true;
|
|
36
|
+
value?: ExtractValue<Item>;
|
|
37
|
+
onValueChange?: (value: ExtractValue<Item> | undefined) => void;
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
error?: Error;
|
|
40
|
+
onSearch: (keyword: string) => void;
|
|
41
|
+
searchDebounce?: number;
|
|
42
|
+
}
|
|
43
|
+
interface MultiSyncProps<Item> {
|
|
44
|
+
multiple: true;
|
|
45
|
+
async?: false;
|
|
46
|
+
value: ExtractValue<Item>[];
|
|
47
|
+
onValueChange: (value: ExtractValue<Item>[]) => void;
|
|
48
|
+
maxCount?: number;
|
|
49
|
+
hideSelectAll?: boolean;
|
|
50
|
+
searchable?: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface MultiAsyncProps<Item> {
|
|
53
|
+
multiple: true;
|
|
54
|
+
async: true;
|
|
55
|
+
value: ExtractValue<Item>[];
|
|
56
|
+
onValueChange: (value: ExtractValue<Item>[]) => void;
|
|
57
|
+
loading?: boolean;
|
|
58
|
+
error?: Error;
|
|
59
|
+
onSearch: (keyword: string) => void;
|
|
60
|
+
searchDebounce?: number;
|
|
61
|
+
maxCount?: number;
|
|
62
|
+
hideSelectAll?: boolean;
|
|
63
|
+
}
|
|
64
|
+
type SelectProps<Item> = SelectPropsBase<Item> & SelectPropsWithValueKey<Item> & (SingleSyncProps<Item> | SingleAsyncProps<Item> | MultiSyncProps<Item> | MultiAsyncProps<Item>);
|
|
65
|
+
export declare const Select: <Item>(props: SelectProps<Item> & React.RefAttributes<HTMLSelectElement>) => React.ReactElement;
|
|
66
|
+
export type { SelectProps, SelectItemDef, ExtractValue };
|
package/dist/contexts/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { type SonamuContextValue, SonamuProvider,
|
|
1
|
+
export { type SonamuContextValue, SonamuProvider, useSonamuBaseContext, } from './sonamu-context';
|
|
2
2
|
export type { Dictionary, SDReturnType, SonamuAuth, SonamuFile } from './types';
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { Dictionary, SDReturnType, SonamuAuth, SonamuFile } from './types';
|
|
3
|
-
export interface SonamuContextValue<D extends Dictionary = Dictionary> {
|
|
3
|
+
export interface SonamuContextValue<D extends Dictionary = Dictionary, TUser = any, TLoginParams = any> {
|
|
4
4
|
uploader?: (files: File[]) => Promise<SonamuFile[]>;
|
|
5
|
-
auth?: SonamuAuth
|
|
5
|
+
auth?: SonamuAuth<TUser, TLoginParams>;
|
|
6
6
|
SD?: <K extends keyof D>(key: K) => SDReturnType<D, K>;
|
|
7
7
|
}
|
|
8
|
-
export interface SonamuProviderProps<D extends Dictionary = Dictionary> extends SonamuContextValue<D> {
|
|
8
|
+
export interface SonamuProviderProps<D extends Dictionary = Dictionary, TUser = any, TLoginParams = any> extends SonamuContextValue<D, TUser, TLoginParams> {
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
}
|
|
11
|
-
export declare function SonamuProvider<D extends Dictionary = Dictionary>({ children, ...value }: SonamuProviderProps<D>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
|
|
11
|
+
export declare function SonamuProvider<D extends Dictionary = Dictionary, TUser = any, TLoginParams = any>({ children, ...value }: SonamuProviderProps<D, TUser, TLoginParams>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* 타입이 지정된 useSonamuContext를 만들기 위한 베이스 훅
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // contexts/sonamu-provider.tsx
|
|
17
|
+
* export function useSonamuContext() {
|
|
18
|
+
* return useSonamuBaseContext<MergedDictionary, UserSubsetSS, UserLoginParams>();
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
export declare function useSonamuBaseContext<D extends Dictionary = Dictionary, TUser = any, TLoginParams = any>(): Required<SonamuContextValue<D, TUser, TLoginParams>>;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ErrorObj } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* FormRegisterReturn
|
|
5
|
+
*
|
|
6
|
+
* register 함수의 반환 타입입니다.
|
|
7
|
+
*/
|
|
8
|
+
export type FormRegisterReturn = {
|
|
9
|
+
value: any;
|
|
10
|
+
onValueChange: (value: any) => void;
|
|
11
|
+
onRowChange?: (row: any) => void;
|
|
12
|
+
error?: ErrorObj;
|
|
13
|
+
};
|
|
3
14
|
export declare function useTypeForm<T extends z.ZodObject<any> | z.ZodArray<any>, U extends z.infer<T>>(zType: T, defaultValue: U): {
|
|
4
15
|
form: z.core.output<T>;
|
|
5
16
|
setForm: import('react').Dispatch<import('react').SetStateAction<z.core.output<T>>>;
|
|
6
|
-
|
|
17
|
+
row: Record<string, any>;
|
|
18
|
+
register: (objPath: string, _emptyStringTo?: "normal" | "nullable" | "optional") => FormRegisterReturn;
|
|
7
19
|
submit: <R>(callback: (formData: z.infer<T>) => Promise<R>) => () => Promise<R>;
|
|
8
20
|
addError: (objPath: string, errorMessage: string | ErrorObj) => void;
|
|
9
21
|
removeError: (objPath: string) => void;
|