@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
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file carryAnimations.ts
|
|
5
|
-
* @input The CSS animations and transitions of an element and its subtree,
|
|
6
|
-
* read before the browser starts them afresh
|
|
7
|
-
* @output Exports `saveAnimations` and `carryAnimations`, which carry them on
|
|
8
|
-
* in a clone of the element. Also `saveAnimation` and `restoreAnimations`,
|
|
9
|
-
* which put them back after a display reset
|
|
10
|
-
* @position Motion foundation; the transient copy (transientCopy.ts) and the
|
|
11
|
-
* layer runtime's re-placement (Layer/preserveAnimations.ts) use it
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Animation members written in a fixed order rather than generically: the
|
|
16
|
-
* timeline before the range that is measured on it, the rate before the
|
|
17
|
-
* time, and the start time (or, for a paused animation, the current time)
|
|
18
|
-
* last, once the play state is set. `effect` is not
|
|
19
|
-
* replaced, because a CSS animation whose effect script replaces leaves the
|
|
20
|
-
* stylesheet's control; its state is copied onto the new effect instead.
|
|
21
|
-
*/
|
|
22
|
-
const ORDERED = new Set(['effect', 'timeline', 'rangeStart', 'rangeEnd', 'playbackRate', 'startTime', 'currentTime']);
|
|
23
|
-
/** Every accessor with a setter on `object`'s prototype chain. */
|
|
24
|
-
function writableAccessors(object) {
|
|
25
|
-
const names = new Set();
|
|
26
|
-
for (let proto = Object.getPrototypeOf(object); proto != null && proto !== Object.prototype; proto = Object.getPrototypeOf(proto)) {
|
|
27
|
-
for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(proto))) {
|
|
28
|
-
if (descriptor.set != null) {
|
|
29
|
-
names.add(name);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return [...names];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* A textual form of a value that is compared by content rather than by
|
|
38
|
-
* identity: a CSS numeric value (as in a timeline range offset) through its
|
|
39
|
-
* serialization, a plain object (a range) through its members. Anything else
|
|
40
|
-
* is compared by identity (`null`).
|
|
41
|
-
*/
|
|
42
|
-
function contentOf(value) {
|
|
43
|
-
if (typeof CSSNumericValue !== 'undefined' && value instanceof CSSNumericValue) {
|
|
44
|
-
return value.toString();
|
|
45
|
-
}
|
|
46
|
-
if (value != null && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {
|
|
47
|
-
return Object.entries(value).map(([key, inner]) => `${key}:${contentOf(inner) ?? String(inner)}`).join(';');
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
function differs(a, b) {
|
|
52
|
-
if (a === b) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
const textA = contentOf(a);
|
|
56
|
-
return textA == null || textA !== contentOf(b);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** One animation's state, read before the browser starts it afresh. */
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Reads one animation's state generically, from what the platform exposes.
|
|
63
|
-
* That is every accessor with a setter on the animation's and its effect's
|
|
64
|
-
* prototype chains, every field of the effect's timing, and its keyframes. Only values
|
|
65
|
-
* that differ from the recreated animation's are written back, so a value the
|
|
66
|
-
* stylesheet controls stays under its control. A few members are not plain
|
|
67
|
-
* state and are written in their own step (`ORDERED`). The Animation and
|
|
68
|
-
* effect objects themselves cannot be carried over: the old ones keep their
|
|
69
|
-
* listeners and promises.
|
|
70
|
-
*/
|
|
71
|
-
export function saveAnimation(animation) {
|
|
72
|
-
const effect = animation.effect;
|
|
73
|
-
const values = {};
|
|
74
|
-
for (const name of writableAccessors(animation)) {
|
|
75
|
-
values[name] = animation[name];
|
|
76
|
-
}
|
|
77
|
-
const effectValues = {};
|
|
78
|
-
if (effect != null) {
|
|
79
|
-
for (const name of writableAccessors(effect)) {
|
|
80
|
-
effectValues[name] = effect[name];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
animation,
|
|
85
|
-
name: animation.animationName ?? '',
|
|
86
|
-
target: effect?.target ?? null,
|
|
87
|
-
pseudoElement: effect?.pseudoElement ?? null,
|
|
88
|
-
values,
|
|
89
|
-
effectValues,
|
|
90
|
-
timing: effect?.getTiming() ?? null,
|
|
91
|
-
keyframes: effect?.getKeyframes() ?? null,
|
|
92
|
-
playState: animation.playState,
|
|
93
|
-
replaceState: animation.replaceState
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function write(object, name, value) {
|
|
97
|
-
object[name] = value;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** Give `next` the effect state `saved` had: every writable member. */
|
|
101
|
-
function restoreEffect(next, saved) {
|
|
102
|
-
for (const name of writableAccessors(next)) {
|
|
103
|
-
if (name in saved.effectValues && differs(saved.effectValues[name], next[name])) {
|
|
104
|
-
write(next, name, saved.effectValues[name]);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (saved.timing != null) {
|
|
108
|
-
const timing = next.getTiming();
|
|
109
|
-
const changed = {};
|
|
110
|
-
for (const [field, value] of Object.entries(saved.timing)) {
|
|
111
|
-
if (differs(value, timing[field])) {
|
|
112
|
-
changed[field] = value;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (Object.keys(changed).length > 0) {
|
|
116
|
-
next.updateTiming(changed);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (saved.keyframes != null && JSON.stringify(saved.keyframes) !== JSON.stringify(next.getKeyframes())) {
|
|
120
|
-
next.setKeyframes(saved.keyframes);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** Give `next` the state `saved` had, member by member. */
|
|
125
|
-
function restore(next, saved) {
|
|
126
|
-
const effect = next.effect;
|
|
127
|
-
if (effect != null) {
|
|
128
|
-
restoreEffect(effect, saved);
|
|
129
|
-
}
|
|
130
|
-
const current = next;
|
|
131
|
-
for (const name of ['timeline', 'rangeStart', 'rangeEnd']) {
|
|
132
|
-
if (name in saved.values && differs(saved.values[name], current[name])) {
|
|
133
|
-
write(next, name, saved.values[name]);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
for (const name of writableAccessors(next)) {
|
|
137
|
-
if (!ORDERED.has(name) && name in saved.values && differs(saved.values[name], current[name])) {
|
|
138
|
-
write(next, name, saved.values[name]);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (saved.replaceState === 'persisted' && next.replaceState !== 'persisted') {
|
|
142
|
-
next.persist();
|
|
143
|
-
}
|
|
144
|
-
const rate = saved.values.playbackRate;
|
|
145
|
-
if (typeof rate === 'number' && rate !== next.playbackRate) {
|
|
146
|
-
next.playbackRate = rate;
|
|
147
|
-
}
|
|
148
|
-
if (saved.playState === 'paused' && next.playState !== 'paused') {
|
|
149
|
-
next.pause();
|
|
150
|
-
} else if (saved.playState !== 'paused' && next.playState === 'paused') {
|
|
151
|
-
next.play();
|
|
152
|
-
}
|
|
153
|
-
// A running animation is anchored to its timeline by its start time, which
|
|
154
|
-
// carries its current time on exactly. A paused one has none and keeps its
|
|
155
|
-
// current time. A finished one holds its end: finishing it again holds the
|
|
156
|
-
// same time, though its start time is then counted from now, since script
|
|
157
|
-
// cannot set a start time and a held time together.
|
|
158
|
-
const start = saved.values.startTime;
|
|
159
|
-
const time = saved.values.currentTime;
|
|
160
|
-
if (saved.playState === 'finished') {
|
|
161
|
-
next.finish();
|
|
162
|
-
} else if (start != null) {
|
|
163
|
-
next.startTime = start;
|
|
164
|
-
} else if (time != null) {
|
|
165
|
-
next.currentTime = time;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** Resume a cancelled CSS transition with a script animation in its state. */
|
|
170
|
-
function resumeTransition(saved) {
|
|
171
|
-
if (saved.target == null || saved.keyframes == null) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const replacement = saved.target.animate(saved.keyframes, {
|
|
175
|
-
pseudoElement: saved.pseudoElement ?? undefined
|
|
176
|
-
});
|
|
177
|
-
restore(replacement, saved);
|
|
178
|
-
}
|
|
179
|
-
function isTransition(animation) {
|
|
180
|
-
return typeof CSSTransition !== 'undefined' && animation instanceof CSSTransition;
|
|
181
|
-
}
|
|
182
|
-
function isCssAnimation(animation) {
|
|
183
|
-
return typeof CSSAnimation !== 'undefined' && animation instanceof CSSAnimation;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Finishes an animation that ends: an infinite one cannot be finished, and is
|
|
188
|
-
* left as it runs.
|
|
189
|
-
*/
|
|
190
|
-
function finishIfItEnds(animation) {
|
|
191
|
-
const end = animation.effect?.getComputedTiming().endTime;
|
|
192
|
-
if (end != null && Number.isFinite(Number(end)) && animation.playbackRate !== 0) {
|
|
193
|
-
animation.finish();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/** The members a copy's animation does not take: its element's keep them. */
|
|
198
|
-
const IDENTITY_MEMBERS = new Set(['id', 'onfinish', 'oncancel', 'onremove']);
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* `saved` for an animation that carries on on the copy of its element:
|
|
202
|
-
* aimed at the copy, without the element's id and event handlers.
|
|
203
|
-
*/
|
|
204
|
-
function retarget(saved, copyOf) {
|
|
205
|
-
const target = saved.target == null ? null : copyOf(saved.target);
|
|
206
|
-
if (target == null) {
|
|
207
|
-
return null;
|
|
208
|
-
}
|
|
209
|
-
const values = Object.fromEntries(Object.entries(saved.values).filter(([name]) => !IDENTITY_MEMBERS.has(name)));
|
|
210
|
-
const effectValues = {
|
|
211
|
-
...saved.effectValues
|
|
212
|
-
};
|
|
213
|
-
if ('target' in effectValues) {
|
|
214
|
-
effectValues.target = target;
|
|
215
|
-
}
|
|
216
|
-
return {
|
|
217
|
-
...saved,
|
|
218
|
-
target,
|
|
219
|
-
values,
|
|
220
|
-
effectValues
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Puts each state `saved` holds on the CSS animations and transitions of
|
|
226
|
-
* `root` and its subtree that are not among `survivors`. Each CSS animation
|
|
227
|
-
* the browser started afresh takes the state of the one it replaces. It is
|
|
228
|
-
* matched by element, pseudo-element and name, in order, and then by name
|
|
229
|
-
* alone (an effect script moved to another element or pseudo-element). Each
|
|
230
|
-
* transition whose animation no longer runs resumes as a script animation in
|
|
231
|
-
* its state. One started afresh that replaces none is finished: an entrance
|
|
232
|
-
* that had played and been dropped, or a transition from `@starting-style`.
|
|
233
|
-
* Script animations are left as they are.
|
|
234
|
-
*/
|
|
235
|
-
export function restoreAnimations(root, saved, survivors) {
|
|
236
|
-
const after = root.getAnimations({
|
|
237
|
-
subtree: true
|
|
238
|
-
});
|
|
239
|
-
const current = new Set(after);
|
|
240
|
-
const cancelled = [];
|
|
241
|
-
for (const state of saved) {
|
|
242
|
-
if (current.has(state.animation)) {
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
if (isTransition(state.animation)) {
|
|
246
|
-
resumeTransition(state);
|
|
247
|
-
} else {
|
|
248
|
-
cancelled.push(state);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
const recreated = after.filter(animation => (isCssAnimation(animation) || isTransition(animation)) && !survivors.has(animation));
|
|
252
|
-
const unmatched = [];
|
|
253
|
-
for (const animation of recreated) {
|
|
254
|
-
const effect = animation.effect;
|
|
255
|
-
const name = animation.animationName ?? '';
|
|
256
|
-
const index = cancelled.findIndex(state => state.name === name && state.target === (effect?.target ?? null) && state.pseudoElement === (effect?.pseudoElement ?? null));
|
|
257
|
-
if (index === -1) {
|
|
258
|
-
unmatched.push(animation);
|
|
259
|
-
} else {
|
|
260
|
-
restore(animation, cancelled.splice(index, 1)[0]);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
for (const animation of unmatched) {
|
|
264
|
-
const name = animation.animationName ?? '';
|
|
265
|
-
const index = cancelled.findIndex(state => state.name === name);
|
|
266
|
-
if (index === -1) {
|
|
267
|
-
finishIfItEnds(animation);
|
|
268
|
-
} else {
|
|
269
|
-
restore(animation, cancelled.splice(index, 1)[0]);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/** The CSS animations and transitions `saveAnimations` read. */
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Reads the state of every CSS animation and transition of `root` and its
|
|
278
|
-
* subtree, for `carryAnimations` to give a copy of it.
|
|
279
|
-
*/
|
|
280
|
-
export function saveAnimations(root) {
|
|
281
|
-
if (typeof root.getAnimations !== 'function') {
|
|
282
|
-
return [];
|
|
283
|
-
}
|
|
284
|
-
return root.getAnimations({
|
|
285
|
-
subtree: true
|
|
286
|
-
}).filter(animation => isCssAnimation(animation) || isTransition(animation)).map(saveAnimation);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Carries on in `copy`, a clone of the root `saved` was read from, now laid
|
|
291
|
-
* out, the CSS animations and transitions its element ran. A clone starts
|
|
292
|
-
* each CSS animation again and runs no transition but a `@starting-style`
|
|
293
|
-
* one. So each CSS animation the clone started takes the state of its
|
|
294
|
-
* element's, and each transition runs on as a script animation. One the
|
|
295
|
-
* clone started that its element no longer ran is finished: an entrance that
|
|
296
|
-
* had played, or a `@starting-style` transition. `copyOf` maps each element
|
|
297
|
-
* of the cloned subtree to its copy. The element's own animations keep
|
|
298
|
-
* running, so the copy's take no id or event handler.
|
|
299
|
-
*/
|
|
300
|
-
export function carryAnimations(saved, copy, copyOf) {
|
|
301
|
-
if (typeof copy.getAnimations !== 'function') {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
restoreAnimations(copy, saved.flatMap(state => retarget(state, copyOf) ?? []), new Set());
|
|
305
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file privateAttributes/menuPressLit.stylex.ts
|
|
3
|
-
* @input The row that a held finger or pen lights in a menu
|
|
4
|
-
* @output markMenuPressLit and clearMenuPressLit, which mark that row,
|
|
5
|
-
* isMenuPressLit, which reads the mark, menuPressLitRowStyle, which
|
|
6
|
-
* paints the marked row, holdMenuPressPaint and releaseMenuPressPaint,
|
|
7
|
-
* which keep the other rows off their pressed paint, and
|
|
8
|
-
* isMenuPressPaintHeld, which reads that hold
|
|
9
|
-
* @position Owner module of the private menu-press-lit attribute: the only
|
|
10
|
-
* file that writes its name. The menu press model (hooks/useMenuPress.ts)
|
|
11
|
-
* marks the row; DropdownMenu's rows compose the styles. No package entry
|
|
12
|
-
* exports it.
|
|
13
|
-
*
|
|
14
|
-
* SYNC: Each row that composes menuPressLitRowStyle reads
|
|
15
|
-
* `--_menu-row-focus-paint` in its `:focus` background, and a row with an
|
|
16
|
-
* `:active` background reads `--_menu-row-active-paint` there:
|
|
17
|
-
* - /packages/core/src/DropdownMenu/DropdownMenuItem.tsx
|
|
18
|
-
* - /packages/core/src/DropdownMenu/DropdownMenuCheckboxItem.tsx
|
|
19
|
-
* - /packages/core/src/DropdownMenu/DropdownMenuRadioItem.tsx
|
|
20
|
-
* - /packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx
|
|
21
|
-
*/
|
|
22
|
-
import type { StyleXStyles } from '@stylexjs/stylex';
|
|
23
|
-
/** Marks `row` as the row that a held finger or pen lights. */
|
|
24
|
-
export declare function markMenuPressLit(row: Element): void;
|
|
25
|
-
/** Removes the mark from `row`. */
|
|
26
|
-
export declare function clearMenuPressLit(row: Element): void;
|
|
27
|
-
/** Whether a held finger or pen lights `row`. */
|
|
28
|
-
export declare function isMenuPressLit(row: Element): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Keeps `menu`'s rows off their `:active` paint while a held finger or pen
|
|
31
|
-
* presses in it. The row the press began on stays `:active` as the press
|
|
32
|
-
* moves on. The lit row keeps the pressed overlay through its own mark.
|
|
33
|
-
*/
|
|
34
|
-
export declare function holdMenuPressPaint(menu: HTMLElement): void;
|
|
35
|
-
/** Gives `menu`'s rows their `:active` paint back. */
|
|
36
|
-
export declare function releaseMenuPressPaint(menu: HTMLElement): void;
|
|
37
|
-
/** Whether a held finger or pen keeps `menu`'s rows off their `:active` paint. */
|
|
38
|
-
export declare function isMenuPressPaintHeld(menu: HTMLElement): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Compose on a menu row whose `:focus` background is
|
|
41
|
-
* `var(--_menu-row-focus-paint, <hover overlay>)`, and whose `:active`
|
|
42
|
-
* background, if any, is `var(--_menu-row-active-paint, <pressed overlay>)`.
|
|
43
|
-
* The row paints the hover overlay on focus, and the pressed overlay while a
|
|
44
|
-
* held finger or pen lights it.
|
|
45
|
-
* Under a finger, the hover overlay is too faint to follow. The variable has
|
|
46
|
-
* no default: a layered stylesheet emits a default unlayered, and it would
|
|
47
|
-
* beat the attribute arm. The value resolves on the row, so a theme set on any
|
|
48
|
-
* ancestor applies. The style sets only a custom property, which shares no
|
|
49
|
-
* key with StyleX's CSS property type, so TypeScript needs the wider type.
|
|
50
|
-
*/
|
|
51
|
-
export declare const menuPressLitRowStyle: StyleXStyles;
|
|
52
|
-
//# sourceMappingURL=menuPressLit.stylex.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"menuPressLit.stylex.d.ts","sourceRoot":"","sources":["../../src/privateAttributes/menuPressLit.stylex.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAMnD,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAEnD;AAED,mCAAmC;AACnC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAEpD;AAED,iDAAiD;AACjD,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAE1D;AAED,sDAAsD;AACtD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAE7D;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAE/D;AA6BD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,EAAiB,YAAY,CAAC"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
/**
|
|
3
|
-
* @file privateAttributes/menuPressLit.stylex.ts
|
|
4
|
-
* @input The row that a held finger or pen lights in a menu
|
|
5
|
-
* @output markMenuPressLit and clearMenuPressLit, which mark that row,
|
|
6
|
-
* isMenuPressLit, which reads the mark, menuPressLitRowStyle, which
|
|
7
|
-
* paints the marked row, holdMenuPressPaint and releaseMenuPressPaint,
|
|
8
|
-
* which keep the other rows off their pressed paint, and
|
|
9
|
-
* isMenuPressPaintHeld, which reads that hold
|
|
10
|
-
* @position Owner module of the private menu-press-lit attribute: the only
|
|
11
|
-
* file that writes its name. The menu press model (hooks/useMenuPress.ts)
|
|
12
|
-
* marks the row; DropdownMenu's rows compose the styles. No package entry
|
|
13
|
-
* exports it.
|
|
14
|
-
*
|
|
15
|
-
* SYNC: Each row that composes menuPressLitRowStyle reads
|
|
16
|
-
* `--_menu-row-focus-paint` in its `:focus` background, and a row with an
|
|
17
|
-
* `:active` background reads `--_menu-row-active-paint` there:
|
|
18
|
-
* - /packages/core/src/DropdownMenu/DropdownMenuItem.tsx
|
|
19
|
-
* - /packages/core/src/DropdownMenu/DropdownMenuCheckboxItem.tsx
|
|
20
|
-
* - /packages/core/src/DropdownMenu/DropdownMenuRadioItem.tsx
|
|
21
|
-
* - /packages/core/src/DropdownMenu/DropdownMenuSubMenu.tsx
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import * as stylex from '@stylexjs/stylex';
|
|
25
|
-
import "../theme/tokens.stylex.js";
|
|
26
|
-
import { colorVars } from "../theme/tokens.stylex.js";
|
|
27
|
-
const MENU_PRESS_LIT = 'data-astryx-menu-press-lit';
|
|
28
|
-
const ACTIVE_PAINT = '--_menu-row-active-paint';
|
|
29
|
-
|
|
30
|
-
/** Marks `row` as the row that a held finger or pen lights. */
|
|
31
|
-
export function markMenuPressLit(row) {
|
|
32
|
-
row.setAttribute(MENU_PRESS_LIT, '');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Removes the mark from `row`. */
|
|
36
|
-
export function clearMenuPressLit(row) {
|
|
37
|
-
row.removeAttribute(MENU_PRESS_LIT);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Whether a held finger or pen lights `row`. */
|
|
41
|
-
export function isMenuPressLit(row) {
|
|
42
|
-
return row.hasAttribute(MENU_PRESS_LIT);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Keeps `menu`'s rows off their `:active` paint while a held finger or pen
|
|
47
|
-
* presses in it. The row the press began on stays `:active` as the press
|
|
48
|
-
* moves on. The lit row keeps the pressed overlay through its own mark.
|
|
49
|
-
*/
|
|
50
|
-
export function holdMenuPressPaint(menu) {
|
|
51
|
-
menu.style.setProperty(ACTIVE_PAINT, 'transparent');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Gives `menu`'s rows their `:active` paint back. */
|
|
55
|
-
export function releaseMenuPressPaint(menu) {
|
|
56
|
-
menu.style.removeProperty(ACTIVE_PAINT);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Whether a held finger or pen keeps `menu`'s rows off their `:active` paint. */
|
|
60
|
-
export function isMenuPressPaintHeld(menu) {
|
|
61
|
-
return menu.style.getPropertyValue(ACTIVE_PAINT) !== '';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* A value for each attribute state. The index signature gives StyleX the value
|
|
66
|
-
* type, which it cannot read from a literal attribute key.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
const litRowPaint = {
|
|
70
|
-
'--_menu-row-focus-paint': {
|
|
71
|
-
default: null,
|
|
72
|
-
'[data-astryx-menu-press-lit]': colorVars['--color-overlay-pressed']
|
|
73
|
-
},
|
|
74
|
-
'--_menu-row-active-paint': {
|
|
75
|
-
default: null,
|
|
76
|
-
'[data-astryx-menu-press-lit]': colorVars['--color-overlay-pressed']
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const styles = {
|
|
80
|
-
row: {
|
|
81
|
-
"--_menu-row-focus-paint": "x1ar3rj9",
|
|
82
|
-
"--_menu-row-active-paint": "xcukuoe",
|
|
83
|
-
$$css: true
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Compose on a menu row whose `:focus` background is
|
|
89
|
-
* `var(--_menu-row-focus-paint, <hover overlay>)`, and whose `:active`
|
|
90
|
-
* background, if any, is `var(--_menu-row-active-paint, <pressed overlay>)`.
|
|
91
|
-
* The row paints the hover overlay on focus, and the pressed overlay while a
|
|
92
|
-
* held finger or pen lights it.
|
|
93
|
-
* Under a finger, the hover overlay is too faint to follow. The variable has
|
|
94
|
-
* no default: a layered stylesheet emits a default unlayered, and it would
|
|
95
|
-
* beat the attribute arm. The value resolves on the row, so a theme set on any
|
|
96
|
-
* ancestor applies. The style sets only a custom property, which shares no
|
|
97
|
-
* key with StyleX's CSS property type, so TypeScript needs the wider type.
|
|
98
|
-
*/
|
|
99
|
-
export const menuPressLitRowStyle = styles.row;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file menuPressValues.ts
|
|
5
|
-
* @input None
|
|
6
|
-
* @output The UIKit value the menu press model reads
|
|
7
|
-
* @position A copy of one UIKit table entry, motion/uikit gestures.ts
|
|
8
|
-
* `UIKIT_MENU_PRESS.handoff`. A menu then bundles this number, not the
|
|
9
|
-
* table with its measurement records. The table stays the source and
|
|
10
|
-
* documents the measurement. menuPressValues.test.ts fails when the copy
|
|
11
|
-
* drifts.
|
|
12
|
-
*
|
|
13
|
-
* SYNC: When modified, update:
|
|
14
|
-
* - /packages/core/src/motion/uikit/gestures.ts
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/** How far the opening finger travels after the menu opens before it picks. */
|
|
18
|
-
export const MENU_PRESS_HANDOFF_PX = 10;
|