tabler-react-2 0.1.105 → 0.1.106
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/offcanvas/index.js +22 -17
- package/package.json +1 -1
package/dist/offcanvas/index.js
CHANGED
|
@@ -116,31 +116,34 @@ Offcanvas.defaultProps = {
|
|
|
116
116
|
};
|
|
117
117
|
var useOffcanvas = exports.useOffcanvas = function useOffcanvas() {
|
|
118
118
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
119
|
-
var
|
|
120
|
-
var _options$content, _options$position;
|
|
121
|
-
return {
|
|
119
|
+
var _useState = (0, _react.useState)({
|
|
122
120
|
show: false,
|
|
123
121
|
resolve: null,
|
|
124
|
-
content:
|
|
125
|
-
position:
|
|
126
|
-
}
|
|
127
|
-
}, [options.content, options.position]);
|
|
128
|
-
var _useState = (0, _react.useState)(initialState),
|
|
122
|
+
content: options.content || null,
|
|
123
|
+
position: options.position || "start"
|
|
124
|
+
}),
|
|
129
125
|
_useState2 = _slicedToArray(_useState, 2),
|
|
130
126
|
state = _useState2[0],
|
|
131
127
|
setState = _useState2[1];
|
|
128
|
+
var _useState3 = (0, _react.useState)(Math.random()),
|
|
129
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
130
|
+
rand = _useState4[0],
|
|
131
|
+
setRand = _useState4[1];
|
|
132
132
|
var offcanvas = (0, _react.useCallback)(function () {
|
|
133
133
|
var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
134
134
|
return new Promise(function (resolve) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
setState(function (prev) {
|
|
136
|
+
var _newOptions$content, _newOptions$position;
|
|
137
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
138
|
+
show: true,
|
|
139
|
+
resolve: resolve,
|
|
140
|
+
content: (_newOptions$content = newOptions.content) !== null && _newOptions$content !== void 0 ? _newOptions$content : prev.content,
|
|
141
|
+
position: (_newOptions$position = newOptions.position) !== null && _newOptions$position !== void 0 ? _newOptions$position : prev.position
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
setRand(Math.random());
|
|
142
145
|
});
|
|
143
|
-
}, [
|
|
146
|
+
}, []);
|
|
144
147
|
var close = (0, _react.useCallback)(function () {
|
|
145
148
|
if (state.resolve) {
|
|
146
149
|
state.resolve();
|
|
@@ -166,7 +169,9 @@ var useOffcanvas = exports.useOffcanvas = function useOffcanvas() {
|
|
|
166
169
|
top: 10,
|
|
167
170
|
right: 10
|
|
168
171
|
}
|
|
169
|
-
}),
|
|
172
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
173
|
+
key: rand
|
|
174
|
+
}, state.content));
|
|
170
175
|
return {
|
|
171
176
|
offcanvas: offcanvas,
|
|
172
177
|
OffcanvasElement: OffcanvasElement,
|