blue-react 9.12.1 → 10.0.0-rc1

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.
@@ -1,366 +1,86 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- exports.default = void 0;
6
+ exports.default = Layout;
9
7
 
10
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
11
9
 
12
- var _SidebarToggler = _interopRequireDefault(require("./SidebarToggler"));
10
+ require("blue-web/dist/js/side-layout");
13
11
 
14
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
13
 
16
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
-
22
- 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); } }
23
-
24
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
25
-
26
- 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
-
28
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
-
30
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
31
-
32
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
33
-
34
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
35
-
36
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
37
-
38
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
-
40
- window.toggleSidebarEvent = new CustomEvent("toggleSidebar");
41
-
42
- /**
43
- * The main component. As soon this component is mounted, it is globally available under `window.blueLayoutRef`.
44
- * You can also append your own event listeners.
45
- *
46
- * Allowed events:
47
- *
48
- * * **componentDidUpdate** - Component was updated.
49
- * Example: `window.blueLayoutRef.addEventListener("componentDidUpdate", (prevProps, prevState) => { })`
50
- * * **pageDidShowAgain** - Page appeared again with the same old state. In the callback function you can reinitialize things.
51
- * Example: `window.blueLayoutRef.addEventListener("pageDidShowAgain", "home", (prevProps, prevState) => { })`
52
- * * **pageDidHide** - This page disappeared and another page appears instead.
53
- * Example: `window.blueLayoutRef.addEventListener("pageDidHide", "home", (prevProps, prevState) => { })`
54
- *
55
- * Method to add event listeners:
56
- * * `window.blueLayoutRef.`**addEventListener**`(eventName: string, param2: any, param3: any, listenerId?: string)`
57
- *
58
- * Methods to remove event listeners:
59
- * * `window.blueLayoutRef.`**removeEventListener**`(eventName: string, listenerId: string)`
60
- * * `window.blueLayoutRef.`**removeDuplicatedEventListeners**`()` - Will automatically be called when running `addEventListener`
61
- */
62
- var Layout = /*#__PURE__*/function (_Component) {
63
- _inherits(Layout, _Component);
64
-
65
- var _super = _createSuper(Layout);
66
-
67
- function Layout(props) {
68
- var _this;
69
-
70
- _classCallCheck(this, Layout);
71
-
72
- _this = _super.call(this, props);
73
- window.blueLayoutRef = _assertThisInitialized(_this);
74
- _this.defaultMatch = ["home"];
75
- var expandSidebar = props.hideSidebarMenu ? false : props.expandSidebar !== undefined ? props.expandSidebar : localStorage.getItem("blueLayoutShrinkSidebar") === null;
76
- _this.state = {
77
- sidebarIn: props.sidebarIn || false,
78
- expandSidebar: expandSidebar,
79
- match: null,
80
- history: [],
81
- hash: window.location.hash,
82
- hashHistory: [],
83
- blockRouting: props.blockRouting || undefined
84
- };
85
- _this.hideSidebar = _this.hideSidebar.bind(_assertThisInitialized(_this));
86
- _this.toggleExpandSidebar = _this.toggleExpandSidebar.bind(_assertThisInitialized(_this));
87
- _this.eventListeners = [];
88
- if (_this.props.onChangeExpandSidebar) _this.props.onChangeExpandSidebar(expandSidebar);
89
- return _this;
90
- }
91
-
92
- _createClass(Layout, [{
93
- key: "onHashChange",
94
- value: function onHashChange() {
95
- window.blueLayoutRef.initMatch();
96
- }
97
- }, {
98
- key: "componentDidMount",
99
- value: function componentDidMount() {
100
- var _this2 = this;
101
-
102
- var me = this;
103
- document.addEventListener("toggleSidebar", function () {
104
- _this2.toggleSidebar(undefined);
105
- }, false);
106
- this.initMatch();
107
- document.addEventListener("touchstart", function (event) {
108
- var xPos = event.touches[0].pageX;
109
-
110
- if (xPos < 5) {
111
- me.toggleSidebar(event);
112
- } else if (me.state.sidebarIn && xPos > 20) {
113
- me.toggleSidebar(event);
114
- }
115
- });
116
- window.addEventListener("hashchange", this.onHashChange);
117
- }
118
- }, {
119
- key: "componentWillUnmount",
120
- value: function componentWillUnmount() {
121
- window.removeEventListener("hashchange", this.onHashChange);
122
- }
123
- }, {
124
- key: "componentDidUpdate",
125
- value: function componentDidUpdate(prevProps, prevState) {
126
- var _this3 = this;
127
-
128
- if (prevProps.sidebarIn !== this.props.sidebarIn) {
129
- this.setState({
130
- sidebarIn: this.props.sidebarIn || false
131
- });
132
- }
133
-
134
- if (this.props.onChangeSidebarIn && prevState.sidebarIn !== this.state.sidebarIn) {
135
- this.props.onChangeSidebarIn(this.state.sidebarIn);
136
- }
137
-
138
- if (prevProps.expandSidebar !== this.props.expandSidebar) {
139
- this.setState({
140
- expandSidebar: this.props.expandSidebar || false
141
- });
142
- }
143
-
144
- if (this.props.onChangeExpandSidebar && prevState.expandSidebar !== this.state.expandSidebar) {
145
- this.props.onChangeExpandSidebar(this.state.expandSidebar);
146
- }
147
-
148
- if (prevProps.blockRouting !== this.props.blockRouting && this.props.blockRouting !== this.state.blockRouting) {
149
- this.setState({
150
- blockRouting: this.props.blockRouting
151
- });
152
- }
153
-
154
- this.eventListeners.forEach(function (eventListener) {
155
- if (eventListener[0] === "componentDidUpdate") {
156
- eventListener[1](prevProps, prevState);
157
- }
158
-
159
- if (eventListener[0] === "pageDidShowAgain") {
160
- var pageId = eventListener[1];
161
- var callback = eventListener[2];
162
-
163
- if (prevState.hash !== _this3.state.hash && _this3.state.match[0] === pageId) {
164
- callback(prevProps, prevState);
165
- }
166
- }
167
-
168
- if (eventListener[0] === "pageDidHide") {
169
- var _pageId = eventListener[1];
170
- var _callback = eventListener[2];
171
-
172
- if (prevState.hash !== _this3.state.hash && prevState.match[0] === _pageId) {
173
- _callback(prevProps, prevState);
174
- }
175
- }
176
- });
177
- }
178
- }, {
179
- key: "toggleSidebar",
180
- value: function toggleSidebar(event) {
181
- if (this.state.sidebarIn) {
182
- this.hideSidebar(event);
183
- }
184
-
185
- this.setState({
186
- sidebarIn: true
187
- });
14
+ function Layout(_ref) {
15
+ var children = _ref.children,
16
+ header = _ref.header,
17
+ side = _ref.side,
18
+ _ref$pageBorder = _ref.pageBorder,
19
+ pageBorder = _ref$pageBorder === void 0 ? true : _ref$pageBorder;
20
+ return /*#__PURE__*/_react.default.createElement("div", {
21
+ style: {
22
+ height: "100vh"
188
23
  }
189
- }, {
190
- key: "hideSidebar",
191
- value: function hideSidebar(e) {
192
- if (!(e.target.classList.contains("blue-open-menu") || e.target.classList.contains("bi-menu") || e.target.classList.contains("blue-search") || e.target.classList.contains("blue-search-control") || e.target.classList.contains("blue-search-btn") || e.target.classList.contains("blue-search-btn-icon") || e.target.classList.contains("blue-menu-item-dropdown-toggle") || e.target.classList.contains("blue-menu-item-dropdown-caret") || e.target.classList.contains("blue-menu-item-dropdown-icon") || e.target.classList.contains("blue-sidebar-exception"))) {
193
- this.setState({
194
- sidebarIn: false
195
- });
196
- }
24
+ }, /*#__PURE__*/_react.default.createElement("side-layout", {
25
+ style: {
26
+ "--base-z-index": 500
197
27
  }
198
- }, {
199
- key: "initMatch",
200
- value: function initMatch() {
201
- var newMatch;
202
-
203
- if (window.location.hash && window.location.hash !== "" && window.location.hash !== "#/") {
204
- newMatch = window.location.hash.replace("#", "").split("/").filter(function (n) {
205
- return n !== "";
206
- });
207
- } else {
208
- newMatch = this.defaultMatch;
209
- }
210
-
211
- if (this.props.unrouteable) {
212
- newMatch = this.defaultMatch;
213
- }
214
-
215
- if (this.state.blockRouting && this.state.blockRouting(newMatch, this.state.match) === true) {
216
- window.location.hash = this.state.hash;
217
- } else {
218
- if (!(this.state.history.indexOf(newMatch[0]) > -1)) {
219
- this.state.history.push(newMatch[0]);
220
- }
221
-
222
- this.setState({
223
- match: newMatch,
224
- history: this.state.history,
225
- hash: window.location.hash,
226
- hashHistory: this.state.hashHistory.concat([window.location.hash])
227
- });
228
- }
229
- }
230
- }, {
231
- key: "addEventListener",
232
- value: function addEventListener(param1, param2, param3, listenerId) {
233
- this.eventListeners.push([param1, param2, param3, listenerId]);
234
- this.removeDuplicatedEventListeners();
235
- }
236
- }, {
237
- key: "removeEventListener",
238
- value: function removeEventListener(type, listenerId) {
239
- this.eventListeners = this.eventListeners.filter(function (param) {
240
- if (param[0] !== type) {
241
- return param;
242
- } else if (param[0] === type && param[3] !== listenerId) {
243
- return param;
244
- }
245
- });
28
+ }, /*#__PURE__*/_react.default.createElement("div", {
29
+ slot: "expand-toggler",
30
+ className: "w-100 h-100",
31
+ style: {
32
+ color: "var(--blue-sidebar-color)",
33
+ background: "var(--blue-sidebar-bg)"
246
34
  }
247
- }, {
248
- key: "removeDuplicatedEventListeners",
249
- value: function removeDuplicatedEventListeners() {
250
- this.eventListeners = this.eventListeners.filter(function (value, index, self) {
251
- return index === self.findIndex(function (t) {
252
- return t[3] === value[3] && t[0] === value[0];
253
- });
254
- });
35
+ }, /*#__PURE__*/_react.default.createElement("div", {
36
+ className: "btn blue-menu-item w-100 h-100 d-flex align-items-center justify-content-center p-0"
37
+ }, /*#__PURE__*/_react.default.createElement("svg", {
38
+ xmlns: "http://www.w3.org/2000/svg",
39
+ viewBox: "0 0 16 16",
40
+ width: "1em",
41
+ height: "1em",
42
+ fill: "currentColor",
43
+ className: "bi bi-layout-sidebar"
44
+ }, /*#__PURE__*/_react.default.createElement("path", {
45
+ d: "M0 3a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zm5-1v12h9a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1zM4 2H2a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h2z"
46
+ })))), /*#__PURE__*/_react.default.createElement("div", {
47
+ slot: "drawer-toggler",
48
+ className: "w-100 h-100",
49
+ style: {
50
+ color: "var(--blue-sidebar-color)",
51
+ background: "var(--blue-sidebar-bg)"
255
52
  }
256
- }, {
257
- key: "toggleExpandSidebar",
258
- value: function toggleExpandSidebar() {
259
- var expandSidebar = this.state.expandSidebar;
260
-
261
- if (expandSidebar) {
262
- localStorage.setItem("blueLayoutShrinkSidebar", "true");
263
- } else {
264
- localStorage.removeItem("blueLayoutShrinkSidebar");
265
- }
266
-
267
- this.setState({
268
- expandSidebar: !expandSidebar
269
- });
270
- }
271
- }, {
272
- key: "render",
273
- value: function render() {
274
- var _this4 = this,
275
- _this$props$pages;
276
-
277
- return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
278
- id: this.props.id ? this.props.id : "",
279
- style: this.props.style ? this.props.style : {},
280
- className: "blue-layout" + (this.props.className ? " " + this.props.className : "") + (this.state.sidebarIn ? " open" : "") + (this.props.hideSidebarMenu ? " hasNoSidebarMenu" : " hasSidebarMenu") + (this.state.expandSidebar ? " expandSidebar" : "") + (this.props.disableHeaders ? " disableHeaders" : "") + (this.props.hideToggleExpandSidebar ? " hideToggleExpandSidebar" : ""),
281
- onClick: this.hideSidebar
282
- }, !this.props.hideSidebarMenu && /*#__PURE__*/_react.default.createElement(_SidebarToggler.default, {
283
- sidebarToggleIconComponent: this.props.sidebarToggleIconComponent,
284
- onClick: function onClick() {
285
- _this4.setState({
286
- sidebarIn: !_this4.state.sidebarIn
287
- });
288
- }
289
- }), !this.props.hideSidebarMenu && !this.props.hideToggleExpandSidebar && /*#__PURE__*/_react.default.createElement(_SidebarToggler.default, {
290
- sidebarToggleIconComponent: this.props.sidebarToggleIconComponent,
291
- onClick: this.toggleExpandSidebar,
292
- className: "d-none d-xxl-block"
293
- }), this.props.children, (_this$props$pages = this.props.pages) === null || _this$props$pages === void 0 ? void 0 : _this$props$pages.map(function (page) {
294
- return _this4.state.history.indexOf(page.name) > -1 && /*#__PURE__*/_react.default.createElement("div", {
295
- key: page.name,
296
- className: "router-page " + (_this4.state.match[0] === page.name ? "active" : "")
297
- }, page.component);
298
- }), this.props.enableStatus && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
299
- className: "blue-status-circle blue-loading blue-status-loading"
300
- }, /*#__PURE__*/_react.default.createElement("div", {
301
- className: "spinner-bounce-circle"
302
- }, /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null))), /*#__PURE__*/_react.default.createElement("div", {
303
- className: "blue-status-circle blue-status-success",
304
- role: "status",
305
- "aria-live": "polite"
306
- }, this.props.statusIcons.success), /*#__PURE__*/_react.default.createElement("div", {
307
- className: "blue-status-circle blue-status-info"
308
- }, this.props.statusIcons.info), /*#__PURE__*/_react.default.createElement("div", {
309
- className: "blue-status-circle blue-status-warning"
310
- }, this.props.statusIcons.warning), /*#__PURE__*/_react.default.createElement("div", {
311
- className: "blue-status-circle blue-status-danger"
312
- }, this.props.statusIcons.danger), /*#__PURE__*/_react.default.createElement("div", {
313
- className: "blue-status-alert alert"
314
- }, /*#__PURE__*/_react.default.createElement("button", {
315
- type: "button",
316
- className: "btn-close float-end mb-1",
317
- "aria-label": "Close"
318
- }), /*#__PURE__*/_react.default.createElement("div", {
319
- className: "alert-body"
320
- })))));
53
+ }, /*#__PURE__*/_react.default.createElement("div", {
54
+ className: "btn blue-menu-item w-100 h-100 d-flex align-items-center justify-content-center p-0"
55
+ }, /*#__PURE__*/_react.default.createElement("svg", {
56
+ xmlns: "http://www.w3.org/2000/svg",
57
+ viewBox: "0 0 16 16",
58
+ width: "1em",
59
+ height: "1em",
60
+ fill: "currentColor",
61
+ className: "bi bi-layout-sidebar-inset"
62
+ }, /*#__PURE__*/_react.default.createElement("path", {
63
+ d: "M14 2a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zM2 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2z"
64
+ }), /*#__PURE__*/_react.default.createElement("path", {
65
+ d: "M3 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z"
66
+ })))), /*#__PURE__*/_react.default.createElement("div", {
67
+ slot: "overlay",
68
+ className: "bg-dark w-100 h-100",
69
+ style: {
70
+ "--bs-bg-opacity": 0.5
321
71
  }
322
- }], [{
323
- key: "defaultProps",
324
- get: function get() {
325
- return {
326
- hideSidebarMenu: false,
327
- unrouteable: false,
328
- disableTitleSet: false,
329
- sidebarToggleIconComponent: /*#__PURE__*/_react.default.createElement("svg", {
330
- xmlns: "http://www.w3.org/2000/svg",
331
- width: "1em",
332
- height: "1em",
333
- fill: "currentColor",
334
- viewBox: "0 0 16 16",
335
- style: {
336
- display: "inline-block",
337
- verticalAlign: "-0.125em"
338
- }
339
- }, /*#__PURE__*/_react.default.createElement("path", {
340
- fillRule: "evenodd",
341
- d: "M2.5 12a.5.5 0 01.5-.5h10a.5.5 0 010 1H3a.5.5 0 01-.5-.5zm0-4a.5.5 0 01.5-.5h10a.5.5 0 010 1H3a.5.5 0 01-.5-.5zm0-4a.5.5 0 01.5-.5h10a.5.5 0 010 1H3a.5.5 0 01-.5-.5z"
342
- })),
343
- enableStatus: true,
344
- statusIcons: {
345
- danger: /*#__PURE__*/_react.default.createElement("span", {
346
- className: "bi-error"
347
- }),
348
- info: /*#__PURE__*/_react.default.createElement("span", {
349
- className: "bi-information"
350
- }),
351
- success: /*#__PURE__*/_react.default.createElement("span", {
352
- className: "bi-check"
353
- }),
354
- warning: /*#__PURE__*/_react.default.createElement("span", {
355
- className: "bi-sign_warning"
356
- })
357
- },
358
- hideToggleExpandSidebar: false
359
- };
72
+ }), /*#__PURE__*/_react.default.createElement("header", {
73
+ slot: "header"
74
+ }, header), /*#__PURE__*/_react.default.createElement("div", {
75
+ slot: "side",
76
+ className: "overflow-x-hidden overflow-y-auto h-100",
77
+ style: {
78
+ color: "var(--blue-sidebar-color)",
79
+ background: "var(--blue-sidebar-bg)"
360
80
  }
361
- }]);
362
-
363
- return Layout;
364
- }(_react.Component);
365
-
366
- exports.default = Layout;
81
+ }, side), /*#__PURE__*/_react.default.createElement("div", {
82
+ className: "w-100 h-100 p-1"
83
+ }, /*#__PURE__*/_react.default.createElement("div", {
84
+ className: "\"w-100 h-100 overflow-auto rounded ".concat(pageBorder ? "border " : "", "bg-body shadow-sm\"")
85
+ }, children))));
86
+ }