@basic-ui/core 0.0.37 → 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 +0 -0
- 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 +0 -0
- 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 -7069
- package/package.json +13 -13
- package/src/Accordion/AccordionItem.tsx +1 -2
- package/src/ComboBox/ComboBox.story.tsx +2 -1
- package/src/ComboBox/Combobox.tsx +2 -2
- package/src/FocusLock/tabUtils.ts +12 -0
- package/src/FocusLock/useFocusLock.ts +4 -11
- 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 +19 -5
- package/src/Modal/Modal.tsx +2 -2
- package/src/Popper/Popper.tsx +4 -0
- package/src/RadioButton/RadioGroup.tsx +2 -2
- package/src/Tabs/TabList.tsx +9 -2
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/RadioButton/RadioGroup.tsx"],"names":["forwardRef","
|
|
1
|
+
{"version":3,"sources":["../../../src/RadioButton/RadioGroup.tsx"],"names":["forwardRef","useId","RadioGroupProvider","useControlledState","RadioGroup","props","forwardedRef","as","Comp","onChange","onChangeProp","value","valueProp","name","nameProp","defaultValue","otherProps","setValue","e","fallbackId"],"mappings":";;AAAA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,kBAAT,QAA+C,WAA/C;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAmBA,OAAO,MAAMC,UAAU,gBAAGJ,UAAU,CAClC,SAASI,UAAT,CAAoBC,KAApB,EAA2BC,YAA3B,EAAyC;AACvC,QAAM;AACJC,IAAAA,EAAE,EAAEC,IAAI,GAAG,KADP;AAEJC,IAAAA,QAAQ,EAAEC,YAFN;AAGJC,IAAAA,KAAK,EAAEC,SAHH;AAIJC,IAAAA,IAAI,EAAEC,QAJF;AAKJC,IAAAA;AALI,MAOFV,KAPJ;AAAA,QAMKW,UANL,iCAOIX,KAPJ;;AAQA,QAAM,CAACM,KAAD,EAAQF,QAAR,IAAoBN,kBAAkB,CAC1CS,SAD0C,EAE1CF,YAF0C,EAG1CK,YAH0C,EAIzCE,QAAD,IAAc,CAACC,CAAD,EAAIP,KAAJ,KAAc;AAC1BM,IAAAA,QAAQ,CAACN,KAAD,CAAR;AACD,GANyC,CAA5C;AASA,QAAMQ,UAAU,GAAGlB,KAAK,EAAxB;AAEA,sBACE,KAAC,kBAAD;AACE,IAAA,KAAK,EAAE;AACLU,MAAAA,KADK;AAELF,MAAAA,QAFK;AAGLI,MAAAA,IAAI,EAAEC,QAAQ,IAAIK;AAHb,KADT;AAAA,2BAOE,KAAC,IAAD;AAAM,MAAA,GAAG,EAAEb,YAAX;AAAyB,MAAA,IAAI,EAAC;AAA9B,OAA+CU,UAA/C;AAPF,IADF;AAWD,CAhCiC,CAA7B","sourcesContent":["import { forwardRef, useId } from 'react';\nimport type * as React from 'react';\nimport { RadioGroupProvider, RadioValue } from './context';\nimport { useControlledState } from '../hooks';\n\nexport interface RadioGroupProps\n extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'value' | 'defaultValue'\n > {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n children?: React.ReactNode;\n value?: RadioValue;\n defaultValue?: RadioValue;\n name?: string;\n onChange?: (\n e: React.ChangeEvent<HTMLInputElement>,\n value: RadioValue\n ) => void;\n}\n\nexport const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(\n function RadioGroup(props, forwardedRef) {\n const {\n as: Comp = 'div',\n onChange: onChangeProp,\n value: valueProp,\n name: nameProp,\n defaultValue,\n ...otherProps\n } = props;\n const [value, onChange] = useControlledState(\n valueProp,\n onChangeProp,\n defaultValue,\n (setValue) => (e, value) => {\n setValue(value);\n }\n );\n\n const fallbackId = useId();\n\n return (\n <RadioGroupProvider\n value={{\n value,\n onChange,\n name: nameProp || fallbackId,\n }}\n >\n <Comp ref={forwardedRef} role=\"radiogroup\" {...otherProps} />\n </RadioGroupProvider>\n );\n }\n);\n"],"file":"RadioGroup.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/Tabs/Tab.d.ts
CHANGED
|
File without changes
|
package/build/esm/Tabs/Tab.js
CHANGED
|
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, useRef, useEffect, Children, cloneElement } from 'react';
|
|
3
|
+
import { forwardRef, useRef, useEffect, Children, cloneElement, useId } from 'react';
|
|
4
4
|
import { TabListProvider, useTabsContext } from './context';
|
|
5
|
-
import { useScope
|
|
5
|
+
import { useScope } from '../hooks';
|
|
6
6
|
import { assignMultipleRefs } from '../utils';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
export const TabList = /*#__PURE__*/forwardRef(function TabList(props, forwardedRef) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Tabs/TabList.tsx"],"names":["forwardRef","useRef","useEffect","Children","cloneElement","TabListProvider","useTabsContext","useScope","
|
|
1
|
+
{"version":3,"sources":["../../../src/Tabs/TabList.tsx"],"names":["forwardRef","useRef","useEffect","Children","cloneElement","useId","TabListProvider","useTabsContext","useScope","assignMultipleRefs","TabList","props","forwardedRef","as","Comp","manualActivation","vertical","children","childrenProps","otherProps","ref","tabsScope","tabsContext","id","Error","undefined","setTabListId","map","node","index"],"mappings":";;AAAA,SACEA,UADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,QAJF,EAKEC,YALF,EAMEC,KANF,QAOO,OAPP;AASA,SAASC,eAAT,EAA0BC,cAA1B,QAAgD,WAAhD;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAUA,OAAO,MAAMC,OAAO,gBAAGV,UAAU,CAC/B,SAASU,OAAT,CAAiBC,KAAjB,EAAwBC,YAAxB,EAAsC;AACpC,QAAM;AACJC,IAAAA,EAAE,EAAEC,IAAI,GAAG,KADP;AAEJC,IAAAA,gBAAgB,GAAG,KAFf;AAGJC,IAAAA,QAAQ,GAAG,KAHP;AAIJC,IAAAA,QAAQ,EAAEC;AAJN,MAMFP,KANJ;AAAA,QAKKQ,UALL,iCAMIR,KANJ;;AAQA,QAAMS,GAAG,GAAGnB,MAAM,EAAlB;AACA,QAAMoB,SAAS,GAAGb,QAAQ,CAACY,GAAD,CAA1B;AACA,QAAME,WAAW,GAAGf,cAAc,EAAlC;AACA,QAAMgB,EAAE,GAAGlB,KAAK,EAAhB;;AAEA,MAAI,CAACiB,WAAL,EAAkB;AAChB,UAAM,IAAIE,KAAJ,CAAU,wCAAV,CAAN;AACD;;AAEDtB,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIqB,EAAE,KAAKE,SAAX,EAAsB;AACpBH,MAAAA,WAAW,CAACI,YAAZ,CAAyBH,EAAzB;AAEA,aAAO,MAAM;AACXD,QAAAA,WAAW,CAACI,YAAZ,CAAyB,IAAzB;AACD,OAFD;AAGD;;AAED;AACD,GAVQ,EAUN,CAACH,EAAD,EAAKD,WAAL,EAAkBA,WAAW,CAACI,YAA9B,CAVM,CAAT;AAYA,QAAMT,QAAQ,GAAGd,QAAQ,CAACwB,GAAT,CAAaT,aAAb,EAA4B,CAACU,IAAD,EAAOC,KAAP,kBAC3CzB,YAAY,CAACwB,IAAD,EAAc;AAAEC,IAAAA;AAAF,GAAd,CADG,CAAjB;AAIA,sBACE,KAAC,eAAD;AAAiB,IAAA,KAAK,EAAE;AAAER,MAAAA,SAAF;AAAaN,MAAAA,gBAAb;AAA+BC,MAAAA;AAA/B,KAAxB;AAAA,2BACE,KAAC,IAAD;AACE,MAAA,GAAG,EAAEP,kBAAkB,CAACG,YAAD,EAAeQ,GAAf,CADzB;AAEE,uBAAc,EAFhB;AAGE,MAAA,IAAI,EAAC;AAHP,OAIMD,UAJN;AAAA,gBAMGF;AANH;AADF,IADF;AAYD,CA/C8B,CAA1B","sourcesContent":["import {\n forwardRef,\n useRef,\n useEffect,\n Children,\n cloneElement,\n useId,\n} from 'react';\nimport type * as React from 'react';\nimport { TabListProvider, useTabsContext } from './context';\nimport { useScope } from '../hooks';\nimport { assignMultipleRefs } from '../utils';\n\nexport interface TabListProps extends React.HTMLAttributes<HTMLDivElement> {\n as?: React.ElementType<any>;\n innerAs?: React.ElementType<any>;\n manualActivation?: boolean;\n vertical?: boolean;\n children?: React.ReactNode;\n}\n\nexport const TabList = forwardRef<HTMLDivElement, TabListProps>(\n function TabList(props, forwardedRef) {\n const {\n as: Comp = 'div',\n manualActivation = false,\n vertical = false,\n children: childrenProps,\n ...otherProps\n } = props;\n\n const ref = useRef();\n const tabsScope = useScope(ref);\n const tabsContext = useTabsContext();\n const id = useId();\n\n if (!tabsContext) {\n throw new Error('Missing <Tabs /> in the component tree');\n }\n\n useEffect(() => {\n if (id !== undefined) {\n tabsContext.setTabListId(id);\n\n return () => {\n tabsContext.setTabListId(null);\n };\n }\n\n return;\n }, [id, tabsContext, tabsContext.setTabListId]);\n\n const children = Children.map(childrenProps, (node, index) =>\n cloneElement(node as any, { index })\n );\n\n return (\n <TabListProvider value={{ tabsScope, manualActivation, vertical }}>\n <Comp\n ref={assignMultipleRefs(forwardedRef, ref)}\n data-tab-list=\"\"\n role=\"tablist\"\n {...otherProps}\n >\n {children}\n </Comp>\n </TabListProvider>\n );\n }\n);\n"],"file":"TabList.js"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/Tabs/Tabs.d.ts
CHANGED
|
File without changes
|
package/build/esm/Tabs/Tabs.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/Tabs/index.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
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 { useRef, useEffect, useState } from 'react';
|
|
3
|
+
import { useRef, useEffect, useState, useId } from 'react';
|
|
4
4
|
import { assignMultipleRefs } from '../utils/assignRef';
|
|
5
5
|
import { wrapEvent } from '../utils/wrapEvent';
|
|
6
|
-
import { useId } from '../hooks/useId';
|
|
7
6
|
import { send, state, subscription, Blur, Focus, LeavingVisible, MouseDown, MouseEnter, MouseLeave, MouseMove, SelectWithKeyboard, Visible } from './stateMachine';
|
|
8
7
|
export function useTooltip(childProps, childRef, tooltipProps) {
|
|
9
8
|
const {
|
|
@@ -17,7 +16,7 @@ export function useTooltip(childProps, childRef, tooltipProps) {
|
|
|
17
16
|
} = childProps;
|
|
18
17
|
const anchorEl = useRef(null);
|
|
19
18
|
const [visible, setVisible] = useState(false);
|
|
20
|
-
const id = useId(
|
|
19
|
+
const id = useId();
|
|
21
20
|
useEffect(() => {
|
|
22
21
|
subscription.subscribe(() => {
|
|
23
22
|
setVisible((state.current.state === Visible || state.current.state === LeavingVisible) && state.current.id === id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Tooltip/useTooltip.ts"],"names":["useRef","useEffect","useState","
|
|
1
|
+
{"version":3,"sources":["../../../src/Tooltip/useTooltip.ts"],"names":["useRef","useEffect","useState","useId","assignMultipleRefs","wrapEvent","send","state","subscription","Blur","Focus","LeavingVisible","MouseDown","MouseEnter","MouseLeave","MouseMove","SelectWithKeyboard","Visible","useTooltip","childProps","childRef","tooltipProps","onMouseEnter","onMouseLeave","onMouseMove","onMouseDown","onKeyDown","onFocus","onBlur","anchorEl","visible","setVisible","id","subscribe","current","handleMouseEnter","handleMouseMove","handleMouseLeave","handleMouseDown","handleFocus","handleBlur","undefined","handleKeyDown","event","key","label","children","tooltipOnMouseEnter","tooltipOnMouseLeave","tooltipOnMouseMove","otherTooltipProps","tooltipId","ref","role"],"mappings":"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","sourcesContent":["import { useRef, RefAttributes, useEffect, useState, useId } from 'react';\nimport { assignMultipleRefs } from '../utils/assignRef';\nimport { wrapEvent } from '../utils/wrapEvent';\nimport {\n send,\n state,\n subscription,\n Blur,\n Focus,\n LeavingVisible,\n MouseDown,\n MouseEnter,\n MouseLeave,\n MouseMove,\n SelectWithKeyboard,\n Visible,\n} from './stateMachine';\n\nexport type ChildProps = React.HTMLAttributes<HTMLElement> &\n RefAttributes<HTMLElement>;\n\nexport interface InjectedTooltipProps\n extends React.HTMLAttributes<HTMLElement> {\n anchorEl: React.RefObject<HTMLElement>;\n visible: boolean;\n children?: React.ReactNode;\n}\n\nexport function useTooltip(\n childProps: ChildProps,\n childRef: React.Ref<HTMLElement> | undefined,\n tooltipProps: React.HTMLAttributes<HTMLElement> & { label?: React.ReactNode }\n): [ChildProps, InjectedTooltipProps] {\n const {\n onMouseEnter,\n onMouseLeave,\n onMouseMove,\n onMouseDown,\n onKeyDown,\n onFocus,\n onBlur,\n } = childProps;\n const anchorEl = useRef<HTMLElement>(null);\n const [visible, setVisible] = useState(false);\n const id = useId();\n\n useEffect(() => {\n subscription.subscribe(() => {\n setVisible(\n (state.current.state === Visible ||\n state.current.state === LeavingVisible) &&\n state.current.id === id\n );\n });\n }, [id]);\n\n function handleMouseEnter() {\n send(MouseEnter, { id });\n }\n\n function handleMouseMove() {\n send(MouseMove, { id });\n }\n\n function handleMouseLeave() {\n send(MouseLeave);\n }\n\n function handleMouseDown() {\n // Allow quick click from one tool to another\n if (state.current.id === id) {\n send(MouseDown);\n }\n }\n\n function handleFocus() {\n send(Focus, { id });\n }\n\n function handleBlur() {\n // Allow quick click from one tool to another\n if (state.current.id === id) {\n send(Blur, undefined);\n }\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLElement>) {\n if (event.key === 'Enter' || event.key === ' ') {\n send(SelectWithKeyboard);\n }\n }\n\n const {\n label: children,\n onMouseEnter: tooltipOnMouseEnter,\n onMouseLeave: tooltipOnMouseLeave,\n onMouseMove: tooltipOnMouseMove,\n ...otherTooltipProps\n } = tooltipProps;\n\n const tooltipId = `tooltip-${id}`;\n return [\n {\n ...childProps,\n ref: assignMultipleRefs(childRef, anchorEl),\n ...(visible && { 'aria-describedby': tooltipId }),\n onMouseEnter: wrapEvent(onMouseEnter, handleMouseEnter),\n onMouseLeave: wrapEvent(onMouseLeave, handleMouseLeave),\n onMouseMove: wrapEvent(onMouseMove, handleMouseMove),\n onMouseDown: wrapEvent(onMouseDown, handleMouseDown),\n onFocus: wrapEvent(onFocus, handleFocus),\n onBlur: wrapEvent(onBlur, handleBlur),\n onKeyDown: wrapEvent(onKeyDown, handleKeyDown),\n },\n {\n id: tooltipId,\n anchorEl,\n visible,\n children,\n onMouseEnter: wrapEvent(tooltipOnMouseEnter, handleMouseEnter),\n onMouseLeave: wrapEvent(tooltipOnMouseLeave, handleMouseLeave),\n onMouseMove: wrapEvent(tooltipOnMouseMove, handleMouseMove),\n role: 'tooltip',\n ...otherTooltipProps,\n },\n ];\n}\n"],"file":"useTooltip.js"}
|
|
@@ -3,7 +3,6 @@ export * from './useControlledState';
|
|
|
3
3
|
export * from './useChildrenCounter';
|
|
4
4
|
export * from './useFocusReturn';
|
|
5
5
|
export * from './useFocusState';
|
|
6
|
-
export * from './useId';
|
|
7
6
|
export * from './useOnClickOutside';
|
|
8
7
|
export * from './useOnKeyDown';
|
|
9
8
|
export * from './useReducerMachine';
|
package/build/esm/hooks/index.js
CHANGED
|
@@ -3,7 +3,6 @@ export * from './useControlledState';
|
|
|
3
3
|
export * from './useChildrenCounter';
|
|
4
4
|
export * from './useFocusReturn';
|
|
5
5
|
export * from './useFocusState';
|
|
6
|
-
export * from './useId';
|
|
7
6
|
export * from './useOnClickOutside';
|
|
8
7
|
export * from './useOnKeyDown';
|
|
9
8
|
export * from './useReducerMachine';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,sBAAd;AACA,cAAc,sBAAd;AACA,cAAc,kBAAd;AACA,cAAc,iBAAd;AACA,cAAc,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,sBAAd;AACA,cAAc,sBAAd;AACA,cAAc,kBAAd;AACA,cAAc,iBAAd;AACA,cAAc,qBAAd;AACA,cAAc,gBAAd;AACA,cAAc,qBAAd;AACA,cAAc,uBAAd;AACA,cAAc,eAAd;AACA,cAAc,cAAd;AACA,cAAc,sBAAd;AACA,cAAc,YAAd","sourcesContent":["export * from './useAutoFocus';\nexport * from './useControlledState';\nexport * from './useChildrenCounter';\nexport * from './useFocusReturn';\nexport * from './useFocusState';\nexport * from './useOnClickOutside';\nexport * from './useOnKeyDown';\nexport * from './useReducerMachine';\nexport * from './useRemoveBodyScroll';\nexport * from './useThrottle';\nexport * from './useMeasure';\nexport * from './useGestureHandlers';\nexport * from './useScope';\n"],"file":"index.js"}
|
|
File without changes
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
import { focusOnChildNode } from '../FocusLock/tabUtils';
|
|
2
3
|
export function useAutoFocus(open, elementRef) {
|
|
3
4
|
useEffect(() => {
|
|
4
5
|
if (open) {
|
|
5
|
-
|
|
6
|
+
// We will only autoFocus on the first child if the currently active element isn't already trapped inside the modal
|
|
7
|
+
if (elementRef.current && !elementRef.current.contains(document.activeElement)) {
|
|
8
|
+
focusOnChildNode(elementRef.current, 0);
|
|
9
|
+
}
|
|
6
10
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7
11
|
|
|
8
12
|
}, [open]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useAutoFocus.ts"],"names":["useEffect","useAutoFocus","open","elementRef","current","
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useAutoFocus.ts"],"names":["useEffect","focusOnChildNode","useAutoFocus","open","elementRef","current","contains","document","activeElement"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AACA,SAASC,gBAAT,QAAiC,uBAAjC;AAEA,OAAO,SAASC,YAAT,CACLC,IADK,EAELC,UAFK,EAGL;AACAJ,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIG,IAAJ,EAAU;AACR;AACA,UACEC,UAAU,CAACC,OAAX,IACA,CAACD,UAAU,CAACC,OAAX,CAAmBC,QAAnB,CAA4BC,QAAQ,CAACC,aAArC,CAFH,EAGE;AACAP,QAAAA,gBAAgB,CAACG,UAAU,CAACC,OAAZ,EAAqB,CAArB,CAAhB;AACD;AACF,KATa,CAUd;;AACD,GAXQ,EAWN,CAACF,IAAD,CAXM,CAAT;AAYD","sourcesContent":["import { useEffect } from 'react';\nimport { focusOnChildNode } from '../FocusLock/tabUtils';\n\nexport function useAutoFocus(\n open: boolean,\n elementRef: React.MutableRefObject<HTMLElement | null>\n) {\n useEffect(() => {\n if (open) {\n // We will only autoFocus on the first child if the currently active element isn't already trapped inside the modal\n if (\n elementRef.current &&\n !elementRef.current.contains(document.activeElement)\n ) {\n focusOnChildNode(elementRef.current, 0);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n}\n"],"file":"useAutoFocus.js"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
export declare function useFocusReturn(open: boolean, rootEl: MutableRefObject<HTMLElement | null>): void;
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
export function useFocusReturn(open) {
|
|
3
|
-
const previousFocusRef = useRef(
|
|
2
|
+
export function useFocusReturn(open, rootEl) {
|
|
3
|
+
const previousFocusRef = useRef((() => {
|
|
4
|
+
if (open && typeof document !== 'undefined' && document.activeElement instanceof HTMLElement) {
|
|
5
|
+
return document.activeElement;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return null;
|
|
9
|
+
})());
|
|
4
10
|
useEffect(() => {
|
|
5
11
|
if (open) {
|
|
12
|
+
var _rootEl$current;
|
|
13
|
+
|
|
6
14
|
// once opened, keep track of the element that triggered
|
|
7
15
|
// the Modal opening
|
|
8
|
-
previousFocusRef.current = document.activeElement
|
|
9
|
-
|
|
16
|
+
if (!previousFocusRef.current && document.activeElement instanceof HTMLElement && !((_rootEl$current = rootEl.current) != null && _rootEl$current.contains(document.activeElement))) {
|
|
17
|
+
previousFocusRef.current = document.activeElement;
|
|
18
|
+
}
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
20
|
+
const rootElement = rootEl.current;
|
|
21
|
+
const previousElement = previousFocusRef.current;
|
|
22
|
+
return () => {
|
|
23
|
+
// on unmount, return focus to that element
|
|
24
|
+
if (previousElement && !(rootElement != null && rootElement.contains(document.activeElement))) {
|
|
25
|
+
previousElement.focus({
|
|
26
|
+
preventScroll: true
|
|
27
|
+
});
|
|
17
28
|
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}, [open]);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}, [open, rootEl]);
|
|
21
32
|
}
|
|
22
33
|
//# sourceMappingURL=useFocusReturn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useFocusReturn.ts"],"names":["useEffect","useRef","useFocusReturn","open","
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useFocusReturn.ts"],"names":["useEffect","useRef","useFocusReturn","open","rootEl","previousFocusRef","document","activeElement","HTMLElement","current","contains","rootElement","previousElement","focus","preventScroll"],"mappings":"AAAA,SAA2BA,SAA3B,EAAsCC,MAAtC,QAAoD,OAApD;AAEA,OAAO,SAASC,cAAT,CACLC,IADK,EAELC,MAFK,EAGL;AACA,QAAMC,gBAAgB,GAAGJ,MAAM,CAC7B,CAAC,MAAM;AACL,QACEE,IAAI,IACJ,OAAOG,QAAP,KAAoB,WADpB,IAEAA,QAAQ,CAACC,aAAT,YAAkCC,WAHpC,EAIE;AACA,aAAOF,QAAQ,CAACC,aAAhB;AACD;;AACD,WAAO,IAAP;AACD,GATD,GAD6B,CAA/B;AAaAP,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIG,IAAJ,EAAU;AAAA;;AACR;AACA;AACA,UACE,CAACE,gBAAgB,CAACI,OAAlB,IACAH,QAAQ,CAACC,aAAT,YAAkCC,WADlC,IAEA,qBAACJ,MAAM,CAACK,OAAR,aAAC,gBAAgBC,QAAhB,CAAyBJ,QAAQ,CAACC,aAAlC,CAAD,CAHF,EAIE;AACAF,QAAAA,gBAAgB,CAACI,OAAjB,GAA2BH,QAAQ,CAACC,aAApC;AACD;;AAED,YAAMI,WAAW,GAAGP,MAAM,CAACK,OAA3B;AACA,YAAMG,eAAe,GAAGP,gBAAgB,CAACI,OAAzC;AACA,aAAO,MAAM;AACX;AACA,YAAIG,eAAe,IAAI,EAACD,WAAD,YAACA,WAAW,CAAED,QAAb,CAAsBJ,QAAQ,CAACC,aAA/B,CAAD,CAAvB,EAAuE;AACrEK,UAAAA,eAAe,CAACC,KAAhB,CAAsB;AAAEC,YAAAA,aAAa,EAAE;AAAjB,WAAtB;AACD;AACF,OALD;AAMD;AACF,GArBQ,EAqBN,CAACX,IAAD,EAAOC,MAAP,CArBM,CAAT;AAsBD","sourcesContent":["import { MutableRefObject, useEffect, useRef } from 'react';\n\nexport function useFocusReturn(\n open: boolean,\n rootEl: MutableRefObject<HTMLElement | null>\n) {\n const previousFocusRef = useRef<HTMLElement | null>(\n (() => {\n if (\n open &&\n typeof document !== 'undefined' &&\n document.activeElement instanceof HTMLElement\n ) {\n return document.activeElement;\n }\n return null;\n })()\n );\n\n useEffect(() => {\n if (open) {\n // once opened, keep track of the element that triggered\n // the Modal opening\n if (\n !previousFocusRef.current &&\n document.activeElement instanceof HTMLElement &&\n !rootEl.current?.contains(document.activeElement)\n ) {\n previousFocusRef.current = document.activeElement;\n }\n\n const rootElement = rootEl.current;\n const previousElement = previousFocusRef.current;\n return () => {\n // on unmount, return focus to that element\n if (previousElement && !rootElement?.contains(document.activeElement)) {\n previousElement.focus({ preventScroll: true });\n }\n };\n }\n }, [open, rootEl]);\n}\n"],"file":"useFocusReturn.js"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/hooks/useId.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
let scrollBodyCount = 0;
|
|
2
3
|
export function useRemoveBodyScroll(open) {
|
|
3
4
|
useEffect(() => {
|
|
4
5
|
if (open) {
|
|
5
|
-
|
|
6
|
+
scrollBodyCount += 1; // calculate scrollbar width if mounting the first scroll lock
|
|
6
7
|
|
|
7
8
|
let scrollBarWidth = 0;
|
|
8
9
|
|
|
9
|
-
if (
|
|
10
|
+
if (scrollBodyCount === 1) {
|
|
10
11
|
scrollBarWidth = window.innerWidth - document.body.clientWidth;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
document.body.style.overflow = 'hidden';
|
|
14
15
|
|
|
15
16
|
if (scrollBarWidth > 0) {
|
|
16
|
-
document.body.style.
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
window.__SCROLL_BODY_COUNT__ = locksCount;
|
|
21
|
-
}
|
|
17
|
+
document.body.style.marginRight = "".concat(scrollBarWidth, "px");
|
|
18
|
+
}
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const locksCount = window.__SCROLL_BODY_COUNT__ - 1;
|
|
20
|
+
return () => {
|
|
21
|
+
scrollBodyCount -= 1;
|
|
26
22
|
|
|
27
|
-
if (
|
|
23
|
+
if (scrollBodyCount === 0) {
|
|
28
24
|
document.body.style.overflow = '';
|
|
29
|
-
document.body.style.
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
window.__SCROLL_BODY_COUNT__ = locksCount;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
25
|
+
document.body.style.marginRight = '';
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
36
29
|
}, [open]);
|
|
37
30
|
}
|
|
38
31
|
//# sourceMappingURL=useRemoveBodyScroll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useRemoveBodyScroll.ts"],"names":["useEffect","useRemoveBodyScroll","open","
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useRemoveBodyScroll.ts"],"names":["useEffect","scrollBodyCount","useRemoveBodyScroll","open","scrollBarWidth","window","innerWidth","document","body","clientWidth","style","overflow","marginRight"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AAEA,IAAIC,eAAe,GAAG,CAAtB;AACA,OAAO,SAASC,mBAAT,CAA6BC,IAA7B,EAA4C;AACjDH,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIG,IAAJ,EAAU;AACRF,MAAAA,eAAe,IAAI,CAAnB,CADQ,CAGR;;AACA,UAAIG,cAAc,GAAG,CAArB;;AACA,UAAIH,eAAe,KAAK,CAAxB,EAA2B;AACzBG,QAAAA,cAAc,GAAGC,MAAM,CAACC,UAAP,GAAoBC,QAAQ,CAACC,IAAT,CAAcC,WAAnD;AACD;;AAEDF,MAAAA,QAAQ,CAACC,IAAT,CAAcE,KAAd,CAAoBC,QAApB,GAA+B,QAA/B;;AACA,UAAIP,cAAc,GAAG,CAArB,EAAwB;AACtBG,QAAAA,QAAQ,CAACC,IAAT,CAAcE,KAAd,CAAoBE,WAApB,aAAqCR,cAArC;AACD;;AAED,aAAO,MAAM;AACXH,QAAAA,eAAe,IAAI,CAAnB;;AACA,YAAIA,eAAe,KAAK,CAAxB,EAA2B;AACzBM,UAAAA,QAAQ,CAACC,IAAT,CAAcE,KAAd,CAAoBC,QAApB,GAA+B,EAA/B;AACAJ,UAAAA,QAAQ,CAACC,IAAT,CAAcE,KAAd,CAAoBE,WAApB,GAAkC,EAAlC;AACD;AACF,OAND;AAOD;AACF,GAvBQ,EAuBN,CAACT,IAAD,CAvBM,CAAT;AAwBD","sourcesContent":["import { useEffect } from 'react';\n\nlet scrollBodyCount = 0;\nexport function useRemoveBodyScroll(open: boolean) {\n useEffect(() => {\n if (open) {\n scrollBodyCount += 1;\n\n // calculate scrollbar width if mounting the first scroll lock\n let scrollBarWidth = 0;\n if (scrollBodyCount === 1) {\n scrollBarWidth = window.innerWidth - document.body.clientWidth;\n }\n\n document.body.style.overflow = 'hidden';\n if (scrollBarWidth > 0) {\n document.body.style.marginRight = `${scrollBarWidth}px`;\n }\n\n return () => {\n scrollBodyCount -= 1;\n if (scrollBodyCount === 0) {\n document.body.style.overflow = '';\n document.body.style.marginRight = '';\n }\n };\n }\n }, [open]);\n}\n"],"file":"useRemoveBodyScroll.js"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/index.d.ts
CHANGED
|
File without changes
|
package/build/esm/index.js
CHANGED
|
File without changes
|
package/build/esm/index.js.map
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/esm/utils/clamp.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/utils/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|