@faststore/ui 1.6.22 → 1.6.25
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 +30 -0
- package/dist/molecules/Dropdown/DropdownMenu.d.ts +2 -2
- package/dist/ui.cjs.development.js +48 -25
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +48 -25
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/molecules/Breadcrumb/Breadcrumb.test.tsx +14 -0
- package/src/molecules/Breadcrumb/Breadcrumb.tsx +15 -15
- package/src/molecules/Dropdown/Dropdown.test.tsx +119 -8
- package/src/molecules/Dropdown/Dropdown.tsx +44 -7
- package/src/molecules/Dropdown/DropdownMenu.tsx +8 -20
package/dist/ui.esm.js
CHANGED
|
@@ -1140,7 +1140,6 @@ const Breadcrumb = /*#__PURE__*/forwardRef(function Breadcrumb({
|
|
|
1140
1140
|
testId = 'store-breadcrumb',
|
|
1141
1141
|
...otherProps
|
|
1142
1142
|
}, ref) {
|
|
1143
|
-
const lastIndex = React.Children.count(children);
|
|
1144
1143
|
return React.createElement("nav", Object.assign({
|
|
1145
1144
|
"aria-label": "Breadcrumb",
|
|
1146
1145
|
role: "navigation",
|
|
@@ -1150,8 +1149,8 @@ const Breadcrumb = /*#__PURE__*/forwardRef(function Breadcrumb({
|
|
|
1150
1149
|
}, otherProps), React.createElement(List, {
|
|
1151
1150
|
"data-breadcrumb-list": true,
|
|
1152
1151
|
variant: "ordered"
|
|
1153
|
-
}, React.Children.
|
|
1154
|
-
const isLastItem = index ===
|
|
1152
|
+
}, React.Children.toArray(children).map((child, index, childrenArray) => {
|
|
1153
|
+
const isLastItem = index === childrenArray.length - 1;
|
|
1155
1154
|
return React.createElement(ListItem, {
|
|
1156
1155
|
isLastItem: isLastItem,
|
|
1157
1156
|
divider: rawDivider,
|
|
@@ -1570,19 +1569,30 @@ const Dropdown = ({
|
|
|
1570
1569
|
const dropdownItemsRef = useRef([]);
|
|
1571
1570
|
const selectedDropdownItemIndexRef = useRef(0);
|
|
1572
1571
|
const dropdownButtonRef = useRef(null);
|
|
1572
|
+
const close = useCallback(() => {
|
|
1573
|
+
var _dropdownButtonRef$cu;
|
|
1573
1574
|
|
|
1574
|
-
const close = () => {
|
|
1575
1575
|
setIsOpen(false);
|
|
1576
|
-
|
|
1576
|
+
onDismiss == null ? void 0 : onDismiss();
|
|
1577
|
+
(_dropdownButtonRef$cu = dropdownButtonRef.current) == null ? void 0 : _dropdownButtonRef$cu.focus();
|
|
1578
|
+
}, [onDismiss]);
|
|
1577
1579
|
|
|
1578
1580
|
const open = () => {
|
|
1579
1581
|
setIsOpen(true);
|
|
1580
1582
|
};
|
|
1581
1583
|
|
|
1582
|
-
const toggle = () => {
|
|
1583
|
-
setIsOpen(old =>
|
|
1584
|
-
|
|
1584
|
+
const toggle = useCallback(() => {
|
|
1585
|
+
setIsOpen(old => {
|
|
1586
|
+
if (old) {
|
|
1587
|
+
var _dropdownButtonRef$cu2;
|
|
1588
|
+
|
|
1589
|
+
onDismiss == null ? void 0 : onDismiss();
|
|
1590
|
+
(_dropdownButtonRef$cu2 = dropdownButtonRef.current) == null ? void 0 : _dropdownButtonRef$cu2.focus();
|
|
1591
|
+
}
|
|
1585
1592
|
|
|
1593
|
+
return !old;
|
|
1594
|
+
});
|
|
1595
|
+
}, [onDismiss]);
|
|
1586
1596
|
useEffect(() => {
|
|
1587
1597
|
setIsOpen(isOpenDefault);
|
|
1588
1598
|
}, [isOpenDefault]);
|
|
@@ -1591,6 +1601,30 @@ const Dropdown = ({
|
|
|
1591
1601
|
|
|
1592
1602
|
isOpen && (dropdownItemsRef == null ? void 0 : (_dropdownItemsRef$cur = dropdownItemsRef.current[0]) == null ? void 0 : _dropdownItemsRef$cur.focus());
|
|
1593
1603
|
}, [isOpen]);
|
|
1604
|
+
useEffect(() => {
|
|
1605
|
+
let firstClick = true;
|
|
1606
|
+
|
|
1607
|
+
const event = e => {
|
|
1608
|
+
const someItemWasClicked = dropdownItemsRef == null ? void 0 : dropdownItemsRef.current.some(item => e.target === item);
|
|
1609
|
+
|
|
1610
|
+
if (firstClick) {
|
|
1611
|
+
firstClick = false;
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
!someItemWasClicked && close();
|
|
1616
|
+
};
|
|
1617
|
+
|
|
1618
|
+
if (isOpen) {
|
|
1619
|
+
document.addEventListener('click', event);
|
|
1620
|
+
} else {
|
|
1621
|
+
document.removeEventListener('click', event);
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
return () => {
|
|
1625
|
+
document.removeEventListener('click', event);
|
|
1626
|
+
};
|
|
1627
|
+
}, [close, isOpen]);
|
|
1594
1628
|
const value = useMemo(() => {
|
|
1595
1629
|
return {
|
|
1596
1630
|
isOpen,
|
|
@@ -1603,7 +1637,7 @@ const Dropdown = ({
|
|
|
1603
1637
|
dropdownItemsRef,
|
|
1604
1638
|
id
|
|
1605
1639
|
};
|
|
1606
|
-
}, [id, isOpen, onDismiss]);
|
|
1640
|
+
}, [close, id, isOpen, onDismiss, toggle]);
|
|
1607
1641
|
return React.createElement(DropdownContext.Provider, {
|
|
1608
1642
|
value: value
|
|
1609
1643
|
}, children);
|
|
@@ -1736,23 +1770,12 @@ const DropdownMenu = ({
|
|
|
1736
1770
|
const {
|
|
1737
1771
|
isOpen,
|
|
1738
1772
|
close,
|
|
1739
|
-
onDismiss,
|
|
1740
1773
|
dropdownItemsRef,
|
|
1741
1774
|
selectedDropdownItemIndexRef,
|
|
1742
1775
|
id
|
|
1743
1776
|
} = useDropdown();
|
|
1744
1777
|
const dropdownPosition = useDropdownPosition();
|
|
1745
|
-
const childrenLength = children.length;
|
|
1746
|
-
|
|
1747
|
-
const handleBackdropClick = event => {
|
|
1748
|
-
if (event.defaultPrevented) {
|
|
1749
|
-
return;
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
event.stopPropagation();
|
|
1753
|
-
onDismiss == null ? void 0 : onDismiss();
|
|
1754
|
-
close == null ? void 0 : close();
|
|
1755
|
-
};
|
|
1778
|
+
const childrenLength = React.Children.toArray(children).length;
|
|
1756
1779
|
|
|
1757
1780
|
const handleDownPress = () => {
|
|
1758
1781
|
var _dropdownItemsRef$cur;
|
|
@@ -1793,7 +1816,6 @@ const DropdownMenu = ({
|
|
|
1793
1816
|
};
|
|
1794
1817
|
|
|
1795
1818
|
const handleEscapePress = () => {
|
|
1796
|
-
onDismiss == null ? void 0 : onDismiss();
|
|
1797
1819
|
close == null ? void 0 : close();
|
|
1798
1820
|
};
|
|
1799
1821
|
|
|
@@ -1816,10 +1838,11 @@ const DropdownMenu = ({
|
|
|
1816
1838
|
return null;
|
|
1817
1839
|
};
|
|
1818
1840
|
|
|
1819
|
-
return isOpen ? createPortal(React.createElement(
|
|
1841
|
+
return isOpen ? createPortal(React.createElement("div", {
|
|
1842
|
+
role: "presentation",
|
|
1820
1843
|
"data-store-dropdown-overlay": true,
|
|
1821
|
-
|
|
1822
|
-
|
|
1844
|
+
onKeyDown: handleBackdropKeyDown,
|
|
1845
|
+
"data-testid": `${testId}-overlay`
|
|
1823
1846
|
}, React.createElement("div", Object.assign({
|
|
1824
1847
|
role: "menu",
|
|
1825
1848
|
"aria-orientation": "vertical",
|