@simplysm/solid 13.0.16 → 13.0.24
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/README.md +0 -10
- package/dist/components/data/calendar/Calendar.d.ts +5 -5
- package/dist/components/data/calendar/Calendar.d.ts.map +1 -1
- package/dist/components/data/calendar/Calendar.js.map +1 -1
- package/dist/components/data/sheet/DataSheetColumn.d.ts +1 -1
- package/dist/components/data/sheet/DataSheetColumn.d.ts.map +1 -1
- package/dist/components/data/sheet/DataSheetColumn.js.map +1 -1
- package/dist/components/data/sheet/sheetUtils.d.ts +4 -4
- package/dist/components/data/sheet/sheetUtils.d.ts.map +1 -1
- package/dist/components/data/sheet/sheetUtils.js.map +1 -1
- package/dist/components/data/sheet/types.d.ts +23 -23
- package/dist/components/data/sheet/types.d.ts.map +1 -1
- package/dist/components/disclosure/DialogInstanceContext.d.ts +3 -3
- package/dist/components/disclosure/DialogInstanceContext.d.ts.map +1 -1
- package/dist/components/disclosure/DialogInstanceContext.js.map +1 -1
- package/dist/components/form-control/checkbox/CheckboxGroup.d.ts +7 -7
- package/dist/components/form-control/checkbox/CheckboxGroup.d.ts.map +1 -1
- package/dist/components/form-control/checkbox/CheckboxGroup.js.map +1 -1
- package/dist/components/form-control/checkbox/RadioGroup.d.ts +7 -7
- package/dist/components/form-control/checkbox/RadioGroup.d.ts.map +1 -1
- package/dist/components/form-control/checkbox/RadioGroup.js.map +1 -1
- package/dist/components/form-control/combobox/Combobox.d.ts +9 -9
- package/dist/components/form-control/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/form-control/combobox/ComboboxContext.d.ts +4 -4
- package/dist/components/form-control/combobox/ComboboxContext.d.ts.map +1 -1
- package/dist/components/form-control/combobox/ComboboxContext.js.map +1 -1
- package/dist/components/form-control/combobox/ComboboxItem.d.ts +2 -2
- package/dist/components/form-control/combobox/ComboboxItem.d.ts.map +1 -1
- package/dist/components/form-control/select/Select.d.ts +16 -16
- package/dist/components/form-control/select/Select.d.ts.map +1 -1
- package/dist/components/form-control/select/SelectContext.d.ts +4 -4
- package/dist/components/form-control/select/SelectContext.d.ts.map +1 -1
- package/dist/components/form-control/select/SelectContext.js.map +1 -1
- package/dist/components/form-control/select/SelectItem.d.ts +3 -3
- package/dist/components/form-control/select/SelectItem.d.ts.map +1 -1
- package/dist/components/form-control/state-preset/StatePreset.d.ts +4 -4
- package/dist/components/form-control/state-preset/StatePreset.d.ts.map +1 -1
- package/dist/components/form-control/state-preset/StatePreset.js.map +1 -1
- package/dist/components/layout/sidebar/SidebarUser.d.ts.map +1 -1
- package/dist/components/layout/sidebar/SidebarUser.js +13 -9
- package/dist/components/layout/sidebar/SidebarUser.js.map +2 -2
- package/dist/helpers/createAppStructure.d.ts +1 -0
- package/dist/helpers/createAppStructure.d.ts.map +1 -1
- package/dist/helpers/createAppStructure.js +16 -1
- package/dist/helpers/createAppStructure.js.map +1 -1
- package/dist/hooks/createControllableSignal.d.ts +5 -5
- package/dist/hooks/createControllableSignal.d.ts.map +1 -1
- package/dist/hooks/createControllableSignal.js.map +1 -1
- package/dist/hooks/useLocalStorage.d.ts +1 -1
- package/dist/hooks/useLocalStorage.d.ts.map +1 -1
- package/dist/hooks/useLocalStorage.js.map +1 -1
- package/dist/hooks/useSyncConfig.d.ts +1 -1
- package/dist/hooks/useSyncConfig.d.ts.map +1 -1
- package/dist/hooks/useSyncConfig.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/InitializeProvider.d.ts +0 -1
- package/dist/providers/InitializeProvider.d.ts.map +1 -1
- package/dist/providers/InitializeProvider.js +1 -6
- package/dist/providers/InitializeProvider.js.map +2 -2
- package/dist/providers/shared-data/SharedDataContext.d.ts +10 -10
- package/dist/providers/shared-data/SharedDataContext.d.ts.map +1 -1
- package/dist/providers/shared-data/SharedDataContext.js.map +1 -1
- package/dist/providers/shared-data/SharedDataProvider.d.ts +2 -2
- package/dist/providers/shared-data/SharedDataProvider.d.ts.map +1 -1
- package/dist/providers/shared-data/SharedDataProvider.js.map +1 -1
- package/docs/hooks.md +19 -0
- package/package.json +5 -5
- package/src/components/data/calendar/Calendar.tsx +8 -8
- package/src/components/data/sheet/DataSheetColumn.tsx +1 -1
- package/src/components/data/sheet/sheetUtils.ts +16 -13
- package/src/components/data/sheet/types.ts +23 -23
- package/src/components/disclosure/DialogInstanceContext.ts +4 -4
- package/src/components/form-control/checkbox/CheckboxGroup.tsx +10 -10
- package/src/components/form-control/checkbox/RadioGroup.tsx +10 -10
- package/src/components/form-control/combobox/Combobox.tsx +9 -9
- package/src/components/form-control/combobox/ComboboxContext.ts +5 -5
- package/src/components/form-control/combobox/ComboboxItem.tsx +2 -2
- package/src/components/form-control/select/Select.tsx +20 -20
- package/src/components/form-control/select/SelectContext.ts +5 -5
- package/src/components/form-control/select/SelectItem.tsx +3 -3
- package/src/components/form-control/state-preset/StatePreset.tsx +10 -10
- package/src/components/layout/sidebar/SidebarUser.tsx +5 -3
- package/src/helpers/createAppStructure.ts +22 -0
- package/src/hooks/createControllableSignal.ts +7 -7
- package/src/hooks/useLocalStorage.ts +11 -8
- package/src/hooks/useSyncConfig.ts +8 -5
- package/src/index.ts +58 -13
- package/src/providers/InitializeProvider.tsx +2 -5
- package/src/providers/shared-data/SharedDataContext.ts +13 -11
- package/src/providers/shared-data/SharedDataProvider.tsx +2 -2
- package/tailwind.config.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/providers/shared-data/SharedDataProvider.tsx"],
|
|
4
|
-
"mappings": ";AAAA,SAAkCA,YAAYC,cAAcC,iBAAiB;AAC7E,SAASC,UAAUC,iBAAiB;AACpC,SACEC,yBAIK;AACP,SAASC,6BAA6B;AACtC,SAASC,wBAAwB;AACjC,SAASC,uBAAuB;AAChC,SAASC,iBAAiB;AAEnB,SAASC,
|
|
4
|
+
"mappings": "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",
|
|
5
5
|
"names": ["createMemo", "createSignal", "onCleanup", "objEqual", "waitUntil", "SharedDataContext", "SharedDataChangeEvent", "useServiceClient", "useNotification", "useLogger", "SharedDataProvider", "props", "serviceClient", "notification", "logger", "loadingCount", "setLoadingCount", "loading", "signalMap", "Map", "memoMap", "listenerKeyMap", "versionMap", "ordering", "data", "orderByList", "result", "orderBy", "reverse", "selector", "item", "orderByDesc", "loadData", "name", "def", "changeKeys", "currentVersion", "get", "set", "c", "signal", "Error", "setItems", "resData", "fetch", "prev", "filtered", "filter", "includes", "getKey", "push", "err", "error", "danger", "message", "wait", "accessors", "Object", "entries", "definitions", "items", "itemMap", "map", "client", "serviceKey", "addEventListener", "then", "key", "undefined", "emit", "emitToServer", "info", "listenerKey", "removeEventListener", "contextValue", "_$createComponent", "Provider", "value", "children"]
|
|
6
6
|
}
|
package/docs/hooks.md
CHANGED
|
@@ -311,3 +311,22 @@ interface AppStructureLeafItem<TModule> {
|
|
|
311
311
|
|
|
312
312
|
type AppStructureItem<TModule> = AppStructureGroupItem<TModule> | AppStructureLeafItem<TModule>;
|
|
313
313
|
```
|
|
314
|
+
|
|
315
|
+
#### getTitleChainByHref
|
|
316
|
+
|
|
317
|
+
Retrieves the breadcrumb title chain for a given href path. Works on raw items (including `isNotMenu` items).
|
|
318
|
+
|
|
319
|
+
```tsx
|
|
320
|
+
import { createAppStructure } from "@simplysm/solid";
|
|
321
|
+
|
|
322
|
+
const appStructure = createAppStructure({ items });
|
|
323
|
+
|
|
324
|
+
// Returns ["Sales", "Invoice"] for /home/sales/invoice
|
|
325
|
+
const titles = appStructure.getTitleChainByHref("/home/sales/invoice");
|
|
326
|
+
|
|
327
|
+
// Use with router for dynamic breadcrumb
|
|
328
|
+
import { useLocation } from "@solidjs/router";
|
|
329
|
+
|
|
330
|
+
const location = useLocation();
|
|
331
|
+
const breadcrumb = () => appStructure.getTitleChainByHref(location.pathname);
|
|
332
|
+
```
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/solid",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.24",
|
|
4
4
|
"description": "심플리즘 패키지 - SolidJS 라이브러리",
|
|
5
|
+
"author": "김석래",
|
|
6
|
+
"license": "Apache-2.0",
|
|
5
7
|
"repository": {
|
|
6
8
|
"type": "git",
|
|
7
9
|
"url": "https://github.com/kslhunter/simplysm.git",
|
|
8
10
|
"directory": "packages/solid"
|
|
9
11
|
},
|
|
10
|
-
"author": "김석래",
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"solid-tiptap": "^0.8.0",
|
|
50
50
|
"tailwind-merge": "^3.4.1",
|
|
51
51
|
"tailwindcss": "^3.4.19",
|
|
52
|
-
"@simplysm/core-browser": "13.0.
|
|
53
|
-
"@simplysm/core-common": "13.0.
|
|
52
|
+
"@simplysm/core-browser": "13.0.24",
|
|
53
|
+
"@simplysm/core-common": "13.0.24"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@solidjs/testing-library": "^0.8.10"
|
|
@@ -4,10 +4,10 @@ import clsx from "clsx";
|
|
|
4
4
|
import { twMerge } from "tailwind-merge";
|
|
5
5
|
import { createControllableSignal } from "../../../hooks/createControllableSignal";
|
|
6
6
|
|
|
7
|
-
export interface CalendarProps<
|
|
8
|
-
items:
|
|
9
|
-
getItemDate: (item:
|
|
10
|
-
renderItem: (item:
|
|
7
|
+
export interface CalendarProps<TValue> extends Omit<JSX.HTMLAttributes<HTMLTableElement>, "children"> {
|
|
8
|
+
items: TValue[];
|
|
9
|
+
getItemDate: (item: TValue, index: number) => DateOnly;
|
|
10
|
+
renderItem: (item: TValue, index: number) => JSX.Element;
|
|
11
11
|
yearMonth?: DateOnly;
|
|
12
12
|
onYearMonthChange?: (value: DateOnly) => void;
|
|
13
13
|
weekStartDay?: number;
|
|
@@ -40,7 +40,7 @@ const notCurrentDayClass = clsx("text-base-300", "dark:text-base-600");
|
|
|
40
40
|
|
|
41
41
|
const contentClass = clsx("flex flex-col gap-1");
|
|
42
42
|
|
|
43
|
-
function CalendarBase<
|
|
43
|
+
function CalendarBase<TValue>(props: CalendarProps<TValue>) {
|
|
44
44
|
const [local, rest] = splitProps(props, [
|
|
45
45
|
"class",
|
|
46
46
|
"items",
|
|
@@ -71,7 +71,7 @@ function CalendarBase<T>(props: CalendarProps<T>) {
|
|
|
71
71
|
const getDate = local.getItemDate;
|
|
72
72
|
|
|
73
73
|
// 아이템을 날짜별로 그룹핑 (O(N))
|
|
74
|
-
const itemMap = new Map<number, { item:
|
|
74
|
+
const itemMap = new Map<number, { item: TValue; index: number }[]>();
|
|
75
75
|
for (let i = 0; i < items.length; i++) {
|
|
76
76
|
const date = getDate(items[i], i);
|
|
77
77
|
const key = date.tick;
|
|
@@ -84,10 +84,10 @@ function CalendarBase<T>(props: CalendarProps<T>) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
const firstDate = ym.getWeekSeqStartDate(weekStartDay(), minDaysInFirstWeek());
|
|
87
|
-
const result: { date: DateOnly; items: { item:
|
|
87
|
+
const result: { date: DateOnly; items: { item: TValue; index: number }[] }[][] = [];
|
|
88
88
|
|
|
89
89
|
for (let r = 0; r < 6; r++) {
|
|
90
|
-
const row: { date: DateOnly; items: { item:
|
|
90
|
+
const row: { date: DateOnly; items: { item: TValue; index: number }[] }[] = [];
|
|
91
91
|
for (let c = 0; c < 7; c++) {
|
|
92
92
|
const date = firstDate.addDays(r * 7 + c);
|
|
93
93
|
row.push({
|
|
@@ -7,7 +7,7 @@ export function isDataSheetColumnDef(value: unknown): value is DataSheetColumnDe
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/* eslint-disable solid/reactivity -- plain object 반환 패턴으로 reactive context 불필요 */
|
|
10
|
-
export function DataSheetColumn<
|
|
10
|
+
export function DataSheetColumn<TItem>(props: DataSheetColumnProps<TItem>): JSX.Element {
|
|
11
11
|
return {
|
|
12
12
|
__type: "sheet-column",
|
|
13
13
|
key: props.key,
|
|
@@ -7,7 +7,7 @@ export function normalizeHeader(header?: string | string[]): string[] {
|
|
|
7
7
|
return header;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export function buildHeaderTable<
|
|
10
|
+
export function buildHeaderTable<TItem>(columns: DataSheetColumnDef<TItem>[]): (HeaderDef | null)[][] {
|
|
11
11
|
if (columns.length === 0) return [];
|
|
12
12
|
|
|
13
13
|
const maxDepth = Math.max(...columns.map((c) => c.header.length));
|
|
@@ -91,11 +91,11 @@ function isSameGroup(padded: string[][], colA: number, colB: number, startRow: n
|
|
|
91
91
|
return true;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export function flattenTree<
|
|
95
|
-
items:
|
|
96
|
-
expandedItems:
|
|
97
|
-
getChildren?: (item:
|
|
98
|
-
): FlatItem<
|
|
94
|
+
export function flattenTree<TNode>(
|
|
95
|
+
items: TNode[],
|
|
96
|
+
expandedItems: TNode[],
|
|
97
|
+
getChildren?: (item: TNode, index: number) => TNode[] | undefined,
|
|
98
|
+
): FlatItem<TNode>[] {
|
|
99
99
|
if (!getChildren) {
|
|
100
100
|
return items.map((item, i) => ({
|
|
101
101
|
item,
|
|
@@ -105,10 +105,10 @@ export function flattenTree<T>(
|
|
|
105
105
|
}));
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
const result: FlatItem<
|
|
108
|
+
const result: FlatItem<TNode>[] = [];
|
|
109
109
|
let index = 0;
|
|
110
110
|
|
|
111
|
-
function walk(list:
|
|
111
|
+
function walk(list: TNode[], depth: number, parent?: TNode): void {
|
|
112
112
|
for (const item of list) {
|
|
113
113
|
const children = getChildren!(item, index);
|
|
114
114
|
const hasChildren = children != null && children.length > 0;
|
|
@@ -125,11 +125,14 @@ export function flattenTree<T>(
|
|
|
125
125
|
return result;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
export function collectAllExpandable<
|
|
129
|
-
|
|
128
|
+
export function collectAllExpandable<TItem>(
|
|
129
|
+
items: TItem[],
|
|
130
|
+
getChildren: (item: TItem, index: number) => TItem[] | undefined,
|
|
131
|
+
): TItem[] {
|
|
132
|
+
const result: TItem[] = [];
|
|
130
133
|
let index = 0;
|
|
131
134
|
|
|
132
|
-
function walk(list:
|
|
135
|
+
function walk(list: TItem[]): void {
|
|
133
136
|
for (const item of list) {
|
|
134
137
|
const children = getChildren(item, index);
|
|
135
138
|
index++;
|
|
@@ -144,12 +147,12 @@ export function collectAllExpandable<T>(items: T[], getChildren: (item: T, index
|
|
|
144
147
|
return result;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
export function applySorting<
|
|
150
|
+
export function applySorting<TItem>(items: TItem[], sorts: SortingDef[]): TItem[] {
|
|
148
151
|
if (sorts.length === 0) return items;
|
|
149
152
|
|
|
150
153
|
let result = [...items];
|
|
151
154
|
for (const sort of [...sorts].reverse()) {
|
|
152
|
-
const selector = (item:
|
|
155
|
+
const selector = (item: TItem) => objGetChainValue(item, sort.key) as string | number | undefined;
|
|
153
156
|
result = sort.desc ? result.orderByDesc(selector) : result.orderBy(selector);
|
|
154
157
|
}
|
|
155
158
|
return result;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { JSX } from "solid-js";
|
|
2
2
|
|
|
3
|
-
export interface DataSheetProps<
|
|
3
|
+
export interface DataSheetProps<TItem> {
|
|
4
4
|
// 데이터
|
|
5
|
-
items?:
|
|
5
|
+
items?: TItem[];
|
|
6
6
|
// 설정
|
|
7
7
|
persistKey?: string;
|
|
8
8
|
hideConfigBar?: boolean;
|
|
@@ -23,29 +23,29 @@ export interface DataSheetProps<T> {
|
|
|
23
23
|
|
|
24
24
|
// 선택
|
|
25
25
|
selectMode?: "single" | "multiple";
|
|
26
|
-
selectedItems?:
|
|
27
|
-
onSelectedItemsChange?: (items:
|
|
26
|
+
selectedItems?: TItem[];
|
|
27
|
+
onSelectedItemsChange?: (items: TItem[]) => void;
|
|
28
28
|
autoSelect?: "click";
|
|
29
|
-
isItemSelectable?: (item:
|
|
29
|
+
isItemSelectable?: (item: TItem) => boolean | string;
|
|
30
30
|
|
|
31
31
|
// 트리 확장
|
|
32
|
-
expandedItems?:
|
|
33
|
-
onExpandedItemsChange?: (items:
|
|
34
|
-
getChildren?: (item:
|
|
32
|
+
expandedItems?: TItem[];
|
|
33
|
+
onExpandedItemsChange?: (items: TItem[]) => void;
|
|
34
|
+
getChildren?: (item: TItem, index: number) => TItem[] | undefined;
|
|
35
35
|
|
|
36
36
|
// 셀 스타일
|
|
37
|
-
cellClass?: (item:
|
|
38
|
-
cellStyle?: (item:
|
|
37
|
+
cellClass?: (item: TItem, colKey: string) => string | undefined;
|
|
38
|
+
cellStyle?: (item: TItem, colKey: string) => string | undefined;
|
|
39
39
|
|
|
40
40
|
// 재정렬
|
|
41
|
-
onItemsReorder?: (event: DataSheetReorderEvent<
|
|
41
|
+
onItemsReorder?: (event: DataSheetReorderEvent<TItem>) => void;
|
|
42
42
|
|
|
43
43
|
// 기타
|
|
44
44
|
class?: string;
|
|
45
45
|
children: JSX.Element;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export interface DataSheetColumnProps<
|
|
48
|
+
export interface DataSheetColumnProps<TItem> {
|
|
49
49
|
key: string;
|
|
50
50
|
header?: string | string[];
|
|
51
51
|
headerContent?: () => JSX.Element;
|
|
@@ -59,11 +59,11 @@ export interface DataSheetColumnProps<T> {
|
|
|
59
59
|
class?: string;
|
|
60
60
|
sortable?: boolean;
|
|
61
61
|
resizable?: boolean;
|
|
62
|
-
children: (ctx: DataSheetCellContext<
|
|
62
|
+
children: (ctx: DataSheetCellContext<TItem>) => JSX.Element;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export interface DataSheetCellContext<
|
|
66
|
-
item:
|
|
65
|
+
export interface DataSheetCellContext<TItem> {
|
|
66
|
+
item: TItem;
|
|
67
67
|
index: number;
|
|
68
68
|
depth: number;
|
|
69
69
|
}
|
|
@@ -84,7 +84,7 @@ export interface DataSheetConfigColumn {
|
|
|
84
84
|
hidden?: boolean;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export interface DataSheetColumnDef<
|
|
87
|
+
export interface DataSheetColumnDef<TItem> {
|
|
88
88
|
__type: "sheet-column";
|
|
89
89
|
key: string;
|
|
90
90
|
header: string[];
|
|
@@ -99,7 +99,7 @@ export interface DataSheetColumnDef<T> {
|
|
|
99
99
|
class?: string;
|
|
100
100
|
sortable: boolean;
|
|
101
101
|
resizable: boolean;
|
|
102
|
-
cell: (ctx: DataSheetCellContext<
|
|
102
|
+
cell: (ctx: DataSheetCellContext<TItem>) => JSX.Element;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export interface HeaderDef {
|
|
@@ -114,21 +114,21 @@ export interface HeaderDef {
|
|
|
114
114
|
headerContent?: () => JSX.Element;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
export interface FlatItem<
|
|
118
|
-
item:
|
|
117
|
+
export interface FlatItem<TItem> {
|
|
118
|
+
item: TItem;
|
|
119
119
|
index: number;
|
|
120
120
|
depth: number;
|
|
121
121
|
hasChildren: boolean;
|
|
122
|
-
parent?:
|
|
122
|
+
parent?: TItem;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// 드래그 앤 드롭 위치
|
|
126
126
|
export type DataSheetDragPosition = "before" | "after" | "inside";
|
|
127
127
|
|
|
128
128
|
// 재정렬 이벤트
|
|
129
|
-
export interface DataSheetReorderEvent<
|
|
130
|
-
item:
|
|
131
|
-
targetItem:
|
|
129
|
+
export interface DataSheetReorderEvent<TItem> {
|
|
130
|
+
item: TItem;
|
|
131
|
+
targetItem: TItem;
|
|
132
132
|
position: DataSheetDragPosition;
|
|
133
133
|
}
|
|
134
134
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createContext, useContext } from "solid-js";
|
|
2
2
|
|
|
3
|
-
export interface DialogInstance<
|
|
4
|
-
close: (result?:
|
|
3
|
+
export interface DialogInstance<TResult> {
|
|
4
|
+
close: (result?: TResult) => void;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export const DialogInstanceContext = createContext<DialogInstance<unknown>>();
|
|
8
8
|
|
|
9
|
-
export function useDialogInstance<
|
|
10
|
-
return useContext(DialogInstanceContext) as DialogInstance<
|
|
9
|
+
export function useDialogInstance<TResult = undefined>(): DialogInstance<TResult> | undefined {
|
|
10
|
+
return useContext(DialogInstanceContext) as DialogInstance<TResult> | undefined;
|
|
11
11
|
}
|
|
@@ -4,9 +4,9 @@ import { createControllableSignal } from "../../../hooks/createControllableSigna
|
|
|
4
4
|
import { Checkbox } from "./Checkbox";
|
|
5
5
|
import type { CheckboxSize, CheckboxTheme } from "./Checkbox.styles";
|
|
6
6
|
|
|
7
|
-
interface CheckboxGroupContextValue<
|
|
8
|
-
value: () =>
|
|
9
|
-
toggle: (item:
|
|
7
|
+
interface CheckboxGroupContextValue<TValue> {
|
|
8
|
+
value: () => TValue[];
|
|
9
|
+
toggle: (item: TValue) => void;
|
|
10
10
|
disabled: () => boolean;
|
|
11
11
|
size: () => CheckboxSize | undefined;
|
|
12
12
|
theme: () => CheckboxTheme | undefined;
|
|
@@ -18,13 +18,13 @@ const CheckboxGroupContext = createContext<CheckboxGroupContextValue<any>>();
|
|
|
18
18
|
|
|
19
19
|
// --- CheckboxGroup.Item ---
|
|
20
20
|
|
|
21
|
-
interface CheckboxGroupItemProps<
|
|
22
|
-
value:
|
|
21
|
+
interface CheckboxGroupItemProps<TValue> {
|
|
22
|
+
value: TValue;
|
|
23
23
|
disabled?: boolean;
|
|
24
24
|
children?: JSX.Element;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function CheckboxGroupItemInner<
|
|
27
|
+
function CheckboxGroupItemInner<TValue>(props: CheckboxGroupItemProps<TValue>) {
|
|
28
28
|
const ctx = useContext(CheckboxGroupContext);
|
|
29
29
|
if (!ctx) throw new Error("CheckboxGroup.Item은 CheckboxGroup 내부에서만 사용할 수 있습니다");
|
|
30
30
|
|
|
@@ -47,9 +47,9 @@ function CheckboxGroupItemInner<T>(props: CheckboxGroupItemProps<T>) {
|
|
|
47
47
|
|
|
48
48
|
// --- CheckboxGroup ---
|
|
49
49
|
|
|
50
|
-
interface CheckboxGroupProps<
|
|
51
|
-
value?:
|
|
52
|
-
onValueChange?: (value:
|
|
50
|
+
interface CheckboxGroupProps<TValue> {
|
|
51
|
+
value?: TValue[];
|
|
52
|
+
onValueChange?: (value: TValue[]) => void;
|
|
53
53
|
disabled?: boolean;
|
|
54
54
|
size?: CheckboxSize;
|
|
55
55
|
theme?: CheckboxTheme;
|
|
@@ -61,7 +61,7 @@ interface CheckboxGroupProps<T> {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
interface CheckboxGroupComponent {
|
|
64
|
-
<
|
|
64
|
+
<TValue = unknown>(props: CheckboxGroupProps<TValue>): JSX.Element;
|
|
65
65
|
Item: typeof CheckboxGroupItemInner;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -4,9 +4,9 @@ import { createControllableSignal } from "../../../hooks/createControllableSigna
|
|
|
4
4
|
import { Radio } from "./Radio";
|
|
5
5
|
import type { CheckboxSize, CheckboxTheme } from "./Checkbox.styles";
|
|
6
6
|
|
|
7
|
-
interface RadioGroupContextValue<
|
|
8
|
-
value: () =>
|
|
9
|
-
select: (item:
|
|
7
|
+
interface RadioGroupContextValue<TValue> {
|
|
8
|
+
value: () => TValue | undefined;
|
|
9
|
+
select: (item: TValue) => void;
|
|
10
10
|
disabled: () => boolean;
|
|
11
11
|
size: () => CheckboxSize | undefined;
|
|
12
12
|
theme: () => CheckboxTheme | undefined;
|
|
@@ -18,13 +18,13 @@ const RadioGroupContext = createContext<RadioGroupContextValue<any>>();
|
|
|
18
18
|
|
|
19
19
|
// --- RadioGroup.Item ---
|
|
20
20
|
|
|
21
|
-
interface RadioGroupItemProps<
|
|
22
|
-
value:
|
|
21
|
+
interface RadioGroupItemProps<TValue> {
|
|
22
|
+
value: TValue;
|
|
23
23
|
disabled?: boolean;
|
|
24
24
|
children?: JSX.Element;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function RadioGroupItemInner<
|
|
27
|
+
function RadioGroupItemInner<TValue>(props: RadioGroupItemProps<TValue>) {
|
|
28
28
|
const ctx = useContext(RadioGroupContext);
|
|
29
29
|
if (!ctx) throw new Error("RadioGroup.Item은 RadioGroup 내부에서만 사용할 수 있습니다");
|
|
30
30
|
|
|
@@ -47,9 +47,9 @@ function RadioGroupItemInner<T>(props: RadioGroupItemProps<T>) {
|
|
|
47
47
|
|
|
48
48
|
// --- RadioGroup ---
|
|
49
49
|
|
|
50
|
-
interface RadioGroupProps<
|
|
51
|
-
value?:
|
|
52
|
-
onValueChange?: (value:
|
|
50
|
+
interface RadioGroupProps<TValue> {
|
|
51
|
+
value?: TValue;
|
|
52
|
+
onValueChange?: (value: TValue) => void;
|
|
53
53
|
disabled?: boolean;
|
|
54
54
|
size?: CheckboxSize;
|
|
55
55
|
theme?: CheckboxTheme;
|
|
@@ -61,7 +61,7 @@ interface RadioGroupProps<T> {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
interface RadioGroupComponent {
|
|
64
|
-
<
|
|
64
|
+
<TValue = unknown>(props: RadioGroupProps<TValue>): JSX.Element;
|
|
65
65
|
Item: typeof RadioGroupItemInner;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -28,8 +28,8 @@ const noResultsClass = clsx("px-3 py-2", textMuted);
|
|
|
28
28
|
/**
|
|
29
29
|
* Combobox 아이템 렌더링 템플릿
|
|
30
30
|
*/
|
|
31
|
-
interface ComboboxItemTemplateProps<
|
|
32
|
-
children: (item:
|
|
31
|
+
interface ComboboxItemTemplateProps<TItem> {
|
|
32
|
+
children: (item: TItem, index: number) => JSX.Element;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// 템플릿 함수를 저장하는 전역 WeakMap
|
|
@@ -46,15 +46,15 @@ const ComboboxItemTemplate = <T,>(props: ComboboxItemTemplateProps<T>) => (
|
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
// Props 정의
|
|
49
|
-
export interface ComboboxProps<
|
|
49
|
+
export interface ComboboxProps<TValue = unknown> {
|
|
50
50
|
/** 현재 선택된 값 */
|
|
51
|
-
value?:
|
|
51
|
+
value?: TValue;
|
|
52
52
|
|
|
53
53
|
/** 값 변경 콜백 */
|
|
54
|
-
onValueChange?: (value:
|
|
54
|
+
onValueChange?: (value: TValue) => void;
|
|
55
55
|
|
|
56
56
|
/** 아이템 로드 함수 (필수) */
|
|
57
|
-
loadItems: (query: string) => Promise<
|
|
57
|
+
loadItems: (query: string) => Promise<TValue[]>;
|
|
58
58
|
|
|
59
59
|
/** 디바운스 딜레이 (기본값: 300ms) */
|
|
60
60
|
debounceMs?: number;
|
|
@@ -63,10 +63,10 @@ export interface ComboboxProps<T = unknown> {
|
|
|
63
63
|
allowCustomValue?: boolean;
|
|
64
64
|
|
|
65
65
|
/** 커스텀 값 파싱 함수 */
|
|
66
|
-
parseCustomValue?: (text: string) =>
|
|
66
|
+
parseCustomValue?: (text: string) => TValue;
|
|
67
67
|
|
|
68
68
|
/** 선택된 값을 렌더링하는 함수 (필수) */
|
|
69
|
-
renderValue: (value:
|
|
69
|
+
renderValue: (value: TValue) => JSX.Element;
|
|
70
70
|
|
|
71
71
|
/** 비활성화 */
|
|
72
72
|
disabled?: boolean;
|
|
@@ -94,7 +94,7 @@ export interface ComboboxProps<T = unknown> {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
interface ComboboxComponent {
|
|
97
|
-
<
|
|
97
|
+
<TValue = unknown>(props: ComboboxProps<TValue>): JSX.Element;
|
|
98
98
|
Item: typeof ComboboxItem;
|
|
99
99
|
ItemTemplate: typeof ComboboxItemTemplate;
|
|
100
100
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createContext, useContext } from "solid-js";
|
|
2
2
|
|
|
3
|
-
export interface ComboboxContextValue<
|
|
3
|
+
export interface ComboboxContextValue<TValue = unknown> {
|
|
4
4
|
/** 값이 선택되어 있는지 확인 */
|
|
5
|
-
isSelected: (value:
|
|
5
|
+
isSelected: (value: TValue) => boolean;
|
|
6
6
|
|
|
7
7
|
/** 값 선택 */
|
|
8
|
-
selectValue: (value:
|
|
8
|
+
selectValue: (value: TValue) => void;
|
|
9
9
|
|
|
10
10
|
/** 드롭다운 닫기 */
|
|
11
11
|
closeDropdown: () => void;
|
|
@@ -13,10 +13,10 @@ export interface ComboboxContextValue<T = unknown> {
|
|
|
13
13
|
|
|
14
14
|
export const ComboboxContext = createContext<ComboboxContextValue>();
|
|
15
15
|
|
|
16
|
-
export function useComboboxContext<
|
|
16
|
+
export function useComboboxContext<TValue = unknown>(): ComboboxContextValue<TValue> {
|
|
17
17
|
const context = useContext(ComboboxContext);
|
|
18
18
|
if (!context) {
|
|
19
19
|
throw new Error("useComboboxContext는 Combobox 컴포넌트 내부에서만 사용할 수 있습니다");
|
|
20
20
|
}
|
|
21
|
-
return context as ComboboxContextValue<
|
|
21
|
+
return context as ComboboxContextValue<TValue>;
|
|
22
22
|
}
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
|
|
12
12
|
void ripple;
|
|
13
13
|
|
|
14
|
-
export interface ComboboxItemProps<
|
|
14
|
+
export interface ComboboxItemProps<TValue = unknown> extends Omit<
|
|
15
15
|
JSX.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
16
16
|
"value" | "onClick"
|
|
17
17
|
> {
|
|
18
18
|
/** 아이템의 값 */
|
|
19
|
-
value:
|
|
19
|
+
value: TValue;
|
|
20
20
|
|
|
21
21
|
/** 비활성화 */
|
|
22
22
|
disabled?: boolean;
|
|
@@ -65,8 +65,8 @@ const SelectHeader: ParentComponent = (props) => <div data-select-header>{props.
|
|
|
65
65
|
*
|
|
66
66
|
* 함수 참조를 저장하기 위해 전역 Map 사용
|
|
67
67
|
*/
|
|
68
|
-
interface SelectItemTemplateProps<
|
|
69
|
-
children: (item:
|
|
68
|
+
interface SelectItemTemplateProps<TValue> {
|
|
69
|
+
children: (item: TValue, index: number, depth: number) => JSX.Element;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// 템플릿 함수를 저장하는 전역 Map (WeakMap 사용하여 메모리 누수 방지)
|
|
@@ -109,15 +109,15 @@ interface SelectCommonProps {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// 단일 선택 Props
|
|
112
|
-
interface SelectSingleBaseProps<
|
|
112
|
+
interface SelectSingleBaseProps<TValue> extends SelectCommonProps {
|
|
113
113
|
/** 다중 선택 모드 */
|
|
114
114
|
multiple?: false;
|
|
115
115
|
|
|
116
116
|
/** 현재 선택된 값 */
|
|
117
|
-
value?:
|
|
117
|
+
value?: TValue;
|
|
118
118
|
|
|
119
119
|
/** 값 변경 콜백 */
|
|
120
|
-
onValueChange?: (value:
|
|
120
|
+
onValueChange?: (value: TValue) => void;
|
|
121
121
|
|
|
122
122
|
/** 다중 선택 시 표시 방향 (단일 선택에서는 사용 안 함) */
|
|
123
123
|
multiDisplayDirection?: never;
|
|
@@ -127,15 +127,15 @@ interface SelectSingleBaseProps<T> extends SelectCommonProps {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// 다중 선택 Props
|
|
130
|
-
interface SelectMultipleBaseProps<
|
|
130
|
+
interface SelectMultipleBaseProps<TValue> extends SelectCommonProps {
|
|
131
131
|
/** 다중 선택 모드 */
|
|
132
132
|
multiple: true;
|
|
133
133
|
|
|
134
134
|
/** 현재 선택된 값 */
|
|
135
|
-
value?:
|
|
135
|
+
value?: TValue[];
|
|
136
136
|
|
|
137
137
|
/** 값 변경 콜백 */
|
|
138
|
-
onValueChange?: (value:
|
|
138
|
+
onValueChange?: (value: TValue[]) => void;
|
|
139
139
|
|
|
140
140
|
/** 다중 선택 시 표시 방향 */
|
|
141
141
|
multiDisplayDirection?: "horizontal" | "vertical";
|
|
@@ -145,29 +145,29 @@ interface SelectMultipleBaseProps<T> extends SelectCommonProps {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// items 방식
|
|
148
|
-
interface SelectWithItemsPropsBase<
|
|
149
|
-
items:
|
|
150
|
-
getChildren?: (item:
|
|
151
|
-
renderValue?: (value:
|
|
148
|
+
interface SelectWithItemsPropsBase<TValue> {
|
|
149
|
+
items: TValue[];
|
|
150
|
+
getChildren?: (item: TValue, index: number, depth: number) => TValue[] | undefined;
|
|
151
|
+
renderValue?: (value: TValue) => JSX.Element;
|
|
152
152
|
children?: JSX.Element;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// children 방식
|
|
156
|
-
interface SelectWithChildrenPropsBase<
|
|
156
|
+
interface SelectWithChildrenPropsBase<TValue> {
|
|
157
157
|
items?: never;
|
|
158
158
|
getChildren?: never;
|
|
159
|
-
renderValue: (value:
|
|
159
|
+
renderValue: (value: TValue) => JSX.Element;
|
|
160
160
|
children: JSX.Element;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export type SelectProps<
|
|
164
|
-
| (SelectSingleBaseProps<
|
|
165
|
-
| (SelectSingleBaseProps<
|
|
166
|
-
| (SelectMultipleBaseProps<
|
|
167
|
-
| (SelectMultipleBaseProps<
|
|
163
|
+
export type SelectProps<TValue = unknown> =
|
|
164
|
+
| (SelectSingleBaseProps<TValue> & SelectWithItemsPropsBase<TValue>)
|
|
165
|
+
| (SelectSingleBaseProps<TValue> & SelectWithChildrenPropsBase<TValue>)
|
|
166
|
+
| (SelectMultipleBaseProps<TValue> & SelectWithItemsPropsBase<TValue>)
|
|
167
|
+
| (SelectMultipleBaseProps<TValue> & SelectWithChildrenPropsBase<TValue>);
|
|
168
168
|
|
|
169
169
|
interface SelectComponent {
|
|
170
|
-
<
|
|
170
|
+
<TValue = unknown>(props: SelectProps<TValue>): JSX.Element;
|
|
171
171
|
Item: typeof SelectItem;
|
|
172
172
|
Action: typeof SelectAction;
|
|
173
173
|
Header: typeof SelectHeader;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createContext, useContext, type Accessor } from "solid-js";
|
|
2
2
|
|
|
3
|
-
export interface SelectContextValue<
|
|
3
|
+
export interface SelectContextValue<TValue = unknown> {
|
|
4
4
|
/** 다중 선택 모드 여부 */
|
|
5
5
|
multiple: Accessor<boolean>;
|
|
6
6
|
|
|
7
7
|
/** 값이 선택되어 있는지 확인 */
|
|
8
|
-
isSelected: (value:
|
|
8
|
+
isSelected: (value: TValue) => boolean;
|
|
9
9
|
|
|
10
10
|
/** 값 선택/해제 토글 */
|
|
11
|
-
toggleValue: (value:
|
|
11
|
+
toggleValue: (value: TValue) => void;
|
|
12
12
|
|
|
13
13
|
/** 드롭다운 닫기 */
|
|
14
14
|
closeDropdown: () => void;
|
|
@@ -16,10 +16,10 @@ export interface SelectContextValue<T = unknown> {
|
|
|
16
16
|
|
|
17
17
|
export const SelectContext = createContext<SelectContextValue>();
|
|
18
18
|
|
|
19
|
-
export function useSelectContext<
|
|
19
|
+
export function useSelectContext<TValue = unknown>(): SelectContextValue<TValue> {
|
|
20
20
|
const context = useContext(SelectContext);
|
|
21
21
|
if (!context) {
|
|
22
22
|
throw new Error("useSelectContext는 Select 컴포넌트 내부에서만 사용할 수 있습니다");
|
|
23
23
|
}
|
|
24
|
-
return context as SelectContextValue<
|
|
24
|
+
return context as SelectContextValue<TValue>;
|
|
25
25
|
}
|