@pega/cosmos-react-core 8.9.5 → 8.10.0

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.
Files changed (53) hide show
  1. package/lib/components/Avatar/Avatar.d.ts.map +1 -1
  2. package/lib/components/Avatar/Avatar.js +10 -4
  3. package/lib/components/Avatar/Avatar.js.map +1 -1
  4. package/lib/components/PageTemplates/PageTemplates.js +3 -3
  5. package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
  6. package/lib/components/RadioCheck/RadioCheck.d.ts.map +1 -1
  7. package/lib/components/RadioCheck/RadioCheck.js +23 -6
  8. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  9. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts +4 -4
  10. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
  11. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +13 -2
  12. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  13. package/lib/components/SpeechToTextButton/SpeechToTextButton.d.ts +13 -0
  14. package/lib/components/SpeechToTextButton/SpeechToTextButton.d.ts.map +1 -0
  15. package/lib/components/SpeechToTextButton/SpeechToTextButton.js +29 -0
  16. package/lib/components/SpeechToTextButton/SpeechToTextButton.js.map +1 -0
  17. package/lib/components/SpeechToTextButton/SpeechToTextButton.test-ids.d.ts +2 -0
  18. package/lib/components/SpeechToTextButton/SpeechToTextButton.test-ids.d.ts.map +1 -0
  19. package/lib/components/SpeechToTextButton/SpeechToTextButton.test-ids.js +3 -0
  20. package/lib/components/SpeechToTextButton/SpeechToTextButton.test-ids.js.map +1 -0
  21. package/lib/components/SpeechToTextButton/index.d.ts +3 -0
  22. package/lib/components/SpeechToTextButton/index.d.ts.map +1 -0
  23. package/lib/components/SpeechToTextButton/index.js +2 -0
  24. package/lib/components/SpeechToTextButton/index.js.map +1 -0
  25. package/lib/hooks/index.d.ts +1 -0
  26. package/lib/hooks/index.d.ts.map +1 -1
  27. package/lib/hooks/index.js +1 -0
  28. package/lib/hooks/index.js.map +1 -1
  29. package/lib/hooks/useAnimatedText.d.ts +3 -1
  30. package/lib/hooks/useAnimatedText.d.ts.map +1 -1
  31. package/lib/hooks/useAnimatedText.js +10 -4
  32. package/lib/hooks/useAnimatedText.js.map +1 -1
  33. package/lib/hooks/useI18n.d.ts +14 -0
  34. package/lib/hooks/useI18n.d.ts.map +1 -1
  35. package/lib/hooks/useSpeechRecognition.d.ts +21 -0
  36. package/lib/hooks/useSpeechRecognition.d.ts.map +1 -0
  37. package/lib/hooks/useSpeechRecognition.js +122 -0
  38. package/lib/hooks/useSpeechRecognition.js.map +1 -0
  39. package/lib/i18n/default.d.ts +14 -0
  40. package/lib/i18n/default.d.ts.map +1 -1
  41. package/lib/i18n/default.js +17 -1
  42. package/lib/i18n/default.js.map +1 -1
  43. package/lib/i18n/i18n.d.ts +14 -0
  44. package/lib/i18n/i18n.d.ts.map +1 -1
  45. package/lib/index.d.ts +2 -0
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/index.js +2 -0
  48. package/lib/index.js.map +1 -1
  49. package/lib/theme/theme.d.ts +60 -0
  50. package/lib/theme/theme.d.ts.map +1 -1
  51. package/lib/theme/themeDefinition.json +32 -0
  52. package/lib/theme/themeOverrides.schema.json +42 -0
  53. package/package.json +2 -1
@@ -0,0 +1,13 @@
1
+ import { type Ref } from 'react';
2
+ import type { NoChildrenProp, TestIdProp, WithAttributes } from '../../types';
3
+ export type SpeechToTextButtonProps = WithAttributes<'button', NoChildrenProp & TestIdProp & {
4
+ /** Whether voice to text is active */
5
+ active: boolean;
6
+ /** Ref to the element */
7
+ ref?: Ref<HTMLButtonElement>;
8
+ }>;
9
+ declare const _default: import("react").ForwardRefExoticComponent<Omit<SpeechToTextButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>> & {
10
+ getTestIds: (testIdProp?: TestIdProp["testId"]) => import("../../types").TestIdsRecord<readonly []>;
11
+ };
12
+ export default _default;
13
+ //# sourceMappingURL=SpeechToTextButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpeechToTextButton.d.ts","sourceRoot":"","sources":["../../../src/components/SpeechToTextButton/SpeechToTextButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAMnE,OAAO,KAAK,EAAE,cAAc,EAAc,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAyB1F,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAClD,QAAQ,EACR,cAAc,GACZ,UAAU,GAAG;IACX,sCAAsC;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,yBAAyB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAC9B,CACJ,CAAC;;;;AAyBF,wBAA6E"}
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { mix } from 'polished';
5
+ import * as micIcon from '../Icon/icons/send-solid.icon';
6
+ import * as micSolidIcon from '../Icon/icons/square-solid.icon';
7
+ import { useI18n, useTestIds } from '../../hooks';
8
+ import Button from '../Button';
9
+ import Icon, { registerIcon } from '../Icon';
10
+ import { tryCatch, withTestIds } from '../../utils';
11
+ import { defaultThemeProp } from '../../theme';
12
+ import { getSpeechToTextButtonTestIds } from './SpeechToTextButton.test-ids';
13
+ registerIcon(micIcon, micSolidIcon);
14
+ const StyledSpeechToTextButton = styled(Button)(({ theme }) => {
15
+ const activeColor = tryCatch(() => mix(0.85, theme.base.palette['primary-background'], theme.base.palette.interactive));
16
+ return css `
17
+ &[aria-pressed='true'] {
18
+ background-color: ${activeColor};
19
+ }
20
+ `;
21
+ });
22
+ StyledSpeechToTextButton.defaultProps = defaultThemeProp;
23
+ const SpeechToTextButton = forwardRef(function SpeechToTextButton({ active, testId, ...restProps }, ref) {
24
+ const t = useI18n();
25
+ const testIds = useTestIds(testId, getSpeechToTextButtonTestIds);
26
+ return (_jsx(StyledSpeechToTextButton, { ref: ref, "data-testid": testIds.root, ...restProps, label: active ? t('stop_dictation') : t('dictate'), "aria-pressed": active, variant: 'simple', icon: true, children: _jsx(Icon, { name: active ? 'mic-solid' : 'mic' }) }));
27
+ });
28
+ export default withTestIds(SpeechToTextButton, getSpeechToTextButtonTestIds);
29
+ //# sourceMappingURL=SpeechToTextButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpeechToTextButton.js","sourceRoot":"","sources":["../../../src/components/SpeechToTextButton/SpeechToTextButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkC,MAAM,OAAO,CAAC;AACnE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAC;AACzD,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAE7E,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAEpC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5D,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,CAChC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CACpF,CAAC;IAEF,OAAO,GAAG,CAAA;;0BAEc,WAAW;;GAElC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,wBAAwB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAazD,MAAM,kBAAkB,GAAG,UAAU,CAGnC,SAAS,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,EAAE,GAAG;IACjE,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;IAEjE,OAAO,CACL,KAAC,wBAAwB,IACvB,GAAG,EAAE,GAAG,iBACK,OAAO,CAAC,IAAI,KACrB,SAAS,EACb,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,kBACpC,MAAM,EACpB,OAAO,EAAC,QAAQ,EAChB,IAAI,kBAEJ,KAAC,IAAI,IAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,GAAI,GACnB,CAC5B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAC","sourcesContent":["import { forwardRef, type PropsWithoutRef, type Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix } from 'polished';\n\nimport * as micIcon from '../Icon/icons/send-solid.icon';\nimport * as micSolidIcon from '../Icon/icons/square-solid.icon';\nimport type { NoChildrenProp, RefElement, TestIdProp, WithAttributes } from '../../types';\nimport { useI18n, useTestIds } from '../../hooks';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport { tryCatch, withTestIds } from '../../utils';\nimport { defaultThemeProp } from '../../theme';\n\nimport { getSpeechToTextButtonTestIds } from './SpeechToTextButton.test-ids';\n\nregisterIcon(micIcon, micSolidIcon);\n\nconst StyledSpeechToTextButton = styled(Button)(({ theme }) => {\n const activeColor = tryCatch(() =>\n mix(0.85, theme.base.palette['primary-background'], theme.base.palette.interactive)\n );\n\n return css`\n &[aria-pressed='true'] {\n background-color: ${activeColor};\n }\n `;\n});\n\nStyledSpeechToTextButton.defaultProps = defaultThemeProp;\n\nexport type SpeechToTextButtonProps = WithAttributes<\n 'button',\n NoChildrenProp &\n TestIdProp & {\n /** Whether voice to text is active */\n active: boolean;\n /** Ref to the element */\n ref?: Ref<HTMLButtonElement>;\n }\n>;\n\nconst SpeechToTextButton = forwardRef<\n RefElement<SpeechToTextButtonProps>,\n PropsWithoutRef<SpeechToTextButtonProps>\n>(function SpeechToTextButton({ active, testId, ...restProps }, ref) {\n const t = useI18n();\n\n const testIds = useTestIds(testId, getSpeechToTextButtonTestIds);\n\n return (\n <StyledSpeechToTextButton\n ref={ref}\n data-testid={testIds.root}\n {...restProps}\n label={active ? t('stop_dictation') : t('dictate')}\n aria-pressed={active}\n variant='simple'\n icon\n >\n <Icon name={active ? 'mic-solid' : 'mic'} />\n </StyledSpeechToTextButton>\n );\n});\n\nexport default withTestIds(SpeechToTextButton, getSpeechToTextButtonTestIds);\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getSpeechToTextButtonTestIds: (testIdProp?: import("../..").TestIdProp["testId"]) => import("../..").TestIdsRecord<readonly []>;
2
+ //# sourceMappingURL=SpeechToTextButton.test-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpeechToTextButton.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/SpeechToTextButton/SpeechToTextButton.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B,mGAAsD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { createTestIds } from '../../utils';
2
+ export const getSpeechToTextButtonTestIds = createTestIds('speech-to-text-button', []);
3
+ //# sourceMappingURL=SpeechToTextButton.test-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpeechToTextButton.test-ids.js","sourceRoot":"","sources":["../../../src/components/SpeechToTextButton/SpeechToTextButton.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,4BAA4B,GAAG,aAAa,CAAC,uBAAuB,EAAE,EAAW,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\n\nexport const getSpeechToTextButtonTestIds = createTestIds('speech-to-text-button', [] as const);\n"]}
@@ -0,0 +1,3 @@
1
+ export { default } from './SpeechToTextButton';
2
+ export type { SpeechToTextButtonProps } from './SpeechToTextButton';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SpeechToTextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from './SpeechToTextButton';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SpeechToTextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { default } from './SpeechToTextButton';\nexport type { SpeechToTextButtonProps } from './SpeechToTextButton';\n"]}
@@ -30,6 +30,7 @@ export { default as useRefMap } from './useRefMap';
30
30
  export { default as useSimpleStore, createSimpleStore } from './useSimpleStore';
31
31
  export type { SimpleStore } from './useSimpleStore';
32
32
  export { default as useSimpleStoreInstance } from './useSimpleStoreInstance';
33
+ export { default as useSpeechRecognition } from './useSpeechRecognition';
33
34
  export { default as useScrollStick } from './useScrollStick';
34
35
  export { default as useScrollToggle } from './useScrollToggle';
35
36
  export { default as useShortcut } from './useShortcut';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,YAAY,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,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kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -28,6 +28,7 @@ export { default as usePrevious } from './usePrevious';
28
28
  export { default as useRefMap } from './useRefMap';
29
29
  export { default as useSimpleStore, createSimpleStore } from './useSimpleStore';
30
30
  export { default as useSimpleStoreInstance } from './useSimpleStoreInstance';
31
+ export { default as useSpeechRecognition } from './useSpeechRecognition';
31
32
  export { default as useScrollStick } from './useScrollStick';
32
33
  export { default as useScrollToggle } from './useScrollToggle';
33
34
  export { default as useShortcut } from './useShortcut';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot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,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export { default as useActiveDescendant, useLazyDescendant } from './useActiveDescendant';\nexport type { UseActiveDescendantConfig } from './useActiveDescendant';\nexport { default as useAfterInitialEffect } from './useAfterInitialEffect';\nexport { default as useAnimatedText } from './useAnimatedText';\nexport { default as useArrows } from './useArrows';\nexport { default as useAutoResize } from './useAutoResize';\nexport { default as useBreakpoint } from './useBreakpoint';\nexport { default as useChToPxConversionFactor } from './useChToPxConversionFactor';\nexport { default as useConfiguration } from './useConfiguration';\nexport { default as useConsolidatedRef } from './useConsolidatedRef';\nexport { default as useDirection } from './useDirection';\nexport { default as useDraggable } from './useDraggable';\nexport { default as useElement } from './useElement';\nexport { default as useEscape } from './useEscape';\nexport { default as useEvent } from './useEvent';\nexport { default as useFocusTrap } from './useFocusTrap';\nexport { default as useFocusWithin } from './useFocusWithin';\nexport { default as useI18n } from './useI18n';\nexport { default as useInputFormatter } from './useInputFormatter';\nexport { default as useItemIntersection } from './useItemIntersection';\nexport { default as useLiveLog } from './useLiveLog';\nexport { default as useLongPress } from './useLongPress';\nexport { default as useModalContext } from './useModalContext';\nexport { default as useModalManager } from './useModalManager';\nexport { default as useOS } from './useOS';\nexport { default as useOuterEvent } from './useOuterEvent';\nexport { default as usePopoverMap } from './usePopoverMap';\nexport { default as usePrevious } from './usePrevious';\nexport { default as useRefMap } from './useRefMap';\nexport { default as useSimpleStore, createSimpleStore } from './useSimpleStore';\nexport type { SimpleStore } from './useSimpleStore';\nexport { default as useSimpleStoreInstance } from './useSimpleStoreInstance';\nexport { default as useScrollStick } from './useScrollStick';\nexport { default as useScrollToggle } from './useScrollToggle';\nexport { default as useShortcut } from './useShortcut';\nexport { default as useShortcutManager } from './useShortcutManager';\nexport { default as useTestIds } from './useTestIds';\nexport { default as useTheme } from './useTheme';\nexport { default as useToaster } from './useToaster';\nexport { default as useTransitionState } from './useTransitionState';\nexport { default as useTriggerableEffect } from './useTriggerableEffect';\nexport { default as useElementFocus } from './useElementFocus';\nexport { default as useTriggerableLayoutEffect } from './useTriggerableLayoutEffect';\nexport { default as useUID } from './useUID';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1F,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAA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mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export { default as useActiveDescendant, useLazyDescendant } from './useActiveDescendant';\nexport type { UseActiveDescendantConfig } from './useActiveDescendant';\nexport { default as useAfterInitialEffect } from './useAfterInitialEffect';\nexport { default as useAnimatedText } from './useAnimatedText';\nexport { default as useArrows } from './useArrows';\nexport { default as useAutoResize } from './useAutoResize';\nexport { default as useBreakpoint } from './useBreakpoint';\nexport { default as useChToPxConversionFactor } from './useChToPxConversionFactor';\nexport { default as useConfiguration } from './useConfiguration';\nexport { default as useConsolidatedRef } from './useConsolidatedRef';\nexport { default as useDirection } from './useDirection';\nexport { default as useDraggable } from './useDraggable';\nexport { default as useElement } from './useElement';\nexport { default as useEscape } from './useEscape';\nexport { default as useEvent } from './useEvent';\nexport { default as useFocusTrap } from './useFocusTrap';\nexport { default as useFocusWithin } from './useFocusWithin';\nexport { default as useI18n } from './useI18n';\nexport { default as useInputFormatter } from './useInputFormatter';\nexport { default as useItemIntersection } from './useItemIntersection';\nexport { default as useLiveLog } from './useLiveLog';\nexport { default as useLongPress } from './useLongPress';\nexport { default as useModalContext } from './useModalContext';\nexport { default as useModalManager } from './useModalManager';\nexport { default as useOS } from './useOS';\nexport { default as useOuterEvent } from './useOuterEvent';\nexport { default as usePopoverMap } from './usePopoverMap';\nexport { default as usePrevious } from './usePrevious';\nexport { default as useRefMap } from './useRefMap';\nexport { default as useSimpleStore, createSimpleStore } from './useSimpleStore';\nexport type { SimpleStore } from './useSimpleStore';\nexport { default as useSimpleStoreInstance } from './useSimpleStoreInstance';\nexport { default as useSpeechRecognition } from './useSpeechRecognition';\nexport { default as useScrollStick } from './useScrollStick';\nexport { default as useScrollToggle } from './useScrollToggle';\nexport { default as useShortcut } from './useShortcut';\nexport { default as useShortcutManager } from './useShortcutManager';\nexport { default as useTestIds } from './useTestIds';\nexport { default as useTheme } from './useTheme';\nexport { default as useToaster } from './useToaster';\nexport { default as useTransitionState } from './useTransitionState';\nexport { default as useTriggerableEffect } from './useTriggerableEffect';\nexport { default as useElementFocus } from './useElementFocus';\nexport { default as useTriggerableLayoutEffect } from './useTriggerableLayoutEffect';\nexport { default as useUID } from './useUID';\n"]}
@@ -1,11 +1,13 @@
1
- declare const useAnimatedText: ({ text, allContentReceived, enabled, tokenizeMarkdown }: {
1
+ declare const useAnimatedText: ({ text, allContentReceived, enabled, tokenizeMarkdown, cursorStartIndex }: {
2
2
  text: string;
3
3
  allContentReceived: boolean;
4
4
  enabled?: boolean;
5
5
  tokenizeMarkdown?: boolean;
6
+ cursorStartIndex?: number;
6
7
  }) => {
7
8
  text: string;
8
9
  isAnimationDone: boolean;
10
+ animatedTillCursor: number;
9
11
  };
10
12
  export default useAnimatedText;
11
13
  //# sourceMappingURL=useAnimatedText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAnimatedText.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnimatedText.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,eAAe,GAAI,yDAKtB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;;;CAiHA,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"useAnimatedText.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnimatedText.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,eAAe,GAAI,2EAMtB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;;;;CAwHA,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState, useRef } from 'react';
2
2
  import tokenizeWithMarkdown from '../utils/markdownTokenizer';
3
- const useAnimatedText = ({ text, allContentReceived = false, enabled = true, tokenizeMarkdown = false }) => {
3
+ const useAnimatedText = ({ text, allContentReceived = false, enabled = true, tokenizeMarkdown = false, cursorStartIndex }) => {
4
4
  const [cursor, setCursor] = useState(0); // End pointer
5
5
  const [startingCursor, setStartingCursor] = useState(0); // animation starting point
6
6
  const [prevText, setPrevText] = useState(text);
@@ -20,6 +20,11 @@ const useAnimatedText = ({ text, allContentReceived = false, enabled = true, tok
20
20
  setStartingCursor(text.startsWith(prevText) ? cursor : 0);
21
21
  setIsAnimationDone(false);
22
22
  }
23
+ useEffect(() => {
24
+ if (cursorStartIndex) {
25
+ setStartingCursor(cursorStartIndex);
26
+ }
27
+ }, []);
23
28
  useEffect(() => {
24
29
  // If streaming is disabled just return the whole chunk back
25
30
  if (!enabled) {
@@ -42,7 +47,7 @@ const useAnimatedText = ({ text, allContentReceived = false, enabled = true, tok
42
47
  let intervalId;
43
48
  let startTime;
44
49
  let isStopped = false;
45
- let currentSpeed = 50; // Start with normal speed
50
+ let currentSpeed = 100; // Start with normal speed
46
51
  let lastCursor = startingCursor;
47
52
  const processTextAnimation = () => {
48
53
  if (isStopped)
@@ -52,7 +57,7 @@ const useAnimatedText = ({ text, allContentReceived = false, enabled = true, tok
52
57
  startTime = currentTime;
53
58
  }
54
59
  // When we have all content with us, speed up streaming animation
55
- const targetSpeed = allContentReceivedRef.current ? 150 : 50;
60
+ const targetSpeed = allContentReceivedRef.current ? 150 : 100;
56
61
  // Smoothly transition to target speed
57
62
  const speedDiff = targetSpeed - currentSpeed;
58
63
  currentSpeed += speedDiff * 0.1; // Smooth transition
@@ -89,7 +94,8 @@ const useAnimatedText = ({ text, allContentReceived = false, enabled = true, tok
89
94
  }, [startingCursor, text, tokenizeMarkdown]);
90
95
  return {
91
96
  text: getTokens(text).slice(0, cursor).join(''),
92
- isAnimationDone
97
+ isAnimationDone,
98
+ animatedTillCursor: cursor
93
99
  };
94
100
  };
95
101
  export default useAnimatedText;
@@ -1 +1 @@
1
- {"version":3,"file":"useAnimatedText.js","sourceRoot":"","sources":["../../src/hooks/useAnimatedText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAE9D,MAAM,eAAe,GAAG,CAAC,EACvB,IAAI,EACJ,kBAAkB,GAAG,KAAK,EAC1B,OAAO,GAAG,IAAI,EACd,gBAAgB,GAAG,KAAK,EAMzB,EAAE,EAAE;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;IACvD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B;IAEpF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAA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,CAAC,CAAC;gBACzB,OAAO;YACT,CAAC;YAED,iCAAiC;YACjC,IAAI,SAAS,GAAG,YAAY,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;gBAC/D,4DAA4D;gBAC5D,MAAM,QAAQ,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,uBAAuB;gBACjF,UAAU,GAAG,UAAU,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAC;QAEF,yCAAyC;QACzC,UAAU,GAAG,UAAU,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QAElD,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,UAAU,EAAE,CAAC;gBACf,YAAY,CAAC,UAAU,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { useEffect, useState, useRef } from 'react';\n\nimport tokenizeWithMarkdown from '../utils/markdownTokenizer';\n\nconst useAnimatedText = ({\n text,\n allContentReceived = false,\n enabled = true,\n tokenizeMarkdown = false\n}: {\n text: string;\n allContentReceived: boolean;\n enabled?: boolean;\n tokenizeMarkdown?: boolean;\n}) => {\n const [cursor, setCursor] = useState(0); // End pointer\n const [startingCursor, setStartingCursor] = useState(0); // animation starting point\n\n const [prevText, setPrevText] = useState(text);\n const [isAnimationDone, setIsAnimationDone] = useState(false);\n\n const allContentReceivedRef = useRef(allContentReceived);\n\n allContentReceivedRef.current = allContentReceived;\n\n // Tokenize text based on markdown flag\n const getTokens = (inputText: string): string[] => {\n if (tokenizeMarkdown) {\n return tokenizeWithMarkdown(inputText);\n }\n return inputText.split('');\n };\n\n // A new chunk has arrived\n if (prevText !== text) {\n setPrevText(text);\n setStartingCursor(text.startsWith(prevText) ? cursor : 0);\n setIsAnimationDone(false);\n }\n\n useEffect(() => {\n // If streaming is disabled just return the whole chunk back\n if (!enabled) {\n setCursor(getTokens(text).length);\n setIsAnimationDone(true);\n return;\n }\n\n const tokens = getTokens(text);\n const targetLength = tokens.length;\n const charactersToAnimate = targetLength - startingCursor;\n\n // If there are no more characters to animate\n if (charactersToAnimate <= 0) {\n setCursor(targetLength);\n // Only set animation done if we have all content AND no more characters to animate\n if (allContentReceivedRef.current) {\n setIsAnimationDone(true);\n }\n return;\n }\n\n let intervalId: ReturnType<typeof setTimeout>;\n let startTime: number;\n let isStopped = false;\n let currentSpeed = 50; // Start with normal speed\n let lastCursor = startingCursor;\n\n const processTextAnimation = () => {\n if (isStopped) return;\n\n const currentTime = performance.now();\n\n if (!startTime) {\n startTime = currentTime;\n }\n\n // When we have all content with us, speed up streaming animation\n const targetSpeed = allContentReceivedRef.current ? 150 : 50;\n\n // Smoothly transition to target speed\n const speedDiff = targetSpeed - currentSpeed;\n currentSpeed += speedDiff * 0.1; // Smooth transition\n\n const elapsed = currentTime - startTime;\n const timeStep = elapsed / 1000;\n\n // Calculate how many characters we should have shown by now\n const expectedCursor = Math.min(startingCursor + timeStep * currentSpeed, targetLength);\n\n const newCursor = Math.min(Math.floor(expectedCursor), targetLength);\n\n // Skip update if the cursor is at the same token\n if (newCursor !== lastCursor) {\n setCursor(newCursor);\n lastCursor = newCursor;\n }\n\n // End condition - stop when we reach the target\n if (newCursor >= targetLength && allContentReceivedRef.current) {\n setIsAnimationDone(true);\n return;\n }\n\n // Continue animation if not done\n if (newCursor < targetLength || !allContentReceivedRef.current) {\n // Use adaptive timing based on content state and visibility\n const interval = allContentReceivedRef.current ? 20 : 50; // Faster when complete\n intervalId = setTimeout(processTextAnimation, interval);\n }\n };\n\n // Start the animation with initial delay\n intervalId = setTimeout(processTextAnimation, 16);\n\n return () => {\n isStopped = true;\n if (intervalId) {\n clearTimeout(intervalId);\n }\n };\n }, [startingCursor, text, tokenizeMarkdown]);\n\n return {\n text: getTokens(text).slice(0, cursor).join(''),\n isAnimationDone\n };\n};\n\nexport default useAnimatedText;\n"]}
1
+ {"version":3,"file":"useAnimatedText.js","sourceRoot":"","sources":["../../src/hooks/useAnimatedText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAE9D,MAAM,eAAe,GAAG,CAAC,EACvB,IAAI,EACJ,kBAAkB,GAAG,KAAK,EAC1B,OAAO,GAAG,IAAI,EACd,gBAAgB,GAAG,KAAK,EACxB,gBAAgB,EAOjB,EAAE,EAAE;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;IACvD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B;IAEpF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,qBAAqB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAEzD,qBAAqB,CAAC,OAAO,GAAG,kBAAkB,CAAC;IAEnD,uCAAuC;IACvC,MAAM,SAAS,GAAG,CAAC,SAAiB,EAAY,EAAE;QAChD,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,oBAAoB,CAAC,SAAS,CAAC,CAAC;QACzC,CAAC;QACD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CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,uBAAuB;gBACjF,UAAU,GAAG,UAAU,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAC;QAEF,yCAAyC;QACzC,UAAU,GAAG,UAAU,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QAElD,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,UAAU,EAAE,CAAC;gBACf,YAAY,CAAC,UAAU,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,eAAe;QACf,kBAAkB,EAAE,MAAM;KAC3B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { useEffect, useState, useRef } from 'react';\n\nimport tokenizeWithMarkdown from '../utils/markdownTokenizer';\n\nconst useAnimatedText = ({\n text,\n allContentReceived = false,\n enabled = true,\n tokenizeMarkdown = false,\n cursorStartIndex\n}: {\n text: string;\n allContentReceived: boolean;\n enabled?: boolean;\n tokenizeMarkdown?: boolean;\n cursorStartIndex?: number;\n}) => {\n const [cursor, setCursor] = useState(0); // End pointer\n const [startingCursor, setStartingCursor] = useState(0); // animation starting point\n\n const [prevText, setPrevText] = useState(text);\n const [isAnimationDone, setIsAnimationDone] = useState(false);\n\n const allContentReceivedRef = useRef(allContentReceived);\n\n allContentReceivedRef.current = allContentReceived;\n\n // Tokenize text based on markdown flag\n const getTokens = (inputText: string): string[] => {\n if (tokenizeMarkdown) {\n return tokenizeWithMarkdown(inputText);\n }\n return inputText.split('');\n };\n\n // A new chunk has arrived\n if (prevText !== text) {\n setPrevText(text);\n setStartingCursor(text.startsWith(prevText) ? cursor : 0);\n setIsAnimationDone(false);\n }\n\n useEffect(() => {\n if (cursorStartIndex) {\n setStartingCursor(cursorStartIndex);\n }\n }, []);\n\n useEffect(() => {\n // If streaming is disabled just return the whole chunk back\n if (!enabled) {\n setCursor(getTokens(text).length);\n setIsAnimationDone(true);\n return;\n }\n\n const tokens = getTokens(text);\n const targetLength = tokens.length;\n const charactersToAnimate = targetLength - startingCursor;\n\n // If there are no more characters to animate\n if (charactersToAnimate <= 0) {\n setCursor(targetLength);\n // Only set animation done if we have all content AND no more characters to animate\n if (allContentReceivedRef.current) {\n setIsAnimationDone(true);\n }\n return;\n }\n\n let intervalId: ReturnType<typeof setTimeout>;\n let startTime: number;\n let isStopped = false;\n let currentSpeed = 100; // Start with normal speed\n let lastCursor = startingCursor;\n\n const processTextAnimation = () => {\n if (isStopped) return;\n\n const currentTime = performance.now();\n\n if (!startTime) {\n startTime = currentTime;\n }\n\n // When we have all content with us, speed up streaming animation\n const targetSpeed = allContentReceivedRef.current ? 150 : 100;\n\n // Smoothly transition to target speed\n const speedDiff = targetSpeed - currentSpeed;\n currentSpeed += speedDiff * 0.1; // Smooth transition\n\n const elapsed = currentTime - startTime;\n const timeStep = elapsed / 1000;\n\n // Calculate how many characters we should have shown by now\n const expectedCursor = Math.min(startingCursor + timeStep * currentSpeed, targetLength);\n\n const newCursor = Math.min(Math.floor(expectedCursor), targetLength);\n\n // Skip update if the cursor is at the same token\n if (newCursor !== lastCursor) {\n setCursor(newCursor);\n lastCursor = newCursor;\n }\n\n // End condition - stop when we reach the target\n if (newCursor >= targetLength && allContentReceivedRef.current) {\n setIsAnimationDone(true);\n return;\n }\n\n // Continue animation if not done\n if (newCursor < targetLength || !allContentReceivedRef.current) {\n // Use adaptive timing based on content state and visibility\n const interval = allContentReceivedRef.current ? 20 : 50; // Faster when complete\n intervalId = setTimeout(processTextAnimation, interval);\n }\n };\n\n // Start the animation with initial delay\n intervalId = setTimeout(processTextAnimation, 16);\n\n return () => {\n isStopped = true;\n if (intervalId) {\n clearTimeout(intervalId);\n }\n };\n }, [startingCursor, text, tokenizeMarkdown]);\n\n return {\n text: getTokens(text).slice(0, cursor).join(''),\n isAnimationDone,\n animatedTillCursor: cursor\n };\n};\n\nexport default useAnimatedText;\n"]}
@@ -96,6 +96,12 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
96
96
  reset: string;
97
97
  refresh: string;
98
98
  copy: string;
99
+ explain: string;
100
+ generate: string;
101
+ reject: string;
102
+ modify: string;
103
+ start: string;
104
+ stop: string;
99
105
  view_all: string;
100
106
  view_less: string;
101
107
  show_more: string;
@@ -402,6 +408,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
402
408
  double_checking_results: string;
403
409
  finalizing_response: string;
404
410
  response_generated: string;
411
+ processing_speech: string;
405
412
  good_response: string;
406
413
  bad_response: string;
407
414
  share_feedback: string;
@@ -436,6 +443,13 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
436
443
  shortcut_DismissToast: string;
437
444
  configurable_layout_instructions: string;
438
445
  page_number: string;
446
+ dictate: string;
447
+ stop_dictation: string;
448
+ no_speech_detected: string;
449
+ no_microphone_found: string;
450
+ microphone_access_denied: string;
451
+ speech_recognition_error: string;
452
+ speech_recognition_not_supported: string;
439
453
  drag_handle_activate_description: string;
440
454
  drag_handle_drop_description: string;
441
455
  drag_handle_cancel_description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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provides real-time voice recognition with support for interim results and automatic error handling.
5
+ */
6
+ export interface UseSpeechRecognitionProps {
7
+ /** onResult handler */
8
+ onResult: (text: string) => void;
9
+ /** onInterimResult handler */
10
+ onInterimResult?: (text: string) => void;
11
+ /** BCP 47 language tag */
12
+ langCode?: string;
13
+ }
14
+ export default function useSpeechRecognition({ onResult, onInterimResult, langCode }: UseSpeechRecognitionProps): {
15
+ supported: boolean;
16
+ active: boolean;
17
+ error: string | null;
18
+ start: () => void;
19
+ stop: () => void;
20
+ };
21
+ //# sourceMappingURL=useSpeechRecognition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSpeechRecognition.d.ts","sourceRoot":"","sources":["../../src/hooks/useSpeechRecognition.ts"],"names":[],"mappings":";AAMA;;;GAGG;AAEH,MAAM,WAAW,yBAAyB;IACxC,uBAAuB;IACvB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,8BAA8B;IAC9B,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,QAAQ,EACR,eAAe,EACf,QAAwC,EACzC,EAAE,yBAAyB,GAAG;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CA2JA"}
@@ -0,0 +1,122 @@
1
+ /// <reference types="dom-speech-recognition" preserve="true" />
2
+ import { useCallback, useEffect, useRef, useState } from 'react';
3
+ import useI18n from './useI18n';
4
+ export default function useSpeechRecognition({ onResult, onInterimResult, langCode = navigator.language ?? 'en-US' }) {
5
+ const SpeechRecognitionAPI = window.SpeechRecognition ?? window.webkitSpeechRecognition;
6
+ const supported = !!SpeechRecognitionAPI;
7
+ const t = useI18n();
8
+ const [active, setActive] = useState(false);
9
+ const [error, setError] = useState(null);
10
+ const speechRecognitionRef = useRef(null);
11
+ const speechRecognitionACRef = useRef(new AbortController());
12
+ const onResultACRef = useRef(new AbortController());
13
+ const keepListeningRef = useRef(false);
14
+ const handleResult = useCallback((event) => {
15
+ let nextValue = '';
16
+ for (let i = event.resultIndex; i < event.results.length; i += 1) {
17
+ const result = event.results[i];
18
+ const processed = result[0].transcript;
19
+ nextValue += processed;
20
+ if (result.isFinal) {
21
+ onResult(nextValue);
22
+ }
23
+ else {
24
+ onInterimResult?.(nextValue);
25
+ }
26
+ }
27
+ }, [onResult, onInterimResult]);
28
+ useEffect(() => {
29
+ if (!speechRecognitionRef.current)
30
+ return;
31
+ onResultACRef.current.abort();
32
+ onResultACRef.current = new AbortController();
33
+ speechRecognitionRef.current.addEventListener('result', handleResult, {
34
+ signal: AbortSignal.any([speechRecognitionACRef.current.signal, onResultACRef.current.signal])
35
+ });
36
+ }, [handleResult]);
37
+ const startRecognition = useCallback(() => {
38
+ if (!supported)
39
+ return;
40
+ // abort previous listeners/session
41
+ speechRecognitionACRef.current.abort();
42
+ speechRecognitionACRef.current = new AbortController();
43
+ const recognition = new SpeechRecognitionAPI();
44
+ recognition.lang = langCode;
45
+ recognition.interimResults = true;
46
+ recognition.maxAlternatives = 1;
47
+ recognition.continuous = true;
48
+ recognition.addEventListener('start', () => {
49
+ setActive(true);
50
+ setError(null);
51
+ }, { signal: speechRecognitionACRef.current.signal });
52
+ recognition.addEventListener('result', handleResult, {
53
+ signal: AbortSignal.any([speechRecognitionACRef.current.signal, onResultACRef.current.signal])
54
+ });
55
+ recognition.addEventListener('error', event => {
56
+ if (event.error === 'no-speech') {
57
+ setError(t('no_speech_detected'));
58
+ }
59
+ else if (event.error === 'audio-capture') {
60
+ setError(t('no_microphone_found'));
61
+ }
62
+ else if (event.error === 'not-allowed') {
63
+ setError(t('microphone_access_denied'));
64
+ }
65
+ else {
66
+ setError(t('speech_recognition_error', [event.error]));
67
+ }
68
+ setActive(false);
69
+ }, { signal: speechRecognitionACRef.current.signal });
70
+ recognition.addEventListener('end', () => {
71
+ if (keepListeningRef.current) {
72
+ startRecognition();
73
+ }
74
+ else {
75
+ setActive(false);
76
+ }
77
+ }, { signal: speechRecognitionACRef.current.signal });
78
+ speechRecognitionRef.current = recognition;
79
+ recognition.start();
80
+ }, [SpeechRecognitionAPI, langCode, t, handleResult, supported]);
81
+ const stop = useCallback(() => {
82
+ keepListeningRef.current = false;
83
+ const recognition = speechRecognitionRef.current;
84
+ if (!recognition) {
85
+ setActive(false);
86
+ return;
87
+ }
88
+ recognition.stop();
89
+ }, []);
90
+ const start = useCallback(() => {
91
+ setError(null);
92
+ if (!supported) {
93
+ setError(t('speech_recognition_not_supported'));
94
+ return;
95
+ }
96
+ keepListeningRef.current = true;
97
+ startRecognition();
98
+ }, [startRecognition, supported, t]);
99
+ // Stop recognition on page hide or visibility change
100
+ useEffect(() => {
101
+ const ac = new AbortController();
102
+ const handleVisibilityChange = () => {
103
+ if (document.visibilityState !== 'visible') {
104
+ stop();
105
+ }
106
+ };
107
+ window.addEventListener('pagehide', stop, { signal: ac.signal });
108
+ window.addEventListener('blur', stop, { signal: ac.signal });
109
+ document.addEventListener('visibilitychange', handleVisibilityChange, { signal: ac.signal });
110
+ return () => {
111
+ ac.abort();
112
+ };
113
+ }, []);
114
+ return {
115
+ supported,
116
+ active,
117
+ error,
118
+ start,
119
+ stop
120
+ };
121
+ }
122
+ //# sourceMappingURL=useSpeechRecognition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSpeechRecognition.js","sourceRoot":"","sources":["../../src/hooks/useSpeechRecognition.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,OAAO,MAA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AC,CAAC;QAC7D,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,sBAAsB,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAE7F,OAAO,GAAG,EAAE;YACV,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,SAAS;QACT,MAAM;QACN,KAAK;QACL,KAAK;QACL,IAAI;KACL,CAAC;AACJ,CAAC","sourcesContent":["/// <reference types=\"dom-speech-recognition\" preserve=\"true\" />\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport useI18n from './useI18n';\n\n/**\n * Hook for speech-to-text conversion using the Web Speech API.\n * Provides real-time voice recognition with support for interim results and automatic error handling.\n */\n\nexport interface UseSpeechRecognitionProps {\n /** onResult handler */\n onResult: (text: string) => void;\n /** onInterimResult handler */\n onInterimResult?: (text: string) => void;\n /** BCP 47 language tag */\n langCode?: string;\n}\n\nexport default function useSpeechRecognition({\n onResult,\n onInterimResult,\n langCode = navigator.language ?? 'en-US'\n}: UseSpeechRecognitionProps): {\n supported: boolean;\n active: boolean;\n error: string | null;\n start: () => void;\n stop: () => void;\n} {\n const SpeechRecognitionAPI: typeof SpeechRecognition | undefined =\n window.SpeechRecognition ?? window.webkitSpeechRecognition;\n\n const supported = !!SpeechRecognitionAPI;\n\n const t = useI18n();\n const [active, setActive] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const speechRecognitionRef = useRef<SpeechRecognition | null>(null);\n const speechRecognitionACRef = useRef(new AbortController());\n const onResultACRef = useRef(new AbortController());\n const keepListeningRef = useRef<boolean>(false);\n\n const handleResult = useCallback(\n (event: SpeechRecognitionEvent) => {\n let nextValue = '';\n\n for (let i = event.resultIndex; i < event.results.length; i += 1) {\n const result = event.results[i];\n const processed = result[0].transcript;\n nextValue += processed;\n\n if (result.isFinal) {\n onResult(nextValue);\n } else {\n onInterimResult?.(nextValue);\n }\n }\n },\n [onResult, onInterimResult]\n );\n\n useEffect(() => {\n if (!speechRecognitionRef.current) return;\n\n onResultACRef.current.abort();\n onResultACRef.current = new AbortController();\n\n speechRecognitionRef.current.addEventListener('result', handleResult, {\n signal: AbortSignal.any([speechRecognitionACRef.current.signal, onResultACRef.current.signal])\n });\n }, [handleResult]);\n\n const startRecognition = useCallback(() => {\n if (!supported) return;\n\n // abort previous listeners/session\n speechRecognitionACRef.current.abort();\n speechRecognitionACRef.current = new AbortController();\n\n const recognition = new SpeechRecognitionAPI();\n recognition.lang = langCode;\n recognition.interimResults = true;\n recognition.maxAlternatives = 1;\n recognition.continuous = true;\n\n recognition.addEventListener(\n 'start',\n () => {\n setActive(true);\n setError(null);\n },\n { signal: speechRecognitionACRef.current.signal }\n );\n\n recognition.addEventListener('result', handleResult, {\n signal: AbortSignal.any([speechRecognitionACRef.current.signal, onResultACRef.current.signal])\n });\n\n recognition.addEventListener(\n 'error',\n event => {\n if (event.error === 'no-speech') {\n setError(t('no_speech_detected'));\n } else if (event.error === 'audio-capture') {\n setError(t('no_microphone_found'));\n } else if (event.error === 'not-allowed') {\n setError(t('microphone_access_denied'));\n } else {\n setError(t('speech_recognition_error', [event.error]));\n }\n setActive(false);\n },\n { signal: speechRecognitionACRef.current.signal }\n );\n\n recognition.addEventListener(\n 'end',\n () => {\n if (keepListeningRef.current) {\n startRecognition();\n } else {\n setActive(false);\n }\n },\n { signal: speechRecognitionACRef.current.signal }\n );\n\n speechRecognitionRef.current = recognition;\n recognition.start();\n }, [SpeechRecognitionAPI, langCode, t, handleResult, supported]);\n\n const stop = useCallback(() => {\n keepListeningRef.current = false;\n\n const recognition = speechRecognitionRef.current;\n\n if (!recognition) {\n setActive(false);\n return;\n }\n\n recognition.stop();\n }, []);\n\n const start = useCallback(() => {\n setError(null);\n\n if (!supported) {\n setError(t('speech_recognition_not_supported'));\n return;\n }\n\n keepListeningRef.current = true;\n startRecognition();\n }, [startRecognition, supported, t]);\n\n // Stop recognition on page hide or visibility change\n useEffect(() => {\n const ac = new AbortController();\n\n const handleVisibilityChange = () => {\n if (document.visibilityState !== 'visible') {\n stop();\n }\n };\n\n window.addEventListener('pagehide', stop, { signal: ac.signal });\n window.addEventListener('blur', stop, { signal: ac.signal });\n document.addEventListener('visibilitychange', handleVisibilityChange, { signal: ac.signal });\n\n return () => {\n ac.abort();\n };\n }, []);\n\n return {\n supported,\n active,\n error,\n start,\n stop\n };\n}\n"]}
@@ -92,6 +92,12 @@ declare const _default: {
92
92
  reset: string;
93
93
  refresh: string;
94
94
  copy: string;
95
+ explain: string;
96
+ generate: string;
97
+ reject: string;
98
+ modify: string;
99
+ start: string;
100
+ stop: string;
95
101
  view_all: string;
96
102
  view_less: string;
97
103
  show_more: string;
@@ -398,6 +404,7 @@ declare const _default: {
398
404
  double_checking_results: string;
399
405
  finalizing_response: string;
400
406
  response_generated: string;
407
+ processing_speech: string;
401
408
  good_response: string;
402
409
  bad_response: string;
403
410
  share_feedback: string;
@@ -432,6 +439,13 @@ declare const _default: {
432
439
  shortcut_DismissToast: string;
433
440
  configurable_layout_instructions: string;
434
441
  page_number: string;
442
+ dictate: string;
443
+ stop_dictation: string;
444
+ no_speech_detected: string;
445
+ no_microphone_found: string;
446
+ microphone_access_denied: string;
447
+ speech_recognition_error: string;
448
+ speech_recognition_not_supported: string;
435
449
  drag_handle_activate_description: string;
436
450
  drag_handle_drop_description: string;
437
451
  drag_handle_cancel_description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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 'Start',
105
+ stop: 'Stop',
100
106
  /* Static verb noun */
101
107
  view_all: 'View all',
102
108
  view_less: 'View less',
@@ -427,7 +433,7 @@ export default {
427
433
  agent: 'Agent',
428
434
  chat_with_ai: 'Chat with AI',
429
435
  agent_noun: '{0} agent',
430
- welcome_text: 'How can I help you?',
436
+ welcome_text: 'How can I assist you today?',
431
437
  start_chat: 'Start chat',
432
438
  starter_message: 'Starter message',
433
439
  ask_coach: 'Ask {0}',
@@ -437,6 +443,7 @@ export default {
437
443
  double_checking_results: 'Double checking results',
438
444
  finalizing_response: 'Finalizing response',
439
445
  response_generated: 'Response generated',
446
+ processing_speech: 'Processing speech',
440
447
  good_response: 'Good response',
441
448
  bad_response: 'Bad response',
442
449
  share_feedback: 'Share feedback',
@@ -478,6 +485,15 @@ export default {
478
485
  /* core: PageTemplates */
479
486
  configurable_layout_instructions: 'Configurable layout. Use tab key to select an item. Use arrow keys to move it to a new position. Use arrow keys with shift to resize the item in the given direction.',
480
487
  page_number: 'Page {0}',
488
+ /* core:SpeechToTextButton */
489
+ dictate: 'Dictate',
490
+ stop_dictation: 'Stop dictation',
491
+ /* core:SpeechRecognition */
492
+ no_speech_detected: 'No speech was detected. Please try speaking again.',
493
+ no_microphone_found: 'No microphone was found. Please check your audio input.',
494
+ microphone_access_denied: 'Microphone access was denied. Please allow access and try again.',
495
+ speech_recognition_error: 'Speech recognition error: {0}',
496
+ speech_recognition_not_supported: 'Speech recognition is not supported in this browser.',
481
497
  /* dnd:DragHandle */
482
498
  drag_handle_activate_description: 'Press Space to activate dragging.',
483
499
  drag_handle_drop_description: 'Press Space again to drop.',