@graphprotocol/gds-react 0.1.1 → 0.2.0
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/GDSProvider.d.ts +12 -10
- package/dist/GDSProvider.d.ts.map +1 -1
- package/dist/GDSProvider.js +10 -8
- 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 +7 -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 +15 -23
- package/dist/components/Breadcrumbs.parts.js.map +1 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +17 -12
- 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 +1 -1
- 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.d.ts +6 -0
- package/dist/components/Chip.d.ts.map +1 -0
- package/dist/components/Chip.js +5 -0
- package/dist/components/Chip.js.map +1 -0
- package/dist/components/Chip.meta.d.ts +15 -0
- package/dist/components/Chip.meta.d.ts.map +1 -0
- package/dist/components/Chip.meta.js +22 -0
- package/dist/components/Chip.meta.js.map +1 -0
- package/dist/components/Chip.parts.d.ts +52 -0
- package/dist/components/Chip.parts.d.ts.map +1 -0
- package/dist/components/Chip.parts.js +114 -0
- package/dist/components/Chip.parts.js.map +1 -0
- 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.map +1 -1
- package/dist/components/CopyButton.js +2 -4
- 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 +2 -1
- 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 +1 -0
- 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 +1 -2
- 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 +23 -32
- package/dist/components/Menu.parts.d.ts.map +1 -1
- package/dist/components/Menu.parts.js +284 -303
- 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 +36 -32
- 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/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.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 +15 -31
- 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/TabSet.parts.js +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.d.ts +0 -2
- package/dist/components/ToggleButton.d.ts.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 +20 -20
- package/dist/components/Tooltip.parts.d.ts.map +1 -1
- package/dist/components/Tooltip.parts.js +129 -88
- 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 +1 -1
- package/dist/components/base/ButtonOrLink.parts.d.ts +14 -10
- package/dist/components/base/ButtonOrLink.parts.d.ts.map +1 -1
- package/dist/components/base/ButtonOrLink.parts.js +47 -47
- 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 +1 -1
- package/dist/components/base/MaybeButtonOrLink.d.ts.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/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 +1 -2
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/base/index.js +1 -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 +6 -6
- 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/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/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.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/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/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 +17 -17
- package/src/GDSProvider.tsx +11 -9
- package/src/components/Address.tsx +2 -2
- package/src/components/Avatar.tsx +10 -11
- package/src/components/Breadcrumbs.meta.ts +3 -1
- package/src/components/Breadcrumbs.parts.tsx +18 -30
- package/src/components/Button.tsx +27 -13
- 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 +1 -1
- package/src/components/Checkbox.meta.ts +1 -5
- package/src/components/Chip.meta.ts +23 -0
- package/src/components/Chip.parts.tsx +319 -0
- package/src/components/Chip.tsx +7 -0
- 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 +3 -4
- package/src/components/CurrencyInput.meta.ts +1 -5
- package/src/components/DescriptionList.parts.tsx +2 -1
- 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 +5 -6
- package/src/components/Keyboard.tsx +1 -1
- package/src/components/Link.meta.ts +1 -0
- package/src/components/Link.tsx +2 -3
- package/src/components/Menu.meta.ts +39 -1
- package/src/components/Menu.parts.tsx +553 -549
- package/src/components/Modal.meta.ts +1 -1
- package/src/components/Modal.parts.tsx +67 -68
- package/src/components/OTCInput.meta.ts +1 -5
- package/src/components/OTCInput.tsx +1 -1
- package/src/components/Radio.meta.ts +1 -5
- package/src/components/SegmentedControl.meta.ts +3 -1
- package/src/components/SegmentedControl.parts.tsx +40 -44
- 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/TabSet.parts.tsx +1 -1
- package/src/components/TextArea.meta.ts +1 -5
- package/src/components/ToggleButton.meta.ts +1 -6
- package/src/components/ToggleButton.tsx +1 -3
- package/src/components/Tooltip.meta.ts +13 -2
- package/src/components/Tooltip.parts.tsx +215 -159
- package/src/components/Tooltip.tsx +2 -2
- package/src/components/base/Addon.meta.ts +3 -1
- package/src/components/base/ButtonOrLink.parts.tsx +91 -73
- package/src/components/base/Checkable.parts.tsx +6 -13
- package/src/components/base/Field.parts.tsx +5 -5
- package/src/components/base/Portal.tsx +5 -7
- 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 +8 -2
- package/src/components/index.ts +3 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useCSSProp.ts +6 -8
- package/src/hooks/useCSSProps.ts +13 -22
- package/src/hooks/useCSSPropsPolyfill.ts +15 -23
- package/src/hooks/useCSSState.ts +11 -6
- package/src/hooks/useEffectWithRefDeps.ts +2 -2
- package/src/hooks/useFirstRender.ts +36 -0
- package/src/hooks/usePrevious.ts +6 -4
- package/src/hooks/useRefWithInit.ts +2 -2
- package/src/hooks/useStyleObserver.ts +5 -1
- 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/cn.ts +3 -1
- package/src/utils/getCSSPropsAttributes.ts +13 -8
- 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
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, type ComponentProps, type ReactNode } from 'react'
|
|
4
|
+
import { Checkbox } from '@base-ui/react/checkbox'
|
|
5
|
+
import { CheckboxGroup } from '@base-ui/react/checkbox-group'
|
|
6
|
+
import { Radio } from '@base-ui/react/radio'
|
|
7
|
+
import { RadioGroup } from '@base-ui/react/radio-group'
|
|
8
|
+
|
|
9
|
+
import type { GDSComponentProps } from '@graphprotocol/gds-css'
|
|
10
|
+
|
|
11
|
+
import { useAutoValue, useCSSPropsPolyfill, useCSSState, useGDS } from '../hooks/index.ts'
|
|
12
|
+
import { cn, getCSSPropsAttributes, splitProps } from '../utils/index.ts'
|
|
13
|
+
import { renderAddon, type AddonValue } from './base/Addon.tsx'
|
|
14
|
+
import { ButtonOrLink, type ButtonOrLinkProps } from './base/ButtonOrLink.tsx'
|
|
15
|
+
import { ChipGroupMeta, ChipMeta } from './Chip.meta.ts'
|
|
16
|
+
|
|
17
|
+
type ExtractFn<T> = T extends (...args: infer A) => infer R ? (...args: A) => R : never
|
|
18
|
+
|
|
19
|
+
export declare namespace ChipProps {
|
|
20
|
+
interface BaseProps extends GDSComponentProps<typeof ChipMeta> {
|
|
21
|
+
/** Name used to submit the chip's value when inside a `<Chip.Group type="checkbox">` in a form. */
|
|
22
|
+
name?: string | undefined
|
|
23
|
+
/** Value used to identify this chip when inside a `<Chip.Group>`. */
|
|
24
|
+
value?: string | undefined
|
|
25
|
+
addonBefore?: AddonValue | undefined
|
|
26
|
+
addonAfter?: AddonValue | undefined
|
|
27
|
+
count?: ReactNode | undefined
|
|
28
|
+
}
|
|
29
|
+
interface ButtonProps
|
|
30
|
+
extends
|
|
31
|
+
BaseProps,
|
|
32
|
+
Omit<ButtonOrLinkProps.ButtonProps, 'value'>,
|
|
33
|
+
ButtonOrLinkProps.DisableableProps {}
|
|
34
|
+
interface LinkProps
|
|
35
|
+
extends BaseProps, ButtonOrLinkProps.LinkProps, ButtonOrLinkProps.DisableableProps {}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type ChipProps = ChipProps.ButtonProps | ChipProps.LinkProps
|
|
39
|
+
|
|
40
|
+
interface ChipGroupContextValue {
|
|
41
|
+
type: 'checkbox' | 'radio'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const ChipGroupContext = createContext<ChipGroupContextValue | null>(null)
|
|
45
|
+
|
|
46
|
+
export function ChipRoot({
|
|
47
|
+
size,
|
|
48
|
+
name,
|
|
49
|
+
value: passedValue,
|
|
50
|
+
addonBefore,
|
|
51
|
+
addonAfter,
|
|
52
|
+
count,
|
|
53
|
+
disabled = false,
|
|
54
|
+
className,
|
|
55
|
+
style,
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
}: ChipProps) {
|
|
59
|
+
useGDS()
|
|
60
|
+
|
|
61
|
+
const { rootProps, nestedProps } = splitProps(props)
|
|
62
|
+
|
|
63
|
+
const autoValue = useAutoValue(children)
|
|
64
|
+
const value = passedValue !== undefined ? passedValue : autoValue
|
|
65
|
+
|
|
66
|
+
const groupContext = useContext(ChipGroupContext)
|
|
67
|
+
|
|
68
|
+
const [stateRef, state] = useCSSState({
|
|
69
|
+
pointer: undefined,
|
|
70
|
+
focus: undefined,
|
|
71
|
+
checked: undefined,
|
|
72
|
+
disabled: Boolean(disabled),
|
|
73
|
+
})
|
|
74
|
+
const [cssPropsPolyfillStateRef, cssPropsPolyfillAttributes] = useCSSPropsPolyfill(
|
|
75
|
+
ChipMeta,
|
|
76
|
+
{ size },
|
|
77
|
+
{ ref: stateRef },
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
ref={cssPropsPolyfillStateRef}
|
|
83
|
+
data-type={groupContext?.type ?? 'plain'}
|
|
84
|
+
className={cn(
|
|
85
|
+
`gds-chip root-flex flex-col u:size-max u:max-w-full
|
|
86
|
+
u:has-nested-checked/chip-ref:expose-checked
|
|
87
|
+
u:has-nested-hover/chip-ref:expose-hover
|
|
88
|
+
u:has-nested-focus-visible/chip-ref:expose-focus
|
|
89
|
+
u:has-nested-disabled/chip-ref:expose-disabled
|
|
90
|
+
u:i:has-nested-checked/chip-ref:data-[type=radio]:state-idle`,
|
|
91
|
+
className,
|
|
92
|
+
)}
|
|
93
|
+
{...state.exposedAttributes}
|
|
94
|
+
{...state.polyfillAttributes}
|
|
95
|
+
{...getCSSPropsAttributes(ChipMeta, { size }, style)}
|
|
96
|
+
{...cssPropsPolyfillAttributes}
|
|
97
|
+
{...rootProps}
|
|
98
|
+
>
|
|
99
|
+
{(() => {
|
|
100
|
+
if (!groupContext || props.href !== undefined) {
|
|
101
|
+
return renderButtonOrLink({})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (groupContext.type === 'checkbox') {
|
|
105
|
+
return (
|
|
106
|
+
<Checkbox.Root
|
|
107
|
+
name={name ?? (undefined as never)}
|
|
108
|
+
value={typeof value === 'string' ? value : (undefined as never)}
|
|
109
|
+
disabled={Boolean(disabled)}
|
|
110
|
+
nativeButton
|
|
111
|
+
render={renderButtonOrLink}
|
|
112
|
+
/>
|
|
113
|
+
)
|
|
114
|
+
} else {
|
|
115
|
+
return (
|
|
116
|
+
<Radio.Root
|
|
117
|
+
value={value}
|
|
118
|
+
disabled={Boolean(disabled)}
|
|
119
|
+
nativeButton
|
|
120
|
+
render={renderButtonOrLink}
|
|
121
|
+
/>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function renderButtonOrLink({
|
|
126
|
+
tabIndex: _tabIndex,
|
|
127
|
+
defaultChecked: _defaultChecked,
|
|
128
|
+
...renderProps
|
|
129
|
+
}: Parameters<
|
|
130
|
+
ExtractFn<ComponentProps<typeof Checkbox.Root | typeof Radio.Root>['render']>
|
|
131
|
+
>[0]) {
|
|
132
|
+
return (
|
|
133
|
+
<ButtonOrLink
|
|
134
|
+
{...renderProps}
|
|
135
|
+
disabled={disabled}
|
|
136
|
+
className={cn(
|
|
137
|
+
renderProps.className,
|
|
138
|
+
`nested/chip-ref flex grow items-center justify-center
|
|
139
|
+
rounded-full border border-default text-muted transition
|
|
140
|
+
@state-checked/chip:border-brand-muted
|
|
141
|
+
@state-checked/chip:bg-brand-subtlest
|
|
142
|
+
@state-checked/chip:text-default
|
|
143
|
+
@state-hover/chip:border-strong
|
|
144
|
+
@state-hover/chip:text-default
|
|
145
|
+
@state-hover/chip:@state-checked/chip:border-brand-default
|
|
146
|
+
@state-hover/chip:@state-checked/chip:bg-brand-subtler
|
|
147
|
+
@prop-size-small/chip:h-6
|
|
148
|
+
@prop-size-small/chip:px-1
|
|
149
|
+
@prop-size-small/chip:text-12
|
|
150
|
+
@prop-size-medium/chip:h-8
|
|
151
|
+
@prop-size-medium/chip:px-1.5
|
|
152
|
+
@prop-size-medium/chip:text-14
|
|
153
|
+
@prop-size-large/chip:h-10
|
|
154
|
+
@prop-size-large/chip:px-2
|
|
155
|
+
@prop-size-large/chip:text-16
|
|
156
|
+
u:*:transition-opacity
|
|
157
|
+
u:*:@state-disabled/chip:opacity-disabled
|
|
158
|
+
u:*:@state-disabled/chip:grayscale
|
|
159
|
+
u:@prop-size-small/chip:addon-small
|
|
160
|
+
u:@prop-size-medium/chip:addon-medium
|
|
161
|
+
u:@prop-size-large/chip:addon-large
|
|
162
|
+
i:@state-disabled/chip:border-muted
|
|
163
|
+
i:@state-disabled/chip:bg-transparent
|
|
164
|
+
i:@state-disabled/chip:text-muted
|
|
165
|
+
i:@state-disabled/chip:@state-checked/chip:border-transparent
|
|
166
|
+
i:@state-disabled/chip:@state-checked/chip:bg-brand-subtlest`,
|
|
167
|
+
)}
|
|
168
|
+
{...nestedProps}
|
|
169
|
+
>
|
|
170
|
+
{/* Ensure rounded corners are clickable */}
|
|
171
|
+
<span className="absolute inset-0 not-in-clickable:hidden" />
|
|
172
|
+
{addonBefore ? <ChipAddon side="before">{renderAddon(addonBefore)}</ChipAddon> : null}
|
|
173
|
+
<span className="flex items-baseline gap-1 px-1">
|
|
174
|
+
<span className="truncate">{children}</span>
|
|
175
|
+
{count ? (
|
|
176
|
+
<span
|
|
177
|
+
className={`
|
|
178
|
+
max-w-full shrink-0 truncate text-subtle transition
|
|
179
|
+
@state-enabled/chip:@state-checked/chip:text-current
|
|
180
|
+
@state-enabled/chip:@state-hover/chip:text-current
|
|
181
|
+
@prop-size-small/chip:text-10
|
|
182
|
+
@prop-size-medium/chip:text-12
|
|
183
|
+
@prop-size-large/chip:text-14
|
|
184
|
+
`}
|
|
185
|
+
>
|
|
186
|
+
{count}
|
|
187
|
+
</span>
|
|
188
|
+
) : null}
|
|
189
|
+
</span>
|
|
190
|
+
{addonAfter ? <ChipAddon side="after">{renderAddon(addonAfter)}</ChipAddon> : null}
|
|
191
|
+
</ButtonOrLink>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
})()}
|
|
195
|
+
</div>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
ChipRoot.displayName = 'Chip'
|
|
199
|
+
|
|
200
|
+
function ChipAddon({
|
|
201
|
+
side,
|
|
202
|
+
className,
|
|
203
|
+
children,
|
|
204
|
+
...props
|
|
205
|
+
}: ComponentProps<'span'> & { side: 'before' | 'after' }) {
|
|
206
|
+
return (
|
|
207
|
+
<span
|
|
208
|
+
data-side={side}
|
|
209
|
+
className={cn(
|
|
210
|
+
`gds-addon root-flex items-center justify-center u:h-(--gds-addon-size) u:min-w-(--gds-addon-size) u:shrink-0
|
|
211
|
+
u:has-avatar-group:data-[side=after]:ps-0.5
|
|
212
|
+
u:has-tag:data-[side=after]:ps-0.5
|
|
213
|
+
u:has-avatar-group:data-[side=before]:pe-0.5
|
|
214
|
+
u:has-tag:data-[side=before]:pe-0.5`,
|
|
215
|
+
className,
|
|
216
|
+
)}
|
|
217
|
+
{...props}
|
|
218
|
+
>
|
|
219
|
+
{children}
|
|
220
|
+
</span>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export declare namespace ChipGroupProps {
|
|
225
|
+
interface BaseProps
|
|
226
|
+
extends Omit<ComponentProps<'div'>, 'onChange'>, GDSComponentProps<typeof ChipGroupMeta> {}
|
|
227
|
+
interface CheckboxProps extends BaseProps {
|
|
228
|
+
type: 'checkbox'
|
|
229
|
+
name?: undefined
|
|
230
|
+
/** Array of checked/selected chip values. */
|
|
231
|
+
value?: string[] | undefined
|
|
232
|
+
defaultValue?: string[] | undefined
|
|
233
|
+
onChange?: ((value: string[]) => void) | undefined
|
|
234
|
+
}
|
|
235
|
+
interface RadioProps extends BaseProps {
|
|
236
|
+
type: 'radio'
|
|
237
|
+
/** Name used to submit the checked/selected chip value when inside a form. */
|
|
238
|
+
name?: string | undefined
|
|
239
|
+
/** Checked/selected chip value. */
|
|
240
|
+
value?: string | undefined
|
|
241
|
+
defaultValue?: string | undefined
|
|
242
|
+
onChange?: ((value: string) => void) | undefined
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export type ChipGroupProps = ChipGroupProps.CheckboxProps | ChipGroupProps.RadioProps
|
|
247
|
+
|
|
248
|
+
export function ChipGroup({
|
|
249
|
+
ref: passedRef,
|
|
250
|
+
type,
|
|
251
|
+
name,
|
|
252
|
+
value,
|
|
253
|
+
defaultValue,
|
|
254
|
+
onChange,
|
|
255
|
+
size,
|
|
256
|
+
className,
|
|
257
|
+
style,
|
|
258
|
+
children,
|
|
259
|
+
...props
|
|
260
|
+
}: ChipGroupProps) {
|
|
261
|
+
useGDS()
|
|
262
|
+
|
|
263
|
+
if (props['aria-label'] === undefined && props['aria-labelledby'] === undefined) {
|
|
264
|
+
// oxlint-disable-next-line no-console
|
|
265
|
+
console.warn(
|
|
266
|
+
'[Chip.Group] One of `aria-label` or `aria-labelledby` should be set for accessibility',
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const [cssPropsPolyfillPassedRef, cssPropsPolyfillAttributes, cssProps] = useCSSPropsPolyfill(
|
|
271
|
+
ChipGroupMeta,
|
|
272
|
+
{ size },
|
|
273
|
+
{ ref: passedRef, returnPropValues: { size } },
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
const sharedProps = {
|
|
277
|
+
ref: cssPropsPolyfillPassedRef,
|
|
278
|
+
'data-size': cssProps.size,
|
|
279
|
+
className: cn(
|
|
280
|
+
`gds-chip-group root-flex u:flex-wrap
|
|
281
|
+
u:data-[size=large]:gap-2
|
|
282
|
+
u:data-[size=medium]:gap-1.5
|
|
283
|
+
u:data-[size=small]:gap-1
|
|
284
|
+
u:**:chip:@prop-size-small/chip-group:prop-size-small
|
|
285
|
+
u:**:chip:@prop-size-medium/chip-group:prop-size-medium
|
|
286
|
+
u:**:chip:@prop-size-large/chip-group:prop-size-large`,
|
|
287
|
+
className,
|
|
288
|
+
),
|
|
289
|
+
...getCSSPropsAttributes(ChipGroupMeta, { size }, style),
|
|
290
|
+
...cssPropsPolyfillAttributes,
|
|
291
|
+
...props,
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<ChipGroupContext.Provider value={{ type }}>
|
|
296
|
+
{type === 'checkbox' ? (
|
|
297
|
+
<CheckboxGroup
|
|
298
|
+
{...sharedProps}
|
|
299
|
+
{...(value !== undefined && { value })}
|
|
300
|
+
{...(defaultValue !== undefined && { defaultValue })}
|
|
301
|
+
{...(onChange !== undefined && { onValueChange: onChange })}
|
|
302
|
+
>
|
|
303
|
+
{children}
|
|
304
|
+
</CheckboxGroup>
|
|
305
|
+
) : (
|
|
306
|
+
<RadioGroup
|
|
307
|
+
name={name ?? (undefined as never)}
|
|
308
|
+
{...sharedProps}
|
|
309
|
+
{...(value !== undefined && { value })}
|
|
310
|
+
{...(defaultValue !== undefined && { defaultValue })}
|
|
311
|
+
{...(onChange !== undefined && { onValueChange: onChange as (value: unknown) => void })}
|
|
312
|
+
>
|
|
313
|
+
{children}
|
|
314
|
+
</RadioGroup>
|
|
315
|
+
)}
|
|
316
|
+
</ChipGroupContext.Provider>
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
ChipGroup.displayName = 'Chip.Group'
|
|
@@ -39,7 +39,9 @@ import {
|
|
|
39
39
|
|
|
40
40
|
import { useControlled, useCSSPropsPolyfill, useGDS } from '../hooks/index.ts'
|
|
41
41
|
import { cn, getCSSPropsAttributes, type Stringifiable } from '../utils/index.ts'
|
|
42
|
+
import { renderAddon, type AddonValue } from './base/Addon.tsx'
|
|
42
43
|
import { Button } from './Button.tsx'
|
|
44
|
+
import { ButtonGroup } from './ButtonGroup.tsx'
|
|
43
45
|
import { CodeBlockMeta } from './CodeBlock.meta.ts'
|
|
44
46
|
import { CopyButton } from './CopyButton.tsx'
|
|
45
47
|
import { TabSet, TabSetContext, type TabSetTabProps } from './TabSet.tsx'
|
|
@@ -150,8 +152,21 @@ function CodeBlockHeader({ buttons, className, children, ...props }: CodeBlockHe
|
|
|
150
152
|
)}
|
|
151
153
|
{...props}
|
|
152
154
|
>
|
|
153
|
-
<div className="grow">{children}</div>
|
|
154
|
-
{buttons ?
|
|
155
|
+
<div className="min-w-em grow">{children}</div>
|
|
156
|
+
{buttons ? (
|
|
157
|
+
<ButtonGroup
|
|
158
|
+
variant="naked"
|
|
159
|
+
size="medium"
|
|
160
|
+
/**
|
|
161
|
+
* The `not-has-button:hidden` class prevents an empty `ButtonGroup` from taking space
|
|
162
|
+
* in the layout, which can happen when the stuff that `CodeBlockTabs` passes as
|
|
163
|
+
* `buttons` ends up rendering nothing (which we can't know in advance).
|
|
164
|
+
*/
|
|
165
|
+
className="me-2 shrink-0 self-center not-has-button:hidden"
|
|
166
|
+
>
|
|
167
|
+
{buttons}
|
|
168
|
+
</ButtonGroup>
|
|
169
|
+
) : null}
|
|
155
170
|
<div className="absolute inset-x-0 bottom-0 border-b border-subtle" />
|
|
156
171
|
</figcaption>
|
|
157
172
|
</CodeBlockHeaderContext.Provider>
|
|
@@ -162,8 +177,8 @@ export interface CodeBlockProps extends Omit<ComponentProps<'div'>, 'onCopy'>, S
|
|
|
162
177
|
/** @default 'text' */
|
|
163
178
|
language?: Language | undefined
|
|
164
179
|
/** Defaults to an icon that matches the `language`. */
|
|
165
|
-
icon?:
|
|
166
|
-
label?:
|
|
180
|
+
icon?: AddonValue | undefined
|
|
181
|
+
label?: ReactNode | undefined
|
|
167
182
|
children: Stringifiable
|
|
168
183
|
}
|
|
169
184
|
|
|
@@ -314,64 +329,74 @@ export function CodeBlockRoot({
|
|
|
314
329
|
})
|
|
315
330
|
}, [highlighter, childrenString, activeTheme, language, highlights, secrets, diff])
|
|
316
331
|
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
{
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
{copy ?
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
onCopy={onCopy}
|
|
334
|
-
/>
|
|
335
|
-
) : null}
|
|
336
|
-
</>
|
|
337
|
-
)
|
|
332
|
+
const buttonElements = [
|
|
333
|
+
secrets.length > 0 && (
|
|
334
|
+
<Button key="reveal" onClick={() => setMasked(!masked)}>
|
|
335
|
+
{masked ? (
|
|
336
|
+
<EyeIcon alt={`Reveal secret${secrets.length > 1 ? 's' : ''}`} />
|
|
337
|
+
) : (
|
|
338
|
+
<EyeClosedIcon alt={`Hide secret${secrets.length > 1 ? 's' : ''}`} />
|
|
339
|
+
)}
|
|
340
|
+
</Button>
|
|
341
|
+
),
|
|
342
|
+
copy && (
|
|
343
|
+
<CopyButton key="copy" value={typeof copy === 'string' ? copy : codeToCopy} onCopy={onCopy} />
|
|
344
|
+
),
|
|
345
|
+
].filter(Boolean)
|
|
346
|
+
|
|
347
|
+
const buttons = buttonElements.length > 0 ? <>{buttonElements}</> : null
|
|
338
348
|
|
|
339
349
|
if (hasAncestorHeader) {
|
|
340
350
|
return buttons
|
|
341
351
|
}
|
|
342
352
|
|
|
343
353
|
const Wrapper = hasAncestorTabs ? 'div' : CodeBlockWrapper
|
|
344
|
-
const headerContent =
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
const headerContent =
|
|
355
|
+
label || passedIcon ? (
|
|
356
|
+
<div className="flex h-full items-center gap-2 ps-2">
|
|
357
|
+
{icon ? (
|
|
358
|
+
<span className="flex size-4 shrink-0 items-center justify-center **:icon:default-size-3.5">
|
|
359
|
+
{renderAddon(icon)}
|
|
360
|
+
</span>
|
|
361
|
+
) : null}
|
|
362
|
+
{label ? <span className="truncate text-14 text-muted">{label}</span> : null}
|
|
363
|
+
</div>
|
|
364
|
+
) : null
|
|
354
365
|
|
|
355
366
|
return (
|
|
356
367
|
<Wrapper
|
|
357
368
|
ref={cssPropsPolyfillPassedRef}
|
|
369
|
+
data-has-header={Boolean(headerContent) || undefined}
|
|
358
370
|
className={cn(
|
|
359
|
-
`gds-code-block
|
|
360
|
-
u:not-in-code-block-tabs:
|
|
361
|
-
u:not-in-code-block-tabs:
|
|
371
|
+
`gds-code-block group/code-block root-flex flex-col
|
|
372
|
+
u:not-in-code-block-tabs:rounded-8
|
|
373
|
+
u:not-in-code-block-tabs:not-data-has-header:min-h-13
|
|
374
|
+
u:not-in-code-block-tabs:data-has-header:min-h-24`,
|
|
362
375
|
className,
|
|
363
376
|
)}
|
|
364
377
|
{...getCSSPropsAttributes(CodeBlockMeta, { wrap, lineNumbers, rows }, style)}
|
|
365
378
|
{...cssPropsPolyfillAttributes}
|
|
366
379
|
{...props}
|
|
367
380
|
>
|
|
368
|
-
{
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
381
|
+
{headerContent ? (
|
|
382
|
+
hasAncestorTabs ? (
|
|
383
|
+
<div className="flex h-10 shrink-0 px-2">
|
|
384
|
+
<div className="absolute inset-0 border-b border-subtle" />
|
|
385
|
+
{headerContent}
|
|
386
|
+
</div>
|
|
387
|
+
) : (
|
|
388
|
+
<CodeBlockHeader buttons={buttons}>{headerContent}</CodeBlockHeader>
|
|
389
|
+
)
|
|
390
|
+
) : !hasAncestorTabs && buttons ? (
|
|
391
|
+
<div
|
|
392
|
+
className={`
|
|
393
|
+
absolute end-3 top-3 z-10 opacity-0 transition
|
|
394
|
+
group-not-hover/code-block:pointer-events-none
|
|
395
|
+
group-hover/code-block:opacity-100
|
|
396
|
+
has-focus-visible:opacity-100
|
|
397
|
+
`}
|
|
398
|
+
>
|
|
399
|
+
<ButtonGroup size="xsmall">{buttons}</ButtonGroup>
|
|
375
400
|
</div>
|
|
376
401
|
) : null}
|
|
377
402
|
<pre
|
|
@@ -384,7 +409,7 @@ export function CodeBlockRoot({
|
|
|
384
409
|
* that case, so it should be fine.
|
|
385
410
|
*/
|
|
386
411
|
className={`
|
|
387
|
-
h-(--max-height) max-h-max grow overflow-auto font-mono text-14
|
|
412
|
+
isolate scrollbar-thin h-(--max-height) max-h-max grow overflow-auto font-mono text-14
|
|
388
413
|
[--max-height:calc(9999px-min(9999px,var(--gds-code-block-rows)*9999px)+var(--gds-code-block-rows)*1lh+2*var(--padding))]
|
|
389
414
|
[--padding:--spacing(4)]
|
|
390
415
|
firefox:h-auto
|
|
@@ -427,8 +452,8 @@ export function CodeBlockRoot({
|
|
|
427
452
|
<span
|
|
428
453
|
aria-hidden
|
|
429
454
|
className={`
|
|
430
|
-
|
|
431
|
-
@prop-line-numbers-
|
|
455
|
+
min-w-4 text-center text-12 text-subtle select-none
|
|
456
|
+
@prop-line-numbers-false/code-block:hidden
|
|
432
457
|
`}
|
|
433
458
|
>
|
|
434
459
|
{lineIndex + 1}
|
|
@@ -544,7 +569,7 @@ export function CodeBlockTabs<const Tabs extends readonly Tab[], T extends TabVa
|
|
|
544
569
|
className,
|
|
545
570
|
children,
|
|
546
571
|
...props
|
|
547
|
-
}: CodeBlockTabsProps<Tabs, T>
|
|
572
|
+
}: CodeBlockTabsProps<Tabs, T>) {
|
|
548
573
|
if (passedTabs.length === 0) {
|
|
549
574
|
throw new Error('[CodeBlock.Tabs] At least 1 tab is required')
|
|
550
575
|
}
|
|
@@ -583,7 +608,7 @@ export function CodeBlockTabs<const Tabs extends readonly Tab[], T extends TabVa
|
|
|
583
608
|
defaultValue={defaultValue ?? (tabs[0]!.value as T)}
|
|
584
609
|
onChange={onChange}
|
|
585
610
|
className={cn(
|
|
586
|
-
`gds-code-block-tabs
|
|
611
|
+
`gds-code-block-tabs root-flex flex-col u:min-h-24 u:rounded-8
|
|
587
612
|
u:[--saved-default-line-numbers:var(--gds-default-line-numbers)]
|
|
588
613
|
u:[--saved-default-rows:var(--gds-default-rows)]
|
|
589
614
|
u:[--saved-default-wrap:var(--gds-default-wrap)]
|
|
@@ -15,8 +15,8 @@ export function CodeInline({ className, children, ...props }: CodeInlineProps) {
|
|
|
15
15
|
return (
|
|
16
16
|
<span
|
|
17
17
|
className={cn(
|
|
18
|
-
`gds-code-inline root-inline
|
|
19
|
-
u:
|
|
18
|
+
`gds-code-inline root-inline u:font-mono u:text-size-inherit u:wrap-anywhere u:whitespace-pre-wrap u:text-code
|
|
19
|
+
u:in-link:text-link-idle
|
|
20
20
|
${/* If inside a link, ensure the underline of the link appears over the background and border by default */ ''}
|
|
21
21
|
u:in-link:-z-10
|
|
22
22
|
${/* Prevent messing with the line height (this needs to be set on the root _and_ on the inner element) */ ''}
|
|
@@ -44,7 +44,7 @@ export function CodeInline({ className, children, ...props }: CodeInlineProps) {
|
|
|
44
44
|
in-link:transition-[border-radius]
|
|
45
45
|
in-link-hover:rounded-b-none
|
|
46
46
|
${/* Prevent incorrect alignment when empty */ ''}
|
|
47
|
-
empty:after:content-
|
|
47
|
+
empty:after:content-nbsp
|
|
48
48
|
`}
|
|
49
49
|
{...props}
|
|
50
50
|
>
|
|
@@ -5,17 +5,12 @@ import { ButtonMeta } from './Button.meta.ts'
|
|
|
5
5
|
type ButtonVariant = (typeof ButtonMeta.cssProps.variant.values)[number]
|
|
6
6
|
|
|
7
7
|
export const CopyButtonMeta = createComponent('CopyButton', {
|
|
8
|
-
|
|
8
|
+
extends: ButtonMeta,
|
|
9
9
|
cssProps: {
|
|
10
|
-
/** @default 'secondary' */
|
|
11
10
|
variant: {
|
|
12
11
|
type: 'values',
|
|
13
12
|
values: ['secondary', 'tertiary', 'inverse', 'naked'] as const satisfies ButtonVariant[],
|
|
14
13
|
defaultValue: 'secondary',
|
|
15
14
|
},
|
|
16
|
-
/** @default 'medium' */
|
|
17
|
-
size: ButtonMeta.cssProps.size,
|
|
18
|
-
/** @default false */
|
|
19
|
-
hideLabel: ButtonMeta.cssProps.hideLabel,
|
|
20
15
|
},
|
|
21
16
|
})
|
|
@@ -42,7 +42,7 @@ export function CopyButton({
|
|
|
42
42
|
if (newStatus === 'copied') {
|
|
43
43
|
timeoutRef.current = window.setTimeout(() => setStatus('copied-exit'), 1000)
|
|
44
44
|
} else if (newStatus === 'copied-exit') {
|
|
45
|
-
timeoutRef.current = window.setTimeout(() => setStatus('idle'),
|
|
45
|
+
timeoutRef.current = window.setTimeout(() => setStatus('idle'), 150)
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -57,9 +57,8 @@ export function CopyButton({
|
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
59
|
<Tooltip
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
: { content: null })}
|
|
60
|
+
content="Copied!"
|
|
61
|
+
{...(status !== 'idle' ? { open: status === 'copied' } : { disabled: true })}
|
|
63
62
|
{...tooltipCSSProps}
|
|
64
63
|
>
|
|
65
64
|
<Button
|
|
@@ -3,9 +3,5 @@ import { createComponent } from '@graphprotocol/gds-css'
|
|
|
3
3
|
import { FieldMeta } from './base/Field.meta.ts'
|
|
4
4
|
|
|
5
5
|
export const CurrencyInputMeta = createComponent('CurrencyInput', {
|
|
6
|
-
|
|
7
|
-
cssProps: {
|
|
8
|
-
/** @default 'medium' */
|
|
9
|
-
size: FieldMeta.cssProps.size,
|
|
10
|
-
},
|
|
6
|
+
extends: FieldMeta,
|
|
11
7
|
})
|
|
@@ -56,6 +56,7 @@ export function DescriptionListRoot({
|
|
|
56
56
|
</div>
|
|
57
57
|
)
|
|
58
58
|
}
|
|
59
|
+
DescriptionListRoot.displayName = 'DescriptionList'
|
|
59
60
|
|
|
60
61
|
export interface DescriptionListItemProps
|
|
61
62
|
extends ComponentProps<'div'>, GDSComponentProps<typeof DescriptionListItemMeta> {
|
|
@@ -189,7 +190,7 @@ export function DescriptionListItem({
|
|
|
189
190
|
<span
|
|
190
191
|
className={`
|
|
191
192
|
absolute inset-y-0 flex items-center justify-center
|
|
192
|
-
not-
|
|
193
|
+
group-not-data-loading/description-list-item:hidden
|
|
193
194
|
@prop-orientation-horizontal/description-list:start-0
|
|
194
195
|
@prop-orientation-vertical/description-list:end-0
|
|
195
196
|
@prop-orientation-vertical/description-list:w-(--gds-addon-size)
|
package/src/components/Icon.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import type { GDSComponentProps } from '@graphprotocol/gds-css'
|
|
|
13
13
|
import { useGDS } from '../hooks/index.ts'
|
|
14
14
|
import { cn, getCSSPropsAttributes } from '../utils/index.ts'
|
|
15
15
|
import { IconMeta } from './Icon.meta.ts'
|
|
16
|
-
import {
|
|
16
|
+
import { useTooltipCollector } from './Tooltip.tsx'
|
|
17
17
|
|
|
18
18
|
export interface IconProps
|
|
19
19
|
extends Omit<ComponentProps<'span'>, 'children' | 'color'>, GDSComponentProps<typeof IconMeta> {
|
|
@@ -35,10 +35,10 @@ export function Icon({ src, alt, size, color, className, style, ...props }: Icon
|
|
|
35
35
|
useGDS()
|
|
36
36
|
|
|
37
37
|
const iconContent = isValidElement(src) ? src : createElement(src)
|
|
38
|
-
const
|
|
38
|
+
const collectTooltipContent = useTooltipCollector()
|
|
39
39
|
|
|
40
|
-
if (
|
|
41
|
-
|
|
40
|
+
if (collectTooltipContent && alt) {
|
|
41
|
+
collectTooltipContent(alt)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
if ('variant' in props) {
|
|
@@ -3,9 +3,5 @@ import { createComponent } from '@graphprotocol/gds-css'
|
|
|
3
3
|
import { FieldMeta } from './base/Field.meta.ts'
|
|
4
4
|
|
|
5
5
|
export const InputMeta = createComponent('Input', {
|
|
6
|
-
|
|
7
|
-
cssProps: {
|
|
8
|
-
/** @default 'medium' */
|
|
9
|
-
size: FieldMeta.cssProps.size,
|
|
10
|
-
},
|
|
6
|
+
extends: FieldMeta,
|
|
11
7
|
})
|