@compill/admin 1.0.57 → 1.0.58

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
@@ -1940,8 +1940,8 @@ function TableMassActions({
1940
1940
  });
1941
1941
  }
1942
1942
 
1943
- const defaultErrorMsg$2 = "Oops, something went wrong...";
1944
- function nonNullValues$1(data) {
1943
+ const defaultErrorMsg$1 = "Oops, something went wrong...";
1944
+ function nonNullValues(data) {
1945
1945
  var _a;
1946
1946
  if (data) {
1947
1947
  const nonNullData = Object.assign({}, data);
@@ -1950,7 +1950,7 @@ function nonNullValues$1(data) {
1950
1950
  }
1951
1951
  return data;
1952
1952
  }
1953
- function ItemEditDialog$1(_a) {
1953
+ function ItemEditDialog(_a) {
1954
1954
  var _b, _c, _d, _e;
1955
1955
  var {
1956
1956
  initialValues,
@@ -1961,9 +1961,9 @@ function ItemEditDialog$1(_a) {
1961
1961
  querySaveOptions,
1962
1962
  onSuccess,
1963
1963
  onFetchError,
1964
- fetchErrorMsg = defaultErrorMsg$2,
1964
+ fetchErrorMsg = defaultErrorMsg$1,
1965
1965
  onSaveError,
1966
- saveErrorMsg = defaultErrorMsg$2,
1966
+ saveErrorMsg = defaultErrorMsg$1,
1967
1967
  fetchToFormData,
1968
1968
  formToQueryData,
1969
1969
  invalidateQueriesOnSuccess = true,
@@ -2051,7 +2051,7 @@ function ItemEditDialog$1(_a) {
2051
2051
  // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
2052
2052
  , Object.assign({
2053
2053
  // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
2054
- initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues$1(data)) : (_e = nonNullValues$1(initialValues(data))) !== null && _e !== void 0 ? _e : {},
2054
+ initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : (_e = nonNullValues(initialValues(data))) !== null && _e !== void 0 ? _e : {},
2055
2055
  onSubmit: saveItem
2056
2056
  }, formikProps, {
2057
2057
  children: ({
@@ -2120,7 +2120,7 @@ function QueryWrapperDialog({
2120
2120
  }, [data, fn, transformFn]);
2121
2121
  if (isFetching) return null;
2122
2122
  // @ts-ignore
2123
- return jsxRuntime.jsx(ItemEditDialog$1, Object.assign({}, config(transformedData), {
2123
+ return jsxRuntime.jsx(ItemEditDialog, Object.assign({}, config(transformedData), {
2124
2124
  queryId: queryId,
2125
2125
  invalidateQueryKey: invalidateQueryKey,
2126
2126
  show: true,
@@ -2158,7 +2158,7 @@ function MultiQueryWrapperDialog({
2158
2158
  // if (isFetching)
2159
2159
  // return null
2160
2160
  // @ts-ignore
2161
- return jsxRuntime.jsx(ItemEditDialog$1, Object.assign({
2161
+ return jsxRuntime.jsx(ItemEditDialog, Object.assign({
2162
2162
  isPreloading: isFetching
2163
2163
  }, config(...transformedData), {
2164
2164
  queryId: queryId,
@@ -2175,7 +2175,7 @@ function DialogRenderer({
2175
2175
  queryId
2176
2176
  }) {
2177
2177
  const props = __rest$1(config, ["type"]);
2178
- if (config.type === "dialog") return jsxRuntime.jsx(ItemEditDialog$1, Object.assign({}, props, {
2178
+ if (config.type === "dialog") return jsxRuntime.jsx(ItemEditDialog, Object.assign({}, props, {
2179
2179
  queryId: queryId,
2180
2180
  invalidateQueryKey: invalidateQueryKey,
2181
2181
  show: true,
@@ -3050,7 +3050,7 @@ function LeftPanel({
3050
3050
  });
3051
3051
  }
3052
3052
 
3053
- const defaultErrorMsg$1 = "Oops, something went wrong...";
3053
+ const defaultErrorMsg = "Oops, something went wrong...";
3054
3054
  function AttachDialog(_a) {
3055
3055
  var {
3056
3056
  queryId,
@@ -3066,9 +3066,9 @@ function AttachDialog(_a) {
3066
3066
  itemLabel,
3067
3067
  onSuccess,
3068
3068
  onFetchError,
3069
- fetchErrorMsg = defaultErrorMsg$1,
3069
+ fetchErrorMsg = defaultErrorMsg,
3070
3070
  onSaveError,
3071
- saveErrorMsg = defaultErrorMsg$1,
3071
+ saveErrorMsg = defaultErrorMsg,
3072
3072
  invalidateQueriesOnSuccess = true,
3073
3073
  retryText = "Retry",
3074
3074
  cancelLabel = "Cancel",
@@ -3295,158 +3295,6 @@ function FormActionDialog(_a) {
3295
3295
  }));
3296
3296
  }
3297
3297
 
3298
- const defaultErrorMsg = "Oops, something went wrong...";
3299
- function nonNullValues(data) {
3300
- var _a;
3301
- if (data) {
3302
- const nonNullData = Object.assign({}, data);
3303
- for (const key in data) nonNullData[key] = (_a = nonNullData[key]) !== null && _a !== void 0 ? _a : "";
3304
- return nonNullData;
3305
- }
3306
- return data;
3307
- }
3308
- function ItemEditDialog(_a) {
3309
- var _b, _c, _d, _e;
3310
- var {
3311
- initialValues,
3312
- itemLabel,
3313
- queryId = "",
3314
- queryKey,
3315
- queryFetchFn,
3316
- queryFetchOptions,
3317
- querySaveFn,
3318
- querySaveOptions,
3319
- onSuccess,
3320
- onFetchError,
3321
- fetchErrorMsg = defaultErrorMsg,
3322
- onSaveError,
3323
- saveErrorMsg = defaultErrorMsg,
3324
- fetchToFormData,
3325
- formToQueryData,
3326
- invalidateQueriesOnSuccess = true,
3327
- invalidateQueryKey,
3328
- retryText = "Retry",
3329
- cancelLabel = "Cancel",
3330
- saveLabel,
3331
- size = "lg",
3332
- title,
3333
- form: form$1,
3334
- show,
3335
- onClose,
3336
- formikProps
3337
- } = _a,
3338
- props = __rest$1(_a, ["initialValues", "itemLabel", "queryId", "queryKey", "queryFetchFn", "queryFetchOptions", "querySaveFn", "querySaveOptions", "onSuccess", "onFetchError", "fetchErrorMsg", "onSaveError", "saveErrorMsg", "fetchToFormData", "formToQueryData", "invalidateQueriesOnSuccess", "invalidateQueryKey", "retryText", "cancelLabel", "saveLabel", "size", "title", "form", "show", "onClose", "formikProps"]);
3339
- const {
3340
- isInitialLoading,
3341
- isFetching,
3342
- data,
3343
- isError,
3344
- error /*, error*/,
3345
- refetch
3346
- } = api.useApiQuery(queryKey, queryFetchFn, queryId, Object.assign({
3347
- enabled: !( /*queryId == 0 || */queryId == "" || queryId == null || queryId == undefined),
3348
- onError: onFetchError
3349
- }, queryFetchOptions));
3350
- // const [activeTab, setActiveTab] = React.useState(form && Array.isArray(form) ? form[0].key : "");
3351
- // const [showTab, setShowTab] = React.useState(true);
3352
- const mutation = invalidateQueriesOnSuccess ? api.useInvalidateParentMutation(querySaveFn, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : queryKey, querySaveOptions) : api.useApiMutation(querySaveFn, queryKey, queryId, querySaveOptions);
3353
- const retry = React__default["default"].useCallback(() => refetch(), [refetch]);
3354
- const saveItem = React__default["default"].useCallback((item, actions) => {
3355
- // Clear mutation error if any
3356
- mutation.reset();
3357
- const formItem = formToQueryData ? formToQueryData(item) : Object.assign({}, item);
3358
- mutation.mutateAsync(formItem).then(response => {
3359
- var _a;
3360
- if (onSuccess) onSuccess(formItem, response);else reactToastify.toast.success(`${title ? title(formItem) : (_a = formItem.name) !== null && _a !== void 0 ? _a : formItem.title} ${queryId ? "saved" : "created"}`);
3361
- // closing delete modal
3362
- onClose === null || onClose === void 0 ? void 0 : onClose();
3363
- }).catch(error => {
3364
- var _a;
3365
- console.error("on error", error);
3366
- if (onSaveError) onSaveError(item);else reactToastify.toast.error(`Couldn't save ${title ? title(formItem) : (_a = formItem.name) !== null && _a !== void 0 ? _a : formItem.title}`);
3367
- actions.setSubmitting(false);
3368
- });
3369
- }, [mutation, formToQueryData, onSuccess, onSaveError, onClose]);
3370
- // const switchTab = React.useCallback((tab: string) =>
3371
- // {
3372
- // setActiveTab(tab);
3373
- // setShowTab(false);
3374
- // setTimeout(function ()
3375
- // {
3376
- // setActiveTab(tab);
3377
- // setShowTab(true);
3378
- // }, 150);
3379
- // }, [setActiveTab])
3380
- return jsxRuntime.jsxs(ui.Modal, Object.assign({
3381
- size: size,
3382
- show: show,
3383
- onClose: onClose,
3384
- scheme: "light",
3385
- transition: true
3386
- }, props, {
3387
- children: [jsxRuntime.jsxs(ui.Modal.Header, {
3388
- 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, {})
3389
- // <ul className="nav nav-bold nav-pills">
3390
- // {form.map(item =>
3391
- // <li key={item.key} className="nav-item cursor-pointer bg-hover-light rounded" onClick={() => switchTab(item.key)}>
3392
- // <span className={clsx("nav-link", activeTab === item.key && "active")} data-toggle="tab">{item.label}</span>
3393
- // </li>
3394
- // )}
3395
- // </ul>
3396
- ]
3397
- }), isInitialLoading && jsxRuntime.jsx(ui.Modal.Body, {
3398
- children: jsxRuntime.jsx(components.QueryLoadingState, {
3399
- minW: "72"
3400
- })
3401
- }), isError && jsxRuntime.jsx(ui.Modal.Body, {
3402
- children: jsxRuntime.jsx(components.RetryOnError, {
3403
- label: `${fetchErrorMsg} ${error}`,
3404
- onClick: retry
3405
- })
3406
- }), !isInitialLoading && !isError && jsxRuntime.jsx(jsxRuntime.Fragment, {
3407
- children: jsxRuntime.jsx(formik.Formik, Object.assign({
3408
- initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : (_e = (_d = nonNullValues(data)) !== null && _d !== void 0 ? _d : initialValues) !== null && _e !== void 0 ? _e : {},
3409
- onSubmit: saveItem
3410
- }, formikProps, {
3411
- children: ({
3412
- setFieldValue,
3413
- dirty,
3414
- handleSubmit,
3415
- isValid,
3416
- values
3417
- }) => jsxRuntime.jsxs(jsxRuntime.Fragment, {
3418
- children: [jsxRuntime.jsx(ui.Modal.Body, {
3419
- pb: "6",
3420
- children: jsxRuntime.jsxs(formik.Form, {
3421
- children: [/*#__PURE__*/React__default["default"].isValidElement(form$1) && form$1, Array.isArray(form$1) && jsxRuntime.jsx(form.FormRenderer, {
3422
- form: form$1
3423
- }), react.isFunction(form$1) && jsxRuntime.jsx(form.FormRenderer, {
3424
- form: form$1(data !== null && data !== void 0 ? data : values)
3425
- })]
3426
- })
3427
- }), jsxRuntime.jsxs(ui.Modal.Footer, {
3428
- dflex: true,
3429
- placeContent: "end",
3430
- spaceX: "3",
3431
- children: [jsxRuntime.jsx(ui.Button, {
3432
- disabled: mutation.isLoading,
3433
- onClick: onClose,
3434
- variant: "borderless",
3435
- me: "2",
3436
- children: cancelLabel
3437
- }), jsxRuntime.jsx(ui.Button, {
3438
- type: "submit",
3439
- disabled: !dirty || mutation.isLoading /* || !isValid*/,
3440
- onClick: () => handleSubmit(),
3441
- children: saveLabel ? saveLabel : queryId ? "Update" : "Create"
3442
- })]
3443
- })]
3444
- })
3445
- }))
3446
- }), mutation.isLoading && jsxRuntime.jsx(components.ModalLoadingOverlay, {})]
3447
- }));
3448
- }
3449
-
3450
3298
  function PageSectionTitle(_a) {
3451
3299
  var {
3452
3300
  children
@@ -3696,6 +3544,7 @@ exports.ButtonBarDialogButton = ButtonBarDialogButton;
3696
3544
  exports.DialogButton = DialogButton;
3697
3545
  exports.FormActionDialog = FormActionDialog;
3698
3546
  exports.InvalidateButton = InvalidateButton;
3547
+ exports.ItemDeleteDialog = ItemDeleteDialog;
3699
3548
  exports.ItemEditDialog = ItemEditDialog;
3700
3549
  exports.NavigateButton = NavigateButton;
3701
3550
  exports.OrderCell = OrderCell;
package/index.esm.js CHANGED
@@ -1931,8 +1931,8 @@ function TableMassActions({
1931
1931
  });
1932
1932
  }
1933
1933
 
1934
- const defaultErrorMsg$2 = "Oops, something went wrong...";
1935
- function nonNullValues$1(data) {
1934
+ const defaultErrorMsg$1 = "Oops, something went wrong...";
1935
+ function nonNullValues(data) {
1936
1936
  var _a;
1937
1937
  if (data) {
1938
1938
  const nonNullData = Object.assign({}, data);
@@ -1941,7 +1941,7 @@ function nonNullValues$1(data) {
1941
1941
  }
1942
1942
  return data;
1943
1943
  }
1944
- function ItemEditDialog$1(_a) {
1944
+ function ItemEditDialog(_a) {
1945
1945
  var _b, _c, _d, _e;
1946
1946
  var {
1947
1947
  initialValues,
@@ -1952,9 +1952,9 @@ function ItemEditDialog$1(_a) {
1952
1952
  querySaveOptions,
1953
1953
  onSuccess,
1954
1954
  onFetchError,
1955
- fetchErrorMsg = defaultErrorMsg$2,
1955
+ fetchErrorMsg = defaultErrorMsg$1,
1956
1956
  onSaveError,
1957
- saveErrorMsg = defaultErrorMsg$2,
1957
+ saveErrorMsg = defaultErrorMsg$1,
1958
1958
  fetchToFormData,
1959
1959
  formToQueryData,
1960
1960
  invalidateQueriesOnSuccess = true,
@@ -2042,7 +2042,7 @@ function ItemEditDialog$1(_a) {
2042
2042
  // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
2043
2043
  , Object.assign({
2044
2044
  // initialValues={fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : nonNullValues(data) ?? initialValues(data) ?? {}}
2045
- initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues$1(data)) : (_e = nonNullValues$1(initialValues(data))) !== null && _e !== void 0 ? _e : {},
2045
+ initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : (_e = nonNullValues(initialValues(data))) !== null && _e !== void 0 ? _e : {},
2046
2046
  onSubmit: saveItem
2047
2047
  }, formikProps, {
2048
2048
  children: ({
@@ -2111,7 +2111,7 @@ function QueryWrapperDialog({
2111
2111
  }, [data, fn, transformFn]);
2112
2112
  if (isFetching) return null;
2113
2113
  // @ts-ignore
2114
- return jsx(ItemEditDialog$1, Object.assign({}, config(transformedData), {
2114
+ return jsx(ItemEditDialog, Object.assign({}, config(transformedData), {
2115
2115
  queryId: queryId,
2116
2116
  invalidateQueryKey: invalidateQueryKey,
2117
2117
  show: true,
@@ -2149,7 +2149,7 @@ function MultiQueryWrapperDialog({
2149
2149
  // if (isFetching)
2150
2150
  // return null
2151
2151
  // @ts-ignore
2152
- return jsx(ItemEditDialog$1, Object.assign({
2152
+ return jsx(ItemEditDialog, Object.assign({
2153
2153
  isPreloading: isFetching
2154
2154
  }, config(...transformedData), {
2155
2155
  queryId: queryId,
@@ -2166,7 +2166,7 @@ function DialogRenderer({
2166
2166
  queryId
2167
2167
  }) {
2168
2168
  const props = __rest$1(config, ["type"]);
2169
- if (config.type === "dialog") return jsx(ItemEditDialog$1, Object.assign({}, props, {
2169
+ if (config.type === "dialog") return jsx(ItemEditDialog, Object.assign({}, props, {
2170
2170
  queryId: queryId,
2171
2171
  invalidateQueryKey: invalidateQueryKey,
2172
2172
  show: true,
@@ -3041,7 +3041,7 @@ function LeftPanel({
3041
3041
  });
3042
3042
  }
3043
3043
 
3044
- const defaultErrorMsg$1 = "Oops, something went wrong...";
3044
+ const defaultErrorMsg = "Oops, something went wrong...";
3045
3045
  function AttachDialog(_a) {
3046
3046
  var {
3047
3047
  queryId,
@@ -3057,9 +3057,9 @@ function AttachDialog(_a) {
3057
3057
  itemLabel,
3058
3058
  onSuccess,
3059
3059
  onFetchError,
3060
- fetchErrorMsg = defaultErrorMsg$1,
3060
+ fetchErrorMsg = defaultErrorMsg,
3061
3061
  onSaveError,
3062
- saveErrorMsg = defaultErrorMsg$1,
3062
+ saveErrorMsg = defaultErrorMsg,
3063
3063
  invalidateQueriesOnSuccess = true,
3064
3064
  retryText = "Retry",
3065
3065
  cancelLabel = "Cancel",
@@ -3286,158 +3286,6 @@ function FormActionDialog(_a) {
3286
3286
  }));
3287
3287
  }
3288
3288
 
3289
- const defaultErrorMsg = "Oops, something went wrong...";
3290
- function nonNullValues(data) {
3291
- var _a;
3292
- if (data) {
3293
- const nonNullData = Object.assign({}, data);
3294
- for (const key in data) nonNullData[key] = (_a = nonNullData[key]) !== null && _a !== void 0 ? _a : "";
3295
- return nonNullData;
3296
- }
3297
- return data;
3298
- }
3299
- function ItemEditDialog(_a) {
3300
- var _b, _c, _d, _e;
3301
- var {
3302
- initialValues,
3303
- itemLabel,
3304
- queryId = "",
3305
- queryKey,
3306
- queryFetchFn,
3307
- queryFetchOptions,
3308
- querySaveFn,
3309
- querySaveOptions,
3310
- onSuccess,
3311
- onFetchError,
3312
- fetchErrorMsg = defaultErrorMsg,
3313
- onSaveError,
3314
- saveErrorMsg = defaultErrorMsg,
3315
- fetchToFormData,
3316
- formToQueryData,
3317
- invalidateQueriesOnSuccess = true,
3318
- invalidateQueryKey,
3319
- retryText = "Retry",
3320
- cancelLabel = "Cancel",
3321
- saveLabel,
3322
- size = "lg",
3323
- title,
3324
- form,
3325
- show,
3326
- onClose,
3327
- formikProps
3328
- } = _a,
3329
- props = __rest$1(_a, ["initialValues", "itemLabel", "queryId", "queryKey", "queryFetchFn", "queryFetchOptions", "querySaveFn", "querySaveOptions", "onSuccess", "onFetchError", "fetchErrorMsg", "onSaveError", "saveErrorMsg", "fetchToFormData", "formToQueryData", "invalidateQueriesOnSuccess", "invalidateQueryKey", "retryText", "cancelLabel", "saveLabel", "size", "title", "form", "show", "onClose", "formikProps"]);
3330
- const {
3331
- isInitialLoading,
3332
- isFetching,
3333
- data,
3334
- isError,
3335
- error /*, error*/,
3336
- refetch
3337
- } = useApiQuery(queryKey, queryFetchFn, queryId, Object.assign({
3338
- enabled: !( /*queryId == 0 || */queryId == "" || queryId == null || queryId == undefined),
3339
- onError: onFetchError
3340
- }, queryFetchOptions));
3341
- // const [activeTab, setActiveTab] = React.useState(form && Array.isArray(form) ? form[0].key : "");
3342
- // const [showTab, setShowTab] = React.useState(true);
3343
- const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(querySaveFn, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : queryKey, querySaveOptions) : useApiMutation(querySaveFn, queryKey, queryId, querySaveOptions);
3344
- const retry = React.useCallback(() => refetch(), [refetch]);
3345
- const saveItem = React.useCallback((item, actions) => {
3346
- // Clear mutation error if any
3347
- mutation.reset();
3348
- const formItem = formToQueryData ? formToQueryData(item) : Object.assign({}, item);
3349
- mutation.mutateAsync(formItem).then(response => {
3350
- var _a;
3351
- if (onSuccess) onSuccess(formItem, response);else toast.success(`${title ? title(formItem) : (_a = formItem.name) !== null && _a !== void 0 ? _a : formItem.title} ${queryId ? "saved" : "created"}`);
3352
- // closing delete modal
3353
- onClose === null || onClose === void 0 ? void 0 : onClose();
3354
- }).catch(error => {
3355
- var _a;
3356
- console.error("on error", error);
3357
- if (onSaveError) onSaveError(item);else toast.error(`Couldn't save ${title ? title(formItem) : (_a = formItem.name) !== null && _a !== void 0 ? _a : formItem.title}`);
3358
- actions.setSubmitting(false);
3359
- });
3360
- }, [mutation, formToQueryData, onSuccess, onSaveError, onClose]);
3361
- // const switchTab = React.useCallback((tab: string) =>
3362
- // {
3363
- // setActiveTab(tab);
3364
- // setShowTab(false);
3365
- // setTimeout(function ()
3366
- // {
3367
- // setActiveTab(tab);
3368
- // setShowTab(true);
3369
- // }, 150);
3370
- // }, [setActiveTab])
3371
- return jsxs(Modal, Object.assign({
3372
- size: size,
3373
- show: show,
3374
- onClose: onClose,
3375
- scheme: "light",
3376
- transition: true
3377
- }, props, {
3378
- children: [jsxs(Modal.Header, {
3379
- 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, {})
3380
- // <ul className="nav nav-bold nav-pills">
3381
- // {form.map(item =>
3382
- // <li key={item.key} className="nav-item cursor-pointer bg-hover-light rounded" onClick={() => switchTab(item.key)}>
3383
- // <span className={clsx("nav-link", activeTab === item.key && "active")} data-toggle="tab">{item.label}</span>
3384
- // </li>
3385
- // )}
3386
- // </ul>
3387
- ]
3388
- }), isInitialLoading && jsx(Modal.Body, {
3389
- children: jsx(QueryLoadingState, {
3390
- minW: "72"
3391
- })
3392
- }), isError && jsx(Modal.Body, {
3393
- children: jsx(RetryOnError, {
3394
- label: `${fetchErrorMsg} ${error}`,
3395
- onClick: retry
3396
- })
3397
- }), !isInitialLoading && !isError && jsx(Fragment, {
3398
- children: jsx(Formik, Object.assign({
3399
- initialValues: fetchToFormData && queryId && data ? fetchToFormData(nonNullValues(data)) : (_e = (_d = nonNullValues(data)) !== null && _d !== void 0 ? _d : initialValues) !== null && _e !== void 0 ? _e : {},
3400
- onSubmit: saveItem
3401
- }, formikProps, {
3402
- children: ({
3403
- setFieldValue,
3404
- dirty,
3405
- handleSubmit,
3406
- isValid,
3407
- values
3408
- }) => jsxs(Fragment, {
3409
- children: [jsx(Modal.Body, {
3410
- pb: "6",
3411
- children: jsxs(Form, {
3412
- children: [/*#__PURE__*/React.isValidElement(form) && form, Array.isArray(form) && jsx(FormRenderer, {
3413
- form: form
3414
- }), isFunction(form) && jsx(FormRenderer, {
3415
- form: form(data !== null && data !== void 0 ? data : values)
3416
- })]
3417
- })
3418
- }), jsxs(Modal.Footer, {
3419
- dflex: true,
3420
- placeContent: "end",
3421
- spaceX: "3",
3422
- children: [jsx(Button, {
3423
- disabled: mutation.isLoading,
3424
- onClick: onClose,
3425
- variant: "borderless",
3426
- me: "2",
3427
- children: cancelLabel
3428
- }), jsx(Button, {
3429
- type: "submit",
3430
- disabled: !dirty || mutation.isLoading /* || !isValid*/,
3431
- onClick: () => handleSubmit(),
3432
- children: saveLabel ? saveLabel : queryId ? "Update" : "Create"
3433
- })]
3434
- })]
3435
- })
3436
- }))
3437
- }), mutation.isLoading && jsx(ModalLoadingOverlay, {})]
3438
- }));
3439
- }
3440
-
3441
3289
  function PageSectionTitle(_a) {
3442
3290
  var {
3443
3291
  children
@@ -3678,4 +3526,4 @@ function TableRowPublishPostButton(_a) {
3678
3526
  }, props));
3679
3527
  }
3680
3528
 
3681
- export { AdminLayout, AttachDialog, Breadcrumbs, ButtonBar, ButtonBarButton, ButtonBarDialogButton, DialogButton, FormActionDialog, InvalidateButton, ItemEditDialog, NavigateButton, OrderCell, PageContainer, PageContentEditor, PageMain, PageQueryStateContainer, PageSectionTitle, PageSidebar, PageSidebarSection, PageStateContainer, PageSubSectionTitle, PageTabbedTopBar, PageTabbedTopBarProvider, PageTitle, PageTopBar, PageTopBarToolbar, PublishButton, ScreenRenderer, SectionTitle, StatusBadge, TableContainer, TableCreateButton, TableFilterButton, TableRowActionBar, TableRowActionButton, TableRowActionDialogButton, TableRowDeleteButton, TableRowEditButton, TableRowNavigateButton, TableRowPublishPostButton, TableRowViewButton, TableTopBar, UpdateButton, ViewButton };
3529
+ export { AdminLayout, AttachDialog, Breadcrumbs, ButtonBar, ButtonBarButton, ButtonBarDialogButton, DialogButton, FormActionDialog, InvalidateButton, ItemDeleteDialog, ItemEditDialog, NavigateButton, OrderCell, PageContainer, PageContentEditor, PageMain, PageQueryStateContainer, PageSectionTitle, PageSidebar, PageSidebarSection, PageStateContainer, PageSubSectionTitle, PageTabbedTopBar, PageTabbedTopBarProvider, PageTitle, PageTopBar, PageTopBarToolbar, PublishButton, ScreenRenderer, SectionTitle, StatusBadge, TableContainer, TableCreateButton, TableFilterButton, TableRowActionBar, TableRowActionButton, TableRowActionDialogButton, TableRowDeleteButton, TableRowEditButton, TableRowNavigateButton, TableRowPublishPostButton, TableRowViewButton, TableTopBar, UpdateButton, ViewButton };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.57",
3
+ "version": "1.0.58",
4
4
  "module": "./index.esm.js",
5
5
  "main": "./index.cjs.js"
6
6
  }
package/src/index.d.ts CHANGED
@@ -7,21 +7,22 @@ export * from "./lib/buttons/PublishButton";
7
7
  export * from "./lib/buttons/UpdateButton";
8
8
  export * from "./lib/buttons/ViewButton";
9
9
  export * from "./lib/cells/OrderCell";
10
- export * from "./lib/json/types/ScreenConfig";
11
- export * from "./lib/json/types/EditItemDialog";
12
- export * from "./lib/json/types/TableView";
13
- export * from "./lib/json/types/TabbedView";
10
+ export * from "./lib/json/ScreenRenderer";
11
+ export * from "./lib/json/dialog/ItemEditDialog";
12
+ export * from "./lib/json/dialog/ItemDeleteDialog";
14
13
  export * from "./lib/json/types/DetailsView";
14
+ export * from "./lib/json/types/EditItemDialog";
15
+ export * from "./lib/json/types/MultiQueryWrapper";
15
16
  export * from "./lib/json/types/QueryWrapper";
16
17
  export * from "./lib/json/types/QueryWrapperDialog";
17
- export * from "./lib/json/types/MultiQueryWrapper";
18
- export * from "./lib/json/ScreenRenderer";
18
+ export * from "./lib/json/types/ScreenConfig";
19
+ export * from "./lib/json/types/TabbedView";
20
+ export * from "./lib/json/types/TableView";
19
21
  export * from "./lib/layout/AdminLayout";
20
22
  export * from "./lib/layout/ButtonBar";
21
23
  export { MenuConfig } from "./lib/layout/Menu";
22
24
  export * from "./lib/modal/AttachDialog";
23
25
  export * from "./lib/modal/FormActionDialog";
24
- export * from "./lib/modal/ItemEditDialog";
25
26
  export * from "./lib/page/PageContainer";
26
27
  export * from "./lib/page/PageContentEditor";
27
28
  export * from "./lib/page/PageMain";
@@ -1,33 +0,0 @@
1
- import { FormRendererConfig } from "@compill/form";
2
- import { UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
3
- import { ModalProps } from "@valerya/ui";
4
- import { FormikConfig } from "formik";
5
- import React from "react";
6
- export interface ItemEditDialogProps<TFormData extends {} = any, TResultData extends {} = any> extends Omit<ModalProps, "id" | "children" | "title" | "position"> {
7
- itemLabel?: string;
8
- queryId?: string;
9
- queryKey: string[];
10
- initialValues?: any;
11
- queryFetchFn: (...args: any[]) => Promise<TResultData>;
12
- queryFetchOptions?: UseQueryOptions;
13
- querySaveFn: (item: TFormData) => Promise<TResultData>;
14
- querySaveOptions?: UseMutationOptions<TResultData, unknown, TFormData>;
15
- onSuccess?: (item: TResultData, response: any) => void;
16
- onFetchError?: () => void;
17
- fetchErrorMsg?: string;
18
- onSaveError?: (item: TFormData) => void;
19
- saveErrorMsg?: string;
20
- fetchToFormData?: (item: TResultData) => TFormData;
21
- formToQueryData?: (TFormData: any) => Partial<TResultData>;
22
- invalidateQueriesOnSuccess?: boolean;
23
- invalidateQueryKey?: string[];
24
- retryText?: string;
25
- cancelLabel?: string;
26
- saveLabel?: string;
27
- title?: ((item?: TResultData) => string);
28
- formikProps: Omit<FormikConfig<any>, "initialValues" | "onSubmit">;
29
- form: React.ReactNode | FormRendererConfig | ((item: TResultData) => FormRendererConfig);
30
- show: boolean;
31
- onClose: () => void;
32
- }
33
- export declare function ItemEditDialog<TFormData extends {}, TResultData extends {}>({ initialValues, itemLabel, queryId, queryKey, queryFetchFn, queryFetchOptions, querySaveFn, querySaveOptions, onSuccess, onFetchError, fetchErrorMsg, onSaveError, saveErrorMsg, fetchToFormData, formToQueryData, invalidateQueriesOnSuccess, invalidateQueryKey, retryText, cancelLabel, saveLabel, size, title, form, show, onClose, formikProps, ...props }: ItemEditDialogProps<TFormData, TResultData>): JSX.Element;