@availity/mui-button 0.1.3 → 0.2.1
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/CHANGELOG.md +9 -0
- package/dist/index.d.ts +45 -5
- package/dist/index.js +94 -5
- package/dist/index.mjs +85 -4
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/lib/Button.tsx +53 -9
- package/src/lib/IconButton.tsx +35 -0
- package/src/lib/LoadingButton.tsx +41 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.2.1](https://github.com/Availity/element/compare/@availity/mui-button@0.2.0...@availity/mui-button@0.2.1) (2023-07-31)
|
|
6
|
+
|
|
7
|
+
## [0.2.0](https://github.com/Availity/element/compare/@availity/mui-button@0.1.3...@availity/mui-button@0.2.0) (2023-06-01)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **mui-button:** design specs ([6b67b24](https://github.com/Availity/element/commit/6b67b24cdfef68e14daaeba18a5fd7d90af46a09))
|
|
13
|
+
|
|
5
14
|
## [0.1.3](https://github.com/Availity/element/compare/@availity/mui-button@0.1.2...@availity/mui-button@0.1.3) (2023-04-07)
|
|
6
15
|
|
|
7
16
|
## [0.1.2](https://github.com/Availity/element/compare/@availity/mui-button@0.1.1...@availity/mui-button@0.1.2) (2023-03-23)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
|
|
3
|
+
import { ButtonProps as ButtonProps$1, IconButtonProps as IconButtonProps$1 } from '@mui/material';
|
|
4
|
+
import { LoadingButtonProps as LoadingButtonProps$1 } from '@mui/lab/LoadingButton';
|
|
3
5
|
|
|
6
|
+
declare module '@mui/material/Button' {
|
|
7
|
+
interface ButtonPropsColorOverrides {
|
|
8
|
+
tertiary: true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
4
11
|
type ButtonProps = {
|
|
12
|
+
/** The color of the component.
|
|
13
|
+
* @default secondary */
|
|
14
|
+
color?: 'primary' | 'secondary' | 'tertiary' | 'error';
|
|
15
|
+
/** The variant to use.
|
|
16
|
+
* @default contained */
|
|
17
|
+
variant?: 'outlined' | 'contained';
|
|
18
|
+
/** Internal prop used by IconButton for contained variant. */
|
|
19
|
+
iconOnly?: boolean;
|
|
20
|
+
} & Omit<ButtonProps$1, 'color' | 'component' | 'variant' | 'disableElevation' | 'disableFocusRipple' | 'disableTouchRipple' | 'centerRipple' | 'disableRipple' | 'focusRipple' | 'TouchRippleProps' | 'touchRippleRef'>;
|
|
21
|
+
declare const Button: react.ForwardRefExoticComponent<Pick<ButtonProps, keyof _mui_material_OverridableComponent.CommonProps | "form" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "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" | "children" | "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" | "onResize" | "onResizeCapture" | "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" | "action" | "disabled" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "endIcon" | "fullWidth" | "href" | "size" | "startIcon" | "variant" | "key" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "iconOnly"> & react.RefAttributes<HTMLButtonElement>>;
|
|
22
|
+
|
|
23
|
+
type IconButtonProps = {
|
|
24
|
+
/**
|
|
25
|
+
* Text for tooltip and aria-label
|
|
26
|
+
*/
|
|
27
|
+
title: string;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Toggles contained Button styling
|
|
31
|
+
*/
|
|
32
|
+
filled?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The color of the component.
|
|
35
|
+
*/
|
|
36
|
+
color?: "primary" | "secondary" | "tertiary" | "error";
|
|
37
|
+
} & Omit<IconButtonProps$1, 'aria-label' | 'color' | 'centerRipple' | 'disableRipple' | 'disableTouchRipple' | 'focusRipple' | 'disableFocusRipple' | 'TouchRippleProps' | 'touchRippleRef'>;
|
|
38
|
+
declare const IconButton: ({ children, title, filled, color, ...rest }: IconButtonProps) => JSX.Element;
|
|
39
|
+
|
|
40
|
+
type LoadingButtonProps = {
|
|
5
41
|
children: React.ReactNode;
|
|
6
|
-
|
|
7
|
-
|
|
42
|
+
/**
|
|
43
|
+
* The color of the component.
|
|
44
|
+
*/
|
|
45
|
+
color?: 'primary' | 'secondary' | 'error';
|
|
46
|
+
} & Omit<LoadingButtonProps$1, 'color' | 'centerRipple' | 'disableRipple' | 'disableTouchRipple' | 'focusRipple' | 'disableFocusRipple' | 'TouchRippleProps' | 'touchRippleRef' | 'loadingIndicator' | 'loadingPosition'>;
|
|
47
|
+
declare const LoadingButton: react.ForwardRefExoticComponent<Pick<LoadingButtonProps, keyof _mui_material_OverridableComponent.CommonProps | "form" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "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" | "children" | "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" | "onResize" | "onResizeCapture" | "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" | "action" | "disabled" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "disableElevation" | "endIcon" | "fullWidth" | "href" | "size" | "startIcon" | "variant" | "key" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "loading"> & react.RefAttributes<HTMLButtonElement>>;
|
|
8
48
|
|
|
9
|
-
export { Button, ButtonProps };
|
|
49
|
+
export { Button, ButtonProps, IconButton, IconButtonProps, LoadingButton, LoadingButtonProps };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,23 +17,110 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
18
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
25
|
|
|
20
26
|
// src/index.ts
|
|
21
27
|
var src_exports = {};
|
|
22
28
|
__export(src_exports, {
|
|
23
|
-
Button: () => Button
|
|
29
|
+
Button: () => Button,
|
|
30
|
+
IconButton: () => IconButton,
|
|
31
|
+
LoadingButton: () => LoadingButton
|
|
24
32
|
});
|
|
25
33
|
module.exports = __toCommonJS(src_exports);
|
|
26
34
|
|
|
27
35
|
// src/lib/Button.tsx
|
|
36
|
+
var import_react = require("react");
|
|
28
37
|
var import_material = require("@mui/material");
|
|
29
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
var overrideProps = {
|
|
40
|
+
disableRipple: true,
|
|
41
|
+
disableFocusRipple: true,
|
|
42
|
+
disableTouchRipple: true
|
|
43
|
+
};
|
|
44
|
+
var iconOnlyStyles = {
|
|
45
|
+
minWidth: 2,
|
|
46
|
+
px: 1,
|
|
47
|
+
"& .MuiButton-startIcon": {
|
|
48
|
+
m: 0
|
|
49
|
+
},
|
|
50
|
+
"& .MuiButton-endIcon": {
|
|
51
|
+
m: 0
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var Button = (0, import_react.forwardRef)((props, ref) => {
|
|
55
|
+
const { iconOnly, sx, ...rest } = props;
|
|
56
|
+
const styles = {
|
|
57
|
+
...iconOnly && iconOnlyStyles
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Button, {
|
|
60
|
+
sx: { ...styles, ...sx },
|
|
61
|
+
...rest,
|
|
62
|
+
...overrideProps,
|
|
63
|
+
ref
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// src/lib/IconButton.tsx
|
|
68
|
+
var import_material2 = require("@mui/material");
|
|
69
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
70
|
+
var IconButton = ({ children, title, filled, color = "tertiary", ...rest }) => {
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material2.Tooltip, {
|
|
72
|
+
title,
|
|
73
|
+
children: filled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
74
|
+
"aria-label": title,
|
|
75
|
+
color,
|
|
76
|
+
startIcon: children,
|
|
77
|
+
iconOnly: true,
|
|
78
|
+
...rest,
|
|
79
|
+
children: "\u2060"
|
|
80
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material2.IconButton, {
|
|
81
|
+
"aria-label": title,
|
|
82
|
+
disableRipple: true,
|
|
83
|
+
color: color === "tertiary" ? "secondary" : color,
|
|
84
|
+
...rest,
|
|
85
|
+
children
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// src/lib/LoadingButton.tsx
|
|
91
|
+
var import_react2 = require("react");
|
|
92
|
+
var import_LoadingButton = __toESM(require("@mui/lab/LoadingButton"));
|
|
93
|
+
var import_CircularProgress = __toESM(require("@mui/material/CircularProgress"));
|
|
94
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
95
|
+
var LoadingIndicator = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_CircularProgress.default, {
|
|
96
|
+
color: "inherit",
|
|
97
|
+
size: 16,
|
|
98
|
+
"aria-label": "loading"
|
|
99
|
+
});
|
|
100
|
+
var LoadingButton = (0, import_react2.forwardRef)((props, ref) => {
|
|
101
|
+
const { children, loading, ...rest } = props;
|
|
102
|
+
const loadingPosition = rest.startIcon ? "start" : "end";
|
|
103
|
+
const nonLoadingStyling = rest.startIcon || rest.endIcon || loading ? {} : { padding: "0 .7rem" };
|
|
104
|
+
const endIcon = rest.startIcon ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
105
|
+
style: loading ? { padding: "0 .7rem" } : {}
|
|
106
|
+
});
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_LoadingButton.default, {
|
|
108
|
+
endIcon,
|
|
109
|
+
loadingPosition,
|
|
110
|
+
loading,
|
|
111
|
+
disableRipple: true,
|
|
112
|
+
loadingIndicator: LoadingIndicator,
|
|
113
|
+
...rest,
|
|
114
|
+
ref,
|
|
115
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
116
|
+
style: nonLoadingStyling,
|
|
117
|
+
children
|
|
118
|
+
})
|
|
119
|
+
});
|
|
33
120
|
});
|
|
34
121
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
122
|
0 && (module.exports = {
|
|
36
|
-
Button
|
|
123
|
+
Button,
|
|
124
|
+
IconButton,
|
|
125
|
+
LoadingButton
|
|
37
126
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,91 @@
|
|
|
1
1
|
// src/lib/Button.tsx
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import { Button as MUIButton } from "@mui/material";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var overrideProps = {
|
|
6
|
+
disableRipple: true,
|
|
7
|
+
disableFocusRipple: true,
|
|
8
|
+
disableTouchRipple: true
|
|
9
|
+
};
|
|
10
|
+
var iconOnlyStyles = {
|
|
11
|
+
minWidth: 2,
|
|
12
|
+
px: 1,
|
|
13
|
+
"& .MuiButton-startIcon": {
|
|
14
|
+
m: 0
|
|
15
|
+
},
|
|
16
|
+
"& .MuiButton-endIcon": {
|
|
17
|
+
m: 0
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var Button = forwardRef((props, ref) => {
|
|
21
|
+
const { iconOnly, sx, ...rest } = props;
|
|
22
|
+
const styles = {
|
|
23
|
+
...iconOnly && iconOnlyStyles
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ jsx(MUIButton, {
|
|
26
|
+
sx: { ...styles, ...sx },
|
|
27
|
+
...rest,
|
|
28
|
+
...overrideProps,
|
|
29
|
+
ref
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// src/lib/IconButton.tsx
|
|
34
|
+
import { IconButton as MuiIconButton, Tooltip } from "@mui/material";
|
|
35
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
36
|
+
var IconButton = ({ children, title, filled, color = "tertiary", ...rest }) => {
|
|
37
|
+
return /* @__PURE__ */ jsx2(Tooltip, {
|
|
38
|
+
title,
|
|
39
|
+
children: filled ? /* @__PURE__ */ jsx2(Button, {
|
|
40
|
+
"aria-label": title,
|
|
41
|
+
color,
|
|
42
|
+
startIcon: children,
|
|
43
|
+
iconOnly: true,
|
|
44
|
+
...rest,
|
|
45
|
+
children: "\u2060"
|
|
46
|
+
}) : /* @__PURE__ */ jsx2(MuiIconButton, {
|
|
47
|
+
"aria-label": title,
|
|
48
|
+
disableRipple: true,
|
|
49
|
+
color: color === "tertiary" ? "secondary" : color,
|
|
50
|
+
...rest,
|
|
51
|
+
children
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/lib/LoadingButton.tsx
|
|
57
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
58
|
+
import MUILoadingButton from "@mui/lab/LoadingButton";
|
|
59
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
|
60
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
61
|
+
var LoadingIndicator = /* @__PURE__ */ jsx3(CircularProgress, {
|
|
62
|
+
color: "inherit",
|
|
63
|
+
size: 16,
|
|
64
|
+
"aria-label": "loading"
|
|
65
|
+
});
|
|
66
|
+
var LoadingButton = forwardRef2((props, ref) => {
|
|
67
|
+
const { children, loading, ...rest } = props;
|
|
68
|
+
const loadingPosition = rest.startIcon ? "start" : "end";
|
|
69
|
+
const nonLoadingStyling = rest.startIcon || rest.endIcon || loading ? {} : { padding: "0 .7rem" };
|
|
70
|
+
const endIcon = rest.startIcon ? void 0 : /* @__PURE__ */ jsx3("span", {
|
|
71
|
+
style: loading ? { padding: "0 .7rem" } : {}
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */ jsx3(MUILoadingButton, {
|
|
74
|
+
endIcon,
|
|
75
|
+
loadingPosition,
|
|
76
|
+
loading,
|
|
77
|
+
disableRipple: true,
|
|
78
|
+
loadingIndicator: LoadingIndicator,
|
|
79
|
+
...rest,
|
|
80
|
+
ref,
|
|
81
|
+
children: /* @__PURE__ */ jsx3("span", {
|
|
82
|
+
style: nonLoadingStyling,
|
|
83
|
+
children
|
|
84
|
+
})
|
|
85
|
+
});
|
|
7
86
|
});
|
|
8
87
|
export {
|
|
9
|
-
Button
|
|
88
|
+
Button,
|
|
89
|
+
IconButton,
|
|
90
|
+
LoadingButton
|
|
10
91
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/lib/Button.tsx
CHANGED
|
@@ -1,15 +1,59 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Button as MUIButton } from '@mui/material';
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { Button as MUIButton, ButtonPropsColorOverrides } from '@mui/material';
|
|
3
3
|
import type { ButtonProps as MUIButtonProps } from '@mui/material';
|
|
4
4
|
|
|
5
|
+
declare module '@mui/material/Button' {
|
|
6
|
+
interface ButtonPropsColorOverrides {
|
|
7
|
+
tertiary: true;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
export type ButtonProps = {
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
/** The color of the component.
|
|
13
|
+
* @default secondary */
|
|
14
|
+
color?: 'primary' | 'secondary' | 'tertiary' | 'error';
|
|
15
|
+
/** The variant to use.
|
|
16
|
+
* @default contained */
|
|
17
|
+
variant?: 'outlined' | 'contained';
|
|
18
|
+
/** Internal prop used by IconButton for contained variant. */
|
|
19
|
+
iconOnly?: boolean;
|
|
20
|
+
} & Omit<
|
|
21
|
+
MUIButtonProps,
|
|
22
|
+
| 'color'
|
|
23
|
+
| 'component'
|
|
24
|
+
| 'variant'
|
|
25
|
+
| 'disableElevation'
|
|
26
|
+
| 'disableFocusRipple'
|
|
27
|
+
| 'disableTouchRipple'
|
|
28
|
+
| 'centerRipple'
|
|
29
|
+
| 'disableRipple'
|
|
30
|
+
| 'focusRipple'
|
|
31
|
+
| 'TouchRippleProps'
|
|
32
|
+
| 'touchRippleRef'
|
|
33
|
+
>;
|
|
34
|
+
|
|
35
|
+
const overrideProps = {
|
|
36
|
+
disableRipple: true,
|
|
37
|
+
disableFocusRipple: true,
|
|
38
|
+
disableTouchRipple: true,
|
|
39
|
+
};
|
|
8
40
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
41
|
+
const iconOnlyStyles = {
|
|
42
|
+
minWidth: 2,
|
|
43
|
+
px: 1,
|
|
44
|
+
'& .MuiButton-startIcon': {
|
|
45
|
+
m: 0,
|
|
46
|
+
},
|
|
47
|
+
'& .MuiButton-endIcon': {
|
|
48
|
+
m: 0,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
14
51
|
|
|
52
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
|
53
|
+
const { iconOnly, sx, ...rest } = props;
|
|
54
|
+
const styles = {
|
|
55
|
+
...(iconOnly && iconOnlyStyles),
|
|
56
|
+
};
|
|
15
57
|
|
|
58
|
+
return <MUIButton sx={{ ...styles, ...sx }} {...rest} {...overrideProps} ref={ref} />;
|
|
59
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IconButton as MuiIconButton, Tooltip } from '@mui/material';
|
|
2
|
+
import type { IconButtonProps as MUIIconButtonProps } from '@mui/material';
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
|
|
5
|
+
export type IconButtonProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Text for tooltip and aria-label
|
|
8
|
+
*/
|
|
9
|
+
title: string;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Toggles contained Button styling
|
|
13
|
+
*/
|
|
14
|
+
filled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The color of the component.
|
|
17
|
+
*/
|
|
18
|
+
color?: "primary" | "secondary" | "tertiary" | "error";
|
|
19
|
+
} & Omit<MUIIconButtonProps, 'aria-label' | 'color' | 'centerRipple' | 'disableRipple' | 'disableTouchRipple' | 'focusRipple' | 'disableFocusRipple' | 'TouchRippleProps' | 'touchRippleRef'>;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export const IconButton = ({ children, title, filled, color = 'tertiary', ...rest }: IconButtonProps): JSX.Element => {
|
|
24
|
+
return (
|
|
25
|
+
<Tooltip title={title}>
|
|
26
|
+
{ filled ?
|
|
27
|
+
<Button aria-label={title} color={color} startIcon={children} iconOnly {...rest}>{'\u2060'}</Button>
|
|
28
|
+
:
|
|
29
|
+
<MuiIconButton aria-label={title} disableRipple color={color === 'tertiary' ? 'secondary' : color} {...rest}>
|
|
30
|
+
{children}
|
|
31
|
+
</MuiIconButton>
|
|
32
|
+
}
|
|
33
|
+
</Tooltip>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -1,14 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import MUILoadingButton, { LoadingButtonProps as MuiLoadingButtonProps} from '@mui/lab/LoadingButton';
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import MUILoadingButton, { LoadingButtonProps as MuiLoadingButtonProps } from '@mui/lab/LoadingButton';
|
|
3
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
3
4
|
|
|
4
5
|
export type LoadingButtonProps = {
|
|
5
6
|
children: React.ReactNode;
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The color of the component.
|
|
9
|
+
*/
|
|
10
|
+
color?: 'primary' | 'secondary' | 'error';
|
|
11
|
+
} & Omit<
|
|
12
|
+
MuiLoadingButtonProps,
|
|
13
|
+
| 'color'
|
|
14
|
+
| 'centerRipple'
|
|
15
|
+
| 'disableRipple'
|
|
16
|
+
| 'disableTouchRipple'
|
|
17
|
+
| 'focusRipple'
|
|
18
|
+
| 'disableFocusRipple'
|
|
19
|
+
| 'TouchRippleProps'
|
|
20
|
+
| 'touchRippleRef'
|
|
21
|
+
| 'loadingIndicator'
|
|
22
|
+
| 'loadingPosition'
|
|
23
|
+
>;
|
|
7
24
|
|
|
8
|
-
|
|
9
|
-
<MUILoadingButton {...rest}>
|
|
10
|
-
{children}
|
|
11
|
-
</MUILoadingButton>
|
|
12
|
-
);
|
|
25
|
+
const LoadingIndicator = <CircularProgress color="inherit" size={16} aria-label="loading" />;
|
|
13
26
|
|
|
27
|
+
export const LoadingButton = forwardRef<HTMLButtonElement, LoadingButtonProps>((props, ref) => {
|
|
28
|
+
const { children, loading, ...rest } = props;
|
|
29
|
+
//changing default loading button behavior to add end loading icon instead of replacing contents completely with icon
|
|
30
|
+
const loadingPosition = rest.startIcon ? 'start' : 'end';
|
|
31
|
+
const nonLoadingStyling = rest.startIcon || rest.endIcon || loading ? {} : { padding: '0 .7rem' };
|
|
32
|
+
const endIcon = rest.startIcon ? undefined : <span style={loading ? { padding: '0 .7rem' } : {}}></span>;
|
|
14
33
|
|
|
34
|
+
return (
|
|
35
|
+
<MUILoadingButton
|
|
36
|
+
endIcon={endIcon}
|
|
37
|
+
loadingPosition={loadingPosition}
|
|
38
|
+
loading={loading}
|
|
39
|
+
disableRipple
|
|
40
|
+
loadingIndicator={LoadingIndicator}
|
|
41
|
+
{...rest}
|
|
42
|
+
ref={ref}
|
|
43
|
+
>
|
|
44
|
+
<span style={nonLoadingStyling}>{children}</span>
|
|
45
|
+
</MUILoadingButton>
|
|
46
|
+
);
|
|
47
|
+
});
|