@strapi-community/plugin-better-auth-dashboard 1.0.0-alpha.9 → 1.0.0-beta.2

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.
Files changed (42) hide show
  1. package/README.md +65 -0
  2. package/dist/admin/Avatar-CdT7eBCh.js +39 -0
  3. package/dist/admin/Avatar-zlMTAZh3.mjs +40 -0
  4. package/dist/admin/Root-CgVBJuoM.mjs +365 -0
  5. package/dist/admin/Root-CsiOnzlB.js +367 -0
  6. package/dist/admin/cs-C_jSgeON.js +416 -0
  7. package/dist/admin/cs-wtnknvBC.mjs +416 -0
  8. package/dist/admin/de-Cg5HyoCY.js +416 -0
  9. package/dist/admin/de-DnnVdUxk.mjs +416 -0
  10. package/dist/admin/en-B3utEgMT.mjs +416 -0
  11. package/dist/admin/en-Cz1IJEvp.js +416 -0
  12. package/dist/admin/es-CGA0Tslt.js +416 -0
  13. package/dist/admin/es-RoCEriJL.mjs +416 -0
  14. package/dist/admin/fr-Ca74t21t.js +416 -0
  15. package/dist/admin/fr-CtmuSfiQ.mjs +416 -0
  16. package/dist/admin/index-BCBu-0nr.js +457 -0
  17. package/dist/admin/index-BI2WIsds.mjs +458 -0
  18. package/dist/admin/index-CPSoAbZt.js +2321 -0
  19. package/dist/admin/index-D9ttdrT3.js +2716 -0
  20. package/dist/admin/index-DQdn5s8q.js +1184 -0
  21. package/dist/admin/index-DvfwvCj0.mjs +1182 -0
  22. package/dist/admin/index-VyHXoQ6p.mjs +2321 -0
  23. package/dist/admin/index-gFqHlMLP.mjs +2716 -0
  24. package/dist/admin/index.js +2 -2
  25. package/dist/admin/index.mjs +2 -2
  26. package/dist/admin/it-BAB9hDdp.mjs +416 -0
  27. package/dist/admin/it-dYT2_ERV.js +416 -0
  28. package/dist/admin/nl-CVqSbUU9.js +416 -0
  29. package/dist/admin/nl-CYv26PHv.mjs +416 -0
  30. package/dist/admin/pl-Bc0cS2mD.mjs +416 -0
  31. package/dist/admin/pl-HYF4BxRv.js +416 -0
  32. package/dist/admin/pt-DDUGyLtb.js +416 -0
  33. package/dist/admin/pt-DZyyK3EG.mjs +416 -0
  34. package/dist/admin/useModelSchema-BogQah8f.js +756 -0
  35. package/dist/admin/useModelSchema-C6bxNjW4.mjs +755 -0
  36. package/dist/server/index.js +220 -10
  37. package/dist/server/index.mjs +220 -10
  38. package/package.json +5 -4
  39. package/dist/admin/Root-BYdYQBE5.mjs +0 -5742
  40. package/dist/admin/Root-D_vCtQoC.js +0 -5744
  41. package/dist/admin/index-BMTIuxZI.mjs +0 -96
  42. package/dist/admin/index-CkSsWnBx.js +0 -95
@@ -0,0 +1,367 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const reactQuery = require("react-query");
6
+ const reactRouterDom = require("react-router-dom");
7
+ const index = require("./index-BCBu-0nr.js");
8
+ const designSystem = require("@strapi/design-system");
9
+ const admin = require("@strapi/strapi/admin");
10
+ const reactIntl = require("react-intl");
11
+ require("@strapi/icons");
12
+ const styled = require("styled-components");
13
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
15
+ const HEIGHT_TOP_NAVIGATION = "6.4rem";
16
+ const HEIGHT_TOP_NAVIGATION_MEDIUM = "5.6rem";
17
+ const WIDTH_SIDE_NAVIGATION = "23.2rem";
18
+ const MainSubNav = styled__default.default(designSystem.SubNav)`
19
+ width: 100%;
20
+ height: 100%;
21
+ overflow: hidden;
22
+ background-color: ${({ theme }) => theme.colors.neutral0};
23
+ display: flex;
24
+ flex-direction: column;
25
+ border-right: 0;
26
+ box-shadow: none;
27
+ position: relative;
28
+
29
+ ${({ theme }) => theme.breakpoints.medium} {
30
+ width: ${WIDTH_SIDE_NAVIGATION};
31
+ position: sticky;
32
+ top: 0;
33
+ border-right: 1px solid ${({ theme }) => theme.colors.neutral150};
34
+ overscroll-behavior: contain;
35
+ }
36
+ `;
37
+ const Main = ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(MainSubNav, { ...props, children });
38
+ const StyledLink = styled__default.default(reactRouterDom.NavLink)`
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: space-between;
42
+ text-decoration: none;
43
+ height: 32px;
44
+ color: ${({ theme }) => theme.colors.neutral800};
45
+
46
+ &.active > div {
47
+ background-color: ${({ theme }) => theme.colors.primary100};
48
+ color: ${({ theme }) => theme.colors.primary700};
49
+ font-weight: 500;
50
+ }
51
+
52
+ &:hover.active > div {
53
+ background-color: ${({ theme }) => theme.colors.primary100};
54
+ color: ${({ theme }) => theme.colors.primary700};
55
+ font-weight: 500;
56
+ }
57
+
58
+ &:hover > div {
59
+ background-color: ${({ theme }) => theme.colors.neutral100};
60
+ }
61
+
62
+ &:focus-visible {
63
+ outline-offset: -2px;
64
+ }
65
+ `;
66
+ const Link = (props) => {
67
+ const { to, label, endAction, handleClick, ...rest } = props;
68
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledLink, { to, ...rest, onClick: handleClick, children: /* @__PURE__ */ jsxRuntime.jsx(
69
+ designSystem.Box,
70
+ {
71
+ width: "100%",
72
+ paddingLeft: 3,
73
+ paddingRight: 3,
74
+ paddingTop: { initial: 1, large: 0 },
75
+ paddingBottom: { initial: 1, large: 0 },
76
+ borderRadius: 1,
77
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
78
+ designSystem.Flex,
79
+ {
80
+ justifyContent: "space-between",
81
+ width: "100%",
82
+ gap: { initial: 2, large: 1 },
83
+ children: [
84
+ /* @__PURE__ */ jsxRuntime.jsx(
85
+ designSystem.Typography,
86
+ {
87
+ tag: "div",
88
+ lineHeight: "32px",
89
+ width: { initial: "80dvw", medium: "100%" },
90
+ overflow: "hidden",
91
+ style: { textOverflow: "ellipsis", whiteSpace: "nowrap" },
92
+ children: label
93
+ }
94
+ ),
95
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, children: endAction })
96
+ ]
97
+ }
98
+ )
99
+ }
100
+ ) });
101
+ };
102
+ const StyledHeader = styled__default.default(designSystem.Flex)`
103
+ flex: 0 0 ${HEIGHT_TOP_NAVIGATION};
104
+ height: ${HEIGHT_TOP_NAVIGATION};
105
+
106
+ ${({ theme }) => theme.breakpoints.medium} {
107
+ flex: 0 0 ${HEIGHT_TOP_NAVIGATION_MEDIUM};
108
+ height: ${HEIGHT_TOP_NAVIGATION_MEDIUM};
109
+ }
110
+ `;
111
+ const Header = ({ label }) => {
112
+ return /* @__PURE__ */ jsxRuntime.jsx(
113
+ StyledHeader,
114
+ {
115
+ justifyContent: "space-between",
116
+ paddingLeft: 5,
117
+ paddingRight: 5,
118
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", children: label })
119
+ }
120
+ );
121
+ };
122
+ const Sections = ({
123
+ children,
124
+ ...props
125
+ }) => {
126
+ return /* @__PURE__ */ jsxRuntime.jsx(
127
+ designSystem.Box,
128
+ {
129
+ paddingTop: { initial: 5, large: 4 },
130
+ paddingBottom: { initial: 5, large: 4 },
131
+ paddingLeft: { initial: 3, large: 0 },
132
+ paddingRight: { initial: 3, large: 0 },
133
+ maxWidth: { initial: "100%", medium: WIDTH_SIDE_NAVIGATION },
134
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { tag: "ul", gap: 6, direction: "column", alignItems: "stretch", ...props, children: children.map((child, index2) => {
135
+ return /* @__PURE__ */ jsxRuntime.jsx("li", { children: child }, index2);
136
+ }) })
137
+ }
138
+ );
139
+ };
140
+ const Section = ({
141
+ label,
142
+ children,
143
+ badgeLabel
144
+ }) => {
145
+ const listId = react.useId();
146
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
147
+ /* @__PURE__ */ jsxRuntime.jsx(
148
+ designSystem.Box,
149
+ {
150
+ paddingLeft: {
151
+ initial: 3,
152
+ large: 5
153
+ },
154
+ paddingRight: {
155
+ initial: 3,
156
+ large: 5
157
+ },
158
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { position: "relative", justifyContent: "space-between", gap: 2, children: [
159
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: label }) }) }),
160
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: badgeLabel && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral600", children: badgeLabel }) })
161
+ ] })
162
+ }
163
+ ),
164
+ /* @__PURE__ */ jsxRuntime.jsx(
165
+ designSystem.Flex,
166
+ {
167
+ tag: "ol",
168
+ id: listId,
169
+ direction: "column",
170
+ gap: { initial: 2, large: "2px" },
171
+ alignItems: "stretch",
172
+ marginLeft: {
173
+ initial: 0,
174
+ large: 2
175
+ },
176
+ marginRight: {
177
+ initial: 0,
178
+ large: 2
179
+ },
180
+ children: children.map((child, index2) => {
181
+ return /* @__PURE__ */ jsxRuntime.jsx("li", { children: child }, index2);
182
+ })
183
+ }
184
+ )
185
+ ] });
186
+ };
187
+ styled__default.default.button`
188
+ cursor: pointer;
189
+ width: 100%;
190
+ border: none;
191
+ padding: 0;
192
+ background: transparent;
193
+ display: flex;
194
+ align-items: center;
195
+ border-radius: ${({ theme }) => theme.borderRadius};
196
+ padding-left: ${({ theme }) => theme.spaces[3]};
197
+ padding-right: ${({ theme }) => theme.spaces[3]};
198
+ padding-top: ${({ theme }) => theme.spaces[2]};
199
+ padding-bottom: ${({ theme }) => theme.spaces[2]};
200
+
201
+ &:hover {
202
+ background-color: ${({ theme }) => theme.colors.neutral100};
203
+ }
204
+ `;
205
+ styled__default.default.li`
206
+ ${StyledLink} > div {
207
+ padding-left: 36px;
208
+ }
209
+ `;
210
+ styled__default.default(designSystem.Box)`
211
+ width: 100%;
212
+
213
+ ${MainSubNav} {
214
+ background-color: transparent;
215
+ border-right: none;
216
+ }
217
+
218
+ ${({ theme }) => theme.breakpoints.medium} {
219
+ overflow: hidden;
220
+
221
+ ${MainSubNav} {
222
+ top: 0;
223
+ }
224
+ }
225
+ `;
226
+ const Content = ({ children }) => {
227
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.ScrollArea, { children });
228
+ };
229
+ const SubNav = {
230
+ Main,
231
+ Content,
232
+ Header,
233
+ Link,
234
+ Sections,
235
+ Section
236
+ };
237
+ const Nav = ({ isFullPage = false }) => {
238
+ const { formatMessage } = reactIntl.useIntl();
239
+ const queryClient = reactQuery.useQueryClient();
240
+ const checkUserHasPermissions = admin.useAuth(
241
+ "DashboardNav",
242
+ (state) => state.checkUserHasPermissions
243
+ );
244
+ const dashLinks = index.getDashLinks();
245
+ const headerLabel = formatMessage({
246
+ id: index.getTranslation("components.nav.header"),
247
+ defaultMessage: "Authentication"
248
+ });
249
+ const [sections, setSections] = react.useState([]);
250
+ react.useEffect(() => {
251
+ let isCurrent = true;
252
+ const loadAuthorizedSections = async () => {
253
+ const authorizedSections = await Promise.all(
254
+ Object.values(dashLinks).map(async (section) => ({
255
+ ...section,
256
+ links: (await Promise.all(
257
+ section.links.map(async (link) => {
258
+ const permissions = link.permissions ?? [];
259
+ const [hasPermission, isAvailable] = await Promise.all([
260
+ permissions.length === 0 ? true : checkUserHasPermissions(permissions).then(
261
+ (authorizedPermissions) => authorizedPermissions.length > 0
262
+ ),
263
+ queryClient.fetchQuery(
264
+ index.getDashLinkAvailabilityQueryKey(link),
265
+ () => index.resolveDashLinkAvailability(link),
266
+ { staleTime: index.DASH_LINK_AVAILABILITY_STALE_TIME }
267
+ )
268
+ ]);
269
+ return hasPermission && isAvailable ? link : null;
270
+ })
271
+ )).filter((link) => link !== null)
272
+ }))
273
+ );
274
+ if (isCurrent) {
275
+ setSections(
276
+ authorizedSections.filter((section) => section.links.length > 0).sort(
277
+ (a, b) => (a.priority ?? 0) - (b.priority ?? 0) || a.id.localeCompare(b.id)
278
+ )
279
+ );
280
+ }
281
+ };
282
+ loadAuthorizedSections();
283
+ return () => {
284
+ isCurrent = false;
285
+ };
286
+ }, [checkUserHasPermissions, dashLinks, queryClient]);
287
+ return /* @__PURE__ */ jsxRuntime.jsxs(SubNav.Main, { children: [
288
+ !isFullPage && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
289
+ /* @__PURE__ */ jsxRuntime.jsx(SubNav.Header, { label: headerLabel }),
290
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {})
291
+ ] }),
292
+ /* @__PURE__ */ jsxRuntime.jsxs(SubNav.Content, { children: [
293
+ isFullPage && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
294
+ /* @__PURE__ */ jsxRuntime.jsx(SubNav.Header, { label: headerLabel }),
295
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {})
296
+ ] }),
297
+ /* @__PURE__ */ jsxRuntime.jsx(SubNav.Sections, { "data-testid": "main-nav", children: sections.map((section) => /* @__PURE__ */ jsxRuntime.jsx(
298
+ SubNav.Section,
299
+ {
300
+ label: formatMessage(section.intlLabel),
301
+ children: section.links.map((link) => {
302
+ return /* @__PURE__ */ jsxRuntime.jsx(
303
+ SubNav.Link,
304
+ {
305
+ to: `/plugins/${index.PLUGIN_ID}/${link.to.replace(/^\/+/, "")}`,
306
+ label: formatMessage(link.intlLabel),
307
+ "data-testid": `nav-${link.id}`,
308
+ children: formatMessage(link.intlLabel)
309
+ },
310
+ link.id
311
+ );
312
+ })
313
+ },
314
+ section.id
315
+ )) })
316
+ ] })
317
+ ] });
318
+ };
319
+ const RESPONSIVE_DEFAULT_SPACING = {
320
+ initial: 4,
321
+ medium: 6,
322
+ large: 10
323
+ };
324
+ const App = () => {
325
+ const { formatMessage } = reactIntl.useIntl();
326
+ return /* @__PURE__ */ jsxRuntime.jsx(
327
+ "div",
328
+ {
329
+ "data-testid": "dashboard-root",
330
+ style: { display: "flex", flex: "1 1 auto", minHeight: "100vh" },
331
+ children: /* @__PURE__ */ jsxRuntime.jsxs(admin.Layouts.Root, { sideNav: /* @__PURE__ */ jsxRuntime.jsx(Nav, {}), children: [
332
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: formatMessage({
333
+ id: index.getTranslation("common.page.title"),
334
+ defaultMessage: "Authentication"
335
+ }) }),
336
+ /* @__PURE__ */ jsxRuntime.jsx(
337
+ designSystem.Box,
338
+ {
339
+ display: { initial: "block", medium: "none" },
340
+ paddingLeft: RESPONSIVE_DEFAULT_SPACING,
341
+ paddingRight: RESPONSIVE_DEFAULT_SPACING,
342
+ paddingTop: RESPONSIVE_DEFAULT_SPACING,
343
+ children: /* @__PURE__ */ jsxRuntime.jsx(admin.BackButton, { fallback: "/plugins/better-auth-dashboard" })
344
+ }
345
+ ),
346
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
347
+ ] })
348
+ }
349
+ );
350
+ };
351
+ function Root() {
352
+ const isDashboardIndex = reactRouterDom.useMatch({
353
+ path: `/plugins/${index.PLUGIN_ID}`,
354
+ end: true
355
+ });
356
+ const queryClient = react.useMemo(
357
+ () => new reactQuery.QueryClient({
358
+ defaultOptions: {
359
+ queries: { retry: 1, refetchOnWindowFocus: false, staleTime: 3e4 }
360
+ }
361
+ }),
362
+ []
363
+ );
364
+ return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children: isDashboardIndex ? /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "overview", replace: true }) : /* @__PURE__ */ jsxRuntime.jsx(App, {}) });
365
+ }
366
+ exports.Root = Root;
367
+ exports.default = Root;