@simplysm/solid 13.0.40 → 13.0.42
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/data/permission-table/PermissionTable.d.ts +5 -11
- package/dist/components/data/permission-table/PermissionTable.d.ts.map +1 -1
- package/dist/components/data/permission-table/PermissionTable.js.map +1 -1
- package/dist/components/form-control/Button.js +5 -1
- package/dist/components/form-control/Button.js.map +1 -1
- package/dist/components/layout/sidebar/Sidebar.d.ts +1 -1
- package/dist/components/layout/sidebar/Sidebar.d.ts.map +1 -1
- package/dist/components/layout/sidebar/SidebarMenu.d.ts +2 -8
- package/dist/components/layout/sidebar/SidebarMenu.d.ts.map +1 -1
- package/dist/components/layout/sidebar/SidebarMenu.js.map +1 -1
- package/dist/helpers/createAppStructure.d.ts +22 -4
- package/dist/helpers/createAppStructure.d.ts.map +1 -1
- package/dist/helpers/createAppStructure.js +126 -27
- package/dist/helpers/createAppStructure.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/data/permission-table/PermissionTable.tsx +25 -35
- package/src/components/form-control/Button.tsx +1 -1
- package/src/components/layout/sidebar/Sidebar.tsx +1 -1
- package/src/components/layout/sidebar/SidebarMenu.tsx +8 -15
- package/src/helpers/createAppStructure.ts +196 -36
- package/src/index.ts +3 -0
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import type { JSX } from "solid-js";
|
|
2
2
|
import { type Component } from "solid-js";
|
|
3
|
-
|
|
4
|
-
title: string;
|
|
5
|
-
href?: string;
|
|
6
|
-
modules?: TModule[];
|
|
7
|
-
perms?: string[];
|
|
8
|
-
children?: PermissionItem<TModule>[];
|
|
9
|
-
}
|
|
3
|
+
import type { AppPerm } from "../../../helpers/createAppStructure";
|
|
10
4
|
export interface PermissionTableProps<TModule = string> {
|
|
11
|
-
items?:
|
|
5
|
+
items?: AppPerm<TModule>[];
|
|
12
6
|
value?: Record<string, boolean>;
|
|
13
7
|
onValueChange?: (value: Record<string, boolean>) => void;
|
|
14
8
|
modules?: TModule[];
|
|
@@ -17,10 +11,10 @@ export interface PermissionTableProps<TModule = string> {
|
|
|
17
11
|
style?: JSX.CSSProperties;
|
|
18
12
|
}
|
|
19
13
|
/** 트리에서 모든 고유 perm 타입을 수집 */
|
|
20
|
-
export declare function collectAllPerms<TModule>(items:
|
|
14
|
+
export declare function collectAllPerms<TModule>(items: AppPerm<TModule>[]): string[];
|
|
21
15
|
/** modules 필터: 활성 모듈과 교차가 있는 아이템만 남김 */
|
|
22
|
-
export declare function filterByModules<TModule>(items:
|
|
16
|
+
export declare function filterByModules<TModule>(items: AppPerm<TModule>[], modules: TModule[] | undefined): AppPerm<TModule>[];
|
|
23
17
|
/** 체크 변경 시 cascading 처리 */
|
|
24
|
-
export declare function changePermCheck<TModule>(value: Record<string, boolean>, item:
|
|
18
|
+
export declare function changePermCheck<TModule>(value: Record<string, boolean>, item: AppPerm<TModule>, perm: string, checked: boolean): Record<string, boolean>;
|
|
25
19
|
export declare const PermissionTable: Component<PermissionTableProps>;
|
|
26
20
|
//# sourceMappingURL=PermissionTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionTable.d.ts","sourceRoot":"","sources":["..\\..\\..\\..\\src\\components\\data\\permission-table\\PermissionTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,KAAK,SAAS,EAQf,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"PermissionTable.d.ts","sourceRoot":"","sources":["..\\..\\..\\..\\src\\components\\data\\permission-table\\PermissionTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,KAAK,SAAS,EAQf,MAAM,UAAU,CAAC;AAMlB,OAAO,KAAK,EAAE,OAAO,EAAE,MA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YAAM0C,UAAU;YAAOC,WAAW;YAAKvD,UAClFwD,SAAQ;AACR,oBAAM5D,OAAO4D,IAAI5D;AACjB,qBAAAoD,kBACGpE,MAAI;gBAAA,IAAC0F,OAAI;AAAA,yBAAE5C,cAAc9B,MAAMgB,IAAI;gBAAC;gBAAA,IAAAZ,WAAA;AAAA,yBAAAgD,kBAClC/D,UAAQ;oBAAA,IACP0B,QAAK;AAAA,6BAAEc,mBAAmB7B,MAAMgB,MAAMyB,aAAa,CAAC;oBAAC;oBACrDO,eAAgB/B,aAAY6B,iBAAiB9C,MAAMgB,MAAMC,OAAO;oBAAC,IACjE0D,WAAQ;AAAA,6BAAEvC,MAAMuC,YAAY5C,eAAe/B,MAAMgB,MAAMyB,aAAa,CAAC;oBAAC;oBACtEmC,OAAK;kBAAA,CAAA;gBAAA;cAAA,CAAA;YAIb;UAAC,CAAA;QAEJ,CAAA,CAAA;MAAA;IAAA,CAAA,CAAA;AAAAC,aAAAC,SAAA;AAAA,UAAAC,MA1C2B5F,QAAQiD,MAAM4C,KAAK,GAACC,OAAS7C,MAAM8C;AAAKH,cAAAD,IAAAK,KAAAlB,YAAAhB,MAAA6B,IAAAK,IAAAJ,GAAA;AAAAD,UAAAM,IAAAC,QAAApC,MAAAgC,MAAAH,IAAAM,CAAA;AAAA,aAAAN;IAAA,GAAA;MAAAK,GAAAvE;MAAAwE,GAAAxE;IAAA,CAAA;AAAA,WAAAqC;EAAA,GAAA;AA+C9E;",
|
|
5
5
|
"names": ["createEffect", "createMemo", "createSignal", "For", "on", "Show", "splitProps", "clsx", "twMerge", "DataSheet", "Checkbox", "borderDefault", "titleCellClass", "indentGuideWrapperClass", "indentGuideLineClass", "collectAllPerms", "items", "set", "Set", "walk", "list", "item", "perms", "p", "add", "children", "filterByModules", "modules", "length", "result", "some", "m", "includes", "undefined", "push", "changePermCheck", "value", "perm", "checked", "apply", "target", "href", "permIndex", "indexOf", "basePerm", "baseOff", "i", "child", "isItemVisible", "collectVisiblePerms", "isGroupPermChecked", "hasPermInTree", "isPermDisabled", "collectExpandable", "getChildren", "PermissionTable", "props", "local", "visibleItems", "filter", "filtered", "allPerms", "currentValue", "getAllExpandable", "expandedItems", "setExpandedItems", "defer", "handlePermChange", "newValue", "onValueChange", "_el$", "_tmpl$", "_$insert", "_$createComponent", "onExpandedItemsChange", "hideConfigBar", "Column", "key", "header", "sortable", "resizable", "ctx", "_el$2", "_tmpl$2", "_el$3", "firstChild", "_$className", "each", "Array", "from", "depth", "_el$4", "_tmpl$3", "_el$5", "title", "when", "disabled", "inset", "_$effect", "_p$", "_v$", "class", "_v$2", "style", "e", "t", "_$style"]
|
|
6
6
|
}
|
|
@@ -13,7 +13,11 @@ import { themeTokens, disabledOpacity } from "../../styles/tokens.styles.js";
|
|
|
13
13
|
void ripple;
|
|
14
14
|
const baseClass = clsx("inline-flex items-center", "px-2 py-1", "font-bold", "justify-center", "text-center", "cursor-pointer", "transition", "rounded", "focus:outline-none", "focus-visible:ring-2", "border border-transparent", "min-w-8");
|
|
15
15
|
const themeClasses = Object.fromEntries(Object.entries(themeTokens).map(([theme, t]) => [theme, {
|
|
16
|
-
solid: clsx(
|
|
16
|
+
solid: clsx(
|
|
17
|
+
t.solid,
|
|
18
|
+
t.solidHover
|
|
19
|
+
/*, "shadow-md hover:shadow-lg"*/
|
|
20
|
+
),
|
|
17
21
|
outline: clsx("bg-transparent", t.hoverBg, t.text, t.border),
|
|
18
22
|
ghost: clsx("bg-transparent", t.hoverBg, t.text)
|
|
19
23
|
}]));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/form-control/Button.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;AAAA,SAAyCA,kBAAkB;AAC3D,OAAOC,UAAU;AACjB,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,SACEC,aAGAC,uBACK;AAGP,KAAKF;AAML,MAAMG,YAAYL,KAChB,4BACA,aACA,aACA,k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,MAAMO,KACR;EACF;AAEA,UAAA,MAAA;AAAA,QAAAC,OAAAC,OAAA;AAAAC,UAIQlC,QAAMgC,MAAA,MAAE,CAACR,MAAMM,QAAQ;AAAAK,aAAAH,MAAAI,aAFvBX,MAAI;MAAA,eAAA;MAAA,IAGRY,OAAI;AAAA,eAAEb,MAAMa,QAAQ;MAAQ;MAAA,KAAA,OAAA,IAAA;AAAA,eACrBX,aAAa;MAAC;MAAA,IACrBI,WAAQ;AAAA,eAAEN,MAAMM;MAAQ;IAAA,CAAA,GAAA,OAAA,IAAA;AAAAQ,aAAAN,MAAA,MAEvBR,MAAMe,QAAQ;AAAA,WAAAP;EAAA,GAAA;AAGrB;",
|
|
5
5
|
"names": ["splitProps", "clsx", "twMerge", "ripple", "themeTokens", "disabledOpacity", "baseClass", "themeClasses", "Object", "fromEntries", "entries", "map", "theme", "t", "solid", "solidHover", "outline", "hoverBg", "text", "border", "ghost", "sizeClasses", "sm", "lg", "xl", "Button", "props", "local", "rest", "getClassName", "variant", "size", "inset", "disabled", "class", "_el$", "_tmpl$", "_$use", "_$spread", "_$mergeProps", "type", "_$insert", "children"]
|
|
6
6
|
}
|
|
@@ -3,7 +3,7 @@ import { SidebarContainer } from "./SidebarContainer";
|
|
|
3
3
|
import { SidebarMenu } from "./SidebarMenu";
|
|
4
4
|
import { SidebarUser } from "./SidebarUser";
|
|
5
5
|
export type { SidebarContainerProps } from "./SidebarContainer";
|
|
6
|
-
export type {
|
|
6
|
+
export type { SidebarMenuProps } from "./SidebarMenu";
|
|
7
7
|
export type { SidebarUserMenu, SidebarUserProps } from "./SidebarUser";
|
|
8
8
|
export interface SidebarProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
9
9
|
children: JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.d.ts","sourceRoot":"","sources":["..\\..\\..\\..\\src\\components\\layout\\sidebar\\Sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,eAAe,EAA0B,MAAM,UAAU,CAAC;AAMlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"Sidebar.d.ts","sourceRoot":"","sources":["..\\..\\..\\..\\src\\components\\layout\\sidebar\\Sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,eAAe,EAA0B,MAAM,UAAU,CAAC;AAMlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAuBvE,MAAM,WAAW,YAAa,SAAQ,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC;IACnE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,UAAU,gBAAiB,SAAQ,eAAe,CAAC,YAAY,CAAC;IAC9D,SAAS,EAAE,OAAO,gBAAgB,CAAC;IACnC,IAAI,EAAE,OAAO,WAAW,CAAC;IACzB,IAAI,EAAE,OAAO,WAAW,CAAC;CAC1B;AAwCD,eAAO,MAAM,OAAO,EAAkB,gBAAgB,CAAC"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { type Component, type JSX } from "solid-js";
|
|
2
|
-
import type {
|
|
3
|
-
export interface SidebarMenuItem {
|
|
4
|
-
title: string;
|
|
5
|
-
href?: string;
|
|
6
|
-
icon?: Component<IconProps>;
|
|
7
|
-
children?: SidebarMenuItem[];
|
|
8
|
-
}
|
|
2
|
+
import type { AppMenu } from "../../../helpers/createAppStructure";
|
|
9
3
|
export interface SidebarMenuProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
10
4
|
/**
|
|
11
5
|
* 메뉴 아이템 배열
|
|
12
6
|
*/
|
|
13
|
-
menus:
|
|
7
|
+
menus: AppMenu[];
|
|
14
8
|
}
|
|
15
9
|
/**
|
|
16
10
|
* 사이드바 메뉴 컴포넌트
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarMenu.d.ts","sourceRoot":"","sources":["..\\..\\..\\..\\src\\components\\layout\\sidebar\\SidebarMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,GAAG,EAUT,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"SidebarMenu.d.ts","sourceRoot":"","sources":["..\\..\\..\\..\\src\\components\\layout\\sidebar\\SidebarMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,GAAG,EAUT,MAAM,UAAU,CAAC;AAKlB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAgBnE,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5F;;OAEG;IACH,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB;AASD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,gBAAgB,CA4CnD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/layout/sidebar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;IAAA;EAAA,CAAA;AAK/E;",
|
|
5
5
|
"names": ["For", "Show", "splitProps", "createSignal", "createMemo", "createEffect", "createContext", "useContext", "useLocation", "useNavigate", "clsx", "twMerge", "Icon", "List", "ListItem", "headerClass", "MenuContext", "SidebarMenu", "props", "local", "rest", "location", "findSelectedPath", "menus", "pathname", "path", "menu", "currentPath", "href", "children", "found", "initialOpenItems", "selectedPath", "Set", "slice", "getClassName", "class", "_$createComponent", "Provider", "value", "_el$", "_tmpl$", "_el$2", "firstChild", "_$spread", "_$mergeProps", "_$className", "_$insert", "inset", "each", "MenuItem", "size", "navigate", "menuContext", "hasChildren", "undefined", "length", "isExternalLink", "includes", "isSelected", "shouldBeOpen", "has", "open", "setOpen", "handleClick", "v", "window", "selected", "onOpenChange", "onClick", "when", "icon", "_el$3", "_tmpl$2", "title", "Children", "child"]
|
|
6
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Accessor } from "solid-js";
|
|
2
2
|
import type { Component } from "solid-js";
|
|
3
3
|
import type { IconProps } from "@tabler/icons-solidjs";
|
|
4
|
-
import type { SidebarMenuItem } from "../components/layout/sidebar/SidebarMenu";
|
|
5
4
|
export interface AppStructureGroupItem<TModule> {
|
|
6
5
|
code: string;
|
|
7
6
|
title: string;
|
|
@@ -29,6 +28,24 @@ export interface AppStructureSubPerm<TModule> {
|
|
|
29
28
|
requiredModules?: TModule[];
|
|
30
29
|
perms: ("use" | "edit")[];
|
|
31
30
|
}
|
|
31
|
+
export interface AppMenu {
|
|
32
|
+
title: string;
|
|
33
|
+
href?: string;
|
|
34
|
+
icon?: Component<IconProps>;
|
|
35
|
+
children?: AppMenu[];
|
|
36
|
+
}
|
|
37
|
+
export interface AppPerm<TModule = string> {
|
|
38
|
+
title: string;
|
|
39
|
+
href?: string;
|
|
40
|
+
modules?: TModule[];
|
|
41
|
+
perms?: string[];
|
|
42
|
+
children?: AppPerm<TModule>[];
|
|
43
|
+
}
|
|
44
|
+
export interface AppFlatPerm<TModule = string> {
|
|
45
|
+
titleChain: string[];
|
|
46
|
+
code: string;
|
|
47
|
+
modulesChain: TModule[][];
|
|
48
|
+
}
|
|
32
49
|
export interface AppRoute {
|
|
33
50
|
path: string;
|
|
34
51
|
component: Component;
|
|
@@ -39,10 +56,11 @@ export interface AppFlatMenu {
|
|
|
39
56
|
}
|
|
40
57
|
export interface AppStructure<TModule> {
|
|
41
58
|
items: AppStructureItem<TModule>[];
|
|
42
|
-
|
|
43
|
-
usableMenus: Accessor<
|
|
59
|
+
usableRoutes: Accessor<AppRoute[]>;
|
|
60
|
+
usableMenus: Accessor<AppMenu[]>;
|
|
44
61
|
usableFlatMenus: Accessor<AppFlatMenu[]>;
|
|
45
|
-
|
|
62
|
+
usablePerms: Accessor<AppPerm<TModule>[]>;
|
|
63
|
+
flatPerms: AppFlatPerm<TModule>[];
|
|
46
64
|
getTitleChainByHref(href: string): string[];
|
|
47
65
|
}
|
|
48
66
|
export declare function createAppStructure<TModule>(opts: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAppStructure.d.ts","sourceRoot":"","sources":["..\\..\\src\\helpers\\createAppStructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAA0B,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"createAppStructure.d.ts","sourceRoot":"","sources":["..\\..\\src\\helpers\\createAppStructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAA0B,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,MAAM,WAAW,qBAAqB,CAAC,OAAO;IAC5C,IAAI,EAAE,MAA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E,GAAG,SAAS,CAAC,CAAC;IAChD,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAChD,GAAG,YAAY,CAAC,OAAO,CAAC,CA0DxB"}
|
|
@@ -12,27 +12,24 @@ function checkModules(modules, requiredModules, usableModules) {
|
|
|
12
12
|
}
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function buildUsableRoutes(items, routeBasePath, permBasePath, usableModules, permRecord) {
|
|
16
|
+
var _a;
|
|
17
|
+
const result = [];
|
|
16
18
|
for (const item of items) {
|
|
17
|
-
|
|
19
|
+
if (!checkModules(item.modules, item.requiredModules, usableModules)) continue;
|
|
20
|
+
const routePath = routeBasePath + "/" + item.code;
|
|
21
|
+
const permPath = permBasePath + "/" + item.code;
|
|
18
22
|
if (isGroupItem(item)) {
|
|
19
|
-
|
|
23
|
+
result.push(
|
|
24
|
+
...buildUsableRoutes(item.children, routePath, permPath, usableModules, permRecord)
|
|
25
|
+
);
|
|
20
26
|
} else if (item.component !== void 0) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
27
|
+
if (permRecord !== void 0 && ((_a = item.perms) == null ? void 0 : _a.includes("use")) && !permRecord[permPath + "/use"])
|
|
28
|
+
continue;
|
|
29
|
+
result.push({ path: routePath, component: item.component });
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
|
-
|
|
28
|
-
function extractRoutes(items) {
|
|
29
|
-
const routes = [];
|
|
30
|
-
for (const top of items) {
|
|
31
|
-
if (isGroupItem(top)) {
|
|
32
|
-
collectRoutes(top.children, [], routes);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return routes;
|
|
32
|
+
return result;
|
|
36
33
|
}
|
|
37
34
|
function buildMenus(items, basePath, usableModules, permRecord) {
|
|
38
35
|
var _a;
|
|
@@ -47,7 +44,7 @@ function buildMenus(items, basePath, usableModules, permRecord) {
|
|
|
47
44
|
}
|
|
48
45
|
} else {
|
|
49
46
|
if (item.isNotMenu) continue;
|
|
50
|
-
if (((_a = item.perms) == null ? void 0 : _a.includes("use")) && !permRecord[href + "/use"]) continue;
|
|
47
|
+
if (((_a = item.perms) == null ? void 0 : _a.includes("use")) && !(permRecord == null ? void 0 : permRecord[href + "/use"])) continue;
|
|
51
48
|
result.push({ title: item.title, href, icon: item.icon });
|
|
52
49
|
}
|
|
53
50
|
}
|
|
@@ -65,6 +62,84 @@ function flattenMenus(menus, titleChain = []) {
|
|
|
65
62
|
}
|
|
66
63
|
return result;
|
|
67
64
|
}
|
|
65
|
+
function buildPerms(items, basePath, usableModules) {
|
|
66
|
+
var _a;
|
|
67
|
+
const result = [];
|
|
68
|
+
for (const item of items) {
|
|
69
|
+
if (!checkModules(item.modules, item.requiredModules, usableModules)) continue;
|
|
70
|
+
const href = basePath + "/" + item.code;
|
|
71
|
+
if (isGroupItem(item)) {
|
|
72
|
+
const children = buildPerms(item.children, href, usableModules);
|
|
73
|
+
result.push({
|
|
74
|
+
title: item.title,
|
|
75
|
+
modules: item.modules,
|
|
76
|
+
children
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
result.push({
|
|
80
|
+
title: item.title,
|
|
81
|
+
href,
|
|
82
|
+
modules: item.modules,
|
|
83
|
+
perms: item.perms,
|
|
84
|
+
children: (_a = item.subPerms) == null ? void 0 : _a.filter((sp) => checkModules(sp.modules, sp.requiredModules, usableModules)).map((sp) => ({
|
|
85
|
+
title: sp.title,
|
|
86
|
+
href: href + "/" + sp.code,
|
|
87
|
+
modules: sp.modules,
|
|
88
|
+
perms: sp.perms
|
|
89
|
+
}))
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
function collectFlatPerms(items) {
|
|
96
|
+
const results = [];
|
|
97
|
+
const queue = items.map((item) => ({
|
|
98
|
+
item,
|
|
99
|
+
titleChain: [],
|
|
100
|
+
codePath: "",
|
|
101
|
+
modulesChain: []
|
|
102
|
+
}));
|
|
103
|
+
while (queue.length > 0) {
|
|
104
|
+
const { item, titleChain, codePath, modulesChain } = queue.shift();
|
|
105
|
+
const currTitleChain = [...titleChain, item.title];
|
|
106
|
+
const currCodePath = codePath + "/" + item.code;
|
|
107
|
+
const currModulesChain = item.modules ? [...modulesChain, item.modules] : modulesChain;
|
|
108
|
+
if (isGroupItem(item)) {
|
|
109
|
+
for (const child of item.children) {
|
|
110
|
+
queue.push({
|
|
111
|
+
item: child,
|
|
112
|
+
titleChain: currTitleChain,
|
|
113
|
+
codePath: currCodePath,
|
|
114
|
+
modulesChain: currModulesChain
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
if (item.perms) {
|
|
119
|
+
for (const perm of item.perms) {
|
|
120
|
+
results.push({
|
|
121
|
+
titleChain: currTitleChain,
|
|
122
|
+
code: currCodePath + "/" + perm,
|
|
123
|
+
modulesChain: currModulesChain
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (item.subPerms) {
|
|
128
|
+
for (const subPerm of item.subPerms) {
|
|
129
|
+
const subModulesChain = subPerm.modules ? [...currModulesChain, subPerm.modules] : currModulesChain;
|
|
130
|
+
for (const perm of subPerm.perms) {
|
|
131
|
+
results.push({
|
|
132
|
+
titleChain: currTitleChain,
|
|
133
|
+
code: currCodePath + "/" + subPerm.code + "/" + perm,
|
|
134
|
+
modulesChain: subModulesChain
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return results;
|
|
142
|
+
}
|
|
68
143
|
function findItemChainByCodes(items, codes) {
|
|
69
144
|
const result = [];
|
|
70
145
|
let currentItems = items;
|
|
@@ -77,33 +152,57 @@ function findItemChainByCodes(items, codes) {
|
|
|
77
152
|
return result;
|
|
78
153
|
}
|
|
79
154
|
function createAppStructure(opts) {
|
|
80
|
-
const
|
|
81
|
-
var _a;
|
|
82
|
-
return ((_a = opts.permRecord) == null ? void 0 : _a.call(opts)) ?? {};
|
|
83
|
-
};
|
|
84
|
-
const routes = extractRoutes(opts.items);
|
|
155
|
+
const flatPerms = collectFlatPerms(opts.items);
|
|
85
156
|
const memos = createRoot(() => {
|
|
157
|
+
const usableRoutes = createMemo(() => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
const routes = [];
|
|
160
|
+
for (const top of opts.items) {
|
|
161
|
+
if (isGroupItem(top)) {
|
|
162
|
+
routes.push(
|
|
163
|
+
...buildUsableRoutes(
|
|
164
|
+
top.children,
|
|
165
|
+
"",
|
|
166
|
+
"/" + top.code,
|
|
167
|
+
(_a = opts.usableModules) == null ? void 0 : _a.call(opts),
|
|
168
|
+
(_b = opts.permRecord) == null ? void 0 : _b.call(opts)
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return routes;
|
|
174
|
+
});
|
|
86
175
|
const usableMenus = createMemo(() => {
|
|
87
|
-
var _a;
|
|
176
|
+
var _a, _b;
|
|
88
177
|
const menus = [];
|
|
89
178
|
for (const top of opts.items) {
|
|
90
179
|
if (isGroupItem(top)) {
|
|
91
180
|
menus.push(
|
|
92
|
-
...buildMenus(
|
|
181
|
+
...buildMenus(
|
|
182
|
+
top.children,
|
|
183
|
+
"/" + top.code,
|
|
184
|
+
(_a = opts.usableModules) == null ? void 0 : _a.call(opts),
|
|
185
|
+
(_b = opts.permRecord) == null ? void 0 : _b.call(opts)
|
|
186
|
+
)
|
|
93
187
|
);
|
|
94
188
|
}
|
|
95
189
|
}
|
|
96
190
|
return menus;
|
|
97
191
|
});
|
|
98
192
|
const usableFlatMenus = createMemo(() => flattenMenus(usableMenus()));
|
|
99
|
-
|
|
193
|
+
const usablePerms = createMemo(() => {
|
|
194
|
+
var _a;
|
|
195
|
+
return buildPerms(opts.items, "", (_a = opts.usableModules) == null ? void 0 : _a.call(opts));
|
|
196
|
+
});
|
|
197
|
+
return { usableRoutes, usableMenus, usableFlatMenus, usablePerms };
|
|
100
198
|
});
|
|
101
199
|
return {
|
|
102
200
|
items: opts.items,
|
|
103
|
-
|
|
201
|
+
usableRoutes: memos.usableRoutes,
|
|
104
202
|
usableMenus: memos.usableMenus,
|
|
105
203
|
usableFlatMenus: memos.usableFlatMenus,
|
|
106
|
-
|
|
204
|
+
usablePerms: memos.usablePerms,
|
|
205
|
+
flatPerms,
|
|
107
206
|
getTitleChainByHref(href) {
|
|
108
207
|
const codes = href.split("/").filter(Boolean);
|
|
109
208
|
return findItemChainByCodes(opts.items, codes).map((item) => item.title);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/createAppStructure.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAwB,YAAY,kBAAkB;
|
|
4
|
+
"mappings": "AAAA,SAAwB,YAAY,kBAAkB;AAoFtD,SAAS,YACP,MACwC;AACxC,SAAO,cAAc;AACvB;AAEA,SAAS,aACP,SACA,iBACA,eACS;AACT,MAAI,kBAAkB,OAAW,QAAO;AAExC,MAAI,YAAY,UAAa,QAAQ,SAAS,GAAG;AAC/C,QAAI,CAAC,QAAQ,KAAK,CAAC,MAAM,cAAc,SAAS,CAAC,CAAC,EAAG,QAAO;AAAA,EAC9D;AAEA,MAAI,oBAAoB,UAAa,gBAAgB,SAAS,GAAG;AAC/D,QAAI,CAAC,gBAAgB,MAAM,CAAC,MAAM,cAAc,SAAS,CAAC,CAAC,EAAG,QAAO;AAAA,EACvE;AAEA,SAAO;AACT;AAIA,SAAS,kBACP,OACA,eACA,cACA,eACA,YACY;AApHd;AAqHE,QAAM,SAAqB,CAAC;AAE5B,aAAW,QAAQ,OAAO;AACxB,QAAI,CAAC,aAAa,KAAK,SAAS,KAAK,iBAAiB,aAAa,EAAG;AAEtE,UAAM,YAAY,gBAAgB,MAAM,KAAK;AAC7C,U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|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -84,5 +84,5 @@ export { ripple } from "./directives/ripple";
|
|
|
84
84
|
export { mergeStyles } from "./helpers/mergeStyles";
|
|
85
85
|
export { splitSlots } from "./helpers/splitSlots";
|
|
86
86
|
export { createAppStructure } from "./helpers/createAppStructure";
|
|
87
|
-
export type { AppStructureItem, AppStructureGroupItem, AppStructureLeafItem, AppStructureSubPerm, AppRoute, AppFlatMenu, AppStructure, } from "./helpers/createAppStructure";
|
|
87
|
+
export type { AppStructureItem, AppStructureGroupItem, AppStructureLeafItem, AppStructureSubPerm, AppRoute, AppFlatMenu, AppMenu, AppPerm, AppFlatPerm, AppStructure, } from "./helpers/createAppStructure";
|
|
88
88
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["..\\src\\index.ts"],"names":[],"mappings":"AAGA,cAAc,kCAAkC,CAAC;AAGjD,cAAc,yCAAyC,CAAC;AAGxD,cAAc,6CAA6C,CAAC;AAG5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAG7D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,kDAAkD,CAAC;AACjE,cAAc,+CAA+C,CAAC;AAG9D,cAAc,oDAAoD,CAAC;AACnE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,iDAAiD,CAAC;AAChE,cAAc,yCAAyC,CAAC;AACxD,cAAc,oDAAoD,CAAC;AACnE,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAMlD,cAAc,+BAA+B,CAAC;AAC9C,cAAc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AACtC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMtD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AAMzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAM7C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,OAAO,EACP,OAAO,EACP,WAAW,EACX,YAAY,GACb,MAAM,8BAA8B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/solid",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.42",
|
|
4
4
|
"description": "심플리즘 패키지 - SolidJS 라이브러리",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"solid-tiptap": "^0.8.0",
|
|
50
50
|
"tailwind-merge": "^3.5.0",
|
|
51
51
|
"tailwindcss": "^3.4.19",
|
|
52
|
-
"@simplysm/core-browser": "13.0.
|
|
53
|
-
"@simplysm/core-common": "13.0.
|
|
52
|
+
"@simplysm/core-browser": "13.0.42",
|
|
53
|
+
"@simplysm/core-common": "13.0.42"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@solidjs/testing-library": "^0.8.10"
|
|
@@ -14,6 +14,7 @@ import { twMerge } from "tailwind-merge";
|
|
|
14
14
|
import { DataSheet } from "../sheet/DataSheet";
|
|
15
15
|
import { Checkbox } from "../../form-control/checkbox/Checkbox";
|
|
16
16
|
import { borderDefault } from "../../../styles/tokens.styles";
|
|
17
|
+
import type { AppPerm } from "../../../helpers/createAppStructure";
|
|
17
18
|
|
|
18
19
|
const titleCellClass = clsx("flex items-stretch", "px-2");
|
|
19
20
|
const indentGuideWrapperClass = clsx("mr-1 flex w-3", "justify-center");
|
|
@@ -21,16 +22,8 @@ const indentGuideLineClass = clsx("w-0 self-stretch", "border-r", borderDefault)
|
|
|
21
22
|
|
|
22
23
|
// --- 타입 ---
|
|
23
24
|
|
|
24
|
-
export interface PermissionItem<TModule = string> {
|
|
25
|
-
title: string;
|
|
26
|
-
href?: string;
|
|
27
|
-
modules?: TModule[];
|
|
28
|
-
perms?: string[];
|
|
29
|
-
children?: PermissionItem<TModule>[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
25
|
export interface PermissionTableProps<TModule = string> {
|
|
33
|
-
items?:
|
|
26
|
+
items?: AppPerm<TModule>[];
|
|
34
27
|
value?: Record<string, boolean>;
|
|
35
28
|
onValueChange?: (value: Record<string, boolean>) => void;
|
|
36
29
|
modules?: TModule[];
|
|
@@ -42,9 +35,9 @@ export interface PermissionTableProps<TModule = string> {
|
|
|
42
35
|
// --- 유틸리티 (테스트에서도 사용) ---
|
|
43
36
|
|
|
44
37
|
/** 트리에서 모든 고유 perm 타입을 수집 */
|
|
45
|
-
export function collectAllPerms<TModule>(items:
|
|
38
|
+
export function collectAllPerms<TModule>(items: AppPerm<TModule>[]): string[] {
|
|
46
39
|
const set = new Set<string>();
|
|
47
|
-
const walk = (list:
|
|
40
|
+
const walk = (list: AppPerm<TModule>[]) => {
|
|
48
41
|
for (const item of list) {
|
|
49
42
|
if (item.perms) {
|
|
50
43
|
for (const p of item.perms) set.add(p);
|
|
@@ -58,12 +51,12 @@ export function collectAllPerms<TModule>(items: PermissionItem<TModule>[]): stri
|
|
|
58
51
|
|
|
59
52
|
/** modules 필터: 활성 모듈과 교차가 있는 아이템만 남김 */
|
|
60
53
|
export function filterByModules<TModule>(
|
|
61
|
-
items:
|
|
54
|
+
items: AppPerm<TModule>[],
|
|
62
55
|
modules: TModule[] | undefined,
|
|
63
|
-
):
|
|
56
|
+
): AppPerm<TModule>[] {
|
|
64
57
|
if (!modules || modules.length === 0) return items;
|
|
65
58
|
|
|
66
|
-
const result:
|
|
59
|
+
const result: AppPerm<TModule>[] = [];
|
|
67
60
|
|
|
68
61
|
for (const item of items) {
|
|
69
62
|
if (item.modules && !item.modules.some((m) => modules.includes(m))) {
|
|
@@ -82,13 +75,13 @@ export function filterByModules<TModule>(
|
|
|
82
75
|
/** 체크 변경 시 cascading 처리 */
|
|
83
76
|
export function changePermCheck<TModule>(
|
|
84
77
|
value: Record<string, boolean>,
|
|
85
|
-
item:
|
|
78
|
+
item: AppPerm<TModule>,
|
|
86
79
|
perm: string,
|
|
87
80
|
checked: boolean,
|
|
88
81
|
): Record<string, boolean> {
|
|
89
82
|
const result = { ...value };
|
|
90
83
|
|
|
91
|
-
const apply = (target:
|
|
84
|
+
const apply = (target: AppPerm<TModule>) => {
|
|
92
85
|
if (target.perms && target.href != null && target.href !== "") {
|
|
93
86
|
const permIndex = target.perms.indexOf(perm);
|
|
94
87
|
|
|
@@ -122,10 +115,7 @@ export function changePermCheck<TModule>(
|
|
|
122
115
|
// --- 내부 헬퍼 ---
|
|
123
116
|
|
|
124
117
|
/** 모듈 필터에 의해 보이는지 확인 (객체 참조 유지) */
|
|
125
|
-
function isItemVisible<TModule>(
|
|
126
|
-
item: PermissionItem<TModule>,
|
|
127
|
-
modules: TModule[] | undefined,
|
|
128
|
-
): boolean {
|
|
118
|
+
function isItemVisible<TModule>(item: AppPerm<TModule>, modules: TModule[] | undefined): boolean {
|
|
129
119
|
if (!modules || modules.length === 0) return true;
|
|
130
120
|
if (item.modules && !item.modules.some((m) => modules.includes(m))) return false;
|
|
131
121
|
if (!item.perms && item.children) {
|
|
@@ -136,12 +126,12 @@ function isItemVisible<TModule>(
|
|
|
136
126
|
|
|
137
127
|
/** 보이는 아이템에서만 고유 perm 타입 수집 */
|
|
138
128
|
function collectVisiblePerms<TModule>(
|
|
139
|
-
items:
|
|
129
|
+
items: AppPerm<TModule>[],
|
|
140
130
|
modules: TModule[] | undefined,
|
|
141
131
|
): string[] {
|
|
142
132
|
const set = new Set<string>();
|
|
143
133
|
|
|
144
|
-
function walk(list:
|
|
134
|
+
function walk(list: AppPerm<TModule>[]) {
|
|
145
135
|
for (const item of list) {
|
|
146
136
|
if (!isItemVisible(item, modules)) continue;
|
|
147
137
|
if (item.perms) {
|
|
@@ -157,7 +147,7 @@ function collectVisiblePerms<TModule>(
|
|
|
157
147
|
|
|
158
148
|
/** 그룹 노드의 체크 상태: 하위 중 하나라도 체크면 true */
|
|
159
149
|
function isGroupPermChecked<TModule>(
|
|
160
|
-
item:
|
|
150
|
+
item: AppPerm<TModule>,
|
|
161
151
|
perm: string,
|
|
162
152
|
value: Record<string, boolean>,
|
|
163
153
|
): boolean {
|
|
@@ -171,7 +161,7 @@ function isGroupPermChecked<TModule>(
|
|
|
171
161
|
}
|
|
172
162
|
|
|
173
163
|
/** 하위에 특정 perm이 하나라도 있으면 true */
|
|
174
|
-
function hasPermInTree<TModule>(item:
|
|
164
|
+
function hasPermInTree<TModule>(item: AppPerm<TModule>, perm: string): boolean {
|
|
175
165
|
if (item.perms?.includes(perm)) return true;
|
|
176
166
|
if (item.children) {
|
|
177
167
|
return item.children.some((child) => hasPermInTree(child, perm));
|
|
@@ -181,7 +171,7 @@ function hasPermInTree<TModule>(item: PermissionItem<TModule>, perm: string): bo
|
|
|
181
171
|
|
|
182
172
|
/** 기본 권한(perms[0])이 꺼져 있어서 비활성화해야 하는지 */
|
|
183
173
|
function isPermDisabled<TModule>(
|
|
184
|
-
item:
|
|
174
|
+
item: AppPerm<TModule>,
|
|
185
175
|
perm: string,
|
|
186
176
|
value: Record<string, boolean>,
|
|
187
177
|
): boolean {
|
|
@@ -193,12 +183,12 @@ function isPermDisabled<TModule>(
|
|
|
193
183
|
|
|
194
184
|
/** 확장 가능한 모든 아이템 수집 (객체 참조 유지) */
|
|
195
185
|
function collectExpandable<TModule>(
|
|
196
|
-
items:
|
|
197
|
-
getChildren: (item:
|
|
198
|
-
):
|
|
199
|
-
const result:
|
|
186
|
+
items: AppPerm<TModule>[],
|
|
187
|
+
getChildren: (item: AppPerm<TModule>) => AppPerm<TModule>[] | undefined,
|
|
188
|
+
): AppPerm<TModule>[] {
|
|
189
|
+
const result: AppPerm<TModule>[] = [];
|
|
200
190
|
|
|
201
|
-
function walk(list:
|
|
191
|
+
function walk(list: AppPerm<TModule>[]) {
|
|
202
192
|
for (const item of list) {
|
|
203
193
|
const children = getChildren(item);
|
|
204
194
|
if (children && children.length > 0) {
|
|
@@ -233,7 +223,7 @@ export const PermissionTable: Component<PermissionTableProps> = (props) => {
|
|
|
233
223
|
});
|
|
234
224
|
|
|
235
225
|
// Sheet의 getChildren — 모듈 필터 적용, 객체 참조 유지
|
|
236
|
-
const getChildren = (item:
|
|
226
|
+
const getChildren = (item: AppPerm): AppPerm[] | undefined => {
|
|
237
227
|
if (!item.children || item.children.length === 0) return undefined;
|
|
238
228
|
const modules = local.modules;
|
|
239
229
|
if (!modules || modules.length === 0) return item.children;
|
|
@@ -249,7 +239,7 @@ export const PermissionTable: Component<PermissionTableProps> = (props) => {
|
|
|
249
239
|
// 확장 상태 — 기본적으로 모두 펼침
|
|
250
240
|
const getAllExpandable = () => collectExpandable(visibleItems(), getChildren);
|
|
251
241
|
|
|
252
|
-
const [expandedItems, setExpandedItems] = createSignal<
|
|
242
|
+
const [expandedItems, setExpandedItems] = createSignal<AppPerm[]>(getAllExpandable());
|
|
253
243
|
|
|
254
244
|
// 트리 구조 변경 시 모두 다시 펼침 (모듈 필터 변경 등)
|
|
255
245
|
createEffect(
|
|
@@ -262,7 +252,7 @@ export const PermissionTable: Component<PermissionTableProps> = (props) => {
|
|
|
262
252
|
),
|
|
263
253
|
);
|
|
264
254
|
|
|
265
|
-
const handlePermChange = (item:
|
|
255
|
+
const handlePermChange = (item: AppPerm, perm: string, checked: boolean) => {
|
|
266
256
|
const newValue = changePermCheck(currentValue(), item, perm, checked);
|
|
267
257
|
local.onValueChange?.(newValue);
|
|
268
258
|
};
|
|
@@ -278,7 +268,7 @@ export const PermissionTable: Component<PermissionTableProps> = (props) => {
|
|
|
278
268
|
>
|
|
279
269
|
<DataSheet.Column key="title" header="권한 항목" sortable={false} resizable={false}>
|
|
280
270
|
{(ctx) => {
|
|
281
|
-
const item = ctx.item as
|
|
271
|
+
const item = ctx.item as AppPerm;
|
|
282
272
|
return (
|
|
283
273
|
<div class={titleCellClass}>
|
|
284
274
|
<For each={Array.from({ length: ctx.depth })}>
|
|
@@ -297,7 +287,7 @@ export const PermissionTable: Component<PermissionTableProps> = (props) => {
|
|
|
297
287
|
{(perm) => (
|
|
298
288
|
<DataSheet.Column key={`perm-${perm}`} header={perm} sortable={false} resizable={false}>
|
|
299
289
|
{(ctx) => {
|
|
300
|
-
const item = ctx.item as
|
|
290
|
+
const item = ctx.item as AppPerm;
|
|
301
291
|
return (
|
|
302
292
|
<Show when={hasPermInTree(item, perm)}>
|
|
303
293
|
<Checkbox
|
|
@@ -35,7 +35,7 @@ const themeClasses = Object.fromEntries(
|
|
|
35
35
|
Object.entries(themeTokens).map(([theme, t]) => [
|
|
36
36
|
theme,
|
|
37
37
|
{
|
|
38
|
-
solid: clsx(t.solid, t.solidHover
|
|
38
|
+
solid: clsx(t.solid, t.solidHover /*, "shadow-md hover:shadow-lg"*/),
|
|
39
39
|
outline: clsx("bg-transparent", t.hoverBg, t.text, t.border),
|
|
40
40
|
ghost: clsx("bg-transparent", t.hoverBg, t.text),
|
|
41
41
|
},
|
|
@@ -9,7 +9,7 @@ import { SidebarMenu } from "./SidebarMenu";
|
|
|
9
9
|
import { SidebarUser } from "./SidebarUser";
|
|
10
10
|
|
|
11
11
|
export type { SidebarContainerProps } from "./SidebarContainer";
|
|
12
|
-
export type {
|
|
12
|
+
export type { SidebarMenuProps } from "./SidebarMenu";
|
|
13
13
|
export type { SidebarUserMenu, SidebarUserProps } from "./SidebarUser";
|
|
14
14
|
|
|
15
15
|
const baseClass = clsx(
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
import { useLocation, useNavigate } from "@solidjs/router";
|
|
15
15
|
import clsx from "clsx";
|
|
16
16
|
import { twMerge } from "tailwind-merge";
|
|
17
|
-
import type { IconProps } from "@tabler/icons-solidjs";
|
|
18
17
|
import type { ComponentSize } from "../../../styles/tokens.styles";
|
|
18
|
+
import type { AppMenu } from "../../../helpers/createAppStructure";
|
|
19
19
|
import { Icon } from "../../display/Icon";
|
|
20
20
|
import { List } from "../../data/list/List";
|
|
21
21
|
import { ListItem } from "../../data/list/ListItem";
|
|
@@ -31,23 +31,16 @@ const headerClass = clsx(
|
|
|
31
31
|
"tracking-wider",
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
export interface SidebarMenuItem {
|
|
35
|
-
title: string;
|
|
36
|
-
href?: string;
|
|
37
|
-
icon?: Component<IconProps>;
|
|
38
|
-
children?: SidebarMenuItem[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
export interface SidebarMenuProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
42
35
|
/**
|
|
43
36
|
* 메뉴 아이템 배열
|
|
44
37
|
*/
|
|
45
|
-
menus:
|
|
38
|
+
menus: AppMenu[];
|
|
46
39
|
}
|
|
47
40
|
|
|
48
41
|
// 내부 Context: 초기 펼침 상태 공유
|
|
49
42
|
interface MenuContextValue {
|
|
50
|
-
initialOpenItems: Accessor<Set<
|
|
43
|
+
initialOpenItems: Accessor<Set<AppMenu>>;
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
const MenuContext = createContext<MenuContextValue>();
|
|
@@ -84,10 +77,10 @@ export const SidebarMenu: Component<SidebarMenuProps> = (props) => {
|
|
|
84
77
|
|
|
85
78
|
// 현재 pathname과 일치하는 메뉴의 부모들을 찾아 펼침 상태 계산
|
|
86
79
|
const findSelectedPath = (
|
|
87
|
-
menus:
|
|
80
|
+
menus: AppMenu[],
|
|
88
81
|
pathname: string,
|
|
89
|
-
path:
|
|
90
|
-
):
|
|
82
|
+
path: AppMenu[] = [],
|
|
83
|
+
): AppMenu[] | null => {
|
|
91
84
|
for (const menu of menus) {
|
|
92
85
|
const currentPath = [...path, menu];
|
|
93
86
|
if (menu.href === pathname) {
|
|
@@ -106,7 +99,7 @@ export const SidebarMenu: Component<SidebarMenuProps> = (props) => {
|
|
|
106
99
|
const selectedPath = findSelectedPath(local.menus, location.pathname);
|
|
107
100
|
return selectedPath
|
|
108
101
|
? new Set(selectedPath.slice(0, -1)) // 마지막 항목(선택된 메뉴)은 제외하고 부모들만 펼침
|
|
109
|
-
: new Set<
|
|
102
|
+
: new Set<AppMenu>();
|
|
110
103
|
});
|
|
111
104
|
|
|
112
105
|
const getClassName = () => twMerge("flex-1 overflow-y-auto", local.class);
|
|
@@ -124,7 +117,7 @@ export const SidebarMenu: Component<SidebarMenuProps> = (props) => {
|
|
|
124
117
|
};
|
|
125
118
|
|
|
126
119
|
interface MenuItemProps {
|
|
127
|
-
menu:
|
|
120
|
+
menu: AppMenu;
|
|
128
121
|
size?: ComponentSize;
|
|
129
122
|
}
|
|
130
123
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Accessor, createMemo, createRoot } from "solid-js";
|
|
2
2
|
import type { Component } from "solid-js";
|
|
3
3
|
import type { IconProps } from "@tabler/icons-solidjs";
|
|
4
|
-
import type { SidebarMenuItem } from "../components/layout/sidebar/SidebarMenu";
|
|
5
4
|
|
|
6
5
|
// ── 입력 타입 ──
|
|
7
6
|
|
|
@@ -40,6 +39,27 @@ export interface AppStructureSubPerm<TModule> {
|
|
|
40
39
|
|
|
41
40
|
// ── 출력 타입 ──
|
|
42
41
|
|
|
42
|
+
export interface AppMenu {
|
|
43
|
+
title: string;
|
|
44
|
+
href?: string;
|
|
45
|
+
icon?: Component<IconProps>;
|
|
46
|
+
children?: AppMenu[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface AppPerm<TModule = string> {
|
|
50
|
+
title: string;
|
|
51
|
+
href?: string;
|
|
52
|
+
modules?: TModule[];
|
|
53
|
+
perms?: string[];
|
|
54
|
+
children?: AppPerm<TModule>[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface AppFlatPerm<TModule = string> {
|
|
58
|
+
titleChain: string[];
|
|
59
|
+
code: string;
|
|
60
|
+
modulesChain: TModule[][];
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
export interface AppRoute {
|
|
44
64
|
path: string;
|
|
45
65
|
component: Component;
|
|
@@ -52,10 +72,11 @@ export interface AppFlatMenu {
|
|
|
52
72
|
|
|
53
73
|
export interface AppStructure<TModule> {
|
|
54
74
|
items: AppStructureItem<TModule>[];
|
|
55
|
-
|
|
56
|
-
usableMenus: Accessor<
|
|
75
|
+
usableRoutes: Accessor<AppRoute[]>;
|
|
76
|
+
usableMenus: Accessor<AppMenu[]>;
|
|
57
77
|
usableFlatMenus: Accessor<AppFlatMenu[]>;
|
|
58
|
-
|
|
78
|
+
usablePerms: Accessor<AppPerm<TModule>[]>;
|
|
79
|
+
flatPerms: AppFlatPerm<TModule>[];
|
|
59
80
|
getTitleChainByHref(href: string): string[];
|
|
60
81
|
}
|
|
61
82
|
|
|
@@ -85,42 +106,46 @@ function checkModules<TModule>(
|
|
|
85
106
|
return true;
|
|
86
107
|
}
|
|
87
108
|
|
|
88
|
-
|
|
109
|
+
// ── Routes ──
|
|
110
|
+
|
|
111
|
+
function buildUsableRoutes<TModule>(
|
|
89
112
|
items: AppStructureItem<TModule>[],
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
routeBasePath: string,
|
|
114
|
+
permBasePath: string,
|
|
115
|
+
usableModules: TModule[] | undefined,
|
|
116
|
+
permRecord: Record<string, boolean> | undefined,
|
|
117
|
+
): AppRoute[] {
|
|
118
|
+
const result: AppRoute[] = [];
|
|
119
|
+
|
|
93
120
|
for (const item of items) {
|
|
94
|
-
|
|
121
|
+
if (!checkModules(item.modules, item.requiredModules, usableModules)) continue;
|
|
122
|
+
|
|
123
|
+
const routePath = routeBasePath + "/" + item.code;
|
|
124
|
+
const permPath = permBasePath + "/" + item.code;
|
|
95
125
|
|
|
96
126
|
if (isGroupItem(item)) {
|
|
97
|
-
|
|
127
|
+
result.push(
|
|
128
|
+
...buildUsableRoutes(item.children, routePath, permPath, usableModules, permRecord),
|
|
129
|
+
);
|
|
98
130
|
} else if (item.component !== undefined) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
131
|
+
if (permRecord !== undefined && item.perms?.includes("use") && !permRecord[permPath + "/use"])
|
|
132
|
+
continue;
|
|
133
|
+
result.push({ path: routePath, component: item.component });
|
|
103
134
|
}
|
|
104
135
|
}
|
|
105
|
-
}
|
|
106
136
|
|
|
107
|
-
|
|
108
|
-
const routes: AppRoute[] = [];
|
|
109
|
-
for (const top of items) {
|
|
110
|
-
if (isGroupItem(top)) {
|
|
111
|
-
collectRoutes(top.children, [], routes);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return routes;
|
|
137
|
+
return result;
|
|
115
138
|
}
|
|
116
139
|
|
|
140
|
+
// ── Menus ──
|
|
141
|
+
|
|
117
142
|
function buildMenus<TModule>(
|
|
118
143
|
items: AppStructureItem<TModule>[],
|
|
119
144
|
basePath: string,
|
|
120
145
|
usableModules: TModule[] | undefined,
|
|
121
|
-
permRecord: Record<string, boolean
|
|
122
|
-
):
|
|
123
|
-
const result:
|
|
146
|
+
permRecord: Record<string, boolean> | undefined,
|
|
147
|
+
): AppMenu[] {
|
|
148
|
+
const result: AppMenu[] = [];
|
|
124
149
|
|
|
125
150
|
for (const item of items) {
|
|
126
151
|
if (!checkModules(item.modules, item.requiredModules, usableModules)) continue;
|
|
@@ -134,7 +159,7 @@ function buildMenus<TModule>(
|
|
|
134
159
|
}
|
|
135
160
|
} else {
|
|
136
161
|
if (item.isNotMenu) continue;
|
|
137
|
-
if (item.perms?.includes("use") && !permRecord[href + "/use"]) continue;
|
|
162
|
+
if (item.perms?.includes("use") && !permRecord?.[href + "/use"]) continue;
|
|
138
163
|
|
|
139
164
|
result.push({ title: item.title, href, icon: item.icon });
|
|
140
165
|
}
|
|
@@ -143,7 +168,7 @@ function buildMenus<TModule>(
|
|
|
143
168
|
return result;
|
|
144
169
|
}
|
|
145
170
|
|
|
146
|
-
function flattenMenus(menus:
|
|
171
|
+
function flattenMenus(menus: AppMenu[], titleChain: string[] = []): AppFlatMenu[] {
|
|
147
172
|
const result: AppFlatMenu[] = [];
|
|
148
173
|
|
|
149
174
|
for (const menu of menus) {
|
|
@@ -159,6 +184,117 @@ function flattenMenus(menus: SidebarMenuItem[], titleChain: string[] = []): AppF
|
|
|
159
184
|
return result;
|
|
160
185
|
}
|
|
161
186
|
|
|
187
|
+
// ── Perms ──
|
|
188
|
+
|
|
189
|
+
function buildPerms<TModule>(
|
|
190
|
+
items: AppStructureItem<TModule>[],
|
|
191
|
+
basePath: string,
|
|
192
|
+
usableModules: TModule[] | undefined,
|
|
193
|
+
): AppPerm<TModule>[] {
|
|
194
|
+
const result: AppPerm<TModule>[] = [];
|
|
195
|
+
|
|
196
|
+
for (const item of items) {
|
|
197
|
+
if (!checkModules(item.modules, item.requiredModules, usableModules)) continue;
|
|
198
|
+
|
|
199
|
+
const href = basePath + "/" + item.code;
|
|
200
|
+
|
|
201
|
+
if (isGroupItem(item)) {
|
|
202
|
+
const children = buildPerms(item.children, href, usableModules);
|
|
203
|
+
result.push({
|
|
204
|
+
title: item.title,
|
|
205
|
+
modules: item.modules,
|
|
206
|
+
children,
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
result.push({
|
|
210
|
+
title: item.title,
|
|
211
|
+
href,
|
|
212
|
+
modules: item.modules,
|
|
213
|
+
perms: item.perms,
|
|
214
|
+
children: item.subPerms
|
|
215
|
+
?.filter((sp) => checkModules(sp.modules, sp.requiredModules, usableModules))
|
|
216
|
+
.map((sp) => ({
|
|
217
|
+
title: sp.title,
|
|
218
|
+
href: href + "/" + sp.code,
|
|
219
|
+
modules: sp.modules,
|
|
220
|
+
perms: sp.perms as string[],
|
|
221
|
+
})),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function collectFlatPerms<TModule>(items: AppStructureItem<TModule>[]): AppFlatPerm<TModule>[] {
|
|
230
|
+
const results: AppFlatPerm<TModule>[] = [];
|
|
231
|
+
|
|
232
|
+
interface QueueItem {
|
|
233
|
+
item: AppStructureItem<TModule>;
|
|
234
|
+
titleChain: string[];
|
|
235
|
+
codePath: string;
|
|
236
|
+
modulesChain: TModule[][];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const queue: QueueItem[] = items.map((item) => ({
|
|
240
|
+
item,
|
|
241
|
+
titleChain: [],
|
|
242
|
+
codePath: "",
|
|
243
|
+
modulesChain: [],
|
|
244
|
+
}));
|
|
245
|
+
|
|
246
|
+
while (queue.length > 0) {
|
|
247
|
+
const { item, titleChain, codePath, modulesChain } = queue.shift()!;
|
|
248
|
+
|
|
249
|
+
const currTitleChain = [...titleChain, item.title];
|
|
250
|
+
const currCodePath = codePath + "/" + item.code;
|
|
251
|
+
const currModulesChain: TModule[][] = item.modules
|
|
252
|
+
? [...modulesChain, item.modules]
|
|
253
|
+
: modulesChain;
|
|
254
|
+
|
|
255
|
+
if (isGroupItem(item)) {
|
|
256
|
+
for (const child of item.children) {
|
|
257
|
+
queue.push({
|
|
258
|
+
item: child,
|
|
259
|
+
titleChain: currTitleChain,
|
|
260
|
+
codePath: currCodePath,
|
|
261
|
+
modulesChain: currModulesChain,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
if (item.perms) {
|
|
266
|
+
for (const perm of item.perms) {
|
|
267
|
+
results.push({
|
|
268
|
+
titleChain: currTitleChain,
|
|
269
|
+
code: currCodePath + "/" + perm,
|
|
270
|
+
modulesChain: currModulesChain,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (item.subPerms) {
|
|
276
|
+
for (const subPerm of item.subPerms) {
|
|
277
|
+
const subModulesChain: TModule[][] = subPerm.modules
|
|
278
|
+
? [...currModulesChain, subPerm.modules]
|
|
279
|
+
: currModulesChain;
|
|
280
|
+
|
|
281
|
+
for (const perm of subPerm.perms) {
|
|
282
|
+
results.push({
|
|
283
|
+
titleChain: currTitleChain,
|
|
284
|
+
code: currCodePath + "/" + subPerm.code + "/" + perm,
|
|
285
|
+
modulesChain: subModulesChain,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return results;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// ── Info ──
|
|
297
|
+
|
|
162
298
|
function findItemChainByCodes<TModule>(
|
|
163
299
|
items: AppStructureItem<TModule>[],
|
|
164
300
|
codes: string[],
|
|
@@ -183,17 +319,38 @@ export function createAppStructure<TModule>(opts: {
|
|
|
183
319
|
usableModules?: Accessor<TModule[] | undefined>;
|
|
184
320
|
permRecord?: Accessor<Record<string, boolean>>;
|
|
185
321
|
}): AppStructure<TModule> {
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
const routes = extractRoutes(opts.items);
|
|
322
|
+
const flatPerms = collectFlatPerms(opts.items);
|
|
189
323
|
|
|
190
324
|
const memos = createRoot(() => {
|
|
325
|
+
const usableRoutes = createMemo(() => {
|
|
326
|
+
const routes: AppRoute[] = [];
|
|
327
|
+
for (const top of opts.items) {
|
|
328
|
+
if (isGroupItem(top)) {
|
|
329
|
+
routes.push(
|
|
330
|
+
...buildUsableRoutes(
|
|
331
|
+
top.children,
|
|
332
|
+
"",
|
|
333
|
+
"/" + top.code,
|
|
334
|
+
opts.usableModules?.(),
|
|
335
|
+
opts.permRecord?.(),
|
|
336
|
+
),
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return routes;
|
|
341
|
+
});
|
|
342
|
+
|
|
191
343
|
const usableMenus = createMemo(() => {
|
|
192
|
-
const menus:
|
|
344
|
+
const menus: AppMenu[] = [];
|
|
193
345
|
for (const top of opts.items) {
|
|
194
346
|
if (isGroupItem(top)) {
|
|
195
347
|
menus.push(
|
|
196
|
-
...buildMenus(
|
|
348
|
+
...buildMenus(
|
|
349
|
+
top.children,
|
|
350
|
+
"/" + top.code,
|
|
351
|
+
opts.usableModules?.(),
|
|
352
|
+
opts.permRecord?.(),
|
|
353
|
+
),
|
|
197
354
|
);
|
|
198
355
|
}
|
|
199
356
|
}
|
|
@@ -202,15 +359,18 @@ export function createAppStructure<TModule>(opts: {
|
|
|
202
359
|
|
|
203
360
|
const usableFlatMenus = createMemo(() => flattenMenus(usableMenus()));
|
|
204
361
|
|
|
205
|
-
|
|
362
|
+
const usablePerms = createMemo(() => buildPerms(opts.items, "", opts.usableModules?.()));
|
|
363
|
+
|
|
364
|
+
return { usableRoutes, usableMenus, usableFlatMenus, usablePerms };
|
|
206
365
|
});
|
|
207
366
|
|
|
208
367
|
return {
|
|
209
368
|
items: opts.items,
|
|
210
|
-
|
|
369
|
+
usableRoutes: memos.usableRoutes,
|
|
211
370
|
usableMenus: memos.usableMenus,
|
|
212
371
|
usableFlatMenus: memos.usableFlatMenus,
|
|
213
|
-
|
|
372
|
+
usablePerms: memos.usablePerms,
|
|
373
|
+
flatPerms,
|
|
214
374
|
getTitleChainByHref(href: string): string[] {
|
|
215
375
|
const codes = href.split("/").filter(Boolean);
|
|
216
376
|
return findItemChainByCodes(opts.items, codes).map((item) => item.title);
|