@webority/mobile-ui 0.147.0 → 0.149.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/dist/canvas-kit/kit.js +4744 -4512
- package/dist/canvas-kit/manifest.json +8 -1
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
- package/lib/commonjs/components/AuthedImage/imageStore.js +1 -1
- package/lib/commonjs/components/AuthedImage/imageStore.web.js +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js +1 -1
- package/lib/commonjs/components/BarChart/BarChart.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Box/Box.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
- package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/commonjs/components/FileViewer/useFileViewerZoom.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/ListItem/ListItem.js +1 -1
- package/lib/commonjs/components/Markdown/Markdown.js +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +1 -1
- package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
- package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/commonjs/components/SignaturePad/writePng.js +1 -1
- package/lib/commonjs/components/SignaturePad/writePng.web.js +1 -1
- package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/commonjs/components/Slider/Slider.js +1 -1
- package/lib/commonjs/components/SortableList/SortableList.js +1 -1
- package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
- package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
- package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/navigation/NavigationScreen.js +1 -1
- package/lib/commonjs/theme/Gradient.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
- package/lib/module/components/AuthedImage/imageStore.js +1 -1
- package/lib/module/components/AuthedImage/imageStore.web.js +1 -1
- package/lib/module/components/Avatar/Avatar.js +1 -1
- package/lib/module/components/BarChart/BarChart.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/Box/Box.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/FieldBase/FieldBase.js +1 -1
- package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/module/components/FileViewer/useFileViewerZoom.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/ListItem/ListItem.js +1 -1
- package/lib/module/components/Markdown/Markdown.js +1 -1
- package/lib/module/components/MessageList/MessageList.js +1 -1
- package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
- package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/module/components/SignaturePad/writePng.js +1 -1
- package/lib/module/components/SignaturePad/writePng.web.js +1 -1
- package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/module/components/Slider/Slider.js +1 -1
- package/lib/module/components/SortableList/SortableList.js +1 -1
- package/lib/module/components/Swipeable/Swipeable.js +1 -1
- package/lib/module/components/WheelPicker/Wheel.js +1 -1
- package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/module/hooks/useDragToDismiss.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/navigation/NavigationScreen.js +1 -1
- package/lib/module/theme/Gradient.js +1 -1
- package/lib/typescript/commonjs/canvasKit/index.d.ts +15 -6
- package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +3 -2
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +2 -2
- package/lib/typescript/commonjs/components/AuthedImage/imageStore.d.ts +1 -1
- package/lib/typescript/commonjs/components/AuthedImage/imageStore.web.d.ts +1 -1
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +2 -2
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +2 -2
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +2 -2
- package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +2 -2
- package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +2 -2
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +3 -4
- package/lib/typescript/commonjs/components/Box/Box.d.ts +4 -4
- package/lib/typescript/commonjs/components/Button/Button.d.ts +3 -2
- package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +3 -2
- package/lib/typescript/commonjs/components/Calendar/calendarStyles.d.ts +25 -116
- package/lib/typescript/commonjs/components/Card/Card.d.ts +2 -2
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +2 -2
- package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +2 -2
- package/lib/typescript/commonjs/components/Composer/Composer.d.ts +2 -3
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +3 -2
- package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/Divider/Divider.d.ts +3 -2
- package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +1 -1
- package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +2 -2
- package/lib/typescript/commonjs/components/FileViewer/useFileViewerZoom.d.ts +14 -22
- package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +3 -2
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +2 -2
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +2 -2
- package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +3 -2
- package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +3 -2
- package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +2 -2
- package/lib/typescript/commonjs/components/Input/Input.d.ts +2 -3
- package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +4 -3
- package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +3 -1
- package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +2 -2
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +3 -3
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -2
- package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +2 -2
- package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +2 -2
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +4 -4
- package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +2 -2
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -3
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +2 -2
- package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +2 -2
- package/lib/typescript/commonjs/components/Screen/Screen.d.ts +2 -2
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +3 -3
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -3
- package/lib/typescript/commonjs/components/Select/Select.d.ts +2 -2
- package/lib/typescript/commonjs/components/SignaturePad/writePng.d.ts +1 -1
- package/lib/typescript/commonjs/components/SignaturePad/writePng.web.d.ts +1 -1
- package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +2 -2
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +2 -2
- package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +2 -2
- package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +3 -2
- package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +2 -2
- package/lib/typescript/commonjs/components/SquircleView/SquircleView.d.ts +3 -2
- package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +3 -3
- package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +2 -2
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +2 -2
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +1 -1
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -3
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -3
- package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/Text/Text.d.ts +2 -2
- package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +3 -3
- package/lib/typescript/commonjs/components/Tour/Tour.d.ts +2 -2
- package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +5 -5
- package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +5 -5
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/Gradient.d.ts +5 -1
- package/lib/typescript/commonjs/theme/makeStyles.d.ts +4 -2
- package/lib/typescript/module/canvasKit/index.d.ts +15 -6
- package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +3 -2
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +2 -2
- package/lib/typescript/module/components/AuthedImage/imageStore.d.ts +1 -1
- package/lib/typescript/module/components/AuthedImage/imageStore.web.d.ts +1 -1
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +2 -2
- package/lib/typescript/module/components/Badge/Badge.d.ts +2 -2
- package/lib/typescript/module/components/Banner/Banner.d.ts +2 -2
- package/lib/typescript/module/components/BarChart/BarChart.d.ts +2 -2
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +2 -2
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +3 -4
- package/lib/typescript/module/components/Box/Box.d.ts +4 -4
- package/lib/typescript/module/components/Button/Button.d.ts +3 -2
- package/lib/typescript/module/components/Calendar/Calendar.d.ts +3 -2
- package/lib/typescript/module/components/Calendar/calendarStyles.d.ts +25 -116
- package/lib/typescript/module/components/Card/Card.d.ts +2 -2
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/typescript/module/components/Chip/Chip.d.ts +2 -2
- package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +2 -2
- package/lib/typescript/module/components/Composer/Composer.d.ts +2 -3
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +3 -2
- package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +3 -2
- package/lib/typescript/module/components/Divider/Divider.d.ts +3 -2
- package/lib/typescript/module/components/Drawer/Drawer.d.ts +1 -1
- package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +2 -2
- package/lib/typescript/module/components/FileViewer/useFileViewerZoom.d.ts +14 -22
- package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +3 -2
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +2 -2
- package/lib/typescript/module/components/FormField/FormField.d.ts +2 -2
- package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +3 -2
- package/lib/typescript/module/components/IconButton/IconButton.d.ts +3 -2
- package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +2 -2
- package/lib/typescript/module/components/Input/Input.d.ts +2 -3
- package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +4 -3
- package/lib/typescript/module/components/Markdown/Markdown.d.ts +3 -1
- package/lib/typescript/module/components/Menu/useContextMenu.d.ts +2 -2
- package/lib/typescript/module/components/Modal/Modal.d.ts +3 -3
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -2
- package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +2 -2
- package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +2 -2
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +4 -4
- package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +2 -2
- package/lib/typescript/module/components/Radio/Radio.d.ts +3 -3
- package/lib/typescript/module/components/Rating/Rating.d.ts +2 -2
- package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +2 -2
- package/lib/typescript/module/components/Screen/Screen.d.ts +2 -2
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +3 -3
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -3
- package/lib/typescript/module/components/Select/Select.d.ts +2 -2
- package/lib/typescript/module/components/SignaturePad/writePng.d.ts +1 -1
- package/lib/typescript/module/components/SignaturePad/writePng.web.d.ts +1 -1
- package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +2 -2
- package/lib/typescript/module/components/Slider/Slider.d.ts +2 -2
- package/lib/typescript/module/components/SliderField/SliderField.d.ts +2 -2
- package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +3 -2
- package/lib/typescript/module/components/Spinner/Spinner.d.ts +2 -2
- package/lib/typescript/module/components/SquircleView/SquircleView.d.ts +3 -2
- package/lib/typescript/module/components/StatTile/StatTile.d.ts +3 -3
- package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +2 -2
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +2 -2
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +1 -1
- package/lib/typescript/module/components/Switch/Switch.d.ts +3 -3
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -3
- package/lib/typescript/module/components/TagInput/TagInput.d.ts +3 -2
- package/lib/typescript/module/components/Text/Text.d.ts +2 -2
- package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +3 -3
- package/lib/typescript/module/components/Tour/Tour.d.ts +2 -2
- package/lib/typescript/module/hooks/useDragToDismiss.d.ts +5 -5
- package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +5 -5
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/theme/Gradient.d.ts +5 -1
- package/lib/typescript/module/theme/makeStyles.d.ts +4 -2
- package/package.json +31 -31
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"kind": "WeborityPhone",
|
|
3
3
|
"library": {
|
|
4
4
|
"name": "@webority/mobile-ui",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.149.0"
|
|
6
6
|
},
|
|
7
7
|
"rendererProtocolVersion": 13,
|
|
8
8
|
"platform": "Phone",
|
|
@@ -9544,6 +9544,13 @@
|
|
|
9544
9544
|
"required": false,
|
|
9545
9545
|
"description": "Shows the skeleton placeholder shape instead of the text while data loads.",
|
|
9546
9546
|
"default": false
|
|
9547
|
+
},
|
|
9548
|
+
{
|
|
9549
|
+
"name": "selectable",
|
|
9550
|
+
"type": "boolean",
|
|
9551
|
+
"required": false,
|
|
9552
|
+
"description": "Makes every text block selectable so a person can select and copy it.",
|
|
9553
|
+
"default": false
|
|
9547
9554
|
}
|
|
9548
9555
|
],
|
|
9549
9556
|
"itemsTakeAction": [],
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webority-phone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.149.0",
|
|
4
4
|
"platform": "Phone",
|
|
5
5
|
"kitModuleVersion": 2,
|
|
6
6
|
"rendererProtocolVersion": 13,
|
|
7
7
|
"library": {
|
|
8
8
|
"name": "@webority/mobile-ui",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.149.0"
|
|
10
10
|
},
|
|
11
11
|
"files": {
|
|
12
12
|
"manifest.json": {
|
|
13
|
-
"sha256": "
|
|
14
|
-
"bytes":
|
|
13
|
+
"sha256": "6bf27a44120c1bddebbd5827560102c578abf7d52fd0005d223d556906d46dde",
|
|
14
|
+
"bytes": 664381
|
|
15
15
|
},
|
|
16
16
|
"kit.js": {
|
|
17
|
-
"sha256": "
|
|
18
|
-
"bytes":
|
|
17
|
+
"sha256": "8f5be6049c165557ee814ba4b4b456b7b8ea2cf52c079f77b94b9426193e55be",
|
|
18
|
+
"bytes": 6144222
|
|
19
19
|
},
|
|
20
20
|
"kit.css": {
|
|
21
21
|
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_APP_BAR_LABELS=exports.AppBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_index2=require("../Menu/index.js"),_Text=require("../Text/Text.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4,DEFAULT_APP_BAR_LABELS=exports.DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"}),variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=(0,_react.forwardRef)(({action:e,side:t,badgeStyle:i,haptic:n,flush:a,onPress:s},
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_APP_BAR_LABELS=exports.AppBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_index2=require("../Menu/index.js"),_Text=require("../Text/Text.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4,DEFAULT_APP_BAR_LABELS=exports.DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"}),variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=(0,_react.forwardRef)(({action:e,side:t,badgeStyle:i,haptic:n,flush:a,onPress:s},r)=>{const l=(0,_index.useTheme)(),{style:o,pressIn:c,pressOut:d}=(0,_usePressAnimation.usePressAnimation)({enabled:!0}),u=(0,_react.useMemo)(()=>buildActionStyles(l),[l]),p=e.badge,h=void 0!==p&&0!==p,x=void 0!==e.label;return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:o,children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:r,onPress:t=>{const i=(0,_hapticUtils.resolveHaptic)(n,"selection");i&&(0,_hapticUtils.triggerHaptic)(i),"onPress"in e&&e.onPress(),s?.(t)},onPressIn:c,onPressOut:d,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,android_ripple:{color:l.colors["surface-pressed"],borderless:!x},style:({pressed:e})=>[x?u.textButton:u.actionButton,a?null:"left"===t?u.actionLeft:u.actionRight,e&&!x?u.actionPressed:null,e&&x?u.textPressed:null],children:[x?(0,_jsxRuntime.jsx)(_Text.Text,{variant:"body",weight:"semibold",color:"link",numberOfLines:1,children:e.label}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.iconWrap,children:e.icon}),h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.badge,i],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_Text.Text,{variant:"caption",weight:"semibold",numberOfLines:1,style:u.badgeText,children:String(p)})}):null,e.dot?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:e.testID?`${e.testID}-dot`:"appbar-action-dot",style:u.dot,pointerEvents:"none"}):null]})})}),COLLAPSE_RANGE=60,AppBar=exports.AppBar=(0,_react.forwardRef)((e,t)=>{const{title:i,subtitle:n,titleAlignment:a="left",leftAction:s,rightActions:r,leading:l,trailing:o,onBack:c,gutter:d,titleVariant:u,titleOffset:p,height:h,divider:x,elevated:g=!1,variant:m="default",transparent:_=!1,scrollY:b,style:f,containerStyle:j,titleStyle:y,subtitleStyle:v,badgeStyle:A,haptic:R,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("AppBar","variant",e.variant,["default","large","compact"]),(0,_assertValidValue.assertValidValue)("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const B=(0,_react.useMemo)(()=>({...DEFAULT_APP_BAR_LABELS,...S}),[S]),L=(0,_index.useTheme)(),N=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),T=(0,_react.useMemo)(()=>variantSize(L,m),[L,m]),I=(0,_react.useMemo)(()=>buildStyles(L),[L]),V="large"===m,P=V&&void 0!==b,[C,z]=(0,_react.useState)(40),O=(0,_react.useCallback)(e=>z(e.nativeEvent.layout.height),[]),E=s??(c?{icon:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"arrow-left",size:24,color:L.colors["text-body"]}),onPress:c,accessibilityLabel:B.back}:void 0),D=o?void 0:r?.[r.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?L.space.sm:Math.max((44-(e.glyphSize??24))/2,0),W=void 0===d?null:{paddingLeft:Math.max(d-opticalInset(E),0),paddingRight:Math.max(d-opticalInset(D),0)},k=void 0!==p,F=Boolean(E)||Boolean(l),q=!k&&"left"===a&&Boolean(E),H=k||q||!F&&"left"===a,M="default"!==m||F?T.titleSize:L.text.xl.size,U=x??!1,$=_reactNative.StyleSheet.hairlineWidth,G=(0,_react.useMemo)(()=>{if(!b)return null;const e=b;return{rootHeight:e.interpolate({inputRange:[0,60],outputRange:[N.top+T.height+C,N.top+T.height],extrapolate:"clamp"}),titleRowOpacity:e.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:e.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:e.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}},[b,N.top,T.height,C]),Z=i?u?(0,_jsxRuntime.jsx)(_Text.Text,{variant:u,align:"center"===a?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[I.titleVariant,y],children:i}):(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityRole:"header",style:[I.title,{fontSize:M,fontWeight:L.weight[T.titleWeight],textAlign:"center"===a?"center":"left"},n?I.stackedText:null,y],numberOfLines:1,children:i}):null,Y=P&&G&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[I.title,{fontSize:L.text.lg.size,fontWeight:L.weight.semibold,textAlign:"center"===a?"center":"left",opacity:G.compactTitleOpacity}],numberOfLines:1,children:i}):null,J=n?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[I.subtitle,{textAlign:"center"===a?"center":"left"},v],numberOfLines:T.subtitleLines,children:n}):null,K=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I.titleColumn,"center"===a?I.titleColumnCenter:null],children:[Z,J]}),Q=P?_reactNative.Animated.View:_reactNative.View,X=P&&G?{height:G.rootHeight,overflow:"hidden"}:V&&void 0===h?null:{height:(h??T.height)+N.top};return(0,_jsxRuntime.jsxs)(Q,{ref:t,testID:w,style:[I.root,{paddingTop:N.top,backgroundColor:_?"transparent":L.colors.surface},X,!P&&U?{borderBottomWidth:$,borderBottomColor:L.colors.border}:null,g&&!_?L.shadow.card:null,j,f],children:[P&&G&&U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[I.animatedBorder,{backgroundColor:L.colors.border,opacity:G.borderOpacity}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:V&&w?`${w}-bar-row`:void 0,style:[I.row,V?{height:T.height}:{flex:1},W],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:w?`${w}-leading-slot`:void 0,style:[I.sideSlot,H?I.sideSlotCompact:null],children:[E?(0,_jsxRuntime.jsx)(ActionButton,{action:E,side:"left",haptic:R,flush:k||q}):null,null!=l&&!1!==l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:I.slotNode,children:l}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[I.center,"center"===a?I.centerAligned:I.centerLeft,k?{paddingLeft:F?p:L.space.none,paddingRight:L.space.none}:H?{paddingLeft:L.space.none}:null],children:V?Y:K}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I.sideSlot,I.sideSlotRight,k?I.sideSlotCompact:null],children:[r?.map((e,t)=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:"menu"in e?(0,_jsxRuntime.jsx)(_index2.Menu,{items:e.menu,title:e.menuTitle,haptic:R,trigger:(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})}):(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})},`appbar-right-${t}`)),null!=o&&!1!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:I.slotNode,children:o}):null]})]}),V?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{testID:w?`${w}-title-row`:void 0,onLayout:P?O:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??L.space.md,paddingBottom:L.space.sm},P&&G?{opacity:G.titleRowOpacity}:null],children:K}):null]})});AppBar.displayName="AppBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{width:"100%"},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.xs},sideSlot:{flexDirection:"row",alignItems:"center",minWidth:48},sideSlotRight:{justifyContent:"flex-end"},sideSlotCompact:{minWidth:0},slotNode:{flexDirection:"row",alignItems:"center"},center:{flex:1,minWidth:0,paddingHorizontal:e.space.xs},centerAligned:{alignItems:"center"},centerLeft:{alignItems:"flex-start"},titleColumn:{flexDirection:"column",maxWidth:"100%"},titleColumnCenter:{alignItems:"center"},title:{color:e.colors["text-body"]},titleVariant:{includeFontPadding:!1,textAlignVertical:"center"},stackedText:{includeFontPadding:!1},subtitle:{includeFontPadding:!1,color:e.colors["text-subtle"],fontSize:e.text.sm.size,fontWeight:e.weight.normal},animatedBorder:{position:"absolute",left:0,right:0,bottom:0,height:_reactNative.StyleSheet.hairlineWidth}}),buildActionStyles=e=>_reactNative.StyleSheet.create({actionButton:{width:44,height:44,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},actionLeft:{marginRight:e.space.xs},actionRight:{marginLeft:e.space.xs},actionPressed:{backgroundColor:e.colors["surface-pressed"]},textButton:{minWidth:44,minHeight:44,paddingHorizontal:e.space.sm,alignItems:"center",justifyContent:"center"},textPressed:{opacity:.6},dot:{position:"absolute",top:10,right:10,width:8,height:8,borderRadius:e.radius.pill,backgroundColor:e.colors.danger},iconWrap:{alignItems:"center",justifyContent:"center"},badge:{position:"absolute",top:4,right:4,minWidth:16,height:16,paddingHorizontal:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.danger,alignItems:"center",justifyContent:"center"},badgeText:{color:e.colors["on-danger"],fontSize:e.text.xs.size,fontWeight:e.weight.semibold,lineHeight:13}});var _default=exports.default=AppBar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.touchEntry=exports.setAuthedImageCacheLimit=exports.removeEntry=exports.releaseFetch=exports.readEntry=exports.isPermanentRefusal=exports.isFresh=exports.getAuthedImageCacheLimit=exports.flushAuthedImageIndex=exports.deriveCacheKey=exports.clearAuthedImageCache=exports.authedImageCacheStats=exports.acquireFetch=exports.DEFAULT_TTL_MS=exports.AuthedImageHttpError=void 0;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native"),_hashString=require("../../utils/hashString.js"),_imageStore=require("./imageStore");const INDEX_KEY="@webority/authed-image/v2/index",LEGACY_PREFIX="@webority/authed-image/v1/",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3,DEFAULT_TTL_MS=exports.DEFAULT_TTL_MS=6048e5;let byteCeiling=52428800;const setAuthedImageCacheLimit=e=>{if(!Number.isFinite(e)||e<=0)throw new Error(`[@webority/mobile-ui] setAuthedImageCacheLimit() needs a positive number of bytes, received ${String(e)}. Pass e.g. 50 * 1024 * 1024 for 50 MB.`);byteCeiling=e};exports.setAuthedImageCacheLimit=setAuthedImageCacheLimit;const getAuthedImageCacheLimit=()=>byteCeiling;exports.getAuthedImageCacheLimit=getAuthedImageCacheLimit;const deriveCacheKey=(e,t)=>(0,_hashString.hashString)(t??e);exports.deriveCacheKey=deriveCacheKey;const toMeta=({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s})=>({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s});let index=null,indexBytes=0,indexLoad=null,persistTimer=null,persistTarget=null,appStateSub=null;const persistIndex=async e=>{if(!(0,_mobileCore.isStorageAvailable)())return;const t={};for(const[r,s]of e)t[r]={...s,persistedAccessAt:s.lastAccessedAt};if(await _mobileCore.Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=_reactNative.AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))},flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};exports.flushAuthedImageIndex=flushAuthedImageIndex;const removeLegacyEntries=async()=>{const e=(await _mobileCore.Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await _mobileCore.Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of(0,_imageStore.listImageNames)())t.has(e)||(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!(0,_mobileCore.isStorageAvailable)())return e;const t=await _mobileCore.Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{for(const[r,s]of Object.entries(JSON.parse(t)))e.set(r,s)}catch{}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,r]of e)(0,_imageStore.imageExists)(r.fileName)||e.delete(t);return index=e,indexBytes=[...e.values()].reduce((e,t)=>e+t.bytes,0),e}).finally(()=>{indexLoad=null})),indexLoad),deleteFile=e=>{try{(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}},readEntry=async e=>{const t=await loadIndex(),r=t.get(e);return r?(0,_imageStore.imageExists)(r.fileName)?{fileUri:(0,_imageStore.imageUri)(r.fileName),meta:toMeta(r)}:(t.delete(e),indexBytes-=r.bytes,schedulePersist(t),null):null};exports.readEntry=readEntry;const removeEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(t.delete(e),indexBytes-=r.bytes,deleteFile(r.fileName),schedulePersist(t))};exports.removeEntry=removeEntry;class AuthedImageHttpError extends Error{constructor(e,t){super(e),this.name="AuthedImageHttpError",this.status=t}}exports.AuthedImageHttpError=AuthedImageHttpError;const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;exports.isPermanentRefusal=isPermanentRefusal;const isFresh=(e,t,r=Date.now())=>r-e.fetchedAt<t;exports.isFresh=isFresh;const touchEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(r.lastAccessedAt=Date.now(),r.lastAccessedAt-r.persistedAccessAt>=36e5&&schedulePersist(t))};exports.touchEntry=touchEntry;const evictIfNeeded=e=>{let t=indexBytes;if(t<=byteCeiling)return 0;const r=[...e].sort(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);let s=0;for(const[i,a]of r){if(t<=byteCeiling)break;e.delete(i),indexBytes-=a.bytes,deleteFile(a.fileName),t-=a.bytes,s+=1}return s},clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,(0,_imageStore.clearImages)(),(0,_mobileCore.isStorageAvailable)()&&await _mobileCore.Storage.removeItem(INDEX_KEY)};exports.clearAuthedImageCache=clearAuthedImageCache;const authedImageCacheStats=async()=>{const e=await loadIndex();let t=0;for(const r of e.values())t+=r.bytes;return{entries:e.size,bytes:t}};exports.authedImageCacheStats=authedImageCacheStats;const responseHeader=(e,t)=>{if(!e||"object"!=typeof e)return;const r=e.get,s="function"==typeof r?r.call(e,t):e[t];return"string"==typeof s?s:void 0},originOf=e=>{const t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);if(null===t)return null;const r=t[1];if(void 0===r)throw new Error("originOf: the origin pattern always captures group 1 when it matches");return r.toLowerCase()},mediaTypeOf=e=>{const[t]=e.split(";");if(void 0===t)throw new Error("mediaTypeOf: String.split always returns at least one part");return t.trim()},isOwnApiAddress=e=>{const t=originOf(e);if(null===t)return!0;const r=(0,_mobileCore.getConfigValue)("baseUrl");return"string"==typeof r&&originOf(r)===t},fetchAndStore=async(e,t,r)=>{const s={Accept:"image/*",...t.headers};if(!t.client&&t.authenticated&&isOwnApiAddress(t.uri)){const e=await(0,_mobileCore.getToken)(_mobileCore.ACCESS_TOKEN_KEY);e?.token&&(s.Authorization=`Bearer ${e.token}`)}const i=t.client??_mobileCore.publicClient;let a;try{a=await i.get(t.uri,{headers:s,responseType:"arraybuffer",signal:r})}catch(e){const r=e?.response?.status;if("number"!=typeof r)throw e;throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered ${r}. Check the URL and whether the request needs to be signed in (pass the signed-in client as \`client\`, or authenticated={false} for public media).`,r)}const o=new Uint8Array(a.data??new ArrayBuffer(0));if(0===o.byteLength)throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered with an empty body, so the address holds no image.`,404);const n=responseHeader(a.headers,"content-type"),l=(n?mediaTypeOf(n):"")||"image/jpeg",c=await loadIndex(),d=Date.now(),u=`${e}-${d.toString(36)}`;let h;try{h=(0,_imageStore.writeImage)(u,o,l)}catch(e){throw new Error(`[@webority/mobile-ui] AuthedImage fetched "${t.uri}" but could not write it to the app's cache folder: ${e instanceof Error?e.message:String(e)}. The device may be out of storage.`)}const m={fetchedAt:d,bytes:o.byteLength,contentType:l,lastAccessedAt:d,fileName:u,persistedAccessAt:d},g=c.get(e);g&&(indexBytes-=g.bytes),c.set(e,m),indexBytes+=m.bytes,g&&g.fileName!==u&&deleteFile(g.fileName);const p=evictIfNeeded(c);return schedulePersist(c),p>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:h,meta:toMeta(m)}},inFlight=new Map,acquireFetch=(e,t)=>{const r=inFlight.get(e);if(r)return r.waiters+=1,r;const s=new AbortController,i={controller:s,waiters:1,promise:Promise.resolve()};return i.promise=fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)}),inFlight.set(e,i),i};exports.acquireFetch=acquireFetch;const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};exports.releaseFetch=releaseFetch;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.touchEntry=exports.setAuthedImageCacheLimit=exports.removeEntry=exports.releaseFetch=exports.readEntry=exports.isPermanentRefusal=exports.isFresh=exports.getAuthedImageCacheLimit=exports.flushAuthedImageIndex=exports.deriveCacheKey=exports.clearAuthedImageCache=exports.authedImageCacheStats=exports.acquireFetch=exports.DEFAULT_TTL_MS=exports.AuthedImageHttpError=void 0;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native"),_hashString=require("../../utils/hashString.js"),_imageStore=require("./imageStore");const INDEX_KEY="@webority/authed-image/v2/index",LEGACY_PREFIX="@webority/authed-image/v1/",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3,DEFAULT_TTL_MS=exports.DEFAULT_TTL_MS=6048e5;let byteCeiling=52428800;const setAuthedImageCacheLimit=e=>{if(!Number.isFinite(e)||e<=0)throw new Error(`[@webority/mobile-ui] setAuthedImageCacheLimit() needs a positive number of bytes, received ${String(e)}. Pass e.g. 50 * 1024 * 1024 for 50 MB.`);byteCeiling=e};exports.setAuthedImageCacheLimit=setAuthedImageCacheLimit;const getAuthedImageCacheLimit=()=>byteCeiling;exports.getAuthedImageCacheLimit=getAuthedImageCacheLimit;const deriveCacheKey=(e,t)=>(0,_hashString.hashString)(t??e);exports.deriveCacheKey=deriveCacheKey;const toMeta=({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s})=>({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s});let index=null,indexBytes=0,indexLoad=null,persistTimer=null,persistTarget=null,appStateSub=null;const persistIndex=async e=>{if(!(0,_mobileCore.isStorageAvailable)())return;const t={};for(const[r,s]of e)t[r]={...s,persistedAccessAt:s.lastAccessedAt};if(await _mobileCore.Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=_reactNative.AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))},flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};exports.flushAuthedImageIndex=flushAuthedImageIndex;const removeLegacyEntries=async()=>{const e=(await _mobileCore.Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await _mobileCore.Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of(0,_imageStore.listImageNames)())t.has(e)||(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!(0,_mobileCore.isStorageAvailable)())return e;const t=await _mobileCore.Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{for(const[r,s]of Object.entries(JSON.parse(t)))e.set(r,s)}catch{}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,r]of e)(0,_imageStore.imageExists)(r.fileName)||e.delete(t);return index=e,indexBytes=[...e.values()].reduce((e,t)=>e+t.bytes,0),e}).finally(()=>{indexLoad=null})),indexLoad),deleteFile=e=>{try{(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}},readEntry=async e=>{const t=await loadIndex(),r=t.get(e);return r?(0,_imageStore.imageExists)(r.fileName)?{fileUri:(0,_imageStore.imageUri)(r.fileName),meta:toMeta(r)}:(t.delete(e),indexBytes-=r.bytes,schedulePersist(t),null):null};exports.readEntry=readEntry;const removeEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(t.delete(e),indexBytes-=r.bytes,deleteFile(r.fileName),schedulePersist(t))};exports.removeEntry=removeEntry;class AuthedImageHttpError extends Error{constructor(e,t){super(e),this.name="AuthedImageHttpError",this.status=t}}exports.AuthedImageHttpError=AuthedImageHttpError;const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;exports.isPermanentRefusal=isPermanentRefusal;const isFresh=(e,t,r=Date.now())=>r-e.fetchedAt<t;exports.isFresh=isFresh;const touchEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(r.lastAccessedAt=Date.now(),r.lastAccessedAt-r.persistedAccessAt>=36e5&&schedulePersist(t))};exports.touchEntry=touchEntry;const evictIfNeeded=e=>{let t=indexBytes;if(t<=byteCeiling)return 0;const r=[...e].sort(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);let s=0;for(const[i,a]of r){if(t<=byteCeiling)break;e.delete(i),indexBytes-=a.bytes,deleteFile(a.fileName),t-=a.bytes,s+=1}return s},clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,(0,_imageStore.clearImages)(),(0,_mobileCore.isStorageAvailable)()&&await _mobileCore.Storage.removeItem(INDEX_KEY)};exports.clearAuthedImageCache=clearAuthedImageCache;const authedImageCacheStats=async()=>{const e=await loadIndex();let t=0;for(const r of e.values())t+=r.bytes;return{entries:e.size,bytes:t}};exports.authedImageCacheStats=authedImageCacheStats;const responseHeader=(e,t)=>{if(!e||"object"!=typeof e)return;const r=e.get,s="function"==typeof r?r.call(e,t):e[t];return"string"==typeof s?s:void 0},originOf=e=>{const t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);if(null===t)return null;const r=t[1];if(void 0===r)throw new Error("originOf: the origin pattern always captures group 1 when it matches");return r.toLowerCase()},mediaTypeOf=e=>{const[t]=e.split(";");if(void 0===t)throw new Error("mediaTypeOf: String.split always returns at least one part");return t.trim()},isOwnApiAddress=e=>{const t=originOf(e);if(null===t)return!0;const r=(0,_mobileCore.getConfigValue)("baseUrl");return"string"==typeof r&&originOf(r)===t},fetchAndStore=async(e,t,r)=>{const s={Accept:"image/*",...t.headers};if(!t.client&&t.authenticated&&isOwnApiAddress(t.uri)){const e=await(0,_mobileCore.getToken)(_mobileCore.ACCESS_TOKEN_KEY);e?.token&&(s.Authorization=`Bearer ${e.token}`)}const i=t.client??_mobileCore.publicClient;let a;try{a=await i.get(t.uri,{headers:s,responseType:"arraybuffer",signal:r})}catch(e){const r=e?.response?.status;if("number"!=typeof r)throw e;throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered ${r}. Check the URL and whether the request needs to be signed in (pass the signed-in client as \`client\`, or authenticated={false} for public media).`,r)}const o=new Uint8Array(a.data??new ArrayBuffer(0));if(0===o.byteLength)throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered with an empty body, so the address holds no image.`,404);const n=responseHeader(a.headers,"content-type"),l=(n?mediaTypeOf(n):"")||"image/jpeg",c=await loadIndex(),d=Date.now(),u=`${e}-${d.toString(36)}`;let h;try{h=await(0,_imageStore.writeImage)(u,o,l)}catch(e){throw new Error(`[@webority/mobile-ui] AuthedImage fetched "${t.uri}" but could not write it to the app's cache folder: ${e instanceof Error?e.message:String(e)}. The device may be out of storage.`)}const m={fetchedAt:d,bytes:o.byteLength,contentType:l,lastAccessedAt:d,fileName:u,persistedAccessAt:d},g=c.get(e);g&&(indexBytes-=g.bytes),c.set(e,m),indexBytes+=m.bytes,g&&g.fileName!==u&&deleteFile(g.fileName);const p=evictIfNeeded(c);return schedulePersist(c),p>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:h,meta:toMeta(m)}},inFlight=new Map,acquireFetch=(e,t)=>{const r=inFlight.get(e);if(r)return r.waiters+=1,r;const s=new AbortController,i={controller:s,waiters:1,promise:Promise.resolve()};return i.promise=fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)}),inFlight.set(e,i),i};exports.acquireFetch=acquireFetch;const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};exports.releaseFetch=releaseFetch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeImage=exports.listImageNames=exports.imageUri=exports.imageExists=exports.deleteImage=exports.clearImages=void 0;var _expoFileSystem=require("expo-file-system");const FOLDER="authed-images",imageFile=e=>new _expoFileSystem.File(_expoFileSystem.Paths.cache,FOLDER,e),writeImage=(e,t,s)=>{const i=imageFile(e);return i.create({intermediates:!0,overwrite:!0}),i.write(t),i.uri};exports.writeImage=writeImage;const imageUri=e=>imageFile(e).uri;exports.imageUri=imageUri;const imageExists=e=>imageFile(e).exists;exports.imageExists=imageExists;const deleteImage=e=>{const t=imageFile(e);t.exists&&t.delete()};exports.deleteImage=deleteImage;const listImageNames=()=>{const e=new _expoFileSystem.Directory(_expoFileSystem.Paths.cache,FOLDER);return e.exists?e.list().map(e=>e.uri.slice(e.uri.lastIndexOf("/")+1)):[]};exports.listImageNames=listImageNames;const clearImages=()=>{const e=new _expoFileSystem.Directory(_expoFileSystem.Paths.cache,FOLDER);e.exists&&e.delete()};exports.clearImages=clearImages;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeImage=exports.listImageNames=exports.imageUri=exports.imageExists=exports.deleteImage=exports.clearImages=void 0;var _expoFileSystem=require("expo-file-system");const FOLDER="authed-images",imageFile=e=>new _expoFileSystem.File(_expoFileSystem.Paths.cache,FOLDER,e),writeImage=async(e,t,s)=>{const i=imageFile(e);return i.create({intermediates:!0,overwrite:!0}),await i.write(t),i.uri};exports.writeImage=writeImage;const imageUri=e=>imageFile(e).uri;exports.imageUri=imageUri;const imageExists=e=>imageFile(e).exists;exports.imageExists=imageExists;const deleteImage=e=>{const t=imageFile(e);t.exists&&t.delete()};exports.deleteImage=deleteImage;const listImageNames=()=>{const e=new _expoFileSystem.Directory(_expoFileSystem.Paths.cache,FOLDER);return e.exists?e.list().map(e=>e.uri.slice(e.uri.lastIndexOf("/")+1)):[]};exports.listImageNames=listImageNames;const clearImages=()=>{const e=new _expoFileSystem.Directory(_expoFileSystem.Paths.cache,FOLDER);e.exists&&e.delete()};exports.clearImages=clearImages;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeImage=exports.listImageNames=exports.imageUri=exports.imageExists=exports.deleteImage=exports.clearImages=void 0;const urls=new Map,writeImage=(e,s,t)=>{const r=urls.get(e);void 0!==r&&URL.revokeObjectURL(r);const a=URL.createObjectURL(new Blob([s],{type:t}));return urls.set(e,a),a};exports.writeImage=writeImage;const imageUri=e=>urls.get(e)??"";exports.imageUri=imageUri;const imageExists=e=>urls.has(e);exports.imageExists=imageExists;const deleteImage=e=>{const s=urls.get(e);void 0!==s&&(URL.revokeObjectURL(s),urls.delete(e))};exports.deleteImage=deleteImage;const listImageNames=()=>[...urls.keys()];exports.listImageNames=listImageNames;const clearImages=()=>{for(const e of urls.values())URL.revokeObjectURL(e);urls.clear()};exports.clearImages=clearImages;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeImage=exports.listImageNames=exports.imageUri=exports.imageExists=exports.deleteImage=exports.clearImages=void 0;const urls=new Map,writeImage=async(e,s,t)=>{const r=urls.get(e);void 0!==r&&URL.revokeObjectURL(r);const a=URL.createObjectURL(new Blob([s],{type:t}));return urls.set(e,a),a};exports.writeImage=writeImage;const imageUri=e=>urls.get(e)??"";exports.imageUri=imageUri;const imageExists=e=>urls.has(e);exports.imageExists=imageExists;const deleteImage=e=>{const s=urls.get(e);void 0!==s&&(URL.revokeObjectURL(s),urls.delete(e))};exports.deleteImage=deleteImage;const listImageNames=()=>[...urls.keys()];exports.listImageNames=listImageNames;const clearImages=()=>{for(const e of urls.values())URL.revokeObjectURL(e);urls.clear()};exports.clearImages=clearImages;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,s)=>{switch(t){case"circle":return r/2;case"rounded":return s?e.radius[s]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,s]=t;return void 0===r?"":void 0===s?r.charAt(0).toUpperCase():(r.charAt(0)+s.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const s=t[Math.abs(r)%t.length];if(void 0===s)throw new Error("The avatar colour palette is empty.");return s},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},Avatar=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:s,imageClient:a,name:o,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:h=null,statusPosition:g="bottomRight",tone:p,backgroundColor:_,color:v,fontSize:b,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:V,style:j,textStyle:S,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[M,w]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(o),[o]),D=(0,_react.useMemo)(()=>p?avatarToneColors(L,p):null,[L,p]),q=(0,_react.useMemo)(()=>_||(D?.background??L.colors[hashColor(o??"",AVATAR_COLORS)]),[_,D,o,L]),G=v??D?.color??L.colors["on-primary"],U=r?keyOfSource(r):null,P=null!==U&&U!==M,$=!P&&""===F&&null!=m,B=v??D?.color??L.colors["text-subtle"],W=b??Math.max(L.text.xs.size,Math.round(.4*E)),H=Math.max(8,Math.round(.25*E)),Y=isRingStatus(h),X=E-2*(Y?3:k),J=Y?resolveRadius(L,n,X,c):Math.max(0,O-k),K=$?(0,_slotIcon.renderSlotIcon)(m,{color:B,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(L,h):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=_??D?.background??L.colors["bg-muted"],re=P?"contain"===d?"transparent":L.colors["bg-muted"]:$?te:q,se=C??"avatar",ae=o?T.avatarOf(o):T.avatar,oe="verified"===h?`, ${T.verified}`:"pending"===h?`, ${T.pendingVerification}`:"",ie=A??`${ae}${oe}`,ne="function"==typeof y||"function"==typeof f,le=A??`${o||ae}${oe}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=V??ce,de=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:Y?0:k,borderColor:N,backgroundColor:Y?"transparent":re},j],me=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:X,height:X,borderRadius:J,..._corners.smoothCorners,borderWidth:Y?k:0,borderColor:N,backgroundColor:Y?re:"transparent"}],children:P?(()=>{const e={width:X,height:X,borderRadius:J,..._corners.smoothCorners},onError=()=>w(U),t=uriOfSource(r);return s?(0,_jsxRuntime.jsx)(s,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):a&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:a,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:G,fontSize:W,lineHeight:Math.round(W*L.leading.body)},S],children:F??" "})}),"verified"===h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,h&&!Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:H,height:H,borderRadius:H/2,..._corners.smoothCorners,backgroundColor:statusColor(L,h),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),he=ne?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:ue,...(0,_hitSlop.hitSlopMarker)(ue),accessibilityRole:"button",accessibilityLabel:le,testID:C,style:({pressed:e})=>[de,e?styles.pressed:null],children:me}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:C,children:me});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):he});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:s})=>{const a=r??resolveSize(e),o="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:o,width:a,height:a,style:s})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:s,children:a})=>{const o=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:_nativeDriver.nativeDriver});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:o.radius.pill,borderColor:r,borderWidth:s,opacity:i}],children:a})},AvatarGroup=e=>{const{children:t,max:r=4,size:s="md",spacing:a="normal",overflowVariant:o="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),m=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),h=m.length,g=m.slice(0,r),p=Math.max(0,h-r),_=p>0,v=-d.space[SPACING_OFFSET[a]],b=d.colors.surface,x=i??u.groupOf(h),A=(0,_react.useMemo)(()=>resolveSize(s),[s]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,a=(0,_react.cloneElement)(e,{size:s,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:v,borderColor:b,borderWidth:1.5,children:a},r)}),_?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:v,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===o?u.moreCount(p):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===o?`+${p}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,s)=>{switch(t){case"circle":return r/2;case"rounded":return s?e.radius[s]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,s]=t;return void 0===r?"":void 0===s?r.charAt(0).toUpperCase():(r.charAt(0)+s.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const s=t[Math.abs(r)%t.length];if(void 0===s)throw new Error("The avatar colour palette is empty.");return s},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isImageSourceList=e=>Array.isArray(e),isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},Avatar=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:s,imageClient:a,name:o,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:h=null,statusPosition:g="bottomRight",tone:p,backgroundColor:_,color:v,fontSize:b,loading:A=!1,accessibilityLabel:x,onPress:y,onLongPress:f,haptic:R,hitSlop:V,style:j,textStyle:S,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[M,w]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(o),[o]),D=(0,_react.useMemo)(()=>p?avatarToneColors(L,p):null,[L,p]),q=(0,_react.useMemo)(()=>_||(D?.background??L.colors[hashColor(o??"",AVATAR_COLORS)]),[_,D,o,L]),G=v??D?.color??L.colors["on-primary"],U=r?keyOfSource(r):null,P=null!==U&&U!==M,$=!P&&""===F&&null!=m,B=v??D?.color??L.colors["text-subtle"],W=b??Math.max(L.text.xs.size,Math.round(.4*E)),H=Math.max(8,Math.round(.25*E)),Y=isRingStatus(h),X=E-2*(Y?3:k),J=Y?resolveRadius(L,n,X,c):Math.max(0,O-k),K=$?(0,_slotIcon.renderSlotIcon)(m,{color:B,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(L,h):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=_??D?.background??L.colors["bg-muted"],re=P?"contain"===d?"transparent":L.colors["bg-muted"]:$?te:q,se=C??"avatar",ae=o?T.avatarOf(o):T.avatar,oe="verified"===h?`, ${T.verified}`:"pending"===h?`, ${T.pendingVerification}`:"",ie=x??`${ae}${oe}`,ne="function"==typeof y||"function"==typeof f,le=x??`${o||ae}${oe}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=V??ce,de=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:Y?0:k,borderColor:N,backgroundColor:Y?"transparent":re},j],me=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:X,height:X,borderRadius:J,..._corners.smoothCorners,borderWidth:Y?k:0,borderColor:N,backgroundColor:Y?re:"transparent"}],children:P?(()=>{const e={width:X,height:X,borderRadius:J,..._corners.smoothCorners},onError=()=>w(U),t=uriOfSource(r);return s?(0,_jsxRuntime.jsx)(s,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):a&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:a,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:isImageSourceList(r)?[...r]:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:G,fontSize:W,lineHeight:Math.round(W*L.leading.body)},S],children:F??" "})}),"verified"===h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,h&&!Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:H,height:H,borderRadius:H/2,..._corners.smoothCorners,backgroundColor:statusColor(L,h),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),he=ne?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:ue,...(0,_hitSlop.hitSlopMarker)(ue),accessibilityRole:"button",accessibilityLabel:le,testID:C,style:({pressed:e})=>[de,e?styles.pressed:null],children:me}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:C,children:me});return A?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):he});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:s})=>{const a=r??resolveSize(e),o="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:o,width:a,height:a,style:s})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:s,children:a})=>{const o=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:_nativeDriver.nativeDriver});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:o.radius.pill,borderColor:r,borderWidth:s,opacity:i}],children:a})},AvatarGroup=e=>{const{children:t,max:r=4,size:s="md",spacing:a="normal",overflowVariant:o="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),m=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),h=m.length,g=m.slice(0,r),p=Math.max(0,h-r),_=p>0,v=-d.space[SPACING_OFFSET[a]],b=d.colors.surface,A=i??u.groupOf(h),x=(0,_react.useMemo)(()=>resolveSize(s),[s]),y=Math.max(d.text.xs.size,Math.round(.34*x));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:A,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,a=(0,_react.cloneElement)(e,{size:s,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:v,borderColor:b,borderWidth:1.5,children:a},r)}),_?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:v,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:x,height:x,borderRadius:x/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===o?u.moreCount(p):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===o?`+${p}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,entryAt=(e,t)=>{const r=e[t];if(void 0===r)throw new Error(`BarChart has no entry at index ${t}.`);return r},defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:y,style:p,testID:b}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...y}),[y]),j=(0,_index2.useTheme)(),R=r.length,[v,A]=(0,_react.useState)(0),[g,w]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),C=null!==g&&g>=0&&g<R?g:null,S=(0,_react.useRef)(C);S.current=C;const T=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(R>0&&R<=7),V=void 0!==s&&s.length>0,B=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??entryAt(STACK_TONES,t%STACK_TONES.length)):[],[V,s]),E=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),D=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),$=(0,_react.useMemo)(()=>D?D.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,D]),H=(0,_react.useMemo)(()=>D?D.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):$,[D,$]),I=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&I.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+(I.max-e)/(I.max-I.min)*F,[k,I.max,I.min,F]),q=G(0),W=(0,_react.useMemo)(()=>I.ticks.map(e=>u(e)),[I.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=R>0?v/R:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=entryAt(r,e);if(t.accessibilityLabel)return t.accessibilityLabel;if(D&&s){const r=entryAt(D,e);return`${t.label}, ${s.map((e,t)=>`${e.label} ${c(entryAt(r,t))}`).join(", ")}`}return`${t.label}, ${c(entryAt($,e))}`},[r,c,$,D,s]),K=(0,_react.useMemo)(()=>{let e=-1,t=0;for(const[r,a]of $.entries())(-1===e||a>t)&&(e=r,t=a);return e},[$]),J=o??(K>=0?f.highest(entryAt(r,K).label,c(entryAt($,K))):""),Y=(0,_react.useRef)({fire:N,setSelected:w,count:R,plotWidth:v});Y.current={fire:N,setSelected:w,count:R,plotWidth:v};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===T.current||(T.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{T.current=S.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(b?`${b}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),T.current=r,Y.current.setSelected(r===S.current?null:r))}).withTestId(b?`${b}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[b]),Q=(0,_react.useCallback)(e=>{if(0===R)return;const t=S.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(R-1,t+1):null===t?R-1:Math.max(0,t-1);r!==t&&(N(),w(r))},[R,N,w]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);A(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??f.chart,ie=0===R?`${ae}, ${f.noData}`:J?`${ae}, ${J}`:ae,se=null===C?J:X(C),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,entryAt(B,r))}},entryAt(E,r)))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=$.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==C&&C!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[v>0&&D?renderStack(entryAt(D,t),t,s):null,v>0&&!D&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&v>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(D?G(entryAt(H,2*t)):r)-20+2:(D?G(entryAt(H,2*t+1)):r)+2},children:u(e)}):null]},t)});return 0===R?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:b,style:[styles.root,p],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:R-1,now:C??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:b,style:[styles.root,p],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===C?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:entryAt(r,C).label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:b?`${b}-callout`:void 0,children:c(entryAt($,C))})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:I.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:entryAt(W,t)},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:b?`${b}-plot`:void 0,children:[I.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:C===t?"primary":"tertiary",weight:C===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,entryAt(B,t))}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,entryAt=(e,t)=>{const r=e[t];if(void 0===r)throw new Error(`BarChart has no entry at index ${t}.`);return r},defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:y,style:b,testID:p}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...y}),[y]),j=(0,_index2.useTheme)(),v=r.length,[R,A]=(0,_react.useState)(0),[g,C]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),S=null!==g&&g>=0&&g<v?g:null,w=(0,_react.useRef)(S);w.current=S;const M=(0,_react.useRef)(-1),T=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{T&&(0,_index3.triggerHaptic)(T)},[T]),L=d??(v>0&&v<=7),V=void 0!==s&&s.length>0,B=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??entryAt(STACK_TONES,t%STACK_TONES.length)):[],[V,s]),D=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),E=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),$=(0,_react.useMemo)(()=>E?E.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,E]),H=(0,_react.useMemo)(()=>E?E.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):$,[E,$]),I=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&I.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+(I.max-e)/(I.max-I.min)*F,[k,I.max,I.min,F]),q=G(0),W=(0,_react.useMemo)(()=>I.ticks.map(e=>u(e)),[I.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=v>0?R/v:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=entryAt(r,e);if(t.accessibilityLabel)return t.accessibilityLabel;if(E&&s){const r=entryAt(E,e);return`${t.label}, ${s.map((e,t)=>`${e.label} ${c(entryAt(r,t))}`).join(", ")}`}return`${t.label}, ${c(entryAt($,e))}`},[r,c,$,E,s]),K=(0,_react.useMemo)(()=>{let e=-1,t=0;for(const[r,a]of $.entries())(-1===e||a>t)&&(e=r,t=a);return e},[$]),J=o??(K>=0?f.highest(entryAt(r,K).label,c(entryAt($,K))):""),Y=(0,_react.useRef)({fire:N,setSelected:C,count:v,plotWidth:R});Y.current={fire:N,setSelected:C,count:v,plotWidth:R};const Z=(0,_react.useCallback)(e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},[]),Q=(0,_react.useCallback)(e=>{const t=Z(e);t<0||t===M.current||(M.current=t,Y.current.fire(),Y.current.setSelected(t))},[Z]),ee=(0,_react.useMemo)(()=>({runOnJS:!0,activeOffsetX:[-8,8],failOffsetY:[-12,12],onActivate:e=>{M.current=w.current??-1,Q(e.x)},onUpdate:e=>Q(e.x),testID:p?`${p}-pan`:"bar-chart-pan"}),[Q,p]),te=(0,_reactNativeGestureHandler.usePanGesture)(ee),re=(0,_react.useMemo)(()=>({runOnJS:!0,onDeactivate:e=>{if(e.canceled)return;const t=Z(e.x);t<0||(Y.current.fire(),M.current=t,Y.current.setSelected(t===w.current?null:t))},testID:p?`${p}-tap`:"bar-chart-tap"}),[Z,p]),ae=(0,_reactNativeGestureHandler.useTapGesture)(re),ie=(0,_reactNativeGestureHandler.useCompetingGestures)(te,ae),se=(0,_react.useCallback)(e=>{if(0===v)return;const t=w.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(v-1,t+1):null===t?v-1:Math.max(0,t-1);r!==t&&(N(),C(r))},[v,N,C]),ne=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);A(e=>e===t?e:t)},[]),le=i??toneColor(j,a),oe=j.radius.sm,ce=l??f.chart,ue=0===v?`${ce}, ${f.noData}`:J?`${ce}, ${J}`:ce,de=null===S?J:X(S),me=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:p?`${p}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,entryAt(B,r))}},entryAt(D,r)))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:p?`${p}-bar-${t}`:void 0,style:{position:"absolute",left:(z-me)/2,top:s,width:me,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:oe,borderTopRightRadius:oe}:null,...i<0?{borderBottomLeftRadius:oe,borderBottomRightRadius:oe}:null},children:n})},xe=$.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==S&&S!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[R>0&&E?renderStack(entryAt(E,t),t,s):null,R>0&&!E&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:p?`${p}-bar-${t}`:void 0,style:{position:"absolute",left:(z-me)/2,top:a,width:me,height:i,backgroundColor:le,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:oe,borderTopRightRadius:oe}:{borderBottomLeftRadius:oe,borderBottomRightRadius:oe}}}):null,L&&R>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(E?G(entryAt(H,2*t)):r)-20+2:(E?G(entryAt(H,2*t+1)):r)+2},children:u(e)}):null]},t)});return 0===v?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ue,testID:p,style:[styles.root,b],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ue,accessibilityValue:{min:0,max:v-1,now:S??0,text:de},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:se,testID:p,style:[styles.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===S?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:entryAt(r,S).label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:p?`${p}-callout`:void 0,children:c(entryAt($,S))})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:I.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:entryAt(W,t)},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ie,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ne,testID:p?`${p}-plot`:void 0,children:[I.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:xe})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:S===t?"primary":"tertiary",weight:S===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,entryAt(B,t))}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:w,actions:j,actionsLayout:C="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=w||null!=d,L=null!=j&&j.length>0,P=null!=M||L,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(P?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[we,je]=(0,_react.useState)(!1),[Ce,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[Te,ke]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===D?Ce:Te;const Ie=(0,_react.useRef)(u);Ie.current=u;const Le=(0,_react.useRef)(r);Le.current=r;const Pe=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(je(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!Ce:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,Ce,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),je(!0)):ke(!0),a<0&&Ae.current?(be.value=r,ye.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,s,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=xe.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,s,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Pe.current)return void t?.();const n=r();"boolean"!=typeof n?(Pe.current=!0,a?.(),n.then(a=>{Pe.current=!1,a&&De.current&&Be.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{Le.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Le.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(B?`${B}-content-gesture`:"bottom-sheet-content-gesture"),[B]),st=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value,o=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t);if(o>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(n-t);e<l&&(l=e,c=t,i=u),u++}r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(i,c)})},[fe,pe,c,nt,tt,at,B,be]),{height:it}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?it.value:0,[ct,it]),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,lt,F,ut,dt,be,Z,ye,tt]),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[lt,K,F,ut,dt,be,Z,tt,Se]),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,B]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!Ce)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:A??mt,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:st,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,w]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:T}):T}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[L?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:we,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:j,actions:C,actionsLayout:w="auto",footer:M,headerStyle:O,footerStyle:E,children:k,accessibilityLabel:T,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=j||null!=d,D=null!=C&&C.length>0,L=null!=M||D,P=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===P?X.top:q.top,ee="modal"===P?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(L?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[je,Ce]=(0,_react.useState)(!1),[we,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[ke,Te]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===P?we:ke;const Ie=(0,_react.useRef)(u);Ie.current=u;const De=(0,_react.useRef)(r);De.current=r;const Le=(0,_react.useRef)(!1),Pe=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(Pe.current=!0,()=>{Pe.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===P?(Ce(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):Te(!1))},[P,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===P?!we:!ke)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[P,we,ke,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===P?(Me(!0),Ce(!0)):Te(!0),a<0&&Ae.current?(be.value=r,ye.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,P,s,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=xe.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,s,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Le.current)return void t?.();const n=r();"boolean"!=typeof n?(Le.current=!0,a?.(),n.then(a=>{Le.current=!1,a&&Pe.current&&Be.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{De.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{De.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),De.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>({testID:B?`${B}-content-gesture`:"bottom-sheet-content-gesture"}),[B]),st=(0,_reactNativeGestureHandler.useNativeGesture)(ot),it=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return{testID:B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";pe.value=be.value},onUpdate:e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const n=be.value,o=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t);if(o>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(n-t);e<l&&(l=e,c=t,i=u),u++}r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(i,c)}}},[fe,pe,c,nt,tt,at,B,be]),ct=(0,_reactNativeGestureHandler.usePanGesture)(it),{height:lt}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ut="shift"===p,dt=(0,_reactNativeReanimated.useDerivedValue)(()=>ut?lt.value:0,[ut,lt]),_t=ve[Re>=0?Re:0]??Se,ht=H.space.md,mt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=dt.value,t=F+e-_t-ht,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+dt.value,t=dt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,dt,F,_t,ht,be,Z,ye,tt]),vt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=dt.value;if(K){const t=F+e-_t-ht,a=e<0&&be.value>t?t:be.value,r=F+e-ht-(a<Z?Z:a);return{height:r<0?0:r>_t?_t:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[dt,K,F,_t,ht,be,Z,tt,Se]),ft=Re>=0,St=(0,_react.useMemo)(()=>buildStyles(H),[H]),bt=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),De.current(),Ye()})},[l,Ye,Ke]),pt=(0,_react.useMemo)(()=>({testID:B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeReanimated.runOnJS)(bt)()}}),[bt,B]),yt=(0,_reactNativeGestureHandler.useTapGesture)(pt),xt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===P&&!ke)return null;if("modal"===P&&!we)return null;const Rt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===P?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===P?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??ft,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:yt,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:T,accessibilityViewIsModal:A??ft,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:_t,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,mt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[St.body,vt],keyboardOffset:dt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ct,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:St.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[St.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[St.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,j]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:st,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:St.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:k})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:k}):k}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[St.footer,E],onLayout:te?ue:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:St.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:C??[],layout:w})}):null,M]})]})})]}),Nt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:xt,children:Rt});return"modal"===P?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:je,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:St.modalRoot,children:Nt}):Nt}):Nt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveBoxStyle=exports.default=exports.Stack=exports.Spacer=exports.Row=exports.Box=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_scale=require("../../theme/scale.js"),_corners=require("../../utils/corners.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],space=(e,r)=>null==r?void 0:(0,_scale.spaceOf)(e,r),resolveBoxStyle=(e,r)=>{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveBoxStyle=exports.default=exports.Stack=exports.Spacer=exports.Row=exports.Box=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_scale=require("../../theme/scale.js"),_corners=require("../../utils/corners.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],space=(e,r)=>null==r?void 0:(0,_scale.spaceOf)(e,r),resolveBoxStyle=(e,r)=>({...null!=r.p?{padding:space(e,r.p)}:{},...null!=r.px?{paddingHorizontal:space(e,r.px)}:{},...null!=r.py?{paddingVertical:space(e,r.py)}:{},...null!=r.pt?{paddingTop:space(e,r.pt)}:{},...null!=r.pr?{paddingRight:space(e,r.pr)}:{},...null!=r.pb?{paddingBottom:space(e,r.pb)}:{},...null!=r.pl?{paddingLeft:space(e,r.pl)}:{},...null!=r.m?{margin:space(e,r.m)}:{},...null!=r.mx?{marginHorizontal:space(e,r.mx)}:{},...null!=r.my?{marginVertical:space(e,r.my)}:{},...null!=r.mt?{marginTop:space(e,r.mt)}:{},...null!=r.mr?{marginRight:space(e,r.mr)}:{},...null!=r.mb?{marginBottom:space(e,r.mb)}:{},...null!=r.ml?{marginLeft:space(e,r.ml)}:{},...null!=r.gap?{gap:space(e,r.gap)}:{},...null!=r.bg?{backgroundColor:BACKGROUND_TOKENS.includes(r.bg)?e.colors[r.bg]:r.bg}:{},...null!=r.radius?{borderRadius:(0,_scale.radiusOf)(e,r.radius),borderCurve:_corners.smoothCorners.borderCurve}:{},...r.border?{borderWidth:e.size.border,borderColor:e.colors.border}:{},...null!=r.flex?{flex:r.flex}:{},...null!=r.align?{alignItems:r.align}:{},...null!=r.justify?{justifyContent:r.justify}:{},...null!=r.direction?{flexDirection:r.direction}:{},...r.wrap?{flexWrap:"wrap"}:{}});exports.resolveBoxStyle=resolveBoxStyle;const Box=exports.Box=(0,_react.forwardRef)((e,r)=>{const l=(0,_index.useTheme)(),{p:t,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:c,mx:u,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:y,radius:_,border:S,flex:j,align:h,justify:R,direction:v,wrap:w,style:B,children:q,...C}=e,N=resolveBoxStyle(l,{p:t,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:c,mx:u,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:y,radius:_,border:S,flex:j,align:h,justify:R,direction:v,wrap:w}),k=(0,_SquircleFill.useSquircle)(null!=_&&(null!=y||Boolean(S)),N.borderRadius,C.onLayout),O=k.active?{...N,backgroundColor:"transparent",borderColor:"transparent"}:N;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,...C,onLayout:k.onLayout,style:[O,B],children:[k.active&&k.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:k.size.width,height:k.size.height,radius:N.borderRadius,fill:N.backgroundColor??"transparent",stroke:N.borderColor,strokeWidth:N.borderWidth??0}):null,q]})});Box.displayName="Box";const Stack=exports.Stack=(0,_react.forwardRef)(({gap:e="md",...r},l)=>(0,_jsxRuntime.jsx)(Box,{ref:l,direction:"column",gap:e,...r}));Stack.displayName="Stack";const Row=exports.Row=(0,_react.forwardRef)(({gap:e="sm",align:r="center",...l},t)=>(0,_jsxRuntime.jsx)(Box,{ref:t,direction:"row",gap:e,align:r,...l}));Row.displayName="Row";const Spacer=({size:e,style:r,testID:l})=>{const t=(0,_index.useTheme)();if(null!=e){const a=(0,_scale.spaceOf)(t,e);return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:l,style:[{width:a,height:a},r]})}return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:l,style:[{flex:1},r]})};exports.Spacer=Spacer,Spacer.displayName="Spacer";var _default=exports.default=Box;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Drawer=exports.DEFAULT_DRAWER_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_DRAWER_LABELS=exports.DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"},DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=exports.Drawer=(0,_react.forwardRef)((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:n="left",width:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Drawer=exports.DEFAULT_DRAWER_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_DRAWER_LABELS=exports.DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"},DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=exports.Drawer=(0,_react.forwardRef)((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:n="left",width:s,enableSwipe:o=!0,enableBackdropPress:c=!0,backdropOpacity:l=.5,haptic:u,containerStyle:d,children:_,accessibilityLabel:v,labels:p,testID:f}=e,h=(0,_index.useTheme)();(0,_assertValidValue.assertValidValue)("Drawer","side",e.side,["left","right","top","bottom"]);const m=(0,_react.useMemo)(()=>({...DEFAULT_DRAWER_LABELS,...p}),[p]),b=(0,_usePresenceMotion.usePresenceMotion)(),R=b.reduced,g=b.duration("default"),N=b.duration("fast"),w=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E="boolean"==typeof a,[S,y]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window"));(0,_react.useEffect)(()=>{const e=_reactNative.Dimensions.addEventListener("change",({window:e})=>y(e));return()=>e.remove()},[]);const x="left"===n||"right"===n,M=(0,_react.useMemo)(()=>resolveSize(s,x,S),[s,x,S]),O=(0,_react.useMemo)(()=>closedOffsetOf(n,M),[n,M]),D=(0,_reactNativeReanimated.useSharedValue)(r?0:O),L=(0,_reactNativeReanimated.useSharedValue)(r?0:O),C=(0,_reactNativeReanimated.useSharedValue)(r?1:0),[A,T]=(0,_react.useState)(r),j=(0,_reactNativeReanimated.useSharedValue)(r);(0,_react.useEffect)(()=>{A||R||(D.value=O,L.value=O)},[O,A,D,L,R]);const k=h.motion.spring.snappy,P=(0,_react.useCallback)(()=>{if(R)return D.value=0,void(C.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}));C.value=1,D.value=(0,_reactNativeReanimated.withSpring)(0,k)},[D,C,k,R,g]),V=(0,_react.useCallback)(()=>{R?C.value=(0,_reactNativeReanimated.withTiming)(0,{duration:N,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(D.value=O)}):D.value=(0,_reactNativeReanimated.withSpring)(O,k)},[D,C,O,k,R,N]),q=(0,_react.useCallback)(e=>{T(t=>t===e?t:(i?.(e),e)),j.value=e},[i,j]),F=(0,_react.useCallback)(()=>{q(!0),P()},[q,P]),I=(0,_react.useCallback)(()=>{q(!1),V()},[q,V]),U=(0,_react.useCallback)(()=>{A?I():F()},[A,F,I]);(0,_react.useImperativeHandle)(t,()=>({open:F,close:I,toggle:U}),[F,I,U]),(0,_react.useEffect)(()=>{E&&a!==A&&(a?F():I())},[a]);const B=(0,_react.useMemo)(()=>{const e=O,t=n,a=o;return{...x?{activeOffsetX:[-10,10],failOffsetY:[-15,15]}:{activeOffsetY:[-10,10],failOffsetX:[-15,15]},onActivate:()=>{"worklet";a&&(L.value=D.value)},onUpdate:t=>{"worklet";if(!a)return;const r=x?t.translationX:t.translationY,i=L.value+r,n=Math.min(0,e),s=Math.max(0,e);D.value=i<n?n+.25*(i-n):i>s?s+.25*(i-s):i},onDeactivate:r=>{"worklet";if(!a)return;const i=x?r.velocityX:r.velocityY,n=D.value;let s=!1;s="left"===t||"top"===t?i<-1e3:i>1e3;const o=Math.abs(e),c=Math.abs(n)/o;s||c>.5?((0,_reactNativeReanimated.runOnJS)(q)(!1),R?C.value=(0,_reactNativeReanimated.withTiming)(0,{duration:N,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(D.value=e)}):D.value=(0,_reactNativeReanimated.withSpring)(e,k)):((0,_reactNativeReanimated.runOnJS)(q)(!0),R?(D.value=0,C.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION})):D.value=(0,_reactNativeReanimated.withSpring)(0,k))}}},[O,L,o,x,D,C,q,n,k,R,g,N]),H=(0,_reactNativeGestureHandler.usePanGesture)(B),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>x?{opacity:C.value,transform:[{translateX:D.value}]}:{opacity:C.value,transform:[{translateY:D.value}]},[x,D,C]),G=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:(0,_reactNativeReanimated.interpolate)(D.value,[O,0],[0,l],_reactNativeReanimated.Extrapolation.CLAMP)*C.value,pointerEvents:Math.abs(D.value-O)<.5?"none":"auto"}),[D,O,l,C]),Y=(0,_react.useMemo)(()=>buildStyles(h),[h]),X=(0,_react.useCallback)(()=>{if(!c)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),I()},[c,I,u]),z=(0,_react.useMemo)(()=>sideLayoutOf(n,M,w),[n,M,w]),J=(0,_react.useRef)(r);return A&&(J.current=!0),J.current?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",testID:f,accessibilityViewIsModal:A,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[Y.backdrop,{backgroundColor:h.colors.scrim},G],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:X,accessibilityRole:"button",accessibilityLabel:m.close,disabled:!c||!A})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:H,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:v??m.drawer,style:[z,{backgroundColor:h.colors.surface,...h.shadow.modal},d,W],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:Y.content,children:_})})})]}):null});Drawer.displayName="Drawer";const closedOffsetOf=(e,t)=>{switch(e){case"left":case"top":return-t;case"right":case"bottom":return t}},sideLayoutOf=(e,t,a)=>{switch(e){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:t,paddingTop:a.top,paddingBottom:a.bottom,paddingLeft:a.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:t,paddingTop:a.top,paddingBottom:a.bottom,paddingRight:a.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:t,paddingTop:a.top,paddingLeft:a.left,paddingRight:a.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:t,paddingBottom:a.bottom,paddingLeft:a.left,paddingRight:a.right}}},resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>_reactNative.StyleSheet.create({backdrop:{..._reactNative.StyleSheet.absoluteFill},content:{flex:1}});var _default=exports.default=Drawer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveVariantColors=exports.resolveFieldTextStyle=exports.pickRepresentativeBorderColor=exports.hasFieldText=exports.fieldTextAsString=exports.default=exports.RequiredPlaceholder=exports.RequiredMark=exports.FieldMessage=exports.FieldLabel=exports.FieldErrorGlyph=exports.FieldBase=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFieldErrorScroll=require("../../hooks/useFieldErrorScroll.js"),_index=require("../../theme/index.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0},pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const r=e[t];if(r&&"transparent"!==r)return r}return e.bottom};exports.pickRepresentativeBorderColor=pickRepresentativeBorderColor;const resolveFieldTextStyle=(e,t={})=>{const{disabled:r=!1}=t;return{color:r?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:r?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:(0,_index.fontFor)(e,"normal")}};exports.resolveFieldTextStyle=resolveFieldTextStyle;const RequiredMark=()=>{const e=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:e.colors["danger-text"]},children:` ${e.settings.components.field?.requiredMarker??"*"}`})};exports.RequiredMark=RequiredMark;const RequiredPlaceholder=({text:e,color:t,fontSize:r,weightStyle:i,align:o="center",paddingTop:l,textAlign:s})=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{justifyContent:"top"===o?"flex-start":"center",paddingTop:l}],children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:r,...i,includeFontPadding:!1,textAlign:s},children:[e,(0,_jsxRuntime.jsx)(RequiredMark,{})]})});exports.RequiredPlaceholder=RequiredPlaceholder;const FieldErrorGlyph=({size:e,color:t})=>{const r=(0,_index.useTheme)().settings.icons.error??_defaultIcons.defaultIcons.error;return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r({size:e,color:t})})};exports.FieldErrorGlyph=FieldErrorGlyph;const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;exports.hasFieldText=hasFieldText;const fieldTextAsString=e=>"string"==typeof e?e:void 0;exports.fieldTextAsString=fieldTextAsString;const FieldLabel=({children:e,size:t="md",required:r=!1,help:i,color:o,style:l})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveFieldSize)(s,t),a=hasFieldText(i),d=(0,_textInk.useTextInk)(l,n["label-text"],o??s.colors["field-label"]),c=(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[familyStyles.label,{color:o??s.colors["field-label"],fontSize:n["label-text"],...(0,_index.fontFor)(s,"semibold"),marginBottom:a?s.space.none:n["label-gap"]},a?familyStyles.labelShrink:null,l],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:d,children:e}),r?(0,_jsxRuntime.jsx)(RequiredMark,{}):null]});return a?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:i})]}):c};exports.FieldLabel=FieldLabel;const FieldMessage=({text:e,error:t=!1,size:r="md",style:i})=>{const o=(0,_index.useTheme)(),l=(0,_index.resolveFieldSize)(o,r),s=t?o.colors["field-message"]:o.colors["text-muted"],n=(0,_textInk.useTextInk)(i,l["message-text"],s);return hasFieldText(e)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:o.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?(0,_jsxRuntime.jsx)(FieldErrorGlyph,{size:l["message-text"],color:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...(0,_index.fontFor)(o,"normal")},i],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:n,children:e})})]}):null};exports.FieldMessage=FieldMessage;const familyStyles=_reactNative.StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}}),resolveVariantColors=(e,t)=>{let r,i,o,l,s;"outline"===t?(r=e.colors["field-bg"],i=e.colors["field-bg-focus"],o=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(r="transparent",i=void 0,o="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(r=e.colors["field-bg"],i=void 0,o=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),a=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:r,backgroundIdleFilled:r,backgroundFocused:i,backgroundError:void 0,backgroundDisabled:o,borderIdle:n,borderFocused:a,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(a)}};exports.resolveVariantColors=resolveVariantColors;const FieldBase=e=>{(0,_assertValidValue.assertValidValue)("FieldBase","variant",e.variant,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:r,focused:i=!1,disabled:o=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:a=!1,trailing:d,slotAlign:c="center",slotLineHeight:u,topNotch:x,children:b,onPress:p,pressFeedback:m=!0,minHeight:g,maxHeight:h,width:f,height:_,paddingHorizontal:y,paddingLeft:R,paddingRight:v,paddingVertical:j,radius:S,borderTopLeftRadius:F,borderTopRightRadius:k,borderBottomLeftRadius:T,borderBottomRightRadius:C,borderWidth:V,borderTopWidth:I,borderRightWidth:q,borderBottomWidth:w,borderLeftWidth:B,gap:L,flushBottom:N=!1,style:z,testID:E,accessibilityRole:M,accessibilityLabel:W,accessibilityState:D,accessibilityHint:P}=e,A=(0,_index.useTheme)(),H=(0,_useFieldErrorScroll.useFieldErrorAnchor)(l),G=(0,_react.useMemo)(()=>buildStyles(),[]),O=r??A.settings.components.field?.defaultVariant??"outline",$=(0,_index.resolveFieldSize)(A,t),J=(0,_react.useMemo)(()=>resolveVariantColors(A,O),[A,O]),K=l?2:i?1:0,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(K)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Q,{toValue:K,duration:A.motion.duration.fast,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[K,Q,A.motion.duration.fast,A.motion.ease["in-out"]]);const U=[0,1,2],X=s?J.backgroundIdleFilled:J.backgroundIdleEmpty,Y=J.backgroundFocused??X,Z=J.backgroundError??X,ee=o?J.backgroundDisabled:Q.interpolate({inputRange:U,outputRange:[X,Y,Z]}),te=J.borderIdle,re=J.borderFocused,ie=J.borderError,oe={top:I,right:q,bottom:w,left:B},le={top:oe.top??V??J.borderWidth.top,right:oe.right??V??J.borderWidth.right,bottom:oe.bottom??V??J.borderWidth.bottom,left:oe.left??V??J.borderWidth.left},se={minHeight:_??g??$["min-height"],maxHeight:h,paddingHorizontal:y??$["padding-x"],paddingVertical:j??$["padding-y"],paddingLeft:R??y??$["padding-x"],paddingRight:v??y??$["padding-x"],backgroundColor:ee,columnGap:L??A.space.md,alignItems:"top"===c?"flex-start":"center"},ne="underline"===O,ae=ne?A.radius.none:S?A.radius[S]:$.radius,de=ne?{tl:A.radius.none,tr:A.radius.none,bl:A.radius.none,br:A.radius.none}:{tl:F??ae,tr:k??ae,bl:T??ae,br:C??ae};se.borderTopLeftRadius=de.tl,se.borderTopRightRadius=de.tr,se.borderBottomLeftRadius=de.bl,se.borderBottomRightRadius=de.br,se.borderCurve=_corners.smoothCorners.borderCurve,se.borderTopWidth=le.top,se.borderRightWidth=le.right,se.borderBottomWidth=le.bottom,se.borderLeftWidth=le.left;const sideColor=e=>Q.interpolate({inputRange:U,outputRange:[te[e],re[e],ie[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,ce=!ne&&de.tl===de.tr&&de.tl===de.bl&&de.tl===de.br&&sameOnEverySide(le)&&sameOnEverySide(te)&&sameOnEverySide(re)&&sameOnEverySide(ie)&&sameOnEverySide(J.borderDisabled),ue=(0,_SquircleFill.useSquircle)(ce,de.tl);if(ue.active)se.backgroundColor="transparent",se.borderTopColor="transparent",se.borderRightColor="transparent",se.borderBottomColor="transparent",se.borderLeftColor="transparent";else if(o){const e=J.borderDisabled;se.borderTopColor=e.top,se.borderRightColor=e.right,se.borderBottomColor=e.bottom,se.borderLeftColor=e.left}else se.borderTopColor=sideColor("top"),se.borderRightColor=sideColor("right"),se.borderBottomColor=sideColor("bottom"),se.borderLeftColor=sideColor("left");const xe=o?J.borderDisabled.top:sideColor("top"),be=(0,_react.useRef)(K);be.current=K,(0,_react.useEffect)(()=>{Q.setValue(be.current)},[J,Q]);const pe=N?{marginBottom:A.space.none}:void 0;void 0!==f&&(se.width=f),void 0!==_&&(se.height=_);const me={disabled:o,...D},ge="top"===c,he=ge?{alignSelf:"flex-start",marginTop:Math.max(0,((u??$.icon)-$.icon)/2)}:null,fe=_??g??$["min-height"],ye=(()=>{if(!x)return 0;const e=Math.min(de.tl,fe/2),t=x.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),Re=x&&le.top>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-le.top,left:x.left-le.left,width:x.width,height:le.top+ye,backgroundColor:ee}}):null,renderInner=e=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ue.active&&ue.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ue.size.width,height:ue.size.height,radius:de.tl,fill:e&&!o?A.colors["surface-pressed"]:ee,stroke:xe,strokeWidth:le.top}):null,Re,null!=n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,he],children:n}):null,null!=n&&a?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[G.divider,he,{height:$.icon,backgroundColor:A.colors["field-border"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.content,ge?G.contentTop:null],children:b}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,he],children:d}):null]}),ve=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ue.onLayout,style:[G.box,se,p?null:pe,z],accessibilityRole:M,accessibilityLabel:W,accessibilityHint:P,accessibilityState:me,...(0,_ariaState.ariaFromState)(me),testID:E,children:renderInner(!1)});return p&&!m?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,accessible:!1,style:pe,children:ve}):p?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,style:pe,accessibilityRole:M??"button",accessibilityLabel:W,accessibilityHint:P,accessibilityState:me,...(0,_ariaState.ariaFromState)(me),testID:E,children:({pressed:e})=>(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ue.onLayout,style:[G.box,se,!e||o||ue.active?null:{backgroundColor:A.colors["surface-pressed"]},z],children:renderInner(e)})}):ve};exports.FieldBase=FieldBase,FieldBase.displayName="FieldBase";const buildStyles=()=>_reactNative.StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});var _default=exports.default=FieldBase;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveVariantColors=exports.resolveFieldTextStyle=exports.pickRepresentativeBorderColor=exports.hasFieldText=exports.fieldTextAsString=exports.default=exports.RequiredPlaceholder=exports.RequiredMark=exports.FieldMessage=exports.FieldLabel=exports.FieldErrorGlyph=exports.FieldBase=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFieldErrorScroll=require("../../hooks/useFieldErrorScroll.js"),_index=require("../../theme/index.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0},pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const r=e[t];if(r&&"transparent"!==r)return r}return e.bottom};exports.pickRepresentativeBorderColor=pickRepresentativeBorderColor;const resolveFieldTextStyle=(e,t={})=>{const{disabled:r=!1}=t;return{color:r?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:r?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:(0,_index.fontFor)(e,"normal")}};exports.resolveFieldTextStyle=resolveFieldTextStyle;const RequiredMark=()=>{const e=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:e.colors["danger-text"]},children:` ${e.settings.components.field?.requiredMarker??"*"}`})};exports.RequiredMark=RequiredMark;const RequiredPlaceholder=({text:e,color:t,fontSize:r,weightStyle:i,align:o="center",paddingTop:l,textAlign:s})=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{justifyContent:"top"===o?"flex-start":"center",paddingTop:l}],children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:r,...i,includeFontPadding:!1,textAlign:s},children:[e,(0,_jsxRuntime.jsx)(RequiredMark,{})]})});exports.RequiredPlaceholder=RequiredPlaceholder;const FieldErrorGlyph=({size:e,color:t})=>{const r=(0,_index.useTheme)().settings.icons.error??_defaultIcons.defaultIcons.error;return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r({size:e,color:t})})};exports.FieldErrorGlyph=FieldErrorGlyph;const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;exports.hasFieldText=hasFieldText;const fieldTextAsString=e=>"string"==typeof e?e:void 0;exports.fieldTextAsString=fieldTextAsString;const FieldLabel=({children:e,size:t="md",required:r=!1,help:i,color:o,style:l})=>{const s=(0,_index.useTheme)(),a=(0,_index.resolveFieldSize)(s,t),n=hasFieldText(i),d=(0,_textInk.useTextInk)(l,a["label-text"],o??s.colors["field-label"]),c=(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[familyStyles.label,{color:o??s.colors["field-label"],fontSize:a["label-text"],...(0,_index.fontFor)(s,"semibold"),marginBottom:n?s.space.none:a["label-gap"]},n?familyStyles.labelShrink:null,l],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:d,children:e}),r?(0,_jsxRuntime.jsx)(RequiredMark,{}):null]});return n?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.labelRow,{marginBottom:a["label-gap"]}],children:[c,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:i})]}):c};exports.FieldLabel=FieldLabel;const FieldMessage=({text:e,error:t=!1,size:r="md",style:i})=>{const o=(0,_index.useTheme)(),l=(0,_index.resolveFieldSize)(o,r),s=t?o.colors["field-message"]:o.colors["text-muted"],a=(0,_textInk.useTextInk)(i,l["message-text"],s);return hasFieldText(e)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:o.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?(0,_jsxRuntime.jsx)(FieldErrorGlyph,{size:l["message-text"],color:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...(0,_index.fontFor)(o,"normal")},i],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:a,children:e})})]}):null};exports.FieldMessage=FieldMessage;const familyStyles=_reactNative.StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}}),resolveVariantColors=(e,t)=>{let r,i,o,l,s;"outline"===t?(r=e.colors["field-bg"],i=e.colors["field-bg-focus"],o=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(r="transparent",i=void 0,o="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(r=e.colors["field-bg"],i=void 0,o=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},a=expandColorSides(l),n=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:r,backgroundIdleFilled:r,backgroundFocused:i,backgroundError:void 0,backgroundDisabled:o,borderIdle:a,borderFocused:n,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(n)}};exports.resolveVariantColors=resolveVariantColors;const FieldBase=e=>{(0,_assertValidValue.assertValidValue)("FieldBase","variant",e.variant,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:r,focused:i=!1,disabled:o=!1,error:l=!1,filled:s=!1,leading:a,leadingDivider:n=!1,trailing:d,slotAlign:c="center",slotLineHeight:u,topNotch:b,children:x,onPress:p,pressFeedback:m=!0,minHeight:g,maxHeight:h,width:f,height:_,paddingHorizontal:y,paddingLeft:v,paddingRight:R,paddingVertical:j,radius:S,borderTopLeftRadius:F,borderTopRightRadius:k,borderBottomLeftRadius:T,borderBottomRightRadius:C,borderWidth:V,borderTopWidth:I,borderRightWidth:q,borderBottomWidth:w,borderLeftWidth:B,gap:L,flushBottom:N=!1,style:z,testID:E,accessibilityRole:D,accessibilityLabel:M,accessibilityState:W,accessibilityHint:P}=e,A=(0,_index.useTheme)(),H=(0,_useFieldErrorScroll.useFieldErrorAnchor)(l),G=(0,_react.useMemo)(()=>buildStyles(),[]),O=r??A.settings.components.field?.defaultVariant??"outline",$=(0,_index.resolveFieldSize)(A,t),J=(0,_react.useMemo)(()=>resolveVariantColors(A,O),[A,O]),K=l?2:i?1:0,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(K)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Q,{toValue:K,duration:A.motion.duration.fast,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[K,Q,A.motion.duration.fast,A.motion.ease["in-out"]]);const U=[0,1,2],X=s?J.backgroundIdleFilled:J.backgroundIdleEmpty,Y=J.backgroundFocused??X,Z=J.backgroundError??X,ee=o?J.backgroundDisabled:Q.interpolate({inputRange:U,outputRange:[X,Y,Z]}),te=J.borderIdle,re=J.borderFocused,ie=J.borderError,oe={top:I,right:q,bottom:w,left:B},le={top:oe.top??V??J.borderWidth.top,right:oe.right??V??J.borderWidth.right,bottom:oe.bottom??V??J.borderWidth.bottom,left:oe.left??V??J.borderWidth.left},se="underline"===O,ae=se?A.radius.none:S?A.radius[S]:$.radius,ne=se?{tl:A.radius.none,tr:A.radius.none,bl:A.radius.none,br:A.radius.none}:{tl:F??ae,tr:k??ae,bl:T??ae,br:C??ae},sideColor=e=>Q.interpolate({inputRange:U,outputRange:[te[e],re[e],ie[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,de=!se&&ne.tl===ne.tr&&ne.tl===ne.bl&&ne.tl===ne.br&&sameOnEverySide(le)&&sameOnEverySide(te)&&sameOnEverySide(re)&&sameOnEverySide(ie)&&sameOnEverySide(J.borderDisabled),ce=(0,_SquircleFill.useSquircle)(de,ne.tl),ue=ce.active?{borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent",borderLeftColor:"transparent"}:o?{borderTopColor:J.borderDisabled.top,borderRightColor:J.borderDisabled.right,borderBottomColor:J.borderDisabled.bottom,borderLeftColor:J.borderDisabled.left}:{borderTopColor:sideColor("top"),borderRightColor:sideColor("right"),borderBottomColor:sideColor("bottom"),borderLeftColor:sideColor("left")},be=o?J.borderDisabled.top:sideColor("top"),xe={minHeight:_??g??$["min-height"],maxHeight:h,paddingHorizontal:y??$["padding-x"],paddingVertical:j??$["padding-y"],paddingLeft:v??y??$["padding-x"],paddingRight:R??y??$["padding-x"],backgroundColor:ce.active?"transparent":ee,columnGap:L??A.space.md,alignItems:"top"===c?"flex-start":"center",borderTopLeftRadius:ne.tl,borderTopRightRadius:ne.tr,borderBottomLeftRadius:ne.bl,borderBottomRightRadius:ne.br,borderCurve:_corners.smoothCorners.borderCurve,borderTopWidth:le.top,borderRightWidth:le.right,borderBottomWidth:le.bottom,borderLeftWidth:le.left,...ue,...void 0!==f?{width:f}:null,...void 0!==_?{height:_}:null},pe=(0,_react.useRef)(K);pe.current=K,(0,_react.useEffect)(()=>{Q.setValue(pe.current)},[J,Q]);const me=N?{marginBottom:A.space.none}:void 0,ge={disabled:o,...W},he="top"===c,fe=he?{alignSelf:"flex-start",marginTop:Math.max(0,((u??$.icon)-$.icon)/2)}:null,ye=_??g??$["min-height"],ve=(()=>{if(!b)return 0;const e=Math.min(ne.tl,ye/2),t=b.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),Re=b&&le.top>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-le.top,left:b.left-le.left,width:b.width,height:le.top+ve,backgroundColor:ee}}):null,renderInner=e=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ce.active&&ce.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ce.size.width,height:ce.size.height,radius:ne.tl,fill:e&&!o?A.colors["surface-pressed"]:ee,stroke:be,strokeWidth:le.top}):null,Re,null!=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:a}):null,null!=a&&n?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[G.divider,fe,{height:$.icon,backgroundColor:A.colors["field-border"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.content,he?G.contentTop:null],children:x}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:d}):null]}),je=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,xe,p?null:me,z],accessibilityRole:D,accessibilityLabel:M,accessibilityHint:P,accessibilityState:ge,...(0,_ariaState.ariaFromState)(ge),testID:E,children:renderInner(!1)});return p&&!m?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,accessible:!1,style:me,children:je}):p?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,style:me,accessibilityRole:D??"button",accessibilityLabel:M,accessibilityHint:P,accessibilityState:ge,...(0,_ariaState.ariaFromState)(ge),testID:E,children:({pressed:e})=>(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,xe,!e||o||ce.active?null:{backgroundColor:A.colors["surface-pressed"]},z],children:renderInner(e)})}):je};exports.FieldBase=FieldBase,FieldBase.displayName="FieldBase";const buildStyles=()=>_reactNative.StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});var _default=exports.default=FieldBase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFloatingLabel=exports.FLOATED_LABEL_SCALE=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_textInk=require("../Text/textInk.js"),_FieldBase=require("./FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");const FLOATED_LABEL_SCALE=exports.FLOATED_LABEL_SCALE=.85,FLOATED_LABEL_LIFT=1,useFloatingLabel=({label:e,enabled:t,floated:i,required:n=!1,variant:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFloatingLabel=exports.FLOATED_LABEL_SCALE=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_textInk=require("../Text/textInk.js"),_FieldBase=require("./FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");const FLOATED_LABEL_SCALE=exports.FLOATED_LABEL_SCALE=.85,FLOATED_LABEL_LIFT=1,useFloatingLabel=({label:e,enabled:t,floated:i,required:n=!1,variant:r,sizeTokens:a,leadingOffset:o,trailingOffset:s=0,textAlign:l="left",paddingLeft:u,lineHeight:d,restNudge:c=0,floatTrim:_=0,color:x,style:g})=>{const h=(0,_index.useTheme)(),v=(0,_react.useRef)((0,_index.createAnimatedValue)(i?1:0)).current,L=(0,_react.useRef)((0,_index.createAnimatedValue)(i?1:0)).current,f="outline"===r,[p,m]=(0,_react.useState)(null);return(0,_react.useEffect)(()=>{const e=i?1:0,timing=(t,i)=>_reactNative.Animated.timing(t,{toValue:e,duration:h.motion.duration.fast,easing:_reactNative.Easing.bezier(...h.motion.ease["in-out"]),useNativeDriver:i});f||L.setValue(e);const t=f?_reactNative.Animated.parallel([timing(v,_nativeDriver.nativeDriver),timing(L,!1)]):timing(v,_nativeDriver.nativeDriver);return t.start(),()=>t.stop()},[i,f,v,L,h.motion.duration.fast,h.motion.ease["in-out"]]),(0,_react.useMemo)(()=>{if(!t||!(0,_FieldBase.hasFieldText)(e))return{node:null,topNotch:void 0};const i=d??p?.height??a.text,r=null!=d?a["padding-y"]+c:Math.max(0,(a["min-height"]-i)/2),A=-(r+i/2+1-_),E=v.interpolate({inputRange:[0,1],outputRange:[0,A]}),F=v.interpolate({inputRange:[0,1],outputRange:[1,FLOATED_LABEL_SCALE]}),R=-o,S=v.interpolate({inputRange:[0,1],outputRange:[0,R]}),T="right"===l?{right:a["padding-x"]+s,transformOrigin:"right center"}:"center"===l?{alignSelf:"center",transformOrigin:"center"}:{left:u+o,transformOrigin:"left center"},j=h.space.xs,D=p?p.width*FLOATED_LABEL_SCALE:0,O=p?"right"===l?p.width-D:"center"===l?(p.width-D)/2:0:0,b=f&&p?{left:p.x+R+O-j,width:L.interpolate({inputRange:[0,1],outputRange:[0,D+2*j]})}:void 0,N=_reactNative.StyleSheet.flatten(g),y={fontSize:N?.fontSize??a.text,color:N?.color??x};return{node:(0,_jsxRuntime.jsxs)(_reactNative.Animated.Text,{pointerEvents:"none",onLayout:e=>{const{x:t,width:i,height:n}=e.nativeEvent.layout;m(e=>e&&e.x===t&&e.width===i&&e.height===n?e:{x:t,width:i,height:n})},style:[styles.label,T,{top:r,color:x,fontSize:a.text,lineHeight:d,...(0,_index.fontFor)(h,"medium"),transform:[{translateX:S},{translateY:E},{scale:F}]},g],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:y,children:e}),n?(0,_jsxRuntime.jsx)(_FieldBase.RequiredMark,{}):null]}),topNotch:b}},[t,e,n,f,a,o,s,l,u,d,c,_,x,g,v,L,p,h])};exports.useFloatingLabel=useFloatingLabel;const styles=_reactNative.StyleSheet.create({label:{position:"absolute",zIndex:1}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFileViewerZoom=exports.ZOOM_REST=void 0;var _react=require("react"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=require("react-native-reanimated");const DOUBLE_TAP_ZOOM=2.5,ZOOM_REST=exports.ZOOM_REST=1.01,clamp=(e,a,t)=>{"worklet";return Math.min(Math.max(e,a),t)},panLimit=(e,a)=>{"worklet";return e*(a-1)/2},useFileViewerZoom=({zoomEnabled:e,maxZoom:a,viewportWidth:t,viewportHeight:i,maxScroll:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFileViewerZoom=exports.ZOOM_REST=void 0;var _react=require("react"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=require("react-native-reanimated");const DOUBLE_TAP_ZOOM=2.5,ZOOM_REST=exports.ZOOM_REST=1.01,clamp=(e,a,t)=>{"worklet";return Math.min(Math.max(e,a),t)},panLimit=(e,a)=>{"worklet";return e*(a-1)/2},useFileViewerZoom=({zoomEnabled:e,maxZoom:a,viewportWidth:t,viewportHeight:i,maxScroll:u})=>{const[l,r]=(0,_react.useState)(1),v=(0,_reactNativeReanimated.useAnimatedRef)(),n=(0,_reactNativeReanimated.useScrollViewOffset)(v),c=(0,_reactNativeReanimated.useSharedValue)(0),m=(0,_reactNativeReanimated.useSharedValue)(0),s=(0,_reactNativeReanimated.useSharedValue)(0),o=(0,_reactNativeReanimated.useSharedValue)(0),d=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(1),N=(0,_reactNativeReanimated.useSharedValue)(0),R=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),w=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{s.value=t,o.value=i,m.value=u},[t,i,u,s,o,m]);const S=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withTiming)(1),N.value=(0,_reactNativeReanimated.withTiming)(0),R.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,r(1)},[d,_,N,R,h,w]);(0,_react.useEffect)(()=>{e||S()},[e,S]);const p=(0,_react.useCallback)(e=>r(e),[]),T=(0,_reactNativeGestureHandler.useNativeGesture)(),O=Math.max(1,a),M=Math.min(2.5,O),f=(0,_react.useMemo)(()=>({enabled:e,simultaneousWith:T,onActivate:()=>{"worklet";_.value=d.value,h.value=N.value,w.value=R.value},onUpdate:e=>{"worklet";const a=clamp(_.value*e.scale,1,O),t=e.focalX-s.value/2,i=e.focalY-o.value/2,u=a/_.value,l=panLimit(s.value,a),r=panLimit(o.value,a);N.value=clamp(t-(t-h.value)*u,-l,l),R.value=clamp(i-(i-w.value)*u,-r,r),d.value=a},onDeactivate:()=>{"worklet";if(d.value<=ZOOM_REST)return d.value=(0,_reactNativeReanimated.withTiming)(1),N.value=(0,_reactNativeReanimated.withTiming)(0),R.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,void(0,_reactNativeReanimated.runOnJS)(p)(1);_.value=d.value,h.value=N.value,w.value=R.value,(0,_reactNativeReanimated.runOnJS)(p)(d.value)}}),[e,O,p,T,d,_,N,R,h,w,s,o]),g=(0,_react.useMemo)(()=>({enabled:e,simultaneousWith:T,minPointers:1,maxPointers:1,manualActivation:!0,onTouchesMove:e=>{"worklet";d.value>ZOOM_REST?_reactNativeGestureHandler.GestureStateManager.activate(e.handlerTag):_reactNativeGestureHandler.GestureStateManager.fail(e.handlerTag)},onActivate:()=>{"worklet";h.value=N.value,w.value=R.value,c.value=n.value},onUpdate:e=>{"worklet";const a=d.value,t=panLimit(s.value,a),i=panLimit(o.value,a);N.value=clamp(h.value+e.translationX,-t,t);const u=w.value+e.translationY,l=clamp(u,-i,i),r=u-l;if(0!==r){const e=clamp(c.value-r/a,0,m.value);e!==c.value&&(c.value=e,(0,_reactNativeReanimated.scrollTo)(v,0,e,!1)),w.value-=r}R.value=l},onDeactivate:()=>{"worklet";h.value=N.value,w.value=R.value}}),[e,T,n,c,m,s,o,d,N,R,h,w,v]),G=(0,_react.useMemo)(()=>({enabled:e,simultaneousWith:T,numberOfTaps:2,maxDistance:10,onDeactivate:e=>{"worklet";if(d.value>ZOOM_REST)return d.value=(0,_reactNativeReanimated.withTiming)(1),N.value=(0,_reactNativeReanimated.withTiming)(0),R.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,void(0,_reactNativeReanimated.runOnJS)(p)(1);if(M<=ZOOM_REST)return;const a=e.x-s.value/2,t=e.y-o.value/2,i=panLimit(s.value,M),u=panLimit(o.value,M),l=clamp(-a*(M-1),-i,i),r=clamp(-t*(M-1),-u,u);d.value=(0,_reactNativeReanimated.withTiming)(M),N.value=(0,_reactNativeReanimated.withTiming)(l),R.value=(0,_reactNativeReanimated.withTiming)(r),_.value=M,h.value=l,w.value=r,(0,_reactNativeReanimated.runOnJS)(p)(M)}}),[e,T,M,p,d,_,N,R,h,w,s,o]),V=(0,_reactNativeGestureHandler.usePinchGesture)(f),Z=(0,_reactNativeGestureHandler.usePanGesture)(g),k=(0,_reactNativeGestureHandler.useTapGesture)(G),x=(0,_reactNativeGestureHandler.useSimultaneousGestures)(V,Z,k),E=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:N.value},{translateY:R.value},{scale:d.value}]}),[N,R,d]);return{scrollRef:v,scrollGesture:T,zoomGesture:x,zoomStyle:E,zoomLevel:l,resetZoom:S}};exports.useFileViewerZoom=useFileViewerZoom;
|