@astryxdesign/core 0.7.2-canary.f16dc9f → 0.7.2-canary.fc12a18
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/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +10 -2
- package/dist/Markdown/plugins/frontmatter.d.ts.map +1 -1
- package/dist/Markdown/plugins/frontmatter.js +7 -3
- package/dist/Text/useTruncation.d.ts +7 -5
- package/dist/Text/useTruncation.d.ts.map +1 -1
- package/dist/Text/useTruncation.js +16 -5
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +83 -1
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +83 -1
- package/dist/utils/sharedMutationObserver.d.ts +21 -0
- package/dist/utils/sharedMutationObserver.d.ts.map +1 -0
- package/dist/utils/sharedMutationObserver.js +69 -0
- package/locales/en.json +328 -0
- package/locales/pseudo.json +246 -0
- package/package.json +3 -3
- package/src/HoverCard/HoverCard.test.tsx +58 -0
- package/src/HoverCard/useHoverCard.tsx +10 -2
- package/src/Markdown/plugins/frontmatter.test.tsx +25 -0
- package/src/Markdown/plugins/frontmatter.ts +7 -3
- package/src/Text/useTruncation.test.tsx +69 -0
- package/src/Text/useTruncation.ts +16 -5
- package/src/i18n/generated-locales/en.generated.ts +89 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +89 -0
- package/src/utils/sharedMutationObserver.test.ts +53 -0
- package/src/utils/sharedMutationObserver.ts +78 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHoverCard.d.ts","sourceRoot":"","sources":["../../src/HoverCard/useHoverCard.tsx"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAA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[clearTimeouts, hideLayer]);
|
|
148
|
+
|
|
149
|
+
// The imperative hide. A card closed while the pointer rests on it unmounts
|
|
150
|
+
// without a mouseleave, so the content-hover latch is cleared here; left set,
|
|
151
|
+
// it would keep the trigger's next hover-open from closing on leave.
|
|
152
|
+
const hide = useCallback(() => {
|
|
153
|
+
isHoveringContentRef.current = false;
|
|
154
|
+
hideLayer();
|
|
155
|
+
}, [hideLayer]);
|
|
148
156
|
const {
|
|
149
157
|
isTouchPointerRef,
|
|
150
158
|
isTouchInteraction,
|
|
@@ -291,7 +299,7 @@ export function useHoverCard(options = {}) {
|
|
|
291
299
|
// clear it.
|
|
292
300
|
const card = typeof document === 'undefined' ? null : document.getElementById(layerId);
|
|
293
301
|
const hadFocus = card?.contains(document.activeElement) ?? false;
|
|
294
|
-
|
|
302
|
+
hide();
|
|
295
303
|
if (hadFocus) {
|
|
296
304
|
isEscapeDismissingRef.current = true;
|
|
297
305
|
triggerRef.current?.focus();
|
|
@@ -448,6 +456,6 @@ export function useHoverCard(options = {}) {
|
|
|
448
456
|
isOpen: isLayerOpen,
|
|
449
457
|
renderHoverCard,
|
|
450
458
|
show: showLayer,
|
|
451
|
-
hide
|
|
459
|
+
hide
|
|
452
460
|
};
|
|
453
461
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../../src/Markdown/plugins/frontmatter.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAKL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EAEzB,MAAM,YAAY,CAAC;AAMpB,KAAK,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAO1D,MAAM,WAAW,0BAA0B,CACzC,QAAQ,SAAS,kBAAkB;IAEnC,4CAA4C;IAC5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AE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,QAAQ,CAAC;CACzD;AAED,MAAM,MAAM,8BAA8B,CACxC,QAAQ,SAAS,kBAAkB,IAEjC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GACzB;IAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAC,GAC1B;IACE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B,CAAC;AAEN,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,kBAAkB;IACtE,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC5C,KAAK,CACH,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,GAChB,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAC5C,WAAW,CACT,QAAQ,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAC/C,QAAQ,GAAG,SAAS,CAAC;CACzB;AAsED,wBAAgB,yBAAyB,CAAC,QAAQ,SAAS,kBAAkB,EAC3E,OAAO,EAAE,0BAA0B,CAAC,QAAQ,CAAC,GAC5C,mBAAmB,CAAC,QAAQ,CAAC,CAoE/B"}
|
|
@@ -35,20 +35,24 @@ function readFrontmatter(source) {
|
|
|
35
35
|
status: 'defer'
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
const
|
|
38
|
+
const entries = new Map();
|
|
39
39
|
for (const line of body.slice(0, close.index).split(/\r?\n/)) {
|
|
40
40
|
if (line.trim() === '') {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
43
|
const separator = line.indexOf(':');
|
|
44
44
|
const key = line.slice(0, separator).trim();
|
|
45
|
-
if (separator <= 0 || key === '' ||
|
|
45
|
+
if (separator <= 0 || key === '' || entries.has(key)) {
|
|
46
46
|
return {
|
|
47
47
|
status: 'none'
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
entries.set(key, line.slice(separator + 1).trim());
|
|
51
51
|
}
|
|
52
|
+
// A plain object, so a parser that returns the record unchanged passes the
|
|
53
|
+
// JSON-like metadata check. `fromEntries` defines every key as an own data
|
|
54
|
+
// property, so a field named `__proto__` stays a field.
|
|
55
|
+
const fields = Object.fromEntries(entries);
|
|
52
56
|
let end = openingLength + close.index + close[0].length;
|
|
53
57
|
if (source.startsWith('\r\n', end)) {
|
|
54
58
|
end += 2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file useTruncation.ts
|
|
3
|
-
* @input Uses React hooks, sharedResizeObserver
|
|
3
|
+
* @input Uses React hooks, sharedResizeObserver, sharedMutationObserver
|
|
4
4
|
* @output Exports useTruncation hook for detecting text overflow
|
|
5
5
|
* @position Hook; consumed by Text.tsx, Heading.tsx
|
|
6
6
|
*
|
|
@@ -32,10 +32,12 @@ export interface UseTruncationReturn {
|
|
|
32
32
|
/**
|
|
33
33
|
* Hook for detecting text overflow/truncation.
|
|
34
34
|
*
|
|
35
|
-
* Uses a shared ResizeObserver singleton (via observeResize)
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
35
|
+
* Uses a shared ResizeObserver singleton (via observeResize) for size
|
|
36
|
+
* changes and a shared MutationObserver singleton (via observeContent) for
|
|
37
|
+
* content changes, so even hundreds of table cells create one observer of
|
|
38
|
+
* each kind. Observing content matters because an element whose text changes
|
|
39
|
+
* without resizing (a fixed-width status line) must still be re-measured for
|
|
40
|
+
* the tooltip text and the truncated state to follow the current content.
|
|
39
41
|
*
|
|
40
42
|
* - Single-line: compares scrollWidth > offsetWidth
|
|
41
43
|
* - Multi-line: uses Range.getBoundingClientRect() to measure actual content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTruncation.d.ts","sourceRoot":"","sources":["../../src/Text/useTruncation.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAAgC,KAAK,WAAW,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useTruncation.d.ts","sourceRoot":"","sources":["../../src/Text/useTruncation.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAAgC,KAAK,WAAW,EAAC,MAAM,OAAO,CAAC;AAItE,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,GAAG,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAE9B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,oBAAoB,GAC5B,mBAAmB,CAmFrB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file useTruncation.ts
|
|
7
|
-
* @input Uses React hooks, sharedResizeObserver
|
|
7
|
+
* @input Uses React hooks, sharedResizeObserver, sharedMutationObserver
|
|
8
8
|
* @output Exports useTruncation hook for detecting text overflow
|
|
9
9
|
* @position Hook; consumed by Text.tsx, Heading.tsx
|
|
10
10
|
*
|
|
@@ -13,13 +13,16 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { useCallback, useRef, useState } from 'react';
|
|
15
15
|
import { observeResize } from "../utils/sharedResizeObserver.js";
|
|
16
|
+
import { observeContent } from "../utils/sharedMutationObserver.js";
|
|
16
17
|
/**
|
|
17
18
|
* Hook for detecting text overflow/truncation.
|
|
18
19
|
*
|
|
19
|
-
* Uses a shared ResizeObserver singleton (via observeResize)
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Uses a shared ResizeObserver singleton (via observeResize) for size
|
|
21
|
+
* changes and a shared MutationObserver singleton (via observeContent) for
|
|
22
|
+
* content changes, so even hundreds of table cells create one observer of
|
|
23
|
+
* each kind. Observing content matters because an element whose text changes
|
|
24
|
+
* without resizing (a fixed-width status line) must still be re-measured for
|
|
25
|
+
* the tooltip text and the truncated state to follow the current content.
|
|
23
26
|
*
|
|
24
27
|
* - Single-line: compares scrollWidth > offsetWidth
|
|
25
28
|
* - Multi-line: uses Range.getBoundingClientRect() to measure actual content
|
|
@@ -44,6 +47,7 @@ export function useTruncation(options) {
|
|
|
44
47
|
const [fullText, setFullText] = useState('');
|
|
45
48
|
const elementRef = useRef(null);
|
|
46
49
|
const unobserveRef = useRef(null);
|
|
50
|
+
const unobserveContentRef = useRef(null);
|
|
47
51
|
const checkTruncation = useCallback(element => {
|
|
48
52
|
if (maxLines === 0) {
|
|
49
53
|
setIsTruncated(false);
|
|
@@ -80,6 +84,8 @@ export function useTruncation(options) {
|
|
|
80
84
|
// by element leaves any other observer of the same node untouched.
|
|
81
85
|
unobserveRef.current?.();
|
|
82
86
|
unobserveRef.current = null;
|
|
87
|
+
unobserveContentRef.current?.();
|
|
88
|
+
unobserveContentRef.current = null;
|
|
83
89
|
elementRef.current = element;
|
|
84
90
|
if (element && maxLines > 0) {
|
|
85
91
|
// Observe via shared singleton (if available).
|
|
@@ -92,6 +98,11 @@ export function useTruncation(options) {
|
|
|
92
98
|
} else {
|
|
93
99
|
checkTruncation(element);
|
|
94
100
|
}
|
|
101
|
+
// New text in a box that keeps its size fires no resize, so the
|
|
102
|
+
// captured text and truncated state would otherwise stay stale.
|
|
103
|
+
unobserveContentRef.current = observeContent(element, () => {
|
|
104
|
+
checkTruncation(element);
|
|
105
|
+
});
|
|
95
106
|
} else {
|
|
96
107
|
setIsTruncated(false);
|
|
97
108
|
setFullText('');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.generated.d.ts","sourceRoot":"","sources":["../../../src/i18n/generated-locales/en.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"en.generated.d.ts","sourceRoot":"","sources":["../../../src/i18n/generated-locales/en.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmjBpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -436,6 +436,88 @@ const runtimeCatalog = {
|
|
|
436
436
|
'@astryx.transferList.announceSearchResults': '{count, number} {count, plural, one {item} other {items}} found.',
|
|
437
437
|
'@astryx.transferListSelector.apply': 'Apply',
|
|
438
438
|
'@astryx.transferListSelector.cancel': 'Cancel',
|
|
439
|
-
'@astryx.transferListSelector.triggerLabel': '{count, number} selected'
|
|
439
|
+
'@astryx.transferListSelector.triggerLabel': '{count, number} selected',
|
|
440
|
+
'@astryx.emojiPicker.label': 'Emoji',
|
|
441
|
+
'@astryx.emojiPicker.searchLabel': 'Search emoji',
|
|
442
|
+
'@astryx.emojiPicker.frequentlyUsed': 'Frequently used',
|
|
443
|
+
'@astryx.emojiPicker.searchResults': 'Search results',
|
|
444
|
+
'@astryx.emojiPicker.noResults': 'No emoji match “{query}”',
|
|
445
|
+
'@astryx.emojiPicker.loading': 'Loading emoji',
|
|
446
|
+
'@astryx.emojiPicker.loadFailed': "More emoji couldn't be loaded.",
|
|
447
|
+
'@astryx.emojiPicker.groupSmileysEmotion': 'Smileys & emotion',
|
|
448
|
+
'@astryx.emojiPicker.groupPeopleBody': 'People & body',
|
|
449
|
+
'@astryx.emojiPicker.groupAnimalsNature': 'Animals & nature',
|
|
450
|
+
'@astryx.emojiPicker.groupFoodDrink': 'Food & drink',
|
|
451
|
+
'@astryx.emojiPicker.groupTravelPlaces': 'Travel & places',
|
|
452
|
+
'@astryx.emojiPicker.groupActivities': 'Activities',
|
|
453
|
+
'@astryx.emojiPicker.groupObjects': 'Objects',
|
|
454
|
+
'@astryx.emojiPicker.groupSymbols': 'Symbols',
|
|
455
|
+
'@astryx.emojiPicker.groupFlags': 'Flags',
|
|
456
|
+
'@astryx.comments.retry': 'Retry',
|
|
457
|
+
'@astryx.commentComposer.placeholder': 'Write a comment…',
|
|
458
|
+
'@astryx.commentComposer.noAgents': 'No agents',
|
|
459
|
+
'@astryx.commentComposer.agents': 'Agents',
|
|
460
|
+
'@astryx.commentComposer.uploadFailed': "Images couldn't be added",
|
|
461
|
+
'@astryx.commentComposer.imagesOnly': 'Only image files can be added',
|
|
462
|
+
'@astryx.commentComposer.chooseImages': 'Choose images',
|
|
463
|
+
'@astryx.commentComposer.imageAlt': 'Image attachment',
|
|
464
|
+
'@astryx.commentComposer.removeQuote': 'Remove quoted text',
|
|
465
|
+
'@astryx.commentComposer.attachImages': 'Attach images',
|
|
466
|
+
'@astryx.commentComposer.addEmoji': 'Add emoji',
|
|
467
|
+
'@astryx.commentComposer.cancel': 'Cancel',
|
|
468
|
+
'@astryx.comments.actionsLabel': "Actions for {name}'s comment",
|
|
469
|
+
'@astryx.comments.addReaction': 'Add reaction',
|
|
470
|
+
'@astryx.comments.agentBadge': 'Agent',
|
|
471
|
+
'@astryx.comments.agentLogo': '{name} logo',
|
|
472
|
+
'@astryx.comments.chooseReaction': 'Choose a reaction',
|
|
473
|
+
'@astryx.comments.copyLink': 'Copy comment link',
|
|
474
|
+
'@astryx.comments.currentVersion': 'Current version',
|
|
475
|
+
'@astryx.comments.delete': 'Delete',
|
|
476
|
+
'@astryx.comments.deleteDescription': "Delete {name}'s comment? This action cannot be undone.",
|
|
477
|
+
'@astryx.comments.deleteFailed': "This comment couldn't be deleted.",
|
|
478
|
+
'@astryx.comments.deleteFailedRetry': "This comment couldn't be deleted. Try again.",
|
|
479
|
+
'@astryx.comments.deleteTitle': 'Delete comment?',
|
|
480
|
+
'@astryx.comments.edit': 'Edit',
|
|
481
|
+
'@astryx.comments.editFailed': "Your edit couldn't be saved.",
|
|
482
|
+
'@astryx.comments.editPlaceholder': 'Edit comment',
|
|
483
|
+
'@astryx.comments.edited': 'Edited',
|
|
484
|
+
'@astryx.comments.editingContext': 'Editing comment',
|
|
485
|
+
'@astryx.comments.hideReplies': 'Hide replies',
|
|
486
|
+
'@astryx.comments.historyEmptyDescription': 'This comment has no earlier versions.',
|
|
487
|
+
'@astryx.comments.historyEmptyTitle': 'No edit history',
|
|
488
|
+
'@astryx.comments.historyFailed': "Edit history couldn't load",
|
|
489
|
+
'@astryx.comments.historyLoadFailed': "The comment's edit history couldn't be loaded. Try again.",
|
|
490
|
+
'@astryx.comments.historyLoading': 'Loading edit history',
|
|
491
|
+
'@astryx.comments.historySubtitle': 'Comment by {name}',
|
|
492
|
+
'@astryx.comments.historyTitle': 'Edit history',
|
|
493
|
+
'@astryx.comments.linkCopied': 'Comment link copied',
|
|
494
|
+
'@astryx.comments.otherReactors': '{count, plural, one {# other} other {# others}}',
|
|
495
|
+
'@astryx.comments.outdated': 'Outdated',
|
|
496
|
+
'@astryx.comments.reactionCelebrate': 'Celebrate',
|
|
497
|
+
'@astryx.comments.reactionCount': '{reaction}: {count, number}',
|
|
498
|
+
'@astryx.comments.reactionFailed': "Your reaction couldn't be saved.",
|
|
499
|
+
'@astryx.comments.reactionLaugh': 'Haha',
|
|
500
|
+
'@astryx.comments.reactionLike': 'Like',
|
|
501
|
+
'@astryx.comments.reactionLove': 'Love',
|
|
502
|
+
'@astryx.comments.reactionSad': 'Sad',
|
|
503
|
+
'@astryx.comments.reactionWow': 'Wow',
|
|
504
|
+
'@astryx.comments.reopen': 'Reopen',
|
|
505
|
+
'@astryx.comments.reopenFailed': "This thread couldn't be reopened.",
|
|
506
|
+
'@astryx.comments.reply': 'Reply',
|
|
507
|
+
'@astryx.comments.replyFailed': "Your reply couldn't be posted.",
|
|
508
|
+
'@astryx.comments.replyPlaceholder': 'Reply to {name}…',
|
|
509
|
+
'@astryx.comments.replyingContext': 'Replying to {name}',
|
|
510
|
+
'@astryx.comments.resolve': 'Mark as resolved',
|
|
511
|
+
'@astryx.comments.resolveFailed': "This thread couldn't be resolved.",
|
|
512
|
+
'@astryx.comments.resolved': 'Resolved',
|
|
513
|
+
'@astryx.comments.resolvedBy': 'Resolved by {name}',
|
|
514
|
+
'@astryx.comments.retryFailed': "Retrying didn't work.",
|
|
515
|
+
'@astryx.comments.sendFailed': "Couldn't send this comment.",
|
|
516
|
+
'@astryx.comments.threadLabel': 'Thread by {name}',
|
|
517
|
+
'@astryx.comments.unread': 'New',
|
|
518
|
+
'@astryx.comments.unsavedDraft': 'Unsaved draft. Dismiss again to discard it.',
|
|
519
|
+
'@astryx.comments.versionAuthor': 'by {name}',
|
|
520
|
+
'@astryx.comments.viewHistory': 'View edit history',
|
|
521
|
+
'@astryx.comments.viewReplies': 'View {count, plural, one {# reply} other {# replies}}'
|
|
440
522
|
};
|
|
441
523
|
export default runtimeCatalog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pseudo.generated.d.ts","sourceRoot":"","sources":["../../../src/i18n/generated-locales/pseudo.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"pseudo.generated.d.ts","sourceRoot":"","sources":["../../../src/i18n/generated-locales/pseudo.generated.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4jBpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -436,6 +436,88 @@ const runtimeCatalog = {
|
|
|
436
436
|
'@astryx.transferList.announceSearchResults': '⟦{count, number} {count, plural, one {item} other {items}} ƒóúñð.⟧',
|
|
437
437
|
'@astryx.transferListSelector.apply': '⟦Àþþłý⟧',
|
|
438
438
|
'@astryx.transferListSelector.cancel': '⟦Çàñçéł⟧',
|
|
439
|
-
'@astryx.transferListSelector.triggerLabel': '⟦{count, number} šéłéçţéð⟧'
|
|
439
|
+
'@astryx.transferListSelector.triggerLabel': '⟦{count, number} šéłéçţéð⟧',
|
|
440
|
+
'@astryx.emojiPicker.label': '⟦Éɱóĵí⟧',
|
|
441
|
+
'@astryx.emojiPicker.searchLabel': '⟦Šéàřçĥ éɱóĵí⟧',
|
|
442
|
+
'@astryx.emojiPicker.frequentlyUsed': '⟦Ƒřéɋúéñţłý úšéð⟧',
|
|
443
|
+
'@astryx.emojiPicker.searchResults': '⟦Šéàřçĥ řéšúłţš⟧',
|
|
444
|
+
'@astryx.emojiPicker.noResults': '⟦Ñó éɱóĵí ɱàţçĥ “{query}”⟧',
|
|
445
|
+
'@astryx.emojiPicker.loading': '⟦Łóàðíñĝ éɱóĵí⟧',
|
|
446
|
+
'@astryx.emojiPicker.loadFailed': "⟦Ṁóřé éɱóĵí çóúłðñ'ţ ƀé łóàðéð.⟧",
|
|
447
|
+
'@astryx.emojiPicker.groupSmileysEmotion': '⟦Šɱíłéýš & éɱóţíóñ⟧',
|
|
448
|
+
'@astryx.emojiPicker.groupPeopleBody': '⟦Þéóþłé & ƀóðý⟧',
|
|
449
|
+
'@astryx.emojiPicker.groupAnimalsNature': '⟦Àñíɱàłš & ñàţúřé⟧',
|
|
450
|
+
'@astryx.emojiPicker.groupFoodDrink': '⟦Ƒóóð & ðříñķ⟧',
|
|
451
|
+
'@astryx.emojiPicker.groupTravelPlaces': '⟦Ţřàṽéł & þłàçéš⟧',
|
|
452
|
+
'@astryx.emojiPicker.groupActivities': '⟦Àçţíṽíţíéš⟧',
|
|
453
|
+
'@astryx.emojiPicker.groupObjects': '⟦Óƀĵéçţš⟧',
|
|
454
|
+
'@astryx.emojiPicker.groupSymbols': '⟦Šýɱƀółš⟧',
|
|
455
|
+
'@astryx.emojiPicker.groupFlags': '⟦Ƒłàĝš⟧',
|
|
456
|
+
'@astryx.comments.retry': '⟦Řéţřý⟧',
|
|
457
|
+
'@astryx.commentComposer.placeholder': '⟦Ŵříţé à çóɱɱéñţ…⟧',
|
|
458
|
+
'@astryx.commentComposer.noAgents': '⟦Ñó àĝéñţš⟧',
|
|
459
|
+
'@astryx.commentComposer.agents': '⟦Àĝéñţš⟧',
|
|
460
|
+
'@astryx.commentComposer.uploadFailed': "⟦Íɱàĝéš çóúłðñ'ţ ƀé àððéð⟧",
|
|
461
|
+
'@astryx.commentComposer.imagesOnly': '⟦Óñłý íɱàĝé ƒíłéš çàñ ƀé àððéð⟧',
|
|
462
|
+
'@astryx.commentComposer.chooseImages': '⟦Çĥóóšé íɱàĝéš⟧',
|
|
463
|
+
'@astryx.commentComposer.imageAlt': '⟦Íɱàĝé àţţàçĥɱéñţ⟧',
|
|
464
|
+
'@astryx.commentComposer.removeQuote': '⟦Řéɱóṽé ɋúóţéð ţéẋţ⟧',
|
|
465
|
+
'@astryx.commentComposer.attachImages': '⟦Àţţàçĥ íɱàĝéš⟧',
|
|
466
|
+
'@astryx.commentComposer.addEmoji': '⟦Àðð éɱóĵí⟧',
|
|
467
|
+
'@astryx.commentComposer.cancel': '⟦Çàñçéł⟧',
|
|
468
|
+
'@astryx.comments.actionsLabel': "⟦Àçţíóñš ƒóř {name}'š çóɱɱéñţ⟧",
|
|
469
|
+
'@astryx.comments.addReaction': '⟦Àðð řéàçţíóñ⟧',
|
|
470
|
+
'@astryx.comments.agentBadge': '⟦Àĝéñţ⟧',
|
|
471
|
+
'@astryx.comments.agentLogo': '⟦{name} łóĝó⟧',
|
|
472
|
+
'@astryx.comments.chooseReaction': '⟦Çĥóóšé à řéàçţíóñ⟧',
|
|
473
|
+
'@astryx.comments.copyLink': '⟦Çóþý çóɱɱéñţ łíñķ⟧',
|
|
474
|
+
'@astryx.comments.currentVersion': '⟦Çúřřéñţ ṽéřšíóñ⟧',
|
|
475
|
+
'@astryx.comments.delete': '⟦Ðéłéţé⟧',
|
|
476
|
+
'@astryx.comments.deleteDescription': "⟦Ðéłéţé {name}'š çóɱɱéñţ? Ţĥíš àçţíóñ çàññóţ ƀé úñðóñé.⟧",
|
|
477
|
+
'@astryx.comments.deleteFailed': "⟦Ţĥíš çóɱɱéñţ çóúłðñ'ţ ƀé ðéłéţéð.⟧",
|
|
478
|
+
'@astryx.comments.deleteFailedRetry': "⟦Ţĥíš çóɱɱéñţ çóúłðñ'ţ ƀé ðéłéţéð. Ţřý àĝàíñ.⟧",
|
|
479
|
+
'@astryx.comments.deleteTitle': '⟦Ðéłéţé çóɱɱéñţ?⟧',
|
|
480
|
+
'@astryx.comments.edit': '⟦Éðíţ⟧',
|
|
481
|
+
'@astryx.comments.editFailed': "⟦Ýóúř éðíţ çóúłðñ'ţ ƀé šàṽéð.⟧",
|
|
482
|
+
'@astryx.comments.editPlaceholder': '⟦Éðíţ çóɱɱéñţ⟧',
|
|
483
|
+
'@astryx.comments.edited': '⟦Éðíţéð⟧',
|
|
484
|
+
'@astryx.comments.editingContext': '⟦Éðíţíñĝ çóɱɱéñţ⟧',
|
|
485
|
+
'@astryx.comments.hideReplies': '⟦Ĥíðé řéþłíéš⟧',
|
|
486
|
+
'@astryx.comments.historyEmptyDescription': '⟦Ţĥíš çóɱɱéñţ ĥàš ñó éàřłíéř ṽéřšíóñš.⟧',
|
|
487
|
+
'@astryx.comments.historyEmptyTitle': '⟦Ñó éðíţ ĥíšţóřý⟧',
|
|
488
|
+
'@astryx.comments.historyFailed': "⟦Éðíţ ĥíšţóřý çóúłðñ'ţ łóàð⟧",
|
|
489
|
+
'@astryx.comments.historyLoadFailed': "⟦Ţĥé çóɱɱéñţ'š éðíţ ĥíšţóřý çóúłðñ'ţ ƀé łóàðéð. Ţřý àĝàíñ.⟧",
|
|
490
|
+
'@astryx.comments.historyLoading': '⟦Łóàðíñĝ éðíţ ĥíšţóřý⟧',
|
|
491
|
+
'@astryx.comments.historySubtitle': '⟦Çóɱɱéñţ ƀý {name}⟧',
|
|
492
|
+
'@astryx.comments.historyTitle': '⟦Éðíţ ĥíšţóřý⟧',
|
|
493
|
+
'@astryx.comments.linkCopied': '⟦Çóɱɱéñţ łíñķ çóþíéð⟧',
|
|
494
|
+
'@astryx.comments.otherReactors': '⟦{count, plural, one {# other} other {# others}}⟧',
|
|
495
|
+
'@astryx.comments.outdated': '⟦Óúţðàţéð⟧',
|
|
496
|
+
'@astryx.comments.reactionCelebrate': '⟦Çéłéƀřàţé⟧',
|
|
497
|
+
'@astryx.comments.reactionCount': '⟦{reaction}: {count, number}⟧',
|
|
498
|
+
'@astryx.comments.reactionFailed': "⟦Ýóúř řéàçţíóñ çóúłðñ'ţ ƀé šàṽéð.⟧",
|
|
499
|
+
'@astryx.comments.reactionLaugh': '⟦Ĥàĥà⟧',
|
|
500
|
+
'@astryx.comments.reactionLike': '⟦Łíķé⟧',
|
|
501
|
+
'@astryx.comments.reactionLove': '⟦Łóṽé⟧',
|
|
502
|
+
'@astryx.comments.reactionSad': '⟦Šàð⟧',
|
|
503
|
+
'@astryx.comments.reactionWow': '⟦Ŵóŵ⟧',
|
|
504
|
+
'@astryx.comments.reopen': '⟦Řéóþéñ⟧',
|
|
505
|
+
'@astryx.comments.reopenFailed': "⟦Ţĥíš ţĥřéàð çóúłðñ'ţ ƀé řéóþéñéð.⟧",
|
|
506
|
+
'@astryx.comments.reply': '⟦Řéþłý⟧',
|
|
507
|
+
'@astryx.comments.replyFailed': "⟦Ýóúř řéþłý çóúłðñ'ţ ƀé þóšţéð.⟧",
|
|
508
|
+
'@astryx.comments.replyPlaceholder': '⟦Řéþłý ţó {name}…⟧',
|
|
509
|
+
'@astryx.comments.replyingContext': '⟦Řéþłýíñĝ ţó {name}⟧',
|
|
510
|
+
'@astryx.comments.resolve': '⟦Ṁàřķ àš řéšółṽéð⟧',
|
|
511
|
+
'@astryx.comments.resolveFailed': "⟦Ţĥíš ţĥřéàð çóúłðñ'ţ ƀé řéšółṽéð.⟧",
|
|
512
|
+
'@astryx.comments.resolved': '⟦Řéšółṽéð⟧',
|
|
513
|
+
'@astryx.comments.resolvedBy': '⟦Řéšółṽéð ƀý {name}⟧',
|
|
514
|
+
'@astryx.comments.retryFailed': "⟦Řéţřýíñĝ ðíðñ'ţ ŵóřķ.⟧",
|
|
515
|
+
'@astryx.comments.sendFailed': "⟦Çóúłðñ'ţ šéñð ţĥíš çóɱɱéñţ.⟧",
|
|
516
|
+
'@astryx.comments.threadLabel': '⟦Ţĥřéàð ƀý {name}⟧',
|
|
517
|
+
'@astryx.comments.unread': '⟦Ñéŵ⟧',
|
|
518
|
+
'@astryx.comments.unsavedDraft': '⟦Úñšàṽéð ðřàƒţ. Ðíšɱíšš àĝàíñ ţó ðíšçàřð íţ.⟧',
|
|
519
|
+
'@astryx.comments.versionAuthor': '⟦ƀý {name}⟧',
|
|
520
|
+
'@astryx.comments.viewHistory': '⟦Ṽíéŵ éðíţ ĥíšţóřý⟧',
|
|
521
|
+
'@astryx.comments.viewReplies': '⟦Ṽíéŵ {count, plural, one {# reply} other {# replies}}⟧'
|
|
440
522
|
};
|
|
441
523
|
export default runtimeCatalog;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file sharedMutationObserver.ts
|
|
3
|
+
* @input MutationObserver API
|
|
4
|
+
* @output Exports observeContent for shared content-change observation
|
|
5
|
+
* @position Internal utility; consumed by useTruncation. The content-change
|
|
6
|
+
* counterpart of sharedResizeObserver: one observer for every element, so a
|
|
7
|
+
* repeated cell or row path does not create one observer per instance.
|
|
8
|
+
*/
|
|
9
|
+
type ContentCallback = () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Call `callback` when the element's text or children change (including
|
|
12
|
+
* descendants). Returns an unsubscribe that removes only this registration.
|
|
13
|
+
*
|
|
14
|
+
* MutationObserver has no per-target unobserve, so a released element stays
|
|
15
|
+
* registered with the shared observer until no element remains; its records
|
|
16
|
+
* match no callback and are ignored. The observer disconnects and is released
|
|
17
|
+
* when the last registration goes.
|
|
18
|
+
*/
|
|
19
|
+
export declare function observeContent(element: Element, callback: ContentCallback): () => void;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=sharedMutationObserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedMutationObserver.d.ts","sourceRoot":"","sources":["../../src/utils/sharedMutationObserver.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,KAAK,eAAe,GAAG,MAAM,IAAI,CAAC;AAuBlC;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,GACxB,MAAM,IAAI,CA6BZ"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file sharedMutationObserver.ts
|
|
7
|
+
* @input MutationObserver API
|
|
8
|
+
* @output Exports observeContent for shared content-change observation
|
|
9
|
+
* @position Internal utility; consumed by useTruncation. The content-change
|
|
10
|
+
* counterpart of sharedResizeObserver: one observer for every element, so a
|
|
11
|
+
* repeated cell or row path does not create one observer per instance.
|
|
12
|
+
*/
|
|
13
|
+
const OPTIONS = {
|
|
14
|
+
characterData: true,
|
|
15
|
+
childList: true,
|
|
16
|
+
subtree: true
|
|
17
|
+
};
|
|
18
|
+
let observer = null;
|
|
19
|
+
const callbacks = new Map();
|
|
20
|
+
function dispatch(records) {
|
|
21
|
+
// One call per callback per batch, however many records it received. A
|
|
22
|
+
// record's target can be any descendant, so walk up to the observed roots.
|
|
23
|
+
const pending = new Set();
|
|
24
|
+
for (const record of records) {
|
|
25
|
+
for (let node = record.target; node; node = node.parentNode) {
|
|
26
|
+
callbacks.get(node)?.forEach(callback => pending.add(callback));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
pending.forEach(callback => callback());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Call `callback` when the element's text or children change (including
|
|
34
|
+
* descendants). Returns an unsubscribe that removes only this registration.
|
|
35
|
+
*
|
|
36
|
+
* MutationObserver has no per-target unobserve, so a released element stays
|
|
37
|
+
* registered with the shared observer until no element remains; its records
|
|
38
|
+
* match no callback and are ignored. The observer disconnects and is released
|
|
39
|
+
* when the last registration goes.
|
|
40
|
+
*/
|
|
41
|
+
export function observeContent(element, callback) {
|
|
42
|
+
if (typeof MutationObserver === 'undefined') {
|
|
43
|
+
return () => {};
|
|
44
|
+
}
|
|
45
|
+
observer ??= new MutationObserver(dispatch);
|
|
46
|
+
const existing = callbacks.get(element);
|
|
47
|
+
if (existing) {
|
|
48
|
+
existing.add(callback);
|
|
49
|
+
} else {
|
|
50
|
+
callbacks.set(element, new Set([callback]));
|
|
51
|
+
observer.observe(element, OPTIONS);
|
|
52
|
+
}
|
|
53
|
+
let isSubscribed = true;
|
|
54
|
+
return () => {
|
|
55
|
+
if (!isSubscribed) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
isSubscribed = false;
|
|
59
|
+
const targetCallbacks = callbacks.get(element);
|
|
60
|
+
targetCallbacks?.delete(callback);
|
|
61
|
+
if (targetCallbacks?.size === 0) {
|
|
62
|
+
callbacks.delete(element);
|
|
63
|
+
}
|
|
64
|
+
if (callbacks.size === 0 && observer) {
|
|
65
|
+
observer.disconnect();
|
|
66
|
+
observer = null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|