@graphprotocol/gds-react 0.2.0 → 0.2.2
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 +1 -9
- package/dist/GDSProvider.d.ts.map +1 -1
- package/dist/GDSProvider.js +4 -3
- package/dist/GDSProvider.js.map +1 -1
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +2 -2
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Breadcrumbs.parts.js +1 -1
- package/dist/components/Breadcrumbs.parts.js.map +1 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +69 -69
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.js +2 -2
- package/dist/components/Card.js.map +1 -1
- package/dist/components/CodeBlock.d.ts +1 -1
- package/dist/components/CodeBlock.parts.d.ts +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 -19
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/Input.js +2 -2
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Link.js +2 -2
- package/dist/components/Link.js.map +1 -1
- package/dist/components/Menu.parts.d.ts +4 -5
- package/dist/components/Menu.parts.d.ts.map +1 -1
- package/dist/components/Menu.parts.js +52 -45
- package/dist/components/Menu.parts.js.map +1 -1
- package/dist/components/Modal.parts.d.ts.map +1 -1
- package/dist/components/Modal.parts.js +17 -21
- package/dist/components/Modal.parts.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/Search.js +1 -1
- package/dist/components/Tooltip.parts.d.ts +13 -4
- package/dist/components/Tooltip.parts.d.ts.map +1 -1
- package/dist/components/Tooltip.parts.js +51 -63
- package/dist/components/Tooltip.parts.js.map +1 -1
- package/dist/components/base/ButtonOrLink.d.ts +1 -1
- package/dist/components/base/ButtonOrLink.d.ts.map +1 -1
- package/dist/components/base/ButtonOrLink.parts.d.ts +10 -3
- package/dist/components/base/ButtonOrLink.parts.d.ts.map +1 -1
- package/dist/components/base/ButtonOrLink.parts.js +27 -35
- package/dist/components/base/ButtonOrLink.parts.js.map +1 -1
- package/dist/components/base/MaybeButtonOrLink.d.ts +19 -2
- 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/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/index.d.ts +1 -0
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/base/index.js +1 -0
- package/dist/components/base/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/useCSSProp.js +1 -1
- package/dist/hooks/useCSSProp.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/useGDS.js +1 -1
- package/dist/hooks/useGDS.js.map +1 -1
- package/dist/hooks/useStyleObserver.js +1 -1
- package/dist/hooks/useStyleObserver.js.map +1 -1
- package/dist/tailwind-plugin.d.ts.map +1 -1
- package/dist/tailwind-plugin.js +3 -0
- 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/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/package.json +14 -14
- package/src/GDSContext.ts +16 -0
- package/src/GDSProvider.tsx +20 -31
- package/src/components/Avatar.tsx +3 -2
- package/src/components/Breadcrumbs.parts.tsx +1 -1
- package/src/components/Button.tsx +113 -107
- package/src/components/Card.tsx +2 -2
- package/src/components/CopyButton.tsx +49 -25
- package/src/components/Input.tsx +1 -1
- package/src/components/Link.tsx +2 -2
- package/src/components/Menu.parts.tsx +78 -73
- package/src/components/Modal.parts.tsx +26 -31
- 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/Search.tsx +1 -1
- package/src/components/Tooltip.parts.tsx +95 -80
- package/src/components/base/ButtonOrLink.parts.tsx +71 -51
- package/src/components/base/ButtonOrLink.tsx +1 -0
- package/src/components/base/MaybeButtonOrLink.tsx +26 -5
- package/src/components/base/Presence.tsx +1375 -0
- package/src/components/base/index.ts +1 -0
- package/src/components/index.ts +10 -0
- package/src/hooks/useCSSProp.ts +1 -1
- package/src/hooks/useControlled.ts +16 -8
- package/src/hooks/useGDS.ts +1 -1
- package/src/hooks/useStyleObserver.ts +1 -1
- package/src/tailwind-plugin.ts +3 -0
- package/src/utils/InlineCounter.tsx +17 -0
- package/src/utils/RenderCount.tsx +7 -0
- package/src/utils/index.ts +2 -0
|
@@ -18,6 +18,7 @@ export { Field, type FieldProps, type FieldState } from './Field.tsx'
|
|
|
18
18
|
export { FieldMeta } from './Field.meta.ts'
|
|
19
19
|
export { MaybeButtonOrLink, type MaybeButtonOrLinkProps } from './MaybeButtonOrLink.tsx'
|
|
20
20
|
export { Portal } from './Portal.tsx'
|
|
21
|
+
export { Presence, usePresence, type PresenceProps } from './Presence.tsx'
|
|
21
22
|
export {
|
|
22
23
|
Render,
|
|
23
24
|
type RenderFnProps,
|
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'
|
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
|
|
@@ -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
|
}
|
package/src/hooks/useGDS.ts
CHANGED
|
@@ -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] & {
|
package/src/tailwind-plugin.ts
CHANGED
|
@@ -31,6 +31,7 @@ import { LinkMeta } from './components/Link.meta.ts'
|
|
|
31
31
|
import { MenuItemMeta, MenuMeta } from './components/Menu.meta.ts'
|
|
32
32
|
import { ModalMeta } from './components/Modal.meta.ts'
|
|
33
33
|
import { OTCInputMeta } from './components/OTCInput.meta.ts'
|
|
34
|
+
import { PaneContainerMeta, PaneMeta } from './components/Pane.meta.ts'
|
|
34
35
|
import { RadioMeta } from './components/Radio.meta.ts'
|
|
35
36
|
import { SearchMeta } from './components/Search.meta.ts'
|
|
36
37
|
import {
|
|
@@ -104,6 +105,8 @@ const gdsTailwindPluginWithComponents: ReturnType<typeof createPlugin> = createP
|
|
|
104
105
|
MenuMeta,
|
|
105
106
|
ModalMeta,
|
|
106
107
|
OTCInputMeta,
|
|
108
|
+
PaneContainerMeta,
|
|
109
|
+
PaneMeta,
|
|
107
110
|
RadioMeta,
|
|
108
111
|
SearchMeta,
|
|
109
112
|
SegmentedControlMeta,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useState, type ComponentProps } from 'react'
|
|
2
|
+
|
|
3
|
+
export function InlineCounter(props: ComponentProps<'span'>) {
|
|
4
|
+
const [count, setCount] = useState(0)
|
|
5
|
+
return (
|
|
6
|
+
<span {...props}>
|
|
7
|
+
{count}{' '}
|
|
8
|
+
<button
|
|
9
|
+
type="button"
|
|
10
|
+
onClick={() => setCount((prev) => prev + 1)}
|
|
11
|
+
className="inline hover:underline"
|
|
12
|
+
>
|
|
13
|
+
(increment)
|
|
14
|
+
</button>
|
|
15
|
+
</span>
|
|
16
|
+
)
|
|
17
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -2,8 +2,10 @@ export { cn } from './cn.ts'
|
|
|
2
2
|
export { getAssetUrl } from './getAssetUrl.ts'
|
|
3
3
|
export { getCSSPropsAttributes } from './getCSSPropsAttributes.ts'
|
|
4
4
|
export { getReactNodeKey } from './getReactNodeKey.ts'
|
|
5
|
+
export { InlineCounter } from './InlineCounter.tsx'
|
|
5
6
|
export { isReactNode } from './isReactNode.ts'
|
|
6
7
|
export { reactNodeToString } from './reactNodeToString.ts'
|
|
8
|
+
export { RenderCount } from './RenderCount.tsx'
|
|
7
9
|
export { splitProps } from './splitProps.ts'
|
|
8
10
|
export { styleScheduler } from './styleScheduler.ts'
|
|
9
11
|
export { trimReactNode } from './trimReactNode.tsx'
|