@octavius2929-personal/design-system 1.0.0 → 1.1.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/index.cjs +93 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +94 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1974,17 +1974,33 @@ var defaultIcons = {
|
|
|
1974
1974
|
warn: TriangleAlertIcon,
|
|
1975
1975
|
danger: CircleXIcon
|
|
1976
1976
|
};
|
|
1977
|
+
var roleBySeverity = {
|
|
1978
|
+
info: "status",
|
|
1979
|
+
ok: "status",
|
|
1980
|
+
warn: "alert",
|
|
1981
|
+
danger: "alert"
|
|
1982
|
+
};
|
|
1977
1983
|
var Alert = (0, import_react41.forwardRef)(function Alert2({ severity: severity2 = "info", title, icon, className, testId, children, ...rest }, ref) {
|
|
1978
1984
|
const styles = useStyles17({ severity: severity2, className });
|
|
1979
1985
|
const { testId: dataTestId, slot } = useTestId("feedback", testId);
|
|
1980
1986
|
const IconComponent = icon ?? defaultIcons[severity2];
|
|
1981
|
-
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
1988
|
+
"div",
|
|
1989
|
+
{
|
|
1990
|
+
ref,
|
|
1991
|
+
role: roleBySeverity[severity2],
|
|
1992
|
+
className: styles.root,
|
|
1993
|
+
"data-testid": dataTestId,
|
|
1994
|
+
...rest,
|
|
1995
|
+
children: [
|
|
1996
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: styles.iconSlot, "data-testid": slot("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconComponent, {}) }),
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: styles.content, "data-testid": slot("content"), children: [
|
|
1998
|
+
title != null && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Typography, { variant: "h4", children: title }),
|
|
1999
|
+
children != null && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Typography, { variant: "body", color: "muted", children })
|
|
2000
|
+
] })
|
|
2001
|
+
]
|
|
2002
|
+
}
|
|
2003
|
+
);
|
|
1988
2004
|
});
|
|
1989
2005
|
|
|
1990
2006
|
// src/components/tooltip/index.tsx
|
|
@@ -3120,26 +3136,80 @@ function useStyles28() {
|
|
|
3120
3136
|
|
|
3121
3137
|
// src/components/snackbar/index.tsx
|
|
3122
3138
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
3123
|
-
var
|
|
3139
|
+
var DEFAULT_DURATION = 5e3;
|
|
3140
|
+
var Snackbar = (0, import_react63.forwardRef)(function Snackbar2({ open, message: message2, action, onClose, duration = DEFAULT_DURATION, testId }, ref) {
|
|
3124
3141
|
const { root: root24, message: messageClass, closeBtn: closeBtn2 } = useStyles28();
|
|
3125
3142
|
const { testId: dataTestId, slot } = useTestId("feedback", testId);
|
|
3143
|
+
const onCloseRef = (0, import_react63.useRef)(onClose);
|
|
3144
|
+
(0, import_react63.useEffect)(() => {
|
|
3145
|
+
onCloseRef.current = onClose;
|
|
3146
|
+
}, [onClose]);
|
|
3147
|
+
const interactingRef = (0, import_react63.useRef)({ hover: false, focus: false });
|
|
3148
|
+
const timeoutRef = (0, import_react63.useRef)();
|
|
3149
|
+
const clearTimer = (0, import_react63.useCallback)(() => {
|
|
3150
|
+
if (timeoutRef.current !== void 0) {
|
|
3151
|
+
clearTimeout(timeoutRef.current);
|
|
3152
|
+
timeoutRef.current = void 0;
|
|
3153
|
+
}
|
|
3154
|
+
}, []);
|
|
3155
|
+
const scheduleTimer = (0, import_react63.useCallback)(() => {
|
|
3156
|
+
clearTimer();
|
|
3157
|
+
if (!open || duration == null || !onCloseRef.current) return;
|
|
3158
|
+
if (interactingRef.current.hover || interactingRef.current.focus) return;
|
|
3159
|
+
timeoutRef.current = setTimeout(() => {
|
|
3160
|
+
onCloseRef.current?.();
|
|
3161
|
+
}, duration);
|
|
3162
|
+
}, [open, duration, clearTimer]);
|
|
3163
|
+
(0, import_react63.useEffect)(() => {
|
|
3164
|
+
scheduleTimer();
|
|
3165
|
+
return clearTimer;
|
|
3166
|
+
}, [scheduleTimer, clearTimer]);
|
|
3167
|
+
const handleMouseEnter = () => {
|
|
3168
|
+
interactingRef.current.hover = true;
|
|
3169
|
+
clearTimer();
|
|
3170
|
+
};
|
|
3171
|
+
const handleMouseLeave = () => {
|
|
3172
|
+
interactingRef.current.hover = false;
|
|
3173
|
+
scheduleTimer();
|
|
3174
|
+
};
|
|
3175
|
+
const handleFocus = () => {
|
|
3176
|
+
interactingRef.current.focus = true;
|
|
3177
|
+
clearTimer();
|
|
3178
|
+
};
|
|
3179
|
+
const handleBlur = () => {
|
|
3180
|
+
interactingRef.current.focus = false;
|
|
3181
|
+
scheduleTimer();
|
|
3182
|
+
};
|
|
3126
3183
|
if (!open || typeof document === "undefined") return null;
|
|
3127
3184
|
return (0, import_react_dom2.createPortal)(
|
|
3128
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
"
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3185
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
3186
|
+
"div",
|
|
3187
|
+
{
|
|
3188
|
+
ref,
|
|
3189
|
+
role: "status",
|
|
3190
|
+
className: root24,
|
|
3191
|
+
"data-testid": dataTestId,
|
|
3192
|
+
onMouseEnter: handleMouseEnter,
|
|
3193
|
+
onMouseLeave: handleMouseLeave,
|
|
3194
|
+
onFocus: handleFocus,
|
|
3195
|
+
onBlur: handleBlur,
|
|
3196
|
+
children: [
|
|
3197
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: messageClass, "data-testid": slot("message"), children: message2 }),
|
|
3198
|
+
action,
|
|
3199
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3200
|
+
"button",
|
|
3201
|
+
{
|
|
3202
|
+
type: "button",
|
|
3203
|
+
"aria-label": "Close",
|
|
3204
|
+
className: closeBtn2,
|
|
3205
|
+
"data-testid": slot("close"),
|
|
3206
|
+
onClick: onClose,
|
|
3207
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(XIcon, { size: 18 })
|
|
3208
|
+
}
|
|
3209
|
+
)
|
|
3210
|
+
]
|
|
3211
|
+
}
|
|
3212
|
+
),
|
|
3143
3213
|
document.body
|
|
3144
3214
|
);
|
|
3145
3215
|
});
|