orn-ui 0.2.9 → 0.3.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.
- package/AGENTS.md +67 -52
- package/README.md +5 -9
- package/lib/commonjs/atoms/Avatar.js +77 -5
- package/lib/commonjs/atoms/Avatar.js.map +1 -1
- package/lib/commonjs/atoms/Badge.js +17 -8
- package/lib/commonjs/atoms/Badge.js.map +1 -1
- package/lib/commonjs/atoms/Button.js +108 -39
- package/lib/commonjs/atoms/Button.js.map +1 -1
- package/lib/commonjs/atoms/Card.js +24 -2
- package/lib/commonjs/atoms/Card.js.map +1 -1
- package/lib/commonjs/atoms/Checkbox.js +41 -10
- package/lib/commonjs/atoms/Checkbox.js.map +1 -1
- package/lib/commonjs/atoms/Divider.js +30 -5
- package/lib/commonjs/atoms/Divider.js.map +1 -1
- package/lib/commonjs/atoms/EmptyState.js +58 -20
- package/lib/commonjs/atoms/EmptyState.js.map +1 -1
- package/lib/commonjs/atoms/Fab.js +32 -12
- package/lib/commonjs/atoms/Fab.js.map +1 -1
- package/lib/commonjs/atoms/Gradient.js +102 -36
- package/lib/commonjs/atoms/Gradient.js.map +1 -1
- package/lib/commonjs/atoms/IconButton.js +25 -4
- package/lib/commonjs/atoms/IconButton.js.map +1 -1
- package/lib/commonjs/atoms/Image.js +61 -25
- package/lib/commonjs/atoms/Image.js.map +1 -1
- package/lib/commonjs/atoms/Input.js +105 -17
- package/lib/commonjs/atoms/Input.js.map +1 -1
- package/lib/commonjs/atoms/KeyValueRow.js +37 -9
- package/lib/commonjs/atoms/KeyValueRow.js.map +1 -1
- package/lib/commonjs/atoms/PressableScale.js +25 -5
- package/lib/commonjs/atoms/PressableScale.js.map +1 -1
- package/lib/commonjs/atoms/ShinyText.js +29 -29
- package/lib/commonjs/atoms/Skeleton.js +28 -13
- package/lib/commonjs/atoms/Skeleton.js.map +1 -1
- package/lib/commonjs/atoms/Spinner.js +81 -22
- package/lib/commonjs/atoms/Spinner.js.map +1 -1
- package/lib/commonjs/atoms/Text.js +56 -5
- package/lib/commonjs/atoms/Text.js.map +1 -1
- package/lib/commonjs/atoms/Transition.js +46 -43
- package/lib/commonjs/atoms/Transition.js.map +1 -1
- package/lib/commonjs/atoms/index.js +6 -0
- package/lib/commonjs/atoms/index.js.map +1 -1
- package/lib/commonjs/atoms/inputValidation.js +56 -0
- package/lib/commonjs/atoms/inputValidation.js.map +1 -0
- package/lib/commonjs/icons/Icon.js +4 -4
- package/lib/commonjs/icons/defaultIcons.js +576 -24
- package/lib/commonjs/icons/defaultIcons.js.map +1 -1
- package/lib/commonjs/icons/index.js +6 -0
- package/lib/commonjs/icons/index.js.map +1 -1
- package/lib/commonjs/molecules/AvatarHeader.js +47 -14
- package/lib/commonjs/molecules/AvatarHeader.js.map +1 -1
- package/lib/commonjs/molecules/FormActions.js +25 -9
- package/lib/commonjs/molecules/FormActions.js.map +1 -1
- package/lib/commonjs/molecules/InfoRow.js +30 -14
- package/lib/commonjs/molecules/InfoRow.js.map +1 -1
- package/lib/commonjs/molecules/OptionCard.js +37 -22
- package/lib/commonjs/molecules/OptionCard.js.map +1 -1
- package/lib/commonjs/molecules/SegmentedControl.js +103 -14
- package/lib/commonjs/molecules/SegmentedControl.js.map +1 -1
- package/lib/commonjs/molecules/Stepper.js +61 -16
- package/lib/commonjs/molecules/Stepper.js.map +1 -1
- package/lib/commonjs/molecules/Steps.js +105 -41
- package/lib/commonjs/molecules/Steps.js.map +1 -1
- package/lib/commonjs/molecules/SymmetricGrid.js +26 -18
- package/lib/commonjs/molecules/SymmetricGrid.js.map +1 -1
- package/lib/commonjs/organisms/Alert.js +49 -35
- package/lib/commonjs/organisms/Alert.js.map +1 -1
- package/lib/commonjs/organisms/AlertProvider.js +10 -10
- package/lib/commonjs/organisms/BottomSheet.js +137 -85
- package/lib/commonjs/organisms/BottomSheet.js.map +1 -1
- package/lib/commonjs/organisms/Chart.js +197 -156
- package/lib/commonjs/organisms/Chart.js.map +1 -1
- package/lib/commonjs/organisms/DateField.js +36 -20
- package/lib/commonjs/organisms/DateField.js.map +1 -1
- package/lib/commonjs/organisms/DatePicker.js +56 -33
- package/lib/commonjs/organisms/DatePicker.js.map +1 -1
- package/lib/commonjs/organisms/List.js +62 -34
- package/lib/commonjs/organisms/List.js.map +1 -1
- package/lib/commonjs/organisms/Modal.js +120 -82
- package/lib/commonjs/organisms/Modal.js.map +1 -1
- package/lib/commonjs/organisms/NavigationBar.js +63 -24
- package/lib/commonjs/organisms/NavigationBar.js.map +1 -1
- package/lib/commonjs/organisms/OptionWheel.js +64 -64
- package/lib/commonjs/organisms/OptionWheel.js.map +1 -1
- package/lib/commonjs/organisms/ReorderableList.js +48 -27
- package/lib/commonjs/organisms/ReorderableList.js.map +1 -1
- package/lib/commonjs/organisms/Screen.js +68 -35
- package/lib/commonjs/organisms/Screen.js.map +1 -1
- package/lib/commonjs/organisms/SearchList.js +56 -26
- package/lib/commonjs/organisms/SearchList.js.map +1 -1
- package/lib/commonjs/organisms/Select.js +45 -24
- package/lib/commonjs/organisms/Select.js.map +1 -1
- package/lib/commonjs/organisms/Slides.js +36 -23
- package/lib/commonjs/organisms/Slides.js.map +1 -1
- package/lib/commonjs/organisms/ThemeToggle.js +10 -9
- package/lib/commonjs/organisms/ThemeToggle.js.map +1 -1
- package/lib/commonjs/organisms/Timeline.js +73 -56
- package/lib/commonjs/organisms/Timeline.js.map +1 -1
- package/lib/commonjs/organisms/Toast.js +46 -15
- package/lib/commonjs/organisms/Toast.js.map +1 -1
- package/lib/commonjs/organisms/ToastProvider.js +14 -10
- package/lib/commonjs/organisms/ToastProvider.js.map +1 -1
- package/lib/commonjs/organisms/Wizard.js +40 -15
- package/lib/commonjs/organisms/Wizard.js.map +1 -1
- package/lib/commonjs/organisms/chart/frame.js +25 -25
- package/lib/commonjs/organisms/chart/frame.js.map +1 -1
- package/lib/commonjs/organisms/chart/marks.js +42 -42
- package/lib/commonjs/organisms/chart/math.js +84 -85
- package/lib/commonjs/organisms/chart/math.js.map +1 -1
- package/lib/commonjs/organisms/chart/palette.js +28 -28
- package/lib/commonjs/organisms/imperativeBridge.js +5 -5
- package/lib/commonjs/organisms/imperativeBridge.js.map +1 -1
- package/lib/commonjs/organisms/useSlides.js +53 -21
- package/lib/commonjs/organisms/useSlides.js.map +1 -1
- package/lib/commonjs/safe-area/SafeAreaUIProvider.js +9 -66
- package/lib/commonjs/safe-area/SafeAreaUIProvider.js.map +1 -1
- package/lib/commonjs/safe-area/index.js.map +1 -1
- package/lib/commonjs/theme/KeyboardAvoidance.js +206 -0
- package/lib/commonjs/theme/KeyboardAvoidance.js.map +1 -0
- package/lib/commonjs/theme/NativeOverlay.js +263 -0
- package/lib/commonjs/theme/NativeOverlay.js.map +1 -0
- package/lib/commonjs/theme/UIProvider.js +86 -33
- package/lib/commonjs/theme/UIProvider.js.map +1 -1
- package/lib/commonjs/theme/colors.js +17 -17
- package/lib/commonjs/theme/colors.js.map +1 -1
- package/lib/commonjs/theme/createStyles.js +19 -16
- package/lib/commonjs/theme/createStyles.js.map +1 -1
- package/lib/commonjs/theme/createTheme.js +6 -6
- package/lib/commonjs/theme/index.js +6 -0
- package/lib/commonjs/theme/index.js.map +1 -1
- package/lib/commonjs/theme/insets.js +1 -1
- package/lib/commonjs/theme/labels.js +29 -1
- package/lib/commonjs/theme/labels.js.map +1 -1
- package/lib/commonjs/theme/palettes.js +25 -23
- package/lib/commonjs/theme/palettes.js.map +1 -1
- package/lib/commonjs/theme/tokens.js +28 -14
- package/lib/commonjs/theme/tokens.js.map +1 -1
- package/lib/commonjs/theme/useKeyboardField.js +36 -0
- package/lib/commonjs/theme/useKeyboardField.js.map +1 -0
- package/lib/commonjs/theme/useReduceMotion.js +31 -0
- package/lib/commonjs/theme/useReduceMotion.js.map +1 -0
- package/lib/module/atoms/Avatar.js +79 -8
- package/lib/module/atoms/Avatar.js.map +1 -1
- package/lib/module/atoms/Badge.js +17 -8
- package/lib/module/atoms/Badge.js.map +1 -1
- package/lib/module/atoms/Button.js +110 -41
- package/lib/module/atoms/Button.js.map +1 -1
- package/lib/module/atoms/Card.js +24 -2
- package/lib/module/atoms/Card.js.map +1 -1
- package/lib/module/atoms/Checkbox.js +42 -11
- package/lib/module/atoms/Checkbox.js.map +1 -1
- package/lib/module/atoms/Divider.js +31 -6
- package/lib/module/atoms/Divider.js.map +1 -1
- package/lib/module/atoms/EmptyState.js +58 -20
- package/lib/module/atoms/EmptyState.js.map +1 -1
- package/lib/module/atoms/Fab.js +33 -13
- package/lib/module/atoms/Fab.js.map +1 -1
- package/lib/module/atoms/Gradient.js +103 -37
- package/lib/module/atoms/Gradient.js.map +1 -1
- package/lib/module/atoms/IconButton.js +25 -4
- package/lib/module/atoms/IconButton.js.map +1 -1
- package/lib/module/atoms/Image.js +61 -25
- package/lib/module/atoms/Image.js.map +1 -1
- package/lib/module/atoms/Input.js +108 -20
- package/lib/module/atoms/Input.js.map +1 -1
- package/lib/module/atoms/KeyValueRow.js +37 -9
- package/lib/module/atoms/KeyValueRow.js.map +1 -1
- package/lib/module/atoms/PressableScale.js +25 -5
- package/lib/module/atoms/PressableScale.js.map +1 -1
- package/lib/module/atoms/ShinyText.js +29 -29
- package/lib/module/atoms/Skeleton.js +30 -13
- package/lib/module/atoms/Skeleton.js.map +1 -1
- package/lib/module/atoms/Spinner.js +82 -23
- package/lib/module/atoms/Spinner.js.map +1 -1
- package/lib/module/atoms/Text.js +56 -5
- package/lib/module/atoms/Text.js.map +1 -1
- package/lib/module/atoms/Transition.js +41 -42
- package/lib/module/atoms/Transition.js.map +1 -1
- package/lib/module/atoms/index.js +1 -1
- package/lib/module/atoms/index.js.map +1 -1
- package/lib/module/atoms/inputValidation.js +52 -0
- package/lib/module/atoms/inputValidation.js.map +1 -0
- package/lib/module/icons/Icon.js +4 -4
- package/lib/module/icons/defaultIcons.js +574 -24
- package/lib/module/icons/defaultIcons.js.map +1 -1
- package/lib/module/icons/index.js +1 -1
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/molecules/AvatarHeader.js +47 -14
- package/lib/module/molecules/AvatarHeader.js.map +1 -1
- package/lib/module/molecules/FormActions.js +25 -9
- package/lib/module/molecules/FormActions.js.map +1 -1
- package/lib/module/molecules/InfoRow.js +30 -14
- package/lib/module/molecules/InfoRow.js.map +1 -1
- package/lib/module/molecules/OptionCard.js +37 -22
- package/lib/module/molecules/OptionCard.js.map +1 -1
- package/lib/module/molecules/SegmentedControl.js +107 -18
- package/lib/module/molecules/SegmentedControl.js.map +1 -1
- package/lib/module/molecules/Stepper.js +63 -18
- package/lib/module/molecules/Stepper.js.map +1 -1
- package/lib/module/molecules/Steps.js +107 -43
- package/lib/module/molecules/Steps.js.map +1 -1
- package/lib/module/molecules/SymmetricGrid.js +26 -18
- package/lib/module/molecules/SymmetricGrid.js.map +1 -1
- package/lib/module/organisms/Alert.js +51 -37
- package/lib/module/organisms/Alert.js.map +1 -1
- package/lib/module/organisms/AlertProvider.js +10 -10
- package/lib/module/organisms/BottomSheet.js +142 -88
- package/lib/module/organisms/BottomSheet.js.map +1 -1
- package/lib/module/organisms/Chart.js +199 -158
- package/lib/module/organisms/Chart.js.map +1 -1
- package/lib/module/organisms/DateField.js +36 -20
- package/lib/module/organisms/DateField.js.map +1 -1
- package/lib/module/organisms/DatePicker.js +56 -33
- package/lib/module/organisms/DatePicker.js.map +1 -1
- package/lib/module/organisms/List.js +62 -34
- package/lib/module/organisms/List.js.map +1 -1
- package/lib/module/organisms/Modal.js +122 -84
- package/lib/module/organisms/Modal.js.map +1 -1
- package/lib/module/organisms/NavigationBar.js +64 -25
- package/lib/module/organisms/NavigationBar.js.map +1 -1
- package/lib/module/organisms/OptionWheel.js +64 -64
- package/lib/module/organisms/OptionWheel.js.map +1 -1
- package/lib/module/organisms/ReorderableList.js +48 -27
- package/lib/module/organisms/ReorderableList.js.map +1 -1
- package/lib/module/organisms/Screen.js +70 -37
- package/lib/module/organisms/Screen.js.map +1 -1
- package/lib/module/organisms/SearchList.js +56 -26
- package/lib/module/organisms/SearchList.js.map +1 -1
- package/lib/module/organisms/Select.js +46 -25
- package/lib/module/organisms/Select.js.map +1 -1
- package/lib/module/organisms/Slides.js +37 -24
- package/lib/module/organisms/Slides.js.map +1 -1
- package/lib/module/organisms/ThemeToggle.js +11 -10
- package/lib/module/organisms/ThemeToggle.js.map +1 -1
- package/lib/module/organisms/Timeline.js +73 -56
- package/lib/module/organisms/Timeline.js.map +1 -1
- package/lib/module/organisms/Toast.js +47 -16
- package/lib/module/organisms/Toast.js.map +1 -1
- package/lib/module/organisms/ToastProvider.js +15 -11
- package/lib/module/organisms/ToastProvider.js.map +1 -1
- package/lib/module/organisms/Wizard.js +41 -16
- package/lib/module/organisms/Wizard.js.map +1 -1
- package/lib/module/organisms/chart/frame.js +25 -25
- package/lib/module/organisms/chart/frame.js.map +1 -1
- package/lib/module/organisms/chart/marks.js +42 -42
- package/lib/module/organisms/chart/math.js +84 -85
- package/lib/module/organisms/chart/math.js.map +1 -1
- package/lib/module/organisms/chart/palette.js +28 -28
- package/lib/module/organisms/imperativeBridge.js +5 -5
- package/lib/module/organisms/imperativeBridge.js.map +1 -1
- package/lib/module/organisms/useSlides.js +53 -21
- package/lib/module/organisms/useSlides.js.map +1 -1
- package/lib/module/safe-area/SafeAreaUIProvider.js +10 -65
- package/lib/module/safe-area/SafeAreaUIProvider.js.map +1 -1
- package/lib/module/safe-area/index.js +1 -0
- package/lib/module/safe-area/index.js.map +1 -1
- package/lib/module/theme/KeyboardAvoidance.js +198 -0
- package/lib/module/theme/KeyboardAvoidance.js.map +1 -0
- package/lib/module/theme/NativeOverlay.js +257 -0
- package/lib/module/theme/NativeOverlay.js.map +1 -0
- package/lib/module/theme/UIProvider.js +88 -35
- package/lib/module/theme/UIProvider.js.map +1 -1
- package/lib/module/theme/colors.js +17 -17
- package/lib/module/theme/colors.js.map +1 -1
- package/lib/module/theme/createStyles.js +20 -16
- package/lib/module/theme/createStyles.js.map +1 -1
- package/lib/module/theme/createTheme.js +6 -6
- package/lib/module/theme/index.js +1 -1
- package/lib/module/theme/index.js.map +1 -1
- package/lib/module/theme/insets.js +1 -1
- package/lib/module/theme/labels.js +29 -1
- package/lib/module/theme/labels.js.map +1 -1
- package/lib/module/theme/palettes.js +25 -23
- package/lib/module/theme/palettes.js.map +1 -1
- package/lib/module/theme/tokens.js +27 -13
- package/lib/module/theme/tokens.js.map +1 -1
- package/lib/module/theme/useKeyboardField.js +33 -0
- package/lib/module/theme/useKeyboardField.js.map +1 -0
- package/lib/module/theme/useReduceMotion.js +28 -0
- package/lib/module/theme/useReduceMotion.js.map +1 -0
- package/lib/typescript/atoms/Avatar.d.ts +35 -5
- package/lib/typescript/atoms/Avatar.d.ts.map +1 -1
- package/lib/typescript/atoms/Badge.d.ts +14 -3
- package/lib/typescript/atoms/Badge.d.ts.map +1 -1
- package/lib/typescript/atoms/Button.d.ts +34 -3
- package/lib/typescript/atoms/Button.d.ts.map +1 -1
- package/lib/typescript/atoms/Card.d.ts +13 -2
- package/lib/typescript/atoms/Card.d.ts.map +1 -1
- package/lib/typescript/atoms/Checkbox.d.ts +26 -1
- package/lib/typescript/atoms/Checkbox.d.ts.map +1 -1
- package/lib/typescript/atoms/Divider.d.ts +18 -1
- package/lib/typescript/atoms/Divider.d.ts.map +1 -1
- package/lib/typescript/atoms/EmptyState.d.ts +30 -3
- package/lib/typescript/atoms/EmptyState.d.ts.map +1 -1
- package/lib/typescript/atoms/Fab.d.ts +24 -4
- package/lib/typescript/atoms/Fab.d.ts.map +1 -1
- package/lib/typescript/atoms/Gradient.d.ts +21 -15
- package/lib/typescript/atoms/Gradient.d.ts.map +1 -1
- package/lib/typescript/atoms/IconButton.d.ts +18 -4
- package/lib/typescript/atoms/IconButton.d.ts.map +1 -1
- package/lib/typescript/atoms/Image.d.ts +39 -17
- package/lib/typescript/atoms/Image.d.ts.map +1 -1
- package/lib/typescript/atoms/Input.d.ts +57 -7
- package/lib/typescript/atoms/Input.d.ts.map +1 -1
- package/lib/typescript/atoms/KeyValueRow.d.ts +16 -4
- package/lib/typescript/atoms/KeyValueRow.d.ts.map +1 -1
- package/lib/typescript/atoms/PressableScale.d.ts +12 -5
- package/lib/typescript/atoms/PressableScale.d.ts.map +1 -1
- package/lib/typescript/atoms/ShinyText.d.ts +17 -17
- package/lib/typescript/atoms/ShinyText.d.ts.map +1 -1
- package/lib/typescript/atoms/Skeleton.d.ts +12 -7
- package/lib/typescript/atoms/Skeleton.d.ts.map +1 -1
- package/lib/typescript/atoms/Spinner.d.ts +29 -1
- package/lib/typescript/atoms/Spinner.d.ts.map +1 -1
- package/lib/typescript/atoms/Text.d.ts +46 -0
- package/lib/typescript/atoms/Text.d.ts.map +1 -1
- package/lib/typescript/atoms/Transition.d.ts +19 -15
- package/lib/typescript/atoms/Transition.d.ts.map +1 -1
- package/lib/typescript/atoms/index.d.ts +3 -3
- package/lib/typescript/atoms/index.d.ts.map +1 -1
- package/lib/typescript/atoms/inputValidation.d.ts +29 -0
- package/lib/typescript/atoms/inputValidation.d.ts.map +1 -0
- package/lib/typescript/icons/Icon.d.ts +4 -4
- package/lib/typescript/icons/defaultIcons.d.ts +19 -2
- package/lib/typescript/icons/defaultIcons.d.ts.map +1 -1
- package/lib/typescript/icons/index.d.ts +2 -2
- package/lib/typescript/icons/index.d.ts.map +1 -1
- package/lib/typescript/icons/types.d.ts +13 -3
- package/lib/typescript/icons/types.d.ts.map +1 -1
- package/lib/typescript/molecules/AvatarHeader.d.ts +23 -4
- package/lib/typescript/molecules/AvatarHeader.d.ts.map +1 -1
- package/lib/typescript/molecules/FormActions.d.ts +21 -4
- package/lib/typescript/molecules/FormActions.d.ts.map +1 -1
- package/lib/typescript/molecules/InfoRow.d.ts +17 -3
- package/lib/typescript/molecules/InfoRow.d.ts.map +1 -1
- package/lib/typescript/molecules/OptionCard.d.ts +20 -5
- package/lib/typescript/molecules/OptionCard.d.ts.map +1 -1
- package/lib/typescript/molecules/SegmentedControl.d.ts +18 -2
- package/lib/typescript/molecules/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/molecules/Stepper.d.ts +23 -7
- package/lib/typescript/molecules/Stepper.d.ts.map +1 -1
- package/lib/typescript/molecules/Steps.d.ts +18 -4
- package/lib/typescript/molecules/Steps.d.ts.map +1 -1
- package/lib/typescript/molecules/SymmetricGrid.d.ts +15 -5
- package/lib/typescript/molecules/SymmetricGrid.d.ts.map +1 -1
- package/lib/typescript/organisms/Alert.d.ts +28 -2
- package/lib/typescript/organisms/Alert.d.ts.map +1 -1
- package/lib/typescript/organisms/AlertProvider.d.ts +10 -10
- package/lib/typescript/organisms/AlertProvider.d.ts.map +1 -1
- package/lib/typescript/organisms/BottomSheet.d.ts +20 -5
- package/lib/typescript/organisms/BottomSheet.d.ts.map +1 -1
- package/lib/typescript/organisms/Chart.d.ts +86 -75
- package/lib/typescript/organisms/Chart.d.ts.map +1 -1
- package/lib/typescript/organisms/DateField.d.ts +17 -3
- package/lib/typescript/organisms/DateField.d.ts.map +1 -1
- package/lib/typescript/organisms/DatePicker.d.ts +7 -11
- package/lib/typescript/organisms/DatePicker.d.ts.map +1 -1
- package/lib/typescript/organisms/List.d.ts +30 -3
- package/lib/typescript/organisms/List.d.ts.map +1 -1
- package/lib/typescript/organisms/Modal.d.ts +30 -3
- package/lib/typescript/organisms/Modal.d.ts.map +1 -1
- package/lib/typescript/organisms/NavigationBar.d.ts +26 -7
- package/lib/typescript/organisms/NavigationBar.d.ts.map +1 -1
- package/lib/typescript/organisms/OptionWheel.d.ts +20 -16
- package/lib/typescript/organisms/OptionWheel.d.ts.map +1 -1
- package/lib/typescript/organisms/ReorderableList.d.ts +20 -11
- package/lib/typescript/organisms/ReorderableList.d.ts.map +1 -1
- package/lib/typescript/organisms/Screen.d.ts +27 -8
- package/lib/typescript/organisms/Screen.d.ts.map +1 -1
- package/lib/typescript/organisms/SearchList.d.ts +46 -3
- package/lib/typescript/organisms/SearchList.d.ts.map +1 -1
- package/lib/typescript/organisms/Select.d.ts +26 -6
- package/lib/typescript/organisms/Select.d.ts.map +1 -1
- package/lib/typescript/organisms/Slides.d.ts +44 -26
- package/lib/typescript/organisms/Slides.d.ts.map +1 -1
- package/lib/typescript/organisms/ThemeToggle.d.ts +6 -2
- package/lib/typescript/organisms/ThemeToggle.d.ts.map +1 -1
- package/lib/typescript/organisms/Timeline.d.ts +26 -9
- package/lib/typescript/organisms/Timeline.d.ts.map +1 -1
- package/lib/typescript/organisms/Toast.d.ts +19 -4
- package/lib/typescript/organisms/Toast.d.ts.map +1 -1
- package/lib/typescript/organisms/ToastProvider.d.ts +8 -8
- package/lib/typescript/organisms/ToastProvider.d.ts.map +1 -1
- package/lib/typescript/organisms/Wizard.d.ts +24 -6
- package/lib/typescript/organisms/Wizard.d.ts.map +1 -1
- package/lib/typescript/organisms/chart/frame.d.ts +21 -21
- package/lib/typescript/organisms/chart/frame.d.ts.map +1 -1
- package/lib/typescript/organisms/chart/marks.d.ts +28 -28
- package/lib/typescript/organisms/chart/marks.d.ts.map +1 -1
- package/lib/typescript/organisms/chart/math.d.ts +69 -70
- package/lib/typescript/organisms/chart/math.d.ts.map +1 -1
- package/lib/typescript/organisms/chart/palette.d.ts +2 -2
- package/lib/typescript/organisms/chart/palette.d.ts.map +1 -1
- package/lib/typescript/organisms/imperativeBridge.d.ts +4 -4
- package/lib/typescript/organisms/useSlides.d.ts +8 -16
- package/lib/typescript/organisms/useSlides.d.ts.map +1 -1
- package/lib/typescript/safe-area/SafeAreaUIProvider.d.ts +9 -7
- package/lib/typescript/safe-area/SafeAreaUIProvider.d.ts.map +1 -1
- package/lib/typescript/safe-area/index.d.ts.map +1 -1
- package/lib/typescript/theme/KeyboardAvoidance.d.ts +62 -0
- package/lib/typescript/theme/KeyboardAvoidance.d.ts.map +1 -0
- package/lib/typescript/theme/NativeOverlay.d.ts +43 -0
- package/lib/typescript/theme/NativeOverlay.d.ts.map +1 -0
- package/lib/typescript/theme/UIProvider.d.ts +38 -20
- package/lib/typescript/theme/UIProvider.d.ts.map +1 -1
- package/lib/typescript/theme/colors.d.ts +13 -13
- package/lib/typescript/theme/colors.d.ts.map +1 -1
- package/lib/typescript/theme/createStyles.d.ts +20 -14
- package/lib/typescript/theme/createStyles.d.ts.map +1 -1
- package/lib/typescript/theme/createTheme.d.ts +5 -5
- package/lib/typescript/theme/index.d.ts +1 -1
- package/lib/typescript/theme/index.d.ts.map +1 -1
- package/lib/typescript/theme/insets.d.ts +1 -1
- package/lib/typescript/theme/insets.d.ts.map +1 -1
- package/lib/typescript/theme/labels.d.ts +57 -2
- package/lib/typescript/theme/labels.d.ts.map +1 -1
- package/lib/typescript/theme/palettes.d.ts +25 -19
- package/lib/typescript/theme/palettes.d.ts.map +1 -1
- package/lib/typescript/theme/tokens.d.ts +15 -8
- package/lib/typescript/theme/tokens.d.ts.map +1 -1
- package/lib/typescript/theme/types.d.ts +7 -7
- package/lib/typescript/theme/types.d.ts.map +1 -1
- package/lib/typescript/theme/useKeyboardField.d.ts +17 -0
- package/lib/typescript/theme/useKeyboardField.d.ts.map +1 -0
- package/lib/typescript/theme/useReduceMotion.d.ts +7 -0
- package/lib/typescript/theme/useReduceMotion.d.ts.map +1 -0
- package/llms.txt +4 -4
- package/package.json +15 -14
- package/registry/alert-provider.json +4 -3
- package/registry/alert.json +3 -2
- package/registry/avatar-header.json +1 -1
- package/registry/avatar.json +3 -2
- package/registry/badge.json +1 -1
- package/registry/bottom-sheet.json +1 -1
- package/registry/button.json +3 -2
- package/registry/card.json +1 -1
- package/registry/chart.json +5 -5
- package/registry/checkbox.json +3 -2
- package/registry/core.json +31 -15
- package/registry/date-field.json +1 -1
- package/registry/date-picker.json +3 -2
- package/registry/divider.json +1 -1
- package/registry/empty-state.json +4 -2
- package/registry/fab.json +3 -2
- package/registry/form-actions.json +3 -2
- package/registry/gradient.json +1 -1
- package/registry/icon-button.json +3 -2
- package/registry/image.json +1 -1
- package/registry/index.json +79 -61
- package/registry/info-row.json +1 -1
- package/registry/input.json +5 -1
- package/registry/key-value-row.json +1 -1
- package/registry/list.json +3 -1
- package/registry/manifest.json +3 -1
- package/registry/modal.json +1 -1
- package/registry/navigation-bar.json +1 -1
- package/registry/option-card.json +3 -2
- package/registry/option-wheel.json +1 -1
- package/registry/pressable-scale.json +3 -2
- package/registry/reorderable-list.json +1 -1
- package/registry/screen.json +1 -1
- package/registry/search-list.json +7 -1
- package/registry/segmented-control.json +1 -1
- package/registry/select.json +1 -1
- package/registry/shiny-text.json +1 -1
- package/registry/skeleton.json +3 -2
- package/registry/slides.json +2 -2
- package/registry/spinner.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/steps.json +1 -1
- package/registry/symmetric-grid.json +1 -1
- package/registry/theme-toggle.json +1 -1
- package/registry/timeline.json +1 -1
- package/registry/title.json +1 -1
- package/registry/toast-provider.json +2 -2
- package/registry/toast.json +1 -1
- package/registry/transition.json +1 -1
- package/registry/wizard.json +1 -1
- package/src/atoms/Avatar.tsx +117 -26
- package/src/atoms/Badge.tsx +20 -9
- package/src/atoms/Button.tsx +102 -30
- package/src/atoms/Card.tsx +23 -3
- package/src/atoms/Checkbox.tsx +49 -12
- package/src/atoms/Divider.tsx +34 -4
- package/src/atoms/EmptyState.tsx +63 -16
- package/src/atoms/Fab.tsx +56 -9
- package/src/atoms/Gradient.tsx +92 -41
- package/src/atoms/IconButton.tsx +27 -4
- package/src/atoms/Image.tsx +74 -28
- package/src/atoms/Input.tsx +129 -19
- package/src/atoms/KeyValueRow.tsx +72 -28
- package/src/atoms/PressableScale.tsx +31 -7
- package/src/atoms/ShinyText.tsx +31 -31
- package/src/atoms/Skeleton.tsx +37 -17
- package/src/atoms/Spinner.tsx +87 -24
- package/src/atoms/Text.tsx +66 -6
- package/src/atoms/Transition.tsx +40 -44
- package/src/atoms/index.ts +3 -3
- package/src/atoms/inputValidation.ts +59 -0
- package/src/icons/Icon.tsx +4 -4
- package/src/icons/defaultIcons.tsx +445 -22
- package/src/icons/index.ts +2 -2
- package/src/icons/types.ts +26 -4
- package/src/molecules/AvatarHeader.tsx +88 -34
- package/src/molecules/FormActions.tsx +36 -6
- package/src/molecules/InfoRow.tsx +39 -12
- package/src/molecules/OptionCard.tsx +55 -20
- package/src/molecules/SegmentedControl.tsx +135 -15
- package/src/molecules/Stepper.tsx +73 -19
- package/src/molecules/Steps.tsx +121 -39
- package/src/molecules/SymmetricGrid.tsx +28 -12
- package/src/organisms/Alert.tsx +97 -26
- package/src/organisms/AlertProvider.tsx +13 -13
- package/src/organisms/BottomSheet.tsx +115 -43
- package/src/organisms/Chart.tsx +223 -165
- package/src/organisms/DateField.tsx +40 -15
- package/src/organisms/DatePicker.tsx +53 -32
- package/src/organisms/List.tsx +64 -15
- package/src/organisms/Modal.tsx +122 -63
- package/src/organisms/NavigationBar.tsx +73 -23
- package/src/organisms/OptionWheel.tsx +70 -66
- package/src/organisms/ReorderableList.tsx +49 -27
- package/src/organisms/Screen.tsx +79 -42
- package/src/organisms/SearchList.tsx +84 -20
- package/src/organisms/Select.tsx +63 -29
- package/src/organisms/Slides.tsx +63 -44
- package/src/organisms/ThemeToggle.tsx +15 -6
- package/src/organisms/Timeline.tsx +79 -62
- package/src/organisms/Toast.tsx +50 -15
- package/src/organisms/ToastProvider.tsx +17 -13
- package/src/organisms/Wizard.tsx +58 -21
- package/src/organisms/chart/frame.tsx +35 -35
- package/src/organisms/chart/marks.tsx +53 -53
- package/src/organisms/chart/math.ts +93 -94
- package/src/organisms/chart/palette.ts +28 -28
- package/src/organisms/imperativeBridge.ts +5 -5
- package/src/organisms/useSlides.ts +66 -31
- package/src/safe-area/SafeAreaUIProvider.tsx +9 -70
- package/src/safe-area/index.ts +1 -0
- package/src/theme/KeyboardAvoidance.tsx +216 -0
- package/src/theme/NativeOverlay.tsx +269 -0
- package/src/theme/UIProvider.tsx +109 -46
- package/src/theme/colors.ts +21 -21
- package/src/theme/createStyles.ts +23 -19
- package/src/theme/createTheme.ts +6 -6
- package/src/theme/index.ts +1 -1
- package/src/theme/insets.ts +1 -1
- package/src/theme/labels.ts +85 -2
- package/src/theme/palettes.ts +33 -25
- package/src/theme/tokens.ts +27 -13
- package/src/theme/types.ts +7 -7
- package/src/theme/useKeyboardField.ts +33 -0
- package/src/theme/useReduceMotion.ts +27 -0
|
@@ -3,11 +3,23 @@
|
|
|
3
3
|
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
4
4
|
import { Image as RNImage, Platform, StyleSheet, View } from 'react-native';
|
|
5
5
|
import { createStyles } from '../theme/createStyles';
|
|
6
|
+
import { useColors, useTheme } from '../theme/UIProvider';
|
|
7
|
+
import { Icon } from '../icons/Icon';
|
|
6
8
|
import { Spinner } from './Spinner';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The event RN's Image passes to `onError`. Taken from its own prop type:
|
|
12
|
+
* react-native 0.88 (Expo SDK 58) renamed the exported name
|
|
13
|
+
* (`ImageErrorEventData` -> `ImageErrorEvent`).
|
|
14
|
+
*/
|
|
7
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
16
|
const useStyles = createStyles(theme => ({
|
|
9
17
|
container: {
|
|
10
|
-
overflow: 'hidden'
|
|
18
|
+
overflow: 'hidden'
|
|
19
|
+
},
|
|
20
|
+
// Only while loading or on failure: once the image has loaded, a PNG with
|
|
21
|
+
// transparency (a logo) let this gray show through.
|
|
22
|
+
placeholder: {
|
|
11
23
|
backgroundColor: theme.colors.skeleton
|
|
12
24
|
},
|
|
13
25
|
overlay: {
|
|
@@ -16,7 +28,9 @@ const useStyles = createStyles(theme => ({
|
|
|
16
28
|
},
|
|
17
29
|
fallback: {
|
|
18
30
|
flex: 1,
|
|
19
|
-
backgroundColor: theme.colors.skeleton
|
|
31
|
+
backgroundColor: theme.colors.skeleton,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center'
|
|
20
34
|
}
|
|
21
35
|
}));
|
|
22
36
|
function sourceUri(source) {
|
|
@@ -25,14 +39,22 @@ function sourceUri(source) {
|
|
|
25
39
|
|
|
26
40
|
/**
|
|
27
41
|
* Image
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* `priority="high"`
|
|
31
|
-
* cache
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
42
|
+
* Zero-dependency wrapper over RN's <Image>: adds loading and error state
|
|
43
|
+
* (with the same placeholders as the rest of the library), and exposes
|
|
44
|
+
* `priority="high"` to start the download early via Image.prefetch(). The
|
|
45
|
+
* actual cache (disk/memory) is handled by RN's native image engine — this
|
|
46
|
+
* doesn't reimplement it, it just keeps it from being accidentally turned off:
|
|
47
|
+
* on iOS it forces `cache="force-cache"` (uses the disk even when the HTTP
|
|
48
|
+
* header doesn't ask for it); on Android the native image's disk cache is
|
|
49
|
+
* always on, there is no equivalent knob to touch.
|
|
50
|
+
*
|
|
51
|
+
* Gestalt, closure: the container takes its final size from the first frame
|
|
52
|
+
* (`skeleton` background), so the layout doesn't jump when the image arrives
|
|
53
|
+
* and the eye completes the shape it will fill. If loading fails, the same
|
|
54
|
+
* slot shows a warning icon: the state is visible, not a silent gray.
|
|
55
|
+
*
|
|
56
|
+
* Success is detected with `onLoad`, not `onLoadEnd`: RN also calls
|
|
57
|
+
* `onLoadEnd` on failure, and using it for "loaded" overwrote the error.
|
|
36
58
|
*/
|
|
37
59
|
export const Image = /*#__PURE__*/memo(({
|
|
38
60
|
source,
|
|
@@ -46,14 +68,17 @@ export const Image = /*#__PURE__*/memo(({
|
|
|
46
68
|
style,
|
|
47
69
|
onLoadEnd,
|
|
48
70
|
onError,
|
|
49
|
-
testID
|
|
71
|
+
testID,
|
|
72
|
+
accessibilityLabel
|
|
50
73
|
}) => {
|
|
51
74
|
const styles = useStyles();
|
|
75
|
+
const colors = useColors();
|
|
76
|
+
const theme = useTheme();
|
|
52
77
|
const [status, setStatus] = useState('loading');
|
|
53
78
|
const uri = sourceUri(source);
|
|
54
79
|
useEffect(() => {
|
|
55
|
-
//
|
|
56
|
-
// source
|
|
80
|
+
// Resets the state if the image changes (same Image instance, different
|
|
81
|
+
// source: e.g. one user's avatar to another's in the same row).
|
|
57
82
|
setStatus('loading');
|
|
58
83
|
}, [uri ?? source]);
|
|
59
84
|
useEffect(() => {
|
|
@@ -65,26 +90,29 @@ export const Image = /*#__PURE__*/memo(({
|
|
|
65
90
|
setStatus('error');
|
|
66
91
|
onError?.(e);
|
|
67
92
|
}, [onError]);
|
|
68
|
-
const
|
|
93
|
+
const handleLoad = useCallback(() => {
|
|
69
94
|
setStatus('loaded');
|
|
70
|
-
|
|
71
|
-
}, [onLoadEnd]);
|
|
95
|
+
}, []);
|
|
72
96
|
return /*#__PURE__*/_jsxs(View, {
|
|
73
|
-
style: [styles.container, {
|
|
97
|
+
style: [styles.container, status !== 'loaded' && styles.placeholder, {
|
|
74
98
|
width,
|
|
75
99
|
height,
|
|
76
100
|
borderRadius: radius
|
|
77
101
|
}, style],
|
|
78
102
|
testID: testID,
|
|
103
|
+
accessible: !!accessibilityLabel,
|
|
104
|
+
accessibilityRole: accessibilityLabel ? 'image' : undefined,
|
|
105
|
+
accessibilityLabel: accessibilityLabel,
|
|
79
106
|
children: [status !== 'error' && /*#__PURE__*/_jsx(RNImage, {
|
|
80
107
|
source: source,
|
|
81
108
|
resizeMode: resizeMode,
|
|
82
109
|
style: StyleSheet.absoluteFill,
|
|
83
|
-
fadeDuration: Platform.OS === 'android' ?
|
|
110
|
+
fadeDuration: Platform.OS === 'android' ? theme.tokens.duration.fast : undefined,
|
|
84
111
|
...(Platform.OS === 'ios' ? {
|
|
85
112
|
cache: 'force-cache'
|
|
86
113
|
} : null),
|
|
87
|
-
|
|
114
|
+
onLoad: handleLoad,
|
|
115
|
+
onLoadEnd: onLoadEnd,
|
|
88
116
|
onError: handleError
|
|
89
117
|
}), status === 'loading' && loading !== false && /*#__PURE__*/_jsx(View, {
|
|
90
118
|
style: [StyleSheet.absoluteFill, styles.overlay],
|
|
@@ -92,17 +120,25 @@ export const Image = /*#__PURE__*/memo(({
|
|
|
92
120
|
size: "small",
|
|
93
121
|
fullscreen: false
|
|
94
122
|
}) : loading
|
|
95
|
-
}), status === 'error' &&
|
|
96
|
-
|
|
97
|
-
|
|
123
|
+
}), status === 'error' &&
|
|
124
|
+
/*#__PURE__*/
|
|
125
|
+
// Custom fallback or the default: always centered in the slot.
|
|
126
|
+
_jsx(View, {
|
|
127
|
+
style: styles.fallback,
|
|
128
|
+
children: fallback ?? /*#__PURE__*/_jsx(Icon, {
|
|
129
|
+
name: "warning",
|
|
130
|
+
size: Math.max(16, Math.min(32, Math.round(Math.min(width ?? 64, height ?? 64) * 0.3))),
|
|
131
|
+
color: colors.textLight
|
|
132
|
+
})
|
|
133
|
+
})]
|
|
98
134
|
});
|
|
99
135
|
});
|
|
100
136
|
Image.displayName = 'Image';
|
|
101
137
|
|
|
102
138
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* Image.prefetch
|
|
139
|
+
* Preloads a URL before mounting the component (e.g. on receiving a list
|
|
140
|
+
* response, before navigating to the detail). Re-exports RN's
|
|
141
|
+
* Image.prefetch — there is nothing zero-dep to add on top.
|
|
106
142
|
*/
|
|
107
143
|
export const prefetchImage = RNImage.prefetch;
|
|
108
144
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","memo","useCallback","useEffect","useState","Image","RNImage","Platform","StyleSheet","View","createStyles","Spinner","jsx","_jsx","jsxs","_jsxs","useStyles","theme","container","overflow","backgroundColor","colors","skeleton","overlay","alignItems","justifyContent","fallback","flex","sourceUri","source","uri","undefined","width","height","resizeMode","radius","loading","priority","style","onLoadEnd","onError","testID","styles","status","setStatus","prefetch","catch","handleError","e","
|
|
1
|
+
{"version":3,"names":["React","memo","useCallback","useEffect","useState","Image","RNImage","Platform","StyleSheet","View","createStyles","useColors","useTheme","Icon","Spinner","jsx","_jsx","jsxs","_jsxs","useStyles","theme","container","overflow","placeholder","backgroundColor","colors","skeleton","overlay","alignItems","justifyContent","fallback","flex","sourceUri","source","uri","undefined","width","height","resizeMode","radius","loading","priority","style","onLoadEnd","onError","testID","accessibilityLabel","styles","status","setStatus","prefetch","catch","handleError","e","handleLoad","borderRadius","accessible","accessibilityRole","children","absoluteFill","fadeDuration","OS","tokens","duration","fast","cache","onLoad","size","fullscreen","name","Math","max","min","round","color","textLight","displayName","prefetchImage"],"sourceRoot":"../../../src","sources":["atoms/Image.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACrE,SACEC,KAAK,IAAIC,OAAO,EAChBC,QAAQ,EACRC,UAAU,EACVC,IAAI,QAMC,cAAc;AACrB,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,qBAAqB;AACzD,SAASC,IAAI,QAAQ,eAAe;AACpC,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAuCA,MAAMC,SAAS,GAAGT,YAAY,CAAEU,KAAK,KAAM;EACzCC,SAAS,EAAE;IAAEC,QAAQ,EAAE;EAAS,CAAC;EACjC;EACA;EACAC,WAAW,EAAE;IAAEC,eAAe,EAAEJ,KAAK,CAACK,MAAM,CAACC;EAAS,CAAC;EACvDC,OAAO,EAAE;IAAEC,UAAU,EAAE,QAAQ;IAAEC,cAAc,EAAE;EAAS,CAAC;EAC3DC,QAAQ,EAAE;IAAEC,IAAI,EAAE,CAAC;IAAEP,eAAe,EAAEJ,KAAK,CAACK,MAAM,CAACC,QAAQ;IAAEE,UAAU,EAAE,QAAQ;IAAEC,cAAc,EAAE;EAAS;AAC9G,CAAC,CAAC,CAAC;AAEH,SAASG,SAASA,CAACC,MAA2B,EAAsB;EAClE,OAAO,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,KAAK,IAAI,IAAI,KAAK,IAAIA,MAAM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E,CACP,EACAQ,MAAM,KAAK,OAAO;IAAA;IACjB;IACAhC,IAAA,CAACP,IAAI;MAACiC,KAAK,EAAEK,MAAM,CAACjB,QAAS;MAAA4B,QAAA,EAC1B5B,QAAQ,iBACPd,IAAA,CAACH,IAAI;QACHwD,IAAI,EAAC,SAAS;QACdF,IAAI,EAAEG,IAAI,CAACC,GAAG,CAAC,EAAE,EAAED,IAAI,CAACE,GAAG,CAAC,EAAE,EAAEF,IAAI,CAACG,KAAK,CAACH,IAAI,CAACE,GAAG,CAACpC,KAAK,IAAI,EAAE,EAAEC,MAAM,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAE;QACxFqC,KAAK,EAAEjD,MAAM,CAACkD;MAAU,CACzB;IACF,CACG,CACP;EAAA,CACG,CAAC;AAEX,CACF,CAAC;AACDtE,KAAK,CAACuE,WAAW,GAAG,OAAO;;AAE3B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGvE,OAAO,CAAC4C,QAAQ","ignoreList":[]}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { memo, useRef, useState } from 'react';
|
|
4
|
-
import { ActivityIndicator, Animated, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import React, { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
4
|
+
import { AccessibilityInfo, ActivityIndicator, Animated, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
|
5
5
|
import { createStyles } from '../theme/createStyles';
|
|
6
|
-
import { useAllowFontScaling, useColors } from '../theme/UIProvider';
|
|
6
|
+
import { useAllowFontScaling, useColors, useLabels, useTheme } from '../theme/UIProvider';
|
|
7
7
|
import { Icon } from '../icons/Icon';
|
|
8
|
+
import { useKeyboardField } from '../theme/useKeyboardField';
|
|
9
|
+
import { validateInputValue } from './inputValidation';
|
|
10
|
+
|
|
11
|
+
/** The TextInput instance, plus `validate()` to check the field on demand (e.g. on submit). */
|
|
8
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
13
|
const useStyles = createStyles(theme => ({
|
|
10
14
|
container: {
|
|
@@ -39,9 +43,15 @@ const useStyles = createStyles(theme => ({
|
|
|
39
43
|
marginLeft: theme.tokens.spacing.lg,
|
|
40
44
|
marginRight: -theme.tokens.spacing.xs
|
|
41
45
|
},
|
|
46
|
+
// 20 icon + md padding (12) per side = 44pt touch area (Fitts).
|
|
42
47
|
rightIcon: {
|
|
43
|
-
padding: theme.tokens.spacing.
|
|
44
|
-
marginRight: theme.tokens.spacing.
|
|
48
|
+
padding: theme.tokens.spacing.md,
|
|
49
|
+
marginRight: theme.tokens.spacing.xxs
|
|
50
|
+
},
|
|
51
|
+
// Read-only: no fill, so it doesn't look like a field you can tap
|
|
52
|
+
// (affordance), but the text keeps its contrast to stay readable.
|
|
53
|
+
readOnly: {
|
|
54
|
+
backgroundColor: 'transparent'
|
|
45
55
|
},
|
|
46
56
|
errorText: {
|
|
47
57
|
marginTop: theme.tokens.spacing.xs,
|
|
@@ -52,18 +62,46 @@ const useStyles = createStyles(theme => ({
|
|
|
52
62
|
|
|
53
63
|
/**
|
|
54
64
|
* Input
|
|
55
|
-
*
|
|
56
|
-
* useNativeDriver:
|
|
57
|
-
*
|
|
65
|
+
* The border animates its color between border/primary/error with Animated
|
|
66
|
+
* (no useNativeDriver: color drivers in RN without Fabric are only reliable
|
|
67
|
+
* on the JS thread; the cost is negligible, it animates one border).
|
|
68
|
+
*
|
|
69
|
+
* Gestalt:
|
|
70
|
+
* - Proximity: label (`spacing.sm` above) and error (`spacing.xs` below) sit
|
|
71
|
+
* right next to the field and the next field is `spacing.lg` away: each
|
|
72
|
+
* label and its error read with their field, not with the neighbor.
|
|
73
|
+
* - Common region: left icon, text and right action share the same border
|
|
74
|
+
* and background, so they read as a single control.
|
|
75
|
+
* - Focal point: the border turns `primary` on focus and `error` on error;
|
|
76
|
+
* the error is also written out (not just color).
|
|
77
|
+
*
|
|
78
|
+
* Accessibility: the accessible name includes "required" when applicable, the
|
|
79
|
+
* error is announced as a hint, and the eye and right-action buttons have a
|
|
80
|
+
* 44pt touch area and texts from `labels` (translatable).
|
|
81
|
+
*
|
|
82
|
+
* Keyboard: on focus it registers with the root UIProvider's host, which
|
|
83
|
+
* lifts the app just enough for the whole field (label, field and error) to
|
|
84
|
+
* sit above the keyboard — without depending on Screen or a ScrollView. What
|
|
85
|
+
* you type is always visible.
|
|
86
|
+
*
|
|
87
|
+
* Validation: `required` and `rules` run when leaving the field (`validateOn`),
|
|
88
|
+
* the error appears in writing, is announced to the screen reader and, once
|
|
89
|
+
* visible, is revalidated on every change so it disappears as soon as it is
|
|
90
|
+
* fixed. An `error` passed by hand overrides the internal validation.
|
|
58
91
|
*/
|
|
59
|
-
export const Input = /*#__PURE__*/memo(({
|
|
92
|
+
export const Input = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(({
|
|
60
93
|
label,
|
|
61
94
|
required = false,
|
|
62
|
-
error,
|
|
95
|
+
error: errorProp,
|
|
96
|
+
rules,
|
|
97
|
+
validateOn = 'blur',
|
|
98
|
+
onValidate,
|
|
99
|
+
onChangeText,
|
|
63
100
|
containerStyle,
|
|
64
101
|
leftIconName,
|
|
65
102
|
rightIconName,
|
|
66
103
|
onRightIconPress,
|
|
104
|
+
rightIconAccessibilityLabel,
|
|
67
105
|
isPassword = false,
|
|
68
106
|
isLoading = false,
|
|
69
107
|
style,
|
|
@@ -71,39 +109,82 @@ export const Input = /*#__PURE__*/memo(({
|
|
|
71
109
|
onBlur,
|
|
72
110
|
testID,
|
|
73
111
|
...props
|
|
74
|
-
}) => {
|
|
112
|
+
}, ref) => {
|
|
75
113
|
const colors = useColors();
|
|
76
114
|
const styles = useStyles();
|
|
77
115
|
const allowFontScaling = useAllowFontScaling();
|
|
116
|
+
const labels = useLabels();
|
|
117
|
+
const theme = useTheme();
|
|
118
|
+
const readOnly = props.editable === false;
|
|
78
119
|
const [isFocused, setIsFocused] = useState(false);
|
|
79
120
|
const [showPassword, setShowPassword] = useState(false);
|
|
80
121
|
const focusProgress = useRef(new Animated.Value(0)).current;
|
|
122
|
+
const inputRef = useRef(null);
|
|
123
|
+
const containerRef = useRef(null);
|
|
124
|
+
const [internalError, setInternalError] = useState(undefined);
|
|
125
|
+
// Last known value: the controlled one (`value`) or what was typed (uncontrolled).
|
|
126
|
+
const valueRef = useRef(props.value ?? props.defaultValue ?? '');
|
|
127
|
+
if (props.value !== undefined) valueRef.current = props.value;
|
|
128
|
+
const error = errorProp ?? internalError;
|
|
129
|
+
const runValidation = () => {
|
|
130
|
+
const next = validateInputValue(valueRef.current, {
|
|
131
|
+
required,
|
|
132
|
+
rules
|
|
133
|
+
}, labels);
|
|
134
|
+
setInternalError(next);
|
|
135
|
+
onValidate?.(next);
|
|
136
|
+
return next;
|
|
137
|
+
};
|
|
138
|
+
useImperativeHandle(ref, () => Object.assign(inputRef.current, {
|
|
139
|
+
validate: runValidation
|
|
140
|
+
}));
|
|
141
|
+
|
|
142
|
+
// The new error is announced right away, not only as a hint when returning to the field.
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (internalError && errorProp === undefined) AccessibilityInfo.announceForAccessibility(internalError);
|
|
145
|
+
}, [internalError, errorProp]);
|
|
146
|
+
const keyboard = useKeyboardField(containerRef);
|
|
147
|
+
|
|
148
|
+
// If the error appears or changes while the field is focused, the block grows:
|
|
149
|
+
// a readjustment is requested so the error line isn't covered either.
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
if (isFocused) keyboard.focus();
|
|
152
|
+
}, [error, isFocused, keyboard]);
|
|
81
153
|
const handleFocus = e => {
|
|
82
154
|
setIsFocused(true);
|
|
155
|
+
keyboard.focus();
|
|
83
156
|
Animated.timing(focusProgress, {
|
|
84
157
|
toValue: 1,
|
|
85
|
-
duration:
|
|
158
|
+
duration: theme.tokens.duration.base,
|
|
86
159
|
useNativeDriver: false
|
|
87
160
|
}).start();
|
|
88
161
|
onFocus?.(e);
|
|
89
162
|
};
|
|
90
163
|
const handleBlur = e => {
|
|
91
164
|
setIsFocused(false);
|
|
165
|
+
keyboard.blur();
|
|
166
|
+
if (validateOn === 'blur') runValidation();
|
|
92
167
|
Animated.timing(focusProgress, {
|
|
93
168
|
toValue: 0,
|
|
94
|
-
duration:
|
|
169
|
+
duration: theme.tokens.duration.base,
|
|
95
170
|
useNativeDriver: false
|
|
96
171
|
}).start();
|
|
97
172
|
onBlur?.(e);
|
|
98
173
|
};
|
|
174
|
+
const handleChangeText = text => {
|
|
175
|
+
valueRef.current = text;
|
|
176
|
+
onChangeText?.(text);
|
|
177
|
+
if (validateOn === 'change' || internalError) runValidation();
|
|
178
|
+
};
|
|
99
179
|
const borderColor = error ? colors.error : focusProgress.interpolate({
|
|
100
180
|
outputRange: [colors.border, colors.primary],
|
|
101
181
|
inputRange: [0, 1]
|
|
102
182
|
});
|
|
103
183
|
return /*#__PURE__*/_jsxs(View, {
|
|
184
|
+
ref: containerRef,
|
|
104
185
|
style: [styles.container, containerStyle],
|
|
105
186
|
testID: testID,
|
|
106
|
-
children: [label && /*#__PURE__*/_jsxs(Text, {
|
|
187
|
+
children: [!!label && /*#__PURE__*/_jsxs(Text, {
|
|
107
188
|
allowFontScaling: allowFontScaling,
|
|
108
189
|
style: styles.label,
|
|
109
190
|
children: [label, required && /*#__PURE__*/_jsx(Text, {
|
|
@@ -111,7 +192,7 @@ export const Input = /*#__PURE__*/memo(({
|
|
|
111
192
|
children: " *"
|
|
112
193
|
})]
|
|
113
194
|
}), /*#__PURE__*/_jsxs(Animated.View, {
|
|
114
|
-
style: [styles.inputWrapper, {
|
|
195
|
+
style: [styles.inputWrapper, readOnly && styles.readOnly, {
|
|
115
196
|
borderColor
|
|
116
197
|
}],
|
|
117
198
|
children: [leftIconName && /*#__PURE__*/_jsx(Icon, {
|
|
@@ -120,6 +201,7 @@ export const Input = /*#__PURE__*/memo(({
|
|
|
120
201
|
color: colors.textLight,
|
|
121
202
|
style: styles.leftIcon
|
|
122
203
|
}), /*#__PURE__*/_jsx(TextInput, {
|
|
204
|
+
ref: inputRef,
|
|
123
205
|
style: [styles.input, style],
|
|
124
206
|
placeholderTextColor: colors.textLight,
|
|
125
207
|
onFocus: handleFocus,
|
|
@@ -127,8 +209,14 @@ export const Input = /*#__PURE__*/memo(({
|
|
|
127
209
|
secureTextEntry: isPassword && !showPassword,
|
|
128
210
|
allowFontScaling: allowFontScaling,
|
|
129
211
|
textAlignVertical: "center",
|
|
130
|
-
accessibilityLabel: label ?? props.placeholder,
|
|
131
|
-
|
|
212
|
+
accessibilityLabel: label || props.placeholder ? `${label ?? props.placeholder}${required ? `, ${labels.required}` : ''}` : undefined,
|
|
213
|
+
accessibilityHint: error || undefined,
|
|
214
|
+
accessibilityState: {
|
|
215
|
+
disabled: readOnly,
|
|
216
|
+
busy: isLoading
|
|
217
|
+
},
|
|
218
|
+
...props,
|
|
219
|
+
onChangeText: handleChangeText
|
|
132
220
|
}), isLoading ? /*#__PURE__*/_jsx(View, {
|
|
133
221
|
style: styles.rightIcon,
|
|
134
222
|
children: /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
@@ -139,7 +227,7 @@ export const Input = /*#__PURE__*/memo(({
|
|
|
139
227
|
onPress: () => setShowPassword(v => !v),
|
|
140
228
|
style: styles.rightIcon,
|
|
141
229
|
accessibilityRole: "button",
|
|
142
|
-
accessibilityLabel: showPassword ?
|
|
230
|
+
accessibilityLabel: showPassword ? labels.hidePassword : labels.showPassword,
|
|
143
231
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
144
232
|
name: showPassword ? 'eye-off' : 'eye',
|
|
145
233
|
size: 20,
|
|
@@ -150,7 +238,7 @@ export const Input = /*#__PURE__*/memo(({
|
|
|
150
238
|
style: styles.rightIcon,
|
|
151
239
|
disabled: !onRightIconPress,
|
|
152
240
|
accessibilityRole: "button",
|
|
153
|
-
accessibilityLabel:
|
|
241
|
+
accessibilityLabel: rightIconAccessibilityLabel ?? labels.clear,
|
|
154
242
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
155
243
|
name: rightIconName,
|
|
156
244
|
size: 20,
|
|
@@ -163,6 +251,6 @@ export const Input = /*#__PURE__*/memo(({
|
|
|
163
251
|
children: error
|
|
164
252
|
})]
|
|
165
253
|
});
|
|
166
|
-
});
|
|
254
|
+
}));
|
|
167
255
|
Input.displayName = 'Input';
|
|
168
256
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","memo","useRef","useState","ActivityIndicator","Animated","Text","TextInput","TouchableOpacity","View","createStyles","useAllowFontScaling","useColors","Icon","jsx","_jsx","jsxs","_jsxs","useStyles","theme","container","marginBottom","tokens","spacing","lg","width","label","sm","fontSize","md","fontWeight","medium","color","colors","text","required","errorText","inputWrapper","flexDirection","alignItems","backgroundColor","inputBackground","borderRadius","radius","borderWidth","minHeight","input","flex","paddingVertical","paddingHorizontal","leftIcon","marginLeft","marginRight","xs","rightIcon","padding","marginTop","Input","error","containerStyle","leftIconName","rightIconName","onRightIconPress","isPassword","isLoading","style","onFocus","onBlur","testID","props","styles","allowFontScaling","isFocused","setIsFocused","showPassword","setShowPassword","focusProgress","Value","current","handleFocus","e","timing","toValue","duration","useNativeDriver","start","handleBlur","borderColor","interpolate","outputRange","border","primary","inputRange","children","name","size","textLight","placeholderTextColor","secureTextEntry","textAlignVertical","accessibilityLabel","placeholder","onPress","v","accessibilityRole","
|
|
1
|
+
{"version":3,"names":["React","forwardRef","memo","useEffect","useImperativeHandle","useRef","useState","AccessibilityInfo","ActivityIndicator","Animated","Text","TextInput","TouchableOpacity","View","createStyles","useAllowFontScaling","useColors","useLabels","useTheme","Icon","useKeyboardField","validateInputValue","jsx","_jsx","jsxs","_jsxs","useStyles","theme","container","marginBottom","tokens","spacing","lg","width","label","sm","fontSize","md","fontWeight","medium","color","colors","text","required","errorText","inputWrapper","flexDirection","alignItems","backgroundColor","inputBackground","borderRadius","radius","borderWidth","minHeight","input","flex","paddingVertical","paddingHorizontal","leftIcon","marginLeft","marginRight","xs","rightIcon","padding","xxs","readOnly","marginTop","Input","error","errorProp","rules","validateOn","onValidate","onChangeText","containerStyle","leftIconName","rightIconName","onRightIconPress","rightIconAccessibilityLabel","isPassword","isLoading","style","onFocus","onBlur","testID","props","ref","styles","allowFontScaling","labels","editable","isFocused","setIsFocused","showPassword","setShowPassword","focusProgress","Value","current","inputRef","containerRef","internalError","setInternalError","undefined","valueRef","value","defaultValue","runValidation","next","Object","assign","validate","announceForAccessibility","keyboard","focus","handleFocus","e","timing","toValue","duration","base","useNativeDriver","start","handleBlur","blur","handleChangeText","borderColor","interpolate","outputRange","border","primary","inputRange","children","name","size","textLight","placeholderTextColor","secureTextEntry","textAlignVertical","accessibilityLabel","placeholder","accessibilityHint","accessibilityState","disabled","busy","onPress","v","accessibilityRole","hidePassword","clear","displayName"],"sourceRoot":"../../../src","sources":["atoms/Input.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,mBAAmB,EAAEC,MAAM,EAAEC,QAAQ,QAA2B,OAAO;AACpH,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EACRC,IAAI,EACJC,SAAS,EACTC,gBAAgB,EAChBC,IAAI,QAIC,cAAc;AACrB,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,mBAAmB,EAAEC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,qBAAqB;AACzF,SAASC,IAAI,QAAQ,eAAe;AAEpC,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,kBAAkB,QAAyB,mBAAmB;;AAIvE;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAwCA,MAAMC,SAAS,GAAGZ,YAAY,CAAEa,KAAK,KAAM;EACzCC,SAAS,EAAE;IAAEC,YAAY,EAAEF,KAAK,CAACG,MAAM,CAACC,OAAO,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D,aAAa,gBACfrD,IAAA,CAACX,gBAAgB;QACfoI,OAAO,EAAEnE,gBAAiB;QAC1BI,KAAK,EAAEM,MAAM,CAACzB,SAAU;QACxBgF,QAAQ,EAAE,CAACjE,gBAAiB;QAC5BqE,iBAAiB,EAAC,QAAQ;QAC1BR,kBAAkB,EAAE5D,2BAA2B,IAAIW,MAAM,CAAC2D,KAAM;QAAAjB,QAAA,eAEhE5G,IAAA,CAACJ,IAAI;UAACiH,IAAI,EAAExD,aAAc;UAACyD,IAAI,EAAE,EAAG;UAAC7F,KAAK,EAAEC,MAAM,CAAC6F;QAAU,CAAE;MAAC,CAChD,CAAC,GACjB,IAAI;IAAA,CACK,CAAC,EAEf,CAAC,CAAClE,KAAK,iBACN7C,IAAA,CAACb,IAAI;MAAC8E,gBAAgB,EAAEA,gBAAiB;MAACP,KAAK,EAAEM,MAAM,CAAC3C,SAAU;MAAAuF,QAAA,EAC/D/D;IAAK,CACF,CACP;EAAA,CACG,CAAC;AAEX,CAAC,CACH,CAAC;AACDD,KAAK,CAACkF,WAAW,GAAG,OAAO","ignoreList":[]}
|
|
@@ -9,42 +9,70 @@ const useStyles = createStyles(theme => ({
|
|
|
9
9
|
row: {
|
|
10
10
|
flexDirection: 'row',
|
|
11
11
|
justifyContent: 'space-between',
|
|
12
|
-
alignItems: 'center'
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
gap: theme.tokens.spacing.md
|
|
13
14
|
},
|
|
15
|
+
// Two texts: aligned on the first line, so a value that wraps onto
|
|
16
|
+
// several lines still reads next to its label.
|
|
17
|
+
rowText: {
|
|
18
|
+
alignItems: 'baseline'
|
|
19
|
+
},
|
|
20
|
+
// The label keeps its natural width up to half the row; the value
|
|
21
|
+
// shrinks and wraps instead of pushing the row off the screen.
|
|
14
22
|
label: {
|
|
23
|
+
flexShrink: 0,
|
|
24
|
+
maxWidth: '50%',
|
|
15
25
|
fontSize: theme.tokens.fontSize.sm,
|
|
26
|
+
lineHeight: theme.tokens.lineHeight.sm,
|
|
16
27
|
fontWeight: theme.tokens.fontWeight.semibold,
|
|
17
28
|
color: theme.colors.textLight
|
|
18
29
|
},
|
|
19
30
|
value: {
|
|
31
|
+
flexShrink: 1,
|
|
20
32
|
fontSize: theme.tokens.fontSize.sm,
|
|
33
|
+
lineHeight: theme.tokens.lineHeight.sm,
|
|
21
34
|
textAlign: 'right',
|
|
22
|
-
color: theme.colors.text
|
|
35
|
+
color: theme.colors.text,
|
|
36
|
+
// Fixed-width digits: in a column of amounts the figures line up
|
|
37
|
+
// across rows.
|
|
38
|
+
fontVariant: ['tabular-nums']
|
|
23
39
|
}
|
|
24
40
|
}));
|
|
41
|
+
const isPrimitive = node => typeof node === 'string' || typeof node === 'number';
|
|
25
42
|
|
|
26
43
|
/**
|
|
27
44
|
* KeyValueRow
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
45
|
+
* Label (left) / value (right) row. If label/value are a string or number,
|
|
46
|
+
* they render with the default style; if they already come wrapped in a
|
|
47
|
+
* custom component, they are kept as is.
|
|
48
|
+
*
|
|
49
|
+
* Gestalt, alignment and similarity: labels share color and weight and values
|
|
50
|
+
* align to the right edge with tabular digits, so a stack of rows reads as
|
|
51
|
+
* two columns — what on the left, how much on the right.
|
|
52
|
+
* With a text label and value, the row is a single accessibility node
|
|
53
|
+
* ("Subtotal, $300.00"); if either is a custom node (a Badge, a button) it
|
|
54
|
+
* isn't merged, so as not to hide what that node announces or lets you tap.
|
|
31
55
|
*/
|
|
32
56
|
export const KeyValueRow = /*#__PURE__*/memo(({
|
|
33
57
|
label,
|
|
34
58
|
value,
|
|
35
59
|
style,
|
|
36
60
|
labelStyle,
|
|
37
|
-
valueStyle
|
|
61
|
+
valueStyle,
|
|
62
|
+
testID
|
|
38
63
|
}) => {
|
|
39
64
|
const styles = useStyles();
|
|
40
65
|
const allowFontScaling = useAllowFontScaling();
|
|
66
|
+
const merge = isPrimitive(label) && isPrimitive(value);
|
|
41
67
|
return /*#__PURE__*/_jsxs(View, {
|
|
42
|
-
style: [styles.row, style],
|
|
43
|
-
|
|
68
|
+
style: [styles.row, merge && styles.rowText, style],
|
|
69
|
+
accessible: merge || undefined,
|
|
70
|
+
testID: testID,
|
|
71
|
+
children: [isPrimitive(label) ? /*#__PURE__*/_jsx(Text, {
|
|
44
72
|
allowFontScaling: allowFontScaling,
|
|
45
73
|
style: [styles.label, labelStyle],
|
|
46
74
|
children: label
|
|
47
|
-
}) : label,
|
|
75
|
+
}) : label, isPrimitive(value) ? /*#__PURE__*/_jsx(Text, {
|
|
48
76
|
allowFontScaling: allowFontScaling,
|
|
49
77
|
style: [styles.value, valueStyle],
|
|
50
78
|
children: value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","memo","Text","View","createStyles","useAllowFontScaling","jsx","_jsx","jsxs","_jsxs","useStyles","theme","row","flexDirection","justifyContent","alignItems","label","
|
|
1
|
+
{"version":3,"names":["React","memo","Text","View","createStyles","useAllowFontScaling","jsx","_jsx","jsxs","_jsxs","useStyles","theme","row","flexDirection","justifyContent","alignItems","gap","tokens","spacing","md","rowText","label","flexShrink","maxWidth","fontSize","sm","lineHeight","fontWeight","semibold","color","colors","textLight","value","textAlign","text","fontVariant","isPrimitive","node","KeyValueRow","style","labelStyle","valueStyle","testID","styles","allowFontScaling","merge","accessible","undefined","children","displayName"],"sourceRoot":"../../../src","sources":["atoms/KeyValueRow.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,IAAI,QAAQ,OAAO;AACnC,SAASC,IAAI,EAAEC,IAAI,QAAwD,cAAc;AACzF,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,mBAAmB,QAAQ,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAe1D,MAAMC,SAAS,GAAGN,YAAY,CAAEO,KAAK,KAAM;EACzCC,GAAG,EAAE;IACHC,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,eAAe;IAC/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GAAGT,WAAW,CAACf,KAAK,CAAC,IAAIe,WAAW,CAACJ,KAAK,CAAC;EACtD,oBACEvB,KAAA,CAACN,IAAI;IAACoC,KAAK,EAAE,CAACI,MAAM,CAAC/B,GAAG,EAAEiC,KAAK,IAAIF,MAAM,CAACvB,OAAO,EAAEmB,KAAK,CAAE;IAACO,UAAU,EAAED,KAAK,IAAIE,SAAU;IAACL,MAAM,EAAEA,MAAO;IAAAM,QAAA,GACvGZ,WAAW,CAACf,KAAK,CAAC,gBACjBd,IAAA,CAACL,IAAI;MAAC0C,gBAAgB,EAAEA,gBAAiB;MAACL,KAAK,EAAE,CAACI,MAAM,CAACtB,KAAK,EAAEmB,UAAU,CAAE;MAAAQ,QAAA,EACzE3B;IAAK,CACF,CAAC,GAEPA,KACD,EACAe,WAAW,CAACJ,KAAK,CAAC,gBACjBzB,IAAA,CAACL,IAAI;MAAC0C,gBAAgB,EAAEA,gBAAiB;MAACL,KAAK,EAAE,CAACI,MAAM,CAACX,KAAK,EAAES,UAAU,CAAE;MAAAO,QAAA,EACzEhB;IAAK,CACF,CAAC,GAEPA,KACD;EAAA,CACG,CAAC;AAEX,CACF,CAAC;AACDM,WAAW,CAACW,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -2,14 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { memo, useRef } from 'react';
|
|
4
4
|
import { Animated, Pressable } from 'react-native';
|
|
5
|
+
import { useReduceMotion } from './Transition';
|
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
/** Short spring with almost no bounce: feedback arrives in ~100 ms (Doherty). */
|
|
8
|
+
const PRESS_SPRING = {
|
|
9
|
+
speed: 50,
|
|
10
|
+
bounciness: 6
|
|
11
|
+
};
|
|
6
12
|
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
7
13
|
|
|
8
14
|
/**
|
|
9
15
|
* PressableScale
|
|
10
|
-
*
|
|
11
|
-
* (useNativeDriver: true —
|
|
12
|
-
*
|
|
16
|
+
* Tactile "shrink" feedback on press, with RN's Animated.spring
|
|
17
|
+
* (useNativeDriver: true — runs on the native thread, no JS cost per frame).
|
|
18
|
+
* Doesn't depend on reanimated: the whole library is zero-dependency.
|
|
19
|
+
*
|
|
20
|
+
* Gestalt, figure/ground: as it sinks, the pressed element separates for an
|
|
21
|
+
* instant from the rest and confirms what was touched (Doherty: immediate
|
|
22
|
+
* response). Announces itself as a button by default (`accessibilityRole` can
|
|
23
|
+
* be changed) and, when disabled, exposes `disabled` to the screen reader.
|
|
24
|
+
* With Reduce Motion it doesn't scale.
|
|
13
25
|
*/
|
|
14
26
|
export const PressableScale = /*#__PURE__*/memo(({
|
|
15
27
|
scaleTo = 0.96,
|
|
@@ -18,15 +30,18 @@ export const PressableScale = /*#__PURE__*/memo(({
|
|
|
18
30
|
onPressIn,
|
|
19
31
|
onPressOut,
|
|
20
32
|
disabled,
|
|
33
|
+
accessibilityRole = 'button',
|
|
34
|
+
accessibilityState,
|
|
21
35
|
...props
|
|
22
36
|
}) => {
|
|
23
37
|
const scale = useRef(new Animated.Value(1)).current;
|
|
38
|
+
const reduceMotion = useReduceMotion();
|
|
24
39
|
const animateTo = value => {
|
|
40
|
+
if (reduceMotion) return;
|
|
25
41
|
Animated.spring(scale, {
|
|
26
42
|
toValue: value,
|
|
27
43
|
useNativeDriver: true,
|
|
28
|
-
|
|
29
|
-
bounciness: 6
|
|
44
|
+
...PRESS_SPRING
|
|
30
45
|
}).start();
|
|
31
46
|
};
|
|
32
47
|
const handlePressIn = e => {
|
|
@@ -39,6 +54,11 @@ export const PressableScale = /*#__PURE__*/memo(({
|
|
|
39
54
|
};
|
|
40
55
|
return /*#__PURE__*/_jsx(AnimatedPressable, {
|
|
41
56
|
...props,
|
|
57
|
+
accessibilityRole: accessibilityRole,
|
|
58
|
+
accessibilityState: {
|
|
59
|
+
...accessibilityState,
|
|
60
|
+
disabled: !!disabled
|
|
61
|
+
},
|
|
42
62
|
disabled: disabled,
|
|
43
63
|
onPressIn: handlePressIn,
|
|
44
64
|
onPressOut: handlePressOut,
|