@snack-uikit/tag 0.9.11 → 0.9.12-preview-1f246c4a.0
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/cjs/components/Tag/Tag.js +68 -0
- package/dist/cjs/components/Tag/constants.js +11 -0
- package/dist/cjs/components/Tag/index.js +25 -0
- package/dist/cjs/components/TagRow/TagRow.js +40 -0
- package/dist/cjs/components/TagRow/constants.js +11 -0
- package/dist/cjs/components/TagRow/index.js +25 -0
- package/dist/cjs/components/TagRow/utils.js +24 -0
- package/dist/cjs/components/index.js +26 -0
- package/dist/cjs/constants.js +21 -0
- package/dist/cjs/helperComponents/TagList/TagList.js +41 -0
- package/dist/cjs/helperComponents/TagList/index.js +25 -0
- package/dist/cjs/helperComponents/TagMore/TagMore.js +55 -0
- package/dist/cjs/helperComponents/TagMore/index.js +25 -0
- package/dist/cjs/helperComponents/TagRowSimple/TagRowSimple.js +45 -0
- package/dist/cjs/helperComponents/TagRowSimple/index.js +25 -0
- package/dist/cjs/helperComponents/TagRowTruncated/TagRowTruncated.js +150 -0
- package/dist/cjs/helperComponents/TagRowTruncated/hooks.js +26 -0
- package/dist/cjs/helperComponents/TagRowTruncated/index.js +25 -0
- package/dist/cjs/helperComponents/TagRowTruncated/utils.js +11 -0
- package/dist/cjs/helperComponents/index.js +26 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/types.js +5 -0
- package/dist/esm/components/Tag/Tag.d.ts +20 -0
- package/dist/esm/components/Tag/constants.d.ts +4 -0
- package/dist/esm/components/Tag/index.js +1 -0
- package/dist/esm/components/TagRow/TagRow.d.ts +19 -0
- package/dist/esm/components/TagRow/constants.d.ts +5 -0
- package/dist/esm/components/TagRow/index.js +1 -0
- package/dist/esm/components/TagRow/utils.d.ts +2 -0
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/constants.d.ts +15 -0
- package/dist/esm/helperComponents/TagList/TagList.d.ts +11 -0
- package/dist/esm/helperComponents/TagList/index.js +1 -0
- package/dist/esm/helperComponents/TagMore/TagMore.d.ts +11 -0
- package/dist/esm/helperComponents/TagMore/index.js +1 -0
- package/dist/esm/helperComponents/TagRowSimple/TagRowSimple.d.ts +11 -0
- package/dist/esm/helperComponents/TagRowSimple/index.js +1 -0
- package/dist/esm/helperComponents/TagRowTruncated/TagRowTruncated.d.ts +13 -0
- package/dist/esm/helperComponents/TagRowTruncated/hooks.d.ts +3 -0
- package/dist/esm/helperComponents/TagRowTruncated/index.js +1 -0
- package/dist/esm/helperComponents/TagRowTruncated/utils.d.ts +2 -0
- package/dist/esm/helperComponents/index.js +2 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/types.d.ts +12 -0
- package/package.json +11 -9
- package/dist/components/Tag/styles.module.css +0 -271
- package/dist/helperComponents/TagList/styles.module.css +0 -3
- package/dist/helperComponents/TagMore/styles.module.css +0 -62
- package/dist/helperComponents/TagRowSimple/styles.module.css +0 -10
- package/dist/helperComponents/TagRowTruncated/styles.module.css +0 -48
- /package/dist/{components → cjs/components}/Tag/Tag.d.ts +0 -0
- /package/dist/{components → cjs/components}/Tag/constants.d.ts +0 -0
- /package/dist/{components → cjs/components}/Tag/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/TagRow/TagRow.d.ts +0 -0
- /package/dist/{components → cjs/components}/TagRow/constants.d.ts +0 -0
- /package/dist/{components → cjs/components}/TagRow/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/TagRow/utils.d.ts +0 -0
- /package/dist/{components → cjs/components}/index.d.ts +0 -0
- /package/dist/{constants.d.ts → cjs/constants.d.ts} +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagList/TagList.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagList/index.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagMore/TagMore.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagMore/index.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagRowSimple/TagRowSimple.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagRowSimple/index.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagRowTruncated/TagRowTruncated.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagRowTruncated/hooks.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagRowTruncated/index.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/TagRowTruncated/utils.d.ts +0 -0
- /package/dist/{helperComponents → cjs/helperComponents}/index.d.ts +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{types.d.ts → cjs/types.d.ts} +0 -0
- /package/dist/{components → esm/components}/Tag/Tag.js +0 -0
- /package/dist/{components → esm/components}/Tag/constants.js +0 -0
- /package/dist/{components/Tag/index.js → esm/components/Tag/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/TagRow/TagRow.js +0 -0
- /package/dist/{components → esm/components}/TagRow/constants.js +0 -0
- /package/dist/{components/TagRow/index.js → esm/components/TagRow/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/TagRow/utils.js +0 -0
- /package/dist/{components/index.js → esm/components/index.d.ts} +0 -0
- /package/dist/{constants.js → esm/constants.js} +0 -0
- /package/dist/{helperComponents → esm/helperComponents}/TagList/TagList.js +0 -0
- /package/dist/{helperComponents/TagList/index.js → esm/helperComponents/TagList/index.d.ts} +0 -0
- /package/dist/{helperComponents → esm/helperComponents}/TagMore/TagMore.js +0 -0
- /package/dist/{helperComponents/TagMore/index.js → esm/helperComponents/TagMore/index.d.ts} +0 -0
- /package/dist/{helperComponents → esm/helperComponents}/TagRowSimple/TagRowSimple.js +0 -0
- /package/dist/{helperComponents/TagRowSimple/index.js → esm/helperComponents/TagRowSimple/index.d.ts} +0 -0
- /package/dist/{helperComponents → esm/helperComponents}/TagRowTruncated/TagRowTruncated.js +0 -0
- /package/dist/{helperComponents → esm/helperComponents}/TagRowTruncated/hooks.js +0 -0
- /package/dist/{helperComponents/TagRowTruncated/index.js → esm/helperComponents/TagRowTruncated/index.d.ts} +0 -0
- /package/dist/{helperComponents → esm/helperComponents}/TagRowTruncated/utils.js +0 -0
- /package/dist/{helperComponents/index.js → esm/helperComponents/index.d.ts} +0 -0
- /package/dist/{index.js → esm/index.d.ts} +0 -0
- /package/dist/{types.js → esm/types.js} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
12
|
+
return mod && mod.__esModule ? mod : {
|
|
13
|
+
"default": mod
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
exports.APPEARANCE = void 0;
|
|
20
|
+
exports.Tag = Tag;
|
|
21
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
22
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
23
|
+
const icons_1 = require("@snack-uikit/icons");
|
|
24
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
25
|
+
const constants_1 = require("../../constants");
|
|
26
|
+
Object.defineProperty(exports, "APPEARANCE", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return constants_1.APPEARANCE;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const constants_2 = require("./constants");
|
|
33
|
+
const styles_module_scss_1 = __importDefault({});
|
|
34
|
+
function Tag(_a) {
|
|
35
|
+
var {
|
|
36
|
+
label,
|
|
37
|
+
size = constants_1.SIZE.Xs,
|
|
38
|
+
appearance = constants_1.APPEARANCE.Neutral,
|
|
39
|
+
onDelete,
|
|
40
|
+
className,
|
|
41
|
+
tabIndex
|
|
42
|
+
} = _a,
|
|
43
|
+
rest = __rest(_a, ["label", "size", "appearance", "onDelete", "className", "tabIndex"]);
|
|
44
|
+
return (0, jsx_runtime_1.jsxs)("span", Object.assign({}, (0, utils_1.extractSupportProps)(rest), {
|
|
45
|
+
className: (0, classnames_1.default)(styles_module_scss_1.default.tag, className),
|
|
46
|
+
"data-size": size,
|
|
47
|
+
"data-appearance": appearance,
|
|
48
|
+
"data-removable": Boolean(onDelete),
|
|
49
|
+
children: [(0, jsx_runtime_1.jsx)("span", {
|
|
50
|
+
title: label,
|
|
51
|
+
className: styles_module_scss_1.default.label,
|
|
52
|
+
children: label
|
|
53
|
+
}), onDelete && (0, jsx_runtime_1.jsx)("button", {
|
|
54
|
+
type: 'button',
|
|
55
|
+
className: styles_module_scss_1.default.tagButton,
|
|
56
|
+
onClick: onDelete,
|
|
57
|
+
"data-test-id": 'tag-remove-button',
|
|
58
|
+
tabIndex: tabIndex,
|
|
59
|
+
children: size === constants_1.SIZE.Xs ? (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {
|
|
60
|
+
size: constants_2.ICON_SIZE[size],
|
|
61
|
+
className: styles_module_scss_1.default.icon
|
|
62
|
+
}) : (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {
|
|
63
|
+
size: constants_2.ICON_SIZE[size],
|
|
64
|
+
className: styles_module_scss_1.default.icon
|
|
65
|
+
})
|
|
66
|
+
})]
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./Tag"), exports);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
exports.TagRow = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const constants_1 = require("../../constants");
|
|
18
|
+
const helperComponents_1 = require("../../helperComponents");
|
|
19
|
+
const utils_1 = require("./utils");
|
|
20
|
+
function TagRowInner(_a) {
|
|
21
|
+
var {
|
|
22
|
+
items,
|
|
23
|
+
rowLimit,
|
|
24
|
+
size = constants_1.SIZE.Xs
|
|
25
|
+
} = _a,
|
|
26
|
+
props = __rest(_a, ["items", "rowLimit", "size"]);
|
|
27
|
+
const coloredItems = (0, react_1.useMemo)(() => items.map(utils_1.mapTagRowItem), [items]);
|
|
28
|
+
if (rowLimit) {
|
|
29
|
+
return (0, jsx_runtime_1.jsx)(helperComponents_1.TagRowTruncated, Object.assign({
|
|
30
|
+
items: coloredItems,
|
|
31
|
+
rowLimit: rowLimit,
|
|
32
|
+
size: size
|
|
33
|
+
}, props));
|
|
34
|
+
}
|
|
35
|
+
return (0, jsx_runtime_1.jsx)(helperComponents_1.TagRowSimple, Object.assign({
|
|
36
|
+
items: coloredItems,
|
|
37
|
+
size: size
|
|
38
|
+
}, props));
|
|
39
|
+
}
|
|
40
|
+
exports.TagRow = (0, react_1.memo)(TagRowInner);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TAG_ROW_TEST_IDS = void 0;
|
|
7
|
+
exports.TAG_ROW_TEST_IDS = {
|
|
8
|
+
moreButton: 'tag-row__more-button',
|
|
9
|
+
visibleTagsWrapper: 'tag-row__visible-row',
|
|
10
|
+
droplistTagsWrapper: 'tag-row__droplist-contents'
|
|
11
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./TagRow"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mapTagRowItem = void 0;
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
|
+
const mapTagRowItem = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
label,
|
|
11
|
+
appearance
|
|
12
|
+
} = _ref;
|
|
13
|
+
if (appearance) {
|
|
14
|
+
return {
|
|
15
|
+
label,
|
|
16
|
+
appearance
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
label,
|
|
21
|
+
appearance: constants_1.APPEARANCE.Neutral
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.mapTagRowItem = mapTagRowItem;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./Tag"), exports);
|
|
26
|
+
__exportStar(require("./TagRow"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SIZE = exports.APPEARANCE = void 0;
|
|
7
|
+
exports.APPEARANCE = {
|
|
8
|
+
Neutral: 'neutral',
|
|
9
|
+
Primary: 'primary',
|
|
10
|
+
Red: 'red',
|
|
11
|
+
Orange: 'orange',
|
|
12
|
+
Yellow: 'yellow',
|
|
13
|
+
Green: 'green',
|
|
14
|
+
Blue: 'blue',
|
|
15
|
+
Violet: 'violet',
|
|
16
|
+
Pink: 'pink'
|
|
17
|
+
};
|
|
18
|
+
exports.SIZE = {
|
|
19
|
+
Xs: 'xs',
|
|
20
|
+
S: 's'
|
|
21
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
"default": mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.TagList = TagList;
|
|
12
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
|
+
const components_1 = require("../../components");
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
const styles_module_scss_1 = __importDefault({});
|
|
16
|
+
function renderTag(size, handleRemoveItem, setRef) {
|
|
17
|
+
return function TagRowItem(item, index) {
|
|
18
|
+
return (0, jsx_runtime_1.jsx)("div", {
|
|
19
|
+
ref: setRef === null || setRef === void 0 ? void 0 : setRef(item, index),
|
|
20
|
+
className: styles_module_scss_1.default.tagWrapper,
|
|
21
|
+
children: (0, jsx_runtime_1.jsx)(components_1.Tag, {
|
|
22
|
+
label: item.label,
|
|
23
|
+
appearance: item.appearance,
|
|
24
|
+
size: size,
|
|
25
|
+
onDelete: handleRemoveItem === null || handleRemoveItem === void 0 ? void 0 : handleRemoveItem(item)
|
|
26
|
+
})
|
|
27
|
+
}, item.label);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function TagList(_ref) {
|
|
31
|
+
let {
|
|
32
|
+
items,
|
|
33
|
+
size = constants_1.SIZE.Xs,
|
|
34
|
+
onItemRemove,
|
|
35
|
+
setTagRef
|
|
36
|
+
} = _ref;
|
|
37
|
+
const handleRemoveItem = onItemRemove ? item => () => onItemRemove(item.label) : undefined;
|
|
38
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {
|
|
39
|
+
children: items.map(renderTag(size, handleRemoveItem, setTagRef))
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./TagList"), exports);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
"default": mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.TagMore = TagMore;
|
|
12
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
|
+
const dropdown_1 = require("@snack-uikit/dropdown");
|
|
14
|
+
const scroll_1 = require("@snack-uikit/scroll");
|
|
15
|
+
const constants_1 = require("../../components/TagRow/constants");
|
|
16
|
+
const constants_2 = require("../../constants");
|
|
17
|
+
const TagRowSimple_1 = require("../TagRowSimple");
|
|
18
|
+
const styles_module_scss_1 = __importDefault({});
|
|
19
|
+
function TagMore(_ref) {
|
|
20
|
+
let {
|
|
21
|
+
items,
|
|
22
|
+
text = '',
|
|
23
|
+
size = constants_2.SIZE.Xs,
|
|
24
|
+
buttonRef,
|
|
25
|
+
onItemRemove
|
|
26
|
+
} = _ref;
|
|
27
|
+
return (0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, {
|
|
28
|
+
placement: 'bottom-end',
|
|
29
|
+
trigger: 'hoverAndFocusVisible',
|
|
30
|
+
triggerClassName: styles_module_scss_1.default.triggerClassName,
|
|
31
|
+
content: (0, jsx_runtime_1.jsx)("div", {
|
|
32
|
+
className: styles_module_scss_1.default.tagRowDroplistContainer,
|
|
33
|
+
"data-size": size,
|
|
34
|
+
children: (0, jsx_runtime_1.jsx)(scroll_1.Scroll, {
|
|
35
|
+
className: styles_module_scss_1.default.tagRowDroplistScroll,
|
|
36
|
+
size: 's',
|
|
37
|
+
barHideStrategy: 'move',
|
|
38
|
+
children: (0, jsx_runtime_1.jsx)(TagRowSimple_1.TagRowSimple, {
|
|
39
|
+
items: items,
|
|
40
|
+
size: size,
|
|
41
|
+
onItemRemove: onItemRemove,
|
|
42
|
+
"data-test-id": constants_1.TAG_ROW_TEST_IDS.droplistTagsWrapper
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
}),
|
|
46
|
+
children: (0, jsx_runtime_1.jsx)("button", {
|
|
47
|
+
type: 'button',
|
|
48
|
+
className: styles_module_scss_1.default.button,
|
|
49
|
+
ref: buttonRef,
|
|
50
|
+
"data-size": size,
|
|
51
|
+
"data-test-id": constants_1.TAG_ROW_TEST_IDS.moreButton,
|
|
52
|
+
children: `${text}${items.length}`
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./TagMore"), exports);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
12
|
+
return mod && mod.__esModule ? mod : {
|
|
13
|
+
"default": mod
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
exports.TagRowSimple = TagRowSimple;
|
|
20
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
21
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
22
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
23
|
+
const TagList_1 = require("../TagList");
|
|
24
|
+
const styles_module_scss_1 = __importDefault({});
|
|
25
|
+
function TagRowSimple(_a) {
|
|
26
|
+
var {
|
|
27
|
+
items,
|
|
28
|
+
size,
|
|
29
|
+
onItemRemove,
|
|
30
|
+
setTagRef,
|
|
31
|
+
className
|
|
32
|
+
} = _a,
|
|
33
|
+
rest = __rest(_a, ["items", "size", "onItemRemove", "setTagRef", "className"]);
|
|
34
|
+
return (0, jsx_runtime_1.jsx)("div", Object.assign({
|
|
35
|
+
className: (0, classnames_1.default)(styles_module_scss_1.default.tagRowSimpleWrapper, className)
|
|
36
|
+
}, (0, utils_1.extractSupportProps)(rest), {
|
|
37
|
+
"data-size": size,
|
|
38
|
+
children: (0, jsx_runtime_1.jsx)(TagList_1.TagList, {
|
|
39
|
+
items: items,
|
|
40
|
+
size: size,
|
|
41
|
+
onItemRemove: onItemRemove,
|
|
42
|
+
setTagRef: setTagRef
|
|
43
|
+
})
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./TagRowSimple"), exports);
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
12
|
+
return mod && mod.__esModule ? mod : {
|
|
13
|
+
"default": mod
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
exports.TagRowTruncated = void 0;
|
|
20
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
21
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
22
|
+
const react_1 = require("react");
|
|
23
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
24
|
+
const constants_1 = require("../../components/TagRow/constants");
|
|
25
|
+
const TagList_1 = require("../TagList");
|
|
26
|
+
const TagMore_1 = require("../TagMore");
|
|
27
|
+
const hooks_1 = require("./hooks");
|
|
28
|
+
const styles_module_scss_1 = __importDefault({});
|
|
29
|
+
const utils_2 = require("./utils");
|
|
30
|
+
function TagRowTruncatedInner(_a) {
|
|
31
|
+
var {
|
|
32
|
+
items,
|
|
33
|
+
rowLimit,
|
|
34
|
+
size,
|
|
35
|
+
moreButtonLabel = '',
|
|
36
|
+
className,
|
|
37
|
+
onItemRemove
|
|
38
|
+
} = _a,
|
|
39
|
+
rest = __rest(_a, ["items", "rowLimit", "size", "moreButtonLabel", "className", "onItemRemove"]);
|
|
40
|
+
const [visibleTags, setVisibleTags] = (0, react_1.useState)([]);
|
|
41
|
+
const [hiddenTags, setHiddenTags] = (0, react_1.useState)([]);
|
|
42
|
+
const hiddenRowElementRef = (0, react_1.useRef)(null);
|
|
43
|
+
const hiddenMoreButtonRef = (0, react_1.useRef)(null);
|
|
44
|
+
const hiddenMoreButtonWrapperRef = (0, react_1.useRef)(null);
|
|
45
|
+
const [firstTagElement, setFirstTagElement] = (0, react_1.useState)(null);
|
|
46
|
+
const tagsMapRef = (0, react_1.useRef)(new Map());
|
|
47
|
+
const {
|
|
48
|
+
width: maxWidth
|
|
49
|
+
} = (0, hooks_1.useResizeObserver)(hiddenRowElementRef.current);
|
|
50
|
+
const {
|
|
51
|
+
width: firstVisibleTagWidth
|
|
52
|
+
} = (0, hooks_1.useResizeObserver)(firstTagElement);
|
|
53
|
+
function setTagElement(tag, index) {
|
|
54
|
+
return tagElement => {
|
|
55
|
+
if (index === 0 && tagElement) {
|
|
56
|
+
setFirstTagElement(tagElement);
|
|
57
|
+
}
|
|
58
|
+
if (tagElement === null) {
|
|
59
|
+
tagsMapRef.current.delete(tag);
|
|
60
|
+
} else {
|
|
61
|
+
tagsMapRef.current.set(tag, tagElement);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const gapWidth = (0, utils_2.getGapWidth)(hiddenRowElementRef);
|
|
66
|
+
(0, react_1.useEffect)(() => {
|
|
67
|
+
var _a;
|
|
68
|
+
if (maxWidth < 1) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const newVisibleTags = [];
|
|
72
|
+
const newHiddenTags = [];
|
|
73
|
+
const moreButtonWidth = ((_a = hiddenMoreButtonRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
|
|
74
|
+
let currentRowWidth = 0;
|
|
75
|
+
let currentRowCount = 1;
|
|
76
|
+
let currentRowVisibleTagAmount = 0;
|
|
77
|
+
tagsMapRef.current.forEach((tagElement, tagRowItem) => {
|
|
78
|
+
const tagWidth = (tagElement === null || tagElement === void 0 ? void 0 : tagElement.offsetWidth) || 0;
|
|
79
|
+
const sumRowWidth = currentRowWidth + tagWidth + gapWidth;
|
|
80
|
+
if (currentRowCount > rowLimit) {
|
|
81
|
+
newHiddenTags.push(tagRowItem);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (currentRowCount === rowLimit) {
|
|
85
|
+
if (sumRowWidth + moreButtonWidth > maxWidth) {
|
|
86
|
+
currentRowCount++;
|
|
87
|
+
currentRowVisibleTagAmount = 0;
|
|
88
|
+
newHiddenTags.push(tagRowItem);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
currentRowWidth = sumRowWidth;
|
|
92
|
+
newVisibleTags.push(tagRowItem);
|
|
93
|
+
currentRowVisibleTagAmount++;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (sumRowWidth > maxWidth) {
|
|
97
|
+
currentRowWidth = currentRowVisibleTagAmount ? tagWidth + gapWidth : 0;
|
|
98
|
+
currentRowCount++;
|
|
99
|
+
currentRowVisibleTagAmount = 0;
|
|
100
|
+
newVisibleTags.push(tagRowItem);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
currentRowVisibleTagAmount++;
|
|
104
|
+
currentRowWidth = sumRowWidth;
|
|
105
|
+
newVisibleTags.push(tagRowItem);
|
|
106
|
+
});
|
|
107
|
+
setVisibleTags(newVisibleTags);
|
|
108
|
+
setHiddenTags(newHiddenTags);
|
|
109
|
+
}, [items, rowLimit, maxWidth, onItemRemove, gapWidth, firstVisibleTagWidth]);
|
|
110
|
+
return (0, jsx_runtime_1.jsxs)("div", Object.assign({
|
|
111
|
+
className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className)
|
|
112
|
+
}, (0, utils_1.extractSupportProps)(rest), {
|
|
113
|
+
"data-size": size,
|
|
114
|
+
children: [(0, jsx_runtime_1.jsx)("div", {
|
|
115
|
+
className: styles_module_scss_1.default.hiddenRow,
|
|
116
|
+
ref: hiddenRowElementRef,
|
|
117
|
+
"data-size": size,
|
|
118
|
+
children: (0, jsx_runtime_1.jsx)(TagList_1.TagList, {
|
|
119
|
+
items: items,
|
|
120
|
+
size: size,
|
|
121
|
+
onItemRemove: onItemRemove,
|
|
122
|
+
setTagRef: setTagElement
|
|
123
|
+
})
|
|
124
|
+
}), (0, jsx_runtime_1.jsx)("div", {
|
|
125
|
+
className: styles_module_scss_1.default.hiddenMoreButton,
|
|
126
|
+
ref: hiddenMoreButtonWrapperRef,
|
|
127
|
+
children: (0, jsx_runtime_1.jsx)(TagMore_1.TagMore, {
|
|
128
|
+
items: items,
|
|
129
|
+
text: moreButtonLabel,
|
|
130
|
+
size: size,
|
|
131
|
+
buttonRef: hiddenMoreButtonRef
|
|
132
|
+
})
|
|
133
|
+
}), (0, jsx_runtime_1.jsxs)("div", {
|
|
134
|
+
className: styles_module_scss_1.default.visibleRow,
|
|
135
|
+
"data-size": size,
|
|
136
|
+
"data-test-id": constants_1.TAG_ROW_TEST_IDS.visibleTagsWrapper,
|
|
137
|
+
children: [(0, jsx_runtime_1.jsx)(TagList_1.TagList, {
|
|
138
|
+
items: visibleTags,
|
|
139
|
+
size: size,
|
|
140
|
+
onItemRemove: onItemRemove
|
|
141
|
+
}), hiddenTags.length > 0 && (0, jsx_runtime_1.jsx)(TagMore_1.TagMore, {
|
|
142
|
+
items: hiddenTags,
|
|
143
|
+
text: moreButtonLabel,
|
|
144
|
+
size: size,
|
|
145
|
+
onItemRemove: onItemRemove
|
|
146
|
+
})]
|
|
147
|
+
})]
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
exports.TagRowTruncated = (0, react_1.memo)(TagRowTruncatedInner);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useResizeObserver = void 0;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const useResizeObserver = element => {
|
|
9
|
+
const [width, setWidth] = (0, react_1.useState)(0);
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (!element) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
15
|
+
if (element.offsetWidth !== width) {
|
|
16
|
+
setWidth(element.offsetWidth);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
resizeObserver.observe(element);
|
|
20
|
+
return () => resizeObserver.disconnect();
|
|
21
|
+
}, [element, width]);
|
|
22
|
+
return {
|
|
23
|
+
width
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exports.useResizeObserver = useResizeObserver;
|