@kazee-ds/react 0.5.0 → 0.5.1
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.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/types/Toast.d.ts +8 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3056,7 +3056,7 @@ var QueueAdapter = class extends UNSTABLE_ToastQueue {
|
|
|
3056
3056
|
}
|
|
3057
3057
|
};
|
|
3058
3058
|
var ToastContext = createContext(null);
|
|
3059
|
-
function ToastProvider({ children, manager: suppliedManager, placement = "bottom-end", label = "Notifikasi / Notifications", closeLabel = "Tutup notifikasi / Close notification", hotkey = ["Alt", "t"], dir = "ltr", showProgress = false, swipeThreshold = 50, renderToast }) {
|
|
3059
|
+
function ToastProvider({ children, manager: suppliedManager, placement = "bottom-end", label = "Notifikasi / Notifications", closeLabel = "Tutup notifikasi / Close notification", hotkey = ["Alt", "t"], dir = "ltr", showProgress = false, showCloseButton = false, swipeThreshold = 50, renderToast }) {
|
|
3060
3060
|
const [ownedManager] = useState(() => createToastManager());
|
|
3061
3061
|
const manager = suppliedManager ?? ownedManager;
|
|
3062
3062
|
const queue = useMemo(() => new QueueAdapter(manager), [manager]);
|
|
@@ -3186,6 +3186,7 @@ function ToastProvider({ children, manager: suppliedManager, placement = "bottom
|
|
|
3186
3186
|
placement,
|
|
3187
3187
|
dir,
|
|
3188
3188
|
showProgress,
|
|
3189
|
+
showCloseButton,
|
|
3189
3190
|
swipeThreshold,
|
|
3190
3191
|
restoreFocus: () => {
|
|
3191
3192
|
const next = region.current?.querySelector(".toast[data-state=\"open\"]");
|
|
@@ -3238,12 +3239,14 @@ function Indicator({ entry }) {
|
|
|
3238
3239
|
}), /* @__PURE__ */ jsx("path", { d: "M12 10v7m0-11v1" })] })
|
|
3239
3240
|
});
|
|
3240
3241
|
}
|
|
3241
|
-
function Toast({ entry, indicator, children, className }) {
|
|
3242
|
+
function Toast({ entry, indicator, children, className, showCloseButton: closeOverride, showProgress: progressOverride }) {
|
|
3242
3243
|
const actionDescriptionId = useId();
|
|
3243
3244
|
const cancelDescriptionId = useId();
|
|
3244
3245
|
const context = useContext(ToastContext);
|
|
3245
3246
|
if (!context) throw new Error("Toast must be used within a ToastProvider region.");
|
|
3246
|
-
const { manager, closeLabel, placement, dir,
|
|
3247
|
+
const { manager, closeLabel, placement, dir, swipeThreshold, restoreFocus } = context;
|
|
3248
|
+
const showCloseButton = closeOverride ?? context.showCloseButton;
|
|
3249
|
+
const showProgress = progressOverride ?? context.showProgress;
|
|
3247
3250
|
const ref = useRef(null);
|
|
3248
3251
|
const drag = useRef(null);
|
|
3249
3252
|
const [offset, setOffset] = useState(0);
|
|
@@ -3338,6 +3341,7 @@ function Toast({ entry, indicator, children, className }) {
|
|
|
3338
3341
|
className: `toast${className ? ` ${className}` : ""}`,
|
|
3339
3342
|
"data-toast-id": entry.id,
|
|
3340
3343
|
"data-tone": entry.tone,
|
|
3344
|
+
"data-has-close": showCloseButton || void 0,
|
|
3341
3345
|
"data-loading": entry.isLoading || void 0,
|
|
3342
3346
|
"data-state": entry.state,
|
|
3343
3347
|
"data-placement": placement,
|
|
@@ -3403,7 +3407,7 @@ function Toast({ entry, indicator, children, className }) {
|
|
|
3403
3407
|
})
|
|
3404
3408
|
]
|
|
3405
3409
|
}),
|
|
3406
|
-
/* @__PURE__ */ jsx(Button$5, {
|
|
3410
|
+
showCloseButton && /* @__PURE__ */ jsx(Button$5, {
|
|
3407
3411
|
slot: "close",
|
|
3408
3412
|
className: "toast__close",
|
|
3409
3413
|
"aria-label": closeLabel,
|