tabler-react-2 0.1.103 → 0.1.105
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 +16 -14
- package/package.json +1 -1
package/dist/offcanvas/index.js
CHANGED
|
@@ -116,29 +116,31 @@ 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
|
|
119
|
+
var initialState = (0, _react.useMemo)(function () {
|
|
120
|
+
var _options$content, _options$position;
|
|
121
|
+
return {
|
|
120
122
|
show: false,
|
|
121
123
|
resolve: null,
|
|
122
|
-
content: options.content
|
|
123
|
-
position: options.position
|
|
124
|
-
}
|
|
124
|
+
content: (_options$content = options.content) !== null && _options$content !== void 0 ? _options$content : null,
|
|
125
|
+
position: (_options$position = options.position) !== null && _options$position !== void 0 ? _options$position : "start"
|
|
126
|
+
};
|
|
127
|
+
}, [options.content, options.position]);
|
|
128
|
+
var _useState = (0, _react.useState)(initialState),
|
|
125
129
|
_useState2 = _slicedToArray(_useState, 2),
|
|
126
130
|
state = _useState2[0],
|
|
127
131
|
setState = _useState2[1];
|
|
128
132
|
var offcanvas = (0, _react.useCallback)(function () {
|
|
129
133
|
var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
130
134
|
return new Promise(function (resolve) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
});
|
|
135
|
+
var _newOptions$content, _newOptions$position;
|
|
136
|
+
setState(_objectSpread(_objectSpread({}, initialState), {}, {
|
|
137
|
+
show: true,
|
|
138
|
+
resolve: resolve,
|
|
139
|
+
content: (_newOptions$content = newOptions.content) !== null && _newOptions$content !== void 0 ? _newOptions$content : initialState.content,
|
|
140
|
+
position: (_newOptions$position = newOptions.position) !== null && _newOptions$position !== void 0 ? _newOptions$position : initialState.position
|
|
141
|
+
}));
|
|
140
142
|
});
|
|
141
|
-
}, []);
|
|
143
|
+
}, [initialState]);
|
|
142
144
|
var close = (0, _react.useCallback)(function () {
|
|
143
145
|
if (state.resolve) {
|
|
144
146
|
state.resolve();
|