@basic-ui/core 0.0.50 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/build/cjs/index.js +106 -92
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +9 -9
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts +6 -6
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts +7 -7
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts +9 -9
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +19 -19
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/Accordion/index.d.ts +4 -4
- package/build/esm/Accordion/index.js.map +1 -1
- package/build/esm/Accordion/scopeQuery.d.ts +2 -2
- package/build/esm/Accordion/scopeQuery.js.map +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +7 -7
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/CheckBox/index.d.ts +1 -1
- package/build/esm/CheckBox/index.js.map +1 -1
- package/build/esm/ComboBox/Combobox.d.ts +18 -18
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +9 -9
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.d.ts +17 -17
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.d.ts +7 -7
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.d.ts +11 -11
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.d.ts +9 -9
- package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
- package/build/esm/ComboBox/cities.d.ts +5 -5
- package/build/esm/ComboBox/cities.js.map +1 -1
- package/build/esm/ComboBox/context.d.ts +30 -30
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +37 -37
- package/build/esm/ComboBox/hooks.js.map +1 -1
- package/build/esm/ComboBox/index.d.ts +8 -8
- package/build/esm/ComboBox/index.js.map +1 -1
- package/build/esm/ComboBox/makeHash.d.ts +1 -1
- package/build/esm/ComboBox/makeHash.js.map +1 -1
- package/build/esm/ComboBox/scopeQuery.d.ts +1 -1
- package/build/esm/ComboBox/scopeQuery.js.map +1 -1
- package/build/esm/FocusLock/FocusLock.d.ts +9 -9
- package/build/esm/FocusLock/FocusLock.js.map +1 -1
- package/build/esm/FocusLock/index.d.ts +1 -1
- package/build/esm/FocusLock/index.js.map +1 -1
- package/build/esm/FocusLock/tabUtils.d.ts +3 -3
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +7 -7
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +7 -7
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.d.ts +7 -7
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.d.ts +4 -4
- package/build/esm/List/context.js.map +1 -1
- package/build/esm/List/index.d.ts +2 -2
- package/build/esm/List/index.js.map +1 -1
- package/build/esm/Menu/ContextMenuTrigger.d.ts +11 -11
- package/build/esm/Menu/ContextMenuTrigger.js.map +1 -1
- package/build/esm/Menu/Menu.d.ts +10 -10
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +11 -11
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +8 -8
- package/build/esm/Menu/MenuItem.js +1 -0
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +7 -7
- package/build/esm/Menu/MenuList.js +17 -4
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts +8 -8
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +25 -25
- package/build/esm/Menu/context.js.map +1 -1
- package/build/esm/Menu/fixtures/countryList.d.ts +1 -1
- package/build/esm/Menu/fixtures/countryList.js.map +1 -1
- package/build/esm/Menu/index.d.ts +6 -6
- package/build/esm/Menu/index.js.map +1 -1
- package/build/esm/Menu/scope.d.ts +1 -1
- package/build/esm/Menu/scope.js.map +1 -1
- package/build/esm/Modal/Modal.d.ts +9 -9
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +10 -10
- package/build/esm/Modal/ModalBackdrop.js.map +1 -1
- package/build/esm/Modal/index.d.ts +2 -2
- package/build/esm/Modal/index.js.map +1 -1
- package/build/esm/Popper/Popper.d.ts +35 -35
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +6 -6
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.d.ts +6 -6
- package/build/esm/Popper/context.js.map +1 -1
- package/build/esm/Popper/index.d.ts +3 -3
- package/build/esm/Popper/index.js.map +1 -1
- package/build/esm/Portal/Portal.d.ts +6 -6
- package/build/esm/Portal/Portal.js.map +1 -1
- package/build/esm/Portal/index.d.ts +1 -1
- package/build/esm/Portal/index.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.d.ts +10 -10
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +12 -12
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +9 -9
- package/build/esm/RadioButton/context.js.map +1 -1
- package/build/esm/RadioButton/index.d.ts +2 -2
- package/build/esm/RadioButton/index.js.map +1 -1
- package/build/esm/SkipNav/SkipNav.d.ts +7 -7
- package/build/esm/SkipNav/SkipNav.js.map +1 -1
- package/build/esm/SkipNav/index.d.ts +1 -1
- package/build/esm/SkipNav/index.js.map +1 -1
- package/build/esm/Slider/Slider.d.ts +197 -197
- package/build/esm/Slider/Slider.js +82 -82
- package/build/esm/Slider/Slider.js.map +1 -1
- package/build/esm/Slider/index.d.ts +1 -1
- package/build/esm/Slider/index.js.map +1 -1
- package/build/esm/Spinner/Spinner.d.ts +12 -12
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.d.ts +8 -8
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.d.ts +12 -12
- package/build/esm/Spinner/context.js.map +1 -1
- package/build/esm/Spinner/index.d.ts +2 -2
- package/build/esm/Spinner/index.js.map +1 -1
- package/build/esm/Tabs/Tab.d.ts +7 -7
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.d.ts +9 -9
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +8 -8
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.d.ts +8 -8
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.d.ts +10 -10
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.d.ts +17 -17
- package/build/esm/Tabs/context.js.map +1 -1
- package/build/esm/Tabs/index.d.ts +5 -5
- package/build/esm/Tabs/index.js.map +1 -1
- package/build/esm/Tabs/scopeQuery.d.ts +1 -1
- package/build/esm/Tabs/scopeQuery.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +10 -10
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/index.d.ts +1 -1
- package/build/esm/Tooltip/index.js.map +1 -1
- package/build/esm/Tooltip/stateMachine.d.ts +28 -28
- package/build/esm/Tooltip/stateMachine.js.map +1 -1
- package/build/esm/Tooltip/useTooltip.d.ts +10 -10
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.d.ts +13 -13
- package/build/esm/hooks/index.js.map +1 -1
- package/build/esm/hooks/useAutoFocus.d.ts +2 -2
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.d.ts +7 -7
- package/build/esm/hooks/useChildrenCounter.js.map +1 -1
- package/build/esm/hooks/useControlledState.d.ts +3 -3
- package/build/esm/hooks/useControlledState.js +1 -1
- package/build/esm/hooks/useControlledState.js.map +1 -1
- package/build/esm/hooks/useFocusReturn.d.ts +2 -2
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +11 -11
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +52 -52
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useMeasure.d.ts +7 -7
- package/build/esm/hooks/useMeasure.js.map +1 -1
- package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
- package/build/esm/hooks/useOnClickOutside.js.map +1 -1
- package/build/esm/hooks/useOnKeyDown.d.ts +1 -1
- package/build/esm/hooks/useOnKeyDown.js.map +1 -1
- package/build/esm/hooks/useReducerMachine.d.ts +24 -24
- package/build/esm/hooks/useReducerMachine.js.map +1 -1
- package/build/esm/hooks/useRemoveBodyScroll.d.ts +2 -2
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +11 -11
- package/build/esm/hooks/useScope.js.map +1 -1
- package/build/esm/hooks/useThrottle.d.ts +1 -1
- package/build/esm/hooks/useThrottle.js.map +1 -1
- package/build/esm/index.d.ts +15 -15
- package/build/esm/index.js.map +1 -1
- package/build/esm/utils/assign-ref.d.ts +3 -3
- package/build/esm/utils/assign-ref.js.map +1 -1
- package/build/esm/utils/can-use-dom.d.ts +1 -1
- package/build/esm/utils/can-use-dom.js.map +1 -1
- package/build/esm/utils/clamp.d.ts +1 -1
- package/build/esm/utils/clamp.js.map +1 -1
- package/build/esm/utils/context.d.ts +7 -7
- package/build/esm/utils/context.js.map +1 -1
- package/build/esm/utils/create-subscription.d.ts +4 -4
- package/build/esm/utils/create-subscription.js.map +1 -1
- package/build/esm/utils/get-circular-index.d.ts +1 -1
- package/build/esm/utils/get-circular-index.js.map +1 -1
- package/build/esm/utils/index.d.ts +10 -10
- package/build/esm/utils/index.js.map +1 -1
- package/build/esm/utils/is-right-click.d.ts +6 -6
- package/build/esm/utils/is-right-click.js +4 -4
- package/build/esm/utils/is-right-click.js.map +1 -1
- package/build/esm/utils/owner-document.d.ts +7 -7
- package/build/esm/utils/owner-document.js +5 -5
- package/build/esm/utils/owner-document.js.map +1 -1
- package/build/esm/utils/polymorphic.d.ts +39 -39
- package/build/esm/utils/polymorphic.js.map +1 -1
- package/build/esm/utils/rubber-band-clamp.d.ts +2 -2
- package/build/esm/utils/rubber-band-clamp.js.map +1 -1
- package/build/esm/utils/use-stable-callback.d.ts +16 -16
- package/build/esm/utils/use-stable-callback.js +16 -16
- package/build/esm/utils/use-stable-callback.js.map +1 -1
- package/build/esm/utils/wrap-event.d.ts +3 -3
- package/build/esm/utils/wrap-event.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Accordion/Accordion.story.tsx +74 -74
- package/src/Accordion/Accordion.tsx +59 -59
- package/src/Accordion/AccordionBody.tsx +52 -52
- package/src/Accordion/AccordionHeader.tsx +167 -167
- package/src/Accordion/AccordionItem.tsx +50 -50
- package/src/Accordion/context.ts +37 -37
- package/src/Accordion/index.ts +4 -4
- package/src/Accordion/scopeQuery.ts +7 -7
- package/src/Accordion/styles.css +21 -21
- package/src/CheckBox/CheckBox.tsx +41 -41
- package/src/CheckBox/index.ts +1 -1
- package/src/ComboBox/ComboBox.story.tsx +120 -120
- package/src/ComboBox/Combobox.tsx +148 -148
- package/src/ComboBox/ComboboxButton.tsx +61 -61
- package/src/ComboBox/ComboboxInput.tsx +187 -187
- package/src/ComboBox/ComboboxLabel.tsx +33 -33
- package/src/ComboBox/ComboboxList.tsx +47 -47
- package/src/ComboBox/ComboboxOption.tsx +111 -111
- package/src/ComboBox/ComboboxPopover.tsx +64 -64
- package/src/ComboBox/cities.ts +23194 -23194
- package/src/ComboBox/context.ts +35 -35
- package/src/ComboBox/hooks.tsx +451 -451
- package/src/ComboBox/index.ts +8 -8
- package/src/ComboBox/makeHash.ts +19 -19
- package/src/ComboBox/scopeQuery.ts +6 -6
- package/src/ComboBox/styles.css +32 -32
- package/src/FocusLock/FocusLock.tsx +66 -66
- package/src/FocusLock/index.ts +1 -1
- package/src/FocusLock/tabUtils.ts +40 -40
- package/src/FocusLock/useFocusLock.ts +56 -56
- package/src/List/List.story.tsx +18 -18
- package/src/List/List.tsx +17 -17
- package/src/List/ListItem.tsx +23 -23
- package/src/List/context.ts +19 -19
- package/src/List/index.ts +2 -2
- package/src/Menu/ContextMenu.story.tsx +73 -73
- package/src/Menu/ContextMenuTrigger.tsx +76 -76
- package/src/Menu/Menu.story.tsx +160 -160
- package/src/Menu/Menu.tsx +83 -83
- package/src/Menu/MenuButton.tsx +83 -83
- package/src/Menu/MenuComplex.story.tsx +58 -58
- package/src/Menu/MenuItem.tsx +88 -87
- package/src/Menu/MenuList.tsx +254 -243
- package/src/Menu/MenuPopover.tsx +35 -35
- package/src/Menu/context.ts +44 -44
- package/src/Menu/fixtures/countryList.ts +198 -198
- package/src/Menu/index.ts +6 -6
- package/src/Menu/scope.ts +7 -7
- package/src/Menu/styles.css +42 -42
- package/src/Modal/Modal.story.tsx +258 -258
- package/src/Modal/Modal.tsx +48 -48
- package/src/Modal/ModalBackdrop.tsx +78 -78
- package/src/Modal/NavDrawer.story.tsx +158 -158
- package/src/Modal/index.ts +2 -2
- package/src/Modal/styles.css +46 -46
- package/src/Popper/Popper.story.tsx +263 -263
- package/src/Popper/Popper.tsx +154 -154
- package/src/Popper/PopperArrow.tsx +35 -35
- package/src/Popper/context.ts +10 -10
- package/src/Popper/index.ts +3 -3
- package/src/Popper/styles.css +60 -60
- package/src/Portal/Portal.tsx +20 -20
- package/src/Portal/index.ts +1 -1
- package/src/RadioButton/RadioButton.story.tsx +77 -77
- package/src/RadioButton/RadioButton.tsx +55 -55
- package/src/RadioButton/RadioGroup.tsx +60 -60
- package/src/RadioButton/context.ts +17 -17
- package/src/RadioButton/index.ts +2 -2
- package/src/SkipNav/SkipNav.tsx +16 -16
- package/src/SkipNav/index.tsx +1 -1
- package/src/Slider/Slider.story.tsx +45 -45
- package/src/Slider/Slider.tsx +1120 -1120
- package/src/Slider/index.ts +1 -1
- package/src/Slider/styles.css +131 -131
- package/src/Spinner/Spinner.story.tsx +31 -31
- package/src/Spinner/Spinner.tsx +117 -117
- package/src/Spinner/SpinnerButton.tsx +54 -54
- package/src/Spinner/context.ts +20 -20
- package/src/Spinner/index.ts +2 -2
- package/src/Spinner/styles.css +23 -23
- package/src/Tabs/Tab.story.tsx +80 -80
- package/src/Tabs/Tab.tsx +136 -136
- package/src/Tabs/TabList.tsx +71 -71
- package/src/Tabs/TabPanel.tsx +53 -53
- package/src/Tabs/TabPanels.tsx +30 -30
- package/src/Tabs/Tabs.tsx +46 -46
- package/src/Tabs/context.ts +30 -30
- package/src/Tabs/index.tsx +5 -5
- package/src/Tabs/scopeQuery.ts +6 -6
- package/src/Tooltip/Tooltip.story.tsx +61 -61
- package/src/Tooltip/Tooltip.tsx +50 -50
- package/src/Tooltip/index.ts +1 -1
- package/src/Tooltip/stateMachine.ts +192 -192
- package/src/Tooltip/styles.css +17 -17
- package/src/Tooltip/useTooltip.ts +136 -136
- package/src/hooks/index.ts +13 -13
- package/src/hooks/useAutoFocus.ts +22 -22
- package/src/hooks/useChildrenCounter.ts +51 -51
- package/src/hooks/useControlledState.ts +3 -3
- package/src/hooks/useFocusReturn.ts +43 -43
- package/src/hooks/useFocusState.ts +30 -30
- package/src/hooks/useGestureHandlers.ts +286 -286
- package/src/hooks/useMeasure.ts +33 -33
- package/src/hooks/useOnClickOutside.ts +32 -32
- package/src/hooks/useOnKeyDown.ts +19 -19
- package/src/hooks/useReducerMachine.ts +60 -60
- package/src/hooks/useRemoveBodyScroll.ts +39 -39
- package/src/hooks/useScope.ts +52 -52
- package/src/hooks/useThrottle.ts +19 -19
- package/src/index.ts +20 -20
- package/src/utils/assign-ref.ts +27 -27
- package/src/utils/can-use-dom.ts +7 -7
- package/src/utils/clamp.ts +3 -3
- package/src/utils/context.tsx +48 -48
- package/src/utils/create-subscription.ts +16 -16
- package/src/utils/get-circular-index.ts +7 -7
- package/src/utils/index.ts +10 -10
- package/src/utils/is-right-click.ts +14 -14
- package/src/utils/owner-document.ts +13 -13
- package/src/utils/polymorphic.ts +78 -78
- package/src/utils/rubber-band-clamp.ts +25 -25
- package/src/utils/use-stable-callback.ts +58 -58
- package/src/utils/wrap-event.ts +22 -22
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detects right clicks
|
|
3
|
-
*
|
|
4
|
-
* @param nativeEvent
|
|
5
|
-
*/
|
|
6
|
-
export declare function isRightClick(nativeEvent: MouseEvent | PointerEvent | TouchEvent): boolean;
|
|
1
|
+
/**
|
|
2
|
+
* Detects right clicks
|
|
3
|
+
*
|
|
4
|
+
* @param nativeEvent
|
|
5
|
+
*/
|
|
6
|
+
export declare function isRightClick(nativeEvent: MouseEvent | PointerEvent | TouchEvent): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detects right clicks
|
|
3
|
-
*
|
|
4
|
-
* @param nativeEvent
|
|
1
|
+
/**
|
|
2
|
+
* Detects right clicks
|
|
3
|
+
*
|
|
4
|
+
* @param nativeEvent
|
|
5
5
|
*/
|
|
6
6
|
export function isRightClick(nativeEvent) {
|
|
7
7
|
return 'which' in nativeEvent ? nativeEvent.which === 3 : 'button' in nativeEvent ? nativeEvent.button === 2 : false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-right-click.js","names":["isRightClick","nativeEvent","which","button"],"sources":["../../../src/utils/is-right-click.ts"],"sourcesContent":["/**\n * Detects right clicks\n *\n * @param nativeEvent\n */\nexport function isRightClick(\n nativeEvent: MouseEvent | PointerEvent | TouchEvent\n) {\n return 'which' in nativeEvent\n ? nativeEvent.which === 3\n : 'button' in nativeEvent\n ? (nativeEvent as any).button === 2\n : false;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAT,CACLC,WADK,EAEL;EACA,OAAO,WAAWA,WAAX,GACHA,WAAW,CAACC,KAAZ,KAAsB,CADnB,GAEH,YAAYD,WAAZ,GACCA,WAAD,CAAqBE,MAArB,KAAgC,CADhC,GAEA,KAJJ;AAKD"}
|
|
1
|
+
{"version":3,"file":"is-right-click.js","names":["isRightClick","nativeEvent","which","button"],"sources":["../../../src/utils/is-right-click.ts"],"sourcesContent":["/**\r\n * Detects right clicks\r\n *\r\n * @param nativeEvent\r\n */\r\nexport function isRightClick(\r\n nativeEvent: MouseEvent | PointerEvent | TouchEvent\r\n) {\r\n return 'which' in nativeEvent\r\n ? nativeEvent.which === 3\r\n : 'button' in nativeEvent\r\n ? (nativeEvent as any).button === 2\r\n : false;\r\n}\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAT,CACLC,WADK,EAEL;EACA,OAAO,WAAWA,WAAX,GACHA,WAAW,CAACC,KAAZ,KAAsB,CADnB,GAEH,YAAYD,WAAZ,GACCA,WAAD,CAAqBE,MAArB,KAAgC,CADhC,GAEA,KAJJ;AAKD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get an element's owner document. Useful when components are used in iframes
|
|
3
|
-
* or other environments like dev tools.
|
|
4
|
-
*
|
|
5
|
-
* @param element
|
|
6
|
-
*/
|
|
7
|
-
export declare function getOwnerDocument<T extends Element>(element: T | null | undefined): Document | null;
|
|
1
|
+
/**
|
|
2
|
+
* Get an element's owner document. Useful when components are used in iframes
|
|
3
|
+
* or other environments like dev tools.
|
|
4
|
+
*
|
|
5
|
+
* @param element
|
|
6
|
+
*/
|
|
7
|
+
export declare function getOwnerDocument<T extends Element>(element: T | null | undefined): Document | null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { canUseDOM } from './can-use-dom';
|
|
2
|
-
/**
|
|
3
|
-
* Get an element's owner document. Useful when components are used in iframes
|
|
4
|
-
* or other environments like dev tools.
|
|
5
|
-
*
|
|
6
|
-
* @param element
|
|
2
|
+
/**
|
|
3
|
+
* Get an element's owner document. Useful when components are used in iframes
|
|
4
|
+
* or other environments like dev tools.
|
|
5
|
+
*
|
|
6
|
+
* @param element
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
export function getOwnerDocument(element) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owner-document.js","names":["canUseDOM","getOwnerDocument","element","ownerDocument","document"],"sources":["../../../src/utils/owner-document.ts"],"sourcesContent":["import { canUseDOM } from './can-use-dom';\n\n/**\n * Get an element's owner document. Useful when components are used in iframes\n * or other environments like dev tools.\n *\n * @param element\n */\nexport function getOwnerDocument<T extends Element>(\n element: T | null | undefined\n) {\n return canUseDOM() ? (element ? element.ownerDocument : document) : null;\n}\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,eAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CACLC,OADK,EAEL;EACA,OAAOF,SAAS,KAAME,OAAO,GAAGA,OAAO,CAACC,aAAX,GAA2BC,QAAxC,GAAoD,IAApE;AACD"}
|
|
1
|
+
{"version":3,"file":"owner-document.js","names":["canUseDOM","getOwnerDocument","element","ownerDocument","document"],"sources":["../../../src/utils/owner-document.ts"],"sourcesContent":["import { canUseDOM } from './can-use-dom';\r\n\r\n/**\r\n * Get an element's owner document. Useful when components are used in iframes\r\n * or other environments like dev tools.\r\n *\r\n * @param element\r\n */\r\nexport function getOwnerDocument<T extends Element>(\r\n element: T | null | undefined\r\n) {\r\n return canUseDOM() ? (element ? element.ownerDocument : document) : null;\r\n}\r\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,eAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CACLC,OADK,EAEL;EACA,OAAOF,SAAS,KAAME,OAAO,GAAGA,OAAO,CAACC,aAAX,GAA2BC,QAAxC,GAAoD,IAApE;AACD"}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import type * as React from 'react';
|
|
2
|
-
export declare type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;
|
|
3
|
-
/**
|
|
4
|
-
* Infers the OwnProps if E is a ForwardRefExoticComponentWithAs
|
|
5
|
-
*/
|
|
6
|
-
export declare type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : {};
|
|
7
|
-
/**
|
|
8
|
-
* Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs
|
|
9
|
-
*/
|
|
10
|
-
export declare type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any> ? I : never;
|
|
11
|
-
declare type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, OwnProps & {
|
|
12
|
-
as?: E;
|
|
13
|
-
innerAs?: E;
|
|
14
|
-
}>>;
|
|
15
|
-
export interface ForwardRefComponent<IntrinsicElementString, OwnProps = {}> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> {
|
|
16
|
-
<As = IntrinsicElementString>(props: As extends '' ? {
|
|
17
|
-
as: keyof JSX.IntrinsicElements;
|
|
18
|
-
innerAs?: keyof JSX.IntrinsicElements;
|
|
19
|
-
} : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & {
|
|
20
|
-
as: As;
|
|
21
|
-
innerAs?: As;
|
|
22
|
-
}> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
|
|
23
|
-
as: As;
|
|
24
|
-
innerAs?: As;
|
|
25
|
-
}> : never): React.ReactElement | null;
|
|
26
|
-
}
|
|
27
|
-
export interface MemoComponent<IntrinsicElementString, OwnProps = {}> extends React.MemoExoticComponent<ForwardRefComponent<IntrinsicElementString, OwnProps>> {
|
|
28
|
-
<As = IntrinsicElementString>(props: As extends '' ? {
|
|
29
|
-
as: keyof JSX.IntrinsicElements;
|
|
30
|
-
innerAs?: keyof JSX.IntrinsicElements;
|
|
31
|
-
} : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & {
|
|
32
|
-
as: As;
|
|
33
|
-
innerAs?: As;
|
|
34
|
-
}> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
|
|
35
|
-
as: As;
|
|
36
|
-
innerAs?: As;
|
|
37
|
-
}> : never): React.ReactElement | null;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export declare type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;
|
|
3
|
+
/**
|
|
4
|
+
* Infers the OwnProps if E is a ForwardRefExoticComponentWithAs
|
|
5
|
+
*/
|
|
6
|
+
export declare type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : {};
|
|
7
|
+
/**
|
|
8
|
+
* Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs
|
|
9
|
+
*/
|
|
10
|
+
export declare type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any> ? I : never;
|
|
11
|
+
declare type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, OwnProps & {
|
|
12
|
+
as?: E;
|
|
13
|
+
innerAs?: E;
|
|
14
|
+
}>>;
|
|
15
|
+
export interface ForwardRefComponent<IntrinsicElementString, OwnProps = {}> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> {
|
|
16
|
+
<As = IntrinsicElementString>(props: As extends '' ? {
|
|
17
|
+
as: keyof JSX.IntrinsicElements;
|
|
18
|
+
innerAs?: keyof JSX.IntrinsicElements;
|
|
19
|
+
} : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & {
|
|
20
|
+
as: As;
|
|
21
|
+
innerAs?: As;
|
|
22
|
+
}> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
|
|
23
|
+
as: As;
|
|
24
|
+
innerAs?: As;
|
|
25
|
+
}> : never): React.ReactElement | null;
|
|
26
|
+
}
|
|
27
|
+
export interface MemoComponent<IntrinsicElementString, OwnProps = {}> extends React.MemoExoticComponent<ForwardRefComponent<IntrinsicElementString, OwnProps>> {
|
|
28
|
+
<As = IntrinsicElementString>(props: As extends '' ? {
|
|
29
|
+
as: keyof JSX.IntrinsicElements;
|
|
30
|
+
innerAs?: keyof JSX.IntrinsicElements;
|
|
31
|
+
} : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & {
|
|
32
|
+
as: As;
|
|
33
|
+
innerAs?: As;
|
|
34
|
+
}> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & {
|
|
35
|
+
as: As;
|
|
36
|
+
innerAs?: As;
|
|
37
|
+
}> : never): React.ReactElement | null;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polymorphic.js","names":[],"sources":["../../../src/utils/polymorphic.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\n// adapted from https://github.com/radix-ui/primitives/blob/2f139a832ba0cdfd445c937ebf63c2e79e0ef7ed/packages/react/polymorphic/src/polymorphic.ts\n// Would have liked to use it directly instead of copying but they are\n// (rightfully) treating it as an internal utility, so copy/paste it is to\n// prevent any needless churn if they make breaking changes. Big thanks to Jenna\n// for the heavy lifting! https://github.com/jjenzz\n\nimport type * as React from 'react';\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;\n\n/**\n * Infers the OwnProps if E is a ForwardRefExoticComponentWithAs\n */\nexport type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : {};\n\n/**\n * Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs\n */\nexport type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any>\n ? I\n : never;\n\ntype ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<\n Merge<\n E extends React.ElementType ? React.ComponentPropsWithRef<E> : never,\n OwnProps & { as?: E; innerAs?: E }\n >\n>;\n\nexport interface ForwardRefComponent<\n IntrinsicElementString,\n OwnProps = {}\n /*\n * Extends original type to ensure built in React types play nice with\n * polymorphic components still e.g. `React.ElementRef` etc.\n */\n> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> {\n /*\n * When `as` prop is passed, use this overload. Merges original own props\n * (without DOM props) and the inferred props from `as` element with the own\n * props taking precendence.\n *\n * We explicitly avoid `React.ElementType` and manually narrow the prop types\n * so that events are typed when using JSX.IntrinsicElements.\n */\n <As = IntrinsicElementString>(\n props: As extends ''\n ? {\n as: keyof JSX.IntrinsicElements;\n innerAs?: keyof JSX.IntrinsicElements;\n }\n : As extends React.ComponentType<infer P>\n ? Merge<P, OwnProps & { as: As; innerAs?: As }>\n : As extends keyof JSX.IntrinsicElements\n ? Merge<JSX.IntrinsicElements[As], OwnProps & { as: As; innerAs?: As }>\n : never\n ): React.ReactElement | null;\n}\n\nexport interface MemoComponent<IntrinsicElementString, OwnProps = {}>\n extends React.MemoExoticComponent<\n ForwardRefComponent<IntrinsicElementString, OwnProps>\n > {\n <As = IntrinsicElementString>(\n props: As extends ''\n ? {\n as: keyof JSX.IntrinsicElements;\n innerAs?: keyof JSX.IntrinsicElements;\n }\n : As extends React.ComponentType<infer P>\n ? Merge<P, OwnProps & { as: As; innerAs?: As }>\n : As extends keyof JSX.IntrinsicElements\n ? Merge<JSX.IntrinsicElements[As], OwnProps & { as: As; innerAs?: As }>\n : never\n ): React.ReactElement | null;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"polymorphic.js","names":[],"sources":["../../../src/utils/polymorphic.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\r\n// adapted from https://github.com/radix-ui/primitives/blob/2f139a832ba0cdfd445c937ebf63c2e79e0ef7ed/packages/react/polymorphic/src/polymorphic.ts\r\n// Would have liked to use it directly instead of copying but they are\r\n// (rightfully) treating it as an internal utility, so copy/paste it is to\r\n// prevent any needless churn if they make breaking changes. Big thanks to Jenna\r\n// for the heavy lifting! https://github.com/jjenzz\r\n\r\nimport type * as React from 'react';\r\n\r\n// eslint-disable-next-line @typescript-eslint/ban-types\r\nexport type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;\r\n\r\n/**\r\n * Infers the OwnProps if E is a ForwardRefExoticComponentWithAs\r\n */\r\nexport type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : {};\r\n\r\n/**\r\n * Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs\r\n */\r\nexport type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any>\r\n ? I\r\n : never;\r\n\r\ntype ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<\r\n Merge<\r\n E extends React.ElementType ? React.ComponentPropsWithRef<E> : never,\r\n OwnProps & { as?: E; innerAs?: E }\r\n >\r\n>;\r\n\r\nexport interface ForwardRefComponent<\r\n IntrinsicElementString,\r\n OwnProps = {}\r\n /*\r\n * Extends original type to ensure built in React types play nice with\r\n * polymorphic components still e.g. `React.ElementRef` etc.\r\n */\r\n> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> {\r\n /*\r\n * When `as` prop is passed, use this overload. Merges original own props\r\n * (without DOM props) and the inferred props from `as` element with the own\r\n * props taking precendence.\r\n *\r\n * We explicitly avoid `React.ElementType` and manually narrow the prop types\r\n * so that events are typed when using JSX.IntrinsicElements.\r\n */\r\n <As = IntrinsicElementString>(\r\n props: As extends ''\r\n ? {\r\n as: keyof JSX.IntrinsicElements;\r\n innerAs?: keyof JSX.IntrinsicElements;\r\n }\r\n : As extends React.ComponentType<infer P>\r\n ? Merge<P, OwnProps & { as: As; innerAs?: As }>\r\n : As extends keyof JSX.IntrinsicElements\r\n ? Merge<JSX.IntrinsicElements[As], OwnProps & { as: As; innerAs?: As }>\r\n : never\r\n ): React.ReactElement | null;\r\n}\r\n\r\nexport interface MemoComponent<IntrinsicElementString, OwnProps = {}>\r\n extends React.MemoExoticComponent<\r\n ForwardRefComponent<IntrinsicElementString, OwnProps>\r\n > {\r\n <As = IntrinsicElementString>(\r\n props: As extends ''\r\n ? {\r\n as: keyof JSX.IntrinsicElements;\r\n innerAs?: keyof JSX.IntrinsicElements;\r\n }\r\n : As extends React.ComponentType<infer P>\r\n ? Merge<P, OwnProps & { as: As; innerAs?: As }>\r\n : As extends keyof JSX.IntrinsicElements\r\n ? Merge<JSX.IntrinsicElements[As], OwnProps & { as: As; innerAs?: As }>\r\n : never\r\n ): React.ReactElement | null;\r\n}\r\n"],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function rubberBand(distance: number, dimension: number, constant?: number): number;
|
|
2
|
-
export declare function rubberBandClamp(min: number, max: number, delta: number, constant?: number): number;
|
|
1
|
+
export declare function rubberBand(distance: number, dimension: number, constant?: number): number;
|
|
2
|
+
export declare function rubberBandClamp(min: number, max: number, delta: number, constant?: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rubber-band-clamp.js","names":["rubberBand","distance","dimension","constant","rubberBandClamp","min","max","delta"],"sources":["../../../src/utils/rubber-band-clamp.ts"],"sourcesContent":["// https://twitter.com/chpwn/status/285540192096497664\n// iOS constant = 0.55\nexport function rubberBand(\n distance: number,\n dimension: number,\n constant = 0.15\n) {\n return (distance * dimension * constant) / (dimension + constant * distance);\n}\n\nexport function rubberBandClamp(\n min: number,\n max: number,\n delta: number,\n constant = 0.15\n) {\n if (delta < min) {\n return -rubberBand(min - delta, max - min, constant) + min;\n }\n if (delta > max) {\n return rubberBand(delta - max, max - min, constant) + max;\n }\n\n return delta;\n}\n"],"mappings":"AAAA;AACA;AACA,OAAO,SAASA,UAAT,CACLC,QADK,EAELC,SAFK,EAIL;EAAA,IADAC,QACA,uEADW,IACX;EACA,OAAQF,QAAQ,GAAGC,SAAX,GAAuBC,QAAxB,IAAqCD,SAAS,GAAGC,QAAQ,GAAGF,QAA5D,CAAP;AACD;AAED,OAAO,SAASG,eAAT,CACLC,GADK,EAELC,GAFK,EAGLC,KAHK,EAKL;EAAA,IADAJ,QACA,uEADW,IACX;;EACA,IAAII,KAAK,GAAGF,GAAZ,EAAiB;IACf,OAAO,CAACL,UAAU,CAACK,GAAG,GAAGE,KAAP,EAAcD,GAAG,GAAGD,GAApB,EAAyBF,QAAzB,CAAX,GAAgDE,GAAvD;EACD;;EACD,IAAIE,KAAK,GAAGD,GAAZ,EAAiB;IACf,OAAON,UAAU,CAACO,KAAK,GAAGD,GAAT,EAAcA,GAAG,GAAGD,GAApB,EAAyBF,QAAzB,CAAV,GAA+CG,GAAtD;EACD;;EAED,OAAOC,KAAP;AACD"}
|
|
1
|
+
{"version":3,"file":"rubber-band-clamp.js","names":["rubberBand","distance","dimension","constant","rubberBandClamp","min","max","delta"],"sources":["../../../src/utils/rubber-band-clamp.ts"],"sourcesContent":["// https://twitter.com/chpwn/status/285540192096497664\r\n// iOS constant = 0.55\r\nexport function rubberBand(\r\n distance: number,\r\n dimension: number,\r\n constant = 0.15\r\n) {\r\n return (distance * dimension * constant) / (dimension + constant * distance);\r\n}\r\n\r\nexport function rubberBandClamp(\r\n min: number,\r\n max: number,\r\n delta: number,\r\n constant = 0.15\r\n) {\r\n if (delta < min) {\r\n return -rubberBand(min - delta, max - min, constant) + min;\r\n }\r\n if (delta > max) {\r\n return rubberBand(delta - max, max - min, constant) + max;\r\n }\r\n\r\n return delta;\r\n}\r\n"],"mappings":"AAAA;AACA;AACA,OAAO,SAASA,UAAT,CACLC,QADK,EAELC,SAFK,EAIL;EAAA,IADAC,QACA,uEADW,IACX;EACA,OAAQF,QAAQ,GAAGC,SAAX,GAAuBC,QAAxB,IAAqCD,SAAS,GAAGC,QAAQ,GAAGF,QAA5D,CAAP;AACD;AAED,OAAO,SAASG,eAAT,CACLC,GADK,EAELC,GAFK,EAGLC,KAHK,EAKL;EAAA,IADAJ,QACA,uEADW,IACX;;EACA,IAAII,KAAK,GAAGF,GAAZ,EAAiB;IACf,OAAO,CAACL,UAAU,CAACK,GAAG,GAAGE,KAAP,EAAcD,GAAG,GAAGD,GAApB,EAAyBF,QAAzB,CAAX,GAAgDE,GAAvD;EACD;;EACD,IAAIE,KAAK,GAAGD,GAAZ,EAAiB;IACf,OAAON,UAAU,CAACO,KAAK,GAAGD,GAAT,EAAcA,GAAG,GAAGD,GAApB,EAAyBF,QAAzB,CAAV,GAA+CG,GAAtD;EACD;;EAED,OAAOC,KAAP;AACD"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
3
|
-
* prop and exposed as a stable function to avoid executing effects when passed
|
|
4
|
-
* as a dependency.
|
|
5
|
-
*/
|
|
6
|
-
export declare function useStableCallback<T extends (...args: any[]) => any>(callback: T | null | undefined): T;
|
|
7
|
-
/**
|
|
8
|
-
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
9
|
-
* prop and exposed as a stable function to avoid executing effects when passed
|
|
10
|
-
* as a dependency.
|
|
11
|
-
*
|
|
12
|
-
* Use this over `useStableCallback` when you want the callback to be cached in
|
|
13
|
-
* `useLayoutEffect` instead of `useEffect` to deal with timing issues only when
|
|
14
|
-
* needed.
|
|
15
|
-
*/
|
|
16
|
-
export declare function useStableLayoutCallback<T extends (...args: any[]) => any>(callback: T | null | undefined): T;
|
|
1
|
+
/**
|
|
2
|
+
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
3
|
+
* prop and exposed as a stable function to avoid executing effects when passed
|
|
4
|
+
* as a dependency.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useStableCallback<T extends (...args: any[]) => any>(callback: T | null | undefined): T;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
9
|
+
* prop and exposed as a stable function to avoid executing effects when passed
|
|
10
|
+
* as a dependency.
|
|
11
|
+
*
|
|
12
|
+
* Use this over `useStableCallback` when you want the callback to be cached in
|
|
13
|
+
* `useLayoutEffect` instead of `useEffect` to deal with timing issues only when
|
|
14
|
+
* needed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useStableLayoutCallback<T extends (...args: any[]) => any>(callback: T | null | undefined): T;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
2
|
import { useRef, useEffect, useCallback, useLayoutEffect } from 'react';
|
|
3
3
|
var useEnhancedEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
4
|
-
/**
|
|
5
|
-
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
6
|
-
* prop and exposed as a stable function to avoid executing effects when
|
|
7
|
-
* passed as a dependency.
|
|
4
|
+
/**
|
|
5
|
+
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
6
|
+
* prop and exposed as a stable function to avoid executing effects when
|
|
7
|
+
* passed as a dependency.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
function createStableCallbackHook(useEffectHook, callback) {
|
|
@@ -17,24 +17,24 @@ function createStableCallbackHook(useEffectHook, callback) {
|
|
|
17
17
|
callbackRef.current && callbackRef.current.apply(callbackRef, arguments);
|
|
18
18
|
}, []);
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
22
|
-
* prop and exposed as a stable function to avoid executing effects when passed
|
|
23
|
-
* as a dependency.
|
|
20
|
+
/**
|
|
21
|
+
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
22
|
+
* prop and exposed as a stable function to avoid executing effects when passed
|
|
23
|
+
* as a dependency.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
export function useStableCallback(callback) {
|
|
28
28
|
return createStableCallbackHook(useEffect, callback);
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
32
|
-
* prop and exposed as a stable function to avoid executing effects when passed
|
|
33
|
-
* as a dependency.
|
|
34
|
-
*
|
|
35
|
-
* Use this over `useStableCallback` when you want the callback to be cached in
|
|
36
|
-
* `useLayoutEffect` instead of `useEffect` to deal with timing issues only when
|
|
37
|
-
* needed.
|
|
30
|
+
/**
|
|
31
|
+
* Converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
32
|
+
* prop and exposed as a stable function to avoid executing effects when passed
|
|
33
|
+
* as a dependency.
|
|
34
|
+
*
|
|
35
|
+
* Use this over `useStableCallback` when you want the callback to be cached in
|
|
36
|
+
* `useLayoutEffect` instead of `useEffect` to deal with timing issues only when
|
|
37
|
+
* needed.
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
export function useStableLayoutCallback(callback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-stable-callback.js","names":["useRef","useEffect","useCallback","useLayoutEffect","useEnhancedEffect","window","createStableCallbackHook","useEffectHook","callback","callbackRef","current","useStableCallback","useStableLayoutCallback"],"sources":["../../../src/utils/use-stable-callback.ts"],"sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\nimport { useRef, useEffect, useCallback, useLayoutEffect } from 'react';\nimport type * as React from 'react';\n\nconst useEnhancedEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\n/**\n * Converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop and exposed as a stable function to avoid executing effects when\n * passed as a dependency.\n */\nfunction createStableCallbackHook<T extends (...args: any[]) => any>(\n useEffectHook: (\n effect: React.EffectCallback,\n deps?: React.DependencyList | undefined\n ) => void,\n callback: T | null | undefined\n): T {\n const callbackRef = useRef(callback);\n useEffectHook(() => {\n callbackRef.current = callback;\n });\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useCallback(\n ((...args) => {\n callbackRef.current && callbackRef.current(...args);\n }) as T,\n []\n );\n}\n\n/**\n * Converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop and exposed as a stable function to avoid executing effects when passed\n * as a dependency.\n */\nexport function useStableCallback<T extends (...args: any[]) => any>(\n callback: T | null | undefined\n): T {\n return createStableCallbackHook(useEffect, callback);\n}\n\n/**\n * Converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop and exposed as a stable function to avoid executing effects when passed\n * as a dependency.\n *\n * Use this over `useStableCallback` when you want the callback to be cached in\n * `useLayoutEffect` instead of `useEffect` to deal with timing issues only when\n * needed.\n */\nexport function useStableLayoutCallback<T extends (...args: any[]) => any>(\n callback: T | null | undefined\n): T {\n return createStableCallbackHook(useEnhancedEffect, callback);\n}\n"],"mappings":"AAAA;AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,WAA5B,EAAyCC,eAAzC,QAAgE,OAAhE;AAGA,IAAMC,iBAAiB,GACrB,OAAOC,MAAP,KAAkB,WAAlB,GAAgCF,eAAhC,GAAkDF,SADpD;AAGA;AACA;AACA;AACA;AACA;;AACA,SAASK,wBAAT,CACEC,aADF,EAKEC,QALF,EAMK;EACH,IAAMC,WAAW,GAAGT,MAAM,CAACQ,QAAD,CAA1B;EACAD,aAAa,CAAC,YAAM;IAClBE,WAAW,CAACC,OAAZ,GAAsBF,QAAtB;EACD,CAFY,CAAb,CAFG,CAMH;;EACA,OAAON,WAAW,CACf,YAAa;IACZO,WAAW,CAACC,OAAZ,IAAuBD,WAAW,CAACC,OAAZ,OAAAD,WAAW,YAAlC;EACD,CAHe,EAIhB,EAJgB,CAAlB;AAMD;AAED;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASE,iBAAT,CACLH,QADK,EAEF;EACH,OAAOF,wBAAwB,CAACL,SAAD,EAAYO,QAAZ,CAA/B;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,uBAAT,CACLJ,QADK,EAEF;EACH,OAAOF,wBAAwB,CAACF,iBAAD,EAAoBI,QAApB,CAA/B;AACD"}
|
|
1
|
+
{"version":3,"file":"use-stable-callback.js","names":["useRef","useEffect","useCallback","useLayoutEffect","useEnhancedEffect","window","createStableCallbackHook","useEffectHook","callback","callbackRef","current","useStableCallback","useStableLayoutCallback"],"sources":["../../../src/utils/use-stable-callback.ts"],"sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\r\nimport { useRef, useEffect, useCallback, useLayoutEffect } from 'react';\r\nimport type * as React from 'react';\r\n\r\nconst useEnhancedEffect =\r\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\r\n\r\n/**\r\n * Converts a callback to a ref to avoid triggering re-renders when passed as a\r\n * prop and exposed as a stable function to avoid executing effects when\r\n * passed as a dependency.\r\n */\r\nfunction createStableCallbackHook<T extends (...args: any[]) => any>(\r\n useEffectHook: (\r\n effect: React.EffectCallback,\r\n deps?: React.DependencyList | undefined\r\n ) => void,\r\n callback: T | null | undefined\r\n): T {\r\n const callbackRef = useRef(callback);\r\n useEffectHook(() => {\r\n callbackRef.current = callback;\r\n });\r\n\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n return useCallback(\r\n ((...args) => {\r\n callbackRef.current && callbackRef.current(...args);\r\n }) as T,\r\n []\r\n );\r\n}\r\n\r\n/**\r\n * Converts a callback to a ref to avoid triggering re-renders when passed as a\r\n * prop and exposed as a stable function to avoid executing effects when passed\r\n * as a dependency.\r\n */\r\nexport function useStableCallback<T extends (...args: any[]) => any>(\r\n callback: T | null | undefined\r\n): T {\r\n return createStableCallbackHook(useEffect, callback);\r\n}\r\n\r\n/**\r\n * Converts a callback to a ref to avoid triggering re-renders when passed as a\r\n * prop and exposed as a stable function to avoid executing effects when passed\r\n * as a dependency.\r\n *\r\n * Use this over `useStableCallback` when you want the callback to be cached in\r\n * `useLayoutEffect` instead of `useEffect` to deal with timing issues only when\r\n * needed.\r\n */\r\nexport function useStableLayoutCallback<T extends (...args: any[]) => any>(\r\n callback: T | null | undefined\r\n): T {\r\n return createStableCallbackHook(useEnhancedEffect, callback);\r\n}\r\n"],"mappings":"AAAA;AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,WAA5B,EAAyCC,eAAzC,QAAgE,OAAhE;AAGA,IAAMC,iBAAiB,GACrB,OAAOC,MAAP,KAAkB,WAAlB,GAAgCF,eAAhC,GAAkDF,SADpD;AAGA;AACA;AACA;AACA;AACA;;AACA,SAASK,wBAAT,CACEC,aADF,EAKEC,QALF,EAMK;EACH,IAAMC,WAAW,GAAGT,MAAM,CAACQ,QAAD,CAA1B;EACAD,aAAa,CAAC,YAAM;IAClBE,WAAW,CAACC,OAAZ,GAAsBF,QAAtB;EACD,CAFY,CAAb,CAFG,CAMH;;EACA,OAAON,WAAW,CACf,YAAa;IACZO,WAAW,CAACC,OAAZ,IAAuBD,WAAW,CAACC,OAAZ,OAAAD,WAAW,YAAlC;EACD,CAHe,EAIhB,EAJgB,CAAlB;AAMD;AAED;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASE,iBAAT,CACLH,QADK,EAEF;EACH,OAAOF,wBAAwB,CAACL,SAAD,EAAYO,QAAZ,CAA/B;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,uBAAT,CACLJ,QADK,EAEF;EACH,OAAOF,wBAAwB,CAACF,iBAAD,EAAoBI,QAApB,CAA/B;AACD"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SyntheticEvent } from 'react';
|
|
2
|
-
export declare type CustomEventHandler<E extends SyntheticEvent<any> | Event, H extends unknown[]> = (e: E, ...args: H) => void;
|
|
3
|
-
export declare function wrapEvent<EventType extends SyntheticEvent<any> | Event, H extends unknown[]>(theirHandler: CustomEventHandler<EventType, H> | undefined, ourHandler: CustomEventHandler<EventType, H>): CustomEventHandler<EventType, H>;
|
|
1
|
+
import type { SyntheticEvent } from 'react';
|
|
2
|
+
export declare type CustomEventHandler<E extends SyntheticEvent<any> | Event, H extends unknown[]> = (e: E, ...args: H) => void;
|
|
3
|
+
export declare function wrapEvent<EventType extends SyntheticEvent<any> | Event, H extends unknown[]>(theirHandler: CustomEventHandler<EventType, H> | undefined, ourHandler: CustomEventHandler<EventType, H>): CustomEventHandler<EventType, H>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-event.js","names":["wrapEvent","theirHandler","ourHandler","event","otherArgs","ret","defaultPrevented"],"sources":["../../../src/utils/wrap-event.ts"],"sourcesContent":["import type { SyntheticEvent } from 'react';\n\nexport type CustomEventHandler<\n E extends SyntheticEvent<any> | Event,\n H extends unknown[]\n> = (e: E, ...args: H) => void;\n\nexport function wrapEvent<\n EventType extends SyntheticEvent<any> | Event,\n H extends unknown[]\n>(\n theirHandler: CustomEventHandler<EventType, H> | undefined,\n ourHandler: CustomEventHandler<EventType, H>\n): CustomEventHandler<EventType, H> {\n return (event: EventType, ...otherArgs: H) => {\n const ret = theirHandler && theirHandler(event, ...otherArgs);\n if (!event || !event.defaultPrevented) {\n return ourHandler(event, ...otherArgs);\n }\n return ret;\n };\n}\n"],"mappings":"AAOA,OAAO,SAASA,SAAT,CAILC,YAJK,EAKLC,UALK,EAM6B;EAClC,OAAO,UAACC,KAAD,EAAuC;IAAA,kCAAjBC,SAAiB;MAAjBA,SAAiB;IAAA;;IAC5C,IAAMC,GAAG,GAAGJ,YAAY,IAAIA,YAAY,MAAZ,UAAaE,KAAb,SAAuBC,SAAvB,EAA5B;;IACA,IAAI,CAACD,KAAD,IAAU,CAACA,KAAK,CAACG,gBAArB,EAAuC;MACrC,OAAOJ,UAAU,MAAV,UAAWC,KAAX,SAAqBC,SAArB,EAAP;IACD;;IACD,OAAOC,GAAP;EACD,CAND;AAOD"}
|
|
1
|
+
{"version":3,"file":"wrap-event.js","names":["wrapEvent","theirHandler","ourHandler","event","otherArgs","ret","defaultPrevented"],"sources":["../../../src/utils/wrap-event.ts"],"sourcesContent":["import type { SyntheticEvent } from 'react';\r\n\r\nexport type CustomEventHandler<\r\n E extends SyntheticEvent<any> | Event,\r\n H extends unknown[]\r\n> = (e: E, ...args: H) => void;\r\n\r\nexport function wrapEvent<\r\n EventType extends SyntheticEvent<any> | Event,\r\n H extends unknown[]\r\n>(\r\n theirHandler: CustomEventHandler<EventType, H> | undefined,\r\n ourHandler: CustomEventHandler<EventType, H>\r\n): CustomEventHandler<EventType, H> {\r\n return (event: EventType, ...otherArgs: H) => {\r\n const ret = theirHandler && theirHandler(event, ...otherArgs);\r\n if (!event || !event.defaultPrevented) {\r\n return ourHandler(event, ...otherArgs);\r\n }\r\n return ret;\r\n };\r\n}\r\n"],"mappings":"AAOA,OAAO,SAASA,SAAT,CAILC,YAJK,EAKLC,UALK,EAM6B;EAClC,OAAO,UAACC,KAAD,EAAuC;IAAA,kCAAjBC,SAAiB;MAAjBA,SAAiB;IAAA;;IAC5C,IAAMC,GAAG,GAAGJ,YAAY,IAAIA,YAAY,MAAZ,UAAaE,KAAb,SAAuBC,SAAvB,EAA5B;;IACA,IAAI,CAACD,KAAD,IAAU,CAACA,KAAK,CAACG,gBAArB,EAAuC;MACrC,OAAOJ,UAAU,MAAV,UAAWC,KAAX,SAAqBC,SAArB,EAAP;IACD;;IACD,OAAOC,GAAP;EACD,CAND;AAOD"}
|