@stokr/components-library 2.3.65-beta.1 → 2.3.65-beta.10
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/dist/components/2FA/main-flow.js +28 -7
- package/dist/components/2FA/main-flow.stories.js +144 -15
- package/dist/components/AdminDashboard/Table/ReactTable.js +123 -7
- package/dist/components/AdminDashboard/Table/ReactTable.stories.js +509 -2
- package/dist/components/Chips/Chip.js +1 -2
- package/dist/components/Icon/Icon.stories.js +108 -0
- package/dist/components/Input/Input.js +33 -33
- package/dist/components/Input/Input.stories.js +83 -8
- package/dist/components/Input/MultiSelect.js +319 -0
- package/dist/components/Input/MultiSelect.stories.js +264 -0
- package/dist/components/Input/SearchInput.js +78 -0
- package/dist/components/Input/SearchInput.stories.js +366 -0
- package/dist/components/Input/SearchInput.styles.js +25 -0
- package/dist/components/Input/Select.js +51 -28
- package/dist/components/Input/Select.stories.js +345 -6
- package/dist/components/Modal/SideModal.js +82 -0
- package/dist/components/Modal/SideModal.stories.js +342 -0
- package/dist/components/Modal/SideModal.styles.js +21 -0
- package/dist/components/Payment/PaymentDetailsCard.js +189 -0
- package/dist/components/Payment/PaymentDetailsCard.stories.js +198 -0
- package/dist/components/Payment/PaymentDisplay.js +2 -12
- package/dist/components/ProfileBox/ProfileBox.js +2 -1
- package/dist/components/Snackbar/Snackbar.js +193 -0
- package/dist/components/Snackbar/Snackbar.stories.js +292 -0
- package/dist/components/Snackbar/Snackbar.styles.js +97 -0
- package/dist/components/Snackbar/SnackbarProvider.js +81 -0
- package/dist/components/Snackbar/index.js +32 -0
- package/dist/components/Snackbar/useSnackbar.js +43 -0
- package/dist/components/StatusTag/StatusTag.js +175 -0
- package/dist/components/StatusTag/StatusTag.stories.js +262 -0
- package/dist/components/StatusTag/StatusTag.styles.js +37 -0
- package/dist/components/StepsProgress/StepIndicator.js +59 -0
- package/dist/components/StepsProgress/StepIndicator.stories.js +153 -0
- package/dist/components/StepsProgress/StepIndicator.styles.js +30 -0
- package/dist/components/TextLink/TextLink.stories.js +35 -0
- package/dist/components/TextLink/TextLink.styles.js +1 -1
- package/dist/components/Timeline/TimelineStep.js +2 -2
- package/dist/components/logo/Logo.stories.js +260 -0
- package/dist/constants/globalVariables.js +41 -2
- package/dist/context/Checkbox/CheckboxContext.js +0 -1
- package/dist/index.js +66 -0
- package/dist/static/images/bmn2-logo.svg +9 -0
- package/dist/static/images/document-icon.svg +3 -0
- package/dist/static/images/plus-icon.svg +4 -0
- package/dist/static/images/search-icon.svg +3 -0
- package/dist/static/images/sent-icon.svg +10 -0
- package/dist/static/images/transfer-icon.svg +10 -0
- package/dist/utils/formatCurrencyValue.js +43 -3
- package/package.json +1 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithoutSeparators = exports.WithTooltips = exports.WithPlaceholders = exports.WithCustomInfoSection = exports.WithCustomAmountSection = exports.WithBitcoin = exports.DetailsOnly = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _PaymentDetailsCard = _interopRequireDefault(require("./PaymentDetailsCard"));
|
|
9
|
+
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
10
|
+
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
11
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
12
|
+
var _colors = _interopRequireDefault(require("../../styles/colors"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const StoryContainer = _styledComponents.default.div.withConfig({
|
|
15
|
+
displayName: "PaymentDetailsCardstories__StoryContainer",
|
|
16
|
+
componentId: "sc-1bzi48y-0"
|
|
17
|
+
})(["max-width:500px;padding:20px;background:", ";"], _colors.default.offWhite);
|
|
18
|
+
var _default = exports.default = {
|
|
19
|
+
title: 'Components Library/Payment/PaymentDetailsCard',
|
|
20
|
+
component: _PaymentDetailsCard.default,
|
|
21
|
+
decorators: [Story => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(StoryContainer, null, /*#__PURE__*/_react.default.createElement(Story, null))))]
|
|
22
|
+
};
|
|
23
|
+
const Default = () => /*#__PURE__*/_react.default.createElement(_PaymentDetailsCard.default, {
|
|
24
|
+
title: "Payment Details",
|
|
25
|
+
amountSection: {
|
|
26
|
+
label: 'Amount to pay',
|
|
27
|
+
amount: 1250.5,
|
|
28
|
+
currency: 'USDC'
|
|
29
|
+
},
|
|
30
|
+
details: [{
|
|
31
|
+
label: 'Reference',
|
|
32
|
+
value: 'INV-2024-001234'
|
|
33
|
+
}, {
|
|
34
|
+
label: 'Date',
|
|
35
|
+
value: 'Dec 19, 2024'
|
|
36
|
+
}, {
|
|
37
|
+
label: 'Status',
|
|
38
|
+
value: 'Pending'
|
|
39
|
+
}]
|
|
40
|
+
});
|
|
41
|
+
exports.Default = Default;
|
|
42
|
+
const WithBitcoin = () => /*#__PURE__*/_react.default.createElement(_PaymentDetailsCard.default, {
|
|
43
|
+
amountSection: {
|
|
44
|
+
label: 'Transfer amount',
|
|
45
|
+
amount: 0.054321,
|
|
46
|
+
currency: 'BTC'
|
|
47
|
+
},
|
|
48
|
+
details: [{
|
|
49
|
+
label: 'Network',
|
|
50
|
+
value: 'Bitcoin Mainnet'
|
|
51
|
+
}, {
|
|
52
|
+
label: 'Fee',
|
|
53
|
+
value: '0.00001 BTC'
|
|
54
|
+
}, {
|
|
55
|
+
label: 'Confirmations',
|
|
56
|
+
value: '3/6'
|
|
57
|
+
}]
|
|
58
|
+
});
|
|
59
|
+
exports.WithBitcoin = WithBitcoin;
|
|
60
|
+
const WithTooltips = () => /*#__PURE__*/_react.default.createElement(_PaymentDetailsCard.default, {
|
|
61
|
+
amountSection: {
|
|
62
|
+
label: 'Investment amount',
|
|
63
|
+
amount: 50000,
|
|
64
|
+
currency: 'USDT'
|
|
65
|
+
},
|
|
66
|
+
details: [{
|
|
67
|
+
label: 'Token price',
|
|
68
|
+
value: '$1.25',
|
|
69
|
+
tooltip: 'Current token price at the time of investment'
|
|
70
|
+
}, {
|
|
71
|
+
label: 'Tokens received',
|
|
72
|
+
value: '40,000 TKN',
|
|
73
|
+
tooltip: 'Number of tokens you will receive'
|
|
74
|
+
}, {
|
|
75
|
+
label: 'Lock-up period',
|
|
76
|
+
value: '12 months',
|
|
77
|
+
tooltip: 'Tokens will be locked for this period'
|
|
78
|
+
}]
|
|
79
|
+
});
|
|
80
|
+
exports.WithTooltips = WithTooltips;
|
|
81
|
+
const WithPlaceholders = () => /*#__PURE__*/_react.default.createElement(_PaymentDetailsCard.default, {
|
|
82
|
+
title: "Pending Payment",
|
|
83
|
+
amountSection: {
|
|
84
|
+
label: 'Amount',
|
|
85
|
+
amount: 500,
|
|
86
|
+
currency: 'USDC'
|
|
87
|
+
},
|
|
88
|
+
details: [{
|
|
89
|
+
label: 'Transaction ID',
|
|
90
|
+
value: null,
|
|
91
|
+
placeholder: 'Awaiting confirmation'
|
|
92
|
+
}, {
|
|
93
|
+
label: 'Recipient',
|
|
94
|
+
value: 'John Doe'
|
|
95
|
+
}, {
|
|
96
|
+
label: 'Status',
|
|
97
|
+
value: null,
|
|
98
|
+
placeholder: 'Processing...'
|
|
99
|
+
}]
|
|
100
|
+
});
|
|
101
|
+
exports.WithPlaceholders = WithPlaceholders;
|
|
102
|
+
const WithCustomInfoSection = () => /*#__PURE__*/_react.default.createElement(_PaymentDetailsCard.default, {
|
|
103
|
+
title: "Order Confirmation",
|
|
104
|
+
amountSection: {
|
|
105
|
+
label: 'Total amount',
|
|
106
|
+
amount: 2500,
|
|
107
|
+
currency: 'USDC'
|
|
108
|
+
},
|
|
109
|
+
details: [{
|
|
110
|
+
label: 'Order ID',
|
|
111
|
+
value: 'ORD-789456'
|
|
112
|
+
}, {
|
|
113
|
+
label: 'Items',
|
|
114
|
+
value: '3 tokens'
|
|
115
|
+
}],
|
|
116
|
+
infoSection: /*#__PURE__*/_react.default.createElement("div", {
|
|
117
|
+
style: {
|
|
118
|
+
padding: '12px',
|
|
119
|
+
background: _colors.default.lightGrey,
|
|
120
|
+
borderRadius: '4px',
|
|
121
|
+
fontSize: '14px',
|
|
122
|
+
color: _colors.default.grey2
|
|
123
|
+
}
|
|
124
|
+
}, "\u24D8 Your payment will be processed within 24 hours. You will receive a confirmation email once complete.")
|
|
125
|
+
});
|
|
126
|
+
exports.WithCustomInfoSection = WithCustomInfoSection;
|
|
127
|
+
const WithoutSeparators = () => /*#__PURE__*/_react.default.createElement(_PaymentDetailsCard.default, {
|
|
128
|
+
title: "Compact View",
|
|
129
|
+
amountSection: {
|
|
130
|
+
label: 'Amount',
|
|
131
|
+
amount: 100,
|
|
132
|
+
currency: 'USDC'
|
|
133
|
+
},
|
|
134
|
+
details: [{
|
|
135
|
+
label: 'From',
|
|
136
|
+
value: 'Wallet A'
|
|
137
|
+
}, {
|
|
138
|
+
label: 'To',
|
|
139
|
+
value: 'Wallet B'
|
|
140
|
+
}],
|
|
141
|
+
showSeparators: false
|
|
142
|
+
});
|
|
143
|
+
exports.WithoutSeparators = WithoutSeparators;
|
|
144
|
+
const DetailsOnly = () => /*#__PURE__*/_react.default.createElement(_PaymentDetailsCard.default, {
|
|
145
|
+
title: "Account Information",
|
|
146
|
+
details: [{
|
|
147
|
+
label: 'Account holder',
|
|
148
|
+
value: 'Jane Smith'
|
|
149
|
+
}, {
|
|
150
|
+
label: 'Account type',
|
|
151
|
+
value: 'Premium'
|
|
152
|
+
}, {
|
|
153
|
+
label: 'Member since',
|
|
154
|
+
value: 'Jan 2023'
|
|
155
|
+
}, {
|
|
156
|
+
label: 'Total investments',
|
|
157
|
+
value: '$125,000'
|
|
158
|
+
}]
|
|
159
|
+
});
|
|
160
|
+
exports.DetailsOnly = DetailsOnly;
|
|
161
|
+
const WithCustomAmountSection = () => {
|
|
162
|
+
const CustomAmount = () => /*#__PURE__*/_react.default.createElement("div", {
|
|
163
|
+
style: {
|
|
164
|
+
textAlign: 'center',
|
|
165
|
+
padding: '20px 0'
|
|
166
|
+
}
|
|
167
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
168
|
+
style: {
|
|
169
|
+
fontSize: '14px',
|
|
170
|
+
color: _colors.default.grey2,
|
|
171
|
+
marginBottom: '8px'
|
|
172
|
+
}
|
|
173
|
+
}, "You are investing"), /*#__PURE__*/_react.default.createElement("div", {
|
|
174
|
+
style: {
|
|
175
|
+
fontSize: '48px',
|
|
176
|
+
fontWeight: '800',
|
|
177
|
+
color: _colors.default.black
|
|
178
|
+
}
|
|
179
|
+
}, "$10,000"), /*#__PURE__*/_react.default.createElement("div", {
|
|
180
|
+
style: {
|
|
181
|
+
fontSize: '14px',
|
|
182
|
+
color: _colors.default.freshGreen,
|
|
183
|
+
marginTop: '8px'
|
|
184
|
+
}
|
|
185
|
+
}, "\u2713 Best rate available"));
|
|
186
|
+
return /*#__PURE__*/_react.default.createElement(_PaymentDetailsCard.default, {
|
|
187
|
+
title: "Custom Investment",
|
|
188
|
+
amountSection: /*#__PURE__*/_react.default.createElement(CustomAmount, null),
|
|
189
|
+
details: [{
|
|
190
|
+
label: 'Exchange rate',
|
|
191
|
+
value: '1 USD = 0.92 EUR'
|
|
192
|
+
}, {
|
|
193
|
+
label: 'Fees',
|
|
194
|
+
value: '$0.00'
|
|
195
|
+
}]
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
exports.WithCustomAmountSection = WithCustomAmountSection;
|
|
@@ -16,9 +16,7 @@ var _SectionTitle = require("../SectionTitle/SectionTitle.styles");
|
|
|
16
16
|
var _reactTippy = require("react-tippy");
|
|
17
17
|
var _Grid = require("../Grid/Grid.styles");
|
|
18
18
|
var _rwd = _interopRequireDefault(require("../../styles/rwd"));
|
|
19
|
-
var
|
|
20
|
-
var _usdqLogo = _interopRequireDefault(require("../../static/images/usdq-logo.png"));
|
|
21
|
-
var _bitcoinLogo = _interopRequireDefault(require("../../static/images/bitcoin-logo.svg"));
|
|
19
|
+
var _formatCurrencyValue = require("../../utils/formatCurrencyValue");
|
|
22
20
|
var _templateObject, _templateObject2, _templateObject3;
|
|
23
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
22
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -105,14 +103,6 @@ const PaymentDisplay = _ref2 => {
|
|
|
105
103
|
onAddressCopy,
|
|
106
104
|
copyButtonStyle
|
|
107
105
|
} = _ref2;
|
|
108
|
-
const getCurrencyIcon = currency => {
|
|
109
|
-
if (customCurrencyIcon) return customCurrencyIcon;
|
|
110
|
-
if (!currency) return null;
|
|
111
|
-
if (currency.toLowerCase().includes('btc')) return _bitcoinLogo.default;
|
|
112
|
-
if (currency.toLowerCase().includes('usdc')) return _usdcLogo.default;
|
|
113
|
-
if (currency.toLowerCase().includes('usdq')) return _usdqLogo.default;
|
|
114
|
-
return null;
|
|
115
|
-
};
|
|
116
106
|
const defaultQRCodeStyle = {
|
|
117
107
|
backgroundColor: '#000000',
|
|
118
108
|
padding: 18,
|
|
@@ -131,7 +121,7 @@ const PaymentDisplay = _ref2 => {
|
|
|
131
121
|
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_SectionTitle.SectionTitle, null, amountTitle), /*#__PURE__*/_react.default.createElement(AmountSection, {
|
|
132
122
|
style: amountSectionStyle
|
|
133
123
|
}, /*#__PURE__*/_react.default.createElement(AmountIcon, {
|
|
134
|
-
src: getCurrencyIcon(currency),
|
|
124
|
+
src: (0, _formatCurrencyValue.getCurrencyIcon)(currency, customCurrencyIcon),
|
|
135
125
|
style: amountIconStyle,
|
|
136
126
|
alt: currency
|
|
137
127
|
}), /*#__PURE__*/_react.default.createElement(AmountText, {
|
|
@@ -29,7 +29,8 @@ const ProfileBox = _ref => {
|
|
|
29
29
|
return /*#__PURE__*/_react.default.createElement(_ProfileBox.Container, null, /*#__PURE__*/_react.default.createElement(_ProfileBox.ImageWrapper, null, /*#__PURE__*/_react.default.createElement(_Background.default, {
|
|
30
30
|
src: pictureSrc
|
|
31
31
|
})), /*#__PURE__*/_react.default.createElement(_ProfileBox.EditButton, {
|
|
32
|
-
onClick: handleEdit
|
|
32
|
+
onClick: handleEdit,
|
|
33
|
+
"data-cy": "edit-button-profile-box"
|
|
33
34
|
}, /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, null, /*#__PURE__*/_react.default.createElement(_ProfileBox.Name, {
|
|
34
35
|
style: _objectSpread(_objectSpread({}, lineBreaker), nameStyle)
|
|
35
36
|
}, name, withEditButton && /*#__PURE__*/_react.default.createElement(_ProfileBox.EditIcon, null)))));
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Snackbar = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactDom = require("react-dom");
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _Snackbar = require("./Snackbar.styles");
|
|
11
|
+
var _crossIcon = require("../../static/images/cross-icon.svg");
|
|
12
|
+
var _warningFilled = require("../../static/images/warning-filled.svg");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // Import existing SVG icons
|
|
16
|
+
// Info icon - circled "i" (not available in library, matching design)
|
|
17
|
+
const InfoIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
|
|
18
|
+
viewBox: "0 0 24 24",
|
|
19
|
+
fill: "none",
|
|
20
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
21
|
+
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
22
|
+
cx: "12",
|
|
23
|
+
cy: "12",
|
|
24
|
+
r: "10",
|
|
25
|
+
stroke: "currentColor",
|
|
26
|
+
strokeWidth: "2"
|
|
27
|
+
}), /*#__PURE__*/_react.default.createElement("line", {
|
|
28
|
+
x1: "12",
|
|
29
|
+
y1: "16",
|
|
30
|
+
x2: "12",
|
|
31
|
+
y2: "12",
|
|
32
|
+
stroke: "currentColor",
|
|
33
|
+
strokeWidth: "2",
|
|
34
|
+
strokeLinecap: "round"
|
|
35
|
+
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
36
|
+
cx: "12",
|
|
37
|
+
cy: "8",
|
|
38
|
+
r: "1",
|
|
39
|
+
fill: "currentColor"
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
// Error icon - circled "!" (not available in library, matching design)
|
|
43
|
+
const ErrorIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
|
|
44
|
+
viewBox: "0 0 24 24",
|
|
45
|
+
fill: "none",
|
|
46
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
48
|
+
cx: "12",
|
|
49
|
+
cy: "12",
|
|
50
|
+
r: "10",
|
|
51
|
+
stroke: "currentColor",
|
|
52
|
+
strokeWidth: "2"
|
|
53
|
+
}), /*#__PURE__*/_react.default.createElement("line", {
|
|
54
|
+
x1: "12",
|
|
55
|
+
y1: "8",
|
|
56
|
+
x2: "12",
|
|
57
|
+
y2: "12",
|
|
58
|
+
stroke: "currentColor",
|
|
59
|
+
strokeWidth: "2",
|
|
60
|
+
strokeLinecap: "round"
|
|
61
|
+
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
62
|
+
cx: "12",
|
|
63
|
+
cy: "16",
|
|
64
|
+
r: "1",
|
|
65
|
+
fill: "currentColor"
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
// Success icon wrapper - adds circle around check icon
|
|
69
|
+
const SuccessIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
|
|
70
|
+
viewBox: "0 0 24 24",
|
|
71
|
+
fill: "none",
|
|
72
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
74
|
+
cx: "12",
|
|
75
|
+
cy: "12",
|
|
76
|
+
r: "10",
|
|
77
|
+
stroke: "currentColor",
|
|
78
|
+
strokeWidth: "2"
|
|
79
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
80
|
+
d: "M8 12L10.5 14.5L16 9",
|
|
81
|
+
stroke: "currentColor",
|
|
82
|
+
strokeWidth: "2",
|
|
83
|
+
strokeLinecap: "round",
|
|
84
|
+
strokeLinejoin: "round"
|
|
85
|
+
}));
|
|
86
|
+
const defaultIcons = {
|
|
87
|
+
info: /*#__PURE__*/_react.default.createElement(InfoIcon, null),
|
|
88
|
+
error: /*#__PURE__*/_react.default.createElement(ErrorIcon, null),
|
|
89
|
+
success: /*#__PURE__*/_react.default.createElement(SuccessIcon, null),
|
|
90
|
+
warning: /*#__PURE__*/_react.default.createElement(_warningFilled.ReactComponent, null)
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Individual Snackbar item component
|
|
95
|
+
*/
|
|
96
|
+
const SnackbarItem = _ref => {
|
|
97
|
+
let {
|
|
98
|
+
id,
|
|
99
|
+
message,
|
|
100
|
+
variant = 'info',
|
|
101
|
+
icon,
|
|
102
|
+
onClick,
|
|
103
|
+
onClose,
|
|
104
|
+
duration = 5000
|
|
105
|
+
} = _ref;
|
|
106
|
+
const [isExiting, setIsExiting] = (0, _react.useState)(false);
|
|
107
|
+
const handleClose = (0, _react.useCallback)(() => {
|
|
108
|
+
setIsExiting(true);
|
|
109
|
+
setTimeout(() => {
|
|
110
|
+
onClose(id);
|
|
111
|
+
}, 300); // Match animation duration
|
|
112
|
+
}, [id, onClose]);
|
|
113
|
+
(0, _react.useEffect)(() => {
|
|
114
|
+
if (duration === 'permanent' || duration === 0) return;
|
|
115
|
+
const timer = setTimeout(() => {
|
|
116
|
+
handleClose();
|
|
117
|
+
}, duration);
|
|
118
|
+
return () => clearTimeout(timer);
|
|
119
|
+
}, [duration, handleClose]);
|
|
120
|
+
const handleClick = () => {
|
|
121
|
+
if (onClick) {
|
|
122
|
+
onClick();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const displayIcon = icon !== undefined ? icon : defaultIcons[variant];
|
|
126
|
+
return /*#__PURE__*/_react.default.createElement(_Snackbar.SnackbarWrapper, {
|
|
127
|
+
$variant: variant,
|
|
128
|
+
$isExiting: isExiting,
|
|
129
|
+
$hasClick: !!onClick,
|
|
130
|
+
onClick: onClick ? handleClick : undefined
|
|
131
|
+
}, displayIcon && /*#__PURE__*/_react.default.createElement(_Snackbar.IconWrapper, {
|
|
132
|
+
$variant: variant
|
|
133
|
+
}, displayIcon), /*#__PURE__*/_react.default.createElement(_Snackbar.Message, null, message), /*#__PURE__*/_react.default.createElement(_Snackbar.CloseButton, {
|
|
134
|
+
onClick: e => {
|
|
135
|
+
e.stopPropagation();
|
|
136
|
+
handleClose();
|
|
137
|
+
},
|
|
138
|
+
"aria-label": "Close"
|
|
139
|
+
}, /*#__PURE__*/_react.default.createElement(_crossIcon.ReactComponent, null)));
|
|
140
|
+
};
|
|
141
|
+
SnackbarItem.propTypes = {
|
|
142
|
+
id: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
|
|
143
|
+
message: _propTypes.default.node.isRequired,
|
|
144
|
+
variant: _propTypes.default.oneOf(['info', 'error', 'success', 'warning']),
|
|
145
|
+
icon: _propTypes.default.node,
|
|
146
|
+
onClick: _propTypes.default.func,
|
|
147
|
+
onClose: _propTypes.default.func.isRequired,
|
|
148
|
+
duration: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.oneOf(['permanent'])])
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Snackbar container component
|
|
153
|
+
* Can render to a specific container or to document.body
|
|
154
|
+
*/
|
|
155
|
+
const Snackbar = _ref2 => {
|
|
156
|
+
let {
|
|
157
|
+
snackbars = [],
|
|
158
|
+
onClose,
|
|
159
|
+
position = 'top-right',
|
|
160
|
+
container = null
|
|
161
|
+
} = _ref2;
|
|
162
|
+
if (snackbars.length === 0) return null;
|
|
163
|
+
const content = /*#__PURE__*/_react.default.createElement(_Snackbar.SnackbarContainer, {
|
|
164
|
+
$position: position,
|
|
165
|
+
$isContained: !!container
|
|
166
|
+
}, snackbars.map(snackbar => /*#__PURE__*/_react.default.createElement(SnackbarItem, _extends({
|
|
167
|
+
key: snackbar.id
|
|
168
|
+
}, snackbar, {
|
|
169
|
+
onClose: onClose
|
|
170
|
+
}))));
|
|
171
|
+
|
|
172
|
+
// If container is provided, render inside it (for contained snackbars)
|
|
173
|
+
// Otherwise, render to document.body via portal
|
|
174
|
+
if (container) {
|
|
175
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(content, container);
|
|
176
|
+
}
|
|
177
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(content, document.body);
|
|
178
|
+
};
|
|
179
|
+
exports.Snackbar = Snackbar;
|
|
180
|
+
Snackbar.propTypes = {
|
|
181
|
+
snackbars: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
182
|
+
id: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
|
|
183
|
+
message: _propTypes.default.node.isRequired,
|
|
184
|
+
variant: _propTypes.default.oneOf(['info', 'error', 'success', 'warning']),
|
|
185
|
+
icon: _propTypes.default.node,
|
|
186
|
+
onClick: _propTypes.default.func,
|
|
187
|
+
duration: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.oneOf(['permanent'])])
|
|
188
|
+
})),
|
|
189
|
+
onClose: _propTypes.default.func.isRequired,
|
|
190
|
+
position: _propTypes.default.oneOf(['top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', 'bottom-center']),
|
|
191
|
+
container: _propTypes.default.instanceOf(Element)
|
|
192
|
+
};
|
|
193
|
+
var _default = exports.default = Snackbar;
|