@astryxdesign/core 0.7.12-canary.ccb4a6d → 0.7.12-canary.f543ec7
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/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +24 -3
- package/dist/Chat/ChatComposer.d.ts.map +1 -1
- package/dist/Chat/ChatComposer.js +9 -3
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +10 -5
- package/dist/Chat/ChatLayout.d.ts +7 -1
- package/dist/Chat/ChatLayout.d.ts.map +1 -1
- package/dist/Chat/ChatLayout.js +66 -16
- package/dist/Chat/keyboardSurface.d.ts +4 -0
- package/dist/Chat/keyboardSurface.d.ts.map +1 -0
- package/dist/Chat/keyboardSurface.js +32 -0
- package/dist/Chat/useChatKeyboard.d.ts +69 -0
- package/dist/Chat/useChatKeyboard.d.ts.map +1 -0
- package/dist/Chat/useChatKeyboard.js +406 -0
- package/dist/Chat/useChatStreamScroll.d.ts +5 -0
- package/dist/Chat/useChatStreamScroll.d.ts.map +1 -1
- package/dist/Chat/useChatStreamScroll.js +26 -3
- package/dist/CodeBlock/grammar.d.ts +5 -14
- package/dist/CodeBlock/grammar.d.ts.map +1 -1
- package/dist/CodeBlock/grammar.js +5 -1
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +17 -4
- package/dist/DateInput/monthGeometry.d.ts +14 -0
- package/dist/DateInput/monthGeometry.d.ts.map +1 -1
- package/dist/DateInput/monthGeometry.js +26 -1
- package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.js +17 -6
- package/dist/Kbd/Kbd.d.ts +3 -2
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +21 -19
- package/dist/Layer/layerSlideRules.d.ts +0 -7
- package/dist/Layer/layerSlideRules.d.ts.map +1 -1
- package/dist/Layer/layerSlideRules.js +1 -14
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +24 -179
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +2 -1
- package/dist/SnapPaging/SnapPaging.js +1 -1
- package/dist/SnapPaging/snapPagingValue.d.ts +5 -2
- package/dist/SnapPaging/snapPagingValue.d.ts.map +1 -1
- package/dist/SnapPaging/snapPagingValue.js +3 -1
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +2 -2
- package/dist/Switch/useSwitchTouch.d.ts +3 -2
- package/dist/Switch/useSwitchTouch.d.ts.map +1 -1
- package/dist/Switch/useSwitchTouch.js +19 -3
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +10 -2
- package/dist/Table/plugins/tree/useTableTreeData.d.ts.map +1 -1
- package/dist/Table/plugins/tree/useTableTreeData.js +38 -19
- package/dist/astryx.css +4 -1
- package/dist/gestures/GestureHost.d.ts +7 -0
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +27 -5
- package/dist/gestures/fingerScroll.d.ts +7 -2
- package/dist/gestures/fingerScroll.d.ts.map +1 -1
- package/dist/gestures/fingerScroll.js +60 -13
- package/dist/gestures/useFingerScroll.d.ts +6 -4
- package/dist/gestures/useFingerScroll.d.ts.map +1 -1
- package/dist/gestures/useFingerScroll.js +7 -5
- package/dist/hooks/usePager.d.ts +3 -2
- package/dist/hooks/usePager.d.ts.map +1 -1
- package/dist/hooks/usePager.js +18 -7
- package/dist/hooks/useScrollOverflow.d.ts +5 -2
- package/dist/hooks/useScrollOverflow.d.ts.map +1 -1
- package/dist/hooks/useScrollOverflow.js +29 -15
- package/dist/i18n/generated-english/Kbd/Kbd.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/Kbd/Kbd.generated.js +3 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +3 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +3 -0
- package/dist/keyboard/keyboardHeight.d.ts +5 -0
- package/dist/keyboard/keyboardHeight.d.ts.map +1 -1
- package/dist/keyboard/keyboardHeight.js +68 -7
- package/dist/keyboard/keyboardLayoutGuide.d.ts.map +1 -1
- package/dist/keyboard/keyboardLayoutGuide.js +2 -2
- package/dist/keyboard/keyboardTarget.d.ts +22 -0
- package/dist/keyboard/keyboardTarget.d.ts.map +1 -1
- package/dist/keyboard/keyboardTarget.js +17 -10
- package/dist/motion/animatedLayout.d.ts +8 -5
- package/dist/motion/animatedLayout.d.ts.map +1 -1
- package/dist/motion/animatedLayout.js +14 -6
- package/dist/motion/animator.d.ts +11 -2
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +74 -7
- package/dist/motion/themeTiming.d.ts +1 -1
- package/dist/motion/themeTiming.d.ts.map +1 -1
- package/dist/motion/themeTiming.js +1 -3
- package/dist/motion/uikit/paging.d.ts +4 -4
- package/dist/motion/uikit/paging.js +4 -4
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/color.js +5 -3
- package/dist/utils/pressFeedback.d.ts +4 -3
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +8 -4
- package/locales/en.json +12 -0
- package/locales/pseudo.json +9 -0
- package/package.json +4 -4
- package/src/Calendar/useCalendarConstraints.doc.mjs +151 -0
- package/src/Calendar/useCalendarNavigation.doc.mjs +173 -0
- package/src/Carousel/Carousel.tsx +34 -10
- package/src/Chat/ChatComposer.tsx +40 -27
- package/src/Chat/ChatComposerInput.tsx +13 -4
- package/src/Chat/ChatLayout.doc.mjs +10 -5
- package/src/Chat/ChatLayout.tsx +66 -8
- package/src/Chat/keyboardSurface.ts +39 -0
- package/src/Chat/useChatKeyboard.ts +497 -0
- package/src/Chat/useChatStreamScroll.ts +26 -3
- package/src/CodeBlock/grammar.ts +12 -3
- package/src/DateInput/TouchDateField.tsx +28 -5
- package/src/DateInput/monthGeometry.ts +36 -0
- package/src/DateTimeInput/TouchDateTimeField.tsx +35 -4
- package/src/Kbd/Kbd.doc.mjs +53 -16
- package/src/Kbd/Kbd.tsx +28 -17
- package/src/Layer/layerSlideRules.ts +0 -14
- package/src/Layer/useLayer.tsx +26 -224
- package/src/Pagination/Pagination.tsx +7 -0
- package/src/SnapPaging/SnapPaging.ts +1 -1
- package/src/SnapPaging/snapPagingValue.ts +11 -4
- package/src/Switch/Switch.tsx +13 -4
- package/src/Switch/useSwitchTouch.ts +12 -6
- package/src/Table/Table.tsx +15 -1
- package/src/Table/plugins/tree/useTableTreeData.tsx +32 -13
- package/src/Table/useTableTreeData.doc.mjs +2 -2
- package/src/gestures/GestureHost.ts +36 -3
- package/src/gestures/fingerScroll.ts +76 -13
- package/src/gestures/useFingerScroll.ts +8 -6
- package/src/hooks/usePager.ts +19 -7
- package/src/hooks/useScrollOverflow.ts +29 -15
- package/src/i18n/generated-english/Kbd/Kbd.generated.ts +3 -0
- package/src/i18n/generated-locales/en.generated.ts +3 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +3 -0
- package/src/keyboard/README.md +17 -3
- package/src/keyboard/keyboardHeight.ts +78 -10
- package/src/keyboard/keyboardLayoutGuide.ts +2 -1
- package/src/keyboard/keyboardTarget.ts +20 -10
- package/src/motion/README.md +4 -1
- package/src/motion/animatedLayout.ts +20 -10
- package/src/motion/animator.ts +105 -9
- package/src/motion/themeTiming.ts +1 -2
- package/src/motion/uikit/paging.ts +4 -4
- package/src/utils/color.ts +5 -3
- package/src/utils/pressFeedback.ts +6 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../src/Carousel/Carousel.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,KAAK,SAAS,EAQf,MAAM,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OAQG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA6MD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,GAAO,EACP,UAAiB,EACjB,WAAkB,EAClB,OAAe,EACf,OAAe,EACf,OAAO,EACP,YAAY,EAAE,kBAAkB,EAChC,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EAAE,MAAM,EACrB,GAAG,SAAS,EACb,EAAE,aAAa,+BAmef;yBAnfe,QAAQ"}
|
|
@@ -193,6 +193,20 @@ const paddingStyles = {
|
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Runs one of Carousel's own calls into the paging: a scroll call or the
|
|
198
|
+
* detach. Such a call can run inside React's commit, so a report it raises
|
|
199
|
+
* takes React's scheduling.
|
|
200
|
+
*/
|
|
201
|
+
function ownCall(depth, run) {
|
|
202
|
+
depth.current += 1;
|
|
203
|
+
try {
|
|
204
|
+
return run();
|
|
205
|
+
} finally {
|
|
206
|
+
depth.current -= 1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
196
210
|
/**
|
|
197
211
|
* Where an edge press under snap paging goes from offset `at`: about one view
|
|
198
212
|
* on, to the nearest stop and at least one stop on. With `wraps`, a press past
|
|
@@ -258,6 +272,7 @@ export function Carousel({
|
|
|
258
272
|
const t = useComponentTranslator();
|
|
259
273
|
const ariaLabel = ariaLabelFromProps ?? t('@astryx.carousel.label');
|
|
260
274
|
const scrollElRef = useRef(null);
|
|
275
|
+
const runningOwnCallsRef = useRef(0);
|
|
261
276
|
const startButtonRef = useRef(null);
|
|
262
277
|
const endButtonRef = useRef(null);
|
|
263
278
|
// Which nav button last held focus, and what the overflow state was on the
|
|
@@ -305,7 +320,13 @@ export function Carousel({
|
|
|
305
320
|
}
|
|
306
321
|
// Attaches snap paging to the scroll area, and follows a replaced one.
|
|
307
322
|
// While the paging holds the row, the edges follow the row as shown.
|
|
308
|
-
useAttachment(scrollElRef, scroller =>
|
|
323
|
+
useAttachment(scrollElRef, scroller => {
|
|
324
|
+
if (attachedPaging == null) {
|
|
325
|
+
return () => {};
|
|
326
|
+
}
|
|
327
|
+
const detach = attachSnapPaging(attachedPaging, scroller, held => followShown(held, runningOwnCallsRef.current === 0));
|
|
328
|
+
return () => ownCall(runningOwnCallsRef, detach);
|
|
329
|
+
}, attachedPaging);
|
|
309
330
|
// React's wheel listener is passive, so it can't stop the browser's own
|
|
310
331
|
// scroll; this native one can. While a flick holds the row, the paging takes
|
|
311
332
|
// a wheel the gesture host leaves to the stop nearest its travel.
|
|
@@ -350,7 +371,7 @@ export function Carousel({
|
|
|
350
371
|
}
|
|
351
372
|
// Under snap paging the paging moves the row, held or at rest. A touch
|
|
352
373
|
// then catches the move, and the release rests on a page.
|
|
353
|
-
if (moveSnapPaging(el, (at, end) => pagingStep(el, at, end, direction, hasLoop && hasOverflow))) {
|
|
374
|
+
if (ownCall(runningOwnCallsRef, () => moveSnapPaging(el, (at, end) => pagingStep(el, at, end, direction, hasLoop && hasOverflow)))) {
|
|
354
375
|
return;
|
|
355
376
|
}
|
|
356
377
|
// Respect the user's reduced-motion preference — mirrors the CSS
|
|
@@ -418,7 +439,7 @@ export function Carousel({
|
|
|
418
439
|
const delta = isRtlElement(el) ? itemRect.right - containerRect.right : itemRect.left - containerRect.left;
|
|
419
440
|
// Under snap paging the row goes to the item's stop, inside the scroll
|
|
420
441
|
// padding, so the hand-back's snap does not pull it back.
|
|
421
|
-
if (moveSnapPaging(el, (at, end) => nearestStop(snapStops(el, at, end), at + (isRtlElement(el) ? -delta : delta)))) {
|
|
442
|
+
if (ownCall(runningOwnCallsRef, () => moveSnapPaging(el, (at, end) => nearestStop(snapStops(el, at, end), at + (isRtlElement(el) ? -delta : delta))))) {
|
|
422
443
|
return;
|
|
423
444
|
}
|
|
424
445
|
el.scrollBy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatComposer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatComposer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,EAMZ,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAwC5C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtE,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAC7C,SAAS,CAAC,cAAc,CAAC,EACzB,UAAU,GAAG,UAAU,CACxB;IACC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC,+CAA+C;IAC/C,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,kFAAkF;IAClF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sBAAsB;IACtB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAI3B,6GAA6G;IAC7G,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,yHAAyH;IACzH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,yGAAyG;IACzG,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,gHAAgH;IAChH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,gHAAgH;IAChH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,gDAAgD;IAChD,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,iEAAiE;IACjE,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,oDAAoD;IACpD,cAAc,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CACnC;AAoOD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBA4OpD;yBA5Oe,YAAY"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* - /apps/storybook/stories/ChatComposer.stories.tsx
|
|
23
23
|
* - /packages/cli/assets/templates/blocks/components/ChatComposer/ (block examples)
|
|
24
24
|
*/
|
|
25
|
-
import React, { useState, useCallback, useRef, useMemo } from 'react';
|
|
25
|
+
import React, { use, useState, useCallback, useRef, useMemo } from 'react';
|
|
26
26
|
import * as stylex from '@stylexjs/stylex';
|
|
27
27
|
import "../theme/tokens.stylex.js";
|
|
28
28
|
import { colorVars, spacingVars, radiusVars, shadowVars, durationVars, easeVars, borderVars, typeScaleVars, typographyVars } from "../theme/tokens.stylex.js";
|
|
@@ -31,6 +31,7 @@ import { Icon } from "../Icon/index.js";
|
|
|
31
31
|
import { ChatComposerInput } from "./ChatComposerInput.js";
|
|
32
32
|
import { ChatComposerContext } from "./ChatContext.js";
|
|
33
33
|
import { ChatSendButton } from "./ChatSendButton.js";
|
|
34
|
+
import { KeyboardSurfaceContext, focusInKeyboardSurface } from "./keyboardSurface.js";
|
|
34
35
|
import { themeProps } from "../utils/themeProps.js";
|
|
35
36
|
import { useAnnounceRenderedText } from "../hooks/useAnnounceRenderedText.js";
|
|
36
37
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
@@ -174,6 +175,9 @@ export function ChatComposer(props) {
|
|
|
174
175
|
// drive it without knowing its DOM shape. Stable ref — safe in the memoized
|
|
175
176
|
// context value.
|
|
176
177
|
const inputControlRef = useRef(null);
|
|
178
|
+
// Inside ChatLayout's keyboard surface, a touch focus skips the browser's
|
|
179
|
+
// reveal. Elsewhere the browser's own focus applies.
|
|
180
|
+
const isKeyboardSurface = use(KeyboardSurfaceContext);
|
|
177
181
|
const handleBodyClick = useCallback(e => {
|
|
178
182
|
// Focus the input when clicking empty space in the body.
|
|
179
183
|
// Skip if the click target is a button, link, or interactive element.
|
|
@@ -190,8 +194,10 @@ export function ChatComposer(props) {
|
|
|
190
194
|
return;
|
|
191
195
|
}
|
|
192
196
|
const editable = bodyRef.current?.querySelector('[contenteditable="true"], textarea');
|
|
193
|
-
editable
|
|
194
|
-
|
|
197
|
+
if (editable) {
|
|
198
|
+
focusInKeyboardSurface(editable, isKeyboardSurface);
|
|
199
|
+
}
|
|
200
|
+
}, [isKeyboardSurface]);
|
|
195
201
|
const handleBodyFocusCapture = useCallback(event => {
|
|
196
202
|
setHasKeyboardEditorFocus(isComposerEditor(event.target) && readModality() === 'keyboard');
|
|
197
203
|
}, [readModality]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposerInput.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatComposerInput.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"ChatComposerInput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storybook/stories/ChatComposer.stories.tsx
|
|
27
27
|
* - /packages/cli/assets/templates/blocks/components/ChatComposerInput/ (block examples)
|
|
28
28
|
*/
|
|
29
|
-
import { useRef, useState, useCallback, useEffect, useImperativeHandle } from 'react';
|
|
29
|
+
import { use, useRef, useState, useCallback, useEffect, useImperativeHandle } from 'react';
|
|
30
30
|
import { createPortal } from 'react-dom';
|
|
31
31
|
import * as stylex from '@stylexjs/stylex';
|
|
32
32
|
import "../theme/tokens.stylex.js";
|
|
@@ -39,6 +39,7 @@ import { ChatPastedTextToken } from "./ChatPastedTextToken.js";
|
|
|
39
39
|
import { useChatPasteAsToken } from "./useChatPasteAsToken.js";
|
|
40
40
|
import { Badge } from "../Badge/index.js";
|
|
41
41
|
import { useChatComposerContext } from "./ChatContext.js";
|
|
42
|
+
import { KeyboardSurfaceContext, focusInKeyboardSurface } from "./keyboardSurface.js";
|
|
42
43
|
import { themeProps } from "../utils/themeProps.js";
|
|
43
44
|
import { withholdCallerHandlers } from "../utils/disabledInteraction.js";
|
|
44
45
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
@@ -195,6 +196,10 @@ export function ChatComposerInput(props) {
|
|
|
195
196
|
const insertTextRef = useRef(() => {});
|
|
196
197
|
const expandTokenRef = useRef(() => {});
|
|
197
198
|
|
|
199
|
+
// Inside ChatLayout's keyboard surface, every touch route into the text
|
|
200
|
+
// skips the browser's reveal. Elsewhere the browser's own focus applies.
|
|
201
|
+
const isKeyboardSurface = use(KeyboardSurfaceContext);
|
|
202
|
+
|
|
198
203
|
// A single handle object shared between the forwarded ref (via
|
|
199
204
|
// `useImperativeHandle`) and `selfRef` (used by internal consumers
|
|
200
205
|
// like paste-as-token). We can't rely on `useImperativeHandle`'s
|
|
@@ -232,13 +237,13 @@ export function ChatComposerInput(props) {
|
|
|
232
237
|
// Read before focusing: `focus()` itself creates the offset-0 caret, so
|
|
233
238
|
// asking afterwards cannot tell the user's own caret from the engine's.
|
|
234
239
|
const existing = getSelectionRangeInside(editable);
|
|
235
|
-
editable
|
|
240
|
+
focusInKeyboardSurface(editable, isKeyboardSurface);
|
|
236
241
|
if (existing) {
|
|
237
242
|
restoreSelectionRange(existing);
|
|
238
243
|
return;
|
|
239
244
|
}
|
|
240
245
|
placeCaretAtEnd(editable);
|
|
241
|
-
}, []);
|
|
246
|
+
}, [isKeyboardSurface]);
|
|
242
247
|
|
|
243
248
|
/**
|
|
244
249
|
* Focus the editable and put the caret after the draft, whatever the
|
|
@@ -253,9 +258,9 @@ export function ChatComposerInput(props) {
|
|
|
253
258
|
if (!editable) {
|
|
254
259
|
return;
|
|
255
260
|
}
|
|
256
|
-
editable
|
|
261
|
+
focusInKeyboardSurface(editable, isKeyboardSurface);
|
|
257
262
|
placeCaretAtEnd(editable);
|
|
258
|
-
}, []);
|
|
263
|
+
}, [isKeyboardSurface]);
|
|
259
264
|
const handle = {
|
|
260
265
|
insertToken: token => insertTokenRef.current(token),
|
|
261
266
|
expandToken: id => expandTokenRef.current(id),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file ChatLayout.tsx
|
|
3
|
-
* @input Uses React, StyleX, theme tokens, useChatStreamScroll, useChatNewMessages
|
|
3
|
+
* @input Uses React, StyleX, theme tokens, useChatStreamScroll, useChatNewMessages,
|
|
4
|
+
* useChatKeyboard
|
|
4
5
|
* @output Exports ChatLayout component and ChatLayoutProps
|
|
5
6
|
* @position Layout shell for full chat interfaces — messages in page flow, composer fixed to bottom
|
|
6
7
|
*
|
|
@@ -15,6 +16,11 @@
|
|
|
15
16
|
* self-scroll mode scrolls (#2573). In external-scrollRef mode the dock
|
|
16
17
|
* is position: fixed (out of flow) and the message area fills the root.
|
|
17
18
|
*
|
|
19
|
+
* Software keyboard (useChatKeyboard): the dock rests above the keyboard.
|
|
20
|
+
* The message area's end padding lets the newest message scroll above it.
|
|
21
|
+
* Both follow the keyboard height, and the keyboard's own motion rides on
|
|
22
|
+
* top. Every route into the composer's text skips Safari's page scroll.
|
|
23
|
+
*
|
|
18
24
|
* Density (compact/balanced/spacious) is controlled via a prop with
|
|
19
25
|
* 'balanced' as the default. No JS measurement or ResizeObserver needed.
|
|
20
26
|
* The container-type on root enables container queries in child components.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatLayout.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatLayout.tsx"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"ChatLayout.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatLayout.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAC,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AAItD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAsB5C,KAAK,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,eAAgB,SAAQ,SAAS,CAAC,cAAc,CAAC;IAChE,yCAAyC;IACzC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAEhC;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IAEvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAEhC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAEhD;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA4LD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,OAAoB,EACpB,UAAU,EACV,YAAY,EACZ,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EAAE,MAAM,EACrB,GAAG,EACH,GAAG,IAAI,EACR,EAAE,eAAe,+BAwIjB;yBArJe,UAAU"}
|
package/dist/Chat/ChatLayout.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file ChatLayout.tsx
|
|
7
|
-
* @input Uses React, StyleX, theme tokens, useChatStreamScroll, useChatNewMessages
|
|
7
|
+
* @input Uses React, StyleX, theme tokens, useChatStreamScroll, useChatNewMessages,
|
|
8
|
+
* useChatKeyboard
|
|
8
9
|
* @output Exports ChatLayout component and ChatLayoutProps
|
|
9
10
|
* @position Layout shell for full chat interfaces — messages in page flow, composer fixed to bottom
|
|
10
11
|
*
|
|
@@ -19,6 +20,11 @@
|
|
|
19
20
|
* self-scroll mode scrolls (#2573). In external-scrollRef mode the dock
|
|
20
21
|
* is position: fixed (out of flow) and the message area fills the root.
|
|
21
22
|
*
|
|
23
|
+
* Software keyboard (useChatKeyboard): the dock rests above the keyboard.
|
|
24
|
+
* The message area's end padding lets the newest message scroll above it.
|
|
25
|
+
* Both follow the keyboard height, and the keyboard's own motion rides on
|
|
26
|
+
* top. Every route into the composer's text skips Safari's page scroll.
|
|
27
|
+
*
|
|
22
28
|
* Density (compact/balanced/spacious) is controlled via a prop with
|
|
23
29
|
* 'balanced' as the default. No JS measurement or ResizeObserver needed.
|
|
24
30
|
* The container-type on root enables container queries in child components.
|
|
@@ -31,12 +37,15 @@
|
|
|
31
37
|
import { useMemo, useRef } from 'react';
|
|
32
38
|
import * as stylex from '@stylexjs/stylex';
|
|
33
39
|
import "../theme/tokens.stylex.js";
|
|
34
|
-
import { spacingVars } from "../theme/tokens.stylex.js";
|
|
40
|
+
import { focusVars, spacingVars } from "../theme/tokens.stylex.js";
|
|
41
|
+
import { focusOutlineStyles } from "../utils/focusOutline.stylex.js";
|
|
35
42
|
import { mergeProps } from "../utils/index.js";
|
|
36
43
|
import { useChatStreamScroll } from "./useChatStreamScroll.js";
|
|
37
44
|
import { useChatNewMessages } from "./useChatNewMessages.js";
|
|
45
|
+
import { useChatKeyboard } from "./useChatKeyboard.js";
|
|
38
46
|
import { ChatLayoutScrollButton } from "./ChatLayoutScrollButton.js";
|
|
39
47
|
import { ChatLayoutContext } from "./ChatContext.js";
|
|
48
|
+
import { KeyboardSurfaceContext } from "./keyboardSurface.js";
|
|
40
49
|
import { themeProps } from "../utils/themeProps.js";
|
|
41
50
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
42
51
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
@@ -46,7 +55,10 @@ registerEnglishFallback(english);
|
|
|
46
55
|
// =============================================================================
|
|
47
56
|
// Types
|
|
48
57
|
// =============================================================================
|
|
49
|
-
|
|
58
|
+
const _temp = {
|
|
59
|
+
kGO01o: "xdz27ya",
|
|
60
|
+
"$$css": true
|
|
61
|
+
};
|
|
50
62
|
// =============================================================================
|
|
51
63
|
// Styles
|
|
52
64
|
// =============================================================================
|
|
@@ -79,6 +91,33 @@ const styles = {
|
|
|
79
91
|
kg3NbH: "xnjsko4",
|
|
80
92
|
$$css: true
|
|
81
93
|
},
|
|
94
|
+
messageAreaKeyboard: lift => [_temp, {
|
|
95
|
+
"--x-paddingBlockEnd": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(`calc(${spacingVars['--spacing-6']} + ${lift}px)`)
|
|
96
|
+
}],
|
|
97
|
+
dockContainer: {
|
|
98
|
+
krVfgx: "x1ey2m1c",
|
|
99
|
+
kLqNvP: "x1o0tod",
|
|
100
|
+
kt4wiu: "xtijo5x",
|
|
101
|
+
kY2c9j: "x1ja2u2z",
|
|
102
|
+
kHBbk8: "xc8icb0",
|
|
103
|
+
kfzvcC: "x47corl",
|
|
104
|
+
kmuXW: "x2lah0s",
|
|
105
|
+
$$css: true
|
|
106
|
+
},
|
|
107
|
+
dockContainerFixed: {
|
|
108
|
+
kVAEAm: "xixxii4",
|
|
109
|
+
$$css: true
|
|
110
|
+
},
|
|
111
|
+
dockContainerSticky: {
|
|
112
|
+
kVAEAm: "x7wzq59",
|
|
113
|
+
$$css: true
|
|
114
|
+
},
|
|
115
|
+
dockLift: lift => [{
|
|
116
|
+
krVfgx: lift != null ? "x1nqzi6q" : lift,
|
|
117
|
+
$$css: true
|
|
118
|
+
}, {
|
|
119
|
+
"--x-bottom": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(lift)
|
|
120
|
+
}],
|
|
82
121
|
blurLayer: {
|
|
83
122
|
kVAEAm: "x10l6tqk",
|
|
84
123
|
krVfgx: "x1ey2m1c",
|
|
@@ -100,6 +139,10 @@ const styles = {
|
|
|
100
139
|
kGO01o: "xvmdzux",
|
|
101
140
|
$$css: true
|
|
102
141
|
},
|
|
142
|
+
dockFocusRing: {
|
|
143
|
+
kInvED: "x1nw7mhf",
|
|
144
|
+
$$css: true
|
|
145
|
+
},
|
|
103
146
|
dockInner: {
|
|
104
147
|
kUOVxO: "xvueqy4",
|
|
105
148
|
kzqmXN: "xh8yej3",
|
|
@@ -233,6 +276,14 @@ export function ChatLayout({
|
|
|
233
276
|
isLocked: scroll.isLocked,
|
|
234
277
|
onResize: scroll.scrollIfLocked
|
|
235
278
|
});
|
|
279
|
+
|
|
280
|
+
// --- Software keyboard ---
|
|
281
|
+
const keyboard = useChatKeyboard({
|
|
282
|
+
rootRef,
|
|
283
|
+
scrollRef: scrollContainerRef,
|
|
284
|
+
isSelfScrolling,
|
|
285
|
+
scrollToBottom: scroll.scrollToBottom
|
|
286
|
+
});
|
|
236
287
|
const defaultScrollButton = /*#__PURE__*/_jsx(ChatLayoutScrollButton, {
|
|
237
288
|
isVisible: scroll.isScrolledUp || newMsgs.hasNewMessages,
|
|
238
289
|
label: newMsgs.hasNewMessages ? t('@astryx.chatLayout.newMessages') : undefined,
|
|
@@ -281,7 +332,8 @@ export function ChatLayout({
|
|
|
281
332
|
density
|
|
282
333
|
}), stylex.props(styles.root, isSelfScrolling && styles.rootScrollable, xstyle), className, style),
|
|
283
334
|
children: [/*#__PURE__*/_jsx("div", {
|
|
284
|
-
|
|
335
|
+
ref: keyboard.messagesRef,
|
|
336
|
+
...stylex.props(styles.messageArea, currentDensity.messageArea, keyboard.lift > 0 && styles.messageAreaKeyboard(keyboard.lift)),
|
|
285
337
|
children: showEmpty && emptyState ? /*#__PURE__*/_jsx("div", {
|
|
286
338
|
...{
|
|
287
339
|
className: "x78zum5 x6s0dn4 xl56j7k x98rzlu xz65tgg"
|
|
@@ -289,21 +341,19 @@ export function ChatLayout({
|
|
|
289
341
|
children: emptyState
|
|
290
342
|
}) : children
|
|
291
343
|
}), /*#__PURE__*/_jsxs("div", {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
className: "x1ey2m1c x1o0tod xtijo5x x1ja2u2z xc8icb0 x47corl x2lah0s xixxii4"
|
|
295
|
-
},
|
|
296
|
-
1: {
|
|
297
|
-
className: "x1ey2m1c x1o0tod xtijo5x x1ja2u2z xc8icb0 x47corl x2lah0s x7wzq59"
|
|
298
|
-
}
|
|
299
|
-
}[!!isSelfScrolling << 0],
|
|
344
|
+
ref: keyboard.dockRef,
|
|
345
|
+
...stylex.props(styles.dockContainer, isSelfScrolling ? styles.dockContainerSticky : styles.dockContainerFixed, keyboard.lift > 0 && styles.dockLift(keyboard.lift)),
|
|
300
346
|
children: [scrollButton === undefined ? defaultScrollButton : scrollButton, /*#__PURE__*/_jsx("div", {
|
|
301
347
|
...stylex.props(styles.blurLayer, currentDensity.blurLayer)
|
|
302
|
-
}), /*#__PURE__*/_jsx(
|
|
303
|
-
|
|
348
|
+
}), /*#__PURE__*/_jsx(KeyboardSurfaceContext, {
|
|
349
|
+
value: true,
|
|
304
350
|
children: /*#__PURE__*/_jsx("div", {
|
|
305
|
-
|
|
306
|
-
|
|
351
|
+
ref: keyboard.composerRef,
|
|
352
|
+
...stylex.props(focusOutlineStyles.focusVisible, styles.dock, currentDensity.dock, styles.dockFocusRing),
|
|
353
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
354
|
+
...stylex.props(styles.dockInner, currentDensity.dockInner),
|
|
355
|
+
children: composer
|
|
356
|
+
})
|
|
307
357
|
})
|
|
308
358
|
})]
|
|
309
359
|
})]
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const KeyboardSurfaceContext: import("react").Context<boolean>;
|
|
2
|
+
/** Focuses `element` the way its surface wants (see the file header). */
|
|
3
|
+
export declare function focusInKeyboardSurface(element: HTMLElement, isKeyboardSurface: boolean): void;
|
|
4
|
+
//# sourceMappingURL=keyboardSurface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboardSurface.d.ts","sourceRoot":"","sources":["../../src/Chat/keyboardSurface.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,sBAAsB,kCAIlC,CAAC;AAEF,yEAAyE;AACzE,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,WAAW,EACpB,iBAAiB,EAAE,OAAO,GACzB,IAAI,CAMN"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file keyboardSurface.ts
|
|
7
|
+
* @input createSharedContext, the keyboard module's touch gate
|
|
8
|
+
* (followsKeyboard)
|
|
9
|
+
* @output Exports KeyboardSurfaceContext and focusInKeyboardSurface: whether a
|
|
10
|
+
* composer sits in ChatLayout's composer region, and the focus it delivers
|
|
11
|
+
* @position Internal to Chat: ChatLayout provides it; ChatComposer and
|
|
12
|
+
* ChatComposerInput read it
|
|
13
|
+
*
|
|
14
|
+
* Under a finger in a top-level page, focus skips the browser's reveal, which
|
|
15
|
+
* on iOS scrolls the whole page. Elsewhere the browser's own focus applies.
|
|
16
|
+
*
|
|
17
|
+
* SYNC: update ChatLayout.tsx, ChatComposer.tsx and ChatComposerInput.tsx
|
|
18
|
+
*/
|
|
19
|
+
import { followsKeyboard } from "../keyboard/keyboardTarget.js";
|
|
20
|
+
import { createSharedContext } from "../utils/sharedContext.js";
|
|
21
|
+
export const KeyboardSurfaceContext = createSharedContext('KeyboardSurfaceContext', 1, false);
|
|
22
|
+
|
|
23
|
+
/** Focuses `element` the way its surface wants (see the file header). */
|
|
24
|
+
export function focusInKeyboardSurface(element, isKeyboardSurface) {
|
|
25
|
+
if (isKeyboardSurface && followsKeyboard(element.ownerDocument.defaultView)) {
|
|
26
|
+
element.focus({
|
|
27
|
+
preventScroll: true
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
element.focus();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file useChatKeyboard.ts
|
|
3
|
+
* @input React refs, the keyboard module's height, focus routes and layout
|
|
4
|
+
* guide, the stream scroll's lock, the motion engine, the touch query and
|
|
5
|
+
* layout viewport height
|
|
6
|
+
* @output Exports useChatKeyboard: the lift for ChatLayout's dock and message
|
|
7
|
+
* area, and the refs for its dock, message area and composer region
|
|
8
|
+
* @position ChatLayout's keyboard behavior (Chat/ChatLayout.tsx); internal
|
|
9
|
+
*
|
|
10
|
+
* The composer sits on the keyboard, as in Messages on iOS. Where the layout
|
|
11
|
+
* guide publishes the keyboard's slide, the dock rides it on the compositor.
|
|
12
|
+
*
|
|
13
|
+
* SYNC: update Chat/ChatLayout.tsx, ChatLayout.doc.mjs and keyboard/README.md
|
|
14
|
+
*/
|
|
15
|
+
import { type RefObject } from 'react';
|
|
16
|
+
import { type UseChatStreamScrollReturn } from './useChatStreamScroll.js';
|
|
17
|
+
export interface UseChatKeyboardOptions {
|
|
18
|
+
/** ChatLayout's root. */
|
|
19
|
+
rootRef: RefObject<HTMLElement | null>;
|
|
20
|
+
/** The element that scrolls the transcript (the root, or an outer one). */
|
|
21
|
+
scrollRef: RefObject<HTMLElement | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the root scrolls itself (a sticky dock at its bottom) rather
|
|
24
|
+
* than an outer scroller (a fixed dock at the layout viewport's bottom).
|
|
25
|
+
*/
|
|
26
|
+
isSelfScrolling: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The stream scroll's jump to the newest message (useChatStreamScroll), the
|
|
29
|
+
* owner of the transcript's lock.
|
|
30
|
+
*/
|
|
31
|
+
scrollToBottom: UseChatStreamScrollReturn['scrollToBottom'];
|
|
32
|
+
}
|
|
33
|
+
export interface UseChatKeyboardResult {
|
|
34
|
+
/**
|
|
35
|
+
* The part of the keyboard over the dock, CSS px: the dock's offset from
|
|
36
|
+
* its bottom and the room the message area's end padding adds.
|
|
37
|
+
*/
|
|
38
|
+
lift: number;
|
|
39
|
+
/** Callback ref for the dock container. */
|
|
40
|
+
dockRef: (element: HTMLElement | null) => void;
|
|
41
|
+
/** Callback ref for the message area. */
|
|
42
|
+
messagesRef: (element: HTMLElement | null) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Ref for the composer region. Its text taps are claimed, and Done parks
|
|
45
|
+
* focus on it.
|
|
46
|
+
*/
|
|
47
|
+
composerRef: RefObject<HTMLDivElement | null>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The composer's text a touch landed in, when that tap would bring up the
|
|
51
|
+
* keyboard and the text has no focus yet. It is contenteditable text, or a
|
|
52
|
+
* text control passed as the composer's input. The browser would reveal
|
|
53
|
+
* either by scrolling the page. Exported for its tests.
|
|
54
|
+
*/
|
|
55
|
+
export declare function editableToClaim(target: unknown): HTMLElement | null;
|
|
56
|
+
/**
|
|
57
|
+
* Keeps ChatLayout's composer on top of the software keyboard.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```
|
|
61
|
+
* const keyboard = useChatKeyboard({rootRef, scrollRef, isSelfScrolling, scrollToBottom});
|
|
62
|
+
* <div ref={keyboard.messagesRef} {...stylex.props(styles.messages(keyboard.lift))}>…</div>
|
|
63
|
+
* <div ref={keyboard.dockRef} {...stylex.props(styles.dock(keyboard.lift))}>
|
|
64
|
+
* <div ref={keyboard.composerRef}>…</div>
|
|
65
|
+
* </div>
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function useChatKeyboard({ rootRef, scrollRef, isSelfScrolling, scrollToBottom, }: UseChatKeyboardOptions): UseChatKeyboardResult;
|
|
69
|
+
//# sourceMappingURL=useChatKeyboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatKeyboard.d.ts","sourceRoot":"","sources":["../../src/Chat/useChatKeyboard.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAyC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AA0B7E,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,sBAAsB;IACrC,yBAAyB;IACzB,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACvC,2EAA2E;IAC3E,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,cAAc,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C,yCAAyC;IACzC,WAAW,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD;;;OAGG;IACH,WAAW,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CAC/C;AAgCD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAuBnE;AAwBD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,SAAS,EACT,eAAe,EACf,cAAc,GACf,EAAE,sBAAsB,GAAG,qBAAqB,CAyShD"}
|