@clake/react-bootstrap4-window 0.7.1 → 0.7.2
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/dist/react-bootstrap4-window.js +23 -4
- package/lib/CTable.js +34 -8
- package/lib/CTable.js.map +3 -3
- package/lib/CTableInput.js +2 -2
- package/lib/CTableInput.js.map +2 -2
- package/lib/Drag.js +2 -2
- package/lib/Drag.js.map +2 -2
- package/lib/IconButton.js +2 -2
- package/lib/IconButton.js.map +2 -2
- package/lib/PageBar.js +2 -2
- package/lib/PageBar.js.map +2 -2
- package/lib/TopMenu.js +2 -2
- package/lib/TopMenu.js.map +2 -2
- package/lib/WCalendar.js +2 -2
- package/lib/WCalendar.js.map +2 -2
- package/lib/WCombo.js +2 -2
- package/lib/WCombo.js.map +2 -2
- package/lib/Window.js +2 -2
- package/lib/Window.js.map +2 -2
- package/lib/WindowGroup.js +2 -2
- package/lib/WindowGroup.js.map +2 -2
- package/lib/i18n/CTable.js +2 -2
- package/lib/i18n/CTable.js.map +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
- package/lib/WModal.js +0 -484
- package/lib/WModal.js.map +0 -5
package/lib/WModal.js
DELETED
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
/* @clake/react-bootstrap4-window v0.7.1 | by Clake
|
|
2
|
-
* Copyright (c) 2024 Clake,
|
|
3
|
-
* 2024-03-13T11:37:05+0800
|
|
4
|
-
*/
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
|
-
var _bind = _interopRequireDefault(require("classnames/bind"));
|
|
17
|
-
|
|
18
|
-
var _reactBootstrap = require("@clake/react-bootstrap4");
|
|
19
|
-
|
|
20
|
-
require("./css/WModal.less");
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
-
|
|
24
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
25
|
-
|
|
26
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
|
-
|
|
28
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
|
-
|
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
31
|
-
|
|
32
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
-
|
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
-
|
|
36
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
-
|
|
38
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
39
|
-
|
|
40
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
41
|
-
|
|
42
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
|
-
|
|
44
|
-
var ModalAlert = 0;
|
|
45
|
-
var ModalConfirm = 1;
|
|
46
|
-
var ModalLoading = 2;
|
|
47
|
-
var ModalView = 3;
|
|
48
|
-
var BaseModal = 950;
|
|
49
|
-
var defBtns = {
|
|
50
|
-
ok: 'Ok',
|
|
51
|
-
cancel: 'Cancel'
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var WModal =
|
|
55
|
-
/*#__PURE__*/
|
|
56
|
-
function (_React$Component) {
|
|
57
|
-
_inherits(WModal, _React$Component);
|
|
58
|
-
|
|
59
|
-
function WModal(props) {
|
|
60
|
-
var _this;
|
|
61
|
-
|
|
62
|
-
_classCallCheck(this, WModal);
|
|
63
|
-
|
|
64
|
-
_this = _possibleConstructorReturn(this, _getPrototypeOf(WModal).call(this, props));
|
|
65
|
-
|
|
66
|
-
_defineProperty(_assertThisInitialized(_this), "closeHandler", function (e) {
|
|
67
|
-
if (typeof _this.props.onClose === 'function') {
|
|
68
|
-
_this.props.onClose();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
_defineProperty(_assertThisInitialized(_this), "openHandler", function (e) {
|
|
73
|
-
if (typeof _this.props.onOpen === 'function') {
|
|
74
|
-
_this.props.onOpen();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
_this.state = {
|
|
79
|
-
content: '',
|
|
80
|
-
title: '',
|
|
81
|
-
isCloseBtn: true,
|
|
82
|
-
type: ModalAlert,
|
|
83
|
-
center: _this.props.center,
|
|
84
|
-
fade: _this.props.fade,
|
|
85
|
-
show: false,
|
|
86
|
-
header: true,
|
|
87
|
-
btns: defBtns
|
|
88
|
-
}; //modal type
|
|
89
|
-
|
|
90
|
-
_this.modalType = ModalAlert; //alert confirm callback function
|
|
91
|
-
|
|
92
|
-
_this.callback = null;
|
|
93
|
-
_this.domId = 'modal-' + _reactBootstrap.Common.RandomString(16);
|
|
94
|
-
|
|
95
|
-
if (_this.props.id) {
|
|
96
|
-
_this.domId = _this.props.id;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
_this.offsetIndex = document.querySelectorAll(".modal").length * 10;
|
|
100
|
-
_this.is_open = false;
|
|
101
|
-
_this.fadeTime = {
|
|
102
|
-
open: 0,
|
|
103
|
-
close: 0
|
|
104
|
-
};
|
|
105
|
-
return _this;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
_createClass(WModal, [{
|
|
109
|
-
key: "shouldComponentUpdate",
|
|
110
|
-
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
111
|
-
return this.state.content !== nextState.content;
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "componentDidMount",
|
|
115
|
-
value: function componentDidMount() {}
|
|
116
|
-
}, {
|
|
117
|
-
key: "componentWillUnmount",
|
|
118
|
-
value: function componentWillUnmount() {}
|
|
119
|
-
}, {
|
|
120
|
-
key: "open",
|
|
121
|
-
value: function open() {
|
|
122
|
-
var _this2 = this;
|
|
123
|
-
|
|
124
|
-
if (this.is_open) {
|
|
125
|
-
clearTimeout(this.fadeTime.open);
|
|
126
|
-
clearTimeout(this.fadeTime.close);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
this._main.classList.add('d-block');
|
|
130
|
-
|
|
131
|
-
this.is_open = true;
|
|
132
|
-
|
|
133
|
-
if (this.state.fade) {
|
|
134
|
-
this.fadeTime.open = setTimeout(function () {
|
|
135
|
-
_this2._shadow.classList.add('modal-show');
|
|
136
|
-
|
|
137
|
-
_this2._dialog.style.opacity = '1';
|
|
138
|
-
_this2._dialog.style.marginTop = '1.75rem';
|
|
139
|
-
}, 150);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
key: "close",
|
|
144
|
-
value: function close() {
|
|
145
|
-
var _this3 = this;
|
|
146
|
-
|
|
147
|
-
if (this.state.fade) {
|
|
148
|
-
this._dialog.style.opacity = '0';
|
|
149
|
-
this._dialog.style.marginTop = '-1rem';
|
|
150
|
-
|
|
151
|
-
this._shadow.classList.remove('modal-show');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this.fadeTime.close = setTimeout(function () {
|
|
155
|
-
if (_this3 !== null && _this3 !== void 0 && _this3._main) {
|
|
156
|
-
_this3._main.classList.remove('d-block');
|
|
157
|
-
|
|
158
|
-
_this3.is_open = false;
|
|
159
|
-
}
|
|
160
|
-
}, 150);
|
|
161
|
-
}
|
|
162
|
-
}, {
|
|
163
|
-
key: "alert",
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* modal alert method
|
|
167
|
-
* opt example
|
|
168
|
-
* {
|
|
169
|
-
* title: '',
|
|
170
|
-
* content: ''
|
|
171
|
-
* [,callback: func]
|
|
172
|
-
* }
|
|
173
|
-
* @param opt object
|
|
174
|
-
*/
|
|
175
|
-
value: function alert(opt, cb) {
|
|
176
|
-
var _this4 = this;
|
|
177
|
-
|
|
178
|
-
this.callback = opt.callback || cb || null;
|
|
179
|
-
this.modalType = ModalAlert;
|
|
180
|
-
this.setState({
|
|
181
|
-
title: opt.title || 'Prompt',
|
|
182
|
-
content: opt.content || opt || '',
|
|
183
|
-
isCloseBtn: true,
|
|
184
|
-
type: ModalAlert,
|
|
185
|
-
center: opt.center || this.props.center,
|
|
186
|
-
fade: opt.fade || this.props.fade,
|
|
187
|
-
header: typeof opt.header === 'undefined' ? true : opt.header,
|
|
188
|
-
btns: typeof opt.btns != 'undefined' ? opt.btns : defBtns
|
|
189
|
-
}, function () {
|
|
190
|
-
_this4.open({
|
|
191
|
-
backdrop: 'static',
|
|
192
|
-
keyboard: false
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* modal confirm method
|
|
198
|
-
* opt example
|
|
199
|
-
* {
|
|
200
|
-
* title:'',
|
|
201
|
-
* content:'',
|
|
202
|
-
* [callback: func]
|
|
203
|
-
* }
|
|
204
|
-
* @param opt
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
}, {
|
|
208
|
-
key: "confirm",
|
|
209
|
-
value: function confirm(opt, cb) {
|
|
210
|
-
var _this5 = this;
|
|
211
|
-
|
|
212
|
-
this.callback = opt.callback || cb || null;
|
|
213
|
-
this.modalType = ModalConfirm;
|
|
214
|
-
this.setState({
|
|
215
|
-
title: opt.title || 'Prompt',
|
|
216
|
-
content: opt.content || '',
|
|
217
|
-
isCloseBtn: true,
|
|
218
|
-
type: ModalConfirm,
|
|
219
|
-
center: opt.center || this.props.center,
|
|
220
|
-
fade: opt.fade || this.props.fade,
|
|
221
|
-
header: typeof opt.header === 'undefined' ? true : opt.header,
|
|
222
|
-
btns: typeof opt.btns != 'undefined' ? opt.btns : defBtns
|
|
223
|
-
}, function () {
|
|
224
|
-
_this5.open({
|
|
225
|
-
backdrop: 'static',
|
|
226
|
-
keyboard: false
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* modal loading method
|
|
232
|
-
* @param opt
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
|
-
}, {
|
|
236
|
-
key: "loading",
|
|
237
|
-
value: function loading(opt) {
|
|
238
|
-
var _this6 = this;
|
|
239
|
-
|
|
240
|
-
this.modalType = ModalLoading;
|
|
241
|
-
this.setState({
|
|
242
|
-
title: opt.title || 'Prompt',
|
|
243
|
-
// content:(
|
|
244
|
-
// <React.Fragment>
|
|
245
|
-
// <Icon icon='spinner'/> {content}
|
|
246
|
-
// </React.Fragment>
|
|
247
|
-
// ),
|
|
248
|
-
content: opt.content || opt || '',
|
|
249
|
-
isCloseBtn: false,
|
|
250
|
-
type: ModalLoading,
|
|
251
|
-
center: opt.center || this.props.center,
|
|
252
|
-
fade: this.props.fade,
|
|
253
|
-
header: opt.header || false
|
|
254
|
-
}, function () {
|
|
255
|
-
_this6.open({
|
|
256
|
-
backdrop: 'static',
|
|
257
|
-
keyboard: false
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* modal view method
|
|
263
|
-
* opt example
|
|
264
|
-
* {
|
|
265
|
-
* title:'',
|
|
266
|
-
* content:flex,
|
|
267
|
-
* [callback:func]
|
|
268
|
-
* }
|
|
269
|
-
* @param opt
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
|
-
}, {
|
|
273
|
-
key: "view",
|
|
274
|
-
value: function view(opt) {
|
|
275
|
-
var _this7 = this;
|
|
276
|
-
|
|
277
|
-
this.callback = opt.callback || null;
|
|
278
|
-
this.modalType = ModalView;
|
|
279
|
-
this.setState({
|
|
280
|
-
title: opt.title || 'Prompt',
|
|
281
|
-
content: opt.content || '',
|
|
282
|
-
isCloseBtn: true,
|
|
283
|
-
type: ModalView,
|
|
284
|
-
center: opt.center || this.props.center,
|
|
285
|
-
fade: opt.fade || this.props.fade,
|
|
286
|
-
header: typeof opt.header === 'undefined' ? true : opt.header
|
|
287
|
-
}, function () {
|
|
288
|
-
_this7.open({
|
|
289
|
-
backdrop: 'static',
|
|
290
|
-
keyboard: false
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}, {
|
|
295
|
-
key: "getMainClasses",
|
|
296
|
-
value: function getMainClasses() {
|
|
297
|
-
var base = 'wmodal-main';
|
|
298
|
-
|
|
299
|
-
if (this.state.fade) {
|
|
300
|
-
base = (0, _bind["default"])(base, 'wmodal-fade');
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return (0, _bind["default"])(base, this.props.className);
|
|
304
|
-
}
|
|
305
|
-
}, {
|
|
306
|
-
key: "getClasses",
|
|
307
|
-
value: function getClasses() {
|
|
308
|
-
var base = 'modal wmodal-sm d-block';
|
|
309
|
-
|
|
310
|
-
if (this.modalType === ModalView) {
|
|
311
|
-
base = (0, _bind["default"])(base, "bd-example-modal-lg");
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (this.state.fade) {
|
|
315
|
-
base = (0, _bind["default"])(base, 'wmodal-fade');
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return (0, _bind["default"])(base, this.props.className);
|
|
319
|
-
}
|
|
320
|
-
}, {
|
|
321
|
-
key: "getDialogStyles",
|
|
322
|
-
value: function getDialogStyles() {
|
|
323
|
-
var base = {};
|
|
324
|
-
|
|
325
|
-
if (this.state.width) {
|
|
326
|
-
base['maxWidth'] = this.state.width;
|
|
327
|
-
} else if (this.props.width) {
|
|
328
|
-
base['maxWidth'] = this.props.width;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return base;
|
|
332
|
-
}
|
|
333
|
-
}, {
|
|
334
|
-
key: "getDialogClasses",
|
|
335
|
-
value: function getDialogClasses() {
|
|
336
|
-
var base = 'modal-dialog';
|
|
337
|
-
|
|
338
|
-
if (this.modalType === ModalView) {
|
|
339
|
-
base = (0, _bind["default"])(base, "modal-lg");
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (this.state.center) {
|
|
343
|
-
base = (0, _bind["default"])(base, "modal-dialog-centered");
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return (0, _bind["default"])(base, this.props.className);
|
|
347
|
-
}
|
|
348
|
-
}, {
|
|
349
|
-
key: "getShadowClasses",
|
|
350
|
-
value: function getShadowClasses() {
|
|
351
|
-
var base = 'modal-backdrop ck-modal-shadow show';
|
|
352
|
-
return (0, _bind["default"])(base, this.props.className);
|
|
353
|
-
}
|
|
354
|
-
}, {
|
|
355
|
-
key: "renderFooter",
|
|
356
|
-
value: function renderFooter() {
|
|
357
|
-
var _this8 = this;
|
|
358
|
-
|
|
359
|
-
var content = null;
|
|
360
|
-
|
|
361
|
-
switch (this.state.type) {
|
|
362
|
-
case ModalAlert:
|
|
363
|
-
content = _react["default"].createElement(_reactBootstrap.Button, {
|
|
364
|
-
className: "w-100",
|
|
365
|
-
size: "sm",
|
|
366
|
-
"data-dismiss": "modal",
|
|
367
|
-
onClick: function onClick(e) {
|
|
368
|
-
_this8.close();
|
|
369
|
-
|
|
370
|
-
if (typeof _this8.callback === 'function') {
|
|
371
|
-
_this8.callback(1);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}, this.state.btns['ok']);
|
|
375
|
-
break;
|
|
376
|
-
|
|
377
|
-
case ModalConfirm:
|
|
378
|
-
content = _react["default"].createElement("div", {
|
|
379
|
-
className: "row flex-grow-1 g-1"
|
|
380
|
-
}, _react["default"].createElement(_reactBootstrap.ButtonGroup, null, _react["default"].createElement(_reactBootstrap.Button, {
|
|
381
|
-
className: "col-6",
|
|
382
|
-
size: "sm",
|
|
383
|
-
onClick: function onClick() {
|
|
384
|
-
_this8.close();
|
|
385
|
-
|
|
386
|
-
if (typeof _this8.callback === 'function') {
|
|
387
|
-
_this8.callback(1);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}, this.state.btns['ok']), _react["default"].createElement(_reactBootstrap.Button, {
|
|
391
|
-
className: "col-6",
|
|
392
|
-
size: "sm",
|
|
393
|
-
onClick: function onClick() {
|
|
394
|
-
_this8.close();
|
|
395
|
-
|
|
396
|
-
if (typeof _this8.callback === 'function') {
|
|
397
|
-
_this8.callback(0);
|
|
398
|
-
}
|
|
399
|
-
},
|
|
400
|
-
theme: "secondary"
|
|
401
|
-
}, this.state.btns['cancel'])));
|
|
402
|
-
break;
|
|
403
|
-
|
|
404
|
-
default:
|
|
405
|
-
return null;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return _react["default"].createElement("div", {
|
|
409
|
-
className: "modal-footer"
|
|
410
|
-
}, content);
|
|
411
|
-
}
|
|
412
|
-
}, {
|
|
413
|
-
key: "render",
|
|
414
|
-
value: function render() {
|
|
415
|
-
var _this9 = this;
|
|
416
|
-
|
|
417
|
-
var modalIndex = {
|
|
418
|
-
zIndex: BaseModal + this.offsetIndex + 2
|
|
419
|
-
};
|
|
420
|
-
var shadowIndex = {
|
|
421
|
-
zIndex: BaseModal + this.offsetIndex + 1
|
|
422
|
-
};
|
|
423
|
-
return _react["default"].createElement("div", {
|
|
424
|
-
ref: function ref(c) {
|
|
425
|
-
return _this9._main = c;
|
|
426
|
-
},
|
|
427
|
-
className: this.getMainClasses()
|
|
428
|
-
}, _react["default"].createElement("div", {
|
|
429
|
-
ref: function ref(c) {
|
|
430
|
-
return _this9._shadow = c;
|
|
431
|
-
},
|
|
432
|
-
className: this.getShadowClasses(),
|
|
433
|
-
style: shadowIndex,
|
|
434
|
-
id: "".concat(this.domId, "-shadow")
|
|
435
|
-
}), _react["default"].createElement("div", {
|
|
436
|
-
className: this.getClasses(),
|
|
437
|
-
style: modalIndex,
|
|
438
|
-
tabIndex: "-1",
|
|
439
|
-
id: this.domId,
|
|
440
|
-
role: "dialog"
|
|
441
|
-
}, _react["default"].createElement("div", {
|
|
442
|
-
ref: function ref(c) {
|
|
443
|
-
return _this9._dialog = c;
|
|
444
|
-
},
|
|
445
|
-
className: this.getDialogClasses(),
|
|
446
|
-
style: this.getDialogStyles(),
|
|
447
|
-
role: "document"
|
|
448
|
-
}, _react["default"].createElement("div", {
|
|
449
|
-
className: "modal-content"
|
|
450
|
-
}, this.state.header ? _react["default"].createElement("div", {
|
|
451
|
-
className: "modal-header"
|
|
452
|
-
}, _react["default"].createElement("h6", {
|
|
453
|
-
className: "modal-title"
|
|
454
|
-
}, this.state.title), this.state.isCloseBtn ? _react["default"].createElement("button", {
|
|
455
|
-
type: "button",
|
|
456
|
-
className: "btn-close",
|
|
457
|
-
onClick: function onClick() {
|
|
458
|
-
_this9.close();
|
|
459
|
-
}
|
|
460
|
-
}) : null) : null, _react["default"].createElement("div", {
|
|
461
|
-
className: "modal-body"
|
|
462
|
-
}, this.state.type === ModalLoading ? _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(_reactBootstrap.Load, null), "\xA0\xA0\xA0", this.state.content) : this.state.content), this.renderFooter()))));
|
|
463
|
-
}
|
|
464
|
-
}]);
|
|
465
|
-
|
|
466
|
-
return WModal;
|
|
467
|
-
}(_react["default"].Component);
|
|
468
|
-
|
|
469
|
-
WModal.propTypes = {
|
|
470
|
-
onOpen: _propTypes["default"].func,
|
|
471
|
-
onClose: _propTypes["default"].func,
|
|
472
|
-
center: _propTypes["default"].bool,
|
|
473
|
-
fade: _propTypes["default"].bool,
|
|
474
|
-
blurSelector: _propTypes["default"].string,
|
|
475
|
-
width: _propTypes["default"].string
|
|
476
|
-
};
|
|
477
|
-
WModal.defaultProps = {
|
|
478
|
-
center: false,
|
|
479
|
-
width: '300px',
|
|
480
|
-
fade: true
|
|
481
|
-
};
|
|
482
|
-
var _default = WModal;
|
|
483
|
-
exports["default"] = _default;
|
|
484
|
-
//# sourceMappingURL=WModal.js.map
|
package/lib/WModal.js.map
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/* @clake/react-bootstrap4-window v0.7.1 | by Clake
|
|
2
|
-
* Copyright (c) 2024 Clake,
|
|
3
|
-
* 2024-03-13T11:37:05+0800
|
|
4
|
-
*/
|
|
5
|
-
{"version":3,"sources":["WModal.js"],"names":["ModalAlert","ModalConfirm","ModalLoading","ModalView","BaseModal","defBtns","ok","cancel","WModal","props","e","onClose","onOpen","state","content","title","isCloseBtn","type","center","fade","show","header","btns","modalType","callback","domId","Common","RandomString","id","offsetIndex","document","querySelectorAll","length","is_open","fadeTime","open","close","nextProps","nextState","clearTimeout","_main","classList","add","setTimeout","_shadow","_dialog","style","opacity","marginTop","remove","opt","cb","setState","backdrop","keyboard","base","className","width","modalIndex","zIndex","shadowIndex","c","getMainClasses","getShadowClasses","getClasses","getDialogClasses","getDialogStyles","renderFooter","React","Component","propTypes","PropTypes","func","bool","blurSelector","string","defaultProps"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,CAAnB;AACA,IAAMC,YAAY,GAAG,CAArB;AACA,IAAMC,YAAY,GAAG,CAArB;AACA,IAAMC,SAAS,GAAG,CAAlB;AACA,IAAMC,SAAS,GAAG,GAAlB;AAEA,IAAMC,OAAO,GAAG;AACZC,EAAAA,EAAE,EAAC,IADS;AAEZC,EAAAA,MAAM,EAAC;AAFK,CAAhB;;IAKMC,M;;;;;AACF,kBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACf,gFAAMA,KAAN;;AADe,mEAyEJ,UAACC,CAAD,EAAK;AAChB,UAAI,OAAO,MAAKD,KAAL,CAAWE,OAAlB,KAA8B,UAAlC,EAA8C;AAC1C,cAAKF,KAAL,CAAWE,OAAX;AACH;AACJ,KA7EkB;;AAAA,kEA+EL,UAACD,CAAD,EAAM;AAChB,UAAI,OAAO,MAAKD,KAAL,CAAWG,MAAlB,KAA6B,UAAjC,EAA6C;AACzC,cAAKH,KAAL,CAAWG,MAAX;AACH;AACJ,KAnFkB;;AAEf,UAAKC,KAAL,GAAa;AACTC,MAAAA,OAAO,EAAC,EADC;AAETC,MAAAA,KAAK,EAAC,EAFG;AAGTC,MAAAA,UAAU,EAAC,IAHF;AAITC,MAAAA,IAAI,EAACjB,UAJI;AAKTkB,MAAAA,MAAM,EAAC,MAAKT,KAAL,CAAWS,MALT;AAMTC,MAAAA,IAAI,EAAC,MAAKV,KAAL,CAAWU,IANP;AAOTC,MAAAA,IAAI,EAAC,KAPI;AAQTC,MAAAA,MAAM,EAAC,IARE;AASTC,MAAAA,IAAI,EAACjB;AATI,KAAb,CAFe,CAaf;;AACA,UAAKkB,SAAL,GAAiBvB,UAAjB,CAde,CAef;;AACA,UAAKwB,QAAL,GAAgB,IAAhB;AAEA,UAAKC,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AAAA,MAAM,EAAC,KADW;AAElBuC,EAAAA,KAAK,EAAE,OAFW;AAGlBtC,EAAAA,IAAI,EAAC;AAHa,CAAtB;eAMeX,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames/bind';\nimport {\n Button,\n Load,\n Common,\n ButtonGroup\n} from '@clake/react-bootstrap4';\nimport './css/WModal.less';\n\nconst ModalAlert = 0;\nconst ModalConfirm = 1;\nconst ModalLoading = 2;\nconst ModalView = 3;\nconst BaseModal = 950;\n\nconst defBtns = {\n ok:'Ok',\n cancel:'Cancel',\n};\n\nclass WModal extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n content:'',\n title:'',\n isCloseBtn:true,\n type:ModalAlert,\n center:this.props.center,\n fade:this.props.fade,\n show:false,\n header:true,\n btns:defBtns,\n };\n //modal type\n this.modalType = ModalAlert;\n //alert confirm callback function\n this.callback = null;\n\n this.domId = 'modal-'+Common.RandomString(16);\n if (this.props.id) {\n this.domId = this.props.id;\n }\n this.offsetIndex = document.querySelectorAll(\".modal\").length * 10;\n this.is_open = false;\n this.fadeTime = {\n open:0,\n close:0\n };\n }\n\n shouldComponentUpdate(nextProps, nextState) {\n return this.state.content !== nextState.content\n }\n\n componentDidMount() {\n\n }\n\n componentWillUnmount() {\n\n }\n\n open() {\n if (this.is_open) {\n clearTimeout(this.fadeTime.open);\n clearTimeout(this.fadeTime.close);\n }\n\n this._main.classList.add('d-block');\n this.is_open = true;\n if (this.state.fade) {\n this.fadeTime.open = setTimeout(()=>{\n this._shadow.classList.add('modal-show');\n this._dialog.style.opacity = '1';\n this._dialog.style.marginTop = '1.75rem';\n },150);\n }\n }\n\n close() {\n if (this.state.fade) {\n this._dialog.style.opacity = '0';\n this._dialog.style.marginTop = '-1rem';\n this._shadow.classList.remove('modal-show');\n }\n this.fadeTime.close = setTimeout(()=>{\n if (this?._main) {\n this._main.classList.remove('d-block');\n this.is_open = false;\n }\n },150);\n }\n\n closeHandler = (e)=>{\n if (typeof this.props.onClose === 'function') {\n this.props.onClose();\n }\n };\n\n openHandler = (e) =>{\n if (typeof this.props.onOpen === 'function') {\n this.props.onOpen();\n }\n };\n\n /**\n * modal alert method\n * opt example\n * {\n * title: '',\n * content: ''\n * [,callback: func]\n * }\n * @param opt object\n */\n alert(opt,cb) {\n this.callback = opt.callback||cb||null;\n this.modalType = ModalAlert;\n this.setState({\n title:opt.title||'Prompt',\n content:opt.content||opt||'',\n isCloseBtn:true,\n type:ModalAlert,\n center:opt.center||this.props.center,\n fade:opt.fade||this.props.fade,\n header: typeof opt.header === 'undefined' ? true:opt.header,\n btns: typeof opt.btns != 'undefined' ? opt.btns:defBtns,\n },()=>{\n this.open({\n backdrop:'static',\n keyboard:false,\n });\n });\n }\n\n /**\n * modal confirm method\n * opt example\n * {\n * title:'',\n * content:'',\n * [callback: func]\n * }\n * @param opt\n */\n confirm(opt,cb) {\n this.callback = opt.callback||cb||null;\n this.modalType = ModalConfirm;\n this.setState({\n title:opt.title||'Prompt',\n content:opt.content||'',\n isCloseBtn:true,\n type:ModalConfirm,\n center:opt.center||this.props.center,\n fade:opt.fade||this.props.fade,\n header: typeof opt.header === 'undefined' ? true:opt.header,\n btns: typeof opt.btns != 'undefined' ? opt.btns:defBtns,\n },()=>{\n this.open({\n backdrop:'static',\n keyboard:false,\n });\n });\n }\n\n /**\n * modal loading method\n * @param opt\n */\n loading(opt) {\n this.modalType = ModalLoading;\n this.setState({\n title:opt.title||'Prompt',\n // content:(\n // <React.Fragment>\n // <Icon icon='spinner'/> {content}\n // </React.Fragment>\n // ),\n content:opt.content||opt||'',\n isCloseBtn:false,\n type:ModalLoading,\n center:opt.center||this.props.center,\n fade:this.props.fade,\n header: opt.header||false,\n },()=>{\n this.open({\n backdrop:'static',\n keyboard:false,\n });\n });\n }\n\n /**\n * modal view method\n * opt example\n * {\n * title:'',\n * content:flex,\n * [callback:func]\n * }\n * @param opt\n */\n view(opt) {\n this.callback = opt.callback||null;\n this.modalType = ModalView;\n this.setState({\n title:opt.title||'Prompt',\n content:opt.content||'',\n isCloseBtn:true,\n type:ModalView,\n center:opt.center||this.props.center,\n fade:opt.fade||this.props.fade,\n header: typeof opt.header === 'undefined' ? true:opt.header\n },()=>{\n this.open({\n backdrop:'static',\n keyboard:false,\n });\n });\n }\n\n getMainClasses() {\n let base = 'wmodal-main';\n\n if (this.state.fade) {\n base = classNames(base,'wmodal-fade');\n }\n\n return classNames(base,this.props.className);\n }\n\n getClasses() {\n let base = 'modal wmodal-sm d-block';\n if (this.modalType === ModalView) {\n base = classNames(base,\"bd-example-modal-lg\");\n }\n\n if (this.state.fade) {\n base = classNames(base,'wmodal-fade');\n }\n\n return classNames(base,this.props.className);\n }\n\n getDialogStyles() {\n let base = {};\n if (this.state.width) {\n base['maxWidth'] = this.state.width;\n } else if (this.props.width) {\n base['maxWidth'] = this.props.width;\n }\n return base;\n }\n\n getDialogClasses() {\n let base = 'modal-dialog';\n if (this.modalType === ModalView) {\n base = classNames(base,\"modal-lg\");\n }\n if (this.state.center) {\n base = classNames(base,\"modal-dialog-centered\");\n }\n\n return classNames(base,this.props.className);\n }\n\n getShadowClasses() {\n let base = 'modal-backdrop ck-modal-shadow show';\n\n return classNames(base,this.props.className);\n }\n\n renderFooter() {\n let content = null;\n switch (this.state.type) {\n case ModalAlert:\n content = (\n <Button className=\"w-100\" size='sm' data-dismiss=\"modal\" onClick={e=>{\n this.close();\n if (typeof this.callback === 'function') {\n this.callback(1);\n }\n }}>{this.state.btns['ok']}</Button>\n );\n break;\n case ModalConfirm:\n content = (\n <div className='row flex-grow-1 g-1'>\n <ButtonGroup>\n <Button className='col-6' size='sm' onClick={()=>{\n this.close();\n if (typeof this.callback === 'function') {\n this.callback(1);\n }\n }}>{this.state.btns['ok']}</Button>\n <Button className='col-6' size='sm' onClick={()=>{\n this.close();\n if (typeof this.callback === 'function') {\n this.callback(0);\n }\n }} theme='secondary'>{this.state.btns['cancel']}</Button>\n </ButtonGroup>\n </div>\n );\n break;\n default:\n return null;\n }\n\n return (\n <div className=\"modal-footer\">\n {content}\n </div>\n )\n }\n\n render() {\n let modalIndex = {zIndex:BaseModal+this.offsetIndex+2};\n let shadowIndex = {zIndex:BaseModal+this.offsetIndex+1};\n return (\n <div ref={c=>this._main=c} className={this.getMainClasses()}>\n <div ref={c=>this._shadow=c} className={this.getShadowClasses()} style={shadowIndex} id={`${this.domId}-shadow`}/>\n <div className={this.getClasses()} style={modalIndex} tabIndex=\"-1\" id={this.domId} role=\"dialog\">\n <div ref={c=>this._dialog=c} className={this.getDialogClasses()} style={this.getDialogStyles()} role=\"document\">\n <div className=\"modal-content\">\n {this.state.header?<div className=\"modal-header\">\n <h6 className=\"modal-title\">{this.state.title}</h6>\n {this.state.isCloseBtn?<button type=\"button\" className=\"btn-close\" onClick={()=>{\n this.close();\n }}>\n </button>:null}\n </div>:null}\n <div className=\"modal-body\">\n {this.state.type === ModalLoading?<React.Fragment>\n <Load/> {this.state.content}\n </React.Fragment>:this.state.content}\n </div>\n {this.renderFooter()}\n </div>\n </div>\n </div>\n </div>\n );\n }\n}\n\nWModal.propTypes = {\n onOpen: PropTypes.func,\n onClose: PropTypes.func,\n center: PropTypes.bool,\n fade: PropTypes.bool,\n blurSelector: PropTypes.string,\n width: PropTypes.string\n};\n\nWModal.defaultProps = {\n center:false,\n width: '300px',\n fade:true,\n};\n\nexport default WModal;"],"file":"WModal.js"}
|