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