@onehat/ui 0.1.2 → 0.2.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/ckeditor5/LICENSE.md +49 -0
- package/ckeditor5/README.md +68 -0
- package/ckeditor5/build/ckeditor.js +6 -0
- package/ckeditor5/build/ckeditor.js.map +1 -0
- package/ckeditor5/build/translations/af.js +1 -0
- package/ckeditor5/build/translations/ar.js +1 -0
- package/ckeditor5/build/translations/ast.js +1 -0
- package/ckeditor5/build/translations/az.js +1 -0
- package/ckeditor5/build/translations/bg.js +1 -0
- package/ckeditor5/build/translations/bn.js +1 -0
- package/ckeditor5/build/translations/bs.js +1 -0
- package/ckeditor5/build/translations/ca.js +1 -0
- package/ckeditor5/build/translations/cs.js +1 -0
- package/ckeditor5/build/translations/da.js +1 -0
- package/ckeditor5/build/translations/de-ch.js +1 -0
- package/ckeditor5/build/translations/de.js +1 -0
- package/ckeditor5/build/translations/el.js +1 -0
- package/ckeditor5/build/translations/en-au.js +1 -0
- package/ckeditor5/build/translations/en-gb.js +1 -0
- package/ckeditor5/build/translations/eo.js +1 -0
- package/ckeditor5/build/translations/es-co.js +1 -0
- package/ckeditor5/build/translations/es.js +1 -0
- package/ckeditor5/build/translations/et.js +1 -0
- package/ckeditor5/build/translations/eu.js +1 -0
- package/ckeditor5/build/translations/fa.js +1 -0
- package/ckeditor5/build/translations/fi.js +1 -0
- package/ckeditor5/build/translations/fr.js +1 -0
- package/ckeditor5/build/translations/gl.js +1 -0
- package/ckeditor5/build/translations/gu.js +1 -0
- package/ckeditor5/build/translations/he.js +1 -0
- package/ckeditor5/build/translations/hi.js +1 -0
- package/ckeditor5/build/translations/hr.js +1 -0
- package/ckeditor5/build/translations/hu.js +1 -0
- package/ckeditor5/build/translations/id.js +1 -0
- package/ckeditor5/build/translations/it.js +1 -0
- package/ckeditor5/build/translations/ja.js +1 -0
- package/ckeditor5/build/translations/jv.js +1 -0
- package/ckeditor5/build/translations/kk.js +1 -0
- package/ckeditor5/build/translations/km.js +1 -0
- package/ckeditor5/build/translations/kn.js +1 -0
- package/ckeditor5/build/translations/ko.js +1 -0
- package/ckeditor5/build/translations/ku.js +1 -0
- package/ckeditor5/build/translations/lt.js +1 -0
- package/ckeditor5/build/translations/lv.js +1 -0
- package/ckeditor5/build/translations/ms.js +1 -0
- package/ckeditor5/build/translations/nb.js +1 -0
- package/ckeditor5/build/translations/ne.js +1 -0
- package/ckeditor5/build/translations/nl.js +1 -0
- package/ckeditor5/build/translations/no.js +1 -0
- package/ckeditor5/build/translations/oc.js +1 -0
- package/ckeditor5/build/translations/pl.js +1 -0
- package/ckeditor5/build/translations/pt-br.js +1 -0
- package/ckeditor5/build/translations/pt.js +1 -0
- package/ckeditor5/build/translations/ro.js +1 -0
- package/ckeditor5/build/translations/ru.js +1 -0
- package/ckeditor5/build/translations/si.js +1 -0
- package/ckeditor5/build/translations/sk.js +1 -0
- package/ckeditor5/build/translations/sl.js +1 -0
- package/ckeditor5/build/translations/sq.js +1 -0
- package/ckeditor5/build/translations/sr-latn.js +1 -0
- package/ckeditor5/build/translations/sr.js +1 -0
- package/ckeditor5/build/translations/sv.js +1 -0
- package/ckeditor5/build/translations/th.js +1 -0
- package/ckeditor5/build/translations/tk.js +1 -0
- package/ckeditor5/build/translations/tr.js +1 -0
- package/ckeditor5/build/translations/tt.js +1 -0
- package/ckeditor5/build/translations/ug.js +1 -0
- package/ckeditor5/build/translations/uk.js +1 -0
- package/ckeditor5/build/translations/ur.js +1 -0
- package/ckeditor5/build/translations/uz.js +1 -0
- package/ckeditor5/build/translations/vi.js +1 -0
- package/ckeditor5/build/translations/zh-cn.js +1 -0
- package/ckeditor5/build/translations/zh.js +1 -0
- package/ckeditor5/package.json +46 -0
- package/ckeditor5/sample/index.html +130 -0
- package/ckeditor5/sample/styles.css +496 -0
- package/ckeditor5/src/ckeditor.js +138 -0
- package/ckeditor5/webpack.config.js +96 -0
- package/package.json +19 -23
- package/src/Components/Accordion/Accordion.js +144 -0
- package/src/Components/Blank.js +14 -0
- package/src/Components/Buttons/BackButton.js +16 -0
- package/src/Components/Buttons/CartButtonWithBadge.js +25 -0
- package/src/Components/Buttons/IconButton.js +42 -0
- package/src/Components/Container/Container.js +178 -0
- package/src/Components/Container/Splitter.js +61 -0
- package/src/Components/Filter/DateRange.js +99 -0
- package/src/Components/Filter/NumberRange.js +96 -0
- package/src/Components/Form/Field/CKEditor/CKEditor.js +62 -0
- package/src/Components/Form/Field/CKEditor/styles.css +503 -0
- package/src/Components/Form/Field/CKEditor.js +12 -0
- package/src/Components/Form/Field/CheckboxGroup/ArrayCheckboxGroup.js +13 -0
- package/src/Components/Form/Field/CheckboxGroup/CheckboxGroup.js +61 -0
- package/src/Components/Form/Field/Color.js +226 -0
- package/src/Components/Form/Field/Combo/ArrayCombo.js +15 -0
- package/src/Components/Form/Field/Combo/BooleanCombo.js +23 -0
- package/src/Components/Form/Field/Combo/Combo.js +504 -0
- package/src/Components/Form/Field/Combo/ComboEditor.js +22 -0
- package/src/Components/Form/Field/Combo/IntervalsCombo.js +18 -0
- package/src/Components/Form/Field/Combo/MonthsCombo.js +24 -0
- package/src/Components/Form/Field/Combo/PageSizeCombo.js +38 -0
- package/src/Components/Form/Field/Combo/Tag.js +12 -0
- package/src/Components/Form/Field/Combo/TimezonesCombo.js +432 -0
- package/src/Components/Form/Field/Combo/YearsCombo.js +35 -0
- package/src/Components/Form/Field/Date.js +370 -0
- package/src/Components/Form/Field/DisplayField.js +28 -0
- package/src/Components/Form/Field/Field.js +14 -0
- package/src/Components/Form/Field/File.js +218 -0
- package/src/Components/Form/Field/Input.js +96 -0
- package/src/Components/Form/Field/Number.js +151 -0
- package/src/Components/Form/Field/RadioGroup/ArrayRadioGroup.js +13 -0
- package/src/Components/Form/Field/RadioGroup/RadioGroup.js +62 -0
- package/src/Components/Form/Field/Tag.js +11 -0
- package/src/Components/Form/Field/Text.js +28 -0
- package/src/Components/Form/Field/TextArea.js +26 -0
- package/src/Components/Form/Field/Toggle.js +39 -0
- package/src/Components/Form/Field/datetime.css +5 -0
- package/src/Components/Form/FieldSet.js +64 -0
- package/src/Components/Form/FiltersForm.js +66 -0
- package/src/Components/Form/Form.js +535 -0
- package/src/Components/Form/Label.js +24 -0
- package/src/Components/Grid/Grid.js +877 -0
- package/src/Components/Grid/GridHeaderRow.js +455 -0
- package/src/Components/Grid/GridRow.js +134 -0
- package/src/Components/Grid/HeaderReorderHandle.js +29 -0
- package/src/Components/Grid/HeaderResizeHandle.js +29 -0
- package/src/Components/Grid/NoRecordsFound.js +43 -0
- package/src/Components/Grid/ReactGrid.js +468 -0
- package/src/Components/Grid/SenchaGrid.js +421 -0
- package/src/Components/Grid/reactgrid.css +6 -0
- package/src/Components/Hoc/withAlert.js +176 -0
- package/src/Components/Hoc/withBlank.js +12 -0
- package/src/Components/Hoc/withCollapsible.js +20 -0
- package/src/Components/Hoc/withContextMenu.js +127 -0
- package/src/Components/Hoc/withData.js +85 -0
- package/src/Components/Hoc/withDraggable.js +259 -0
- package/src/Components/Hoc/withEditor.js +160 -0
- package/src/Components/Hoc/withEvents.js +12 -0
- package/src/Components/Hoc/withFilters.js +456 -0
- package/src/Components/Hoc/withInlineEditor.js +119 -0
- package/src/Components/Hoc/withMultiSelection.js +16 -0
- package/src/Components/Hoc/withPresetButtons.js +239 -0
- package/src/Components/Hoc/withSelection.js +332 -0
- package/src/Components/Hoc/withTooltip.js +21 -0
- package/src/Components/Hoc/withValue.js +87 -0
- package/src/Components/Hoc/withWindowedEditor.js +51 -0
- package/src/Components/Icons/AddressBook.js +14 -0
- package/src/Components/Icons/Alt.js +17 -0
- package/src/Components/Icons/AngleLeft.js +18 -0
- package/src/Components/Icons/AngleRight.js +18 -0
- package/src/Components/Icons/AnglesLeft.js +18 -0
- package/src/Components/Icons/AnglesRight.js +18 -0
- package/src/Components/Icons/Asterisk.js +14 -0
- package/src/Components/Icons/Ban.js +18 -0
- package/src/Components/Icons/Bars.js +14 -0
- package/src/Components/Icons/BigCircle.js +17 -0
- package/src/Components/Icons/Book.js +14 -0
- package/src/Components/Icons/BookOpen.js +14 -0
- package/src/Components/Icons/Bug.js +14 -0
- package/src/Components/Icons/Building.js +14 -0
- package/src/Components/Icons/Calendar.js +18 -0
- package/src/Components/Icons/Calendar2.js +18 -0
- package/src/Components/Icons/CalendarDays.js +18 -0
- package/src/Components/Icons/Camera.js +18 -0
- package/src/Components/Icons/CaretDown.js +18 -0
- package/src/Components/Icons/CaretUp.js +18 -0
- package/src/Components/Icons/CartPlus.js +14 -0
- package/src/Components/Icons/CartShopping.js +14 -0
- package/src/Components/Icons/CashRegister.js +14 -0
- package/src/Components/Icons/ChartLine.js +14 -0
- package/src/Components/Icons/Check.js +14 -0
- package/src/Components/Icons/CheckDouble.js +14 -0
- package/src/Components/Icons/ChevronDown.js +14 -0
- package/src/Components/Icons/ChevronLeft.js +14 -0
- package/src/Components/Icons/ChevronRight.js +14 -0
- package/src/Components/Icons/ChevronUp.js +14 -0
- package/src/Components/Icons/CircleArrowRight.js +14 -0
- package/src/Components/Icons/CircleExclamation.js +18 -0
- package/src/Components/Icons/CircleInfo.js +14 -0
- package/src/Components/Icons/CircleQuestion.js +14 -0
- package/src/Components/Icons/CircleXmark.js +14 -0
- package/src/Components/Icons/CircleXmarkRegular.js +14 -0
- package/src/Components/Icons/Clipboard.js +18 -0
- package/src/Components/Icons/Clock.js +14 -0
- package/src/Components/Icons/ClockRegular.js +14 -0
- package/src/Components/Icons/ClockRotateLeft.js +14 -0
- package/src/Components/Icons/Clone.js +14 -0
- package/src/Components/Icons/Comment.js +14 -0
- package/src/Components/Icons/CommentRegular.js +14 -0
- package/src/Components/Icons/Comments.js +14 -0
- package/src/Components/Icons/CommentsRegular.js +14 -0
- package/src/Components/Icons/Copyright.js +14 -0
- package/src/Components/Icons/Duplicate.js +18 -0
- package/src/Components/Icons/Edit.js +18 -0
- package/src/Components/Icons/EllipsisVertical.js +18 -0
- package/src/Components/Icons/Envelope.js +14 -0
- package/src/Components/Icons/EnvelopeRegular.js +14 -0
- package/src/Components/Icons/Exclamation.js +14 -0
- package/src/Components/Icons/Expand.js +14 -0
- package/src/Components/Icons/Eye.js +18 -0
- package/src/Components/Icons/File.js +18 -0
- package/src/Components/Icons/FloppyDiskRegular.js +14 -0
- package/src/Components/Icons/Gear.js +18 -0
- package/src/Components/Icons/Gift.js +14 -0
- package/src/Components/Icons/Grip.js +18 -0
- package/src/Components/Icons/GripLines.js +18 -0
- package/src/Components/Icons/GripLinesVertical.js +18 -0
- package/src/Components/Icons/GripVertical.js +18 -0
- package/src/Components/Icons/Hammer.js +14 -0
- package/src/Components/Icons/Hand.js +14 -0
- package/src/Components/Icons/House.js +14 -0
- package/src/Components/Icons/Info.js +14 -0
- package/src/Components/Icons/ItunesNote.js +14 -0
- package/src/Components/Icons/List.js +14 -0
- package/src/Components/Icons/ListCheck.js +14 -0
- package/src/Components/Icons/LocationDot.js +14 -0
- package/src/Components/Icons/Loop.js +17 -0
- package/src/Components/Icons/Loop1.js +18 -0
- package/src/Components/Icons/LoopAll.js +18 -0
- package/src/Components/Icons/Maximize.js +14 -0
- package/src/Components/Icons/Microphone.js +14 -0
- package/src/Components/Icons/Minimize.js +14 -0
- package/src/Components/Icons/Minus.js +18 -0
- package/src/Components/Icons/MobileScreenButton.js +14 -0
- package/src/Components/Icons/MoneyBill.js +14 -0
- package/src/Components/Icons/MoneyBillWave.js +14 -0
- package/src/Components/Icons/Mouth.js +24 -0
- package/src/Components/Icons/Music.js +14 -0
- package/src/Components/Icons/NoLoop.js +24 -0
- package/src/Components/Icons/NoReorderRows.js +25 -0
- package/src/Components/Icons/ObjectGroupRegular.js +14 -0
- package/src/Components/Icons/Pause.js +14 -0
- package/src/Components/Icons/Pencil.js +18 -0
- package/src/Components/Icons/Phone.js +14 -0
- package/src/Components/Icons/Play.js +14 -0
- package/src/Components/Icons/Plus.js +18 -0
- package/src/Components/Icons/Presentation.js +19 -0
- package/src/Components/Icons/Print.js +18 -0
- package/src/Components/Icons/Question.js +14 -0
- package/src/Components/Icons/Rate-.25x.js +20 -0
- package/src/Components/Icons/Rate-.5x.js +19 -0
- package/src/Components/Icons/Rate-.75x.js +19 -0
- package/src/Components/Icons/Rate-1.25x.js +20 -0
- package/src/Components/Icons/Rate-1.5x.js +19 -0
- package/src/Components/Icons/Rate-1.75x.js +19 -0
- package/src/Components/Icons/Rate-1x.js +19 -0
- package/src/Components/Icons/Rate-2x.js +19 -0
- package/src/Components/Icons/RateIcon-.25x.js +20 -0
- package/src/Components/Icons/RateIcon-.5x.js +19 -0
- package/src/Components/Icons/RateIcon-.75x.js +19 -0
- package/src/Components/Icons/RateIcon-1.25x.js +20 -0
- package/src/Components/Icons/RateIcon-1.5x.js +19 -0
- package/src/Components/Icons/RateIcon-1.75x.js +19 -0
- package/src/Components/Icons/RateIcon-1x.js +19 -0
- package/src/Components/Icons/RateIcon-2x.js +19 -0
- package/src/Components/Icons/RectangleXmark.js +14 -0
- package/src/Components/Icons/RectangleXmarkRegular.js +14 -0
- package/src/Components/Icons/ReorderRows.js +21 -0
- package/src/Components/Icons/RightFromBracket.js +14 -0
- package/src/Components/Icons/RightToBracket.js +14 -0
- package/src/Components/Icons/Rotate.js +18 -0
- package/src/Components/Icons/RotateLeft.js +14 -0
- package/src/Components/Icons/RotateRight.js +18 -0
- package/src/Components/Icons/ScrewdriverWrench.js +14 -0
- package/src/Components/Icons/Scroll.js +14 -0
- package/src/Components/Icons/Share.js +14 -0
- package/src/Components/Icons/Shop.js +14 -0
- package/src/Components/Icons/SortDown.js +18 -0
- package/src/Components/Icons/SortUp.js +18 -0
- package/src/Components/Icons/Square.js +14 -0
- package/src/Components/Icons/SquareCheck.js +14 -0
- package/src/Components/Icons/SquareCheckRegular.js +14 -0
- package/src/Components/Icons/SquareMinus.js +18 -0
- package/src/Components/Icons/SquareRegular.js +14 -0
- package/src/Components/Icons/Store.js +14 -0
- package/src/Components/Icons/ThumbsDown.js +14 -0
- package/src/Components/Icons/ThumbsDownRegular.js +14 -0
- package/src/Components/Icons/ThumbsUp.js +14 -0
- package/src/Components/Icons/ThumbsUpRegular.js +14 -0
- package/src/Components/Icons/Trash.js +18 -0
- package/src/Components/Icons/TrashCan.js +18 -0
- package/src/Components/Icons/TriangleExclamation.js +18 -0
- package/src/Components/Icons/Truck.js +14 -0
- package/src/Components/Icons/TruckFast.js +14 -0
- package/src/Components/Icons/User.js +14 -0
- package/src/Components/Icons/UserGroup.js +14 -0
- package/src/Components/Icons/UserSecret.js +14 -0
- package/src/Components/Icons/X.js +14 -0
- package/src/Components/Icons/Xmark.js +14 -0
- package/src/Components/Mask.js +11 -0
- package/src/Components/Messages/ConfirmationMessage.js +26 -0
- package/src/Components/Messages/ErrorMessage.js +15 -0
- package/src/Components/Messages/Loading.js +16 -0
- package/src/Components/Messages/OkMessage.js +24 -0
- package/src/Components/Messages/WaitMessage.js +18 -0
- package/src/Components/Panel/AccordionGridPanel.js +94 -0
- package/src/Components/Panel/Footer.js +20 -0
- package/src/Components/Panel/FormPanel.js +23 -0
- package/src/Components/Panel/GridPanel.js +45 -0
- package/src/Components/Panel/Header.js +107 -0
- package/src/Components/Panel/Panel.js +152 -0
- package/src/Components/Panel/TabPanel.js +331 -0
- package/src/Components/Panel/UploadDownload.js +10 -0
- package/src/Components/Picker/Picker.js +64 -0
- package/src/Components/ScreenContainer.js +71 -0
- package/src/Components/Screens/DataMgt.js +250 -0
- package/src/Components/Toolbar/FilterToolbar.js +20 -0
- package/src/Components/Toolbar/Pagination.js +146 -0
- package/src/Components/Toolbar/PaginationToolbar.js +22 -0
- package/src/Components/Toolbar/Toolbar.js +18 -0
- package/src/Components/WaitModal.js +31 -0
- package/src/Components/Window/Editor.js +19 -0
- package/src/Constants/Alert.js +3 -0
- package/src/Constants/Date.js +3 -0
- package/src/Constants/Directions.js +8 -0
- package/src/Constants/EditorTypes.js +4 -0
- package/src/Constants/File.js +2 -0
- package/src/Constants/Grid.js +4 -0
- package/src/Constants/Input.js +1 -0
- package/src/Constants/Selection.js +5 -0
- package/src/Constants/Styles.js +86 -0
- package/src/Constants/UiModes.js +2 -0
- package/src/Data/Hoc/withRedux.js +48 -0
- package/src/Data/useOneHatData.js +75 -0
- package/src/Functions/BankersRound.js +11 -0
- package/src/Functions/Timer.js +92 -0
- package/src/Functions/deleteSecure.js +6 -0
- package/src/Functions/emptyFn.js +1 -0
- package/src/Functions/getComponentFromType.js +106 -0
- package/src/Functions/getIsMobile.js +5 -0
- package/src/Functions/getPref.js +7 -0
- package/src/Functions/getSecure.js +21 -0
- package/src/Functions/getTokenHeaders.js +13 -0
- package/src/Functions/inArray.js +5 -0
- package/src/Functions/isJson.js +8 -0
- package/src/Functions/processImage.js +16 -0
- package/src/Functions/setPref.js +14 -0
- package/src/Functions/setProgress.js +49 -0
- package/src/Functions/setSecure.js +35 -0
- package/src/Functions/setUiMode.js +5 -0
- package/src/Functions/sleep.js +3 -0
- package/src/Functions/testProps.js +24 -0
- package/src/Functions/trackEngagementHit.js +11 -0
- package/src/Functions/verifyCompleted.js +18 -0
- package/src/Functions/waitFor.js +16 -0
- package/src/Hooks/useAppState.js +34 -0
- package/src/Hooks/useAsync.js +13 -0
- package/src/Hooks/useBlocking.js +18 -0
- package/src/Hooks/useCameraRoll.js +41 -0
- package/src/Hooks/useForceUpdate.js +14 -0
- package/src/Hooks/useIsMounted.js +14 -0
- package/src/Hooks/useNotifications.js +279 -0
- package/src/Styles/StyleSheets.js +14 -0
- package/src/Styles/ThemeOverrides.js +264 -0
- package/src/UiConfig.js +19 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Icon,
|
|
4
|
+
Popover,
|
|
5
|
+
Pressable,
|
|
6
|
+
Row,
|
|
7
|
+
Text,
|
|
8
|
+
Tooltip,
|
|
9
|
+
} from 'native-base';
|
|
10
|
+
import {
|
|
11
|
+
DATE,
|
|
12
|
+
TIME,
|
|
13
|
+
DATETIME,
|
|
14
|
+
} from '../../../Constants/Date';
|
|
15
|
+
// import DateTimePickerModal from 'react-native-modal-datetime-picker'; // https://github.com/mmazzarolo/react-native-modal-datetime-picker
|
|
16
|
+
// import DateTimePicker from '@react-native-community/datetimepicker'; // https://github.com/react-native-datetimepicker/datetimepicker
|
|
17
|
+
import Datetime from 'react-datetime'; // https://www.npmjs.com/package/react-datetime
|
|
18
|
+
import 'react-datetime/css/react-datetime.css';
|
|
19
|
+
import './datetime.css';
|
|
20
|
+
import {
|
|
21
|
+
UI_MODE_WEB,
|
|
22
|
+
} from '../../../Constants/UiModes';
|
|
23
|
+
import UiConfig from '../../../UiConfig';
|
|
24
|
+
import Formatters from '@onehat/data/src/Util/Formatters';
|
|
25
|
+
import Parsers from '@onehat/data/src/Util/Parsers';
|
|
26
|
+
import Input from '../Field/Input';
|
|
27
|
+
import IconButton from '../../Buttons/IconButton';
|
|
28
|
+
import withValue from '../../Hoc/withValue';
|
|
29
|
+
import emptyFn from '../../../Functions/emptyFn';
|
|
30
|
+
import Calendar from '../../Icons/Calendar';
|
|
31
|
+
import styles from '../../../Constants/Styles';
|
|
32
|
+
import _ from 'lodash';
|
|
33
|
+
|
|
34
|
+
export function DateElement(props) {
|
|
35
|
+
const {
|
|
36
|
+
placeholderText,
|
|
37
|
+
value,
|
|
38
|
+
setValue,
|
|
39
|
+
format,
|
|
40
|
+
mode = DATE,
|
|
41
|
+
tooltip = 'Choose a date.',
|
|
42
|
+
tooltipPlacement = 'bottom',
|
|
43
|
+
} = props,
|
|
44
|
+
inputRef = useRef(),
|
|
45
|
+
triggerRef = useRef(),
|
|
46
|
+
pickerRef = useRef(),
|
|
47
|
+
[isPickerShown, setIsPickerShown] = useState(false),
|
|
48
|
+
[isRendered, setIsRendered] = useState(false),
|
|
49
|
+
[isTranslateX, setIsTranslateX] = useState(false),
|
|
50
|
+
[isTranslateY, setIsTranslateY] = useState(false),
|
|
51
|
+
[top, setTop] = useState(0),
|
|
52
|
+
[left, setLeft] = useState(0),
|
|
53
|
+
showPicker = () => {
|
|
54
|
+
if (isPickerShown) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (UiConfig.mode === UI_MODE_WEB && triggerRef.current?.getBoundingClientRect) {
|
|
58
|
+
// For web, ensure it's in the proper place
|
|
59
|
+
const
|
|
60
|
+
triggerRect = triggerRef.current.getBoundingClientRect(),
|
|
61
|
+
inputRect = inputRef.current.getBoundingClientRect(),
|
|
62
|
+
bodyRect = document.body.getBoundingClientRect(),
|
|
63
|
+
isLower = triggerRect.top > (bodyRect.height / 2),
|
|
64
|
+
isRight = triggerRect.left > (bodyRect.width / 2);
|
|
65
|
+
|
|
66
|
+
setLeft(inputRect.left);
|
|
67
|
+
if (isLower) {
|
|
68
|
+
setTop(inputRect.top);
|
|
69
|
+
setIsTranslateY(true);
|
|
70
|
+
} else {
|
|
71
|
+
setTop(inputRect.top + inputRect.height);
|
|
72
|
+
}
|
|
73
|
+
if (isRight) {
|
|
74
|
+
// setIsTranslateX(true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
setIsPickerShown(true);
|
|
79
|
+
},
|
|
80
|
+
hidePicker = () => {
|
|
81
|
+
if (!isPickerShown) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setIsPickerShown(false);
|
|
85
|
+
},
|
|
86
|
+
onInputKeyPress = (e) => {
|
|
87
|
+
switch(e.key) {
|
|
88
|
+
case 'Escape':
|
|
89
|
+
case 'Enter':
|
|
90
|
+
hidePicker();
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
onInputBlur = (e) => {
|
|
96
|
+
const {
|
|
97
|
+
relatedTarget
|
|
98
|
+
} = e;
|
|
99
|
+
if (!relatedTarget ||
|
|
100
|
+
(!inputRef.current.contains(relatedTarget) && triggerRef.current !== relatedTarget && (!pickerRef.current || !pickerRef.current.contains(relatedTarget)))) {
|
|
101
|
+
// hidePicker();
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
onInputClick = (e) => {
|
|
105
|
+
if (!isRendered) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
showPicker();
|
|
109
|
+
},
|
|
110
|
+
onInputSetValue = (value) => {
|
|
111
|
+
if (value === '') {
|
|
112
|
+
setValue(null);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
switch(mode) {
|
|
116
|
+
case DATE:
|
|
117
|
+
if (!_.isNil(value)) {
|
|
118
|
+
value = Parsers.ParseDate(value);
|
|
119
|
+
value = Formatters.FormatDate(value, 'YYYY-MM-DD');
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
case TIME:
|
|
123
|
+
if (!_.isNil(value)) {
|
|
124
|
+
value = Parsers.ParseTime(value);
|
|
125
|
+
value = Formatters.FormatTime(value);
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case DATETIME:
|
|
129
|
+
if (!_.isNil(value)) {
|
|
130
|
+
value = Parsers.ParseDate(value);
|
|
131
|
+
value = Formatters.FormatDate(value, 'YYYY-MM-DD HH:mm:ss');
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
}
|
|
136
|
+
setValue(value);
|
|
137
|
+
},
|
|
138
|
+
onTriggerPress = (e) => {
|
|
139
|
+
if (!isRendered) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (isPickerShown) {
|
|
143
|
+
hidePicker();
|
|
144
|
+
} else {
|
|
145
|
+
showPicker();
|
|
146
|
+
}
|
|
147
|
+
inputRef.current.focus();
|
|
148
|
+
},
|
|
149
|
+
onTriggerBlur = (e) => {
|
|
150
|
+
if (!isPickerShown) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const {
|
|
154
|
+
relatedTarget
|
|
155
|
+
} = e;
|
|
156
|
+
if (!relatedTarget ||
|
|
157
|
+
(!inputRef.current.contains(relatedTarget) && triggerRef.current !== relatedTarget && !pickerRef.current.contains(relatedTarget))) {
|
|
158
|
+
hidePicker();
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
onPickerChange = (moment) => {
|
|
162
|
+
let value = null;
|
|
163
|
+
switch(mode) {
|
|
164
|
+
case DATE:
|
|
165
|
+
value = Formatters.FormatDate(moment, 'YYYY-MM-DD');
|
|
166
|
+
break;
|
|
167
|
+
case TIME:
|
|
168
|
+
value = Formatters.FormatTime(moment);
|
|
169
|
+
break;
|
|
170
|
+
case DATETIME:
|
|
171
|
+
value = Formatters.FormatDateTime(moment, 'YYYY-MM-DD HH:mm:ss');
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
}
|
|
175
|
+
setValue(value);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
// place the picker in a convenient spot
|
|
180
|
+
const
|
|
181
|
+
translateParts = [],
|
|
182
|
+
translateProps = {};
|
|
183
|
+
if (isTranslateX) {
|
|
184
|
+
translateParts.push('translateX(-100%)');
|
|
185
|
+
}
|
|
186
|
+
if (isTranslateY) {
|
|
187
|
+
translateParts.push('translateY(-100%)');
|
|
188
|
+
}
|
|
189
|
+
if (!_.isEmpty(translateParts)) {
|
|
190
|
+
translateProps.style = {
|
|
191
|
+
transform: translateParts.join(' '),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Format the display date/time/datetime
|
|
196
|
+
let title = placeholderText,
|
|
197
|
+
pickerValue = null,
|
|
198
|
+
height = 300,
|
|
199
|
+
width = 300;
|
|
200
|
+
switch(mode) {
|
|
201
|
+
case DATE:
|
|
202
|
+
height = 272;
|
|
203
|
+
if (!_.isNil(value)) {
|
|
204
|
+
title = format ? Formatters.FormatDate(value, format) : Formatters.FormatDate(value);
|
|
205
|
+
pickerValue = Parsers.ParseDate(value, 'YYYY-MM-DD');
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
case TIME:
|
|
209
|
+
height = 120;
|
|
210
|
+
width = 150;
|
|
211
|
+
if (!_.isNil(value)) {
|
|
212
|
+
title = format ? Formatters.FormatTime(value, format) : Formatters.FormatTime(value);
|
|
213
|
+
pickerValue = Parsers.ParseDate(value, 'HH:mm:ss');
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
case DATETIME:
|
|
217
|
+
if (!_.isNil(value)) {
|
|
218
|
+
title = format ? Formatters.FormatDateTime(value, format) : Formatters.FormatDateTime(value);
|
|
219
|
+
pickerValue = Parsers.ParseDate(value, 'YYYY-MM-DD HH:mm:ss');
|
|
220
|
+
}
|
|
221
|
+
break;
|
|
222
|
+
default:
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (pickerValue?.toDate) {
|
|
226
|
+
pickerValue = pickerValue.toDate();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
// Web version
|
|
231
|
+
return <Tooltip label={tooltip} placement={tooltipPlacement}>
|
|
232
|
+
<Row flex={1} h="100%" alignItems="center" onLayout={() => setIsRendered(true)}>
|
|
233
|
+
<IconButton
|
|
234
|
+
ref={triggerRef}
|
|
235
|
+
icon={<Icon as={Calendar} color={styles.FORM_DATE_ICON_COLOR} />}
|
|
236
|
+
onPress={onTriggerPress}
|
|
237
|
+
onBlur={onTriggerBlur}
|
|
238
|
+
h={10}
|
|
239
|
+
w={10}
|
|
240
|
+
borderTopLeftRadius={6}
|
|
241
|
+
borderBottomLeftRadius={6}
|
|
242
|
+
borderTopRightRadius={0}
|
|
243
|
+
borderBottomRightRadius={0}
|
|
244
|
+
bg={styles.FORM_DATE_ICON_BG}
|
|
245
|
+
_hover={{
|
|
246
|
+
bg: styles.FORM_DATE_ICON_BG_HOVER,
|
|
247
|
+
}}
|
|
248
|
+
/>
|
|
249
|
+
<Input
|
|
250
|
+
ref={inputRef}
|
|
251
|
+
value={title}
|
|
252
|
+
setValue={onInputSetValue}
|
|
253
|
+
onKeyPress={onInputKeyPress}
|
|
254
|
+
onBlur={onInputBlur}
|
|
255
|
+
onClick={onInputClick}
|
|
256
|
+
flex={1}
|
|
257
|
+
h="100%"
|
|
258
|
+
p={2}
|
|
259
|
+
borderWidth={1}
|
|
260
|
+
borderColor="trueGray.300"
|
|
261
|
+
borderLeftWidth={0}
|
|
262
|
+
borderTopLeftRadius={0}
|
|
263
|
+
borderBottomLeftRadius={0}
|
|
264
|
+
borderTopRightRadius={6}
|
|
265
|
+
borderBottomRightRadius={6}
|
|
266
|
+
fontSize={styles.FORM_DATE_READOUT_FONTSIZE}
|
|
267
|
+
bg={styles.FORM_DATE_INPUT_BG}
|
|
268
|
+
_focus={{
|
|
269
|
+
bg: styles.FORM_DATE_INPUT_FOCUS_BG,
|
|
270
|
+
}}
|
|
271
|
+
numberOfLines={1}
|
|
272
|
+
ellipsizeMode="head"
|
|
273
|
+
onLayout={(e) => {
|
|
274
|
+
// On web, this is not needed, but on RN it might be, so leave it in for now
|
|
275
|
+
const {
|
|
276
|
+
height,
|
|
277
|
+
top,
|
|
278
|
+
left,
|
|
279
|
+
} = e.nativeEvent.layout;
|
|
280
|
+
setTop(top + height);
|
|
281
|
+
setLeft(left);
|
|
282
|
+
}}
|
|
283
|
+
/>
|
|
284
|
+
{/* <Pressable
|
|
285
|
+
flex={1}
|
|
286
|
+
h="100%"
|
|
287
|
+
onPress={showPicker}
|
|
288
|
+
>
|
|
289
|
+
<Text
|
|
290
|
+
flex={1}
|
|
291
|
+
h="100%"
|
|
292
|
+
ml={1}
|
|
293
|
+
p={2}
|
|
294
|
+
fontSize={styles.FORM_DATE_READOUT_FONTSIZE}
|
|
295
|
+
borderWidth={1}
|
|
296
|
+
borderColor="trueGray.300"
|
|
297
|
+
borderRadius={4}
|
|
298
|
+
numberOfLines={1}
|
|
299
|
+
ellipsizeMode="head"
|
|
300
|
+
>{title}</Text>
|
|
301
|
+
</Pressable> */}
|
|
302
|
+
<Popover
|
|
303
|
+
isOpen={isPickerShown}
|
|
304
|
+
onClose={() => {
|
|
305
|
+
hidePicker();
|
|
306
|
+
}}
|
|
307
|
+
trigger={emptyFn}
|
|
308
|
+
trapFocus={false}
|
|
309
|
+
placement={'auto'}
|
|
310
|
+
{...props}
|
|
311
|
+
>
|
|
312
|
+
<Popover.Content
|
|
313
|
+
position="absolute"
|
|
314
|
+
top={top + 'px'}
|
|
315
|
+
left={left + 'px'}
|
|
316
|
+
w={width}
|
|
317
|
+
h={height}
|
|
318
|
+
{...translateProps}
|
|
319
|
+
>
|
|
320
|
+
<Popover.Body
|
|
321
|
+
ref={pickerRef}
|
|
322
|
+
p={0}
|
|
323
|
+
>
|
|
324
|
+
<Datetime
|
|
325
|
+
open={true}
|
|
326
|
+
input={false}
|
|
327
|
+
closeOnClickOutside={false}
|
|
328
|
+
value={pickerValue}
|
|
329
|
+
dateFormat={mode === DATE || mode === DATETIME ? 'YYYY-MM-DD' : false}
|
|
330
|
+
timeFormat={mode === TIME || mode === DATETIME ? 'HH:mm:ss' : false}
|
|
331
|
+
onChange={onPickerChange}
|
|
332
|
+
/>
|
|
333
|
+
</Popover.Body>
|
|
334
|
+
</Popover.Content>
|
|
335
|
+
</Popover>
|
|
336
|
+
</Row>
|
|
337
|
+
</Tooltip>;
|
|
338
|
+
|
|
339
|
+
// React Native v1
|
|
340
|
+
// return <Row>
|
|
341
|
+
// <Icon as={Calendar} />
|
|
342
|
+
// <Text>{title}</Text>
|
|
343
|
+
// {isPickerShown && <DateTimePicker
|
|
344
|
+
// value={value}
|
|
345
|
+
// mode={mode}
|
|
346
|
+
// display="default"
|
|
347
|
+
// onChange={(e, value) => {
|
|
348
|
+
// setValue(value);
|
|
349
|
+
// }}
|
|
350
|
+
// {...propsToPass}
|
|
351
|
+
// />}
|
|
352
|
+
// </Row>;
|
|
353
|
+
|
|
354
|
+
// React Native v2
|
|
355
|
+
// return <Box>
|
|
356
|
+
// <Button
|
|
357
|
+
// leftIcon={<Icon as={Calendar} />}
|
|
358
|
+
// onPress={showPicker}
|
|
359
|
+
// >{title}</Button>
|
|
360
|
+
// <DateTimePickerModal
|
|
361
|
+
// isPickerShown={isPickerShown}
|
|
362
|
+
// mode="date"
|
|
363
|
+
// onConfirm={handleConfirm}
|
|
364
|
+
// onCancel={hidePicker}
|
|
365
|
+
// {...propsToPass}
|
|
366
|
+
// />
|
|
367
|
+
// </Box>;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export default withValue(DateElement);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Text,
|
|
4
|
+
} from 'native-base';
|
|
5
|
+
import styles from '../../../Constants/Styles';
|
|
6
|
+
import withTooltip from '../../Hoc/withTooltip';
|
|
7
|
+
import withValue from '../../Hoc/withValue';
|
|
8
|
+
|
|
9
|
+
const
|
|
10
|
+
DisplayElement = (props) => {
|
|
11
|
+
const {
|
|
12
|
+
value,
|
|
13
|
+
text = value,
|
|
14
|
+
} = props;
|
|
15
|
+
return <Text
|
|
16
|
+
ref={props.outerRef}
|
|
17
|
+
onChangeText={props.setValue}
|
|
18
|
+
flex={1}
|
|
19
|
+
fontSize={styles.TEXT_FONTSIZE}
|
|
20
|
+
{...props}
|
|
21
|
+
>{text}</Text>;
|
|
22
|
+
},
|
|
23
|
+
DisplayField = withValue(DisplayElement);
|
|
24
|
+
|
|
25
|
+
// Tooltip needs us to forwardRef
|
|
26
|
+
export default withTooltip(React.forwardRef((props, ref) => {
|
|
27
|
+
return <DisplayField {...props} outerRef={ref} />;
|
|
28
|
+
}));
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Icon,
|
|
5
|
+
Row,
|
|
6
|
+
Text,
|
|
7
|
+
Tooltip,
|
|
8
|
+
} from 'native-base';
|
|
9
|
+
import {
|
|
10
|
+
UI_MODE_WEB,
|
|
11
|
+
UI_MODE_REACT_NATIVE,
|
|
12
|
+
} from '../../../Constants/UiModes';
|
|
13
|
+
import UiConfig from '../../../UiConfig';
|
|
14
|
+
import styles from '../../../Constants/Styles';
|
|
15
|
+
import {
|
|
16
|
+
FILE_MODE_IMAGE,
|
|
17
|
+
FILE_MODE_FILE,
|
|
18
|
+
} from '../../../Constants/File';
|
|
19
|
+
import IconButton from '../../Buttons/IconButton';
|
|
20
|
+
import withValue from '../../Hoc/withValue';
|
|
21
|
+
import File from '../../Icons/File';
|
|
22
|
+
import Trash from '../../Icons/Trash';
|
|
23
|
+
import _ from 'lodash';
|
|
24
|
+
|
|
25
|
+
// NOTES: Since this arrangement of form and fields has only a single value per field,
|
|
26
|
+
// but there are multiple fields used in file uploads, change things so that the single
|
|
27
|
+
// value is a JSON object, with the separate values encoded within.
|
|
28
|
+
|
|
29
|
+
// TODO:
|
|
30
|
+
// √ Combine values into single JSON value
|
|
31
|
+
// Build interpreter so the field can work with existing value
|
|
32
|
+
// Build back-end to receive this
|
|
33
|
+
// Build thumbnail viewer for existing image
|
|
34
|
+
// Build editor, with large viewer for existing image / video / pdf
|
|
35
|
+
//
|
|
36
|
+
|
|
37
|
+
function FileElement(props) {
|
|
38
|
+
const {
|
|
39
|
+
name,
|
|
40
|
+
value = {
|
|
41
|
+
dataUri: null,
|
|
42
|
+
control: null,
|
|
43
|
+
filename: null,
|
|
44
|
+
},
|
|
45
|
+
setValue,
|
|
46
|
+
|
|
47
|
+
mode = FILE_MODE_IMAGE, // FILE_MODE_IMAGE, FILE_MODE_FILE
|
|
48
|
+
imagePath = '',
|
|
49
|
+
version = 2,
|
|
50
|
+
tooltip = 'Choose or drag a file on top of this control.',
|
|
51
|
+
tooltipPlacement = 'bottom',
|
|
52
|
+
} = props,
|
|
53
|
+
dragRef = useRef(),
|
|
54
|
+
fileInputRef = useRef(),
|
|
55
|
+
[isDropping, setIsDropping] = useState(false),
|
|
56
|
+
[localDataUri, setLocalDataUri] = useState(null),
|
|
57
|
+
[localControl, setLocalControl] = useState(null),
|
|
58
|
+
[localFilename, setLocalFilename] = useState(null),
|
|
59
|
+
onClear = () => {
|
|
60
|
+
setLocalDataUri(null);
|
|
61
|
+
setLocalControl(null);
|
|
62
|
+
setLocalFilename(null);
|
|
63
|
+
|
|
64
|
+
setValue({
|
|
65
|
+
dataUri: null,
|
|
66
|
+
control: null,
|
|
67
|
+
filename: null,
|
|
68
|
+
version,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
fileInputRef.current.value = null;
|
|
72
|
+
},
|
|
73
|
+
onSelect = () => {
|
|
74
|
+
fileInputRef.current.click();
|
|
75
|
+
|
|
76
|
+
setValue({
|
|
77
|
+
dataUri: null,
|
|
78
|
+
control: null,
|
|
79
|
+
filename: null,
|
|
80
|
+
version,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
onChangeFile = (e) => {
|
|
84
|
+
const
|
|
85
|
+
files = fileInputRef.current.files,
|
|
86
|
+
file = files[0],
|
|
87
|
+
reader = new FileReader();
|
|
88
|
+
|
|
89
|
+
reader.readAsBinaryString(file);
|
|
90
|
+
reader.onload = (e) => {
|
|
91
|
+
setBase64(file, e.target.result);
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
setBase64 = (file, readerResult) => {
|
|
95
|
+
const
|
|
96
|
+
base64 = btoa(readerResult), // 'btoa' is deprecated in Node.js, but not browsers, so use it!
|
|
97
|
+
dataUri = `data:${file.type};base64,${base64}`,
|
|
98
|
+
control = '',
|
|
99
|
+
filename = file.name;
|
|
100
|
+
|
|
101
|
+
setLocalDataUri(dataUri);
|
|
102
|
+
setLocalControl(control);
|
|
103
|
+
setLocalFilename(filename);
|
|
104
|
+
|
|
105
|
+
setValue({
|
|
106
|
+
dataUri,
|
|
107
|
+
control,
|
|
108
|
+
filename,
|
|
109
|
+
version,
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
onDragEnter = (e) => {
|
|
113
|
+
const
|
|
114
|
+
fileTypes = e.dataTransfer && e.dataTransfer.types,
|
|
115
|
+
items = e.dataTransfer && e.dataTransfer.items;
|
|
116
|
+
|
|
117
|
+
if (fileTypes.indexOf('Files') === -1) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (items && items.length > 1) {
|
|
121
|
+
throw new Error('You can only drop a single file!');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
setIsDropping(true);
|
|
125
|
+
},
|
|
126
|
+
onDragLeave = (e) => {
|
|
127
|
+
if (dragRef.current.contains(e.relatedTarget)) {
|
|
128
|
+
return; // ignore events that bubble from within
|
|
129
|
+
}
|
|
130
|
+
setIsDropping(false);
|
|
131
|
+
},
|
|
132
|
+
onDragOver = (e) => {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
},
|
|
135
|
+
onDrop = (e) => {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
const
|
|
138
|
+
files = e.dataTransfer && e.dataTransfer.files,
|
|
139
|
+
file = files[0],
|
|
140
|
+
reader = new FileReader();
|
|
141
|
+
|
|
142
|
+
reader.readAsDataURL(file);
|
|
143
|
+
reader.onload = (e) => {
|
|
144
|
+
setBase64(file, e.target.result);
|
|
145
|
+
};
|
|
146
|
+
setIsDropping(false);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const {
|
|
151
|
+
dataUri,
|
|
152
|
+
control,
|
|
153
|
+
filename,
|
|
154
|
+
} = value;
|
|
155
|
+
setLocalDataUri(localDataUri);
|
|
156
|
+
setLocalControl(localControl);
|
|
157
|
+
setLocalFilename(localFilename);
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
if (UiConfig.mode === UI_MODE_REACT_NATIVE) {
|
|
161
|
+
throw new Error('Not yet implemented for RN.');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return <div ref={dragRef} style={{ flex: 1, height: '100%', }} onDragEnter={onDragEnter} onDragLeave={onDragLeave} onDragOver={onDragOver} onDrop={onDrop}>
|
|
165
|
+
<Tooltip label={tooltip} placement={tooltipPlacement}>
|
|
166
|
+
<Row flex={1} h={10} alignItems="center">
|
|
167
|
+
{isDropping && <Box position="absolute" borderWidth={isDropping ? 2 : 0} borderColor="primary.800" top={0} left={0} w="100%" h="100%" bg="trueGray.200" zIndex={10000} justifyContent="center" alignItems="center">
|
|
168
|
+
<Text>Set File</Text>
|
|
169
|
+
</Box>}
|
|
170
|
+
<IconButton
|
|
171
|
+
icon={<Icon as={File} color={styles.FORM_FILE_ICON_COLOR} />}
|
|
172
|
+
onPress={onSelect}
|
|
173
|
+
h={10}
|
|
174
|
+
w={10}
|
|
175
|
+
bg={styles.FORM_FILE_ICON_BG}
|
|
176
|
+
_hover={{
|
|
177
|
+
bg: styles.FORM_FILE_ICON_BG_HOVER,
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
<IconButton
|
|
181
|
+
icon={<Icon as={Trash} color={styles.FORM_FILE_ICON_COLOR} />}
|
|
182
|
+
onPress={onClear}
|
|
183
|
+
h={10}
|
|
184
|
+
w={10}
|
|
185
|
+
ml={1}
|
|
186
|
+
isDisabled={!value?.dataUri}
|
|
187
|
+
bg={value?.dataUri ? styles.FORM_FILE_ICON_BG : 'disabled'}
|
|
188
|
+
_hover={{
|
|
189
|
+
bg: value?.dataUri ? styles.FORM_FILE_ICON_BG_HOVER : 'disabled',
|
|
190
|
+
}}
|
|
191
|
+
/>
|
|
192
|
+
{mode === FILE_MODE_FILE && <Text
|
|
193
|
+
flex={1}
|
|
194
|
+
ml={3}
|
|
195
|
+
fontSize={styles.FORM_FILE_READOUT_FONTSIZE}
|
|
196
|
+
fontStyle="italic"
|
|
197
|
+
numberOfLines={1}
|
|
198
|
+
ellipsizeMode="head"
|
|
199
|
+
bg={styles.FORM_FILE_READOUT_BG}
|
|
200
|
+
>{value.filename || 'No file'}</Text>}
|
|
201
|
+
{mode === FILE_MODE_IMAGE && <Box
|
|
202
|
+
flex={1}
|
|
203
|
+
h="100%"
|
|
204
|
+
ml={1}
|
|
205
|
+
bg={styles.FORM_FILE_READOUT_BG}
|
|
206
|
+
backgroundImage={value?.dataUri ? 'url(' + imagePath + encodeURIComponent(value.dataUri) + ')' : 'none'}
|
|
207
|
+
backgroundSize="contain"
|
|
208
|
+
backgroundRepeat="no-repeat"
|
|
209
|
+
borderRadius={4}
|
|
210
|
+
borderWidth={1}
|
|
211
|
+
/>}
|
|
212
|
+
<input type="file" ref={fileInputRef} name={name} onChange={onChangeFile} style={{ position: 'absolute', opacity: 0, height: 0, width: 0, }} />
|
|
213
|
+
</Row>
|
|
214
|
+
</Tooltip>
|
|
215
|
+
</div>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export default withValue(FileElement);
|