@scripso-homepad/ui 0.4.38 → 0.4.39
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/web/index.cjs +30 -13
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +13 -2
- package/dist/web/index.d.ts +13 -2
- package/dist/web/index.js +30 -14
- package/dist/web/index.js.map +1 -1
- package/package.json +1 -1
- package/src/web/components/ConfirmModal.tsx +5 -4
- package/src/web/components/Drawer.tsx +4 -1
- package/src/web/components/Modal.tsx +5 -12
- package/src/web/hooks/useBackdropDismiss.ts +44 -0
- package/src/web/index.ts +1 -0
package/dist/web/index.cjs
CHANGED
|
@@ -31201,6 +31201,26 @@ var styles3 = reactNative.StyleSheet.create({
|
|
|
31201
31201
|
flexShrink: 0
|
|
31202
31202
|
}
|
|
31203
31203
|
});
|
|
31204
|
+
function useBackdropDismiss(onDismiss, enabled = true) {
|
|
31205
|
+
const pointerDownOnBackdropRef = react.useRef(false);
|
|
31206
|
+
const onPointerDown = react.useCallback(
|
|
31207
|
+
(event) => {
|
|
31208
|
+
pointerDownOnBackdropRef.current = enabled && event.target === event.currentTarget;
|
|
31209
|
+
},
|
|
31210
|
+
[enabled]
|
|
31211
|
+
);
|
|
31212
|
+
const onClick = react.useCallback(
|
|
31213
|
+
(event) => {
|
|
31214
|
+
const shouldDismiss = enabled && pointerDownOnBackdropRef.current && event.target === event.currentTarget;
|
|
31215
|
+
pointerDownOnBackdropRef.current = false;
|
|
31216
|
+
if (shouldDismiss) {
|
|
31217
|
+
onDismiss();
|
|
31218
|
+
}
|
|
31219
|
+
},
|
|
31220
|
+
[enabled, onDismiss]
|
|
31221
|
+
);
|
|
31222
|
+
return { onPointerDown, onClick };
|
|
31223
|
+
}
|
|
31204
31224
|
var footerAlignClasses = {
|
|
31205
31225
|
left: "justify-start",
|
|
31206
31226
|
center: "justify-center",
|
|
@@ -31229,6 +31249,7 @@ function Modal({
|
|
|
31229
31249
|
contentClassName,
|
|
31230
31250
|
buttonClassName
|
|
31231
31251
|
}) {
|
|
31252
|
+
const backdropDismiss = useBackdropDismiss(onCancel, closeOnBackdrop);
|
|
31232
31253
|
react.useEffect(() => {
|
|
31233
31254
|
if (!open) {
|
|
31234
31255
|
return;
|
|
@@ -31257,11 +31278,8 @@ function Modal({
|
|
|
31257
31278
|
"div",
|
|
31258
31279
|
{
|
|
31259
31280
|
className: "fixed inset-0 z-[100] flex items-center justify-center p-4 backdrop-blur-[12px] bg-storm-gray-850/40",
|
|
31260
|
-
|
|
31261
|
-
|
|
31262
|
-
onCancel();
|
|
31263
|
-
}
|
|
31264
|
-
} : void 0,
|
|
31281
|
+
onPointerDown: backdropDismiss.onPointerDown,
|
|
31282
|
+
onClick: backdropDismiss.onClick,
|
|
31265
31283
|
role: "presentation",
|
|
31266
31284
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
31267
31285
|
"div",
|
|
@@ -31274,9 +31292,6 @@ function Modal({
|
|
|
31274
31292
|
"flex max-h-[min(90dvh,calc(100dvh-2rem))] w-full max-w-2xl flex-col gap-6 rounded-2xl bg-white p-4 opacity-100 md:p-6",
|
|
31275
31293
|
containerClassName
|
|
31276
31294
|
),
|
|
31277
|
-
onClick: (event) => {
|
|
31278
|
-
event.stopPropagation();
|
|
31279
|
-
},
|
|
31280
31295
|
children: [
|
|
31281
31296
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: cn("flex shrink-0", icon ? "items-center gap-2.5" : void 0), children: [
|
|
31282
31297
|
icon ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -31396,6 +31411,7 @@ function Drawer({
|
|
|
31396
31411
|
const [isPresent, setIsPresent] = react.useState(open);
|
|
31397
31412
|
const [isAnimatedIn, setIsAnimatedIn] = react.useState(false);
|
|
31398
31413
|
const [isTransformSettled, setIsTransformSettled] = react.useState(open);
|
|
31414
|
+
const backdropDismiss = useBackdropDismiss(onClose);
|
|
31399
31415
|
react.useEffect(() => {
|
|
31400
31416
|
if (open) {
|
|
31401
31417
|
setIsPresent(true);
|
|
@@ -31462,7 +31478,8 @@ function Drawer({
|
|
|
31462
31478
|
"absolute inset-0 z-0 cursor-pointer bg-storm-gray-850/40 backdrop-blur-[12px] transition-opacity duration-300 ease-in-out",
|
|
31463
31479
|
isAnimatedIn ? "opacity-100" : "opacity-0"
|
|
31464
31480
|
),
|
|
31465
|
-
|
|
31481
|
+
onPointerDown: backdropDismiss.onPointerDown,
|
|
31482
|
+
onClick: backdropDismiss.onClick
|
|
31466
31483
|
}
|
|
31467
31484
|
),
|
|
31468
31485
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -31798,6 +31815,7 @@ function ConfirmModal({
|
|
|
31798
31815
|
containerClassName,
|
|
31799
31816
|
buttonClassName
|
|
31800
31817
|
}) {
|
|
31818
|
+
const backdropDismiss = useBackdropDismiss(onCancel, closeOnBackdrop);
|
|
31801
31819
|
react.useEffect(() => {
|
|
31802
31820
|
if (!open) {
|
|
31803
31821
|
return;
|
|
@@ -31823,7 +31841,8 @@ function ConfirmModal({
|
|
|
31823
31841
|
"div",
|
|
31824
31842
|
{
|
|
31825
31843
|
className: "fixed inset-0 z-50 flex items-center justify-center p-4 backdrop-blur-md bg-storm-gray-850/40",
|
|
31826
|
-
|
|
31844
|
+
onPointerDown: backdropDismiss.onPointerDown,
|
|
31845
|
+
onClick: backdropDismiss.onClick,
|
|
31827
31846
|
role: "presentation",
|
|
31828
31847
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
31829
31848
|
"div",
|
|
@@ -31836,9 +31855,6 @@ function ConfirmModal({
|
|
|
31836
31855
|
"flex w-full max-w-md flex-col gap-8 rounded-3xl bg-white p-6 opacity-100 md:p-8",
|
|
31837
31856
|
containerClassName
|
|
31838
31857
|
),
|
|
31839
|
-
onClick: (event) => {
|
|
31840
|
-
event.stopPropagation();
|
|
31841
|
-
},
|
|
31842
31858
|
children: [
|
|
31843
31859
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
31844
31860
|
icon ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-14 items-center justify-center rounded-2xl bg-storm-gray-50 text-storm-gray-500", children: icon }) : null,
|
|
@@ -32007,6 +32023,7 @@ exports.getVisiblePageNumbers = getVisiblePageNumbers;
|
|
|
32007
32023
|
exports.isNavItemActive = isNavItemActive;
|
|
32008
32024
|
exports.runMutationWithToast = runMutationWithToast;
|
|
32009
32025
|
exports.tableRowDisabledCellClassName = tableRowDisabledCellClassName;
|
|
32026
|
+
exports.useBackdropDismiss = useBackdropDismiss;
|
|
32010
32027
|
exports.useMediaQuery = useMediaQuery;
|
|
32011
32028
|
exports.useOnClickOutside = useOnClickOutside;
|
|
32012
32029
|
//# sourceMappingURL=index.cjs.map
|