@onehat/ui 0.1.3 → 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,127 @@
|
|
|
1
|
+
import React, { useState, useEffect, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Column,
|
|
5
|
+
FlatList,
|
|
6
|
+
Icon,
|
|
7
|
+
Modal,
|
|
8
|
+
Pressable,
|
|
9
|
+
Row,
|
|
10
|
+
Spacer,
|
|
11
|
+
Text,
|
|
12
|
+
} from 'native-base';
|
|
13
|
+
import _ from 'lodash';
|
|
14
|
+
|
|
15
|
+
export default function withContextMenu(WrappedComponent) {
|
|
16
|
+
return (props) => {
|
|
17
|
+
const {
|
|
18
|
+
// extract and pass
|
|
19
|
+
disableContextMenu = false,
|
|
20
|
+
contextMenuItems,
|
|
21
|
+
...propsToPass
|
|
22
|
+
} = props,
|
|
23
|
+
{
|
|
24
|
+
// for local use
|
|
25
|
+
selection,
|
|
26
|
+
setSelection, // in case it's ever needed!
|
|
27
|
+
} = props,
|
|
28
|
+
[isReady, setIsReady] = useState(false),
|
|
29
|
+
[isContextMenuShown, setIsContextMenuShown] = useState(false),
|
|
30
|
+
[contextMenuX, setContextMenuX] = useState(0),
|
|
31
|
+
[contextMenuY, setContextMenuY] = useState(0),
|
|
32
|
+
[contextMenuItemComponents, setContextMenuItemComponents] = useState([]),
|
|
33
|
+
onContextMenu = (entity, rowIx, e, selection, setSelection) => {
|
|
34
|
+
if (disableContextMenu) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!selection.length && entity) {
|
|
38
|
+
// No current selections, so select this row so operations apply to it
|
|
39
|
+
setSelection([entity]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setIsContextMenuShown(true);
|
|
43
|
+
setContextMenuX(e.nativeEvent.pageX);
|
|
44
|
+
setContextMenuY(e.nativeEvent.pageY);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const contextMenuItemComponents = _.map(contextMenuItems, (config, ix) => {
|
|
49
|
+
let {
|
|
50
|
+
text,
|
|
51
|
+
handler,
|
|
52
|
+
icon = null,
|
|
53
|
+
isDisabled = false,
|
|
54
|
+
} = config;
|
|
55
|
+
|
|
56
|
+
if (icon) {
|
|
57
|
+
const iconProps = {
|
|
58
|
+
alignSelf: 'center',
|
|
59
|
+
size: 'sm',
|
|
60
|
+
color: isDisabled ? 'disabled' : 'trueGray.800',
|
|
61
|
+
h: 20,
|
|
62
|
+
w: 20,
|
|
63
|
+
mr: 2,
|
|
64
|
+
};
|
|
65
|
+
icon = React.cloneElement(icon, {...iconProps});
|
|
66
|
+
}
|
|
67
|
+
return <Pressable
|
|
68
|
+
key={ix}
|
|
69
|
+
onPress={() => {
|
|
70
|
+
setIsContextMenuShown(false);
|
|
71
|
+
handler();
|
|
72
|
+
}}
|
|
73
|
+
flexDirection="row"
|
|
74
|
+
borderBottomWidth={1}
|
|
75
|
+
borderBottomColor="trueGray.200"
|
|
76
|
+
py={2}
|
|
77
|
+
px={4}
|
|
78
|
+
_hover={{
|
|
79
|
+
bg: '#ffc',
|
|
80
|
+
}}
|
|
81
|
+
isDisabled={isDisabled}
|
|
82
|
+
>
|
|
83
|
+
{icon}
|
|
84
|
+
<Text
|
|
85
|
+
flex={1}
|
|
86
|
+
color={isDisabled ? 'disabled' : 'trueGray.800'}
|
|
87
|
+
numberOfLines={1}
|
|
88
|
+
ellipsizeMode="head"
|
|
89
|
+
>{text}</Text>
|
|
90
|
+
</Pressable>;
|
|
91
|
+
});
|
|
92
|
+
const showId = true; // TODO: This should only be for local dev
|
|
93
|
+
if (showId) {
|
|
94
|
+
contextMenuItemComponents.push(<Text
|
|
95
|
+
key="idViewer"
|
|
96
|
+
flex={1}
|
|
97
|
+
py={2}
|
|
98
|
+
px={4}
|
|
99
|
+
>id: {selection?.[0]?.id}</Text>);
|
|
100
|
+
}
|
|
101
|
+
setContextMenuItemComponents(contextMenuItemComponents);
|
|
102
|
+
|
|
103
|
+
if (!isReady) {
|
|
104
|
+
setIsReady(true);
|
|
105
|
+
}
|
|
106
|
+
}, [contextMenuItems, setIsContextMenuShown]);
|
|
107
|
+
|
|
108
|
+
if (!isReady) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return <>
|
|
113
|
+
<WrappedComponent
|
|
114
|
+
{...propsToPass}
|
|
115
|
+
onContextMenu={onContextMenu}
|
|
116
|
+
/>
|
|
117
|
+
<Modal
|
|
118
|
+
isOpen={isContextMenuShown && !disableContextMenu}
|
|
119
|
+
onClose={() => setIsContextMenuShown(false)}
|
|
120
|
+
>
|
|
121
|
+
<Column bg="#fff" w={180} position="absolute" top={contextMenuY} left={contextMenuX}>
|
|
122
|
+
{contextMenuItemComponents}
|
|
123
|
+
</Column>
|
|
124
|
+
</Modal>
|
|
125
|
+
</>;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useState, useEffect, } from 'react';
|
|
2
|
+
import oneHatData from '@onehat/data';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
|
|
5
|
+
// Keeps track of LocalRepository.
|
|
6
|
+
// If a Repository was submitted, this simply passes everything through
|
|
7
|
+
// without changing anything. In that way, a component can have multiple
|
|
8
|
+
// levels of withData() applied, to no ill effect.
|
|
9
|
+
|
|
10
|
+
// This is the primary link between @onehat/data and the UI components
|
|
11
|
+
|
|
12
|
+
export default function withData(WrappedComponent) {
|
|
13
|
+
return (props) => {
|
|
14
|
+
const
|
|
15
|
+
{
|
|
16
|
+
// For @onehat/data repositories
|
|
17
|
+
Repository,
|
|
18
|
+
setRepository,
|
|
19
|
+
uniqueRepository = false,
|
|
20
|
+
model,
|
|
21
|
+
autoLoad = false,
|
|
22
|
+
|
|
23
|
+
// For plain JS data
|
|
24
|
+
data,
|
|
25
|
+
fields = ['id', 'value'],
|
|
26
|
+
idField = 'id',
|
|
27
|
+
displayField = 'value',
|
|
28
|
+
idIx,
|
|
29
|
+
displayIx,
|
|
30
|
+
} = props,
|
|
31
|
+
propsToPass = _.omit(props, ['model']), // passing 'model' would mess things up if withData gets called twice (e.g. withData(...withData(...)) ), as we'd be trying to recreate Repository twice
|
|
32
|
+
localIdIx = idIx || (fields && idField ? fields.indexOf(idField) : null),
|
|
33
|
+
localDisplayIx = displayIx || (fields && displayField ? fields?.indexOf(displayField) : null),
|
|
34
|
+
[LocalRepository, setLocalRepository] = useState(Repository || null), // simply pass on Repository if it's already supplied
|
|
35
|
+
[isReady, setIsReady] = useState(!!LocalRepository || !!data); // It's already ready if a LocalRepository or data array is already set. Otherwise, we need to create the repository
|
|
36
|
+
|
|
37
|
+
// Create LocalRepository
|
|
38
|
+
// If Repository was submitted to this withData(), the useEffect has no effect.
|
|
39
|
+
// If it's empty, it tries to create a LocalRepository
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!!LocalRepository || !!data) {
|
|
42
|
+
return () => {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
(async () => {
|
|
46
|
+
let Repository;
|
|
47
|
+
if (uniqueRepository) {
|
|
48
|
+
const schema = oneHatData.getSchema(model);
|
|
49
|
+
Repository = await oneHatData.createRepository({ schema });
|
|
50
|
+
} else {
|
|
51
|
+
Repository = oneHatData.getRepository(model);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if (autoLoad && Repository && !Repository.isLoaded && Repository.isRemote && !Repository.isAutoLoad && !Repository.isLoading) {
|
|
56
|
+
await Repository.load();
|
|
57
|
+
// TODO: Implement some method by which I can detect if Repository is still loading and wait until it's done!
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setLocalRepository(Repository);
|
|
61
|
+
if (setRepository) { // pass it on up to higher components
|
|
62
|
+
setRepository(Repository);
|
|
63
|
+
}
|
|
64
|
+
setIsReady(true);
|
|
65
|
+
})();
|
|
66
|
+
|
|
67
|
+
}, [LocalRepository]);
|
|
68
|
+
|
|
69
|
+
if (!isReady) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return <WrappedComponent
|
|
74
|
+
{...propsToPass}
|
|
75
|
+
Repository={LocalRepository}
|
|
76
|
+
model={model}
|
|
77
|
+
data={data}
|
|
78
|
+
fields={fields}
|
|
79
|
+
idField={idField}
|
|
80
|
+
displayField={displayField}
|
|
81
|
+
idIx={localIdIx}
|
|
82
|
+
displayIx={localDisplayIx}
|
|
83
|
+
/>;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { useState, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
HORIZONTAL,
|
|
4
|
+
VERTICAL,
|
|
5
|
+
} from '../../Constants/Directions';
|
|
6
|
+
import {
|
|
7
|
+
UI_MODE_WEB,
|
|
8
|
+
UI_MODE_REACT_NATIVE,
|
|
9
|
+
} from '../../Constants/UiModes';
|
|
10
|
+
import UiConfig from '../../UiConfig';
|
|
11
|
+
import Draggable from 'react-draggable'; // https://github.com/react-grid-layout/react-draggable
|
|
12
|
+
import useBlocking from '../../Hooks/useBlocking';
|
|
13
|
+
import {
|
|
14
|
+
v4 as uuid,
|
|
15
|
+
} from 'uuid';
|
|
16
|
+
|
|
17
|
+
// Note on modes:
|
|
18
|
+
// HORIZONTAL means the component moves along the X axis.
|
|
19
|
+
// VERTICAL means the component moves along the Y axis.
|
|
20
|
+
|
|
21
|
+
export default function withDraggable(WrappedComponent) {
|
|
22
|
+
return (props) => {
|
|
23
|
+
|
|
24
|
+
if (UiConfig.mode === UI_MODE_REACT_NATIVE) {
|
|
25
|
+
throw new Error('Not yet implemented for RN.');
|
|
26
|
+
}
|
|
27
|
+
const {
|
|
28
|
+
// extract and pass
|
|
29
|
+
onDragStart,
|
|
30
|
+
onDrag,
|
|
31
|
+
onDragStop,
|
|
32
|
+
onChangeIsDragging,
|
|
33
|
+
getParentNode = (node) => node.parentElement.parentElement,
|
|
34
|
+
getProxy,
|
|
35
|
+
proxyParent,
|
|
36
|
+
proxyPositionRelativeToParent = false,
|
|
37
|
+
handle,
|
|
38
|
+
...propsToPass
|
|
39
|
+
} = props,
|
|
40
|
+
{
|
|
41
|
+
// for local use
|
|
42
|
+
mode = HORIZONTAL, // HORIZONTAL, VERTICAL
|
|
43
|
+
} = props,
|
|
44
|
+
[isDragging, setIsDraggingRaw] = useState(false),
|
|
45
|
+
[node, setNode] = useState(false),
|
|
46
|
+
[bounds, setBounds] = useState(null),
|
|
47
|
+
{ block } = useBlocking(),
|
|
48
|
+
setIsDragging = (value) => {
|
|
49
|
+
setIsDraggingRaw(value);
|
|
50
|
+
if (onChangeIsDragging) {
|
|
51
|
+
onChangeIsDragging(value);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
handleStart = (e, info) => {
|
|
55
|
+
if (isDragging) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const
|
|
60
|
+
node = info.node,
|
|
61
|
+
parentContainer = getParentNode && getParentNode(node);
|
|
62
|
+
|
|
63
|
+
setNode(node);
|
|
64
|
+
|
|
65
|
+
if (parentContainer && !parentContainer.id) {
|
|
66
|
+
parentContainer.id = 'a' + uuid().replace(/-/g, '');
|
|
67
|
+
setBounds(parentContainer.getBoundingClientRect());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// clone node for proxy, append to DOM
|
|
71
|
+
let proxy;
|
|
72
|
+
if (getProxy) {
|
|
73
|
+
proxy = getProxy(node);
|
|
74
|
+
} else {
|
|
75
|
+
proxy = node.cloneNode(true);
|
|
76
|
+
const nodeRect = node.getBoundingClientRect();
|
|
77
|
+
proxy.style.top = nodeRect.top + 'px';
|
|
78
|
+
proxy.style.left = nodeRect.left + 'px';
|
|
79
|
+
proxy.style.height = nodeRect.height + 'px';
|
|
80
|
+
proxy.style.width = nodeRect.width + 'px';
|
|
81
|
+
}
|
|
82
|
+
proxy = proxyParent ? proxyParent.appendChild(proxy) : document.body.appendChild(proxy);
|
|
83
|
+
proxy.style.zIndex = 10000;
|
|
84
|
+
proxy.style.position = 'absolute';
|
|
85
|
+
proxy.style.visibility = 'visible';
|
|
86
|
+
proxy.style.backgroundColor = '#fff';
|
|
87
|
+
proxy.id = 'dragproxy';
|
|
88
|
+
proxy.className = '';
|
|
89
|
+
|
|
90
|
+
node.style.visibility = 'hidden';
|
|
91
|
+
|
|
92
|
+
setIsDragging(true);
|
|
93
|
+
|
|
94
|
+
if (onDragStart) {
|
|
95
|
+
onDragStart(info, e, proxy, node)
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
isWithinBounds = ({ pageX, pageY }) => {
|
|
99
|
+
if (!bounds) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
const {
|
|
103
|
+
left,
|
|
104
|
+
right,
|
|
105
|
+
top,
|
|
106
|
+
bottom,
|
|
107
|
+
} = bounds;
|
|
108
|
+
|
|
109
|
+
if (mode === HORIZONTAL) {
|
|
110
|
+
return pageX >= left && pageX <= right;
|
|
111
|
+
} else if (mode === VERTICAL) {
|
|
112
|
+
return pageY <= bottom && pageX >= top;
|
|
113
|
+
} else {
|
|
114
|
+
return pageX >= left && pageX <= right && pageY <= bottom && pageX >= top;
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
handleDrag = (e, info) => {
|
|
118
|
+
// Move proxy to new page coords
|
|
119
|
+
if (!isWithinBounds(e)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const {
|
|
124
|
+
deltaX,
|
|
125
|
+
deltaY,
|
|
126
|
+
} = info;
|
|
127
|
+
|
|
128
|
+
// Move the proxy to where it should be
|
|
129
|
+
const
|
|
130
|
+
proxy = document.getElementById('dragproxy'),
|
|
131
|
+
currentLeft = parseInt(proxy.style.left),
|
|
132
|
+
currentTop = parseInt(proxy.style.top);
|
|
133
|
+
if (mode === HORIZONTAL) {
|
|
134
|
+
const left = proxyPositionRelativeToParent ? e.pageX - proxyParent.getBoundingClientRect().left : e.pageX;
|
|
135
|
+
proxy.style.left = left + 'px';
|
|
136
|
+
} else if (mode === VERTICAL) {
|
|
137
|
+
const top = proxyPositionRelativeToParent ? e.pageY - proxyParent.getBoundingClientRect().top : e.pageY;
|
|
138
|
+
proxy.style.top = top + 'px';
|
|
139
|
+
} else {
|
|
140
|
+
proxy.style.left = currentLeft + deltaX + 'px';
|
|
141
|
+
proxy.style.top = currentTop + deltaY + 'px';
|
|
142
|
+
}
|
|
143
|
+
if (onDrag) {
|
|
144
|
+
onDrag(info, e, proxy, node);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
},
|
|
148
|
+
handleStop = (e, info) => {
|
|
149
|
+
if (!isDragging) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// console.log('end', info);
|
|
154
|
+
// remove proxy
|
|
155
|
+
const proxy = document.getElementById('dragproxy');
|
|
156
|
+
proxy.remove();
|
|
157
|
+
|
|
158
|
+
// constrain node to bounds
|
|
159
|
+
if (!isWithinBounds(e)) {
|
|
160
|
+
const {
|
|
161
|
+
left,
|
|
162
|
+
right,
|
|
163
|
+
top,
|
|
164
|
+
bottom,
|
|
165
|
+
} = bounds,
|
|
166
|
+
{ pageX, pageY } = e;
|
|
167
|
+
let newX = pageX,
|
|
168
|
+
newY = pageY;
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if (mode === HORIZONTAL) {
|
|
172
|
+
if (left > pageX) {
|
|
173
|
+
newX = left;
|
|
174
|
+
} else if (pageX > right) {
|
|
175
|
+
newX = right;
|
|
176
|
+
}
|
|
177
|
+
node.style.left = newX + 'px';
|
|
178
|
+
} else if (mode === VERTICAL) {
|
|
179
|
+
if (top > pageY) {
|
|
180
|
+
newX = top;
|
|
181
|
+
} else if (pageY > bottom) {
|
|
182
|
+
newX = bottom;
|
|
183
|
+
}
|
|
184
|
+
node.style.top = newY + 'px';
|
|
185
|
+
} else {
|
|
186
|
+
if (left > pageX) {
|
|
187
|
+
newX = left;
|
|
188
|
+
} else if (pageX > right) {
|
|
189
|
+
newX = right;
|
|
190
|
+
}
|
|
191
|
+
node.style.left = newX + 'px';
|
|
192
|
+
|
|
193
|
+
if (top > pageY) {
|
|
194
|
+
newX = top;
|
|
195
|
+
} else if (pageY > bottom) {
|
|
196
|
+
newX = bottom;
|
|
197
|
+
}
|
|
198
|
+
node.style.top = newY + 'px';
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// show original node
|
|
203
|
+
node.style.visibility = 'visible';
|
|
204
|
+
|
|
205
|
+
block();
|
|
206
|
+
if (onDragStop) {
|
|
207
|
+
if (mode === HORIZONTAL) {
|
|
208
|
+
onDragStop(info.x, e, node);
|
|
209
|
+
} else if (mode === VERTICAL) {
|
|
210
|
+
onDragStop(info.y, e, node);
|
|
211
|
+
} else {
|
|
212
|
+
onDragStop(info, e, node);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
setIsDragging(false);
|
|
216
|
+
};
|
|
217
|
+
propsToPass.isDragging = isDragging;
|
|
218
|
+
|
|
219
|
+
if (mode === VERTICAL) {
|
|
220
|
+
return <Draggable
|
|
221
|
+
axis="x"
|
|
222
|
+
onStart={handleStart}
|
|
223
|
+
onDrag={handleDrag}
|
|
224
|
+
onStop={handleStop}
|
|
225
|
+
position={{ x: 0, y: 0, /* reset to dropped position */ }}
|
|
226
|
+
// bounds={bounds}
|
|
227
|
+
>
|
|
228
|
+
<div className="nsResize" style={{ width: '100%', }}>
|
|
229
|
+
<WrappedComponent {...propsToPass} />
|
|
230
|
+
</div>
|
|
231
|
+
</Draggable>;
|
|
232
|
+
} else if (mode === HORIZONTAL) {
|
|
233
|
+
return <Draggable
|
|
234
|
+
axis="y"
|
|
235
|
+
onStart={handleStart}
|
|
236
|
+
onDrag={handleDrag}
|
|
237
|
+
onStop={handleStop}
|
|
238
|
+
position={{ x: 0, y: 0, /* reset to dropped position */ }}
|
|
239
|
+
// bounds={bounds}
|
|
240
|
+
>
|
|
241
|
+
<div className="ewResize" style={{ height: '100%', }}>
|
|
242
|
+
<WrappedComponent {...propsToPass} />
|
|
243
|
+
</div>
|
|
244
|
+
</Draggable>;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// can drag in all directions
|
|
248
|
+
return <Draggable
|
|
249
|
+
axis="both"
|
|
250
|
+
onStart={handleStart}
|
|
251
|
+
onDrag={handleDrag}
|
|
252
|
+
onStop={handleStop}
|
|
253
|
+
// position={{ x: 0, y: 0, /* reset to dropped position */ }}
|
|
254
|
+
handle={handle}
|
|
255
|
+
>
|
|
256
|
+
<WrappedComponent {...propsToPass} />
|
|
257
|
+
</Draggable>;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useState, } from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
|
|
4
|
+
export default function withEditor(WrappedComponent) {
|
|
5
|
+
return (props) => {
|
|
6
|
+
const {
|
|
7
|
+
useEditor = false,
|
|
8
|
+
userCanEdit = true,
|
|
9
|
+
userCanView = true,
|
|
10
|
+
disableAdd = false,
|
|
11
|
+
disableEdit = false,
|
|
12
|
+
disableDelete = false,
|
|
13
|
+
disableDuplicate = false,
|
|
14
|
+
disableView = false,
|
|
15
|
+
getRecordIdentifier = (selection) => {
|
|
16
|
+
if (selection.length > 1) {
|
|
17
|
+
return 'records?';
|
|
18
|
+
}
|
|
19
|
+
return 'record?';
|
|
20
|
+
},
|
|
21
|
+
record,
|
|
22
|
+
|
|
23
|
+
// withData
|
|
24
|
+
Repository,
|
|
25
|
+
|
|
26
|
+
// withSelection
|
|
27
|
+
selection,
|
|
28
|
+
setSelection,
|
|
29
|
+
|
|
30
|
+
// withAlert
|
|
31
|
+
confirm,
|
|
32
|
+
} = props,
|
|
33
|
+
[currentRecord, setCurrentRecord] = useState(null),
|
|
34
|
+
[isEditorShown, setIsEditorShown] = useState(false),
|
|
35
|
+
[isEditorViewOnly, setIsEditorViewOnly] = useState(false),
|
|
36
|
+
addRecord = async () => {
|
|
37
|
+
if (!userCanEdit) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const
|
|
41
|
+
defaultValues = Repository.getSchema().model.defaultValues,
|
|
42
|
+
entity = await Repository.add(defaultValues, false, true, true);
|
|
43
|
+
setSelection([entity]);
|
|
44
|
+
setIsEditorViewOnly(false);
|
|
45
|
+
setIsEditorShown(true);
|
|
46
|
+
},
|
|
47
|
+
editRecord = () => {
|
|
48
|
+
if (!userCanEdit) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setIsEditorViewOnly(false);
|
|
52
|
+
setIsEditorShown(true);
|
|
53
|
+
},
|
|
54
|
+
deleteRecord = (e) => {
|
|
55
|
+
if (!userCanEdit) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const
|
|
59
|
+
isSingle = selection.length === 1,
|
|
60
|
+
isPhantom = selection[0] && selection[0].isPhantom;
|
|
61
|
+
|
|
62
|
+
if (isSingle && isPhantom) {
|
|
63
|
+
onDelete();
|
|
64
|
+
} else {
|
|
65
|
+
const identifier = getRecordIdentifier(selection);
|
|
66
|
+
confirm('Are you sure you want to delete the ' + identifier, onDelete);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
onDelete = () => {
|
|
70
|
+
Repository.delete(selection);
|
|
71
|
+
if (!Repository.isAutoSave) {
|
|
72
|
+
Repository.save();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
viewRecord = () => {
|
|
76
|
+
if (!userCanView) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (selection.length !== 1) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setIsEditorViewOnly(true);
|
|
83
|
+
setIsEditorShown(true);
|
|
84
|
+
},
|
|
85
|
+
duplicateRecord = async () => {
|
|
86
|
+
if (!userCanEdit) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (selection.length !== 1) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const
|
|
93
|
+
entity = selection[0],
|
|
94
|
+
idProperty = Repository.getSchema().model.idProperty,
|
|
95
|
+
rawValues = _.omit(entity.rawValues, idProperty),
|
|
96
|
+
duplicate = await Repository.add(rawValues, false, true);
|
|
97
|
+
setSelection([duplicate]);
|
|
98
|
+
setIsEditorShown(true);
|
|
99
|
+
},
|
|
100
|
+
onEditorSave = (data, e) => {
|
|
101
|
+
const
|
|
102
|
+
what = record || selection,
|
|
103
|
+
isSingle = what.length === 1;
|
|
104
|
+
if (isSingle) {
|
|
105
|
+
// just update this one entity
|
|
106
|
+
what[0].setValues(data);
|
|
107
|
+
|
|
108
|
+
} else if (selection.length > 1) {
|
|
109
|
+
// Edit multiple entities
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
debugger;
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
if (!Repository.isAutoSave) {
|
|
118
|
+
Repository.save();
|
|
119
|
+
}
|
|
120
|
+
setIsEditorShown(false);
|
|
121
|
+
},
|
|
122
|
+
onEditorCancel = () => {
|
|
123
|
+
const
|
|
124
|
+
isSingle = selection.length === 1,
|
|
125
|
+
isPhantom = selection[0] && selection[0].isPhantom;
|
|
126
|
+
if (isSingle && isPhantom) {
|
|
127
|
+
onDelete();
|
|
128
|
+
}
|
|
129
|
+
setIsEditorShown(false);
|
|
130
|
+
},
|
|
131
|
+
onEditorClose = () => {
|
|
132
|
+
setIsEditorShown(false);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return <WrappedComponent
|
|
136
|
+
{...props}
|
|
137
|
+
currentRecord={currentRecord}
|
|
138
|
+
setCurrentRecord={setCurrentRecord}
|
|
139
|
+
isEditorShown={isEditorShown}
|
|
140
|
+
isEditorViewOnly={isEditorViewOnly}
|
|
141
|
+
setIsEditorShown={setIsEditorShown}
|
|
142
|
+
onAdd={addRecord}
|
|
143
|
+
onEdit={editRecord}
|
|
144
|
+
onDelete={deleteRecord}
|
|
145
|
+
onView={viewRecord}
|
|
146
|
+
onDuplicate={duplicateRecord}
|
|
147
|
+
onEditorSave={onEditorSave}
|
|
148
|
+
onEditorCancel={onEditorCancel}
|
|
149
|
+
onEditorClose={onEditorClose}
|
|
150
|
+
useEditor={useEditor}
|
|
151
|
+
userCanEdit={userCanEdit}
|
|
152
|
+
userCanView={userCanView}
|
|
153
|
+
disableAdd={disableAdd}
|
|
154
|
+
disableEdit={disableEdit}
|
|
155
|
+
disableDelete={disableDelete}
|
|
156
|
+
disableDuplicate={disableDuplicate}
|
|
157
|
+
disableView ={disableView}
|
|
158
|
+
/>;
|
|
159
|
+
};
|
|
160
|
+
}
|