@bolttech/ob-atoms-button 1.0.2 → 1.0.3
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/index.cjs.js +45 -39
- package/package.json +1 -1
- package/src/index.d.ts +2 -0
- package/src/lib/button.d.ts +4 -0
- package/src/lib/button.interface.d.ts +27 -0
- package/src/lib/button.stories.d.ts +12 -0
package/index.cjs.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
3
4
|
var react = require('react');
|
|
4
5
|
var uiUtils = require('@bolttech/ui-utils');
|
|
5
6
|
var obAtomsIcon = require('@bolttech/ob-atoms-icon');
|
|
6
|
-
var jsxDevRuntime = require('react/jsx-dev-runtime');
|
|
7
|
-
|
|
8
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
9
|
-
if (null == r) return {};
|
|
10
|
-
var t = {};
|
|
11
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
12
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
13
|
-
t[n] = r[n];
|
|
14
|
-
}
|
|
15
|
-
return t;
|
|
16
|
-
}
|
|
17
7
|
|
|
18
8
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
19
9
|
|
|
@@ -1076,10 +1066,42 @@ $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign },
|
|
|
1076
1066
|
assign: assign
|
|
1077
1067
|
});
|
|
1078
1068
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1069
|
+
/******************************************************************************
|
|
1070
|
+
Copyright (c) Microsoft Corporation.
|
|
1071
|
+
|
|
1072
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1073
|
+
purpose with or without fee is hereby granted.
|
|
1074
|
+
|
|
1075
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1076
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1077
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1078
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1079
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1080
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1081
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1082
|
+
***************************************************************************** */
|
|
1083
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
function __rest(s, e) {
|
|
1087
|
+
var t = {};
|
|
1088
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1089
|
+
t[p] = s[p];
|
|
1090
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1091
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1092
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1093
|
+
t[p[i]] = s[p[i]];
|
|
1094
|
+
}
|
|
1095
|
+
return t;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1099
|
+
var e = new Error(message);
|
|
1100
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
const Button = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
1104
|
+
var {
|
|
1083
1105
|
id,
|
|
1084
1106
|
title,
|
|
1085
1107
|
variant,
|
|
@@ -1091,9 +1113,9 @@ const Button = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
1091
1113
|
iconLeft,
|
|
1092
1114
|
iconRight,
|
|
1093
1115
|
dataTestId
|
|
1094
|
-
} =
|
|
1095
|
-
props =
|
|
1096
|
-
return
|
|
1116
|
+
} = _a,
|
|
1117
|
+
props = __rest(_a, ["id", "title", "variant", "size", "disabled", "fullWidth", "onClick", "type", "iconLeft", "iconRight", "dataTestId"]);
|
|
1118
|
+
return jsxRuntime.jsxs("button", Object.assign({}, props, {
|
|
1097
1119
|
ref: ref,
|
|
1098
1120
|
"data-testid": dataTestId,
|
|
1099
1121
|
id: id,
|
|
@@ -1104,34 +1126,18 @@ const Button = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
1104
1126
|
}, disabled ? {
|
|
1105
1127
|
'aria-disabled': disabled
|
|
1106
1128
|
} : {}, uiUtils.applyDataAttributes(props), {
|
|
1107
|
-
children: [iconLeft &&
|
|
1129
|
+
children: [iconLeft && jsxRuntime.jsx(obAtomsIcon.Icon, Object.assign({
|
|
1108
1130
|
icon: iconLeft,
|
|
1109
1131
|
dataTestId: `buttonIcon-${iconLeft}`,
|
|
1110
1132
|
"aria-hidden": true
|
|
1111
|
-
}, uiUtils.applyDataAttributes(props, 'icon-left')),
|
|
1112
|
-
fileName: _jsxFileName,
|
|
1113
|
-
lineNumber: 40,
|
|
1114
|
-
columnNumber: 11
|
|
1115
|
-
}, undefined), title && /*#__PURE__*/jsxDevRuntime.jsxDEV("span", Object.assign({}, uiUtils.applyDataAttributes(props, 'label'), {
|
|
1133
|
+
}, uiUtils.applyDataAttributes(props, 'icon-left'))), title && jsxRuntime.jsx("span", Object.assign({}, uiUtils.applyDataAttributes(props, 'label'), {
|
|
1116
1134
|
children: title
|
|
1117
|
-
}),
|
|
1118
|
-
fileName: _jsxFileName,
|
|
1119
|
-
lineNumber: 47,
|
|
1120
|
-
columnNumber: 19
|
|
1121
|
-
}, undefined), iconRight && /*#__PURE__*/jsxDevRuntime.jsxDEV(obAtomsIcon.Icon, Object.assign({
|
|
1135
|
+
})), iconRight && jsxRuntime.jsx(obAtomsIcon.Icon, Object.assign({
|
|
1122
1136
|
dataTestId: `buttonIcon-${iconRight}`,
|
|
1123
1137
|
icon: iconRight,
|
|
1124
1138
|
"aria-hidden": true
|
|
1125
|
-
}, uiUtils.applyDataAttributes(props, 'icon-right'))
|
|
1126
|
-
|
|
1127
|
-
lineNumber: 49,
|
|
1128
|
-
columnNumber: 11
|
|
1129
|
-
}, undefined)]
|
|
1130
|
-
}), void 0, true, {
|
|
1131
|
-
fileName: _jsxFileName,
|
|
1132
|
-
lineNumber: 27,
|
|
1133
|
-
columnNumber: 7
|
|
1134
|
-
}, undefined);
|
|
1139
|
+
}, uiUtils.applyDataAttributes(props, 'icon-right')))]
|
|
1140
|
+
}));
|
|
1135
1141
|
});
|
|
1136
1142
|
|
|
1137
1143
|
exports.Button = Button;
|
package/package.json
CHANGED
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DefaultProps } from '@bolttech/ui-utils';
|
|
2
|
+
export type ButtonVariants = 'transaction' | 'brand' | 'alternative' | 'outline' | 'ghost';
|
|
3
|
+
export type ButtonSizes = 'sm' | 'md' | 'lg';
|
|
4
|
+
export type ButtonTypes = 'button' | 'submit';
|
|
5
|
+
export interface IButtonProps extends DefaultProps {
|
|
6
|
+
dataTestId?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
variant: ButtonVariants;
|
|
10
|
+
size: ButtonSizes;
|
|
11
|
+
/**
|
|
12
|
+
* The HTML `id` attribute for the button.
|
|
13
|
+
*
|
|
14
|
+
* Must be unique within the document and conform to
|
|
15
|
+
* HTML `id` naming rules (no spaces, not starting with a digit, etc.).
|
|
16
|
+
* Useful for targeting the button in scripts, automated tests,
|
|
17
|
+
* or associating it with a `<label>` for accessibility.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue - no `id` attribute is rendered
|
|
20
|
+
*/
|
|
21
|
+
id?: string;
|
|
22
|
+
iconRight?: string;
|
|
23
|
+
iconLeft?: string;
|
|
24
|
+
type?: ButtonTypes;
|
|
25
|
+
fullWidth?: boolean;
|
|
26
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
component: import("react").ForwardRefExoticComponent<import("./button.interface").IButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
title: string;
|
|
5
|
+
};
|
|
6
|
+
export default meta;
|
|
7
|
+
type Story = StoryObj<typeof meta>;
|
|
8
|
+
export declare const Alternative: Story;
|
|
9
|
+
export declare const Brand: Story;
|
|
10
|
+
export declare const Ghost: Story;
|
|
11
|
+
export declare const Outline: Story;
|
|
12
|
+
export declare const Transaction: Story;
|