fastapi-rtk 0.2.10 → 0.2.12

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.
Files changed (46) hide show
  1. package/dist/.bundled/jsonforms/cjs/_virtual/index10.cjs +2 -2
  2. package/dist/.bundled/jsonforms/cjs/_virtual/index3.cjs +2 -2
  3. package/dist/.bundled/jsonforms/cjs/_virtual/index4.cjs +2 -2
  4. package/dist/.bundled/jsonforms/cjs/_virtual/index5.cjs +2 -2
  5. package/dist/.bundled/jsonforms/cjs/_virtual/index6.cjs +2 -2
  6. package/dist/.bundled/jsonforms/cjs/_virtual/index7.cjs +2 -2
  7. package/dist/.bundled/jsonforms/cjs/_virtual/index8.cjs +2 -2
  8. package/dist/.bundled/jsonforms/cjs/_virtual/index9.cjs +2 -2
  9. package/dist/.bundled/jsonforms/esm/_virtual/index10.mjs +2 -2
  10. package/dist/.bundled/jsonforms/esm/_virtual/index3.mjs +2 -2
  11. package/dist/.bundled/jsonforms/esm/_virtual/index4.mjs +2 -2
  12. package/dist/.bundled/jsonforms/esm/_virtual/index5.mjs +2 -2
  13. package/dist/.bundled/jsonforms/esm/_virtual/index6.mjs +2 -2
  14. package/dist/.bundled/jsonforms/esm/_virtual/index7.mjs +2 -2
  15. package/dist/.bundled/jsonforms/esm/_virtual/index8.mjs +2 -2
  16. package/dist/.bundled/jsonforms/esm/_virtual/index9.mjs +2 -2
  17. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/compile/codegen/index.cjs +1 -1
  18. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/compile/index.cjs +1 -1
  19. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/compile/validate/index.cjs +1 -1
  20. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/applicator/index.cjs +1 -1
  21. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/core/index.cjs +1 -1
  22. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/discriminator/index.cjs +1 -1
  23. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/format/index.cjs +1 -1
  24. package/dist/.external/cjs/ajv@8.17.1/ajv/dist/vocabularies/validation/index.cjs +1 -1
  25. package/dist/.external/esm/ajv@8.17.1/ajv/dist/compile/codegen/index.mjs +1 -1
  26. package/dist/.external/esm/ajv@8.17.1/ajv/dist/compile/index.mjs +1 -1
  27. package/dist/.external/esm/ajv@8.17.1/ajv/dist/compile/validate/index.mjs +1 -1
  28. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/applicator/index.mjs +1 -1
  29. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/core/index.mjs +1 -1
  30. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/discriminator/index.mjs +1 -1
  31. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/format/index.mjs +1 -1
  32. package/dist/.external/esm/ajv@8.17.1/ajv/dist/vocabularies/validation/index.mjs +1 -1
  33. package/dist/core/cjs/ActionIcons/Edit/EditDialog.cjs +22 -12
  34. package/dist/core/cjs/Tables/NextGenDataGrid/NextGenDataGrid.cjs +14 -1
  35. package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/Cell.cjs +8 -12
  36. package/dist/core/cjs/_virtual/_commonjsHelpers.cjs +2 -0
  37. package/dist/core/cjs/_virtual/lodash.cjs +5 -0
  38. package/dist/core/cjs/_virtual/lodash2.cjs +4 -0
  39. package/dist/core/esm/ActionIcons/Edit/EditDialog.mjs +23 -13
  40. package/dist/core/esm/Tables/NextGenDataGrid/NextGenDataGrid.mjs +14 -1
  41. package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/Cell.mjs +8 -12
  42. package/dist/core/esm/_virtual/_commonjsHelpers.mjs +2 -0
  43. package/dist/core/esm/_virtual/lodash.mjs +5 -0
  44. package/dist/core/esm/_virtual/lodash2.mjs +4 -0
  45. package/dist/core/lib/Tables/NextGenDataGrid/NextGenDataGrid.d.ts +88 -4
  46. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var format = {};
4
- exports.__exports = format;
3
+ var compile = {};
4
+ exports.__exports = compile;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var discriminator = {};
4
- exports.__exports = discriminator;
3
+ var codegen = {};
4
+ exports.__exports = codegen;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var validate = {};
4
- exports.__exports = validate;
3
+ var discriminator = {};
4
+ exports.__exports = discriminator;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var codegen = {};
4
- exports.__exports = codegen;
3
+ var validate = {};
4
+ exports.__exports = validate;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var compile = {};
4
- exports.__exports = compile;
3
+ var core = {};
4
+ exports.__exports = core;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var core = {};
4
- exports.__exports = core;
3
+ var validation = {};
4
+ exports.__exports = validation;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var validation = {};
4
- exports.__exports = validation;
3
+ var applicator = {};
4
+ exports.__exports = applicator;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var applicator = {};
4
- exports.__exports = applicator;
3
+ var format = {};
4
+ exports.__exports = format;
@@ -1,4 +1,4 @@
1
- var format = {};
1
+ var compile = {};
2
2
  export {
3
- format as __exports
3
+ compile as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var discriminator = {};
1
+ var codegen = {};
2
2
  export {
3
- discriminator as __exports
3
+ codegen as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var validate = {};
1
+ var discriminator = {};
2
2
  export {
3
- validate as __exports
3
+ discriminator as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var codegen = {};
1
+ var validate = {};
2
2
  export {
3
- codegen as __exports
3
+ validate as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var compile = {};
1
+ var core = {};
2
2
  export {
3
- compile as __exports
3
+ core as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var core = {};
1
+ var validation = {};
2
2
  export {
3
- core as __exports
3
+ validation as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var validation = {};
1
+ var applicator = {};
2
2
  export {
3
- validation as __exports
3
+ applicator as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var applicator = {};
1
+ var format = {};
2
2
  export {
3
- applicator as __exports
3
+ format as __exports
4
4
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index5.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index3.cjs");
4
4
  const code = require("./code.cjs");
5
5
  const scope = require("./scope.cjs");
6
6
  var hasRequiredCodegen;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../.bundled/jsonforms/cjs/_virtual/index6.cjs");
3
+ const index = require("../../../../../../.bundled/jsonforms/cjs/_virtual/index10.cjs");
4
4
  const index$1 = require("./codegen/index.cjs");
5
5
  const validation_error = require("../runtime/validation_error.cjs");
6
6
  const names = require("./names.cjs");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index4.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index5.cjs");
4
4
  const boolSchema = require("./boolSchema.cjs");
5
5
  const dataType = require("./dataType.cjs");
6
6
  const applicability = require("./applicability.cjs");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index9.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index8.cjs");
4
4
  const additionalItems = require("./additionalItems.cjs");
5
5
  const prefixItems = require("./prefixItems.cjs");
6
6
  const items = require("./items.cjs");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index7.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index6.cjs");
4
4
  const id = require("./id.cjs");
5
5
  const ref = require("./ref.cjs");
6
6
  var hasRequiredCore;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index3.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index4.cjs");
4
4
  const index$1 = require("../../compile/codegen/index.cjs");
5
5
  const types = require("./types.cjs");
6
6
  const index$2 = require("../../compile/index.cjs");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index10.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index9.cjs");
4
4
  const format = require("./format.cjs");
5
5
  var hasRequiredFormat;
6
6
  function requireFormat() {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index8.cjs");
3
+ const index = require("../../../../../../../.bundled/jsonforms/cjs/_virtual/index7.cjs");
4
4
  const limitNumber = require("./limitNumber.cjs");
5
5
  const multipleOf = require("./multipleOf.cjs");
6
6
  const limitLength = require("./limitLength.cjs");
@@ -1,4 +1,4 @@
1
- import { __exports as codegen } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index5.mjs";
1
+ import { __exports as codegen } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index3.mjs";
2
2
  import { __require as requireCode } from "./code.mjs";
3
3
  import { __require as requireScope } from "./scope.mjs";
4
4
  var hasRequiredCodegen;
@@ -1,4 +1,4 @@
1
- import { __exports as compile } from "../../../../../../.bundled/jsonforms/esm/_virtual/index6.mjs";
1
+ import { __exports as compile } from "../../../../../../.bundled/jsonforms/esm/_virtual/index10.mjs";
2
2
  import { __require as requireCodegen } from "./codegen/index.mjs";
3
3
  import { __require as requireValidation_error } from "../runtime/validation_error.mjs";
4
4
  import { __require as requireNames } from "./names.mjs";
@@ -1,4 +1,4 @@
1
- import { __exports as validate } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index4.mjs";
1
+ import { __exports as validate } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index5.mjs";
2
2
  import { __require as requireBoolSchema } from "./boolSchema.mjs";
3
3
  import { __require as requireDataType } from "./dataType.mjs";
4
4
  import { __require as requireApplicability } from "./applicability.mjs";
@@ -1,4 +1,4 @@
1
- import { __exports as applicator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index9.mjs";
1
+ import { __exports as applicator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index8.mjs";
2
2
  import { __require as requireAdditionalItems } from "./additionalItems.mjs";
3
3
  import { __require as requirePrefixItems } from "./prefixItems.mjs";
4
4
  import { __require as requireItems } from "./items.mjs";
@@ -1,4 +1,4 @@
1
- import { __exports as core } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index7.mjs";
1
+ import { __exports as core } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index6.mjs";
2
2
  import { __require as requireId } from "./id.mjs";
3
3
  import { __require as requireRef } from "./ref.mjs";
4
4
  var hasRequiredCore;
@@ -1,4 +1,4 @@
1
- import { __exports as discriminator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index3.mjs";
1
+ import { __exports as discriminator } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index4.mjs";
2
2
  import { __require as requireCodegen } from "../../compile/codegen/index.mjs";
3
3
  import { __require as requireTypes } from "./types.mjs";
4
4
  import { __require as requireCompile } from "../../compile/index.mjs";
@@ -1,4 +1,4 @@
1
- import { __exports as format } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index10.mjs";
1
+ import { __exports as format } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index9.mjs";
2
2
  import { __require as requireFormat$1 } from "./format.mjs";
3
3
  var hasRequiredFormat;
4
4
  function requireFormat() {
@@ -1,4 +1,4 @@
1
- import { __exports as validation } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index8.mjs";
1
+ import { __exports as validation } from "../../../../../../../.bundled/jsonforms/esm/_virtual/index7.mjs";
2
2
  import { __require as requireLimitNumber } from "./limitNumber.mjs";
3
3
  import { __require as requireMultipleOf } from "./multipleOf.mjs";
4
4
  import { __require as requireLimitLength } from "./limitLength.mjs";
@@ -5,6 +5,7 @@ const constants = require("fastapi-rtk/constants");
5
5
  const utils = require("fastapi-rtk/utils");
6
6
  const core = require("@mantine/core");
7
7
  const hooks = require("@mantine/hooks");
8
+ const lodash = require("../../_virtual/lodash.cjs");
8
9
  const React = require("react");
9
10
  const convertToFormInputs = require("../../fab-react-toolkit-patch/utils/convertToFormInputs.cjs");
10
11
  const useApi = require("../../hooks/api/useApi.cjs");
@@ -23,11 +24,31 @@ function EditDialog({ jsonForms: __jsonForms, ...props }) {
23
24
  () => utils.deepMerge({ __: { setNull: true } }, _jsonForms, __jsonForms),
24
25
  [_jsonForms, __jsonForms]
25
26
  );
27
+ const { fab } = useInfo.useInfo();
28
+ const initialState = React.useMemo(
29
+ () => ({
30
+ ...constants.initialState,
31
+ data: fab ? convertToFormInputs.convertToFormInputs((item == null ? void 0 : item.result) || {}, info.edit_columns) : convertToFormInputs$1.convertToFormInputs((item == null ? void 0 : item.result) || {}, info.edit_schema)
32
+ }),
33
+ [fab, info.edit_columns, info.edit_schema, item == null ? void 0 : item.result]
34
+ );
35
+ const initialStateRef = React.useRef(initialState);
36
+ React.useEffect(() => {
37
+ setState({ data: initialState.data });
38
+ initialStateRef.current = initialState;
39
+ }, [initialState, setState]);
26
40
  const onSubmit = React.useCallback(
27
41
  (e) => {
28
42
  e == null ? void 0 : e.preventDefault();
29
43
  setLoading(true);
30
- updateEntry(utils.getItemId(getItem()), getState().data).then((res) => {
44
+ const new_data = Object.entries(getState().data).reduce((acc, [key, value]) => {
45
+ if (lodash.lodashExports.isEqual(value, initialStateRef.current.data[key])) {
46
+ return acc;
47
+ }
48
+ acc[key] = value;
49
+ return acc;
50
+ }, {});
51
+ updateEntry(utils.getItemId(getItem()), new_data).then((res) => {
31
52
  if (res) {
32
53
  refetch();
33
54
  refetchInfo();
@@ -40,17 +61,6 @@ function EditDialog({ jsonForms: __jsonForms, ...props }) {
40
61
  },
41
62
  [setLoading, updateEntry, getItem, getState, refetch, refetchInfo, setOpened]
42
63
  );
43
- const { fab } = useInfo.useInfo();
44
- const initialState = React.useMemo(
45
- () => ({
46
- ...constants.initialState,
47
- data: fab ? convertToFormInputs.convertToFormInputs((item == null ? void 0 : item.result) || {}, info.edit_columns) : convertToFormInputs$1.convertToFormInputs((item == null ? void 0 : item.result) || {}, info.edit_schema)
48
- }),
49
- [fab, info.edit_columns, info.edit_schema, item == null ? void 0 : item.result]
50
- );
51
- React.useEffect(() => {
52
- setState({ data: initialState.data });
53
- }, [initialState, setState]);
54
64
  return /* @__PURE__ */ jsxRuntime.jsx(
55
65
  CommonModal.CommonModal,
56
66
  {
@@ -28,7 +28,7 @@ const useToolbarAlertBanner = require("./hooks/useToolbarAlertBanner/useToolbarA
28
28
  const baseProps = { enableStickyHeader: true, enableColumnPinning: true };
29
29
  const NextGenDataGrid = React.forwardRef((props, ref) => {
30
30
  var _a, _b, _c;
31
- const { info, data, queryParams, refetch, specialKey } = useApi.useApi();
31
+ const { info, data, queryParams, setQueryParams, refetch, specialKey } = useApi.useApi();
32
32
  const propsFromMantineTheme = core.useProps("NextGenDataGrid", {}, {});
33
33
  const {
34
34
  children,
@@ -55,6 +55,7 @@ const NextGenDataGrid = React.forwardRef((props, ref) => {
55
55
  enableAdvancedFilters,
56
56
  wrapperProps,
57
57
  memo,
58
+ queryOnlyVisibleColumns,
58
59
  // Deprecated props
59
60
  bodySeparator,
60
61
  bodyTruncate,
@@ -192,6 +193,18 @@ const NextGenDataGrid = React.forwardRef((props, ref) => {
192
193
  onSelectCheckbox == null ? void 0 : onSelectCheckbox(Object.keys(mrtTable.getState().rowSelection));
193
194
  bulkActions == null ? void 0 : bulkActions.setSelectedIds(Object.keys(mrtTable.getState().rowSelection));
194
195
  }, [bulkActions, data == null ? void 0 : data.ids, mrtTable.getState().rowSelection, onSelectCheckbox]);
196
+ React.useEffect(() => {
197
+ if (!queryOnlyVisibleColumns || !(data == null ? void 0 : data.list_columns)) {
198
+ return;
199
+ }
200
+ const columnVisibility = mrtTable.getState().columnVisibility;
201
+ const visibleColumns = mrtTable.getAllColumns().filter((col) => columnVisibility[col.id] !== false).filter((col) => data.list_columns.includes(col.id));
202
+ if (data.list_columns.length === visibleColumns.length) {
203
+ setQueryParams({ columns: [] });
204
+ return;
205
+ }
206
+ setQueryParams({ columns: visibleColumns.map((col) => col.id) });
207
+ }, [mrtTable.getState().columnVisibility, setQueryParams]);
195
208
  const { setView: setViewAdd } = useForms.useForms("add");
196
209
  const { setView: setViewEdit } = useForms.useForms("edit");
197
210
  React.useEffect(() => {
@@ -13,7 +13,8 @@ const Cell = ({ body, col, textFilterSeparator, mrtProps }) => {
13
13
  const auth = useAuth.useAuth();
14
14
  const { specialKey } = useApi.useApi();
15
15
  const colProps = utils.mergeProps(body, specialKey.all, col);
16
- const { component, separator, truncate, tooltipProps, highlightProps } = colProps;
16
+ const { component, separator, truncate, highlight: _highlight, tooltipProps, highlightProps } = colProps;
17
+ let functionProps = { api, auth, data: cell.row.original, colProps, mrtProps };
17
18
  const highlights = React.useMemo(() => {
18
19
  const globalFilter = table.getState().globalFilter;
19
20
  const columnTextFilter = column.getFilterValue();
@@ -24,8 +25,12 @@ const Cell = ({ body, col, textFilterSeparator, mrtProps }) => {
24
25
  if (columnTextFilter && typeof columnTextFilter === "string") {
25
26
  highlights2.push(...columnTextFilter.split(textFilterSeparator).map((f) => f.trim()));
26
27
  }
28
+ if (_highlight) {
29
+ const extraHighlight = utils.parseFromValuesOrFunc(_highlight, functionProps);
30
+ highlights2.push(...Array.isArray(extraHighlight) ? extraHighlight : [extraHighlight]);
31
+ }
27
32
  return highlights2;
28
- }, [column.getFilterValue(), table.getState().globalFilter, textFilterSeparator]);
33
+ }, [column.getFilterValue(), table.getState().globalFilter, textFilterSeparator, _highlight]);
29
34
  const cellObj = React.useMemo(() => {
30
35
  const result = { value: cell.getValue(), truncate: {}, highlight: [] };
31
36
  if (typeof result.value === "number") {
@@ -53,16 +58,7 @@ const Cell = ({ body, col, textFilterSeparator, mrtProps }) => {
53
58
  return result;
54
59
  }, [cell.getValue(), separator, truncate]);
55
60
  const highlight = React.useMemo(() => [...highlights, ...cellObj.highlight], [highlights, cellObj.highlight]);
56
- const functionProps = {
57
- api,
58
- auth,
59
- data: cell.row.original,
60
- highlight,
61
- cell: cellObj,
62
- colProps,
63
- componentProps: { value: cellObj.value },
64
- mrtProps
65
- };
61
+ functionProps = { ...functionProps, highlight, cell: cellObj, componentProps: { value: cellObj.value } };
66
62
  return /* @__PURE__ */ jsxRuntime.jsx(
67
63
  FallbackWrapper.FallbackWrapper,
68
64
  {
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
3
4
  function getDefaultExportFromCjs(x) {
4
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
5
6
  }
7
+ exports.commonjsGlobal = commonjsGlobal;
6
8
  exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const lodash = require("../../../.external/cjs/lodash@4.17.21/lodash/lodash.cjs");
4
+ var lodashExports = lodash.__require();
5
+ exports.lodashExports = lodashExports;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var lodash = { exports: {} };
4
+ exports.__module = lodash;
@@ -3,7 +3,8 @@ import { DEBOUNCE_LOADING_DELAY, initialState, VIEW_MODE } from "fastapi-rtk/con
3
3
  import { deepMerge, getItemId } from "fastapi-rtk/utils";
4
4
  import { useProps } from "@mantine/core";
5
5
  import { useDebouncedState } from "@mantine/hooks";
6
- import { useMemo, useCallback, useEffect } from "react";
6
+ import { l as lodashExports } from "../../_virtual/lodash.mjs";
7
+ import { useMemo, useRef, useEffect, useCallback } from "react";
7
8
  import { convertToFormInputs } from "../../fab-react-toolkit-patch/utils/convertToFormInputs.mjs";
8
9
  import { useApi } from "../../hooks/api/useApi.mjs";
9
10
  import { useForms } from "../../hooks/api/useForms.mjs";
@@ -21,11 +22,31 @@ function EditDialog({ jsonForms: __jsonForms, ...props }) {
21
22
  () => deepMerge({ __: { setNull: true } }, _jsonForms, __jsonForms),
22
23
  [_jsonForms, __jsonForms]
23
24
  );
25
+ const { fab } = useInfo();
26
+ const initialState$1 = useMemo(
27
+ () => ({
28
+ ...initialState,
29
+ data: fab ? convertToFormInputs((item == null ? void 0 : item.result) || {}, info.edit_columns) : convertToFormInputs$1((item == null ? void 0 : item.result) || {}, info.edit_schema)
30
+ }),
31
+ [fab, info.edit_columns, info.edit_schema, item == null ? void 0 : item.result]
32
+ );
33
+ const initialStateRef = useRef(initialState$1);
34
+ useEffect(() => {
35
+ setState({ data: initialState$1.data });
36
+ initialStateRef.current = initialState$1;
37
+ }, [initialState$1, setState]);
24
38
  const onSubmit = useCallback(
25
39
  (e) => {
26
40
  e == null ? void 0 : e.preventDefault();
27
41
  setLoading(true);
28
- updateEntry(getItemId(getItem()), getState().data).then((res) => {
42
+ const new_data = Object.entries(getState().data).reduce((acc, [key, value]) => {
43
+ if (lodashExports.isEqual(value, initialStateRef.current.data[key])) {
44
+ return acc;
45
+ }
46
+ acc[key] = value;
47
+ return acc;
48
+ }, {});
49
+ updateEntry(getItemId(getItem()), new_data).then((res) => {
29
50
  if (res) {
30
51
  refetch();
31
52
  refetchInfo();
@@ -38,17 +59,6 @@ function EditDialog({ jsonForms: __jsonForms, ...props }) {
38
59
  },
39
60
  [setLoading, updateEntry, getItem, getState, refetch, refetchInfo, setOpened]
40
61
  );
41
- const { fab } = useInfo();
42
- const initialState$1 = useMemo(
43
- () => ({
44
- ...initialState,
45
- data: fab ? convertToFormInputs((item == null ? void 0 : item.result) || {}, info.edit_columns) : convertToFormInputs$1((item == null ? void 0 : item.result) || {}, info.edit_schema)
46
- }),
47
- [fab, info.edit_columns, info.edit_schema, item == null ? void 0 : item.result]
48
- );
49
- useEffect(() => {
50
- setState({ data: initialState$1.data });
51
- }, [initialState$1, setState]);
52
62
  return /* @__PURE__ */ jsx(
53
63
  CommonModal,
54
64
  {
@@ -26,7 +26,7 @@ import { useToolbarAlertBanner } from "./hooks/useToolbarAlertBanner/useToolbarA
26
26
  const baseProps = { enableStickyHeader: true, enableColumnPinning: true };
27
27
  const NextGenDataGrid = forwardRef((props, ref) => {
28
28
  var _a, _b, _c;
29
- const { info, data, queryParams, refetch, specialKey } = useApi();
29
+ const { info, data, queryParams, setQueryParams, refetch, specialKey } = useApi();
30
30
  const propsFromMantineTheme = useProps("NextGenDataGrid", {}, {});
31
31
  const {
32
32
  children,
@@ -53,6 +53,7 @@ const NextGenDataGrid = forwardRef((props, ref) => {
53
53
  enableAdvancedFilters,
54
54
  wrapperProps,
55
55
  memo,
56
+ queryOnlyVisibleColumns,
56
57
  // Deprecated props
57
58
  bodySeparator,
58
59
  bodyTruncate,
@@ -190,6 +191,18 @@ const NextGenDataGrid = forwardRef((props, ref) => {
190
191
  onSelectCheckbox == null ? void 0 : onSelectCheckbox(Object.keys(mrtTable.getState().rowSelection));
191
192
  bulkActions == null ? void 0 : bulkActions.setSelectedIds(Object.keys(mrtTable.getState().rowSelection));
192
193
  }, [bulkActions, data == null ? void 0 : data.ids, mrtTable.getState().rowSelection, onSelectCheckbox]);
194
+ useEffect(() => {
195
+ if (!queryOnlyVisibleColumns || !(data == null ? void 0 : data.list_columns)) {
196
+ return;
197
+ }
198
+ const columnVisibility = mrtTable.getState().columnVisibility;
199
+ const visibleColumns = mrtTable.getAllColumns().filter((col) => columnVisibility[col.id] !== false).filter((col) => data.list_columns.includes(col.id));
200
+ if (data.list_columns.length === visibleColumns.length) {
201
+ setQueryParams({ columns: [] });
202
+ return;
203
+ }
204
+ setQueryParams({ columns: visibleColumns.map((col) => col.id) });
205
+ }, [mrtTable.getState().columnVisibility, setQueryParams]);
193
206
  const { setView: setViewAdd } = useForms("add");
194
207
  const { setView: setViewEdit } = useForms("edit");
195
208
  useEffect(() => {
@@ -11,7 +11,8 @@ const Cell = ({ body, col, textFilterSeparator, mrtProps }) => {
11
11
  const auth = useAuth();
12
12
  const { specialKey } = useApi();
13
13
  const colProps = mergeProps(body, specialKey.all, col);
14
- const { component, separator, truncate, tooltipProps, highlightProps } = colProps;
14
+ const { component, separator, truncate, highlight: _highlight, tooltipProps, highlightProps } = colProps;
15
+ let functionProps = { api, auth, data: cell.row.original, colProps, mrtProps };
15
16
  const highlights = useMemo(() => {
16
17
  const globalFilter = table.getState().globalFilter;
17
18
  const columnTextFilter = column.getFilterValue();
@@ -22,8 +23,12 @@ const Cell = ({ body, col, textFilterSeparator, mrtProps }) => {
22
23
  if (columnTextFilter && typeof columnTextFilter === "string") {
23
24
  highlights2.push(...columnTextFilter.split(textFilterSeparator).map((f) => f.trim()));
24
25
  }
26
+ if (_highlight) {
27
+ const extraHighlight = parseFromValuesOrFunc(_highlight, functionProps);
28
+ highlights2.push(...Array.isArray(extraHighlight) ? extraHighlight : [extraHighlight]);
29
+ }
25
30
  return highlights2;
26
- }, [column.getFilterValue(), table.getState().globalFilter, textFilterSeparator]);
31
+ }, [column.getFilterValue(), table.getState().globalFilter, textFilterSeparator, _highlight]);
27
32
  const cellObj = useMemo(() => {
28
33
  const result = { value: cell.getValue(), truncate: {}, highlight: [] };
29
34
  if (typeof result.value === "number") {
@@ -51,16 +56,7 @@ const Cell = ({ body, col, textFilterSeparator, mrtProps }) => {
51
56
  return result;
52
57
  }, [cell.getValue(), separator, truncate]);
53
58
  const highlight = useMemo(() => [...highlights, ...cellObj.highlight], [highlights, cellObj.highlight]);
54
- const functionProps = {
55
- api,
56
- auth,
57
- data: cell.row.original,
58
- highlight,
59
- cell: cellObj,
60
- colProps,
61
- componentProps: { value: cellObj.value },
62
- mrtProps
63
- };
59
+ functionProps = { ...functionProps, highlight, cell: cellObj, componentProps: { value: cellObj.value } };
64
60
  return /* @__PURE__ */ jsx(
65
61
  FallbackWrapper,
66
62
  {
@@ -1,6 +1,8 @@
1
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1
2
  function getDefaultExportFromCjs(x) {
2
3
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
3
4
  }
4
5
  export {
6
+ commonjsGlobal,
5
7
  getDefaultExportFromCjs
6
8
  };
@@ -0,0 +1,5 @@
1
+ import { __require as requireLodash } from "../../../.external/esm/lodash@4.17.21/lodash/lodash.mjs";
2
+ var lodashExports = requireLodash();
3
+ export {
4
+ lodashExports as l
5
+ };
@@ -0,0 +1,4 @@
1
+ var lodash = { exports: {} };
2
+ export {
3
+ lodash as __module
4
+ };
@@ -32,6 +32,82 @@ export type NextGenDataGridFilterSyncProps = {
32
32
  */
33
33
  delay?: number;
34
34
  };
35
+ export type NextGenDataGridBodyCellHighlightProps = {
36
+ /**
37
+ * - API instance
38
+ */
39
+ api: Record<string, any>;
40
+ /**
41
+ * - Auth instance
42
+ */
43
+ auth: Record<string, any>;
44
+ /**
45
+ * - Row data
46
+ */
47
+ data: Record<string, any>;
48
+ /**
49
+ * - Column properties
50
+ */
51
+ colProps: Record<string, any>;
52
+ /**
53
+ * - MantineReactTable props
54
+ */
55
+ mrtProps: Record<string, any>;
56
+ };
57
+ export type NextGenDataGridBodyCellCellProps = {
58
+ /**
59
+ * - The value of the cell, either `string` or `string[]`
60
+ */
61
+ value: string | string[];
62
+ /**
63
+ * - The truncate object containing the original and truncated value
64
+ */
65
+ truncate: Record<string, any>;
66
+ /**
67
+ * - The highlight keywords to highlight in the cell value
68
+ */
69
+ highlight: string[];
70
+ };
71
+ export type NextGenDataGridBodyCellComponentProps = {
72
+ /**
73
+ * - The value of the cell, either `string` or `string[]`
74
+ */
75
+ value: string | string[];
76
+ };
77
+ export type NextGenDataGridBodyCellProps = {
78
+ /**
79
+ * - API instance
80
+ */
81
+ api: Record<string, any>;
82
+ /**
83
+ * - Auth instance
84
+ */
85
+ auth: Record<string, any>;
86
+ /**
87
+ * - Row data
88
+ */
89
+ data: Record<string, any>;
90
+ /**
91
+ * - Column properties
92
+ */
93
+ colProps: Record<string, any>;
94
+ /**
95
+ * - MantineReactTable props
96
+ */
97
+ mrtProps: Record<string, any>;
98
+ /**
99
+ * - Array of highlight keywords
100
+ */
101
+ highlights: string[];
102
+ /**
103
+ * - The cell object containing the value, truncate and highlight
104
+ */
105
+ cell: NextGenDataGridBodyCellCellProps;
106
+ /**
107
+ * - Props for the cell component
108
+ */
109
+ componentProps: NextGenDataGridBodyCellComponentProps;
110
+ };
35
111
  export type NextGenDataGridHeaderProps = {
36
112
  /**
37
113
  * - Customize the header that is shown above the filter
@@ -88,7 +164,7 @@ export type NextGenDataGridBodyProps = {
88
164
  /**
89
165
  * - Customize the component within the body
90
166
  */
91
- component?: JSX.Element | (({ api, auth, mrtProps }: any) => JSX.Element);
167
+ component?: JSX.Element | ((props: NextGenDataGridBodyCellProps) => JSX.Element);
92
168
  /**
93
169
  * - Separate the value of a column into multiple rows
94
170
  */
@@ -97,14 +173,18 @@ export type NextGenDataGridBodyProps = {
97
173
  * - Truncate the value of a column to a certain length. Will be shown as `...` when it exceeds the length with a tooltip containing the full value
98
174
  */
99
175
  truncate?: number;
176
+ /**
177
+ * - Additional highlight keywords to highlight in the cell value. Can be a string, an array of strings, or a function that returns a string or an array of strings
178
+ */
179
+ highlight?: string | string[] | ((props: NextGenDataGridBodyCellHighlightProps) => string | string[]);
100
180
  /**
101
181
  * - Props for the tooltip component that is shown when the value is truncated. The `value` is the value of the cell, either `string` or `string[]`, `data` is the row data, and `cellObj` is the cell object containing the value, truncate and highlight
102
182
  */
103
- tooltipProps?: Record<string, any> | (({ value, data, cellObj }: any) => Record<string, any>);
183
+ tooltipProps?: Record<string, any> | ((props: NextGenDataGridBodyCellProps & NextGenDataGridBodyCellComponentProps) => Record<string, any>);
104
184
  /**
105
185
  * - Props for the highlight component. The `value` is the value of the cell, either `string` or `string[]`, `data` is the row data, and `cellObj` is the cell object containing the value, truncate and highlight
106
186
  */
107
- highlightProps?: Record<string, any> | (({ value, data, cellObj }: any) => Record<string, any>);
187
+ highlightProps?: Record<string, any> | ((props: NextGenDataGridBodyCellProps & NextGenDataGridBodyCellComponentProps) => Record<string, any>);
108
188
  };
109
189
  export type NextGenDataGridProps = {
110
190
  /**
@@ -201,9 +281,13 @@ export type NextGenDataGridProps = {
201
281
  wrapperProps?: Record<string, any>;
202
282
  /**
203
283
  * - Whether to memoize the filters and body cells. If `true`, both filters and body cells will be memoized. If `'filters'`, only filters will be memoized. If `'cells'`, only body cells will be memoized. Defaults to `false` (no memoization)
204
- * Deprecated props
205
284
  */
206
285
  memo?: boolean | "filters" | "cells";
286
+ /**
287
+ * - Whether to only query the visible columns from the backend. When enabled, it modifies the `columns` from the `queryParams` to only include the visible columns. Defaults to `false`
288
+ * Deprecated props
289
+ */
290
+ queryOnlyVisibleColumns?: boolean;
207
291
  /**
208
292
  * - Body separator for the table
209
293
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastapi-rtk",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "private": false,
5
5
  "description": "A React component library for FastAPI in combination with FastAPI React Toolkit backend, built with Mantine, JsonForms, and Zustand.",
6
6
  "license": "MIT",