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,172 @@
|
|
|
1
|
+
import { createClass as _createClass, classCallCheck as _classCallCheck } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import queryString from 'query-string';
|
|
3
|
+
|
|
4
|
+
var StringStardize = function StringStardize(str) {
|
|
5
|
+
var _a;
|
|
6
|
+
return (_a = str === null || str === void 0 ? void 0 : str.trim().toLowerCase()) !== null && _a !== void 0 ? _a : '';
|
|
7
|
+
};
|
|
8
|
+
var QueryParamBase = /*#__PURE__*/function () {
|
|
9
|
+
function QueryParamBase() {
|
|
10
|
+
var _this = this;
|
|
11
|
+
_classCallCheck(this, QueryParamBase);
|
|
12
|
+
this.getPath = function () {
|
|
13
|
+
return window.location.pathname === '/' ? '' : window.location.pathname;
|
|
14
|
+
};
|
|
15
|
+
// stringify<TParam extends {} = any>(param: TParam) {
|
|
16
|
+
// return `?${encodeURIComponent(queryString.stringify(param, { skipNull: true, skipEmptyString: true }))}`
|
|
17
|
+
// }
|
|
18
|
+
this.stringify = function (param) {
|
|
19
|
+
var entries = Object.keys(param).filter(function (key) {
|
|
20
|
+
return param[key];
|
|
21
|
+
}) // skip null & empty string
|
|
22
|
+
.reduce(function (a, key) {
|
|
23
|
+
var encodedValue = encodeURIComponent(param[key]);
|
|
24
|
+
a[key] = encodedValue;
|
|
25
|
+
return a;
|
|
26
|
+
}, {});
|
|
27
|
+
return '?' + queryString.stringify(entries, {
|
|
28
|
+
skipNull: true,
|
|
29
|
+
skipEmptyString: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
this.GetAll = function () {
|
|
33
|
+
return _this._GetValues();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return _createClass(QueryParamBase, [{
|
|
37
|
+
key: "_GetValues",
|
|
38
|
+
value: function _GetValues() {
|
|
39
|
+
// return queryString.parse(decodeURIComponent(window.location.search))
|
|
40
|
+
return queryString.parse(decodeURIComponent(window.location.search));
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
key: "_GetValuesMap",
|
|
44
|
+
value: function _GetValuesMap() {
|
|
45
|
+
var query = this._GetValues();
|
|
46
|
+
return new Map(Object.keys(query).map(function (x) {
|
|
47
|
+
return [StringStardize(x), query[x]];
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "_GetkeysMap",
|
|
52
|
+
value: function _GetkeysMap() {
|
|
53
|
+
var query = this._GetValues();
|
|
54
|
+
return new Map(Object.keys(query).map(function (x) {
|
|
55
|
+
return [StringStardize(x), x];
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "Replace",
|
|
60
|
+
value: function Replace(param, state) {
|
|
61
|
+
window.history.replaceState(state !== null && state !== void 0 ? state : {}, '', "".concat(this.getPath()).concat(this.stringify(param)));
|
|
62
|
+
window.dispatchEvent(new window.PopStateEvent('popstate'));
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "Patch",
|
|
66
|
+
value: function Patch(param, state) {
|
|
67
|
+
var query = this._GetValues();
|
|
68
|
+
var keyMap = this._GetkeysMap();
|
|
69
|
+
Object.keys(param).forEach(function (k) {
|
|
70
|
+
var _a;
|
|
71
|
+
var key = StringStardize(k);
|
|
72
|
+
if (keyMap.has(key)) {
|
|
73
|
+
query[(_a = keyMap.get(key)) !== null && _a !== void 0 ? _a : ''] = param[k];
|
|
74
|
+
} else {
|
|
75
|
+
query[k] = param[k];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
this.Put(query, state);
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "ReplacePatch",
|
|
82
|
+
value: function ReplacePatch(param, state) {
|
|
83
|
+
var query = this._GetValues();
|
|
84
|
+
var keyMap = this._GetkeysMap();
|
|
85
|
+
Object.keys(param).forEach(function (k) {
|
|
86
|
+
var _a;
|
|
87
|
+
var key = StringStardize(k);
|
|
88
|
+
if (keyMap.has(key)) {
|
|
89
|
+
query[(_a = keyMap.get(key)) !== null && _a !== void 0 ? _a : ''] = param[k];
|
|
90
|
+
} else {
|
|
91
|
+
query[k] = param[k];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
this.Replace(query, state);
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "Put",
|
|
98
|
+
value: function Put(param, state) {
|
|
99
|
+
window.history.pushState(state !== null && state !== void 0 ? state : {}, '', "".concat(this.getPath()).concat(this.stringify(param)));
|
|
100
|
+
window.dispatchEvent(new window.PopStateEvent('popstate'));
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "Deletes",
|
|
104
|
+
value: function Deletes() {
|
|
105
|
+
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
106
|
+
keys[_key] = arguments[_key];
|
|
107
|
+
}
|
|
108
|
+
this.DeletesWithState(keys);
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "ReplaceDeletes",
|
|
112
|
+
value: function ReplaceDeletes() {
|
|
113
|
+
for (var _len2 = arguments.length, keys = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
114
|
+
keys[_key2] = arguments[_key2];
|
|
115
|
+
}
|
|
116
|
+
this.ReplaceDeletesWithState(keys);
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "ReplaceDeletesWithState",
|
|
120
|
+
value: function ReplaceDeletesWithState(keys, state) {
|
|
121
|
+
var query = this._GetValues();
|
|
122
|
+
var keyMap = this._GetkeysMap();
|
|
123
|
+
keys.forEach(function (k) {
|
|
124
|
+
var _a;
|
|
125
|
+
var key = StringStardize(k.toString());
|
|
126
|
+
if (keyMap.has(key)) {
|
|
127
|
+
delete query[(_a = keyMap.get(key)) !== null && _a !== void 0 ? _a : ''];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
this.Replace(query, state);
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "DeletesWithState",
|
|
134
|
+
value: function DeletesWithState(keys, state) {
|
|
135
|
+
var query = this._GetValues();
|
|
136
|
+
var keyMap = this._GetkeysMap();
|
|
137
|
+
keys.forEach(function (k) {
|
|
138
|
+
var _a;
|
|
139
|
+
var key = StringStardize(k.toString());
|
|
140
|
+
if (keyMap.has(key)) {
|
|
141
|
+
delete query[(_a = keyMap.get(key)) !== null && _a !== void 0 ? _a : ''];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
this.Put(query, state);
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "DeleteAll",
|
|
148
|
+
value: function DeleteAll() {
|
|
149
|
+
window.history.replaceState({}, '', "".concat(this.getPath()));
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "Gets",
|
|
153
|
+
value: function Gets() {
|
|
154
|
+
var query = this._GetValuesMap();
|
|
155
|
+
for (var _len3 = arguments.length, keys = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
156
|
+
keys[_key3] = arguments[_key3];
|
|
157
|
+
}
|
|
158
|
+
return keys.reduce(function (a, k) {
|
|
159
|
+
var key = StringStardize(k.toString());
|
|
160
|
+
if (query.has(key)) {
|
|
161
|
+
a[k] = query.get(key);
|
|
162
|
+
}
|
|
163
|
+
return a;
|
|
164
|
+
}, {});
|
|
165
|
+
}
|
|
166
|
+
}]);
|
|
167
|
+
}();
|
|
168
|
+
var QueryParam = new QueryParamBase();
|
|
169
|
+
window.QueryParam = QueryParam;
|
|
170
|
+
|
|
171
|
+
export { QueryParam, QueryParam as default };
|
|
172
|
+
//# sourceMappingURL=query-param.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-param.js","sources":["../../../src/utils/query-param.ts"],"sourcesContent":["import queryString from 'query-string'\r\n\r\nconst StringStardize = (str: string) => str?.trim().toLowerCase() ?? ''\r\n\r\nclass QueryParamBase {\r\n private _GetValues() {\r\n // return queryString.parse(decodeURIComponent(window.location.search))\r\n return queryString.parse(decodeURIComponent(window.location.search))\r\n }\r\n\r\n private _GetValuesMap() {\r\n const query = this._GetValues()\r\n return new Map(Object.keys(query).map((x) => [StringStardize(x), query[x] as string]))\r\n }\r\n\r\n private _GetkeysMap() {\r\n const query = this._GetValues()\r\n return new Map(Object.keys(query).map((x) => [StringStardize(x), x]))\r\n }\r\n\r\n private getPath = () => (window.location.pathname === '/' ? '' : window.location.pathname)\r\n\r\n // stringify<TParam extends {} = any>(param: TParam) {\r\n // return `?${encodeURIComponent(queryString.stringify(param, { skipNull: true, skipEmptyString: true }))}`\r\n // }\r\n stringify = <TParam extends Record<string, any> = any>(param: TParam): string => {\r\n const entries = Object.keys(param)\r\n .filter((key) => param[key]) // skip null & empty string\r\n .reduce((a, key) => {\r\n const encodedValue = encodeURIComponent(param[key])\r\n a[key] = encodedValue\r\n return a\r\n }, {} as any)\r\n\r\n return '?' + queryString.stringify(entries, { skipNull: true, skipEmptyString: true })\r\n }\r\n\r\n Replace<TParam extends {} = any, TState = any>(param: TParam, state?: TState) {\r\n window.history.replaceState(state ?? {}, '', `${this.getPath()}${this.stringify(param)}`)\r\n window.dispatchEvent(new window.PopStateEvent('popstate'))\r\n }\r\n\r\n Patch<TParam extends { [key: string]: any } = any, TState = any>(param: TParam, state?: TState) {\r\n const query = this._GetValues()\r\n const keyMap = this._GetkeysMap()\r\n Object.keys(param).forEach((k) => {\r\n const key = StringStardize(k)\r\n if (keyMap.has(key)) {\r\n query[keyMap.get(key) ?? ''] = param[k]\r\n } else {\r\n query[k] = param[k]\r\n }\r\n })\r\n this.Put(query, state)\r\n }\r\n\r\n ReplacePatch<TParam extends { [key: string]: any } = any, TState = any>(param: TParam, state?: TState) {\r\n const query = this._GetValues()\r\n const keyMap = this._GetkeysMap()\r\n Object.keys(param).forEach((k) => {\r\n const key = StringStardize(k)\r\n if (keyMap.has(key)) {\r\n query[keyMap.get(key) ?? ''] = param[k]\r\n } else {\r\n query[k] = param[k]\r\n }\r\n })\r\n this.Replace(query, state)\r\n }\r\n\r\n Put<TParam extends {} = any, TState = any>(param: TParam, state?: TState) {\r\n window.history.pushState(state ?? {}, '', `${this.getPath()}${this.stringify(param)}`)\r\n window.dispatchEvent(new window.PopStateEvent('popstate'))\r\n }\r\n\r\n Deletes<TValue extends {} = any>(...keys: (keyof TValue)[]) {\r\n this.DeletesWithState(keys)\r\n }\r\n\r\n ReplaceDeletes<TValue extends {} = any>(...keys: (keyof TValue)[]) {\r\n this.ReplaceDeletesWithState(keys)\r\n }\r\n\r\n ReplaceDeletesWithState<TValue extends {} = any, TState = any>(keys: (keyof TValue)[], state?: TState) {\r\n const query = this._GetValues()\r\n const keyMap = this._GetkeysMap()\r\n keys.forEach((k) => {\r\n const key = StringStardize(k.toString())\r\n if (keyMap.has(key)) {\r\n delete query[keyMap.get(key) ?? '']\r\n }\r\n })\r\n this.Replace(query, state)\r\n }\r\n\r\n DeletesWithState<TValue extends {} = any, TState = any>(keys: (keyof TValue)[], state?: TState) {\r\n const query = this._GetValues()\r\n const keyMap = this._GetkeysMap()\r\n keys.forEach((k) => {\r\n const key = StringStardize(k.toString())\r\n if (keyMap.has(key)) {\r\n delete query[keyMap.get(key) ?? '']\r\n }\r\n })\r\n this.Put(query, state)\r\n }\r\n\r\n DeleteAll() {\r\n window.history.replaceState({}, '', `${this.getPath()}`)\r\n }\r\n\r\n GetAll = () => {\r\n return this._GetValues()\r\n }\r\n\r\n Gets<TValue extends {} = any>(...keys: (keyof TValue)[]) {\r\n const query = this._GetValuesMap()\r\n return keys.reduce<Partial<TValue>>((a, k) => {\r\n const key = StringStardize(k.toString())\r\n if (query.has(key)) {\r\n a[k] = query.get(key) as any\r\n }\r\n return a\r\n }, {})\r\n }\r\n}\r\nexport const QueryParam = new QueryParamBase()\r\n;(window as any).QueryParam = QueryParam\r\nexport default QueryParam\r\n"],"names":["StringStardize","str","_a","trim","toLowerCase","QueryParamBase","_this","_classCallCheck","getPath","window","location","pathname","stringify","param","entries","Object","keys","filter","key","reduce","a","encodedValue","encodeURIComponent","queryString","skipNull","skipEmptyString","GetAll","_GetValues","_createClass","value","parse","decodeURIComponent","search","_GetValuesMap","query","Map","map","x","_GetkeysMap","Replace","state","history","replaceState","concat","dispatchEvent","PopStateEvent","Patch","keyMap","forEach","k","has","get","Put","ReplacePatch","pushState","Deletes","_len","arguments","length","Array","_key","DeletesWithState","ReplaceDeletes","_len2","_key2","ReplaceDeletesWithState","toString","DeleteAll","Gets","_len3","_key3","QueryParam"],"mappings":";;;AAEA,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,GAAW,EAAI;AAAA,EAAA,IAAAC,EAAA;AAAC,EAAA,OAAA,CAAAA,EAAA,GAAAD,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAH,MAAA,GAAA,MAAA,GAAAA,GAAG,CAAEE,IAAI,EAAG,CAAAC,WAAW,EAAE,MAAI,IAAA,IAAAF,EAAA,KAAA,MAAA,GAAAA,EAAA,GAAA,EAAE;AAAA,CAAA;AAAA,IAEjEG,cAAc,gBAAA,YAAA;AAApB,EAAA,SAAAA,iBAAA;AAAA,IAAA,IAAAC,KAAA,GAAA,IAAA;AAAAC,IAAAA,eAAA,OAAAF,cAAA,CAAA;IAgBU,IAAO,CAAAG,OAAA,GAAG,YAAA;AAAA,MAAA,OAAOC,MAAM,CAACC,QAAQ,CAACC,QAAQ,KAAK,GAAG,GA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EAAE;UAClBE,CAAC,CAAC6B,CAAC,CAAC,GAAGf,KAAK,CAACiB,GAAG,CAACjC,GAAG,CAAQ;AAC7B;AACD,QAAA,OAAOE,CAAC;OACT,EAAE,EAAE,CAAC;AACR;AAAC,GAAA,CAAA,CAAA;AAAA,CAAA,EAAA;IAEUmD,UAAU,GAAG,IAAIlE,cAAc;AAC1CI,MAAc,CAAC8D,UAAU,GAAGA,UAAU;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dinocollab-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "npx rimraf dist && rollup -c"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@mui/icons-material": "5.17.1",
|
|
17
|
+
"@mui/material": "5.17.1",
|
|
18
|
+
"@mui/x-data-grid": "6.20.4",
|
|
19
|
+
"@mui/x-date-pickers": "6.20.2",
|
|
20
|
+
"axios": "1.8.3",
|
|
21
|
+
"clipboard-copy": "4.0.1",
|
|
22
|
+
"dayjs": "1.11.5",
|
|
23
|
+
"dotenv": "16.4.7",
|
|
24
|
+
"query-string": "9.1.1",
|
|
25
|
+
"react": "18.3.1",
|
|
26
|
+
"react-dom": "18.3.1",
|
|
27
|
+
"react-quill": "2.0.0",
|
|
28
|
+
"react-router-dom": "6.30.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@babel/core": "7.27.1",
|
|
32
|
+
"@babel/preset-env": "7.27.2",
|
|
33
|
+
"@babel/preset-react": "7.27.1",
|
|
34
|
+
"@babel/preset-typescript": "7.27.1",
|
|
35
|
+
"@rollup/plugin-alias": "5.1.1",
|
|
36
|
+
"@rollup/plugin-babel": "6.0.4",
|
|
37
|
+
"@rollup/plugin-commonjs": "28.0.3",
|
|
38
|
+
"@rollup/plugin-node-resolve": "16.0.1",
|
|
39
|
+
"@rollup/plugin-typescript": "12.1.2",
|
|
40
|
+
"@rollup/plugin-url": "8.0.2",
|
|
41
|
+
"@types/node": "16.18.126",
|
|
42
|
+
"@types/react": "18.3.20",
|
|
43
|
+
"@types/react-dom": "18.3.5",
|
|
44
|
+
"babel-preset-react": "6.24.1",
|
|
45
|
+
"babel-preset-typescript": "7.0.0-alpha.19",
|
|
46
|
+
"rollup": "4.41.0",
|
|
47
|
+
"rollup-plugin-multi-input": "1.5.0",
|
|
48
|
+
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
49
|
+
"tslib": "2.8.1",
|
|
50
|
+
"typescript": "4.9.5"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve'
|
|
3
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
4
|
+
import typescript from '@rollup/plugin-typescript'
|
|
5
|
+
import babel from '@rollup/plugin-babel'
|
|
6
|
+
import url from '@rollup/plugin-url'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
input: ['src/index.ts'],
|
|
10
|
+
output: [
|
|
11
|
+
{
|
|
12
|
+
dir: 'dist',
|
|
13
|
+
format: 'esm',
|
|
14
|
+
sourcemap: true,
|
|
15
|
+
preserveModules: true,
|
|
16
|
+
entryFileNames: '[name].js'
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
plugins: [
|
|
20
|
+
url({
|
|
21
|
+
include: ['**/*.webp'], // 👈 hỗ trợ file .webp
|
|
22
|
+
limit: 8192, // nếu file < 8kb sẽ convert sang base64, ngược lại sẽ emit file
|
|
23
|
+
emitFiles: true,
|
|
24
|
+
fileName: '[name][hash][extname]',
|
|
25
|
+
destDir: 'dist/assets' // thư mục chứa file ảnh
|
|
26
|
+
}),
|
|
27
|
+
peerDepsExternal(),
|
|
28
|
+
resolve(),
|
|
29
|
+
commonjs(),
|
|
30
|
+
typescript({ tsconfig: './tsconfig.json' }),
|
|
31
|
+
babel({
|
|
32
|
+
babelHelpers: 'bundled',
|
|
33
|
+
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
|
34
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
35
|
+
exclude: 'node_modules/**'
|
|
36
|
+
})
|
|
37
|
+
],
|
|
38
|
+
external: ['react', 'react-dom']
|
|
39
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import React, { FC, useCallback, useEffect, useState } from 'react'
|
|
2
|
+
import { Box, Stack, styled, Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material'
|
|
3
|
+
import MuiAlert, { AlertProps, AlertColor } from '@mui/material/Alert'
|
|
4
|
+
|
|
5
|
+
const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(props, ref) {
|
|
6
|
+
return <MuiAlert elevation={6} ref={ref} variant='standard' {...props} style={{ minWidth: '300px' }} />
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
interface MessageData {
|
|
10
|
+
id: string
|
|
11
|
+
text: string
|
|
12
|
+
type: AlertColor
|
|
13
|
+
duration?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface IOptions {
|
|
17
|
+
duration?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface IApiAlert {
|
|
21
|
+
PushMessage: (data: MessageData) => void
|
|
22
|
+
PushInfo: (data: string) => void
|
|
23
|
+
PushError: (data: string) => void
|
|
24
|
+
PushWarning: (data: string) => void
|
|
25
|
+
PushSuccess: (data: string) => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IApiContext {
|
|
29
|
+
ApiAlert?: IApiAlert
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const ApiAlertContext: IApiContext = {}
|
|
33
|
+
|
|
34
|
+
const RenderArea = (messages: MessageData[], onClose: (data: MessageData) => void) => {
|
|
35
|
+
return messages.map((x, i) => {
|
|
36
|
+
return <Message key={x.id + i} data={x} IsOpen={true} handleClose={onClose} autoDurationHide={x.duration} />
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function AlertGlobal() {
|
|
41
|
+
const [Messages, setMessages] = useState<MessageData[]>([])
|
|
42
|
+
const _PushMessage = useCallback((data: MessageData) => {
|
|
43
|
+
setMessages((st) => [...st, data])
|
|
44
|
+
}, [])
|
|
45
|
+
const _HandleClose = useCallback(
|
|
46
|
+
(data: MessageData) => {
|
|
47
|
+
const index = Messages.findIndex((x) => x.id === data.id)
|
|
48
|
+
Messages.splice(index, 1)
|
|
49
|
+
setMessages([...Messages])
|
|
50
|
+
},
|
|
51
|
+
[Messages]
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
ApiAlertContext.ApiAlert = {
|
|
56
|
+
...(ApiAlertContext.ApiAlert ? ApiAlertContext.ApiAlert : {}),
|
|
57
|
+
PushMessage: _PushMessage,
|
|
58
|
+
PushError: function (data: string, options?: IOptions) {
|
|
59
|
+
this.PushMessage({
|
|
60
|
+
id: new Date().getTime().toString(),
|
|
61
|
+
text: data,
|
|
62
|
+
type: 'error',
|
|
63
|
+
duration: options?.duration || 15000
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
PushInfo: function (data: string, options?: IOptions) {
|
|
67
|
+
this.PushMessage({
|
|
68
|
+
id: new Date().getTime().toString(),
|
|
69
|
+
text: data,
|
|
70
|
+
type: 'info',
|
|
71
|
+
duration: options?.duration || 6000
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
PushWarning: function (data: string, options?: IOptions) {
|
|
75
|
+
this.PushMessage({
|
|
76
|
+
id: new Date().getTime().toString(),
|
|
77
|
+
text: data,
|
|
78
|
+
type: 'warning',
|
|
79
|
+
duration: options?.duration || 6000
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
PushSuccess: function (data: string, options?: IOptions) {
|
|
83
|
+
this.PushMessage({
|
|
84
|
+
id: new Date().getTime().toString(),
|
|
85
|
+
text: data,
|
|
86
|
+
type: 'success',
|
|
87
|
+
duration: options?.duration || 3000
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, [_PushMessage])
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Wrap>
|
|
95
|
+
<Stack spacing={2} sx={{ maxWidth: '300px' }}>
|
|
96
|
+
{RenderArea(Messages, _HandleClose)}
|
|
97
|
+
</Stack>
|
|
98
|
+
</Wrap>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
export default AlertGlobal
|
|
102
|
+
|
|
103
|
+
interface MessageProps {
|
|
104
|
+
IsOpen: boolean
|
|
105
|
+
handleClose: (data: MessageData) => void
|
|
106
|
+
data: MessageData
|
|
107
|
+
autoDurationHide?: number
|
|
108
|
+
}
|
|
109
|
+
const Message: FC<MessageProps> = (props) => {
|
|
110
|
+
const _handleClose = useCallback(() => props.handleClose(props.data), [props])
|
|
111
|
+
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
let Timer: any = null
|
|
114
|
+
if (props.autoDurationHide) {
|
|
115
|
+
Timer = setTimeout(() => {
|
|
116
|
+
props.handleClose(props.data)
|
|
117
|
+
}, props.autoDurationHide)
|
|
118
|
+
}
|
|
119
|
+
return () => {
|
|
120
|
+
clearTimeout(Timer as any)
|
|
121
|
+
}
|
|
122
|
+
}, [props])
|
|
123
|
+
return (
|
|
124
|
+
<Alert onClose={_handleClose} severity={props.data.type}>
|
|
125
|
+
{props.data.text}
|
|
126
|
+
</Alert>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const Wrap = styled(Box)({
|
|
131
|
+
position: 'fixed',
|
|
132
|
+
top: 'calc(var(--height-header) + 20px)',
|
|
133
|
+
right: '50px',
|
|
134
|
+
zIndex: 2000,
|
|
135
|
+
display: 'flex',
|
|
136
|
+
justifyContent: 'flex-start',
|
|
137
|
+
alignItems: 'center'
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
interface AlertDialogProps {
|
|
141
|
+
IsOpen: boolean
|
|
142
|
+
onClose?: () => void
|
|
143
|
+
onAccept?: () => void
|
|
144
|
+
Title: string
|
|
145
|
+
Message: string
|
|
146
|
+
}
|
|
147
|
+
export const AlertDialog: React.FC<AlertDialogProps> = (props) => {
|
|
148
|
+
const [Open, setOpen] = React.useState(props.IsOpen)
|
|
149
|
+
React.useEffect(() => {
|
|
150
|
+
setOpen(props.IsOpen)
|
|
151
|
+
}, [props.IsOpen])
|
|
152
|
+
const _handleClose = React.useCallback(() => {
|
|
153
|
+
setOpen(false)
|
|
154
|
+
props.onClose && props.onClose()
|
|
155
|
+
}, [props])
|
|
156
|
+
return (
|
|
157
|
+
<div>
|
|
158
|
+
<Dialog open={Open} onClose={_handleClose} aria-labelledby='alert-dialog-title' aria-describedby='alert-dialog-description'>
|
|
159
|
+
<DialogTitle id='alert-dialog-title'>{props.Title}</DialogTitle>
|
|
160
|
+
<DialogContent>
|
|
161
|
+
<DialogContentText id='alert-dialog-description'>{props.Message}</DialogContentText>
|
|
162
|
+
</DialogContent>
|
|
163
|
+
<DialogActions>
|
|
164
|
+
<Button onClick={props.onAccept} autoFocus color='info'>
|
|
165
|
+
Ok
|
|
166
|
+
</Button>
|
|
167
|
+
<Button onClick={_handleClose} color='error'>
|
|
168
|
+
Cancel
|
|
169
|
+
</Button>
|
|
170
|
+
</DialogActions>
|
|
171
|
+
</Dialog>
|
|
172
|
+
</div>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { Component, ReactNode } from 'react'
|
|
2
|
+
import { Box, Divider, Drawer, DrawerProps, IconButton, styled, Typography } from '@mui/material'
|
|
3
|
+
import CloseIcon from '@mui/icons-material/Close'
|
|
4
|
+
|
|
5
|
+
const drawerGlobalClasses = {
|
|
6
|
+
root: 'DrawerGlobal-root',
|
|
7
|
+
title: 'DrawerGlobal-title',
|
|
8
|
+
content: 'DrawerGlobal-content',
|
|
9
|
+
fullHeight: 'DrawerGlobal-fullHeight'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface IProps {}
|
|
13
|
+
|
|
14
|
+
interface IState {
|
|
15
|
+
title?: ReactNode
|
|
16
|
+
icon?: ReactNode
|
|
17
|
+
fullHeight?: boolean
|
|
18
|
+
anchor?: DrawerProps['anchor']
|
|
19
|
+
/** @default true */
|
|
20
|
+
backdropClickeable?: boolean
|
|
21
|
+
renderContent?: () => ReactNode
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type TReason = 'backdropClick' | 'escapeKeyDown'
|
|
25
|
+
|
|
26
|
+
interface DrawerGlobalApiType {
|
|
27
|
+
open: (state: IState) => void
|
|
28
|
+
close: (reason?: TReason) => void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const DrawerGlobalApi: DrawerGlobalApiType = {
|
|
32
|
+
close: () => {
|
|
33
|
+
console.warn('DrawerGlobal provider not found!')
|
|
34
|
+
},
|
|
35
|
+
open: () => {
|
|
36
|
+
console.warn('DrawerGlobal provider not found!')
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class DrawerGlobalProvider extends Component<IProps, IState> {
|
|
41
|
+
constructor(props: IProps) {
|
|
42
|
+
super(props)
|
|
43
|
+
this.state = {}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
close = (reason?: TReason) => {
|
|
47
|
+
if (this.state.backdropClickeable === false && reason === 'backdropClick') return
|
|
48
|
+
this.setState({ renderContent: undefined })
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
open = (state: IState) => this.setState(state)
|
|
52
|
+
|
|
53
|
+
componentDidMount() {
|
|
54
|
+
DrawerGlobalApi.open = this.open
|
|
55
|
+
DrawerGlobalApi.close = this.close
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render() {
|
|
59
|
+
return (
|
|
60
|
+
<Drawer anchor={this.state.anchor} open={Boolean(this.state.renderContent)} onClose={(_, reason) => this.close(reason)}>
|
|
61
|
+
<Wrap className={this.getClasses()}>
|
|
62
|
+
<div className={drawerGlobalClasses.title}>
|
|
63
|
+
{this.state.icon}
|
|
64
|
+
{this.renderTitle()}
|
|
65
|
+
<Box sx={{ flex: 1 }} />
|
|
66
|
+
<IconButton onClick={() => this.close()}>
|
|
67
|
+
<CloseIcon />
|
|
68
|
+
</IconButton>
|
|
69
|
+
</div>
|
|
70
|
+
<Divider variant='middle' />
|
|
71
|
+
<div className={drawerGlobalClasses.content}>{this.state.renderContent && this.state.renderContent()}</div>
|
|
72
|
+
</Wrap>
|
|
73
|
+
</Drawer>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
renderTitle = () => {
|
|
78
|
+
if (typeof this.state.title === 'string') {
|
|
79
|
+
return (
|
|
80
|
+
<Typography variant='h6' noWrap>
|
|
81
|
+
{this.state.title}
|
|
82
|
+
</Typography>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
return this.state.title
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getClasses = () => {
|
|
89
|
+
const classes = [drawerGlobalClasses.root]
|
|
90
|
+
if (this.state.fullHeight) classes.push(drawerGlobalClasses.fullHeight)
|
|
91
|
+
return classes.join(' ')
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const DrawerGlobal = {
|
|
96
|
+
Provider: DrawerGlobalProvider,
|
|
97
|
+
Api: DrawerGlobalApi
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default DrawerGlobal
|
|
101
|
+
|
|
102
|
+
const Wrap = styled(Box)({
|
|
103
|
+
'--height-title': '56px',
|
|
104
|
+
[`.${drawerGlobalClasses.title}`]: {
|
|
105
|
+
display: 'flex',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
height: 'var(--height-title)',
|
|
108
|
+
padding: '0 12px',
|
|
109
|
+
gap: '6px'
|
|
110
|
+
},
|
|
111
|
+
[`&.${drawerGlobalClasses.fullHeight}`]: {
|
|
112
|
+
[`.${drawerGlobalClasses.content}`]: {
|
|
113
|
+
height: 'calc(100vh - var(--height-title) - 60px)'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
})
|