@basic-ui/core 0.0.35 → 0.0.38
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/build/cjs/index.js +84 -83
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +0 -0
- package/build/esm/Accordion/Accordion.js +0 -0
- package/build/esm/Accordion/Accordion.js.map +0 -0
- package/build/esm/Accordion/AccordionBody.d.ts +0 -0
- package/build/esm/Accordion/AccordionBody.js +0 -0
- package/build/esm/Accordion/AccordionBody.js.map +0 -0
- package/build/esm/Accordion/AccordionHeader.d.ts +0 -0
- package/build/esm/Accordion/AccordionHeader.js +0 -0
- package/build/esm/Accordion/AccordionHeader.js.map +0 -0
- package/build/esm/Accordion/AccordionItem.d.ts +0 -0
- package/build/esm/Accordion/AccordionItem.js +1 -2
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +0 -0
- package/build/esm/Accordion/context.js +0 -0
- package/build/esm/Accordion/context.js.map +0 -0
- package/build/esm/Accordion/index.d.ts +0 -0
- package/build/esm/Accordion/index.js +0 -0
- package/build/esm/Accordion/index.js.map +0 -0
- package/build/esm/Accordion/scopeQuery.d.ts +0 -0
- package/build/esm/Accordion/scopeQuery.js +0 -0
- package/build/esm/Accordion/scopeQuery.js.map +0 -0
- package/build/esm/CheckBox/CheckBox.d.ts +0 -0
- package/build/esm/CheckBox/CheckBox.js +0 -0
- package/build/esm/CheckBox/CheckBox.js.map +0 -0
- package/build/esm/CheckBox/index.d.ts +0 -0
- package/build/esm/CheckBox/index.js +0 -0
- package/build/esm/CheckBox/index.js.map +0 -0
- package/build/esm/ComboBox/Combobox.d.ts +0 -0
- package/build/esm/ComboBox/Combobox.js +2 -2
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxButton.js +0 -0
- package/build/esm/ComboBox/ComboboxButton.js.map +0 -0
- package/build/esm/ComboBox/ComboboxInput.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxInput.js +0 -0
- package/build/esm/ComboBox/ComboboxInput.js.map +0 -0
- package/build/esm/ComboBox/ComboboxLabel.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxLabel.js +0 -0
- package/build/esm/ComboBox/ComboboxLabel.js.map +0 -0
- package/build/esm/ComboBox/ComboboxList.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxList.js +0 -0
- package/build/esm/ComboBox/ComboboxList.js.map +0 -0
- package/build/esm/ComboBox/ComboboxOption.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxOption.js +0 -0
- package/build/esm/ComboBox/ComboboxOption.js.map +0 -0
- package/build/esm/ComboBox/ComboboxPopover.d.ts +0 -0
- package/build/esm/ComboBox/ComboboxPopover.js +0 -0
- package/build/esm/ComboBox/ComboboxPopover.js.map +0 -0
- package/build/esm/ComboBox/cities.d.ts +0 -0
- package/build/esm/ComboBox/cities.js +0 -0
- package/build/esm/ComboBox/cities.js.map +0 -0
- package/build/esm/ComboBox/context.d.ts +0 -0
- package/build/esm/ComboBox/context.js +0 -0
- package/build/esm/ComboBox/context.js.map +0 -0
- package/build/esm/ComboBox/hooks.d.ts +0 -0
- package/build/esm/ComboBox/hooks.js +0 -0
- package/build/esm/ComboBox/hooks.js.map +0 -0
- package/build/esm/ComboBox/index.d.ts +0 -0
- package/build/esm/ComboBox/index.js +0 -0
- package/build/esm/ComboBox/index.js.map +0 -0
- package/build/esm/ComboBox/makeHash.d.ts +0 -0
- package/build/esm/ComboBox/makeHash.js +0 -0
- package/build/esm/ComboBox/makeHash.js.map +0 -0
- package/build/esm/ComboBox/scopeQuery.d.ts +0 -0
- package/build/esm/ComboBox/scopeQuery.js +0 -0
- package/build/esm/ComboBox/scopeQuery.js.map +0 -0
- package/build/esm/FocusLock/FocusLock.d.ts +0 -0
- package/build/esm/FocusLock/FocusLock.js +0 -0
- package/build/esm/FocusLock/FocusLock.js.map +0 -0
- package/build/esm/FocusLock/index.d.ts +0 -0
- package/build/esm/FocusLock/index.js +0 -0
- package/build/esm/FocusLock/index.js.map +0 -0
- package/build/esm/FocusLock/tabUtils.d.ts +1 -0
- package/build/esm/FocusLock/tabUtils.js +12 -0
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +0 -0
- package/build/esm/FocusLock/useFocusLock.js +4 -11
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +0 -0
- package/build/esm/List/List.js +0 -0
- package/build/esm/List/List.js.map +0 -0
- package/build/esm/List/ListItem.d.ts +0 -0
- package/build/esm/List/ListItem.js +0 -0
- package/build/esm/List/ListItem.js.map +0 -0
- package/build/esm/List/context.d.ts +0 -0
- package/build/esm/List/context.js +0 -0
- package/build/esm/List/context.js.map +0 -0
- package/build/esm/List/index.d.ts +0 -0
- package/build/esm/List/index.js +0 -0
- package/build/esm/List/index.js.map +0 -0
- package/build/esm/Menu/Menu.d.ts +0 -0
- package/build/esm/Menu/Menu.js +1 -2
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +0 -0
- package/build/esm/Menu/MenuButton.js +3 -3
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +0 -0
- package/build/esm/Menu/MenuItem.js +3 -4
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +0 -0
- package/build/esm/Menu/MenuList.js +0 -0
- package/build/esm/Menu/MenuList.js.map +0 -0
- package/build/esm/Menu/MenuPopover.d.ts +0 -0
- package/build/esm/Menu/MenuPopover.js +0 -0
- package/build/esm/Menu/MenuPopover.js.map +0 -0
- package/build/esm/Menu/context.d.ts +0 -0
- package/build/esm/Menu/context.js +0 -0
- package/build/esm/Menu/context.js.map +0 -0
- package/build/esm/Menu/index.d.ts +0 -0
- package/build/esm/Menu/index.js +0 -0
- package/build/esm/Menu/index.js.map +0 -0
- package/build/esm/Menu/scope.d.ts +0 -0
- package/build/esm/Menu/scope.js +0 -0
- package/build/esm/Menu/scope.js.map +0 -0
- package/build/esm/Modal/Modal.d.ts +0 -0
- package/build/esm/Modal/Modal.js +2 -2
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +0 -0
- package/build/esm/Modal/ModalBackdrop.js +0 -0
- package/build/esm/Modal/ModalBackdrop.js.map +0 -0
- package/build/esm/Modal/index.d.ts +0 -0
- package/build/esm/Modal/index.js +0 -0
- package/build/esm/Modal/index.js.map +0 -0
- package/build/esm/Popper/Popper.d.ts +0 -0
- package/build/esm/Popper/Popper.js +5 -0
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +0 -0
- package/build/esm/Popper/PopperArrow.js +0 -0
- package/build/esm/Popper/PopperArrow.js.map +0 -0
- package/build/esm/Popper/context.d.ts +0 -0
- package/build/esm/Popper/context.js +0 -0
- package/build/esm/Popper/context.js.map +0 -0
- package/build/esm/Popper/index.d.ts +0 -0
- package/build/esm/Popper/index.js +0 -0
- package/build/esm/Popper/index.js.map +0 -0
- package/build/esm/Portal/Portal.d.ts +0 -0
- package/build/esm/Portal/Portal.js +0 -0
- package/build/esm/Portal/Portal.js.map +0 -0
- package/build/esm/Portal/index.d.ts +0 -0
- package/build/esm/Portal/index.js +0 -0
- package/build/esm/Portal/index.js.map +0 -0
- package/build/esm/RadioButton/RadioButton.d.ts +0 -0
- package/build/esm/RadioButton/RadioButton.js +0 -0
- package/build/esm/RadioButton/RadioButton.js.map +0 -0
- package/build/esm/RadioButton/RadioGroup.d.ts +0 -0
- package/build/esm/RadioButton/RadioGroup.js +2 -2
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +0 -0
- package/build/esm/RadioButton/context.js +0 -0
- package/build/esm/RadioButton/context.js.map +0 -0
- package/build/esm/RadioButton/index.d.ts +0 -0
- package/build/esm/RadioButton/index.js +0 -0
- package/build/esm/RadioButton/index.js.map +0 -0
- package/build/esm/SkipNav/SkipNav.d.ts +0 -0
- package/build/esm/SkipNav/SkipNav.js +0 -0
- package/build/esm/SkipNav/SkipNav.js.map +0 -0
- package/build/esm/SkipNav/index.d.ts +0 -0
- package/build/esm/SkipNav/index.js +0 -0
- package/build/esm/SkipNav/index.js.map +0 -0
- package/build/esm/Spinner/Spinner.d.ts +0 -0
- package/build/esm/Spinner/Spinner.js +0 -0
- package/build/esm/Spinner/Spinner.js.map +0 -0
- package/build/esm/Spinner/SpinnerButton.d.ts +0 -0
- package/build/esm/Spinner/SpinnerButton.js +0 -0
- package/build/esm/Spinner/SpinnerButton.js.map +0 -0
- package/build/esm/Spinner/context.d.ts +0 -0
- package/build/esm/Spinner/context.js +0 -0
- package/build/esm/Spinner/context.js.map +0 -0
- package/build/esm/Spinner/index.d.ts +0 -0
- package/build/esm/Spinner/index.js +0 -0
- package/build/esm/Spinner/index.js.map +0 -0
- package/build/esm/Tabs/Tab.d.ts +0 -0
- package/build/esm/Tabs/Tab.js +0 -0
- package/build/esm/Tabs/Tab.js.map +0 -0
- package/build/esm/Tabs/TabList.d.ts +0 -0
- package/build/esm/Tabs/TabList.js +2 -2
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +0 -0
- package/build/esm/Tabs/TabPanel.js +0 -0
- package/build/esm/Tabs/TabPanel.js.map +0 -0
- package/build/esm/Tabs/TabPanels.d.ts +0 -0
- package/build/esm/Tabs/TabPanels.js +0 -0
- package/build/esm/Tabs/TabPanels.js.map +0 -0
- package/build/esm/Tabs/Tabs.d.ts +0 -0
- package/build/esm/Tabs/Tabs.js +0 -0
- package/build/esm/Tabs/Tabs.js.map +0 -0
- package/build/esm/Tabs/context.d.ts +0 -0
- package/build/esm/Tabs/context.js +0 -0
- package/build/esm/Tabs/context.js.map +0 -0
- package/build/esm/Tabs/index.d.ts +0 -0
- package/build/esm/Tabs/index.js +0 -0
- package/build/esm/Tabs/index.js.map +0 -0
- package/build/esm/Tabs/scopeQuery.d.ts +0 -0
- package/build/esm/Tabs/scopeQuery.js +0 -0
- package/build/esm/Tabs/scopeQuery.js.map +0 -0
- package/build/esm/Tooltip/Tooltip.d.ts +0 -0
- package/build/esm/Tooltip/Tooltip.js +0 -0
- package/build/esm/Tooltip/Tooltip.js.map +0 -0
- package/build/esm/Tooltip/index.d.ts +0 -0
- package/build/esm/Tooltip/index.js +0 -0
- package/build/esm/Tooltip/index.js.map +0 -0
- package/build/esm/Tooltip/stateMachine.d.ts +0 -0
- package/build/esm/Tooltip/stateMachine.js +0 -0
- package/build/esm/Tooltip/stateMachine.js.map +0 -0
- package/build/esm/Tooltip/useTooltip.d.ts +1 -1
- package/build/esm/Tooltip/useTooltip.js +2 -3
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.d.ts +0 -1
- package/build/esm/hooks/index.js +0 -1
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useAutoFocus.d.ts +0 -0
- package/build/esm/hooks/useAutoFocus.js +5 -1
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.d.ts +0 -0
- package/build/esm/hooks/useChildrenCounter.js +0 -0
- package/build/esm/hooks/useChildrenCounter.js.map +0 -0
- package/build/esm/hooks/useControlledState.d.ts +0 -0
- package/build/esm/hooks/useControlledState.js +0 -0
- package/build/esm/hooks/useControlledState.js.map +0 -0
- package/build/esm/hooks/useFocusReturn.d.ts +2 -1
- package/build/esm/hooks/useFocusReturn.js +24 -13
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +2 -2
- package/build/esm/hooks/useFocusState.js +0 -0
- package/build/esm/hooks/useFocusState.js.map +0 -0
- package/build/esm/hooks/useGestureHandlers.d.ts +0 -0
- package/build/esm/hooks/useGestureHandlers.js +0 -0
- package/build/esm/hooks/useGestureHandlers.js.map +0 -0
- package/build/esm/hooks/useId.d.ts +0 -0
- package/build/esm/hooks/useId.js +0 -0
- package/build/esm/hooks/useId.js.map +0 -0
- package/build/esm/hooks/useMeasure.d.ts +0 -0
- package/build/esm/hooks/useMeasure.js +0 -0
- package/build/esm/hooks/useMeasure.js.map +0 -0
- package/build/esm/hooks/useOnClickOutside.d.ts +0 -0
- package/build/esm/hooks/useOnClickOutside.js +0 -0
- package/build/esm/hooks/useOnClickOutside.js.map +0 -0
- package/build/esm/hooks/useOnKeyDown.d.ts +0 -0
- package/build/esm/hooks/useOnKeyDown.js +0 -0
- package/build/esm/hooks/useOnKeyDown.js.map +0 -0
- package/build/esm/hooks/useReducerMachine.d.ts +0 -0
- package/build/esm/hooks/useReducerMachine.js +0 -0
- package/build/esm/hooks/useReducerMachine.js.map +0 -0
- package/build/esm/hooks/useRemoveBodyScroll.d.ts +0 -0
- package/build/esm/hooks/useRemoveBodyScroll.js +12 -19
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +0 -0
- package/build/esm/hooks/useScope.js +0 -0
- package/build/esm/hooks/useScope.js.map +0 -0
- package/build/esm/hooks/useThrottle.d.ts +0 -0
- package/build/esm/hooks/useThrottle.js +0 -0
- package/build/esm/hooks/useThrottle.js.map +0 -0
- package/build/esm/index.d.ts +0 -0
- package/build/esm/index.js +0 -0
- package/build/esm/index.js.map +0 -0
- package/build/esm/utils/assignRef.d.ts +0 -0
- package/build/esm/utils/assignRef.js +0 -0
- package/build/esm/utils/assignRef.js.map +0 -0
- package/build/esm/utils/clamp.d.ts +0 -0
- package/build/esm/utils/clamp.js +0 -0
- package/build/esm/utils/clamp.js.map +0 -0
- package/build/esm/utils/createSubscription.d.ts +0 -0
- package/build/esm/utils/createSubscription.js +0 -0
- package/build/esm/utils/createSubscription.js.map +0 -0
- package/build/esm/utils/getCircularIndex.d.ts +0 -0
- package/build/esm/utils/getCircularIndex.js +0 -0
- package/build/esm/utils/getCircularIndex.js.map +0 -0
- package/build/esm/utils/index.d.ts +0 -0
- package/build/esm/utils/index.js +0 -0
- package/build/esm/utils/index.js.map +0 -0
- package/build/esm/utils/rubberBandClamp.d.ts +0 -0
- package/build/esm/utils/rubberBandClamp.js +0 -0
- package/build/esm/utils/rubberBandClamp.js.map +0 -0
- package/build/esm/utils/wrapEvent.d.ts +0 -0
- package/build/esm/utils/wrapEvent.js +0 -0
- package/build/esm/utils/wrapEvent.js.map +0 -0
- package/build/tsconfig.tsbuildinfo +1 -7127
- package/package.json +15 -15
- package/src/Accordion/Accordion.story.tsx +5 -4
- package/src/Accordion/AccordionItem.tsx +1 -2
- package/src/ComboBox/ComboBox.story.tsx +11 -9
- package/src/ComboBox/Combobox.tsx +2 -2
- package/src/FocusLock/tabUtils.ts +12 -0
- package/src/FocusLock/useFocusLock.ts +4 -11
- package/src/List/List.story.tsx +5 -4
- package/src/Menu/Menu.story.tsx +9 -8
- package/src/Menu/Menu.tsx +1 -2
- package/src/Menu/MenuButton.tsx +3 -3
- package/src/Menu/MenuItem.tsx +4 -6
- package/src/Modal/Modal.story.tsx +34 -19
- package/src/Modal/Modal.tsx +2 -2
- package/src/Modal/NavDrawer.story.tsx +5 -4
- package/src/Popper/Popper.story.tsx +13 -16
- package/src/Popper/Popper.tsx +4 -0
- package/src/RadioButton/RadioButton.story.tsx +12 -9
- package/src/RadioButton/RadioGroup.tsx +2 -2
- package/src/Spinner/Spinner.story.tsx +5 -5
- package/src/Tabs/Tab.story.tsx +9 -8
- package/src/Tabs/TabList.tsx +9 -2
- package/src/Tooltip/Tooltip.story.tsx +6 -5
- package/src/Tooltip/useTooltip.ts +2 -3
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useAutoFocus.ts +8 -1
- package/src/hooks/useFocusReturn.ts +33 -14
- package/src/hooks/useRemoveBodyScroll.ts +10 -18
- package/src/hooks/useId.ts +0 -18
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,4 +8,16 @@ export const getTabblableNodes = parentNode => {
|
|
|
8
8
|
|
|
9
9
|
return Array.from(parentNode.querySelectorAll(tabblable));
|
|
10
10
|
};
|
|
11
|
+
export function focusOnChildNode(parentNode, itemIndex) {
|
|
12
|
+
const elements = getTabblableNodes(parentNode);
|
|
13
|
+
|
|
14
|
+
if (elements.length > 0) {
|
|
15
|
+
elements[itemIndex === -1 ? elements.length - 1 : 0].focus();
|
|
16
|
+
} else {
|
|
17
|
+
const currentTabIndex = parentNode.tabIndex;
|
|
18
|
+
parentNode.tabIndex = 0;
|
|
19
|
+
parentNode.focus();
|
|
20
|
+
parentNode.tabIndex = currentTabIndex;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
11
23
|
//# sourceMappingURL=tabUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/FocusLock/tabUtils.ts"],"names":["tabblable","join","getTabblableNodes","parentNode","Array","from","querySelectorAll"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG,CACvB,gCADuB,EAEvB,gCAFuB,EAGvB,kCAHuB,EAIvB,+BAJuB,EAMvB,SANuB,EAOvB,YAPuB,EASvB,QATuB,EAUvB,QAVuB,EAWvB,OAXuB,EAavB,YAbuB,EAcvB,mBAduB,EAevB,aAfuB,EAgBvBC,IAhBuB,CAgBlB,GAhBkB,CAAlB;AAkBP;;AACA,OAAO,MAAMC,iBAAiB,GAC5BC,UAD+B,IAEb;AAClB,MAAI,CAACA,UAAL,EAAiB;AACf,WAAO,EAAP;AACD;;AAED,SAAOC,KAAK,CAACC,IAAN,CAAWF,UAAU,CAACG,gBAAX,CAA4BN,SAA5B,CAAX,CAAP;AACD,CARM","sourcesContent":["export const tabblable = [\n 'button:enabled:not([readonly])',\n 'select:enabled:not([readonly])',\n 'textarea:enabled:not([readonly])',\n 'input:enabled:not([readonly])',\n\n 'a[href]',\n 'area[href]',\n\n 'iframe',\n 'object',\n 'embed',\n\n '[tabindex]',\n '[contenteditable]',\n '[autofocus]',\n].join(',');\n\n/* This is naive and will not consider tabIndex */\nexport const getTabblableNodes = (\n parentNode: HTMLElement | null\n): HTMLElement[] => {\n if (!parentNode) {\n return [];\n }\n\n return Array.from(parentNode.querySelectorAll(tabblable));\n};\n"],"file":"tabUtils.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/FocusLock/tabUtils.ts"],"names":["tabblable","join","getTabblableNodes","parentNode","Array","from","querySelectorAll","focusOnChildNode","itemIndex","elements","length","focus","currentTabIndex","tabIndex"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG,CACvB,gCADuB,EAEvB,gCAFuB,EAGvB,kCAHuB,EAIvB,+BAJuB,EAMvB,SANuB,EAOvB,YAPuB,EASvB,QATuB,EAUvB,QAVuB,EAWvB,OAXuB,EAavB,YAbuB,EAcvB,mBAduB,EAevB,aAfuB,EAgBvBC,IAhBuB,CAgBlB,GAhBkB,CAAlB;AAkBP;;AACA,OAAO,MAAMC,iBAAiB,GAC5BC,UAD+B,IAEb;AAClB,MAAI,CAACA,UAAL,EAAiB;AACf,WAAO,EAAP;AACD;;AAED,SAAOC,KAAK,CAACC,IAAN,CAAWF,UAAU,CAACG,gBAAX,CAA4BN,SAA5B,CAAX,CAAP;AACD,CARM;AAUP,OAAO,SAASO,gBAAT,CAA0BJ,UAA1B,EAAmDK,SAAnD,EAAsE;AAC3E,QAAMC,QAAQ,GAAGP,iBAAiB,CAACC,UAAD,CAAlC;;AACA,MAAIM,QAAQ,CAACC,MAAT,GAAkB,CAAtB,EAAyB;AACvBD,IAAAA,QAAQ,CAACD,SAAS,KAAK,CAAC,CAAf,GAAmBC,QAAQ,CAACC,MAAT,GAAkB,CAArC,GAAyC,CAA1C,CAAR,CAAqDC,KAArD;AACD,GAFD,MAEO;AACL,UAAMC,eAAe,GAAGT,UAAU,CAACU,QAAnC;AACAV,IAAAA,UAAU,CAACU,QAAX,GAAsB,CAAtB;AACAV,IAAAA,UAAU,CAACQ,KAAX;AACAR,IAAAA,UAAU,CAACU,QAAX,GAAsBD,eAAtB;AACD;AACF","sourcesContent":["export const tabblable = [\n 'button:enabled:not([readonly])',\n 'select:enabled:not([readonly])',\n 'textarea:enabled:not([readonly])',\n 'input:enabled:not([readonly])',\n\n 'a[href]',\n 'area[href]',\n\n 'iframe',\n 'object',\n 'embed',\n\n '[tabindex]',\n '[contenteditable]',\n '[autofocus]',\n].join(',');\n\n/* This is naive and will not consider tabIndex */\nexport const getTabblableNodes = (\n parentNode: HTMLElement | null\n): HTMLElement[] => {\n if (!parentNode) {\n return [];\n }\n\n return Array.from(parentNode.querySelectorAll(tabblable));\n};\n\nexport function focusOnChildNode(parentNode: HTMLElement, itemIndex: 0 | -1) {\n const elements = getTabblableNodes(parentNode);\n if (elements.length > 0) {\n elements[itemIndex === -1 ? elements.length - 1 : 0].focus();\n } else {\n const currentTabIndex = parentNode.tabIndex;\n parentNode.tabIndex = 0;\n parentNode.focus();\n parentNode.tabIndex = currentTabIndex;\n }\n}\n"],"file":"tabUtils.js"}
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { focusOnChildNode } from './tabUtils';
|
|
3
3
|
const focusLockStack = [];
|
|
4
4
|
export function useFocusLock(ref, opts) {
|
|
5
5
|
const {
|
|
@@ -22,19 +22,12 @@ export function useFocusLock(ref, opts) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (event.target === lockEndRef.current) {
|
|
25
|
-
rootEl
|
|
25
|
+
focusOnChildNode(rootEl, 0);
|
|
26
26
|
} else if (event.target === lockStartRef.current) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (nodes.length > 0) {
|
|
30
|
-
const nodeToFocus = nodes.length - 1;
|
|
31
|
-
nodes[nodeToFocus].focus();
|
|
32
|
-
} else {
|
|
33
|
-
rootEl.focus();
|
|
34
|
-
}
|
|
27
|
+
focusOnChildNode(rootEl, -1);
|
|
35
28
|
} else if (document !== event.target && rootEl !== event.target && !rootEl.contains(event.target)) {
|
|
36
29
|
event.preventDefault();
|
|
37
|
-
rootEl
|
|
30
|
+
focusOnChildNode(rootEl, 0);
|
|
38
31
|
}
|
|
39
32
|
};
|
|
40
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/FocusLock/useFocusLock.ts"],"names":["useEffect","
|
|
1
|
+
{"version":3,"sources":["../../../src/FocusLock/useFocusLock.ts"],"names":["useEffect","focusOnChildNode","focusLockStack","useFocusLock","ref","opts","enabled","lockStartRef","lockEndRef","rootEl","current","push","listener","event","isActiveFocusLock","length","target","document","contains","preventDefault","addEventListener","removeEventListener","pop"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AACA,SAASC,gBAAT,QAAiC,YAAjC;AAQA,MAAMC,cAA6B,GAAG,EAAtC;AACA,OAAO,SAASC,YAAT,CACLC,GADK,EAELC,IAFK,EAGL;AACA,QAAM;AAAEC,IAAAA,OAAO,GAAG,IAAZ;AAAkBC,IAAAA,YAAlB;AAAgCC,IAAAA;AAAhC,MAA+CH,IAArD;AAEAL,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMS,MAAM,GAAGL,GAAG,CAACM,OAAnB;;AACA,QAAIJ,OAAO,IAAIG,MAAf,EAAuB;AACrBP,MAAAA,cAAc,CAACS,IAAf,CAAoBF,MAApB;;AAEA,YAAMG,QAAQ,GAAIC,KAAD,IAAuB;AACtC,cAAMC,iBAAiB,GACrBZ,cAAc,CAACA,cAAc,CAACa,MAAf,GAAwB,CAAzB,CAAd,KAA8CN,MADhD;;AAEA,YAAI,CAACK,iBAAL,EAAwB;AACtB;AACA;AACD;;AAED,YAAID,KAAK,CAACG,MAAN,KAAiBR,UAAU,CAACE,OAAhC,EAAyC;AACvCT,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;AACD,SAFD,MAEO,IAAII,KAAK,CAACG,MAAN,KAAiBT,YAAY,CAACG,OAAlC,EAA2C;AAChDT,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAC,CAAV,CAAhB;AACD,SAFM,MAEA,IACLQ,QAAQ,KAAKJ,KAAK,CAACG,MAAnB,IACAP,MAAM,KAAKI,KAAK,CAACG,MADjB,IAEA,CAACP,MAAM,CAACS,QAAP,CAAgBL,KAAK,CAACG,MAAtB,CAHI,EAIL;AACAH,UAAAA,KAAK,CAACM,cAAN;AACAlB,UAAAA,gBAAgB,CAACQ,MAAD,EAAS,CAAT,CAAhB;AACD;AACF,OApBD;;AAsBAQ,MAAAA,QAAQ,CAACG,gBAAT,CAA0B,SAA1B,EAAqCR,QAArC;AACA,aAAO,MAAM;AACXK,QAAAA,QAAQ,CAACI,mBAAT,CAA6B,SAA7B,EAAwCT,QAAxC,EADW,CAGX;;AACAV,QAAAA,cAAc,CAACoB,GAAf;AACD,OALD;AAMD,KAlCa,CAmCd;;AACD,GApCQ,EAoCN,CAAChB,OAAD,CApCM,CAAT;AAqCD","sourcesContent":["import { useEffect } from 'react';\nimport { focusOnChildNode } from './tabUtils';\n\nexport interface FocusLockOptions {\n enabled: boolean;\n lockStartRef: React.MutableRefObject<HTMLElement | null>;\n lockEndRef: React.MutableRefObject<HTMLElement | null>;\n}\n\nconst focusLockStack: HTMLElement[] = [];\nexport function useFocusLock(\n ref: React.MutableRefObject<HTMLElement | null>,\n opts: FocusLockOptions\n) {\n const { enabled = true, lockStartRef, lockEndRef } = opts;\n\n useEffect(() => {\n const rootEl = ref.current;\n if (enabled && rootEl) {\n focusLockStack.push(rootEl);\n\n const listener = (event: FocusEvent) => {\n const isActiveFocusLock =\n focusLockStack[focusLockStack.length - 1] === rootEl;\n if (!isActiveFocusLock) {\n // Not the currently focused lock. Forget about it.\n return;\n }\n\n if (event.target === lockEndRef.current) {\n focusOnChildNode(rootEl, 0);\n } else if (event.target === lockStartRef.current) {\n focusOnChildNode(rootEl, -1);\n } else if (\n document !== event.target &&\n rootEl !== event.target &&\n !rootEl.contains(event.target as any)\n ) {\n event.preventDefault();\n focusOnChildNode(rootEl, 0);\n }\n };\n\n document.addEventListener('focusin', listener);\n return () => {\n document.removeEventListener('focusin', listener);\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n focusLockStack.pop();\n };\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled]);\n}\n"],"file":"useFocusLock.js"}
|
package/build/esm/List/List.d.ts
CHANGED
|
File without changes
|
package/build/esm/List/List.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/List/index.js
CHANGED
|
File without changes
|
|
File without changes
|
package/build/esm/Menu/Menu.d.ts
CHANGED
|
File without changes
|
package/build/esm/Menu/Menu.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
import { forwardRef, useRef, Fragment } from 'react';
|
|
3
|
+
import { forwardRef, useRef, Fragment, useId } from 'react';
|
|
4
4
|
import { MenuProvider } from './context';
|
|
5
|
-
import { useId } from '../hooks/useId';
|
|
6
5
|
import { useControlledState } from '../hooks';
|
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
7
|
export const Menu = /*#__PURE__*/forwardRef(function Menu(props, forwardedRef) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Menu/Menu.tsx"],"names":["forwardRef","useRef","Fragment","
|
|
1
|
+
{"version":3,"sources":["../../../src/Menu/Menu.tsx"],"names":["forwardRef","useRef","Fragment","useId","MenuProvider","useControlledState","Menu","props","forwardedRef","as","Comp","open","openProp","defaultOpen","onChange","onChangeProp","otherProps","menuListIdRef","openWithArrowKeyRef","buttonRef","setState","e","isOpen","current","value"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,QAA7B,EAAuCC,KAAvC,QAAoD,OAApD;AAEA,SAASC,YAAT,QAA+C,WAA/C;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAiBA,OAAO,MAAMC,IAAI,gBAAGN,UAAU,CAA4B,SAASM,IAAT,CACxDC,KADwD,EAExDC,YAFwD,EAGxD;AACA,QAAM;AACJC,IAAAA,EAAE,EAAEC,IAAI,GAAGR,QADP;AAEJS,IAAAA,IAAI,EAAEC,QAFF;AAGJC,IAAAA,WAAW,GAAG,KAHV;AAIJC,IAAAA,QAAQ,EAAEC;AAJN,MAMFR,KANJ;AAAA,QAKKS,UALL,iCAMIT,KANJ;;AAOA,QAAMU,aAAa,GAAGhB,MAAM,EAA5B;AACA,QAAMiB,mBAAmB,GAAGjB,MAAM,CAAiC,IAAjC,CAAlC;AACA,QAAMkB,SAAS,GAAGlB,MAAM,CAAoB,IAApB,CAAxB;AACA,QAAM,CAACU,IAAD,EAAOG,QAAP,IAAmBT,kBAAkB,CACzCO,QADyC,EAEzCG,YAFyC,EAGzCF,WAHyC,EAIxCO,QAAD,IAAc,CAACC,CAAD,EAAIC,MAAJ,KAAe;AAC3BF,IAAAA,QAAQ,CAACE,MAAD,CAAR;AACD,GANwC,CAA3C;AASAL,EAAAA,aAAa,CAACM,OAAd,GAAwBpB,KAAK,EAA7B;AAEA,QAAMqB,KAAuB,GAAG;AAC9BP,IAAAA,aAD8B;AAE9BC,IAAAA,mBAF8B;AAG9BP,IAAAA,IAH8B;AAI9BG,IAAAA,QAJ8B;AAK9BK,IAAAA;AAL8B,GAAhC;AAQA,sBACE,KAAC,YAAD;AAAc,IAAA,KAAK,EAAEK,KAArB;AAAA,2BACE,KAAC,IAAD;AAAM,MAAA,GAAG,EAAEhB;AAAX,OAA6BQ,UAA7B;AADF,IADF;AAKD,CAtC6B,CAAvB","sourcesContent":["import { forwardRef, useRef, Fragment, useId } from 'react';\nimport type * as React from 'react';\nimport { MenuProvider, MenuContextProps } from './context';\nimport { useControlledState } from '../hooks';\n\nexport interface MenuProps {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n onChange?: (\n e:\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement>\n | React.PointerEvent<HTMLElement>,\n isOpen: boolean\n ) => void;\n open?: boolean;\n defaultOpen?: boolean;\n}\n\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n open: openProp,\n defaultOpen = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const menuListIdRef = useRef<string>();\n const openWithArrowKeyRef = useRef<'ArrowUp' | 'ArrowDown' | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [open, onChange] = useControlledState(\n openProp,\n onChangeProp,\n defaultOpen,\n (setState) => (e, isOpen) => {\n setState(isOpen);\n }\n );\n\n menuListIdRef.current = useId();\n\n const value: MenuContextProps = {\n menuListIdRef,\n openWithArrowKeyRef,\n open,\n onChange,\n buttonRef,\n };\n\n return (\n <MenuProvider value={value}>\n <Comp ref={forwardedRef} {...otherProps} />\n </MenuProvider>\n );\n});\n"],"file":"Menu.js"}
|
|
File without changes
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
import { forwardRef } from 'react';
|
|
3
|
+
import { forwardRef, useId } from 'react';
|
|
4
4
|
import { useMenuContext } from './context';
|
|
5
5
|
import { wrapEvent } from '../utils/wrapEvent';
|
|
6
|
-
import { useId } from '../hooks';
|
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
7
|
export const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, forwardedRef) {
|
|
9
8
|
const {
|
|
@@ -22,7 +21,8 @@ export const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, for
|
|
|
22
21
|
buttonRef,
|
|
23
22
|
onChange
|
|
24
23
|
} = useMenuContext();
|
|
25
|
-
const
|
|
24
|
+
const buttonIdGenerated = useId();
|
|
25
|
+
const buttonId = preferredId || buttonIdGenerated;
|
|
26
26
|
|
|
27
27
|
const handleKeyDown = e => {
|
|
28
28
|
if (disabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Menu/MenuButton.tsx"],"names":["forwardRef","
|
|
1
|
+
{"version":3,"sources":["../../../src/Menu/MenuButton.tsx"],"names":["forwardRef","useId","useMenuContext","wrapEvent","MenuButton","props","forwardedRef","as","Comp","id","preferredId","onClick","onKeyDown","disabled","otherProps","menuListIdRef","openWithArrowKeyRef","open","buttonRef","onChange","buttonIdGenerated","buttonId","handleKeyDown","e","current","currentTarget","isArrowKey","includes","key","isEnterKey","openedWithArrow","preventDefault","handleClick","undefined"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,oBAA1B;;AAYA,OAAO,MAAMC,UAAU,gBAAGJ,UAAU,CAClC,SAASI,UAAT,CAAoBC,KAApB,EAA2BC,YAA3B,EAAyC;AACvC,QAAM;AACJC,IAAAA,EAAE,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AD,EAAI,CAACN,IAAL,CAApB;AACD,GAPD;;AASA,sBACE,KAAC,IAAD;AACE,IAAA,GAAG,EAAEX,YADP;AAEE,IAAA,EAAE,EAAEe,QAFN;AAGE,IAAA,IAAI,EAAC,QAHP;AAIE,IAAA,IAAI,EAAC,QAJP;AAKE,qBAAe,IALjB;AAME,qBAAeN,aAAa,CAACS,OAN/B;AAOE,qBAAeP,IAAI,GAAG,IAAH,GAAUgB,SAP/B;AAQE,wBAAiB,EARnB;AASE,IAAA,OAAO,EAAE9B,SAAS,CAACQ,OAAD,EAAUqB,WAAV,CATpB;AAUE,IAAA,SAAS,EAAE7B,SAAS,CAACS,SAAD,EAAYU,aAAZ,CAVtB;AAWE,IAAA,QAAQ,EAAET;AAXZ,KAYMC,UAZN,EADF;AAgBD,CAlEiC,CAA7B","sourcesContent":["import { forwardRef, useId } from 'react';\nimport type * as React from 'react';\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrapEvent';\n\nexport type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n onClick?: (\n e:\n | React.MouseEvent<HTMLButtonElement>\n | React.KeyboardEvent<HTMLButtonElement>\n ) => void;\n};\n\nexport const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(\n function MenuButton(props, forwardedRef) {\n const {\n as: Comp = 'button',\n id: preferredId,\n onClick,\n onKeyDown,\n disabled,\n ...otherProps\n } = props;\n const {\n menuListIdRef,\n openWithArrowKeyRef,\n open,\n buttonRef,\n onChange,\n } = useMenuContext();\n\n const buttonIdGenerated = useId();\n const buttonId = preferredId || buttonIdGenerated;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n const isArrowKey = () => ['ArrowUp', 'ArrowDown'].includes(e.key);\n const isEnterKey = () => [' ', 'Enter'].includes(e.key);\n\n const openedWithArrow = isArrowKey();\n if (openedWithArrow || isEnterKey()) {\n if (openedWithArrow) {\n // Used to make it open at the end or begining of the list\n openWithArrowKeyRef.current = e.key;\n }\n onChange && onChange(e, true);\n e.preventDefault();\n }\n };\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n onChange && onChange(e, !open);\n };\n\n return (\n <Comp\n ref={forwardedRef}\n id={buttonId}\n role=\"button\"\n type=\"button\"\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-button=\"\"\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n disabled={disabled}\n {...otherProps}\n />\n );\n }\n);\n"],"file":"MenuButton.js"}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
import { forwardRef, useRef } from 'react';
|
|
3
|
+
import { forwardRef, useRef, useId } from 'react';
|
|
4
4
|
import { useMenuContext, useMenuListContext } from './context';
|
|
5
5
|
import { assignMultipleRefs } from '../utils/assignRef';
|
|
6
6
|
import { wrapEvent } from '../utils';
|
|
@@ -16,7 +16,6 @@ export const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forward
|
|
|
16
16
|
otherProps = _objectWithoutPropertiesLoose(props, ["as", "disabled", "onSelect", "onClick", "onKeyDown"]);
|
|
17
17
|
|
|
18
18
|
const {
|
|
19
|
-
menuListIdRef,
|
|
20
19
|
onChange,
|
|
21
20
|
buttonRef
|
|
22
21
|
} = useMenuContext();
|
|
@@ -25,7 +24,7 @@ export const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forward
|
|
|
25
24
|
onNavigate
|
|
26
25
|
} = useMenuListContext();
|
|
27
26
|
const ref = useRef();
|
|
28
|
-
const
|
|
27
|
+
const itemId = useId();
|
|
29
28
|
const isActive = ref.current && ref.current === navigationItem;
|
|
30
29
|
const handleSelect = wrapEvent(onSelect, e => {
|
|
31
30
|
var _buttonRef$current;
|
|
@@ -57,7 +56,7 @@ export const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forward
|
|
|
57
56
|
|
|
58
57
|
return /*#__PURE__*/_jsx(Comp, _extends({
|
|
59
58
|
ref: assignMultipleRefs(ref, forwardedRef),
|
|
60
|
-
id: disabled ? undefined :
|
|
59
|
+
id: disabled ? undefined : itemId,
|
|
61
60
|
"data-menu-item": "",
|
|
62
61
|
"data-highlighted": isActive ? '' : undefined,
|
|
63
62
|
role: "menuitem",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Menu/MenuItem.tsx"],"names":["forwardRef","useRef","useMenuContext","useMenuListContext","assignMultipleRefs","wrapEvent","MenuItem","props","forwardedRef","as","Comp","disabled","onSelect","onClick","onKeyDown","otherProps","
|
|
1
|
+
{"version":3,"sources":["../../../src/Menu/MenuItem.tsx"],"names":["forwardRef","useRef","useId","useMenuContext","useMenuListContext","assignMultipleRefs","wrapEvent","MenuItem","props","forwardedRef","as","Comp","disabled","onSelect","onClick","onKeyDown","otherProps","onChange","buttonRef","navigationItem","onNavigate","ref","itemId","isActive","current","handleSelect","e","focus","preventDefault","handleClick","handleKeyDown","key","undefined"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,KAA7B,QAA0C,OAA1C;AAEA,SAASC,cAAT,EAAyBC,kBAAzB,QAAmD,WAAnD;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAWA,OAAO,MAAMC,QAAQ,gBAAGP,UAAU,CAAqB,SAASO,QAAT,CACrDC,KADqD,EAErDC,YAFqD,EAGrD;AACA,QAAM;AACJC,IAAAA,EAAE,EAAEC,IAAI,GAAG,IADP;AAEJC,IAAAA,QAFI;AAGJC,IAAA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HjB;AAIE,wBAAkBC,QAAQ,GAAG,EAAH,GAAQS,SAJpC;AAKE,IAAA,IAAI,EAAC,UALP;AAME,IAAA,OAAO,EAAE1B,SAAS,CAACQ,OAAD,EAAUe,WAAV,CANpB;AAOE,IAAA,QAAQ,EAAEjB,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAP5B;AAQE,IAAA,SAAS,EAAEN,SAAS,CAACS,SAAD,EAAYe,aAAZ,CARtB;AASE,qBAAelB,QAAQ,GAAG,EAAH,GAAQoB,SATjC;AAUE,qBAAepB,QAAQ,GAAG,EAAH,GAAQoB,SAVjC;AAWE,IAAA,QAAQ,EAAEpB;AAXZ,KAYMI,UAZN,EADF;AAgBD,CAjEiC,CAA3B","sourcesContent":["import { forwardRef, useRef, useId } from 'react';\nimport type * as React from 'react';\nimport { useMenuContext, useMenuListContext } from './context';\nimport { assignMultipleRefs } from '../utils/assignRef';\nimport { wrapEvent } from '../utils';\n\nexport interface MenuItemProps extends React.LiHTMLAttributes<HTMLLIElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n onSelect?: (\n e: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>\n ) => void;\n disabled?: boolean;\n}\n\nexport const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'li',\n disabled,\n onSelect,\n onClick,\n onKeyDown,\n ...otherProps\n } = props;\n const { onChange, buttonRef } = useMenuContext();\n const { navigationItem, onNavigate } = useMenuListContext();\n const ref = useRef<HTMLLIElement>();\n const itemId = useId();\n\n const isActive = ref.current && ref.current === navigationItem;\n\n const handleSelect = wrapEvent(\n onSelect,\n (\n e: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLLIElement>\n ) => {\n onChange && onChange(e, false);\n buttonRef.current?.focus();\n e.preventDefault();\n }\n );\n\n const handleClick = (e: React.MouseEvent<HTMLLIElement>) => {\n if (!disabled) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n onNavigate && onNavigate(ref.current!);\n handleSelect(e);\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLLIElement> = (e) => {\n switch (e.key) {\n case 'Enter':\n case ' ':\n if (!disabled) {\n handleSelect(e);\n }\n break;\n }\n };\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n id={disabled ? undefined : itemId}\n data-menu-item=\"\"\n data-highlighted={isActive ? '' : undefined}\n role=\"menuitem\"\n onClick={wrapEvent(onClick, handleClick)}\n tabIndex={disabled ? -1 : 0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n data-disabled={disabled ? '' : undefined}\n aria-disabled={disabled ? '' : undefined}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"file":"MenuItem.js"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/Menu/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/Menu/scope.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/Modal/Modal.js
CHANGED
|
@@ -15,7 +15,7 @@ export const Modal = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
15
15
|
otherProps = _objectWithoutPropertiesLoose(_ref, ["as", "children", "trapFocus", "style"]);
|
|
16
16
|
|
|
17
17
|
const modalRef = useRef(null);
|
|
18
|
-
useFocusReturn(trapFocus);
|
|
18
|
+
useFocusReturn(trapFocus, modalRef);
|
|
19
19
|
useRemoveBodyScroll(trapFocus);
|
|
20
20
|
useAutoFocus(trapFocus, modalRef);
|
|
21
21
|
return /*#__PURE__*/_jsx(FocusLock, {
|
|
@@ -27,7 +27,7 @@ export const Modal = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
27
27
|
role: "dialog",
|
|
28
28
|
"aria-modal": "true",
|
|
29
29
|
style: style,
|
|
30
|
-
tabIndex:
|
|
30
|
+
tabIndex: -1
|
|
31
31
|
}, otherProps, {
|
|
32
32
|
children: children
|
|
33
33
|
}))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Modal/Modal.tsx"],"names":["forwardRef","useRef","useAutoFocus","useFocusReturn","useRemoveBodyScroll","FocusLock","assignMultipleRefs","Modal","ref","as","Comp","children","trapFocus","style","otherProps","modalRef"],"mappings":";;AAAA,SAAoBA,UAApB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SAASC,YAAT,EAAuBC,cAAvB,EAAuCC,mBAAvC,QAAkE,UAAlE;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAUA,OAAO,MAAMC,KAAK,gBAAGP,UAAU,CAC7B,OAEEQ,GAFF,KAGK;AAAA,MAFH;AAAEC,IAAAA,EAAE,EAAEC,IAAI,GAAG,KAAb;AAAoBC,IAAAA,QAApB;AAA8BC,IAAAA,SAAS,GAAG,IAA1C;AAAgDC,IAAAA,KAAK,GAAG;AAAxD,GAEG;AAAA,MAF4DC,UAE5D;;AACH,QAAMC,QAAQ,GAAGd,MAAM,CAAiB,IAAjB,CAAvB;AAEAE,EAAAA,cAAc,CAACS,SAAD,CAAd;
|
|
1
|
+
{"version":3,"sources":["../../../src/Modal/Modal.tsx"],"names":["forwardRef","useRef","useAutoFocus","useFocusReturn","useRemoveBodyScroll","FocusLock","assignMultipleRefs","Modal","ref","as","Comp","children","trapFocus","style","otherProps","modalRef"],"mappings":";;AAAA,SAAoBA,UAApB,EAAgCC,MAAhC,QAA8C,OAA9C;AAEA,SAASC,YAAT,EAAuBC,cAAvB,EAAuCC,mBAAvC,QAAkE,UAAlE;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAUA,OAAO,MAAMC,KAAK,gBAAGP,UAAU,CAC7B,OAEEQ,GAFF,KAGK;AAAA,MAFH;AAAEC,IAAAA,EAAE,EAAEC,IAAI,GAAG,KAAb;AAAoBC,IAAAA,QAApB;AAA8BC,IAAAA,SAAS,GAAG,IAA1C;AAAgDC,IAAAA,KAAK,GAAG;AAAxD,GAEG;AAAA,MAF4DC,UAE5D;;AACH,QAAMC,QAAQ,GAAGd,MAAM,CAAiB,IAAjB,CAAvB;AAEAE,EAAAA,cAAc,CAACS,SAAD,EAAYG,QAAZ,CAAd;AACAX,EAAAA,mBAAmB,CAACQ,SAAD,CAAnB;AACAV,EAAAA,YAAY,CAACU,SAAD,EAAYG,QAAZ,CAAZ;AAEA,sBACE,KAAC,SAAD;AAAW,IAAA,QAAQ,EAAEA,QAArB;AAA+B,IAAA,OAAO,EAAEH,SAAxC;AAAA,2BACE,KAAC,IAAD;AACE,MAAA,GAAG,EAAEN,kBAAkB,CAACE,GAAD,EAAMO,QAAN,CADzB;AAEE,8BAAqB,EAFvB;AAGE,MAAA,IAAI,EAAC,QAHP;AAIE,oBAAW,MAJb;AAKE,MAAA,KAAK,EAAEF,KALT;AAME,MAAA,QAAQ,EAAE,CAAC;AANb,OAOMC,UAPN;AAAA,gBASGH;AATH;AADF,IADF;AAeD,CA1B4B,CAAxB","sourcesContent":["import { ReactNode, forwardRef, useRef } from 'react';\nimport type * as React from 'react';\nimport { useAutoFocus, useFocusReturn, useRemoveBodyScroll } from '../hooks';\nimport { FocusLock } from '../FocusLock';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface ModalProps extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: ReactNode;\n style?: React.CSSProperties;\n trapFocus?: boolean;\n}\n\nexport const Modal = forwardRef<HTMLDivElement, ModalProps>(\n (\n { as: Comp = 'div', children, trapFocus = true, style = {}, ...otherProps },\n ref\n ) => {\n const modalRef = useRef<HTMLDivElement>(null);\n\n useFocusReturn(trapFocus, modalRef);\n useRemoveBodyScroll(trapFocus);\n useAutoFocus(trapFocus, modalRef);\n\n return (\n <FocusLock childRef={modalRef} enabled={trapFocus}>\n <Comp\n ref={assignMultipleRefs(ref, modalRef)}\n data-modal-container=\"\"\n role=\"dialog\"\n aria-modal=\"true\"\n style={style}\n tabIndex={-1}\n {...otherProps}\n >\n {children}\n </Comp>\n </FocusLock>\n );\n }\n);\n"],"file":"Modal.js"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/Modal/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -60,6 +60,11 @@ export const Popper = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Popper
|
|
|
60
60
|
popperEngineInstance.current = null;
|
|
61
61
|
};
|
|
62
62
|
}, [anchorEl, modifiers, placement, strategy, defaultModifiers]);
|
|
63
|
+
useEnhancedEffect(() => {
|
|
64
|
+
var _popperEngineInstance;
|
|
65
|
+
|
|
66
|
+
(_popperEngineInstance = popperEngineInstance.current) == null ? void 0 : _popperEngineInstance.forceUpdate();
|
|
67
|
+
}, [props.hidden || props['aria-hidden']]);
|
|
63
68
|
const contextValue = {
|
|
64
69
|
arrowRef
|
|
65
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Popper/Popper.tsx"],"names":["forwardRef","useRef","useEffect","useLayoutEffect","useMemo","memo","assignMultipleRefs","PopperProvider","Portal","createPopper","useEnhancedEffect","window","emptyModifiers","Popper","forwardedRef","placement","strategy","as","Comp","innerAs","anchorEl","children","modifiers","usePortal","style","portalSelector","distance","skidding","arrowPadding","offsetFn","props","arrowRef","popperRef","popperEngineInstance","defaultModifiers","arrowModifier","name","options","element","padding","offsetModifier","offset","current","destroy","contextValue","ret","position","left","top"],"mappings":";;AAAA,SACEA,UADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,eAJF,EAKEC,OALF,EAMEC,IANF,QAOO,OAPP;AASA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,cAAT,QAAmD,WAAnD;AACA,SAAS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,QAAF,WAAEA,QAAF,GAAc,CAACF,QAAD,EAAWD,QAAX;AADb;AAF8D,KAAzE;AAOA,WAAO,CAACS,aAAD,EAAgBK,cAAhB,CAAP;AACD,GAhBmE,EAgBjE,CAACZ,YAAD,EAAeF,QAAf,EAAyBC,QAAzB,EAAmCE,QAAnC,CAhBiE,CAApE;AAkBAnB,EAAAA,iBAAiB,CAAC,MAAM;AACtB,QAAIU,QAAQ,IAAIA,QAAQ,CAACsB,OAArB,IAAgCV,SAAS,CAACU,OAA9C,EAAuD;AACrDT,MAAAA,oBAAoB,CAACS,OAArB,GAA+BjC,YAAY,CACzCW,QAAQ,CAACsB,OADgC,EAEzCV,SAAS,CAACU,OAF+B,EAGzC;AACE3B,QAAAA,SADF;AAEEC,QAAAA,QAFF;AAGEM,QAAAA,SAAS,EAAE,CAAC,GAAGY,gBAAJ,EAAsB,GAAGZ,SAAzB;AAHb,OAHyC,CAA3C;AASD;;AAED,WAAO,MAAM;AACXW,MAAAA,oBAAoB,CAACS,OAArB,IAAgCT,oBAAoB,CAACS,OAArB,CAA6BC,OAA7B,EAAhC;AACAV,MAAAA,oBAAoB,CAACS,OAArB,GAA+B,IAA/B;AACD,KAHD;AAID,GAjBgB,EAiBd,CAACtB,QAAD,EAAWE,SAAX,EAAsBP,SAAtB,EAAiCC,QAAjC,EAA2CkB,gBAA3C,CAjBc,CAAjB;
|
|
1
|
+
{"version":3,"sources":["../../../src/Popper/Popper.tsx"],"names":["forwardRef","useRef","useEffect","useLayoutEffect","useMemo","memo","assignMultipleRefs","PopperProvider","Portal","createPopper","useEnhancedEffect","window","emptyModifiers","Popper","forwardedRef","placement","strategy","as","Comp","innerAs","anchorEl","children","modifiers","usePortal","style","portalSelector","distance","skidding","arrowPadding","offsetFn","props","arrowRef","popperRef","popperEngineInstance","defaultModifiers","arrowModifier","name","options","element","padding","offsetModifier","offset","current","destroy","forceUpdate","hidden","contextValue","ret","position","left","top"],"mappings":";;AAAA,SACEA,UADF,EAEEC,MA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zC;;AAIA,QAAMgB,GAAG,gBACP,KAAC,cAAD;AAAgB,IAAA,KAAK,EAAED,YAAvB;AAAA,2BACE,KAAC,IAAD,eACMhB,KADN;AAEE,MAAA,EAAE,EAAEX,OAFN;AAGE,MAAA,GAAG,EAAEb,kBAAkB,CAAC0B,SAAD,EAAYlB,YAAZ,CAHzB;AAIE,MAAA,KAAK;AAAIkC,QAAAA,QAAQ,EAAE,OAAd;AAAuBC,QAAAA,IAAI,EAAE,CAAC,IAA9B;AAAoCC,QAAAA,GAAG,EAAE,CAAC;AAA1C,SAAmD1B,KAAnD,CAJP;AAAA,gBAMGH;AANH;AADF,IADF;;AAaA,MAAIE,SAAJ,EAAe;AACb,wBAAO,KAAC,MAAD;AAAQ,MAAA,QAAQ,EAAEE,cAAlB;AAAA,gBAAmCsB;AAAnC,MAAP;AACD;;AAED,SAAOA,GAAP;AACD,CAxFS,CADc,CAAnB","sourcesContent":["import {\n forwardRef,\n useRef,\n useEffect,\n useLayoutEffect,\n useMemo,\n memo,\n} from 'react';\nimport type * as React from 'react';\nimport { assignMultipleRefs } from '../utils/assignRef';\nimport { PopperProvider, PopperContextProps } from './context';\nimport { Portal } from '../Portal';\n\nimport {\n Placement,\n Modifier,\n PositioningStrategy,\n Instance,\n Rect,\n createPopper,\n} from '@popperjs/core';\nimport type { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\nimport type { ArrowModifier } from '@popperjs/core/lib/modifiers/arrow';\n\nconst useEnhancedEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nexport type OffsetsFunction = (arg0: {\n popper: Rect;\n reference: Rect;\n placement: Placement;\n}) => [number | null | undefined, number | null | undefined];\n\nexport interface PopperProps extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n anchorEl: React.RefObject<HTMLElement>;\n children?: React.ReactNode;\n placement?: Placement;\n strategy?: PositioningStrategy;\n modifiers?: Array<Partial<Modifier<any, any>>>;\n usePortal?: boolean;\n portalSelector?: string;\n /**\n * Displaces the popper along the reference element.\n */\n skidding?: number;\n /**\n * Displaces the popper away from, or toward, the reference element in the direction of its placement. A positive number displaces it further away, while a negative number lets it overlap the reference.\n */\n distance?: number;\n /**\n * An optional function that must return a pair of [skidding, padding]. Useful for doing things like, displace the popper by 100%.\n */\n offsetFn?: OffsetsFunction;\n /**\n * If you don't want the arrow to reach the very edge of the popper (this is common if your popper has rounded corners using border-radius), you can apply some padding to it.\n */\n arrowPadding?: number;\n}\n\nconst emptyModifiers: Array<Partial<Modifier<any, any>>> = [];\nexport const Popper = memo(\n forwardRef<HTMLDivElement, PopperProps>(function Popper(\n {\n placement = 'bottom',\n strategy = 'absolute',\n as: Comp = 'div',\n innerAs,\n anchorEl,\n children,\n modifiers = emptyModifiers,\n usePortal = false,\n style = {},\n portalSelector = 'body',\n distance = 0,\n skidding = 0,\n arrowPadding = 5,\n offsetFn,\n ...props\n },\n forwardedRef\n ) {\n const arrowRef = useRef<HTMLSpanElement>(null);\n\n const popperRef = useRef<HTMLDivElement | null>(null);\n const popperEngineInstance = useRef<null | Instance>(null);\n\n const defaultModifiers: Array<Partial<Modifier<any, any>>> = useMemo(() => {\n const arrowModifier: Omit<ArrowModifier, 'enabled' | 'fn' | 'phase'> = {\n name: 'arrow',\n options: {\n element: '[data-popper-arrow]',\n padding: arrowPadding,\n },\n };\n const offsetModifier: Omit<OffsetModifier, 'enabled' | 'fn' | 'phase'> = {\n name: 'offset',\n options: {\n offset: offsetFn ?? [skidding, distance],\n },\n };\n\n return [arrowModifier, offsetModifier];\n }, [arrowPadding, distance, skidding, offsetFn]);\n\n useEnhancedEffect(() => {\n if (anchorEl && anchorEl.current && popperRef.current) {\n popperEngineInstance.current = createPopper(\n anchorEl.current,\n popperRef.current,\n {\n placement,\n strategy,\n modifiers: [...defaultModifiers, ...modifiers],\n }\n );\n }\n\n return () => {\n popperEngineInstance.current && popperEngineInstance.current.destroy();\n popperEngineInstance.current = null;\n };\n }, [anchorEl, modifiers, placement, strategy, defaultModifiers]);\n\n useEnhancedEffect(() => {\n popperEngineInstance.current?.forceUpdate();\n }, [props.hidden || props['aria-hidden']]);\n\n const contextValue: PopperContextProps = {\n arrowRef,\n };\n\n const ret = (\n <PopperProvider value={contextValue}>\n <Comp\n {...props}\n as={innerAs}\n ref={assignMultipleRefs(popperRef, forwardedRef)}\n style={{ position: 'fixed', left: -5000, top: -5000, ...style }}\n >\n {children}\n </Comp>\n </PopperProvider>\n );\n\n if (usePortal) {\n return <Portal selector={portalSelector}>{ret}</Portal>;\n }\n\n return ret;\n })\n);\n"],"file":"Popper.js"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
import { forwardRef } from 'react';
|
|
3
|
+
import { forwardRef, useId } from 'react';
|
|
4
4
|
import { RadioGroupProvider } from './context';
|
|
5
|
-
import { useControlledState
|
|
5
|
+
import { useControlledState } from '../hooks';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const RadioGroup = /*#__PURE__*/forwardRef(function RadioGroup(props, forwardedRef) {
|
|
8
8
|
const {
|