dinocollab-core 1.0.0
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/README.md +54 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js +431 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/dist/assets/vector-404265a04f4f9c8be1f.webp +0 -0
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@1_d0d2002d9033600b6738d939bd598bc6/node_modules/tslib/tslib.es6.js +46 -0
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@1_d0d2002d9033600b6738d939bd598bc6/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/src/api-context/alert-global.js +151 -0
- package/dist/src/api-context/alert-global.js.map +1 -0
- package/dist/src/api-context/drawer-global.js +105 -0
- package/dist/src/api-context/drawer-global.js.map +1 -0
- package/dist/src/api-context/global-modal.js +87 -0
- package/dist/src/api-context/global-modal.js.map +1 -0
- package/dist/src/api-context/popover-global.js +102 -0
- package/dist/src/api-context/popover-global.js.map +1 -0
- package/dist/src/api-context/popover.js +86 -0
- package/dist/src/api-context/popover.js.map +1 -0
- package/dist/src/api-context/ui.units.js +21 -0
- package/dist/src/api-context/ui.units.js.map +1 -0
- package/dist/src/components/copy-to-clipboard.js +105 -0
- package/dist/src/components/copy-to-clipboard.js.map +1 -0
- package/dist/src/components/custom.breadcrumbs.js +61 -0
- package/dist/src/components/custom.breadcrumbs.js.map +1 -0
- package/dist/src/components/help-tooltip.js +91 -0
- package/dist/src/components/help-tooltip.js.map +1 -0
- package/dist/src/components/image-with-fallback.js +48 -0
- package/dist/src/components/image-with-fallback.js.map +1 -0
- package/dist/src/components/text-editor.js +117 -0
- package/dist/src/components/text-editor.js.map +1 -0
- package/dist/src/form/create.autocomplete.chips.js +218 -0
- package/dist/src/form/create.autocomplete.chips.js.map +1 -0
- package/dist/src/form/create.date-expired.js +201 -0
- package/dist/src/form/create.date-expired.js.map +1 -0
- package/dist/src/form/create.date-picker.js +125 -0
- package/dist/src/form/create.date-picker.js.map +1 -0
- package/dist/src/form/create.form-base.js +135 -0
- package/dist/src/form/create.form-base.js.map +1 -0
- package/dist/src/form/create.form-comfirm.js +119 -0
- package/dist/src/form/create.form-comfirm.js.map +1 -0
- package/dist/src/form/create.form-grid-layout.js +177 -0
- package/dist/src/form/create.form-grid-layout.js.map +1 -0
- package/dist/src/form/create.form-grid-layout.units.js +39 -0
- package/dist/src/form/create.form-grid-layout.units.js.map +1 -0
- package/dist/src/form/create.input-base.js +260 -0
- package/dist/src/form/create.input-base.js.map +1 -0
- package/dist/src/form/create.input.file.js +74 -0
- package/dist/src/form/create.input.file.js.map +1 -0
- package/dist/src/form/create.select-simple.js +104 -0
- package/dist/src/form/create.select-simple.js.map +1 -0
- package/dist/src/form/create.select-with-api.js +271 -0
- package/dist/src/form/create.select-with-api.js.map +1 -0
- package/dist/src/form/create.text-editor.js +156 -0
- package/dist/src/form/create.text-editor.js.map +1 -0
- package/dist/src/form/dino-form.js +42 -0
- package/dist/src/form/dino-form.js.map +1 -0
- package/dist/src/form/helper.js +157 -0
- package/dist/src/form/helper.js.map +1 -0
- package/dist/src/form/modal-wrapper.js +75 -0
- package/dist/src/form/modal-wrapper.js.map +1 -0
- package/dist/src/form/validator.js +186 -0
- package/dist/src/form/validator.js.map +1 -0
- package/dist/src/hooks/index.js +48 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/index.js +26 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/redux/create.hoc-lazy.js +67 -0
- package/dist/src/redux/create.hoc-lazy.js.map +1 -0
- package/dist/src/redux/dino.js +11 -0
- package/dist/src/redux/dino.js.map +1 -0
- package/dist/src/redux/types.js +9 -0
- package/dist/src/redux/types.js.map +1 -0
- package/dist/src/redux/ui.error-page.js +80 -0
- package/dist/src/redux/ui.error-page.js.map +1 -0
- package/dist/src/redux/vector-404.webp.js +4 -0
- package/dist/src/redux/vector-404.webp.js.map +1 -0
- package/dist/src/table/context.js +12 -0
- package/dist/src/table/context.js.map +1 -0
- package/dist/src/table/create.action-row.js +135 -0
- package/dist/src/table/create.action-row.js.map +1 -0
- package/dist/src/table/create.status-cell.js +49 -0
- package/dist/src/table/create.status-cell.js.map +1 -0
- package/dist/src/table/create.table.js +233 -0
- package/dist/src/table/create.table.js.map +1 -0
- package/dist/src/table/custom.filter-operators.js +89 -0
- package/dist/src/table/custom.filter-operators.js.map +1 -0
- package/dist/src/table/dino.js +129 -0
- package/dist/src/table/dino.js.map +1 -0
- package/dist/src/table/helpers.js +116 -0
- package/dist/src/table/helpers.js.map +1 -0
- package/dist/src/table/model-filter.js +23 -0
- package/dist/src/table/model-filter.js.map +1 -0
- package/dist/src/table/toolbar-pannel.js +134 -0
- package/dist/src/table/toolbar-pannel.js.map +1 -0
- package/dist/src/table/ui.buttons.js +60 -0
- package/dist/src/table/ui.buttons.js.map +1 -0
- package/dist/src/table/ui.units.js +201 -0
- package/dist/src/table/ui.units.js.map +1 -0
- package/dist/src/utils/dayjs-config.js +12 -0
- package/dist/src/utils/dayjs-config.js.map +1 -0
- package/dist/src/utils/helpers.js +197 -0
- package/dist/src/utils/helpers.js.map +1 -0
- package/dist/src/utils/json-object.js +38 -0
- package/dist/src/utils/json-object.js.map +1 -0
- package/dist/src/utils/query-param.js +172 -0
- package/dist/src/utils/query-param.js.map +1 -0
- package/package.json +52 -0
- package/rollup.config.js +39 -0
- package/src/@types/global.d.ts +5 -0
- package/src/api-context/alert-global.tsx +174 -0
- package/src/api-context/drawer-global.tsx +116 -0
- package/src/api-context/global-modal.tsx +109 -0
- package/src/api-context/index.ts +13 -0
- package/src/api-context/popover-global.tsx +107 -0
- package/src/api-context/popover.tsx +89 -0
- package/src/api-context/ui.units.tsx +10 -0
- package/src/components/copy-to-clipboard.tsx +86 -0
- package/src/components/custom.breadcrumbs.tsx +67 -0
- package/src/components/help-tooltip.tsx +75 -0
- package/src/components/image-with-fallback.tsx +51 -0
- package/src/components/index.tsx +1 -0
- package/src/components/input-debounce-timer.tsx +138 -0
- package/src/components/loading-buttons.tsx +35 -0
- package/src/components/text-editor.preview.tsx +30 -0
- package/src/components/text-editor.tsx +125 -0
- package/src/form/README.md +55 -0
- package/src/form/create.autocomplete.chips.tsx +199 -0
- package/src/form/create.date-expired.tsx +195 -0
- package/src/form/create.date-picker.tsx +122 -0
- package/src/form/create.form-base.tsx +102 -0
- package/src/form/create.form-comfirm.tsx +83 -0
- package/src/form/create.form-grid-layout.tsx +170 -0
- package/src/form/create.form-grid-layout.units.tsx +37 -0
- package/src/form/create.input-base.tsx +222 -0
- package/src/form/create.input.file.tsx +76 -0
- package/src/form/create.select-simple.tsx +101 -0
- package/src/form/create.select-with-api.tsx +213 -0
- package/src/form/create.text-editor.tsx +161 -0
- package/src/form/dino-form.tsx +40 -0
- package/src/form/helper.ts +132 -0
- package/src/form/index.ts +12 -0
- package/src/form/modal-wrapper.tsx +75 -0
- package/src/form/types.ts +16 -0
- package/src/form/validator.ts +202 -0
- package/src/hooks/index.ts +44 -0
- package/src/index.ts +7 -0
- package/src/lab/create.autocomplete.simple.tsx +57 -0
- package/src/lab/create.dino-store.ts +59 -0
- package/src/lab/create.multi-select-dropdown.tsx +189 -0
- package/src/lab/create.select-mul-with-api/index.tsx +271 -0
- package/src/lab/create.select-mul-with-api/table-custom.tsx +194 -0
- package/src/lab/create.select-mul-with-api/types.ts +26 -0
- package/src/lab/create.select-mul-with-api/ui.units.tsx +163 -0
- package/src/lab/filter-bar/base.tsx +162 -0
- package/src/lab/filter-bar/create.filter-bar.tsx +190 -0
- package/src/lab/filter-bar/create.filter-menu.tsx +156 -0
- package/src/lab/filter-bar/create.filter-panel.tsx +95 -0
- package/src/lab/filter-bar/create.filtered.tsx +41 -0
- package/src/lab/filter-bar/create.sort-menu.tsx +43 -0
- package/src/lab/filter-bar/demo.tsx +50 -0
- package/src/lab/filter-bar/index.ts +6 -0
- package/src/lab/filter-bar/types.ts +105 -0
- package/src/lab/filter-bar/ui.units.tsx +70 -0
- package/src/lab/grafana-dashboard/configs.ts +43 -0
- package/src/lab/grafana-dashboard/date-time-range/absolute-time-rage.tsx +137 -0
- package/src/lab/grafana-dashboard/date-time-range/helpers.ts +126 -0
- package/src/lab/grafana-dashboard/date-time-range/index.tsx +62 -0
- package/src/lab/grafana-dashboard/date-time-range/menu-wrap.tsx +101 -0
- package/src/lab/grafana-dashboard/date-time-range/quick-ranges.tsx +161 -0
- package/src/lab/grafana-dashboard/date-time-range/types.ts +9 -0
- package/src/lab/grafana-dashboard/date-time-range/units.tsx +18 -0
- package/src/lab/grafana-dashboard/helper.ts +25 -0
- package/src/lab/grafana-dashboard/hooks.tsx +79 -0
- package/src/lab/grafana-dashboard/icons.tsx +67 -0
- package/src/lab/grafana-dashboard/index.tsx +120 -0
- package/src/lab/grafana-dashboard/top-bar.tsx +62 -0
- package/src/lab/grafana-dashboard/top-bar.types.ts +5 -0
- package/src/lab/grafana-dashboard/types.ts +8 -0
- package/src/lab/media-player.core1.tsx +273 -0
- package/src/lab/media-player.muted.tsx +62 -0
- package/src/lab/media-player.units.ts +80 -0
- package/src/lab/table-grid/create.table-grid.tsx +183 -0
- package/src/lab/table-grid/demo.tsx +53 -0
- package/src/lab/table-grid/dino.tsx +8 -0
- package/src/lab/table-grid/helpers.tsx +11 -0
- package/src/lab/table-grid/index.ts +3 -0
- package/src/lab/table-grid/item-actions.tsx +138 -0
- package/src/lab/table-grid/toolbar-pannel.tsx +98 -0
- package/src/lab/table-grid/types.ts +68 -0
- package/src/redux/create.hoc-lazy.tsx +80 -0
- package/src/redux/dino.ts +9 -0
- package/src/redux/index.ts +6 -0
- package/src/redux/types.ts +27 -0
- package/src/redux/ui.error-page.tsx +62 -0
- package/src/redux/ui.units.tsx +41 -0
- package/src/redux/vector-404.webp +0 -0
- package/src/table/context.tsx +16 -0
- package/src/table/create.action-row.tsx +91 -0
- package/src/table/create.status-cell.tsx +51 -0
- package/src/table/create.table.tsx +239 -0
- package/src/table/custom.filter-operators.ts +94 -0
- package/src/table/dino.tsx +120 -0
- package/src/table/helpers.ts +94 -0
- package/src/table/index.ts +13 -0
- package/src/table/model-filter.ts +43 -0
- package/src/table/toolbar-pannel.tsx +106 -0
- package/src/table/types.ts +50 -0
- package/src/table/ui.buttons.tsx +54 -0
- package/src/table/ui.units.tsx +189 -0
- package/src/utils/dayjs-config.ts +13 -0
- package/src/utils/helpers.ts +171 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/json-object.ts +29 -0
- package/src/utils/mfe-events.tsx +34 -0
- package/src/utils/query-param.ts +129 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { useState, useCallback, useEffect } from 'react';
|
|
3
|
+
import { styled, Box, Stack, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button } from '@mui/material';
|
|
4
|
+
import MuiAlert from '@mui/material/Alert';
|
|
5
|
+
|
|
6
|
+
var Alert = /*#__PURE__*/React.forwardRef(function Alert(props, ref) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(MuiAlert, _extends({
|
|
8
|
+
elevation: 6,
|
|
9
|
+
ref: ref,
|
|
10
|
+
variant: "standard"
|
|
11
|
+
}, props, {
|
|
12
|
+
style: {
|
|
13
|
+
minWidth: '300px'
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
});
|
|
17
|
+
var ApiAlertContext = {};
|
|
18
|
+
var RenderArea = function RenderArea(messages, onClose) {
|
|
19
|
+
return messages.map(function (x, i) {
|
|
20
|
+
return /*#__PURE__*/React.createElement(Message, {
|
|
21
|
+
key: x.id + i,
|
|
22
|
+
data: x,
|
|
23
|
+
IsOpen: true,
|
|
24
|
+
handleClose: onClose,
|
|
25
|
+
autoDurationHide: x.duration
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
function AlertGlobal() {
|
|
30
|
+
var _useState = useState([]),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
Messages = _useState2[0],
|
|
33
|
+
setMessages = _useState2[1];
|
|
34
|
+
var _PushMessage = useCallback(function (data) {
|
|
35
|
+
setMessages(function (st) {
|
|
36
|
+
return [].concat(_toConsumableArray(st), [data]);
|
|
37
|
+
});
|
|
38
|
+
}, []);
|
|
39
|
+
var _HandleClose = useCallback(function (data) {
|
|
40
|
+
var index = Messages.findIndex(function (x) {
|
|
41
|
+
return x.id === data.id;
|
|
42
|
+
});
|
|
43
|
+
Messages.splice(index, 1);
|
|
44
|
+
setMessages(_toConsumableArray(Messages));
|
|
45
|
+
}, [Messages]);
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
ApiAlertContext.ApiAlert = Object.assign(Object.assign({}, ApiAlertContext.ApiAlert ? ApiAlertContext.ApiAlert : {}), {
|
|
48
|
+
PushMessage: _PushMessage,
|
|
49
|
+
PushError: function PushError(data, options) {
|
|
50
|
+
this.PushMessage({
|
|
51
|
+
id: new Date().getTime().toString(),
|
|
52
|
+
text: data,
|
|
53
|
+
type: 'error',
|
|
54
|
+
duration: (options === null || options === void 0 ? void 0 : options.duration) || 15000
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
PushInfo: function PushInfo(data, options) {
|
|
58
|
+
this.PushMessage({
|
|
59
|
+
id: new Date().getTime().toString(),
|
|
60
|
+
text: data,
|
|
61
|
+
type: 'info',
|
|
62
|
+
duration: (options === null || options === void 0 ? void 0 : options.duration) || 6000
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
PushWarning: function PushWarning(data, options) {
|
|
66
|
+
this.PushMessage({
|
|
67
|
+
id: new Date().getTime().toString(),
|
|
68
|
+
text: data,
|
|
69
|
+
type: 'warning',
|
|
70
|
+
duration: (options === null || options === void 0 ? void 0 : options.duration) || 6000
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
PushSuccess: function PushSuccess(data, options) {
|
|
74
|
+
this.PushMessage({
|
|
75
|
+
id: new Date().getTime().toString(),
|
|
76
|
+
text: data,
|
|
77
|
+
type: 'success',
|
|
78
|
+
duration: (options === null || options === void 0 ? void 0 : options.duration) || 3000
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}, [_PushMessage]);
|
|
83
|
+
return /*#__PURE__*/React.createElement(Wrap, null, /*#__PURE__*/React.createElement(Stack, {
|
|
84
|
+
spacing: 2,
|
|
85
|
+
sx: {
|
|
86
|
+
maxWidth: '300px'
|
|
87
|
+
}
|
|
88
|
+
}, RenderArea(Messages, _HandleClose)));
|
|
89
|
+
}
|
|
90
|
+
var Message = function Message(props) {
|
|
91
|
+
var _handleClose = useCallback(function () {
|
|
92
|
+
return props.handleClose(props.data);
|
|
93
|
+
}, [props]);
|
|
94
|
+
useEffect(function () {
|
|
95
|
+
var Timer = null;
|
|
96
|
+
if (props.autoDurationHide) {
|
|
97
|
+
Timer = setTimeout(function () {
|
|
98
|
+
props.handleClose(props.data);
|
|
99
|
+
}, props.autoDurationHide);
|
|
100
|
+
}
|
|
101
|
+
return function () {
|
|
102
|
+
clearTimeout(Timer);
|
|
103
|
+
};
|
|
104
|
+
}, [props]);
|
|
105
|
+
return /*#__PURE__*/React.createElement(Alert, {
|
|
106
|
+
onClose: _handleClose,
|
|
107
|
+
severity: props.data.type
|
|
108
|
+
}, props.data.text);
|
|
109
|
+
};
|
|
110
|
+
var Wrap = styled(Box)({
|
|
111
|
+
position: 'fixed',
|
|
112
|
+
top: 'calc(var(--height-header) + 20px)',
|
|
113
|
+
right: '50px',
|
|
114
|
+
zIndex: 2000,
|
|
115
|
+
display: 'flex',
|
|
116
|
+
justifyContent: 'flex-start',
|
|
117
|
+
alignItems: 'center'
|
|
118
|
+
});
|
|
119
|
+
var AlertDialog = function AlertDialog(props) {
|
|
120
|
+
var _React$useState = React.useState(props.IsOpen),
|
|
121
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
122
|
+
Open = _React$useState2[0],
|
|
123
|
+
setOpen = _React$useState2[1];
|
|
124
|
+
React.useEffect(function () {
|
|
125
|
+
setOpen(props.IsOpen);
|
|
126
|
+
}, [props.IsOpen]);
|
|
127
|
+
var _handleClose = React.useCallback(function () {
|
|
128
|
+
setOpen(false);
|
|
129
|
+
props.onClose && props.onClose();
|
|
130
|
+
}, [props]);
|
|
131
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Dialog, {
|
|
132
|
+
open: Open,
|
|
133
|
+
onClose: _handleClose,
|
|
134
|
+
"aria-labelledby": "alert-dialog-title",
|
|
135
|
+
"aria-describedby": "alert-dialog-description"
|
|
136
|
+
}, /*#__PURE__*/React.createElement(DialogTitle, {
|
|
137
|
+
id: "alert-dialog-title"
|
|
138
|
+
}, props.Title), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(DialogContentText, {
|
|
139
|
+
id: "alert-dialog-description"
|
|
140
|
+
}, props.Message)), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
|
|
141
|
+
onClick: props.onAccept,
|
|
142
|
+
autoFocus: true,
|
|
143
|
+
color: "info"
|
|
144
|
+
}, "Ok"), /*#__PURE__*/React.createElement(Button, {
|
|
145
|
+
onClick: _handleClose,
|
|
146
|
+
color: "error"
|
|
147
|
+
}, "Cancel"))));
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export { AlertDialog, ApiAlertContext, AlertGlobal as default };
|
|
151
|
+
//# sourceMappingURL=alert-global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-global.js","sources":["../../../src/api-context/alert-global.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useState } from 'react'\r\nimport { Box, Stack, styled, Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material'\r\nimport MuiAlert, { AlertProps, AlertColor } from '@mui/material/Alert'\r\n\r\nconst Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(props, ref) {\r\n return <MuiAlert elevation={6} ref={ref} variant='standard' {...props} style={{ minWidth: '300px' }} />\r\n})\r\n\r\ninterface MessageData {\r\n id: string\r\n text: string\r\n type: AlertColor\r\n duration?: number\r\n}\r\n\r\ninterface IOptions {\r\n duration?: number\r\n}\r\n\r\ninterface IApiAlert {\r\n PushMessage: (data: MessageData) => void\r\n PushInfo: (data: string) => void\r\n PushError: (data: string) => void\r\n PushWarning: (data: string) => void\r\n PushSuccess: (data: string) => void\r\n}\r\n\r\nexport interface IApiContext {\r\n ApiAlert?: IApiAlert\r\n}\r\n\r\nexport const ApiAlertContext: IApiContext = {}\r\n\r\nconst RenderArea = (messages: MessageData[], onClose: (data: MessageData) => void) => {\r\n return messages.map((x, i) => {\r\n return <Message key={x.id + i} data={x} IsOpen={true} handleClose={onClose} autoDurationHide={x.duration} />\r\n })\r\n}\r\n\r\nfunction AlertGlobal() {\r\n const [Messages, setMessages] = useState<MessageData[]>([])\r\n const _PushMessage = useCallback((data: MessageData) => {\r\n setMessages((st) => [...st, data])\r\n }, [])\r\n const _HandleClose = useCallback(\r\n (data: MessageData) => {\r\n const index = Messages.findIndex((x) => x.id === data.id)\r\n Messages.splice(index, 1)\r\n setMessages([...Messages])\r\n },\r\n [Messages]\r\n )\r\n\r\n useEffect(() => {\r\n ApiAlertContext.ApiAlert = {\r\n ...(ApiAlertContext.ApiAlert ? ApiAlertContext.ApiAlert : {}),\r\n PushMessage: _PushMessage,\r\n PushError: function (data: string, options?: IOptions) {\r\n this.PushMessage({\r\n id: new Date().getTime().toString(),\r\n text: data,\r\n type: 'error',\r\n duration: options?.duration || 15000\r\n })\r\n },\r\n PushInfo: function (data: string, options?: IOptions) {\r\n this.PushMessage({\r\n id: new Date().getTime().toString(),\r\n text: data,\r\n type: 'info',\r\n duration: options?.duration || 6000\r\n })\r\n },\r\n PushWarning: function (data: string, options?: IOptions) {\r\n this.PushMessage({\r\n id: new Date().getTime().toString(),\r\n text: data,\r\n type: 'warning',\r\n duration: options?.duration || 6000\r\n })\r\n },\r\n PushSuccess: function (data: string, options?: IOptions) {\r\n this.PushMessage({\r\n id: new Date().getTime().toString(),\r\n text: data,\r\n type: 'success',\r\n duration: options?.duration || 3000\r\n })\r\n }\r\n }\r\n }, [_PushMessage])\r\n\r\n return (\r\n <Wrap>\r\n <Stack spacing={2} sx={{ maxWidth: '300px' }}>\r\n {RenderArea(Messages, _HandleClose)}\r\n </Stack>\r\n </Wrap>\r\n )\r\n}\r\nexport default AlertGlobal\r\n\r\ninterface MessageProps {\r\n IsOpen: boolean\r\n handleClose: (data: MessageData) => void\r\n data: MessageData\r\n autoDurationHide?: number\r\n}\r\nconst Message: FC<MessageProps> = (props) => {\r\n const _handleClose = useCallback(() => props.handleClose(props.data), [props])\r\n\r\n useEffect(() => {\r\n let Timer: any = null\r\n if (props.autoDurationHide) {\r\n Timer = setTimeout(() => {\r\n props.handleClose(props.data)\r\n }, props.autoDurationHide)\r\n }\r\n return () => {\r\n clearTimeout(Timer as any)\r\n }\r\n }, [props])\r\n return (\r\n <Alert onClose={_handleClose} severity={props.data.type}>\r\n {props.data.text}\r\n </Alert>\r\n )\r\n}\r\n\r\nconst Wrap = styled(Box)({\r\n position: 'fixed',\r\n top: 'calc(var(--height-header) + 20px)',\r\n right: '50px',\r\n zIndex: 2000,\r\n display: 'flex',\r\n justifyContent: 'flex-start',\r\n alignItems: 'center'\r\n})\r\n\r\ninterface AlertDialogProps {\r\n IsOpen: boolean\r\n onClose?: () => void\r\n onAccept?: () => void\r\n Title: string\r\n Message: string\r\n}\r\nexport const AlertDialog: React.FC<AlertDialogProps> = (props) => {\r\n const [Open, setOpen] = React.useState(props.IsOpen)\r\n React.useEffect(() => {\r\n setOpen(props.IsOpen)\r\n }, [props.IsOpen])\r\n const _handleClose = React.useCallback(() => {\r\n setOpen(false)\r\n props.onClose && props.onClose()\r\n }, [props])\r\n return (\r\n <div>\r\n <Dialog open={Open} onClose={_handleClose} aria-labelledby='alert-dialog-title' aria-describedby='alert-dialog-description'>\r\n <DialogTitle id='alert-dialog-title'>{props.Title}</DialogTitle>\r\n <DialogContent>\r\n <DialogContentText id='alert-dialog-description'>{props.Message}</DialogContentText>\r\n </DialogContent>\r\n <DialogActions>\r\n <Button onClick={props.onAccept} autoFocus color='info'>\r\n Ok\r\n </Button>\r\n <Button onClick={_handleClose} color='error'>\r\n Cancel\r\n </Button>\r\n </DialogActions>\r\n </Dialog>\r\n </div>\r\n )\r\n}\r\n"],"names":["Alert","React","forwardRef","props","ref","createElement","MuiAlert","_extends","elevation","variant","style","minWidth","ApiAlertContext","RenderArea","messages","onClose","map","x","i","Message","key","id","data","IsOpen","handleClose","autoDurationHide","duration","AlertGlobal","_useState","useState","_useState2","_slicedToArray","Messages","setMessages","_PushMessage","useCallback","st","concat","_toConsumableArray","_HandleClose","index","findIndex","splice","useEffect","ApiAlert","Object","assign","PushMessage","PushError","options","Date","getTime","toString","text","type","PushInfo","PushWarning","PushSuccess","Wrap","Stack","spacing","sx","maxWidth","_handleClose","Timer","setTimeout","clearTimeout","severity","styled","Box","position","top","right","zIndex","display","justifyContent","alignItems","AlertDialog","_React$useState","_React$useState2","Open","setOpen","Dialog","open","DialogTitle","Title","DialogContent","DialogContentText","DialogActions","Button","onClick","onAccept","autoFocus","color"],"mappings":";;;;;AAIA,IAAMA,KAAK,gBAAGC,KAAK,CAACC,UAAU,CAA6B,SAASF,KAAKA,CAACG,KAAK,EAAEC,GAAG,EAAA;AAClF,EAAA,oBAAOH,KAAA,CAAAI,aAAA,CAACC,QAAQ,EAAAC,QAAA,CAAA;AAACC,IAAAA,SAAS,EAAE,CAAE;AAACJ,IAAAA,GAAG,EAAEA,GAAI;AAACK,IAAAA,OAAO,EAAC;AAAU,GAAA,EAAKN,KAAK,EAAA;AAAEO,IAAAA,KAAK,EAAE;AAAEC,MAAAA,QAAQ,EAAE;AAAS;AAAC,GAAA,EAAG;AACzG,CA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+1,105 @@
|
|
|
1
|
+
import { defineProperty as _defineProperty, inherits as _inherits, createClass as _createClass, classCallCheck as _classCallCheck, callSuper as _callSuper } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { styled, Box, Drawer, IconButton, Divider, Typography } from '@mui/material';
|
|
4
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
5
|
+
|
|
6
|
+
var drawerGlobalClasses = {
|
|
7
|
+
root: 'DrawerGlobal-root',
|
|
8
|
+
title: 'DrawerGlobal-title',
|
|
9
|
+
content: 'DrawerGlobal-content',
|
|
10
|
+
fullHeight: 'DrawerGlobal-fullHeight'
|
|
11
|
+
};
|
|
12
|
+
var DrawerGlobalApi = {
|
|
13
|
+
close: function close() {
|
|
14
|
+
console.warn('DrawerGlobal provider not found!');
|
|
15
|
+
},
|
|
16
|
+
open: function open() {
|
|
17
|
+
console.warn('DrawerGlobal provider not found!');
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var DrawerGlobalProvider = /*#__PURE__*/function (_Component) {
|
|
21
|
+
function DrawerGlobalProvider(props) {
|
|
22
|
+
var _this;
|
|
23
|
+
_classCallCheck(this, DrawerGlobalProvider);
|
|
24
|
+
_this = _callSuper(this, DrawerGlobalProvider, [props]);
|
|
25
|
+
_this.close = function (reason) {
|
|
26
|
+
if (_this.state.backdropClickeable === false && reason === 'backdropClick') return;
|
|
27
|
+
_this.setState({
|
|
28
|
+
renderContent: undefined
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
_this.open = function (state) {
|
|
32
|
+
return _this.setState(state);
|
|
33
|
+
};
|
|
34
|
+
_this.renderTitle = function () {
|
|
35
|
+
if (typeof _this.state.title === 'string') {
|
|
36
|
+
return /*#__PURE__*/React.createElement(Typography, {
|
|
37
|
+
variant: "h6",
|
|
38
|
+
noWrap: true
|
|
39
|
+
}, _this.state.title);
|
|
40
|
+
}
|
|
41
|
+
return _this.state.title;
|
|
42
|
+
};
|
|
43
|
+
_this.getClasses = function () {
|
|
44
|
+
var classes = [drawerGlobalClasses.root];
|
|
45
|
+
if (_this.state.fullHeight) classes.push(drawerGlobalClasses.fullHeight);
|
|
46
|
+
return classes.join(' ');
|
|
47
|
+
};
|
|
48
|
+
_this.state = {};
|
|
49
|
+
return _this;
|
|
50
|
+
}
|
|
51
|
+
_inherits(DrawerGlobalProvider, _Component);
|
|
52
|
+
return _createClass(DrawerGlobalProvider, [{
|
|
53
|
+
key: "componentDidMount",
|
|
54
|
+
value: function componentDidMount() {
|
|
55
|
+
DrawerGlobalApi.open = this.open;
|
|
56
|
+
DrawerGlobalApi.close = this.close;
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "render",
|
|
60
|
+
value: function render() {
|
|
61
|
+
var _this2 = this;
|
|
62
|
+
return /*#__PURE__*/React.createElement(Drawer, {
|
|
63
|
+
anchor: this.state.anchor,
|
|
64
|
+
open: Boolean(this.state.renderContent),
|
|
65
|
+
onClose: function onClose(_, reason) {
|
|
66
|
+
return _this2.close(reason);
|
|
67
|
+
}
|
|
68
|
+
}, /*#__PURE__*/React.createElement(Wrap, {
|
|
69
|
+
className: this.getClasses()
|
|
70
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: drawerGlobalClasses.title
|
|
72
|
+
}, this.state.icon, this.renderTitle(), /*#__PURE__*/React.createElement(Box, {
|
|
73
|
+
sx: {
|
|
74
|
+
flex: 1
|
|
75
|
+
}
|
|
76
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
77
|
+
onClick: function onClick() {
|
|
78
|
+
return _this2.close();
|
|
79
|
+
}
|
|
80
|
+
}, /*#__PURE__*/React.createElement(CloseIcon, null))), /*#__PURE__*/React.createElement(Divider, {
|
|
81
|
+
variant: "middle"
|
|
82
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
className: drawerGlobalClasses.content
|
|
84
|
+
}, this.state.renderContent && this.state.renderContent())));
|
|
85
|
+
}
|
|
86
|
+
}]);
|
|
87
|
+
}(Component);
|
|
88
|
+
var DrawerGlobal = {
|
|
89
|
+
Provider: DrawerGlobalProvider,
|
|
90
|
+
Api: DrawerGlobalApi
|
|
91
|
+
};
|
|
92
|
+
var Wrap = styled(Box)(_defineProperty(_defineProperty({
|
|
93
|
+
'--height-title': '56px'
|
|
94
|
+
}, ".".concat(drawerGlobalClasses.title), {
|
|
95
|
+
display: 'flex',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
height: 'var(--height-title)',
|
|
98
|
+
padding: '0 12px',
|
|
99
|
+
gap: '6px'
|
|
100
|
+
}), "&.".concat(drawerGlobalClasses.fullHeight), _defineProperty({}, ".".concat(drawerGlobalClasses.content), {
|
|
101
|
+
height: 'calc(100vh - var(--height-title) - 60px)'
|
|
102
|
+
})));
|
|
103
|
+
|
|
104
|
+
export { DrawerGlobal as default };
|
|
105
|
+
//# sourceMappingURL=drawer-global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-global.js","sources":["../../../src/api-context/drawer-global.tsx"],"sourcesContent":["import React, { Component, ReactNode } from 'react'\r\nimport { Box, Divider, Drawer, DrawerProps, IconButton, styled, Typography } from '@mui/material'\r\nimport CloseIcon from '@mui/icons-material/Close'\r\n\r\nconst drawerGlobalClasses = {\r\n root: 'DrawerGlobal-root',\r\n title: 'DrawerGlobal-title',\r\n content: 'DrawerGlobal-content',\r\n fullHeight: 'DrawerGlobal-fullHeight'\r\n}\r\n\r\ninterface IProps {}\r\n\r\ninterface IState {\r\n title?: ReactNode\r\n icon?: ReactNode\r\n fullHeight?: boolean\r\n anchor?: DrawerProps['anchor']\r\n /** @default true */\r\n backdropClickeable?: boolean\r\n renderContent?: () => ReactNode\r\n}\r\n\r\ntype TReason = 'backdropClick' | 'escapeKeyDown'\r\n\r\ninterface DrawerGlobalApiType {\r\n open: (state: IState) => void\r\n close: (reason?: TReason) => void\r\n}\r\n\r\nconst DrawerGlobalApi: DrawerGlobalApiType = {\r\n close: () => {\r\n console.warn('DrawerGlobal provider not found!')\r\n },\r\n open: () => {\r\n console.warn('DrawerGlobal provider not found!')\r\n }\r\n}\r\n\r\nclass DrawerGlobalProvider extends Component<IProps, IState> {\r\n constructor(props: IProps) {\r\n super(props)\r\n this.state = {}\r\n }\r\n\r\n close = (reason?: TReason) => {\r\n if (this.state.backdropClickeable === false && reason === 'backdropClick') return\r\n this.setState({ renderContent: undefined })\r\n }\r\n\r\n open = (state: IState) => this.setState(state)\r\n\r\n componentDidMount() {\r\n DrawerGlobalApi.open = this.open\r\n DrawerGlobalApi.close = this.close\r\n }\r\n\r\n render() {\r\n return (\r\n <Drawer anchor={this.state.anchor} open={Boolean(this.state.renderContent)} onClose={(_, reason) => this.close(reason)}>\r\n <Wrap className={this.getClasses()}>\r\n <div className={drawerGlobalClasses.title}>\r\n {this.state.icon}\r\n {this.renderTitle()}\r\n <Box sx={{ flex: 1 }} />\r\n <IconButton onClick={() => this.close()}>\r\n <CloseIcon />\r\n </IconButton>\r\n </div>\r\n <Divider variant='middle' />\r\n <div className={drawerGlobalClasses.content}>{this.state.renderContent && this.state.renderContent()}</div>\r\n </Wrap>\r\n </Drawer>\r\n )\r\n }\r\n\r\n renderTitle = () => {\r\n if (typeof this.state.title === 'string') {\r\n return (\r\n <Typography variant='h6' noWrap>\r\n {this.state.title}\r\n </Typography>\r\n )\r\n }\r\n return this.state.title\r\n }\r\n\r\n getClasses = () => {\r\n const classes = [drawerGlobalClasses.root]\r\n if (this.state.fullHeight) classes.push(drawerGlobalClasses.fullHeight)\r\n return classes.join(' ')\r\n }\r\n}\r\n\r\nconst DrawerGlobal = {\r\n Provider: DrawerGlobalProvider,\r\n Api: DrawerGlobalApi\r\n}\r\n\r\nexport default DrawerGlobal\r\n\r\nconst Wrap = styled(Box)({\r\n '--height-title': '56px',\r\n [`.${drawerGlobalClasses.title}`]: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n height: 'var(--height-title)',\r\n padding: '0 12px',\r\n gap: '6px'\r\n },\r\n [`&.${drawerGlobalClasses.fullHeight}`]: {\r\n [`.${drawerGlobalClasses.content}`]: {\r\n height: 'calc(100vh - var(--height-title) - 60px)'\r\n }\r\n }\r\n})\r\n"],"names":["drawerGlobalClasses","root","title","content","fullHeight","DrawerGlobalApi","close","console","warn","open","DrawerGlobalProvider","_Component","props","_this","_classCallCheck","_callSuper","reason","state","backdropClickeable","setState","renderContent","undefined","renderTitle","React","createElement","Typography","variant","noWrap","getClasses","classes","push","join","_inherits","_createClass","key","value","componentDidMount","render","_this2","Drawer","anchor","Boolean","onClose","_","Wrap","className","icon","Box","sx","flex","IconButton","onClick","CloseIcon","Divider","Component","DrawerGlobal","Provider","Api","styled","_defineProperty","concat","display","alignItems","height","padding","gap"],"mappings":";;;;;AAIA,IAAMA,mBAAmB,GAAG;AAC1BC,EAAAA,IAAI,EAAE,mBAAmB;AACzBC,EAAAA,KAAK,EAAE,oBAAoB;AAC3BC,EAAAA,OAAO,EAAE,sBAAsB;AAC/BC,EAAAA,UAAU,EAAE;CACb;AAqBD,IAAMC,eAAe,GAAwB;AAC3CC,EAAAA,KAAK,EAAE,SAAPA,KAAKA,GAAO;AACVC,IAAAA,OAAO,CAACC,IAAI,CAAC,kCAAkC,CAAC;GACjD;AACDC,EAAAA,IAAI,EAAE,SAANA,IAAIA,GAAO;AACTF,IAAAA,OAAO,CAACC,IAAI,CAAC,kCAAkC,CAAC;AAClD;CACD;AAAA,IAEKE,oBAAqB,0BAAAC,UAAA,EAAA;EACzB,SAAAD,oBAAAA,CAAYE,KAAa,EAAA;AAAA,IAAA,IAAAC,KAAA;AAAAC,IAAAA,eAAA,OAAAJ,oBAAA,CAAA;AACvBG,IAAAA,KAAA,GAAAE,UAAA,CAAAL,IAAAA,EAAAA,oBAAA,GAAME,KAAK,CAAA,CAAA;AAIbC,IAAAA,KAAA,CAAAP,KAAK,GAAG,UAACU,MAAgB,EAAI;MAC3B,IAAIH,KAAA,CAAKI,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,KAAA,EAAA;QAAKqB,SAAS,EAAE7C,mBAAmB,CAACG;AAAQ,OAAA,EAAE,IAAI,CAACc,KAAK,CAACG,aAAa,IAAI,IAAI,CAACH,KAAK,CAACG,aAAa,EAAQ,CACtG,CACA,CAAC;AAEb;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA,CAnCgCkC,SAAyB,CAAA;AAuD5D,IAAMC,YAAY,GAAG;AACnBC,EAAAA,QAAQ,EAAE9C,oBAAoB;AAC9B+C,EAAAA,GAAG,EAAEpD;;AAKP,IAAMuC,IAAI,GAAGc,MAAM,CAACX,GAAG,CAAC,CAAAY,eAAA,CAAAA,eAAA,CAAA;AACtB,EAAA,gBAAgB,EAAE;AAAM,CAAA,EAAA,GAAA,CAAAC,MAAA,CACnB5D,mBAAmB,CAACE,KAAK,CAAK,EAAA;AACjC2D,EAAAA,OAAO,EAAE,MAAM;AACfC,EAAAA,UAAU,EAAE,QAAQ;AACpBC,EAAAA,MAAM,EAAE,qBAAqB;AAC7BC,EAAAA,OAAO,EAAE,QAAQ;AACjBC,EAAAA,GAAG,EAAE;AACN,CAAA,CAAAL,EAAAA,IAAAA,CAAAA,MAAA,CACK5D,mBAAmB,CAACI,UAAU,CAAA,EAAAuD,eAAA,CAAA,EAAA,EAAA,GAAA,CAAAC,MAAA,CAC7B5D,mBAAmB,CAACG,OAAO,CAAK,EAAA;AACnC4D,EAAAA,MAAM,EAAE;AACT,CAAA,EAEJ,CAAC;;;;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { inherits as _inherits, createClass as _createClass, classCallCheck as _classCallCheck, callSuper as _callSuper, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { styled, Box, Modal, Backdrop } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
var GlobalModalContext = /*#__PURE__*/React.createContext({
|
|
6
|
+
close: function close() {
|
|
7
|
+
console.warn('GlobalModal provider not found!');
|
|
8
|
+
},
|
|
9
|
+
show: function show() {
|
|
10
|
+
console.warn('GlobalModal provider not found!');
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var MapGlobalModalContext = function MapGlobalModalContext(context) {
|
|
14
|
+
return /*#__PURE__*/React.createElement(GlobalModalContext.Consumer, null, context);
|
|
15
|
+
};
|
|
16
|
+
var GlobalModal = /*#__PURE__*/function (_Component) {
|
|
17
|
+
function GlobalModal(props) {
|
|
18
|
+
var _this;
|
|
19
|
+
_classCallCheck(this, GlobalModal);
|
|
20
|
+
_this = _callSuper(this, GlobalModal, [props]);
|
|
21
|
+
_this.show = function (value) {
|
|
22
|
+
_this.setState(value);
|
|
23
|
+
};
|
|
24
|
+
_this.close = function (_, reason) {
|
|
25
|
+
if (reason === 'backdropClick' && _this.state.backdropActivated === false) return;
|
|
26
|
+
_this.setState({
|
|
27
|
+
renderContent: undefined
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
_this.renderContent = function () {
|
|
31
|
+
return _this.state.renderContent ? _this.state.renderContent() : /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
32
|
+
};
|
|
33
|
+
_this.state = {};
|
|
34
|
+
return _this;
|
|
35
|
+
}
|
|
36
|
+
_inherits(GlobalModal, _Component);
|
|
37
|
+
return _createClass(GlobalModal, [{
|
|
38
|
+
key: "render",
|
|
39
|
+
value: function render() {
|
|
40
|
+
return /*#__PURE__*/React.createElement(GlobalModalContext.Provider, {
|
|
41
|
+
value: this
|
|
42
|
+
}, this.props.children, /*#__PURE__*/React.createElement(Modal, {
|
|
43
|
+
open: !!this.state.renderContent,
|
|
44
|
+
onClose: this.close,
|
|
45
|
+
slots: {
|
|
46
|
+
backdrop: Backdrop
|
|
47
|
+
},
|
|
48
|
+
slotProps: {
|
|
49
|
+
backdrop: {
|
|
50
|
+
timeout: 300
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
sx: this.state.sx
|
|
54
|
+
}, /*#__PURE__*/React.createElement(Wrapper, {
|
|
55
|
+
sx: this.state.sxWrap
|
|
56
|
+
}, this.renderContent())));
|
|
57
|
+
}
|
|
58
|
+
}]);
|
|
59
|
+
}(Component);
|
|
60
|
+
var Wrapper = styled(Box)({
|
|
61
|
+
position: 'absolute',
|
|
62
|
+
top: '50%',
|
|
63
|
+
left: '50%',
|
|
64
|
+
transform: 'translate(-50%, -50%)',
|
|
65
|
+
outline: 'none'
|
|
66
|
+
});
|
|
67
|
+
var withApiGlobalModalContext = function withApiGlobalModalContext(Component) {
|
|
68
|
+
return function (props) {
|
|
69
|
+
return /*#__PURE__*/React.createElement(GlobalModal, null, MapGlobalModalContext(function (context) {
|
|
70
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
71
|
+
contextGlobalModal: context
|
|
72
|
+
}));
|
|
73
|
+
}));
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
var withApiGlobalModalConsumerContext = function withApiGlobalModalConsumerContext(Component) {
|
|
77
|
+
return function (props) {
|
|
78
|
+
return MapGlobalModalContext(function (context) {
|
|
79
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
80
|
+
contextGlobalModal: context
|
|
81
|
+
}));
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { GlobalModalContext, MapGlobalModalContext, GlobalModal as default, withApiGlobalModalConsumerContext, withApiGlobalModalContext };
|
|
87
|
+
//# sourceMappingURL=global-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-modal.js","sources":["../../../src/api-context/global-modal.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport { Backdrop, Box, Modal, SxProps, styled } from '@mui/material'\r\n\r\nexport interface GlobalModalState {\r\n sx?: SxProps\r\n sxWrap?: SxProps\r\n /** @default true */\r\n backdropActivated?: boolean\r\n onClose?: (reason?: TModalReason) => void\r\n renderContent?: () => React.ReactNode\r\n}\r\n\r\nexport type TModalReason = 'backdropClick' | 'escapeKeyDown'\r\n\r\ninterface GlobalModalProps {}\r\n\r\nexport type TShowModal = (value: GlobalModalState) => void\r\n\r\nexport type TCloseModal = (event?: {}, reason?: TModalReason) => void\r\n\r\nexport interface IGlobalModalContext {\r\n show: TShowModal\r\n close: TCloseModal\r\n}\r\n\r\nexport const GlobalModalContext = React.createContext<IGlobalModalContext>({\r\n close: () => {\r\n console.warn('GlobalModal provider not found!')\r\n },\r\n show: () => {\r\n console.warn('GlobalModal provider not found!')\r\n }\r\n})\r\n\r\nexport interface IMapGlobalModal {\r\n context: IGlobalModalContext\r\n}\r\n\r\nexport const MapGlobalModalContext = (context: (state: IGlobalModalContext) => React.ReactNode) => (\r\n <GlobalModalContext.Consumer>{context}</GlobalModalContext.Consumer>\r\n)\r\n\r\nclass GlobalModal extends Component<React.PropsWithChildren<GlobalModalProps>, GlobalModalState> implements IGlobalModalContext {\r\n constructor(props: any) {\r\n super(props)\r\n this.state = {}\r\n }\r\n\r\n show: TShowModal = (value) => {\r\n this.setState(value)\r\n }\r\n\r\n close: TCloseModal = (_, reason) => {\r\n if (reason === 'backdropClick' && this.state.backdropActivated === false) return\r\n this.setState({ renderContent: undefined })\r\n }\r\n\r\n render() {\r\n return (\r\n <GlobalModalContext.Provider value={this}>\r\n {this.props.children}\r\n <Modal\r\n open={!!this.state.renderContent}\r\n onClose={this.close}\r\n slots={{ backdrop: Backdrop }}\r\n slotProps={{ backdrop: { timeout: 300 } }}\r\n sx={this.state.sx}\r\n >\r\n <Wrapper sx={this.state.sxWrap}>{this.renderContent()}</Wrapper>\r\n </Modal>\r\n </GlobalModalContext.Provider>\r\n )\r\n }\r\n\r\n renderContent = (): React.ReactNode => {\r\n return this.state.renderContent ? this.state.renderContent() : <></>\r\n }\r\n}\r\nexport default GlobalModal\r\n\r\nconst Wrapper = styled(Box)({\r\n position: 'absolute',\r\n top: '50%',\r\n left: '50%',\r\n transform: 'translate(-50%, -50%)',\r\n outline: 'none'\r\n})\r\n\r\nexport interface IApiGlobalModalContextProps {\r\n contextGlobalModal: IGlobalModalContext\r\n}\r\n\r\nexport const withApiGlobalModalContext = <P extends IApiGlobalModalContextProps>(Component: React.ComponentType<P>) => {\r\n return (props: Omit<P, keyof IApiGlobalModalContextProps>) => {\r\n return (\r\n <GlobalModal>\r\n {MapGlobalModalContext((context) => (\r\n <Component {...(props as P)} contextGlobalModal={context} />\r\n ))}\r\n </GlobalModal>\r\n )\r\n }\r\n}\r\n\r\nexport const withApiGlobalModalConsumerContext = <P extends IApiGlobalModalContextProps>(Component: React.ComponentType<P>) => {\r\n return (props: Omit<P, keyof IApiGlobalModalContextProps>) => {\r\n return MapGlobalModalContext((context) => <Component {...(props as P)} contextGlobalModal={context} />)\r\n }\r\n}\r\n"],"names":["GlobalModalContext","React","createContext","close","console","warn","show","MapGlobalModalContext","context","createElement","Consumer","GlobalModal","_Component","props","_this","_classCallCheck","_callSuper","value","setState","_","reason","state","backdropActivated","renderContent","undefined","Fragment","_inherits","_createClass","key","render","Provider","children","Modal","open","onClose","slots","backdrop","Backdrop","slotProps","timeout","sx","Wrapper","sxWrap","Component","styled","Box","position","top","left","transform","outline","withApiGlobalModalContext","_extends","contextGlobalModal","withApiGlobalModalConsumerContext"],"mappings":";;;;IAyBaA,kBAAkB,gBAAGC,KAAK,CAACC,aAAa,CAAsB;AACzEC,EAAAA,KAAK,EAAE,SAAPA,KAAKA,GAAO;AACVC,IAAAA,OAAO,CAACC,IAAI,CAAC,iCAAiC,CAAC;GAChD;AACDC,EAAAA,IAAI,EAAE,SAANA,IAAIA,GAAO;AACTF,IAAAA,OAAO,CAACC,IAAI,CAAC,iCAAiC,CAAC;AACjD;AACD,CAAA;IAMYE,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAIC,OAAwD,EAAA;EAAA,oBAC5FP,KAAA,CAAAQ,aAAA,CAACT,kBAAkB,CAACU,QAAQ,EAAEF,IAAAA,EAAAA,OAAqC,CAAC;AAAA;AAGhEG,IAAAA,WAAY,0BAA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iD,EAAI;IAC3D,OAAON,qBAAqB,CAAC,UAACC,OAAO,EAAA;MAAA,oBAAKP,KAAA,CAAAQ,aAAA,CAACkC,SAAS,EAAAS,QAAA,KAAMvC,KAAW,EAAA;AAAEwC,QAAAA,kBAAkB,EAAE7C;AAAQ,OAAA,CAAG,CAAA;KAAC,CAAA;GACxG;AACH;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { inherits as _inherits, createClass as _createClass, extends as _extends, classCallCheck as _classCallCheck, callSuper as _callSuper } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { Popover } from '@mui/material';
|
|
4
|
+
import { ContentDefault } from './ui.units.js';
|
|
5
|
+
|
|
6
|
+
var PopoverGlobalApi = {
|
|
7
|
+
open: function open() {
|
|
8
|
+
console.warn('PopoverGlobal provider not found!');
|
|
9
|
+
},
|
|
10
|
+
close: function close() {
|
|
11
|
+
console.warn('PopoverGlobal provider not found!');
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var PopoverGlobalContext = /*#__PURE__*/React.createContext(PopoverGlobalApi);
|
|
15
|
+
var MapPopoverGlobalContext = function MapPopoverGlobalContext(context) {
|
|
16
|
+
return /*#__PURE__*/React.createElement(PopoverGlobalContext.Consumer, null, context);
|
|
17
|
+
};
|
|
18
|
+
var PopoverGlobalProvider = /*#__PURE__*/function (_Component) {
|
|
19
|
+
function PopoverGlobalProvider(props) {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, PopoverGlobalProvider);
|
|
22
|
+
_this = _callSuper(this, PopoverGlobalProvider, [props]);
|
|
23
|
+
_this.openPopover = function (option) {
|
|
24
|
+
clearTimeout(_this.timer);
|
|
25
|
+
_this.setState(Object.assign({}, option));
|
|
26
|
+
};
|
|
27
|
+
_this.closePopover = function () {
|
|
28
|
+
clearTimeout(_this.timer);
|
|
29
|
+
_this.setState({
|
|
30
|
+
anchorEl: null
|
|
31
|
+
}, function () {
|
|
32
|
+
_this.timer = setTimeout(function () {
|
|
33
|
+
_this.setState({
|
|
34
|
+
content: /*#__PURE__*/React.createElement(ContentDefault, null)
|
|
35
|
+
});
|
|
36
|
+
}, 500);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
_this.state = {
|
|
40
|
+
anchorEl: null,
|
|
41
|
+
content: /*#__PURE__*/React.createElement(ContentDefault, null)
|
|
42
|
+
};
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
_inherits(PopoverGlobalProvider, _Component);
|
|
46
|
+
return _createClass(PopoverGlobalProvider, [{
|
|
47
|
+
key: "componentDidMount",
|
|
48
|
+
value: function componentDidMount() {
|
|
49
|
+
PopoverGlobalApi.open = this.openPopover;
|
|
50
|
+
PopoverGlobalApi.close = this.closePopover;
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "render",
|
|
54
|
+
value: function render() {
|
|
55
|
+
var _this2 = this;
|
|
56
|
+
return /*#__PURE__*/React.createElement(PopoverGlobalContext.Provider, {
|
|
57
|
+
value: {
|
|
58
|
+
open: this.openPopover,
|
|
59
|
+
close: this.closePopover
|
|
60
|
+
}
|
|
61
|
+
}, this.props.children, /*#__PURE__*/React.createElement(Popover, _extends({
|
|
62
|
+
sx: {
|
|
63
|
+
'& .MuiPaper-root.MuiPaper-elevation': {
|
|
64
|
+
overflow: 'hidden'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
anchorEl: this.state.anchorEl,
|
|
68
|
+
open: Boolean(this.state.anchorEl),
|
|
69
|
+
onClose: function onClose(_, reason) {
|
|
70
|
+
return _this2.closePopover(reason);
|
|
71
|
+
},
|
|
72
|
+
anchorOrigin: {
|
|
73
|
+
vertical: 'bottom',
|
|
74
|
+
horizontal: 'right'
|
|
75
|
+
},
|
|
76
|
+
transformOrigin: {
|
|
77
|
+
vertical: 'top',
|
|
78
|
+
horizontal: 'right'
|
|
79
|
+
},
|
|
80
|
+
disableScrollLock: true
|
|
81
|
+
}, this.state.popoverProps), this.state.content));
|
|
82
|
+
}
|
|
83
|
+
}]);
|
|
84
|
+
}(Component);
|
|
85
|
+
var withPopoverGlobalContext = function withPopoverGlobalContext(Component) {
|
|
86
|
+
return function (props) {
|
|
87
|
+
return /*#__PURE__*/React.createElement(PopoverGlobalProvider, null, MapPopoverGlobalContext(function (context) {
|
|
88
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
89
|
+
contextPopover: context
|
|
90
|
+
}));
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
var PopoverGlobal = {
|
|
95
|
+
Provider: PopoverGlobalProvider,
|
|
96
|
+
Api: PopoverGlobalApi,
|
|
97
|
+
Context: PopoverGlobalContext,
|
|
98
|
+
mapContext: MapPopoverGlobalContext
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { MapPopoverGlobalContext, PopoverGlobalApi, PopoverGlobalContext, PopoverGlobalProvider, PopoverGlobal as default, withPopoverGlobalContext };
|
|
102
|
+
//# sourceMappingURL=popover-global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover-global.js","sources":["../../../src/api-context/popover-global.tsx"],"sourcesContent":["import React, { Component, PropsWithChildren } from 'react'\r\nimport { Popover, PopoverProps, PopoverVirtualElement } from '@mui/material'\r\nimport { ContentDefault } from './ui.units'\r\n\r\nexport interface PopoverGlobalState {\r\n anchorEl?: Element | (() => Element) | PopoverVirtualElement | (() => PopoverVirtualElement) | null\r\n popoverProps?: Omit<PopoverProps, 'open'>\r\n content: React.ReactNode\r\n}\r\n\r\nexport type OpenPopover = (value: PopoverGlobalState) => void\r\n\r\nexport type ClosePopover = (reason?: 'backdropClick' | 'escapeKeyDown') => void\r\n\r\nexport interface PopoverGlobalContext {\r\n open: OpenPopover\r\n close: ClosePopover\r\n}\r\n\r\nexport const PopoverGlobalApi: PopoverGlobalContext = {\r\n open: () => {\r\n console.warn('PopoverGlobal provider not found!')\r\n },\r\n close: () => {\r\n console.warn('PopoverGlobal provider not found!')\r\n }\r\n}\r\n\r\nexport const PopoverGlobalContext = React.createContext<PopoverGlobalContext>(PopoverGlobalApi)\r\n\r\nexport const MapPopoverGlobalContext = (context: (state: PopoverGlobalContext) => React.ReactNode) => (\r\n <PopoverGlobalContext.Consumer>{context}</PopoverGlobalContext.Consumer>\r\n)\r\n\r\ninterface IProps extends PropsWithChildren {}\r\n\r\nexport class PopoverGlobalProvider extends Component<IProps, PopoverGlobalState> {\r\n constructor(props: any) {\r\n super(props)\r\n this.state = { anchorEl: null, content: <ContentDefault /> }\r\n }\r\n\r\n componentDidMount() {\r\n PopoverGlobalApi.open = this.openPopover\r\n PopoverGlobalApi.close = this.closePopover\r\n }\r\n\r\n render() {\r\n return (\r\n <PopoverGlobalContext.Provider value={{ open: this.openPopover, close: this.closePopover }}>\r\n {this.props.children}\r\n <Popover\r\n sx={{ '& .MuiPaper-root.MuiPaper-elevation': { overflow: 'hidden' } }}\r\n anchorEl={this.state.anchorEl}\r\n open={Boolean(this.state.anchorEl)}\r\n onClose={(_, reason) => this.closePopover(reason)}\r\n anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}\r\n transformOrigin={{ vertical: 'top', horizontal: 'right' }}\r\n disableScrollLock\r\n {...this.state.popoverProps}\r\n >\r\n {this.state.content}\r\n </Popover>\r\n </PopoverGlobalContext.Provider>\r\n )\r\n }\r\n\r\n openPopover: OpenPopover = (option) => {\r\n clearTimeout(this.timer)\r\n this.setState({ ...option })\r\n }\r\n\r\n timer: any\r\n closePopover: ClosePopover = () => {\r\n clearTimeout(this.timer)\r\n this.setState({ anchorEl: null }, () => {\r\n this.timer = setTimeout(() => {\r\n this.setState({ content: <ContentDefault /> })\r\n }, 500)\r\n })\r\n }\r\n}\r\n\r\nexport interface IPopoverGlobalContextProps {\r\n contextPopover: PopoverGlobalContext\r\n}\r\n\r\nexport const withPopoverGlobalContext = <P extends IPopoverGlobalContextProps>(Component: React.ComponentType<P>) => {\r\n return (props: Omit<P, keyof IPopoverGlobalContextProps>) => {\r\n return (\r\n <PopoverGlobalProvider>\r\n {MapPopoverGlobalContext((context) => (\r\n <Component {...(props as P)} contextPopover={context} />\r\n ))}\r\n </PopoverGlobalProvider>\r\n )\r\n }\r\n}\r\n\r\nconst PopoverGlobal = {\r\n Provider: PopoverGlobalProvider,\r\n Api: PopoverGlobalApi,\r\n Context: PopoverGlobalContext,\r\n mapContext: MapPopoverGlobalContext\r\n}\r\n\r\nexport default PopoverGlobal\r\n"],"names":["PopoverGlobalApi","open","console","warn","close","PopoverGlobalContext","React","createContext","MapPopoverGlobalContext","context","createElement","Consumer","PopoverGlobalProvider","_Component","props","_this","_classCallCheck","_callSuper","openPopover","option","clearTimeout","timer","setState","Object","assign","closePopover","anchorEl","setTimeout","content","ContentDefault","state","_inherits","_createClass","key","value","componentDidMount","render","_this2","Provider","children","Popover","_extends","sx","overflow","Boolean","onClose","_","reason","anchorOrigin","vertical","horizontal","transformOrigin","disableScrollLock","popoverProps","Component","withPopoverGlobalContext","contextPopover","PopoverGlobal","Api","Context","mapContext"],"mappings":";;;;;AAmBO,IAAMA,gBAAgB,GAAyB;AACpDC,EAAAA,IAAI,EAAE,SAANA,IAAIA,GAAO;AACTC,IAAAA,OAAO,CAACC,IAAI,CAAC,mCAAmC,CAAC;GAClD;AACDC,EAAAA,KAAK,EAAE,SAAPA,KAAKA,GAAO;AACVF,IAAAA,OAAO,CAACC,IAAI,CAAC,mCAAmC,CAAC;AACnD;;AAGK,IAAME,oBAAoB,gBAAGC,KAAK,CAACC,aAAa,CAAuBP,gBAAgB;IAEjFQ,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAAIC,OAAyD,EAAA;EAAA,oBAC/FH,KAAA,CAAAI,aAAA,CAACL,oBAAoB,CAACM,QAAQ,EAAEF,IAAAA,EAAAA,OAAuC,CAAC;AAAA;AAK7DG,IAAAA,qBAAsB,0BAAAC,UAAA,EAAA;EACjC,SAAAD,q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G,SAA3BA,wBAAwBA,CAA0CD,SAAiC,EAAI;EAClH,OAAO,UAACxC,KAAgD,EAAI;IAC1D,oBACER,KAAA,CAAAI,aAAA,CAACE,qBAAqB,EACnBJ,IAAAA,EAAAA,uBAAuB,CAAC,UAACC,OAAO,EAAA;MAAA,oBAC/BH,KAAA,CAAAI,aAAA,CAAC4C,SAAS,EAAAb,QAAA,KAAM3B,KAAW,EAAA;AAAE0C,QAAAA,cAAc,EAAE/C;AAAQ,OAAA,CAAA,CAAG;AAAA,KACzD,CACoB,CAAC;GAE3B;AACH;AAEA,IAAMgD,aAAa,GAAG;AACpBnB,EAAAA,QAAQ,EAAE1B,qBAAqB;AAC/B8C,EAAAA,GAAG,EAAE1D,gBAAgB;AACrB2D,EAAAA,OAAO,EAAEtD,oBAAoB;AAC7BuD,EAAAA,UAAU,EAAEpD;;;;;"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { inherits as _inherits, createClass as _createClass, extends as _extends, classCallCheck as _classCallCheck, callSuper as _callSuper } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { Popover } from '@mui/material';
|
|
4
|
+
import { ContentDefault } from './ui.units.js';
|
|
5
|
+
|
|
6
|
+
var ApiPopoverContext = /*#__PURE__*/React.createContext({
|
|
7
|
+
showPopover: function showPopover() {
|
|
8
|
+
console.warn('ApiPopover provider not found!');
|
|
9
|
+
},
|
|
10
|
+
closePopover: function closePopover() {
|
|
11
|
+
console.warn('ApiPopover provider not found!');
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var MapApiPopoverContext = function MapApiPopoverContext(context) {
|
|
15
|
+
return /*#__PURE__*/React.createElement(ApiPopoverContext.Consumer, null, context);
|
|
16
|
+
};
|
|
17
|
+
var ApiPopover = /*#__PURE__*/function (_Component) {
|
|
18
|
+
function ApiPopover(props) {
|
|
19
|
+
var _this;
|
|
20
|
+
_classCallCheck(this, ApiPopover);
|
|
21
|
+
_this = _callSuper(this, ApiPopover, [props]);
|
|
22
|
+
_this.showPopover = function (option) {
|
|
23
|
+
clearTimeout(_this.timer);
|
|
24
|
+
_this.setState(Object.assign({}, option));
|
|
25
|
+
};
|
|
26
|
+
_this.closePopover = function () {
|
|
27
|
+
clearTimeout(_this.timer);
|
|
28
|
+
_this.setState({
|
|
29
|
+
anchorEl: null
|
|
30
|
+
}, function () {
|
|
31
|
+
_this.timer = setTimeout(function () {
|
|
32
|
+
_this.setState({
|
|
33
|
+
content: /*#__PURE__*/React.createElement(ContentDefault, null)
|
|
34
|
+
});
|
|
35
|
+
}, 500);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
_this.state = {
|
|
39
|
+
anchorEl: null,
|
|
40
|
+
content: /*#__PURE__*/React.createElement(ContentDefault, null)
|
|
41
|
+
};
|
|
42
|
+
return _this;
|
|
43
|
+
}
|
|
44
|
+
_inherits(ApiPopover, _Component);
|
|
45
|
+
return _createClass(ApiPopover, [{
|
|
46
|
+
key: "render",
|
|
47
|
+
value: function render() {
|
|
48
|
+
var _this2 = this;
|
|
49
|
+
return /*#__PURE__*/React.createElement(ApiPopoverContext.Provider, {
|
|
50
|
+
value: this
|
|
51
|
+
}, this.props.children, /*#__PURE__*/React.createElement(Popover, _extends({
|
|
52
|
+
sx: {
|
|
53
|
+
'& .MuiPaper-root.MuiPaper-elevation': {
|
|
54
|
+
overflow: 'hidden'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
anchorEl: this.state.anchorEl,
|
|
58
|
+
open: Boolean(this.state.anchorEl),
|
|
59
|
+
onClose: function onClose(_, reason) {
|
|
60
|
+
return _this2.closePopover(reason);
|
|
61
|
+
},
|
|
62
|
+
anchorOrigin: {
|
|
63
|
+
vertical: 'bottom',
|
|
64
|
+
horizontal: 'right'
|
|
65
|
+
},
|
|
66
|
+
transformOrigin: {
|
|
67
|
+
vertical: 'top',
|
|
68
|
+
horizontal: 'right'
|
|
69
|
+
},
|
|
70
|
+
disableScrollLock: true
|
|
71
|
+
}, this.state.popoverProps), this.state.content));
|
|
72
|
+
}
|
|
73
|
+
}]);
|
|
74
|
+
}(Component);
|
|
75
|
+
var withApiPopoverContext = function withApiPopoverContext(Component) {
|
|
76
|
+
return function (props) {
|
|
77
|
+
return /*#__PURE__*/React.createElement(ApiPopover, null, MapApiPopoverContext(function (context) {
|
|
78
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
79
|
+
contextPopover: context
|
|
80
|
+
}));
|
|
81
|
+
}));
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { ApiPopoverContext, MapApiPopoverContext, ApiPopover as default, withApiPopoverContext };
|
|
86
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../../src/api-context/popover.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport { Popover, PopoverProps, PopoverVirtualElement } from '@mui/material'\r\nimport { ContentDefault } from './ui.units'\r\n\r\nexport interface IPopoverOptions {\r\n anchorEl?: Element | (() => Element) | PopoverVirtualElement | (() => PopoverVirtualElement) | null\r\n popoverProps?: Omit<PopoverProps, 'open'>\r\n content: React.ReactNode\r\n}\r\n\r\nexport type TShowPopover = (option: IPopoverOptions) => void\r\n\r\nexport type TClosePopover = (reason?: 'backdropClick' | 'escapeKeyDown') => void\r\n\r\nexport interface IApiPopoverContext {\r\n showPopover: TShowPopover\r\n closePopover: TClosePopover\r\n}\r\n\r\nexport const ApiPopoverContext = React.createContext<IApiPopoverContext>({\r\n showPopover: () => {\r\n console.warn('ApiPopover provider not found!')\r\n },\r\n closePopover: () => {\r\n console.warn('ApiPopover provider not found!')\r\n }\r\n})\r\n\r\nexport const MapApiPopoverContext = (context: (state: IApiPopoverContext) => React.ReactNode) => (\r\n <ApiPopoverContext.Consumer>{context}</ApiPopoverContext.Consumer>\r\n)\r\n\r\ninterface IProps {}\r\ninterface IState extends IPopoverOptions {}\r\ntype TProps = React.PropsWithChildren<IProps>\r\nclass ApiPopover extends Component<TProps, IState> implements IApiPopoverContext {\r\n constructor(props: any) {\r\n super(props)\r\n this.state = { anchorEl: null, content: <ContentDefault /> }\r\n }\r\n render() {\r\n return (\r\n <ApiPopoverContext.Provider value={this}>\r\n {this.props.children}\r\n <Popover\r\n sx={{ '& .MuiPaper-root.MuiPaper-elevation': { overflow: 'hidden' } }}\r\n anchorEl={this.state.anchorEl}\r\n open={Boolean(this.state.anchorEl)}\r\n onClose={(_, reason) => this.closePopover(reason)}\r\n anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}\r\n transformOrigin={{ vertical: 'top', horizontal: 'right' }}\r\n disableScrollLock\r\n {...this.state.popoverProps}\r\n >\r\n {this.state.content}\r\n </Popover>\r\n </ApiPopoverContext.Provider>\r\n )\r\n }\r\n showPopover = (option: IPopoverOptions) => {\r\n clearTimeout(this.timer)\r\n this.setState({ ...option })\r\n }\r\n timer: any\r\n closePopover: TClosePopover = () => {\r\n clearTimeout(this.timer)\r\n this.setState({ anchorEl: null }, () => {\r\n this.timer = setTimeout(() => {\r\n this.setState({ content: <ContentDefault /> })\r\n }, 500)\r\n })\r\n }\r\n}\r\nexport default ApiPopover\r\n\r\nexport interface IApiPopoverContextProps {\r\n contextPopover: IApiPopoverContext\r\n}\r\nexport const withApiPopoverContext = <P extends IApiPopoverContextProps>(Component: React.ComponentType<P>) => {\r\n return (props: Omit<P, keyof IApiPopoverContextProps>) => {\r\n return (\r\n <ApiPopover>\r\n {MapApiPopoverContext((context) => (\r\n <Component {...(props as P)} contextPopover={context} />\r\n ))}\r\n </ApiPopover>\r\n )\r\n }\r\n}\r\n"],"names":["ApiPopoverContext","React","createContext","showPopover","console","warn","closePopover","MapApiPopoverContext","context","createElement","Consumer","ApiPopover","_Component","props","_this","_classCallCheck","_callSuper","option","clearTimeout","timer","setState","Object","assign","anchorEl","setTimeout","content","ContentDefault","state","_inherits","_createClass","key","value","render","_this2","Provider","children","Popover","_extends","sx","overflow","open","Boolean","onClose","_","reason","anchorOrigin","vertical","horizontal","transformOrigin","disableScrollLock","popoverProps","Component","withApiPopoverContext","contextPopover"],"mappings":";;;;;IAmBaA,iBAAiB,gBAAGC,KAAK,CAACC,aAAa,CAAqB;AACvEC,EAAAA,WAAW,EAAE,SAAbA,WAAWA,GAAO;AAChBC,IAAAA,OAAO,CAACC,IAAI,CAAC,gCAAgC,CAAC;GAC/C;AACDC,EAAAA,YAAY,EAAE,SAAdA,YAAYA,GAAO;AACjBF,IAAAA,OAAO,CAACC,IAAI,CAAC,gCAAgC,CAAC;AAChD;AACD,CAAA;IAEYE,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAIC,OAAuD,EAAA;EAAA,oBAC1FP,KAAA,CAAAQ,aAAA,CAACT,iBAAiB,CAACU,QAAQ,EAAEF,IAAAA,EAAAA,OAAoC,CAAC;AAAA;AAM9DG,IAAAA,UAAW,0BAAAC,UAAA,EAAA;EACf,SAAAD,UAAAA,CAAYE,KAAU,EAAA;AAAA,IAAA,IAAAC,KAAA;AAAAC,IAAAA,eAAA,OAAAJ,UAAA,CAAA;AACpBG,IAAAA,KAAA,GAAAE,UAAA,CAAAL,IAAAA,EAAAA,UAAA,GAAME,KAAK,CAAA,CAAA;AAsBbC,IAAAA,KAAA,CAAAX,WAAW,GAAG,UAACc,MAAuB,EAAI;AACxCC,MAAAA,YAAY,CAACJ,KAAA,CAAKK,KAAK,CAAC;AACxBL,MAAAA,KAAA,CAAKM,QAAQ,CAAMC,MAAA,CAAAC,MAAA,CAAA,EAAA,EAAAL,MAAM,EAAG;KAC7B;IAEDH,KAAA,CAAYR,YAAA,GAAkB,YAAK;AACjCY,MAAAA,YAAY,CAACJ,KAAA,CAAKK,KAAK,CAAC;MACxBL,KAAA,CAAKM,QAAQ,CAAC;AAAEG,QAAAA,QAAQ,EAAE;AAAI,OAAE,EAAE,YAAK;AACrCT,QAAAA,KAAA,CAAKK,KAAK,GAAGK,UAA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U,EAAE;SAAU;AAC1DC,QAAAA,eAAe,EAAE;AAAEF,UAAAA,QAAQ,EAAE,KAAK;AAAEC,UAAAA,UAAU,EAAE;SAAU;QAC1DE,iBAAiB,EAAA;AAAA,OAAA,EACb,IAAI,CAACtB,KAAK,CAACuB,YAAY,CAAA,EAE1B,IAAI,CAACvB,KAAK,CAACF,OACL,CACiB,CAAC;AAEjC;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA,CAvBsB0B,SAAyB;IA2CrCC,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAuCD,SAAiC,EAAI;EAC5G,OAAO,UAACtC,KAA6C,EAAI;IACvD,oBACEZ,KAAA,CAAAQ,aAAA,CAACE,UAAU,EACRJ,IAAAA,EAAAA,oBAAoB,CAAC,UAACC,OAAO,EAAA;MAAA,oBAC5BP,KAAA,CAAAQ,aAAA,CAAC0C,SAAS,EAAAd,QAAA,KAAMxB,KAAW,EAAA;AAAEwC,QAAAA,cAAc,EAAE7C;AAAQ,OAAA,CAAA,CAAG;AAAA,KACzD,CACS,CAAC;GAEhB;AACH;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Typography } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
var ContentDefault = function ContentDefault() {
|
|
5
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
6
|
+
sx: {
|
|
7
|
+
p: '9px 12px',
|
|
8
|
+
m: '12px',
|
|
9
|
+
backgroundColor: 'rgba(0,0,0,0.1)'
|
|
10
|
+
}
|
|
11
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
12
|
+
variant: "caption",
|
|
13
|
+
sx: {
|
|
14
|
+
fontWeight: 600,
|
|
15
|
+
fontStyle: 'italic'
|
|
16
|
+
}
|
|
17
|
+
}, "Content"));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { ContentDefault };
|
|
21
|
+
//# sourceMappingURL=ui.units.js.map
|