@dovetail-v2/refine 0.3.29-alpha.1 → 0.3.29-alpha.3

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 {};
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export interface DataExpiredModalProps {
3
+ onAbandon: () => void;
4
+ }
5
+ export declare function DataExpiredModal({ onAbandon }: DataExpiredModalProps): JSX.Element;
@@ -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 {};
@@ -0,0 +1,9 @@
1
+ import { BaseRecord } from '@refinedev/core';
2
+ import { QueryObserverResult } from '@tanstack/react-query';
3
+ interface UseResourceVersionCheckParams {
4
+ queryResult?: QueryObserverResult<{
5
+ data: BaseRecord;
6
+ }>;
7
+ }
8
+ export declare const useResourceVersionCheck: ({ queryResult, }: UseResourceVersionCheckParams) => boolean;
9
+ export {};
package/dist/i18n.d.ts CHANGED
@@ -184,6 +184,10 @@ export declare const resources: {
184
184
  connecting: string;
185
185
  reconnect: string;
186
186
  edit_form: string;
187
+ data_expired: string;
188
+ data_expired_body: string;
189
+ data_expired_note: string;
190
+ abandon_edit: string;
187
191
  exit_yaml_tip: string;
188
192
  value_optional: string;
189
193
  effect: string;
@@ -466,6 +470,10 @@ export declare const resources: {
466
470
  reconnect: string;
467
471
  search: string;
468
472
  edit_form: string;
473
+ data_expired: string;
474
+ data_expired_body: string;
475
+ data_expired_note: string;
476
+ abandon_edit: string;
469
477
  exit_yaml_tip: string;
470
478
  form: string;
471
479
  yaml: string;
@@ -181,6 +181,10 @@ declare const _default: {
181
181
  connecting: string;
182
182
  reconnect: string;
183
183
  edit_form: string;
184
+ data_expired: string;
185
+ data_expired_body: string;
186
+ data_expired_note: string;
187
+ abandon_edit: string;
184
188
  exit_yaml_tip: string;
185
189
  value_optional: string;
186
190
  effect: string;
@@ -183,6 +183,10 @@ declare const _default: {
183
183
  reconnect: string;
184
184
  search: string;
185
185
  edit_form: string;
186
+ data_expired: string;
187
+ data_expired_body: string;
188
+ data_expired_note: string;
189
+ abandon_edit: string;
186
190
  exit_yaml_tip: string;
187
191
  form: string;
188
192
  yaml: string;
package/dist/refine.cjs CHANGED
@@ -638,6 +638,10 @@ const disconnected$1 = "Connection Error.";
638
638
  const connecting$1 = "Connecting...";
639
639
  const reconnect$1 = "Reconnect";
640
640
  const edit_form$1 = "Edit form";
641
+ const data_expired$1 = "Data expired";
642
+ const data_expired_body$1 = "The data in this form is no longer the latest version. To avoid saving errors, please discard this edit and reopen the form to edit again.";
643
+ const data_expired_note$1 = "Your current entries will not be saved.";
644
+ const abandon_edit$1 = "Discard edit";
641
645
  const exit_yaml_tip$1 = "If you go back to the form, any changes made to the YAML file will be lost.";
642
646
  const value_optional$1 = "Value (optional)";
643
647
  const effect$1 = "Effect";
@@ -915,6 +919,10 @@ const dovetail$1 = {
915
919
  connecting: connecting$1,
916
920
  reconnect: reconnect$1,
917
921
  edit_form: edit_form$1,
922
+ data_expired: data_expired$1,
923
+ data_expired_body: data_expired_body$1,
924
+ data_expired_note: data_expired_note$1,
925
+ abandon_edit: abandon_edit$1,
918
926
  exit_yaml_tip: exit_yaml_tip$1,
919
927
  value_optional: value_optional$1,
920
928
  effect: effect$1,
@@ -1194,6 +1202,10 @@ const connecting = "正在连接...";
1194
1202
  const reconnect = "重新连接";
1195
1203
  const search = "搜索";
1196
1204
  const edit_form = "编辑表单";
1205
+ const data_expired = "数据已过期";
1206
+ const data_expired_body = "当前表单中的数据已不是最新版。为避免保存失败,请放弃本次编辑,并重新打开表单进行编辑。";
1207
+ const data_expired_note = "当前已填写内容将不会保留。";
1208
+ const abandon_edit = "放弃编辑";
1197
1209
  const exit_yaml_tip = "返回编辑表单,不会保留对 YAML 文件做出的所有更改。";
1198
1210
  const form = "表单";
1199
1211
  const yaml = "YAML";
@@ -1470,6 +1482,10 @@ const dovetail = {
1470
1482
  reconnect,
1471
1483
  search,
1472
1484
  edit_form,
1485
+ data_expired,
1486
+ data_expired_body,
1487
+ data_expired_note,
1488
+ abandon_edit,
1473
1489
  exit_yaml_tip,
1474
1490
  form,
1475
1491
  yaml,
@@ -8048,7 +8064,7 @@ function MetadataForm() {
8048
8064
  }
8049
8065
  const ComponentContext = React.createContext({});
8050
8066
  const GlobalStoreContext = React.createContext({});
8051
- const index_o09auy = "";
8067
+ const index_1s9fcl3 = "";
8052
8068
  const ErrorWrapper = /* @__PURE__ */ styled_default("div")({
8053
8069
  name: "ErrorWrapper",
8054
8070
  class: "egn3dbn",
@@ -10685,6 +10701,26 @@ function usePathMap(options) {
10685
10701
  transformApplyValues
10686
10702
  };
10687
10703
  }
10704
+ const useResourceVersionCheck = ({
10705
+ queryResult
10706
+ }) => {
10707
+ var _a, _b, _c;
10708
+ const initialResourceVersionRef = React.useRef();
10709
+ const [isExpired, setIsExpired] = React.useState(false);
10710
+ const currentResourceVersion = (_c = (_b = (_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data) == null ? void 0 : _b.metadata) == null ? void 0 : _c.resourceVersion;
10711
+ React.useEffect(() => {
10712
+ if (!currentResourceVersion)
10713
+ return;
10714
+ if (!initialResourceVersionRef.current) {
10715
+ initialResourceVersionRef.current = currentResourceVersion;
10716
+ return;
10717
+ }
10718
+ if (currentResourceVersion !== initialResourceVersionRef.current) {
10719
+ setIsExpired(true);
10720
+ }
10721
+ }, [currentResourceVersion]);
10722
+ return isExpired;
10723
+ };
10688
10724
  function getInitialValues(resourceConfig) {
10689
10725
  return resourceConfig.initValue || {
10690
10726
  apiVersion: resourceConfig.apiVersion,
@@ -10693,6 +10729,42 @@ function getInitialValues(resourceConfig) {
10693
10729
  spec: {}
10694
10730
  };
10695
10731
  }
10732
+ const button_1v659kh = "";
10733
+ const WarningButtonStyle = "wwyz7ti";
10734
+ const DataExpiredModal_eazxh6 = "";
10735
+ const NoteStyle = "n609wlp";
10736
+ function DataExpiredModal({
10737
+ onAbandon
10738
+ }) {
10739
+ const {
10740
+ t: t2
10741
+ } = common.useTranslation();
10742
+ return /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.SmallDialog, {
10743
+ title: t2("dovetail.data_expired"),
10744
+ closable: false,
10745
+ maskClosable: false,
10746
+ cancelButtonProps: {
10747
+ style: {
10748
+ display: "none"
10749
+ }
10750
+ },
10751
+ okText: t2("dovetail.abandon_edit"),
10752
+ okButtonProps: {
10753
+ className: WarningButtonStyle
10754
+ },
10755
+ onOk: (popModal) => {
10756
+ popModal();
10757
+ onAbandon();
10758
+ },
10759
+ children: [/* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
10760
+ className: eagle.Typo.Label.l2_regular,
10761
+ children: t2("dovetail.data_expired_body")
10762
+ }), /* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
10763
+ className: `${eagle.Typo.Label.l2_regular} ${NoteStyle}`,
10764
+ children: t2("dovetail.data_expired_note")
10765
+ })]
10766
+ });
10767
+ }
10696
10768
  const index_az4wrx = "";
10697
10769
  const WrapperStyle$5 = "w1akirqw";
10698
10770
  const TitleStyle$2 = "t30srnq";
@@ -11575,6 +11647,29 @@ function YamlFormContainer({
11575
11647
  onSaveButtonPropsChange
11576
11648
  }) {
11577
11649
  const action = id ? "edit" : "create";
11650
+ const pushModal = eagle.usePushModal();
11651
+ const popModal = eagle.usePopModal();
11652
+ const hasShownExpiredRef = React.useRef(false);
11653
+ const queryResult = core.useOne({
11654
+ resource: resourceConfig.name,
11655
+ id,
11656
+ liveMode: id ? "auto" : "off",
11657
+ queryOptions: { enabled: !!id }
11658
+ });
11659
+ const isExpired = useResourceVersionCheck({ queryResult });
11660
+ React.useEffect(() => {
11661
+ if (isExpired && !hasShownExpiredRef.current) {
11662
+ hasShownExpiredRef.current = true;
11663
+ pushModal({
11664
+ component: DataExpiredModal,
11665
+ props: {
11666
+ onAbandon: () => {
11667
+ popModal();
11668
+ }
11669
+ }
11670
+ });
11671
+ }
11672
+ }, [isExpired, pushModal, popModal]);
11578
11673
  const { transformInitValues, transformApplyValues } = usePathMap({
11579
11674
  pathMap: formConfig == null ? void 0 : formConfig.pathMap,
11580
11675
  transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
@@ -12254,17 +12349,14 @@ function CreateButton(props) {
12254
12349
  const { t: t2, i18n: i18n2 } = common.useTranslation();
12255
12350
  const openForm = useOpenForm();
12256
12351
  const { resource } = core.useResource();
12257
- const configs = React.useContext(ConfigsContext);
12258
- const config = configs[(resource == null ? void 0 : resource.name) || ""];
12259
12352
  const label2 = props.label || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
12260
- const createButtonText = config.createButtonText;
12261
12353
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
12262
12354
  eagle.Button,
12263
12355
  {
12264
12356
  prefixIcon: /* @__PURE__ */ common.jsxRuntimeExports.jsx(iconsReact.PlusAddCreateNew16BoldOntintIcon, {}),
12265
12357
  type: "primary",
12266
12358
  onClick: () => openForm(),
12267
- children: createButtonText || t2("dovetail.create_resource", {
12359
+ children: props.children || t2("dovetail.create_resource", {
12268
12360
  resource: transformResourceKindInSentence(label2, i18n2.language)
12269
12361
  })
12270
12362
  }
@@ -12322,7 +12414,8 @@ const TableToolBar = ({
12322
12414
  title,
12323
12415
  description,
12324
12416
  selectedKeys,
12325
- hideCreate
12417
+ hideCreate,
12418
+ createButtonElement
12326
12419
  }) => {
12327
12420
  const {
12328
12421
  resource
@@ -12340,7 +12433,7 @@ const TableToolBar = ({
12340
12433
  }) : void 0, /* @__PURE__ */ common.jsxRuntimeExports.jsx(core.CanAccess, {
12341
12434
  resource: resource == null ? void 0 : resource.name,
12342
12435
  action: AccessControlAuth.Create,
12343
- children: !hideCreate ? /* @__PURE__ */ common.jsxRuntimeExports.jsx(CreateButton, {
12436
+ children: !hideCreate ? createButtonElement || /* @__PURE__ */ common.jsxRuntimeExports.jsx(CreateButton, {
12344
12437
  label: title
12345
12438
  }) : null
12346
12439
  })]
@@ -15870,7 +15963,8 @@ function ListPage(props) {
15870
15963
  selectedKeys,
15871
15964
  title: (config == null ? void 0 : config.customListTitle) || (config == null ? void 0 : config.displayName) || config.kind,
15872
15965
  description: config == null ? void 0 : config.description,
15873
- hideCreate: config == null ? void 0 : config.hideCreate
15966
+ hideCreate: config == null ? void 0 : config.hideCreate,
15967
+ createButtonElement: config == null ? void 0 : config.createButtonElement
15874
15968
  }), belowToolBarContent, /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Divider, {
15875
15969
  style: {
15876
15970
  margin: 0,
@@ -15939,8 +16033,6 @@ function ResourceShow(props) {
15939
16033
  }
15940
16034
  );
15941
16035
  }
15942
- const button_1v659kh = "";
15943
- const WarningButtonStyle = "wwyz7ti";
15944
16036
  const modal_1eijuvm = "";
15945
16037
  const SmallModalStyle = "s1nc293e";
15946
16038
  function FormModeSegmentControl({
@@ -16973,7 +17065,7 @@ const useRefineForm = (props) => {
16973
17065
  resource: resourceConfig.name,
16974
17066
  action: id ? "edit" : "create",
16975
17067
  id,
16976
- liveMode: "off",
17068
+ liveMode: id ? "auto" : "off",
16977
17069
  ...refineProps
16978
17070
  },
16979
17071
  defaultValues: (options == null ? void 0 : options.initialValues) || (resourceConfig == null ? void 0 : resourceConfig.initValue),
@@ -17017,6 +17109,9 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17017
17109
  }, ref) {
17018
17110
  var _a, _b;
17019
17111
  const action = id ? "edit" : "create";
17112
+ const pushModal = eagle.usePushModal();
17113
+ const popModal = eagle.usePopModal();
17114
+ const hasShownExpiredRef = React.useRef(false);
17020
17115
  const refineFormResult = useRefineForm({
17021
17116
  resourceConfig,
17022
17117
  id,
@@ -17043,6 +17138,22 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17043
17138
  }
17044
17139
  }
17045
17140
  });
17141
+ const isExpired = useResourceVersionCheck({
17142
+ queryResult: refineFormResult.formResult.refineCore.queryResult
17143
+ });
17144
+ React.useEffect(() => {
17145
+ if (isExpired && !hasShownExpiredRef.current) {
17146
+ hasShownExpiredRef.current = true;
17147
+ pushModal({
17148
+ component: DataExpiredModal,
17149
+ props: {
17150
+ onAbandon: () => {
17151
+ popModal();
17152
+ }
17153
+ }
17154
+ });
17155
+ }
17156
+ }, [isExpired, pushModal, popModal]);
17046
17157
  const fieldsConfig = useFieldsConfig(
17047
17158
  resourceConfig,
17048
17159
  { fields: formConfig == null ? void 0 : formConfig.fields },
package/dist/refine.js CHANGED
@@ -7,7 +7,7 @@ var __publicField = (obj, key2, value2) => {
7
7
  import dayjs from "dayjs";
8
8
  import i18n from "i18next";
9
9
  import { w as warnOnce, g as getDefaults, a as warn, b as getI18n, s as setDefaults, d as setI18n, I as I18nContext, j as jsxRuntimeExports, u as useTranslation, c as cx_default, S as SocketStatus } from "./common-241b21f8.js";
10
- import { ResourceContext, matchResourceFromRoute, useResource, useDelete, useNavigation, useBreadcrumb, useList, CanAccess, useUpdate, useForm as useForm$2, pickNotDeprecated, useWarnAboutChange, useParsed, useGo, useCan, useTable, useDeleteMany, useShow, useRefineContext, useTranslate, flattenObjectKeys, useMenu, Refine } from "@refinedev/core";
10
+ import { ResourceContext, matchResourceFromRoute, useResource, useDelete, useNavigation, useBreadcrumb, useList, CanAccess, useUpdate, useForm as useForm$2, pickNotDeprecated, useWarnAboutChange, useOne, useParsed, useGo, useCan, useTable, useDeleteMany, useShow, useRefineContext, useTranslate, flattenObjectKeys, useMenu, Refine } from "@refinedev/core";
11
11
  import { parse, stringify } from "qs";
12
12
  import React, { createElement, isValidElement, cloneElement, Children, useContext, useCallback, createContext, useState, useEffect, useMemo, useRef, useImperativeHandle, forwardRef, Suspense, lazy, memo } from "react";
13
13
  import { useLocation, useHistory, useParams, matchPath, Link, Route, NavLink, Router } from "react-router-dom";
@@ -619,6 +619,10 @@ const disconnected$1 = "Connection Error.";
619
619
  const connecting$1 = "Connecting...";
620
620
  const reconnect$1 = "Reconnect";
621
621
  const edit_form$1 = "Edit form";
622
+ const data_expired$1 = "Data expired";
623
+ const data_expired_body$1 = "The data in this form is no longer the latest version. To avoid saving errors, please discard this edit and reopen the form to edit again.";
624
+ const data_expired_note$1 = "Your current entries will not be saved.";
625
+ const abandon_edit$1 = "Discard edit";
622
626
  const exit_yaml_tip$1 = "If you go back to the form, any changes made to the YAML file will be lost.";
623
627
  const value_optional$1 = "Value (optional)";
624
628
  const effect$1 = "Effect";
@@ -896,6 +900,10 @@ const dovetail$1 = {
896
900
  connecting: connecting$1,
897
901
  reconnect: reconnect$1,
898
902
  edit_form: edit_form$1,
903
+ data_expired: data_expired$1,
904
+ data_expired_body: data_expired_body$1,
905
+ data_expired_note: data_expired_note$1,
906
+ abandon_edit: abandon_edit$1,
899
907
  exit_yaml_tip: exit_yaml_tip$1,
900
908
  value_optional: value_optional$1,
901
909
  effect: effect$1,
@@ -1175,6 +1183,10 @@ const connecting = "正在连接...";
1175
1183
  const reconnect = "重新连接";
1176
1184
  const search = "搜索";
1177
1185
  const edit_form = "编辑表单";
1186
+ const data_expired = "数据已过期";
1187
+ const data_expired_body = "当前表单中的数据已不是最新版。为避免保存失败,请放弃本次编辑,并重新打开表单进行编辑。";
1188
+ const data_expired_note = "当前已填写内容将不会保留。";
1189
+ const abandon_edit = "放弃编辑";
1178
1190
  const exit_yaml_tip = "返回编辑表单,不会保留对 YAML 文件做出的所有更改。";
1179
1191
  const form = "表单";
1180
1192
  const yaml = "YAML";
@@ -1451,6 +1463,10 @@ const dovetail = {
1451
1463
  reconnect,
1452
1464
  search,
1453
1465
  edit_form,
1466
+ data_expired,
1467
+ data_expired_body,
1468
+ data_expired_note,
1469
+ abandon_edit,
1454
1470
  exit_yaml_tip,
1455
1471
  form,
1456
1472
  yaml,
@@ -8029,7 +8045,7 @@ function MetadataForm() {
8029
8045
  }
8030
8046
  const ComponentContext = createContext({});
8031
8047
  const GlobalStoreContext = createContext({});
8032
- const index_o09auy = "";
8048
+ const index_1s9fcl3 = "";
8033
8049
  const ErrorWrapper = /* @__PURE__ */ styled_default("div")({
8034
8050
  name: "ErrorWrapper",
8035
8051
  class: "egn3dbn",
@@ -10666,6 +10682,26 @@ function usePathMap(options) {
10666
10682
  transformApplyValues
10667
10683
  };
10668
10684
  }
10685
+ const useResourceVersionCheck = ({
10686
+ queryResult
10687
+ }) => {
10688
+ var _a, _b, _c;
10689
+ const initialResourceVersionRef = useRef();
10690
+ const [isExpired, setIsExpired] = useState(false);
10691
+ const currentResourceVersion = (_c = (_b = (_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data) == null ? void 0 : _b.metadata) == null ? void 0 : _c.resourceVersion;
10692
+ useEffect(() => {
10693
+ if (!currentResourceVersion)
10694
+ return;
10695
+ if (!initialResourceVersionRef.current) {
10696
+ initialResourceVersionRef.current = currentResourceVersion;
10697
+ return;
10698
+ }
10699
+ if (currentResourceVersion !== initialResourceVersionRef.current) {
10700
+ setIsExpired(true);
10701
+ }
10702
+ }, [currentResourceVersion]);
10703
+ return isExpired;
10704
+ };
10669
10705
  function getInitialValues(resourceConfig) {
10670
10706
  return resourceConfig.initValue || {
10671
10707
  apiVersion: resourceConfig.apiVersion,
@@ -10674,6 +10710,42 @@ function getInitialValues(resourceConfig) {
10674
10710
  spec: {}
10675
10711
  };
10676
10712
  }
10713
+ const button_1v659kh = "";
10714
+ const WarningButtonStyle = "wwyz7ti";
10715
+ const DataExpiredModal_eazxh6 = "";
10716
+ const NoteStyle = "n609wlp";
10717
+ function DataExpiredModal({
10718
+ onAbandon
10719
+ }) {
10720
+ const {
10721
+ t: t2
10722
+ } = useTranslation();
10723
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(SmallDialog, {
10724
+ title: t2("dovetail.data_expired"),
10725
+ closable: false,
10726
+ maskClosable: false,
10727
+ cancelButtonProps: {
10728
+ style: {
10729
+ display: "none"
10730
+ }
10731
+ },
10732
+ okText: t2("dovetail.abandon_edit"),
10733
+ okButtonProps: {
10734
+ className: WarningButtonStyle
10735
+ },
10736
+ onOk: (popModal) => {
10737
+ popModal();
10738
+ onAbandon();
10739
+ },
10740
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx("div", {
10741
+ className: Typo.Label.l2_regular,
10742
+ children: t2("dovetail.data_expired_body")
10743
+ }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
10744
+ className: `${Typo.Label.l2_regular} ${NoteStyle}`,
10745
+ children: t2("dovetail.data_expired_note")
10746
+ })]
10747
+ });
10748
+ }
10677
10749
  const index_az4wrx = "";
10678
10750
  const WrapperStyle$5 = "w1akirqw";
10679
10751
  const TitleStyle$2 = "t30srnq";
@@ -11556,6 +11628,29 @@ function YamlFormContainer({
11556
11628
  onSaveButtonPropsChange
11557
11629
  }) {
11558
11630
  const action = id ? "edit" : "create";
11631
+ const pushModal = usePushModal();
11632
+ const popModal = usePopModal();
11633
+ const hasShownExpiredRef = useRef(false);
11634
+ const queryResult = useOne({
11635
+ resource: resourceConfig.name,
11636
+ id,
11637
+ liveMode: id ? "auto" : "off",
11638
+ queryOptions: { enabled: !!id }
11639
+ });
11640
+ const isExpired = useResourceVersionCheck({ queryResult });
11641
+ useEffect(() => {
11642
+ if (isExpired && !hasShownExpiredRef.current) {
11643
+ hasShownExpiredRef.current = true;
11644
+ pushModal({
11645
+ component: DataExpiredModal,
11646
+ props: {
11647
+ onAbandon: () => {
11648
+ popModal();
11649
+ }
11650
+ }
11651
+ });
11652
+ }
11653
+ }, [isExpired, pushModal, popModal]);
11559
11654
  const { transformInitValues, transformApplyValues } = usePathMap({
11560
11655
  pathMap: formConfig == null ? void 0 : formConfig.pathMap,
11561
11656
  transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
@@ -12235,17 +12330,14 @@ function CreateButton(props) {
12235
12330
  const { t: t2, i18n: i18n2 } = useTranslation();
12236
12331
  const openForm = useOpenForm();
12237
12332
  const { resource } = useResource();
12238
- const configs = useContext(ConfigsContext);
12239
- const config = configs[(resource == null ? void 0 : resource.name) || ""];
12240
12333
  const label2 = props.label || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
12241
- const createButtonText = config.createButtonText;
12242
12334
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
12243
12335
  Button,
12244
12336
  {
12245
12337
  prefixIcon: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusAddCreateNew16BoldOntintIcon, {}),
12246
12338
  type: "primary",
12247
12339
  onClick: () => openForm(),
12248
- children: createButtonText || t2("dovetail.create_resource", {
12340
+ children: props.children || t2("dovetail.create_resource", {
12249
12341
  resource: transformResourceKindInSentence(label2, i18n2.language)
12250
12342
  })
12251
12343
  }
@@ -12303,7 +12395,8 @@ const TableToolBar = ({
12303
12395
  title,
12304
12396
  description,
12305
12397
  selectedKeys,
12306
- hideCreate
12398
+ hideCreate,
12399
+ createButtonElement
12307
12400
  }) => {
12308
12401
  const {
12309
12402
  resource
@@ -12321,7 +12414,7 @@ const TableToolBar = ({
12321
12414
  }) : void 0, /* @__PURE__ */ jsxRuntimeExports.jsx(CanAccess, {
12322
12415
  resource: resource == null ? void 0 : resource.name,
12323
12416
  action: AccessControlAuth.Create,
12324
- children: !hideCreate ? /* @__PURE__ */ jsxRuntimeExports.jsx(CreateButton, {
12417
+ children: !hideCreate ? createButtonElement || /* @__PURE__ */ jsxRuntimeExports.jsx(CreateButton, {
12325
12418
  label: title
12326
12419
  }) : null
12327
12420
  })]
@@ -15851,7 +15944,8 @@ function ListPage(props) {
15851
15944
  selectedKeys,
15852
15945
  title: (config == null ? void 0 : config.customListTitle) || (config == null ? void 0 : config.displayName) || config.kind,
15853
15946
  description: config == null ? void 0 : config.description,
15854
- hideCreate: config == null ? void 0 : config.hideCreate
15947
+ hideCreate: config == null ? void 0 : config.hideCreate,
15948
+ createButtonElement: config == null ? void 0 : config.createButtonElement
15855
15949
  }), belowToolBarContent, /* @__PURE__ */ jsxRuntimeExports.jsx(Divider, {
15856
15950
  style: {
15857
15951
  margin: 0,
@@ -15920,8 +16014,6 @@ function ResourceShow(props) {
15920
16014
  }
15921
16015
  );
15922
16016
  }
15923
- const button_1v659kh = "";
15924
- const WarningButtonStyle = "wwyz7ti";
15925
16017
  const modal_1eijuvm = "";
15926
16018
  const SmallModalStyle = "s1nc293e";
15927
16019
  function FormModeSegmentControl({
@@ -16954,7 +17046,7 @@ const useRefineForm = (props) => {
16954
17046
  resource: resourceConfig.name,
16955
17047
  action: id ? "edit" : "create",
16956
17048
  id,
16957
- liveMode: "off",
17049
+ liveMode: id ? "auto" : "off",
16958
17050
  ...refineProps
16959
17051
  },
16960
17052
  defaultValues: (options == null ? void 0 : options.initialValues) || (resourceConfig == null ? void 0 : resourceConfig.initValue),
@@ -16998,6 +17090,9 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
16998
17090
  }, ref) {
16999
17091
  var _a, _b;
17000
17092
  const action = id ? "edit" : "create";
17093
+ const pushModal = usePushModal();
17094
+ const popModal = usePopModal();
17095
+ const hasShownExpiredRef = useRef(false);
17001
17096
  const refineFormResult = useRefineForm({
17002
17097
  resourceConfig,
17003
17098
  id,
@@ -17024,6 +17119,22 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17024
17119
  }
17025
17120
  }
17026
17121
  });
17122
+ const isExpired = useResourceVersionCheck({
17123
+ queryResult: refineFormResult.formResult.refineCore.queryResult
17124
+ });
17125
+ useEffect(() => {
17126
+ if (isExpired && !hasShownExpiredRef.current) {
17127
+ hasShownExpiredRef.current = true;
17128
+ pushModal({
17129
+ component: DataExpiredModal,
17130
+ props: {
17131
+ onAbandon: () => {
17132
+ popModal();
17133
+ }
17134
+ }
17135
+ });
17136
+ }
17137
+ }, [isExpired, pushModal, popModal]);
17027
17138
  const fieldsConfig = useFieldsConfig(
17028
17139
  resourceConfig,
17029
17140
  { fields: formConfig == null ? void 0 : formConfig.fields },
package/dist/style.css CHANGED
@@ -716,7 +716,7 @@
716
716
  color: rgba(44, 56, 82, 0.6);
717
717
  }
718
718
  .egn3dbn.card {
719
- padding: 15px 0;
719
+ padding: 8px 0;
720
720
  }
721
721
  .egn3dbn.card .title {
722
722
  color: rgba(0, 21, 64, 0.3);
@@ -1148,6 +1148,113 @@
1148
1148
  /* box shadow */
1149
1149
  /* fisheye */
1150
1150
  /* z-index */
1151
+ .wwyz7ti.ant-btn.ant-btn.ant-btn-primary {
1152
+ background-color: #fea008;
1153
+ }
1154
+ .wwyz7ti.ant-btn.ant-btn.ant-btn-primary:hover {
1155
+ background-color: #feba33;
1156
+ }
1157
+
1158
+ .c1xsou5f.ant-btn {
1159
+ border-radius: 6px;
1160
+ border: 1px solid rgba(172, 186, 211, 0.6) !important;
1161
+ }/* // basic */
1162
+ /* FishEye Color Variables and Functions */
1163
+ /*
1164
+ --------------------------- Primary Color ---------------------------
1165
+ */
1166
+ /*
1167
+ ---------------------------When necessary to add at any time---------------------------
1168
+ */
1169
+ /* computed */
1170
+ /* blue */
1171
+ /* green */
1172
+ /* yellow */
1173
+ /* red */
1174
+ /* purple */
1175
+ /* palette global token*/
1176
+ /* color opaque */
1177
+ /* color transparent */
1178
+ /* blue transparent */
1179
+ /* green transparent */
1180
+ /* yellow transparent */
1181
+ /* red transparent */
1182
+ /* gray transparent */
1183
+ /* white transparent */
1184
+ /* gradient opaque */
1185
+ /* blue radial gradient */
1186
+ /* blue linear gradient */
1187
+ /* green radial gradient */
1188
+ /* yellow radial gradient */
1189
+ /* red radial gradient */
1190
+ /* gray radial gradient */
1191
+ /* white to gray radial gradient */
1192
+ /* white to gray linear gradient */
1193
+ /* gradient transparent */
1194
+ /* secondary palette */
1195
+ /* purple radial gradient */
1196
+ /* refine alias color */
1197
+ /* text */
1198
+ /* link */
1199
+ /* fill */
1200
+ /* fill element */
1201
+ /* fill interaction */
1202
+ /* stroke */
1203
+ /* background */
1204
+ /* dim */
1205
+ /* box shadow */
1206
+ /* fisheye */
1207
+ /* z-index */
1208
+ .n609wlp {
1209
+ margin-top: 8px;
1210
+ color: #2d3a56;
1211
+ }/* // basic */
1212
+ /* FishEye Color Variables and Functions */
1213
+ /*
1214
+ --------------------------- Primary Color ---------------------------
1215
+ */
1216
+ /*
1217
+ ---------------------------When necessary to add at any time---------------------------
1218
+ */
1219
+ /* computed */
1220
+ /* blue */
1221
+ /* green */
1222
+ /* yellow */
1223
+ /* red */
1224
+ /* purple */
1225
+ /* palette global token*/
1226
+ /* color opaque */
1227
+ /* color transparent */
1228
+ /* blue transparent */
1229
+ /* green transparent */
1230
+ /* yellow transparent */
1231
+ /* red transparent */
1232
+ /* gray transparent */
1233
+ /* white transparent */
1234
+ /* gradient opaque */
1235
+ /* blue radial gradient */
1236
+ /* blue linear gradient */
1237
+ /* green radial gradient */
1238
+ /* yellow radial gradient */
1239
+ /* red radial gradient */
1240
+ /* gray radial gradient */
1241
+ /* white to gray radial gradient */
1242
+ /* white to gray linear gradient */
1243
+ /* gradient transparent */
1244
+ /* secondary palette */
1245
+ /* purple radial gradient */
1246
+ /* refine alias color */
1247
+ /* text */
1248
+ /* link */
1249
+ /* fill */
1250
+ /* fill element */
1251
+ /* fill interaction */
1252
+ /* stroke */
1253
+ /* background */
1254
+ /* dim */
1255
+ /* box shadow */
1256
+ /* fisheye */
1257
+ /* z-index */
1151
1258
  .w1akirqw {
1152
1259
  height: 100%;
1153
1260
  display: flex;
@@ -4269,63 +4376,6 @@
4269
4376
  /* box shadow */
4270
4377
  /* fisheye */
4271
4378
  /* z-index */
4272
- .wwyz7ti.ant-btn.ant-btn.ant-btn-primary {
4273
- background-color: #fea008;
4274
- }
4275
- .wwyz7ti.ant-btn.ant-btn.ant-btn-primary:hover {
4276
- background-color: #feba33;
4277
- }
4278
-
4279
- .c1xsou5f.ant-btn {
4280
- border-radius: 6px;
4281
- border: 1px solid rgba(172, 186, 211, 0.6) !important;
4282
- }/* // basic */
4283
- /* FishEye Color Variables and Functions */
4284
- /*
4285
- --------------------------- Primary Color ---------------------------
4286
- */
4287
- /*
4288
- ---------------------------When necessary to add at any time---------------------------
4289
- */
4290
- /* computed */
4291
- /* blue */
4292
- /* green */
4293
- /* yellow */
4294
- /* red */
4295
- /* purple */
4296
- /* palette global token*/
4297
- /* color opaque */
4298
- /* color transparent */
4299
- /* blue transparent */
4300
- /* green transparent */
4301
- /* yellow transparent */
4302
- /* red transparent */
4303
- /* gray transparent */
4304
- /* white transparent */
4305
- /* gradient opaque */
4306
- /* blue radial gradient */
4307
- /* blue linear gradient */
4308
- /* green radial gradient */
4309
- /* yellow radial gradient */
4310
- /* red radial gradient */
4311
- /* gray radial gradient */
4312
- /* white to gray radial gradient */
4313
- /* white to gray linear gradient */
4314
- /* gradient transparent */
4315
- /* secondary palette */
4316
- /* purple radial gradient */
4317
- /* refine alias color */
4318
- /* text */
4319
- /* link */
4320
- /* fill */
4321
- /* fill element */
4322
- /* fill interaction */
4323
- /* stroke */
4324
- /* background */
4325
- /* dim */
4326
- /* box shadow */
4327
- /* fisheye */
4328
- /* z-index */
4329
4379
  .fq4465w.ant-modal.fullscreen .ant-modal-header {
4330
4380
  padding: 60px 0 32px 0;
4331
4381
  max-width: var(--max-modal-width, 1024px);
@@ -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.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",