@algolia/satellite 1.0.0-beta.159 → 1.0.0-beta.160
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/AutoComplete/AutoComplete.js +1 -1
- package/cjs/Tag/Tag.d.ts +10 -10
- package/cjs/Tag/Tag.js +17 -17
- package/esm/AutoComplete/AutoComplete.js +1 -1
- package/esm/Tag/Tag.d.ts +10 -10
- package/esm/Tag/Tag.js +17 -17
- package/package.json +1 -1
@@ -362,7 +362,7 @@ var AutoComplete = /*#__PURE__*/function (_Component) {
|
|
362
362
|
key: String(option.value),
|
363
363
|
editable: !disabled
|
364
364
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag["default"], {
|
365
|
-
|
365
|
+
onRemove: disabled ? undefined : function () {
|
366
366
|
return _this.removeValue(option);
|
367
367
|
},
|
368
368
|
className: (0, _satellitePrefixer["default"])(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["m-1 max-w-48 ", ""])), disabled && "opacity-50"),
|
package/cjs/Tag/Tag.d.ts
CHANGED
@@ -3,7 +3,7 @@ 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
|
-
|
6
|
+
removeButton?: string | ((title: string) => string);
|
7
7
|
};
|
8
8
|
export interface TagProps extends DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
|
9
9
|
/**
|
@@ -20,22 +20,22 @@ export interface TagProps extends DetailedHTMLProps<HTMLAttributes<HTMLSpanEleme
|
|
20
20
|
*/
|
21
21
|
addTooltip?: string;
|
22
22
|
/**
|
23
|
-
* Handler function called when the "
|
23
|
+
* Handler function called when the "remove" button is clicked.
|
24
24
|
*/
|
25
|
-
|
25
|
+
onRemove?: MouseEventHandler<HTMLElement>;
|
26
26
|
/**
|
27
|
-
* The tooltip text to display when hovering over the "
|
27
|
+
* The tooltip text to display when hovering over the "remove" button.
|
28
28
|
*/
|
29
|
-
|
29
|
+
removeTooltip?: string;
|
30
30
|
/**
|
31
|
-
* Customize the text describing the "add" and "
|
31
|
+
* Customize the text describing the "add" and "remove" buttons.
|
32
32
|
* If not provided, default values will be used.
|
33
33
|
*/
|
34
34
|
locale?: TagLocale;
|
35
35
|
}
|
36
36
|
/**
|
37
|
-
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or
|
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
|
37
|
+
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or removed 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 removed from an object by users.
|
39
39
|
*
|
40
40
|
* - For status information, use badges instead
|
41
41
|
* - For tallies or counts, use badges
|
@@ -50,9 +50,9 @@ export interface TagProps extends DetailedHTMLProps<HTMLAttributes<HTMLSpanEleme
|
|
50
50
|
* - **Error**: `variant="red"`
|
51
51
|
*
|
52
52
|
* ## Usability best practices
|
53
|
-
* - 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 remove tags
|
54
54
|
* - When writing tags, avoid line-wrapping
|
55
55
|
* - Define the max width of text within a tag. Once the text reaches the max, truncate with ellipses
|
56
56
|
*/
|
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" | "
|
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" | "onRemove" | "removeTooltip"> & import("react").RefAttributes<HTMLSpanElement>>;
|
58
58
|
export default Tag;
|
package/cjs/Tag/Tag.js
CHANGED
@@ -15,16 +15,16 @@ var _Satellite = require("../Satellite");
|
|
15
15
|
var _satellitePrefixer = _interopRequireDefault(require("../styles/helpers/satellitePrefixer"));
|
16
16
|
var _Tooltip = require("../Tooltip");
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
18
|
-
var _excluded = ["children", "variant", "className", "onAdd", "addTooltip", "
|
18
|
+
var _excluded = ["children", "variant", "className", "onAdd", "addTooltip", "onRemove", "removeTooltip", "locale"];
|
19
19
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21;
|
20
20
|
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; }
|
21
21
|
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) { (0, _defineProperty2["default"])(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; }
|
22
22
|
var DEFAULT_TAG_LOCALE = {
|
23
23
|
addButton: function addButton(title) {
|
24
|
-
return "Add ".concat(title);
|
24
|
+
return "Add \"".concat(title, "\"");
|
25
25
|
},
|
26
|
-
|
27
|
-
return "
|
26
|
+
removeButton: function removeButton(title) {
|
27
|
+
return "Remove \"".concat(title, "\"");
|
28
28
|
}
|
29
29
|
};
|
30
30
|
var VARIANT_CLASSNAMES = {
|
@@ -47,8 +47,8 @@ var BUTTON_VARIANT_CLASSNAMES = {
|
|
47
47
|
};
|
48
48
|
|
49
49
|
/**
|
50
|
-
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or
|
51
|
-
* 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
|
50
|
+
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or removed from an object by users**.
|
51
|
+
* 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 removed from an object by users.
|
52
52
|
*
|
53
53
|
* - For status information, use badges instead
|
54
54
|
* - For tallies or counts, use badges
|
@@ -63,7 +63,7 @@ var BUTTON_VARIANT_CLASSNAMES = {
|
|
63
63
|
* - **Error**: `variant="red"`
|
64
64
|
*
|
65
65
|
* ## Usability best practices
|
66
|
-
* - Present tags close to or within the input control to allow users to add and
|
66
|
+
* - Present tags close to or within the input control to allow users to add and remove tags
|
67
67
|
* - When writing tags, avoid line-wrapping
|
68
68
|
* - Define the max width of text within a tag. Once the text reaches the max, truncate with ellipses
|
69
69
|
*/
|
@@ -74,8 +74,8 @@ var Tag = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
74
74
|
className = _ref.className,
|
75
75
|
onAdd = _ref.onAdd,
|
76
76
|
addTooltip = _ref.addTooltip,
|
77
|
-
|
78
|
-
|
77
|
+
onRemove = _ref.onRemove,
|
78
|
+
removeTooltip = _ref.removeTooltip,
|
79
79
|
propsLocale = _ref.locale,
|
80
80
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
81
81
|
var title = typeof children === "string" ? children : "tag";
|
@@ -83,14 +83,14 @@ var Tag = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
83
83
|
var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_TAG_LOCALE), contextLocale), propsLocale);
|
84
84
|
var tagClassName = (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["tag"]))), VARIANT_CLASSNAMES[variant], className);
|
85
85
|
var addable = Boolean(onAdd);
|
86
|
-
var
|
86
|
+
var removable = Boolean(onRemove);
|
87
87
|
var handleAdd = function handleAdd(evt) {
|
88
88
|
evt.stopPropagation();
|
89
89
|
onAdd === null || onAdd === void 0 ? void 0 : onAdd(evt);
|
90
90
|
};
|
91
|
-
var
|
91
|
+
var handleRemove = function handleRemove(evt) {
|
92
92
|
evt.stopPropagation();
|
93
|
-
|
93
|
+
onRemove === null || onRemove === void 0 ? void 0 : onRemove(evt);
|
94
94
|
};
|
95
95
|
var content = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
96
96
|
className: (0, _satellitePrefixer["default"])(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["truncate flex-1 leading-base"]))),
|
@@ -105,7 +105,7 @@ var Tag = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
105
105
|
placement: "bottom",
|
106
106
|
wrapperClassName: (0, _satellitePrefixer["default"])(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["h-full"]))),
|
107
107
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
108
|
-
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2["default"])(["tag-add-button"]))), !
|
108
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2["default"])(["tag-add-button"]))), !removable && (0, _satellitePrefixer["default"])(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2["default"])(["-mr-2"]))), BUTTON_VARIANT_CLASSNAMES[variant]),
|
109
109
|
type: "button",
|
110
110
|
onClick: handleAdd,
|
111
111
|
"aria-label": typeof locale.addButton === "function" ? locale.addButton(title) : locale.addButton,
|
@@ -113,15 +113,15 @@ var Tag = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
113
113
|
size: "1em"
|
114
114
|
}), content]
|
115
115
|
})
|
116
|
-
}) : content,
|
117
|
-
content:
|
116
|
+
}) : content, removable && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.TooltipWrapper, {
|
117
|
+
content: removeTooltip,
|
118
118
|
hideDelay: 0,
|
119
119
|
placement: "bottom-start",
|
120
120
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
121
121
|
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject20 || (_templateObject20 = (0, _taggedTemplateLiteral2["default"])(["tag-close-button p-1"]))), !addable && (0, _satellitePrefixer["default"])(_templateObject21 || (_templateObject21 = (0, _taggedTemplateLiteral2["default"])(["ml-2"]))), BUTTON_VARIANT_CLASSNAMES[variant]),
|
122
122
|
type: "button",
|
123
|
-
onClick:
|
124
|
-
"aria-label": typeof locale.
|
123
|
+
onClick: handleRemove,
|
124
|
+
"aria-label": typeof locale.removeButton === "function" ? locale.removeButton(title) : locale.removeButton,
|
125
125
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFeather.X, {
|
126
126
|
size: "1em"
|
127
127
|
})
|
@@ -356,7 +356,7 @@ export var AutoComplete = /*#__PURE__*/function (_Component) {
|
|
356
356
|
key: String(option.value),
|
357
357
|
editable: !disabled
|
358
358
|
}) : /*#__PURE__*/_jsx(Tag, {
|
359
|
-
|
359
|
+
onRemove: disabled ? undefined : function () {
|
360
360
|
return _this.removeValue(option);
|
361
361
|
},
|
362
362
|
className: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["m-1 max-w-48 ", ""])), disabled && "opacity-50"),
|
package/esm/Tag/Tag.d.ts
CHANGED
@@ -3,7 +3,7 @@ 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
|
-
|
6
|
+
removeButton?: string | ((title: string) => string);
|
7
7
|
};
|
8
8
|
export interface TagProps extends DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
|
9
9
|
/**
|
@@ -20,22 +20,22 @@ export interface TagProps extends DetailedHTMLProps<HTMLAttributes<HTMLSpanEleme
|
|
20
20
|
*/
|
21
21
|
addTooltip?: string;
|
22
22
|
/**
|
23
|
-
* Handler function called when the "
|
23
|
+
* Handler function called when the "remove" button is clicked.
|
24
24
|
*/
|
25
|
-
|
25
|
+
onRemove?: MouseEventHandler<HTMLElement>;
|
26
26
|
/**
|
27
|
-
* The tooltip text to display when hovering over the "
|
27
|
+
* The tooltip text to display when hovering over the "remove" button.
|
28
28
|
*/
|
29
|
-
|
29
|
+
removeTooltip?: string;
|
30
30
|
/**
|
31
|
-
* Customize the text describing the "add" and "
|
31
|
+
* Customize the text describing the "add" and "remove" buttons.
|
32
32
|
* If not provided, default values will be used.
|
33
33
|
*/
|
34
34
|
locale?: TagLocale;
|
35
35
|
}
|
36
36
|
/**
|
37
|
-
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or
|
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
|
37
|
+
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or removed 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 removed from an object by users.
|
39
39
|
*
|
40
40
|
* - For status information, use badges instead
|
41
41
|
* - For tallies or counts, use badges
|
@@ -50,9 +50,9 @@ export interface TagProps extends DetailedHTMLProps<HTMLAttributes<HTMLSpanEleme
|
|
50
50
|
* - **Error**: `variant="red"`
|
51
51
|
*
|
52
52
|
* ## Usability best practices
|
53
|
-
* - 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 remove tags
|
54
54
|
* - When writing tags, avoid line-wrapping
|
55
55
|
* - Define the max width of text within a tag. Once the text reaches the max, truncate with ellipses
|
56
56
|
*/
|
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" | "
|
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" | "onRemove" | "removeTooltip"> & import("react").RefAttributes<HTMLSpanElement>>;
|
58
58
|
export default Tag;
|
package/esm/Tag/Tag.js
CHANGED
@@ -1,7 +1,7 @@
|
|
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", "onAdd", "addTooltip", "
|
4
|
+
var _excluded = ["children", "variant", "className", "onAdd", "addTooltip", "onRemove", "removeTooltip", "locale"];
|
5
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; }
|
@@ -15,10 +15,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
16
16
|
var DEFAULT_TAG_LOCALE = {
|
17
17
|
addButton: function addButton(title) {
|
18
|
-
return "Add ".concat(title);
|
18
|
+
return "Add \"".concat(title, "\"");
|
19
19
|
},
|
20
|
-
|
21
|
-
return "
|
20
|
+
removeButton: function removeButton(title) {
|
21
|
+
return "Remove \"".concat(title, "\"");
|
22
22
|
}
|
23
23
|
};
|
24
24
|
var VARIANT_CLASSNAMES = {
|
@@ -41,8 +41,8 @@ var BUTTON_VARIANT_CLASSNAMES = {
|
|
41
41
|
};
|
42
42
|
|
43
43
|
/**
|
44
|
-
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or
|
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
|
44
|
+
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or removed 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 removed from an object by users.
|
46
46
|
*
|
47
47
|
* - For status information, use badges instead
|
48
48
|
* - For tallies or counts, use badges
|
@@ -57,7 +57,7 @@ var BUTTON_VARIANT_CLASSNAMES = {
|
|
57
57
|
* - **Error**: `variant="red"`
|
58
58
|
*
|
59
59
|
* ## Usability best practices
|
60
|
-
* - 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 remove tags
|
61
61
|
* - When writing tags, avoid line-wrapping
|
62
62
|
* - Define the max width of text within a tag. Once the text reaches the max, truncate with ellipses
|
63
63
|
*/
|
@@ -68,8 +68,8 @@ export var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
68
68
|
className = _ref.className,
|
69
69
|
onAdd = _ref.onAdd,
|
70
70
|
addTooltip = _ref.addTooltip,
|
71
|
-
|
72
|
-
|
71
|
+
onRemove = _ref.onRemove,
|
72
|
+
removeTooltip = _ref.removeTooltip,
|
73
73
|
propsLocale = _ref.locale,
|
74
74
|
props = _objectWithoutProperties(_ref, _excluded);
|
75
75
|
var title = typeof children === "string" ? children : "tag";
|
@@ -77,14 +77,14 @@ export var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
77
77
|
var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_TAG_LOCALE), contextLocale), propsLocale);
|
78
78
|
var tagClassName = cx(stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["tag"]))), VARIANT_CLASSNAMES[variant], className);
|
79
79
|
var addable = Boolean(onAdd);
|
80
|
-
var
|
80
|
+
var removable = Boolean(onRemove);
|
81
81
|
var handleAdd = function handleAdd(evt) {
|
82
82
|
evt.stopPropagation();
|
83
83
|
onAdd === null || onAdd === void 0 ? void 0 : onAdd(evt);
|
84
84
|
};
|
85
|
-
var
|
85
|
+
var handleRemove = function handleRemove(evt) {
|
86
86
|
evt.stopPropagation();
|
87
|
-
|
87
|
+
onRemove === null || onRemove === void 0 ? void 0 : onRemove(evt);
|
88
88
|
};
|
89
89
|
var content = /*#__PURE__*/_jsx("span", {
|
90
90
|
className: stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["truncate flex-1 leading-base"]))),
|
@@ -99,7 +99,7 @@ export var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
99
99
|
placement: "bottom",
|
100
100
|
wrapperClassName: stl(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["h-full"]))),
|
101
101
|
children: /*#__PURE__*/_jsxs("button", {
|
102
|
-
className: cx(stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["tag-add-button"]))), !
|
102
|
+
className: cx(stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["tag-add-button"]))), !removable && stl(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["-mr-2"]))), BUTTON_VARIANT_CLASSNAMES[variant]),
|
103
103
|
type: "button",
|
104
104
|
onClick: handleAdd,
|
105
105
|
"aria-label": typeof locale.addButton === "function" ? locale.addButton(title) : locale.addButton,
|
@@ -107,15 +107,15 @@ export var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
107
107
|
size: "1em"
|
108
108
|
}), content]
|
109
109
|
})
|
110
|
-
}) : content,
|
111
|
-
content:
|
110
|
+
}) : content, removable && /*#__PURE__*/_jsx(TooltipWrapper, {
|
111
|
+
content: removeTooltip,
|
112
112
|
hideDelay: 0,
|
113
113
|
placement: "bottom-start",
|
114
114
|
children: /*#__PURE__*/_jsx("button", {
|
115
115
|
className: cx(stl(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["tag-close-button p-1"]))), !addable && stl(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["ml-2"]))), BUTTON_VARIANT_CLASSNAMES[variant]),
|
116
116
|
type: "button",
|
117
|
-
onClick:
|
118
|
-
"aria-label": typeof locale.
|
117
|
+
onClick: handleRemove,
|
118
|
+
"aria-label": typeof locale.removeButton === "function" ? locale.removeButton(title) : locale.removeButton,
|
119
119
|
children: /*#__PURE__*/_jsx(X, {
|
120
120
|
size: "1em"
|
121
121
|
})
|