tabler-react-2 0.1.102 → 0.1.104
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/input/dropdown.js +4 -1
- package/dist/offcanvas/index.js +14 -9
- package/package.json +1 -1
package/dist/input/dropdown.js
CHANGED
|
@@ -104,11 +104,14 @@ var DropdownInput = exports.DropdownInput = function DropdownInput(_ref) {
|
|
|
104
104
|
}) || null;
|
|
105
105
|
setSelectedValue(matchedValue);
|
|
106
106
|
}, [value, values]);
|
|
107
|
+
var normalize = function normalize(str) {
|
|
108
|
+
return str.toLowerCase().replace(/[\s_\-+]+/g, "");
|
|
109
|
+
};
|
|
107
110
|
|
|
108
111
|
// Filter values based on the search query using getLabelText
|
|
109
112
|
(0, _react.useEffect)(function () {
|
|
110
113
|
setFilteredValues(values.filter(function (val) {
|
|
111
|
-
return getLabelText(val).toLowerCase().includes(searchQuery.toLowerCase());
|
|
114
|
+
return getLabelText(val).toLowerCase().includes(searchQuery.toLowerCase()) || normalize(val.searchIndex.toLowerCase()).includes(normalize(searchQuery).toLowerCase());
|
|
112
115
|
}));
|
|
113
116
|
}, [searchQuery, values]);
|
|
114
117
|
var handleSelection = function handleSelection(val) {
|
package/dist/offcanvas/index.js
CHANGED
|
@@ -116,15 +116,21 @@ 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
|
-
|
|
119
|
+
// Store the initial state in a memo so it doesn't change across renders
|
|
120
|
+
var initialState = (0, _react.useMemo)(function () {
|
|
121
|
+
return {
|
|
120
122
|
show: false,
|
|
121
123
|
resolve: null,
|
|
122
124
|
content: options.content || null,
|
|
123
125
|
position: options.position || "start"
|
|
124
|
-
}
|
|
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];
|
|
132
|
+
|
|
133
|
+
// Open the offcanvas, optionally providing new content or position
|
|
128
134
|
var offcanvas = (0, _react.useCallback)(function () {
|
|
129
135
|
var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
130
136
|
return new Promise(function (resolve) {
|
|
@@ -139,17 +145,16 @@ var useOffcanvas = exports.useOffcanvas = function useOffcanvas() {
|
|
|
139
145
|
});
|
|
140
146
|
});
|
|
141
147
|
}, []);
|
|
148
|
+
|
|
149
|
+
// Close the offcanvas and reset to the initial state
|
|
142
150
|
var close = (0, _react.useCallback)(function () {
|
|
143
151
|
if (state.resolve) {
|
|
144
152
|
state.resolve();
|
|
145
153
|
}
|
|
146
|
-
setState(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
}, [state.resolve]);
|
|
154
|
+
setState(initialState);
|
|
155
|
+
}, [state.resolve, initialState]);
|
|
156
|
+
|
|
157
|
+
// The Offcanvas element to render
|
|
153
158
|
var OffcanvasElement = /*#__PURE__*/_react["default"].createElement(Offcanvas, _extends({
|
|
154
159
|
show: state.show,
|
|
155
160
|
onHide: close,
|