@oods/components-react 0.4.0 → 0.4.2
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/README.md +1 -1
- package/dist/{chunk-OFTMKX3W.js → chunk-ICXOX5B3.js} +51 -2
- package/dist/index.cjs +488 -155
- package/dist/index.d.cts +25 -6
- package/dist/index.d.ts +25 -6
- package/dist/index.js +399 -117
- package/dist/ported.cjs +50 -1
- package/dist/ported.d.cts +2 -0
- package/dist/ported.d.ts +2 -0
- package/dist/ported.js +1 -1
- package/dist/types.d.cts +62 -1
- package/dist/types.d.ts +62 -1
- package/evidence/react-readiness.v1.json +146 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -32,4 +32,4 @@ Use matching versions of the OODS packages. These packages are separate from the
|
|
|
32
32
|
|
|
33
33
|
## License
|
|
34
34
|
|
|
35
|
-
Apache License 2.0. See [LICENSE](https://cdn.jsdelivr.net/npm/@oods/components-react@0.4.
|
|
35
|
+
Apache License 2.0. See [LICENSE](https://cdn.jsdelivr.net/npm/@oods/components-react@0.4.2/LICENSE) and [NOTICE](https://cdn.jsdelivr.net/npm/@oods/components-react@0.4.2/NOTICE). Generated output belongs to its user; installed package dependencies retain their own licenses.
|
|
@@ -636,6 +636,31 @@ var noSubscription = () => () => void 0;
|
|
|
636
636
|
var useIsomorphicLayoutEffect = typeof window === "undefined" ? React3.useEffect : React3.useLayoutEffect;
|
|
637
637
|
var canShowModal = () => typeof HTMLDialogElement !== "undefined" && typeof HTMLDialogElement.prototype.showModal === "function";
|
|
638
638
|
var hasContent = (node) => node !== void 0 && node !== null && node !== false && node !== "";
|
|
639
|
+
var pageLocks = 0;
|
|
640
|
+
var pageStyle;
|
|
641
|
+
function lockPageScroll() {
|
|
642
|
+
const page = document.documentElement;
|
|
643
|
+
if (pageLocks++ === 0) {
|
|
644
|
+
const scrollbar = window.innerWidth - page.clientWidth;
|
|
645
|
+
pageStyle = { overflow: page.style.overflow, paddingRight: page.style.paddingRight };
|
|
646
|
+
if (scrollbar > 0) page.style.paddingRight = `${parseFloat(getComputedStyle(page).paddingRight) + scrollbar}px`;
|
|
647
|
+
page.style.overflow = "hidden";
|
|
648
|
+
}
|
|
649
|
+
let held = true;
|
|
650
|
+
return () => {
|
|
651
|
+
if (!held) return;
|
|
652
|
+
held = false;
|
|
653
|
+
if (--pageLocks === 0 && pageStyle) {
|
|
654
|
+
page.style.overflow = pageStyle.overflow;
|
|
655
|
+
page.style.paddingRight = pageStyle.paddingRight;
|
|
656
|
+
pageStyle = void 0;
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
var outsideBox = (event, dialog) => {
|
|
661
|
+
const box = dialog.getBoundingClientRect();
|
|
662
|
+
return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
|
|
663
|
+
};
|
|
639
664
|
var Dialog = React3.forwardRef(
|
|
640
665
|
({
|
|
641
666
|
id,
|
|
@@ -650,12 +675,16 @@ var Dialog = React3.forwardRef(
|
|
|
650
675
|
className,
|
|
651
676
|
onClose,
|
|
652
677
|
onKeyDown,
|
|
678
|
+
onMouseDown,
|
|
679
|
+
onClick,
|
|
653
680
|
...rest
|
|
654
681
|
}, ref) => {
|
|
655
682
|
const generatedId = React3.useId().replace(/[^\w-]/g, "");
|
|
656
683
|
const dialogId = id ?? `oods-dialog-${generatedId}`;
|
|
657
684
|
const element = React3.useRef(null);
|
|
658
685
|
const openRef = React3.useRef(open);
|
|
686
|
+
const scrollLock = React3.useRef(null);
|
|
687
|
+
const pressedBackdrop = React3.useRef(false);
|
|
659
688
|
const serverMarkup = React3.useSyncExternalStore(noSubscription, () => false, () => true);
|
|
660
689
|
const managed = modal && !serverMarkup && canShowModal();
|
|
661
690
|
const setRef = React3.useCallback((node) => {
|
|
@@ -663,13 +692,19 @@ var Dialog = React3.forwardRef(
|
|
|
663
692
|
if (typeof ref === "function") ref(node);
|
|
664
693
|
else if (ref) ref.current = node;
|
|
665
694
|
}, [ref]);
|
|
695
|
+
const releaseScroll = React3.useCallback(() => {
|
|
696
|
+
scrollLock.current?.();
|
|
697
|
+
scrollLock.current = null;
|
|
698
|
+
}, []);
|
|
666
699
|
useIsomorphicLayoutEffect(() => {
|
|
667
700
|
openRef.current = open;
|
|
668
701
|
const dialog = element.current;
|
|
669
702
|
if (!dialog || !managed) return;
|
|
670
703
|
if (open && !dialog.open) dialog.showModal();
|
|
671
704
|
else if (!open && dialog.open) dialog.close();
|
|
705
|
+
if (open && dialog.open) scrollLock.current ??= lockPageScroll();
|
|
672
706
|
}, [open, managed]);
|
|
707
|
+
React3.useEffect(() => releaseScroll, [releaseScroll]);
|
|
673
708
|
const requestClose = (event) => {
|
|
674
709
|
event.preventDefault();
|
|
675
710
|
onClose?.();
|
|
@@ -691,7 +726,19 @@ var Dialog = React3.forwardRef(
|
|
|
691
726
|
},
|
|
692
727
|
onCancel: requestClose,
|
|
693
728
|
onClose: () => {
|
|
694
|
-
if (
|
|
729
|
+
if (element.current?.open) return;
|
|
730
|
+
releaseScroll();
|
|
731
|
+
if (openRef.current) onClose?.();
|
|
732
|
+
},
|
|
733
|
+
onMouseDown: (event) => {
|
|
734
|
+
onMouseDown?.(event);
|
|
735
|
+
pressedBackdrop.current = managed && event.target === event.currentTarget && outsideBox(event, event.currentTarget);
|
|
736
|
+
},
|
|
737
|
+
onClick: (event) => {
|
|
738
|
+
onClick?.(event);
|
|
739
|
+
const backdrop = pressedBackdrop.current && event.target === event.currentTarget && outsideBox(event, event.currentTarget);
|
|
740
|
+
pressedBackdrop.current = false;
|
|
741
|
+
if (backdrop && !event.defaultPrevented) onClose?.();
|
|
695
742
|
},
|
|
696
743
|
...rest,
|
|
697
744
|
children: [
|
|
@@ -1007,10 +1054,12 @@ var CancellationSummary = React3.forwardRef(
|
|
|
1007
1054
|
requestedAtField,
|
|
1008
1055
|
reasonField,
|
|
1009
1056
|
codeField,
|
|
1057
|
+
hideWhenDefault,
|
|
1010
1058
|
className,
|
|
1011
1059
|
...rest
|
|
1012
1060
|
}, ref) => {
|
|
1013
1061
|
const childValue = typeof children === "boolean" ? children ? "Yes" : "No" : children;
|
|
1062
|
+
if (hideWhenDefault === true && cancelAtPeriodEnd === false && !requestedAt && !reason && !code && (childValue === void 0 || childValue === null)) return null;
|
|
1014
1063
|
return /* @__PURE__ */ jsxs(
|
|
1015
1064
|
"section",
|
|
1016
1065
|
{
|
|
@@ -1353,4 +1402,4 @@ var RelativeTimestamp = React3.forwardRef(
|
|
|
1353
1402
|
);
|
|
1354
1403
|
RelativeTimestamp.displayName = "OODS.RelativeTimestamp";
|
|
1355
1404
|
|
|
1356
|
-
export { AuditTimeline, Badge, Banner, Button, CancellationSummary, Card, Checkbox, DatePicker, Dialog, Input, PaginationBar, PriceBadge, RelativeTimestamp, SearchInput, Select, StatusBadge, StatusTimeline, Switch, Text, Textarea };
|
|
1405
|
+
export { AuditTimeline, Badge, Banner, Button, CancellationSummary, Card, Checkbox, DatePicker, Dialog, Input, PaginationBar, PriceBadge, RelativeTimestamp, SearchInput, Select, StatusBadge, StatusIcon, StatusTimeline, Switch, Text, Textarea };
|