@onehat/ui 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +14 -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
- package/src/index.js +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useState, useEffect, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Column,
|
|
4
|
+
Checkbox,
|
|
5
|
+
Row,
|
|
6
|
+
} from 'native-base';
|
|
7
|
+
import withData from '../../../Hoc/withData.js';
|
|
8
|
+
import withValue from '../../../Hoc/withValue.js';
|
|
9
|
+
import withTooltip from '../../../Hoc/withTooltip.js';
|
|
10
|
+
import _ from 'lodash';
|
|
11
|
+
|
|
12
|
+
const
|
|
13
|
+
CheckboxGroupElement = (props) => {
|
|
14
|
+
const {
|
|
15
|
+
value,
|
|
16
|
+
|
|
17
|
+
// withData
|
|
18
|
+
Repository,
|
|
19
|
+
data,
|
|
20
|
+
idIx,
|
|
21
|
+
displayIx,
|
|
22
|
+
} = props,
|
|
23
|
+
[checkboxes, setCheckboxes] = useState([]);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
|
|
27
|
+
// adjust the checkboxes to match the value
|
|
28
|
+
let checkboxes = [];
|
|
29
|
+
const checkboxProps = {
|
|
30
|
+
};
|
|
31
|
+
if (Repository) {
|
|
32
|
+
const entities = Repository.getEntitiesOnPage();
|
|
33
|
+
checkboxes = _.map(entities, (entity, ix) => {
|
|
34
|
+
return <Checkbox
|
|
35
|
+
key={ix}
|
|
36
|
+
value={entity.id}
|
|
37
|
+
{...checkboxProps}
|
|
38
|
+
>{entity.displayValue}</Checkbox>;
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
checkboxes = _.map(data, (datum, ix) => {
|
|
42
|
+
return <Checkbox
|
|
43
|
+
key={ix}
|
|
44
|
+
value={datum[idIx]}
|
|
45
|
+
{...checkboxProps}
|
|
46
|
+
>{datum[displayIx]}</Checkbox>;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
setCheckboxes(checkboxes);
|
|
50
|
+
}, [value]);
|
|
51
|
+
|
|
52
|
+
return <Checkbox.Group onChange={props.setValue} accessibilityLabel={props.name} {...props}>
|
|
53
|
+
{checkboxes}
|
|
54
|
+
</Checkbox.Group>;
|
|
55
|
+
},
|
|
56
|
+
CheckboxGroupField = withValue(withData(CheckboxGroupElement));
|
|
57
|
+
|
|
58
|
+
// Tooltip needs us to forwardRef
|
|
59
|
+
export default withTooltip(React.forwardRef((props, ref) => {
|
|
60
|
+
return <CheckboxGroupField {...props} outerRef={ref} />;
|
|
61
|
+
}));
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Popover,
|
|
4
|
+
Pressable,
|
|
5
|
+
Row,
|
|
6
|
+
Text,
|
|
7
|
+
Tooltip,
|
|
8
|
+
} from 'native-base';
|
|
9
|
+
import { SketchPicker } from 'react-color';
|
|
10
|
+
import {
|
|
11
|
+
UI_MODE_WEB,
|
|
12
|
+
} from '../../../Constants/UiModes.js';
|
|
13
|
+
import UiConfig from '../../../UiConfig.js';
|
|
14
|
+
import Input from '../Field/Input.js';
|
|
15
|
+
import styles from '../../../Constants/Styles.js';
|
|
16
|
+
import withValue from '../../Hoc/withValue.js';
|
|
17
|
+
import emptyFn from '../../../Functions/emptyFn.js';
|
|
18
|
+
import _ from 'lodash';
|
|
19
|
+
|
|
20
|
+
export function ColorElement(props) {
|
|
21
|
+
const {
|
|
22
|
+
value = '#000',
|
|
23
|
+
setValue,
|
|
24
|
+
tooltip = 'Choose a color.',
|
|
25
|
+
tooltipPlacement = 'bottom',
|
|
26
|
+
} = props,
|
|
27
|
+
inputRef = useRef(),
|
|
28
|
+
triggerRef = useRef(),
|
|
29
|
+
pickerRef = useRef(),
|
|
30
|
+
[isPickerShown, setIsPickerShown] = useState(false),
|
|
31
|
+
[isRendered, setIsRendered] = useState(false),
|
|
32
|
+
[isTranslateX, setIsTranslateX] = useState(false),
|
|
33
|
+
[isTranslateY, setIsTranslateY] = useState(false),
|
|
34
|
+
[top, setTop] = useState(0),
|
|
35
|
+
[left, setLeft] = useState(0),
|
|
36
|
+
showPicker = () => {
|
|
37
|
+
if (isPickerShown) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (UiConfig.mode === UI_MODE_WEB && triggerRef.current?.getBoundingClientRect) {
|
|
42
|
+
// For web, ensure it's in the proper place
|
|
43
|
+
const
|
|
44
|
+
triggerRect = triggerRef.current.getBoundingClientRect(),
|
|
45
|
+
inputRect = inputRef.current.getBoundingClientRect(),
|
|
46
|
+
bodyRect = document.body.getBoundingClientRect(),
|
|
47
|
+
isLower = triggerRect.top > (bodyRect.height / 2),
|
|
48
|
+
isRight = triggerRect.left > (bodyRect.width / 2);
|
|
49
|
+
|
|
50
|
+
setLeft(inputRect.left);
|
|
51
|
+
if (isLower) {
|
|
52
|
+
setTop(inputRect.top);
|
|
53
|
+
setIsTranslateY(true);
|
|
54
|
+
} else {
|
|
55
|
+
setTop(inputRect.top + inputRect.height);
|
|
56
|
+
}
|
|
57
|
+
if (isRight) {
|
|
58
|
+
// setIsTranslateX(true);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setIsPickerShown(true);
|
|
63
|
+
},
|
|
64
|
+
hidePicker = () => {
|
|
65
|
+
if (!isPickerShown) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setIsPickerShown(false);
|
|
69
|
+
},
|
|
70
|
+
onInputKeyPress = (e) => {
|
|
71
|
+
switch(e.key) {
|
|
72
|
+
case 'Escape':
|
|
73
|
+
case 'Enter':
|
|
74
|
+
hidePicker();
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
onInputBlur = (e) => {
|
|
80
|
+
const {
|
|
81
|
+
relatedTarget
|
|
82
|
+
} = e;
|
|
83
|
+
if (!relatedTarget ||
|
|
84
|
+
(!inputRef.current.contains(relatedTarget) && triggerRef.current !== relatedTarget && (!pickerRef.current || !pickerRef.current.contains(relatedTarget)))) {
|
|
85
|
+
hidePicker();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
onInputClick = (e) => {
|
|
89
|
+
if (!isRendered) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
showPicker();
|
|
93
|
+
},
|
|
94
|
+
onTriggerPress = (e) => {
|
|
95
|
+
if (!isRendered) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (isPickerShown) {
|
|
99
|
+
hidePicker();
|
|
100
|
+
} else {
|
|
101
|
+
showPicker();
|
|
102
|
+
}
|
|
103
|
+
inputRef.current.focus();
|
|
104
|
+
},
|
|
105
|
+
onTriggerBlur = (e) => {
|
|
106
|
+
if (!isPickerShown) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const {
|
|
110
|
+
relatedTarget
|
|
111
|
+
} = e;
|
|
112
|
+
if (!relatedTarget ||
|
|
113
|
+
(!inputRef.current.contains(relatedTarget) && triggerRef.current !== relatedTarget && !pickerRef.current.contains(relatedTarget))) {
|
|
114
|
+
hidePicker();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const
|
|
120
|
+
translateParts = [],
|
|
121
|
+
translateProps = {};
|
|
122
|
+
if (isTranslateX) {
|
|
123
|
+
translateParts.push('translateX(-100%)');
|
|
124
|
+
}
|
|
125
|
+
if (isTranslateY) {
|
|
126
|
+
translateParts.push('translateY(-100%)');
|
|
127
|
+
}
|
|
128
|
+
if (!_.isEmpty(translateParts)) {
|
|
129
|
+
translateProps.style = {
|
|
130
|
+
transform: translateParts.join(' '),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// Web version
|
|
136
|
+
return <Tooltip label={tooltip} placement={tooltipPlacement}>
|
|
137
|
+
<Row flex={1} h="100%" alignItems="center" onLayout={() => setIsRendered(true)}>
|
|
138
|
+
<Pressable
|
|
139
|
+
ref={triggerRef}
|
|
140
|
+
onPress={onTriggerPress}
|
|
141
|
+
onBlur={onTriggerBlur}
|
|
142
|
+
h={10}
|
|
143
|
+
w={10}
|
|
144
|
+
bg={value}
|
|
145
|
+
borderTopLeftRadius={6}
|
|
146
|
+
borderBottomLeftRadius={6}
|
|
147
|
+
borderTopRightRadius={0}
|
|
148
|
+
borderBottomRightRadius={0}
|
|
149
|
+
borderWidth={1}
|
|
150
|
+
borderColor="trueGray.300"
|
|
151
|
+
/>
|
|
152
|
+
<Input
|
|
153
|
+
ref={inputRef}
|
|
154
|
+
value={value}
|
|
155
|
+
setValue={setValue}
|
|
156
|
+
maxLength={7}
|
|
157
|
+
onBlur={onInputBlur}
|
|
158
|
+
onClick={onInputClick}
|
|
159
|
+
flex={1}
|
|
160
|
+
h="100%"
|
|
161
|
+
p={2}
|
|
162
|
+
borderWidth={1}
|
|
163
|
+
borderColor="trueGray.300"
|
|
164
|
+
borderLeftWidth={0}
|
|
165
|
+
borderTopLeftRadius={0}
|
|
166
|
+
borderBottomLeftRadius={0}
|
|
167
|
+
borderTopRightRadius={6}
|
|
168
|
+
borderBottomRightRadius={6}
|
|
169
|
+
fontSize={styles.FORM_COLOR_READOUT_FONTSIZE}
|
|
170
|
+
bg={styles.FORM_COLOR_INPUT_BG}
|
|
171
|
+
_focus={{
|
|
172
|
+
bg: styles.FORM_COLOR_INPUT_FOCUS_BG,
|
|
173
|
+
}}
|
|
174
|
+
onLayout={(e) => {
|
|
175
|
+
// On web, this is not needed, but on RN it might be, so leave it in for now
|
|
176
|
+
const {
|
|
177
|
+
height,
|
|
178
|
+
top,
|
|
179
|
+
left,
|
|
180
|
+
} = e.nativeEvent.layout;
|
|
181
|
+
setTop(top + height);
|
|
182
|
+
setLeft(left);
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
<Popover
|
|
186
|
+
isOpen={isPickerShown}
|
|
187
|
+
onClose={() => {
|
|
188
|
+
hidePicker();
|
|
189
|
+
}}
|
|
190
|
+
trigger={emptyFn}
|
|
191
|
+
trapFocus={true}
|
|
192
|
+
placement={'auto'}
|
|
193
|
+
{...props}
|
|
194
|
+
>
|
|
195
|
+
<Popover.Content
|
|
196
|
+
position="absolute"
|
|
197
|
+
top={top + 'px'}
|
|
198
|
+
left={left + 'px'}
|
|
199
|
+
w={220}
|
|
200
|
+
h={287}
|
|
201
|
+
{...translateProps}
|
|
202
|
+
>
|
|
203
|
+
<Popover.Body
|
|
204
|
+
ref={pickerRef}
|
|
205
|
+
p={0}
|
|
206
|
+
>
|
|
207
|
+
<SketchPicker
|
|
208
|
+
disableAlpha={true}
|
|
209
|
+
color={value}
|
|
210
|
+
onChange={(color) => setValue(color.hex)}
|
|
211
|
+
{...props}
|
|
212
|
+
/>
|
|
213
|
+
</Popover.Body>
|
|
214
|
+
</Popover.Content>
|
|
215
|
+
</Popover>
|
|
216
|
+
</Row>
|
|
217
|
+
</Tooltip>;
|
|
218
|
+
|
|
219
|
+
// React Native v1
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
// React Native v2
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export default withValue(ColorElement);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Combo from './Combo.js';
|
|
2
|
+
|
|
3
|
+
// This is a building block for other combos,
|
|
4
|
+
// which store their data as a JSON array, not a data repository.
|
|
5
|
+
// Need to supply data prop from outer component.
|
|
6
|
+
// See MonthsCombo for an example.
|
|
7
|
+
export default function ArrayCombo(props) {
|
|
8
|
+
return <Combo
|
|
9
|
+
idField="id"
|
|
10
|
+
displayField="value"
|
|
11
|
+
fields={['id', 'value']}
|
|
12
|
+
columnsConfig={['value']}
|
|
13
|
+
{...props}
|
|
14
|
+
/>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ArrayCombo from './ArrayCombo.js';
|
|
2
|
+
|
|
3
|
+
const
|
|
4
|
+
trueFalseData = [
|
|
5
|
+
[true, 'Yes'],
|
|
6
|
+
[false, 'No'],
|
|
7
|
+
],
|
|
8
|
+
oneZeroData = [
|
|
9
|
+
[1, 'Yes'],
|
|
10
|
+
[0, 'No'],
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export default function BooleanCombo(props) {
|
|
14
|
+
const {
|
|
15
|
+
useTrueFalse = true,
|
|
16
|
+
} = props,
|
|
17
|
+
data = useTrueFalse ? trueFalseData : oneZeroData;
|
|
18
|
+
|
|
19
|
+
return <ArrayCombo
|
|
20
|
+
data={data}
|
|
21
|
+
{...props}
|
|
22
|
+
/>;
|
|
23
|
+
}
|