@compill/admin 1.0.73 → 1.0.74
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 +56 -31
- package/index.esm.js +57 -33
- package/package.json +1 -1
- package/src/lib/json/ScreenTopBar.d.ts +2 -1
- package/src/lib/json/types/DetailsView.d.ts +2 -1
- package/src/lib/layout/ButtonBar.d.ts +4 -0
package/index.cjs.js
CHANGED
@@ -8,15 +8,15 @@ var Link = require('next/link');
|
|
8
8
|
var React = require('react');
|
9
9
|
var adminApi = require('@compill/admin-api');
|
10
10
|
var api = require('@compill/api');
|
11
|
+
var formik = require('formik');
|
11
12
|
var reactRouterDom = require('react-router-dom');
|
13
|
+
var admin = require('@compill/admin');
|
12
14
|
var reactToastify = require('react-toastify');
|
13
|
-
var form = require('@compill/form');
|
14
|
-
var formik = require('formik');
|
15
15
|
require('react/jsx-runtime');
|
16
16
|
var components = require('@compill/components');
|
17
|
+
var form = require('@compill/form');
|
17
18
|
var react = require('@soperio/react');
|
18
19
|
var editor = require('@compill/editor');
|
19
|
-
var admin = require('@compill/admin');
|
20
20
|
var reactDom = require('react-dom');
|
21
21
|
var router = require('next/router');
|
22
22
|
var table = require('@compill/table');
|
@@ -205,6 +205,43 @@ const ButtonBarButton = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
205
205
|
}), children]
|
206
206
|
}));
|
207
207
|
});
|
208
|
+
const ButtonBarSubmitButton = /*#__PURE__*/React__default["default"].forwardRef(function (_a, ref) {
|
209
|
+
var _b;
|
210
|
+
var {
|
211
|
+
useDirty,
|
212
|
+
disabled,
|
213
|
+
icon,
|
214
|
+
children
|
215
|
+
} = _a,
|
216
|
+
props = __rest$1(_a, ["useDirty", "disabled", "icon", "children"]);
|
217
|
+
const {
|
218
|
+
dirty,
|
219
|
+
handleSubmit
|
220
|
+
} = (_b = formik.useFormikContext()) !== null && _b !== void 0 ? _b : {
|
221
|
+
dirty: false,
|
222
|
+
handleSubmit: undefined,
|
223
|
+
values: {}
|
224
|
+
};
|
225
|
+
const onSubmit = React__default["default"].useCallback(() => handleSubmit(), [handleSubmit]);
|
226
|
+
return jsxRuntime.jsxs(ui.Button, Object.assign({
|
227
|
+
scheme: "dark",
|
228
|
+
size: "sm",
|
229
|
+
aspectRatio: icon && !children ? "square" : undefined,
|
230
|
+
variant: "borderless",
|
231
|
+
dflex: true,
|
232
|
+
alignItems: "center",
|
233
|
+
placeContent: "center",
|
234
|
+
corners: "square",
|
235
|
+
gap: "2",
|
236
|
+
disabled: useDirty && !dirty || disabled,
|
237
|
+
onClick: onSubmit
|
238
|
+
}, props, {
|
239
|
+
ref: ref,
|
240
|
+
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
241
|
+
path: icon
|
242
|
+
}), children]
|
243
|
+
}));
|
244
|
+
});
|
208
245
|
function ButtonBarDialogButton(_a) {
|
209
246
|
var {
|
210
247
|
icon,
|
@@ -285,20 +322,12 @@ function PublishButton(_a) {
|
|
285
322
|
mutation.reset();
|
286
323
|
mutation.mutateAsync(queryId).then(() => reactToastify.toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => reactToastify.toast.error(`Error: ${error}`));
|
287
324
|
}, [mutation, queryId]);
|
288
|
-
return jsxRuntime.
|
289
|
-
scheme: "secondary",
|
290
|
-
variant: "glass",
|
291
|
-
size: "sm",
|
292
|
-
px: "3",
|
325
|
+
return jsxRuntime.jsx(admin.ButtonBarButton, Object.assign({
|
293
326
|
disabled: mutation.isLoading,
|
294
327
|
onClick: publish,
|
295
|
-
|
296
|
-
alignItems: "center",
|
297
|
-
gap: "3"
|
328
|
+
icon: isDraft ? mdiEye : mdiEyeOff
|
298
329
|
}, props, {
|
299
|
-
children:
|
300
|
-
path: isDraft ? mdiEye : mdiEyeOff
|
301
|
-
}), isDraft ? "Publish" : "Switch to draft"]
|
330
|
+
children: isDraft ? "Publish" : "Switch to draft"
|
302
331
|
}));
|
303
332
|
}
|
304
333
|
|
@@ -705,17 +734,10 @@ function UpdateButton(_a) {
|
|
705
734
|
}, {
|
706
735
|
preventDefault: true
|
707
736
|
}, [dirty, props, handleSubmit]);
|
708
|
-
return jsxRuntime.
|
709
|
-
|
710
|
-
size: "sm",
|
711
|
-
px: "3",
|
712
|
-
dflex: true,
|
713
|
-
alignItems: "center",
|
714
|
-
gap: "3"
|
737
|
+
return jsxRuntime.jsx(admin.ButtonBarSubmitButton, Object.assign({
|
738
|
+
icon: mdiCloudUpload
|
715
739
|
}, props, {
|
716
|
-
children:
|
717
|
-
path: mdiCloudUpload
|
718
|
-
}), "Update"]
|
740
|
+
children: "Update"
|
719
741
|
}));
|
720
742
|
}
|
721
743
|
|
@@ -1119,13 +1141,15 @@ function Buttons$1({
|
|
1119
1141
|
}), button.type === "invalidate" && jsxRuntime.jsx(InvalidateButton, {
|
1120
1142
|
pathOrPermalink: button.pathOrPermalink
|
1121
1143
|
}), button.type == "custom" && button.render(item)]
|
1122
|
-
}, index)), jsxRuntime.
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1144
|
+
}, index)), jsxRuntime.jsxs(admin.ButtonBar, {
|
1145
|
+
children: [api instanceof adminApi.API && jsxRuntime.jsx(PublishButton, {
|
1146
|
+
api: api,
|
1147
|
+
queryId: item.id,
|
1148
|
+
status: item.status,
|
1149
|
+
disabled: isLoading
|
1150
|
+
}), jsxRuntime.jsx(UpdateButton, {
|
1151
|
+
disabled: isLoading
|
1152
|
+
})]
|
1129
1153
|
})]
|
1130
1154
|
});
|
1131
1155
|
}
|
@@ -3652,6 +3676,7 @@ exports.Breadcrumbs = Breadcrumbs;
|
|
3652
3676
|
exports.ButtonBar = ButtonBar;
|
3653
3677
|
exports.ButtonBarButton = ButtonBarButton;
|
3654
3678
|
exports.ButtonBarDialogButton = ButtonBarDialogButton;
|
3679
|
+
exports.ButtonBarSubmitButton = ButtonBarSubmitButton;
|
3655
3680
|
exports.DialogButton = DialogButton;
|
3656
3681
|
exports.FormActionDialog = FormActionDialog;
|
3657
3682
|
exports.InvalidateButton = InvalidateButton;
|
package/index.esm.js
CHANGED
@@ -2,17 +2,17 @@ import { jsx, jsxs, Fragment } from '@soperio/jsx-runtime';
|
|
2
2
|
import { Icon, Button, IconButton, Container, Tile, Popover, Collapse, Modal, Checkbox, Badge } from '@valerya/ui';
|
3
3
|
import Link from 'next/link';
|
4
4
|
import React, { useRef, useCallback, useContext as useContext$2, useLayoutEffect, useEffect, createContext } from 'react';
|
5
|
-
import { INVALIDATE_API } from '@compill/admin-api';
|
5
|
+
import { INVALIDATE_API, API } from '@compill/admin-api';
|
6
6
|
import { useApiMutation, useMutate, useInvalidateMutation, useApiQuery, useInvalidateQuery, useInvalidateParentMutation, useApiQueries } from '@compill/api';
|
7
|
+
import { useFormikContext, Field, Formik, Form } from 'formik';
|
7
8
|
import { useNavigate, useParams, Outlet, useLocation, useMatch, Link as Link$1 } from 'react-router-dom';
|
9
|
+
import { ButtonBarButton as ButtonBarButton$1, ButtonBarSubmitButton as ButtonBarSubmitButton$1, PageSectionTitle as PageSectionTitle$1, ButtonBar as ButtonBar$1, ButtonBarDialogButton as ButtonBarDialogButton$1, TableRowActionButton as TableRowActionButton$1, DialogButton as DialogButton$1 } from '@compill/admin';
|
8
10
|
import { toast } from 'react-toastify';
|
9
|
-
import { SubmitButton, FormProvider, TextArea, FormRenderer, mergeInitialFormValues, FieldLabel } from '@compill/form';
|
10
|
-
import { useFormikContext, Field, Formik, Form } from 'formik';
|
11
11
|
import 'react/jsx-runtime';
|
12
12
|
import { FlexCenter, QueryLoadingState, RetryOnError, TabContainer, ModalLoadingOverlay } from '@compill/components';
|
13
|
+
import { FormProvider, TextArea, FormRenderer, mergeInitialFormValues, FieldLabel, SubmitButton } from '@compill/form';
|
13
14
|
import { createContext as createContext$1, runIfFn, isFunction } from '@soperio/react';
|
14
15
|
import { Editor } from '@compill/editor';
|
15
|
-
import { PageSectionTitle as PageSectionTitle$1, ButtonBarDialogButton as ButtonBarDialogButton$1, TableRowActionButton as TableRowActionButton$1, DialogButton as DialogButton$1 } from '@compill/admin';
|
16
16
|
import { createPortal } from 'react-dom';
|
17
17
|
import { useRouter } from 'next/router';
|
18
18
|
import { TableContextProvider, useTableContext, Table } from '@compill/table';
|
@@ -195,6 +195,43 @@ const ButtonBarButton = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
195
195
|
}), children]
|
196
196
|
}));
|
197
197
|
});
|
198
|
+
const ButtonBarSubmitButton = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
199
|
+
var _b;
|
200
|
+
var {
|
201
|
+
useDirty,
|
202
|
+
disabled,
|
203
|
+
icon,
|
204
|
+
children
|
205
|
+
} = _a,
|
206
|
+
props = __rest$1(_a, ["useDirty", "disabled", "icon", "children"]);
|
207
|
+
const {
|
208
|
+
dirty,
|
209
|
+
handleSubmit
|
210
|
+
} = (_b = useFormikContext()) !== null && _b !== void 0 ? _b : {
|
211
|
+
dirty: false,
|
212
|
+
handleSubmit: undefined,
|
213
|
+
values: {}
|
214
|
+
};
|
215
|
+
const onSubmit = React.useCallback(() => handleSubmit(), [handleSubmit]);
|
216
|
+
return jsxs(Button, Object.assign({
|
217
|
+
scheme: "dark",
|
218
|
+
size: "sm",
|
219
|
+
aspectRatio: icon && !children ? "square" : undefined,
|
220
|
+
variant: "borderless",
|
221
|
+
dflex: true,
|
222
|
+
alignItems: "center",
|
223
|
+
placeContent: "center",
|
224
|
+
corners: "square",
|
225
|
+
gap: "2",
|
226
|
+
disabled: useDirty && !dirty || disabled,
|
227
|
+
onClick: onSubmit
|
228
|
+
}, props, {
|
229
|
+
ref: ref,
|
230
|
+
children: [icon && jsx(Icon, {
|
231
|
+
path: icon
|
232
|
+
}), children]
|
233
|
+
}));
|
234
|
+
});
|
198
235
|
function ButtonBarDialogButton(_a) {
|
199
236
|
var {
|
200
237
|
icon,
|
@@ -275,20 +312,12 @@ function PublishButton(_a) {
|
|
275
312
|
mutation.reset();
|
276
313
|
mutation.mutateAsync(queryId).then(() => toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => toast.error(`Error: ${error}`));
|
277
314
|
}, [mutation, queryId]);
|
278
|
-
return
|
279
|
-
scheme: "secondary",
|
280
|
-
variant: "glass",
|
281
|
-
size: "sm",
|
282
|
-
px: "3",
|
315
|
+
return jsx(ButtonBarButton$1, Object.assign({
|
283
316
|
disabled: mutation.isLoading,
|
284
317
|
onClick: publish,
|
285
|
-
|
286
|
-
alignItems: "center",
|
287
|
-
gap: "3"
|
318
|
+
icon: isDraft ? mdiEye : mdiEyeOff
|
288
319
|
}, props, {
|
289
|
-
children:
|
290
|
-
path: isDraft ? mdiEye : mdiEyeOff
|
291
|
-
}), isDraft ? "Publish" : "Switch to draft"]
|
320
|
+
children: isDraft ? "Publish" : "Switch to draft"
|
292
321
|
}));
|
293
322
|
}
|
294
323
|
|
@@ -695,17 +724,10 @@ function UpdateButton(_a) {
|
|
695
724
|
}, {
|
696
725
|
preventDefault: true
|
697
726
|
}, [dirty, props, handleSubmit]);
|
698
|
-
return
|
699
|
-
|
700
|
-
size: "sm",
|
701
|
-
px: "3",
|
702
|
-
dflex: true,
|
703
|
-
alignItems: "center",
|
704
|
-
gap: "3"
|
727
|
+
return jsx(ButtonBarSubmitButton$1, Object.assign({
|
728
|
+
icon: mdiCloudUpload
|
705
729
|
}, props, {
|
706
|
-
children:
|
707
|
-
path: mdiCloudUpload
|
708
|
-
}), "Update"]
|
730
|
+
children: "Update"
|
709
731
|
}));
|
710
732
|
}
|
711
733
|
|
@@ -1109,13 +1131,15 @@ function Buttons$1({
|
|
1109
1131
|
}), button.type === "invalidate" && jsx(InvalidateButton, {
|
1110
1132
|
pathOrPermalink: button.pathOrPermalink
|
1111
1133
|
}), button.type == "custom" && button.render(item)]
|
1112
|
-
}, index)),
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1134
|
+
}, index)), jsxs(ButtonBar$1, {
|
1135
|
+
children: [api instanceof API && jsx(PublishButton, {
|
1136
|
+
api: api,
|
1137
|
+
queryId: item.id,
|
1138
|
+
status: item.status,
|
1139
|
+
disabled: isLoading
|
1140
|
+
}), jsx(UpdateButton, {
|
1141
|
+
disabled: isLoading
|
1142
|
+
})]
|
1119
1143
|
})]
|
1120
1144
|
});
|
1121
1145
|
}
|
@@ -3636,4 +3660,4 @@ function TableRowPublishPostButton(_a) {
|
|
3636
3660
|
}, props));
|
3637
3661
|
}
|
3638
3662
|
|
3639
|
-
export { AdminLayout, AttachDialog, Breadcrumbs, ButtonBar, ButtonBarButton, ButtonBarDialogButton, DialogButton, FormActionDialog, InvalidateButton, ItemDeleteDialog, ItemEditDialog, Menu, 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 };
|
3663
|
+
export { AdminLayout, AttachDialog, Breadcrumbs, ButtonBar, ButtonBarButton, ButtonBarDialogButton, ButtonBarSubmitButton, DialogButton, FormActionDialog, InvalidateButton, ItemDeleteDialog, ItemEditDialog, Menu, 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
@@ -2,11 +2,12 @@
|
|
2
2
|
import { API } from "@compill/admin-api";
|
3
3
|
import { Breadcrumb } from "../breadcrumbs/BreadCrumbs";
|
4
4
|
import { DetailViewButton } from "./types/DetailsView";
|
5
|
+
import { CRUDAPI } from "@compill/api";
|
5
6
|
interface ScreenTopBarProps {
|
6
7
|
tabbed?: boolean;
|
7
8
|
breadcrumbs?: Breadcrumb[];
|
8
9
|
buttonBar?: DetailViewButton[];
|
9
|
-
api: API<any>;
|
10
|
+
api: CRUDAPI<any> | API<any>;
|
10
11
|
item: any;
|
11
12
|
isLoading: boolean;
|
12
13
|
trackingRef?: Element | null;
|
@@ -3,9 +3,10 @@ import { API } from "@compill/admin-api";
|
|
3
3
|
import * as Yup from "yup";
|
4
4
|
import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs";
|
5
5
|
import { FormRendererConfig } from "@compill/form";
|
6
|
+
import { CRUDAPI } from "@compill/api";
|
6
7
|
export type DetailsViewConfig<T = any> = {
|
7
8
|
type: "details";
|
8
|
-
api: API<T>;
|
9
|
+
api: CRUDAPI<T> | API<T>;
|
9
10
|
queryField: string;
|
10
11
|
useNextRouter?: boolean;
|
11
12
|
processInput?: (input: T) => any;
|
@@ -9,6 +9,10 @@ export type ButtonBarButtonProps = {
|
|
9
9
|
export declare const ButtonBarButton: React.ForwardRefExoticComponent<{
|
10
10
|
icon?: string | undefined;
|
11
11
|
} & ButtonProps & React.RefAttributes<HTMLDivElement>>;
|
12
|
+
export interface ButtonBarSubmitButtonProps extends ButtonBarButtonProps {
|
13
|
+
useDirty?: boolean;
|
14
|
+
}
|
15
|
+
export declare const ButtonBarSubmitButton: React.ForwardRefExoticComponent<ButtonBarSubmitButtonProps & React.RefAttributes<HTMLDivElement>>;
|
12
16
|
export type ButtonBarDialogButtonProps = {
|
13
17
|
icon?: string;
|
14
18
|
} & DialogButtonProps;
|