tabler-react-2 0.1.104 → 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,45 +116,42 @@ 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
- // Store the initial state in a memo so it doesn't change across renders
120
119
  var initialState = (0, _react.useMemo)(function () {
120
+ var _options$content, _options$position;
121
121
  return {
122
122
  show: false,
123
123
  resolve: null,
124
- content: options.content || null,
125
- position: options.position || "start"
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
126
  };
127
127
  }, [options.content, options.position]);
128
128
  var _useState = (0, _react.useState)(initialState),
129
129
  _useState2 = _slicedToArray(_useState, 2),
130
130
  state = _useState2[0],
131
131
  setState = _useState2[1];
132
-
133
- // Open the offcanvas, optionally providing new content or position
134
132
  var offcanvas = (0, _react.useCallback)(function () {
135
133
  var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
136
134
  return new Promise(function (resolve) {
137
- setState(function (prev) {
138
- var _newOptions$content, _newOptions$position;
139
- return _objectSpread(_objectSpread({}, prev), {}, {
140
- show: true,
141
- resolve: resolve,
142
- content: (_newOptions$content = newOptions.content) !== null && _newOptions$content !== void 0 ? _newOptions$content : prev.content,
143
- position: (_newOptions$position = newOptions.position) !== null && _newOptions$position !== void 0 ? _newOptions$position : prev.position
144
- });
145
- });
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
+ }));
146
142
  });
147
- }, []);
148
-
149
- // Close the offcanvas and reset to the initial state
143
+ }, [initialState]);
150
144
  var close = (0, _react.useCallback)(function () {
151
145
  if (state.resolve) {
152
146
  state.resolve();
153
147
  }
154
- setState(initialState);
155
- }, [state.resolve, initialState]);
156
-
157
- // The Offcanvas element to render
148
+ setState(function (prev) {
149
+ return _objectSpread(_objectSpread({}, prev), {}, {
150
+ show: false,
151
+ resolve: null
152
+ });
153
+ });
154
+ }, [state.resolve]);
158
155
  var OffcanvasElement = /*#__PURE__*/_react["default"].createElement(Offcanvas, _extends({
159
156
  show: state.show,
160
157
  onHide: close,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.104",
3
+ "version": "0.1.105",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {