@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
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { type Key, type ReactNode } from 'react';
|
|
2
|
+
import { type RenderProp } from './Render.tsx';
|
|
3
|
+
type VisibleKey = Key | Key[] | null;
|
|
4
|
+
type GetChildKey = (child: ReactNode, index: number) => Key | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* - "entering": just added / made visible, transitioning in.
|
|
7
|
+
* - "visible": present and not transitioning.
|
|
8
|
+
* - "exiting": just removed / made hidden, transitioning out.
|
|
9
|
+
* - "hidden": kept mounted but not shown (persistent mode only).
|
|
10
|
+
*/
|
|
11
|
+
type Status = 'entering' | 'visible' | 'exiting' | 'hidden';
|
|
12
|
+
interface Item {
|
|
13
|
+
key: Key;
|
|
14
|
+
element: ReactNode;
|
|
15
|
+
status: Status;
|
|
16
|
+
/**
|
|
17
|
+
* The previous status before the most recent change, or `null` if status hasn't just changed.
|
|
18
|
+
* Cleared after next frame.
|
|
19
|
+
*/
|
|
20
|
+
previousStatus: Status | null;
|
|
21
|
+
/** Whether this item was present on mount and hasn't re-entered since. */
|
|
22
|
+
initial: boolean;
|
|
23
|
+
}
|
|
24
|
+
type PresenceItemState = Omit<Item, 'element'>;
|
|
25
|
+
type PresenceWrapperState = {
|
|
26
|
+
/** Whether at least one item is currently transitioning (entering or exiting). */
|
|
27
|
+
transitioning: boolean;
|
|
28
|
+
/** Whether at least one item is present (entering or visible). */
|
|
29
|
+
hasPresent: boolean;
|
|
30
|
+
/** Array of all currently rendered items (entering, visible, exiting, and hidden). */
|
|
31
|
+
items: Item[];
|
|
32
|
+
};
|
|
33
|
+
interface PresenceContextValue {
|
|
34
|
+
/** The status of the nearest `Presence` item ancestor. */
|
|
35
|
+
status: Status;
|
|
36
|
+
/**
|
|
37
|
+
* Whether all `Presence` item ancestors are present (entering or visible). If any ancestor is
|
|
38
|
+
* exiting or hidden, this will be `false`.
|
|
39
|
+
*/
|
|
40
|
+
present: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Hook to access presence information from the nearest `Presence` item ancestor.
|
|
44
|
+
*
|
|
45
|
+
* @returns An object with `status` and `present`, or `null` if not inside a `Presence` component.
|
|
46
|
+
*/
|
|
47
|
+
export declare function usePresence(): PresenceContextValue | null;
|
|
48
|
+
interface BasePresenceProps {
|
|
49
|
+
/**
|
|
50
|
+
* How long, in milliseconds, children stay in the "entering" status before switching to
|
|
51
|
+
* "visible".
|
|
52
|
+
*
|
|
53
|
+
* @default 0
|
|
54
|
+
*/
|
|
55
|
+
enterMs?: number | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* How long, in milliseconds, children stay in the "exiting" status before being unmounted (or
|
|
58
|
+
* switching to "hidden", in persistent mode).
|
|
59
|
+
*
|
|
60
|
+
* @default 0
|
|
61
|
+
*/
|
|
62
|
+
exitMs?: number | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Whether children that are present on mount should start in the "entering" status, instead of
|
|
65
|
+
* "visible".
|
|
66
|
+
*
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
initial?: boolean | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Element or render function for the outer wrapper. By default, renders a fragment (no wrapper).
|
|
72
|
+
*
|
|
73
|
+
* Receives state with `transitioning`, `hasPresent`, and `items`.
|
|
74
|
+
*/
|
|
75
|
+
render?: RenderProp<PresenceWrapperState> | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Element or render function for each child's inner wrapper. By default, renders a `div`.
|
|
78
|
+
*
|
|
79
|
+
* Receives props (including `hidden`, `inert`, `data-key`, `data-status`, `data-starting-style`,
|
|
80
|
+
* and `data-initial`) and state (`key`, `status`, `previousStatus`, and `initial`).
|
|
81
|
+
*/
|
|
82
|
+
renderChild?: RenderProp<PresenceItemState> | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Function to extract a key from a child node. Keys determine identity: when a child's key
|
|
85
|
+
* changes, the old one exits and the new one enters (triggering exit/enter transitions). If not
|
|
86
|
+
* provided, falls back to the child's `key` prop (with React's internal prefixes stripped) or the
|
|
87
|
+
* index.
|
|
88
|
+
*/
|
|
89
|
+
getChildKey?: GetChildKey | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Called synchronously during state update, before React commits DOM changes. Exiting elements
|
|
92
|
+
* are still in their original positions; entering elements don't exist yet (only keys provided).
|
|
93
|
+
* Useful for measuring layout before transitions begin.
|
|
94
|
+
*
|
|
95
|
+
* `previouslyTransitioning` contains items that were already in `entering` or `exiting` status
|
|
96
|
+
* before this transition started (useful for detecting interrupted transitions).
|
|
97
|
+
*/
|
|
98
|
+
onBeforeTransitionStart?: ((changes: {
|
|
99
|
+
entering: Set<Key>;
|
|
100
|
+
exiting: Map<Key, HTMLElement>;
|
|
101
|
+
previouslyTransitioning: Map<Key, 'entering' | 'exiting'>;
|
|
102
|
+
}) => void) | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Called in a layout effect after React commits DOM changes but before browser paint. Both
|
|
105
|
+
* entering and exiting elements are in the DOM. Useful for triggering CSS transitions.
|
|
106
|
+
*
|
|
107
|
+
* `previouslyTransitioning` contains items that were already in `entering` or `exiting` status
|
|
108
|
+
* before this transition started (useful for detecting interrupted transitions).
|
|
109
|
+
*/
|
|
110
|
+
onTransitionStart?: ((changes: {
|
|
111
|
+
entering: Map<Key, HTMLElement>;
|
|
112
|
+
exiting: Map<Key, HTMLElement>;
|
|
113
|
+
previouslyTransitioning: Map<Key, 'entering' | 'exiting'>;
|
|
114
|
+
}) => void) | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Called synchronously during state update, before React commits DOM changes. Both entered and
|
|
117
|
+
* exited elements are still in the DOM. This is the last chance to access exited elements.
|
|
118
|
+
*/
|
|
119
|
+
onBeforeTransitionEnd?: ((changes: {
|
|
120
|
+
entered: Map<Key, HTMLElement>;
|
|
121
|
+
exited: Map<Key, HTMLElement>;
|
|
122
|
+
}) => void) | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Called in a layout effect after React commits DOM changes but before browser paint. Entered
|
|
125
|
+
* elements are still in the DOM; exited elements have been removed (only keys provided).
|
|
126
|
+
*/
|
|
127
|
+
onTransitionEnd?: ((changes: {
|
|
128
|
+
entered: Map<Key, HTMLElement>;
|
|
129
|
+
exited: Set<Key>;
|
|
130
|
+
}) => void) | undefined;
|
|
131
|
+
children?: ReactNode;
|
|
132
|
+
}
|
|
133
|
+
/** Unmounting mode: delays unmounting for exit transitions (similar to Motion's `AnimatePresence`). */
|
|
134
|
+
interface UnmountingPresenceProps extends BasePresenceProps {
|
|
135
|
+
visibleKey?: undefined;
|
|
136
|
+
}
|
|
137
|
+
/** Persistent mode: keeps children mounted, but toggles their visibility with a delay. */
|
|
138
|
+
interface PersistentPresenceProps extends BasePresenceProps {
|
|
139
|
+
/**
|
|
140
|
+
* Key(s) of children that should be visible. Accepts:
|
|
141
|
+
*
|
|
142
|
+
* - Single key: `"foo"`
|
|
143
|
+
* - Array of keys: `["foo", "bar"]`
|
|
144
|
+
* - `null`: no child is visible.
|
|
145
|
+
*/
|
|
146
|
+
visibleKey?: VisibleKey;
|
|
147
|
+
}
|
|
148
|
+
export type PresenceProps = UnmountingPresenceProps | PersistentPresenceProps;
|
|
149
|
+
/**
|
|
150
|
+
* Presence.
|
|
151
|
+
*
|
|
152
|
+
* - If you pass no `visibleKey` → unmounting mode.
|
|
153
|
+
* - If you pass `visibleKey` → persistent mode.
|
|
154
|
+
*/
|
|
155
|
+
export declare function Presence({ visibleKey, enterMs, exitMs, initial, render, renderChild, getChildKey, onBeforeTransitionStart, onTransitionStart, onBeforeTransitionEnd, onTransitionEnd, children, }: PresenceProps): import("react/jsx-runtime").JSX.Element;
|
|
156
|
+
export {};
|
|
157
|
+
//# sourceMappingURL=Presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Presence.d.ts","sourceRoot":"","sources":["../../../src/components/base/Presence.tsx"],"names":[],"mappings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