@compill/admin 1.0.42 → 1.0.44

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.
package/index.cjs.js CHANGED
@@ -836,11 +836,12 @@ function PageQueryStateContainerInner(_a) {
836
836
  children
837
837
  } = _a,
838
838
  props = __rest$1(_a, ["queryId", "api", "apiFn", "loadingStyles", "errorStyles", "children"]);
839
+ // @ts-ignore
839
840
  const {
840
841
  data,
841
842
  isLoading,
842
843
  isError
843
- } = apiFn == "get" ? api.useApiQuery(api$1.queryKey, api$1.get, queryId) : api.useApiQuery(api$1.queryKey, api$1.getAll);
844
+ } = apiFn == "getAll" ? api.useApiQuery(api$1.queryKey, api$1.getAll, props.apiParams) : api.useApiQuery(api$1.queryKey, api$1.get, queryId);
844
845
  const invalidate = api.useInvalidateQuery(api$1.queryKey, queryId);
845
846
  if (isLoading) return jsxRuntime.jsx(components.QueryLoadingState, Object.assign({
846
847
  w: "full",
@@ -1132,8 +1133,14 @@ function Internal({
1132
1133
  });
1133
1134
  const save = api.useMutate(mutation, {
1134
1135
  processInput,
1135
- successMsg: (item, values) => `${item.title} updated.`,
1136
- errorMsg: (error, item) => `Error updating ${item.title}: ${error}`
1136
+ successMsg: (item, values) => {
1137
+ var _a;
1138
+ return `${(_a = item.title) !== null && _a !== void 0 ? _a : item.name} updated.`;
1139
+ },
1140
+ errorMsg: (error, item) => {
1141
+ var _a;
1142
+ return `Error updating ${(_a = item.title) !== null && _a !== void 0 ? _a : item.name}: ${error}`;
1143
+ }
1137
1144
  });
1138
1145
  let editorMaxW = undefined;
1139
1146
  if (!type || type == "post") editorMaxW = "calc(1280px - 28rem)";else if (type == "section") editorMaxW = "calc(1280px - 22rem)";
@@ -1497,7 +1504,7 @@ function nonNullValues$1(data) {
1497
1504
  return data;
1498
1505
  }
1499
1506
  function ItemEditDialog$1(_a) {
1500
- var _b, _c, _d;
1507
+ var _b, _c, _d, _e;
1501
1508
  var {
1502
1509
  initialValues,
1503
1510
  itemLabel,
@@ -1574,7 +1581,7 @@ function ItemEditDialog$1(_a) {
1574
1581
  transition: true
1575
1582
  }, props, {
1576
1583
  children: [jsxRuntime.jsxs(ui.Modal.Header, {
1577
- children: [!isInitialLoading && queryId && `Edit ${title ? title(data) : (_c = (_b = data === null || data === void 0 ? void 0 : data["name"]) !== null && _b !== void 0 ? _b : data === null || data === void 0 ? void 0 : data["title"]) !== null && _c !== void 0 ? _c : ""}`, !queryId && `Create new ${itemLabel !== null && itemLabel !== void 0 ? itemLabel : "item"}`, Array.isArray(form$1) && jsxRuntime.jsx(jsxRuntime.Fragment, {})
1584
+ children: [!isInitialLoading && queryId && `Edit ${title ? title(data) : (_d = (_c = (_b = data === null || data === void 0 ? void 0 : data["name"]) !== null && _b !== void 0 ? _b : data === null || data === void 0 ? void 0 : data["title"]) !== null && _c !== void 0 ? _c : data === null || data === void 0 ? void 0 : data["name"]) !== null && _d !== void 0 ? _d : ""}`, !queryId && `Create new ${itemLabel !== null && itemLabel !== void 0 ? itemLabel : "item"}`, Array.isArray(form$1) && jsxRuntime.jsx(jsxRuntime.Fragment, {})
1578
1585
  // <ul className="nav nav-bold nav-pills">
1579
1586
  // {form.map(item =>
1580
1587
  // <li key={item.key} className="nav-item cursor-pointer bg-hover-light rounded" onClick={() => switchTab(item.key)}>
@@ -1597,7 +1604,7 @@ function ItemEditDialog$1(_a) {
1597
1604
  // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
1598
1605
  , Object.assign({
1599
1606
  // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
1600
- initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues$1(data)) : (_d = nonNullValues$1(initialValues(data))) !== null && _d !== void 0 ? _d : {},
1607
+ initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues$1(data)) : (_e = nonNullValues$1(initialValues(data))) !== null && _e !== void 0 ? _e : {},
1601
1608
  onSubmit: saveItem
1602
1609
  }, formikProps, {
1603
1610
  children: ({
package/index.esm.js CHANGED
@@ -827,11 +827,12 @@ function PageQueryStateContainerInner(_a) {
827
827
  children
828
828
  } = _a,
829
829
  props = __rest$1(_a, ["queryId", "api", "apiFn", "loadingStyles", "errorStyles", "children"]);
830
+ // @ts-ignore
830
831
  const {
831
832
  data,
832
833
  isLoading,
833
834
  isError
834
- } = apiFn == "get" ? useApiQuery(api.queryKey, api.get, queryId) : useApiQuery(api.queryKey, api.getAll);
835
+ } = apiFn == "getAll" ? useApiQuery(api.queryKey, api.getAll, props.apiParams) : useApiQuery(api.queryKey, api.get, queryId);
835
836
  const invalidate = useInvalidateQuery(api.queryKey, queryId);
836
837
  if (isLoading) return jsx(QueryLoadingState, Object.assign({
837
838
  w: "full",
@@ -1123,8 +1124,14 @@ function Internal({
1123
1124
  });
1124
1125
  const save = useMutate(mutation, {
1125
1126
  processInput,
1126
- successMsg: (item, values) => `${item.title} updated.`,
1127
- errorMsg: (error, item) => `Error updating ${item.title}: ${error}`
1127
+ successMsg: (item, values) => {
1128
+ var _a;
1129
+ return `${(_a = item.title) !== null && _a !== void 0 ? _a : item.name} updated.`;
1130
+ },
1131
+ errorMsg: (error, item) => {
1132
+ var _a;
1133
+ return `Error updating ${(_a = item.title) !== null && _a !== void 0 ? _a : item.name}: ${error}`;
1134
+ }
1128
1135
  });
1129
1136
  let editorMaxW = undefined;
1130
1137
  if (!type || type == "post") editorMaxW = "calc(1280px - 28rem)";else if (type == "section") editorMaxW = "calc(1280px - 22rem)";
@@ -1488,7 +1495,7 @@ function nonNullValues$1(data) {
1488
1495
  return data;
1489
1496
  }
1490
1497
  function ItemEditDialog$1(_a) {
1491
- var _b, _c, _d;
1498
+ var _b, _c, _d, _e;
1492
1499
  var {
1493
1500
  initialValues,
1494
1501
  itemLabel,
@@ -1565,7 +1572,7 @@ function ItemEditDialog$1(_a) {
1565
1572
  transition: true
1566
1573
  }, props, {
1567
1574
  children: [jsxs(Modal.Header, {
1568
- children: [!isInitialLoading && queryId && `Edit ${title ? title(data) : (_c = (_b = data === null || data === void 0 ? void 0 : data["name"]) !== null && _b !== void 0 ? _b : data === null || data === void 0 ? void 0 : data["title"]) !== null && _c !== void 0 ? _c : ""}`, !queryId && `Create new ${itemLabel !== null && itemLabel !== void 0 ? itemLabel : "item"}`, Array.isArray(form) && jsx(Fragment, {})
1575
+ children: [!isInitialLoading && queryId && `Edit ${title ? title(data) : (_d = (_c = (_b = data === null || data === void 0 ? void 0 : data["name"]) !== null && _b !== void 0 ? _b : data === null || data === void 0 ? void 0 : data["title"]) !== null && _c !== void 0 ? _c : data === null || data === void 0 ? void 0 : data["name"]) !== null && _d !== void 0 ? _d : ""}`, !queryId && `Create new ${itemLabel !== null && itemLabel !== void 0 ? itemLabel : "item"}`, Array.isArray(form) && jsx(Fragment, {})
1569
1576
  // <ul className="nav nav-bold nav-pills">
1570
1577
  // {form.map(item =>
1571
1578
  // <li key={item.key} className="nav-item cursor-pointer bg-hover-light rounded" onClick={() => switchTab(item.key)}>
@@ -1588,7 +1595,7 @@ function ItemEditDialog$1(_a) {
1588
1595
  // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
1589
1596
  , Object.assign({
1590
1597
  // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
1591
- initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues$1(data)) : (_d = nonNullValues$1(initialValues(data))) !== null && _d !== void 0 ? _d : {},
1598
+ initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues$1(data)) : (_e = nonNullValues$1(initialValues(data))) !== null && _e !== void 0 ? _e : {},
1592
1599
  onSubmit: saveItem
1593
1600
  }, formikProps, {
1594
1601
  children: ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "module": "./index.esm.js",
5
5
  "main": "./index.cjs.js"
6
6
  }
@@ -12,6 +12,7 @@ type PageQueryContainerProps<T extends CRUD_MODEL> = Omit<ContainerProps, "child
12
12
  children: (data: T) => React.ReactElement;
13
13
  } | {
14
14
  apiFn: "getAll";
15
+ apiParams?: any;
15
16
  children: (data: T[]) => React.ReactElement;
16
17
  }));
17
18
  export declare const PageQueryStateContainer: <T extends CRUD_MODEL>(p: PageQueryContainerProps<T> & {