@algolia/satellite 1.0.0-beta.157 → 1.0.0-beta.159
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/cjs/Badge/Badge.d.ts +2 -2
- package/cjs/Badge/Badge.js +7 -6
- package/cjs/Banners/Alert/Alert.js +1 -1
- package/cjs/Button/Button.d.ts +3 -5
- package/cjs/Button/Button.js +8 -51
- package/cjs/Button/IconButton.d.ts +3 -18
- package/cjs/Button/IconButton.js +8 -64
- package/cjs/Button/PolymorphicButton.d.ts +11 -0
- package/cjs/Button/PolymorphicButton.js +76 -0
- package/cjs/Button/PolymorphicIconButton.d.ts +24 -0
- package/cjs/Button/PolymorphicIconButton.js +84 -0
- package/cjs/Button/index.d.ts +1 -1
- package/cjs/Button/index.js +16 -12
- package/cjs/Button/types.d.ts +11 -6
- package/cjs/Button/types.js +3 -1
- package/cjs/Dropdown/DropdownButton.d.ts +3 -3
- package/cjs/Dropdown/DropdownButton.js +5 -2
- package/cjs/Link/ButtonLink.d.ts +5 -3
- package/cjs/Link/ButtonLink.js +9 -6
- package/cjs/Link/IconButtonLink.d.ts +5 -4
- package/cjs/Link/IconButtonLink.js +8 -5
- package/cjs/Medallion/Medallion.js +1 -1
- package/cjs/Modal/Modal.d.ts +35 -11
- package/cjs/Modal/Modal.js +101 -109
- package/cjs/Modal/Modal.tailwind.js +54 -18
- package/cjs/Satellite/Satellite.d.ts +2 -1
- package/cjs/Satellite/Satellite.js +26 -2
- package/cjs/Tag/Tag.d.ts +26 -6
- package/cjs/Tag/Tag.js +51 -19
- package/cjs/Tag/Tag.tailwind.js +17 -1
- package/cjs/styles/colors.d.ts +18 -0
- package/cjs/styles/colors.js +33 -15
- package/cjs/types.d.ts +9 -0
- package/esm/Badge/Badge.d.ts +2 -2
- package/esm/Badge/Badge.js +7 -6
- package/esm/Banners/Alert/Alert.js +1 -1
- package/esm/Button/Button.d.ts +3 -5
- package/esm/Button/Button.js +8 -52
- package/esm/Button/IconButton.d.ts +3 -18
- package/esm/Button/IconButton.js +8 -66
- package/esm/Button/PolymorphicButton.d.ts +11 -0
- package/esm/Button/PolymorphicButton.js +66 -0
- package/esm/Button/PolymorphicIconButton.d.ts +24 -0
- package/esm/Button/PolymorphicIconButton.js +78 -0
- package/esm/Button/index.d.ts +1 -1
- package/esm/Button/index.js +1 -1
- package/esm/Button/types.d.ts +11 -6
- package/esm/Button/types.js +3 -1
- package/esm/Dropdown/DropdownButton.d.ts +3 -3
- package/esm/Dropdown/DropdownButton.js +5 -2
- package/esm/Link/ButtonLink.d.ts +5 -3
- package/esm/Link/ButtonLink.js +9 -6
- package/esm/Link/IconButtonLink.d.ts +5 -4
- package/esm/Link/IconButtonLink.js +8 -5
- package/esm/Medallion/Medallion.js +1 -1
- package/esm/Modal/Modal.d.ts +35 -11
- package/esm/Modal/Modal.js +99 -111
- package/esm/Modal/Modal.tailwind.js +53 -18
- package/esm/Satellite/Satellite.d.ts +2 -1
- package/esm/Satellite/Satellite.js +24 -1
- package/esm/Tag/Tag.d.ts +26 -6
- package/esm/Tag/Tag.js +52 -20
- package/esm/Tag/Tag.tailwind.js +17 -1
- package/esm/styles/colors.d.ts +18 -0
- package/esm/styles/colors.js +33 -15
- package/esm/types.d.ts +9 -0
- package/package.json +7 -4
- package/satellite.min.css +1 -1
- package/scss/colors.scss +27 -10
package/esm/Modal/Modal.js
CHANGED
@@ -1,58 +1,37 @@
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
|
5
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
6
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
6
|
+
import * as Dialog from "@radix-ui/react-dialog";
|
7
7
|
import cx from "clsx";
|
8
|
-
import {
|
8
|
+
import { Fragment } from "react";
|
9
9
|
import { X } from "react-feather";
|
10
|
-
import { CSSTransition } from "react-transition-group";
|
11
|
-
import useKeyPressEvent from "react-use/lib/useKeyPressEvent";
|
12
|
-
import useLockBodyScroll from "react-use/lib/useLockBodyScroll";
|
13
10
|
import { IconButton } from "../Button";
|
14
11
|
import Card from "../Card";
|
15
12
|
import { useCreatePortal, useLocale } from "../Satellite";
|
16
13
|
import stl from "../styles/helpers/satellitePrefixer";
|
17
|
-
import uniqueId from "../utils/uniqueId";
|
18
14
|
import ModalFooter from "./components/ModalFooter";
|
15
|
+
import ModalSection from "./components/ModalSection";
|
19
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
20
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
21
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
22
18
|
var DEFAULT_MODAL_LOCALE = {
|
23
|
-
dismissText: "Dismiss"
|
24
|
-
|
25
|
-
var ModalAnimation = function ModalAnimation(props) {
|
26
|
-
return (
|
27
|
-
/*#__PURE__*/
|
28
|
-
/* eslint-disable-next-line @algolia/satellite/invalid-classnames */
|
29
|
-
_jsx(CSSTransition, _objectSpread(_objectSpread({}, props), {}, {
|
30
|
-
classNames: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["satellite-modal"]))),
|
31
|
-
timeout: 200,
|
32
|
-
appear: true,
|
33
|
-
unmountOnExit: true
|
34
|
-
}))
|
35
|
-
);
|
36
|
-
};
|
37
|
-
var ModalNoAnimation = function ModalNoAnimation(props) {
|
38
|
-
return props["in"] ? /*#__PURE__*/_jsx(_Fragment, {
|
39
|
-
children: props.children
|
40
|
-
}) : null;
|
19
|
+
dismissText: "Dismiss",
|
20
|
+
modalTitle: "Modal"
|
41
21
|
};
|
42
22
|
var SIZE_CLASSNAMES = {
|
43
|
-
medium: stl(
|
44
|
-
large: stl(
|
23
|
+
medium: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["modal-dialog-medium"]))),
|
24
|
+
large: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["modal-dialog-large"])))
|
45
25
|
};
|
46
26
|
export var Modal = function Modal(_ref) {
|
47
27
|
var title = _ref.title,
|
48
28
|
className = _ref.className,
|
49
29
|
children = _ref.children,
|
50
30
|
_ref$open = _ref.open,
|
51
|
-
open = _ref$open === void 0 ?
|
31
|
+
open = _ref$open === void 0 ? false : _ref$open,
|
32
|
+
onDismiss = _ref.onDismiss,
|
52
33
|
_ref$fullBleed = _ref.fullBleed,
|
53
34
|
fullBleed = _ref$fullBleed === void 0 ? false : _ref$fullBleed,
|
54
|
-
_ref$onDismiss = _ref.onDismiss,
|
55
|
-
onDismiss = _ref$onDismiss === void 0 ? function () {} : _ref$onDismiss,
|
56
35
|
_ref$animate = _ref.animate,
|
57
36
|
animate = _ref$animate === void 0 ? true : _ref$animate,
|
58
37
|
_ref$hideCloseIcon = _ref.hideCloseIcon,
|
@@ -61,91 +40,100 @@ export var Modal = function Modal(_ref) {
|
|
61
40
|
size = _ref$size === void 0 ? "medium" : _ref$size,
|
62
41
|
_ref$centerY = _ref.centerY,
|
63
42
|
centerY = _ref$centerY === void 0 ? false : _ref$centerY,
|
43
|
+
autoFocusOnOpenElement = _ref.autoFocusOnOpenElement,
|
44
|
+
autoFocusOnCloseElement = _ref.autoFocusOnCloseElement,
|
45
|
+
triggerButton = _ref.triggerButton,
|
64
46
|
propsLocale = _ref.locale;
|
65
|
-
var createPortal = useCreatePortal();
|
66
47
|
var contextLocale = useLocale("modal");
|
67
48
|
var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_MODAL_LOCALE), contextLocale), propsLocale);
|
68
|
-
var
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
return uniqueId("modal-title");
|
77
|
-
}, []);
|
78
|
-
useLockBodyScroll(open);
|
79
|
-
useKeyPressEvent("Escape", function () {
|
80
|
-
if (open) onDismiss();
|
81
|
-
});
|
82
|
-
useEffect(function () {
|
83
|
-
if (!modalWrapperRef) return;
|
84
|
-
var onMouseUp = function onMouseUp(evt) {
|
85
|
-
if (evt.target === mouseDownTargetRef.current && dialogRef.current && !dialogRef.current.contains(evt.target)) {
|
86
|
-
onDismiss();
|
49
|
+
var createPortal = useCreatePortal();
|
50
|
+
var isControlled = triggerButton === undefined;
|
51
|
+
if (typeof document === "undefined") return /*#__PURE__*/_jsx(Fragment, {});
|
52
|
+
return /*#__PURE__*/_jsxs(Dialog.Root, {
|
53
|
+
open: isControlled ? open : undefined,
|
54
|
+
onOpenChange: function onOpenChange(open) {
|
55
|
+
if (!open) {
|
56
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
87
57
|
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
children:
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
58
|
+
},
|
59
|
+
modal: true,
|
60
|
+
children: [!isControlled && /*#__PURE__*/_jsx(Dialog.Trigger, {
|
61
|
+
asChild: true,
|
62
|
+
children: triggerButton
|
63
|
+
}), createPortal( /*#__PURE__*/_jsx(Dialog.Overlay, {
|
64
|
+
className: cx(animate && stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["modal-animated"]))), stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["modal-overlay bg-grey-900/30 z-modalOverlay inset-0 fixed w-full h-full flex items-start justify-center overflow-x-hidden overflow-y-auto px-4 py-10"])))),
|
65
|
+
children: /*#__PURE__*/_jsx(Dialog.Content, {
|
66
|
+
className: cx(stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["modal-content"]))), SIZE_CLASSNAMES[size], centerY && stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["flex m-auto"])))),
|
67
|
+
onOpenAutoFocus: function onOpenAutoFocus(e) {
|
68
|
+
if (autoFocusOnOpenElement === false) {
|
69
|
+
e.preventDefault();
|
70
|
+
} else if (autoFocusOnOpenElement instanceof HTMLElement) {
|
71
|
+
e.preventDefault();
|
72
|
+
autoFocusOnOpenElement.focus();
|
73
|
+
}
|
74
|
+
},
|
75
|
+
onCloseAutoFocus: function onCloseAutoFocus(e) {
|
76
|
+
if (autoFocusOnCloseElement instanceof HTMLElement) {
|
77
|
+
e.preventDefault();
|
78
|
+
autoFocusOnCloseElement.focus();
|
79
|
+
}
|
80
|
+
},
|
81
|
+
onEscapeKeyDown: function onEscapeKeyDown(e) {
|
82
|
+
if (isControlled) {
|
83
|
+
e.preventDefault();
|
84
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
85
|
+
}
|
86
|
+
},
|
87
|
+
onInteractOutside: function onInteractOutside(e) {
|
88
|
+
if (isControlled) {
|
89
|
+
e.preventDefault();
|
90
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"aria-label": !title ? locale.modalTitle : undefined,
|
94
|
+
"aria-describedby": undefined,
|
95
|
+
children: /*#__PURE__*/_jsx("div", {
|
96
|
+
children: /*#__PURE__*/_jsx("div", {
|
97
|
+
className: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["modal-container"]))),
|
98
|
+
children: /*#__PURE__*/_jsxs(Card, {
|
99
|
+
as: "div",
|
100
|
+
elevation: "500",
|
101
|
+
className: cx(stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["relative"]))), className),
|
102
|
+
fullBleed: true,
|
103
|
+
children: [/*#__PURE__*/_jsx("header", {
|
104
|
+
className: cx(stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["min-h-14 flex items-center justify-between space-x-2"]))), title ? stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["border-b border-grey-100 pl-8 pr-16"]))) : stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["justify-end px-8"]))), !title && hideCloseIcon && stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["hidden"])))),
|
105
|
+
children: !!title && /*#__PURE__*/_jsx(Dialog.Title, {
|
106
|
+
className: stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["flex-1 display-heading truncate"]))),
|
107
|
+
children: title
|
108
|
+
})
|
109
|
+
}), /*#__PURE__*/_jsx("div", {
|
110
|
+
className: cx(!fullBleed && stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["p-10"])))),
|
111
|
+
children: children
|
112
|
+
}), !hideCloseIcon && /*#__PURE__*/_jsx("div", {
|
113
|
+
className: stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["-mr-2 absolute top-3 right-8"]))),
|
114
|
+
children: /*#__PURE__*/_jsx(Dialog.Close, {
|
115
|
+
asChild: true,
|
116
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
117
|
+
icon: X,
|
118
|
+
title: locale.dismissText,
|
119
|
+
variant: "subtle",
|
120
|
+
showTooltip: false,
|
121
|
+
onClick: function onClick(e) {
|
122
|
+
if (isControlled) {
|
123
|
+
e.preventDefault();
|
124
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
125
|
+
}
|
126
|
+
}
|
127
|
+
})
|
128
|
+
})
|
129
|
+
})]
|
130
|
+
})
|
131
|
+
})
|
145
132
|
})
|
146
|
-
})
|
147
|
-
})
|
148
|
-
})
|
133
|
+
})
|
134
|
+
}))]
|
135
|
+
});
|
149
136
|
};
|
150
137
|
Modal.Footer = ModalFooter;
|
138
|
+
Modal.Section = ModalSection;
|
151
139
|
export default Modal;
|
@@ -5,11 +5,18 @@ var modalPlugin = plugin(function (_ref) {
|
|
5
5
|
var addComponents = _ref.addComponents,
|
6
6
|
theme = _ref.theme;
|
7
7
|
var transitionEasing = "cubic-bezier(0.6, -0.28, 0.735, 0.045)";
|
8
|
-
var transitionDuration =
|
8
|
+
var transitionDuration = "200ms";
|
9
9
|
addComponents({
|
10
10
|
".modal-container": {
|
11
11
|
zIndex: theme("zIndex.modal")
|
12
12
|
},
|
13
|
+
".modal-content": {
|
14
|
+
borderRadius: "8px",
|
15
|
+
width: "100%",
|
16
|
+
"&:focus": {
|
17
|
+
outline: "none"
|
18
|
+
}
|
19
|
+
},
|
13
20
|
// Sizes
|
14
21
|
".modal-dialog-medium": {
|
15
22
|
maxWidth: "640px"
|
@@ -21,24 +28,52 @@ var modalPlugin = plugin(function (_ref) {
|
|
21
28
|
|
22
29
|
// Animation
|
23
30
|
addComponents({
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
},
|
33
|
-
"
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
31
|
+
/* eslint-disable @algolia/satellite/prefer-stl-helper */
|
32
|
+
"@keyframes stl-modal-overlay-fade-in": {
|
33
|
+
from: {
|
34
|
+
opacity: "0"
|
35
|
+
},
|
36
|
+
to: {
|
37
|
+
opacity: "1"
|
38
|
+
}
|
39
|
+
},
|
40
|
+
"@keyframes stl-modal-overlay-fade-out": {
|
41
|
+
from: {
|
42
|
+
opacity: "1"
|
43
|
+
},
|
44
|
+
to: {
|
45
|
+
opacity: "0"
|
46
|
+
}
|
47
|
+
},
|
48
|
+
"@keyframes stl-modal-content-zoop-in": {
|
49
|
+
from: {
|
50
|
+
transform: "translate(0, 8px) scale(0.94)"
|
51
|
+
},
|
52
|
+
to: {
|
53
|
+
transform: "translate(0, 0) scale(1)"
|
54
|
+
}
|
55
|
+
},
|
56
|
+
"@keyframes stl-modal-content-zoop-out": {
|
57
|
+
from: {
|
58
|
+
transform: "translate(0, 0) scale(1)"
|
59
|
+
},
|
60
|
+
to: {
|
61
|
+
transform: "translate(0, 8px) scale(0.94)"
|
62
|
+
}
|
63
|
+
},
|
64
|
+
".modal-animated.modal-overlay[data-state='open']": {
|
65
|
+
animation: "stl-modal-overlay-fade-in ".concat(transitionDuration, " ").concat(transitionEasing)
|
66
|
+
},
|
67
|
+
".modal-animated.modal-overlay[data-state='closed']": {
|
68
|
+
animation: "stl-modal-overlay-fade-out ".concat(transitionDuration, " ").concat(transitionEasing)
|
69
|
+
},
|
70
|
+
".modal-animated .modal-content[data-state='open']": {
|
71
|
+
animation: "stl-modal-content-zoop-in ".concat(transitionDuration, " ").concat(transitionEasing)
|
72
|
+
},
|
73
|
+
".modal-animated .modal-content[data-state='closed']": {
|
74
|
+
animation: "stl-modal-content-zoop-out ".concat(transitionDuration, " ").concat(transitionEasing)
|
41
75
|
}
|
76
|
+
/* eslint-enable @algolia/satellite/prefer-stl-helper */
|
42
77
|
});
|
43
78
|
});
|
44
79
|
export default modalPlugin;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type
|
1
|
+
import { type FunctionComponent, type ReactNode } from "react";
|
2
2
|
import type { ComponentsLocales } from "./locale";
|
3
3
|
import type { SatelliteRouter } from "./SatelliteRouter";
|
4
4
|
export interface SatelliteProps {
|
@@ -7,5 +7,6 @@ export interface SatelliteProps {
|
|
7
7
|
portalTarget?: HTMLElement;
|
8
8
|
children: ReactNode;
|
9
9
|
}
|
10
|
+
export declare const DEFAULT_PORTAL_TARGET_ID = "satellite-portal";
|
10
11
|
export declare const Satellite: FunctionComponent<SatelliteProps>;
|
11
12
|
export default Satellite;
|
@@ -1,12 +1,35 @@
|
|
1
|
+
import { useEffect } from "react";
|
1
2
|
import SatelliteContext from "./SatelliteContext";
|
2
3
|
import { router as defaultRouter } from "./SatelliteRouter";
|
3
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
export var DEFAULT_PORTAL_TARGET_ID = "satellite-portal";
|
6
|
+
var portalElement;
|
7
|
+
var getPortalElement = function getPortalElement() {
|
8
|
+
if (typeof document === "undefined") return;
|
9
|
+
if (!portalElement) {
|
10
|
+
var element = document.createElement("div");
|
11
|
+
element.setAttribute("id", DEFAULT_PORTAL_TARGET_ID);
|
12
|
+
document.body.appendChild(element);
|
13
|
+
portalElement = element;
|
14
|
+
}
|
15
|
+
return portalElement;
|
16
|
+
};
|
4
17
|
export var Satellite = function Satellite(_ref) {
|
5
18
|
var _ref$router = _ref.router,
|
6
19
|
router = _ref$router === void 0 ? defaultRouter : _ref$router,
|
7
20
|
locales = _ref.locales,
|
8
|
-
portalTarget = _ref.portalTarget,
|
21
|
+
_ref$portalTarget = _ref.portalTarget,
|
22
|
+
portalTarget = _ref$portalTarget === void 0 ? getPortalElement() : _ref$portalTarget,
|
9
23
|
children = _ref.children;
|
24
|
+
useEffect(function () {
|
25
|
+
if (!portalTarget) return;
|
26
|
+
if (portalTarget === document.body) {
|
27
|
+
console.warn("Avoid using the document body as a portal target.");
|
28
|
+
}
|
29
|
+
|
30
|
+
// Radix adds pointer-events: none; on the body for its modal, so we need to reenable it for other portaled elements (tooltips, menus, autocomplete)
|
31
|
+
portalTarget.style.pointerEvents = "auto";
|
32
|
+
}, [portalTarget]);
|
10
33
|
return /*#__PURE__*/_jsx(SatelliteContext.Provider, {
|
11
34
|
value: {
|
12
35
|
router: router,
|
package/esm/Tag/Tag.d.ts
CHANGED
@@ -2,20 +2,40 @@ import type { DetailedHTMLProps, HTMLAttributes, MouseEventHandler } from "react
|
|
2
2
|
import type { ColorVariant } from "../types";
|
3
3
|
export declare type TagVariants = ColorVariant | "pink";
|
4
4
|
export declare type TagLocale = {
|
5
|
-
|
5
|
+
addButton?: string | ((title: string) => string);
|
6
|
+
deleteButton?: string | ((title: string) => string);
|
6
7
|
};
|
7
8
|
export interface TagProps extends DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
|
8
9
|
/**
|
9
10
|
* The "pink" variant should only be used for **Algolia admin** related things.
|
10
11
|
* @default "grey"
|
11
|
-
|
12
|
+
*/
|
12
13
|
variant?: TagVariants;
|
14
|
+
/**
|
15
|
+
* Handler function called when the "add" button is clicked.
|
16
|
+
*/
|
17
|
+
onAdd?: MouseEventHandler<HTMLElement>;
|
18
|
+
/**
|
19
|
+
* The tooltip text to display when hovering over the "add" button.
|
20
|
+
*/
|
21
|
+
addTooltip?: string;
|
22
|
+
/**
|
23
|
+
* Handler function called when the "delete" button is clicked.
|
24
|
+
*/
|
13
25
|
onDelete?: MouseEventHandler<HTMLElement>;
|
26
|
+
/**
|
27
|
+
* The tooltip text to display when hovering over the "delete" button.
|
28
|
+
*/
|
29
|
+
deleteTooltip?: string;
|
30
|
+
/**
|
31
|
+
* Customize the text describing the "add" and "delete" buttons.
|
32
|
+
* If not provided, default values will be used.
|
33
|
+
*/
|
14
34
|
locale?: TagLocale;
|
15
35
|
}
|
16
36
|
/**
|
17
|
-
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or
|
18
|
-
* Keep in mind that tags increase the amount of visual noise, particularly when combined with other visual labelling elements, so use them in moderation. Tags can be added or
|
37
|
+
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or deleted from an object by users**.
|
38
|
+
* Keep in mind that tags increase the amount of visual noise, particularly when combined with other visual labelling elements, so use them in moderation. Tags can be added or deleted from an object by users.
|
19
39
|
*
|
20
40
|
* - For status information, use badges instead
|
21
41
|
* - For tallies or counts, use badges
|
@@ -30,9 +50,9 @@ export interface TagProps extends DetailedHTMLProps<HTMLAttributes<HTMLSpanEleme
|
|
30
50
|
* - **Error**: `variant="red"`
|
31
51
|
*
|
32
52
|
* ## Usability best practices
|
33
|
-
* - Present tags close to or within the input control to allow users to add and
|
53
|
+
* - Present tags close to or within the input control to allow users to add and delete tags
|
34
54
|
* - When writing tags, avoid line-wrapping
|
35
55
|
* - Define the max width of text within a tag. Once the text reaches the max, truncate with ellipses
|
36
56
|
*/
|
37
|
-
export declare const Tag: import("react").ForwardRefExoticComponent<Pick<TagProps, "key" | "id" | "color" | "translate" | "hidden" | "dir" | "slot" | "style" | "title" | "accessKey" | "draggable" | "lang" | "className" | "prefix" | "children" | "contentEditable" | "inputMode" | "tabIndex" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "variant" | "locale" | "onDelete"> & import("react").RefAttributes<HTMLSpanElement>>;
|
57
|
+
export declare const Tag: import("react").ForwardRefExoticComponent<Pick<TagProps, "key" | "id" | "color" | "translate" | "hidden" | "dir" | "slot" | "style" | "title" | "accessKey" | "draggable" | "lang" | "className" | "prefix" | "children" | "contentEditable" | "inputMode" | "tabIndex" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "variant" | "locale" | "onAdd" | "addTooltip" | "onDelete" | "deleteTooltip"> & import("react").RefAttributes<HTMLSpanElement>>;
|
38
58
|
export default Tag;
|
package/esm/Tag/Tag.js
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
|
-
var _excluded = ["children", "variant", "className", "onDelete", "locale"];
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
4
|
+
var _excluded = ["children", "variant", "className", "onAdd", "addTooltip", "onDelete", "deleteTooltip", "locale"];
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21;
|
6
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
8
|
import cx from "clsx";
|
9
9
|
import { forwardRef } from "react";
|
10
|
-
import { X } from "react-feather";
|
10
|
+
import { Plus, X } from "react-feather";
|
11
11
|
import { useLocale } from "../Satellite";
|
12
12
|
import stl from "../styles/helpers/satellitePrefixer";
|
13
|
+
import { TooltipWrapper } from "../Tooltip";
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
14
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
15
16
|
var DEFAULT_TAG_LOCALE = {
|
16
|
-
|
17
|
-
return "
|
17
|
+
addButton: function addButton(title) {
|
18
|
+
return "Add ".concat(title);
|
19
|
+
},
|
20
|
+
deleteButton: function deleteButton(title) {
|
21
|
+
return "Delete ".concat(title);
|
18
22
|
}
|
19
23
|
};
|
20
24
|
var VARIANT_CLASSNAMES = {
|
@@ -26,7 +30,7 @@ var VARIANT_CLASSNAMES = {
|
|
26
30
|
red: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["bg-red-100 border-red-200 text-red-700"]))),
|
27
31
|
pink: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["bg-pink-100 border-pink-200 text-pink-700"])))
|
28
32
|
};
|
29
|
-
var
|
33
|
+
var BUTTON_VARIANT_CLASSNAMES = {
|
30
34
|
accent: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["border-accent-200 hover:bg-accent-200 focus:bg-accent-200"]))),
|
31
35
|
grey: stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["border-grey-200 hover:bg-grey-200 focus:bg-grey-200"]))),
|
32
36
|
blue: stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["border-blue-200 hover:bg-blue-200 focus:bg-blue-200"]))),
|
@@ -37,8 +41,8 @@ var BUTTON_CLOSE_VARIANT_CLASSNAMES = {
|
|
37
41
|
};
|
38
42
|
|
39
43
|
/**
|
40
|
-
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or
|
41
|
-
* Keep in mind that tags increase the amount of visual noise, particularly when combined with other visual labelling elements, so use them in moderation. Tags can be added or
|
44
|
+
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or deleted from an object by users**.
|
45
|
+
* Keep in mind that tags increase the amount of visual noise, particularly when combined with other visual labelling elements, so use them in moderation. Tags can be added or deleted from an object by users.
|
42
46
|
*
|
43
47
|
* - For status information, use badges instead
|
44
48
|
* - For tallies or counts, use badges
|
@@ -53,7 +57,7 @@ var BUTTON_CLOSE_VARIANT_CLASSNAMES = {
|
|
53
57
|
* - **Error**: `variant="red"`
|
54
58
|
*
|
55
59
|
* ## Usability best practices
|
56
|
-
* - Present tags close to or within the input control to allow users to add and
|
60
|
+
* - Present tags close to or within the input control to allow users to add and delete tags
|
57
61
|
* - When writing tags, avoid line-wrapping
|
58
62
|
* - Define the max width of text within a tag. Once the text reaches the max, truncate with ellipses
|
59
63
|
*/
|
@@ -62,31 +66,59 @@ export var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
62
66
|
_ref$variant = _ref.variant,
|
63
67
|
variant = _ref$variant === void 0 ? "grey" : _ref$variant,
|
64
68
|
className = _ref.className,
|
69
|
+
onAdd = _ref.onAdd,
|
70
|
+
addTooltip = _ref.addTooltip,
|
65
71
|
onDelete = _ref.onDelete,
|
72
|
+
deleteTooltip = _ref.deleteTooltip,
|
66
73
|
propsLocale = _ref.locale,
|
67
74
|
props = _objectWithoutProperties(_ref, _excluded);
|
68
75
|
var title = typeof children === "string" ? children : "tag";
|
69
76
|
var contextLocale = useLocale("tag");
|
70
77
|
var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_TAG_LOCALE), contextLocale), propsLocale);
|
71
78
|
var tagClassName = cx(stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["tag"]))), VARIANT_CLASSNAMES[variant], className);
|
72
|
-
var
|
79
|
+
var addable = Boolean(onAdd);
|
80
|
+
var deletable = Boolean(onDelete);
|
81
|
+
var handleAdd = function handleAdd(evt) {
|
82
|
+
evt.stopPropagation();
|
83
|
+
onAdd === null || onAdd === void 0 ? void 0 : onAdd(evt);
|
84
|
+
};
|
73
85
|
var handleDelete = function handleDelete(evt) {
|
74
86
|
evt.stopPropagation();
|
75
87
|
onDelete === null || onDelete === void 0 ? void 0 : onDelete(evt);
|
76
88
|
};
|
89
|
+
var content = /*#__PURE__*/_jsx("span", {
|
90
|
+
className: stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["truncate flex-1 leading-base"]))),
|
91
|
+
children: children
|
92
|
+
});
|
77
93
|
return /*#__PURE__*/_jsxs("span", _objectSpread(_objectSpread({}, props), {}, {
|
78
94
|
className: tagClassName,
|
79
95
|
ref: ref,
|
80
|
-
children: [/*#__PURE__*/_jsx(
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
96
|
+
children: [addable ? /*#__PURE__*/_jsx(TooltipWrapper, {
|
97
|
+
content: addTooltip,
|
98
|
+
hideDelay: 0,
|
99
|
+
placement: "bottom",
|
100
|
+
wrapperClassName: stl(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["h-full"]))),
|
101
|
+
children: /*#__PURE__*/_jsxs("button", {
|
102
|
+
className: cx(stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["tag-add-button"]))), !deletable && stl(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["-mr-2"]))), BUTTON_VARIANT_CLASSNAMES[variant]),
|
103
|
+
type: "button",
|
104
|
+
onClick: handleAdd,
|
105
|
+
"aria-label": typeof locale.addButton === "function" ? locale.addButton(title) : locale.addButton,
|
106
|
+
children: [/*#__PURE__*/_jsx(Plus, {
|
107
|
+
size: "1em"
|
108
|
+
}), content]
|
109
|
+
})
|
110
|
+
}) : content, deletable && /*#__PURE__*/_jsx(TooltipWrapper, {
|
111
|
+
content: deleteTooltip,
|
112
|
+
hideDelay: 0,
|
113
|
+
placement: "bottom-start",
|
114
|
+
children: /*#__PURE__*/_jsx("button", {
|
115
|
+
className: cx(stl(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["tag-close-button p-1"]))), !addable && stl(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["ml-2"]))), BUTTON_VARIANT_CLASSNAMES[variant]),
|
116
|
+
type: "button",
|
117
|
+
onClick: handleDelete,
|
118
|
+
"aria-label": typeof locale.deleteButton === "function" ? locale.deleteButton(title) : locale.deleteButton,
|
119
|
+
children: /*#__PURE__*/_jsx(X, {
|
120
|
+
size: "1em"
|
121
|
+
})
|
90
122
|
})
|
91
123
|
})]
|
92
124
|
}));
|