@quintoandar-tokko/wrapped 1.0.83 → 1.0.85
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/lib/index.js +12 -7
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.Wrapped = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _box = require("@quintoandar-tokko/box");
|
|
9
9
|
var _tags = require("@quintoandar-tokko/tags");
|
|
10
|
-
var _excluded = ["items", "fnClose", "widthRestItemsWindow", "printKey", "tagVariant", "clickFn", "idKey"];
|
|
10
|
+
var _excluded = ["items", "fnClose", "widthRestItemsWindow", "printKey", "tagVariant", "clickFn", "idKey", "showCloseIconCallback"];
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
13
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
@@ -50,6 +50,7 @@ var Wrapped = exports.Wrapped = function Wrapped(_ref) {
|
|
|
50
50
|
clickFn = _ref.clickFn,
|
|
51
51
|
_ref$idKey = _ref.idKey,
|
|
52
52
|
idKey = _ref$idKey === void 0 ? 'id' : _ref$idKey,
|
|
53
|
+
showCloseIconCallback = _ref.showCloseIconCallback,
|
|
53
54
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
54
55
|
var _useReducer = (0, _react.useReducer)(wrappedReducer, {
|
|
55
56
|
restItems: []
|
|
@@ -102,8 +103,9 @@ var Wrapped = exports.Wrapped = function Wrapped(_ref) {
|
|
|
102
103
|
}, [items]);
|
|
103
104
|
(0, _react.useEffect)(function () {
|
|
104
105
|
var handleClick = function handleClick(event) {
|
|
105
|
-
var _RefItemsWindow$curre, _event$target$
|
|
106
|
-
if (!((_RefItemsWindow$curre = RefItemsWindow.current) !== null && _RefItemsWindow$curre !== void 0 && _RefItemsWindow$curre.contains(event.target)) && !((_event$target$
|
|
106
|
+
var _RefItemsWindow$curre, _event$target$classLi;
|
|
107
|
+
if (!((_RefItemsWindow$curre = RefItemsWindow.current) !== null && _RefItemsWindow$curre !== void 0 && _RefItemsWindow$curre.contains(event.target)) && !((_event$target$classLi = event.target.classList) !== null && _event$target$classLi !== void 0 && _event$target$classLi.contains('numberTag')) // fallback for svg's cases
|
|
108
|
+
) {
|
|
107
109
|
setShowRestItems(false);
|
|
108
110
|
}
|
|
109
111
|
};
|
|
@@ -124,6 +126,9 @@ var Wrapped = exports.Wrapped = function Wrapped(_ref) {
|
|
|
124
126
|
});
|
|
125
127
|
fnClose(item);
|
|
126
128
|
};
|
|
129
|
+
var shouldShowCloseIcon = function shouldShowCloseIcon(item) {
|
|
130
|
+
return typeof showCloseIconCallback === 'function' ? showCloseIconCallback(item) : true;
|
|
131
|
+
};
|
|
127
132
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_box.Box, _extends({
|
|
128
133
|
__css: {
|
|
129
134
|
display: 'block',
|
|
@@ -136,10 +141,10 @@ var Wrapped = exports.Wrapped = function Wrapped(_ref) {
|
|
|
136
141
|
ref: Ref
|
|
137
142
|
}), items.map(function (item, i) {
|
|
138
143
|
return /*#__PURE__*/_react["default"].createElement(_tags.Tags, {
|
|
139
|
-
key: item[idKey]
|
|
144
|
+
key: "".concat(item[idKey], "-").concat(i),
|
|
140
145
|
id: item[idKey],
|
|
141
146
|
variant: tagVariant,
|
|
142
|
-
closeIcon: fnClose ? function () {
|
|
147
|
+
closeIcon: fnClose && shouldShowCloseIcon(item) ? function () {
|
|
143
148
|
return deleteRestItem(item);
|
|
144
149
|
} : false,
|
|
145
150
|
style: {
|
|
@@ -173,10 +178,10 @@ var Wrapped = exports.Wrapped = function Wrapped(_ref) {
|
|
|
173
178
|
}
|
|
174
179
|
}, store.restItems.map(function (item, i) {
|
|
175
180
|
return /*#__PURE__*/_react["default"].createElement(_tags.Tags, {
|
|
176
|
-
key: item[idKey]
|
|
181
|
+
key: "".concat(item[idKey], "-").concat(i),
|
|
177
182
|
id: item[idKey],
|
|
178
183
|
variant: tagVariant,
|
|
179
|
-
closeIcon: fnClose ? function () {
|
|
184
|
+
closeIcon: fnClose && shouldShowCloseIcon(item) ? function () {
|
|
180
185
|
return deleteRestItem(item);
|
|
181
186
|
} : false,
|
|
182
187
|
style: {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintoandar-tokko/wrapped",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.85",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"lib"
|
|
8
8
|
],
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@quintoandar-tokko/box": "^1.2.
|
|
10
|
+
"@quintoandar-tokko/box": "^1.2.287"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"react": "^16.8.0"
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "27528c5be1f5a65c43763be93a4c4ebcca52f20e"
|
|
19
19
|
}
|