@astryxdesign/core 0.7.8-canary.fbb81c6 → 0.7.8
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/CHANGELOG.md +132 -0
- package/dist/ClickableCard/ClickableCard.d.ts +1 -1
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +1 -5
- package/dist/DateInput/PickerWheel.d.ts.map +1 -1
- package/dist/DateInput/PickerWheel.js +1 -7
- package/dist/DropdownMenu/DropdownMenu.d.ts +1 -9
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +4 -9
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +2 -3
- package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuItem.js +2 -3
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +2 -3
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +2 -3
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +1 -6
- package/dist/Layer/preserveAnimations.d.ts +5 -1
- package/dist/Layer/preserveAnimations.d.ts.map +1 -1
- package/dist/Layer/preserveAnimations.js +214 -12
- package/dist/MoreMenu/MoreMenu.d.ts +3 -5
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.d.ts +1 -1
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +1 -5
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +1 -3
- package/dist/astryx.css +2 -6
- package/dist/hooks/menuPressGesture.d.ts +21 -132
- package/dist/hooks/menuPressGesture.d.ts.map +1 -1
- package/dist/hooks/menuPressGesture.js +30 -155
- package/dist/hooks/useClickableContainer.d.ts +5 -19
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +5 -28
- package/dist/hooks/useMenuPress.d.ts +1 -34
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +5 -93
- package/dist/motion/transientCopy.d.ts +2 -4
- package/dist/motion/transientCopy.d.ts.map +1 -1
- package/dist/motion/transientCopy.js +5 -34
- package/dist/motion/uikit/gestures.d.ts +0 -41
- package/dist/motion/uikit/gestures.d.ts.map +1 -1
- package/dist/motion/uikit/gestures.js +0 -25
- package/dist/motion/uikit/index.d.ts +1 -1
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +1 -1
- package/dist/utils/pressFeedback.d.ts +0 -7
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +1 -16
- package/package.json +5 -5
- package/src/ClickableCard/ClickableCard.tsx +1 -8
- package/src/DateInput/PickerWheel.tsx +2 -7
- package/src/DropdownMenu/DropdownMenu.doc.mjs +2 -1
- package/src/DropdownMenu/DropdownMenu.tsx +5 -29
- package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +1 -5
- package/src/DropdownMenu/DropdownMenuItem.tsx +4 -8
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +1 -5
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +1 -5
- package/src/Item/Item.tsx +5 -15
- package/src/Layer/preserveAnimations.ts +275 -12
- package/src/MoreMenu/MoreMenu.doc.mjs +4 -2
- package/src/MoreMenu/MoreMenu.tsx +3 -5
- package/src/SelectableCard/SelectableCard.tsx +1 -8
- package/src/TreeList/TreeListItem.tsx +6 -8
- package/src/hooks/menuPressGesture.ts +38 -243
- package/src/hooks/useClickableContainer.doc.mjs +2 -8
- package/src/hooks/useClickableContainer.ts +6 -52
- package/src/hooks/useMenuPress.ts +11 -118
- package/src/motion/MEASUREMENTS.md +0 -11
- package/src/motion/transientCopy.ts +5 -45
- package/src/motion/uikit/gestures.ts +0 -22
- package/src/motion/uikit/index.ts +0 -1
- package/src/utils/pressFeedback.ts +1 -16
- package/dist/hooks/menuPressValues.d.ts +0 -16
- package/dist/hooks/menuPressValues.d.ts.map +0 -1
- package/dist/hooks/menuPressValues.js +0 -18
- package/dist/motion/carryAnimations.d.ts +0 -58
- package/dist/motion/carryAnimations.d.ts.map +0 -1
- package/dist/motion/carryAnimations.js +0 -305
- package/dist/privateAttributes/menuPressLit.stylex.d.ts +0 -52
- package/dist/privateAttributes/menuPressLit.stylex.d.ts.map +0 -1
- package/dist/privateAttributes/menuPressLit.stylex.js +0 -99
- package/src/hooks/menuPressValues.ts +0 -18
- package/src/motion/carryAnimations.ts +0 -389
- package/src/privateAttributes/menuPressLit.stylex.ts +0 -104
|
@@ -11,23 +11,245 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Taking an element out of rendering cancels every CSS animation and
|
|
13
13
|
* transition of it and its subtree. When it returns, the browser creates the
|
|
14
|
-
* animations again from the stylesheet, at their start
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
14
|
+
* animations again from the stylesheet, at their start, and the transitions
|
|
15
|
+
* not at all; script-created animations are untouched. `preserveAnimations`
|
|
16
|
+
* reads every animation's state first and, afterwards, gives each recreated
|
|
17
|
+
* CSS animation that state and resumes each cancelled transition with a
|
|
18
|
+
* script animation at the same point.
|
|
19
|
+
*
|
|
20
|
+
* The state is read generically, from what the platform exposes: every
|
|
21
|
+
* accessor with a setter on the animation's and its effect's prototype
|
|
22
|
+
* chains, every field of the effect's timing, and its keyframes. Only values
|
|
23
|
+
* that differ from the recreated animation's are written, so a value the
|
|
24
|
+
* stylesheet controls stays under its control. A few members are not plain
|
|
25
|
+
* state and are handled in their own step (`ORDERED`); the rest need no
|
|
26
|
+
* handling (`DERIVED`). What cannot be carried over is the Animation and
|
|
27
|
+
* effect objects themselves: the old ones are idle, their `addEventListener`
|
|
28
|
+
* listeners and `finished`/`ready` promises stay with them, and the browser
|
|
29
|
+
* fires `animationcancel`/`transitioncancel` for them and `animationstart`
|
|
22
30
|
* for the new ones.
|
|
23
31
|
*/
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Animation members written in a fixed order rather than generically: the
|
|
35
|
+
* timeline before the range that is measured on it, the rate before the
|
|
36
|
+
* time, and the start time (or, for a paused animation, the current time)
|
|
37
|
+
* last, once the play state is set. `effect` is not
|
|
38
|
+
* replaced, because a CSS animation whose effect script replaces leaves the
|
|
39
|
+
* stylesheet's control; its state is copied onto the new effect instead.
|
|
40
|
+
*/
|
|
41
|
+
const ORDERED = new Set([
|
|
42
|
+
'effect',
|
|
43
|
+
'timeline',
|
|
44
|
+
'rangeStart',
|
|
45
|
+
'rangeEnd',
|
|
46
|
+
'playbackRate',
|
|
47
|
+
'startTime',
|
|
48
|
+
'currentTime',
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
type Writable = Record<string, unknown>;
|
|
52
|
+
|
|
53
|
+
/** Every accessor with a setter on `object`'s prototype chain. */
|
|
54
|
+
function writableAccessors(object: object): string[] {
|
|
55
|
+
const names = new Set<string>();
|
|
56
|
+
for (
|
|
57
|
+
let proto: object | null = Object.getPrototypeOf(object);
|
|
58
|
+
proto != null && proto !== Object.prototype;
|
|
59
|
+
proto = Object.getPrototypeOf(proto)
|
|
60
|
+
) {
|
|
61
|
+
for (const [name, descriptor] of Object.entries(
|
|
62
|
+
Object.getOwnPropertyDescriptors(proto),
|
|
63
|
+
)) {
|
|
64
|
+
if (descriptor.set != null) {
|
|
65
|
+
names.add(name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return [...names];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A textual form of a value that is compared by content rather than by
|
|
74
|
+
* identity: a CSS numeric value (as in a timeline range offset) through its
|
|
75
|
+
* serialization, a plain object (a range) through its members. Anything else
|
|
76
|
+
* is compared by identity (`null`).
|
|
77
|
+
*/
|
|
78
|
+
function contentOf(value: unknown): string | null {
|
|
79
|
+
if (
|
|
80
|
+
typeof CSSNumericValue !== 'undefined' &&
|
|
81
|
+
value instanceof CSSNumericValue
|
|
82
|
+
) {
|
|
83
|
+
return value.toString();
|
|
84
|
+
}
|
|
85
|
+
if (
|
|
86
|
+
value != null &&
|
|
87
|
+
typeof value === 'object' &&
|
|
88
|
+
Object.getPrototypeOf(value) === Object.prototype
|
|
89
|
+
) {
|
|
90
|
+
return Object.entries(value)
|
|
91
|
+
.map(([key, inner]) => `${key}:${contentOf(inner) ?? String(inner)}`)
|
|
92
|
+
.join(';');
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function differs(a: unknown, b: unknown): boolean {
|
|
98
|
+
if (a === b) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const textA = contentOf(a);
|
|
102
|
+
return textA == null || textA !== contentOf(b);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface Saved {
|
|
106
|
+
animation: Animation;
|
|
107
|
+
name: string;
|
|
108
|
+
target: Element | null;
|
|
109
|
+
pseudoElement: string | null;
|
|
110
|
+
values: Writable;
|
|
111
|
+
effectValues: Writable;
|
|
112
|
+
timing: EffectTiming | null;
|
|
113
|
+
keyframes: ComputedKeyframe[] | null;
|
|
114
|
+
playState: AnimationPlayState;
|
|
115
|
+
replaceState: AnimationReplaceState;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function save(animation: Animation): Saved {
|
|
119
|
+
const effect = animation.effect as KeyframeEffect | null;
|
|
120
|
+
const values: Writable = {};
|
|
121
|
+
for (const name of writableAccessors(animation)) {
|
|
122
|
+
values[name] = (animation as unknown as Writable)[name];
|
|
123
|
+
}
|
|
124
|
+
const effectValues: Writable = {};
|
|
125
|
+
if (effect != null) {
|
|
126
|
+
for (const name of writableAccessors(effect)) {
|
|
127
|
+
effectValues[name] = (effect as unknown as Writable)[name];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
animation,
|
|
132
|
+
name:
|
|
133
|
+
(animation as Animation & {animationName?: string}).animationName ?? '',
|
|
134
|
+
target: effect?.target ?? null,
|
|
135
|
+
pseudoElement: effect?.pseudoElement ?? null,
|
|
136
|
+
values,
|
|
137
|
+
effectValues,
|
|
138
|
+
timing: effect?.getTiming() ?? null,
|
|
139
|
+
keyframes: effect?.getKeyframes() ?? null,
|
|
140
|
+
playState: animation.playState,
|
|
141
|
+
replaceState: animation.replaceState,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function write(object: object, name: string, value: unknown): void {
|
|
146
|
+
(object as Writable)[name] = value;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Give `next` the effect state `saved` had: every writable member. */
|
|
150
|
+
function restoreEffect(next: KeyframeEffect, saved: Saved): void {
|
|
151
|
+
for (const name of writableAccessors(next)) {
|
|
152
|
+
if (
|
|
153
|
+
name in saved.effectValues &&
|
|
154
|
+
differs(saved.effectValues[name], (next as unknown as Writable)[name])
|
|
155
|
+
) {
|
|
156
|
+
write(next, name, saved.effectValues[name]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (saved.timing != null) {
|
|
160
|
+
const timing = next.getTiming() as unknown as Writable;
|
|
161
|
+
const changed: Writable = {};
|
|
162
|
+
for (const [field, value] of Object.entries(saved.timing)) {
|
|
163
|
+
if (differs(value, timing[field])) {
|
|
164
|
+
changed[field] = value;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (Object.keys(changed).length > 0) {
|
|
168
|
+
next.updateTiming(changed);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (
|
|
172
|
+
saved.keyframes != null &&
|
|
173
|
+
JSON.stringify(saved.keyframes) !== JSON.stringify(next.getKeyframes())
|
|
174
|
+
) {
|
|
175
|
+
next.setKeyframes(saved.keyframes);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Give `next` the state `saved` had, member by member. */
|
|
180
|
+
function restore(next: Animation, saved: Saved): void {
|
|
181
|
+
const effect = next.effect as KeyframeEffect | null;
|
|
182
|
+
if (effect != null) {
|
|
183
|
+
restoreEffect(effect, saved);
|
|
184
|
+
}
|
|
185
|
+
const current = next as unknown as Writable;
|
|
186
|
+
for (const name of ['timeline', 'rangeStart', 'rangeEnd']) {
|
|
187
|
+
if (name in saved.values && differs(saved.values[name], current[name])) {
|
|
188
|
+
write(next, name, saved.values[name]);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
for (const name of writableAccessors(next)) {
|
|
192
|
+
if (
|
|
193
|
+
!ORDERED.has(name) &&
|
|
194
|
+
name in saved.values &&
|
|
195
|
+
differs(saved.values[name], current[name])
|
|
196
|
+
) {
|
|
197
|
+
write(next, name, saved.values[name]);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (saved.replaceState === 'persisted' && next.replaceState !== 'persisted') {
|
|
201
|
+
next.persist();
|
|
202
|
+
}
|
|
203
|
+
const rate = saved.values.playbackRate;
|
|
204
|
+
if (typeof rate === 'number' && rate !== next.playbackRate) {
|
|
205
|
+
next.playbackRate = rate;
|
|
206
|
+
}
|
|
207
|
+
if (saved.playState === 'paused' && next.playState !== 'paused') {
|
|
208
|
+
next.pause();
|
|
209
|
+
} else if (saved.playState !== 'paused' && next.playState === 'paused') {
|
|
210
|
+
next.play();
|
|
211
|
+
}
|
|
212
|
+
// A running animation is anchored to its timeline by its start time, which
|
|
213
|
+
// carries its current time on exactly. A paused one has none and keeps its
|
|
214
|
+
// current time. A finished one holds its end: finishing it again holds the
|
|
215
|
+
// same time, though its start time is then counted from now, since script
|
|
216
|
+
// cannot set a start time and a held time together.
|
|
217
|
+
const start = saved.values.startTime as CSSNumberish | null | undefined;
|
|
218
|
+
const time = saved.values.currentTime as CSSNumberish | null | undefined;
|
|
219
|
+
if (saved.playState === 'finished') {
|
|
220
|
+
next.finish();
|
|
221
|
+
} else if (start != null) {
|
|
222
|
+
next.startTime = start;
|
|
223
|
+
} else if (time != null) {
|
|
224
|
+
next.currentTime = time;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Resume a cancelled CSS transition with a script animation in its state. */
|
|
229
|
+
function resumeTransition(saved: Saved): void {
|
|
230
|
+
if (saved.target == null || saved.keyframes == null) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const replacement = saved.target.animate(saved.keyframes, {
|
|
234
|
+
pseudoElement: saved.pseudoElement ?? undefined,
|
|
235
|
+
});
|
|
236
|
+
restore(replacement, saved);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function isTransition(animation: Animation): boolean {
|
|
240
|
+
return (
|
|
241
|
+
typeof CSSTransition !== 'undefined' && animation instanceof CSSTransition
|
|
242
|
+
);
|
|
243
|
+
}
|
|
26
244
|
|
|
27
245
|
/**
|
|
28
246
|
* Run `reset`, which takes `root` out of rendering and back, and put every
|
|
29
247
|
* CSS animation and transition of `root` and its subtree back in the state it
|
|
30
|
-
* was in before.
|
|
248
|
+
* was in before. Recreated animations are matched to the ones they replace by
|
|
249
|
+
* element, pseudo-element and name, in order, and then by name alone (an
|
|
250
|
+
* effect script moved to another element or pseudo-element); a recreated
|
|
251
|
+
* animation with no predecessor (an entry animation that had already played
|
|
252
|
+
* and been dropped) is finished.
|
|
31
253
|
*/
|
|
32
254
|
export function preserveAnimations(root: Element, reset: () => void): void {
|
|
33
255
|
if (typeof root.getAnimations !== 'function') {
|
|
@@ -35,7 +257,48 @@ export function preserveAnimations(root: Element, reset: () => void): void {
|
|
|
35
257
|
return;
|
|
36
258
|
}
|
|
37
259
|
const before = root.getAnimations({subtree: true});
|
|
38
|
-
const saved = before.map(
|
|
260
|
+
const saved = before.map(save);
|
|
39
261
|
reset();
|
|
40
|
-
|
|
262
|
+
const after = root.getAnimations({subtree: true});
|
|
263
|
+
const current = new Set(after);
|
|
264
|
+
const survivors = new Set(before);
|
|
265
|
+
const cancelled: Saved[] = [];
|
|
266
|
+
for (const state of saved) {
|
|
267
|
+
if (current.has(state.animation)) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (isTransition(state.animation)) {
|
|
271
|
+
resumeTransition(state);
|
|
272
|
+
} else {
|
|
273
|
+
cancelled.push(state);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const recreated = after.filter(animation => !survivors.has(animation));
|
|
277
|
+
const unmatched: Animation[] = [];
|
|
278
|
+
for (const animation of recreated) {
|
|
279
|
+
const effect = animation.effect as KeyframeEffect | null;
|
|
280
|
+
const name =
|
|
281
|
+
(animation as Animation & {animationName?: string}).animationName ?? '';
|
|
282
|
+
const index = cancelled.findIndex(
|
|
283
|
+
state =>
|
|
284
|
+
state.name === name &&
|
|
285
|
+
state.target === (effect?.target ?? null) &&
|
|
286
|
+
state.pseudoElement === (effect?.pseudoElement ?? null),
|
|
287
|
+
);
|
|
288
|
+
if (index === -1) {
|
|
289
|
+
unmatched.push(animation);
|
|
290
|
+
} else {
|
|
291
|
+
restore(animation, cancelled.splice(index, 1)[0]);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
for (const animation of unmatched) {
|
|
295
|
+
const name =
|
|
296
|
+
(animation as Animation & {animationName?: string}).animationName ?? '';
|
|
297
|
+
const index = cancelled.findIndex(state => state.name === name);
|
|
298
|
+
if (index === -1) {
|
|
299
|
+
animation.finish();
|
|
300
|
+
} else {
|
|
301
|
+
restore(animation, cancelled.splice(index, 1)[0]);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
41
304
|
}
|
|
@@ -104,7 +104,8 @@ export const docs = {
|
|
|
104
104
|
{
|
|
105
105
|
name: 'presentation',
|
|
106
106
|
type: "'popover' | 'bottom-sheet' | 'adaptive'",
|
|
107
|
-
description: 'Presentation policy forwarded to DropdownMenu. `adaptive` keeps the anchored popover on pointer-based layouts and uses a BottomSheet on a compact touch screen: a coarse primary pointer, and a viewport narrower than the theme `md` breakpoint (768px by default) or shorter than 500px.
|
|
107
|
+
description: 'Presentation policy forwarded to DropdownMenu. `adaptive` keeps the anchored popover on pointer-based layouts and uses a BottomSheet on a compact touch screen: a coarse primary pointer, and a viewport narrower than the theme `md` breakpoint (768px by default) or shorter than 500px.',
|
|
108
|
+
default: "'popover'",
|
|
108
109
|
},
|
|
109
110
|
{
|
|
110
111
|
name: 'onOpenChange',
|
|
@@ -203,7 +204,8 @@ export const docsZh = {
|
|
|
203
204
|
{
|
|
204
205
|
name: 'presentation',
|
|
205
206
|
type: "'popover' | 'bottom-sheet' | 'adaptive'",
|
|
206
|
-
description: '菜单呈现策略。`adaptive` 在指针布局中使用锚定浮层,在主指针为粗略指针且视口宽度小于主题的 `md` 断点(默认 768px)或高度小于 500px 时使用 BottomSheet
|
|
207
|
+
description: '菜单呈现策略。`adaptive` 在指针布局中使用锚定浮层,在主指针为粗略指针且视口宽度小于主题的 `md` 断点(默认 768px)或高度小于 500px 时使用 BottomSheet。',
|
|
208
|
+
default: "'popover'",
|
|
207
209
|
},
|
|
208
210
|
{
|
|
209
211
|
name: 'xstyle',
|
|
@@ -97,11 +97,9 @@ export interface MoreMenuProps extends Pick<
|
|
|
97
97
|
alignment?: LayerAlignment;
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
* Menu presentation policy
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* opened it follows UIMenu's handoff on every device. `'popover'` pins the
|
|
104
|
-
* pointer behavior on every device.
|
|
100
|
+
* Menu presentation policy. `adaptive` uses a BottomSheet on compact
|
|
101
|
+
* coarse-pointer viewports and an anchored popover elsewhere.
|
|
102
|
+
* @default 'popover'
|
|
105
103
|
*/
|
|
106
104
|
presentation?: DropdownMenuPresentation;
|
|
107
105
|
|
|
@@ -44,7 +44,6 @@ import type {StyleXStyles} from '@stylexjs/stylex';
|
|
|
44
44
|
import {colorVars, durationVars, easeVars} from '../theme/tokens.stylex';
|
|
45
45
|
import type {Elevation, SizeValue, SpacingStep} from '../utils/types';
|
|
46
46
|
import {isImeKeyEvent, mergeProps} from '../utils';
|
|
47
|
-
import {chainEventHandlers} from '../utils/chainEventHandlers';
|
|
48
47
|
import {Card} from '../Card/Card';
|
|
49
48
|
import type {CardVariant} from '../Card/Card';
|
|
50
49
|
import {useClickableContainer} from '../hooks/useClickableContainer';
|
|
@@ -399,7 +398,6 @@ export function SelectableCard({
|
|
|
399
398
|
onChange,
|
|
400
399
|
onClick: onClickProp,
|
|
401
400
|
onMouseUp: onMouseUpProp,
|
|
402
|
-
onPointerDown: onPointerDownProp,
|
|
403
401
|
isDisabled = false,
|
|
404
402
|
children,
|
|
405
403
|
padding,
|
|
@@ -460,7 +458,7 @@ export function SelectableCard({
|
|
|
460
458
|
[isDisabled, requestChange],
|
|
461
459
|
);
|
|
462
460
|
|
|
463
|
-
const {onClick, onMouseUp
|
|
461
|
+
const {onClick, onMouseUp} = useClickableContainer({
|
|
464
462
|
containerRef,
|
|
465
463
|
interactiveRef,
|
|
466
464
|
onClick: handleClick,
|
|
@@ -532,11 +530,6 @@ export function SelectableCard({
|
|
|
532
530
|
}
|
|
533
531
|
onClick={!isDisabled ? composedOnClick : undefined}
|
|
534
532
|
onMouseUp={!isDisabled ? composedOnMouseUp : undefined}
|
|
535
|
-
onPointerDown={
|
|
536
|
-
!isDisabled
|
|
537
|
-
? chainEventHandlers(onPointerDown, onPointerDownProp)
|
|
538
|
-
: onPointerDownProp
|
|
539
|
-
}
|
|
540
533
|
{...props}
|
|
541
534
|
onClickCapture={
|
|
542
535
|
!isDisabled && handleLayerClickCapture
|
|
@@ -480,12 +480,11 @@ export function TreeListItem({
|
|
|
480
480
|
// a plain element and both hook instances stay inert on it.
|
|
481
481
|
const forwardsToLink = href != null && handleClick == null;
|
|
482
482
|
const linkRowRef = useRef<HTMLDivElement>(null);
|
|
483
|
-
const {onClick: delegateToLink
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
});
|
|
483
|
+
const {onClick: delegateToLink} = useClickableContainer({
|
|
484
|
+
containerRef: linkRowRef,
|
|
485
|
+
interactiveRef: linkRef,
|
|
486
|
+
disabled: isDisabled || !forwardsToLink,
|
|
487
|
+
});
|
|
489
488
|
const {onMouseUp: openLinkOnMiddleClick} = useClickableContainer({
|
|
490
489
|
containerRef: linkRowRef,
|
|
491
490
|
href,
|
|
@@ -733,8 +732,7 @@ export function TreeListItem({
|
|
|
733
732
|
)}
|
|
734
733
|
ref={forwardsToLink ? linkRowRef : undefined}
|
|
735
734
|
onClick={forwardsToLink ? delegateToLink : handleClick}
|
|
736
|
-
onMouseUp={forwardsToLink ? openLinkOnMiddleClick : undefined}
|
|
737
|
-
onPointerDown={forwardsToLink ? pressOnLinkRow : undefined}>
|
|
735
|
+
onMouseUp={forwardsToLink ? openLinkOnMiddleClick : undefined}>
|
|
738
736
|
<div {...stylex.props(styles.indentedContent)}>{innerContent}</div>
|
|
739
737
|
</div>
|
|
740
738
|
</div>
|