@galaxy-io/dls 1.1.2 → 1.2.0
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/accordion/Accordion.js +1 -1
- package/dist/chips/Chip.js +3 -3
- package/dist/containers/FlexItem.d.ts +20 -0
- package/dist/containers/FlexItem.js +10 -16
- package/dist/containers/FlexWrapper.d.ts +16 -0
- package/dist/containers/FlexWrapper.js +23 -14
- package/dist/inputs/CheckboxInput.js +2 -2
- package/dist/inputs/ColorInput.js +1 -1
- package/dist/inputs/CopyInput.js +1 -1
- package/dist/inputs/DateInput.js +1 -1
- package/dist/inputs/Input.js +2 -2
- package/dist/inputs/MultiSelectInput.js +1 -1
- package/dist/inputs/RadioInput.js +1 -1
- package/dist/inputs/SelectInput.js +1 -1
- package/dist/inputs/TextAreaInput.js +1 -1
- package/dist/spreadsheet/InfiniteSpreadsheet.js +1 -1
- package/dist/spreadsheet/SpreadsheetHeaderCell.js +1 -1
- package/dist/spreadsheet/SpreadsheetRowActionCell.js +1 -1
- package/dist/styles.css +3 -1
- package/dist/toast/Toast.d.ts +18 -0
- package/dist/toast/Toast.js +103 -0
- package/dist/toast/ToastContainer.d.ts +10 -0
- package/dist/toast/ToastContainer.js +31 -0
- package/dist/toast/ToastProvider.d.ts +16 -0
- package/dist/toast/ToastProvider.js +111 -0
- package/dist/toast/ToastWrapper.d.ts +6 -0
- package/dist/toast/ToastWrapper.js +27 -0
- package/dist/toast/useToast.d.ts +1 -0
- package/dist/toast/useToast.js +10 -0
- package/package.json +5 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
3
3
|
import Text, { TextSize, TextVariant, TextWeight } from "../text/Text.js";
|
|
4
|
-
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
5
4
|
import FlexItem from "../containers/FlexItem.js";
|
|
6
5
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
6
|
+
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
7
|
import RotateWithTransition from "../animations/RotateWithTransition.js";
|
|
8
8
|
import HorizontalDivider from "../dividers/HorizontalDivider.js";
|
|
9
9
|
/* empty css */
|
package/dist/chips/Chip.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
3
|
-
import TextShimmer from "../text/TextShimmer.js";
|
|
4
|
-
import Ellipsis from "../text/Ellipsis.js";
|
|
5
|
-
import FlexWrapper from "../containers/FlexWrapper.js";
|
|
6
3
|
import FlexItem from "../containers/FlexItem.js";
|
|
7
4
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
5
|
+
import FlexWrapper from "../containers/FlexWrapper.js";
|
|
6
|
+
import TextShimmer from "../text/TextShimmer.js";
|
|
7
|
+
import Ellipsis from "../text/Ellipsis.js";
|
|
8
8
|
import AvatarShimmer from "../avatar/AvatarShimmer.js";
|
|
9
9
|
/* empty css */
|
|
10
10
|
import { styled } from "@linaria/react";
|
|
@@ -2,8 +2,19 @@ import { type CSSProperties } from "react";
|
|
|
2
2
|
import { AlignItems, JustifyContent } from "./FlexWrapper";
|
|
3
3
|
interface FlexItemProps {
|
|
4
4
|
position?: CSSProperties["position"];
|
|
5
|
+
/**
|
|
6
|
+
* flex-grow of this item within its parent flex container.
|
|
7
|
+
* Defaults to 0 (content-sized), matching the CSS default.
|
|
8
|
+
*/
|
|
5
9
|
grow?: number;
|
|
10
|
+
/**
|
|
11
|
+
* flex-shrink of this item within its parent flex container.
|
|
12
|
+
* Defaults to 1, matching the CSS default.
|
|
13
|
+
*/
|
|
6
14
|
shrink?: number;
|
|
15
|
+
/**
|
|
16
|
+
* flex-basis of this item. Defaults to auto.
|
|
17
|
+
*/
|
|
7
18
|
basis?: number | string;
|
|
8
19
|
overflow?: CSSProperties["overflow"];
|
|
9
20
|
whiteSpace?: CSSProperties["whiteSpace"];
|
|
@@ -12,9 +23,18 @@ interface FlexItemProps {
|
|
|
12
23
|
height?: number | string;
|
|
13
24
|
fillWidth?: boolean;
|
|
14
25
|
fillHeight?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Defaults to "flex" (not "block"): a FlexItem is itself a flex container,
|
|
28
|
+
* which sidesteps inline-baseline gaps around svg/icon children and makes
|
|
29
|
+
* alignItems/justifyContent work without extra props.
|
|
30
|
+
*/
|
|
15
31
|
display?: CSSProperties["display"];
|
|
16
32
|
alignItems?: AlignItems;
|
|
17
33
|
justifyContent?: JustifyContent;
|
|
34
|
+
/**
|
|
35
|
+
* Accepts 0 explicitly - `minWidth={0}` is the standard way to let a flex
|
|
36
|
+
* child shrink below its content size so nested text can ellipsize.
|
|
37
|
+
*/
|
|
18
38
|
minWidth?: number | string;
|
|
19
39
|
minHeight?: number | string;
|
|
20
40
|
maxWidth?: number | string;
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
2
|
-
import { AlignItems, JustifyContent } from "./FlexWrapper.js";
|
|
3
2
|
/* empty css */
|
|
4
3
|
import { styled } from "@linaria/react";
|
|
5
|
-
import { match } from "ts-pattern";
|
|
6
4
|
import { forwardRef } from "react";
|
|
7
5
|
import { jsx } from "react/jsx-runtime";
|
|
8
6
|
//#region src/containers/FlexItem.tsx
|
|
9
7
|
var _exp = () => ({ $position }) => $position ?? "static";
|
|
10
8
|
var _exp2 = () => ({ $display }) => $display ?? "flex";
|
|
11
|
-
var _exp3 = () => ({ $alignItems }) =>
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
var _exp4 = () => ({ $justifyContent }) => {
|
|
15
|
-
return match($justifyContent).with(JustifyContent.START, () => "flex-start").with(JustifyContent.CENTER, () => "center").with(JustifyContent.END, () => "flex-end").otherwise(() => "flex-start");
|
|
16
|
-
};
|
|
17
|
-
var _exp5 = () => ({ $grow }) => $grow ?? 1;
|
|
9
|
+
var _exp3 = () => ({ $alignItems }) => $alignItems ?? "inherit";
|
|
10
|
+
var _exp4 = () => ({ $justifyContent }) => $justifyContent ?? "flex-start";
|
|
11
|
+
var _exp5 = () => ({ $grow }) => $grow ?? 0;
|
|
18
12
|
var _exp6 = () => ({ $shrink }) => $shrink ?? 1;
|
|
19
|
-
var _exp7 = () => ({ $basis }) => $basis
|
|
13
|
+
var _exp7 = () => ({ $basis }) => $basis != null ? getCssSizeValue($basis) : "auto";
|
|
20
14
|
var _exp8 = () => ({ $width, $fillWidth }) => {
|
|
21
15
|
if ($fillWidth) return "100%";
|
|
22
|
-
if ($width) return getCssSizeValue($width, "0");
|
|
16
|
+
if ($width != null) return getCssSizeValue($width, "0");
|
|
23
17
|
return "auto";
|
|
24
18
|
};
|
|
25
19
|
var _exp9 = () => ({ $height, $fillHeight }) => {
|
|
26
20
|
if ($fillHeight) return "100%";
|
|
27
|
-
if ($height) return getCssSizeValue($height);
|
|
21
|
+
if ($height != null) return getCssSizeValue($height);
|
|
28
22
|
return "auto";
|
|
29
23
|
};
|
|
30
|
-
var _exp0 = () => ({ $minWidth }) => $minWidth ? getCssSizeValue($minWidth) : "auto";
|
|
31
|
-
var _exp1 = () => ({ $maxWidth }) => $maxWidth ? getCssSizeValue($maxWidth) : "none";
|
|
32
|
-
var _exp10 = () => ({ $minHeight }) => $minHeight ? getCssSizeValue($minHeight) : "auto";
|
|
33
|
-
var _exp11 = () => ({ $maxHeight }) => $maxHeight ? getCssSizeValue($maxHeight) : "none";
|
|
24
|
+
var _exp0 = () => ({ $minWidth }) => $minWidth != null ? getCssSizeValue($minWidth) : "auto";
|
|
25
|
+
var _exp1 = () => ({ $maxWidth }) => $maxWidth != null ? getCssSizeValue($maxWidth) : "none";
|
|
26
|
+
var _exp10 = () => ({ $minHeight }) => $minHeight != null ? getCssSizeValue($minHeight) : "auto";
|
|
27
|
+
var _exp11 = () => ({ $maxHeight }) => $maxHeight != null ? getCssSizeValue($maxHeight) : "none";
|
|
34
28
|
var _exp12 = () => ({ $overflow }) => $overflow ?? "visible";
|
|
35
29
|
var _exp13 = () => ({ $whiteSpace }) => $whiteSpace ?? "normal";
|
|
36
30
|
var _exp14 = () => ({ $textOverflow }) => $textOverflow ?? "clip";
|
|
@@ -73,6 +73,22 @@ interface FlexWrapperProps {
|
|
|
73
73
|
* Sets the gap between flex items in pixels or string (for other units)
|
|
74
74
|
*/
|
|
75
75
|
gap?: number | string;
|
|
76
|
+
/**
|
|
77
|
+
* flex-grow of this wrapper when it is itself a child of a flex container.
|
|
78
|
+
* Defaults to the CSS initial value (0). Saves wrapping in a FlexItem just
|
|
79
|
+
* to control how the wrapper flexes.
|
|
80
|
+
*/
|
|
81
|
+
grow?: number;
|
|
82
|
+
/**
|
|
83
|
+
* flex-shrink of this wrapper when it is itself a child of a flex container.
|
|
84
|
+
* Defaults to the CSS initial value (1).
|
|
85
|
+
*/
|
|
86
|
+
shrink?: number;
|
|
87
|
+
/**
|
|
88
|
+
* flex-basis of this wrapper when it is itself a child of a flex container.
|
|
89
|
+
* Defaults to the CSS initial value (auto).
|
|
90
|
+
*/
|
|
91
|
+
basis?: number | string;
|
|
76
92
|
/**
|
|
77
93
|
* Sets the width of the flex container in pixels
|
|
78
94
|
*/
|
|
@@ -50,24 +50,27 @@ var _exp2 = () => ({ alignItems = "start" }) => alignItems;
|
|
|
50
50
|
var _exp3 = () => ({ justifyContent = "start" }) => justifyContent;
|
|
51
51
|
var _exp4 = () => ({ gap }) => getCssSizeValue(gap);
|
|
52
52
|
var _exp5 = () => ({ wrap = "nowrap" }) => wrap;
|
|
53
|
-
var _exp6 = () => ({
|
|
53
|
+
var _exp6 = () => ({ grow }) => grow ?? "initial";
|
|
54
|
+
var _exp7 = () => ({ shrink }) => shrink ?? "initial";
|
|
55
|
+
var _exp8 = () => ({ basis }) => basis != null ? getCssSizeValue(basis) : "initial";
|
|
56
|
+
var _exp9 = () => ({ width, fillWidth }) => {
|
|
54
57
|
if (fillWidth) return "100%";
|
|
55
|
-
if (width) return getCssSizeValue(width, "0");
|
|
58
|
+
if (width != null) return getCssSizeValue(width, "0");
|
|
56
59
|
return "auto";
|
|
57
60
|
};
|
|
58
|
-
var
|
|
61
|
+
var _exp0 = () => ({ height, fillHeight }) => {
|
|
59
62
|
if (fillHeight) return "100%";
|
|
60
|
-
if (height) return getCssSizeValue(height);
|
|
63
|
+
if (height != null) return getCssSizeValue(height);
|
|
61
64
|
return "auto";
|
|
62
65
|
};
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
var
|
|
66
|
+
var _exp1 = () => ({ minWidth }) => minWidth != null ? getCssSizeValue(minWidth) : "auto";
|
|
67
|
+
var _exp10 = () => ({ maxWidth }) => maxWidth != null ? getCssSizeValue(maxWidth) : "none";
|
|
68
|
+
var _exp11 = () => ({ minHeight }) => minHeight != null ? getCssSizeValue(minHeight) : "auto";
|
|
69
|
+
var _exp12 = () => ({ maxHeight }) => maxHeight != null ? getCssSizeValue(maxHeight) : "none";
|
|
70
|
+
var _exp13 = () => ({ overflow = "visible" }) => overflow;
|
|
71
|
+
var _exp14 = () => ({ padding = "0" }) => padding;
|
|
72
|
+
var _exp15 = () => ({ margin = "0" }) => margin;
|
|
73
|
+
var _exp16 = () => ({ onClick }) => onClick ? "pointer" : "inherit";
|
|
71
74
|
var StyledFlexWrapper = /*#__PURE__*/ styled("div")({
|
|
72
75
|
name: "StyledFlexWrapper",
|
|
73
76
|
class: "s12krdms",
|
|
@@ -87,10 +90,13 @@ var StyledFlexWrapper = /*#__PURE__*/ styled("div")({
|
|
|
87
90
|
"s12krdms-11": [_exp10()],
|
|
88
91
|
"s12krdms-12": [_exp11()],
|
|
89
92
|
"s12krdms-13": [_exp12()],
|
|
90
|
-
"s12krdms-14": [_exp13()]
|
|
93
|
+
"s12krdms-14": [_exp13()],
|
|
94
|
+
"s12krdms-15": [_exp14()],
|
|
95
|
+
"s12krdms-16": [_exp15()],
|
|
96
|
+
"s12krdms-17": [_exp16()]
|
|
91
97
|
}
|
|
92
98
|
});
|
|
93
|
-
var FlexWrapper = forwardRef(({ children, direction, alignItems, justifyContent, wrap, gap, width, height, minWidth, maxWidth, minHeight, maxHeight, fillWidth = false, fillHeight = false, overflow, padding, margin, onClick, onMouseDown, onMouseEnter, onMouseLeave, onScroll }, ref) => {
|
|
99
|
+
var FlexWrapper = forwardRef(({ children, direction, alignItems, justifyContent, wrap, gap, grow, shrink, basis, width, height, minWidth, maxWidth, minHeight, maxHeight, fillWidth = false, fillHeight = false, overflow, padding, margin, onClick, onMouseDown, onMouseEnter, onMouseLeave, onScroll }, ref) => {
|
|
94
100
|
return /* @__PURE__ */ jsx(StyledFlexWrapper, {
|
|
95
101
|
ref,
|
|
96
102
|
direction,
|
|
@@ -98,6 +104,9 @@ var FlexWrapper = forwardRef(({ children, direction, alignItems, justifyContent,
|
|
|
98
104
|
justifyContent,
|
|
99
105
|
wrap,
|
|
100
106
|
gap,
|
|
107
|
+
grow,
|
|
108
|
+
shrink,
|
|
109
|
+
basis,
|
|
101
110
|
width,
|
|
102
111
|
height,
|
|
103
112
|
minWidth,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import Text, { TextVariant } from "../text/Text.js";
|
|
3
|
-
import RequiredMarker from "../text/RequiredMarker.js";
|
|
4
|
-
import FlexWrapper, { AlignItems } from "../containers/FlexWrapper.js";
|
|
5
3
|
import Icon, { IconVariant, IconWeight } from "../icons/Icon.js";
|
|
4
|
+
import FlexWrapper, { AlignItems } from "../containers/FlexWrapper.js";
|
|
5
|
+
import RequiredMarker from "../text/RequiredMarker.js";
|
|
6
6
|
/* empty css */
|
|
7
7
|
import { styled } from "@linaria/react";
|
|
8
8
|
import { match } from "ts-pattern";
|
|
@@ -2,8 +2,8 @@ import { withTheme } from "../theme/GalaxyTheme.js";
|
|
|
2
2
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
3
3
|
import { hexToHsva, hsvaToHex } from "../utils/colors.js";
|
|
4
4
|
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
5
|
-
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
6
5
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
6
|
+
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
7
|
import Dropdown, { DropdownVariant } from "../dropdown/Dropdown.js";
|
|
8
8
|
import GridWrapper from "../containers/GridWrapper.js";
|
|
9
9
|
import Spacing from "../containers/Spacing.js";
|
package/dist/inputs/CopyInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import FlexWrapper, { AlignItems } from "../containers/FlexWrapper.js";
|
|
2
1
|
import Button, { ButtonSize, ButtonVariant } from "../buttons/Button.js";
|
|
2
|
+
import FlexWrapper, { AlignItems } from "../containers/FlexWrapper.js";
|
|
3
3
|
import { InputSize } from "./Input.js";
|
|
4
4
|
import TextInput from "./TextInput.js";
|
|
5
5
|
import { useCallback, useState } from "react";
|
package/dist/inputs/DateInput.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
3
3
|
import Text, { TextSize, TextVariant, TextWeight } from "../text/Text.js";
|
|
4
|
-
import FlexWrapper, { AlignItems, FlexDirection, JustifyContent } from "../containers/FlexWrapper.js";
|
|
5
4
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
5
|
+
import FlexWrapper, { AlignItems, FlexDirection, JustifyContent } from "../containers/FlexWrapper.js";
|
|
6
6
|
import Dropdown, { DropdownVariant } from "../dropdown/Dropdown.js";
|
|
7
7
|
import GridWrapper from "../containers/GridWrapper.js";
|
|
8
8
|
import Spacing from "../containers/Spacing.js";
|
package/dist/inputs/Input.js
CHANGED
|
@@ -2,9 +2,9 @@ import { withTheme } from "../theme/GalaxyTheme.js";
|
|
|
2
2
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
3
3
|
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
4
4
|
import Tooltip, { TooltipPosition } from "../tooltip/Tooltip.js";
|
|
5
|
-
import RequiredMarker from "../text/RequiredMarker.js";
|
|
6
|
-
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
5
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
6
|
+
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
|
+
import RequiredMarker from "../text/RequiredMarker.js";
|
|
8
8
|
import Spacing from "../containers/Spacing.js";
|
|
9
9
|
import HelpIcon from "../icons/HelpIcon.js";
|
|
10
10
|
/* empty css */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
3
3
|
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
4
|
-
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
5
4
|
import FlexItem from "../containers/FlexItem.js";
|
|
6
5
|
import Icon, { IconVariant } from "../icons/Icon.js";
|
|
6
|
+
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
7
|
import Dropdown, { DropdownPosition, DropdownVariant } from "../dropdown/Dropdown.js";
|
|
8
8
|
import { InputLabel } from "./Input.js";
|
|
9
9
|
import RotateWithTransition from "../animations/RotateWithTransition.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import Text, { TextVariant } from "../text/Text.js";
|
|
3
3
|
import Tooltip, { TooltipPosition } from "../tooltip/Tooltip.js";
|
|
4
|
-
import RequiredMarker from "../text/RequiredMarker.js";
|
|
5
4
|
import FlexWrapper, { AlignItems } from "../containers/FlexWrapper.js";
|
|
5
|
+
import RequiredMarker from "../text/RequiredMarker.js";
|
|
6
6
|
import Spacing from "../containers/Spacing.js";
|
|
7
7
|
import HelpIcon from "../icons/HelpIcon.js";
|
|
8
8
|
/* empty css */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
3
3
|
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
4
|
-
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
5
4
|
import FlexItem from "../containers/FlexItem.js";
|
|
6
5
|
import Icon, { IconVariant, IconWeight } from "../icons/Icon.js";
|
|
6
|
+
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
7
|
import Dropdown, { DropdownVariant } from "../dropdown/Dropdown.js";
|
|
8
8
|
import Spacing from "../containers/Spacing.js";
|
|
9
9
|
import { InputLabel } from "./Input.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import { getCssSizeValue } from "../utils/linaria.js";
|
|
3
3
|
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
4
|
-
import TextShimmer from "../text/TextShimmer.js";
|
|
5
4
|
import FlexWrapper, { FlexDirection } from "../containers/FlexWrapper.js";
|
|
5
|
+
import TextShimmer from "../text/TextShimmer.js";
|
|
6
6
|
import { InputLabel } from "./Input.js";
|
|
7
7
|
/* empty css */
|
|
8
8
|
import { styled } from "@linaria/react";
|
|
@@ -12,8 +12,8 @@ import { styled } from "@linaria/react";
|
|
|
12
12
|
import { match } from "ts-pattern";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
16
15
|
import { PlusIcon } from "@phosphor-icons/react";
|
|
16
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
17
17
|
//#region src/spreadsheet/InfiniteSpreadsheet.tsx
|
|
18
18
|
var _exp = () => ({ $width, $fillWidth }) => {
|
|
19
19
|
if ($fillWidth) return "100%";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
2
|
import Text, { TextSize, TextVariant, TextWeight } from "../text/Text.js";
|
|
3
|
-
import FlexWrapper, { FlexDirection } from "../containers/FlexWrapper.js";
|
|
4
3
|
import Button, { ButtonSize, ButtonVariant } from "../buttons/Button.js";
|
|
4
|
+
import FlexWrapper, { FlexDirection } from "../containers/FlexWrapper.js";
|
|
5
5
|
import { ColumnAlign, ColumnPin } from "../table/InfiniteTable.js";
|
|
6
6
|
import Dropdown, { DropdownPosition } from "../dropdown/Dropdown.js";
|
|
7
7
|
import DropdownItem from "../dropdown/DropdownItem.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
|
-
import FlexWrapper, { FlexDirection } from "../containers/FlexWrapper.js";
|
|
3
2
|
import Button, { ButtonSize, ButtonVariant } from "../buttons/Button.js";
|
|
3
|
+
import FlexWrapper, { FlexDirection } from "../containers/FlexWrapper.js";
|
|
4
4
|
import Dropdown, { DropdownPosition } from "../dropdown/Dropdown.js";
|
|
5
5
|
import DropdownItem from "../dropdown/DropdownItem.js";
|
|
6
6
|
/* empty css */
|
package/dist/styles.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
.a1f5gwwu{overflow:hidden;overscroll-behavior:auto;}
|
|
5
5
|
.r94gjni{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-transition:rotate var(--r94gjni-0) ease-in-out;transition:rotate var(--r94gjni-0) ease-in-out;rotate:var(--r94gjni-1);}
|
|
6
6
|
.s1he36jx{position:var(--s1he36jx-0);display:var(--s1he36jx-1);-webkit-align-items:var(--s1he36jx-2);-webkit-box-align:var(--s1he36jx-2);-ms-flex-align:var(--s1he36jx-2);align-items:var(--s1he36jx-2);-webkit-box-pack:var(--s1he36jx-3);-ms-flex-pack:var(--s1he36jx-3);-webkit-justify-content:var(--s1he36jx-3);justify-content:var(--s1he36jx-3);-webkit-box-flex:var(--s1he36jx-4);-webkit-flex-grow:var(--s1he36jx-4);-ms-flex-positive:var(--s1he36jx-4);flex-grow:var(--s1he36jx-4);-webkit-flex-shrink:var(--s1he36jx-5);-ms-flex-negative:var(--s1he36jx-5);flex-shrink:var(--s1he36jx-5);-webkit-flex-basis:var(--s1he36jx-6);-ms-flex-preferred-size:var(--s1he36jx-6);flex-basis:var(--s1he36jx-6);width:var(--s1he36jx-7);height:var(--s1he36jx-8);min-width:var(--s1he36jx-9);max-width:var(--s1he36jx-10);min-height:var(--s1he36jx-11);max-height:var(--s1he36jx-12);overflow:var(--s1he36jx-13);white-space:var(--s1he36jx-14);text-overflow:var(--s1he36jx-15);padding:var(--s1he36jx-16);overscroll-behavior:auto;cursor:var(--s1he36jx-17);}
|
|
7
|
-
.s12krdms{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;box-sizing:border-box;-webkit-flex-direction:var(--s12krdms-0);-ms-flex-direction:var(--s12krdms-0);flex-direction:var(--s12krdms-0);-webkit-align-items:var(--s12krdms-1);-webkit-box-align:var(--s12krdms-1);-ms-flex-align:var(--s12krdms-1);align-items:var(--s12krdms-1);-webkit-box-pack:var(--s12krdms-2);-ms-flex-pack:var(--s12krdms-2);-webkit-justify-content:var(--s12krdms-2);justify-content:var(--s12krdms-2);gap:var(--s12krdms-3);-webkit-box-flex-wrap:var(--s12krdms-4);-webkit-flex-wrap:var(--s12krdms-4);-ms-flex-wrap:var(--s12krdms-4);flex-wrap:var(--s12krdms-4);
|
|
7
|
+
.s12krdms{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;box-sizing:border-box;-webkit-flex-direction:var(--s12krdms-0);-ms-flex-direction:var(--s12krdms-0);flex-direction:var(--s12krdms-0);-webkit-align-items:var(--s12krdms-1);-webkit-box-align:var(--s12krdms-1);-ms-flex-align:var(--s12krdms-1);align-items:var(--s12krdms-1);-webkit-box-pack:var(--s12krdms-2);-ms-flex-pack:var(--s12krdms-2);-webkit-justify-content:var(--s12krdms-2);justify-content:var(--s12krdms-2);gap:var(--s12krdms-3);-webkit-box-flex-wrap:var(--s12krdms-4);-webkit-flex-wrap:var(--s12krdms-4);-ms-flex-wrap:var(--s12krdms-4);flex-wrap:var(--s12krdms-4);-webkit-box-flex:var(--s12krdms-5);-webkit-flex-grow:var(--s12krdms-5);-ms-flex-positive:var(--s12krdms-5);flex-grow:var(--s12krdms-5);-webkit-flex-shrink:var(--s12krdms-6);-ms-flex-negative:var(--s12krdms-6);flex-shrink:var(--s12krdms-6);-webkit-flex-basis:var(--s12krdms-7);-ms-flex-preferred-size:var(--s12krdms-7);flex-basis:var(--s12krdms-7);width:var(--s12krdms-8);height:var(--s12krdms-9);min-width:var(--s12krdms-10);max-width:var(--s12krdms-11);min-height:var(--s12krdms-12);max-height:var(--s12krdms-13);overflow:var(--s12krdms-14);padding:var(--s12krdms-15);margin:var(--s12krdms-16);overscroll-behavior:auto;cursor:var(--s12krdms-17);}
|
|
8
8
|
.h1sww5hz{width:100%;height:0.5px;background-color:var(--h1sww5hz-0);}
|
|
9
9
|
.shbcgkd{color:var(--shbcgkd-0);font-family:var(--shbcgkd-1);font-size:var(--shbcgkd-2);font-weight:var(--shbcgkd-3);line-height:var(--shbcgkd-4);letter-spacing:var(--shbcgkd-5);text-align:var(--shbcgkd-6);-webkit-text-decoration:var(--shbcgkd-7);text-decoration:var(--shbcgkd-7);cursor:var(--shbcgkd-8);-webkit-user-select:var(--shbcgkd-9);-moz-user-select:var(--shbcgkd-9);-ms-user-select:var(--shbcgkd-9);user-select:var(--shbcgkd-9);-webkit-user-select:var(--shbcgkd-9);-moz-user-select:var(--shbcgkd-9);-ms-user-select:var(--shbcgkd-9);overflow:var(--shbcgkd-10);text-overflow:var(--shbcgkd-11);white-space:var(--shbcgkd-12);width:var(--shbcgkd-13);overscroll-behavior:auto;-webkit-transition:color 0.075s ease-in-out;transition:color 0.075s ease-in-out;}
|
|
10
10
|
.s1v6noph{-webkit-animation:flash-s1v6noph 1s ease-in-out infinite;animation:flash-s1v6noph 1s ease-in-out infinite;}@-webkit-keyframes flash-s1v6noph{0%,100%{opacity:1;}50%{opacity:0.4;}}@keyframes flash-s1v6noph{0%,100%{opacity:1;}50%{opacity:0.4;}}
|
|
@@ -208,5 +208,7 @@
|
|
|
208
208
|
.s10h6trl{margin:10px 0 4px 0;}.s10h6trl:first-child{margin-top:0;}
|
|
209
209
|
.sts1mtj{color:var(--sts1mtj-0);font-family:var(--sts1mtj-1);font-size:var(--sts1mtj-2);font-weight:var(--sts1mtj-3);line-height:var(--sts1mtj-4);letter-spacing:var(--sts1mtj-5);text-align:var(--sts1mtj-6);cursor:var(--sts1mtj-7);-webkit-user-select:var(--sts1mtj-8);-moz-user-select:var(--sts1mtj-8);-ms-user-select:var(--sts1mtj-8);user-select:var(--sts1mtj-8);-webkit-user-select:var(--sts1mtj-8);-moz-user-select:var(--sts1mtj-8);-ms-user-select:var(--sts1mtj-8);display:var(--sts1mtj-9);-webkit-line-clamp:var(--sts1mtj-10);-webkit-box-orient:var(--sts1mtj-11);overflow:var(--sts1mtj-12);width:var(--sts1mtj-13);min-height:var(--sts1mtj-14);overscroll-behavior:auto;-webkit-transition:color 0.075s ease-in-out;transition:color 0.075s ease-in-out;}
|
|
210
210
|
.sfziwh{-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;}
|
|
211
|
+
.sgmrm4{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;gap:8px;padding:var(--sgmrm4-0);min-width:360px;max-width:420px;background-color:var(--sgmrm4-1);border:0.5px solid var(--sgmrm4-2);border-radius:5px;}
|
|
212
|
+
.stlie57{position:fixed;z-index:11000;top:var(--stlie57-0);right:var(--stlie57-1);bottom:var(--stlie57-2);left:var(--stlie57-3);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse;gap:8px;pointer-events:none;}.stlie57 >*{pointer-events:auto;}
|
|
211
213
|
.sx1o0cd{background:var(--sx1o0cd-0);border:0.5px solid var(--sx1o0cd-1);border-radius:5px;padding:var(--sx1o0cd-2);box-shadow:0 1px 10px 0 var(--sx1o0cd-3),0 1px 1px 0 var(--sx1o0cd-4);width:var(--sx1o0cd-5);height:var(--sx1o0cd-6);min-width:var(--sx1o0cd-7);max-width:var(--sx1o0cd-8);min-height:var(--sx1o0cd-9);max-height:var(--sx1o0cd-10);cursor:var(--sx1o0cd-11);}.sx1o0cd:hover{border-color:var(--sx1o0cd-12);}
|
|
212
214
|
/*$vite$:1*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Icon as PhosphorIcon } from "@phosphor-icons/react";
|
|
2
|
+
import { ButtonProps } from "../buttons/Button";
|
|
3
|
+
export declare enum ToastVariant {
|
|
4
|
+
PRIMARY = "PRIMARY",
|
|
5
|
+
SUCCESS = "SUCCESS",
|
|
6
|
+
WARNING = "WARNING",
|
|
7
|
+
ERROR = "ERROR"
|
|
8
|
+
}
|
|
9
|
+
export interface ToastProps {
|
|
10
|
+
variant?: ToastVariant;
|
|
11
|
+
icon?: PhosphorIcon;
|
|
12
|
+
header: string | React.ReactNode;
|
|
13
|
+
subheader: string | React.ReactNode;
|
|
14
|
+
actions?: ButtonProps[];
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
}
|
|
17
|
+
declare const Toast: ({ variant, icon, header, subheader, actions, onClose, }: ToastProps) => import("react").JSX.Element;
|
|
18
|
+
export default Toast;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { withTheme } from "../theme/GalaxyTheme.js";
|
|
2
|
+
import Text, { TextVariant } from "../text/Text.js";
|
|
3
|
+
import FlexItem from "../containers/FlexItem.js";
|
|
4
|
+
import Icon, { IconVariant, IconWeight } from "../icons/Icon.js";
|
|
5
|
+
import Button, { ButtonSize, ButtonVariant } from "../buttons/Button.js";
|
|
6
|
+
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
import { styled } from "@linaria/react";
|
|
9
|
+
import { match } from "ts-pattern";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { CheckCircleIcon, SpinnerGapIcon, WarningIcon, XIcon } from "@phosphor-icons/react";
|
|
12
|
+
//#region src/toast/Toast.tsx
|
|
13
|
+
var ToastVariant = /* @__PURE__ */ function(ToastVariant) {
|
|
14
|
+
ToastVariant["PRIMARY"] = "PRIMARY";
|
|
15
|
+
ToastVariant["SUCCESS"] = "SUCCESS";
|
|
16
|
+
ToastVariant["WARNING"] = "WARNING";
|
|
17
|
+
ToastVariant["ERROR"] = "ERROR";
|
|
18
|
+
return ToastVariant;
|
|
19
|
+
}({});
|
|
20
|
+
var _exp = () => ({ $hasActions }) => $hasActions ? "12px 12px 8px 12px" : "12px";
|
|
21
|
+
var _exp2 = () => ({ theme, $variant }) => match($variant).with("PRIMARY", () => theme.color.background.tertiary).with("SUCCESS", () => theme.color.background.tertiary).with("WARNING", () => theme.color.background.tertiary).with("ERROR", () => theme.color.background.tertiary).exhaustive();
|
|
22
|
+
var _exp3 = () => ({ theme, $variant }) => match($variant).with("PRIMARY", () => theme.color.border.secondary).with("SUCCESS", () => theme.color.border.success).with("WARNING", () => theme.color.border.warning).with("ERROR", () => theme.color.border.error).exhaustive();
|
|
23
|
+
var StyledToast = withTheme(/*#__PURE__*/ styled("div")({
|
|
24
|
+
name: "StyledToast",
|
|
25
|
+
class: "sgmrm4",
|
|
26
|
+
propsAsIs: false,
|
|
27
|
+
vars: {
|
|
28
|
+
"sgmrm4-0": [_exp()],
|
|
29
|
+
"sgmrm4-1": [_exp2()],
|
|
30
|
+
"sgmrm4-2": [_exp3()]
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
var Toast = ({ variant = "PRIMARY", icon, header, subheader, actions, onClose }) => {
|
|
34
|
+
const renderIcon = () => {
|
|
35
|
+
if (icon) return /* @__PURE__ */ jsx(Icon, {
|
|
36
|
+
component: icon,
|
|
37
|
+
size: 16
|
|
38
|
+
});
|
|
39
|
+
return match(variant).with("PRIMARY", () => /* @__PURE__ */ jsx(Icon, {
|
|
40
|
+
component: SpinnerGapIcon,
|
|
41
|
+
size: 16
|
|
42
|
+
})).with("SUCCESS", () => /* @__PURE__ */ jsx(Icon, {
|
|
43
|
+
component: CheckCircleIcon,
|
|
44
|
+
variant: IconVariant.SUCCESS,
|
|
45
|
+
size: 16,
|
|
46
|
+
weight: IconWeight.FILL
|
|
47
|
+
})).with("WARNING", () => /* @__PURE__ */ jsx(Icon, {
|
|
48
|
+
component: WarningIcon,
|
|
49
|
+
variant: IconVariant.WARNING,
|
|
50
|
+
size: 16,
|
|
51
|
+
weight: IconWeight.FILL
|
|
52
|
+
})).with("ERROR", () => /* @__PURE__ */ jsx(Icon, {
|
|
53
|
+
component: WarningIcon,
|
|
54
|
+
variant: IconVariant.ERROR,
|
|
55
|
+
size: 16,
|
|
56
|
+
weight: IconWeight.FILL
|
|
57
|
+
})).exhaustive();
|
|
58
|
+
};
|
|
59
|
+
const hasActions = (actions && actions.length > 0) ?? false;
|
|
60
|
+
return /* @__PURE__ */ jsxs(StyledToast, {
|
|
61
|
+
$variant: variant,
|
|
62
|
+
$hasActions: hasActions,
|
|
63
|
+
children: [/* @__PURE__ */ jsxs(FlexWrapper, {
|
|
64
|
+
alignItems: AlignItems.START,
|
|
65
|
+
gap: 8,
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx(FlexWrapper, {
|
|
68
|
+
width: 20,
|
|
69
|
+
height: 20,
|
|
70
|
+
children: renderIcon()
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(FlexItem, {
|
|
73
|
+
grow: 1,
|
|
74
|
+
children: /* @__PURE__ */ jsxs(FlexWrapper, {
|
|
75
|
+
direction: FlexDirection.COLUMN,
|
|
76
|
+
gap: 4,
|
|
77
|
+
children: [typeof header === "string" ? /* @__PURE__ */ jsx(Text, { children: header }) : header, typeof subheader === "string" ? /* @__PURE__ */ jsx(Text, {
|
|
78
|
+
variant: TextVariant.TERTIARY,
|
|
79
|
+
children: subheader
|
|
80
|
+
}) : subheader]
|
|
81
|
+
})
|
|
82
|
+
}),
|
|
83
|
+
onClose && /* @__PURE__ */ jsx(Button, {
|
|
84
|
+
icon: XIcon,
|
|
85
|
+
variant: ButtonVariant.TERTIARY,
|
|
86
|
+
size: ButtonSize.SMALL,
|
|
87
|
+
onClick: onClose
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}), hasActions && /* @__PURE__ */ jsx(FlexWrapper, {
|
|
91
|
+
alignItems: AlignItems.CENTER,
|
|
92
|
+
gap: 8,
|
|
93
|
+
children: actions?.map((action, index) => /* @__PURE__ */ jsx(Button, {
|
|
94
|
+
label: action.label,
|
|
95
|
+
variant: action.variant ?? ButtonVariant.TERTIARY,
|
|
96
|
+
size: ButtonSize.SMALL,
|
|
97
|
+
onClick: action.onClick
|
|
98
|
+
}, index))
|
|
99
|
+
})]
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
export { ToastVariant, Toast as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface ToastContainerProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
top?: number | string;
|
|
5
|
+
right?: number | string;
|
|
6
|
+
bottom?: number | string;
|
|
7
|
+
left?: number | string;
|
|
8
|
+
}
|
|
9
|
+
declare const ToastContainer: ({ children, top, right, bottom, left }: ToastContainerProps) => import("react").JSX.Element;
|
|
10
|
+
export default ToastContainer;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getCssSizeValue } from "../utils/linaria.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { styled } from "@linaria/react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/toast/ToastContainer.tsx
|
|
6
|
+
var _exp2 = () => ({ $top, $bottom }) => $top !== void 0 ? getCssSizeValue($top) : $bottom !== void 0 ? "auto" : "auto";
|
|
7
|
+
var _exp3 = () => ({ $right, $left }) => $right !== void 0 ? getCssSizeValue($right) : $left !== void 0 ? "auto" : getCssSizeValue(24);
|
|
8
|
+
var _exp4 = () => ({ $bottom, $top }) => $bottom !== void 0 ? getCssSizeValue($bottom) : $top !== void 0 ? "auto" : getCssSizeValue(24);
|
|
9
|
+
var _exp5 = () => ({ $left }) => $left !== void 0 ? getCssSizeValue($left) : "auto";
|
|
10
|
+
var StyledToastContainer = /*#__PURE__*/ styled("div")({
|
|
11
|
+
name: "StyledToastContainer",
|
|
12
|
+
class: "stlie57",
|
|
13
|
+
propsAsIs: false,
|
|
14
|
+
vars: {
|
|
15
|
+
"stlie57-0": [_exp2()],
|
|
16
|
+
"stlie57-1": [_exp3()],
|
|
17
|
+
"stlie57-2": [_exp4()],
|
|
18
|
+
"stlie57-3": [_exp5()]
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var ToastContainer = ({ children, top, right, bottom, left }) => {
|
|
22
|
+
return /* @__PURE__ */ jsx(StyledToastContainer, {
|
|
23
|
+
$top: top,
|
|
24
|
+
$right: right,
|
|
25
|
+
$bottom: bottom,
|
|
26
|
+
$left: left,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ToastContainer as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { ToastVariant, type ToastProps } from "./Toast";
|
|
3
|
+
export type ShowToastProps = Omit<ToastProps, "onClose"> & {
|
|
4
|
+
timeout?: number;
|
|
5
|
+
top?: number | string;
|
|
6
|
+
left?: number | string;
|
|
7
|
+
right?: number | string;
|
|
8
|
+
bottom?: number | string;
|
|
9
|
+
};
|
|
10
|
+
export interface ToastContextProps {
|
|
11
|
+
showToast: (options: ShowToastProps) => string;
|
|
12
|
+
hideToast: (id?: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const ToastContext: import("react").Context<ToastContextProps | undefined>;
|
|
15
|
+
export declare const ToastProvider: ({ children }: PropsWithChildren) => import("react").JSX.Element;
|
|
16
|
+
export { ToastVariant };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import Toast, { ToastVariant } from "./Toast.js";
|
|
2
|
+
import ToastContainer from "./ToastContainer.js";
|
|
3
|
+
import ToastWrapper from "./ToastWrapper.js";
|
|
4
|
+
import { createContext, useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { createPortal } from "react-dom";
|
|
7
|
+
import { AnimatePresence } from "framer-motion";
|
|
8
|
+
//#region src/toast/ToastProvider.tsx
|
|
9
|
+
var ToastContext = createContext(void 0);
|
|
10
|
+
var DEFAULT_TIMEOUT = 3e3;
|
|
11
|
+
var toastCounter = 0;
|
|
12
|
+
var nextToastId = () => `toast-${++toastCounter}`;
|
|
13
|
+
var positionKey = (toast) => JSON.stringify([
|
|
14
|
+
toast.top,
|
|
15
|
+
toast.right,
|
|
16
|
+
toast.bottom,
|
|
17
|
+
toast.left
|
|
18
|
+
]);
|
|
19
|
+
var ToastProvider = ({ children }) => {
|
|
20
|
+
const [toasts, setToasts] = useState([]);
|
|
21
|
+
const timeoutRefs = useRef(/* @__PURE__ */ new Map());
|
|
22
|
+
const showToast = useCallback((options) => {
|
|
23
|
+
const id = nextToastId();
|
|
24
|
+
const { timeout, top, right, bottom, left, ...props } = options;
|
|
25
|
+
const finalTimeout = timeout === void 0 ? DEFAULT_TIMEOUT : timeout;
|
|
26
|
+
setToasts((prev) => [...prev, {
|
|
27
|
+
id,
|
|
28
|
+
props,
|
|
29
|
+
timeout: finalTimeout,
|
|
30
|
+
top,
|
|
31
|
+
right,
|
|
32
|
+
bottom,
|
|
33
|
+
left
|
|
34
|
+
}]);
|
|
35
|
+
return id;
|
|
36
|
+
}, []);
|
|
37
|
+
const hideToast = useCallback((id) => {
|
|
38
|
+
if (id) {
|
|
39
|
+
const timeoutId = timeoutRefs.current.get(id);
|
|
40
|
+
if (timeoutId) {
|
|
41
|
+
clearTimeout(timeoutId);
|
|
42
|
+
timeoutRefs.current.delete(id);
|
|
43
|
+
}
|
|
44
|
+
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
45
|
+
} else setToasts((prev) => {
|
|
46
|
+
const firstToast = prev[0];
|
|
47
|
+
if (firstToast) {
|
|
48
|
+
const timeoutId = timeoutRefs.current.get(firstToast.id);
|
|
49
|
+
if (timeoutId) {
|
|
50
|
+
clearTimeout(timeoutId);
|
|
51
|
+
timeoutRefs.current.delete(firstToast.id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return prev.slice(1);
|
|
55
|
+
});
|
|
56
|
+
}, []);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const currentToastIds = new Set(toasts.map((toast) => toast.id));
|
|
59
|
+
toasts.forEach((toast) => {
|
|
60
|
+
if (timeoutRefs.current.has(toast.id)) return;
|
|
61
|
+
if (toast.timeout > 0) {
|
|
62
|
+
const timeoutId = setTimeout(() => {
|
|
63
|
+
setToasts((prev) => prev.filter((t) => t.id !== toast.id));
|
|
64
|
+
timeoutRefs.current.delete(toast.id);
|
|
65
|
+
}, toast.timeout);
|
|
66
|
+
timeoutRefs.current.set(toast.id, timeoutId);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
timeoutRefs.current.forEach((timeoutId, toastId) => {
|
|
70
|
+
if (!currentToastIds.has(toastId)) {
|
|
71
|
+
clearTimeout(timeoutId);
|
|
72
|
+
timeoutRefs.current.delete(toastId);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}, [toasts]);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const refs = timeoutRefs.current;
|
|
78
|
+
return () => {
|
|
79
|
+
refs.forEach((timeoutId) => {
|
|
80
|
+
clearTimeout(timeoutId);
|
|
81
|
+
});
|
|
82
|
+
refs.clear();
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
const positionGroups = /* @__PURE__ */ new Map();
|
|
86
|
+
toasts.forEach((toast) => {
|
|
87
|
+
const key = positionKey(toast);
|
|
88
|
+
const group = positionGroups.get(key);
|
|
89
|
+
if (group) group.push(toast);
|
|
90
|
+
else positionGroups.set(key, [toast]);
|
|
91
|
+
});
|
|
92
|
+
const toastContent = /* @__PURE__ */ jsx(Fragment, { children: [...positionGroups.entries()].map(([key, group]) => /* @__PURE__ */ jsx(ToastContainer, {
|
|
93
|
+
top: group[0].top,
|
|
94
|
+
right: group[0].right,
|
|
95
|
+
bottom: group[0].bottom,
|
|
96
|
+
left: group[0].left,
|
|
97
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, { children: group.map((toast) => /* @__PURE__ */ jsx(ToastWrapper, { children: /* @__PURE__ */ jsx(Toast, {
|
|
98
|
+
...toast.props,
|
|
99
|
+
onClose: () => hideToast(toast.id)
|
|
100
|
+
}) }, toast.id)) })
|
|
101
|
+
}, key)) });
|
|
102
|
+
return /* @__PURE__ */ jsxs(ToastContext.Provider, {
|
|
103
|
+
value: {
|
|
104
|
+
showToast,
|
|
105
|
+
hideToast
|
|
106
|
+
},
|
|
107
|
+
children: [children, typeof document !== "undefined" && createPortal(toastContent, document.body)]
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { ToastContext, ToastProvider, ToastVariant };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { motion } from "framer-motion";
|
|
3
|
+
//#region src/toast/ToastWrapper.tsx
|
|
4
|
+
var ToastWrapper = ({ children }) => {
|
|
5
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
6
|
+
initial: {
|
|
7
|
+
opacity: 0,
|
|
8
|
+
x: 50
|
|
9
|
+
},
|
|
10
|
+
animate: {
|
|
11
|
+
opacity: 1,
|
|
12
|
+
x: 0
|
|
13
|
+
},
|
|
14
|
+
exit: {
|
|
15
|
+
opacity: 0,
|
|
16
|
+
x: 50
|
|
17
|
+
},
|
|
18
|
+
transition: {
|
|
19
|
+
type: "tween",
|
|
20
|
+
duration: .15,
|
|
21
|
+
ease: "easeOut"
|
|
22
|
+
},
|
|
23
|
+
children
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ToastWrapper as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useToast: () => import("./ToastProvider").ToastContextProps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ToastContext } from "./ToastProvider.js";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
//#region src/toast/useToast.ts
|
|
4
|
+
var useToast = () => {
|
|
5
|
+
const context = useContext(ToastContext);
|
|
6
|
+
if (!context) throw new Error("useToast must be used within a ToastProvider");
|
|
7
|
+
return context;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { useToast };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galaxy-io/dls",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Galaxy Design Language System",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -143,6 +143,10 @@
|
|
|
143
143
|
"types": "./dist/theme/*.d.ts",
|
|
144
144
|
"import": "./dist/theme/*.js"
|
|
145
145
|
},
|
|
146
|
+
"./toast/*": {
|
|
147
|
+
"types": "./dist/toast/*.d.ts",
|
|
148
|
+
"import": "./dist/toast/*.js"
|
|
149
|
+
},
|
|
146
150
|
"./tooltip/*": {
|
|
147
151
|
"types": "./dist/tooltip/*.d.ts",
|
|
148
152
|
"import": "./dist/tooltip/*.js"
|