@unif/react-native-design 0.20.0 → 0.21.1
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/README.md +121 -12
- package/lib/module/components/business/AvatarWithRing/AvatarWithRing.js +4 -5
- package/lib/module/components/business/AvatarWithRing/AvatarWithRing.js.map +1 -1
- package/lib/module/components/business/AvatarWithRing/styles.js +10 -9
- package/lib/module/components/business/AvatarWithRing/styles.js.map +1 -1
- package/lib/module/components/business/VersionPill/VersionPill.js +32 -15
- package/lib/module/components/business/VersionPill/VersionPill.js.map +1 -1
- package/lib/module/components/business/VersionPill/content.js +30 -0
- package/lib/module/components/business/VersionPill/content.js.map +1 -0
- package/lib/module/components/business/VersionPill/styles.js +4 -0
- package/lib/module/components/business/VersionPill/styles.js.map +1 -1
- package/lib/module/components/business/useSvgId.js +17 -8
- package/lib/module/components/business/useSvgId.js.map +1 -1
- package/lib/module/components/ui/Avatar/Avatar.js +22 -29
- package/lib/module/components/ui/Avatar/Avatar.js.map +1 -1
- package/lib/module/components/ui/Button/Button.js +40 -23
- package/lib/module/components/ui/Button/Button.js.map +1 -1
- package/lib/module/components/ui/Button/ButtonBase.js +13 -13
- package/lib/module/components/ui/Button/ButtonBase.js.map +1 -1
- package/lib/module/components/ui/Carousel/Carousel.js +68 -40
- package/lib/module/components/ui/Carousel/Carousel.js.map +1 -1
- package/lib/module/components/ui/Carousel/behavior.js +60 -0
- package/lib/module/components/ui/Carousel/behavior.js.map +1 -0
- package/lib/module/components/ui/Carousel/styles.js +6 -8
- package/lib/module/components/ui/Carousel/styles.js.map +1 -1
- package/lib/module/components/ui/Cell/Cell.js +76 -65
- package/lib/module/components/ui/Cell/Cell.js.map +1 -1
- package/lib/module/components/ui/Cell/Leading.js +11 -5
- package/lib/module/components/ui/Cell/Leading.js.map +1 -1
- package/lib/module/components/ui/Cell/content.js +34 -0
- package/lib/module/components/ui/Cell/content.js.map +1 -0
- package/lib/module/components/ui/Checkbox/Checkbox.js +25 -8
- package/lib/module/components/ui/Checkbox/Checkbox.js.map +1 -1
- package/lib/module/components/ui/Confirm/ConfirmHost.js +49 -25
- package/lib/module/components/ui/Confirm/ConfirmHost.js.map +1 -1
- package/lib/module/components/ui/Confirm/confirm.js +15 -29
- package/lib/module/components/ui/Confirm/confirm.js.map +1 -1
- package/lib/module/components/ui/Confirm/labels.js +10 -0
- package/lib/module/components/ui/Confirm/labels.js.map +1 -0
- package/lib/module/components/ui/Confirm/store.js +113 -0
- package/lib/module/components/ui/Confirm/store.js.map +1 -0
- package/lib/module/components/ui/Confirm/styles.js +4 -0
- package/lib/module/components/ui/Confirm/styles.js.map +1 -1
- package/lib/module/components/ui/DrawerHeader/DrawerHeader.js +17 -25
- package/lib/module/components/ui/DrawerHeader/DrawerHeader.js.map +1 -1
- package/lib/module/components/ui/Grid/Grid.js +26 -9
- package/lib/module/components/ui/Grid/Grid.js.map +1 -1
- package/lib/module/components/ui/Grid/accessibility.js +13 -0
- package/lib/module/components/ui/Grid/accessibility.js.map +1 -0
- package/lib/module/components/ui/IconButton/IconButton.js +16 -3
- package/lib/module/components/ui/IconButton/IconButton.js.map +1 -1
- package/lib/module/components/ui/Input/Input.js +8 -5
- package/lib/module/components/ui/Input/Input.js.map +1 -1
- package/lib/module/components/ui/Logo/Logo.js +22 -4
- package/lib/module/components/ui/Logo/Logo.js.map +1 -1
- package/lib/module/components/ui/NavBar/NavBar.js +23 -14
- package/lib/module/components/ui/NavBar/NavBar.js.map +1 -1
- package/lib/module/components/ui/NavBar/isSlot.js +297 -4
- package/lib/module/components/ui/NavBar/isSlot.js.map +1 -1
- package/lib/module/components/ui/PasswordInput/PasswordInput.js +61 -66
- package/lib/module/components/ui/PasswordInput/PasswordInput.js.map +1 -1
- package/lib/module/components/ui/Pulse/Pulse.js +1 -1
- package/lib/module/components/ui/Pulse/Pulse.js.map +1 -1
- package/lib/module/components/ui/Pulse/PulseDot.js +5 -7
- package/lib/module/components/ui/Pulse/PulseDot.js.map +1 -1
- package/lib/module/components/ui/Pulse/index.js +1 -1
- package/lib/module/components/ui/Pulse/index.js.map +1 -1
- package/lib/module/components/ui/Pulse/normalizePulseOptions.js +45 -0
- package/lib/module/components/ui/Pulse/normalizePulseOptions.js.map +1 -0
- package/lib/module/components/ui/Pulse/usePulse.js +61 -24
- package/lib/module/components/ui/Pulse/usePulse.js.map +1 -1
- package/lib/module/components/ui/Pulse/usePulseDriver.js +44 -0
- package/lib/module/components/ui/Pulse/usePulseDriver.js.map +1 -0
- package/lib/module/components/ui/Pulse/usePulseDriver.web.js +67 -0
- package/lib/module/components/ui/Pulse/usePulseDriver.web.js.map +1 -0
- package/lib/module/components/ui/Radio/Radio.js +31 -14
- package/lib/module/components/ui/Radio/Radio.js.map +1 -1
- package/lib/module/components/ui/Radio/RadioGroup.js +15 -2
- package/lib/module/components/ui/Radio/RadioGroup.js.map +1 -1
- package/lib/module/components/ui/Reveal/Reveal.js +4 -3
- package/lib/module/components/ui/Reveal/Reveal.js.map +1 -1
- package/lib/module/components/ui/Reveal/Reveal.web.js +55 -32
- package/lib/module/components/ui/Reveal/Reveal.web.js.map +1 -1
- package/lib/module/components/ui/Reveal/webTransition.js +157 -0
- package/lib/module/components/ui/Reveal/webTransition.js.map +1 -0
- package/lib/module/components/ui/Search/Search.js +85 -58
- package/lib/module/components/ui/Search/Search.js.map +1 -1
- package/lib/module/components/ui/Segmented/Segmented.js +4 -2
- package/lib/module/components/ui/Segmented/Segmented.js.map +1 -1
- package/lib/module/components/ui/Skeleton/Skeleton.js +5 -7
- package/lib/module/components/ui/Skeleton/Skeleton.js.map +1 -1
- package/lib/module/components/ui/Spinner/Spinner.js +18 -11
- package/lib/module/components/ui/Spinner/Spinner.js.map +1 -1
- package/lib/module/components/ui/Spinner/Spinner.web.js +18 -14
- package/lib/module/components/ui/Spinner/Spinner.web.js.map +1 -1
- package/lib/module/components/ui/Spinner/shared.js +6 -0
- package/lib/module/components/ui/Spinner/shared.js.map +1 -1
- package/lib/module/components/ui/Stepper/Stepper.js +131 -99
- package/lib/module/components/ui/Stepper/Stepper.js.map +1 -1
- package/lib/module/components/ui/Stepper/StepperPressable.js +4 -0
- package/lib/module/components/ui/Stepper/StepperPressable.js.map +1 -0
- package/lib/module/components/ui/Stepper/StepperPressable.web.js +4 -0
- package/lib/module/components/ui/Stepper/StepperPressable.web.js.map +1 -0
- package/lib/module/components/ui/Stepper/accessibility.js +30 -0
- package/lib/module/components/ui/Stepper/accessibility.js.map +1 -0
- package/lib/module/components/ui/Stepper/accessibility.types.js +4 -0
- package/lib/module/components/ui/Stepper/accessibility.types.js.map +1 -0
- package/lib/module/components/ui/Stepper/accessibility.web.js +57 -0
- package/lib/module/components/ui/Stepper/accessibility.web.js.map +1 -0
- package/lib/module/components/ui/Stepper/layout.js +28 -0
- package/lib/module/components/ui/Stepper/layout.js.map +1 -0
- package/lib/module/components/ui/Stepper/normalizeStepper.js +53 -0
- package/lib/module/components/ui/Stepper/normalizeStepper.js.map +1 -0
- package/lib/module/components/ui/Stepper/styles.js +9 -2
- package/lib/module/components/ui/Stepper/styles.js.map +1 -1
- package/lib/module/components/ui/Switch/Switch.js +45 -19
- package/lib/module/components/ui/Switch/Switch.js.map +1 -1
- package/lib/module/components/ui/Switch/Switch.web.js +47 -20
- package/lib/module/components/ui/Switch/Switch.web.js.map +1 -1
- package/lib/module/components/ui/Switch/styles.js +12 -5
- package/lib/module/components/ui/Switch/styles.js.map +1 -1
- package/lib/module/components/ui/Tag/Tag.js +3 -2
- package/lib/module/components/ui/Tag/Tag.js.map +1 -1
- package/lib/module/components/ui/TextField/TextFieldBase.js +131 -86
- package/lib/module/components/ui/TextField/TextFieldBase.js.map +1 -1
- package/lib/module/components/ui/TextField/TextFieldSlot.js +82 -0
- package/lib/module/components/ui/TextField/TextFieldSlot.js.map +1 -0
- package/lib/module/components/ui/TextField/normalize.js +238 -0
- package/lib/module/components/ui/TextField/normalize.js.map +1 -0
- package/lib/module/components/ui/TextField/styles.js +31 -0
- package/lib/module/components/ui/TextField/styles.js.map +1 -1
- package/lib/module/components/ui/TextField/useErrorAnnouncement.js +27 -0
- package/lib/module/components/ui/TextField/useErrorAnnouncement.js.map +1 -0
- package/lib/module/components/ui/TextField/useTextFieldValue.js +66 -0
- package/lib/module/components/ui/TextField/useTextFieldValue.js.map +1 -0
- package/lib/module/components/ui/TextField/valueState.js +93 -0
- package/lib/module/components/ui/TextField/valueState.js.map +1 -0
- package/lib/module/components/ui/Textarea/Textarea.js +7 -3
- package/lib/module/components/ui/Textarea/Textarea.js.map +1 -1
- package/lib/module/components/ui/Thumbnail/Thumbnail.js +67 -48
- package/lib/module/components/ui/Thumbnail/Thumbnail.js.map +1 -1
- package/lib/module/components/ui/Thumbnail/normalize.js +58 -0
- package/lib/module/components/ui/Thumbnail/normalize.js.map +1 -0
- package/lib/module/components/ui/Thumbnail/styles.js +6 -11
- package/lib/module/components/ui/Thumbnail/styles.js.map +1 -1
- package/lib/module/components/ui/Toast/ToastHost.js +64 -21
- package/lib/module/components/ui/Toast/ToastHost.js.map +1 -1
- package/lib/module/components/ui/Toast/ToastHost.web.js +73 -24
- package/lib/module/components/ui/Toast/ToastHost.web.js.map +1 -1
- package/lib/module/components/ui/Toast/store.js +110 -0
- package/lib/module/components/ui/Toast/store.js.map +1 -0
- package/lib/module/components/ui/Toast/toast.js +17 -7
- package/lib/module/components/ui/Toast/toast.js.map +1 -1
- package/lib/module/components/ui/index.js.map +1 -1
- package/lib/module/components/ui/shared/ImageAttempt.js +28 -0
- package/lib/module/components/ui/shared/ImageAttempt.js.map +1 -0
- package/lib/module/components/ui/shared/a11y.js +21 -0
- package/lib/module/components/ui/shared/a11y.js.map +1 -0
- package/lib/module/components/ui/shared/accessibilityName.js +9 -0
- package/lib/module/components/ui/shared/accessibilityName.js.map +1 -0
- package/lib/module/components/ui/shared/selectImageAttemptSource.js +5 -0
- package/lib/module/components/ui/shared/selectImageAttemptSource.js.map +1 -0
- package/lib/module/components/ui/shared/selectImageAttemptSource.shared.js +13 -0
- package/lib/module/components/ui/shared/selectImageAttemptSource.shared.js.map +1 -0
- package/lib/module/components/ui/shared/selectImageAttemptSource.web.js +5 -0
- package/lib/module/components/ui/shared/selectImageAttemptSource.web.js.map +1 -0
- package/lib/module/icons/data.js +1 -1
- package/lib/module/icons/data.js.map +1 -1
- package/lib/module/theme/ThemeProvider.js +14 -4
- package/lib/module/theme/ThemeProvider.js.map +1 -1
- package/lib/module/theme/fontScale.js +13 -0
- package/lib/module/theme/fontScale.js.map +1 -0
- package/lib/module/theme/index.js +2 -4
- package/lib/module/theme/index.js.map +1 -1
- package/lib/module/theme/themeContext.js +15 -0
- package/lib/module/theme/themeContext.js.map +1 -0
- package/lib/module/theme/themeDiagnostics.js +29 -0
- package/lib/module/theme/themeDiagnostics.js.map +1 -0
- package/lib/module/theme/usePrefersReducedMotion.js +11 -4
- package/lib/module/theme/usePrefersReducedMotion.js.map +1 -1
- package/lib/module/theme/usePrefersReducedMotion.web.js +5 -2
- package/lib/module/theme/usePrefersReducedMotion.web.js.map +1 -1
- package/lib/module/theme/useTheme.js +12 -25
- package/lib/module/theme/useTheme.js.map +1 -1
- package/lib/module/theme/useThemedStyles.js +9 -6
- package/lib/module/theme/useThemedStyles.js.map +1 -1
- package/lib/module/utils/imageSource.js +198 -0
- package/lib/module/utils/imageSource.js.map +1 -0
- package/lib/typescript/manual-tests/runtime-api/RuntimeApiScreen.d.ts +12 -0
- package/lib/typescript/manual-tests/runtime-api/RuntimeApiScreen.d.ts.map +1 -0
- package/lib/typescript/src/components/business/AvatarWithRing/AvatarWithRing.d.ts.map +1 -1
- package/lib/typescript/src/components/business/AvatarWithRing/styles.d.ts +8 -7
- package/lib/typescript/src/components/business/AvatarWithRing/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/business/VersionPill/VersionPill.d.ts +1 -1
- package/lib/typescript/src/components/business/VersionPill/VersionPill.d.ts.map +1 -1
- package/lib/typescript/src/components/business/VersionPill/content.d.ts +19 -0
- package/lib/typescript/src/components/business/VersionPill/content.d.ts.map +1 -0
- package/lib/typescript/src/components/business/VersionPill/index.d.ts +1 -1
- package/lib/typescript/src/components/business/VersionPill/index.d.ts.map +1 -1
- package/lib/typescript/src/components/business/VersionPill/styles.d.ts +4 -0
- package/lib/typescript/src/components/business/VersionPill/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/business/VersionPill/types.d.ts +6 -2
- package/lib/typescript/src/components/business/VersionPill/types.d.ts.map +1 -1
- package/lib/typescript/src/components/business/index.d.ts +1 -1
- package/lib/typescript/src/components/business/index.d.ts.map +1 -1
- package/lib/typescript/src/components/business/useSvgId.d.ts +6 -5
- package/lib/typescript/src/components/business/useSvgId.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Avatar/Avatar.d.ts +2 -2
- package/lib/typescript/src/components/ui/Avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Avatar/types.d.ts +6 -2
- package/lib/typescript/src/components/ui/Avatar/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Button/Button.d.ts +1 -1
- package/lib/typescript/src/components/ui/Button/Button.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Button/ButtonBase.d.ts +5 -3
- package/lib/typescript/src/components/ui/Button/ButtonBase.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Button/types.d.ts +5 -3
- package/lib/typescript/src/components/ui/Button/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Carousel/Carousel.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Carousel/behavior.d.ts +25 -0
- package/lib/typescript/src/components/ui/Carousel/behavior.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Carousel/styles.d.ts +4 -6
- package/lib/typescript/src/components/ui/Carousel/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Carousel/types.d.ts +14 -6
- package/lib/typescript/src/components/ui/Carousel/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Cell/Cell.d.ts +1 -1
- package/lib/typescript/src/components/ui/Cell/Cell.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Cell/Leading.d.ts +2 -3
- package/lib/typescript/src/components/ui/Cell/Leading.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Cell/content.d.ts +18 -0
- package/lib/typescript/src/components/ui/Cell/content.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Cell/index.d.ts +1 -1
- package/lib/typescript/src/components/ui/Cell/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Cell/types.d.ts +66 -30
- package/lib/typescript/src/components/ui/Cell/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Checkbox/Checkbox.d.ts +1 -1
- package/lib/typescript/src/components/ui/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Checkbox/types.d.ts +12 -3
- package/lib/typescript/src/components/ui/Checkbox/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Confirm/ConfirmHost.d.ts +6 -3
- package/lib/typescript/src/components/ui/Confirm/ConfirmHost.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Confirm/confirm.d.ts +10 -4
- package/lib/typescript/src/components/ui/Confirm/confirm.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Confirm/labels.d.ts +6 -0
- package/lib/typescript/src/components/ui/Confirm/labels.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Confirm/store.d.ts +44 -0
- package/lib/typescript/src/components/ui/Confirm/store.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Confirm/styles.d.ts +3 -0
- package/lib/typescript/src/components/ui/Confirm/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Confirm/types.d.ts +0 -9
- package/lib/typescript/src/components/ui/Confirm/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/DrawerHeader/DrawerHeader.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/DrawerHeader/types.d.ts +7 -1
- package/lib/typescript/src/components/ui/DrawerHeader/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Grid/Grid.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Grid/accessibility.d.ts +5 -0
- package/lib/typescript/src/components/ui/Grid/accessibility.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Grid/types.d.ts +2 -0
- package/lib/typescript/src/components/ui/Grid/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/IconButton/IconButton.d.ts +1 -1
- package/lib/typescript/src/components/ui/IconButton/IconButton.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/IconButton/types.d.ts +4 -2
- package/lib/typescript/src/components/ui/IconButton/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Input/Input.d.ts +5 -383
- package/lib/typescript/src/components/ui/Input/Input.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Input/index.d.ts +1 -0
- package/lib/typescript/src/components/ui/Input/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Input/types.d.ts +3 -17
- package/lib/typescript/src/components/ui/Input/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Logo/Logo.d.ts +2 -2
- package/lib/typescript/src/components/ui/Logo/Logo.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Logo/types.d.ts +2 -2
- package/lib/typescript/src/components/ui/Logo/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/NavBar/NavBar.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/NavBar/index.d.ts +1 -1
- package/lib/typescript/src/components/ui/NavBar/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/NavBar/isSlot.d.ts +24 -4
- package/lib/typescript/src/components/ui/NavBar/isSlot.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/NavBar/types.d.ts +8 -8
- package/lib/typescript/src/components/ui/NavBar/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/PasswordInput/PasswordInput.d.ts +6 -14
- package/lib/typescript/src/components/ui/PasswordInput/PasswordInput.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/PasswordInput/types.d.ts +4 -14
- package/lib/typescript/src/components/ui/PasswordInput/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Pulse/PulseDot.d.ts +1 -1
- package/lib/typescript/src/components/ui/Pulse/PulseDot.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Pulse/normalizePulseOptions.d.ts +32 -0
- package/lib/typescript/src/components/ui/Pulse/normalizePulseOptions.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Pulse/usePulse.d.ts +10 -5
- package/lib/typescript/src/components/ui/Pulse/usePulse.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Pulse/usePulseDriver.d.ts +11 -0
- package/lib/typescript/src/components/ui/Pulse/usePulseDriver.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Pulse/usePulseDriver.web.d.ts +18 -0
- package/lib/typescript/src/components/ui/Pulse/usePulseDriver.web.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Radio/Radio.d.ts +1 -1
- package/lib/typescript/src/components/ui/Radio/Radio.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Radio/RadioGroup.d.ts +2 -2
- package/lib/typescript/src/components/ui/Radio/RadioGroup.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Radio/types.d.ts +14 -3
- package/lib/typescript/src/components/ui/Radio/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Reveal/Reveal.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Reveal/Reveal.web.d.ts +2 -8
- package/lib/typescript/src/components/ui/Reveal/Reveal.web.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Reveal/types.d.ts +1 -1
- package/lib/typescript/src/components/ui/Reveal/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Reveal/webTransition.d.ts +38 -0
- package/lib/typescript/src/components/ui/Reveal/webTransition.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Search/Search.d.ts +4 -214
- package/lib/typescript/src/components/ui/Search/Search.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Search/types.d.ts +13 -6
- package/lib/typescript/src/components/ui/Search/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Segmented/Segmented.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Skeleton/Skeleton.d.ts +3 -3
- package/lib/typescript/src/components/ui/Skeleton/Skeleton.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Spinner/Spinner.d.ts +1 -1
- package/lib/typescript/src/components/ui/Spinner/Spinner.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Spinner/Spinner.web.d.ts +1 -1
- package/lib/typescript/src/components/ui/Spinner/Spinner.web.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Spinner/shared.d.ts +5 -0
- package/lib/typescript/src/components/ui/Spinner/shared.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Spinner/types.d.ts +1 -1
- package/lib/typescript/src/components/ui/Spinner/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Stepper/Stepper.d.ts +3 -3
- package/lib/typescript/src/components/ui/Stepper/Stepper.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Stepper/StepperPressable.d.ts +2 -0
- package/lib/typescript/src/components/ui/Stepper/StepperPressable.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Stepper/StepperPressable.web.d.ts +2 -0
- package/lib/typescript/src/components/ui/Stepper/StepperPressable.web.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Stepper/accessibility.d.ts +3 -0
- package/lib/typescript/src/components/ui/Stepper/accessibility.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Stepper/accessibility.types.d.ts +23 -0
- package/lib/typescript/src/components/ui/Stepper/accessibility.types.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Stepper/accessibility.web.d.ts +9 -0
- package/lib/typescript/src/components/ui/Stepper/accessibility.web.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Stepper/layout.d.ts +22 -0
- package/lib/typescript/src/components/ui/Stepper/layout.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Stepper/normalizeStepper.d.ts +31 -0
- package/lib/typescript/src/components/ui/Stepper/normalizeStepper.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Stepper/styles.d.ts +9 -2
- package/lib/typescript/src/components/ui/Stepper/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Stepper/types.d.ts +3 -1
- package/lib/typescript/src/components/ui/Stepper/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Switch/Switch.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Switch/Switch.web.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Switch/styles.d.ts +9 -3
- package/lib/typescript/src/components/ui/Switch/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Switch/types.d.ts +2 -2
- package/lib/typescript/src/components/ui/Switch/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Tag/Tag.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/TextField/TextFieldBase.d.ts +4 -401
- package/lib/typescript/src/components/ui/TextField/TextFieldBase.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/TextField/TextFieldSlot.d.ts +13 -0
- package/lib/typescript/src/components/ui/TextField/TextFieldSlot.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/TextField/normalize.d.ts +51 -0
- package/lib/typescript/src/components/ui/TextField/normalize.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/TextField/styles.d.ts +30 -0
- package/lib/typescript/src/components/ui/TextField/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/TextField/types.d.ts +92 -18
- package/lib/typescript/src/components/ui/TextField/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/TextField/useErrorAnnouncement.d.ts +3 -0
- package/lib/typescript/src/components/ui/TextField/useErrorAnnouncement.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/TextField/useTextFieldValue.d.ts +18 -0
- package/lib/typescript/src/components/ui/TextField/useTextFieldValue.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/TextField/valueState.d.ts +50 -0
- package/lib/typescript/src/components/ui/TextField/valueState.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Textarea/Textarea.d.ts +4 -382
- package/lib/typescript/src/components/ui/Textarea/Textarea.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Textarea/index.d.ts +1 -0
- package/lib/typescript/src/components/ui/Textarea/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Textarea/types.d.ts +3 -14
- package/lib/typescript/src/components/ui/Textarea/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/Thumbnail.d.ts +5 -12
- package/lib/typescript/src/components/ui/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/index.d.ts +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/normalize.d.ts +13 -0
- package/lib/typescript/src/components/ui/Thumbnail/normalize.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Thumbnail/styles.d.ts +4 -8
- package/lib/typescript/src/components/ui/Thumbnail/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/types.d.ts +21 -13
- package/lib/typescript/src/components/ui/Thumbnail/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Toast/ToastHost.d.ts +6 -2
- package/lib/typescript/src/components/ui/Toast/ToastHost.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Toast/ToastHost.web.d.ts +6 -3
- package/lib/typescript/src/components/ui/Toast/ToastHost.web.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Toast/store.d.ts +39 -0
- package/lib/typescript/src/components/ui/Toast/store.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Toast/toast.d.ts +7 -2
- package/lib/typescript/src/components/ui/Toast/toast.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Toast/types.d.ts +5 -3
- package/lib/typescript/src/components/ui/Toast/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/index.d.ts +4 -4
- package/lib/typescript/src/components/ui/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/shared/ImageAttempt.d.ts +13 -0
- package/lib/typescript/src/components/ui/shared/ImageAttempt.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/a11y.d.ts +19 -0
- package/lib/typescript/src/components/ui/shared/a11y.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/accessibilityName.d.ts +3 -0
- package/lib/typescript/src/components/ui/shared/accessibilityName.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/selectImageAttemptSource.d.ts +3 -0
- package/lib/typescript/src/components/ui/shared/selectImageAttemptSource.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/selectImageAttemptSource.shared.d.ts +4 -0
- package/lib/typescript/src/components/ui/shared/selectImageAttemptSource.shared.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/selectImageAttemptSource.web.d.ts +3 -0
- package/lib/typescript/src/components/ui/shared/selectImageAttemptSource.web.d.ts.map +1 -0
- package/lib/typescript/src/theme/ThemeProvider.d.ts +2 -3
- package/lib/typescript/src/theme/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/theme/fontScale.d.ts +4 -0
- package/lib/typescript/src/theme/fontScale.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +2 -1
- package/lib/typescript/src/theme/index.d.ts.map +1 -1
- package/lib/typescript/src/theme/themeContext.d.ts +6 -0
- package/lib/typescript/src/theme/themeContext.d.ts.map +1 -0
- package/lib/typescript/src/theme/themeDiagnostics.d.ts +6 -0
- package/lib/typescript/src/theme/themeDiagnostics.d.ts.map +1 -0
- package/lib/typescript/src/theme/usePrefersReducedMotion.d.ts +8 -3
- package/lib/typescript/src/theme/usePrefersReducedMotion.d.ts.map +1 -1
- package/lib/typescript/src/theme/usePrefersReducedMotion.web.d.ts +5 -2
- package/lib/typescript/src/theme/usePrefersReducedMotion.web.d.ts.map +1 -1
- package/lib/typescript/src/theme/useTheme.d.ts +1 -1
- package/lib/typescript/src/theme/useTheme.d.ts.map +1 -1
- package/lib/typescript/src/theme/useThemedStyles.d.ts +1 -1
- package/lib/typescript/src/theme/useThemedStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/imageSource.d.ts +20 -0
- package/lib/typescript/src/utils/imageSource.d.ts.map +1 -0
- package/lib/typescript/type-tests/public-api.d.ts +2 -0
- package/lib/typescript/type-tests/public-api.d.ts.map +1 -0
- package/lib/typescript/website/src/components/iconCatalogCategories.d.ts +11 -0
- package/lib/typescript/website/src/components/iconCatalogCategories.d.ts.map +1 -0
- package/package.json +30 -14
- package/src/components/business/AvatarWithRing/AvatarWithRing.tsx +11 -4
- package/src/components/business/AvatarWithRing/styles.ts +11 -9
- package/src/components/business/VersionPill/VersionPill.tsx +31 -25
- package/src/components/business/VersionPill/content.ts +47 -0
- package/src/components/business/VersionPill/index.ts +1 -1
- package/src/components/business/VersionPill/styles.ts +4 -0
- package/src/components/business/VersionPill/types.ts +7 -2
- package/src/components/business/index.ts +1 -1
- package/src/components/business/useSvgId.ts +29 -8
- package/src/components/ui/Avatar/Avatar.tsx +25 -34
- package/src/components/ui/Avatar/types.ts +6 -2
- package/src/components/ui/Button/Button.tsx +39 -20
- package/src/components/ui/Button/ButtonBase.tsx +21 -12
- package/src/components/ui/Button/types.ts +5 -3
- package/src/components/ui/Carousel/Carousel.tsx +102 -40
- package/src/components/ui/Carousel/behavior.ts +78 -0
- package/src/components/ui/Carousel/styles.ts +5 -7
- package/src/components/ui/Carousel/types.ts +18 -6
- package/src/components/ui/Cell/Cell.tsx +85 -74
- package/src/components/ui/Cell/Leading.tsx +14 -14
- package/src/components/ui/Cell/content.ts +53 -0
- package/src/components/ui/Cell/index.ts +7 -1
- package/src/components/ui/Cell/types.ts +64 -30
- package/src/components/ui/Checkbox/Checkbox.tsx +35 -8
- package/src/components/ui/Checkbox/types.ts +15 -3
- package/src/components/ui/Confirm/ConfirmHost.tsx +51 -26
- package/src/components/ui/Confirm/confirm.ts +17 -34
- package/src/components/ui/Confirm/labels.ts +14 -0
- package/src/components/ui/Confirm/store.ts +147 -0
- package/src/components/ui/Confirm/styles.ts +4 -0
- package/src/components/ui/Confirm/types.ts +2 -10
- package/src/components/ui/DrawerHeader/DrawerHeader.tsx +22 -27
- package/src/components/ui/DrawerHeader/types.ts +7 -1
- package/src/components/ui/Grid/Grid.tsx +44 -12
- package/src/components/ui/Grid/accessibility.ts +21 -0
- package/src/components/ui/Grid/types.ts +2 -0
- package/src/components/ui/IconButton/IconButton.tsx +20 -3
- package/src/components/ui/IconButton/types.ts +4 -2
- package/src/components/ui/Input/Input.tsx +16 -6
- package/src/components/ui/Input/index.ts +5 -0
- package/src/components/ui/Input/types.ts +12 -23
- package/src/components/ui/Logo/Logo.tsx +27 -4
- package/src/components/ui/Logo/types.ts +2 -2
- package/src/components/ui/NavBar/NavBar.tsx +27 -19
- package/src/components/ui/NavBar/index.ts +1 -1
- package/src/components/ui/NavBar/isSlot.ts +372 -5
- package/src/components/ui/NavBar/types.ts +9 -8
- package/src/components/ui/PasswordInput/PasswordInput.tsx +67 -69
- package/src/components/ui/PasswordInput/types.ts +12 -14
- package/src/components/ui/Pulse/PulseDot.tsx +5 -4
- package/src/components/ui/Pulse/normalizePulseOptions.ts +76 -0
- package/src/components/ui/Pulse/usePulse.ts +80 -34
- package/src/components/ui/Pulse/usePulseDriver.ts +49 -0
- package/src/components/ui/Pulse/usePulseDriver.web.ts +66 -0
- package/src/components/ui/Radio/Radio.tsx +44 -15
- package/src/components/ui/Radio/RadioGroup.tsx +21 -3
- package/src/components/ui/Radio/types.ts +17 -3
- package/src/components/ui/Reveal/Reveal.tsx +5 -3
- package/src/components/ui/Reveal/Reveal.web.tsx +72 -29
- package/src/components/ui/Reveal/types.ts +1 -1
- package/src/components/ui/Reveal/webTransition.ts +206 -0
- package/src/components/ui/Search/Search.tsx +127 -58
- package/src/components/ui/Search/types.ts +30 -9
- package/src/components/ui/Segmented/Segmented.tsx +10 -2
- package/src/components/ui/Skeleton/Skeleton.tsx +9 -5
- package/src/components/ui/Spinner/Spinner.tsx +25 -17
- package/src/components/ui/Spinner/Spinner.web.tsx +23 -18
- package/src/components/ui/Spinner/shared.ts +7 -0
- package/src/components/ui/Spinner/types.ts +1 -1
- package/src/components/ui/Stepper/Stepper.tsx +166 -86
- package/src/components/ui/Stepper/StepperPressable.tsx +1 -0
- package/src/components/ui/Stepper/StepperPressable.web.tsx +1 -0
- package/src/components/ui/Stepper/accessibility.ts +32 -0
- package/src/components/ui/Stepper/accessibility.types.ts +22 -0
- package/src/components/ui/Stepper/accessibility.web.ts +65 -0
- package/src/components/ui/Stepper/layout.ts +44 -0
- package/src/components/ui/Stepper/normalizeStepper.ts +85 -0
- package/src/components/ui/Stepper/styles.ts +9 -2
- package/src/components/ui/Stepper/types.ts +3 -1
- package/src/components/ui/Switch/Switch.tsx +54 -15
- package/src/components/ui/Switch/Switch.web.tsx +57 -19
- package/src/components/ui/Switch/styles.ts +11 -4
- package/src/components/ui/Switch/types.ts +2 -2
- package/src/components/ui/Tag/Tag.tsx +6 -2
- package/src/components/ui/TextField/TextFieldBase.tsx +175 -70
- package/src/components/ui/TextField/TextFieldSlot.tsx +91 -0
- package/src/components/ui/TextField/normalize.ts +280 -0
- package/src/components/ui/TextField/styles.ts +31 -0
- package/src/components/ui/TextField/types.ts +118 -22
- package/src/components/ui/TextField/useErrorAnnouncement.ts +27 -0
- package/src/components/ui/TextField/useTextFieldValue.ts +94 -0
- package/src/components/ui/TextField/valueState.ts +125 -0
- package/src/components/ui/Textarea/Textarea.tsx +11 -4
- package/src/components/ui/Textarea/index.ts +5 -0
- package/src/components/ui/Textarea/types.ts +14 -22
- package/src/components/ui/Thumbnail/Thumbnail.tsx +86 -51
- package/src/components/ui/Thumbnail/index.ts +5 -1
- package/src/components/ui/Thumbnail/normalize.ts +78 -0
- package/src/components/ui/Thumbnail/styles.ts +5 -10
- package/src/components/ui/Thumbnail/types.ts +43 -13
- package/src/components/ui/Toast/ToastHost.tsx +81 -22
- package/src/components/ui/Toast/ToastHost.web.tsx +91 -29
- package/src/components/ui/Toast/store.ts +148 -0
- package/src/components/ui/Toast/toast.ts +19 -10
- package/src/components/ui/Toast/types.ts +7 -3
- package/src/components/ui/index.ts +19 -4
- package/src/components/ui/shared/ImageAttempt.tsx +30 -0
- package/src/components/ui/shared/a11y.ts +18 -0
- package/src/components/ui/shared/accessibilityName.ts +6 -0
- package/src/components/ui/shared/selectImageAttemptSource.shared.ts +17 -0
- package/src/components/ui/shared/selectImageAttemptSource.ts +3 -0
- package/src/components/ui/shared/selectImageAttemptSource.web.ts +3 -0
- package/src/icons/data.ts +1 -1
- package/src/theme/ThemeProvider.tsx +18 -7
- package/src/theme/fontScale.ts +15 -0
- package/src/theme/index.ts +2 -3
- package/src/theme/themeContext.ts +24 -0
- package/src/theme/themeDiagnostics.ts +41 -0
- package/src/theme/usePrefersReducedMotion.ts +11 -4
- package/src/theme/usePrefersReducedMotion.web.ts +5 -2
- package/src/theme/useTheme.ts +19 -27
- package/src/theme/useThemedStyles.ts +12 -7
- package/src/utils/imageSource.ts +303 -0
- package/lib/module/components/ui/PasswordInput/styles.js +0 -12
- package/lib/module/components/ui/PasswordInput/styles.js.map +0 -1
- package/lib/module/components/ui/Pulse/usePulse.web.js +0 -76
- package/lib/module/components/ui/Pulse/usePulse.web.js.map +0 -1
- package/lib/typescript/src/components/ui/PasswordInput/styles.d.ts +0 -7
- package/lib/typescript/src/components/ui/PasswordInput/styles.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/Pulse/usePulse.web.d.ts +0 -21
- package/lib/typescript/src/components/ui/Pulse/usePulse.web.d.ts.map +0 -1
- package/src/components/ui/PasswordInput/styles.ts +0 -7
- package/src/components/ui/Pulse/usePulse.web.ts +0 -74
|
@@ -7,14 +7,20 @@ import Animated, { cancelAnimation, runOnJS, useAnimatedStyle, useSharedValue, w
|
|
|
7
7
|
import { useColors, useThemedStyles, motion, space } from "../../../theme/index.js";
|
|
8
8
|
import { childTestID } from "../../../utils/testID/index.js";
|
|
9
9
|
import { dotColorFor, makeStyles } from "./styles.js";
|
|
10
|
-
import {
|
|
10
|
+
import { completeToast, isCurrentToastDelivery, registerToastHost } from "./toast.js";
|
|
11
|
+
|
|
12
|
+
/** Host 侧的同步身份副本 —— 迟到回调据此在动 UI 前自证「我还是当前那一次投递」。 */
|
|
11
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
14
|
-
* 同一时间只显示一条 ——
|
|
15
|
+
* 在根附近挂**一次**。监听 toast() 调用并渲染当前 toast。
|
|
16
|
+
* 同一时间只显示一条 —— 新的会替换旧的(latest-wins)。
|
|
15
17
|
*
|
|
16
18
|
* 位置由 `entry.position`('top' / 'bottom' / 'center')决定,top/bottom 自动避让
|
|
17
19
|
* safe-area;进入动画方向随位置(top 从上滑、bottom/center 从下滑)。
|
|
20
|
+
*
|
|
21
|
+
* 竞态纪律:每个 timer / 动画完成回调在改 UI 或上报完成前,都要同时通过同步 ref
|
|
22
|
+
* 与 `isCurrentToastDelivery(delivery)` 两道校验 —— 只靠其中之一都不够:ref 挡不住
|
|
23
|
+
* 「Host 重挂后同一 entry 的新投递」,Store 挡不住 React 批处理造成的 state 滞后。
|
|
18
24
|
*/
|
|
19
25
|
export function ToastHost({
|
|
20
26
|
testID
|
|
@@ -22,32 +28,63 @@ export function ToastHost({
|
|
|
22
28
|
const c = useColors();
|
|
23
29
|
const styles = useThemedStyles(makeStyles);
|
|
24
30
|
const insets = useSafeAreaInsets();
|
|
25
|
-
const [
|
|
31
|
+
const [delivery, setDelivery] = useState(null);
|
|
32
|
+
const [inert, setInert] = useState(false);
|
|
26
33
|
const op = useSharedValue(0);
|
|
27
34
|
const ty = useSharedValue(8);
|
|
28
35
|
const dismissTimer = useRef(null);
|
|
36
|
+
const currentDeliveryRef = useRef(null);
|
|
29
37
|
useEffect(() => {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
const subscriber = next => {
|
|
39
|
+
// 顺序固定:先撤销旧回调 → 再写同步身份 ref → 最后才动 React state。
|
|
40
|
+
if (dismissTimer.current) {
|
|
41
|
+
clearTimeout(dismissTimer.current);
|
|
42
|
+
dismissTimer.current = null;
|
|
43
|
+
}
|
|
44
|
+
cancelAnimation(op);
|
|
45
|
+
cancelAnimation(ty);
|
|
46
|
+
currentDeliveryRef.current = {
|
|
47
|
+
ownerToken: next.ownerToken,
|
|
48
|
+
leaseId: next.leaseId,
|
|
49
|
+
entryId: next.entry.id
|
|
50
|
+
};
|
|
51
|
+
setDelivery(next);
|
|
33
52
|
};
|
|
34
|
-
|
|
53
|
+
const lease = registerToastHost(subscriber);
|
|
54
|
+
if (!lease) {
|
|
55
|
+
setInert(true);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
35
58
|
return () => {
|
|
36
|
-
|
|
59
|
+
// 顺序固定:先清身份 ref(让所有在途回调立刻失效)→ 撤销 timer/动画 → 最后释放 owner。
|
|
60
|
+
currentDeliveryRef.current = null;
|
|
61
|
+
if (dismissTimer.current) {
|
|
62
|
+
clearTimeout(dismissTimer.current);
|
|
63
|
+
dismissTimer.current = null;
|
|
64
|
+
}
|
|
65
|
+
cancelAnimation(op);
|
|
66
|
+
cancelAnimation(ty);
|
|
67
|
+
lease.release();
|
|
37
68
|
};
|
|
38
|
-
}, []);
|
|
69
|
+
}, [op, ty]);
|
|
39
70
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
71
|
+
/** 退场完成:双重校验通过才清 UI 并上报完成,避免抹掉竞态期到达的新 toast([M-14])。 */
|
|
72
|
+
const finishIfCurrent = useCallback(finished => {
|
|
73
|
+
const identity = currentDeliveryRef.current;
|
|
74
|
+
if (!identity || identity.ownerToken !== finished.ownerToken || identity.leaseId !== finished.leaseId || identity.entryId !== finished.entry.id) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!isCurrentToastDelivery(finished)) return;
|
|
78
|
+
completeToast(finished.ownerToken, finished.leaseId, finished.entry.id);
|
|
79
|
+
currentDeliveryRef.current = null;
|
|
80
|
+
setDelivery(current => current === finished ? null : current);
|
|
44
81
|
}, []);
|
|
45
82
|
useEffect(() => {
|
|
46
|
-
if (!
|
|
83
|
+
if (!delivery) return;
|
|
84
|
+
const entry = delivery.entry;
|
|
47
85
|
// [M-15] toast 出现时主动播报 —— 容器 pointerEvents="none" + 3s 自动消失,
|
|
48
86
|
// SR 用户对一闪而过的反馈本无任何感知通道。
|
|
49
87
|
AccessibilityInfo.announceForAccessibility(entry.message);
|
|
50
|
-
const id = entry.id;
|
|
51
88
|
// 进入方向:top 从上(-8)滑入,bottom / center 从下(8)滑入
|
|
52
89
|
const from = entry.position === 'top' ? -8 : 8;
|
|
53
90
|
cancelAnimation(op);
|
|
@@ -61,28 +98,34 @@ export function ToastHost({
|
|
|
61
98
|
duration: motion.base
|
|
62
99
|
});
|
|
63
100
|
dismissTimer.current = setTimeout(() => {
|
|
101
|
+
// 定时器触发时可能早已不是当前投递(新 toast 抢先)—— 先自证再播退场动画。
|
|
102
|
+
if (!isCurrentToastDelivery(delivery)) return;
|
|
64
103
|
op.value = withTiming(0, {
|
|
65
104
|
duration: motion.base
|
|
66
105
|
});
|
|
67
106
|
ty.value = withTiming(from, {
|
|
68
107
|
duration: motion.base
|
|
69
|
-
},
|
|
70
|
-
if (
|
|
108
|
+
}, done => {
|
|
109
|
+
if (done) runOnJS(finishIfCurrent)(delivery);
|
|
71
110
|
});
|
|
72
111
|
}, entry.duration);
|
|
73
112
|
return () => {
|
|
74
|
-
if (dismissTimer.current)
|
|
113
|
+
if (dismissTimer.current) {
|
|
114
|
+
clearTimeout(dismissTimer.current);
|
|
115
|
+
dismissTimer.current = null;
|
|
116
|
+
}
|
|
75
117
|
cancelAnimation(op);
|
|
76
118
|
cancelAnimation(ty);
|
|
77
119
|
};
|
|
78
|
-
}, [
|
|
120
|
+
}, [delivery, op, ty, finishIfCurrent]);
|
|
79
121
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
80
122
|
opacity: op.value,
|
|
81
123
|
transform: [{
|
|
82
124
|
translateY: ty.value
|
|
83
125
|
}]
|
|
84
126
|
}));
|
|
85
|
-
if (!
|
|
127
|
+
if (inert || !delivery) return null;
|
|
128
|
+
const entry = delivery.entry;
|
|
86
129
|
|
|
87
130
|
// 位置:top=顶部(safe-area + 间距)/ center=屏幕居中 / bottom=底部(默认)
|
|
88
131
|
const posStyle = entry.position === 'top' ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useRef","useState","AccessibilityInfo","Text","View","useSafeAreaInsets","Animated","cancelAnimation","runOnJS","useAnimatedStyle","useSharedValue","withTiming","useColors","useThemedStyles","motion","space","childTestID","dotColorFor","makeStyles","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useRef","useState","AccessibilityInfo","Text","View","useSafeAreaInsets","Animated","cancelAnimation","runOnJS","useAnimatedStyle","useSharedValue","withTiming","useColors","useThemedStyles","motion","space","childTestID","dotColorFor","makeStyles","completeToast","isCurrentToastDelivery","registerToastHost","jsx","_jsx","jsxs","_jsxs","ToastHost","testID","c","styles","insets","delivery","setDelivery","inert","setInert","op","ty","dismissTimer","currentDeliveryRef","subscriber","next","current","clearTimeout","ownerToken","leaseId","entryId","entry","id","lease","release","finishIfCurrent","finished","identity","announceForAccessibility","message","from","position","value","duration","base","setTimeout","done","animatedStyle","opacity","transform","translateY","posStyle","top","bottom","justifyContent","dotColor","kind","style","host","pointerEvents","children","toast","dot","backgroundColor","text"],"sourceRoot":"../../../../../src","sources":["components/ui/Toast/ToastHost.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACvE,SAASC,iBAAiB,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAC5D,SAASC,iBAA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MAAM,CAAC4C,IAAI,EAAEP,QAAQ,CAAE;IAACQ,aAAa,EAAC,MAAM;IAAC/C,MAAM,EAAEA,MAAO;IAAAgD,QAAA,eACxElD,KAAA,CAACnB,QAAQ,CAACF,IAAI;MAACoE,KAAK,EAAE,CAAC3C,MAAM,CAAC+C,KAAK,EAAEd,aAAa,CAAE;MAAAa,QAAA,GACjDL,QAAQ,gBACP/C,IAAA,CAACnB,IAAI;QAACoE,KAAK,EAAE,CAAC3C,MAAM,CAACgD,GAAG,EAAE;UAAEC,eAAe,EAAER;QAAS,CAAC;MAAE,CAAE,CAAC,GAC1D,IAAI,eACR/C,IAAA,CAACpB,IAAI;QAACqE,KAAK,EAAE3C,MAAM,CAACkD,IAAK;QAACpD,MAAM,EAAEX,WAAW,CAACW,MAAM,EAAE,MAAM,CAAE;QAAAgD,QAAA,EAC3D7B,KAAK,CAACQ;MAAO,CACV,CAAC;IAAA,CACM;EAAC,CACZ,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { AccessibilityInfo, Text, View } from 'react-native';
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
6
|
import { motion, space, useColors, usePrefersReducedMotion, useThemedStyles } from "../../../theme/index.js";
|
|
7
|
+
import { childTestID } from "../../../utils/testID/index.js";
|
|
7
8
|
import { dotColorFor, makeStyles } from "./styles.js";
|
|
8
|
-
import {
|
|
9
|
+
import { completeToast, isCurrentToastDelivery, registerToastHost } from "./toast.js";
|
|
10
|
+
|
|
11
|
+
/** Host 侧的同步身份副本 —— 迟到回调据此在动 UI 前自证「我还是当前那一次投递」。 */
|
|
9
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
13
|
/**
|
|
11
|
-
* Web 端 ToastHost —— RN-Web 上 reanimated
|
|
12
|
-
*
|
|
13
|
-
* transition 实现 fade + slide
|
|
14
|
+
* Web 端 ToastHost —— RN-Web 上 reanimated 的 useAnimatedStyle 链路会在
|
|
15
|
+
* `_updatePropsJS` 里 `Object.keys` 抛 TypeError(点击就崩),故走纯 React + CSS
|
|
16
|
+
* transition 实现 fade + slide;native 端仍走 ToastHost.tsx 的 reanimated 实现。
|
|
14
17
|
*
|
|
15
18
|
* 行为复刻 native 版:
|
|
16
19
|
* - opacity 0→1 + translateY 8→0 入场(motion.base ms)
|
|
17
20
|
* - 停留 entry.duration ms
|
|
18
21
|
* - opacity 1→0 + translateY 0→8 退场后 unmount
|
|
22
|
+
*
|
|
23
|
+
* 竞态纪律与 native 版一致:timer / RAF 在改 UI 或上报完成前,都要同时通过同步 ref
|
|
24
|
+
* 与 `isCurrentToastDelivery(delivery)` 两道校验。
|
|
19
25
|
*/
|
|
20
26
|
export function ToastHost({
|
|
21
27
|
testID
|
|
@@ -24,59 +30,102 @@ export function ToastHost({
|
|
|
24
30
|
const styles = useThemedStyles(makeStyles);
|
|
25
31
|
const insets = useSafeAreaInsets();
|
|
26
32
|
const reduced = usePrefersReducedMotion();
|
|
27
|
-
const [
|
|
33
|
+
const [delivery, setDelivery] = useState(null);
|
|
34
|
+
const [inert, setInert] = useState(false);
|
|
28
35
|
const [visible, setVisible] = useState(false);
|
|
29
36
|
const dismissTimerRef = useRef(null);
|
|
30
37
|
const exitTimerRef = useRef(null);
|
|
31
38
|
const enterRafRef = useRef(null);
|
|
39
|
+
const currentDeliveryRef = useRef(null);
|
|
40
|
+
const cancelCallbacks = useCallback(() => {
|
|
41
|
+
if (dismissTimerRef.current) {
|
|
42
|
+
clearTimeout(dismissTimerRef.current);
|
|
43
|
+
dismissTimerRef.current = null;
|
|
44
|
+
}
|
|
45
|
+
if (exitTimerRef.current) {
|
|
46
|
+
clearTimeout(exitTimerRef.current);
|
|
47
|
+
exitTimerRef.current = null;
|
|
48
|
+
}
|
|
49
|
+
if (enterRafRef.current != null) {
|
|
50
|
+
cancelAnimationFrame(enterRafRef.current);
|
|
51
|
+
enterRafRef.current = null;
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
32
54
|
useEffect(() => {
|
|
33
|
-
const
|
|
34
|
-
|
|
55
|
+
const subscriber = next => {
|
|
56
|
+
// 顺序固定:先撤销旧回调 → 再写同步身份 ref → 最后才动 React state。
|
|
57
|
+
cancelCallbacks();
|
|
58
|
+
currentDeliveryRef.current = {
|
|
59
|
+
ownerToken: next.ownerToken,
|
|
60
|
+
leaseId: next.leaseId,
|
|
61
|
+
entryId: next.entry.id
|
|
62
|
+
};
|
|
63
|
+
setDelivery(next);
|
|
35
64
|
};
|
|
36
|
-
|
|
65
|
+
const lease = registerToastHost(subscriber);
|
|
66
|
+
if (!lease) {
|
|
67
|
+
setInert(true);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
37
70
|
return () => {
|
|
38
|
-
|
|
71
|
+
// 顺序固定:先清身份 ref(让所有在途回调立刻失效)→ 撤销 timer/RAF → 最后释放 owner。
|
|
72
|
+
currentDeliveryRef.current = null;
|
|
73
|
+
cancelCallbacks();
|
|
74
|
+
lease.release();
|
|
39
75
|
};
|
|
76
|
+
}, [cancelCallbacks]);
|
|
77
|
+
|
|
78
|
+
/** 退场完成:双重校验通过才清 UI 并上报完成。 */
|
|
79
|
+
const finishIfCurrent = useCallback(finished => {
|
|
80
|
+
const identity = currentDeliveryRef.current;
|
|
81
|
+
if (!identity || identity.ownerToken !== finished.ownerToken || identity.leaseId !== finished.leaseId || identity.entryId !== finished.entry.id) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!isCurrentToastDelivery(finished)) return;
|
|
85
|
+
completeToast(finished.ownerToken, finished.leaseId, finished.entry.id);
|
|
86
|
+
currentDeliveryRef.current = null;
|
|
87
|
+
setDelivery(current => current === finished ? null : current);
|
|
40
88
|
}, []);
|
|
41
89
|
useEffect(() => {
|
|
42
|
-
//
|
|
43
|
-
if (!
|
|
90
|
+
// delivery=null:上一轮 effect 的 cleanup 已清 timer/RAF,这里无需重复。
|
|
91
|
+
if (!delivery) return;
|
|
92
|
+
const entry = delivery.entry;
|
|
44
93
|
// [M-15] web 同样主动播报(RN-Web announceForAccessibility 注入 aria-live region)。
|
|
45
94
|
AccessibilityInfo.announceForAccessibility(entry.message);
|
|
46
95
|
|
|
47
|
-
// cancelled 标志:
|
|
96
|
+
// cancelled 标志:delivery 快速连续切换 / 组件卸载时,cleanup 置 true。RAF 与
|
|
48
97
|
// timer 回调执行前都检查它 —— cancelAnimationFrame 在部分浏览器不保证取消
|
|
49
98
|
// 已排队回调,且双 RAF 的外层回调可能在 cleanup 后仍跑并 queue 内层,光靠
|
|
50
99
|
// cancel 防不住。cancelled 兜底,杜绝 unmount 后 setState 警告 + 状态错位。
|
|
51
100
|
let cancelled = false;
|
|
52
|
-
//
|
|
101
|
+
// 进场:每次切换都从 visible=false 开始,确保 CSS transition 有起点
|
|
53
102
|
setVisible(false);
|
|
54
103
|
// 双 RAF 才能稳过 React commit/paint 一帧 —— 否则同一 microtask 内 visible
|
|
55
104
|
// 还是 true(未刷),CSS transition 没起点。
|
|
56
105
|
enterRafRef.current = requestAnimationFrame(() => {
|
|
57
106
|
if (cancelled) return;
|
|
58
107
|
enterRafRef.current = requestAnimationFrame(() => {
|
|
59
|
-
if (cancelled) return;
|
|
108
|
+
if (cancelled || !isCurrentToastDelivery(delivery)) return;
|
|
109
|
+
enterRafRef.current = null;
|
|
60
110
|
setVisible(true);
|
|
61
111
|
});
|
|
62
112
|
});
|
|
63
|
-
//
|
|
113
|
+
// 停留时长:从投递到关闭 = entry.duration ms。
|
|
64
114
|
dismissTimerRef.current = setTimeout(() => {
|
|
65
|
-
if (cancelled) return;
|
|
115
|
+
if (cancelled || !isCurrentToastDelivery(delivery)) return;
|
|
66
116
|
setVisible(false);
|
|
67
117
|
exitTimerRef.current = setTimeout(() => {
|
|
68
118
|
if (cancelled) return;
|
|
69
|
-
|
|
119
|
+
finishIfCurrent(delivery);
|
|
70
120
|
}, motion.base);
|
|
71
121
|
}, entry.duration);
|
|
72
122
|
return () => {
|
|
73
123
|
cancelled = true;
|
|
74
|
-
|
|
75
|
-
if (exitTimerRef.current) clearTimeout(exitTimerRef.current);
|
|
76
|
-
if (enterRafRef.current != null) cancelAnimationFrame(enterRafRef.current);
|
|
124
|
+
cancelCallbacks();
|
|
77
125
|
};
|
|
78
|
-
}, [
|
|
79
|
-
if (!
|
|
126
|
+
}, [delivery, cancelCallbacks, finishIfCurrent]);
|
|
127
|
+
if (inert || !delivery) return null;
|
|
128
|
+
const entry = delivery.entry;
|
|
80
129
|
|
|
81
130
|
// 位置:top=顶部(safe-area + 间距)/ center=屏幕居中 / bottom=底部(默认),复刻 native 版。
|
|
82
131
|
// 此前 web 完全未注入定位,position 参数被静默忽略、垂直位置随挂载次序漂移([H-6])。
|
|
@@ -109,7 +158,7 @@ export function ToastHost({
|
|
|
109
158
|
}]
|
|
110
159
|
}) : null, /*#__PURE__*/_jsx(Text, {
|
|
111
160
|
style: styles.text,
|
|
112
|
-
testID: testID
|
|
161
|
+
testID: childTestID(testID, 'text'),
|
|
113
162
|
children: entry.message
|
|
114
163
|
})]
|
|
115
164
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","AccessibilityInfo","Text","View","useSafeAreaInsets","motion","space","useColors","usePrefersReducedMotion","useThemedStyles","dotColorFor","makeStyles","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useRef","useState","AccessibilityInfo","Text","View","useSafeAreaInsets","motion","space","useColors","usePrefersReducedMotion","useThemedStyles","childTestID","dotColorFor","makeStyles","completeToast","isCurrentToastDelivery","registerToastHost","jsx","_jsx","jsxs","_jsxs","ToastHost","testID","c","styles","insets","reduced","delivery","setDelivery","inert","setInert","visible","setVisible","dismissTimerRef","exitTimerRef","enterRafRef","currentDeliveryRef","cancelCallbacks","current","clearTimeout","cancelAnimationFrame","subscriber","next","ownerToken","leaseId","entryId","entry","id","lease","release","finishIfCurrent","finished","identity","announceForAccessibility","message","cancelled","requestAnimationFrame","setTimeout","base","duration","posStyle","position","top","bottom","justifyContent","dotColor","kind","animatedWebStyle","opacity","transform","transition","style","host","pointerEvents","children","toast","dot","backgroundColor","text"],"sourceRoot":"../../../../../src","sources":["components/ui/Toast/ToastHost.web.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACvE,SAASC,iBAAiB,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAC5D,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SACEC,MAAM,EACNC,KAAK,EACLC,SAAS,EACTC,uBAAuB,EACvBC,eAAe,QACV,yBAAgB;AACvB,SAASC,WAAW,QAAQ,gCAAuB;AACnD,SAASC,WAAW,EAAEC,UAAU,QAAQ,aAAU;AAClD,SACEC,aAAa,EACbC,sBAAsB,EACtBC,iBAAiB,QACZ,YAAS;;AAIhB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAC;EACxBC;AACc,CAAC,GAAG,CAAC,CAAC,EAA4B;EAChD,MAAMC,CAAC,GAAGf,SAAS,CAAC,CAAC;EACrB,MAAMgB,MAAM,GAAGd,eAAe,CAACG,UAAU,CAAC;EAC1C,MAAMY,MAAM,GAAGpB,iBAAiB,CAAC,CAAC;EAClC,MAAMqB,OAAO,GAAGjB,uBAAuB,CAAC,CAAC;EACzC,MAAM,CAACkB,QAAQ,EAAEC,WAAW,CAAC,GAAG3B,QAAQ,CAAuB,IAAI,CAAC;EACpE,MAAM,CAAC4B,KAAK,EAAEC,QAAQ,CAAC,GAAG7B,QAAQ,CAAC,KAAK,CAAC;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C,gBAAqC,GAAG;IAC5CC,OAAO,EAAErC,OAAO,GAAG,CAAC,GAAG,CAAC;IACxBsC,SAAS,EAAEtC,OAAO,GAAG,iBAAiB,GAAG,iBAAiB;IAC1DuC,UAAU,EAAE5C,OAAO,GACf,MAAM,GACN,WAAWpB,MAAM,CAACoD,IAAI,0BAA0BpD,MAAM,CAACoD,IAAI;EACjE,CAAC;EAED,oBACExC,IAAA,CAACd,IAAI;IAACmE,KAAK,EAAE,CAAC/C,MAAM,CAACgD,IAAI,EAAEZ,QAAQ,CAAE;IAACa,aAAa,EAAC,MAAM;IAACnD,MAAM,EAAEA,MAAO;IAAAoD,QAAA,eACxExD,IAAA;MAAKqD,KAAK,EAAEJ,gBAAiB;MAAAO,QAAA,eAC3BtD,KAAA,CAAChB,IAAI;QAACmE,KAAK,EAAE/C,MAAM,CAACmD,KAAM;QAAAD,QAAA,GACvBT,QAAQ,gBACP/C,IAAA,CAACd,IAAI;UAACmE,KAAK,EAAE,CAAC/C,MAAM,CAACoD,GAAG,EAAE;YAAEC,eAAe,EAAEZ;UAAS,CAAC;QAAE,CAAE,CAAC,GAC1D,IAAI,eACR/C,IAAA,CAACf,IAAI;UAACoE,KAAK,EAAE/C,MAAM,CAACsD,IAAK;UAACxD,MAAM,EAAEX,WAAW,CAACW,MAAM,EAAE,MAAM,CAAE;UAAAoD,QAAA,EAC3D5B,KAAK,CAACQ;QAAO,CACV,CAAC;MAAA,CACH;IAAC,CACJ;EAAC,CACF,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Toast 的纯状态机 —— 不含任何 React / 渲染依赖,可直接单测。
|
|
5
|
+
*
|
|
6
|
+
* 与 Confirm 的语义**不同**,故意不抽成泛型事件总线:
|
|
7
|
+
* - Confirm 是「一次决策」,需要 active entry + Promise;
|
|
8
|
+
* - Toast 是「最新一条覆盖旧的」,需要 pending / delivery 双态。
|
|
9
|
+
*
|
|
10
|
+
* 双态模型:
|
|
11
|
+
* - `pending` —— 还没有 Host 接住的最新一条消息。**latest-wins**:后来的直接覆盖,
|
|
12
|
+
* 不排队(toast 是瞬时反馈,补投一串历史消息毫无意义)。
|
|
13
|
+
* - `delivered` —— 已交给当前 Host 的那一条,带 `ownerToken` + `leaseId` + `entry.id`
|
|
14
|
+
* 三重身份。Host 的每个 timer / RAF / 动画完成回调在动 UI 前都必须用这三项做 CAS,
|
|
15
|
+
* 否则旧回调会把新 toast 提前抹掉(经典竞态:A 的 3s 定时器在 B 显示后才触发)。
|
|
16
|
+
*
|
|
17
|
+
* `leaseId` 单调递增,同一 entry 被重新投递(Host 重挂)也会拿到新的 leaseId ——
|
|
18
|
+
* 仅比较 entry.id 不足以区分「同一条消息的两次投递」。
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export function createToastStore(log) {
|
|
22
|
+
let pending = null;
|
|
23
|
+
let delivered = null;
|
|
24
|
+
let owner = null;
|
|
25
|
+
let leaseCounter = 0;
|
|
26
|
+
function beginDelivery(entry, capturedOwner) {
|
|
27
|
+
const delivery = {
|
|
28
|
+
entry,
|
|
29
|
+
ownerToken: capturedOwner.token,
|
|
30
|
+
leaseId: ++leaseCounter
|
|
31
|
+
};
|
|
32
|
+
// 先原子地把 pending 取走并落 delivered,再调 subscriber:subscriber 内同步
|
|
33
|
+
// 再 publish 时看到的必须是「已投递」而不是「还在 pending」的半状态。
|
|
34
|
+
pending = null;
|
|
35
|
+
delivered = delivery;
|
|
36
|
+
try {
|
|
37
|
+
capturedOwner.subscriber?.(delivery);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
log.error('ToastHost subscriber 抛错', error);
|
|
40
|
+
// 期间若 owner 已换人 / 已被作废,这次抛错不能牵连新 owner 或覆盖更新的 pending。
|
|
41
|
+
if (owner?.token !== capturedOwner.token) return;
|
|
42
|
+
owner = null;
|
|
43
|
+
if (delivered?.ownerToken === capturedOwner.token) {
|
|
44
|
+
// 回存的是 delivered 而非 entry:subscriber 内可能已同步投递了更新的一条,
|
|
45
|
+
// 那条才是当前逻辑消息(latest-wins)。已 complete 的则 delivered 为 null,不复活。
|
|
46
|
+
pending = delivered.entry;
|
|
47
|
+
delivered = null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function publish(entry) {
|
|
52
|
+
const current = owner;
|
|
53
|
+
// 未挂 Host 是**受支持路径**,不告警:启动早期的 toast 应当在 Host 挂上后补投。
|
|
54
|
+
if (!current?.subscriber) {
|
|
55
|
+
pending = entry;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
beginDelivery(entry, current);
|
|
59
|
+
}
|
|
60
|
+
function registerHost(subscriber) {
|
|
61
|
+
if (owner) {
|
|
62
|
+
log.warn('检测到多个 <ToastHost />。只有第一个生效,重复挂载的实例保持惰性 —— 请在 app 根只挂一次。');
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const token = Symbol('ToastHostOwner');
|
|
66
|
+
const self = {
|
|
67
|
+
token,
|
|
68
|
+
subscriber
|
|
69
|
+
};
|
|
70
|
+
owner = self;
|
|
71
|
+
if (pending) beginDelivery(pending, self);
|
|
72
|
+
// 首投期间 subscriber 抛错会把 owner 作废 —— 此时不能发出可用的 lease。
|
|
73
|
+
if (owner?.token !== token) return null;
|
|
74
|
+
return {
|
|
75
|
+
ownerToken: token,
|
|
76
|
+
release() {
|
|
77
|
+
if (owner?.token !== token) return;
|
|
78
|
+
self.subscriber = null;
|
|
79
|
+
owner = null;
|
|
80
|
+
if (delivered?.ownerToken === token) {
|
|
81
|
+
// 未完成的投递退回 pending,让下一个 Host 能补投;但更新的 pending 优先。
|
|
82
|
+
if (!pending) pending = delivered.entry;
|
|
83
|
+
delivered = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function complete(ownerToken, leaseId, entryId) {
|
|
89
|
+
const current = delivered;
|
|
90
|
+
if (!current) return false;
|
|
91
|
+
if (current.ownerToken !== ownerToken) return false;
|
|
92
|
+
if (current.leaseId !== leaseId) return false;
|
|
93
|
+
if (current.entry.id !== entryId) return false;
|
|
94
|
+
delivered = null;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
function isCurrent(delivery) {
|
|
98
|
+
const current = delivered;
|
|
99
|
+
return current !== null && current.ownerToken === delivery.ownerToken && current.leaseId === delivery.leaseId && current.entry.id === delivery.entry.id;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
publish,
|
|
103
|
+
registerHost,
|
|
104
|
+
complete,
|
|
105
|
+
isCurrent,
|
|
106
|
+
pendingEntry: () => pending,
|
|
107
|
+
currentDelivery: () => delivered
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createToastStore","log","pending","delivered","owner","leaseCounter","beginDelivery","entry","capturedOwner","delivery","ownerToken","token","leaseId","subscriber","error","publish","current","registerHost","warn","Symbol","self","release","complete","entryId","id","isCurrent","pendingEntry","currentDelivery"],"sourceRoot":"../../../../../src","sources":["components/ui/Toast/store.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA,OAAO,SAASA,gBAAgBA,CAACC,GAAW,EAAc;EACxD,IAAIC,OAA0B,GAAG,IAAI;EACrC,IAAIC,SAA+B,GAAG,IAAI;EAC1C,IAAIC,KAAmB,GAAG,IAAI;EAC9B,IAAIC,YAAY,GAAG,CAAC;EAEpB,SAASC,aAAaA,CAACC,KAAiB,EAAEC,aAAoB,EAAQ;IACpE,MAAMC,QAAuB,GAAG;MAC9BF,KAAK;MACLG,UAAU,EAAEF,aAAa,CAACG,KAAK;MAC/BC,OAAO,EAAE,EAAEP;IACb,CAAC;IACD;IACA;IACAH,OAAO,GAAG,IAAI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SAAS,EAAEO,UAAU,KAAKC,KAAK,EAAE;UACnC;UACA,IAAI,CAACT,OAAO,EAAEA,OAAO,GAAGC,SAAS,CAACI,KAAK;UACvCJ,SAAS,GAAG,IAAI;QAClB;MACF;IACF,CAAC;EACH;EAEA,SAASmB,QAAQA,CACfZ,UAAkB,EAClBE,OAAe,EACfW,OAAe,EACN;IACT,MAAMP,OAAO,GAAGb,SAAS;IACzB,IAAI,CAACa,OAAO,EAAE,OAAO,KAAK;IAC1B,IAAIA,OAAO,CAACN,UAAU,KAAKA,UAAU,EAAE,OAAO,KAAK;IACnD,IAAIM,OAAO,CAACJ,OAAO,KAAKA,OAAO,EAAE,OAAO,KAAK;IAC7C,IAAII,OAAO,CAACT,KAAK,CAACiB,EAAE,KAAKD,OAAO,EAAE,OAAO,KAAK;IAC9CpB,SAAS,GAAG,IAAI;IAChB,OAAO,IAAI;EACb;EAEA,SAASsB,SAASA,CAAChB,QAAuB,EAAW;IACnD,MAAMO,OAAO,GAAGb,SAAS;IACzB,OACEa,OAAO,KAAK,IAAI,IAChBA,OAAO,CAACN,UAAU,KAAKD,QAAQ,CAACC,UAAU,IAC1CM,OAAO,CAACJ,OAAO,KAAKH,QAAQ,CAACG,OAAO,IACpCI,OAAO,CAACT,KAAK,CAACiB,EAAE,KAAKf,QAAQ,CAACF,KAAK,CAACiB,EAAE;EAE1C;EAEA,OAAO;IACLT,OAAO;IACPE,YAAY;IACZK,QAAQ;IACRG,SAAS;IACTC,YAAY,EAAEA,CAAA,KAAMxB,OAAO;IAC3ByB,eAAe,EAAEA,CAAA,KAAMxB;EACzB,CAAC;AACH","ignoreList":[]}
|
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
* 命令式 `toast()` API —— 与 `<ToastHost />` 配对使用。
|
|
5
5
|
*
|
|
6
6
|
* 文件名故意小写 `toast.ts`,host 组件叫 `ToastHost.tsx`,避免 APFS 大小写冲突。
|
|
7
|
+
*
|
|
8
|
+
* 本文件只做公共入参归一化(kind / duration / position),投递与身份仲裁全部在
|
|
9
|
+
* `store.ts`。下面三个内部导出只给两个 Host 用,**不进公共 barrel**。
|
|
7
10
|
*/
|
|
8
11
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
12
|
+
import { createToastStore } from "./store.js";
|
|
9
13
|
const log = createLogger('toast');
|
|
14
|
+
const store = createToastStore(log);
|
|
10
15
|
let _id = 0;
|
|
11
|
-
export const _subs = new Set();
|
|
12
16
|
const DEFAULT_DURATION = 3000;
|
|
13
17
|
// [L-55] duration 合法域:[1, 2^31)。INT32_MAX = 2^31-1 = 2147483647,
|
|
14
18
|
// setTimeout 内部用 int32 存储,超出会溢出变成 0 立即触发。
|
|
@@ -37,12 +41,9 @@ function emit(input, kind = 'info') {
|
|
|
37
41
|
duration: clampDuration(input.duration),
|
|
38
42
|
position: input.position ?? 'bottom'
|
|
39
43
|
};
|
|
40
|
-
// 未挂 <ToastHost
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
_subs.forEach(s => s(entry));
|
|
44
|
+
// 未挂 <ToastHost /> 是**受支持路径**:消息留在 pending,Host 挂上后立即补投。
|
|
45
|
+
// 故这里不告警 —— 启动早期的 toast 本来就可能先于 Host。
|
|
46
|
+
store.publish(entry);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
/**
|
|
@@ -58,4 +59,13 @@ export const toast = Object.assign(input => emit(input, 'info'), {
|
|
|
58
59
|
success: input => emit(input, 'success'),
|
|
59
60
|
error: input => emit(input, 'error')
|
|
60
61
|
});
|
|
62
|
+
|
|
63
|
+
/** 内部:ToastHost 挂载时注册唯一 owner;重复挂载得到 null。 */
|
|
64
|
+
export const registerToastHost = store.registerHost;
|
|
65
|
+
|
|
66
|
+
/** 内部:三重身份 CAS —— owner token + leaseId + entry id 全对才算完成。 */
|
|
67
|
+
export const completeToast = store.complete;
|
|
68
|
+
|
|
69
|
+
/** 内部:timer / RAF / 动画回调动 UI 前的守卫。 */
|
|
70
|
+
export const isCurrentToastDelivery = store.isCurrent;
|
|
61
71
|
//# sourceMappingURL=toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createLogger","
|
|
1
|
+
{"version":3,"names":["createLogger","createToastStore","log","store","_id","DEFAULT_DURATION","MAX_DURATION","clampDuration","raw","Number","isFinite","warn","Math","trunc","emit","input","kind","entry","id","message","duration","position","publish","toast","Object","assign","info","success","error","registerToastHost","registerHost","completeToast","complete","isCurrentToastDelivery","isCurrent"],"sourceRoot":"../../../../../src","sources":["components/ui/Toast/toast.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gCAAuB;AACpD,SAASC,gBAAgB,QAAQ,YAAS;AAG1C,MAAMC,GAAG,GAAGF,YAAY,CAAC,OAAO,CAAC;AAEjC,MAAMG,KAAK,GAAGF,gBAAgB,CAACC,GAAG,CAAC;AAEnC,IAAIE,GAAG,GAAG,CAAC;AAEX,MAAMC,gBAAgB,GAAG,IAAI;AAC7B;AACA;AACA,MAAMC,YAAY,GAAG,UAAU;;AAE/B;AACA,SAASC,aAAaA,CAACC,GAAuB,EAAU;EACtD,IAAIA,GAAG,IAAI,IAAI,EAAE,OAAOH,gBAAgB;EACxC,IAAI,CAACI,MAAM,CAACC,QAAQ,CAACF,GAAG,CAAC,IAAIA,GAAG,GAAG,CAAC,IAAIA,GAAG,IAAIF,YAAY,EAAE;IAC3DJ,GAAG,CAACS,IAAI,CACN,kBAAkBH,GAAG,yBAAyBH,gBAAgB,KAChE,CAAC;IACD,OAAOA,gBAAgB;EACzB;EACA,OAAOO,IAAI,CAACC,KAAK,CAACL,GAAG,CAAC;AACxB;AAEA,SAASM,IAAIA,CAACC,KAAiB,EAAEC,IAAe,GAAG,MAAM,EAAE;EACzD,MAAMC,KAAiB,GACrB,OAAOF,KAAK,KAAK,QAAQ,GACrB;IACEG,EAAE,EAAE,EAAEd,GAAG;IACTe,OAAO,EAAEJ,KAAK;IACdC,IAAI;IACJI,QAAQ,EAAEf,gBAAgB;IAC1BgB,QAAQ,EAAE;EACZ,CAAC,GACD;IACEH,EAAE,EAAE,EAAEd,GAAG;IACTe,OAAO,EAAEJ,KAAK,CAACI,OAAO;IACtBH,IAAI,EAAED,KAAK,CAACC,IAAI,IAAIA,IAAI;IACxBI,QAAQ,EAAEb,aAAa,CAACQ,KAAK,CAACK,QAAQ,CAAC;IACvCC,QAAQ,EAAEN,KAAK,CAACM,QAAQ,IAAI;EAC9B,CAAC;EACP;EACA;EACAlB,KAAK,CAACmB,OAAO,CAACL,KAAK,CAAC;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,KAAK,GAAGC,MAAM,CAACC,MAAM,CAAEV,KAAiB,IAAKD,IAAI,CAACC,KAAK,EAAE,MAAM,CAAC,EAAE;EAC7EW,IAAI,EAAGX,KAAiB,IAAKD,IAAI,CAACC,KAAK,EAAE,MAAM,CAAC;EAChDY,OAAO,EAAGZ,KAAiB,IAAKD,IAAI,CAACC,KAAK,EAAE,SAAS,CAAC;EACtDa,KAAK,EAAGb,KAAiB,IAAKD,IAAI,CAACC,KAAK,EAAE,OAAO;AACnD,CAAC,CAAC;;AAEF;AACA,OAAO,MAAMc,iBAAiB,GAAG1B,KAAK,CAAC2B,YAAY;;AAEnD;AACA,OAAO,MAAMC,aAAa,GAAG5B,KAAK,CAAC6B,QAAQ;;AAE3C;AACA,OAAO,MAAMC,sBAAsB,GAAG9B,KAAK,CAAC+B,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Avatar","BlurLayer","Button","Card","Carousel","Cell","List","Checkbox","Chip","confirm","ConfirmHost","DrawerHeader","Empty","EntryCard","Form","FormGroup","FormRow","Grid","Icon","IconButton","Input","Logo","NavBar","PasswordInput","Pulse","PulseDot","usePulse","Radio","Reveal","Search","Skeleton","Segmented","Spinner","StatusDot","Stepper","Switch","TabBar","Tabs","Tag","Textarea","Thumbnail","toast","ToastHost"],"sourceRoot":"../../../../src","sources":["components/ui/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,mBAAU;AAEjC,SAASC,SAAS,QAAQ,sBAAa;AAEvC,SAASC,MAAM,QAAQ,mBAAU;AAEjC,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,QAAQ,QAAQ,qBAAY;AAErC,SAASC,IAAI,EAAEC,IAAI,QAAQ,iBAAQ;
|
|
1
|
+
{"version":3,"names":["Avatar","BlurLayer","Button","Card","Carousel","Cell","List","Checkbox","Chip","confirm","ConfirmHost","DrawerHeader","Empty","EntryCard","Form","FormGroup","FormRow","Grid","Icon","IconButton","Input","Logo","NavBar","PasswordInput","Pulse","PulseDot","usePulse","Radio","Reveal","Search","Skeleton","Segmented","Spinner","StatusDot","Stepper","Switch","TabBar","Tabs","Tag","Textarea","Thumbnail","toast","ToastHost"],"sourceRoot":"../../../../src","sources":["components/ui/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,mBAAU;AAEjC,SAASC,SAAS,QAAQ,sBAAa;AAEvC,SAASC,MAAM,QAAQ,mBAAU;AAEjC,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,QAAQ,QAAQ,qBAAY;AAErC,SAASC,IAAI,EAAEC,IAAI,QAAQ,iBAAQ;AAQnC,SAASC,QAAQ,QAAQ,qBAAY;AAErC,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,OAAO,EAAEC,WAAW,QAAQ,oBAAW;AAEhD,SAASC,YAAY,QAAQ,yBAAgB;AAE7C,SAASC,KAAK,QAAQ,kBAAS;AAE/B,SAASC,SAAS,QAAQ,sBAAa;AAEvC,SAASC,IAAI,EAAEC,SAAS,EAAEC,OAAO,QAAQ,iBAAQ;AAEjD,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,UAAU,QAAQ,uBAAc;AAEzC,SAASC,KAAK,QAAQ,kBAAS;AAO/B,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,MAAM,QAAQ,mBAAU;AAEjC,SAASC,aAAa,QAAQ,0BAAiB;AAE/C,SAASC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,kBAAS;AAEnD,SAASC,KAAK,QAAQ,kBAAS;AAE/B,SAASC,MAAM,QAAQ,mBAAU;AAEjC,SAASC,MAAM,QAAQ,mBAAU;AAEjC,SAASC,QAAQ,QAAQ,qBAAY;AAErC,SAASC,SAAS,QAAQ,sBAAa;AAEvC,SAASC,OAAO,QAAQ,oBAAW;AAEnC,SAASC,SAAS,QAAQ,sBAAa;AAMvC,SAASC,OAAO,QAAQ,oBAAW;AAEnC,SAASC,MAAM,QAAQ,mBAAU;AAEjC,SAASC,MAAM,QAAQ,mBAAU;AAEjC,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,GAAG,QAAQ,gBAAO;AAE3B,SAASC,QAAQ,QAAQ,qBAAY;AAErC,SAASC,SAAS,QAAQ,sBAAa;AAMvC,SAASC,KAAK,EAAEC,SAAS,QAAQ,kBAAS","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useState } from 'react';
|
|
4
|
+
import { Image } from 'react-native';
|
|
5
|
+
import { selectImageAttemptSource } from './selectImageAttemptSource';
|
|
6
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* 每个 keyed 挂载实例只拥有自己的失败状态。source identity 变化时由父级 key
|
|
9
|
+
* 同步换实例,旧 onError 无法写入新 attempt。
|
|
10
|
+
*/
|
|
11
|
+
export function ImageAttempt({
|
|
12
|
+
source,
|
|
13
|
+
fallback,
|
|
14
|
+
...imageProps
|
|
15
|
+
}) {
|
|
16
|
+
const [failed, setFailed] = useState(false);
|
|
17
|
+
// RNW 的加载 effect 依赖 onError identity;等价 render 不应中止并重发请求。
|
|
18
|
+
const handleError = useCallback(() => setFailed(true), []);
|
|
19
|
+
const selectedSource = selectImageAttemptSource(source);
|
|
20
|
+
return failed || selectedSource === undefined ? /*#__PURE__*/_jsx(_Fragment, {
|
|
21
|
+
children: fallback
|
|
22
|
+
}) : /*#__PURE__*/_jsx(Image, {
|
|
23
|
+
...imageProps,
|
|
24
|
+
source: selectedSource,
|
|
25
|
+
onError: handleError
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ImageAttempt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useState","Image","selectImageAttemptSource","Fragment","_Fragment","jsx","_jsx","ImageAttempt","source","fallback","imageProps","failed","setFailed","handleError","selectedSource","undefined","children","onError"],"sourceRoot":"../../../../../src","sources":["components/ui/shared/ImageAttempt.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACpD,SAASC,KAAK,QAAQ,cAAc;AAEpC,SAASC,wBAAwB,QAAQ,4BAA4B;AAAC,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA;AAOtE;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAC;EAC3BC,MAAM;EACNC,QAAQ;EACR,GAAGC;AACc,CAAC,EAAqB;EACvC,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGZ,QAAQ,CAAC,KAAK,CAAC;EAC3C;EACA,MAAMa,WAAW,GAAGd,WAAW,CAAC,MAAMa,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;EAC1D,MAAME,cAAc,GAAGZ,wBAAwB,CAACM,MAAM,CAAC;EAEvD,OAAOG,MAAM,IAAIG,cAAc,KAAKC,SAAS,gBAC3CT,IAAA,CAAAF,SAAA;IAAAY,QAAA,EAAGP;EAAQ,CAAG,CAAC,gBAEfH,IAAA,CAACL,KAAK;IAAA,GAAKS,UAAU;IAAEF,MAAM,EAAEM,cAAe;IAACG,OAAO,EAAEJ;EAAY,CAAE,CACvE;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 装饰性节点从 a11y 树里隐藏所需的**全套**属性 —— 四个平台各认一个,少一个就漏。
|
|
5
|
+
*
|
|
6
|
+
* - `accessible: false` —— iOS/Android 都不把该节点合并成可聚焦元素
|
|
7
|
+
* - `accessibilityElementsHidden` —— iOS 连同后代一起移出 a11y 树
|
|
8
|
+
* - `importantForAccessibility: 'no-hide-descendants'` —— Android 同上
|
|
9
|
+
* - `aria-hidden` —— react-native-web 映射到 DOM 的 `aria-hidden`
|
|
10
|
+
*
|
|
11
|
+
* **只能**落在库内本地的 RN `View` / `Image` / `Text` 上。绝不要展开给未知第三方组件:
|
|
12
|
+
* 它们可能把未识别的 props 原样透传到原生层,或者干脆用同名 prop 表达别的语义。
|
|
13
|
+
* 需要隐藏第三方子树时,用一个本地 View 包住它,把这些属性挂在包装层。
|
|
14
|
+
*/
|
|
15
|
+
export const A11Y_HIDDEN_PROPS = {
|
|
16
|
+
'accessible': false,
|
|
17
|
+
'accessibilityElementsHidden': true,
|
|
18
|
+
'importantForAccessibility': 'no-hide-descendants',
|
|
19
|
+
'aria-hidden': true
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=a11y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["A11Y_HIDDEN_PROPS"],"sourceRoot":"../../../../../src","sources":["components/ui/shared/a11y.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,iBAAiB,GAAG;EAC/B,YAAY,EAAE,KAAK;EACnB,6BAA6B,EAAE,IAAI;EACnC,2BAA2B,EAAE,qBAAqB;EAClD,aAAa,EAAE;AACjB,CAAU","ignoreList":[]}
|