@webority/mobile-ui 0.168.0 → 0.169.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 +10 -10
- package/dist/canvas-kit/manifest.json +85 -1
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/Composer/Composer.js +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/commonjs/components/DecimalInput/DecimalInput.js +1 -1
- package/lib/commonjs/components/IdleTimeoutDialog/IdleTimeoutDialog.js +1 -0
- package/lib/commonjs/components/IdleTimeoutDialog/index.js +1 -0
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
- package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/commonjs/components/PagedList/PagedList.js +1 -0
- package/lib/commonjs/components/PagedList/index.js +1 -0
- package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
- package/lib/commonjs/components/Screen/Screen.js +1 -1
- package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
- package/lib/commonjs/components/SliderField/SliderField.js +1 -1
- package/lib/commonjs/components/TagInput/TagInput.js +1 -1
- package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
- package/lib/commonjs/components/index.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/text/phone/idleTimeoutDialog.g.js +1 -0
- package/lib/commonjs/text/phone/index.g.js +1 -1
- package/lib/module/components/Composer/Composer.js +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +1 -1
- package/lib/module/components/DecimalInput/DecimalInput.js +1 -1
- package/lib/module/components/IdleTimeoutDialog/IdleTimeoutDialog.js +1 -0
- package/lib/module/components/IdleTimeoutDialog/index.js +1 -0
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/NumberInput/NumberInput.js +1 -1
- package/lib/module/components/OTPInput/OTPInput.js +1 -1
- package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/module/components/PagedList/PagedList.js +1 -0
- package/lib/module/components/PagedList/index.js +1 -0
- package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
- package/lib/module/components/Screen/Screen.js +1 -1
- package/lib/module/components/SearchBar/SearchBar.js +1 -1
- package/lib/module/components/SliderField/SliderField.js +1 -1
- package/lib/module/components/TagInput/TagInput.js +1 -1
- package/lib/module/components/WheelPicker/Wheel.js +1 -1
- package/lib/module/components/index.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/text/phone/idleTimeoutDialog.g.js +1 -0
- package/lib/module/text/phone/index.g.js +1 -1
- package/lib/text/en.json +6 -0
- package/lib/typescript/commonjs/components/IdleTimeoutDialog/IdleTimeoutDialog.d.ts +14 -0
- package/lib/typescript/commonjs/components/IdleTimeoutDialog/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/PagedList/PagedList.d.ts +34 -0
- package/lib/typescript/commonjs/components/PagedList/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/text/phone/catalogue.g.d.ts +2 -0
- package/lib/typescript/commonjs/text/phone/idleTimeoutDialog.g.d.ts +8 -0
- package/lib/typescript/commonjs/text/phone/index.g.d.ts +1 -0
- package/lib/typescript/module/components/IdleTimeoutDialog/IdleTimeoutDialog.d.ts +14 -0
- package/lib/typescript/module/components/IdleTimeoutDialog/index.d.ts +3 -0
- package/lib/typescript/module/components/PagedList/PagedList.d.ts +34 -0
- package/lib/typescript/module/components/PagedList/index.d.ts +3 -0
- package/lib/typescript/module/components/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/text/phone/catalogue.g.d.ts +2 -0
- package/lib/typescript/module/text/phone/idleTimeoutDialog.g.d.ts +8 -0
- package/lib/typescript/module/text/phone/index.g.d.ts +1 -0
- package/package.json +9 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _amountSliderG=require("./amountSlider.g.js");Object.keys(_amountSliderG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_amountSliderG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _amountSliderG[e]}}))});var _asyncBlockG=require("./asyncBlock.g.js");Object.keys(_asyncBlockG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_asyncBlockG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _asyncBlockG[e]}}))});var _authedImageG=require("./authedImage.g.js");Object.keys(_authedImageG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_authedImageG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _authedImageG[e]}}))});var _autocompleteG=require("./autocomplete.g.js");Object.keys(_autocompleteG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_autocompleteG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _autocompleteG[e]}}))});var _avatarG=require("./avatar.g.js");Object.keys(_avatarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_avatarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _avatarG[e]}}))});var _badgeG=require("./badge.g.js");Object.keys(_badgeG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_badgeG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _badgeG[e]}}))});var _bannerG=require("./banner.g.js");Object.keys(_bannerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_bannerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _bannerG[e]}}))});var _barG=require("./bar.g.js");Object.keys(_barG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_barG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _barG[e]}}))});var _barChartG=require("./barChart.g.js");Object.keys(_barChartG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_barChartG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _barChartG[e]}}))});var _bottomNavigationG=require("./bottomNavigation.g.js");Object.keys(_bottomNavigationG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_bottomNavigationG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _bottomNavigationG[e]}}))});var _bottomSheetG=require("./bottomSheet.g.js");Object.keys(_bottomSheetG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_bottomSheetG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _bottomSheetG[e]}}))});var _buttonG=require("./button.g.js");Object.keys(_buttonG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_buttonG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _buttonG[e]}}))});var _calendarG=require("./calendar.g.js");Object.keys(_calendarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_calendarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _calendarG[e]}}))});var _cardG=require("./card.g.js");Object.keys(_cardG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_cardG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _cardG[e]}}))});var _carouselG=require("./carousel.g.js");Object.keys(_carouselG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_carouselG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _carouselG[e]}}))});var _chipG=require("./chip.g.js");Object.keys(_chipG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_chipG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _chipG[e]}}))});var _composerG=require("./composer.g.js");Object.keys(_composerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_composerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _composerG[e]}}))});var _confirmG=require("./confirm.g.js");Object.keys(_confirmG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_confirmG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _confirmG[e]}}))});var _datePickerG=require("./datePicker.g.js");Object.keys(_datePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_datePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _datePickerG[e]}}))});var _dateRangePickerG=require("./dateRangePicker.g.js");Object.keys(_dateRangePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_dateRangePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _dateRangePickerG[e]}}))});var _dateSeparatorG=require("./dateSeparator.g.js");Object.keys(_dateSeparatorG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_dateSeparatorG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _dateSeparatorG[e]}}))});var _decimalInputG=require("./decimalInput.g.js");Object.keys(_decimalInputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_decimalInputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _decimalInputG[e]}}))});var _discardGuardG=require("./discardGuard.g.js");Object.keys(_discardGuardG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_discardGuardG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _discardGuardG[e]}}))});var _drawerG=require("./drawer.g.js");Object.keys(_drawerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_drawerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _drawerG[e]}}))});var _errorBoundaryG=require("./errorBoundary.g.js");Object.keys(_errorBoundaryG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_errorBoundaryG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _errorBoundaryG[e]}}))});var _filePickerG=require("./filePicker.g.js");Object.keys(_filePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_filePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _filePickerG[e]}}))});var _floatingActionButtonG=require("./floatingActionButton.g.js");Object.keys(_floatingActionButtonG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_floatingActionButtonG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _floatingActionButtonG[e]}}))});var _forceUpdateDialogG=require("./forceUpdateDialog.g.js");Object.keys(_forceUpdateDialogG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_forceUpdateDialogG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _forceUpdateDialogG[e]}}))});var _formFieldG=require("./formField.g.js");Object.keys(_formFieldG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_formFieldG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _formFieldG[e]}}))});var _imageGalleryG=require("./imageGallery.g.js");Object.keys(_imageGalleryG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_imageGalleryG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _imageGalleryG[e]}}))});var _inlineSelectG=require("./inlineSelect.g.js");Object.keys(_inlineSelectG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_inlineSelectG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _inlineSelectG[e]}}))});var _inputG=require("./input.g.js");Object.keys(_inputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_inputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _inputG[e]}}))});var _keyboardToolbarG=require("./keyboardToolbar.g.js");Object.keys(_keyboardToolbarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_keyboardToolbarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _keyboardToolbarG[e]}}))});var _loaderOverlayG=require("./loaderOverlay.g.js");Object.keys(_loaderOverlayG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_loaderOverlayG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _loaderOverlayG[e]}}))});var _lockOverlayG=require("./lockOverlay.g.js");Object.keys(_lockOverlayG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_lockOverlayG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _lockOverlayG[e]}}))});var _menuG=require("./menu.g.js");Object.keys(_menuG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_menuG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _menuG[e]}}))});var _messageBubbleG=require("./messageBubble.g.js");Object.keys(_messageBubbleG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_messageBubbleG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _messageBubbleG[e]}}))});var _messageListG=require("./messageList.g.js");Object.keys(_messageListG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_messageListG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _messageListG[e]}}))});var _modalG=require("./modal.g.js");Object.keys(_modalG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_modalG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _modalG[e]}}))});var _networkStatusBannerG=require("./networkStatusBanner.g.js");Object.keys(_networkStatusBannerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_networkStatusBannerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _networkStatusBannerG[e]}}))});var _nonModalBottomSheetG=require("./nonModalBottomSheet.g.js");Object.keys(_nonModalBottomSheetG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_nonModalBottomSheetG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _nonModalBottomSheetG[e]}}))});var _numberInputG=require("./numberInput.g.js");Object.keys(_numberInputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_numberInputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _numberInputG[e]}}))});var _onboardingPagerG=require("./onboardingPager.g.js");Object.keys(_onboardingPagerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_onboardingPagerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _onboardingPagerG[e]}}))});var _optionSheetG=require("./optionSheet.g.js");Object.keys(_optionSheetG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_optionSheetG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _optionSheetG[e]}}))});var _otpInputG=require("./otpInput.g.js");Object.keys(_otpInputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_otpInputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _otpInputG[e]}}))});var _pagedListFooterG=require("./pagedListFooter.g.js");Object.keys(_pagedListFooterG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_pagedListFooterG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _pagedListFooterG[e]}}))});var _permissionPromptG=require("./permissionPrompt.g.js");Object.keys(_permissionPromptG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_permissionPromptG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _permissionPromptG[e]}}))});var _phoneNumberInputG=require("./phoneNumberInput.g.js");Object.keys(_phoneNumberInputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_phoneNumberInputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _phoneNumberInputG[e]}}))});var _pickerTriggerG=require("./pickerTrigger.g.js");Object.keys(_pickerTriggerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_pickerTriggerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _pickerTriggerG[e]}}))});var _profileCompletionG=require("./profileCompletion.g.js");Object.keys(_profileCompletionG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_profileCompletionG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _profileCompletionG[e]}}))});var _profilePickerG=require("./profilePicker.g.js");Object.keys(_profilePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_profilePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _profilePickerG[e]}}))});var _progressBarG=require("./progressBar.g.js");Object.keys(_progressBarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_progressBarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _progressBarG[e]}}))});var _ratingG=require("./rating.g.js");Object.keys(_ratingG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_ratingG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _ratingG[e]}}))});var _refreshControlG=require("./refreshControl.g.js");Object.keys(_refreshControlG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_refreshControlG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _refreshControlG[e]}}))});var _repeaterG=require("./repeater.g.js");Object.keys(_repeaterG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_repeaterG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _repeaterG[e]}}))});var _richTextEditorG=require("./richTextEditor.g.js");Object.keys(_richTextEditorG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_richTextEditorG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _richTextEditorG[e]}}))});var _scannerOverlayG=require("./scannerOverlay.g.js");Object.keys(_scannerOverlayG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_scannerOverlayG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _scannerOverlayG[e]}}))});var _searchBarG=require("./searchBar.g.js");Object.keys(_searchBarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_searchBarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _searchBarG[e]}}))});var _sectionHeaderG=require("./sectionHeader.g.js");Object.keys(_sectionHeaderG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sectionHeaderG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sectionHeaderG[e]}}))});var _selectG=require("./select.g.js");Object.keys(_selectG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_selectG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _selectG[e]}}))});var _signaturePadG=require("./signaturePad.g.js");Object.keys(_signaturePadG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_signaturePadG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _signaturePadG[e]}}))});var _skeletonG=require("./skeleton.g.js");Object.keys(_skeletonG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_skeletonG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _skeletonG[e]}}))});var _sliderG=require("./slider.g.js");Object.keys(_sliderG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sliderG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sliderG[e]}}))});var _sliderFieldG=require("./sliderField.g.js");Object.keys(_sliderFieldG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sliderFieldG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sliderFieldG[e]}}))});var _slideToConfirmG=require("./slideToConfirm.g.js");Object.keys(_slideToConfirmG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_slideToConfirmG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _slideToConfirmG[e]}}))});var _sortableListG=require("./sortableList.g.js");Object.keys(_sortableListG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sortableListG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sortableListG[e]}}))});var _sparklineG=require("./sparkline.g.js");Object.keys(_sparklineG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sparklineG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sparklineG[e]}}))});var _spinnerG=require("./spinner.g.js");Object.keys(_spinnerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_spinnerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _spinnerG[e]}}))});var _stepperG=require("./stepper.g.js");Object.keys(_stepperG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_stepperG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _stepperG[e]}}))});var _timePickerG=require("./timePicker.g.js");Object.keys(_timePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_timePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _timePickerG[e]}}))});var _toastG=require("./toast.g.js");Object.keys(_toastG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_toastG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _toastG[e]}}))});var _tooltipG=require("./tooltip.g.js");Object.keys(_tooltipG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_tooltipG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _tooltipG[e]}}))});var _tourG=require("./tour.g.js");Object.keys(_tourG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_tourG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _tourG[e]}}))});var _typingIndicatorG=require("./typingIndicator.g.js");Object.keys(_typingIndicatorG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_typingIndicatorG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _typingIndicatorG[e]}}))});var _wheelPickerG=require("./wheelPicker.g.js");Object.keys(_wheelPickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_wheelPickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _wheelPickerG[e]}}))});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _amountSliderG=require("./amountSlider.g.js");Object.keys(_amountSliderG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_amountSliderG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _amountSliderG[e]}}))});var _asyncBlockG=require("./asyncBlock.g.js");Object.keys(_asyncBlockG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_asyncBlockG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _asyncBlockG[e]}}))});var _authedImageG=require("./authedImage.g.js");Object.keys(_authedImageG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_authedImageG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _authedImageG[e]}}))});var _autocompleteG=require("./autocomplete.g.js");Object.keys(_autocompleteG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_autocompleteG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _autocompleteG[e]}}))});var _avatarG=require("./avatar.g.js");Object.keys(_avatarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_avatarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _avatarG[e]}}))});var _badgeG=require("./badge.g.js");Object.keys(_badgeG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_badgeG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _badgeG[e]}}))});var _bannerG=require("./banner.g.js");Object.keys(_bannerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_bannerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _bannerG[e]}}))});var _barG=require("./bar.g.js");Object.keys(_barG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_barG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _barG[e]}}))});var _barChartG=require("./barChart.g.js");Object.keys(_barChartG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_barChartG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _barChartG[e]}}))});var _bottomNavigationG=require("./bottomNavigation.g.js");Object.keys(_bottomNavigationG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_bottomNavigationG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _bottomNavigationG[e]}}))});var _bottomSheetG=require("./bottomSheet.g.js");Object.keys(_bottomSheetG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_bottomSheetG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _bottomSheetG[e]}}))});var _buttonG=require("./button.g.js");Object.keys(_buttonG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_buttonG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _buttonG[e]}}))});var _calendarG=require("./calendar.g.js");Object.keys(_calendarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_calendarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _calendarG[e]}}))});var _cardG=require("./card.g.js");Object.keys(_cardG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_cardG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _cardG[e]}}))});var _carouselG=require("./carousel.g.js");Object.keys(_carouselG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_carouselG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _carouselG[e]}}))});var _chipG=require("./chip.g.js");Object.keys(_chipG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_chipG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _chipG[e]}}))});var _composerG=require("./composer.g.js");Object.keys(_composerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_composerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _composerG[e]}}))});var _confirmG=require("./confirm.g.js");Object.keys(_confirmG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_confirmG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _confirmG[e]}}))});var _datePickerG=require("./datePicker.g.js");Object.keys(_datePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_datePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _datePickerG[e]}}))});var _dateRangePickerG=require("./dateRangePicker.g.js");Object.keys(_dateRangePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_dateRangePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _dateRangePickerG[e]}}))});var _dateSeparatorG=require("./dateSeparator.g.js");Object.keys(_dateSeparatorG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_dateSeparatorG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _dateSeparatorG[e]}}))});var _decimalInputG=require("./decimalInput.g.js");Object.keys(_decimalInputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_decimalInputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _decimalInputG[e]}}))});var _discardGuardG=require("./discardGuard.g.js");Object.keys(_discardGuardG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_discardGuardG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _discardGuardG[e]}}))});var _drawerG=require("./drawer.g.js");Object.keys(_drawerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_drawerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _drawerG[e]}}))});var _errorBoundaryG=require("./errorBoundary.g.js");Object.keys(_errorBoundaryG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_errorBoundaryG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _errorBoundaryG[e]}}))});var _filePickerG=require("./filePicker.g.js");Object.keys(_filePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_filePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _filePickerG[e]}}))});var _floatingActionButtonG=require("./floatingActionButton.g.js");Object.keys(_floatingActionButtonG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_floatingActionButtonG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _floatingActionButtonG[e]}}))});var _forceUpdateDialogG=require("./forceUpdateDialog.g.js");Object.keys(_forceUpdateDialogG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_forceUpdateDialogG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _forceUpdateDialogG[e]}}))});var _formFieldG=require("./formField.g.js");Object.keys(_formFieldG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_formFieldG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _formFieldG[e]}}))});var _idleTimeoutDialogG=require("./idleTimeoutDialog.g.js");Object.keys(_idleTimeoutDialogG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_idleTimeoutDialogG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _idleTimeoutDialogG[e]}}))});var _imageGalleryG=require("./imageGallery.g.js");Object.keys(_imageGalleryG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_imageGalleryG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _imageGalleryG[e]}}))});var _inlineSelectG=require("./inlineSelect.g.js");Object.keys(_inlineSelectG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_inlineSelectG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _inlineSelectG[e]}}))});var _inputG=require("./input.g.js");Object.keys(_inputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_inputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _inputG[e]}}))});var _keyboardToolbarG=require("./keyboardToolbar.g.js");Object.keys(_keyboardToolbarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_keyboardToolbarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _keyboardToolbarG[e]}}))});var _loaderOverlayG=require("./loaderOverlay.g.js");Object.keys(_loaderOverlayG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_loaderOverlayG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _loaderOverlayG[e]}}))});var _lockOverlayG=require("./lockOverlay.g.js");Object.keys(_lockOverlayG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_lockOverlayG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _lockOverlayG[e]}}))});var _menuG=require("./menu.g.js");Object.keys(_menuG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_menuG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _menuG[e]}}))});var _messageBubbleG=require("./messageBubble.g.js");Object.keys(_messageBubbleG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_messageBubbleG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _messageBubbleG[e]}}))});var _messageListG=require("./messageList.g.js");Object.keys(_messageListG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_messageListG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _messageListG[e]}}))});var _modalG=require("./modal.g.js");Object.keys(_modalG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_modalG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _modalG[e]}}))});var _networkStatusBannerG=require("./networkStatusBanner.g.js");Object.keys(_networkStatusBannerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_networkStatusBannerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _networkStatusBannerG[e]}}))});var _nonModalBottomSheetG=require("./nonModalBottomSheet.g.js");Object.keys(_nonModalBottomSheetG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_nonModalBottomSheetG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _nonModalBottomSheetG[e]}}))});var _numberInputG=require("./numberInput.g.js");Object.keys(_numberInputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_numberInputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _numberInputG[e]}}))});var _onboardingPagerG=require("./onboardingPager.g.js");Object.keys(_onboardingPagerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_onboardingPagerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _onboardingPagerG[e]}}))});var _optionSheetG=require("./optionSheet.g.js");Object.keys(_optionSheetG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_optionSheetG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _optionSheetG[e]}}))});var _otpInputG=require("./otpInput.g.js");Object.keys(_otpInputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_otpInputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _otpInputG[e]}}))});var _pagedListFooterG=require("./pagedListFooter.g.js");Object.keys(_pagedListFooterG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_pagedListFooterG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _pagedListFooterG[e]}}))});var _permissionPromptG=require("./permissionPrompt.g.js");Object.keys(_permissionPromptG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_permissionPromptG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _permissionPromptG[e]}}))});var _phoneNumberInputG=require("./phoneNumberInput.g.js");Object.keys(_phoneNumberInputG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_phoneNumberInputG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _phoneNumberInputG[e]}}))});var _pickerTriggerG=require("./pickerTrigger.g.js");Object.keys(_pickerTriggerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_pickerTriggerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _pickerTriggerG[e]}}))});var _profileCompletionG=require("./profileCompletion.g.js");Object.keys(_profileCompletionG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_profileCompletionG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _profileCompletionG[e]}}))});var _profilePickerG=require("./profilePicker.g.js");Object.keys(_profilePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_profilePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _profilePickerG[e]}}))});var _progressBarG=require("./progressBar.g.js");Object.keys(_progressBarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_progressBarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _progressBarG[e]}}))});var _ratingG=require("./rating.g.js");Object.keys(_ratingG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_ratingG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _ratingG[e]}}))});var _refreshControlG=require("./refreshControl.g.js");Object.keys(_refreshControlG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_refreshControlG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _refreshControlG[e]}}))});var _repeaterG=require("./repeater.g.js");Object.keys(_repeaterG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_repeaterG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _repeaterG[e]}}))});var _richTextEditorG=require("./richTextEditor.g.js");Object.keys(_richTextEditorG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_richTextEditorG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _richTextEditorG[e]}}))});var _scannerOverlayG=require("./scannerOverlay.g.js");Object.keys(_scannerOverlayG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_scannerOverlayG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _scannerOverlayG[e]}}))});var _searchBarG=require("./searchBar.g.js");Object.keys(_searchBarG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_searchBarG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _searchBarG[e]}}))});var _sectionHeaderG=require("./sectionHeader.g.js");Object.keys(_sectionHeaderG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sectionHeaderG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sectionHeaderG[e]}}))});var _selectG=require("./select.g.js");Object.keys(_selectG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_selectG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _selectG[e]}}))});var _signaturePadG=require("./signaturePad.g.js");Object.keys(_signaturePadG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_signaturePadG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _signaturePadG[e]}}))});var _skeletonG=require("./skeleton.g.js");Object.keys(_skeletonG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_skeletonG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _skeletonG[e]}}))});var _sliderG=require("./slider.g.js");Object.keys(_sliderG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sliderG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sliderG[e]}}))});var _sliderFieldG=require("./sliderField.g.js");Object.keys(_sliderFieldG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sliderFieldG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sliderFieldG[e]}}))});var _slideToConfirmG=require("./slideToConfirm.g.js");Object.keys(_slideToConfirmG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_slideToConfirmG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _slideToConfirmG[e]}}))});var _sortableListG=require("./sortableList.g.js");Object.keys(_sortableListG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sortableListG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sortableListG[e]}}))});var _sparklineG=require("./sparkline.g.js");Object.keys(_sparklineG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_sparklineG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _sparklineG[e]}}))});var _spinnerG=require("./spinner.g.js");Object.keys(_spinnerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_spinnerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _spinnerG[e]}}))});var _stepperG=require("./stepper.g.js");Object.keys(_stepperG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_stepperG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _stepperG[e]}}))});var _timePickerG=require("./timePicker.g.js");Object.keys(_timePickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_timePickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _timePickerG[e]}}))});var _toastG=require("./toast.g.js");Object.keys(_toastG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_toastG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _toastG[e]}}))});var _tooltipG=require("./tooltip.g.js");Object.keys(_tooltipG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_tooltipG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _tooltipG[e]}}))});var _tourG=require("./tour.g.js");Object.keys(_tourG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_tourG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _tourG[e]}}))});var _typingIndicatorG=require("./typingIndicator.g.js");Object.keys(_typingIndicatorG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_typingIndicatorG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _typingIndicatorG[e]}}))});var _wheelPickerG=require("./wheelPicker.g.js");Object.keys(_wheelPickerG).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in exports&&exports[e]===_wheelPickerG[e]||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return _wheelPickerG[e]}}))});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Platform,StyleSheet,TextInput,View}from"react-native";import{KeyboardStickyView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useControllableState}from"../../hooks/useControllableState.js";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useMobileUiText}from"../../text/index.js";import{COMPOSER_TEXT}from"../../text/phone/composer.g.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MIN_BOX=44,RING_MS=900,RING_WIDTH=1.5;export const Composer=forwardRef(({onSend:e,value:o,onChangeText:t,placeholder:
|
|
1
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Platform,StyleSheet,TextInput,View}from"react-native";import{KeyboardStickyView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useControllableState}from"../../hooks/useControllableState.js";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useMobileUiText}from"../../text/index.js";import{COMPOSER_TEXT}from"../../text/phone/composer.g.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MIN_BOX=44,RING_MS=900,RING_WIDTH=1.5;export const Composer=forwardRef(({onSend:e,value:o,onChangeText:t,placeholder:i,accessibilityLabel:a,hint:s,labels:r,loading:l=!1,onStop:n,stopLabel:d,disabled:c=!1,canSend:u,ring:m=!1,sendReveal:p="always",sendIcon:b="send",maxLength:g,maxLines:f=5,leading:x,trailing:h,above:y,below:S,keyboardAware:C=!0,keyboardOffset:v,safeArea:j=!0,autoFocus:w,haptic:I,style:T,testID:M},R)=>{const k=useTheme(),A=useSafeAreaInsets(),V=useMemo(()=>buildStyles(k),[k]),_=useMobileUiText("composer",COMPOSER_TEXT),E=useMemo(()=>({..._,...r}),[_,r]),[D,O]=useControllableState({value:o,defaultValue:"",onChange:t}),H=D.trim(),L=l&&void 0!==n,z=l||c||!(u??""!==H),B=j?A.bottom:0,F=v??B,P=resolveFieldTextStyle(k,{disabled:c}),N=k.text.base.size,W=Math.round(N*k.leading.body),X=(44-W)/2,$=W*f+2*X,[G,K]=useState(void 0),U=useCallback(e=>{const o=e.nativeEvent.contentSize.height+2*X;K(Math.min(Math.max(o,44),$))},[X,$]),q=useReducedMotion(),J=useRef(new Animated.Value(0)).current;useEffect(()=>{if(!m||q)return void J.setValue(m?1:0);const e=Animated.loop(Animated.sequence([Animated.timing(J,{toValue:1,duration:900,easing:Easing.inOut(Easing.ease),useNativeDriver:!1}),Animated.timing(J,{toValue:0,duration:900,easing:Easing.inOut(Easing.ease),useNativeDriver:!1})]));return e.start(),()=>e.stop()},[m,q,J]);const Q=m?{borderWidth:1.5,borderColor:J.interpolate({inputRange:[0,1],outputRange:[k.colors["border-subtle"],k.colors.primary]})}:null,Y="always"===p||l||""!==D||!0===u,Z=useCallback(()=>{L?n?.():z||(O(""),e(H))},[L,n,z,O,e,H]),ee=useCallback(e=>{reportIdleActivity(),O(e)},[O]),oe=_jsxs(View,{style:[V.bar,{paddingBottom:k.space.sm+B},T],testID:M,children:[y,_jsxs(View,{style:V.row,children:[x,_jsx(Animated.View,{style:[V.box,c?V.boxDisabled:null,Q],testID:M?`${M}-box`:void 0,children:_jsx(TextInput,{ref:R,value:D,onChangeText:ee,multiline:!0,maxLength:g,editable:!c,autoFocus:w,placeholder:i??E.message,placeholderTextColor:P.placeholderColor,selectionColor:k.colors["field-caret"],accessibilityLabel:a??i??E.message,accessibilityHint:s,accessibilityState:{disabled:c},"aria-disabled":c,onContentSizeChange:"web"===Platform.OS?U:void 0,style:[V.input,{color:P.color,...P.weightStyle,fontSize:N,lineHeight:W,paddingVertical:X,maxHeight:$,height:"web"===Platform.OS?G:void 0}],testID:M?`${M}-input`:void 0})}),h,Y?_jsx(IconButton,{icon:L?"stop":b,accessibilityLabel:L?d??E.stopLabel:E.send,variant:"solid",tone:"primary",disabled:L?c:z,loading:l&&!L,haptic:I,onPress:Z,testID:M?`${M}-send`:void 0}):null]}),S]});return C?_jsx(KeyboardStickyView,{offset:{closed:0,opened:F},children:oe}):oe});Composer.displayName="Composer";const buildStyles=e=>StyleSheet.create({bar:{gap:e.space.xs,paddingHorizontal:e.space.md,paddingTop:e.space.sm,backgroundColor:e.colors.bg,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:e.colors["border-subtle"]},row:{flexDirection:"row",alignItems:"flex-end",gap:e.space.sm},box:{flex:1,minHeight:44,justifyContent:"center",backgroundColor:e.colors["field-bg"],borderRadius:e.radius.pill,...smoothCorners,paddingHorizontal:e.space.md},boxDisabled:{backgroundColor:e.colors["field-bg-disabled"]},input:{margin:e.space.none,paddingHorizontal:e.space.none,includeFontPadding:!1,textAlignVertical:"top"}});export default Composer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{fillText,useMobileUiText}from"../../text/index.js";import{DATE_PICKER_TEXT}from"../../text/phone/datePicker.g.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Calendar}from"../Calendar/index.js";import{Modal}from"../Modal/index.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const NAV_BUTTON_SIZE=36,GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:s,maxDate:i,disabledDates:o,inline:l=!1,locale:n="en-IN",weekStartsOn:c=0,title:d,labels:u,style:g,sheetStyle:m,headerLabelStyle:h,navButtonStyle:y,footerButtonStyle:b,haptic:p,testID:x,label:f,help:v,placeholder:j,helperText:D,error:C,required:w,disabled:S,size:T,variant:_,clearable:M,onClear:R,leftIcon:k,trailing:P,triggerStyle:I,valueStyle:V,labelStyle:A,messageStyle:F,accessibilityLabel:L,triggerLabels:z,formatValue:B}=e,H=l?"inline":"modal",Y=useMobileUiText("datePicker",DATE_PICKER_TEXT),E=useMemo(()=>u?{...Y,...u}:Y,[Y,u]),O=void 0!==e.open,[$,N]=useState(!1),W=void 0!==e.open?e.open:$,G=O?x:x?`${x}-calendar`:void 0,q=useTheme(),U=usePresenceMotion(),[X,K]=useModalInsets(),Z=useMemo(()=>buildStyles(q),[q]),[J,Q]=useState(()=>startOfDay(new Date));useEffect(()=>{W&&Q(startOfDay(new Date))},[W]);const ee=t?startOfDay(t):J,[te,ae]=useState(ee),[re,se]=useState(t?startOfDay(t):null),[ie,oe]=useState("days"),le=useRef(createAnimatedValue(0)).current,ne=useRef(0),ce=useRef(createAnimatedValue(1)).current,de=useRef(createAnimatedValue(1)).current,ue=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(t){const e=startOfDay(t);se(e),ae(e)}else se(null)},[t]);const ge=useMemo(()=>s?startOfDay(s):null,[s]),me=useMemo(()=>i?startOfDay(i):null,[i]),he=useMemo(()=>buildYearCells(te.getFullYear()),[te]),ye=useMemo(()=>buildDecadeCells(te.getFullYear()),[te]),be=useMemo(()=>{const e=te.getFullYear();if("years"===ie)return`${e-4} - ${e+7}`;const t=decadeStartFor(e)-40;return`${t} - ${t+110+9}`},[te,ie]),pe=useCallback(e=>!!(ge&&e<ge.getFullYear())||!!(me&&e>me.getFullYear()),[ge,me]),xe=useCallback(e=>!!(ge&&e+10-1<ge.getFullYear())||!!(me&&e>me.getFullYear()),[ge,me]),fe=useCallback(()=>{!1!==p&&triggerHaptic("impactLight"),ae("years"===ie?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))},[ie,p]),ve=useCallback(()=>{!1!==p&&triggerHaptic("impactLight"),ae("years"===ie?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))},[ie,p]),je=useCallback(()=>{const[e]=U.range(.9,1),t=U.reduced?U.duration("default"):q.motion.duration.default;setNativeValue(ce,0),setNativeValue(de,e),Animated.parallel([Animated.timing(ce,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver}),Animated.timing(de,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver})]).start()},[ce,de,U,q.motion.duration.default]),De=useCallback(()=>{const e=resolveHaptic(p,"selection");if(e&&triggerHaptic(e),!U.reduced){const e=80,t=100;Animated.sequence([Animated.timing(ue,{toValue:.96,duration:e,useNativeDriver:nativeDriver}),Animated.timing(ue,{toValue:1,duration:t,useNativeDriver:nativeDriver})]).start()}oe(e=>"days"===e?"years":"years"===e?"decades":"years"),je()},[je,ue,p,U.reduced]),Ce=useCallback(e=>{const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),ae(t=>new Date(e,t.getMonth(),1)),oe("days"),je()},[je,p]),we=useCallback(e=>{const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),ae(t=>new Date(e+4,t.getMonth(),1)),oe("years"),je()},[je,p]),Se=useCallback(e=>{se(e.start)},[]),Te=useCallback(()=>{O||N(!1),r?.()},[O,r]),{handleGesture:Me,opacity:Re}=useDragToDismiss({drag:le,travel:()=>ne.current||320,onDismiss:Te});useEffect(()=>{W&&"modal"===H&&(setNativeValue(le,0),setNativeValue(Re,1))},[W,H,le,Re]);const ke=useCallback(()=>{!1!==p&&triggerHaptic("selection"),Te()},[Te,p]),Pe=useCallback(()=>{re&&(!1!==p&&triggerHaptic("notificationSuccess"),a?.(re),Te())},[Te,a,re,p]),Ie=_jsx(View,{style:Z.titleRow,children:_jsx(Text,{style:Z.title,variant:"title",accessibilityRole:"header",children:d??E.title})}),Ve=_jsxs(View,{style:[Z.card,m],accessibilityRole:"modal"===H?void 0:"none",accessible:!1,testID:G,children:["modal"===H?_jsx(GestureDetector,{gesture:Me,children:_jsxs(View,{style:Z.grabArea,children:[_jsx(View,{style:Z.handle}),Ie]})}):Ie,"days"!==ie?_jsxs(View,{style:Z.headerRow,children:[_jsx(Pressable,{onPress:fe,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,y],accessibilityRole:"button",accessibilityLabel:"years"===ie?E.previousYears:E.previousDecades,hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:Z.navText,variant:"title",children:"‹"})}),_jsx(Pressable,{onPress:De,style:[Z.headerLabelWrap,h],accessibilityRole:"button",accessibilityLabel:`${be}, ${"years"===ie?E.switchToDecades:E.switchToYears}`,hitSlop:8,...hitSlopMarker(8),children:_jsxs(Animated.View,{style:[Z.headerLabelInner,{transform:[{scale:ue}]}],children:[_jsx(Animated.Text,{style:[Z.headerLabel,{transform:[{translateX:0}]}],accessibilityLiveRegion:"polite",children:be}),_jsx(View,{style:Z.headerCaret,children:(q.settings.icons.chevronDown??defaultIcons.chevronDown)({size:q.text.sm.size,color:q.colors["text-muted"]})})]})}),_jsx(Pressable,{onPress:ve,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,y],accessibilityRole:"button",accessibilityLabel:"years"===ie?E.nextYears:E.nextDecades,hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:Z.navText,variant:"title",children:"›"})})]}):null,"days"===ie?_jsx(Calendar,{selectionMode:"single",value:re?{start:re}:null,onChange:Se,month:te,onMonthChange:ae,minDate:s,maxDate:i,disabledDates:o,weekStartsOn:c,locale:n,haptic:p,headerLabelStyle:h,navButtonStyle:y,onTitlePress:De,labels:{previousMonth:E.previousMonth,nextMonth:E.nextMonth},testID:G?`${G}-grid`:void 0}):_jsx(Animated.View,"years"===ie?{style:[Z.yearGrid,{opacity:ce,transform:[{scale:de}]}],children:Array.from({length:3},(e,t)=>he.slice(4*t,4*t+4)).map(e=>_jsx(View,{style:Z.gridRow,children:e.map(e=>{const t=pe(e),a=!!re&&re.getFullYear()===e,r=J.getFullYear()===e,s=a?q.colors.primary:"transparent",i=r&&!a?q.colors.primary:"transparent",o=a?q.colors["on-primary"]:t?q.colors["text-disabled"]:q.colors["text-body"],l=t?.3:1;return _jsx(Pressable,{disabled:t,onPress:()=>Ce(e),accessibilityRole:"button",accessibilityLabel:fillText(E.year,{year:e}),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:Z.yearCell,children:_jsx(View,{style:[Z.yearInner,{backgroundColor:s,borderColor:i,borderWidth:r&&!a?1.5:0,opacity:l}],children:_jsx(Text,{style:[Z.yearText,{color:o}],variant:"body",children:e})})},`year-${e}`)})},`yr-${e.join("-")}`))}:{style:[Z.yearGrid,{opacity:ce,transform:[{scale:de}]}],children:Array.from({length:3},(e,t)=>ye.slice(4*t,4*t+4)).map(e=>_jsx(View,{style:Z.gridRow,children:e.map(e=>{const t=e+10-1,a=xe(e),r=!!re&&decadeStartFor(re.getFullYear())===e,s=decadeStartFor(J.getFullYear())===e,i=r?q.colors.primary:"transparent",o=s&&!r?q.colors.primary:"transparent",l=r?q.colors["on-primary"]:a?q.colors["text-disabled"]:q.colors["text-body"],n=a?.3:1;return _jsx(Pressable,{disabled:a,onPress:()=>we(e),accessibilityRole:"button",accessibilityLabel:fillText(E.decade,{start:e,end:t}),accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:Z.yearCell,children:_jsxs(View,{style:[Z.yearInner,{backgroundColor:i,borderColor:o,borderWidth:s&&!r?1.5:0,opacity:n}],children:[_jsx(Text,{style:[Z.yearText,{color:l}],variant:"body",children:`${e}s`}),_jsx(Text,{variant:"caption",style:[Z.decadeRangeText,{color:r?q.colors["on-primary"]:q.colors["text-subtle"]}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${e.join("-")}`))}),_jsxs(View,{style:Z.footer,children:[_jsx(Pressable,{onPress:ke,style:({pressed:e})=>[Z.footerBtn,Z.footerCancel,e&&Z.footerBtnPressed,b],accessibilityRole:"button",accessibilityLabel:E.cancel,children:_jsx(Text,{style:[Z.footerBtnText,{color:q.colors["text-muted"]}],variant:"label",weight:"semibold",children:E.cancel})}),_jsx(Pressable,{onPress:Pe,disabled:!re,style:({pressed:e})=>[Z.footerBtn,Z.footerConfirm,{backgroundColor:q.colors.primary,opacity:re?1:.5},e&&{backgroundColor:q.colors["primary-hover"]},b],accessibilityRole:"button",accessibilityLabel:E.confirm,accessibilityState:{disabled:!re},"aria-disabled":!re,children:_jsx(Text,{style:[Z.footerBtnText,{color:q.colors["on-primary"]}],variant:"label",weight:"semibold",children:E.confirm})})]})]}),Ae=t?(B??(e=>e.toLocaleDateString()))(t):void 0,Fe=!O,Le={label:f,help:v,placeholder:j,helperText:D,error:C,required:w,disabled:S,size:T,variant:_,clearable:M,onClear:R,leftIcon:k,trailing:P,triggerStyle:I,valueStyle:V,labelStyle:A,messageStyle:F,accessibilityLabel:L,labels:z,style:g};if("inline"===H)return W||Fe?Fe?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...Le,value:Ae,onPress:()=>N(!0),testID:x}),W?Ve:null]}):Ve:null;const ze=_jsx(Modal,{open:W,onClose:Te,presentation:"bottom",bare:!0,haptic:!1,labels:{close:E.dismiss},onInsetsChange:K,children:_jsx(GestureHandlerRootView,{style:Z.gestureRoot,children:_jsx(Animated.View,{style:[Z.sheetWrap,{paddingBottom:Math.max(X.bottom,q.space.lg),opacity:Re,transform:[{translateY:le}]}],onLayout:e=>{ne.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Ve})})});return Fe?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...Le,value:Ae,onPress:()=>N(!0),testID:x}),ze]}):ze},buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({gestureRoot:{width:"100%"},sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navText:{fontSize:e.text["2xl"].size,lineHeight:Math.round(e.text["2xl"].size*e.leading.heading),color:e.colors["text-body"],fontWeight:e.weight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.text.base.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerCaret:{marginLeft:e.space.xs,alignItems:"center",justifyContent:"center"},gridRow:{flexDirection:"row"},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.space.xs},yearInner:{width:"100%",height:"100%",borderRadius:e.radius.lg,...smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.text.base.size,lineHeight:Math.round(e.text.base.size*e.leading.body),fontWeight:e.weight.semibold},decadeRangeText:{fontSize:e.text.xs.size,lineHeight:Math.round(e.text.xs.size*e.leading.body),fontWeight:e.weight.medium,marginTop:e.space.xxs},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};export{DatePicker};export default DatePicker;
|
|
1
|
+
"use strict";import{formatDate}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{fillText,useMobileUiText}from"../../text/index.js";import{DATE_PICKER_TEXT}from"../../text/phone/datePicker.g.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Calendar}from"../Calendar/index.js";import{Modal}from"../Modal/index.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const NAV_BUTTON_SIZE=36,GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,r)=>t+r)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,r)=>t+10*r)},DatePicker=e=>{const{value:t,onChange:r,onClose:a,minDate:s,maxDate:i,disabledDates:o,inline:l=!1,locale:n="en-IN",weekStartsOn:c=0,title:d,labels:u,style:m,sheetStyle:g,headerLabelStyle:h,navButtonStyle:y,footerButtonStyle:b,haptic:p,testID:f,label:x,help:v,placeholder:D,helperText:j,error:w,required:C,disabled:S,size:T,variant:_,clearable:M,onClear:R,leftIcon:k,trailing:P,triggerStyle:I,valueStyle:V,labelStyle:A,messageStyle:F,accessibilityLabel:z,triggerLabels:B,formatValue:L}=e,H=l?"inline":"modal",Y=useMobileUiText("datePicker",DATE_PICKER_TEXT),E=useMemo(()=>u?{...Y,...u}:Y,[Y,u]),O=void 0!==e.open,[$,N]=useState(!1),W=void 0!==e.open?e.open:$,G=O?f:f?`${f}-calendar`:void 0,q=useTheme(),U=usePresenceMotion(),[X,K]=useModalInsets(),Z=useMemo(()=>buildStyles(q),[q]),[J,Q]=useState(()=>startOfDay(new Date));useEffect(()=>{W&&Q(startOfDay(new Date))},[W]);const ee=t?startOfDay(t):J,[te,re]=useState(ee),[ae,se]=useState(t?startOfDay(t):null),[ie,oe]=useState("days"),le=useRef(createAnimatedValue(0)).current,ne=useRef(0),ce=useRef(createAnimatedValue(1)).current,de=useRef(createAnimatedValue(1)).current,ue=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(t){const e=startOfDay(t);se(e),re(e)}else se(null)},[t]);const me=useMemo(()=>s?startOfDay(s):null,[s]),ge=useMemo(()=>i?startOfDay(i):null,[i]),he=useMemo(()=>buildYearCells(te.getFullYear()),[te]),ye=useMemo(()=>buildDecadeCells(te.getFullYear()),[te]),be=useMemo(()=>{const e=te.getFullYear();if("years"===ie)return`${e-4} - ${e+7}`;const t=decadeStartFor(e)-40;return`${t} - ${t+110+9}`},[te,ie]),pe=useCallback(e=>!!(me&&e<me.getFullYear())||!!(ge&&e>ge.getFullYear()),[me,ge]),fe=useCallback(e=>!!(me&&e+10-1<me.getFullYear())||!!(ge&&e>ge.getFullYear()),[me,ge]),xe=useCallback(()=>{!1!==p&&triggerHaptic("impactLight"),re("years"===ie?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))},[ie,p]),ve=useCallback(()=>{!1!==p&&triggerHaptic("impactLight"),re("years"===ie?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))},[ie,p]),De=useCallback(()=>{const[e]=U.range(.9,1),t=U.reduced?U.duration("default"):q.motion.duration.default;setNativeValue(ce,0),setNativeValue(de,e),Animated.parallel([Animated.timing(ce,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver}),Animated.timing(de,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver})]).start()},[ce,de,U,q.motion.duration.default]),je=useCallback(()=>{const e=resolveHaptic(p,"selection");if(e&&triggerHaptic(e),!U.reduced){const e=80,t=100;Animated.sequence([Animated.timing(ue,{toValue:.96,duration:e,useNativeDriver:nativeDriver}),Animated.timing(ue,{toValue:1,duration:t,useNativeDriver:nativeDriver})]).start()}oe(e=>"days"===e?"years":"years"===e?"decades":"years"),De()},[De,ue,p,U.reduced]),we=useCallback(e=>{const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),re(t=>new Date(e,t.getMonth(),1)),oe("days"),De()},[De,p]),Ce=useCallback(e=>{const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),re(t=>new Date(e+4,t.getMonth(),1)),oe("years"),De()},[De,p]),Se=useCallback(e=>{se(e.start)},[]),Te=useCallback(()=>{O||N(!1),a?.()},[O,a]),{handleGesture:Me,opacity:Re}=useDragToDismiss({drag:le,travel:()=>ne.current||320,onDismiss:Te});useEffect(()=>{W&&"modal"===H&&(setNativeValue(le,0),setNativeValue(Re,1))},[W,H,le,Re]);const ke=useCallback(()=>{!1!==p&&triggerHaptic("selection"),Te()},[Te,p]),Pe=useCallback(()=>{ae&&(!1!==p&&triggerHaptic("notificationSuccess"),r?.(ae),Te())},[Te,r,ae,p]),Ie=_jsx(View,{style:Z.titleRow,children:_jsx(Text,{style:Z.title,variant:"title",accessibilityRole:"header",children:d??E.title})}),Ve=_jsxs(View,{style:[Z.card,g],accessibilityRole:"modal"===H?void 0:"none",accessible:!1,testID:G,children:["modal"===H?_jsx(GestureDetector,{gesture:Me,children:_jsxs(View,{style:Z.grabArea,children:[_jsx(View,{style:Z.handle}),Ie]})}):Ie,"days"!==ie?_jsxs(View,{style:Z.headerRow,children:[_jsx(Pressable,{onPress:xe,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,y],accessibilityRole:"button",accessibilityLabel:"years"===ie?E.previousYears:E.previousDecades,hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:Z.navText,variant:"title",children:"‹"})}),_jsx(Pressable,{onPress:je,style:[Z.headerLabelWrap,h],accessibilityRole:"button",accessibilityLabel:`${be}, ${"years"===ie?E.switchToDecades:E.switchToYears}`,hitSlop:8,...hitSlopMarker(8),children:_jsxs(Animated.View,{style:[Z.headerLabelInner,{transform:[{scale:ue}]}],children:[_jsx(Animated.Text,{style:[Z.headerLabel,{transform:[{translateX:0}]}],accessibilityLiveRegion:"polite",children:be}),_jsx(View,{style:Z.headerCaret,children:(q.settings.icons.chevronDown??defaultIcons.chevronDown)({size:q.text.sm.size,color:q.colors["text-muted"]})})]})}),_jsx(Pressable,{onPress:ve,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,y],accessibilityRole:"button",accessibilityLabel:"years"===ie?E.nextYears:E.nextDecades,hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:Z.navText,variant:"title",children:"›"})})]}):null,"days"===ie?_jsx(Calendar,{selectionMode:"single",value:ae?{start:ae}:null,onChange:Se,month:te,onMonthChange:re,minDate:s,maxDate:i,disabledDates:o,weekStartsOn:c,locale:n,haptic:p,headerLabelStyle:h,navButtonStyle:y,onTitlePress:je,labels:{previousMonth:E.previousMonth,nextMonth:E.nextMonth},testID:G?`${G}-grid`:void 0}):_jsx(Animated.View,"years"===ie?{style:[Z.yearGrid,{opacity:ce,transform:[{scale:de}]}],children:Array.from({length:3},(e,t)=>he.slice(4*t,4*t+4)).map(e=>_jsx(View,{style:Z.gridRow,children:e.map(e=>{const t=pe(e),r=!!ae&&ae.getFullYear()===e,a=J.getFullYear()===e,s=r?q.colors.primary:"transparent",i=a&&!r?q.colors.primary:"transparent",o=r?q.colors["on-primary"]:t?q.colors["text-disabled"]:q.colors["text-body"],l=t?.3:1;return _jsx(Pressable,{disabled:t,onPress:()=>we(e),accessibilityRole:"button",accessibilityLabel:fillText(E.year,{year:e}),accessibilityState:{selected:r,disabled:t},"aria-selected":r,"aria-disabled":t,style:Z.yearCell,children:_jsx(View,{style:[Z.yearInner,{backgroundColor:s,borderColor:i,borderWidth:a&&!r?1.5:0,opacity:l}],children:_jsx(Text,{style:[Z.yearText,{color:o}],variant:"body",children:e})})},`year-${e}`)})},`yr-${e.join("-")}`))}:{style:[Z.yearGrid,{opacity:ce,transform:[{scale:de}]}],children:Array.from({length:3},(e,t)=>ye.slice(4*t,4*t+4)).map(e=>_jsx(View,{style:Z.gridRow,children:e.map(e=>{const t=e+10-1,r=fe(e),a=!!ae&&decadeStartFor(ae.getFullYear())===e,s=decadeStartFor(J.getFullYear())===e,i=a?q.colors.primary:"transparent",o=s&&!a?q.colors.primary:"transparent",l=a?q.colors["on-primary"]:r?q.colors["text-disabled"]:q.colors["text-body"],n=r?.3:1;return _jsx(Pressable,{disabled:r,onPress:()=>Ce(e),accessibilityRole:"button",accessibilityLabel:fillText(E.decade,{start:e,end:t}),accessibilityState:{selected:a,disabled:r},"aria-selected":a,"aria-disabled":r,style:Z.yearCell,children:_jsxs(View,{style:[Z.yearInner,{backgroundColor:i,borderColor:o,borderWidth:s&&!a?1.5:0,opacity:n}],children:[_jsx(Text,{style:[Z.yearText,{color:l}],variant:"body",children:`${e}s`}),_jsx(Text,{variant:"caption",style:[Z.decadeRangeText,{color:a?q.colors["on-primary"]:q.colors["text-subtle"]}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${e.join("-")}`))}),_jsxs(View,{style:Z.footer,children:[_jsx(Pressable,{onPress:ke,style:({pressed:e})=>[Z.footerBtn,Z.footerCancel,e&&Z.footerBtnPressed,b],accessibilityRole:"button",accessibilityLabel:E.cancel,children:_jsx(Text,{style:[Z.footerBtnText,{color:q.colors["text-muted"]}],variant:"label",weight:"semibold",children:E.cancel})}),_jsx(Pressable,{onPress:Pe,disabled:!ae,style:({pressed:e})=>[Z.footerBtn,Z.footerConfirm,{backgroundColor:q.colors.primary,opacity:ae?1:.5},e&&{backgroundColor:q.colors["primary-hover"]},b],accessibilityRole:"button",accessibilityLabel:E.confirm,accessibilityState:{disabled:!ae},"aria-disabled":!ae,children:_jsx(Text,{style:[Z.footerBtnText,{color:q.colors["on-primary"]}],variant:"label",weight:"semibold",children:E.confirm})})]})]}),Ae=t?(L??(e=>formatDate(e,{zone:"viewer"})))(t):void 0,Fe=!O,ze={label:x,help:v,placeholder:D,helperText:j,error:w,required:C,disabled:S,size:T,variant:_,clearable:M,onClear:R,leftIcon:k,trailing:P,triggerStyle:I,valueStyle:V,labelStyle:A,messageStyle:F,accessibilityLabel:z,labels:B,style:m};if("inline"===H)return W||Fe?Fe?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...ze,value:Ae,onPress:()=>N(!0),testID:f}),W?Ve:null]}):Ve:null;const Be=_jsx(Modal,{open:W,onClose:Te,presentation:"bottom",bare:!0,haptic:!1,labels:{close:E.dismiss},onInsetsChange:K,children:_jsx(GestureHandlerRootView,{style:Z.gestureRoot,children:_jsx(Animated.View,{style:[Z.sheetWrap,{paddingBottom:Math.max(X.bottom,q.space.lg),opacity:Re,transform:[{translateY:le}]}],onLayout:e=>{ne.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Ve})})});return Fe?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...ze,value:Ae,onPress:()=>N(!0),testID:f}),Be]}):Be},buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({gestureRoot:{width:"100%"},sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navText:{fontSize:e.text["2xl"].size,lineHeight:Math.round(e.text["2xl"].size*e.leading.heading),color:e.colors["text-body"],fontWeight:e.weight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.text.base.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerCaret:{marginLeft:e.space.xs,alignItems:"center",justifyContent:"center"},gridRow:{flexDirection:"row"},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.space.xs},yearInner:{width:"100%",height:"100%",borderRadius:e.radius.lg,...smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.text.base.size,lineHeight:Math.round(e.text.base.size*e.leading.body),fontWeight:e.weight.semibold},decadeRangeText:{fontSize:e.text.xs.size,lineHeight:Math.round(e.text.xs.size*e.leading.body),fontWeight:e.weight.medium,marginTop:e.space.xxs},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};export{DatePicker};export default DatePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useEffect,useMemo,useState}from"react";import{Platform}from"react-native";import{useMobileUiText}from"../../text/index.js";import{DECIMAL_INPUT_TEXT}from"../../text/phone/decimalInput.g.js";import{Input}from"../Input/index.js";import{jsx as _jsx}from"react/jsx-runtime";export function cleanDecimalText(e,{whole:t,signed:
|
|
1
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{forwardRef,useEffect,useMemo,useState}from"react";import{Platform}from"react-native";import{useMobileUiText}from"../../text/index.js";import{DECIMAL_INPUT_TEXT}from"../../text/phone/decimalInput.g.js";import{Input}from"../Input/index.js";import{jsx as _jsx}from"react/jsx-runtime";export function cleanDecimalText(e,{whole:t,signed:r,decimals:n,allowExponent:o}={}){const l=String(e??"");if(o)return l.replace(/[^\d.eE+-]/g,"");const i=Boolean(r)&&l.replace(/[^\d.,-]/g,"").startsWith("-");let a=l.replace(t?/\D/g:/[^\d.,]/g,"");const c=a.search(/[.,]/);if(-1!==c){const e=a.slice(c+1).replace(/[.,]/g,"");a=a.slice(0,c+1)+(null==n?e:e.slice(0,n))}return(i?"-":"")+a}export function isUnclearDecimalComma(e){return/,\d{3}$/.test(String(e??""))}export function pointDecimalText(e){return isUnclearDecimalComma(e)?e:e.replace(",",".")}export function parseDecimalText(e){if(isUnclearDecimalComma(e))return"";const t=pointDecimalText(e);if(""===t||"-"===t||"."===t||"-."===t)return"";const r=Number(t);return Number.isFinite(r)?r:""}const textOf=e=>null==e?"":String(e),toNull=e=>""===e?null:e;function keyboardFor({whole:e,signed:t,allowExponent:r}){return r?"ios"===Platform.OS?"numbers-and-punctuation":"default":t?"numeric":e?"number-pad":"decimal-pad"}const DecimalInput=forwardRef((e,t)=>{const{symbol:r,value:n,onChange:o,onBlur:l,min:i,max:a,whole:c=!1,signed:m=!1,decimals:s,allowExponent:u=!1,labels:p,error:d,readOnly:x=!1,disabled:f=!1,...D}=e,T=useMobileUiText("decimalInput",DECIMAL_INPUT_TEXT),b=useMemo(()=>({...T,...p}),[T,p]),[I,g]=useState(textOf(n));useEffect(()=>{g(e=>toNull(parseDecimalText(e))===(n??null)?e:textOf(n))},[n]);const w=x||f,y={whole:c,signed:m,decimals:s,allowExponent:u},C=I;return _jsx(Input,{prefix:r,keyboardType:keyboardFor(y),autoCapitalize:"none",autoCorrect:!1,readOnly:x,disabled:f,...D,ref:t,error:d??(isUnclearDecimalComma(C)?b.unclearComma:void 0),value:C,onChangeText:w?void 0:e=>{reportIdleActivity();const t=cleanDecimalText(e,y),r=u?""===t?"":Number(t):parseDecimalText(t);""!==r&&Number.isFinite(r)&&(null!=a&&r>a||null!=i&&r<i)||(g(t),o?.(toNull(parseDecimalText(t))))},onBlur:w?void 0:e=>{const t=pointDecimalText(C);t!==C&&g(t),l?.(e)}})});DecimalInput.displayName="DecimalInput";export{DecimalInput};export default DecimalInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useMemo}from"react";import{useMobileUiText}from"../../text/index.js";import{IDLE_TIMEOUT_DIALOG_TEXT}from"../../text/phone/idleTimeoutDialog.g.js";import{fillText}from"../../text/textStore.js";import{Dialog}from"../Dialog/index.js";import{jsx as _jsx}from"react/jsx-runtime";const noop=()=>{},formatRemaining=e=>{if(!Number.isFinite(e)||e<0)throw new RangeError("IdleTimeoutDialog remainingMs must be a finite number of milliseconds, zero or more");const t=Math.ceil(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`};export function IdleTimeoutDialog({open:e,remainingMs:t,onStay:o,onSignOut:i,labels:n,testID:r}){const s=useMobileUiText("idleTimeoutDialog",IDLE_TIMEOUT_DIALOG_TEXT),a=useMemo(()=>({...s,...n}),[s,n]),m=formatRemaining(t);return _jsx(Dialog,{open:e,onClose:noop,tone:"warning",title:a.title,message:fillText(a.message,{time:m}),actionsLayout:"stacked",dismissOnAction:!1,actions:[{label:a.stay,onPress:o,tone:"primary"},{label:a.signOut,onPress:i,tone:"neutral"}],testID:r})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{IdleTimeoutDialog}from"./IdleTimeoutDialog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{useReducedMotion}from"../../hooks/index.js";import{useMobileUiText}from"../../text/index.js";import{INPUT_TEXT}from"../../text/phone/input.g.js";import{createAnimatedValue,fontFor,resolveFieldSize,setNativeValue,useTheme}from"../../theme/index.js";import{mergeRefs,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon,slotIconView}from"../AppIcon/slotIcon.js";import{Button}from"../Button/index.js";import{FieldBase,FieldErrorGlyph,FieldLabel,fieldTextAsString,hasFieldText,RequiredPlaceholder,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{TextInkContext,useTextInk}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Input=forwardRef((e,t)=>{const{label:i,help:
|
|
1
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{useReducedMotion}from"../../hooks/index.js";import{useMobileUiText}from"../../text/index.js";import{INPUT_TEXT}from"../../text/phone/input.g.js";import{createAnimatedValue,fontFor,resolveFieldSize,setNativeValue,useTheme}from"../../theme/index.js";import{mergeRefs,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon,slotIconView}from"../AppIcon/slotIcon.js";import{Button}from"../Button/index.js";import{FieldBase,FieldErrorGlyph,FieldLabel,fieldTextAsString,hasFieldText,RequiredPlaceholder,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{TextInkContext,useTextInk}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Input=forwardRef((e,t)=>{const{label:i,help:o,placeholder:n,value:l,onChangeText:s,error:r,helperText:a,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:p=!1,multiline:f=!1,leftIcon:m,rightIcon:x,unit:g,unitStyle:h,prefix:y,prefixStyle:v,readOnly:b=!1,action:S,actionStyle:T,size:j="md",variant:I,labelMode:w,required:V=!1,maxLength:F,showCounter:R=!0,textAlign:_,format:A,parse:D,style:z,fieldStyle:k,inputStyle:P,labelStyle:C,messageStyle:L,radius:M,onFocus:N,onBlur:E,accessibilityLabel:B,labels:H,testID:O,editable:q,...G}=e;assertValidValue("Input","variant",I,["outline","filled","underline"]),assertValidValue("Input","size",e.size,["sm","md","lg"]),assertValidValue("Input","labelMode",w,["float","top"]),assertValidValue("Input","type",e.type,["input","password","textarea"]);const U=useMobileUiText("input",INPUT_TEXT),W=useMemo(()=>({...U,...H}),[U,H]),X=useTheme(),$=useMemo(()=>buildStyles(X),[X]),J=resolveFieldSize(X,j),K=X.components.input[j]["multiline-min-height"],Q=Math.round(J.text*X.leading.body),Y=I??X.settings.components.input?.defaultVariant??X.settings.components.field?.defaultVariant??"outline",Z=w??X.settings.components.input?.defaultLabelMode??"top",[ee,te]=useState(!1),[ie,oe]=useState(!1),ne="password"===d||u||c,le="password"===d||u,se="textarea"===d||f,re=se?Math.round(.1*J.text):0,ae="string"==typeof l&&l.length>0,de=hasFieldText(r),ce=!0===r||de,ue=hasFieldText(a),pe=de||!ce&&ue,fe=hasFieldText(i),me=hasFieldText(y),xe=!p&&!1!==q,ge=ee||ae||me,he=useRef(null),ye=useMemo(()=>mergeRefs(he,t),[t]),ve=useCallback(()=>{xe&&he.current?.focus()},[xe]),be=fe&&"float"===Z,Se=useRef(createAnimatedValue(0)).current,Te=useRef(createAnimatedValue(pe?1:0)).current;useEffect(()=>{const e=Animated.timing(Te,{toValue:pe?1:0,duration:X.motion.duration.fast,easing:Easing.bezier(...X.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[pe,Te,X.motion.duration.fast,X.motion.ease["in-out"]]);const je=useReducedMotion(),Ie=X.settings.components.input?.shakeOnError??!1,we=useRef(ce);useEffect(()=>{if(!Ie)return void(we.current=ce);let e;return ce&&!we.current&&(je||(setNativeValue(Se,0),e=Animated.sequence([Animated.timing(Se,{toValue:1,duration:50,useNativeDriver:nativeDriver}),Animated.timing(Se,{toValue:-1,duration:50,useNativeDriver:nativeDriver}),Animated.timing(Se,{toValue:1,duration:50,useNativeDriver:nativeDriver}),Animated.timing(Se,{toValue:-1,duration:50,useNativeDriver:nativeDriver}),Animated.timing(Se,{toValue:0,duration:100,useNativeDriver:nativeDriver})]),e.start()),triggerHaptic("notificationError")),we.current=ce,()=>e?.stop()},[ce,Se,Ie,je]);const Ve=useCallback(e=>{te(!0),N?.(e)},[N]),Fe=useCallback(e=>{te(!1),E?.(e)},[E]),Re=useCallback(()=>{triggerHaptic("selection"),oe(e=>!e)},[]),Ae=X.colors["field-caret"],De=X.settings.components.input?.tintLabelOnFocus??!1,ze=ee&&De?X.colors["field-border-focus"]:X.colors["field-label"],ke=Se.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),Pe=Boolean(x)||Boolean(g)||le,Ce="underline"===Y,Le=m?J.icon+X.space.md+1+X.space.md:0,Me=useFloatingLabel({label:i,enabled:be,floated:ge,required:V,variant:Y,sizeTokens:J,leadingOffset:Le,trailingOffset:Pe?J.icon+X.space.sm:0,textAlign:"center"===_||"right"===_?_:"left",paddingLeft:Ce?X.space.none:J["padding-x"],lineHeight:se?Q:void 0,restNudge:re,floatTrim:se?2:0,color:ze,style:C}),Ne=resolveFieldTextStyle(X,{disabled:p}),Ee=Ne.color,Be=Ne.placeholderColor,He=V&&!fe&&!ae&&"string"==typeof n&&n.length>0,Oe=ce?r:a,qe=R&&"number"==typeof F&&"string"==typeof l?`${l.length} / ${F}`:null,Ge=ce?X.colors["field-message"]:X.colors["text-muted"],Ue=useTextInk(L,J["message-text"],Ge),We=B??fieldTextAsString(i)??n,Xe=p?X.colors["field-icon-disabled"]:ee?X.colors["field-icon-focus"]:X.colors["field-icon"],$e={focused:ee,disabled:p,error:ce,color:Xe,size:J.icon},renderSlot=e=>renderSlotIcon(e,$e),Je=(()=>{if(le){const e=(ie?X.settings.icons.eyeOff:X.settings.icons.eye)??(ie?defaultIcons.eyeOff:defaultIcons.eye);return _jsx(Pressable,{onPress:Re,disabled:!xe,hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:ie?W.hidePassword:W.showPassword,children:e({size:J.icon,color:Xe})})}const e=g?_jsx(Text,{style:[$.unit,{fontSize:J.text,color:Be},h],children:g}):null,t=x?slotIconView(x,renderSlot(x)):null;return e&&t?_jsxs(View,{style:$.trailingRow,children:[e,t]}):e??t})(),Ke=m?slotIconView(m,renderSlot(m)):null,Qe=StyleSheet.flatten(v),Ye=Qe?.fontSize??J.text,Ze=Qe?.color??Be,et=useMemo(()=>({fontSize:Ye,color:Ze}),[Ye,Ze]),tt=me?"string"==typeof y||"number"==typeof y?_jsx(Text,{style:[$.prefix,{fontSize:J.text,color:Be,marginRight:X.space.xs,lineHeight:se?Q:void 0,paddingTop:se?re:void 0},v],children:y}):_jsx(View,{style:[$.prefixNode,{marginRight:X.space.xs,minHeight:se?Q:void 0,justifyContent:"center",paddingTop:se?re:void 0}],children:_jsx(Text,{style:[$.prefix,{fontSize:J.text,color:Be,lineHeight:se?Q:void 0},v],children:_jsx(TextInkContext.Provider,{value:et,children:y})})}):null,it=S?_jsx(Button,{variant:S.variant??"outline",tone:S.tone??"primary",size:j,label:S.label,leftIcon:S.icon,loading:S.loading,disabled:p||S.disabled,onPress:S.onPress,pressAnimation:!1,testID:S.testID,style:[$.action,{minHeight:J["min-height"],alignSelf:se?"flex-start":"stretch"},T]}):null;return _jsxs(Animated.View,{style:[$.container,{transform:[{translateX:ke}]},z],children:[fe&&!be?_jsx(FieldLabel,{size:j,required:V,help:o,color:ze,style:C,children:i}):null,_jsxs(View,{style:[$.fieldRow,{columnGap:X.space.sm,alignItems:se?"flex-start":"stretch"}],children:[_jsxs(View,{style:$.fieldWrapper,children:[_jsxs(FieldBase,{testID:O?`${O}-field`:void 0,size:j,variant:Y,focused:ee,disabled:p,error:ce,filled:ae,minHeight:se?K:void 0,radius:M,leading:Ke,leadingDivider:null!=m,paddingLeft:Ce?X.space.none:void 0,trailing:Je,slotAlign:se?"top":"center",slotLineHeight:se?Q:void 0,topNotch:Me.topNotch,onPress:ve,pressFeedback:!1,style:k,children:[tt,_jsxs(View,{style:$.inputWrap,children:[_jsx(TextInput,{ref:ye,style:[$.input,{color:Ee,fontSize:J.text,...Ne.weightStyle,paddingLeft:Ce?X.space.none:void 0,minHeight:se?K-2*J["padding-y"]:void 0,lineHeight:se?Q:void 0,paddingTop:se?re:void 0,textAlignVertical:se?"top":"center"},P],textAlign:_,placeholder:be&&!ge||He?void 0:n,placeholderTextColor:Be,value:A&&null!=l?A(l):l,onChangeText:e=>{reportIdleActivity(),s&&s(D?D(e):e)},onFocus:Ve,onBlur:Fe,editable:xe,readOnly:b,secureTextEntry:ne&&!ie,multiline:se,autoCapitalize:ne?"none":void 0,autoCorrect:!ne&&void 0,maxLength:F,selectionColor:Ae,accessibilityLabel:We,accessibilityState:{disabled:p},"aria-disabled":p,testID:O,...G}),He&&"string"==typeof n?_jsx(RequiredPlaceholder,{text:n,color:Be,fontSize:J.text,weightStyle:Ne.weightStyle,align:se?"top":"center",paddingTop:se?re:void 0,textAlign:_}):null]})]}),Me.node]}),it]}),pe||qe?_jsxs(View,{style:[$.footerRow,{marginTop:J["message-gap"]}],children:[pe?_jsxs(Animated.View,{style:[$.messageRow,{columnGap:X.space.xs,opacity:Te}],accessibilityLiveRegion:ce?"polite":"none",children:[ce?_jsx(FieldErrorGlyph,{size:J["message-text"],color:Ge}):null,_jsx(Text,{style:[$.messageText,{color:Ge,fontSize:J["message-text"],...fontFor(X,"normal")},L],children:_jsx(TextInkContext.Provider,{value:Ue,children:Oe})})]}):_jsx(View,{style:$.footerSpacer}),qe?_jsx(Text,{style:[$.counterText,{color:X.colors["text-subtle"],fontSize:J["message-text"],...fontFor(X,"normal")}],children:qe}):null]}):null]})});Input.displayName="Input";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},fieldRow:{flexDirection:"row"},fieldWrapper:{position:"relative",overflow:"visible",flex:1},action:{flexShrink:0},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"},unit:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},footerSpacer:{flex:1},messageRow:{flex:1,flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1},counterText:{flexShrink:0,includeFontPadding:!1}});export{Input};export default Input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{useMobileUiText}from"../../text/index.js";import{NUMBER_INPUT_TEXT}from"../../text/phone/numberInput.g.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_LONG_PRESS_DELAY=500,DEFAULT_LONG_PRESS_INTERVAL=80,roundToPrecision=(e,t)=>{if(!Number.isFinite(e))return 0;if(t<=0)return Math.round(e);const i=10**t;return Math.round(e*i)/i},clamp=(e,t,i)=>e<t?t:e>i?i:e,formatValue=(e,t,i)=>Number.isFinite(e)?t&&i>0?e.toFixed(i):String(Math.trunc(e)):"",sanitizeTyped=(e,t)=>{if(!e)return"";let i=e.replace(/[^0-9.-]/g,"");if(i=i.replace(/(?!^)-/g,""),t){const e=i.indexOf(".");-1!==e&&(i=i.slice(0,e+1)+i.slice(e+1).replace(/\./g,""))}else i=i.replace(/\./g,"");return i},NumberInput=forwardRef((e,t)=>{const{value:i,defaultValue:s,onChange:l,min:r=Number.NEGATIVE_INFINITY,max:a=Number.POSITIVE_INFINITY,step:n=1,allowDecimal:o=!1,precision:c=0,label:u,help:d,helperText:m,error:b,disabled:p=!1,size:f="md",variant:x="inline",unit:h,haptic:
|
|
1
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import React,{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{useMobileUiText}from"../../text/index.js";import{NUMBER_INPUT_TEXT}from"../../text/phone/numberInput.g.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_LONG_PRESS_DELAY=500,DEFAULT_LONG_PRESS_INTERVAL=80,roundToPrecision=(e,t)=>{if(!Number.isFinite(e))return 0;if(t<=0)return Math.round(e);const i=10**t;return Math.round(e*i)/i},clamp=(e,t,i)=>e<t?t:e>i?i:e,formatValue=(e,t,i)=>Number.isFinite(e)?t&&i>0?e.toFixed(i):String(Math.trunc(e)):"",sanitizeTyped=(e,t)=>{if(!e)return"";let i=e.replace(/[^0-9.-]/g,"");if(i=i.replace(/(?!^)-/g,""),t){const e=i.indexOf(".");-1!==e&&(i=i.slice(0,e+1)+i.slice(e+1).replace(/\./g,""))}else i=i.replace(/\./g,"");return i},NumberInput=forwardRef((e,t)=>{const{value:i,defaultValue:s,onChange:l,min:r=Number.NEGATIVE_INFINITY,max:a=Number.POSITIVE_INFINITY,step:n=1,allowDecimal:o=!1,precision:c=0,label:u,help:d,helperText:m,error:b,disabled:p=!1,size:f="md",variant:x="inline",unit:h,haptic:y,labels:T,accessibilityLabel:I,style:S,inputStyle:g,buttonStyle:N,unitStyle:_,labelStyle:F,textInputProps:j,testID:v}=e;assertValidValue("NumberInput","size",e.size,NUMBER_INPUT_SIZES),assertValidValue("NumberInput","variant",e.variant,NUMBER_INPUT_VARIANTS);const V=useMobileUiText("numberInput",NUMBER_INPUT_TEXT),R=useMemo(()=>({...V,...T}),[V,T]),[C,E]=useControllableState({value:i,defaultValue:s??e.min??0,onChange:l}),P=useTheme(),w=resolveFieldSize(P,f),z=resolveFieldTextStyle(P,{disabled:p}),A=useMemo(()=>buildStyles(P),[P]),M=useRef(null),[L,U]=useState(formatValue(C,o,c)),[k,B]=useState(!1),[D,H]=useState(!1),O=useCallback(()=>{p||M.current?.focus()},[p]),G=useRef(null),W=useRef(null),Y=useCallback(()=>{null!==G.current&&(clearTimeout(G.current),G.current=null),null!==W.current&&(clearInterval(W.current),W.current=null)},[]);useEffect(()=>Y,[Y]),useEffect(()=>{k||U(formatValue(C,o,c))},[C,o,c,k]);const $=C<=r,X=C>=a,Z=!p,q=useCallback(e=>{const t=roundToPrecision(e,o?c:0),i=clamp(t,r,a);i!==C&&E(i)},[o,a,r,E,c,C]),J=useCallback(()=>{if(!Z||$)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),q(C-n)},[$,Z,y,q,n,C]),K=useCallback(()=>{if(!Z||X)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),q(C+n)},[X,Z,y,q,n,C]);React.useImperativeHandle(t,()=>({focus:()=>M.current?.focus(),blur:()=>M.current?.blur(),clear:()=>{U(""),Number.isFinite(r)&&r>0?E(r):E(0<r?r:Math.min(a,0))}}),[a,r,E]);const Q=useCallback(e=>{Z&&(Y(),G.current=setTimeout(()=>{W.current=setInterval(()=>{"inc"===e?K():J()},80)},500))},[Y,J,K,Z]),ee=useCallback(e=>{reportIdleActivity();const t=sanitizeTyped(e,o);U(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=r&&i<=a&&i!==C&&E(roundToPrecision(i,o?c:0))},[o,a,r,E,c,C]),te=useCallback(()=>{B(!1),H(!1);const e=Number(L);if(""===L||!Number.isFinite(e))return void U(formatValue(C,o,c));const t=roundToPrecision(e,o?c:0),i=clamp(t,r,a);i!==C&&E(i),U(formatValue(i,o,c))},[o,L,a,r,E,c,C]),ie=useCallback(()=>{B(!0),H(!0)},[]),se=$||p?P.colors["text-disabled"]:P.colors["text-body"],le=X||p?P.colors["text-disabled"]:P.colors["text-body"],re=w.icon+8,renderStepper=(e,t,i,s,l,r)=>_jsx(Pressable,{onPress:t,onLongPress:()=>Q(e),onPressOut:Y,delayLongPress:500,disabled:i,accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:re,height:re,alignItems:"center",justifyContent:"center",borderRadius:P.radius.pill,...smoothCorners},e&&!i?{backgroundColor:P.colors["surface-pressed"]}:null,N],testID:`${v??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:_jsx(Text,{variant:"body",weight:"semibold",style:{fontSize:w.icon,color:l,fontWeight:P.weight.semibold,lineHeight:w.icon+2},children:r})}),ae=I??fieldTextAsString(u)??R.input,ne=!0===b||hasFieldText(b),oe=_jsx(FieldBase,{testID:v?`${v}-field`:void 0,size:f,disabled:p,error:ne,filled:!0,focused:D,onPress:O,pressFeedback:!1,leading:renderStepper("dec",J,$||p,R.decrease,se,"−"),trailing:renderStepper("inc",K,X||p,R.increase,le,"+"),children:_jsxs(View,{style:A.inputRow,children:[_jsx(TextInput,{ref:M,value:L,onChangeText:ee,onFocus:ie,onBlur:te,editable:!p,keyboardType:o?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:ae,accessibilityValue:{now:Number.isFinite(C)?C:0},accessibilityState:{disabled:p},"aria-disabled":p,accessibilityActions:[{name:"increment",label:R.increase},{name:"decrement",label:R.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&K(),"decrement"===e.nativeEvent.actionName&&J()},style:[A.input,{fontSize:w.text,color:z.color,...z.weightStyle},g],...j}),h?_jsx(Text,{variant:"bodySmall",style:[A.unit,{fontSize:w.text,color:z.placeholderColor},_],children:h}):null]})}),ce=hasFieldText(u)?_jsx(FieldLabel,{size:f,help:d,style:F,children:u}):null,ue=_jsx(FieldMessage,{size:f,error:ne,text:ne?b:m});return _jsxs(View,"horizontal"===x?{style:[A.horizontalContainer,S],testID:v,accessibilityState:{disabled:p},"aria-disabled":p,children:[_jsx(View,{style:A.horizontalLabelWrap,children:ce}),_jsxs(View,{children:[oe,ue]})]}:{style:[S],testID:v,accessibilityState:{disabled:p},"aria-disabled":p,children:[ce,oe,ue]})});NumberInput.displayName="NumberInput";const buildStyles=e=>StyleSheet.create({inputRow:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},input:{flex:1,textAlign:"center",padding:e.space.none,margin:e.space.none,includeFontPadding:!1},unit:{marginLeft:e.space.xs},label:{marginBottom:e.space.xs},helper:{marginTop:e.space.xs},horizontalContainer:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},horizontalLabelWrap:{flexShrink:1,paddingRight:e.space.md}});export{NumberInput};export default NumberInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState,useReducedMotion}from"../../hooks/index.js";import{fillText,useMobileUiText}from"../../text/index.js";import{OTP_INPUT_TEXT}from"../../text/phone/otpInput.g.js";import{createAnimatedValue,fontFor,resolveOtpInputSize,setNativeValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{FieldBase,FieldMessage,hasFieldText}from"../FieldBase/FieldBase.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const cellAt=(e,t)=>{const i=e[t];if(void 0===i)throw new Error(`OTP cell ${t} is outside the ${e.length} cells.`);return i},sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=forwardRef((e,t)=>{const{value:i,defaultValue:n,onChange:
|
|
1
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState,useReducedMotion}from"../../hooks/index.js";import{fillText,useMobileUiText}from"../../text/index.js";import{OTP_INPUT_TEXT}from"../../text/phone/otpInput.g.js";import{createAnimatedValue,fontFor,resolveOtpInputSize,setNativeValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{FieldBase,FieldMessage,hasFieldText}from"../FieldBase/FieldBase.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const cellAt=(e,t)=>{const i=e[t];if(void 0===i)throw new Error(`OTP cell ${t} is outside the ${e.length} cells.`);return i},sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=forwardRef((e,t)=>{const{value:i,defaultValue:n,onChange:r,onComplete:s,length:a=6,keyboardType:o="number-pad",autoFocus:l=!1,autoFocusDelay:u=0,disabled:c=!1,error:d,size:m="md",secure:p=!1,haptic:f,labels:g,onFocus:h,accessibilityLabel:b,style:x,cellStyle:y,textStyle:v,testID:T}=e;assertValidValue("OTPInput","size",e.size,["sm","md","lg"]),assertValidValue("OTPInput","keyboardType",e.keyboardType,["number-pad","default"]);const j=useMobileUiText("otpInput",OTP_INPUT_TEXT),V=useMemo(()=>({...j,...g}),[j,g]),[A,C]=useControllableState({value:i,defaultValue:n??"",onChange:r}),I=useTheme(),k=useMemo(()=>buildStyles(I),[I]),w=resolveOtpInputSize(I,m),E=I.components["otp-input"][m].radius,S=useRef([]),[M,D]=useState(-1),[F,O]=useState(0),P=useRef(null),_=useRef(createAnimatedValue(0)).current,R=useRef(new Map),z=useMemo(()=>{const e=R.current,t=[];for(let i=0;i<a;i+=1){let n=e.get(i);n||(n=new Animated.Value(0),e.set(i,n)),t.push(n)}for(const t of Array.from(e.keys()))t>=a&&e.delete(t);return t},[a]),N=useRef(-1),H=I.settings.components["otp-input"]?.shakeOnError??!1,B=useReducedMotion(),L=!0===d||hasFieldText(d);useEffect(()=>{let e;return null===P.current||!L||P.current||(f&&triggerHaptic("notificationError"),H&&!B&&(setNativeValue(_,0),e=Animated.sequence([Animated.timing(_,{toValue:1,duration:I.motion.duration.instant,easing:Easing.linear,useNativeDriver:nativeDriver}),Animated.timing(_,{toValue:-1,duration:I.motion.duration.instant,easing:Easing.linear,useNativeDriver:nativeDriver}),Animated.timing(_,{toValue:1,duration:I.motion.duration.instant,easing:Easing.linear,useNativeDriver:nativeDriver}),Animated.timing(_,{toValue:0,duration:I.motion.duration.instant,easing:Easing.linear,useNativeDriver:nativeDriver})]),e.start())),P.current=L,()=>e?.stop()},[L,_,H,f,B,I.motion.duration.instant]),useEffect(()=>{const e=N.current;if(N.current=M,e===M)return;if(-1===e&&-1===M)return;const t=[];return z.forEach((i,n)=>{const r=n===M?1:0;if(n!==M&&n!==e)return;const s=Animated.timing(i,{toValue:r,duration:I.motion.duration.fast,easing:Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:nativeDriver});s.start(),t.push(s)}),()=>t.forEach(e=>{e.stop()})},[M,z,I]);const U=useCallback(e=>{const t=S.current[e];t&&t.focus()},[]);useImperativeHandle(t,()=>({focus:()=>U(0),blur:()=>{const e=S.current[Math.max(M,0)];e?.blur()},clear:()=>{C(""),U(0)}}),[U,M,C]),useEffect(()=>{if(l&&!c){const e=setTimeout(()=>U(0),u);return()=>clearTimeout(e)}},[l,u,c,U]);const W=useMemo(()=>{const e=new Array(a).fill("");for(let t=0;t<Math.min(A.length,a);t+=1)e[t]=A.charAt(t);return e},[A,a]),X=useMemo(()=>W.map((e,t)=>({key:`otp-cell-${t}`,index:t,char:e})),[W]),$=useCallback(e=>{const t=e.slice(0,a);t!==A&&(C(t),t.length===a&&s&&s(t))},[a,C,s,A]),q=useCallback((e,t)=>{const i=t.replace(/\u200B/g,""),n=sanitizeChar(i,o);if(!n){const t=W.slice(),i=cellAt(W,e).length>0;if(t[e]="",$(t.join("").slice(0,a)),!i&&e>0){const t=W.slice();t[e-1]="",$(t.join("")),U(e-1)}return}const r=cellAt(W,e),s=r&&n.length>a&&n.startsWith(r)?n.slice(r.length):n;if(s.length>=a){const t=s.slice(0,a),i=A.length;return $(t),t.length!==i&&f&&triggerHaptic(f),void S.current[e]?.blur()}const l=W.slice();let u=e;for(let e=0;e<n.length&&u<a;e+=1)l[u]=n.charAt(e),u+=1;const c=l.join("").slice(0,a),d=A.length;$(c),c.length!==d&&f&&triggerHaptic(f);const m=Math.min(u,a-1);u>=a?S.current[e]?.blur():U(m)},[W,U,o,a,f,$,A]),G=useCallback((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===cellAt(W,e).length){if(e>0){const t=W.slice();t[e-1]="",$(t.join("")),U(e-1)}}else{const t=W.slice();t[e]="",$(t.join(""))}},[W,U,$]),K=useCallback((e,t)=>{D(e),h?.(t)},[h]),J=useCallback(()=>{D(-1)},[]),Q=useCallback(()=>{if(c)return;const e=W.indexOf("");U(-1===e?a-1:e)},[W,c,U,a]),Y=useCallback(e=>{O(e.nativeEvent.layout.width)},[]),Z=b??fillText(V.field,{length:a}),ee=F>0?Math.max(24,Math.min(w.cell,Math.floor((F-w.gap*(a-1))/a))):w.cell,te=_.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return _jsxs(View,{style:x,onLayout:Y,accessible:!0,accessibilityRole:"none",accessibilityLabel:Z,accessibilityValue:{text:i},accessibilityState:{disabled:c},"aria-disabled":c,testID:T,children:[_jsx(Pressable,{onPress:Q,disabled:c,accessible:!1,children:_jsx(Animated.View,{style:[k.row,{columnGap:w.gap,transform:[{translateX:te}]}],children:X.map(({key:e,index:t,char:i})=>{const n=M===t,r=i.length>0,s=L?I.colors["danger-border"]:I.colors["focus-ring"],l=z[t];if(!l)return null;const u=p&&r?"●":i;return _jsxs(View,{style:k.cellWrapper,children:[_jsxs(FieldBase,{size:m,width:ee,height:ee,radius:E,borderWidth:1.5,focused:n,error:L,filled:r,disabled:c,paddingHorizontal:I.space.none,paddingVertical:I.space.none,gap:I.space.none,style:y,children:[_jsx(TextInput,{ref:e=>{S.current[t]=e},value:(p&&r?"":i)||"",onChangeText:e=>{reportIdleActivity(),q(t,e)},onKeyPress:e=>G(t,e),onFocus:e=>K(t,e),onBlur:J,keyboardType:o,editable:!c,selectTextOnFocus:!0,caretHidden:r,maxLength:a+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[k.input,{fontSize:w.text,color:I.colors["text-body"],...fontFor(I,"semibold")},v]}),p&&r?_jsx(View,{pointerEvents:"none",style:k.maskOverlay,children:_jsx(Text,{variant:"body",weight:"semibold",style:[{fontSize:w.text},v],children:u})}):null]}),_jsx(Animated.View,{style:[k.underline,{backgroundColor:s,opacity:l}]})]},e)})})}),_jsx(FieldMessage,{size:m,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{...StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,...smoothCorners}});export{OTPInput};export default OTPInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Pressable,StatusBar,StyleSheet,TextInput,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture}from"react-native-gesture-handler";import{useKeyboardState}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{fillText,useMobileUiText}from"../../text/index.js";import{OPTION_SHEET_TEXT}from"../../text/phone/optionSheet.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{selectOptionAction,selectOptionDescription,selectOptionDisabled,selectOptionIcon,selectOptionLabel,selectOptionValue}from"./optionAccessors.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const SEARCH_ICON_SIZE=18,hostStyle=StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:o,options:s,sections:i,renderSectionHeader:r,renderOption:l,alphabetIndex:n=!1,labels:a,getOptionLabel:c,getOptionValue:d,getOptionDescription:p,isOptionDisabled:u,getOptionIcon:h,destructiveOf:m,getOptionAction:g,value:b,onChange:x,multi:f=!1,searchable:y=!1,searchSelectionColor:S,accessibilityLabel:T,optionStyle:j,selectedOptionStyle:w,optionTextStyle:C,selectedOptionTextStyle:_,testID:I}=e,k=c??selectOptionLabel,O=d??selectOptionValue,R=p??selectOptionDescription,L=u??selectOptionDisabled,V=h??selectOptionIcon,D=g??selectOptionAction,v=useTheme(),H=useSafeAreaInsets(),M=useMemo(()=>buildStyles(v),[v]),[P,A]=useState(""),B=Dimensions.get("window").height,z=Math.round(.7*B),E=useRef(createAnimatedValue(0)).current,{handleGesture:F,opacity:W}=useDragToDismiss({drag:E,travel:z,onDismiss:t,testID:I}),G=useNativeGesture(),N=useKeyboardState(e=>e.height),U=Math.max(0,Math.round(N)),$=Math.max(H.top,StatusBar.currentHeight??0)+v.space.sm,K=U>0,X=K?Math.max(0,Math.min(z,B-U-$)):z,Y=useMemo(()=>{const e=y?P.trim().toLowerCase():"",matches=t=>0===e.length||k(t).toLowerCase().includes(e)||(R(t)??"").toLowerCase().includes(e);if(!i)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return i.forEach((e,o)=>{const s=e.options.filter(matches);if(0!==s.length){t.push({kind:"header",title:e.title});for(const e of s)t.push({kind:"option",option:e,section:o})}}),t},[y,P,s,i,k,R]),Z=useCallback(()=>{t()},[t]),J=useRef(null),Q=useMemo(()=>{const e=new Map;if(!n)return e;let t=0;if(i)for(const[e,o]of Y.entries())"header"===o.kind&&(t=e+1);for(const[o,s]of Y.entries()){if(o<t||"option"!==s.kind)continue;const i=k(s.option).trim().charAt(0).toUpperCase(),r=/^[A-Z]$/.test(i)?i:"#";e.has(r)||e.set(r,o)}return e},[n,Y,i,k]),q=n&&Q.size>0&&0===P.trim().length,ee=useMemo(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Q.has("#")?["#"]:[]],[Q]),te=useCallback(e=>{const t=Q.get(e);void 0!==t&&J.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Q]),oe=useRef(null),se=useCallback(()=>{null!==oe.current&&(clearTimeout(oe.current),oe.current=null)},[]),ie=useCallback(e=>{J.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),se(),oe.current=setTimeout(()=>{oe.current=null,J.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[se]);useEffect(()=>se,[se]);return _jsx(GestureHandlerRootView,{style:M.gestureRoot,children:_jsxs(Animated.View,{testID:I,accessibilityViewIsModal:!0,accessibilityLabel:T??o??a.fallbackName,style:[M.sheet,{maxHeight:X,marginBottom:U,paddingBottom:K?v.space.lg:H.bottom+v.space.lg,backgroundColor:v.colors.surface,borderTopLeftRadius:v.radius.xl,borderTopRightRadius:v.radius.xl,...smoothCorners,opacity:W,transform:[{translateY:E}],...v.shadow.modal}],children:[_jsx(GestureDetector,{gesture:F,children:_jsxs(View,{children:[_jsx(View,{style:M.sheetHandleRow,children:_jsx(View,{style:[M.sheetHandle,{backgroundColor:v.colors.border}]})}),o?_jsx(Text,{variant:"title",style:[M.sheetTitle,{paddingHorizontal:v.space.lg,marginBottom:v.space.sm}],children:o}):null]})}),y?_jsx(View,{style:[M.searchWrap,{marginHorizontal:v.space.lg,marginBottom:v.space.sm}],children:_jsxs(View,{style:[M.searchBox,{backgroundColor:v.colors["bg-subtle"],borderColor:v.colors.border,borderRadius:v.radius.md,...smoothCorners,paddingHorizontal:v.space.md,gap:v.space.sm}],children:[(v.settings.icons.search??defaultIcons.search)({size:18,color:v.colors["text-subtle"]}),_jsx(TextInput,{value:P,onChangeText:A,placeholder:a.searchPlaceholder,placeholderTextColor:v.colors["text-subtle"],selectionColor:S??v.colors["focus-ring"],accessibilityLabel:a.searchOptions,style:[M.searchInput,{color:v.colors["text-body"],fontSize:v.text.base.size,paddingVertical:v.space.sm}]}),P.length>0?_jsx(Pressable,{onPress:()=>A(""),hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:a.clearSearch,children:(v.settings.icons.close??defaultIcons.close)({size:18,color:v.colors["text-muted"]})}):null]})}):null,_jsxs(View,{style:[M.listWrap,q?M.listRow:null],children:[_jsx(GestureDetector,{gesture:G,children:_jsx(FlatList,{ref:J,data:Y,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(O(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return _jsx(View,{accessible:!0,accessibilityRole:"header",style:[M.sectionHeader,{paddingHorizontal:v.space.lg,paddingTop:v.space.md}],children:r?r(e.title):_jsx(Text,{variant:"caption",weight:"semibold",color:"tertiary",style:M.sectionTitle,children:e.title.toUpperCase()})});const o=e.option,s=k(o),i=O(o),n=R(o),a=V(o),c=(d=i,Array.isArray(b)?b.some(e=>String(e)===String(d)):null!=b&&String(b)===String(d));var d;const p=L(o),u=m?.(o)??!1,h=D(o);return _jsxs(Pressable,{onPress:()=>{if(h)return h(),void Z();x(i,o)},disabled:p,android_ripple:{color:v.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{selected:c,disabled:p},"aria-selected":c,"aria-disabled":p,style:({pressed:e})=>[M.optionRow,{backgroundColor:c?v.colors["surface-selected"]:e?v.colors["surface-pressed"]:"transparent",opacity:p?.5:1,paddingHorizontal:v.space.lg,paddingVertical:v.space.md},j,c?w:null],children:[l?_jsx(View,{style:M.optionTextWrap,children:l({option:o,selected:c,disabled:p,index:t})}):_jsxs(_Fragment,{children:[a?_jsx(View,{style:M.optionIcon,children:a}):null,_jsxs(View,{style:M.optionTextWrap,children:[_jsx(Text,{variant:"body",weight:c?"semibold":"medium",color:u?"danger":c?"brand":void 0,style:[M.optionLabel,C,c?_:null],children:s}),n?_jsx(Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:M.optionDescription,children:n}):null]})]}),f?_jsx(View,{style:[M.checkbox,{borderColor:c?v.colors.primary:v.colors.border,backgroundColor:c?v.colors.primary:"transparent"}],children:c?_jsx(View,{style:M.checkboxTick}):null}):c?"icon"===v.settings.components["option-sheet"]?.selectedMarker?_jsx(View,{style:M.singleSelectedIcon,children:(v.settings.icons.selectedTick??defaultIcons.selectedTick)({size:20,color:v.colors.primary})}):_jsx(View,{style:[M.singleSelectedDot,{backgroundColor:v.colors.primary}]}):null]})},onScrollToIndexFailed:ie,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!q,style:q?M.listBesideRail:null,ListEmptyComponent:_jsx(Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:v.space.xl},children:a.empty})})}),q?_jsx(View,{style:[M.rail,{paddingRight:v.space.xs}],accessibilityRole:"list",accessibilityLabel:a.jumpToLetter,testID:"option-sheet-alphabet",children:ee.map(e=>{const t=Q.has(e);return _jsx(Pressable,{onPress:()=>te(e),disabled:!t,hitSlop:{left:8,right:8},...hitSlopMarker({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:fillText(a.jumpTo,{letter:e}),accessibilityState:{disabled:!t},"aria-disabled":!t,style:M.railLetter,children:_jsx(Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[M.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),f?_jsx(View,{style:[M.sheetFooter,{borderTopColor:v.colors["border-subtle"],paddingHorizontal:v.space.lg,paddingVertical:v.space.md}],children:_jsx(Pressable,{onPress:Z,accessibilityRole:"button",accessibilityLabel:a.done,style:({pressed:e})=>[M.doneButton,{backgroundColor:e?v.colors["primary-pressed"]:v.colors.primary,borderRadius:v.radius.md,...smoothCorners,paddingVertical:v.space.sm,paddingHorizontal:v.space.lg}],children:_jsx(Text,{variant:"body",weight:"semibold",style:{color:v.colors["on-primary"]},children:a.done})})}):null]})})}export function OptionSheet(e){const{open:t,onOpenChange:o,onAfterClose:s,labels:i,onClose:r,haptic:l,...n}=e,a=useMobileUiText("optionSheet",OPTION_SHEET_TEXT),c=useMemo(()=>({...a,...i}),[a,i]),d=useRef(o);d.current=o;const p=useRef(!1);return useEffect(()=>{p.current!==t&&(p.current=t,d.current?.(t))},[t]),_jsx(Modal,{open:t,onClose:r,presentation:"bottom",onDismissed:s,haptic:l,contentStyle:hostStyle,labels:{close:c.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??c.fallbackName,children:_jsx(OptionSheetPanel,{...n,onClose:r,labels:c})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:Math.round(e.text.xs.size*e.leading.heading)},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,...smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});export default OptionSheet;
|
|
1
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Pressable,StatusBar,StyleSheet,TextInput,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture}from"react-native-gesture-handler";import{useKeyboardState}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{fillText,useMobileUiText}from"../../text/index.js";import{OPTION_SHEET_TEXT}from"../../text/phone/optionSheet.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{selectOptionAction,selectOptionDescription,selectOptionDisabled,selectOptionIcon,selectOptionLabel,selectOptionValue}from"./optionAccessors.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const SEARCH_ICON_SIZE=18,hostStyle=StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:o,options:s,sections:i,renderSectionHeader:r,renderOption:l,alphabetIndex:n=!1,labels:a,getOptionLabel:c,getOptionValue:d,getOptionDescription:p,isOptionDisabled:u,getOptionIcon:h,destructiveOf:m,getOptionAction:b,value:g,onChange:x,multi:f=!1,searchable:y=!1,searchSelectionColor:S,accessibilityLabel:T,optionStyle:j,selectedOptionStyle:w,optionTextStyle:C,selectedOptionTextStyle:_,testID:I}=e,k=c??selectOptionLabel,O=d??selectOptionValue,R=p??selectOptionDescription,L=u??selectOptionDisabled,V=h??selectOptionIcon,D=b??selectOptionAction,v=useTheme(),H=useSafeAreaInsets(),M=useMemo(()=>buildStyles(v),[v]),[P,A]=useState(""),B=useCallback(e=>{reportIdleActivity(),A(e)},[]),z=Dimensions.get("window").height,E=Math.round(.7*z),F=useRef(createAnimatedValue(0)).current,{handleGesture:W,opacity:G}=useDragToDismiss({drag:F,travel:E,onDismiss:t,testID:I}),N=useNativeGesture(),U=useKeyboardState(e=>e.height),$=Math.max(0,Math.round(U)),K=Math.max(H.top,StatusBar.currentHeight??0)+v.space.sm,X=$>0,Y=X?Math.max(0,Math.min(E,z-$-K)):E,Z=useMemo(()=>{const e=y?P.trim().toLowerCase():"",matches=t=>0===e.length||k(t).toLowerCase().includes(e)||(R(t)??"").toLowerCase().includes(e);if(!i)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return i.forEach((e,o)=>{const s=e.options.filter(matches);if(0!==s.length){t.push({kind:"header",title:e.title});for(const e of s)t.push({kind:"option",option:e,section:o})}}),t},[y,P,s,i,k,R]),J=useCallback(()=>{t()},[t]),Q=useRef(null),q=useMemo(()=>{const e=new Map;if(!n)return e;let t=0;if(i)for(const[e,o]of Z.entries())"header"===o.kind&&(t=e+1);for(const[o,s]of Z.entries()){if(o<t||"option"!==s.kind)continue;const i=k(s.option).trim().charAt(0).toUpperCase(),r=/^[A-Z]$/.test(i)?i:"#";e.has(r)||e.set(r,o)}return e},[n,Z,i,k]),ee=n&&q.size>0&&0===P.trim().length,te=useMemo(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...q.has("#")?["#"]:[]],[q]),oe=useCallback(e=>{const t=q.get(e);void 0!==t&&Q.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[q]),se=useRef(null),ie=useCallback(()=>{null!==se.current&&(clearTimeout(se.current),se.current=null)},[]),re=useCallback(e=>{Q.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),ie(),se.current=setTimeout(()=>{se.current=null,Q.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[ie]);useEffect(()=>ie,[ie]);return _jsx(GestureHandlerRootView,{style:M.gestureRoot,children:_jsxs(Animated.View,{testID:I,accessibilityViewIsModal:!0,accessibilityLabel:T??o??a.fallbackName,style:[M.sheet,{maxHeight:Y,marginBottom:$,paddingBottom:X?v.space.lg:H.bottom+v.space.lg,backgroundColor:v.colors.surface,borderTopLeftRadius:v.radius.xl,borderTopRightRadius:v.radius.xl,...smoothCorners,opacity:G,transform:[{translateY:F}],...v.shadow.modal}],children:[_jsx(GestureDetector,{gesture:W,children:_jsxs(View,{children:[_jsx(View,{style:M.sheetHandleRow,children:_jsx(View,{style:[M.sheetHandle,{backgroundColor:v.colors.border}]})}),o?_jsx(Text,{variant:"title",style:[M.sheetTitle,{paddingHorizontal:v.space.lg,marginBottom:v.space.sm}],children:o}):null]})}),y?_jsx(View,{style:[M.searchWrap,{marginHorizontal:v.space.lg,marginBottom:v.space.sm}],children:_jsxs(View,{style:[M.searchBox,{backgroundColor:v.colors["bg-subtle"],borderColor:v.colors.border,borderRadius:v.radius.md,...smoothCorners,paddingHorizontal:v.space.md,gap:v.space.sm}],children:[(v.settings.icons.search??defaultIcons.search)({size:18,color:v.colors["text-subtle"]}),_jsx(TextInput,{value:P,onChangeText:B,placeholder:a.searchPlaceholder,placeholderTextColor:v.colors["text-subtle"],selectionColor:S??v.colors["focus-ring"],accessibilityLabel:a.searchOptions,style:[M.searchInput,{color:v.colors["text-body"],fontSize:v.text.base.size,paddingVertical:v.space.sm}]}),P.length>0?_jsx(Pressable,{onPress:()=>A(""),hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:a.clearSearch,children:(v.settings.icons.close??defaultIcons.close)({size:18,color:v.colors["text-muted"]})}):null]})}):null,_jsxs(View,{style:[M.listWrap,ee?M.listRow:null],children:[_jsx(GestureDetector,{gesture:N,children:_jsx(FlatList,{ref:Q,data:Z,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(O(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return _jsx(View,{accessible:!0,accessibilityRole:"header",style:[M.sectionHeader,{paddingHorizontal:v.space.lg,paddingTop:v.space.md}],children:r?r(e.title):_jsx(Text,{variant:"caption",weight:"semibold",color:"tertiary",style:M.sectionTitle,children:e.title.toUpperCase()})});const o=e.option,s=k(o),i=O(o),n=R(o),a=V(o),c=(d=i,Array.isArray(g)?g.some(e=>String(e)===String(d)):null!=g&&String(g)===String(d));var d;const p=L(o),u=m?.(o)??!1,h=D(o);return _jsxs(Pressable,{onPress:()=>{if(h)return h(),void J();x(i,o)},disabled:p,android_ripple:{color:v.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{selected:c,disabled:p},"aria-selected":c,"aria-disabled":p,style:({pressed:e})=>[M.optionRow,{backgroundColor:c?v.colors["surface-selected"]:e?v.colors["surface-pressed"]:"transparent",opacity:p?.5:1,paddingHorizontal:v.space.lg,paddingVertical:v.space.md},j,c?w:null],children:[l?_jsx(View,{style:M.optionTextWrap,children:l({option:o,selected:c,disabled:p,index:t})}):_jsxs(_Fragment,{children:[a?_jsx(View,{style:M.optionIcon,children:a}):null,_jsxs(View,{style:M.optionTextWrap,children:[_jsx(Text,{variant:"body",weight:c?"semibold":"medium",color:u?"danger":c?"brand":void 0,style:[M.optionLabel,C,c?_:null],children:s}),n?_jsx(Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:M.optionDescription,children:n}):null]})]}),f?_jsx(View,{style:[M.checkbox,{borderColor:c?v.colors.primary:v.colors.border,backgroundColor:c?v.colors.primary:"transparent"}],children:c?_jsx(View,{style:M.checkboxTick}):null}):c?"icon"===v.settings.components["option-sheet"]?.selectedMarker?_jsx(View,{style:M.singleSelectedIcon,children:(v.settings.icons.selectedTick??defaultIcons.selectedTick)({size:20,color:v.colors.primary})}):_jsx(View,{style:[M.singleSelectedDot,{backgroundColor:v.colors.primary}]}):null]})},onScrollToIndexFailed:re,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!ee,style:ee?M.listBesideRail:null,ListEmptyComponent:_jsx(Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:v.space.xl},children:a.empty})})}),ee?_jsx(View,{style:[M.rail,{paddingRight:v.space.xs}],accessibilityRole:"list",accessibilityLabel:a.jumpToLetter,testID:"option-sheet-alphabet",children:te.map(e=>{const t=q.has(e);return _jsx(Pressable,{onPress:()=>oe(e),disabled:!t,hitSlop:{left:8,right:8},...hitSlopMarker({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:fillText(a.jumpTo,{letter:e}),accessibilityState:{disabled:!t},"aria-disabled":!t,style:M.railLetter,children:_jsx(Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[M.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),f?_jsx(View,{style:[M.sheetFooter,{borderTopColor:v.colors["border-subtle"],paddingHorizontal:v.space.lg,paddingVertical:v.space.md}],children:_jsx(Pressable,{onPress:J,accessibilityRole:"button",accessibilityLabel:a.done,style:({pressed:e})=>[M.doneButton,{backgroundColor:e?v.colors["primary-pressed"]:v.colors.primary,borderRadius:v.radius.md,...smoothCorners,paddingVertical:v.space.sm,paddingHorizontal:v.space.lg}],children:_jsx(Text,{variant:"body",weight:"semibold",style:{color:v.colors["on-primary"]},children:a.done})})}):null]})})}export function OptionSheet(e){const{open:t,onOpenChange:o,onAfterClose:s,labels:i,onClose:r,haptic:l,...n}=e,a=useMobileUiText("optionSheet",OPTION_SHEET_TEXT),c=useMemo(()=>({...a,...i}),[a,i]),d=useRef(o);d.current=o;const p=useRef(!1);return useEffect(()=>{p.current!==t&&(p.current=t,d.current?.(t))},[t]),_jsx(Modal,{open:t,onClose:r,presentation:"bottom",onDismissed:s,haptic:l,contentStyle:hostStyle,labels:{close:c.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??c.fallbackName,children:_jsx(OptionSheetPanel,{...n,onClose:r,labels:c})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:Math.round(e.text.xs.size*e.leading.heading)},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,...smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});export default OptionSheet;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{cloneElement,isValidElement}from"react";import{FlatList,StyleSheet}from"react-native";import{useRefreshControl}from"../../hooks/useRefreshControl.js";import{useMobileUiText}from"../../text/index.js";import{ASYNC_BLOCK_TEXT}from"../../text/phone/asyncBlock.g.js";import{AsyncBlock}from"../AsyncBlock/index.js";import{EmptyState}from"../EmptyState/index.js";import{PagedListFooter}from"../PagedListFooter/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const noop=()=>{},styles=StyleSheet.create({flex:{flex:1},grow:{flexGrow:1}}),isElementFooter=e=>isValidElement(e);function renderFooter(e){if(null==e)return null;if(isElementFooter(e))return e;return _jsx(e,{})}export function PagedList(e){const{state:t,paging:o,empty:r,skeleton:s,errorTitle:n,data:i,placeholderStyle:l,onRefresh:a,refreshing:m,progressViewOffset:d,ref:f,onEndReached:p,ListFooterComponent:c,style:y,contentContainerStyle:h,...x}=e,u=useMobileUiText("asyncBlock",ASYNC_BLOCK_TEXT),g="data"===t?.status||"empty"===t?.status?t:void 0,{refreshControl:j}=useRefreshControl({onRefresh:g?g.refresh:a??noop,refreshing:g?g.refreshing:m}),E=a||g?void 0===d?j:cloneElement(j,{progressViewOffset:d}):void 0,handleEndReached=e=>{o?.hasMore&&!o.loadingMore&&null==o.errorMore&&o.loadMore(),p?.(e)},renderList=(e,t)=>_jsx(FlatList,{data:e,keyboardShouldPersistTaps:"handled",onEndReachedThreshold:o?.5:void 0,...x,ref:f,refreshControl:E,onEndReached:o?handleEndReached:p,ListEmptyComponent:t,ListFooterComponent:o||c?_jsxs(_Fragment,{children:[renderFooter(c),o?_jsx(PagedListFooter,{paging:o}):null]}):void 0,style:[styles.flex,y],contentContainerStyle:[h,t?styles.grow:void 0]});return"empty"===t?.status?renderList([],_jsx(EmptyState,{...r??{title:u.emptyTitle}})):t?_jsx(AsyncBlock,{state:t,skeleton:s,errorTitle:n,style:[styles.flex,l],children:e=>renderList(e,void 0)}):renderList(i,r?_jsx(EmptyState,{...r}):void 0)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{PagedList}from"./PagedList.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{countryFlagEmoji,formatPhoneAsTyped,getFormatterConfig,getPhoneCountries,isSupportedCountry,isValidNationalNumber,maxNationalNumberLength,splitPhoneNumber}from"@webority/mobile-core";import{PHONE_COUNTRY_NAMES}from"@webority/mobile-core/phone/countries";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fillText,useMobileUiText}from"../../text/index.js";import{PHONE_NUMBER_INPUT_TEXT}from"../../text/phone/phoneNumberInput.g.js";import{fontFor,resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,RequiredPlaceholder,resolveFieldTextStyle}from"../FieldBase/index.js";import{Chevron}from"../FieldBase/Chevron.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CALLING_CODES=[{iso:"AU",code:"61",label:"Australia"},{iso:"CA",code:"1",label:"Canada"},{iso:"IN",code:"91",label:"India"},{iso:"SA",code:"966",label:"Saudi Arabia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"}];export const ALL_CALLING_CODES=getPhoneCountries().map(e=>({iso:e.iso,code:e.callingCode,label:PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label));const digitsOnly=e=>e.replace(/[^0-9]/g,"");export const formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;export const parseE164=(e,t,o)=>{const i=e.replace(/[^0-9]/g,"");if(!i)return null;const n=splitPhoneNumber(`+${i}`);let l=n?.callingCode,a=n?.nationalNumber??"";if(!l){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(l=e.find(e=>i.startsWith(e)),!l)return null;a=i.slice(l.length)}const r=t.filter(e=>e.code===l),s=r.find(e=>e.iso===o)?.iso??r.find(e=>e.iso===n?.country)?.iso??n?.country??r[0]?.iso??"";return{callingCode:l,nationalNumber:a,iso:s}};const planOf=e=>isSupportedCountry(e)?e:null,assertDefaultCountryVisible=(e,t)=>{if(void 0!==e&&!t.some(t=>t.iso===e))throw new RangeError(`PhoneNumberInput: defaultCountry "${e}" is not among the visible countries. Add it to countries, or remove it from hiddenCountries.`)};export const PhoneNumberInput=forwardRef((e,t)=>{const{value:o,defaultValue:i,onChange:n,e164:l,onChangeE164:a,returnKeyType:r,submitBehavior:s,onSubmitEditing:u,onComplete:d,onValidityChange:c,countries:p=ALL_CALLING_CODES,popularCountries:m,hiddenCountries:b,showFlag:f=!0,renderFlag:h,renderCountry:g,showAlphabetIndex:N,defaultCountry:x,validation:C="any",maxLength:y,formatAsYouType:v=!0,countryLocked:S=!1,label:T,labelMode:I="top",labelStyle:F,placeholder:E,helperText:P,error:j,invalidMessage:_,required:L,disabled:V=!1,size:O="md",variant:M,radius:A,labels:w,haptic:k,accessibilityLabel:z,countryAccessibilityLabel:D,onFocus:R,onBlur:U,style:B,testID:$}=e;assertValidValue("PhoneNumberInput","size",e.size,["sm","md","lg"]),assertValidValue("PhoneNumberInput","variant",e.variant,["outline","filled","underline"]),assertValidValue("PhoneNumberInput","labelMode",e.labelMode,["top","float"]),assertValidValue("PhoneNumberInput","validation",!1===e.validation?void 0:e.validation,["any","mobile"]);const H=useTheme(),W=useMemo(()=>buildStyles(H),[H]),q=useRef(null),G=useMobileUiText("phoneNumberInput",PHONE_NUMBER_INPUT_TEXT),Y=useMemo(()=>({...G,...w}),[G,w]),K=E??Y.placeholder,X=useMemo(()=>/-([A-Za-z]{2})(?:-|$)/.exec(getFormatterConfig().locale)?.[1]?.toUpperCase(),[]),Z=useMemo(()=>b?.length?p.filter(e=>!b.includes(e.iso)):p,[p,b]),J=useMemo(()=>{if(!m?.length)return;const e=m.map(e=>Z.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:Y.popular,options:e},{title:Y.allCountries,options:Z}]:void 0},[m,Y.popular,Y.allCountries,Z]),Q=useCallback((e,t,o)=>{if(!e)return null;if(h)return h(e);if(!f)return null;const i=countryFlagEmoji(e.iso);return i?_jsx(Text,{variant:"body",style:[W.flag,{fontSize:t}],testID:o,children:i}):null},[h,f,W.flag]),ee=useCallback(e=>{const t=planOf(e),o=t?maxNationalNumberLength(t,!1===C?"any":C):Number.POSITIVE_INFINITY;return y?Math.min(o,y):o},[y,C]),te=useCallback((e,t)=>e.slice(0,ee(t)),[ee]),oe=useCallback((e,t)=>{const o=planOf(t)??void 0,i=splitPhoneNumber(e,o);if(!i)return null;const n=i.country??t,l=p.find(e=>e.iso===n);return{callingCode:l?.code??i.callingCode,nationalNumber:te(i.nationalNumber,n),iso:l?.iso??n}},[p,te]);useState(()=>assertDefaultCountryVisible(x,Z));const ie=useMemo(()=>{const e=Z.find(e=>e.iso===(x??X))??Z[0]??p[0],t={callingCode:e?.code??"",nationalNumber:"",iso:e?.iso??""};return"string"==typeof i?oe(i,t.iso)??t:i??t},[p,Z,x,X,i,oe]),ne=useCallback(e=>{if(!1===C)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?isValidNationalNumber(e.nationalNumber,t,C):e.nationalNumber.length>0},[C]),[le,ae]=useState(ie.iso),re=useMemo(()=>{if(void 0===l)return;const e=l?parseE164(l,p,le):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=p.find(e=>e.iso===le);return{callingCode:t?.code??ie.callingCode,nationalNumber:"",iso:le}},[l,p,le,ie.callingCode,te]),se=useCallback(e=>{ae(e.iso),n?.(e),a?.(e.nationalNumber?formatE164(e):"",{country:p.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,a,p,ne]),[ue,de]=useControllableState({value:o??re,defaultValue:ie,onChange:se}),[ce,pe]=useState(!1),me=useCallback(()=>{V||q.current?.focus()},[V]),[be,fe]=useState(!1),[he,ge]=useState(!1),[Ne,xe]=useState(!1),Ce=useRef(!1);useEffect(()=>{Ne||(Ce.current=!1)},[Ne]);const ye=resolveFieldSize(H,O),ve=resolveFieldTextStyle(H,{disabled:V}),Se=M??H.settings.components.field?.defaultVariant??"outline",Te="underline"===Se,Ie=H.space.md,[Fe,Ee]=useState(0),Pe=Fe+Ie+1+Ie,je=ue.nationalNumber.length>0,Le=L&&!T&&!je&&K.length>0,Ve=ce||je,Oe=Boolean(T)&&"float"===I&&Fe>0,Me=useFloatingLabel({label:T,enabled:Oe,floated:Ve,required:L,variant:Se,sizeTokens:ye,leadingOffset:Pe,paddingLeft:Te?H.space.none:ye["padding-x"],color:H.colors["field-label"],style:F}),Ae=useMemo(()=>p.find(e=>e.iso===ue.iso),[p,ue.iso]),we=planOf(ue.iso),ke=v&&we?formatPhoneAsTyped(ue.nationalNumber,we):ue.nationalNumber,ze=ee(ue.iso),De=0===ue.nationalNumber.length||be||!Number.isFinite(ze)?void 0:ke.length+Math.max(0,ze-ue.nationalNumber.length),Re=ne(ue);useEffect(()=>{je||ge(!1)},[je]);const Ue=we?maxNationalNumberLength(we,!1===C?"any":C):Number.POSITIVE_INFINITY,Be=ue.nationalNumber.length>=Ue,$e=!1!==C&&!1!==_&&je&&!Re&&(he||Be),He="mobile"===C?Y.invalidMobile:Y.invalid,We=hasFieldText(j)?j:$e?_||He:void 0,qe=!0===j||hasFieldText(We),Ge=useRef(Re),Ye=useRef(ue);Ye.current=ue,useEffect(()=>{Ge.current!==Re&&(Ge.current=Re,c?.(Re),Re&&d?.(formatE164(Ye.current)))},[Re,d,c]);const Ke=useCallback(e=>{if(e.includes("+")){const t=oe(e,ue.iso);if(t&&!S&&Z.some(e=>e.iso===t.iso))return void de(t);if(t&&t.iso===ue.iso)return void de(t)}de({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[Z,S,ue,oe,te,de]),Xe=useCallback(e=>{de({callingCode:e.code,iso:e.iso,nationalNumber:te(ue.nationalNumber,e.iso)}),xe(!1);const t=resolveHaptic(k,"selection");t&&triggerHaptic(t)},[ue,k,te,de]);useImperativeHandle(t,()=>({focus:()=>q.current?.focus(),blur:()=>q.current?.blur(),clear:()=>de({...Ye.current,nationalNumber:""}),isFocused:()=>q.current?.isFocused()??!1,getValue:()=>Ye.current,getE164:()=>formatE164(Ye.current),getFormatted:()=>{const e=Ye.current,t=planOf(e.iso);return t?formatPhoneAsTyped(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ye.current),getCountry:()=>p.find(e=>e.iso===Ye.current.iso)}),[p,ne,de]);const Ze=V||S,Je=_jsx(FieldBase,{testID:$?`${$}-field`:void 0,size:O,variant:Se,radius:A,topNotch:Me.topNotch,focused:ce,disabled:V,error:qe,filled:je,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Te?H.space.none:void 0,leading:_jsxs(Pressable,{onPress:()=>{Ze||(Ce.current=!0,xe(!0))},disabled:Ze,accessibilityRole:"button",accessibilityLabel:D??fillText(Y.countryButton,{callingCode:ue.callingCode}),accessibilityState:{disabled:Ze},"aria-disabled":Ze,hitSlop:6,...hitSlopMarker(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Ee(e=>e===t?e:t)},style:W.codeTrigger,testID:$?`${$}-code`:void 0,children:[Q(Ae,ye.text,$?`${$}-flag`:void 0),_jsx(Text,{variant:"body",style:[W.codeText,{color:ve.color,fontSize:ye.text}],children:`+${ue.callingCode}`}),S?null:_jsx(Chevron,{color:V?H.colors["field-icon-disabled"]:H.colors["field-icon"],size:ye.icon,open:Ne})]}),children:_jsxs(View,{style:W.inputWrap,children:[_jsx(TextInput,{ref:q,value:ke,maxLength:De,onChangeText:Ke,returnKeyType:r,submitBehavior:s,onSubmitEditing:u,onSelectionChange:e=>{const{start:t,end:o}=e.nativeEvent.selection;fe(t!==o)},onFocus:()=>{pe(!0),R?.()},onBlur:()=>{pe(!1),je&&!Ce.current&&ge(!0),U?.()},editable:!V,placeholder:Oe&&!Ve||Le?void 0:K,placeholderTextColor:ve.placeholderColor,accessibilityLabel:z??T??K,selectionColor:H.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[W.input,{color:ve.color,fontSize:ye.text,...ve.weightStyle,paddingLeft:Te?H.space.none:void 0}],testID:$?`${$}-input`:void 0}),Le?_jsx(RequiredPlaceholder,{text:K,color:ve.placeholderColor,fontSize:ye.text,weightStyle:ve.weightStyle}):null]})});return _jsxs(View,{style:B,testID:$,children:[T&&"top"===I?_jsx(FieldLabel,{size:O,required:L,children:T}):null,_jsxs(View,{style:W.fieldWrapper,children:[Je,Me.node]}),_jsx(FieldMessage,{size:O,error:qe,text:qe?We:P}),_jsx(OptionSheet,{open:Ne,haptic:k,onClose:()=>xe(!1),title:Y.countrySheetTitle,options:Z,sections:J,getOptionLabel:e=>`${e.label} (+${e.code})`,getOptionValue:e=>e.iso,getOptionIcon:e=>Q(e,H.text.lg.size),renderOption:g?({option:e,selected:t})=>g(e,{selected:t}):void 0,value:Ae?.iso,onChange:(e,t)=>Xe(t),searchable:Z.length>8,labels:{searchPlaceholder:Y.countrySearchPlaceholder},alphabetIndex:N??Z.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},flag:{includeFontPadding:!1,marginRight:e.space.xs},codeText:{...fontFor(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});export default PhoneNumberInput;
|
|
1
|
+
"use strict";import{countryFlagEmoji,formatPhoneAsTyped,getFormatterConfig,getPhoneCountries,isSupportedCountry,isValidNationalNumber,maxNationalNumberLength,reportIdleActivity,splitPhoneNumber}from"@webority/mobile-core";import{PHONE_COUNTRY_NAMES}from"@webority/mobile-core/phone/countries";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fillText,useMobileUiText}from"../../text/index.js";import{PHONE_NUMBER_INPUT_TEXT}from"../../text/phone/phoneNumberInput.g.js";import{fontFor,resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,RequiredPlaceholder,resolveFieldTextStyle}from"../FieldBase/index.js";import{Chevron}from"../FieldBase/Chevron.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CALLING_CODES=[{iso:"AU",code:"61",label:"Australia"},{iso:"CA",code:"1",label:"Canada"},{iso:"IN",code:"91",label:"India"},{iso:"SA",code:"966",label:"Saudi Arabia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"}];export const ALL_CALLING_CODES=getPhoneCountries().map(e=>({iso:e.iso,code:e.callingCode,label:PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label));const digitsOnly=e=>e.replace(/[^0-9]/g,"");export const formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;export const parseE164=(e,t,o)=>{const i=e.replace(/[^0-9]/g,"");if(!i)return null;const n=splitPhoneNumber(`+${i}`);let l=n?.callingCode,r=n?.nationalNumber??"";if(!l){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(l=e.find(e=>i.startsWith(e)),!l)return null;r=i.slice(l.length)}const a=t.filter(e=>e.code===l),s=a.find(e=>e.iso===o)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:l,nationalNumber:r,iso:s}};const planOf=e=>isSupportedCountry(e)?e:null,assertDefaultCountryVisible=(e,t)=>{if(void 0!==e&&!t.some(t=>t.iso===e))throw new RangeError(`PhoneNumberInput: defaultCountry "${e}" is not among the visible countries. Add it to countries, or remove it from hiddenCountries.`)};export const PhoneNumberInput=forwardRef((e,t)=>{const{value:o,defaultValue:i,onChange:n,e164:l,onChangeE164:r,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,onComplete:d,onValidityChange:c,countries:p=ALL_CALLING_CODES,popularCountries:m,hiddenCountries:b,showFlag:f=!0,renderFlag:h,renderCountry:g,showAlphabetIndex:N,defaultCountry:x,validation:y="any",maxLength:C,formatAsYouType:v=!0,countryLocked:S=!1,label:T,labelMode:I="top",labelStyle:F,placeholder:E,helperText:P,error:j,invalidMessage:_,required:L,disabled:V=!1,size:O="md",variant:A,radius:M,labels:w,haptic:k,accessibilityLabel:z,countryAccessibilityLabel:D,onFocus:R,onBlur:U,style:B,testID:$}=e;assertValidValue("PhoneNumberInput","size",e.size,["sm","md","lg"]),assertValidValue("PhoneNumberInput","variant",e.variant,["outline","filled","underline"]),assertValidValue("PhoneNumberInput","labelMode",e.labelMode,["top","float"]),assertValidValue("PhoneNumberInput","validation",!1===e.validation?void 0:e.validation,["any","mobile"]);const H=useTheme(),W=useMemo(()=>buildStyles(H),[H]),q=useRef(null),G=useMobileUiText("phoneNumberInput",PHONE_NUMBER_INPUT_TEXT),Y=useMemo(()=>({...G,...w}),[G,w]),K=E??Y.placeholder,X=useMemo(()=>/-([A-Za-z]{2})(?:-|$)/.exec(getFormatterConfig().locale)?.[1]?.toUpperCase(),[]),Z=useMemo(()=>b?.length?p.filter(e=>!b.includes(e.iso)):p,[p,b]),J=useMemo(()=>{if(!m?.length)return;const e=m.map(e=>Z.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:Y.popular,options:e},{title:Y.allCountries,options:Z}]:void 0},[m,Y.popular,Y.allCountries,Z]),Q=useCallback((e,t,o)=>{if(!e)return null;if(h)return h(e);if(!f)return null;const i=countryFlagEmoji(e.iso);return i?_jsx(Text,{variant:"body",style:[W.flag,{fontSize:t}],testID:o,children:i}):null},[h,f,W.flag]),ee=useCallback(e=>{const t=planOf(e),o=t?maxNationalNumberLength(t,!1===y?"any":y):Number.POSITIVE_INFINITY;return C?Math.min(o,C):o},[C,y]),te=useCallback((e,t)=>e.slice(0,ee(t)),[ee]),oe=useCallback((e,t)=>{const o=planOf(t)??void 0,i=splitPhoneNumber(e,o);if(!i)return null;const n=i.country??t,l=p.find(e=>e.iso===n);return{callingCode:l?.code??i.callingCode,nationalNumber:te(i.nationalNumber,n),iso:l?.iso??n}},[p,te]);useState(()=>assertDefaultCountryVisible(x,Z));const ie=useMemo(()=>{const e=Z.find(e=>e.iso===(x??X))??Z[0]??p[0],t={callingCode:e?.code??"",nationalNumber:"",iso:e?.iso??""};return"string"==typeof i?oe(i,t.iso)??t:i??t},[p,Z,x,X,i,oe]),ne=useCallback(e=>{if(!1===y)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?isValidNationalNumber(e.nationalNumber,t,y):e.nationalNumber.length>0},[y]),[le,re]=useState(ie.iso),ae=useMemo(()=>{if(void 0===l)return;const e=l?parseE164(l,p,le):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=p.find(e=>e.iso===le);return{callingCode:t?.code??ie.callingCode,nationalNumber:"",iso:le}},[l,p,le,ie.callingCode,te]),se=useCallback(e=>{re(e.iso),n?.(e),r?.(e.nationalNumber?formatE164(e):"",{country:p.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,r,p,ne]),[ue,de]=useControllableState({value:o??ae,defaultValue:ie,onChange:se}),[ce,pe]=useState(!1),me=useCallback(()=>{V||q.current?.focus()},[V]),[be,fe]=useState(!1),[he,ge]=useState(!1),[Ne,xe]=useState(!1),ye=useRef(!1);useEffect(()=>{Ne||(ye.current=!1)},[Ne]);const Ce=resolveFieldSize(H,O),ve=resolveFieldTextStyle(H,{disabled:V}),Se=A??H.settings.components.field?.defaultVariant??"outline",Te="underline"===Se,Ie=H.space.md,[Fe,Ee]=useState(0),Pe=Fe+Ie+1+Ie,je=ue.nationalNumber.length>0,Le=L&&!T&&!je&&K.length>0,Ve=ce||je,Oe=Boolean(T)&&"float"===I&&Fe>0,Ae=useFloatingLabel({label:T,enabled:Oe,floated:Ve,required:L,variant:Se,sizeTokens:Ce,leadingOffset:Pe,paddingLeft:Te?H.space.none:Ce["padding-x"],color:H.colors["field-label"],style:F}),Me=useMemo(()=>p.find(e=>e.iso===ue.iso),[p,ue.iso]),we=planOf(ue.iso),ke=v&&we?formatPhoneAsTyped(ue.nationalNumber,we):ue.nationalNumber,ze=ee(ue.iso),De=0===ue.nationalNumber.length||be||!Number.isFinite(ze)?void 0:ke.length+Math.max(0,ze-ue.nationalNumber.length),Re=ne(ue);useEffect(()=>{je||ge(!1)},[je]);const Ue=we?maxNationalNumberLength(we,!1===y?"any":y):Number.POSITIVE_INFINITY,Be=ue.nationalNumber.length>=Ue,$e=!1!==y&&!1!==_&&je&&!Re&&(he||Be),He="mobile"===y?Y.invalidMobile:Y.invalid,We=hasFieldText(j)?j:$e?_||He:void 0,qe=!0===j||hasFieldText(We),Ge=useRef(Re),Ye=useRef(ue);Ye.current=ue,useEffect(()=>{Ge.current!==Re&&(Ge.current=Re,c?.(Re),Re&&d?.(formatE164(Ye.current)))},[Re,d,c]);const Ke=useCallback(e=>{if(reportIdleActivity(),e.includes("+")){const t=oe(e,ue.iso);if(t&&!S&&Z.some(e=>e.iso===t.iso))return void de(t);if(t&&t.iso===ue.iso)return void de(t)}de({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[Z,S,ue,oe,te,de]),Xe=useCallback(e=>{de({callingCode:e.code,iso:e.iso,nationalNumber:te(ue.nationalNumber,e.iso)}),xe(!1);const t=resolveHaptic(k,"selection");t&&triggerHaptic(t)},[ue,k,te,de]);useImperativeHandle(t,()=>({focus:()=>q.current?.focus(),blur:()=>q.current?.blur(),clear:()=>de({...Ye.current,nationalNumber:""}),isFocused:()=>q.current?.isFocused()??!1,getValue:()=>Ye.current,getE164:()=>formatE164(Ye.current),getFormatted:()=>{const e=Ye.current,t=planOf(e.iso);return t?formatPhoneAsTyped(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ye.current),getCountry:()=>p.find(e=>e.iso===Ye.current.iso)}),[p,ne,de]);const Ze=V||S,Je=_jsx(FieldBase,{testID:$?`${$}-field`:void 0,size:O,variant:Se,radius:M,topNotch:Ae.topNotch,focused:ce,disabled:V,error:qe,filled:je,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Te?H.space.none:void 0,leading:_jsxs(Pressable,{onPress:()=>{Ze||(ye.current=!0,xe(!0))},disabled:Ze,accessibilityRole:"button",accessibilityLabel:D??fillText(Y.countryButton,{callingCode:ue.callingCode}),accessibilityState:{disabled:Ze},"aria-disabled":Ze,hitSlop:6,...hitSlopMarker(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Ee(e=>e===t?e:t)},style:W.codeTrigger,testID:$?`${$}-code`:void 0,children:[Q(Me,Ce.text,$?`${$}-flag`:void 0),_jsx(Text,{variant:"body",style:[W.codeText,{color:ve.color,fontSize:Ce.text}],children:`+${ue.callingCode}`}),S?null:_jsx(Chevron,{color:V?H.colors["field-icon-disabled"]:H.colors["field-icon"],size:Ce.icon,open:Ne})]}),children:_jsxs(View,{style:W.inputWrap,children:[_jsx(TextInput,{ref:q,value:ke,maxLength:De,onChangeText:Ke,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,onSelectionChange:e=>{const{start:t,end:o}=e.nativeEvent.selection;fe(t!==o)},onFocus:()=>{pe(!0),R?.()},onBlur:()=>{pe(!1),je&&!ye.current&&ge(!0),U?.()},editable:!V,placeholder:Oe&&!Ve||Le?void 0:K,placeholderTextColor:ve.placeholderColor,accessibilityLabel:z??T??K,selectionColor:H.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[W.input,{color:ve.color,fontSize:Ce.text,...ve.weightStyle,paddingLeft:Te?H.space.none:void 0}],testID:$?`${$}-input`:void 0}),Le?_jsx(RequiredPlaceholder,{text:K,color:ve.placeholderColor,fontSize:Ce.text,weightStyle:ve.weightStyle}):null]})});return _jsxs(View,{style:B,testID:$,children:[T&&"top"===I?_jsx(FieldLabel,{size:O,required:L,children:T}):null,_jsxs(View,{style:W.fieldWrapper,children:[Je,Ae.node]}),_jsx(FieldMessage,{size:O,error:qe,text:qe?We:P}),_jsx(OptionSheet,{open:Ne,haptic:k,onClose:()=>xe(!1),title:Y.countrySheetTitle,options:Z,sections:J,getOptionLabel:e=>`${e.label} (+${e.code})`,getOptionValue:e=>e.iso,getOptionIcon:e=>Q(e,H.text.lg.size),renderOption:g?({option:e,selected:t})=>g(e,{selected:t}):void 0,value:Me?.iso,onChange:(e,t)=>Xe(t),searchable:Z.length>8,labels:{searchPlaceholder:Y.countrySearchPlaceholder},alphabetIndex:N??Z.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},flag:{includeFontPadding:!1,marginRight:e.space.xs},codeText:{...fontFor(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});export default PhoneNumberInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useMobileUiText}from"../../text/index.js";import{RICH_TEXT_EDITOR_TEXT}from"../../text/phone/richTextEditor.g.js";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{applyMarkdownAction,normalizeSelection}from"./markdownActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ACTION_GLYPH={bold:"B",italic:"I",strikethrough:"S",code:"</>",link:"link",heading1:"H1",heading2:"H2",bulletList:"•",numberedList:"1.",quote:">"},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5;export const RichTextEditor=forwardRef((e,t)=>{const{value:o,onChangeText:i,placeholder:s,actions:r=DEFAULT_ACTIONS,disabled:l=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:
|
|
1
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useMobileUiText}from"../../text/index.js";import{RICH_TEXT_EDITOR_TEXT}from"../../text/phone/richTextEditor.g.js";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{applyMarkdownAction,normalizeSelection}from"./markdownActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ACTION_GLYPH={bold:"B",italic:"I",strikethrough:"S",code:"</>",link:"link",heading1:"H1",heading2:"H2",bulletList:"•",numberedList:"1.",quote:">"},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5;export const RichTextEditor=forwardRef((e,t)=>{const{value:o,onChangeText:i,placeholder:s,actions:r=DEFAULT_ACTIONS,disabled:l=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:c=!1,accessibilityLabel:d,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),y=useMobileUiText("richTextEditor",RICH_TEXT_EDITOR_TEXT),S=useMemo(()=>u?{...y,...u}:y,[y,u]),f=o??"",[_,k]=useState({start:0,end:0}),[j,I]=useState(!1),[C,E]=useState(null),H=useCallback(e=>{k(e.nativeEvent.selection),E(null)},[]),w=useCallback(e=>{reportIdleActivity(),E(null),i?.(e)},[i]),L=useCallback(e=>{if(l)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:f,selection:normalizeSelection(_,f.length)},e);k(o.selection),E(o.selection),i?.(o.text)},[l,h,i,_,f]);return n?_jsx(RichTextEditorSkeleton,{actionCount:r.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:j?g.colors["focus-ring"]:g.colors.border,opacity:l?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:r.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:l,onPress:L,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:f,onChangeText:w,onSelectionChange:H,onFocus:()=>I(!0),onBlur:()=>I(!1),selection:C??void 0,editable:!l,autoFocus:c,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:d,style:[T.input,{minHeight:a},p],testID:x?`${x}-input`:void 0})]})});RichTextEditor.displayName="RichTextEditor";const ToolbarButton=({action:e,label:t,disabled:o,onPress:i,styles:s,theme:r,testID:l})=>{const n={color:o?r.colors["text-disabled"]:r.colors["text-body"],..."bold"===e?{fontWeight:r.weight.bold}:{},..."italic"===e?{fontStyle:"italic"}:{},..."strikethrough"===e?{textDecorationLine:"line-through"}:{}};return _jsx(Pressable,{onPress:()=>i(e),disabled:o,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:o},"aria-disabled":o,hitSlop:4,...hitSlopMarker(4),testID:l,style:({pressed:e})=>[s.button,{backgroundColor:e?r.colors["surface-pressed"]:r.colors["bg-subtle"]}],children:_jsx(Text,{variant:"body",maxFontSizeMultiplier:Math.min(r.settings.maxFontSizeMultiplier??1.5,1.5),style:[s.buttonLabel,n],children:ACTION_GLYPH[e]})})};ToolbarButton.displayName="RichTextEditorToolbarButton";const RichTextEditorSkeleton=({actionCount:e,minHeight:t,style:o,testID:i})=>{const s=useTheme(),r=useMemo(()=>buildStyles(s),[s]),l=Array.from({length:Math.max(1,e)},(e,t)=>t);return _jsxs(View,{testID:i,style:[r.container,o],children:[_jsx(View,{style:r.toolbar,children:l.map(e=>_jsx(Skeleton,{width:34,height:30,radius:"sm"},e))}),_jsxs(View,{style:[r.skeletonBody,{minHeight:t}],children:[_jsx(Skeleton,{shape:"text",width:"94%",height:14}),_jsx(Skeleton,{shape:"text",width:"100%",height:14}),_jsx(Skeleton,{shape:"text",width:"72%",height:14})]})]})};RichTextEditorSkeleton.displayName="RichTextEditorSkeleton";const buildStyles=e=>StyleSheet.create({container:{borderWidth:e.size.border,borderColor:e.colors.border,borderRadius:e.radius.md,...smoothCorners,backgroundColor:e.colors.bg,overflow:"hidden"},toolbar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,padding:e.space.xs,borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors["border-subtle"],backgroundColor:e.colors["bg-subtle"]},button:{minWidth:34,height:30,paddingHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,alignItems:"center",justifyContent:"center"},buttonLabel:{...fontFor(e,"medium"),fontSize:e.text.sm.size},input:{...fontFor(e,"normal"),color:e.colors["text-body"],fontSize:e.text.base.size,lineHeight:1.5*e.text.base.size,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},skeletonBody:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.sm}});export default RichTextEditor;
|