@stokr/components-library 2.3.65-beta.6 → 2.3.65-beta.8

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.
@@ -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;
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithClickAction = exports.TopLeft = exports.TopCenter = exports.Default = exports.CustomDuration = exports.ContainedSnackbar = exports.BottomRight = exports.BottomLeft = exports.BottomCenter = exports.AllVariants = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _SnackbarProvider = require("./SnackbarProvider");
9
+ var _useSnackbar = require("./useSnackbar");
10
+ var _Snackbar = require("./Snackbar");
11
+ var _global = _interopRequireDefault(require("../../styles/global"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ 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); }
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
18
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
+ var _default = exports.default = {
20
+ title: 'Components/Snackbar',
21
+ component: _Snackbar.Snackbar,
22
+ decorators: [Story => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(Story, null))],
23
+ parameters: {
24
+ layout: 'fullscreen'
25
+ }
26
+ }; // Interactive demo with provider
27
+ const SnackbarDemo = _ref => {
28
+ let {
29
+ position
30
+ } = _ref;
31
+ const {
32
+ showSnackbar,
33
+ clearAll
34
+ } = (0, _useSnackbar.useSnackbar)();
35
+ return /*#__PURE__*/_react.default.createElement("div", {
36
+ style: {
37
+ padding: 40
38
+ }
39
+ }, /*#__PURE__*/_react.default.createElement("h2", {
40
+ style: {
41
+ marginBottom: 20
42
+ }
43
+ }, "Snackbar Demo - ", position), /*#__PURE__*/_react.default.createElement("div", {
44
+ style: {
45
+ display: 'flex',
46
+ gap: 10,
47
+ flexWrap: 'wrap'
48
+ }
49
+ }, /*#__PURE__*/_react.default.createElement("button", {
50
+ onClick: () => showSnackbar({
51
+ message: 'Verification to be completed.',
52
+ variant: 'info'
53
+ })
54
+ }, "Show Info"), /*#__PURE__*/_react.default.createElement("button", {
55
+ onClick: () => showSnackbar({
56
+ message: 'Verification not completed.',
57
+ variant: 'error'
58
+ })
59
+ }, "Show Error"), /*#__PURE__*/_react.default.createElement("button", {
60
+ onClick: () => showSnackbar({
61
+ message: 'Verification completed successfully!',
62
+ variant: 'success'
63
+ })
64
+ }, "Show Success"), /*#__PURE__*/_react.default.createElement("button", {
65
+ onClick: () => showSnackbar({
66
+ message: 'Verification missing few details.',
67
+ variant: 'warning'
68
+ })
69
+ }, "Show Warning"), /*#__PURE__*/_react.default.createElement("button", {
70
+ onClick: () => showSnackbar({
71
+ message: 'This snackbar will stay until you close it.',
72
+ variant: 'info',
73
+ duration: 'permanent'
74
+ })
75
+ }, "Show Permanent"), /*#__PURE__*/_react.default.createElement("button", {
76
+ onClick: () => showSnackbar({
77
+ message: /*#__PURE__*/_react.default.createElement("span", null, "Custom content with ", /*#__PURE__*/_react.default.createElement("strong", null, "bold text")),
78
+ variant: 'success'
79
+ })
80
+ }, "Show Custom Content"), /*#__PURE__*/_react.default.createElement("button", {
81
+ onClick: clearAll
82
+ }, "Clear All")));
83
+ };
84
+ const Default = exports.Default = {
85
+ render: () => /*#__PURE__*/_react.default.createElement(_SnackbarProvider.SnackbarProvider, {
86
+ position: "top-right"
87
+ }, /*#__PURE__*/_react.default.createElement(SnackbarDemo, {
88
+ position: "top-right"
89
+ }))
90
+ };
91
+ const TopLeft = exports.TopLeft = {
92
+ render: () => /*#__PURE__*/_react.default.createElement(_SnackbarProvider.SnackbarProvider, {
93
+ position: "top-left"
94
+ }, /*#__PURE__*/_react.default.createElement(SnackbarDemo, {
95
+ position: "top-left"
96
+ }))
97
+ };
98
+ const TopCenter = exports.TopCenter = {
99
+ render: () => /*#__PURE__*/_react.default.createElement(_SnackbarProvider.SnackbarProvider, {
100
+ position: "top-center"
101
+ }, /*#__PURE__*/_react.default.createElement(SnackbarDemo, {
102
+ position: "top-center"
103
+ }))
104
+ };
105
+ const BottomRight = exports.BottomRight = {
106
+ render: () => /*#__PURE__*/_react.default.createElement(_SnackbarProvider.SnackbarProvider, {
107
+ position: "bottom-right"
108
+ }, /*#__PURE__*/_react.default.createElement(SnackbarDemo, {
109
+ position: "bottom-right"
110
+ }))
111
+ };
112
+ const BottomLeft = exports.BottomLeft = {
113
+ render: () => /*#__PURE__*/_react.default.createElement(_SnackbarProvider.SnackbarProvider, {
114
+ position: "bottom-left"
115
+ }, /*#__PURE__*/_react.default.createElement(SnackbarDemo, {
116
+ position: "bottom-left"
117
+ }))
118
+ };
119
+ const BottomCenter = exports.BottomCenter = {
120
+ render: () => /*#__PURE__*/_react.default.createElement(_SnackbarProvider.SnackbarProvider, {
121
+ position: "bottom-center"
122
+ }, /*#__PURE__*/_react.default.createElement(SnackbarDemo, {
123
+ position: "bottom-center"
124
+ }))
125
+ };
126
+
127
+ // All variants showcase - extracted to a proper component
128
+ const AllVariantsDemo = () => {
129
+ const [snackbars, setSnackbars] = (0, _react.useState)([{
130
+ id: 1,
131
+ message: 'Verification to be completed.',
132
+ variant: 'info'
133
+ }, {
134
+ id: 2,
135
+ message: 'Verification not completed.',
136
+ variant: 'error'
137
+ }, {
138
+ id: 3,
139
+ message: 'Verification completed successfully!',
140
+ variant: 'success'
141
+ }, {
142
+ id: 4,
143
+ message: 'Verification missing few details.',
144
+ variant: 'warning'
145
+ }]);
146
+ const handleClose = id => {
147
+ setSnackbars(prev => prev.filter(s => s.id !== id));
148
+ };
149
+ return /*#__PURE__*/_react.default.createElement("div", {
150
+ style: {
151
+ padding: 40
152
+ }
153
+ }, /*#__PURE__*/_react.default.createElement("h2", null, "All Variants"), /*#__PURE__*/_react.default.createElement("div", {
154
+ style: {
155
+ display: 'flex',
156
+ flexDirection: 'column',
157
+ gap: 16,
158
+ maxWidth: 500
159
+ }
160
+ }, snackbars.map(snackbar => /*#__PURE__*/_react.default.createElement("div", {
161
+ key: snackbar.id,
162
+ style: {
163
+ position: 'relative'
164
+ }
165
+ }, /*#__PURE__*/_react.default.createElement(_Snackbar.Snackbar, {
166
+ snackbars: [_objectSpread(_objectSpread({}, snackbar), {}, {
167
+ duration: 'permanent'
168
+ })],
169
+ onClose: handleClose,
170
+ position: "top-right",
171
+ container: null
172
+ })))));
173
+ };
174
+ const AllVariants = exports.AllVariants = {
175
+ render: () => /*#__PURE__*/_react.default.createElement(AllVariantsDemo, null)
176
+ };
177
+
178
+ // Contained snackbar - extracted to a proper component
179
+ const ContainedSnackbarDemo = () => {
180
+ const containerRef = (0, _react.useRef)(null);
181
+ const [snackbars, setSnackbars] = (0, _react.useState)([]);
182
+ const addSnackbar = () => {
183
+ const variants = ['info', 'error', 'success', 'warning'];
184
+ const variant = variants[Math.floor(Math.random() * variants.length)];
185
+ setSnackbars(prev => [...prev, {
186
+ id: Date.now(),
187
+ message: "Snackbar inside container (".concat(variant, ")"),
188
+ variant
189
+ }]);
190
+ };
191
+ const handleClose = id => {
192
+ setSnackbars(prev => prev.filter(s => s.id !== id));
193
+ };
194
+ return /*#__PURE__*/_react.default.createElement("div", {
195
+ style: {
196
+ padding: 40
197
+ }
198
+ }, /*#__PURE__*/_react.default.createElement("h2", null, "Contained Snackbar"), /*#__PURE__*/_react.default.createElement("p", null, "Snackbars appear inside the bordered container below:"), /*#__PURE__*/_react.default.createElement("button", {
199
+ onClick: addSnackbar,
200
+ style: {
201
+ marginBottom: 20
202
+ }
203
+ }, "Add Snackbar"), /*#__PURE__*/_react.default.createElement("div", {
204
+ ref: containerRef,
205
+ style: {
206
+ position: 'relative',
207
+ width: '100%',
208
+ height: 400,
209
+ border: '2px dashed #ccc',
210
+ borderRadius: 8,
211
+ overflow: 'hidden'
212
+ }
213
+ }, containerRef.current && /*#__PURE__*/_react.default.createElement(_Snackbar.Snackbar, {
214
+ snackbars: snackbars,
215
+ onClose: handleClose,
216
+ position: "top-right",
217
+ container: containerRef.current
218
+ })));
219
+ };
220
+ const ContainedSnackbar = exports.ContainedSnackbar = {
221
+ render: () => /*#__PURE__*/_react.default.createElement(ContainedSnackbarDemo, null)
222
+ };
223
+
224
+ // Custom duration demo
225
+ const SnackbarDemoCustomDuration = () => {
226
+ const {
227
+ showSnackbar
228
+ } = (0, _useSnackbar.useSnackbar)();
229
+ return /*#__PURE__*/_react.default.createElement("div", {
230
+ style: {
231
+ display: 'flex',
232
+ gap: 10
233
+ }
234
+ }, /*#__PURE__*/_react.default.createElement("button", {
235
+ onClick: () => showSnackbar({
236
+ message: 'Auto-dismiss in 3 seconds (default)',
237
+ variant: 'info'
238
+ })
239
+ }, "3s (default)"), /*#__PURE__*/_react.default.createElement("button", {
240
+ onClick: () => showSnackbar({
241
+ message: 'Auto-dismiss in 1 second',
242
+ variant: 'warning',
243
+ duration: 1000
244
+ })
245
+ }, "1 second"), /*#__PURE__*/_react.default.createElement("button", {
246
+ onClick: () => showSnackbar({
247
+ message: 'Auto-dismiss in 10 seconds',
248
+ variant: 'success',
249
+ duration: 10000
250
+ })
251
+ }, "10 seconds"), /*#__PURE__*/_react.default.createElement("button", {
252
+ onClick: () => showSnackbar({
253
+ message: 'I stay until you close me!',
254
+ variant: 'error',
255
+ duration: 'permanent'
256
+ })
257
+ }, "Permanent"));
258
+ };
259
+ const CustomDuration = exports.CustomDuration = {
260
+ render: () => /*#__PURE__*/_react.default.createElement(_SnackbarProvider.SnackbarProvider, {
261
+ position: "top-right",
262
+ defaultDuration: 3000
263
+ }, /*#__PURE__*/_react.default.createElement("div", {
264
+ style: {
265
+ padding: 40
266
+ }
267
+ }, /*#__PURE__*/_react.default.createElement("h2", null, "Custom Duration (3 seconds default)"), /*#__PURE__*/_react.default.createElement(SnackbarDemoCustomDuration, null)))
268
+ };
269
+
270
+ // With onClick action
271
+ const SnackbarDemoWithClick = () => {
272
+ const {
273
+ showSnackbar
274
+ } = (0, _useSnackbar.useSnackbar)();
275
+ return /*#__PURE__*/_react.default.createElement("div", {
276
+ style: {
277
+ padding: 40
278
+ }
279
+ }, /*#__PURE__*/_react.default.createElement("h2", null, "Snackbar with Click Action"), /*#__PURE__*/_react.default.createElement("button", {
280
+ onClick: () => showSnackbar({
281
+ message: 'Click me to see an alert!',
282
+ variant: 'info',
283
+ duration: 'permanent',
284
+ onClick: () => alert('Snackbar clicked!')
285
+ })
286
+ }, "Show Clickable Snackbar"));
287
+ };
288
+ const WithClickAction = exports.WithClickAction = {
289
+ render: () => /*#__PURE__*/_react.default.createElement(_SnackbarProvider.SnackbarProvider, {
290
+ position: "top-right"
291
+ }, /*#__PURE__*/_react.default.createElement(SnackbarDemoWithClick, null))
292
+ };
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.variantStyles = exports.SnackbarWrapper = exports.SnackbarContainer = exports.Message = exports.IconWrapper = exports.CloseButton = void 0;
7
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
+ var _colors = _interopRequireDefault(require("../../styles/colors"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ 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); }
11
+ const slideIn = (0, _styledComponents.keyframes)(["from{opacity:0;transform:translateX(100%);}to{opacity:1;transform:translateX(0);}"]);
12
+ const slideOut = (0, _styledComponents.keyframes)(["from{opacity:1;transform:translateX(0);}to{opacity:0;transform:translateX(100%);}"]);
13
+ const slideInLeft = (0, _styledComponents.keyframes)(["from{opacity:0;transform:translateX(-100%);}to{opacity:1;transform:translateX(0);}"]);
14
+ const slideInUp = (0, _styledComponents.keyframes)(["from{opacity:0;transform:translateY(100%);}to{opacity:1;transform:translateY(0);}"]);
15
+ const slideInDown = (0, _styledComponents.keyframes)(["from{opacity:0;transform:translateY(-100%);}to{opacity:1;transform:translateY(0);}"]);
16
+
17
+ // Variant configurations
18
+ const variantStyles = exports.variantStyles = {
19
+ info: {
20
+ borderColor: _colors.default.blue,
21
+ iconColor: _colors.default.blue
22
+ },
23
+ error: {
24
+ borderColor: _colors.default.orangishRed,
25
+ iconColor: _colors.default.orangishRed
26
+ },
27
+ success: {
28
+ borderColor: _colors.default.progressAccentStart,
29
+ iconColor: _colors.default.progressAccentStart
30
+ },
31
+ warning: {
32
+ borderColor: _colors.default.warningOrange,
33
+ iconColor: _colors.default.warningOrange
34
+ }
35
+ };
36
+
37
+ // Position configurations
38
+ const positionStyles = {
39
+ 'top-right': (0, _styledComponents.css)(["top:20px;right:20px;animation:", " 0.3s ease-out forwards;"], slideIn),
40
+ 'top-left': (0, _styledComponents.css)(["top:20px;left:20px;animation:", " 0.3s ease-out forwards;"], slideInLeft),
41
+ 'top-center': (0, _styledComponents.css)(["top:20px;left:50%;transform:translateX(-50%);animation:", " 0.3s ease-out forwards;"], slideInDown),
42
+ 'bottom-right': (0, _styledComponents.css)(["bottom:20px;right:20px;animation:", " 0.3s ease-out forwards;"], slideIn),
43
+ 'bottom-left': (0, _styledComponents.css)(["bottom:20px;left:20px;animation:", " 0.3s ease-out forwards;"], slideInLeft),
44
+ 'bottom-center': (0, _styledComponents.css)(["bottom:20px;left:50%;transform:translateX(-50%);animation:", " 0.3s ease-out forwards;"], slideInUp)
45
+ };
46
+ const SnackbarContainer = exports.SnackbarContainer = _styledComponents.default.div.withConfig({
47
+ displayName: "Snackbarstyles__SnackbarContainer",
48
+ componentId: "sc-xf2wxi-0"
49
+ })(["position:", ";z-index:1100;display:flex;flex-direction:column;gap:10px;pointer-events:none;", ""], _ref => {
50
+ let {
51
+ $isContained
52
+ } = _ref;
53
+ return $isContained ? 'absolute' : 'fixed';
54
+ }, _ref2 => {
55
+ let {
56
+ $position
57
+ } = _ref2;
58
+ return positionStyles[$position] || positionStyles['top-right'];
59
+ });
60
+ const SnackbarWrapper = exports.SnackbarWrapper = _styledComponents.default.div.withConfig({
61
+ displayName: "Snackbarstyles__SnackbarWrapper",
62
+ componentId: "sc-xf2wxi-1"
63
+ })(["display:flex;align-items:center;gap:12px;min-width:320px;max-width:480px;padding:12px 16px;background-color:", ";box-shadow:0 1px 2px -1px rgba(0,0,0,0.12);border-radius:6px;border:1px solid ", ";border-bottom:3px solid ", ";pointer-events:auto;animation:", " 0.3s ease-out forwards;", ""], _colors.default.white, _colors.default.grey, _ref3 => {
64
+ var _variantStyles$$varia;
65
+ let {
66
+ $variant
67
+ } = _ref3;
68
+ return ((_variantStyles$$varia = variantStyles[$variant]) === null || _variantStyles$$varia === void 0 ? void 0 : _variantStyles$$varia.borderColor) || _colors.default.blue;
69
+ }, _ref4 => {
70
+ let {
71
+ $isExiting
72
+ } = _ref4;
73
+ return $isExiting ? slideOut : 'none';
74
+ }, _ref5 => {
75
+ let {
76
+ $hasClick
77
+ } = _ref5;
78
+ return $hasClick && (0, _styledComponents.css)(["cursor:pointer;&:hover{box-shadow:0 4px 24px rgba(0,0,0,0.16);}"]);
79
+ });
80
+ const IconWrapper = exports.IconWrapper = _styledComponents.default.div.withConfig({
81
+ displayName: "Snackbarstyles__IconWrapper",
82
+ componentId: "sc-xf2wxi-2"
83
+ })(["flex-shrink:0;display:flex;align-items:center;justify-content:center;width:20px;height:20px;color:", ";svg{width:100%;height:100%;}"], _ref6 => {
84
+ var _variantStyles$$varia2;
85
+ let {
86
+ $variant
87
+ } = _ref6;
88
+ return ((_variantStyles$$varia2 = variantStyles[$variant]) === null || _variantStyles$$varia2 === void 0 ? void 0 : _variantStyles$$varia2.iconColor) || _colors.default.blue;
89
+ });
90
+ const Message = exports.Message = _styledComponents.default.div.withConfig({
91
+ displayName: "Snackbarstyles__Message",
92
+ componentId: "sc-xf2wxi-3"
93
+ })(["flex:1;font-size:16px;font-weight:600;line-height:24px;letter-spacing:0.6px;color:", ";"], _colors.default.black);
94
+ const CloseButton = exports.CloseButton = _styledComponents.default.button.withConfig({
95
+ displayName: "Snackbarstyles__CloseButton",
96
+ componentId: "sc-xf2wxi-4"
97
+ })(["flex-shrink:0;display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;background:transparent;border:none;cursor:pointer;transition:opacity 0.2s ease;&:hover{opacity:0.7;}svg{width:12px;height:12px;path{stroke:", ";stroke-width:2;}}&:hover svg path{stroke:", ";}"], _colors.default.grey2, _colors.default.black);
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.SnackbarProvider = exports.SnackbarContext = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _Snackbar = require("./Snackbar");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ 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); }
12
+ const SnackbarContext = exports.SnackbarContext = /*#__PURE__*/(0, _react.createContext)(null);
13
+ let snackbarId = 0;
14
+
15
+ /**
16
+ * SnackbarProvider - Wrap your app with this to enable global snackbar functionality
17
+ *
18
+ * @example
19
+ * <SnackbarProvider position="top-right" maxSnacks={5}>
20
+ * <App />
21
+ * </SnackbarProvider>
22
+ */
23
+ const SnackbarProvider = _ref => {
24
+ let {
25
+ children,
26
+ position = 'top-right',
27
+ maxSnacks = 5,
28
+ defaultDuration = 5000,
29
+ container = null
30
+ } = _ref;
31
+ const [snackbars, setSnackbars] = (0, _react.useState)([]);
32
+ const closeSnackbar = (0, _react.useCallback)(id => {
33
+ setSnackbars(prev => prev.filter(s => s.id !== id));
34
+ }, []);
35
+ const showSnackbar = (0, _react.useCallback)(options => {
36
+ var _options$id, _options$duration;
37
+ const id = (_options$id = options.id) !== null && _options$id !== void 0 ? _options$id : ++snackbarId;
38
+ const newSnackbar = {
39
+ id,
40
+ message: options.message,
41
+ variant: options.variant || 'info',
42
+ icon: options.icon,
43
+ onClick: options.onClick,
44
+ duration: (_options$duration = options.duration) !== null && _options$duration !== void 0 ? _options$duration : defaultDuration
45
+ };
46
+ setSnackbars(prev => {
47
+ // Remove oldest if we exceed maxSnacks
48
+ const updated = [...prev, newSnackbar];
49
+ if (updated.length > maxSnacks) {
50
+ return updated.slice(-maxSnacks);
51
+ }
52
+ return updated;
53
+ });
54
+ return id;
55
+ }, [maxSnacks, defaultDuration]);
56
+ const clearAll = (0, _react.useCallback)(() => {
57
+ setSnackbars([]);
58
+ }, []);
59
+ const contextValue = (0, _react.useMemo)(() => ({
60
+ showSnackbar,
61
+ closeSnackbar,
62
+ clearAll
63
+ }), [showSnackbar, closeSnackbar, clearAll]);
64
+ return /*#__PURE__*/_react.default.createElement(SnackbarContext.Provider, {
65
+ value: contextValue
66
+ }, children, /*#__PURE__*/_react.default.createElement(_Snackbar.Snackbar, {
67
+ snackbars: snackbars,
68
+ onClose: closeSnackbar,
69
+ position: position,
70
+ container: container
71
+ }));
72
+ };
73
+ exports.SnackbarProvider = SnackbarProvider;
74
+ SnackbarProvider.propTypes = {
75
+ children: _propTypes.default.node.isRequired,
76
+ position: _propTypes.default.oneOf(['top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', 'bottom-center']),
77
+ maxSnacks: _propTypes.default.number,
78
+ defaultDuration: _propTypes.default.number,
79
+ container: _propTypes.default.instanceOf(Element)
80
+ };
81
+ var _default = exports.default = SnackbarProvider;