react-toolkits 2.9.4 → 2.9.6

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/locale/en_GB.js CHANGED
@@ -25,7 +25,7 @@ var locale = {
25
25
  SignIn: {
26
26
  title: "Sign In Method",
27
27
  thirdParty: "Third party sign in",
28
- signInWithIDass: "Sign in width IDass",
28
+ signInWithIDass: "Sign in with IDass",
29
29
  unregistered: "You are not yet registered on the platform, please contact the administrator",
30
30
  welcome: "Welcome"
31
31
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/locale/en_GB.ts"],"names":[],"mappings":";AAEA,IAAM,MAAiB,GAAA;AAAA,EACrB,MAAQ,EAAA;AAAA,IACN,aAAe,EAAA,kDAAA;AAAA,IACf,IAAM,EAAA,MAAA;AAAA,IACN,YAAc,EAAA,eAAA;AAAA,IACd,SAAW,EAAA,WAAA;AAAA,IACX,MAAQ,EAAA,QAAA;AAAA,IACR,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,QAAA;AAAA,IACR,SAAW,EAAA,YAAA;AAAA,IACX,IAAM,EAAA,MAAA;AAAA,IACN,IAAM,EAAA,MAAA;AAAA,IACN,IAAM,EAAA,MAAA;AAAA,IACN,QAAU,EAAA,UAAA;AAAA,IACV,QAAU,EAAA,UAAA;AAAA,IACV,KAAO,EAAA,OAAA;AAAA,IACP,MAAQ,EAAA,QAAA;AAAA,IACR,KAAO,EAAA,OAAA;AAAA,IACP,OAAS,EAAA,SAAA;AAAA,IACT,QAAU,EAAA,UAAA;AAAA,IACV,GAAK,EAAA,KAAA;AAAA,IACL,MAAQ,EAAA,SAAA;AAAA,GACV;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,gBAAA;AAAA,IACP,UAAY,EAAA,qBAAA;AAAA,IACZ,eAAiB,EAAA,qBAAA;AAAA,IACjB,YAAc,EAAA,8EAAA;AAAA,IACd,OAAS,EAAA,SAAA;AAAA,GACX;A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,OAAS,EAAA,sBAAA;AAAA,GACX;AAAA,EACA,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,cAAA;AAAA,GACT;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,WAAa,EAAA,YAAA;AAAA,IACb,YAAc,EAAA,wBAAA;AAAA,IACd,YAAc,EAAA,WAAA;AAAA,GAChB;AACF,CAAA,CAAA;AAEA,IAAO,aAAQ,GAAA","file":"en_GB.js","sourcesContent":["import type { Locale } from '.'\n\nconst locale: Locale = {\n global: {\n noEntitlement: 'No permission, please contact the administrator.',\n name: 'Name',\n creationTime: 'Creation Time',\n operation: 'Operation',\n update: 'Update',\n edit: 'Edit',\n delete: 'Delete',\n selectAll: 'Select All',\n game: 'Game',\n user: 'User',\n role: 'Role',\n username: 'Username',\n password: 'Password',\n label: 'Label',\n method: 'Method',\n route: 'Route',\n request: 'Request',\n response: 'Response',\n add: 'Add',\n signIn: 'Sign In',\n },\n SignIn: {\n title: 'Sign In Method',\n thirdParty: 'Third party sign in',\n signInWithIDass: 'Sign in width IDass',\n unregistered: 'You are not yet registered on the platform, please contact the administrator',\n welcome: 'Welcome',\n },\n NotFound: {\n subTitle: 'The page you visited does not exist',\n buttonText: 'Return to homepage',\n },\n FilterFormWrapper: {\n confirmText: 'Search',\n resetText: 'Reset',\n },\n FormModal: {\n confirmText: 'Confirm',\n cancelText: 'Cancel',\n },\n GameSelect: {\n label: 'Current Game',\n placeholder: 'Please select a game',\n },\n RequireGame: {\n description: 'Please select a game',\n },\n UserWidget: {\n signOutText: 'Sign Out',\n },\n UserList: {\n createTitle: 'Create User',\n createSuccessfully: 'User created successfully',\n updateTitle: 'Update User',\n updateSuccessfully: 'User updated successfully',\n deleteTitle: 'Delete User',\n deleteContent: 'Are you sure you want to delete user <%= user %>?',\n deleteSuccessfully: 'User deleted successfully',\n },\n RoleList: {\n createTitle: 'Create Role',\n createSuccessfully: 'Role created successfully',\n updateTitle: 'Update Role',\n updateSuccessfully: 'Role updated successfully',\n deleteTitle: 'Delete Role',\n deleteContent: 'Are you sure you want to delete role <%= role %>?',\n deleteSuccessfully: 'Role deleted successfully',\n },\n PermissionList: {\n failedDescription: 'Failed to get permission list',\n baseSectionTitle: 'Platform Basic Permissions',\n gameSectionTitle: 'Game Permissions',\n gameSectionDescription: 'Please select a game first',\n gameSelectPlaceholder: 'Please select a game first',\n removeText: 'Remove',\n addText: 'Add Game Permissions',\n },\n RoleDetail: {\n title: 'Role Details',\n },\n InfiniteList: {\n loadingText: 'Loading...',\n reachEndText: \"You've reached the end\",\n loadMoreText: 'Load more',\n },\n}\n\nexport default locale\n"]}
1
+ {"version":3,"sources":["../src/components/locale/en_GB.ts"],"names":[],"mappings":";AAEA,IAAM,MAAiB,GAAA;AAAA,EACrB,MAAQ,EAAA;AAAA,IACN,aAAe,EAAA,kDAAA;AAAA,IACf,IAAM,EAAA,MAAA;AAAA,IACN,YAAc,EAAA,eAAA;AAAA,IACd,SAAW,EAAA,WAAA;AAAA,IACX,MAAQ,EAAA,QAAA;AAAA,IACR,IAAM,EAAA,MAAA;AAAA,IACN,MAAQ,EAAA,QAAA;AAAA,IACR,SAAW,EAAA,YAAA;AAAA,IACX,IAAM,EAAA,MAAA;AAAA,IACN,IAAM,EAAA,MAAA;AAAA,IACN,IAAM,EAAA,MAAA;AAAA,IACN,QAAU,EAAA,UAAA;AAAA,IACV,QAAU,EAAA,UAAA;AAAA,IACV,KAAO,EAAA,OAAA;AAAA,IACP,MAAQ,EAAA,QAAA;AAAA,IACR,KAAO,EAAA,OAAA;AAAA,IACP,OAAS,EAAA,SAAA;AAAA,IACT,QAAU,EAAA,UAAA;AAAA,IACV,GAAK,EAAA,KAAA;AAAA,IACL,MAAQ,EAAA,SAAA;AAAA,GACV;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,gBAAA;AAAA,IACP,UAAY,EAAA,qBAAA;AAAA,IACZ,eAAiB,EAAA,oBAAA;AAAA,IACjB,YAAc,EAAA,8EAAA;AAAA,IAC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ACvB,UAAY,EAAA,QAAA;AAAA,IACZ,OAAS,EAAA,sBAAA;AAAA,GACX;AAAA,EACA,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,cAAA;AAAA,GACT;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,WAAa,EAAA,YAAA;AAAA,IACb,YAAc,EAAA,wBAAA;AAAA,IACd,YAAc,EAAA,WAAA;AAAA,GAChB;AACF,CAAA,CAAA;AAEA,IAAO,aAAQ,GAAA","file":"en_GB.js","sourcesContent":["import type { Locale } from '.'\n\nconst locale: Locale = {\n global: {\n noEntitlement: 'No permission, please contact the administrator.',\n name: 'Name',\n creationTime: 'Creation Time',\n operation: 'Operation',\n update: 'Update',\n edit: 'Edit',\n delete: 'Delete',\n selectAll: 'Select All',\n game: 'Game',\n user: 'User',\n role: 'Role',\n username: 'Username',\n password: 'Password',\n label: 'Label',\n method: 'Method',\n route: 'Route',\n request: 'Request',\n response: 'Response',\n add: 'Add',\n signIn: 'Sign In',\n },\n SignIn: {\n title: 'Sign In Method',\n thirdParty: 'Third party sign in',\n signInWithIDass: 'Sign in with IDass',\n unregistered: 'You are not yet registered on the platform, please contact the administrator',\n welcome: 'Welcome',\n },\n NotFound: {\n subTitle: 'The page you visited does not exist',\n buttonText: 'Return to homepage',\n },\n FilterFormWrapper: {\n confirmText: 'Search',\n resetText: 'Reset',\n },\n FormModal: {\n confirmText: 'Confirm',\n cancelText: 'Cancel',\n },\n GameSelect: {\n label: 'Current Game',\n placeholder: 'Please select a game',\n },\n RequireGame: {\n description: 'Please select a game',\n },\n UserWidget: {\n signOutText: 'Sign Out',\n },\n UserList: {\n createTitle: 'Create User',\n createSuccessfully: 'User created successfully',\n updateTitle: 'Update User',\n updateSuccessfully: 'User updated successfully',\n deleteTitle: 'Delete User',\n deleteContent: 'Are you sure you want to delete user <%= user %>?',\n deleteSuccessfully: 'User deleted successfully',\n },\n RoleList: {\n createTitle: 'Create Role',\n createSuccessfully: 'Role created successfully',\n updateTitle: 'Update Role',\n updateSuccessfully: 'Role updated successfully',\n deleteTitle: 'Delete Role',\n deleteContent: 'Are you sure you want to delete role <%= role %>?',\n deleteSuccessfully: 'Role deleted successfully',\n },\n PermissionList: {\n failedDescription: 'Failed to get permission list',\n baseSectionTitle: 'Platform Basic Permissions',\n gameSectionTitle: 'Game Permissions',\n gameSectionDescription: 'Please select a game first',\n gameSelectPlaceholder: 'Please select a game first',\n removeText: 'Remove',\n addText: 'Add Game Permissions',\n },\n RoleDetail: {\n title: 'Role Details',\n },\n InfiniteList: {\n loadingText: 'Loading...',\n reachEndText: \"You've reached the end\",\n loadMoreText: 'Load more',\n },\n}\n\nexport default locale\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/contextProvider/Provider.tsx","../src/components/locale/hooks.ts"],"names":["locale"],"mappings":";;;;;;AAwCA,IAAM,eAAA,GAAkB,cAAmC,IAAI,CAAA,CAAA;AAExD,SAAS,mBAAsB,QAAsC,EAAA;AAC1E,EAAM,MAAA,KAAA,GAAQ,WAAW,eAAe,CAAA,CAAA;AACxC,EAAA,IAAI,CAAC,KAAA,EAAa,MAAA,IAAI,MAAM,8CAA8C,CAAA,CAAA;AAC1E,EAAO,OAAA,QAAA,CAAS,OAAO,QAAQ,CAAA,CAAA;AACjC,CAAA;AAiBA,IAAI,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,YAAc,EAAA,CAE3C;;;AC9CO,SAAS,cAAiB,GAAA;AAC/B,EAAA,MAAMA,OAAS,GAAA,kBAAA,CAAmB,CAAS,KAAA,KAAA,KAAA,CAAM,MAAM,CAAA,CAAA;AAEvD,EAAA,MAAM,CAAI,GAAA,OAAA;AAAA,IACR,MAAM,CAAC,GAAoB,EAAA,IAAA,KACzB,IAAIA,OAAQ,EAAA,GAAG,CAAI,GAAA,QAAA,CAAS,IAAIA,OAAQ,EAAA,GAAa,CAAC,CAAA,CAAE,IAAI,CAAI,GAAA,GAAA;AAAA,IAClE,CAACA,OAAM,CAAA;AAAA,GACT,CAAA;AAEA,EAAA,OAAO,EAAE,CAAE,EAAA,CAAA;AACb","file":"hooks.js","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC, PropsWithChildren } from 'react'\nimport { createContext, useContext, useRef } from 'react'\nimport { createStore, useStore } from 'zustand'\nimport type { RequestOptions } from '../../utils/request'\nimport type { Locale } from '../locale'\nimport enGb from '../locale/en_GB'\n\nexport interface ContextProps {\n locale: Locale\n usePermissionApiV2: boolean // 使用 V2 版本的权限接口\n interceptor?: {\n response?: (response: Response, opts: RequestOptions) => Promise<any>\n }\n}\n\nexport interface ContextState extends ContextProps {\n setContext: (props: Partial<ContextProps>) => void\n}\n\nconst createContextStore = (initProps?: Partial<ContextProps>) => {\n const DEFAULT_PROPS: ContextProps = {\n usePermissionApiV2: false,\n locale: enGb,\n }\n\n return createStore<ContextState>()(set => ({\n ...DEFAULT_PROPS,\n ...initProps,\n setContext: props => {\n set({ ...props })\n },\n }))\n}\n\ntype ContextStore = ReturnType<typeof createContextStore>\n\n// 全局的 store 实例,等于最内层的 ContextProvider 所包含的实例。\nexport let contextStore: ContextStore\n\nconst ToolkitsContext = createContext<ContextStore | null>(null)\n\nexport function useToolkitsContext<T>(selector: (state: ContextState) => T) {\n const store = useContext(ToolkitsContext)\n if (!store) throw new Error('Missing ToolkitsContext.Provider in the tree')\n return useStore(store, selector)\n}\n\ntype ContextProviderProps = PropsWithChildren<Partial<ContextProps>>\n\nconst ContextProvider: FC<ContextProviderProps> = props => {\n const { children, ...restProps } = props\n const storeRef = useRef<ContextStore>()\n\n if (!storeRef.current) {\n storeRef.current = createContextStore(restProps)\n }\n\n contextStore = storeRef.current\n\n return <ToolkitsContext.Provider value={storeRef.current}>{children}</ToolkitsContext.Provider>\n}\n\nif (process.env.NODE_ENV !== 'production') {\n ContextProvider.displayName = 'ContextProvider'\n}\n\nexport default ContextProvider\n","import { get, has, template } from 'lodash-es'\nimport { useMemo } from 'react'\nimport { useToolkitsContext } from '../contextProvider'\nimport type { Locale } from './index'\n\ntype Join<K, P> = K extends string | number\n ? P extends string | number\n ? `${K}${'' extends P ? '' : '.'}${P}`\n : never\n : never\n\ntype Paths<T, D extends number = 10> = [D] extends [never]\n ? never\n : T extends object\n ? {\n [K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Paths<T[K]>> : never\n }[keyof T]\n : ''\n\nexport function useTranslation() {\n const locale = useToolkitsContext(state => state.locale)\n\n const t = useMemo(\n () => (key: Paths<Locale>, data?: Record<string, unknown>) =>\n has(locale, key) ? template(get(locale, key as string))(data) : key,\n [locale],\n )\n\n return { t }\n}\n"]}
1
+ {"version":3,"sources":["../src/components/contextProvider/Provider.tsx","../src/components/locale/hooks.ts"],"names":["locale"],"mappings":";;;;;;AAwCA,IAAM,eAAA,GAAkB,cAAmC,IAAI,CAAA,CAAA;AAExD,SAAS,mBAAsB,QAAsC,EAAA;AAC1E,EAAM,MAAA,KAAA,GAAQ,WAAW,eAAe,CAAA,CAAA;AACxC,EAAA,IAAI,CAAC,KAAA,EAAa,MAAA,IAAI,MAAM,8CAA8C,CAAA,CAAA;AAC1E,EAAO,OAAA,QAAA,CAAS,OAAO,QAAQ,CAAA,CAAA;AACjC,CAAA;AAkBA,IAAI,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,YAAc,EAAA,CAE3C;;;AC/CO,SAAS,cAAiB,GAAA;AAC/B,EAAA,MAAMA,OAAS,GAAA,kBAAA,CAAmB,CAAS,KAAA,KAAA,KAAA,CAAM,MAAM,CAAA,CAAA;AAEvD,EAAA,MAAM,CAAI,GAAA,OAAA;AAAA,IACR,MAAM,CAAC,GAAoB,EAAA,IAAA,KACzB,IAAIA,OAAQ,EAAA,GAAG,CAAI,GAAA,QAAA,CAAS,IAAIA,OAAQ,EAAA,GAAa,CAAC,CAAA,CAAE,IAAI,CAAI,GAAA,GAAA;AAAA,IAClE,CAACA,OAAM,CAAA;AAAA,GACT,CAAA;AAEA,EAAA,OAAO,EAAE,CAAE,EAAA,CAAA;AACb","file":"hooks.js","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC, PropsWithChildren } from 'react'\nimport { createContext, useContext, useRef } from 'react'\nimport { createStore, useStore } from 'zustand'\nimport type { RequestOptions } from '../../utils/request'\nimport type { Locale } from '../locale'\nimport enGb from '../locale/en_GB'\n\nexport interface ContextProps {\n locale: Locale\n usePermissionApiV2: boolean // 使用 V2 版本的权限接口\n interceptor?: {\n response?: (response: Response, opts: RequestOptions) => Promise<any>\n }\n}\n\nexport interface ContextState extends ContextProps {\n setContext: (props: Partial<ContextProps>) => void\n}\n\nconst createContextStore = (initProps?: Partial<ContextProps>) => {\n const DEFAULT_PROPS: ContextProps = {\n usePermissionApiV2: false,\n locale: enGb,\n }\n\n return createStore<ContextState>()(set => ({\n ...DEFAULT_PROPS,\n ...initProps,\n setContext: props => {\n set({ ...props })\n },\n }))\n}\n\ntype ContextStore = ReturnType<typeof createContextStore>\n\n// 全局的 store 实例,等于最内层的 ContextProvider 所包含的实例。\nexport let contextStore: ContextStore\n\nconst ToolkitsContext = createContext<ContextStore | null>(null)\n\nexport function useToolkitsContext<T>(selector: (state: ContextState) => T) {\n const store = useContext(ToolkitsContext)\n if (!store) throw new Error('Missing ToolkitsContext.Provider in the tree')\n return useStore(store, selector)\n}\n\ntype ContextProviderProps = PropsWithChildren<Partial<ContextProps>>\n\n// TODO: 合并父级的 state\nconst ContextProvider: FC<ContextProviderProps> = props => {\n const { children, ...restProps } = props\n const storeRef = useRef<ContextStore>()\n\n if (!storeRef.current) {\n storeRef.current = createContextStore(restProps)\n }\n\n contextStore = storeRef.current\n\n return <ToolkitsContext.Provider value={storeRef.current}>{children}</ToolkitsContext.Provider>\n}\n\nif (process.env.NODE_ENV !== 'production') {\n ContextProvider.displayName = 'ContextProvider'\n}\n\nexport default ContextProvider\n","import { get, has, template } from 'lodash-es'\nimport { useMemo } from 'react'\nimport { useToolkitsContext } from '../contextProvider'\nimport type { Locale } from './index'\n\ntype Join<K, P> = K extends string | number\n ? P extends string | number\n ? `${K}${'' extends P ? '' : '.'}${P}`\n : never\n : never\n\ntype Paths<T, D extends number = 10> = [D] extends [never]\n ? never\n : T extends object\n ? {\n [K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Paths<T[K]>> : never\n }[keyof T]\n : ''\n\nexport function useTranslation() {\n const locale = useToolkitsContext(state => state.locale)\n\n const t = useMemo(\n () => (key: Paths<Locale>, data?: Record<string, unknown>) =>\n has(locale, key) ? template(get(locale, key as string))(data) : key,\n [locale],\n )\n\n return { t }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/contextProvider/Provider.tsx","../src/components/locale/hooks.ts"],"names":["locale"],"mappings":";;;;;;AAwCA,IAAM,eAAA,GAAkB,cAAmC,IAAI,CAAA,CAAA;AAExD,SAAS,mBAAsB,QAAsC,EAAA;AAC1E,EAAM,MAAA,KAAA,GAAQ,WAAW,eAAe,CAAA,CAAA;AACxC,EAAA,IAAI,CAAC,KAAA,EAAa,MAAA,IAAI,MAAM,8CAA8C,CAAA,CAAA;AAC1E,EAAO,OAAA,QAAA,CAAS,OAAO,QAAQ,CAAA,CAAA;AACjC,CAAA;AAiBA,IAAI,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,YAAc,EAAA,CAE3C;;;AC9CO,SAAS,cAAiB,GAAA;AAC/B,EAAA,MAAMA,OAAS,GAAA,kBAAA,CAAmB,CAAS,KAAA,KAAA,KAAA,CAAM,MAAM,CAAA,CAAA;AAEvD,EAAA,MAAM,CAAI,GAAA,OAAA;AAAA,IACR,MAAM,CAAC,GAAoB,EAAA,IAAA,KACzB,IAAIA,OAAQ,EAAA,GAAG,CAAI,GAAA,QAAA,CAAS,IAAIA,OAAQ,EAAA,GAAa,CAAC,CAAA,CAAE,IAAI,CAAI,GAAA,GAAA;AAAA,IAClE,CAACA,OAAM,CAAA;AAAA,GACT,CAAA;AAEA,EAAA,OAAO,EAAE,CAAE,EAAA,CAAA;AACb","file":"index.js","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC, PropsWithChildren } from 'react'\nimport { createContext, useContext, useRef } from 'react'\nimport { createStore, useStore } from 'zustand'\nimport type { RequestOptions } from '../../utils/request'\nimport type { Locale } from '../locale'\nimport enGb from '../locale/en_GB'\n\nexport interface ContextProps {\n locale: Locale\n usePermissionApiV2: boolean // 使用 V2 版本的权限接口\n interceptor?: {\n response?: (response: Response, opts: RequestOptions) => Promise<any>\n }\n}\n\nexport interface ContextState extends ContextProps {\n setContext: (props: Partial<ContextProps>) => void\n}\n\nconst createContextStore = (initProps?: Partial<ContextProps>) => {\n const DEFAULT_PROPS: ContextProps = {\n usePermissionApiV2: false,\n locale: enGb,\n }\n\n return createStore<ContextState>()(set => ({\n ...DEFAULT_PROPS,\n ...initProps,\n setContext: props => {\n set({ ...props })\n },\n }))\n}\n\ntype ContextStore = ReturnType<typeof createContextStore>\n\n// 全局的 store 实例,等于最内层的 ContextProvider 所包含的实例。\nexport let contextStore: ContextStore\n\nconst ToolkitsContext = createContext<ContextStore | null>(null)\n\nexport function useToolkitsContext<T>(selector: (state: ContextState) => T) {\n const store = useContext(ToolkitsContext)\n if (!store) throw new Error('Missing ToolkitsContext.Provider in the tree')\n return useStore(store, selector)\n}\n\ntype ContextProviderProps = PropsWithChildren<Partial<ContextProps>>\n\nconst ContextProvider: FC<ContextProviderProps> = props => {\n const { children, ...restProps } = props\n const storeRef = useRef<ContextStore>()\n\n if (!storeRef.current) {\n storeRef.current = createContextStore(restProps)\n }\n\n contextStore = storeRef.current\n\n return <ToolkitsContext.Provider value={storeRef.current}>{children}</ToolkitsContext.Provider>\n}\n\nif (process.env.NODE_ENV !== 'production') {\n ContextProvider.displayName = 'ContextProvider'\n}\n\nexport default ContextProvider\n","import { get, has, template } from 'lodash-es'\nimport { useMemo } from 'react'\nimport { useToolkitsContext } from '../contextProvider'\nimport type { Locale } from './index'\n\ntype Join<K, P> = K extends string | number\n ? P extends string | number\n ? `${K}${'' extends P ? '' : '.'}${P}`\n : never\n : never\n\ntype Paths<T, D extends number = 10> = [D] extends [never]\n ? never\n : T extends object\n ? {\n [K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Paths<T[K]>> : never\n }[keyof T]\n : ''\n\nexport function useTranslation() {\n const locale = useToolkitsContext(state => state.locale)\n\n const t = useMemo(\n () => (key: Paths<Locale>, data?: Record<string, unknown>) =>\n has(locale, key) ? template(get(locale, key as string))(data) : key,\n [locale],\n )\n\n return { t }\n}\n"]}
1
+ {"version":3,"sources":["../src/components/contextProvider/Provider.tsx","../src/components/locale/hooks.ts"],"names":["locale"],"mappings":";;;;;;AAwCA,IAAM,eAAA,GAAkB,cAAmC,IAAI,CAAA,CAAA;AAExD,SAAS,mBAAsB,QAAsC,EAAA;AAC1E,EAAM,MAAA,KAAA,GAAQ,WAAW,eAAe,CAAA,CAAA;AACxC,EAAA,IAAI,CAAC,KAAA,EAAa,MAAA,IAAI,MAAM,8CAA8C,CAAA,CAAA;AAC1E,EAAO,OAAA,QAAA,CAAS,OAAO,QAAQ,CAAA,CAAA;AACjC,CAAA;AAkBA,IAAI,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,YAAc,EAAA,CAE3C;;;AC/CO,SAAS,cAAiB,GAAA;AAC/B,EAAA,MAAMA,OAAS,GAAA,kBAAA,CAAmB,CAAS,KAAA,KAAA,KAAA,CAAM,MAAM,CAAA,CAAA;AAEvD,EAAA,MAAM,CAAI,GAAA,OAAA;AAAA,IACR,MAAM,CAAC,GAAoB,EAAA,IAAA,KACzB,IAAIA,OAAQ,EAAA,GAAG,CAAI,GAAA,QAAA,CAAS,IAAIA,OAAQ,EAAA,GAAa,CAAC,CAAA,CAAE,IAAI,CAAI,GAAA,GAAA;AAAA,IAClE,CAACA,OAAM,CAAA;AAAA,GACT,CAAA;AAEA,EAAA,OAAO,EAAE,CAAE,EAAA,CAAA;AACb","file":"index.js","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { FC, PropsWithChildren } from 'react'\nimport { createContext, useContext, useRef } from 'react'\nimport { createStore, useStore } from 'zustand'\nimport type { RequestOptions } from '../../utils/request'\nimport type { Locale } from '../locale'\nimport enGb from '../locale/en_GB'\n\nexport interface ContextProps {\n locale: Locale\n usePermissionApiV2: boolean // 使用 V2 版本的权限接口\n interceptor?: {\n response?: (response: Response, opts: RequestOptions) => Promise<any>\n }\n}\n\nexport interface ContextState extends ContextProps {\n setContext: (props: Partial<ContextProps>) => void\n}\n\nconst createContextStore = (initProps?: Partial<ContextProps>) => {\n const DEFAULT_PROPS: ContextProps = {\n usePermissionApiV2: false,\n locale: enGb,\n }\n\n return createStore<ContextState>()(set => ({\n ...DEFAULT_PROPS,\n ...initProps,\n setContext: props => {\n set({ ...props })\n },\n }))\n}\n\ntype ContextStore = ReturnType<typeof createContextStore>\n\n// 全局的 store 实例,等于最内层的 ContextProvider 所包含的实例。\nexport let contextStore: ContextStore\n\nconst ToolkitsContext = createContext<ContextStore | null>(null)\n\nexport function useToolkitsContext<T>(selector: (state: ContextState) => T) {\n const store = useContext(ToolkitsContext)\n if (!store) throw new Error('Missing ToolkitsContext.Provider in the tree')\n return useStore(store, selector)\n}\n\ntype ContextProviderProps = PropsWithChildren<Partial<ContextProps>>\n\n// TODO: 合并父级的 state\nconst ContextProvider: FC<ContextProviderProps> = props => {\n const { children, ...restProps } = props\n const storeRef = useRef<ContextStore>()\n\n if (!storeRef.current) {\n storeRef.current = createContextStore(restProps)\n }\n\n contextStore = storeRef.current\n\n return <ToolkitsContext.Provider value={storeRef.current}>{children}</ToolkitsContext.Provider>\n}\n\nif (process.env.NODE_ENV !== 'production') {\n ContextProvider.displayName = 'ContextProvider'\n}\n\nexport default ContextProvider\n","import { get, has, template } from 'lodash-es'\nimport { useMemo } from 'react'\nimport { useToolkitsContext } from '../contextProvider'\nimport type { Locale } from './index'\n\ntype Join<K, P> = K extends string | number\n ? P extends string | number\n ? `${K}${'' extends P ? '' : '.'}${P}`\n : never\n : never\n\ntype Paths<T, D extends number = 10> = [D] extends [never]\n ? never\n : T extends object\n ? {\n [K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Paths<T[K]>> : never\n }[keyof T]\n : ''\n\nexport function useTranslation() {\n const locale = useToolkitsContext(state => state.locale)\n\n const t = useMemo(\n () => (key: Paths<Locale>, data?: Record<string, unknown>) =>\n has(locale, key) ? template(get(locale, key as string))(data) : key,\n [locale],\n )\n\n return { t }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-toolkits",
3
3
  "type": "module",
4
- "version": "2.9.4",
4
+ "version": "2.9.6",
5
5
  "sideEffects": [
6
6
  "*.css"
7
7
  ],
@@ -65,8 +65,8 @@
65
65
  "tsup": "^8.1.0",
66
66
  "typescript": "^5.5.4",
67
67
  "@flow97/eslint-config-react": "0.0.4",
68
- "tsconfig": "0.0.6",
69
- "tailwind-config": "0.1.2"
68
+ "tailwind-config": "0.1.2",
69
+ "tsconfig": "0.0.6"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "antd": "^5.12.2",