react-toolkits 0.1.0 → 0.1.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 (56) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.css +1 -251
  3. package/dist/index.css.map +1 -1
  4. package/dist/index.d.mts +1 -1
  5. package/dist/index.esm.js +14 -3569
  6. package/dist/index.esm.js.map +1 -1
  7. package/package.json +11 -5
  8. package/.eslintignore +0 -2
  9. package/.eslintrc.js +0 -4
  10. package/.turbo/turbo-build.log +0 -20
  11. package/postcss.config.js +0 -9
  12. package/src/assets/512_orange_nobackground.png +0 -0
  13. package/src/components/DynamicTags/index.tsx +0 -160
  14. package/src/components/FilterForm/index.tsx +0 -63
  15. package/src/components/FormModal/hooks.tsx +0 -47
  16. package/src/components/FormModal/index.tsx +0 -137
  17. package/src/components/GameSelect/index.tsx +0 -82
  18. package/src/components/Highlight/index.tsx +0 -51
  19. package/src/components/Layout/index.tsx +0 -90
  20. package/src/components/NavMenu/index.tsx +0 -142
  21. package/src/components/PermissionButton/index.tsx +0 -36
  22. package/src/components/QueryList/index.tsx +0 -152
  23. package/src/components/ReactToolkitsProvider/context.ts +0 -76
  24. package/src/components/ReactToolkitsProvider/index.tsx +0 -23
  25. package/src/components/UserWidget/index.tsx +0 -46
  26. package/src/components/index.ts +0 -51
  27. package/src/constants/index.ts +0 -1
  28. package/src/features/permission/components/PermissionCollapse/index.tsx +0 -121
  29. package/src/features/permission/components/PermissionList/index.tsx +0 -28
  30. package/src/features/permission/components/PermissionListV1/index.tsx +0 -42
  31. package/src/features/permission/components/PermissionListV2/index.tsx +0 -146
  32. package/src/features/permission/hooks/index.ts +0 -140
  33. package/src/features/permission/index.ts +0 -5
  34. package/src/features/permission/types/index.ts +0 -40
  35. package/src/hooks/index.ts +0 -2
  36. package/src/hooks/use-http-client.tsx +0 -85
  37. package/src/hooks/use-permission.tsx +0 -75
  38. package/src/index.ts +0 -7
  39. package/src/pages/base/Login/default.tsx +0 -864
  40. package/src/pages/base/Login/index.tsx +0 -101
  41. package/src/pages/base/NotFound/index.tsx +0 -27
  42. package/src/pages/base/index.tsx +0 -20
  43. package/src/pages/index.ts +0 -4
  44. package/src/pages/permission/RoleDetail/index.tsx +0 -40
  45. package/src/pages/permission/RoleList/index.tsx +0 -251
  46. package/src/pages/permission/UserList/index.tsx +0 -236
  47. package/src/pages/permission/index.tsx +0 -56
  48. package/src/shims.d.ts +0 -20
  49. package/src/stores/index.ts +0 -2
  50. package/src/stores/query-list.ts +0 -61
  51. package/src/stores/token.ts +0 -39
  52. package/src/styles/index.css +0 -5
  53. package/src/types/index.ts +0 -10
  54. package/tailwind.config.js +0 -5
  55. package/tsconfig.json +0 -11
  56. package/tsup.config.ts +0 -27
@@ -1,56 +0,0 @@
1
- import { lazy } from 'react'
2
- import type { RouteObject } from 'react-router-dom'
3
- import { Navigate, Outlet } from 'react-router-dom'
4
- import { Layout, ReactToolkitsProvider, useReactToolkitsContext } from '@/components'
5
- import { SWRConfig } from 'swr'
6
- import { useHttpClient } from '@/hooks'
7
-
8
- const UserList = lazy(() => import('./UserList'))
9
- const RoleList = lazy(() => import('./RoleList'))
10
- const RoleDetail = lazy(() => import('./RoleDetail'))
11
-
12
- const PermissionRoot = () => {
13
- const httpClient = useHttpClient()
14
- const configs = useReactToolkitsContext(state => state)
15
-
16
- return (
17
- // NOTE: 目前嵌套的 ReactToolkitsProvider 只能手动注入父级 ReactToolkitsProvider 的配置
18
- <ReactToolkitsProvider {...configs} isGlobalNS>
19
- <SWRConfig
20
- value={{
21
- fetcher: httpClient.request,
22
- shouldRetryOnError: false,
23
- }}
24
- >
25
- <Layout>
26
- <Outlet />
27
- </Layout>
28
- </SWRConfig>
29
- </ReactToolkitsProvider>
30
- )
31
- }
32
-
33
- const routes: RouteObject = {
34
- path: 'permission',
35
- element: <PermissionRoot />,
36
- children: [
37
- {
38
- index: true,
39
- element: <Navigate relative="path" to="user" />,
40
- },
41
- {
42
- path: 'user',
43
- element: <UserList />,
44
- },
45
- {
46
- path: 'role',
47
- element: <RoleList />,
48
- },
49
- {
50
- path: 'role/:name',
51
- element: <RoleDetail />,
52
- },
53
- ],
54
- }
55
-
56
- export default routes
package/src/shims.d.ts DELETED
@@ -1,20 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- declare module '*.jpg' {
3
- const content: any
4
- export default content
5
- }
6
-
7
- declare module '*.png' {
8
- const content: any
9
- export default content
10
- }
11
-
12
- declare module '*.svg' {
13
- const content: any
14
- export default content
15
- }
16
-
17
- declare module '*.yaml' {
18
- const content: any
19
- export default content
20
- }
@@ -1,2 +0,0 @@
1
- export * from './token'
2
- export * from './query-list'
@@ -1,61 +0,0 @@
1
- import type { QueryListKey } from '@/components/QueryList'
2
- import type { PaginationParams } from '@/types'
3
- import { create } from 'zustand'
4
-
5
- type RefreshFunction = (arg?: Partial<PaginationParams>) => void
6
-
7
- export interface QueryListState {
8
- data: Map<
9
- QueryListKey,
10
- {
11
- pagination?: PaginationParams
12
- refresh?: RefreshFunction
13
- }
14
- >
15
- getPaginationData: (key: QueryListKey) => PaginationParams
16
- setPaginationData: (key: QueryListKey, pagination?: Partial<PaginationParams>) => void
17
- refresh: (key: QueryListKey, arg?: Partial<PaginationParams>) => void
18
- setRefresh: (key: QueryListKey, trigger: RefreshFunction) => void
19
- }
20
-
21
- export const useQueryListStore = create<QueryListState>((set, get) => ({
22
- data: new Map(),
23
- getPaginationData: (key: QueryListKey) => {
24
- const pagination = get().data.get(key)?.pagination
25
- return {
26
- page: pagination?.page ?? 1,
27
- size: pagination?.size ?? 10,
28
- }
29
- },
30
- setPaginationData: (key: QueryListKey, pagination?: Partial<PaginationParams>) => {
31
- set({
32
- data: new Map(get().data).set(key, {
33
- ...get().data.get(key),
34
- pagination: {
35
- page: pagination?.page ?? get().getPaginationData(key).page,
36
- size: pagination?.size ?? get().getPaginationData(key).size,
37
- },
38
- }),
39
- })
40
- },
41
- refresh: (key: QueryListKey, pagination?: Partial<PaginationParams>) => {
42
- const refresh = get().data.get(key)?.refresh
43
-
44
- if (refresh) {
45
- refresh({
46
- page: pagination?.page ?? get().getPaginationData(key).page,
47
- size: pagination?.size ?? get().getPaginationData(key).size,
48
- })
49
- }
50
- },
51
- setRefresh: (key: QueryListKey, refresh: RefreshFunction) => {
52
- const data = get().data
53
-
54
- set({
55
- data: new Map(data).set(key, {
56
- ...data.get(key),
57
- refresh,
58
- }),
59
- })
60
- },
61
- }))
@@ -1,39 +0,0 @@
1
- import { create } from 'zustand'
2
- import { persist } from 'zustand/middleware'
3
- import jwtDecode from 'jwt-decode'
4
-
5
- interface UserInfo {
6
- authorityId: string
7
- exp: number
8
- }
9
-
10
- export interface TokenState {
11
- token: string
12
- getUser: () => UserInfo | null
13
- setToken: (token: string) => void
14
- clearToken: () => void
15
- }
16
-
17
- export const useTokenStore = create<TokenState>()(
18
- persist(
19
- (set, get) => ({
20
- token: '',
21
- getUser: () => {
22
- try {
23
- return jwtDecode(get().token) as UserInfo
24
- } catch (_) {
25
- return null
26
- }
27
- },
28
- setToken: token => set({ token }),
29
- clearToken: () => {
30
- set({ token: '' })
31
- useTokenStore.persist.clearStorage()
32
- },
33
- }),
34
- {
35
- name: 'token',
36
- partialize: state => ({ token: state.token }),
37
- },
38
- ),
39
- )
@@ -1,5 +0,0 @@
1
- @import "antd/dist/reset.css";
2
-
3
- @tailwind base;
4
- @tailwind components;
5
- @tailwind utilities;
@@ -1,10 +0,0 @@
1
- export interface ListResponse<T> {
2
- List: T[]
3
- Page?: number
4
- Total: number
5
- }
6
-
7
- export type PaginationParams = {
8
- page: number
9
- size: number
10
- }
@@ -1,5 +0,0 @@
1
- import sharedConfig from 'tailwind-config/config'
2
-
3
- module.exports = {
4
- presets: [sharedConfig],
5
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "tsconfig/react-library.json",
3
- "include": ["./src"],
4
- "exclude": ["dist", "node_modules"],
5
- "compilerOptions": {
6
- "baseUrl": ".",
7
- "paths": {
8
- "@/*": ["./src/*"]
9
- }
10
- }
11
- }
package/tsup.config.ts DELETED
@@ -1,27 +0,0 @@
1
- import { defineConfig } from 'tsup'
2
- import * as process from 'process'
3
-
4
- const isProduction = process.env.NODE_ENV === 'production'
5
-
6
- export default defineConfig({
7
- entry: ['src/index.ts'],
8
- format: ['esm'],
9
- sourcemap: true,
10
- minify: false,
11
- treeshake: true,
12
- splitting: false,
13
- dts: true,
14
- clean: true,
15
- shims: true,
16
- external: ['react', 'react-dom'],
17
- loader: {
18
- '.jpg': 'base64',
19
- '.png': 'copy',
20
- '.webp': 'file',
21
- },
22
- outExtension({ format }) {
23
- return {
24
- js: `.${format}.js`,
25
- }
26
- },
27
- })