tabler-react-2 0.1.105 → 0.1.107

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.
@@ -7,7 +7,7 @@ exports.DropdownInput = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _index = require("../index");
10
- var _excluded = ["prompt", "values", "items", "value", "onChange", "aprops", "showSearch", "loading", "disabled", "disabledText", "label", "showLabel", "color", "outline", "maxHeight"];
10
+ var _excluded = ["prompt", "values", "items", "value", "onChange", "aprops", "showSearch", "loading", "disabled", "disabledText", "label", "showLabel", "color", "outline", "maxHeight", "required"];
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -42,6 +42,7 @@ var DropdownInput = exports.DropdownInput = function DropdownInput(_ref) {
42
42
  outline = _ref.outline,
43
43
  _ref$maxHeight = _ref.maxHeight,
44
44
  maxHeight = _ref$maxHeight === void 0 ? "300px" : _ref$maxHeight,
45
+ required = _ref.required,
45
46
  props = _objectWithoutProperties(_ref, _excluded);
46
47
  // Allow aliasing: pass either `values` or `items`
47
48
  var values = ivalues || items || [];
@@ -160,7 +161,9 @@ var DropdownInput = exports.DropdownInput = function DropdownInput(_ref) {
160
161
  // If a label is provided, wrap the dropdown with the label inside a container.
161
162
  return label && showLabel ? /*#__PURE__*/_react["default"].createElement(_index.Util.Col, null, /*#__PURE__*/_react["default"].createElement("label", {
162
163
  className: "form-label"
163
- }, label), dropdownContent) : dropdownContent;
164
+ }, label, required && /*#__PURE__*/_react["default"].createElement("span", {
165
+ className: "form-label-required"
166
+ }, "*")), dropdownContent) : dropdownContent;
164
167
  };
165
168
  DropdownInput.propTypes = {
166
169
  prompt: _propTypes["default"].string.isRequired,
@@ -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 initialState = (0, _react.useMemo)(function () {
120
- var _options$content, _options$position;
121
- return {
119
+ var _useState = (0, _react.useState)({
122
120
  show: false,
123
121
  resolve: null,
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),
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
- 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
- }));
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
- }, [initialState]);
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
- }), state.content);
172
+ }), /*#__PURE__*/_react["default"].createElement("div", {
173
+ key: rand
174
+ }, state.content));
170
175
  return {
171
176
  offcanvas: offcanvas,
172
177
  OffcanvasElement: OffcanvasElement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.105",
3
+ "version": "0.1.107",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {