@algolia/satellite 1.0.0-beta.157 → 1.0.0-beta.158
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 +131 -95
- package/cjs/Modal/Modal.tailwind.js +7 -0
- 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 +129 -96
- package/esm/Modal/Modal.tailwind.js +7 -0
- 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/cjs/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/cjs/Tag/Tag.js
CHANGED
@@ -13,14 +13,18 @@ var _react = require("react");
|
|
13
13
|
var _reactFeather = require("react-feather");
|
14
14
|
var _Satellite = require("../Satellite");
|
15
15
|
var _satellitePrefixer = _interopRequireDefault(require("../styles/helpers/satellitePrefixer"));
|
16
|
+
var _Tooltip = require("../Tooltip");
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
17
|
-
var _excluded = ["children", "variant", "className", "onDelete", "locale"];
|
18
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
18
|
+
var _excluded = ["children", "variant", "className", "onAdd", "addTooltip", "onDelete", "deleteTooltip", "locale"];
|
19
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21;
|
19
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; }
|
20
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; }
|
21
22
|
var DEFAULT_TAG_LOCALE = {
|
22
|
-
|
23
|
-
return "
|
23
|
+
addButton: function addButton(title) {
|
24
|
+
return "Add ".concat(title);
|
25
|
+
},
|
26
|
+
deleteButton: function deleteButton(title) {
|
27
|
+
return "Delete ".concat(title);
|
24
28
|
}
|
25
29
|
};
|
26
30
|
var VARIANT_CLASSNAMES = {
|
@@ -32,7 +36,7 @@ var VARIANT_CLASSNAMES = {
|
|
32
36
|
red: (0, _satellitePrefixer["default"])(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["bg-red-100 border-red-200 text-red-700"]))),
|
33
37
|
pink: (0, _satellitePrefixer["default"])(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["bg-pink-100 border-pink-200 text-pink-700"])))
|
34
38
|
};
|
35
|
-
var
|
39
|
+
var BUTTON_VARIANT_CLASSNAMES = {
|
36
40
|
accent: (0, _satellitePrefixer["default"])(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["border-accent-200 hover:bg-accent-200 focus:bg-accent-200"]))),
|
37
41
|
grey: (0, _satellitePrefixer["default"])(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["border-grey-200 hover:bg-grey-200 focus:bg-grey-200"]))),
|
38
42
|
blue: (0, _satellitePrefixer["default"])(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["border-blue-200 hover:bg-blue-200 focus:bg-blue-200"]))),
|
@@ -43,8 +47,8 @@ var BUTTON_CLOSE_VARIANT_CLASSNAMES = {
|
|
43
47
|
};
|
44
48
|
|
45
49
|
/**
|
46
|
-
* Use tags to visually label UI objects for quick recognition and navigation. (!) **Tags can be added or
|
47
|
-
* 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 deleted 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 deleted from an object by users.
|
48
52
|
*
|
49
53
|
* - For status information, use badges instead
|
50
54
|
* - For tallies or counts, use badges
|
@@ -59,7 +63,7 @@ var BUTTON_CLOSE_VARIANT_CLASSNAMES = {
|
|
59
63
|
* - **Error**: `variant="red"`
|
60
64
|
*
|
61
65
|
* ## Usability best practices
|
62
|
-
* - 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 delete tags
|
63
67
|
* - When writing tags, avoid line-wrapping
|
64
68
|
* - Define the max width of text within a tag. Once the text reaches the max, truncate with ellipses
|
65
69
|
*/
|
@@ -68,31 +72,59 @@ var Tag = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
68
72
|
_ref$variant = _ref.variant,
|
69
73
|
variant = _ref$variant === void 0 ? "grey" : _ref$variant,
|
70
74
|
className = _ref.className,
|
75
|
+
onAdd = _ref.onAdd,
|
76
|
+
addTooltip = _ref.addTooltip,
|
71
77
|
onDelete = _ref.onDelete,
|
78
|
+
deleteTooltip = _ref.deleteTooltip,
|
72
79
|
propsLocale = _ref.locale,
|
73
80
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
74
81
|
var title = typeof children === "string" ? children : "tag";
|
75
82
|
var contextLocale = (0, _Satellite.useLocale)("tag");
|
76
83
|
var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_TAG_LOCALE), contextLocale), propsLocale);
|
77
84
|
var tagClassName = (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["tag"]))), VARIANT_CLASSNAMES[variant], className);
|
78
|
-
var
|
85
|
+
var addable = Boolean(onAdd);
|
86
|
+
var deletable = Boolean(onDelete);
|
87
|
+
var handleAdd = function handleAdd(evt) {
|
88
|
+
evt.stopPropagation();
|
89
|
+
onAdd === null || onAdd === void 0 ? void 0 : onAdd(evt);
|
90
|
+
};
|
79
91
|
var handleDelete = function handleDelete(evt) {
|
80
92
|
evt.stopPropagation();
|
81
93
|
onDelete === null || onDelete === void 0 ? void 0 : onDelete(evt);
|
82
94
|
};
|
95
|
+
var content = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
96
|
+
className: (0, _satellitePrefixer["default"])(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["truncate flex-1 leading-base"]))),
|
97
|
+
children: children
|
98
|
+
});
|
83
99
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", _objectSpread(_objectSpread({}, props), {}, {
|
84
100
|
className: tagClassName,
|
85
101
|
ref: ref,
|
86
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
102
|
+
children: [addable ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.TooltipWrapper, {
|
103
|
+
content: addTooltip,
|
104
|
+
hideDelay: 0,
|
105
|
+
placement: "bottom",
|
106
|
+
wrapperClassName: (0, _satellitePrefixer["default"])(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["h-full"]))),
|
107
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
108
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2["default"])(["tag-add-button"]))), !deletable && (0, _satellitePrefixer["default"])(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2["default"])(["-mr-2"]))), BUTTON_VARIANT_CLASSNAMES[variant]),
|
109
|
+
type: "button",
|
110
|
+
onClick: handleAdd,
|
111
|
+
"aria-label": typeof locale.addButton === "function" ? locale.addButton(title) : locale.addButton,
|
112
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFeather.Plus, {
|
113
|
+
size: "1em"
|
114
|
+
}), content]
|
115
|
+
})
|
116
|
+
}) : content, deletable && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.TooltipWrapper, {
|
117
|
+
content: deleteTooltip,
|
118
|
+
hideDelay: 0,
|
119
|
+
placement: "bottom-start",
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
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
|
+
type: "button",
|
123
|
+
onClick: handleDelete,
|
124
|
+
"aria-label": typeof locale.deleteButton === "function" ? locale.deleteButton(title) : locale.deleteButton,
|
125
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFeather.X, {
|
126
|
+
size: "1em"
|
127
|
+
})
|
96
128
|
})
|
97
129
|
})]
|
98
130
|
}));
|
package/cjs/Tag/Tag.tailwind.js
CHANGED
@@ -17,11 +17,27 @@ var tagPlugin = plugin(function (_ref) {
|
|
17
17
|
fontSize: theme("fontSize.base"),
|
18
18
|
lineHeight: theme("lineHeight.sm")
|
19
19
|
},
|
20
|
+
".tag-add-button": {
|
21
|
+
display: "inline-flex",
|
22
|
+
alignItems: "center",
|
23
|
+
height: "100%",
|
24
|
+
paddingLeft: theme("spacing.2"),
|
25
|
+
paddingRight: theme("spacing.2"),
|
26
|
+
marginLeft: "-".concat(theme("spacing.2")),
|
27
|
+
columnGap: theme("spacing.2"),
|
28
|
+
"&, &:focus": {
|
29
|
+
outlineWidth: "0px"
|
30
|
+
},
|
31
|
+
"&:focus-visible": {
|
32
|
+
outlineOffset: "-2px",
|
33
|
+
outlineWidth: "3px",
|
34
|
+
outlineColor: theme("colors.accent.600")
|
35
|
+
}
|
36
|
+
},
|
20
37
|
".tag-close-button": {
|
21
38
|
height: "100%",
|
22
39
|
paddingLeft: theme("spacing.1"),
|
23
40
|
paddingRight: theme("spacing.1"),
|
24
|
-
marginLeft: theme("spacing.2"),
|
25
41
|
marginRight: "-".concat(theme("spacing.2")),
|
26
42
|
borderLeft: "1px solid transparent",
|
27
43
|
"&, &:focus": {
|
package/cjs/styles/colors.d.ts
CHANGED
@@ -23,6 +23,7 @@ export const pink: {
|
|
23
23
|
300: string;
|
24
24
|
200: string;
|
25
25
|
100: string;
|
26
|
+
50: string;
|
26
27
|
};
|
27
28
|
export const nebula: {
|
28
29
|
900: string;
|
@@ -45,6 +46,7 @@ export const xenon: {
|
|
45
46
|
300: string;
|
46
47
|
200: string;
|
47
48
|
100: string;
|
49
|
+
50: string;
|
48
50
|
};
|
49
51
|
export const blue: {
|
50
52
|
900: string;
|
@@ -56,6 +58,7 @@ export const blue: {
|
|
56
58
|
300: string;
|
57
59
|
200: string;
|
58
60
|
100: string;
|
61
|
+
50: string;
|
59
62
|
};
|
60
63
|
export const green: {
|
61
64
|
900: string;
|
@@ -67,6 +70,7 @@ export const green: {
|
|
67
70
|
300: string;
|
68
71
|
200: string;
|
69
72
|
100: string;
|
73
|
+
50: string;
|
70
74
|
};
|
71
75
|
export const orange: {
|
72
76
|
900: string;
|
@@ -78,6 +82,7 @@ export const orange: {
|
|
78
82
|
300: string;
|
79
83
|
200: string;
|
80
84
|
100: string;
|
85
|
+
50: string;
|
81
86
|
};
|
82
87
|
export const red: {
|
83
88
|
900: string;
|
@@ -89,4 +94,17 @@ export const red: {
|
|
89
94
|
300: string;
|
90
95
|
200: string;
|
91
96
|
100: string;
|
97
|
+
50: string;
|
98
|
+
};
|
99
|
+
export const purple: {
|
100
|
+
900: string;
|
101
|
+
800: string;
|
102
|
+
700: string;
|
103
|
+
600: string;
|
104
|
+
500: string;
|
105
|
+
400: string;
|
106
|
+
300: string;
|
107
|
+
200: string;
|
108
|
+
100: string;
|
109
|
+
50: string;
|
92
110
|
};
|
package/cjs/styles/colors.js
CHANGED
@@ -26,7 +26,8 @@ var colors = {
|
|
26
26
|
400: "#fb5abc",
|
27
27
|
300: "#fd89ce",
|
28
28
|
200: "#feb9e2",
|
29
|
-
100: "#ffeaf6"
|
29
|
+
100: "#ffeaf6",
|
30
|
+
50: "#fff5fb"
|
30
31
|
},
|
31
32
|
nebula: {
|
32
33
|
900: "#141d61",
|
@@ -48,7 +49,8 @@ var colors = {
|
|
48
49
|
400: "#457aff",
|
49
50
|
300: "#76a0ff",
|
50
51
|
200: "#bbd1ff",
|
51
|
-
100: "#f2f4ff"
|
52
|
+
100: "#f2f4ff",
|
53
|
+
50: "#f9f9ff"
|
52
54
|
},
|
53
55
|
blue: {
|
54
56
|
900: "#00526c",
|
@@ -59,18 +61,20 @@ var colors = {
|
|
59
61
|
400: "#5adaff",
|
60
62
|
300: "#89e5ff",
|
61
63
|
200: "#b9efff",
|
62
|
-
100: "#e8faff"
|
64
|
+
100: "#e8faff",
|
65
|
+
50: "#f3fdff"
|
63
66
|
},
|
64
67
|
green: {
|
65
|
-
900: "#
|
66
|
-
800: "#
|
67
|
-
700: "#
|
68
|
-
600: "#
|
69
|
-
500: "#
|
70
|
-
400: "#
|
71
|
-
300: "#
|
72
|
-
200: "#
|
73
|
-
100: "#
|
68
|
+
900: "#005d43",
|
69
|
+
800: "#007046",
|
70
|
+
700: "#008b4a",
|
71
|
+
600: "#00a648",
|
72
|
+
500: "#00c241",
|
73
|
+
400: "#4ade6d",
|
74
|
+
300: "#86f195",
|
75
|
+
200: "#bffbc2",
|
76
|
+
100: "#e5fde4",
|
77
|
+
50: "#f2fef1"
|
74
78
|
},
|
75
79
|
orange: {
|
76
80
|
900: "#963209",
|
@@ -81,18 +85,32 @@ var colors = {
|
|
81
85
|
400: "#fcbc73",
|
82
86
|
300: "#fed59a",
|
83
87
|
200: "#ffe9c3",
|
84
|
-
100: "#fff9ec"
|
88
|
+
100: "#fff9ec",
|
89
|
+
50: "#fffcf5"
|
85
90
|
},
|
86
91
|
red: {
|
87
92
|
900: "#83111e",
|
88
93
|
800: "#ab1325",
|
89
94
|
700: "#d4142a",
|
90
|
-
600: "#
|
95
|
+
600: "#e9122c",
|
91
96
|
500: "#f4495d",
|
92
97
|
400: "#f86e7e",
|
93
98
|
300: "#fc95a1",
|
94
99
|
200: "#febdc5",
|
95
|
-
100: "#ffe6e9"
|
100
|
+
100: "#ffe6e9",
|
101
|
+
50: "#fff3f4"
|
102
|
+
},
|
103
|
+
purple: {
|
104
|
+
900: "#3c0b93",
|
105
|
+
800: "#5612b7",
|
106
|
+
700: "#731adb",
|
107
|
+
600: "#9524ff",
|
108
|
+
500: "#b75aff",
|
109
|
+
400: "#cc7bff",
|
110
|
+
300: "#e2a7ff",
|
111
|
+
200: "#f2d3ff",
|
112
|
+
100: "#fcf4ff",
|
113
|
+
50: "#fdf9ff"
|
96
114
|
}
|
97
115
|
};
|
98
116
|
module.exports = colors;
|
package/cjs/types.d.ts
CHANGED
@@ -17,3 +17,12 @@ export declare type AtLeastOne<T, U = {
|
|
17
17
|
export declare type WithRequiredProperty<Type, Key extends keyof Type> = Type & {
|
18
18
|
[Property in Key]-?: Type[Property];
|
19
19
|
};
|
20
|
+
declare type Without<T, U> = {
|
21
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
22
|
+
};
|
23
|
+
/**
|
24
|
+
* Makes two types mutually exclusive
|
25
|
+
* https://stackoverflow.com/questions/42123407/does-typescript-support-mutually-exclusive-types
|
26
|
+
*/
|
27
|
+
export declare type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
28
|
+
export {};
|
package/esm/Badge/Badge.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { FunctionComponent, HTMLAttributes, ReactNode } from "react";
|
2
2
|
import type { AtLeastOne, ColorVariant, IconComponentType } from "../types";
|
3
|
-
export declare type BadgeSizes = "
|
3
|
+
export declare type BadgeSizes = "small" | "medium" | "large";
|
4
4
|
export declare type BadgeVariants = ColorVariant | "pink";
|
5
5
|
interface BaseBadgeProps extends HTMLAttributes<HTMLDivElement> {
|
6
6
|
/** @default "grey" */
|
@@ -21,7 +21,7 @@ export declare type BadgeProps = BaseBadgeProps & AtLeastOne<BadgeContentProps>;
|
|
21
21
|
*
|
22
22
|
* - Stay consistent with badge content (text), don't vary your vocabulary
|
23
23
|
* - Bages usually come after a textual information or explanation
|
24
|
-
* - Don't use badges where traditional error messages
|
24
|
+
* - Don't use badges where traditional error messages (such as form validation) can be used instead
|
25
25
|
* - Don't use badges with combination of buttons
|
26
26
|
* - Badges are not interactive
|
27
27
|
*
|
package/esm/Badge/Badge.js
CHANGED
@@ -2,7 +2,7 @@ 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
4
|
var _excluded = ["children", "value", "icon", "variant", "size", "className"];
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
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";
|
@@ -21,8 +21,9 @@ var VARIANT_CLASSNAMES = {
|
|
21
21
|
pink: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["bg-pink-100 border-pink-200 text-pink-700"])))
|
22
22
|
};
|
23
23
|
var SIZE_CLASSNAMES = {
|
24
|
-
|
25
|
-
|
24
|
+
small: stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["h-4 display-caption px-1 space-x-1"]))),
|
25
|
+
medium: stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["h-5 display-body px-2 space-x-2"]))),
|
26
|
+
large: stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["h-6 display-body px-2 space-x-2"])))
|
26
27
|
};
|
27
28
|
|
28
29
|
/**
|
@@ -30,7 +31,7 @@ var SIZE_CLASSNAMES = {
|
|
30
31
|
*
|
31
32
|
* - Stay consistent with badge content (text), don't vary your vocabulary
|
32
33
|
* - Bages usually come after a textual information or explanation
|
33
|
-
* - Don't use badges where traditional error messages
|
34
|
+
* - Don't use badges where traditional error messages (such as form validation) can be used instead
|
34
35
|
* - Don't use badges with combination of buttons
|
35
36
|
* - Badges are not interactive
|
36
37
|
*
|
@@ -47,7 +48,7 @@ export var Badge = function Badge(_ref) {
|
|
47
48
|
_ref$variant = _ref.variant,
|
48
49
|
variant = _ref$variant === void 0 ? "grey" : _ref$variant,
|
49
50
|
_ref$size = _ref.size,
|
50
|
-
size = _ref$size === void 0 ? "
|
51
|
+
size = _ref$size === void 0 ? "large" : _ref$size,
|
51
52
|
className = _ref.className,
|
52
53
|
props = _objectWithoutProperties(_ref, _excluded);
|
53
54
|
var badgeClassName = cx(BASE_CLASSNAMES, VARIANT_CLASSNAMES[variant], SIZE_CLASSNAMES[size], className);
|
@@ -58,7 +59,7 @@ export var Badge = function Badge(_ref) {
|
|
58
59
|
size: ".8em"
|
59
60
|
})
|
60
61
|
}), isRenderedChild(children) && /*#__PURE__*/_jsx("span", {
|
61
|
-
className: stl(
|
62
|
+
className: stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["truncate"]))),
|
62
63
|
children: children
|
63
64
|
}), isRenderedChild(value) && /*#__PURE__*/_jsx("span", {
|
64
65
|
children: value
|
@@ -31,7 +31,7 @@ var ICON_VARIANTS = {
|
|
31
31
|
var ICON_CLASSNAME_VARIANTS = {
|
32
32
|
grey: stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["text-grey-600"]))),
|
33
33
|
accent: stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["text-accent-600"]))),
|
34
|
-
green: stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["text-green-
|
34
|
+
green: stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["text-green-600"]))),
|
35
35
|
orange: stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["text-orange-600"]))),
|
36
36
|
red: stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["text-red-600"])))
|
37
37
|
};
|
package/esm/Button/Button.d.ts
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import {
|
3
|
-
export declare type ButtonProps
|
4
|
-
as?: T;
|
5
|
-
};
|
2
|
+
import { type PolymorphicButtonProps } from "./PolymorphicButton";
|
3
|
+
export declare type ButtonProps = Omit<PolymorphicButtonProps<"button">, "as" | "ref">;
|
6
4
|
/**
|
7
5
|
* Buttons are used to trigger user actions (like "Add", "Close" or "Save") or navigate users elsewhere through the links. Buttons can contain a combination of a clear label and an icon while links are always text.
|
8
6
|
*
|
@@ -17,5 +15,5 @@ export declare type ButtonProps<T extends AcceptableButtonType = "button"> = But
|
|
17
15
|
* - Use icon-only button for an action that is less critical and doesn't have to drag too much of user attention
|
18
16
|
* - Buttons can take the full width to fill the parent container
|
19
17
|
*/
|
20
|
-
export declare const Button: <
|
18
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
21
19
|
export default Button;
|
package/esm/Button/Button.js
CHANGED
@@ -1,19 +1,9 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
|
-
var _excluded = ["as", "className", "variant", "size", "startIcon", "endIcon", "loading", "children"];
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
6
2
|
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
3
|
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
|
-
import
|
9
|
-
import
|
10
|
-
import stl from "../styles/helpers/satellitePrefixer";
|
11
|
-
import { BUTTON_LOADER_ICON_SIZES, BUTTON_SIZE_CLASSNAMES, BUTTON_VARIANT_CLASSNAMES, getIconColorClassName } from "./styles";
|
12
|
-
import { isButtonType } from "./types";
|
4
|
+
import { forwardRef } from "react";
|
5
|
+
import { PolymorphicButton } from "./PolymorphicButton";
|
13
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
14
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
15
|
-
var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["btn inline-flex justify-center items-center px-4 typo-display-body"])));
|
16
|
-
|
17
7
|
/**
|
18
8
|
* Buttons are used to trigger user actions (like "Add", "Close" or "Save") or navigate users elsewhere through the links. Buttons can contain a combination of a clear label and an icon while links are always text.
|
19
9
|
*
|
@@ -28,45 +18,11 @@ var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateL
|
|
28
18
|
* - Use icon-only button for an action that is less critical and doesn't have to drag too much of user attention
|
29
19
|
* - Buttons can take the full width to fill the parent container
|
30
20
|
*/
|
31
|
-
export var Button = function
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
_props$variant = props.variant,
|
36
|
-
variant = _props$variant === void 0 ? "neutral" : _props$variant,
|
37
|
-
_props$size = props.size,
|
38
|
-
size = _props$size === void 0 ? "medium" : _props$size,
|
39
|
-
StartIcon = props.startIcon,
|
40
|
-
EndIcon = props.endIcon,
|
41
|
-
_props$loading = props.loading,
|
42
|
-
loading = _props$loading === void 0 ? false : _props$loading,
|
43
|
-
children = props.children,
|
44
|
-
cleanedProps = _objectWithoutProperties(props, _excluded);
|
45
|
-
if (loading) {
|
46
|
-
cleanedProps.disabled = true;
|
47
|
-
}
|
48
|
-
var buttonClassName = cx(BASE_CLASSNAMES, BUTTON_SIZE_CLASSNAMES[size], BUTTON_VARIANT_CLASSNAMES[variant], cleanedProps.disabled && stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["btn-disabled"]))), className);
|
49
|
-
var loaderClassNames = stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["absolute ", ""])), (variant === "destructive" || variant === "primary") && "text-white");
|
50
|
-
var iconClassNames = cx(getIconColorClassName(props), loading && stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["invisible"]))));
|
51
|
-
var textClassNames = cx(loading && stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["invisible"]))));
|
52
|
-
if (isButtonType(props) && !Object.prototype.hasOwnProperty.call(cleanedProps, "type")) {
|
53
|
-
// @ts-ignore
|
54
|
-
cleanedProps.type = "button";
|
55
|
-
}
|
56
|
-
return /*#__PURE__*/_jsxs(Component, _objectSpread(_objectSpread({}, cleanedProps), {}, {
|
57
|
-
className: buttonClassName,
|
58
|
-
children: [loading && /*#__PURE__*/_jsx(ProgressSpinner, {
|
59
|
-
className: loaderClassNames,
|
60
|
-
size: BUTTON_LOADER_ICON_SIZES[size],
|
61
|
-
thickness: 1
|
62
|
-
}), StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
63
|
-
className: cx(stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["shrink-0 pr-2"]))), iconClassNames)
|
64
|
-
}), /*#__PURE__*/_jsx("span", {
|
65
|
-
className: cx(stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["truncate text-center"]))), textClassNames),
|
66
|
-
children: children
|
67
|
-
}), EndIcon && /*#__PURE__*/_jsx(EndIcon, {
|
68
|
-
className: cx(stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["shrink-0 pl-2"]))), iconClassNames)
|
69
|
-
})]
|
21
|
+
export var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
22
|
+
return /*#__PURE__*/_jsx(PolymorphicButton, _objectSpread(_objectSpread({}, props), {}, {
|
23
|
+
as: "button",
|
24
|
+
ref: ref
|
70
25
|
}));
|
71
|
-
};
|
26
|
+
});
|
27
|
+
Button.displayName = "Button";
|
72
28
|
export default Button;
|
@@ -1,20 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import type
|
3
|
-
|
4
|
-
|
5
|
-
export interface IconButtonBaseProps {
|
6
|
-
variant?: ButtonVariant;
|
7
|
-
size?: ButtonSize;
|
8
|
-
disabled?: boolean;
|
9
|
-
icon: IconComponentType;
|
10
|
-
title: string;
|
11
|
-
showTooltip?: boolean;
|
12
|
-
/** @default "top" */
|
13
|
-
tooltipPlacement?: TooltipWrapperBaseProps["placement"];
|
14
|
-
loading?: boolean;
|
15
|
-
}
|
16
|
-
export declare type IconButtonProps<T extends AcceptableButtonType> = IconButtonBaseProps & ExtractProps<T> & {
|
17
|
-
as?: T;
|
18
|
-
};
|
19
|
-
export declare const IconButton: <T extends AcceptableButtonType = "button">(props: IconButtonProps<T>) => JSX.Element;
|
2
|
+
import { type PolymorphicIconButtonProps } from "./PolymorphicIconButton";
|
3
|
+
export declare type IconButtonProps = Omit<PolymorphicIconButtonProps<"button">, "as" | "ref">;
|
4
|
+
export declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
20
5
|
export default IconButton;
|