@lazar-ui/kit 0.7.0 → 0.8.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/CHANGELOG.md +6 -0
- package/dist/Alert-BW15jsDc.mjs +20 -0
- package/dist/Flex-DvO3gB0Z.mjs +73 -0
- package/dist/Text-DQPy-DZ5.mjs +46 -0
- package/dist/alert.js +2 -18
- package/dist/flex.js +2 -71
- package/dist/text.js +6 -48
- package/dist/toast.css +1 -0
- package/dist/toast.d.ts +86 -0
- package/dist/toast.js +86 -0
- package/package.json +1 -1
- /package/dist/{alert.css → Alert.css} +0 -0
- /package/dist/{flex.css → Flex.css} +0 -0
- /package/dist/{text.css → Text.css} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.0] - 2026-07-10
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- **Toast**: add Toast component — notification system with `ToastProvider` and `useToast` hook. Supports auto-dismiss, max visible toasts, multiple positions, success/error/warning/info variants, and custom duration. ([d506b59](https://github.com/lazar-ui/lazar-ui/commit/d506b59))
|
|
8
|
+
|
|
3
9
|
## [0.7.0] - 2026-07-06
|
|
4
10
|
|
|
5
11
|
### Features
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import s from "clsx";
|
|
3
|
+
import { g as c } from "./getVariantClassName-DoCNtwBw.mjs";
|
|
4
|
+
import './Alert.css';const e = "Alert", _ = "_root_1ibdz_9", v = "_variantDanger_1ibdz_18", l = "_variantInfo_1ibdz_25", m = "_variantSuccess_1ibdz_32", d = "_variantWarning_1ibdz_39", a = {
|
|
5
|
+
root: _,
|
|
6
|
+
variantDanger: v,
|
|
7
|
+
variantInfo: l,
|
|
8
|
+
variantSuccess: m,
|
|
9
|
+
variantWarning: d
|
|
10
|
+
}, g = (n) => {
|
|
11
|
+
const { children: r, variant: t = "info" } = n, o = s(
|
|
12
|
+
a.root,
|
|
13
|
+
c("variant", t, a)
|
|
14
|
+
);
|
|
15
|
+
return /* @__PURE__ */ i("div", { className: o, role: "alert", children: r });
|
|
16
|
+
};
|
|
17
|
+
g.displayName = e;
|
|
18
|
+
export {
|
|
19
|
+
g as A
|
|
20
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import x from "clsx";
|
|
3
|
+
import j from "lodash/camelCase";
|
|
4
|
+
import './Flex.css';const S = "Flex", v = "_root_1mp2w_7", C = "_directionRow_1mp2w_14", F = "_directionColumn_1mp2w_18", h = "_directionRowReverse_1mp2w_22", R = "_directionColumnReverse_1mp2w_26", E = "_alignFlexStart_1mp2w_30", B = "_alignCenter_1mp2w_34", k = "_alignFlexEnd_1mp2w_38", A = "_alignStretch_1mp2w_42", W = "_alignBaseline_1mp2w_46", $ = "_justifyFlexStart_1mp2w_50", N = "_justifyCenter_1mp2w_54", D = "_justifyFlexEnd_1mp2w_58", I = "_justifySpaceBetween_1mp2w_62", L = "_justifySpaceAround_1mp2w_66", M = "_justifySpaceEvenly_1mp2w_70", P = "_fullWidth_1mp2w_74", Y = "_wrap_1mp2w_78", b = "_grow_1mp2w_82", q = "_shrink_1mp2w_86", e = {
|
|
5
|
+
root: v,
|
|
6
|
+
directionRow: C,
|
|
7
|
+
directionColumn: F,
|
|
8
|
+
directionRowReverse: h,
|
|
9
|
+
directionColumnReverse: R,
|
|
10
|
+
alignFlexStart: E,
|
|
11
|
+
alignCenter: B,
|
|
12
|
+
alignFlexEnd: k,
|
|
13
|
+
alignStretch: A,
|
|
14
|
+
alignBaseline: W,
|
|
15
|
+
justifyFlexStart: $,
|
|
16
|
+
justifyCenter: N,
|
|
17
|
+
justifyFlexEnd: D,
|
|
18
|
+
justifySpaceBetween: I,
|
|
19
|
+
justifySpaceAround: L,
|
|
20
|
+
justifySpaceEvenly: M,
|
|
21
|
+
fullWidth: P,
|
|
22
|
+
wrap: Y,
|
|
23
|
+
grow: b,
|
|
24
|
+
shrink: q
|
|
25
|
+
};
|
|
26
|
+
function i(n, t) {
|
|
27
|
+
return e[j(`${n}-${t}`)];
|
|
28
|
+
}
|
|
29
|
+
const z = (n) => {
|
|
30
|
+
const {
|
|
31
|
+
align: t,
|
|
32
|
+
as: _ = "div",
|
|
33
|
+
children: a,
|
|
34
|
+
direction: c = "row",
|
|
35
|
+
fullWidth: p,
|
|
36
|
+
gap: o,
|
|
37
|
+
grow: u,
|
|
38
|
+
id: w,
|
|
39
|
+
justify: l,
|
|
40
|
+
px: s,
|
|
41
|
+
py: r,
|
|
42
|
+
shrink: m,
|
|
43
|
+
style: d,
|
|
44
|
+
wrap: f
|
|
45
|
+
} = n, y = x(
|
|
46
|
+
e.root,
|
|
47
|
+
i("direction", c),
|
|
48
|
+
t != null && i("align", t),
|
|
49
|
+
l != null && i("justify", l),
|
|
50
|
+
f && e.wrap,
|
|
51
|
+
p && e.fullWidth,
|
|
52
|
+
u && e.grow,
|
|
53
|
+
m && e.shrink
|
|
54
|
+
);
|
|
55
|
+
return /* @__PURE__ */ g(
|
|
56
|
+
_,
|
|
57
|
+
{
|
|
58
|
+
className: y,
|
|
59
|
+
id: w,
|
|
60
|
+
style: {
|
|
61
|
+
"--flex-gap": o != null ? `var(--lui-space-${o})` : void 0,
|
|
62
|
+
"--flex-px": s != null ? `var(--lui-space-${s})` : void 0,
|
|
63
|
+
"--flex-py": r != null ? `var(--lui-space-${r})` : void 0,
|
|
64
|
+
...d
|
|
65
|
+
},
|
|
66
|
+
children: a
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
z.displayName = S;
|
|
71
|
+
export {
|
|
72
|
+
z as F
|
|
73
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import j from "react";
|
|
3
|
+
import v from "clsx";
|
|
4
|
+
import { g as w } from "./getDecorationStyle-BCBONKEl.mjs";
|
|
5
|
+
import { g as t } from "./getVariantClassName-DoCNtwBw.mjs";
|
|
6
|
+
import './Text.css';const y = "Text", z = "sm", S = "normal", u = "p", T = "_root_1vl2j_1", p = "_truncate_1vl2j_5", f = "_sizeXs_1vl2j_12", D = "_sizeSm_1vl2j_18", N = "_sizeMd_1vl2j_24", L = "_sizeLg_1vl2j_30", M = "_weightNormal_1vl2j_37", b = "_weightMedium_1vl2j_41", A = "_weightSemibold_1vl2j_45", B = "_weightBold_1vl2j_49", E = "_colorPrimary_1vl2j_54", x = "_colorSecondary_1vl2j_58", P = "_colorTertiary_1vl2j_62", C = "_colorDisabled_1vl2j_66", F = "_colorBrand_1vl2j_70", o = {
|
|
7
|
+
root: T,
|
|
8
|
+
truncate: p,
|
|
9
|
+
sizeXs: f,
|
|
10
|
+
sizeSm: D,
|
|
11
|
+
sizeMd: N,
|
|
12
|
+
sizeLg: L,
|
|
13
|
+
weightNormal: M,
|
|
14
|
+
weightMedium: b,
|
|
15
|
+
weightSemibold: A,
|
|
16
|
+
weightBold: B,
|
|
17
|
+
colorPrimary: E,
|
|
18
|
+
colorSecondary: x,
|
|
19
|
+
colorTertiary: P,
|
|
20
|
+
colorDisabled: C,
|
|
21
|
+
colorBrand: F
|
|
22
|
+
}, I = j.forwardRef((r, s) => {
|
|
23
|
+
const {
|
|
24
|
+
as: l = u,
|
|
25
|
+
children: c,
|
|
26
|
+
color: e,
|
|
27
|
+
size: i = z,
|
|
28
|
+
weight: _ = S,
|
|
29
|
+
truncate: n = !1,
|
|
30
|
+
underline: a,
|
|
31
|
+
strikethrough: m
|
|
32
|
+
} = r, d = w({ strikethrough: m, underline: a }), g = v(
|
|
33
|
+
o.root,
|
|
34
|
+
t("size", i, o),
|
|
35
|
+
t("weight", _, o),
|
|
36
|
+
e && t("color", e, o),
|
|
37
|
+
{
|
|
38
|
+
[o.truncate]: n
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
return /* @__PURE__ */ h(l, { className: g, ref: s, style: d, children: c });
|
|
42
|
+
});
|
|
43
|
+
I.displayName = y;
|
|
44
|
+
export {
|
|
45
|
+
I as T
|
|
46
|
+
};
|
package/dist/alert.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import s from "clsx";
|
|
3
|
-
import { g as c } from "./getVariantClassName-DoCNtwBw.mjs";
|
|
4
|
-
import './alert.css';const e = "Alert", _ = "_root_1ibdz_9", v = "_variantDanger_1ibdz_18", l = "_variantInfo_1ibdz_25", m = "_variantSuccess_1ibdz_32", d = "_variantWarning_1ibdz_39", a = {
|
|
5
|
-
root: _,
|
|
6
|
-
variantDanger: v,
|
|
7
|
-
variantInfo: l,
|
|
8
|
-
variantSuccess: m,
|
|
9
|
-
variantWarning: d
|
|
10
|
-
}, g = (n) => {
|
|
11
|
-
const { children: r, variant: t = "info" } = n, o = s(
|
|
12
|
-
a.root,
|
|
13
|
-
c("variant", t, a)
|
|
14
|
-
);
|
|
15
|
-
return /* @__PURE__ */ i("div", { className: o, role: "alert", children: r });
|
|
16
|
-
};
|
|
17
|
-
g.displayName = e;
|
|
1
|
+
import { A as o } from "./Alert-BW15jsDc.mjs";
|
|
18
2
|
export {
|
|
19
|
-
|
|
3
|
+
o as Alert
|
|
20
4
|
};
|
package/dist/flex.js
CHANGED
|
@@ -1,73 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import x from "clsx";
|
|
3
|
-
import j from "lodash/camelCase";
|
|
4
|
-
import './flex.css';const S = "Flex", v = "_root_1mp2w_7", C = "_directionRow_1mp2w_14", F = "_directionColumn_1mp2w_18", h = "_directionRowReverse_1mp2w_22", R = "_directionColumnReverse_1mp2w_26", E = "_alignFlexStart_1mp2w_30", B = "_alignCenter_1mp2w_34", k = "_alignFlexEnd_1mp2w_38", A = "_alignStretch_1mp2w_42", W = "_alignBaseline_1mp2w_46", $ = "_justifyFlexStart_1mp2w_50", N = "_justifyCenter_1mp2w_54", D = "_justifyFlexEnd_1mp2w_58", I = "_justifySpaceBetween_1mp2w_62", L = "_justifySpaceAround_1mp2w_66", M = "_justifySpaceEvenly_1mp2w_70", P = "_fullWidth_1mp2w_74", Y = "_wrap_1mp2w_78", b = "_grow_1mp2w_82", q = "_shrink_1mp2w_86", e = {
|
|
5
|
-
root: v,
|
|
6
|
-
directionRow: C,
|
|
7
|
-
directionColumn: F,
|
|
8
|
-
directionRowReverse: h,
|
|
9
|
-
directionColumnReverse: R,
|
|
10
|
-
alignFlexStart: E,
|
|
11
|
-
alignCenter: B,
|
|
12
|
-
alignFlexEnd: k,
|
|
13
|
-
alignStretch: A,
|
|
14
|
-
alignBaseline: W,
|
|
15
|
-
justifyFlexStart: $,
|
|
16
|
-
justifyCenter: N,
|
|
17
|
-
justifyFlexEnd: D,
|
|
18
|
-
justifySpaceBetween: I,
|
|
19
|
-
justifySpaceAround: L,
|
|
20
|
-
justifySpaceEvenly: M,
|
|
21
|
-
fullWidth: P,
|
|
22
|
-
wrap: Y,
|
|
23
|
-
grow: b,
|
|
24
|
-
shrink: q
|
|
25
|
-
};
|
|
26
|
-
function i(n, t) {
|
|
27
|
-
return e[j(`${n}-${t}`)];
|
|
28
|
-
}
|
|
29
|
-
const z = (n) => {
|
|
30
|
-
const {
|
|
31
|
-
align: t,
|
|
32
|
-
as: _ = "div",
|
|
33
|
-
children: c,
|
|
34
|
-
direction: a = "row",
|
|
35
|
-
fullWidth: p,
|
|
36
|
-
gap: o,
|
|
37
|
-
grow: u,
|
|
38
|
-
id: w,
|
|
39
|
-
justify: l,
|
|
40
|
-
px: s,
|
|
41
|
-
py: r,
|
|
42
|
-
shrink: m,
|
|
43
|
-
style: d,
|
|
44
|
-
wrap: f
|
|
45
|
-
} = n, y = x(
|
|
46
|
-
e.root,
|
|
47
|
-
i("direction", a),
|
|
48
|
-
t != null && i("align", t),
|
|
49
|
-
l != null && i("justify", l),
|
|
50
|
-
f && e.wrap,
|
|
51
|
-
p && e.fullWidth,
|
|
52
|
-
u && e.grow,
|
|
53
|
-
m && e.shrink
|
|
54
|
-
);
|
|
55
|
-
return /* @__PURE__ */ g(
|
|
56
|
-
_,
|
|
57
|
-
{
|
|
58
|
-
className: y,
|
|
59
|
-
id: w,
|
|
60
|
-
style: {
|
|
61
|
-
"--flex-gap": o != null ? `var(--lui-space-${o})` : void 0,
|
|
62
|
-
"--flex-px": s != null ? `var(--lui-space-${s})` : void 0,
|
|
63
|
-
"--flex-py": r != null ? `var(--lui-space-${r})` : void 0,
|
|
64
|
-
...d
|
|
65
|
-
},
|
|
66
|
-
children: c
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
z.displayName = S;
|
|
1
|
+
import { F as r } from "./Flex-DvO3gB0Z.mjs";
|
|
71
2
|
export {
|
|
72
|
-
|
|
3
|
+
r as Flex
|
|
73
4
|
};
|
package/dist/text.js
CHANGED
|
@@ -1,50 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import j from "clsx";
|
|
4
|
-
import { g as D } from "./getDecorationStyle-BCBONKEl.mjs";
|
|
5
|
-
import { g as t } from "./getVariantClassName-DoCNtwBw.mjs";
|
|
6
|
-
import './text.css';const u = "Text", w = "sm", S = "normal", h = "p", M = "_root_1vl2j_1", A = "_truncate_1vl2j_5", L = "_sizeXs_1vl2j_12", z = "_sizeSm_1vl2j_18", N = "_sizeMd_1vl2j_24", b = "_sizeLg_1vl2j_30", p = "_weightNormal_1vl2j_37", B = "_weightMedium_1vl2j_41", R = "_weightSemibold_1vl2j_45", f = "_weightBold_1vl2j_49", I = "_colorPrimary_1vl2j_54", P = "_colorSecondary_1vl2j_58", O = "_colorTertiary_1vl2j_62", U = "_colorDisabled_1vl2j_66", X = "_colorBrand_1vl2j_70", r = {
|
|
7
|
-
root: M,
|
|
8
|
-
truncate: A,
|
|
9
|
-
sizeXs: L,
|
|
10
|
-
sizeSm: z,
|
|
11
|
-
sizeMd: N,
|
|
12
|
-
sizeLg: b,
|
|
13
|
-
weightNormal: p,
|
|
14
|
-
weightMedium: B,
|
|
15
|
-
weightSemibold: R,
|
|
16
|
-
weightBold: f,
|
|
17
|
-
colorPrimary: I,
|
|
18
|
-
colorSecondary: P,
|
|
19
|
-
colorTertiary: O,
|
|
20
|
-
colorDisabled: U,
|
|
21
|
-
colorBrand: X
|
|
22
|
-
}, Y = y.forwardRef((o, e) => {
|
|
23
|
-
const {
|
|
24
|
-
as: l = h,
|
|
25
|
-
children: c,
|
|
26
|
-
color: s,
|
|
27
|
-
size: i = w,
|
|
28
|
-
weight: a = S,
|
|
29
|
-
truncate: n = !1,
|
|
30
|
-
underline: _,
|
|
31
|
-
strikethrough: m
|
|
32
|
-
} = o, d = D({ strikethrough: m, underline: _ }), g = j(
|
|
33
|
-
r.root,
|
|
34
|
-
t("size", i, r),
|
|
35
|
-
t("weight", a, r),
|
|
36
|
-
s && t("color", s, r),
|
|
37
|
-
{
|
|
38
|
-
[r.truncate]: n
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
return /* @__PURE__ */ v(l, { className: g, ref: e, style: d, children: c });
|
|
42
|
-
});
|
|
43
|
-
Y.displayName = u;
|
|
44
|
-
var F = /* @__PURE__ */ ((o) => (o.XS = "xs", o.SM = "sm", o.MD = "md", o.LG = "lg", o))(F || {}), G = /* @__PURE__ */ ((o) => (o.PRIMARY = "primary", o.SECONDARY = "secondary", o.TERTIARY = "tertiary", o.DISABLED = "disabled", o.BRAND = "brand", o))(G || {}), T = /* @__PURE__ */ ((o) => (o.NORMAL = "normal", o.MEDIUM = "medium", o.SEMIBOLD = "semibold", o.BOLD = "bold", o))(T || {});
|
|
1
|
+
import { T as R } from "./Text-DQPy-DZ5.mjs";
|
|
2
|
+
var a = /* @__PURE__ */ ((r) => (r.XS = "xs", r.SM = "sm", r.MD = "md", r.LG = "lg", r))(a || {}), d = /* @__PURE__ */ ((r) => (r.PRIMARY = "primary", r.SECONDARY = "secondary", r.TERTIARY = "tertiary", r.DISABLED = "disabled", r.BRAND = "brand", r))(d || {}), m = /* @__PURE__ */ ((r) => (r.NORMAL = "normal", r.MEDIUM = "medium", r.SEMIBOLD = "semibold", r.BOLD = "bold", r))(m || {});
|
|
45
3
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
4
|
+
d as ETextColor,
|
|
5
|
+
a as ETextSize,
|
|
6
|
+
m as ETextWeight,
|
|
7
|
+
R as Text
|
|
50
8
|
};
|
package/dist/toast.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--toast-gap: var(--lui-space-2);--toast-max-width: 400px;--toast-offset: var(--lui-space-4);--toast-z-index: 9999}._root_1eefh_8{display:flex;flex-direction:column;gap:var(--toast-gap);max-width:var(--toast-max-width);position:fixed;z-index:var(--toast-z-index)}._positionBottomLeft_1eefh_17{bottom:var(--toast-offset);left:var(--toast-offset)}._positionBottomRight_1eefh_22{bottom:var(--toast-offset);right:var(--toast-offset)}._positionTopLeft_1eefh_27{left:var(--toast-offset);top:var(--toast-offset)}._positionTopRight_1eefh_32{right:var(--toast-offset);top:var(--toast-offset)}
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
|
|
3
|
+
declare enum EToastPosition {
|
|
4
|
+
BOTTOM_LEFT = "bottomLeft",
|
|
5
|
+
BOTTOM_RIGHT = "bottomRight",
|
|
6
|
+
TOP_LEFT = "topLeft",
|
|
7
|
+
TOP_RIGHT = "topRight"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare enum EToastType {
|
|
11
|
+
ERROR = "error",
|
|
12
|
+
INFO = "info",
|
|
13
|
+
SUCCESS = "success"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare interface IToast {
|
|
17
|
+
id: string;
|
|
18
|
+
message: string;
|
|
19
|
+
type: TToastType;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export declare interface IToastContext {
|
|
23
|
+
addToast: (message: string, type: TToastType) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare interface IToastProps extends default_2.PropsWithChildren {
|
|
27
|
+
/** Auto-dismiss timeout in milliseconds. Set to 0 to disable. Default: 4000. */
|
|
28
|
+
autoDismissMs?: number;
|
|
29
|
+
/** Maximum number of visible toasts. Oldest are removed first. */
|
|
30
|
+
maxToasts?: number;
|
|
31
|
+
/** Position of the toast container on the screen. Default: 'bottomRight'. */
|
|
32
|
+
position?: TToastPosition;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* ToastProvider — context provider and fixed-position container for toast notifications.
|
|
37
|
+
*
|
|
38
|
+
* Wraps the application and renders a container that displays toast messages
|
|
39
|
+
* triggered via the `useToast` hook. Supports configurable position, auto-dismiss
|
|
40
|
+
* timeout, and maximum number of visible toasts.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <ToastProvider position="bottomRight" autoDismissMs={4000}>
|
|
45
|
+
* <App />
|
|
46
|
+
* </ToastProvider>
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* // Disable auto-dismiss and limit to 3 toasts
|
|
52
|
+
* <ToastProvider autoDismissMs={0} maxToasts={3}>
|
|
53
|
+
* <App />
|
|
54
|
+
* </ToastProvider>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare const ToastProvider: default_2.FC<IToastProps>;
|
|
58
|
+
|
|
59
|
+
export declare type TToastPosition = `${EToastPosition.BOTTOM_LEFT | EToastPosition.BOTTOM_RIGHT | EToastPosition.TOP_LEFT | EToastPosition.TOP_RIGHT}`;
|
|
60
|
+
|
|
61
|
+
export declare type TToastType = `${EToastType.ERROR | EToastType.INFO | EToastType.SUCCESS}`;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Hook to show toast notifications.
|
|
65
|
+
*
|
|
66
|
+
* Must be used within a `ToastProvider`. Returns an object with a `toast` property
|
|
67
|
+
* containing `success`, `error`, and `info` methods.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* const { toast } = useToast();
|
|
72
|
+
*
|
|
73
|
+
* toast.success('Saved successfully');
|
|
74
|
+
* toast.error('Operation failed');
|
|
75
|
+
* toast.info('Processing...');
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function useToast(): {
|
|
79
|
+
toast: {
|
|
80
|
+
error: (message: string) => void;
|
|
81
|
+
info: (message: string) => void;
|
|
82
|
+
success: (message: string) => void;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { }
|
package/dist/toast.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsxs as h, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as v, useState as C, useRef as E, useCallback as p, useEffect as N, useContext as B, useMemo as M } from "react";
|
|
3
|
+
import y from "clsx";
|
|
4
|
+
import { A as P } from "./Alert-BW15jsDc.mjs";
|
|
5
|
+
import { B as b } from "./Button-BN85EtaZ.mjs";
|
|
6
|
+
import { F as w } from "./Flex-DvO3gB0Z.mjs";
|
|
7
|
+
import { T as F } from "./Text-DQPy-DZ5.mjs";
|
|
8
|
+
import { g as O } from "./getVariantClassName-DoCNtwBw.mjs";
|
|
9
|
+
import './toast.css';const U = 4e3, j = "bottomRight", g = "Toast", k = 36, z = 11, V = 2, X = {
|
|
10
|
+
error: "danger",
|
|
11
|
+
info: "info",
|
|
12
|
+
success: "success"
|
|
13
|
+
}, Y = "_root_1eefh_8", $ = "_positionBottomLeft_1eefh_17", q = "_positionBottomRight_1eefh_22", G = "_positionTopLeft_1eefh_27", H = "_positionTopRight_1eefh_32", _ = {
|
|
14
|
+
root: Y,
|
|
15
|
+
positionBottomLeft: $,
|
|
16
|
+
positionBottomRight: q,
|
|
17
|
+
positionTopLeft: G,
|
|
18
|
+
positionTopRight: H
|
|
19
|
+
}, x = v(null), I = ({ toast: e, onDismiss: o }) => {
|
|
20
|
+
const l = X[e.type], t = p(() => {
|
|
21
|
+
o(e.id);
|
|
22
|
+
}, [o, e.id]);
|
|
23
|
+
return /* @__PURE__ */ m(P, { variant: l, children: /* @__PURE__ */ h(w, { align: "center", gap: 3, children: [
|
|
24
|
+
/* @__PURE__ */ m(F, { as: "span", color: "primary", size: "sm", children: e.message }),
|
|
25
|
+
/* @__PURE__ */ m(b, { "aria-label": "Dismiss", icon: "x", mode: "text", size: "sm", variant: "secondary", onClick: t })
|
|
26
|
+
] }) });
|
|
27
|
+
};
|
|
28
|
+
I.displayName = `${g}.Item`;
|
|
29
|
+
const J = (e) => {
|
|
30
|
+
const { autoDismissMs: o = U, children: l, maxToasts: t, position: A = j } = e, [D, u] = C([]), i = E(/* @__PURE__ */ new Map()), f = p((s) => {
|
|
31
|
+
const r = i.current.get(s);
|
|
32
|
+
r && (clearTimeout(r), i.current.delete(s)), u((n) => n.filter((c) => c.id !== s));
|
|
33
|
+
}, []), R = p(
|
|
34
|
+
(s, r) => {
|
|
35
|
+
const n = Math.random().toString(k).slice(V, z);
|
|
36
|
+
if (u((c) => {
|
|
37
|
+
const a = [...c, { id: n, message: s, type: r }];
|
|
38
|
+
if (t != null && a.length > t) {
|
|
39
|
+
const L = a.slice(0, a.length - t);
|
|
40
|
+
for (const T of L) {
|
|
41
|
+
const d = i.current.get(T.id);
|
|
42
|
+
d && (clearTimeout(d), i.current.delete(T.id));
|
|
43
|
+
}
|
|
44
|
+
return a.slice(-t);
|
|
45
|
+
}
|
|
46
|
+
return a;
|
|
47
|
+
}), o > 0) {
|
|
48
|
+
const c = setTimeout(() => {
|
|
49
|
+
f(n);
|
|
50
|
+
}, o);
|
|
51
|
+
i.current.set(n, c);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[o, t, f]
|
|
55
|
+
);
|
|
56
|
+
N(() => {
|
|
57
|
+
const s = i.current;
|
|
58
|
+
return () => {
|
|
59
|
+
s.forEach((r) => clearTimeout(r)), s.clear();
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
62
|
+
const S = y(_.root, O("position", A, _));
|
|
63
|
+
return /* @__PURE__ */ h(x.Provider, { value: { addToast: R }, children: [
|
|
64
|
+
l,
|
|
65
|
+
/* @__PURE__ */ m("div", { className: S, children: D.map((s) => /* @__PURE__ */ m(I, { onDismiss: f, toast: s }, s.id)) })
|
|
66
|
+
] });
|
|
67
|
+
};
|
|
68
|
+
J.displayName = g;
|
|
69
|
+
function it() {
|
|
70
|
+
const e = B(x);
|
|
71
|
+
if (!e)
|
|
72
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
73
|
+
const { addToast: o } = e;
|
|
74
|
+
return { toast: M(
|
|
75
|
+
() => ({
|
|
76
|
+
error: (t) => o(t, "error"),
|
|
77
|
+
info: (t) => o(t, "info"),
|
|
78
|
+
success: (t) => o(t, "success")
|
|
79
|
+
}),
|
|
80
|
+
[o]
|
|
81
|
+
) };
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
J as ToastProvider,
|
|
85
|
+
it as useToast
|
|
86
|
+
};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|