@xsolla/xui-notification-panel 0.92.0-pr143.1771218288

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,83 @@
1
+ import React from 'react';
2
+ import { ButtonProps } from '@xsolla/xui-button';
3
+
4
+ /** Props for the action button, excluding children which is set via actionLabel */
5
+ type ActionButtonProps = Omit<ButtonProps, "children" | "size" | "variant" | "tone">;
6
+ interface NotificationPanelProps {
7
+ /** Visual variant/tone of the notification */
8
+ type?: "alert" | "warning" | "success" | "neutral" | "brand";
9
+ /** Title text (optional) */
10
+ title?: string;
11
+ /** Description text (optional) */
12
+ description?: string;
13
+ /** Show/hide the icon frame */
14
+ showIcon?: boolean;
15
+ /** Custom icon override (optional) */
16
+ icon?: React.ReactNode;
17
+ /** Action button label (optional - hides button if not provided) */
18
+ actionLabel?: string;
19
+ /**
20
+ * Additional props to pass to the action Button component.
21
+ * Supports all Button props except children, size, variant, and tone (which are controlled by NotificationPanel).
22
+ * Use this to add icons, dividers, or other Button customizations.
23
+ * @example
24
+ * ```tsx
25
+ * <NotificationPanel
26
+ * actionLabel="Open documentation"
27
+ * actionProps={{
28
+ * iconRight: <ArrowRight />,
29
+ * divider: true,
30
+ * onPress: () => openDocs()
31
+ * }}
32
+ * />
33
+ * ```
34
+ */
35
+ actionProps?: ActionButtonProps;
36
+ /** Show/hide close button */
37
+ showCloseButton?: boolean;
38
+ /** Close button click handler */
39
+ onClose?: () => void;
40
+ /** Test ID for testing frameworks */
41
+ testID?: string;
42
+ }
43
+ /**
44
+ * NotificationPanel - A full-width notification bar for displaying contextual feedback.
45
+ *
46
+ * Unlike the Notification component (designed for toast popups), NotificationPanel
47
+ * is a horizontal banner intended for persistent inline notifications within page layouts.
48
+ *
49
+ * ## Features
50
+ * - 5 visual variants: alert, warning, success, neutral, brand
51
+ * - Optional icon frame with type-specific coloring
52
+ * - Optional action button with type-matched styling
53
+ * - Optional close button
54
+ * - Accessible: uses role="status" for screen reader announcements
55
+ *
56
+ * ## Usage
57
+ * ```tsx
58
+ * // Simple usage
59
+ * <NotificationPanel
60
+ * type="success"
61
+ * title="Success!"
62
+ * description="Your changes have been saved."
63
+ * actionLabel="Undo"
64
+ * actionProps={{ onPress: () => handleUndo() }}
65
+ * onClose={() => dismiss()}
66
+ * />
67
+ *
68
+ * // With button icon and divider
69
+ * <NotificationPanel
70
+ * type="warning"
71
+ * description="Check our guide to view all webhooks"
72
+ * actionLabel="Open documentation"
73
+ * actionProps={{
74
+ * iconRight: <ArrowRight />,
75
+ * divider: true,
76
+ * onPress: () => openDocs()
77
+ * }}
78
+ * />
79
+ * ```
80
+ */
81
+ declare const NotificationPanel: React.FC<NotificationPanelProps>;
82
+
83
+ export { type ActionButtonProps, NotificationPanel, type NotificationPanelProps };
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { ButtonProps } from '@xsolla/xui-button';
3
+
4
+ /** Props for the action button, excluding children which is set via actionLabel */
5
+ type ActionButtonProps = Omit<ButtonProps, "children" | "size" | "variant" | "tone">;
6
+ interface NotificationPanelProps {
7
+ /** Visual variant/tone of the notification */
8
+ type?: "alert" | "warning" | "success" | "neutral" | "brand";
9
+ /** Title text (optional) */
10
+ title?: string;
11
+ /** Description text (optional) */
12
+ description?: string;
13
+ /** Show/hide the icon frame */
14
+ showIcon?: boolean;
15
+ /** Custom icon override (optional) */
16
+ icon?: React.ReactNode;
17
+ /** Action button label (optional - hides button if not provided) */
18
+ actionLabel?: string;
19
+ /**
20
+ * Additional props to pass to the action Button component.
21
+ * Supports all Button props except children, size, variant, and tone (which are controlled by NotificationPanel).
22
+ * Use this to add icons, dividers, or other Button customizations.
23
+ * @example
24
+ * ```tsx
25
+ * <NotificationPanel
26
+ * actionLabel="Open documentation"
27
+ * actionProps={{
28
+ * iconRight: <ArrowRight />,
29
+ * divider: true,
30
+ * onPress: () => openDocs()
31
+ * }}
32
+ * />
33
+ * ```
34
+ */
35
+ actionProps?: ActionButtonProps;
36
+ /** Show/hide close button */
37
+ showCloseButton?: boolean;
38
+ /** Close button click handler */
39
+ onClose?: () => void;
40
+ /** Test ID for testing frameworks */
41
+ testID?: string;
42
+ }
43
+ /**
44
+ * NotificationPanel - A full-width notification bar for displaying contextual feedback.
45
+ *
46
+ * Unlike the Notification component (designed for toast popups), NotificationPanel
47
+ * is a horizontal banner intended for persistent inline notifications within page layouts.
48
+ *
49
+ * ## Features
50
+ * - 5 visual variants: alert, warning, success, neutral, brand
51
+ * - Optional icon frame with type-specific coloring
52
+ * - Optional action button with type-matched styling
53
+ * - Optional close button
54
+ * - Accessible: uses role="status" for screen reader announcements
55
+ *
56
+ * ## Usage
57
+ * ```tsx
58
+ * // Simple usage
59
+ * <NotificationPanel
60
+ * type="success"
61
+ * title="Success!"
62
+ * description="Your changes have been saved."
63
+ * actionLabel="Undo"
64
+ * actionProps={{ onPress: () => handleUndo() }}
65
+ * onClose={() => dismiss()}
66
+ * />
67
+ *
68
+ * // With button icon and divider
69
+ * <NotificationPanel
70
+ * type="warning"
71
+ * description="Check our guide to view all webhooks"
72
+ * actionLabel="Open documentation"
73
+ * actionProps={{
74
+ * iconRight: <ArrowRight />,
75
+ * divider: true,
76
+ * onPress: () => openDocs()
77
+ * }}
78
+ * />
79
+ * ```
80
+ */
81
+ declare const NotificationPanel: React.FC<NotificationPanelProps>;
82
+
83
+ export { type ActionButtonProps, NotificationPanel, type NotificationPanelProps };
@@ -0,0 +1,394 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.tsx
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ NotificationPanel: () => NotificationPanel
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // ../primitives-native/src/Box.tsx
28
+ var import_react_native = require("react-native");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var Box = ({
31
+ children,
32
+ onPress,
33
+ onLayout,
34
+ onMoveShouldSetResponder,
35
+ onResponderGrant,
36
+ onResponderMove,
37
+ onResponderRelease,
38
+ onResponderTerminate,
39
+ backgroundColor,
40
+ borderColor,
41
+ borderWidth,
42
+ borderBottomWidth,
43
+ borderBottomColor,
44
+ borderTopWidth,
45
+ borderTopColor,
46
+ borderLeftWidth,
47
+ borderLeftColor,
48
+ borderRightWidth,
49
+ borderRightColor,
50
+ borderRadius,
51
+ borderStyle,
52
+ height,
53
+ padding,
54
+ paddingHorizontal,
55
+ paddingVertical,
56
+ margin,
57
+ marginTop,
58
+ marginBottom,
59
+ marginLeft,
60
+ marginRight,
61
+ flexDirection,
62
+ alignItems,
63
+ justifyContent,
64
+ position,
65
+ top,
66
+ bottom,
67
+ left,
68
+ right,
69
+ width,
70
+ flex,
71
+ overflow,
72
+ zIndex,
73
+ hoverStyle,
74
+ pressStyle,
75
+ style,
76
+ "data-testid": dataTestId,
77
+ testID,
78
+ as,
79
+ src,
80
+ alt,
81
+ ...rest
82
+ }) => {
83
+ const getContainerStyle = (pressed) => ({
84
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
85
+ borderColor,
86
+ borderWidth,
87
+ borderBottomWidth,
88
+ borderBottomColor,
89
+ borderTopWidth,
90
+ borderTopColor,
91
+ borderLeftWidth,
92
+ borderLeftColor,
93
+ borderRightWidth,
94
+ borderRightColor,
95
+ borderRadius,
96
+ borderStyle,
97
+ overflow,
98
+ zIndex,
99
+ height,
100
+ width,
101
+ padding,
102
+ paddingHorizontal,
103
+ paddingVertical,
104
+ margin,
105
+ marginTop,
106
+ marginBottom,
107
+ marginLeft,
108
+ marginRight,
109
+ flexDirection,
110
+ alignItems,
111
+ justifyContent,
112
+ position,
113
+ top,
114
+ bottom,
115
+ left,
116
+ right,
117
+ flex,
118
+ ...style
119
+ });
120
+ const finalTestID = dataTestId || testID;
121
+ const {
122
+ role,
123
+ tabIndex,
124
+ onKeyDown,
125
+ onKeyUp,
126
+ "aria-label": _ariaLabel,
127
+ "aria-labelledby": _ariaLabelledBy,
128
+ "aria-current": _ariaCurrent,
129
+ "aria-disabled": _ariaDisabled,
130
+ "aria-live": _ariaLive,
131
+ className,
132
+ "data-testid": _dataTestId,
133
+ ...nativeRest
134
+ } = rest;
135
+ if (as === "img" && src) {
136
+ const imageStyle = {
137
+ width,
138
+ height,
139
+ borderRadius,
140
+ position,
141
+ top,
142
+ bottom,
143
+ left,
144
+ right,
145
+ ...style
146
+ };
147
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
148
+ import_react_native.Image,
149
+ {
150
+ source: { uri: src },
151
+ style: imageStyle,
152
+ testID: finalTestID,
153
+ resizeMode: "cover",
154
+ ...nativeRest
155
+ }
156
+ );
157
+ }
158
+ if (onPress) {
159
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
160
+ import_react_native.Pressable,
161
+ {
162
+ onPress,
163
+ onLayout,
164
+ onMoveShouldSetResponder,
165
+ onResponderGrant,
166
+ onResponderMove,
167
+ onResponderRelease,
168
+ onResponderTerminate,
169
+ style: ({ pressed }) => getContainerStyle(pressed),
170
+ testID: finalTestID,
171
+ ...nativeRest,
172
+ children
173
+ }
174
+ );
175
+ }
176
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
177
+ import_react_native.View,
178
+ {
179
+ style: getContainerStyle(),
180
+ testID: finalTestID,
181
+ onLayout,
182
+ onMoveShouldSetResponder,
183
+ onResponderGrant,
184
+ onResponderMove,
185
+ onResponderRelease,
186
+ onResponderTerminate,
187
+ ...nativeRest,
188
+ children
189
+ }
190
+ );
191
+ };
192
+
193
+ // ../primitives-native/src/Text.tsx
194
+ var import_react_native2 = require("react-native");
195
+ var import_jsx_runtime2 = require("react/jsx-runtime");
196
+ var roleMap = {
197
+ alert: "alert",
198
+ heading: "header",
199
+ button: "button",
200
+ link: "link",
201
+ text: "text"
202
+ };
203
+ var Text = ({
204
+ children,
205
+ color,
206
+ fontSize,
207
+ fontWeight,
208
+ fontFamily,
209
+ id,
210
+ role,
211
+ ...props
212
+ }) => {
213
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
214
+ if (resolvedFontFamily === "Pilat Wide Bold") {
215
+ resolvedFontFamily = void 0;
216
+ }
217
+ const style = {
218
+ color,
219
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
220
+ fontWeight,
221
+ fontFamily: resolvedFontFamily,
222
+ textDecorationLine: props.textDecoration
223
+ };
224
+ const accessibilityRole = role ? roleMap[role] : void 0;
225
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
226
+ };
227
+
228
+ // src/NotificationPanel.tsx
229
+ var import_xui_core = require("@xsolla/xui-core");
230
+ var import_xui_button = require("@xsolla/xui-button");
231
+ var import_xui_icons_base = require("@xsolla/xui-icons-base");
232
+ var import_jsx_runtime3 = require("react/jsx-runtime");
233
+ var NotificationPanel = ({
234
+ type = "neutral",
235
+ title,
236
+ description,
237
+ showIcon = true,
238
+ icon,
239
+ actionLabel,
240
+ actionProps,
241
+ showCloseButton = true,
242
+ onClose,
243
+ testID
244
+ }) => {
245
+ const { theme } = (0, import_xui_core.useDesignSystem)();
246
+ const config = theme.sizing.notificationPanel();
247
+ const typeConfig = {
248
+ alert: {
249
+ panelBg: theme.colors.overlay.alert,
250
+ iconFrameBg: theme.colors.overlay.alert,
251
+ iconColor: theme.colors.content.primary,
252
+ buttonTone: "alert",
253
+ IconComponent: import_xui_icons_base.ExclamationMarkSq
254
+ },
255
+ warning: {
256
+ panelBg: theme.colors.overlay.warning,
257
+ iconFrameBg: theme.colors.background.warning.primary,
258
+ iconColor: theme.colors.content.primary,
259
+ buttonTone: "mono",
260
+ IconComponent: import_xui_icons_base.ExclamationMarkSq
261
+ },
262
+ success: {
263
+ panelBg: theme.colors.overlay.success,
264
+ iconFrameBg: theme.colors.background.success.primary,
265
+ iconColor: theme.colors.content.primary,
266
+ buttonTone: "brandExtra",
267
+ IconComponent: import_xui_icons_base.CheckCr
268
+ },
269
+ neutral: {
270
+ panelBg: theme.colors.overlay.mono,
271
+ iconFrameBg: theme.colors.overlay.mono,
272
+ iconColor: theme.colors.content.primary,
273
+ buttonTone: "mono",
274
+ IconComponent: import_xui_icons_base.InfoSq
275
+ },
276
+ brand: {
277
+ panelBg: theme.colors.overlay.brand,
278
+ iconFrameBg: theme.colors.overlay.brand,
279
+ iconColor: theme.colors.content.primary,
280
+ buttonTone: "brand",
281
+ IconComponent: import_xui_icons_base.InfoSq
282
+ }
283
+ };
284
+ const currentConfig = typeConfig[type];
285
+ const IconComponent = currentConfig.IconComponent;
286
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
287
+ Box,
288
+ {
289
+ backgroundColor: currentConfig.panelBg,
290
+ borderRadius: config.borderRadius,
291
+ flexDirection: "row",
292
+ alignItems: "stretch",
293
+ overflow: "hidden",
294
+ testID,
295
+ role: "status",
296
+ "aria-label": `${type} notification`,
297
+ children: [
298
+ showIcon && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
299
+ Box,
300
+ {
301
+ backgroundColor: currentConfig.iconFrameBg,
302
+ width: config.iconFrameWidth,
303
+ alignItems: "center",
304
+ justifyContent: "center",
305
+ style: {
306
+ borderTopLeftRadius: config.borderRadius,
307
+ borderBottomLeftRadius: config.borderRadius
308
+ },
309
+ children: icon || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
310
+ IconComponent,
311
+ {
312
+ size: config.iconSize,
313
+ color: currentConfig.iconColor,
314
+ variant: "solid"
315
+ }
316
+ )
317
+ }
318
+ ),
319
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
320
+ Box,
321
+ {
322
+ flex: 1,
323
+ flexDirection: "row",
324
+ alignItems: "center",
325
+ paddingHorizontal: config.bodyPaddingHorizontal,
326
+ paddingVertical: config.bodyPaddingVertical,
327
+ gap: config.contentGap,
328
+ children: [
329
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box, { flex: 1, gap: config.textGap, children: [
330
+ title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
331
+ Text,
332
+ {
333
+ color: theme.colors.content.primary,
334
+ fontSize: config.titleFontSize,
335
+ lineHeight: config.titleLineHeight,
336
+ fontWeight: "500",
337
+ children: title
338
+ }
339
+ ),
340
+ description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
341
+ Text,
342
+ {
343
+ color: theme.colors.content.tertiary,
344
+ fontSize: config.descriptionFontSize,
345
+ lineHeight: config.descriptionLineHeight,
346
+ children: description
347
+ }
348
+ )
349
+ ] }),
350
+ (actionLabel || showCloseButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box, { flexDirection: "row", alignItems: "center", gap: config.buttonsGap, children: [
351
+ actionLabel && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
352
+ import_xui_button.Button,
353
+ {
354
+ size: "xs",
355
+ variant: "secondary",
356
+ tone: currentConfig.buttonTone,
357
+ ...actionProps,
358
+ children: actionLabel
359
+ }
360
+ ),
361
+ showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
362
+ Box,
363
+ {
364
+ width: config.closeButtonSize,
365
+ height: config.closeButtonSize,
366
+ alignItems: "center",
367
+ justifyContent: "center",
368
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
369
+ import_xui_button.FlexButton,
370
+ {
371
+ variant: "primary",
372
+ size: "sm",
373
+ onPress: onClose,
374
+ "aria-label": "Close notification",
375
+ iconRight: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_icons_base.Remove, {}),
376
+ children: ""
377
+ }
378
+ )
379
+ }
380
+ )
381
+ ] })
382
+ ]
383
+ }
384
+ )
385
+ ]
386
+ }
387
+ );
388
+ };
389
+ NotificationPanel.displayName = "NotificationPanel";
390
+ // Annotate the CommonJS export names for ESM import in node:
391
+ 0 && (module.exports = {
392
+ NotificationPanel
393
+ });
394
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Flowtype definitions for index
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import React from "react";
9
+ import { ButtonProps } from "@xsolla/xui-button";
10
+
11
+ /**
12
+ * Props for the action button, excluding children which is set via actionLabel
13
+ */
14
+ declare type ActionButtonProps = $Diff<
15
+ ButtonProps,
16
+ { children: any, size: any, variant: any, tone: any }
17
+ >;
18
+ declare interface NotificationPanelProps {
19
+ /**
20
+ * Visual variant/tone of the notification
21
+ */
22
+ type?: "alert" | "warning" | "success" | "neutral" | "brand";
23
+
24
+ /**
25
+ * Title text (optional)
26
+ */
27
+ title?: string;
28
+
29
+ /**
30
+ * Description text (optional)
31
+ */
32
+ description?: string;
33
+
34
+ /**
35
+ * Show/hide the icon frame
36
+ */
37
+ showIcon?: boolean;
38
+
39
+ /**
40
+ * Custom icon override (optional)
41
+ */
42
+ icon?: React.ReactNode;
43
+
44
+ /**
45
+ * Action button label (optional - hides button if not provided)
46
+ */
47
+ actionLabel?: string;
48
+
49
+ /**
50
+ * Additional props to pass to the action Button component.
51
+ * Supports all Button props except children, size, variant, and tone (which are controlled by NotificationPanel).
52
+ * Use this to add icons, dividers, or other Button customizations.
53
+ * @example ```tsx
54
+ * <NotificationPanel
55
+ * actionLabel="Open documentation"
56
+ * actionProps={{
57
+ * iconRight: <ArrowRight />,
58
+ * divider: true,
59
+ * onPress: () => openDocs()
60
+ * }}
61
+ * />
62
+ * ```
63
+ */
64
+ actionProps?: ActionButtonProps;
65
+
66
+ /**
67
+ * Show/hide close button
68
+ */
69
+ showCloseButton?: boolean;
70
+
71
+ /**
72
+ * Close button click handler
73
+ */
74
+ onClose?: () => void;
75
+
76
+ /**
77
+ * Test ID for testing frameworks
78
+ */
79
+ testID?: string;
80
+ }
81
+ /**
82
+ * NotificationPanel - A full-width notification bar for displaying contextual feedback.
83
+ *
84
+ * Unlike the Notification component (designed for toast popups), NotificationPanel
85
+ * is a horizontal banner intended for persistent inline notifications within page layouts.
86
+ *
87
+ * ## Features
88
+ * - 5 visual variants: alert, warning, success, neutral, brand
89
+ * - Optional icon frame with type-specific coloring
90
+ * - Optional action button with type-matched styling
91
+ * - Optional close button
92
+ * - Accessible: uses role="status" for screen reader announcements
93
+ *
94
+ * ## Usage
95
+ * ```tsx
96
+ * // Simple usage
97
+ * <NotificationPanel
98
+ * type="success"
99
+ * title="Success!"
100
+ * description="Your changes have been saved."
101
+ * actionLabel="Undo"
102
+ * actionProps={{ onPress: () => handleUndo() }}
103
+ * onClose={() => dismiss()}
104
+ * />
105
+ *
106
+ * // With button icon and divider
107
+ * <NotificationPanel
108
+ * type="warning"
109
+ * description="Check our guide to view all webhooks"
110
+ * actionLabel="Open documentation"
111
+ * actionProps={{
112
+ * iconRight: <ArrowRight />,
113
+ * divider: true,
114
+ * onPress: () => openDocs()
115
+ * }}
116
+ * />
117
+ * ```
118
+ */
119
+ declare var NotificationPanel: React.FC<NotificationPanelProps>;
120
+ export type { ActionButtonProps, NotificationPanelProps };
121
+ declare export { NotificationPanel };