nucleus-core-ts 0.8.6 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +1 -1
- package/dist/dist/index.d.ts +475 -12
- package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
- package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
- package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
- package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
- package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
- package/dist/fe/components/AuthorizationPage/index.js +6 -0
- package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
- package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
- package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
- package/dist/fe/components/Button/components/Button.js +158 -0
- package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
- package/dist/fe/components/Button/index.js +3 -0
- package/dist/fe/components/Button/theme/index.js +186 -0
- package/dist/fe/components/Button/types/index.js +1 -0
- package/dist/fe/components/Button/utils/cn.js +5 -0
- package/dist/fe/components/Captcha/components/Captcha.js +311 -0
- package/dist/fe/components/Captcha/index.js +2 -0
- package/dist/fe/components/Captcha/theme.js +52 -0
- package/dist/fe/components/Captcha/types.js +1 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
- package/dist/fe/components/ChangePasswordPage/index.js +5 -0
- package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
- package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
- package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
- package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
- package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
- package/dist/fe/components/Checkbox/index.js +4 -0
- package/dist/fe/components/Checkbox/theme/index.js +221 -0
- package/dist/fe/components/Checkbox/types/index.js +1 -0
- package/dist/fe/components/Checkbox/utils/cn.js +5 -0
- package/dist/fe/components/DataTable/DataTable.js +225 -0
- package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
- package/dist/fe/components/DataTable/components/DataCell.js +76 -0
- package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
- package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
- package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
- package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
- package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
- package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
- package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
- package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
- package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
- package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
- package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
- package/dist/fe/components/DataTable/components/TableRow.js +118 -0
- package/dist/fe/components/DataTable/components/index.js +14 -0
- package/dist/fe/components/DataTable/hooks/index.js +2 -0
- package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
- package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
- package/dist/fe/components/DataTable/index.js +3 -0
- package/dist/fe/components/DataTable/store/index.js +97 -0
- package/dist/fe/components/DataTable/theme/index.js +144 -0
- package/dist/fe/components/DataTable/types/index.js +1 -0
- package/dist/fe/components/DataTable/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
- package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
- package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
- package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
- package/dist/fe/components/DatePicker/index.js +7 -0
- package/dist/fe/components/DatePicker/locales/index.js +1113 -0
- package/dist/fe/components/DatePicker/theme/index.js +315 -0
- package/dist/fe/components/DatePicker/types/index.js +1 -0
- package/dist/fe/components/DatePicker/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/utils/date.js +132 -0
- package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
- package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
- package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
- package/dist/fe/components/DevicesPage/index.js +5 -0
- package/dist/fe/components/DevicesPage/store/index.js +55 -0
- package/dist/fe/components/DevicesPage/theme/index.js +131 -0
- package/dist/fe/components/DevicesPage/types/index.js +1 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
- package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
- package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
- package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
- package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
- package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
- package/dist/fe/components/FormBuilder/index.js +4 -0
- package/dist/fe/components/FormBuilder/theme/index.js +134 -0
- package/dist/fe/components/FormBuilder/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
- package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
- package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
- package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
- package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
- package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
- package/dist/fe/components/LoginPage/index.js +5 -0
- package/dist/fe/components/LoginPage/store/index.js +59 -0
- package/dist/fe/components/LoginPage/theme/index.js +98 -0
- package/dist/fe/components/LoginPage/types/index.js +1 -0
- package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
- package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
- package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
- package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
- package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
- package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
- package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
- package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
- package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
- package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
- package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
- package/dist/fe/components/NucleusTextInput/index.js +7 -0
- package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
- package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
- package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
- package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
- package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
- package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
- package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
- package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
- package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
- package/dist/fe/components/ProfilePage/index.js +6 -0
- package/dist/fe/components/ProfilePage/store/index.js +115 -0
- package/dist/fe/components/ProfilePage/theme/index.js +168 -0
- package/dist/fe/components/ProfilePage/types/index.js +1 -0
- package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
- package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
- package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
- package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
- package/dist/fe/components/RangePicker/index.js +5 -0
- package/dist/fe/components/RangePicker/theme/index.js +88 -0
- package/dist/fe/components/RangePicker/types/index.js +1 -0
- package/dist/fe/components/RangePicker/utils/cn.js +3 -0
- package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
- package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
- package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
- package/dist/fe/components/RegisterPage/index.js +6 -0
- package/dist/fe/components/RegisterPage/store/index.js +106 -0
- package/dist/fe/components/RegisterPage/theme/index.js +128 -0
- package/dist/fe/components/RegisterPage/types/index.js +1 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
- package/dist/fe/components/ResetPasswordPage/index.js +5 -0
- package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
- package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
- package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
- package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
- package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
- package/dist/fe/components/SearchBox/index.js +5 -0
- package/dist/fe/components/SearchBox/theme/index.js +184 -0
- package/dist/fe/components/SearchBox/types/index.js +1 -0
- package/dist/fe/components/SearchBox/utils/cn.js +5 -0
- package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
- package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
- package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
- package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
- package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
- package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
- package/dist/fe/components/SelectBox/index.js +5 -0
- package/dist/fe/components/SelectBox/theme/index.js +98 -0
- package/dist/fe/components/SelectBox/types/index.js +1 -0
- package/dist/fe/components/SelectBox/utils/cn.js +3 -0
- package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
- package/dist/fe/components/SetPasswordPage/index.js +7 -0
- package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
- package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
- package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
- package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
- package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
- package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
- package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
- package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
- package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
- package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
- package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
- package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
- package/dist/fe/components/UsersPage/index.js +10 -0
- package/dist/fe/components/UsersPage/store/index.js +151 -0
- package/dist/fe/components/UsersPage/theme/index.js +231 -0
- package/dist/fe/components/UsersPage/types/index.js +1 -0
- package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
- package/dist/fe/components/VerifyEmailPage/index.js +3 -0
- package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
- package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
- package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
- package/dist/fe/hooks/useNucleusEntity.js +247 -0
- package/dist/fe/index.js +28 -110
- package/dist/fe/types/index.js +1 -0
- package/dist/fe/utils/cn.js +5 -0
- package/dist/fe/utils/columnUtils.js +189 -0
- package/dist/fe/utils/endpointKeys.js +44 -0
- package/dist/index.js +1 -1
- package/dist/nucleus.config.d.ts +3 -0
- package/dist/src/Client/Proxy/httpProxy.js +1 -0
- package/dist/src/Client/Proxy/index.js +1 -1
- package/dist/src/Client/Proxy/server.js +1 -0
- package/dist/src/Client/Proxy/types.js +1 -0
- package/dist/src/Client/Proxy/utils.js +1 -0
- package/dist/src/Client/Proxy/wsProxy.js +1 -0
- package/package.json +1 -1
- package/scripts/build.ts +78 -8
- package/dist/dist/index-0yyw12k6.d.ts +0 -8
- package/dist/dist/index-tv67j5qd.d.ts +0 -488
- package/dist/index-0yyw12k6.js +0 -1
- package/dist/index-tv67j5qd.js +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../utils/cn";
|
|
4
|
+
import { authorizationPageTheme } from "../theme";
|
|
5
|
+
export function ClaimList({ claims, isLoading }) {
|
|
6
|
+
const theme = authorizationPageTheme;
|
|
7
|
+
const getClaimEntity = (action)=>{
|
|
8
|
+
const parts = action.split(".");
|
|
9
|
+
if (parts[1] === "bulk") {
|
|
10
|
+
return parts[2] || "bulk";
|
|
11
|
+
}
|
|
12
|
+
return parts[1] || "other";
|
|
13
|
+
};
|
|
14
|
+
const groupedClaims = claims.reduce((acc, claim)=>{
|
|
15
|
+
const entity = getClaimEntity(claim.action);
|
|
16
|
+
if (!acc[entity]) {
|
|
17
|
+
acc[entity] = [];
|
|
18
|
+
}
|
|
19
|
+
acc[entity].push(claim);
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
const getMethodBadgeClass = (method)=>{
|
|
23
|
+
const methodLower = method.toLowerCase();
|
|
24
|
+
if (methodLower === "get") return theme.claimList.methodBadge.get;
|
|
25
|
+
if (methodLower === "post") return theme.claimList.methodBadge.post;
|
|
26
|
+
if (methodLower === "put") return theme.claimList.methodBadge.put;
|
|
27
|
+
if (methodLower === "patch") return theme.claimList.methodBadge.patch;
|
|
28
|
+
if (methodLower === "delete") return theme.claimList.methodBadge.delete;
|
|
29
|
+
return theme.claimList.methodBadge.get;
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
32
|
+
className: theme.card.wrapper,
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
35
|
+
className: theme.card.header,
|
|
36
|
+
children: "All Claims"
|
|
37
|
+
}),
|
|
38
|
+
isLoading ? /*#__PURE__*/ _jsx("div", {
|
|
39
|
+
className: theme.loading.wrapper,
|
|
40
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
41
|
+
className: theme.loading.text,
|
|
42
|
+
children: "Loading claims..."
|
|
43
|
+
})
|
|
44
|
+
}) : Object.keys(groupedClaims).length === 0 ? /*#__PURE__*/ _jsx("div", {
|
|
45
|
+
className: theme.empty.wrapper,
|
|
46
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
47
|
+
className: theme.empty.text,
|
|
48
|
+
children: "No claims match the filters."
|
|
49
|
+
})
|
|
50
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
51
|
+
className: theme.claimList.wrapper,
|
|
52
|
+
children: Object.entries(groupedClaims).map(([entity, entityClaims])=>/*#__PURE__*/ _jsxs("div", {
|
|
53
|
+
className: theme.claimList.group,
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
56
|
+
className: theme.claimList.groupHeader,
|
|
57
|
+
children: [
|
|
58
|
+
entity,
|
|
59
|
+
" (",
|
|
60
|
+
entityClaims.length,
|
|
61
|
+
")"
|
|
62
|
+
]
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ _jsx("div", {
|
|
65
|
+
className: "divide-y divide-zinc-200 dark:divide-zinc-700",
|
|
66
|
+
children: entityClaims.map((claim)=>/*#__PURE__*/ _jsx("div", {
|
|
67
|
+
className: theme.claimList.item,
|
|
68
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
69
|
+
className: "flex items-center justify-between",
|
|
70
|
+
children: [
|
|
71
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
72
|
+
className: "flex-1 min-w-0",
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ _jsx("div", {
|
|
75
|
+
className: theme.claimList.itemAction,
|
|
76
|
+
children: claim.action
|
|
77
|
+
}),
|
|
78
|
+
/*#__PURE__*/ _jsx("div", {
|
|
79
|
+
className: theme.claimList.itemDescription,
|
|
80
|
+
children: claim.description
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsx("div", {
|
|
85
|
+
className: "flex items-center gap-2",
|
|
86
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
87
|
+
className: cn("px-2 py-0.5 text-xs rounded-full", getMethodBadgeClass(claim.method)),
|
|
88
|
+
children: claim.method
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
}, claim.id))
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
}, entity))
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../utils/cn";
|
|
4
|
+
import { authorizationPageTheme } from "../theme";
|
|
5
|
+
export function RoleClaimEditor({ selectedRole, claims, roleClaims, isLoading, isToggling, onToggleClaim, onUpdateScope, editingScope, onEditScope, scopeValue, onScopeValueChange }) {
|
|
6
|
+
const theme = authorizationPageTheme;
|
|
7
|
+
const getClaimEntity = (action)=>{
|
|
8
|
+
const parts = action.split(".");
|
|
9
|
+
if (parts[1] === "bulk") {
|
|
10
|
+
return parts[2] || "bulk";
|
|
11
|
+
}
|
|
12
|
+
return parts[1] || "other";
|
|
13
|
+
};
|
|
14
|
+
const groupedClaims = claims.reduce((acc, claim)=>{
|
|
15
|
+
const entity = getClaimEntity(claim.action);
|
|
16
|
+
if (!acc[entity]) {
|
|
17
|
+
acc[entity] = [];
|
|
18
|
+
}
|
|
19
|
+
acc[entity].push(claim);
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
const isClaimAssigned = (claimId)=>roleClaims.some((rc)=>rc.claimId === claimId);
|
|
23
|
+
const getRoleClaimForClaim = (claimId)=>roleClaims.find((rc)=>rc.claimId === claimId);
|
|
24
|
+
const handleScopeSubmit = (roleClaimId)=>{
|
|
25
|
+
if (onUpdateScope && scopeValue !== undefined) {
|
|
26
|
+
onUpdateScope(roleClaimId, scopeValue);
|
|
27
|
+
onEditScope?.(null);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const handleScopeCancel = ()=>{
|
|
31
|
+
onEditScope?.(null);
|
|
32
|
+
};
|
|
33
|
+
const startEditingScope = (claimId, currentScope)=>{
|
|
34
|
+
onScopeValueChange?.(currentScope || "");
|
|
35
|
+
onEditScope?.(claimId);
|
|
36
|
+
};
|
|
37
|
+
if (!selectedRole) {
|
|
38
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
39
|
+
className: theme.card.wrapper,
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
42
|
+
className: theme.card.header,
|
|
43
|
+
children: "Select a role"
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ _jsx("div", {
|
|
46
|
+
className: theme.empty.wrapper,
|
|
47
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
48
|
+
className: theme.empty.text,
|
|
49
|
+
children: "Select a role from the list to manage its claims"
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (selectedRole.name === "godmin") {
|
|
56
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
57
|
+
className: theme.card.wrapper,
|
|
58
|
+
children: [
|
|
59
|
+
/*#__PURE__*/ _jsxs("h2", {
|
|
60
|
+
className: theme.card.header,
|
|
61
|
+
children: [
|
|
62
|
+
'Claims for "',
|
|
63
|
+
selectedRole.name,
|
|
64
|
+
'"'
|
|
65
|
+
]
|
|
66
|
+
}),
|
|
67
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
68
|
+
className: theme.empty.wrapper,
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ _jsx("svg", {
|
|
71
|
+
className: theme.empty.icon,
|
|
72
|
+
fill: "none",
|
|
73
|
+
stroke: "currentColor",
|
|
74
|
+
viewBox: "0 0 24 24",
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
77
|
+
strokeLinecap: "round",
|
|
78
|
+
strokeLinejoin: "round",
|
|
79
|
+
strokeWidth: 2,
|
|
80
|
+
d: "M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"
|
|
81
|
+
})
|
|
82
|
+
}),
|
|
83
|
+
/*#__PURE__*/ _jsxs("p", {
|
|
84
|
+
className: theme.empty.text,
|
|
85
|
+
children: [
|
|
86
|
+
"Godmin role has full access to all resources.",
|
|
87
|
+
/*#__PURE__*/ _jsx("br", {}),
|
|
88
|
+
"Claims cannot be modified."
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
97
|
+
className: theme.card.wrapper,
|
|
98
|
+
children: [
|
|
99
|
+
/*#__PURE__*/ _jsxs("h2", {
|
|
100
|
+
className: theme.card.header,
|
|
101
|
+
children: [
|
|
102
|
+
'Claims for "',
|
|
103
|
+
selectedRole.name,
|
|
104
|
+
'"'
|
|
105
|
+
]
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
108
|
+
className: theme.stats.text,
|
|
109
|
+
children: [
|
|
110
|
+
roleClaims.length,
|
|
111
|
+
" claims assigned"
|
|
112
|
+
]
|
|
113
|
+
}),
|
|
114
|
+
isLoading ? /*#__PURE__*/ _jsx("div", {
|
|
115
|
+
className: theme.loading.wrapper,
|
|
116
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
117
|
+
className: theme.loading.text,
|
|
118
|
+
children: "Loading claims..."
|
|
119
|
+
})
|
|
120
|
+
}) : Object.keys(groupedClaims).length === 0 ? /*#__PURE__*/ _jsx("div", {
|
|
121
|
+
className: theme.empty.wrapper,
|
|
122
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
123
|
+
className: theme.empty.text,
|
|
124
|
+
children: "No claims match the filters."
|
|
125
|
+
})
|
|
126
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
127
|
+
className: "max-h-[500px] overflow-y-auto space-y-4",
|
|
128
|
+
children: Object.entries(groupedClaims).map(([entity, entityClaims])=>/*#__PURE__*/ _jsxs("div", {
|
|
129
|
+
className: theme.claimList.group,
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
132
|
+
className: theme.claimList.groupHeader,
|
|
133
|
+
children: [
|
|
134
|
+
entity,
|
|
135
|
+
" (",
|
|
136
|
+
entityClaims.length,
|
|
137
|
+
")"
|
|
138
|
+
]
|
|
139
|
+
}),
|
|
140
|
+
/*#__PURE__*/ _jsx("div", {
|
|
141
|
+
className: "divide-y divide-zinc-200 dark:divide-zinc-700",
|
|
142
|
+
children: entityClaims.map((claim)=>{
|
|
143
|
+
const assigned = isClaimAssigned(claim.id);
|
|
144
|
+
const roleClaim = getRoleClaimForClaim(claim.id);
|
|
145
|
+
const isEditingThisClaim = editingScope === claim.id;
|
|
146
|
+
const currentScope = roleClaim?.scope || "";
|
|
147
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
148
|
+
className: cn("py-3 px-2 hover:bg-zinc-50 dark:hover:bg-zinc-800/50 transition-colors", assigned && "bg-emerald-50/50 dark:bg-emerald-900/10"),
|
|
149
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
150
|
+
className: "flex items-start gap-3",
|
|
151
|
+
children: [
|
|
152
|
+
/*#__PURE__*/ _jsx("input", {
|
|
153
|
+
type: "checkbox",
|
|
154
|
+
checked: assigned,
|
|
155
|
+
onChange: ()=>onToggleClaim(claim, assigned),
|
|
156
|
+
disabled: isToggling || claim.id.startsWith("temp-"),
|
|
157
|
+
className: cn(theme.checkbox.input, "mt-1 shrink-0")
|
|
158
|
+
}),
|
|
159
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
160
|
+
className: "flex-1 min-w-0",
|
|
161
|
+
children: [
|
|
162
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
163
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
164
|
+
children: [
|
|
165
|
+
/*#__PURE__*/ _jsx("span", {
|
|
166
|
+
className: "text-sm font-mono text-zinc-900 dark:text-zinc-100 truncate",
|
|
167
|
+
children: claim.action
|
|
168
|
+
}),
|
|
169
|
+
/*#__PURE__*/ _jsx("span", {
|
|
170
|
+
className: cn("px-1.5 py-0.5 text-xs font-medium rounded", claim.method === "GET" && "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400", claim.method === "POST" && "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400", claim.method === "PUT" && "bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400", claim.method === "PATCH" && "bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400", claim.method === "DELETE" && "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"),
|
|
171
|
+
children: claim.method
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ _jsx("p", {
|
|
176
|
+
className: "text-xs text-zinc-500 dark:text-zinc-400 mt-0.5",
|
|
177
|
+
children: claim.description
|
|
178
|
+
}),
|
|
179
|
+
assigned && roleClaim && !roleClaim.id.startsWith("temp-") && /*#__PURE__*/ _jsx("div", {
|
|
180
|
+
className: "mt-2",
|
|
181
|
+
children: isEditingThisClaim ? /*#__PURE__*/ _jsxs("div", {
|
|
182
|
+
className: "flex items-center gap-2",
|
|
183
|
+
children: [
|
|
184
|
+
/*#__PURE__*/ _jsx("input", {
|
|
185
|
+
type: "text",
|
|
186
|
+
value: scopeValue || "",
|
|
187
|
+
onChange: (e)=>onScopeValueChange?.(e.target.value),
|
|
188
|
+
placeholder: "e.g. user_id=123&tenant_id=456",
|
|
189
|
+
className: "flex-1 px-2 py-1 text-xs border border-zinc-300 dark:border-zinc-600 rounded bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100 placeholder:text-zinc-400"
|
|
190
|
+
}),
|
|
191
|
+
/*#__PURE__*/ _jsx("button", {
|
|
192
|
+
type: "button",
|
|
193
|
+
onClick: ()=>handleScopeSubmit(roleClaim.id),
|
|
194
|
+
className: "px-2 py-1 text-xs font-medium text-white bg-emerald-600 hover:bg-emerald-700 rounded transition-colors",
|
|
195
|
+
children: "Save"
|
|
196
|
+
}),
|
|
197
|
+
/*#__PURE__*/ _jsx("button", {
|
|
198
|
+
type: "button",
|
|
199
|
+
onClick: handleScopeCancel,
|
|
200
|
+
className: "px-2 py-1 text-xs font-medium text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors",
|
|
201
|
+
children: "Cancel"
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
}) : /*#__PURE__*/ _jsx("button", {
|
|
205
|
+
type: "button",
|
|
206
|
+
onClick: ()=>startEditingScope(claim.id, currentScope),
|
|
207
|
+
className: "text-xs text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200 transition-colors",
|
|
208
|
+
children: currentScope ? /*#__PURE__*/ _jsxs("span", {
|
|
209
|
+
className: "font-mono bg-zinc-100 dark:bg-zinc-800 px-1.5 py-0.5 rounded",
|
|
210
|
+
children: [
|
|
211
|
+
"Scope: ",
|
|
212
|
+
currentScope
|
|
213
|
+
]
|
|
214
|
+
}) : /*#__PURE__*/ _jsx("span", {
|
|
215
|
+
className: "italic",
|
|
216
|
+
children: "+ Add scope filter"
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
})
|
|
224
|
+
}, claim.id);
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
}, entity))
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
});
|
|
232
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../utils/cn";
|
|
4
|
+
import { authorizationPageTheme } from "../theme";
|
|
5
|
+
export function RoleList({ roles, selectedRole, isLoading, isCreating, isDeleting, newRoleName, newRoleDescription, onNewRoleNameChange, onNewRoleDescriptionChange, onSelectRole, onDeleteRole, onCreateRole }) {
|
|
6
|
+
const theme = authorizationPageTheme;
|
|
7
|
+
const handleDelete = (e, roleId)=>{
|
|
8
|
+
e.stopPropagation();
|
|
9
|
+
if (confirm("Are you sure you want to delete this role?")) {
|
|
10
|
+
onDeleteRole(roleId);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const isTempId = (id)=>id.startsWith("temp-");
|
|
14
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
15
|
+
className: theme.card.wrapper,
|
|
16
|
+
children: [
|
|
17
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
18
|
+
className: theme.card.header,
|
|
19
|
+
children: "Roles"
|
|
20
|
+
}),
|
|
21
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
22
|
+
className: theme.form.wrapper,
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ _jsx("h3", {
|
|
25
|
+
className: theme.form.title,
|
|
26
|
+
children: "Create New Role"
|
|
27
|
+
}),
|
|
28
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
29
|
+
className: "space-y-3",
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ _jsx("input", {
|
|
32
|
+
type: "text",
|
|
33
|
+
placeholder: "Role name",
|
|
34
|
+
value: newRoleName,
|
|
35
|
+
onChange: (e)=>onNewRoleNameChange(e.target.value),
|
|
36
|
+
className: theme.form.input
|
|
37
|
+
}),
|
|
38
|
+
/*#__PURE__*/ _jsx("input", {
|
|
39
|
+
type: "text",
|
|
40
|
+
placeholder: "Description (optional)",
|
|
41
|
+
value: newRoleDescription,
|
|
42
|
+
onChange: (e)=>onNewRoleDescriptionChange(e.target.value),
|
|
43
|
+
className: theme.form.input
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ _jsx("button", {
|
|
46
|
+
type: "button",
|
|
47
|
+
onClick: onCreateRole,
|
|
48
|
+
disabled: !newRoleName.trim() || isCreating,
|
|
49
|
+
className: cn(theme.form.button, (!newRoleName.trim() || isCreating) && theme.form.buttonDisabled),
|
|
50
|
+
children: isCreating ? "Creating..." : "Create Role"
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
}),
|
|
56
|
+
isLoading ? /*#__PURE__*/ _jsx("div", {
|
|
57
|
+
className: theme.loading.wrapper,
|
|
58
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
59
|
+
className: theme.loading.text,
|
|
60
|
+
children: "Loading roles..."
|
|
61
|
+
})
|
|
62
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
63
|
+
className: theme.roleList.wrapper,
|
|
64
|
+
children: roles.map((role)=>/*#__PURE__*/ _jsx("button", {
|
|
65
|
+
type: "button",
|
|
66
|
+
onClick: ()=>onSelectRole(role),
|
|
67
|
+
disabled: isTempId(role.id),
|
|
68
|
+
className: cn(theme.roleList.item, selectedRole?.id === role.id ? theme.roleList.itemSelected : theme.roleList.itemHover, isTempId(role.id) && "opacity-50 cursor-wait"),
|
|
69
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
70
|
+
className: "flex items-center justify-between",
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ _jsxs("h4", {
|
|
75
|
+
className: theme.roleList.name,
|
|
76
|
+
children: [
|
|
77
|
+
role.name,
|
|
78
|
+
role.name === "godmin" && /*#__PURE__*/ _jsx("span", {
|
|
79
|
+
className: theme.roleList.badge,
|
|
80
|
+
children: "Super Admin"
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
}),
|
|
84
|
+
role.description && /*#__PURE__*/ _jsx("p", {
|
|
85
|
+
className: theme.roleList.description,
|
|
86
|
+
children: role.description
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
}),
|
|
90
|
+
role.name !== "godmin" && !isTempId(role.id) && /*#__PURE__*/ _jsx("button", {
|
|
91
|
+
type: "button",
|
|
92
|
+
onClick: (e)=>handleDelete(e, role.id),
|
|
93
|
+
disabled: isDeleting,
|
|
94
|
+
className: cn(theme.roleList.deleteButton, isDeleting && "opacity-50 cursor-not-allowed"),
|
|
95
|
+
children: /*#__PURE__*/ _jsx("svg", {
|
|
96
|
+
className: "w-5 h-5",
|
|
97
|
+
fill: "none",
|
|
98
|
+
stroke: "currentColor",
|
|
99
|
+
viewBox: "0 0 24 24",
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
102
|
+
strokeLinecap: "round",
|
|
103
|
+
strokeLinejoin: "round",
|
|
104
|
+
strokeWidth: 2,
|
|
105
|
+
d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
}, role.id))
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AuthorizationPage } from "./components/AuthorizationPage";
|
|
2
|
+
export { ClaimList } from "./components/ClaimList";
|
|
3
|
+
export { RoleClaimEditor } from "./components/RoleClaimEditor";
|
|
4
|
+
export { RoleList } from "./components/RoleList";
|
|
5
|
+
export { useAuthorizationStore } from "./store";
|
|
6
|
+
export { authorizationPageTheme, extendAuthorizationPageTheme } from "./theme";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { batch, createStore } from "h-state";
|
|
3
|
+
const initialState = {
|
|
4
|
+
roles: [],
|
|
5
|
+
claims: [],
|
|
6
|
+
roleClaims: [],
|
|
7
|
+
selectedRole: null,
|
|
8
|
+
newRoleName: "",
|
|
9
|
+
newRoleDescription: "",
|
|
10
|
+
searchClaim: "",
|
|
11
|
+
entityFilter: "all",
|
|
12
|
+
methodFilter: "all",
|
|
13
|
+
showAssignedOnly: false,
|
|
14
|
+
activeTab: "roles",
|
|
15
|
+
editingScopeClaimId: null,
|
|
16
|
+
scopeInputValue: "",
|
|
17
|
+
editingRoleId: null,
|
|
18
|
+
editRoleDescription: ""
|
|
19
|
+
};
|
|
20
|
+
export const { useStore: useAuthorizationStore } = createStore(initialState, {
|
|
21
|
+
setRoles: (store)=>(roles)=>{
|
|
22
|
+
store.roles = roles;
|
|
23
|
+
},
|
|
24
|
+
setClaims: (store)=>(claims)=>{
|
|
25
|
+
store.claims = claims;
|
|
26
|
+
},
|
|
27
|
+
setRoleClaims: (store)=>(roleClaims)=>{
|
|
28
|
+
store.roleClaims = roleClaims;
|
|
29
|
+
},
|
|
30
|
+
setSelectedRole: (store)=>(role)=>{
|
|
31
|
+
store.selectedRole = role;
|
|
32
|
+
},
|
|
33
|
+
setNewRoleName: (store)=>(name)=>{
|
|
34
|
+
store.newRoleName = name;
|
|
35
|
+
},
|
|
36
|
+
setNewRoleDescription: (store)=>(description)=>{
|
|
37
|
+
store.newRoleDescription = description;
|
|
38
|
+
},
|
|
39
|
+
setSearchClaim: (store)=>(query)=>{
|
|
40
|
+
store.searchClaim = query;
|
|
41
|
+
},
|
|
42
|
+
setEntityFilter: (store)=>(entity)=>{
|
|
43
|
+
store.entityFilter = entity;
|
|
44
|
+
},
|
|
45
|
+
setMethodFilter: (store)=>(method)=>{
|
|
46
|
+
store.methodFilter = method;
|
|
47
|
+
},
|
|
48
|
+
setShowAssignedOnly: (store)=>(show)=>{
|
|
49
|
+
store.showAssignedOnly = show;
|
|
50
|
+
},
|
|
51
|
+
setActiveTab: (store)=>(tab)=>{
|
|
52
|
+
store.activeTab = tab;
|
|
53
|
+
},
|
|
54
|
+
addRole: (store)=>(role)=>{
|
|
55
|
+
store.roles = [
|
|
56
|
+
...store.roles,
|
|
57
|
+
role
|
|
58
|
+
];
|
|
59
|
+
},
|
|
60
|
+
removeRole: (store)=>(roleId)=>{
|
|
61
|
+
store.roles = store.roles.filter((r)=>r.id !== roleId);
|
|
62
|
+
if (store.selectedRole?.id === roleId) {
|
|
63
|
+
store.selectedRole = null;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
addRoleClaim: (store)=>(roleClaim)=>{
|
|
67
|
+
store.roleClaims = [
|
|
68
|
+
...store.roleClaims,
|
|
69
|
+
roleClaim
|
|
70
|
+
];
|
|
71
|
+
},
|
|
72
|
+
removeRoleClaim: (store)=>(roleClaimId)=>{
|
|
73
|
+
store.roleClaims = store.roleClaims.filter((rc)=>rc.id !== roleClaimId);
|
|
74
|
+
},
|
|
75
|
+
updateRoleClaimScope: (store)=>(roleClaimId, scope)=>{
|
|
76
|
+
store.roleClaims = store.roleClaims.map((rc)=>rc.id === roleClaimId ? {
|
|
77
|
+
...rc,
|
|
78
|
+
scope
|
|
79
|
+
} : rc);
|
|
80
|
+
},
|
|
81
|
+
setEditingScopeClaimId: (store)=>(claimId)=>{
|
|
82
|
+
store.editingScopeClaimId = claimId;
|
|
83
|
+
if (claimId === null) {
|
|
84
|
+
store.scopeInputValue = "";
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
setScopeInputValue: (store)=>(value)=>{
|
|
88
|
+
store.scopeInputValue = value;
|
|
89
|
+
},
|
|
90
|
+
setEditingRoleId: (store)=>(roleId)=>{
|
|
91
|
+
store.editingRoleId = roleId;
|
|
92
|
+
if (roleId === null) {
|
|
93
|
+
store.editRoleDescription = "";
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
setEditRoleDescription: (store)=>(description)=>{
|
|
97
|
+
store.editRoleDescription = description;
|
|
98
|
+
},
|
|
99
|
+
updateRole: (store)=>(roleId, updates)=>{
|
|
100
|
+
store.roles = store.roles.map((r)=>r.id === roleId ? {
|
|
101
|
+
...r,
|
|
102
|
+
...updates
|
|
103
|
+
} : r);
|
|
104
|
+
if (store.selectedRole?.id === roleId) {
|
|
105
|
+
store.selectedRole = {
|
|
106
|
+
...store.selectedRole,
|
|
107
|
+
...updates
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
resetForm: (store)=>()=>{
|
|
112
|
+
batch(()=>{
|
|
113
|
+
store.newRoleName = "";
|
|
114
|
+
store.newRoleDescription = "";
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|