@longline/aqua-ui 1.0.302 → 1.0.304
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/controls/Chip/Chip.d.ts +41 -13
- package/controls/Chip/Chip.js +76 -22
- package/controls/Chip/index.d.ts +2 -1
- package/controls/Chip/index.js +1 -1
- package/controls/CircularProgress/CircularProgress.d.ts +38 -6
- package/controls/CircularProgress/CircularProgress.js +67 -17
- package/controls/CircularProgress/index.d.ts +1 -0
- package/controls/Dropzone/Dropzone.d.ts +42 -10
- package/controls/Dropzone/Dropzone.js +76 -16
- package/controls/Dropzone/index.d.ts +1 -0
- package/controls/Fab/Fab.d.ts +40 -15
- package/controls/Fab/Fab.js +76 -28
- package/controls/Fab/index.d.ts +2 -1
- package/controls/Fab/index.js +1 -1
- package/controls/Ghost/Ghost.d.ts +36 -0
- package/controls/Ghost/Ghost.js +72 -1
- package/controls/Ghost/index.d.ts +2 -1
- package/controls/Ghost/index.js +1 -1
- package/controls/Gradient/Gradient.d.ts +51 -5
- package/controls/Gradient/Gradient.js +98 -8
- package/controls/Gradient/index.d.ts +1 -0
- package/controls/Histogram/Histogram.d.ts +47 -6
- package/controls/Histogram/Histogram.js +84 -21
- package/controls/Histogram/HistogramAppearance.d.ts +2 -1
- package/controls/Histogram/IHistogramBin.d.ts +1 -1
- package/controls/Histogram/index.d.ts +5 -3
- package/controls/Histogram/index.js +2 -3
- package/controls/Icon/Icon.d.ts +50 -22
- package/controls/Icon/Icon.js +47 -18
- package/controls/Icon/index.d.ts +2 -1
- package/controls/Icon/index.js +1 -1
- package/controls/Key/Key.d.ts +39 -5
- package/controls/Key/Key.js +74 -8
- package/controls/Key/index.d.ts +2 -1
- package/controls/Key/index.js +1 -1
- package/controls/LinearChart/LinearChart.d.ts +36 -5
- package/controls/LinearChart/LinearChart.js +64 -6
- package/controls/LinearChart/index.d.ts +2 -1
- package/controls/LinearChart/index.js +1 -1
- package/controls/ListView/Column.d.ts +42 -5
- package/controls/ListView/Column.js +39 -3
- package/controls/ListView/IListViewProps.d.ts +2 -2
- package/controls/ListView/ListView.d.ts +58 -2
- package/controls/ListView/ListView.js +57 -2
- package/controls/ListView/index.d.ts +1 -0
- package/controls/Mouse/Mouse.d.ts +32 -7
- package/controls/Mouse/Mouse.js +60 -12
- package/controls/Mouse/index.d.ts +2 -1
- package/controls/Mouse/index.js +1 -1
- package/controls/PrimaryButton/PrimaryButton.d.ts +37 -9
- package/controls/PrimaryButton/PrimaryButton.js +70 -16
- package/controls/PrimaryButton/index.d.ts +2 -1
- package/controls/PrimaryButton/index.js +1 -1
- package/controls/Progress/Progress.d.ts +32 -10
- package/controls/Progress/Progress.js +60 -18
- package/controls/Progress/index.d.ts +2 -1
- package/controls/Progress/index.js +1 -1
- package/controls/SecondaryButton/SecondaryButton.d.ts +34 -8
- package/controls/SecondaryButton/SecondaryButton.js +64 -14
- package/controls/SecondaryButton/index.d.ts +1 -0
- package/controls/SpeechRecognizer/SpeechRecognizer.d.ts +31 -1
- package/controls/SpeechRecognizer/SpeechRecognizer.js +29 -1
- package/controls/SpeechRecognizer/index.d.ts +1 -1
- package/controls/SpeechRecognizer/index.js +1 -1
- package/controls/TabBar/Tab.d.ts +31 -1
- package/controls/TabBar/Tab.js +58 -1
- package/controls/TabBar/TabBar.d.ts +43 -5
- package/controls/TabBar/TabBar.js +82 -8
- package/controls/TabBar/index.d.ts +3 -1
- package/controls/TabBar/index.js +1 -1
- package/controls/TertiaryButton/TertiaryButton.d.ts +32 -7
- package/controls/TertiaryButton/TertiaryButton.js +60 -12
- package/controls/TertiaryButton/index.d.ts +2 -1
- package/controls/TertiaryButton/index.js +1 -1
- package/controls/ToggleButton/ToggleButton.d.ts +36 -3
- package/controls/ToggleButton/ToggleButton.js +69 -5
- package/controls/ToggleButton/index.d.ts +2 -1
- package/controls/ToggleButton/index.js +1 -1
- package/controls/View/View.d.ts +22 -8
- package/controls/View/View.js +40 -14
- package/controls/View/index.d.ts +2 -1
- package/controls/View/index.js +1 -1
- package/inputs/Dropdown/Dropdown.d.ts +2 -1
- package/inputs/Dropdown/index.d.ts +2 -1
- package/map/controls/CompassButton/CompassButton.d.ts +1 -1
- package/map/controls/FullscreenButton/FullscreenButton.d.ts +1 -1
- package/map/controls/ZoomInButton/ZoomInButton.d.ts +3 -2
- package/map/controls/ZoomOutButton/ZoomOutButton.d.ts +3 -2
- package/map/controls/base/MapButton/MapButton.d.ts +2 -1
- package/map/controls/base/MapButton/index.d.ts +2 -1
- package/map/layers/InterpolationLayer/ContoursFragmentShader.d.ts +1 -1
- package/map/layers/InterpolationLayer/ContoursFragmentShader.js +1 -1
- package/map/layers/InterpolationLayer/InterpolationLayer.d.ts +54 -5
- package/map/layers/InterpolationLayer/InterpolationLayer.js +52 -7
- package/map/layers/InterpolationLayer/index.d.ts +2 -1
- package/map/layers/InterpolationLayer/index.js +1 -1
- package/package.json +1 -1
- package/services/Toast/IToastMessage.d.ts +3 -3
- package/services/Toast/IToastProps.d.ts +1 -1
- package/services/Toast/Toast.d.ts +43 -5
- package/services/Toast/Toast.js +35 -4
- package/services/Toast/ToastContainer.d.ts +37 -4
- package/services/Toast/ToastContainer.js +75 -9
- package/services/Toast/ToastContext.d.ts +5 -4
- package/services/Toast/ToastProvider.js +16 -11
- package/services/Toast/useToast.d.ts +37 -1
- package/services/Toast/useToast.js +42 -2
|
@@ -58,7 +58,7 @@ var InterpolationLayerBase = function (props) {
|
|
|
58
58
|
// Do this by varying its `key` with the current time.
|
|
59
59
|
React.useEffect(function () {
|
|
60
60
|
setTime(Date.now());
|
|
61
|
-
}, [props.levels, props.data, props.contourColor, props.gradientStops]);
|
|
61
|
+
}, [props.levels, props.data, props.contourColor, props.contourThickness, props.gradientStops]);
|
|
62
62
|
//
|
|
63
63
|
// Convert IPoint array to polygons.
|
|
64
64
|
//
|
|
@@ -257,6 +257,8 @@ var InterpolationLayerBase = function (props) {
|
|
|
257
257
|
gl.uniformMatrix4fv(gl.getUniformLocation(contoursProgram.current, 'u_matrix'), false, matrix);
|
|
258
258
|
// Pass in levels for contours:
|
|
259
259
|
gl.uniform1i(gl.getUniformLocation(contoursProgram.current, 'levels'), props.levels);
|
|
260
|
+
// Pass in contour thickness:
|
|
261
|
+
gl.uniform1f(gl.getUniformLocation(contoursProgram.current, 'u_contourThickness'), props.contourThickness);
|
|
260
262
|
// Pass in contours color:
|
|
261
263
|
var clr = colorToRGBA(props.contourColor);
|
|
262
264
|
gl.uniform4f(gl.getUniformLocation(contoursProgram.current, 'u_contourColor'), clr[0], clr[1], clr[2], clr[3]);
|
|
@@ -320,16 +322,59 @@ var InterpolationLayerBase = function (props) {
|
|
|
320
322
|
return (React.createElement(Layer, { id: null, type: "custom", beforeId: "overlay", key: time, onAdd: onAddLayer, render: function (gl, matrix) { return onRender(gl, matrix, map.current.getZoom(), map.current.getContainer().clientWidth, map.current.getContainer().clientHeight); } }));
|
|
321
323
|
};
|
|
322
324
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
325
|
+
* A custom WebGL map layer that renders interpolated data with optional contour lines.
|
|
326
|
+
*
|
|
327
|
+
* Takes an array of geographic points with values and creates a smooth, gradient-filled
|
|
328
|
+
* triangulated surface using Delaunay triangulation via Turf.js.
|
|
329
|
+
*
|
|
330
|
+
* ## Usage
|
|
331
|
+
*
|
|
332
|
+
* ```tsx
|
|
333
|
+
* <Map>
|
|
334
|
+
* <InterpolationLayer
|
|
335
|
+
* data={[
|
|
336
|
+
* { latitude: 40.7, longitude: -74.0, value: 25 },
|
|
337
|
+
* { latitude: 40.8, longitude: -73.9, value: 30 },
|
|
338
|
+
* // ...more points
|
|
339
|
+
* ]}
|
|
340
|
+
* gradientStops={[
|
|
341
|
+
* { pos: 0.0, color: '#0000ff' },
|
|
342
|
+
* { pos: 0.5, color: '#00ff00' },
|
|
343
|
+
* { pos: 1.0, color: '#ff0000' }
|
|
344
|
+
* ]}
|
|
345
|
+
* levels={16}
|
|
346
|
+
* contourColor="#ffffff"
|
|
347
|
+
* />
|
|
348
|
+
* </Map>
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
351
|
+
* ## Rendering Pipeline
|
|
352
|
+
*
|
|
353
|
+
* Uses a two-pass WebGL rendering approach:
|
|
354
|
+
*
|
|
355
|
+
* 1. **Pass 1 (off-screen):** Renders triangulated data to a 1024×1024 texture
|
|
356
|
+
* as grayscale values (normalized 0-1)
|
|
357
|
+
* 2. **Pass 2 (on-screen):** Reads the texture, applies gradient colors, and
|
|
358
|
+
* optionally draws contour lines by detecting edges between shade levels
|
|
359
|
+
*
|
|
360
|
+
* ## Contour Detection
|
|
361
|
+
*
|
|
362
|
+
* Contour lines are drawn where adjacent pixels have different "shade levels".
|
|
363
|
+
* The `levels` prop controls quantization—higher values produce more contour lines.
|
|
364
|
+
* Set `levels={0}` to disable contour lines entirely.
|
|
365
|
+
*
|
|
366
|
+
* ## Data Requirements
|
|
367
|
+
*
|
|
368
|
+
* - Minimum 3 points required for triangulation
|
|
369
|
+
* - Points with `NaN` values are filtered out
|
|
370
|
+
* - Values are automatically normalized to 0-1 range
|
|
326
371
|
*/
|
|
327
372
|
var InterpolationLayer = function (_a) {
|
|
328
|
-
var _b = _a.levels, levels = _b === void 0 ? 0 : _b, _c = _a.contourColor, contourColor = _c === void 0 ? '#35ABE2' : _c, _d = _a.gradientStops, gradientStops =
|
|
373
|
+
var _b = _a.levels, levels = _b === void 0 ? 0 : _b, _c = _a.contourColor, contourColor = _c === void 0 ? '#35ABE2' : _c, _d = _a.contourThickness, contourThickness = _d === void 0 ? 1 : _d, _e = _a.gradientStops, gradientStops = _e === void 0 ? [
|
|
329
374
|
{ pos: 0.0, color: '#0000ffff' },
|
|
330
375
|
{ pos: 1.0, color: '#000000ff' }
|
|
331
|
-
] :
|
|
332
|
-
return React.createElement(InterpolationLayerBase, __assign({ levels: levels, contourColor: contourColor, gradientStops: gradientStops, minZoom: minZoom, maxZoom: maxZoom, dots: dots }, props));
|
|
376
|
+
] : _e, _f = _a.minZoom, minZoom = _f === void 0 ? 0 : _f, _g = _a.maxZoom, maxZoom = _g === void 0 ? 99 : _g, _h = _a.dots, dots = _h === void 0 ? false : _h, props = __rest(_a, ["levels", "contourColor", "contourThickness", "gradientStops", "minZoom", "maxZoom", "dots"]);
|
|
377
|
+
return React.createElement(InterpolationLayerBase, __assign({ levels: levels, contourColor: contourColor, contourThickness: contourThickness, gradientStops: gradientStops, minZoom: minZoom, maxZoom: maxZoom, dots: dots }, props));
|
|
333
378
|
};
|
|
334
379
|
InterpolationLayer.displayName = 'InterpolationLayer';
|
|
335
380
|
export { InterpolationLayer };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { InterpolationLayer } from './InterpolationLayer';
|
|
2
|
+
export type { IInterpolationLayerProps } from './InterpolationLayer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { InterpolationLayer } from './InterpolationLayer';
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IToastProps } from "./IToastProps";
|
|
1
|
+
import type { IToastProps } from "./IToastProps";
|
|
2
2
|
/**
|
|
3
3
|
* A ToastMessage is a message with a duration, displayed as a Toast in
|
|
4
4
|
* a ToastContainer.
|
|
5
5
|
*/
|
|
6
6
|
interface IToastMessage {
|
|
7
7
|
message: React.ReactNode;
|
|
8
|
-
options
|
|
8
|
+
options?: IToastProps;
|
|
9
9
|
}
|
|
10
|
-
export { IToastMessage };
|
|
10
|
+
export type { IToastMessage };
|
|
@@ -1,21 +1,59 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IToastProps } from './IToastProps';
|
|
2
|
+
import type { IToastProps } from './IToastProps';
|
|
3
3
|
interface IProps {
|
|
4
4
|
/** @ignore */
|
|
5
5
|
className?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Message shown in the Toast. This can be a simple string or JSX.
|
|
8
|
+
*/
|
|
6
9
|
message: React.ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Called when the Toast self-closes due to a timeout, or when the user
|
|
12
|
+
* dismisses the Toast.
|
|
13
|
+
*/
|
|
7
14
|
onClose: () => void;
|
|
8
15
|
}
|
|
9
16
|
/**
|
|
10
|
-
* A
|
|
17
|
+
* A brief notification message that appears temporarily to provide feedback to the user.
|
|
11
18
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
19
|
+
* Toasts are typically created through the `useToast` hook rather than being rendered directly.
|
|
20
|
+
* They automatically disappear after a configurable duration, or can be manually dismissed
|
|
21
|
+
* by the user if `dismissable` is enabled.
|
|
22
|
+
*
|
|
23
|
+
* ## Usage
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* const { toast } = useToast();
|
|
27
|
+
*
|
|
28
|
+
* // Simple toast
|
|
29
|
+
* toast("Changes saved successfully");
|
|
30
|
+
*
|
|
31
|
+
* // Toast with options
|
|
32
|
+
* toast("File uploaded", {
|
|
15
33
|
* duration: 5000,
|
|
16
34
|
* dismissable: true
|
|
17
35
|
* });
|
|
36
|
+
*
|
|
37
|
+
* // Toast with action button
|
|
38
|
+
* toast("Item deleted", {
|
|
39
|
+
* action: () => undoDelete(),
|
|
40
|
+
* actionLabel: "Undo"
|
|
41
|
+
* });
|
|
18
42
|
* ```
|
|
43
|
+
*
|
|
44
|
+
* ## Toast Options
|
|
45
|
+
*
|
|
46
|
+
* | Option | Type | Default | Description |
|
|
47
|
+
* |--------|------|---------|-------------|
|
|
48
|
+
* | `duration` | `number` | `8000` | Auto-dismiss delay in ms. Set to `0` for persistent toast. |
|
|
49
|
+
* | `dismissable` | `boolean` | `false` | Show close button for manual dismissal |
|
|
50
|
+
* | `action` | `function` | - | Callback for action button click |
|
|
51
|
+
* | `actionLabel` | `ReactNode` | `"Action"` | Label for the action button |
|
|
52
|
+
*
|
|
53
|
+
* ## Animation
|
|
54
|
+
*
|
|
55
|
+
* Toasts fade in when appearing and fade out when dismissed or timed out.
|
|
56
|
+
* The animation duration is derived from the theme's animation settings.
|
|
19
57
|
*/
|
|
20
58
|
declare const Toast: {
|
|
21
59
|
({ duration, dismissable, actionLabel, ...props }: IProps & IToastProps): React.JSX.Element;
|
package/services/Toast/Toast.js
CHANGED
|
@@ -76,15 +76,46 @@ var CloseButton = styled.div(templateObject_2 || (templateObject_2 = __makeTempl
|
|
|
76
76
|
var Action = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n padding-left: 8px;\n color: ", ";\n cursor: pointer;\n white-space: nowrap;\n font: ", ";\n text-transform: uppercase;\n transition: color ease-in-out ", "ms;\n &:hover {\n color: ", ";\n }\n &:last-child {\n padding-right: 16px;\n }\n"], ["\n display: flex;\n align-items: center;\n padding-left: 8px;\n color: ", ";\n cursor: pointer;\n white-space: nowrap;\n font: ", ";\n text-transform: uppercase;\n transition: color ease-in-out ", "ms;\n &:hover {\n color: ", ";\n }\n &:last-child {\n padding-right: 16px;\n }\n"])), function (p) { return p.theme.colors.primary[4]; }, function (p) { return p.theme.font.labelCaps; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.theme.colors.primary[2]; });
|
|
77
77
|
var ToastStyled = styled(ToastBase)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n // Position and size:\n display: flex;\n width: 344px;\n box-sizing: border-box;\n align-items: stretch;\n justify-content: space-between;\n user-select: none;\n pointer-events: all;\n\n // Space between toasts:\n margin: 8px 0 8px 0; \n\n // Appearance:\n padding: 14px 0 14px 0;\n background-color: ", ";\n color: #fff;\n border-radius: ", "px;\n font: ", ";\n\n // Content:\n a {\n color: ", " !important;\n }\n\n /* useTransitionState classes */\n transition: opacity ", "ms ease;\n &.preEnter, &.exiting, &.unmounted {\n opacity: 0;\n }\n &.entering {\n opacity: 1;\n }\n &.entered {\n opacity: 1;\n }\n\n"], ["\n // Position and size:\n display: flex;\n width: 344px;\n box-sizing: border-box;\n align-items: stretch;\n justify-content: space-between;\n user-select: none;\n pointer-events: all;\n\n // Space between toasts:\n margin: 8px 0 8px 0; \n\n // Appearance:\n padding: 14px 0 14px 0;\n background-color: ", ";\n color: #fff;\n border-radius: ", "px;\n font: ", ";\n\n // Content:\n a {\n color: ", " !important;\n }\n\n /* useTransitionState classes */\n transition: opacity ", "ms ease;\n &.preEnter, &.exiting, &.unmounted {\n opacity: 0;\n }\n &.entering {\n opacity: 1;\n }\n &.entered {\n opacity: 1;\n }\n\n"])), function (p) { return p.theme.colors.primary[1]; }, function (p) { return p.theme.radius.normal; }, function (p) { return p.theme.font.bodyMedium; }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return p.theme.animation.duration * 2; });
|
|
78
78
|
/**
|
|
79
|
-
* A
|
|
79
|
+
* A brief notification message that appears temporarily to provide feedback to the user.
|
|
80
80
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
81
|
+
* Toasts are typically created through the `useToast` hook rather than being rendered directly.
|
|
82
|
+
* They automatically disappear after a configurable duration, or can be manually dismissed
|
|
83
|
+
* by the user if `dismissable` is enabled.
|
|
84
|
+
*
|
|
85
|
+
* ## Usage
|
|
86
|
+
*
|
|
87
|
+
* ```tsx
|
|
88
|
+
* const { toast } = useToast();
|
|
89
|
+
*
|
|
90
|
+
* // Simple toast
|
|
91
|
+
* toast("Changes saved successfully");
|
|
92
|
+
*
|
|
93
|
+
* // Toast with options
|
|
94
|
+
* toast("File uploaded", {
|
|
84
95
|
* duration: 5000,
|
|
85
96
|
* dismissable: true
|
|
86
97
|
* });
|
|
98
|
+
*
|
|
99
|
+
* // Toast with action button
|
|
100
|
+
* toast("Item deleted", {
|
|
101
|
+
* action: () => undoDelete(),
|
|
102
|
+
* actionLabel: "Undo"
|
|
103
|
+
* });
|
|
87
104
|
* ```
|
|
105
|
+
*
|
|
106
|
+
* ## Toast Options
|
|
107
|
+
*
|
|
108
|
+
* | Option | Type | Default | Description |
|
|
109
|
+
* |--------|------|---------|-------------|
|
|
110
|
+
* | `duration` | `number` | `8000` | Auto-dismiss delay in ms. Set to `0` for persistent toast. |
|
|
111
|
+
* | `dismissable` | `boolean` | `false` | Show close button for manual dismissal |
|
|
112
|
+
* | `action` | `function` | - | Callback for action button click |
|
|
113
|
+
* | `actionLabel` | `ReactNode` | `"Action"` | Label for the action button |
|
|
114
|
+
*
|
|
115
|
+
* ## Animation
|
|
116
|
+
*
|
|
117
|
+
* Toasts fade in when appearing and fade out when dismissed or timed out.
|
|
118
|
+
* The animation duration is derived from the theme's animation settings.
|
|
88
119
|
*/
|
|
89
120
|
var Toast = function (_a) {
|
|
90
121
|
var _b = _a.duration, duration = _b === void 0 ? 8000 : _b, _c = _a.dismissable, dismissable = _c === void 0 ? false : _c, _d = _a.actionLabel, actionLabel = _d === void 0 ? "Action" : _d, props = __rest(_a, ["duration", "dismissable", "actionLabel"]);
|
|
@@ -30,11 +30,44 @@ interface IToastContainerProps {
|
|
|
30
30
|
verticalOffset?: number;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* A
|
|
34
|
-
* which is a context that must wrap the ToastContainer.
|
|
33
|
+
* A container that renders and positions all active toasts from the `ToastProvider` context.
|
|
35
34
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* The `ToastContainer` must be placed inside a `ToastProvider`. It automatically subscribes
|
|
36
|
+
* to the toast context and renders any active toasts. The container itself is invisible and
|
|
37
|
+
* does not capture pointer events, but individual toasts within it do.
|
|
38
|
+
*
|
|
39
|
+
* ## Usage
|
|
40
|
+
*
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <ToastProvider>
|
|
43
|
+
* <App />
|
|
44
|
+
* <ToastContainer
|
|
45
|
+
* verticalAlign="bottom"
|
|
46
|
+
* horizontalAlign="right"
|
|
47
|
+
* />
|
|
48
|
+
* </ToastProvider>
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* ## Positioning
|
|
52
|
+
*
|
|
53
|
+
* Toasts can be positioned in any corner or centered horizontally:
|
|
54
|
+
*
|
|
55
|
+
* | Position | Props |
|
|
56
|
+
* |----------|-------|
|
|
57
|
+
* | Bottom-left | `verticalAlign="bottom" horizontalAlign="left"` (default) |
|
|
58
|
+
* | Bottom-right | `verticalAlign="bottom" horizontalAlign="right"` |
|
|
59
|
+
* | Bottom-center | `verticalAlign="bottom" horizontalAlign="center"` |
|
|
60
|
+
* | Top-left | `verticalAlign="top" horizontalAlign="left"` |
|
|
61
|
+
* | Top-right | `verticalAlign="top" horizontalAlign="right"` |
|
|
62
|
+
* | Top-center | `verticalAlign="top" horizontalAlign="center"` |
|
|
63
|
+
*
|
|
64
|
+
* Use `horizontalOffset` and `verticalOffset` to add padding from the edges.
|
|
65
|
+
*
|
|
66
|
+
* ## Stacking
|
|
67
|
+
*
|
|
68
|
+
* When multiple toasts are active, they stack vertically. With `verticalAlign="bottom"`,
|
|
69
|
+
* newer toasts appear above older ones. With `verticalAlign="top"`, newer toasts
|
|
70
|
+
* appear below older ones.
|
|
38
71
|
*/
|
|
39
72
|
declare const ToastContainer: {
|
|
40
73
|
({ horizontalOffset, verticalOffset, verticalAlign, horizontalAlign, ...props }: IToastContainerProps): React.JSX.Element;
|
|
@@ -40,19 +40,85 @@ var ToastContainerBase = function (props) {
|
|
|
40
40
|
};
|
|
41
41
|
var ToastContainerStyled = styled(ToastContainerBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n // Position:\n // ToastContainer occupies all area that it can, but captures no pointer events.\n // Toast children do capture pointer events.\n position: absolute;\n z-index: 9999;\n top: ", "px;\n bottom: ", "px;\n left: ", "px;\n right: ", "px;\n pointer-events: none !important;\n // Toasts are placed using a flexbox:\n display: flex;\n flex-direction: ", ";\n align-items: ", ";\n justify-content: ", ";\n"], ["\n // Position:\n // ToastContainer occupies all area that it can, but captures no pointer events.\n // Toast children do capture pointer events.\n position: absolute;\n z-index: 9999;\n top: ", "px;\n bottom: ", "px;\n left: ", "px;\n right: ", "px;\n pointer-events: none !important;\n // Toasts are placed using a flexbox:\n display: flex;\n flex-direction: ", ";\n align-items: ", ";\n justify-content: ", ";\n"
|
|
42
42
|
/**
|
|
43
|
-
* A
|
|
44
|
-
* which is a context that must wrap the ToastContainer.
|
|
43
|
+
* A container that renders and positions all active toasts from the `ToastProvider` context.
|
|
45
44
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* The `ToastContainer` must be placed inside a `ToastProvider`. It automatically subscribes
|
|
46
|
+
* to the toast context and renders any active toasts. The container itself is invisible and
|
|
47
|
+
* does not capture pointer events, but individual toasts within it do.
|
|
48
|
+
*
|
|
49
|
+
* ## Usage
|
|
50
|
+
*
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <ToastProvider>
|
|
53
|
+
* <App />
|
|
54
|
+
* <ToastContainer
|
|
55
|
+
* verticalAlign="bottom"
|
|
56
|
+
* horizontalAlign="right"
|
|
57
|
+
* />
|
|
58
|
+
* </ToastProvider>
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* ## Positioning
|
|
62
|
+
*
|
|
63
|
+
* Toasts can be positioned in any corner or centered horizontally:
|
|
64
|
+
*
|
|
65
|
+
* | Position | Props |
|
|
66
|
+
* |----------|-------|
|
|
67
|
+
* | Bottom-left | `verticalAlign="bottom" horizontalAlign="left"` (default) |
|
|
68
|
+
* | Bottom-right | `verticalAlign="bottom" horizontalAlign="right"` |
|
|
69
|
+
* | Bottom-center | `verticalAlign="bottom" horizontalAlign="center"` |
|
|
70
|
+
* | Top-left | `verticalAlign="top" horizontalAlign="left"` |
|
|
71
|
+
* | Top-right | `verticalAlign="top" horizontalAlign="right"` |
|
|
72
|
+
* | Top-center | `verticalAlign="top" horizontalAlign="center"` |
|
|
73
|
+
*
|
|
74
|
+
* Use `horizontalOffset` and `verticalOffset` to add padding from the edges.
|
|
75
|
+
*
|
|
76
|
+
* ## Stacking
|
|
77
|
+
*
|
|
78
|
+
* When multiple toasts are active, they stack vertically. With `verticalAlign="bottom"`,
|
|
79
|
+
* newer toasts appear above older ones. With `verticalAlign="top"`, newer toasts
|
|
80
|
+
* appear below older ones.
|
|
48
81
|
*/
|
|
49
|
-
])), function (p) { return p.verticalAlign === 'top' ? p.verticalOffset : 0; }, function (p) { return p.verticalAlign === 'bottom' ? p.verticalOffset : 0; }, function (p) { return p.horizontalAlign === 'left' ? p.horizontalOffset : 0; }, function (p) { return p.horizontalAlign === 'right' ? p.horizontalOffset : 0; }, function (p) { return p.verticalAlign === 'top' ? 'column' : 'column-reverse'; }, function (p) { return p.horizontalAlign === 'left' ? 'start' : (p.horizontalAlign === 'right' ? 'end' : 'center'); }, function (p) { return p.verticalAlign
|
|
82
|
+
])), function (p) { return p.verticalAlign === 'top' ? p.verticalOffset : 0; }, function (p) { return p.verticalAlign === 'bottom' ? p.verticalOffset : 0; }, function (p) { return p.horizontalAlign === 'left' ? p.horizontalOffset : 0; }, function (p) { return p.horizontalAlign === 'right' ? p.horizontalOffset : 0; }, function (p) { return p.verticalAlign === 'top' ? 'column' : 'column-reverse'; }, function (p) { return p.horizontalAlign === 'left' ? 'start' : (p.horizontalAlign === 'right' ? 'end' : 'center'); }, function (p) { return p.verticalAlign === 'top' ? 'start' : 'end'; });
|
|
50
83
|
/**
|
|
51
|
-
* A
|
|
52
|
-
*
|
|
84
|
+
* A container that renders and positions all active toasts from the `ToastProvider` context.
|
|
85
|
+
*
|
|
86
|
+
* The `ToastContainer` must be placed inside a `ToastProvider`. It automatically subscribes
|
|
87
|
+
* to the toast context and renders any active toasts. The container itself is invisible and
|
|
88
|
+
* does not capture pointer events, but individual toasts within it do.
|
|
89
|
+
*
|
|
90
|
+
* ## Usage
|
|
91
|
+
*
|
|
92
|
+
* ```tsx
|
|
93
|
+
* <ToastProvider>
|
|
94
|
+
* <App />
|
|
95
|
+
* <ToastContainer
|
|
96
|
+
* verticalAlign="bottom"
|
|
97
|
+
* horizontalAlign="right"
|
|
98
|
+
* />
|
|
99
|
+
* </ToastProvider>
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* ## Positioning
|
|
103
|
+
*
|
|
104
|
+
* Toasts can be positioned in any corner or centered horizontally:
|
|
105
|
+
*
|
|
106
|
+
* | Position | Props |
|
|
107
|
+
* |----------|-------|
|
|
108
|
+
* | Bottom-left | `verticalAlign="bottom" horizontalAlign="left"` (default) |
|
|
109
|
+
* | Bottom-right | `verticalAlign="bottom" horizontalAlign="right"` |
|
|
110
|
+
* | Bottom-center | `verticalAlign="bottom" horizontalAlign="center"` |
|
|
111
|
+
* | Top-left | `verticalAlign="top" horizontalAlign="left"` |
|
|
112
|
+
* | Top-right | `verticalAlign="top" horizontalAlign="right"` |
|
|
113
|
+
* | Top-center | `verticalAlign="top" horizontalAlign="center"` |
|
|
114
|
+
*
|
|
115
|
+
* Use `horizontalOffset` and `verticalOffset` to add padding from the edges.
|
|
116
|
+
*
|
|
117
|
+
* ## Stacking
|
|
53
118
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
119
|
+
* When multiple toasts are active, they stack vertically. With `verticalAlign="bottom"`,
|
|
120
|
+
* newer toasts appear above older ones. With `verticalAlign="top"`, newer toasts
|
|
121
|
+
* appear below older ones.
|
|
56
122
|
*/
|
|
57
123
|
var ToastContainer = function (_a) {
|
|
58
124
|
var _b = _a.horizontalOffset, horizontalOffset = _b === void 0 ? 0 : _b, _c = _a.verticalOffset, verticalOffset = _c === void 0 ? 0 : _c, _d = _a.verticalAlign, verticalAlign = _d === void 0 ? 'bottom' : _d, _e = _a.horizontalAlign, horizontalAlign = _e === void 0 ? 'left' : _e, props = __rest(_a, ["horizontalOffset", "verticalOffset", "verticalAlign", "horizontalAlign"]);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IToastMessage } from './IToastMessage';
|
|
3
|
-
import { IToastProps } from './IToastProps';
|
|
2
|
+
import type { IToastMessage } from './IToastMessage';
|
|
3
|
+
import type { IToastProps } from './IToastProps';
|
|
4
4
|
interface IToastContext {
|
|
5
5
|
/**
|
|
6
6
|
* Creates a new `Toast`, with the React node for content. Optional
|
|
7
7
|
* properties can be provided.
|
|
8
8
|
*/
|
|
9
|
-
toast: (content: React.ReactNode, options
|
|
9
|
+
toast: (content: React.ReactNode, options?: IToastProps) => void;
|
|
10
10
|
/**
|
|
11
11
|
* Removes all toasts from the display.
|
|
12
12
|
*/
|
|
@@ -23,4 +23,5 @@ interface IToastContext {
|
|
|
23
23
|
remove: (key: string) => void;
|
|
24
24
|
}
|
|
25
25
|
declare const ToastContext: React.Context<IToastContext>;
|
|
26
|
-
export { ToastContext
|
|
26
|
+
export { ToastContext };
|
|
27
|
+
export type { IToastContext };
|
|
@@ -22,6 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import * as React from 'react';
|
|
24
24
|
import { ToastContext } from './ToastContext';
|
|
25
|
+
var toastCounter = 0;
|
|
25
26
|
/**
|
|
26
27
|
* The `ToastProvider` is a React context that wraps both components that
|
|
27
28
|
* generate toasts (through `useToast`) and the `ToastContainer` that displays
|
|
@@ -39,18 +40,22 @@ var ToastProvider = function (_a) {
|
|
|
39
40
|
* can be provided.
|
|
40
41
|
*/
|
|
41
42
|
var toast = function (content, options) {
|
|
42
|
-
setMessages(function (
|
|
43
|
+
setMessages(function (prevMessages) {
|
|
44
|
+
var _a;
|
|
45
|
+
var keys = Object.keys(prevMessages);
|
|
46
|
+
var newMessages = __assign({}, prevMessages);
|
|
43
47
|
// Remove excess messages:
|
|
44
|
-
while (
|
|
45
|
-
|
|
48
|
+
while (keys.length >= maxToasts) {
|
|
49
|
+
var oldestKey = keys.shift();
|
|
50
|
+
var _b = newMessages, _c = oldestKey, _ = _b[_c], rest = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
|
|
51
|
+
newMessages = rest;
|
|
46
52
|
}
|
|
47
|
-
// Create new message:
|
|
48
|
-
var key =
|
|
49
|
-
|
|
53
|
+
// Create new message with unique key:
|
|
54
|
+
var key = "toast-".concat(++toastCounter);
|
|
55
|
+
return __assign(__assign({}, newMessages), (_a = {}, _a[key] = {
|
|
50
56
|
message: content,
|
|
51
57
|
options: options
|
|
52
|
-
};
|
|
53
|
-
return __assign({}, messages);
|
|
58
|
+
}, _a));
|
|
54
59
|
});
|
|
55
60
|
};
|
|
56
61
|
/**
|
|
@@ -63,9 +68,9 @@ var ToastProvider = function (_a) {
|
|
|
63
68
|
* Remove a toast from the display list by key.
|
|
64
69
|
*/
|
|
65
70
|
var remove = function (key) {
|
|
66
|
-
setMessages(function (
|
|
67
|
-
|
|
68
|
-
return
|
|
71
|
+
setMessages(function (prevMessages) {
|
|
72
|
+
var _a = prevMessages, _b = key, _ = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
73
|
+
return rest;
|
|
69
74
|
});
|
|
70
75
|
};
|
|
71
76
|
return (React.createElement(ToastContext.Provider, { value: { toast: toast, messages: messages, clear: clear, remove: remove } }, props.children));
|
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* A hook that provides access to the toast notification system.
|
|
3
|
+
*
|
|
4
|
+
* Must be used within a `ToastProvider`. Returns an object with methods to create,
|
|
5
|
+
* remove, and manage toast notifications.
|
|
6
|
+
*
|
|
7
|
+
* ## Usage
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const { toast, clear, remove, messages } = useToast();
|
|
11
|
+
*
|
|
12
|
+
* // Show a simple toast
|
|
13
|
+
* toast("Operation completed");
|
|
14
|
+
*
|
|
15
|
+
* // Show a toast with options
|
|
16
|
+
* toast("File saved", { duration: 3000, dismissable: true });
|
|
17
|
+
*
|
|
18
|
+
* // Show a toast with an action
|
|
19
|
+
* toast("Email sent", {
|
|
20
|
+
* action: () => openEmail(),
|
|
21
|
+
* actionLabel: "View"
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Clear all toasts
|
|
25
|
+
* clear();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## Returned Object
|
|
29
|
+
*
|
|
30
|
+
* | Property | Type | Description |
|
|
31
|
+
* |----------|------|-------------|
|
|
32
|
+
* | `toast` | `(content, options?) => void` | Create a new toast notification |
|
|
33
|
+
* | `clear` | `() => void` | Remove all active toasts |
|
|
34
|
+
* | `remove` | `(key) => void` | Remove a specific toast by key |
|
|
35
|
+
* | `messages` | `object` | Current active toasts (for advanced use) |
|
|
36
|
+
*
|
|
37
|
+
* @throws Error if called outside of a `ToastProvider`
|
|
38
|
+
* @returns The toast context with methods to manage notifications
|
|
3
39
|
*/
|
|
4
40
|
declare const useToast: () => import("./ToastContext").IToastContext;
|
|
5
41
|
export { useToast };
|
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ToastContext } from './ToastContext';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* A hook that provides access to the toast notification system.
|
|
5
|
+
*
|
|
6
|
+
* Must be used within a `ToastProvider`. Returns an object with methods to create,
|
|
7
|
+
* remove, and manage toast notifications.
|
|
8
|
+
*
|
|
9
|
+
* ## Usage
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const { toast, clear, remove, messages } = useToast();
|
|
13
|
+
*
|
|
14
|
+
* // Show a simple toast
|
|
15
|
+
* toast("Operation completed");
|
|
16
|
+
*
|
|
17
|
+
* // Show a toast with options
|
|
18
|
+
* toast("File saved", { duration: 3000, dismissable: true });
|
|
19
|
+
*
|
|
20
|
+
* // Show a toast with an action
|
|
21
|
+
* toast("Email sent", {
|
|
22
|
+
* action: () => openEmail(),
|
|
23
|
+
* actionLabel: "View"
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Clear all toasts
|
|
27
|
+
* clear();
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ## Returned Object
|
|
31
|
+
*
|
|
32
|
+
* | Property | Type | Description |
|
|
33
|
+
* |----------|------|-------------|
|
|
34
|
+
* | `toast` | `(content, options?) => void` | Create a new toast notification |
|
|
35
|
+
* | `clear` | `() => void` | Remove all active toasts |
|
|
36
|
+
* | `remove` | `(key) => void` | Remove a specific toast by key |
|
|
37
|
+
* | `messages` | `object` | Current active toasts (for advanced use) |
|
|
38
|
+
*
|
|
39
|
+
* @throws Error if called outside of a `ToastProvider`
|
|
40
|
+
* @returns The toast context with methods to manage notifications
|
|
5
41
|
*/
|
|
6
42
|
var useToast = function () {
|
|
7
|
-
|
|
43
|
+
var context = React.useContext(ToastContext);
|
|
44
|
+
if (context === null) {
|
|
45
|
+
throw new Error('useToast must be used within a ToastProvider');
|
|
46
|
+
}
|
|
47
|
+
return context;
|
|
8
48
|
};
|
|
9
49
|
export { useToast };
|