@graphprotocol/gds-react 0.1.2 → 0.2.1
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/dist/GDSContext.d.ts +13 -0
- package/dist/GDSContext.d.ts.map +1 -0
- package/dist/GDSContext.js +4 -0
- package/dist/GDSContext.js.map +1 -0
- package/dist/GDSProvider.d.ts +13 -19
- package/dist/GDSProvider.d.ts.map +1 -1
- package/dist/GDSProvider.js +14 -11
- package/dist/GDSProvider.js.map +1 -1
- package/dist/components/Address.js +2 -2
- package/dist/components/Address.meta.d.ts +1 -13
- package/dist/components/Address.meta.d.ts.map +1 -1
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +3 -11
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Avatar.meta.d.ts +0 -2
- package/dist/components/Avatar.meta.d.ts.map +1 -1
- package/dist/components/AvatarGroup.meta.d.ts +8 -2
- package/dist/components/AvatarGroup.meta.d.ts.map +1 -1
- package/dist/components/Breadcrumbs.meta.d.ts +2 -3
- package/dist/components/Breadcrumbs.meta.d.ts.map +1 -1
- package/dist/components/Breadcrumbs.meta.js +3 -1
- package/dist/components/Breadcrumbs.meta.js.map +1 -1
- package/dist/components/Breadcrumbs.parts.d.ts.map +1 -1
- package/dist/components/Breadcrumbs.parts.js +13 -21
- package/dist/components/Breadcrumbs.parts.js.map +1 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +70 -69
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Button.meta.d.ts +1 -4
- package/dist/components/Button.meta.d.ts.map +1 -1
- package/dist/components/ButtonGroup.d.ts.map +1 -1
- package/dist/components/ButtonGroup.js +1 -5
- package/dist/components/ButtonGroup.js.map +1 -1
- package/dist/components/ButtonGroup.meta.d.ts +1 -5
- package/dist/components/ButtonGroup.meta.d.ts.map +1 -1
- package/dist/components/ButtonGroup.meta.js +8 -0
- package/dist/components/ButtonGroup.meta.js.map +1 -1
- package/dist/components/Card.js +2 -2
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Card.meta.d.ts +1 -2
- package/dist/components/Card.meta.d.ts.map +1 -1
- package/dist/components/Card.meta.js +1 -0
- package/dist/components/Card.meta.js.map +1 -1
- package/dist/components/Checkbox.meta.d.ts +1 -6
- package/dist/components/Checkbox.meta.d.ts.map +1 -1
- package/dist/components/Checkbox.meta.js +1 -5
- package/dist/components/Checkbox.meta.js.map +1 -1
- package/dist/components/Chip.meta.d.ts +2 -4
- package/dist/components/Chip.meta.d.ts.map +1 -1
- package/dist/components/Chip.parts.d.ts.map +1 -1
- package/dist/components/Chip.parts.js +1 -9
- package/dist/components/Chip.parts.js.map +1 -1
- package/dist/components/Cluster.meta.d.ts +8 -2
- package/dist/components/Cluster.meta.d.ts.map +1 -1
- package/dist/components/CodeBlock.d.ts +1 -1
- package/dist/components/CodeBlock.meta.d.ts +2 -4
- package/dist/components/CodeBlock.meta.d.ts.map +1 -1
- package/dist/components/CodeBlock.parts.d.ts +6 -7
- package/dist/components/CodeBlock.parts.d.ts.map +1 -1
- package/dist/components/CodeBlock.parts.js +28 -10
- package/dist/components/CodeBlock.parts.js.map +1 -1
- package/dist/components/CodeInline.js +3 -3
- package/dist/components/CodeInline.meta.d.ts +1 -1
- package/dist/components/CodeInline.meta.d.ts.map +1 -1
- package/dist/components/CopyButton.d.ts +1 -1
- package/dist/components/CopyButton.d.ts.map +1 -1
- package/dist/components/CopyButton.js +46 -21
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/CopyButton.meta.d.ts +1 -12
- package/dist/components/CopyButton.meta.d.ts.map +1 -1
- package/dist/components/CopyButton.meta.js +1 -6
- package/dist/components/CopyButton.meta.js.map +1 -1
- package/dist/components/CurrencyInput.meta.d.ts +1 -6
- package/dist/components/CurrencyInput.meta.d.ts.map +1 -1
- package/dist/components/CurrencyInput.meta.js +1 -5
- package/dist/components/CurrencyInput.meta.js.map +1 -1
- package/dist/components/DescriptionList.meta.d.ts +2 -5
- package/dist/components/DescriptionList.meta.d.ts.map +1 -1
- package/dist/components/DescriptionList.parts.d.ts +3 -0
- package/dist/components/DescriptionList.parts.d.ts.map +1 -1
- package/dist/components/DescriptionList.parts.js +1 -0
- package/dist/components/DescriptionList.parts.js.map +1 -1
- package/dist/components/Divider.meta.d.ts +1 -3
- package/dist/components/Divider.meta.d.ts.map +1 -1
- package/dist/components/Icon.js +4 -4
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/Icon.meta.d.ts +0 -2
- package/dist/components/Icon.meta.d.ts.map +1 -1
- package/dist/components/Icon.meta.js +1 -0
- package/dist/components/Icon.meta.js.map +1 -1
- package/dist/components/Input.d.ts +5 -4
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +3 -2
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Input.meta.d.ts +1 -6
- package/dist/components/Input.meta.d.ts.map +1 -1
- package/dist/components/Input.meta.js +1 -5
- package/dist/components/Input.meta.js.map +1 -1
- package/dist/components/Keyboard.js +1 -1
- package/dist/components/Keyboard.meta.d.ts +0 -1
- package/dist/components/Keyboard.meta.d.ts.map +1 -1
- package/dist/components/Label.meta.d.ts +1 -3
- package/dist/components/Label.meta.d.ts.map +1 -1
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/Link.js +3 -4
- package/dist/components/Link.js.map +1 -1
- package/dist/components/Link.meta.d.ts +1 -2
- package/dist/components/Link.meta.d.ts.map +1 -1
- package/dist/components/Link.meta.js +1 -0
- package/dist/components/Link.meta.js.map +1 -1
- package/dist/components/Menu.meta.d.ts +31 -2
- package/dist/components/Menu.meta.d.ts.map +1 -1
- package/dist/components/Menu.meta.js +39 -1
- package/dist/components/Menu.meta.js.map +1 -1
- package/dist/components/Menu.parts.d.ts +22 -32
- package/dist/components/Menu.parts.d.ts.map +1 -1
- package/dist/components/Menu.parts.js +286 -300
- package/dist/components/Menu.parts.js.map +1 -1
- package/dist/components/Modal.d.ts +1 -1
- package/dist/components/Modal.meta.d.ts +1 -3
- package/dist/components/Modal.meta.d.ts.map +1 -1
- package/dist/components/Modal.meta.js +1 -1
- package/dist/components/Modal.meta.js.map +1 -1
- package/dist/components/Modal.parts.d.ts +14 -15
- package/dist/components/Modal.parts.d.ts.map +1 -1
- package/dist/components/Modal.parts.js +20 -20
- package/dist/components/Modal.parts.js.map +1 -1
- package/dist/components/OTCInput.js +1 -1
- package/dist/components/OTCInput.meta.d.ts +1 -6
- package/dist/components/OTCInput.meta.d.ts.map +1 -1
- package/dist/components/OTCInput.meta.js +1 -5
- package/dist/components/OTCInput.meta.js.map +1 -1
- package/dist/components/Pane.d.ts +9 -0
- package/dist/components/Pane.d.ts.map +1 -0
- package/dist/components/Pane.js +8 -0
- package/dist/components/Pane.js.map +1 -0
- package/dist/components/Pane.meta.d.ts +20 -0
- package/dist/components/Pane.meta.d.ts.map +1 -0
- package/dist/components/Pane.meta.js +30 -0
- package/dist/components/Pane.meta.js.map +1 -0
- package/dist/components/Pane.parts.d.ts +77 -0
- package/dist/components/Pane.parts.d.ts.map +1 -0
- package/dist/components/Pane.parts.js +412 -0
- package/dist/components/Pane.parts.js.map +1 -0
- package/dist/components/Radio.meta.d.ts +1 -6
- package/dist/components/Radio.meta.d.ts.map +1 -1
- package/dist/components/Radio.meta.js +1 -5
- package/dist/components/Radio.meta.js.map +1 -1
- package/dist/components/Search.js +1 -1
- package/dist/components/Search.meta.d.ts +1 -3
- package/dist/components/Search.meta.d.ts.map +1 -1
- package/dist/components/SegmentedControl.meta.d.ts +2 -3
- package/dist/components/SegmentedControl.meta.d.ts.map +1 -1
- package/dist/components/SegmentedControl.meta.js +3 -1
- package/dist/components/SegmentedControl.meta.js.map +1 -1
- package/dist/components/SegmentedControl.parts.d.ts.map +1 -1
- package/dist/components/SegmentedControl.parts.js +4 -9
- package/dist/components/SegmentedControl.parts.js.map +1 -1
- package/dist/components/Status.meta.d.ts +0 -2
- package/dist/components/Status.meta.d.ts.map +1 -1
- package/dist/components/Stepper.meta.d.ts +1 -2
- package/dist/components/Stepper.meta.d.ts.map +1 -1
- package/dist/components/Stepper.meta.js +1 -0
- package/dist/components/Stepper.meta.js.map +1 -1
- package/dist/components/Stepper.parts.d.ts.map +1 -1
- package/dist/components/Stepper.parts.js +1 -1
- package/dist/components/Stepper.parts.js.map +1 -1
- package/dist/components/Switch.meta.d.ts +1 -6
- package/dist/components/Switch.meta.d.ts.map +1 -1
- package/dist/components/Switch.meta.js +1 -5
- package/dist/components/Switch.meta.js.map +1 -1
- package/dist/components/TabSet.meta.d.ts +2 -5
- package/dist/components/TabSet.meta.d.ts.map +1 -1
- package/dist/components/TabSet.meta.js +3 -1
- package/dist/components/TabSet.meta.js.map +1 -1
- package/dist/components/Tag.meta.d.ts +0 -2
- package/dist/components/Tag.meta.d.ts.map +1 -1
- package/dist/components/TextArea.meta.d.ts +1 -6
- package/dist/components/TextArea.meta.d.ts.map +1 -1
- package/dist/components/TextArea.meta.js +1 -5
- package/dist/components/TextArea.meta.js.map +1 -1
- package/dist/components/ToggleButton.js +2 -2
- package/dist/components/ToggleButton.js.map +1 -1
- package/dist/components/ToggleButton.meta.d.ts +1 -12
- package/dist/components/ToggleButton.meta.d.ts.map +1 -1
- package/dist/components/ToggleButton.meta.js +1 -6
- package/dist/components/ToggleButton.meta.js.map +1 -1
- package/dist/components/Tooltip.d.ts +2 -2
- package/dist/components/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip.js +2 -2
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/Tooltip.meta.d.ts +12 -7
- package/dist/components/Tooltip.meta.d.ts.map +1 -1
- package/dist/components/Tooltip.meta.js +13 -2
- package/dist/components/Tooltip.meta.js.map +1 -1
- package/dist/components/Tooltip.parts.d.ts +31 -22
- package/dist/components/Tooltip.parts.d.ts.map +1 -1
- package/dist/components/Tooltip.parts.js +127 -98
- package/dist/components/Tooltip.parts.js.map +1 -1
- package/dist/components/base/Addon.meta.d.ts +1 -1
- package/dist/components/base/Addon.meta.d.ts.map +1 -1
- package/dist/components/base/Addon.meta.js +3 -1
- package/dist/components/base/Addon.meta.js.map +1 -1
- package/dist/components/base/ButtonOrLink.d.ts +2 -2
- package/dist/components/base/ButtonOrLink.d.ts.map +1 -1
- package/dist/components/base/ButtonOrLink.parts.d.ts +14 -6
- package/dist/components/base/ButtonOrLink.parts.d.ts.map +1 -1
- package/dist/components/base/ButtonOrLink.parts.js +54 -65
- package/dist/components/base/ButtonOrLink.parts.js.map +1 -1
- package/dist/components/base/Checkable.meta.d.ts +1 -2
- package/dist/components/base/Checkable.meta.d.ts.map +1 -1
- package/dist/components/base/Checkable.parts.d.ts +6 -6
- package/dist/components/base/Checkable.parts.d.ts.map +1 -1
- package/dist/components/base/Checkable.parts.js +2 -2
- package/dist/components/base/Checkable.parts.js.map +1 -1
- package/dist/components/base/Field.meta.d.ts +1 -2
- package/dist/components/base/Field.meta.d.ts.map +1 -1
- package/dist/components/base/Field.parts.d.ts +5 -4
- package/dist/components/base/Field.parts.d.ts.map +1 -1
- package/dist/components/base/Field.parts.js +1 -1
- package/dist/components/base/Field.parts.js.map +1 -1
- package/dist/components/base/MaybeButtonOrLink.d.ts +20 -3
- package/dist/components/base/MaybeButtonOrLink.d.ts.map +1 -1
- package/dist/components/base/MaybeButtonOrLink.js +5 -3
- package/dist/components/base/MaybeButtonOrLink.js.map +1 -1
- package/dist/components/base/Portal.d.ts +1 -1
- package/dist/components/base/Portal.d.ts.map +1 -1
- package/dist/components/base/Portal.js +3 -6
- package/dist/components/base/Portal.js.map +1 -1
- package/dist/components/base/Presence.d.ts +157 -0
- package/dist/components/base/Presence.d.ts.map +1 -0
- package/dist/components/base/Presence.js +808 -0
- package/dist/components/base/Presence.js.map +1 -0
- package/dist/components/base/Render.d.ts +21 -6
- package/dist/components/base/Render.d.ts.map +1 -1
- package/dist/components/base/Render.js +3 -2
- package/dist/components/base/Render.js.map +1 -1
- package/dist/components/base/Transition.js +2 -2
- package/dist/components/base/Transition.meta.d.ts +1 -1
- package/dist/components/base/Transition.meta.d.ts.map +1 -1
- package/dist/components/base/Transition.meta.js +1 -0
- package/dist/components/base/Transition.meta.js.map +1 -1
- package/dist/components/base/index.d.ts +2 -2
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/base/index.js +2 -2
- package/dist/components/base/index.js.map +1 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -1
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useCSSProp.d.ts.map +1 -1
- package/dist/hooks/useCSSProp.js +7 -7
- package/dist/hooks/useCSSProp.js.map +1 -1
- package/dist/hooks/useCSSProps.d.ts +11 -13
- package/dist/hooks/useCSSProps.d.ts.map +1 -1
- package/dist/hooks/useCSSProps.js +11 -19
- package/dist/hooks/useCSSProps.js.map +1 -1
- package/dist/hooks/useCSSPropsPolyfill.d.ts +1 -1
- package/dist/hooks/useCSSPropsPolyfill.d.ts.map +1 -1
- package/dist/hooks/useCSSPropsPolyfill.js +12 -20
- package/dist/hooks/useCSSPropsPolyfill.js.map +1 -1
- package/dist/hooks/useCSSState.d.ts.map +1 -1
- package/dist/hooks/useCSSState.js +7 -3
- package/dist/hooks/useCSSState.js.map +1 -1
- package/dist/hooks/useControlled.d.ts.map +1 -1
- package/dist/hooks/useControlled.js +6 -4
- package/dist/hooks/useControlled.js.map +1 -1
- package/dist/hooks/useEffectWithRefDeps.d.ts +2 -2
- package/dist/hooks/useEffectWithRefDeps.d.ts.map +1 -1
- package/dist/hooks/useEffectWithRefDeps.js +1 -1
- package/dist/hooks/useEffectWithRefDeps.js.map +1 -1
- package/dist/hooks/useFirstRender.d.ts +14 -0
- package/dist/hooks/useFirstRender.d.ts.map +1 -0
- package/dist/hooks/useFirstRender.js +20 -0
- package/dist/hooks/useFirstRender.js.map +1 -0
- package/dist/hooks/useGDS.d.ts +1 -1
- package/dist/hooks/useGDS.js +1 -1
- package/dist/hooks/useGDS.js.map +1 -1
- package/dist/hooks/usePrevious.d.ts +6 -4
- package/dist/hooks/usePrevious.d.ts.map +1 -1
- package/dist/hooks/usePrevious.js +6 -4
- package/dist/hooks/usePrevious.js.map +1 -1
- package/dist/hooks/useRefWithInit.d.ts +2 -2
- package/dist/hooks/useRefWithInit.d.ts.map +1 -1
- package/dist/hooks/useRefWithInit.js.map +1 -1
- package/dist/hooks/useStyleObserver.d.ts +2 -2
- package/dist/hooks/useStyleObserver.d.ts.map +1 -1
- package/dist/hooks/useStyleObserver.js +1 -1
- package/dist/hooks/useStyleObserver.js.map +1 -1
- package/dist/icons/CalendarDynamicIcon.d.ts +8 -5
- package/dist/icons/CalendarDynamicIcon.d.ts.map +1 -1
- package/dist/icons/CalendarDynamicIcon.js +5 -2
- package/dist/icons/CalendarDynamicIcon.js.map +1 -1
- package/dist/icons/CopyInteractiveIcon.d.ts +5 -4
- package/dist/icons/CopyInteractiveIcon.d.ts.map +1 -1
- package/dist/icons/CopyInteractiveIcon.js +2 -2
- package/dist/icons/CopyInteractiveIcon.js.map +1 -1
- package/dist/icons/SidebarLeftInteractiveIcon.d.ts +4 -3
- package/dist/icons/SidebarLeftInteractiveIcon.d.ts.map +1 -1
- package/dist/icons/SidebarLeftInteractiveIcon.js +2 -2
- package/dist/icons/SidebarLeftInteractiveIcon.js.map +1 -1
- package/dist/icons/SidebarRightInteractiveIcon.d.ts +4 -3
- package/dist/icons/SidebarRightInteractiveIcon.d.ts.map +1 -1
- package/dist/icons/SidebarRightInteractiveIcon.js +2 -2
- package/dist/icons/SidebarRightInteractiveIcon.js.map +1 -1
- package/dist/tailwind-plugin.d.ts.map +1 -1
- package/dist/tailwind-plugin.js +8 -5
- package/dist/tailwind-plugin.js.map +1 -1
- package/dist/utils/InlineCounter.d.ts +3 -0
- package/dist/utils/InlineCounter.d.ts.map +1 -0
- package/dist/utils/InlineCounter.js +7 -0
- package/dist/utils/InlineCounter.js.map +1 -0
- package/dist/utils/RenderCount.d.ts +3 -0
- package/dist/utils/RenderCount.d.ts.map +1 -0
- package/dist/utils/RenderCount.js +7 -0
- package/dist/utils/RenderCount.js.map +1 -0
- package/dist/utils/cn.d.ts +3 -1
- package/dist/utils/cn.d.ts.map +1 -1
- package/dist/utils/cn.js +3 -1
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/getCSSPropsAttributes.d.ts +10 -3
- package/dist/utils/getCSSPropsAttributes.d.ts.map +1 -1
- package/dist/utils/getCSSPropsAttributes.js +4 -5
- package/dist/utils/getCSSPropsAttributes.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/splitProps.d.ts +1 -4
- package/dist/utils/splitProps.d.ts.map +1 -1
- package/dist/utils/splitProps.js +2 -7
- package/dist/utils/splitProps.js.map +1 -1
- package/dist/utils/trimReactNode.d.ts +10 -8
- package/dist/utils/trimReactNode.d.ts.map +1 -1
- package/dist/utils/trimReactNode.js +10 -8
- package/dist/utils/trimReactNode.js.map +1 -1
- package/package.json +21 -21
- package/src/GDSContext.ts +16 -0
- package/src/GDSProvider.tsx +31 -40
- package/src/components/Address.tsx +2 -2
- package/src/components/Avatar.tsx +8 -12
- package/src/components/Breadcrumbs.meta.ts +3 -1
- package/src/components/Breadcrumbs.parts.tsx +16 -28
- package/src/components/Button.tsx +114 -104
- package/src/components/ButtonGroup.meta.ts +8 -0
- package/src/components/ButtonGroup.tsx +1 -5
- package/src/components/Card.meta.ts +1 -0
- package/src/components/Card.tsx +2 -2
- package/src/components/Checkbox.meta.ts +1 -5
- package/src/components/Chip.parts.tsx +1 -11
- package/src/components/CodeBlock.parts.tsx +75 -50
- package/src/components/CodeInline.tsx +3 -3
- package/src/components/CopyButton.meta.ts +1 -6
- package/src/components/CopyButton.tsx +50 -27
- package/src/components/CurrencyInput.meta.ts +1 -5
- package/src/components/DescriptionList.parts.tsx +1 -0
- package/src/components/Icon.meta.ts +1 -0
- package/src/components/Icon.tsx +4 -4
- package/src/components/Input.meta.ts +1 -5
- package/src/components/Input.tsx +6 -7
- package/src/components/Keyboard.tsx +1 -1
- package/src/components/Link.meta.ts +1 -0
- package/src/components/Link.tsx +4 -5
- package/src/components/Menu.meta.ts +39 -1
- package/src/components/Menu.parts.tsx +554 -547
- package/src/components/Modal.meta.ts +1 -1
- package/src/components/Modal.parts.tsx +40 -46
- package/src/components/OTCInput.meta.ts +1 -5
- package/src/components/OTCInput.tsx +1 -1
- package/src/components/Pane.meta.ts +31 -0
- package/src/components/Pane.parts.tsx +713 -0
- package/src/components/Pane.tsx +17 -0
- package/src/components/Radio.meta.ts +1 -5
- package/src/components/Search.tsx +1 -1
- package/src/components/SegmentedControl.meta.ts +3 -1
- package/src/components/SegmentedControl.parts.tsx +7 -10
- package/src/components/Stepper.meta.ts +1 -0
- package/src/components/Stepper.parts.tsx +3 -1
- package/src/components/Switch.meta.ts +1 -5
- package/src/components/TabSet.meta.ts +3 -1
- package/src/components/TextArea.meta.ts +1 -5
- package/src/components/ToggleButton.meta.ts +1 -6
- package/src/components/ToggleButton.tsx +1 -1
- package/src/components/Tooltip.meta.ts +13 -2
- package/src/components/Tooltip.parts.tsx +241 -169
- package/src/components/Tooltip.tsx +2 -2
- package/src/components/base/Addon.meta.ts +3 -1
- package/src/components/base/ButtonOrLink.parts.tsx +118 -97
- package/src/components/base/ButtonOrLink.tsx +1 -0
- package/src/components/base/Checkable.parts.tsx +6 -13
- package/src/components/base/Field.parts.tsx +5 -5
- package/src/components/base/MaybeButtonOrLink.tsx +26 -5
- package/src/components/base/Portal.tsx +5 -7
- package/src/components/base/Presence.tsx +1375 -0
- package/src/components/base/Render.tsx +37 -15
- package/src/components/base/Transition.meta.ts +1 -0
- package/src/components/base/Transition.tsx +2 -2
- package/src/components/base/index.ts +9 -2
- package/src/components/index.ts +11 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useCSSProp.ts +7 -9
- package/src/hooks/useCSSProps.ts +13 -22
- package/src/hooks/useCSSPropsPolyfill.ts +15 -23
- package/src/hooks/useCSSState.ts +11 -6
- package/src/hooks/useControlled.ts +16 -8
- package/src/hooks/useEffectWithRefDeps.ts +2 -2
- package/src/hooks/useFirstRender.ts +36 -0
- package/src/hooks/useGDS.ts +1 -1
- package/src/hooks/usePrevious.ts +6 -4
- package/src/hooks/useRefWithInit.ts +2 -2
- package/src/hooks/useStyleObserver.ts +6 -2
- package/src/icons/CalendarDynamicIcon.tsx +16 -6
- package/src/icons/CopyInteractiveIcon.tsx +10 -5
- package/src/icons/SidebarLeftInteractiveIcon.tsx +9 -5
- package/src/icons/SidebarRightInteractiveIcon.tsx +9 -5
- package/src/tailwind-plugin.ts +8 -5
- package/src/utils/InlineCounter.tsx +17 -0
- package/src/utils/RenderCount.tsx +7 -0
- package/src/utils/cn.ts +3 -1
- package/src/utils/getCSSPropsAttributes.ts +13 -8
- package/src/utils/index.ts +2 -0
- package/src/utils/splitProps.ts +9 -9
- package/src/utils/trimReactNode.tsx +10 -8
- package/dist/components/base/ButtonOrLink.meta.d.ts +0 -2
- package/dist/components/base/ButtonOrLink.meta.d.ts.map +0 -1
- package/dist/components/base/ButtonOrLink.meta.js +0 -6
- package/dist/components/base/ButtonOrLink.meta.js.map +0 -1
- package/src/components/base/ButtonOrLink.meta.ts +0 -6
|
@@ -1,31 +1,53 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import { useRender } from '@base-ui/react/use-render'
|
|
3
|
+
import type { ReactElement } from 'react'
|
|
4
|
+
import { useRender, type HTMLProps } from '@base-ui/react/use-render'
|
|
5
|
+
import { objectFromEntries } from 'ts-extras'
|
|
5
6
|
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export type RenderFnProps = HTMLProps
|
|
8
|
+
export type RenderFnState = Record<string, unknown> | undefined
|
|
9
|
+
|
|
10
|
+
export type RenderFn<State extends RenderFnState = undefined, ElementProps = unknown> = (
|
|
11
|
+
renderProps: RenderFnProps,
|
|
12
|
+
state: State,
|
|
13
|
+
) => ReactElement<ElementProps>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Type for a `render` prop that accepts either a React element or a render function.
|
|
17
|
+
*
|
|
18
|
+
* - **Element form**: Pass a React element to replace the default tag (e.g., `<strong />`).
|
|
19
|
+
* - **Function form**: Pass a callback `(props, state) => ReactElement` for full control.
|
|
20
|
+
*
|
|
21
|
+
* @template State - The state object passed to the render function.
|
|
22
|
+
* @template ElementProps - Optional constraint on the returned element's props (e.g., `{ disabled?:
|
|
23
|
+
* boolean }`).
|
|
24
|
+
*/
|
|
25
|
+
export type RenderProp<State extends RenderFnState = undefined, ElementProps = unknown> =
|
|
26
|
+
| ReactElement<ElementProps>
|
|
27
|
+
| RenderFn<State, ElementProps>
|
|
28
|
+
|
|
29
|
+
export interface RenderProps<State extends RenderFnState = undefined> {
|
|
30
|
+
render: RenderProp<State>
|
|
11
31
|
state?: State | undefined
|
|
32
|
+
[key: string]: unknown
|
|
12
33
|
}
|
|
13
34
|
|
|
14
35
|
/**
|
|
15
36
|
* A utility component that provides polymorphic rendering capabilities. It can render as any HTML
|
|
16
37
|
* element or React component.
|
|
17
38
|
*/
|
|
18
|
-
export function Render<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
export function Render<State extends RenderFnState>({
|
|
40
|
+
render,
|
|
41
|
+
state,
|
|
42
|
+
...props
|
|
43
|
+
}: RenderProps<State>) {
|
|
22
44
|
return useRender({
|
|
23
45
|
render,
|
|
24
|
-
state,
|
|
46
|
+
state: state !== undefined ? state : (undefined as never),
|
|
25
47
|
props,
|
|
26
48
|
// Do not automatically add data attributes for state properties
|
|
27
|
-
stateAttributesMapping:
|
|
28
|
-
Object.keys(state ?? {}).map((stateProperty) => [stateProperty, (
|
|
29
|
-
)
|
|
49
|
+
stateAttributesMapping: objectFromEntries(
|
|
50
|
+
Object.keys(state ?? {}).map((stateProperty) => [stateProperty, () => null] as const),
|
|
51
|
+
),
|
|
30
52
|
})
|
|
31
53
|
}
|
|
@@ -108,7 +108,7 @@ export function Transition({
|
|
|
108
108
|
ref={statePassedRef}
|
|
109
109
|
data-layout={layout}
|
|
110
110
|
className={cn(
|
|
111
|
-
`gds-transition
|
|
111
|
+
`gds-transition
|
|
112
112
|
u:state-[transition=idle]
|
|
113
113
|
u:data-[layout=block]:block
|
|
114
114
|
u:data-[layout=flex-col]:flex
|
|
@@ -130,7 +130,7 @@ export function Transition({
|
|
|
130
130
|
data-layout={layout}
|
|
131
131
|
data-animate-size={animateSize || undefined}
|
|
132
132
|
className={cn(
|
|
133
|
-
`gds-transition
|
|
133
|
+
`gds-transition
|
|
134
134
|
u:state-[transition=idle]
|
|
135
135
|
u:has-[>*>*>[inert]]:state-[transition=running]
|
|
136
136
|
u:has-[>*>*>[inert]]:data-[animate-size=clip]:overflow-clip
|
|
@@ -7,7 +7,6 @@ export {
|
|
|
7
7
|
type ButtonOrLinkProps,
|
|
8
8
|
type ButtonOrLinkState,
|
|
9
9
|
} from './ButtonOrLink.tsx'
|
|
10
|
-
export { ButtonOrLinkMeta } from './ButtonOrLink.meta.ts'
|
|
11
10
|
export {
|
|
12
11
|
Checkable,
|
|
13
12
|
type CheckableLabelProps,
|
|
@@ -19,6 +18,14 @@ export { Field, type FieldProps, type FieldState } from './Field.tsx'
|
|
|
19
18
|
export { FieldMeta } from './Field.meta.ts'
|
|
20
19
|
export { MaybeButtonOrLink, type MaybeButtonOrLinkProps } from './MaybeButtonOrLink.tsx'
|
|
21
20
|
export { Portal } from './Portal.tsx'
|
|
22
|
-
export {
|
|
21
|
+
export { Presence, usePresence, type PresenceProps } from './Presence.tsx'
|
|
22
|
+
export {
|
|
23
|
+
Render,
|
|
24
|
+
type RenderFnProps,
|
|
25
|
+
type RenderFnState,
|
|
26
|
+
type RenderFn,
|
|
27
|
+
type RenderProp,
|
|
28
|
+
type RenderProps,
|
|
29
|
+
} from './Render.tsx'
|
|
23
30
|
export { Transition, type TransitionProps } from './Transition.tsx'
|
|
24
31
|
export { TransitionMeta } from './Transition.meta.ts'
|
package/src/components/index.ts
CHANGED
|
@@ -63,6 +63,16 @@ export {
|
|
|
63
63
|
export { ModalMeta } from './Modal.meta.ts'
|
|
64
64
|
export { OTCInput, type OTCInputProps } from './OTCInput.tsx'
|
|
65
65
|
export { OTCInputMeta } from './OTCInput.meta.ts'
|
|
66
|
+
export {
|
|
67
|
+
Pane,
|
|
68
|
+
usePane,
|
|
69
|
+
type PaneContainerProps,
|
|
70
|
+
type PaneProps,
|
|
71
|
+
type PaneProviderProps,
|
|
72
|
+
type PaneToggleButtonProps,
|
|
73
|
+
type UsePaneOptions,
|
|
74
|
+
} from './Pane.tsx'
|
|
75
|
+
export { PaneContainerMeta, PaneMeta } from './Pane.meta.ts'
|
|
66
76
|
export { Radio, type RadioAreaProps, type RadioGroupProps, type RadioProps } from './Radio.tsx'
|
|
67
77
|
export { RadioMeta } from './Radio.meta.ts'
|
|
68
78
|
export { Search, type SearchProps } from './Search.tsx'
|
|
@@ -97,8 +107,7 @@ export { ToggleButton, type ToggleButtonProps } from './ToggleButton.tsx'
|
|
|
97
107
|
export { ToggleButtonMeta } from './ToggleButton.meta.ts'
|
|
98
108
|
export {
|
|
99
109
|
Tooltip,
|
|
100
|
-
|
|
101
|
-
useCollectedTooltip,
|
|
110
|
+
useTooltipCollector,
|
|
102
111
|
type TooltipProps,
|
|
103
112
|
type TooltipCollectorProps,
|
|
104
113
|
type TooltipContentProps,
|
package/src/hooks/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { useCSSProps } from './useCSSProps.ts'
|
|
|
12
12
|
export { useCSSPropsPolyfill } from './useCSSPropsPolyfill.ts'
|
|
13
13
|
export { useCSSState } from './useCSSState.ts'
|
|
14
14
|
export { useEffectWithRefDeps } from './useEffectWithRefDeps.ts'
|
|
15
|
+
export { useFirstRender } from './useFirstRender.ts'
|
|
15
16
|
export { useForceRerender } from './useForceRerender.ts'
|
|
16
17
|
export { useMapWithInit } from './useMapWithInit.ts'
|
|
17
18
|
export {
|
package/src/hooks/useCSSProp.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type GDSComponent,
|
|
9
9
|
} from '@graphprotocol/gds-css'
|
|
10
10
|
|
|
11
|
-
import { styleScheduler } from '../utils/
|
|
11
|
+
import { styleScheduler } from '../utils/index.ts'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Returns a `ref` to set on an element, and an async function to get the current value of a CSS
|
|
@@ -21,17 +21,15 @@ export function useCSSProp<
|
|
|
21
21
|
const { ref: passedRef } = options
|
|
22
22
|
const elementRef = useRef<HTMLElement>(null)
|
|
23
23
|
const callbackRef: RefCallback<HTMLElement> | null = useMergedRefs(elementRef, passedRef)
|
|
24
|
-
const
|
|
24
|
+
const cssProp = component.getCSSPropByName(propName)
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const getCSSPropValue = useCallback(async () => {
|
|
27
27
|
if (typeof window === 'undefined' || !elementRef.current) return null
|
|
28
28
|
const element = elementRef.current
|
|
29
29
|
const computedStyle = await styleScheduler.getComputedStyle(element)
|
|
30
|
-
const rawValue = computedStyle.getPropertyValue(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return parseCSSPropValue(prop, rawValue) as CSSPropType<ComponentCSSPropsConfig<C>[P]>
|
|
34
|
-
}, [component, prop])
|
|
30
|
+
const rawValue = computedStyle.getPropertyValue(cssProp.cssProperty)
|
|
31
|
+
return parseCSSPropValue(cssProp, rawValue) as CSSPropType<ComponentCSSPropsConfig<C>[P]>
|
|
32
|
+
}, [cssProp])
|
|
35
33
|
|
|
36
|
-
return [callbackRef,
|
|
34
|
+
return [callbackRef, getCSSPropValue] as const
|
|
37
35
|
}
|
package/src/hooks/useCSSProps.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { objectKeys } from 'ts-extras'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
parseCSSPropValue,
|
|
@@ -22,48 +22,39 @@ export type PropValues<P extends PassedValues<GDSComponent>> = {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Hook to observe and track CSS prop values from the DOM. Returns a callback ref, a map of prop
|
|
25
|
-
* values that updates when CSS properties change, and
|
|
25
|
+
* values that updates when CSS properties change, and the array of CSS props.
|
|
26
26
|
*/
|
|
27
27
|
export function useCSSProps<C extends GDSComponent, P extends PassedValues<C>>(
|
|
28
28
|
component: C,
|
|
29
29
|
passedValues: P,
|
|
30
30
|
options: {
|
|
31
31
|
ref?: Ref<HTMLElement> | undefined
|
|
32
|
-
disabled?: boolean
|
|
32
|
+
disabled?: boolean | undefined
|
|
33
33
|
} = {},
|
|
34
34
|
) {
|
|
35
35
|
const { ref, disabled = false } = options
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const cssProp = component.getCSSPropByName(propName)
|
|
40
|
-
return {
|
|
41
|
-
name: propName,
|
|
42
|
-
passedValue,
|
|
43
|
-
cssProp,
|
|
44
|
-
cssProperty: `--gds-${component.kebabName}-${cssProp.kebabName}`,
|
|
45
|
-
polyfillAttribute: `data-gds-prop-polyfill-${cssProp.kebabName}`,
|
|
46
|
-
}
|
|
47
|
-
}),
|
|
37
|
+
const cssProps = useRefWithInit(() =>
|
|
38
|
+
objectKeys(passedValues).map((propName) => component.getCSSPropByName(propName)),
|
|
48
39
|
).current
|
|
49
40
|
|
|
50
41
|
const propValues = useMapWithInit(() =>
|
|
51
|
-
|
|
42
|
+
cssProps.map((cssProp) => {
|
|
52
43
|
// Using the initial value for missing passed values could be wrong because it can be overridden in CSS, but it's just for the first render
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
return [
|
|
44
|
+
const passedValue = passedValues[cssProp.name]
|
|
45
|
+
const initialValue = passedValue !== undefined ? passedValue : cssProp.initialValue
|
|
46
|
+
return [cssProp.name, initialValue]
|
|
56
47
|
}),
|
|
57
48
|
)
|
|
58
49
|
|
|
59
|
-
const cssProperties = useRefWithInit(() =>
|
|
50
|
+
const cssProperties = useRefWithInit(() => cssProps.map((cssProp) => cssProp.cssProperty)).current
|
|
60
51
|
|
|
61
52
|
const callbackRef = useStyleObserver(
|
|
62
53
|
cssProperties,
|
|
63
54
|
(records) => {
|
|
64
55
|
for (const record of records) {
|
|
65
|
-
const prop =
|
|
66
|
-
const value = parseCSSPropValue(prop
|
|
56
|
+
const prop = cssProps.find((prop) => prop.cssProperty === record.property)!
|
|
57
|
+
const value = parseCSSPropValue(prop, record.value)
|
|
67
58
|
if (propValues.get(prop.name) !== value) {
|
|
68
59
|
propValues.set(prop.name, value)
|
|
69
60
|
}
|
|
@@ -73,5 +64,5 @@ export function useCSSProps<C extends GDSComponent, P extends PassedValues<C>>(
|
|
|
73
64
|
{ ...(ref !== undefined && { ref }), immediate: true, disabled },
|
|
74
65
|
)
|
|
75
66
|
|
|
76
|
-
return [callbackRef, Object.fromEntries(propValues) as PropValues<P>,
|
|
67
|
+
return [callbackRef, Object.fromEntries(propValues) as PropValues<P>, cssProps] as const
|
|
77
68
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Ref, RefCallback } from 'react'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
getCSSPropRawValue,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@graphprotocol/gds-css'
|
|
10
10
|
|
|
11
11
|
import { useCSSProps, type PassedValues, type PropValues } from './useCSSProps.ts'
|
|
12
|
-
import {
|
|
12
|
+
import { useFirstRender } from './useFirstRender.ts'
|
|
13
13
|
|
|
14
14
|
type ExtractPolyfillValues<P extends CSSPropsConfig> = {
|
|
15
15
|
[K in keyof P as P[K]['type'] extends 'values' ? K : never]: CSSPropType<P[K]> | undefined
|
|
@@ -68,19 +68,21 @@ export function useCSSPropsPolyfill<
|
|
|
68
68
|
const allPassedValues = (() => {
|
|
69
69
|
if (!returnPropValues) return passedValues
|
|
70
70
|
if (returnPropValues === true) return passedValues
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const passed = passedValues as Record<string, unknown>
|
|
72
|
+
const merged = { ...passed }
|
|
73
|
+
for (const key of Object.keys(returnPropValues)) {
|
|
74
|
+
const value = returnPropValues[key]
|
|
75
|
+
if (key in passedValues && passed[key] !== value) {
|
|
74
76
|
throw new Error(
|
|
75
|
-
`[useCSSPropsPolyfill] Conflicting values for prop \`${key}\`: ${
|
|
77
|
+
`[useCSSPropsPolyfill] Conflicting values for prop \`${key}\`: ${String(passed[key])} vs ${value}`,
|
|
76
78
|
)
|
|
77
79
|
}
|
|
78
|
-
merged[key
|
|
80
|
+
merged[key] = value
|
|
79
81
|
}
|
|
80
|
-
return merged
|
|
82
|
+
return merged as typeof passedValues
|
|
81
83
|
})()
|
|
82
84
|
|
|
83
|
-
const [callbackRef, propValues,
|
|
85
|
+
const [callbackRef, propValues, cssProps] = useCSSProps(component, allPassedValues, {
|
|
84
86
|
ref,
|
|
85
87
|
disabled: !polyfillEnabled && !returnPropValues,
|
|
86
88
|
})
|
|
@@ -92,30 +94,20 @@ export function useCSSPropsPolyfill<
|
|
|
92
94
|
* to immediately rerender in browsers that support style queries); unfortunately, that would
|
|
93
95
|
* cause a flash of missing styles in browsers that need the polyfill.
|
|
94
96
|
*/
|
|
95
|
-
const firstRender =
|
|
97
|
+
const firstRender = useFirstRender({ immediatelyRerender: !polyfillEnabled })
|
|
96
98
|
const polyfillAttributes =
|
|
97
|
-
polyfillEnabled || firstRender
|
|
99
|
+
polyfillEnabled || firstRender
|
|
98
100
|
? Object.fromEntries(
|
|
99
|
-
|
|
101
|
+
cssProps
|
|
100
102
|
.filter((prop) => prop.name in passedValues)
|
|
101
103
|
.map((prop) => {
|
|
102
104
|
const value = propValues[prop.name as keyof typeof propValues]
|
|
103
|
-
const rawValue = getCSSPropRawValue(prop
|
|
105
|
+
const rawValue = getCSSPropRawValue(prop, value)
|
|
104
106
|
return [prop.polyfillAttribute, rawValue]
|
|
105
107
|
}),
|
|
106
108
|
)
|
|
107
109
|
: {}
|
|
108
110
|
|
|
109
|
-
// If the polyfill is not needed, rerender to remove the polyfill attributes
|
|
110
|
-
const [rerender] = useForceRerender()
|
|
111
|
-
useLayoutEffect(() => {
|
|
112
|
-
firstRender.current = false
|
|
113
|
-
if (!polyfillEnabled) {
|
|
114
|
-
rerender()
|
|
115
|
-
}
|
|
116
|
-
// oxlint-disable-next-line exhaustive-deps
|
|
117
|
-
}, [])
|
|
118
|
-
|
|
119
111
|
if (!returnPropValues) {
|
|
120
112
|
return [callbackRef, polyfillAttributes] as const
|
|
121
113
|
}
|
package/src/hooks/useCSSState.ts
CHANGED
|
@@ -56,15 +56,17 @@ export function useCSSState<
|
|
|
56
56
|
|
|
57
57
|
const variables = useRefWithInit(() =>
|
|
58
58
|
Object.keys(variableInitialValues).map((variableName) => {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const isArbitrary = !(variableName in cssStateVariables)
|
|
60
|
+
const defaultValue = !isArbitrary
|
|
61
|
+
? cssStateVariables[variableName as CSSStateVariableName].defaultValue
|
|
62
|
+
: undefined
|
|
63
63
|
return {
|
|
64
64
|
name: variableName,
|
|
65
65
|
defaultValue,
|
|
66
66
|
initialValue: variableInitialValues[variableName as keyof T] ?? defaultValue,
|
|
67
|
-
observedProperty:
|
|
67
|
+
observedProperty: isArbitrary
|
|
68
|
+
? `--gds-state-${variableName}`
|
|
69
|
+
: `--gds-observed-${variableName}`,
|
|
68
70
|
exposedProperty: `--gds-exposed-${variableName}`,
|
|
69
71
|
exposedAttribute: `data-gds-exposed-${variableName}`,
|
|
70
72
|
polyfillAttribute: `data-gds-state-polyfill-${variableName}`,
|
|
@@ -105,7 +107,10 @@ export function useCSSState<
|
|
|
105
107
|
for (const record of records) {
|
|
106
108
|
if (propertyValues.get(record.property) !== record.value) {
|
|
107
109
|
propertyValues.set(record.property, record.value)
|
|
108
|
-
if (
|
|
110
|
+
if (
|
|
111
|
+
record.property.startsWith('--gds-state-') ||
|
|
112
|
+
record.property.startsWith('--gds-observed-')
|
|
113
|
+
) {
|
|
109
114
|
statePropertiesChanged = true
|
|
110
115
|
}
|
|
111
116
|
}
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
1
|
+
import { useCallback, useRef, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
export function useControlled<T, OnChangeValue extends T = T, OnChangeArgs extends unknown[] = []>(
|
|
4
4
|
controlledValue: T | undefined,
|
|
5
5
|
defaultValue: T,
|
|
6
6
|
onChange?: (value: OnChangeValue, ...args: OnChangeArgs) => void,
|
|
7
7
|
) {
|
|
8
|
+
const onChangeRef = useRef(onChange)
|
|
9
|
+
onChangeRef.current = onChange
|
|
10
|
+
|
|
8
11
|
const [uncontrolledValue, setUncontrolledValue] = useState(
|
|
9
12
|
controlledValue !== undefined ? controlledValue : defaultValue,
|
|
10
13
|
)
|
|
14
|
+
|
|
11
15
|
const value = controlledValue !== undefined ? controlledValue : uncontrolledValue
|
|
12
|
-
const setValue = (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const setValue = useCallback(
|
|
17
|
+
(newValue: OnChangeValue, ...args: OnChangeArgs) => {
|
|
18
|
+
if (newValue === value) return
|
|
19
|
+
onChangeRef.current?.(newValue, ...args)
|
|
20
|
+
if (controlledValue === undefined) {
|
|
21
|
+
setUncontrolledValue(newValue)
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
[controlledValue, value],
|
|
25
|
+
)
|
|
26
|
+
|
|
19
27
|
return [value, setValue] as const
|
|
20
28
|
}
|
|
@@ -20,7 +20,7 @@ export function useEffectWithRefDeps<T, RefDeps extends readonly Ref<T>[]>(
|
|
|
20
20
|
effect: EffectCallback,
|
|
21
21
|
regularDeps: unknown[],
|
|
22
22
|
refDeps: [...RefDeps],
|
|
23
|
-
options: { deepCompare?: boolean; hook?: EffectHook } = {},
|
|
23
|
+
options: { deepCompare?: boolean | undefined; hook?: EffectHook | undefined } = {},
|
|
24
24
|
) {
|
|
25
25
|
const { deepCompare = false, hook = useEffect } = options
|
|
26
26
|
|
|
@@ -53,7 +53,7 @@ export function useEffectWithRefDeps<T, RefDeps extends readonly Ref<T>[]>(
|
|
|
53
53
|
|
|
54
54
|
const runEffectNextTick = useCallback(() => {
|
|
55
55
|
const token = ++runEffectToken.current
|
|
56
|
-
queueMicrotask(() => {
|
|
56
|
+
window.queueMicrotask(() => {
|
|
57
57
|
if (runEffectToken.current === token) {
|
|
58
58
|
runEffect()
|
|
59
59
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { useForceRerender } from './useForceRerender.ts'
|
|
4
|
+
|
|
5
|
+
interface UseFirstRenderOptions {
|
|
6
|
+
/** Callback to run on first render. */
|
|
7
|
+
callback?: () => void
|
|
8
|
+
/**
|
|
9
|
+
* If true, immediately triggers a re-render after the first render.
|
|
10
|
+
*
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
immediatelyRerender?: boolean | undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useFirstRender(callback?: () => void): boolean
|
|
17
|
+
export function useFirstRender(options: UseFirstRenderOptions): boolean
|
|
18
|
+
export function useFirstRender(callbackOrOptions?: (() => void) | UseFirstRenderOptions) {
|
|
19
|
+
const options = typeof callbackOrOptions === 'function' ? undefined : callbackOrOptions
|
|
20
|
+
const callback = typeof callbackOrOptions === 'function' ? callbackOrOptions : options?.callback
|
|
21
|
+
|
|
22
|
+
const firstRender = useRef(true)
|
|
23
|
+
const [rerender] = useForceRerender()
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!firstRender.current) return
|
|
27
|
+
firstRender.current = false
|
|
28
|
+
callback?.()
|
|
29
|
+
if (options?.immediatelyRerender) {
|
|
30
|
+
rerender()
|
|
31
|
+
}
|
|
32
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [])
|
|
34
|
+
|
|
35
|
+
return firstRender.current
|
|
36
|
+
}
|
package/src/hooks/useGDS.ts
CHANGED
package/src/hooks/usePrevious.ts
CHANGED
|
@@ -12,10 +12,12 @@ const NOT_SET = Symbol('NOT_SET')
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const previous = usePrevious(someValue)
|
|
17
|
+
* if (previous.hasChanged) {
|
|
18
|
+
* // Value changed from `previous.value` to `someValue`
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
19
21
|
*/
|
|
20
22
|
export function usePrevious<T>(value: T) {
|
|
21
23
|
const previousRenderValueRef = useRef<T | typeof NOT_SET>(NOT_SET)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef, type
|
|
1
|
+
import { useRef, type RefObject } from 'react'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Works like `useRef` but accepts an initializer function that runs once on the first render, like
|
|
@@ -11,5 +11,5 @@ export function useRefWithInit<T>(initFn: () => T) {
|
|
|
11
11
|
ref.current = initFn()
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
return ref as
|
|
14
|
+
return ref as RefObject<T>
|
|
15
15
|
}
|
|
@@ -2,7 +2,7 @@ import { useCallback, useLayoutEffect, useRef, type Ref } from 'react'
|
|
|
2
2
|
import { useMergedRefs } from '@base-ui/utils/useMergedRefs'
|
|
3
3
|
import StyleObserver from 'style-observer'
|
|
4
4
|
|
|
5
|
-
import { styleScheduler } from '../utils/
|
|
5
|
+
import { styleScheduler } from '../utils/index.ts'
|
|
6
6
|
import { useEffectWithRefDeps } from './useEffectWithRefDeps.ts'
|
|
7
7
|
|
|
8
8
|
type Record<T extends string> = Parameters<ConstructorParameters<typeof StyleObserver>[0]>[0][0] & {
|
|
@@ -17,7 +17,11 @@ export function useStyleObserver<T extends string>(
|
|
|
17
17
|
properties: T[],
|
|
18
18
|
onChange: (records: Record<T>[]) => void,
|
|
19
19
|
deps: unknown[],
|
|
20
|
-
options: {
|
|
20
|
+
options: {
|
|
21
|
+
ref?: Ref<HTMLElement> | undefined
|
|
22
|
+
immediate?: boolean | undefined
|
|
23
|
+
disabled?: boolean | undefined
|
|
24
|
+
} = {},
|
|
21
25
|
) {
|
|
22
26
|
const { ref: passedRef, immediate = false, disabled = false } = options
|
|
23
27
|
const elementRef = useRef<HTMLElement>(null)
|
|
@@ -2,17 +2,21 @@ import { useId } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { Icon, type IconProps } from '../components/Icon.tsx'
|
|
4
4
|
|
|
5
|
-
export interface CalendarDynamicIconProps extends IconProps {
|
|
5
|
+
export interface CalendarDynamicIconProps extends Omit<IconProps, 'alt'> {
|
|
6
|
+
/** Defaults to a formatted version of `date`. */
|
|
7
|
+
alt?: string
|
|
6
8
|
/**
|
|
7
|
-
* Day of the month.
|
|
9
|
+
* Day of the month, or a full date. If the latter, the icon will only display the day part, but
|
|
10
|
+
* the default `alt` will be the full formatted date.
|
|
8
11
|
*
|
|
9
|
-
* @default new Date()
|
|
12
|
+
* @default new Date()
|
|
10
13
|
*/
|
|
11
|
-
date?: number
|
|
14
|
+
date?: number | Date
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
export function CalendarDynamicIcon({
|
|
15
|
-
|
|
18
|
+
alt,
|
|
19
|
+
date = new Date(),
|
|
16
20
|
...props
|
|
17
21
|
}: CalendarDynamicIconProps) {
|
|
18
22
|
const uniqueId = useId()
|
|
@@ -37,13 +41,19 @@ export function CalendarDynamicIcon({
|
|
|
37
41
|
fontSize="7px"
|
|
38
42
|
fontWeight="bold"
|
|
39
43
|
>
|
|
40
|
-
{date}
|
|
44
|
+
{typeof date === 'number' ? date : date.getDate()}
|
|
41
45
|
</text>
|
|
42
46
|
</mask>
|
|
43
47
|
</defs>
|
|
44
48
|
<use href={`#${uniqueId}-calendar-path`} mask={`url(#${uniqueId}-text-mask)`} />
|
|
45
49
|
</svg>
|
|
46
50
|
}
|
|
51
|
+
alt={
|
|
52
|
+
alt ??
|
|
53
|
+
(typeof date === 'number'
|
|
54
|
+
? `Day ${date} of the month`
|
|
55
|
+
: date.toLocaleDateString(undefined, { dateStyle: 'long' }))
|
|
56
|
+
}
|
|
47
57
|
data-name="CalendarDynamic"
|
|
48
58
|
{...props}
|
|
49
59
|
/>
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { useId } from 'react'
|
|
2
|
-
import type { SetOptional } from 'type-fest'
|
|
3
2
|
|
|
4
3
|
import { Icon, type IconProps } from '../components/Icon.tsx'
|
|
5
4
|
|
|
6
|
-
export interface CopyInteractiveIconProps extends
|
|
5
|
+
export interface CopyInteractiveIconProps extends Omit<IconProps, 'alt'> {
|
|
6
|
+
/** @default 'Copy' */
|
|
7
|
+
alt?: IconProps['alt']
|
|
7
8
|
/** @default false */
|
|
8
|
-
copied?: boolean
|
|
9
|
+
copied?: boolean | undefined
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export function CopyInteractiveIcon({
|
|
12
|
+
export function CopyInteractiveIcon({
|
|
13
|
+
alt = 'Copy',
|
|
14
|
+
copied = false,
|
|
15
|
+
...props
|
|
16
|
+
}: CopyInteractiveIconProps) {
|
|
12
17
|
const uniqueId = useId()
|
|
13
18
|
|
|
14
19
|
return (
|
|
@@ -85,7 +90,7 @@ export function CopyInteractiveIcon({ copied = false, ...props }: CopyInteractiv
|
|
|
85
90
|
</g>
|
|
86
91
|
</svg>
|
|
87
92
|
}
|
|
88
|
-
alt=
|
|
93
|
+
alt={alt}
|
|
89
94
|
data-name="CopyAnimated"
|
|
90
95
|
{...props}
|
|
91
96
|
/>
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type { SetOptional } from 'type-fest'
|
|
2
|
-
|
|
3
1
|
import { Icon, type IconProps } from '../components/Icon.tsx'
|
|
4
2
|
|
|
5
|
-
export interface SidebarLeftInteractiveIconProps extends
|
|
3
|
+
export interface SidebarLeftInteractiveIconProps extends Omit<IconProps, 'alt'> {
|
|
4
|
+
/** @default 'Toggle sidebar' */
|
|
5
|
+
alt?: IconProps['alt']
|
|
6
|
+
}
|
|
6
7
|
|
|
7
|
-
export function SidebarLeftInteractiveIcon(
|
|
8
|
+
export function SidebarLeftInteractiveIcon({
|
|
9
|
+
alt = 'Toggle sidebar',
|
|
10
|
+
...props
|
|
11
|
+
}: SidebarLeftInteractiveIconProps) {
|
|
8
12
|
return (
|
|
9
13
|
<Icon
|
|
10
14
|
src={
|
|
@@ -19,7 +23,7 @@ export function SidebarLeftInteractiveIcon(props: SidebarLeftInteractiveIconProp
|
|
|
19
23
|
/>
|
|
20
24
|
</svg>
|
|
21
25
|
}
|
|
22
|
-
alt=
|
|
26
|
+
alt={alt}
|
|
23
27
|
data-name="SidebarLeftInteractive"
|
|
24
28
|
{...props}
|
|
25
29
|
/>
|