@dovetail-v2/refine 0.3.29-alpha.1 → 0.3.29-alpha.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.
@@ -1,6 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  interface CreateButtonProps {
3
3
  label?: string;
4
+ children?: React.ReactNode;
4
5
  }
5
6
  export declare function CreateButton(props: CreateButtonProps): JSX.Element;
6
7
  export {};
@@ -4,6 +4,7 @@ type Props = {
4
4
  description?: React.ReactNode;
5
5
  selectedKeys: string[];
6
6
  hideCreate?: boolean;
7
+ createButtonElement?: React.ReactNode;
7
8
  };
8
9
  export declare const TableToolBar: React.FC<Props>;
9
10
  export {};
package/dist/refine.cjs CHANGED
@@ -12254,17 +12254,14 @@ function CreateButton(props) {
12254
12254
  const { t: t2, i18n: i18n2 } = common.useTranslation();
12255
12255
  const openForm = useOpenForm();
12256
12256
  const { resource } = core.useResource();
12257
- const configs = React.useContext(ConfigsContext);
12258
- const config = configs[(resource == null ? void 0 : resource.name) || ""];
12259
12257
  const label2 = props.label || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
12260
- const createButtonText = config.createButtonText;
12261
12258
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
12262
12259
  eagle.Button,
12263
12260
  {
12264
12261
  prefixIcon: /* @__PURE__ */ common.jsxRuntimeExports.jsx(iconsReact.PlusAddCreateNew16BoldOntintIcon, {}),
12265
12262
  type: "primary",
12266
12263
  onClick: () => openForm(),
12267
- children: createButtonText || t2("dovetail.create_resource", {
12264
+ children: props.children || t2("dovetail.create_resource", {
12268
12265
  resource: transformResourceKindInSentence(label2, i18n2.language)
12269
12266
  })
12270
12267
  }
@@ -12322,7 +12319,8 @@ const TableToolBar = ({
12322
12319
  title,
12323
12320
  description,
12324
12321
  selectedKeys,
12325
- hideCreate
12322
+ hideCreate,
12323
+ createButtonElement
12326
12324
  }) => {
12327
12325
  const {
12328
12326
  resource
@@ -12340,7 +12338,7 @@ const TableToolBar = ({
12340
12338
  }) : void 0, /* @__PURE__ */ common.jsxRuntimeExports.jsx(core.CanAccess, {
12341
12339
  resource: resource == null ? void 0 : resource.name,
12342
12340
  action: AccessControlAuth.Create,
12343
- children: !hideCreate ? /* @__PURE__ */ common.jsxRuntimeExports.jsx(CreateButton, {
12341
+ children: !hideCreate ? createButtonElement || /* @__PURE__ */ common.jsxRuntimeExports.jsx(CreateButton, {
12344
12342
  label: title
12345
12343
  }) : null
12346
12344
  })]
@@ -15870,7 +15868,8 @@ function ListPage(props) {
15870
15868
  selectedKeys,
15871
15869
  title: (config == null ? void 0 : config.customListTitle) || (config == null ? void 0 : config.displayName) || config.kind,
15872
15870
  description: config == null ? void 0 : config.description,
15873
- hideCreate: config == null ? void 0 : config.hideCreate
15871
+ hideCreate: config == null ? void 0 : config.hideCreate,
15872
+ createButtonElement: config == null ? void 0 : config.createButtonElement
15874
15873
  }), belowToolBarContent, /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Divider, {
15875
15874
  style: {
15876
15875
  margin: 0,
package/dist/refine.js CHANGED
@@ -12235,17 +12235,14 @@ function CreateButton(props) {
12235
12235
  const { t: t2, i18n: i18n2 } = useTranslation();
12236
12236
  const openForm = useOpenForm();
12237
12237
  const { resource } = useResource();
12238
- const configs = useContext(ConfigsContext);
12239
- const config = configs[(resource == null ? void 0 : resource.name) || ""];
12240
12238
  const label2 = props.label || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
12241
- const createButtonText = config.createButtonText;
12242
12239
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
12243
12240
  Button,
12244
12241
  {
12245
12242
  prefixIcon: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusAddCreateNew16BoldOntintIcon, {}),
12246
12243
  type: "primary",
12247
12244
  onClick: () => openForm(),
12248
- children: createButtonText || t2("dovetail.create_resource", {
12245
+ children: props.children || t2("dovetail.create_resource", {
12249
12246
  resource: transformResourceKindInSentence(label2, i18n2.language)
12250
12247
  })
12251
12248
  }
@@ -12303,7 +12300,8 @@ const TableToolBar = ({
12303
12300
  title,
12304
12301
  description,
12305
12302
  selectedKeys,
12306
- hideCreate
12303
+ hideCreate,
12304
+ createButtonElement
12307
12305
  }) => {
12308
12306
  const {
12309
12307
  resource
@@ -12321,7 +12319,7 @@ const TableToolBar = ({
12321
12319
  }) : void 0, /* @__PURE__ */ jsxRuntimeExports.jsx(CanAccess, {
12322
12320
  resource: resource == null ? void 0 : resource.name,
12323
12321
  action: AccessControlAuth.Create,
12324
- children: !hideCreate ? /* @__PURE__ */ jsxRuntimeExports.jsx(CreateButton, {
12322
+ children: !hideCreate ? createButtonElement || /* @__PURE__ */ jsxRuntimeExports.jsx(CreateButton, {
12325
12323
  label: title
12326
12324
  }) : null
12327
12325
  })]
@@ -15851,7 +15849,8 @@ function ListPage(props) {
15851
15849
  selectedKeys,
15852
15850
  title: (config == null ? void 0 : config.customListTitle) || (config == null ? void 0 : config.displayName) || config.kind,
15853
15851
  description: config == null ? void 0 : config.description,
15854
- hideCreate: config == null ? void 0 : config.hideCreate
15852
+ hideCreate: config == null ? void 0 : config.hideCreate,
15853
+ createButtonElement: config == null ? void 0 : config.createButtonElement
15855
15854
  }), belowToolBarContent, /* @__PURE__ */ jsxRuntimeExports.jsx(Divider, {
15856
15855
  style: {
15857
15856
  margin: 0,
@@ -205,8 +205,8 @@ export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
205
205
  * 开启后,Dovetail不会为该资源创建路由,也不会渲染默认的UI组件。
206
206
  */
207
207
  isCustom?: boolean;
208
- /** 创建按钮的文本 */
209
- createButtonText?: string;
208
+ /** 自定义创建按钮元素,提供时替代默认的 CreateButton 组件 */
209
+ createButtonElement?: React.ReactNode;
210
210
  /** 删除操作的提示文本
211
211
  * 默认是:该操作无法被撤回。
212
212
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.3.29-alpha.1",
3
+ "version": "0.3.29-alpha.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",