fix: client internal method (T-3711 and T-3712 and T-3713) (#3839)
* fix: client internal method (T-3711 and T-3712 and T-3712) * fix: bug
This commit is contained in:
parent
d932546194
commit
7566a7b357
@ -175,6 +175,9 @@ export class Application {
|
|||||||
return this.dataSourceManager.getDataSource(dataSource)?.collectionManager;
|
return this.dataSourceManager.getDataSource(dataSource)?.collectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
getComposeProviders() {
|
getComposeProviders() {
|
||||||
const Providers = compose(...this.providers)(BlankComponent);
|
const Providers = compose(...this.providers)(BlankComponent);
|
||||||
Providers.displayName = 'Providers';
|
Providers.displayName = 'Providers';
|
||||||
@ -280,6 +283,9 @@ export class Application {
|
|||||||
return React.createElement(this.getComponent(Component), props);
|
return React.createElement(this.getComponent(Component), props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal use addComponents({ SomeComponent }) instead
|
||||||
|
*/
|
||||||
protected addComponent(component: ComponentType, name?: string) {
|
protected addComponent(component: ComponentType, name?: string) {
|
||||||
const componentName = name || component.displayName || component.name;
|
const componentName = name || component.displayName || component.name;
|
||||||
if (!componentName) {
|
if (!componentName) {
|
||||||
|
@ -26,6 +26,9 @@ export class PluginManager {
|
|||||||
this.initPlugins = this.init(_plugins);
|
this.initPlugins = this.init(_plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
async init(_plugins: PluginType[]) {
|
async init(_plugins: PluginType[]) {
|
||||||
await this.initStaticPlugins(_plugins);
|
await this.initStaticPlugins(_plugins);
|
||||||
if (this.loadRemotePlugins) {
|
if (this.loadRemotePlugins) {
|
||||||
@ -84,6 +87,9 @@ export class PluginManager {
|
|||||||
return new plugin(opts, this.app);
|
return new plugin(opts, this.app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
async load() {
|
async load() {
|
||||||
await this.initPlugins;
|
await this.initPlugins;
|
||||||
|
|
||||||
|
@ -41,6 +41,9 @@ export class RouterManager {
|
|||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
getRoutesTree(): RouteObject[] {
|
getRoutesTree(): RouteObject[] {
|
||||||
type RouteTypeWithChildren = RouteType & { children?: RouteTypeWithChildren };
|
type RouteTypeWithChildren = RouteType & { children?: RouteTypeWithChildren };
|
||||||
const routes: Record<string, RouteTypeWithChildren> = {};
|
const routes: Record<string, RouteTypeWithChildren> = {};
|
||||||
@ -106,6 +109,9 @@ export class RouterManager {
|
|||||||
this.options.basename = basename;
|
this.options.basename = basename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
getRouterComponent() {
|
getRouterComponent() {
|
||||||
const { type = 'browser', ...opts } = this.options;
|
const { type = 'browser', ...opts } = this.options;
|
||||||
const Routers = {
|
const Routers = {
|
||||||
|
@ -9,11 +9,17 @@ import { SchemaInitializerOptions } from '../types';
|
|||||||
|
|
||||||
export * from './useAriaAttributeOfMenuItem';
|
export * from './useAriaAttributeOfMenuItem';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function useSchemaInitializerMenuItems(items: any[], name?: string, onClick?: (args: any) => void) {
|
export function useSchemaInitializerMenuItems(items: any[], name?: string, onClick?: (args: any) => void) {
|
||||||
const getMenuItems = useGetSchemaInitializerMenuItems(onClick);
|
const getMenuItems = useGetSchemaInitializerMenuItems(onClick);
|
||||||
return useMemo(() => getMenuItems(items, name), [getMenuItems, items, name]);
|
return useMemo(() => getMenuItems(items, name), [getMenuItems, items, name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function useGetSchemaInitializerMenuItems(onClick?: (args: any) => void) {
|
export function useGetSchemaInitializerMenuItems(onClick?: (args: any) => void) {
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useSchemaInitializerSubMenuContext } from '../components/SchemaInitializerSubMenu';
|
import { useSchemaInitializerSubMenuContext } from '../components/SchemaInitializerSubMenu';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export const useAriaAttributeOfMenuItem = () => {
|
export const useAriaAttributeOfMenuItem = () => {
|
||||||
const { isInMenu } = useSchemaInitializerSubMenuContext();
|
const { isInMenu } = useSchemaInitializerSubMenuContext();
|
||||||
// 在 Menu 中,每一项的 role 已经被标记为 menuitem 了,不需要再次标记;
|
// 在 Menu 中,每一项的 role 已经被标记为 menuitem 了,不需要再次标记;
|
||||||
|
@ -7,6 +7,9 @@ import React from 'react';
|
|||||||
import { useDesignable } from '../../../schema-component';
|
import { useDesignable } from '../../../schema-component';
|
||||||
import { useField, useFieldSchema } from '@formily/react';
|
import { useField, useFieldSchema } from '@formily/react';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export const SchemaSettingsWrapper: FC<SchemaSettingOptions<any>> = (props) => {
|
export const SchemaSettingsWrapper: FC<SchemaSettingOptions<any>> = (props) => {
|
||||||
const { items, Component = SchemaSettingsIcon, name, componentProps, style, ...others } = props;
|
const { items, Component = SchemaSettingsIcon, name, componentProps, style, ...others } = props;
|
||||||
const { dn } = useDesignable();
|
const { dn } = useDesignable();
|
||||||
|
@ -35,6 +35,9 @@ import * as nocobaseClient from '../../index';
|
|||||||
|
|
||||||
import type { RequireJS } from './requirejs';
|
import type { RequireJS } from './requirejs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function defineGlobalDeps(requirejs: RequireJS) {
|
export function defineGlobalDeps(requirejs: RequireJS) {
|
||||||
// react
|
// react
|
||||||
requirejs.define('react', () => React);
|
requirejs.define('react', () => React);
|
||||||
|
@ -3,12 +3,18 @@ import type { PluginData } from '../PluginManager';
|
|||||||
import type { RequireJS } from './requirejs';
|
import type { RequireJS } from './requirejs';
|
||||||
import type { DevDynamicImport } from '../Application';
|
import type { DevDynamicImport } from '../Application';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function defineDevPlugins(plugins: Record<string, typeof Plugin>) {
|
export function defineDevPlugins(plugins: Record<string, typeof Plugin>) {
|
||||||
Object.entries(plugins).forEach(([packageName, plugin]) => {
|
Object.entries(plugins).forEach(([packageName, plugin]) => {
|
||||||
window.define(`${packageName}/client`, () => plugin);
|
window.define(`${packageName}/client`, () => plugin);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function definePluginClient(packageName: string) {
|
export function definePluginClient(packageName: string) {
|
||||||
window.define(`${packageName}/client`, ['exports', packageName], function (_exports: any, _pluginExports: any) {
|
window.define(`${packageName}/client`, ['exports', packageName], function (_exports: any, _pluginExports: any) {
|
||||||
Object.defineProperty(_exports, '__esModule', {
|
Object.defineProperty(_exports, '__esModule', {
|
||||||
@ -27,6 +33,9 @@ export function definePluginClient(packageName: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function configRequirejs(requirejs: any, pluginData: PluginData[]) {
|
export function configRequirejs(requirejs: any, pluginData: PluginData[]) {
|
||||||
requirejs.requirejs.config({
|
requirejs.requirejs.config({
|
||||||
waitSeconds: 120,
|
waitSeconds: 120,
|
||||||
@ -37,6 +46,9 @@ export function configRequirejs(requirejs: any, pluginData: PluginData[]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function processRemotePlugins(pluginData: PluginData[], resolve: (plugins: [string, typeof Plugin][]) => void) {
|
export function processRemotePlugins(pluginData: PluginData[], resolve: (plugins: [string, typeof Plugin][]) => void) {
|
||||||
return (...pluginModules: (typeof Plugin & { default?: typeof Plugin })[]) => {
|
return (...pluginModules: (typeof Plugin & { default?: typeof Plugin })[]) => {
|
||||||
const res: [string, typeof Plugin][] = pluginModules
|
const res: [string, typeof Plugin][] = pluginModules
|
||||||
@ -58,6 +70,9 @@ export function processRemotePlugins(pluginData: PluginData[], resolve: (plugins
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function getRemotePlugins(
|
export function getRemotePlugins(
|
||||||
requirejs: any,
|
requirejs: any,
|
||||||
pluginData: PluginData[] = [],
|
pluginData: PluginData[] = [],
|
||||||
@ -80,6 +95,9 @@ interface GetPluginsOption {
|
|||||||
devDynamicImport?: DevDynamicImport;
|
devDynamicImport?: DevDynamicImport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export async function getPlugins(options: GetPluginsOption): Promise<Array<[string, typeof Plugin]>> {
|
export async function getPlugins(options: GetPluginsOption): Promise<Array<[string, typeof Plugin]>> {
|
||||||
const { requirejs, pluginData, devDynamicImport } = options;
|
const { requirejs, pluginData, devDynamicImport } = options;
|
||||||
if (pluginData.length === 0) return [];
|
if (pluginData.length === 0) return [];
|
||||||
|
@ -10,6 +10,9 @@ export interface RequireJS {
|
|||||||
define: RequireDefine
|
define: RequireDefine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function getRequireJs(): RequireJS {
|
export function getRequireJs(): RequireJS {
|
||||||
var requirejs, require, define;
|
var requirejs, require, define;
|
||||||
var req, s, head, baseElement, dataMain, src,
|
var req, s, head, baseElement, dataMain, src,
|
||||||
|
@ -110,7 +110,7 @@ export class InheritanceCollectionMixin extends Collection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// override Collection
|
// override Collection
|
||||||
getFieldsMap() {
|
protected getFieldsMap() {
|
||||||
if (this.fieldsMap) {
|
if (this.fieldsMap) {
|
||||||
return this.fieldsMap;
|
return this.fieldsMap;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,10 @@ type Props = {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: 初步适配
|
/**
|
||||||
|
* TODO: 初步适配
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export const CollectionFieldInternalField: React.FC = (props: Props) => {
|
export const CollectionFieldInternalField: React.FC = (props: Props) => {
|
||||||
const { component } = props;
|
const { component } = props;
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
|
@ -234,7 +234,8 @@ export class Collection {
|
|||||||
getFields(predicate?: GetCollectionFieldPredicate) {
|
getFields(predicate?: GetCollectionFieldPredicate) {
|
||||||
return predicate ? filter(this.fields, predicate) : this.fields;
|
return predicate ? filter(this.fields, predicate) : this.fields;
|
||||||
}
|
}
|
||||||
getFieldsMap() {
|
|
||||||
|
protected getFieldsMap() {
|
||||||
if (!this.fieldsMap) {
|
if (!this.fieldsMap) {
|
||||||
this.fieldsMap = this.getFields().reduce((memo, field) => {
|
this.fieldsMap = this.getFields().reduce((memo, field) => {
|
||||||
memo[field.name] = field;
|
memo[field.name] = field;
|
||||||
|
@ -131,6 +131,9 @@ export class CollectionManager {
|
|||||||
return this.getCollection(collectionName)?.getFields(predicate) || [];
|
return this.getCollection(collectionName)?.getFields(predicate) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
clone(collections: CollectionOptions[] = []) {
|
clone(collections: CollectionOptions[] = []) {
|
||||||
const collectionManager = new CollectionManager([], this.dataSource);
|
const collectionManager = new CollectionManager([], this.dataSource);
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import type { Application } from '../../application/Application';
|
import type { Application } from '../../application/Application';
|
||||||
import type { CollectionOptions } from './Collection';
|
import type { CollectionOptions } from './Collection';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export const collectionTransform = (collection: CollectionOptions, app: Application) => {
|
export const collectionTransform = (collection: CollectionOptions, app: Application) => {
|
||||||
const { rawTitle, title, fields = [], ...rest } = collection;
|
const { rawTitle, title, fields = [], ...rest } = collection;
|
||||||
return {
|
return {
|
||||||
@ -26,6 +29,9 @@ export const collectionTransform = (collection: CollectionOptions, app: Applicat
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export function applyMixins(Cls: any, mixins: any[], options?: any, collectionManager?: any) {
|
export function applyMixins(Cls: any, mixins: any[], options?: any, collectionManager?: any) {
|
||||||
const instance = new Cls(options, collectionManager);
|
const instance = new Cls(options, collectionManager);
|
||||||
mixins.forEach((MixinClass) => {
|
mixins.forEach((MixinClass) => {
|
||||||
|
@ -15,6 +15,9 @@ export interface CollectionDeletedPlaceholderProps {
|
|||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export const CollectionDeletedPlaceholder: FC<CollectionDeletedPlaceholderProps> = ({ type, name, message }) => {
|
export const CollectionDeletedPlaceholder: FC<CollectionDeletedPlaceholderProps> = ({ type, name, message }) => {
|
||||||
const { designable, dn } = useDesignable();
|
const { designable, dn } = useDesignable();
|
||||||
const { modal } = App.useApp();
|
const { modal } = App.useApp();
|
||||||
|
@ -10,6 +10,9 @@ interface DataSourceApplicationProviderProps extends CollectionManagerProviderPr
|
|||||||
dataSourceManager: DataSourceManager;
|
dataSourceManager: DataSourceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export const DataSourceApplicationProvider: FC<DataSourceApplicationProviderProps> = ({
|
export const DataSourceApplicationProvider: FC<DataSourceApplicationProviderProps> = ({
|
||||||
children,
|
children,
|
||||||
dataSourceManager,
|
dataSourceManager,
|
||||||
|
@ -103,6 +103,9 @@ export interface DataBlockContextValue<T extends {} = {}> {
|
|||||||
export const DataBlockContext = createContext<DataBlockContextValue<any>>({} as any);
|
export const DataBlockContext = createContext<DataBlockContextValue<any>>({} as any);
|
||||||
DataBlockContext.displayName = 'DataBlockContext';
|
DataBlockContext.displayName = 'DataBlockContext';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export const AssociationOrCollectionProvider = (props: {
|
export const AssociationOrCollectionProvider = (props: {
|
||||||
collection: string | CollectionOptions;
|
collection: string | CollectionOptions;
|
||||||
association: string;
|
association: string;
|
||||||
|
@ -83,6 +83,9 @@ export abstract class DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export class LocalDataSource extends DataSource {
|
export class LocalDataSource extends DataSource {
|
||||||
getDataSource() {
|
getDataSource() {
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user