@streamsai/ui 0.1.7 → 0.1.9
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.
|
@@ -1004,7 +1004,23 @@ function TypeaheadMenuAboveCaret({ anchor, dataAttr, className, children, option
|
|
|
1004
1004
|
// Lexical writes top/left on the absolute anchor when the caret moves.
|
|
1005
1005
|
const observer = new MutationObserver(update);
|
|
1006
1006
|
observer.observe(anchor, { attributes: true, attributeFilter: ['style'] });
|
|
1007
|
+
// The iOS app lifts the composer on the keyboard's curve by tweening its padding in JS: the
|
|
1008
|
+
// editor moves frame by frame with no viewport, scroll, selection or resize event to follow.
|
|
1009
|
+
// A menu opened with the keyboard down stayed where the composer used to be, on top of it.
|
|
1010
|
+
const editorRoot = editor.getRootElement();
|
|
1011
|
+
let editorTop = editorRoot?.getBoundingClientRect().top;
|
|
1012
|
+
let watchRaf = 0;
|
|
1013
|
+
const watchEditor = () => {
|
|
1014
|
+
const top = editorRoot?.getBoundingClientRect().top;
|
|
1015
|
+
if (top !== editorTop) {
|
|
1016
|
+
editorTop = top;
|
|
1017
|
+
update();
|
|
1018
|
+
}
|
|
1019
|
+
watchRaf = window.requestAnimationFrame(watchEditor);
|
|
1020
|
+
};
|
|
1021
|
+
watchRaf = window.requestAnimationFrame(watchEditor);
|
|
1007
1022
|
return () => {
|
|
1023
|
+
window.cancelAnimationFrame(watchRaf);
|
|
1008
1024
|
if (rafRef.current != null)
|
|
1009
1025
|
window.cancelAnimationFrame(rafRef.current);
|
|
1010
1026
|
rafRef.current = null;
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants
|
|
|
33
33
|
export { Button, buttonVariants } from './components/ui/button.js';
|
|
34
34
|
export { cn } from './lib/utils.js';
|
|
35
35
|
export { HOME_TILE_COUNT, homeTileIndex } from './lib/home-tile.js';
|
|
36
|
-
export { detectTextDirection, hasStrongCharacter, isNeutralToken, openingDirection, } from './lib/text-direction.js';
|
|
36
|
+
export { detectTextDirection, firstStrongLetterDirection, hasStrongCharacter, isNeutralToken, openingDirection, scriptsIn, } from './lib/text-direction.js';
|
|
37
37
|
export { Checkbox } from './components/ui/checkbox.js';
|
|
38
38
|
export { Clickable, clickableVariants, type ClickableProps } from './components/ui/clickable.js';
|
|
39
39
|
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger } from './components/ui/dialog.js';
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants
|
|
|
38
38
|
export { Button, buttonVariants } from './components/ui/button.js';
|
|
39
39
|
export { cn } from './lib/utils.js';
|
|
40
40
|
export { HOME_TILE_COUNT, homeTileIndex } from './lib/home-tile.js';
|
|
41
|
-
export { detectTextDirection, hasStrongCharacter, isNeutralToken, openingDirection, } from './lib/text-direction.js';
|
|
41
|
+
export { detectTextDirection, firstStrongLetterDirection, hasStrongCharacter, isNeutralToken, openingDirection, scriptsIn, } from './lib/text-direction.js';
|
|
42
42
|
export { Checkbox } from './components/ui/checkbox.js';
|
|
43
43
|
export { Clickable, clickableVariants } from './components/ui/clickable.js';
|
|
44
44
|
// prettier-ignore
|
|
@@ -31,3 +31,10 @@ export declare const detectTextDirection: (text: string) => TextDirection;
|
|
|
31
31
|
* letter (blank, digit-only and punctuation-only openers are skipped), or `null` when no block has one.
|
|
32
32
|
*/
|
|
33
33
|
export declare const openingDirection: (blockTexts: Iterable<string>) => TextDirection | null;
|
|
34
|
+
/** Which scripts `text` contains letters of, ignoring digits and punctuation. */
|
|
35
|
+
export declare const scriptsIn: (text: string) => {
|
|
36
|
+
rtl: boolean;
|
|
37
|
+
ltr: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** Direction of the first strong letter in `text`, or `null` when it has none (digits and punctuation never count). */
|
|
40
|
+
export declare const firstStrongLetterDirection: (text: string) => TextDirection | null;
|
|
@@ -137,3 +137,31 @@ export const openingDirection = (blockTexts) => {
|
|
|
137
137
|
}
|
|
138
138
|
return null;
|
|
139
139
|
};
|
|
140
|
+
/** Which scripts `text` contains letters of, ignoring digits and punctuation. */
|
|
141
|
+
export const scriptsIn = (text) => {
|
|
142
|
+
let rtl = false;
|
|
143
|
+
let ltr = false;
|
|
144
|
+
for (const character of text) {
|
|
145
|
+
if (!LETTER.test(character))
|
|
146
|
+
continue;
|
|
147
|
+
const strength = strengthOf(character);
|
|
148
|
+
if (strength === 'rtl')
|
|
149
|
+
rtl = true;
|
|
150
|
+
else if (strength === 'ltr')
|
|
151
|
+
ltr = true;
|
|
152
|
+
if (rtl && ltr)
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
return { rtl, ltr };
|
|
156
|
+
};
|
|
157
|
+
/** Direction of the first strong letter in `text`, or `null` when it has none (digits and punctuation never count). */
|
|
158
|
+
export const firstStrongLetterDirection = (text) => {
|
|
159
|
+
for (const character of text) {
|
|
160
|
+
if (!LETTER.test(character))
|
|
161
|
+
continue;
|
|
162
|
+
const strength = strengthOf(character);
|
|
163
|
+
if (strength !== null)
|
|
164
|
+
return strength;
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
};
|
package/package.json
CHANGED