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.
@@ -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 _useState = (0, _react.useState)({
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 || null,
123
- position: options.position || "start"
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
- setState(function (prev) {
132
- var _newOptions$content, _newOptions$position;
133
- return _objectSpread(_objectSpread({}, prev), {}, {
134
- show: true,
135
- resolve: resolve,
136
- content: (_newOptions$content = newOptions.content) !== null && _newOptions$content !== void 0 ? _newOptions$content : prev.content,
137
- position: (_newOptions$position = newOptions.position) !== null && _newOptions$position !== void 0 ? _newOptions$position : prev.position
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.103",
3
+ "version": "0.1.105",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {