@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,468 @@
|
|
|
1
|
+
import { useState, useEffect, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Column as Col,
|
|
4
|
+
Text,
|
|
5
|
+
} from 'native-base';
|
|
6
|
+
import {
|
|
7
|
+
ReactGrid,
|
|
8
|
+
} from '@silevis/reactgrid';
|
|
9
|
+
// import {
|
|
10
|
+
// // Undocumented API
|
|
11
|
+
// getCalculatedScrollLeftValueToLeft,
|
|
12
|
+
// getCalculatedScrollLeftValueToRight,
|
|
13
|
+
// getDerivedStateFromProps,
|
|
14
|
+
// getLocationFromClient,
|
|
15
|
+
// getReactGridOffsets,
|
|
16
|
+
// getScrollLeft,
|
|
17
|
+
// getSizeOfElement,
|
|
18
|
+
// getVisibleColumns,
|
|
19
|
+
// getVisibleScrollAreaWidth,
|
|
20
|
+
// getVisibleSizeOfReactGrid,
|
|
21
|
+
// recalcVisibleRange,
|
|
22
|
+
// setStyles,
|
|
23
|
+
// VS_PAGE_WIDTH,
|
|
24
|
+
// stateDeriver,
|
|
25
|
+
// updateStateProps,
|
|
26
|
+
// } from '@silevis/reactgrid';
|
|
27
|
+
import '@silevis/reactgrid/Styles.css'; // https://www.npmjs.com/package/@silevis/reactgrid
|
|
28
|
+
import './reactgrid.css';
|
|
29
|
+
// import * as Silevis from '@silevis/reactgrid';
|
|
30
|
+
// debugger;
|
|
31
|
+
// import { useReactGridState } from '@silevis/reactgrid/src/lib/Components/StateProvider';
|
|
32
|
+
import oneHatData from '@onehat/data';
|
|
33
|
+
import testProps from '../../Functions/testProps';
|
|
34
|
+
import inArray from '../../Functions/inArray';
|
|
35
|
+
import useForceUpdate from '../../Hooks/useForceUpdate';
|
|
36
|
+
import Loading from '../Messages/Loading';
|
|
37
|
+
import Toolbar from '../Toolbar/Toolbar';
|
|
38
|
+
import PaginationToolbar from '../Toolbar/PaginationToolbar';
|
|
39
|
+
import NoRecordsFound from './NoRecordsFound';
|
|
40
|
+
import AngleRight from '../Icons/AngleRight';
|
|
41
|
+
import _ from 'lodash';
|
|
42
|
+
|
|
43
|
+
// This grid makes @silevis/reactgrid a UI for @onehat/data
|
|
44
|
+
// If you want a simple grid for static data, just use <ReactGrid /> directly.
|
|
45
|
+
|
|
46
|
+
// helper fn from https://reactgrid.com/docs/4.0/2-implementing-core-features/3-column-and-row-reordering/
|
|
47
|
+
const reorderArray = (arr, idxs, to) => {
|
|
48
|
+
const
|
|
49
|
+
movedElements = arr.filter((_, idx) => idxs.includes(idx)),
|
|
50
|
+
targetIdx = Math.min(...idxs) < to ? to += 1 : to -= idxs.filter(idx => idx < to).length,
|
|
51
|
+
leftSide = arr.filter((_, idx) => idx < targetIdx && !idxs.includes(idx)),
|
|
52
|
+
rightSide = arr.filter((_, idx) => idx >= targetIdx && !idxs.includes(idx));
|
|
53
|
+
return [...leftSide, ...movedElements, ...rightSide];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default function Grid(props) {
|
|
57
|
+
const
|
|
58
|
+
{
|
|
59
|
+
// #### General grid configuration ####
|
|
60
|
+
model, // @onehat/data model name
|
|
61
|
+
topToolbar,
|
|
62
|
+
bottomToolbar = 'pagination',
|
|
63
|
+
columnsConfig = [], // json configurations for each column in format:
|
|
64
|
+
// [{
|
|
65
|
+
// text, // header
|
|
66
|
+
// field, // field name from @onehat/data model
|
|
67
|
+
// type, // specify which column type to use (custom or built-in)
|
|
68
|
+
// editable = false,
|
|
69
|
+
// editor,
|
|
70
|
+
// format,
|
|
71
|
+
// renderer, // React component will render the output
|
|
72
|
+
// resizable = true,
|
|
73
|
+
// sortable = true,
|
|
74
|
+
// width = 150, // default of ReactGrid
|
|
75
|
+
// }]
|
|
76
|
+
showHeaders = true,
|
|
77
|
+
showRowExpander = false,
|
|
78
|
+
enableEditors = false,
|
|
79
|
+
cellEditing = false,
|
|
80
|
+
rowEditing = false,
|
|
81
|
+
contextMenuOptions = [], // json configurations for each menu option in format:
|
|
82
|
+
// [{
|
|
83
|
+
// id;
|
|
84
|
+
// label;
|
|
85
|
+
// handler: (selectedRowIds, selectedColIds, selectionMode, selectedRanges) => {},
|
|
86
|
+
// }]
|
|
87
|
+
// columnProps = {},
|
|
88
|
+
// getRowProps = () => {
|
|
89
|
+
// return {
|
|
90
|
+
// bg: '#fff',
|
|
91
|
+
// p: 2,
|
|
92
|
+
// };
|
|
93
|
+
// },
|
|
94
|
+
gridProps = {},
|
|
95
|
+
pullToRefresh = true,
|
|
96
|
+
hideNavColumn = true,
|
|
97
|
+
disableReloadOnChangeFilters = false,
|
|
98
|
+
noneFoundText,
|
|
99
|
+
|
|
100
|
+
// #### ReactGrid overrides ####
|
|
101
|
+
// properties
|
|
102
|
+
customCellTemplates,
|
|
103
|
+
focusLocation,
|
|
104
|
+
initialFocusLocation,
|
|
105
|
+
highlights,
|
|
106
|
+
stickyTopRows = 0,
|
|
107
|
+
stickyBottomRows = 0,
|
|
108
|
+
stickyLeftColumns = 0,
|
|
109
|
+
stickyRightColumns = 0,
|
|
110
|
+
enableFillHandle,
|
|
111
|
+
enableRangeSelection = true,
|
|
112
|
+
enableRowSelection = false,
|
|
113
|
+
enableColumnSelection = false,
|
|
114
|
+
labels,
|
|
115
|
+
enableFullWidthHeader = false,
|
|
116
|
+
enableGroupIdRender = false,
|
|
117
|
+
horizontalStickyBreakpoint,
|
|
118
|
+
verticalStickyBreakpoint,
|
|
119
|
+
disableVirtualScrolling = false,
|
|
120
|
+
|
|
121
|
+
// ReactGrid events
|
|
122
|
+
onCellsChanged,
|
|
123
|
+
onFocusLocationChanged,
|
|
124
|
+
onFocusLocationChanging,
|
|
125
|
+
// onColumnResized,
|
|
126
|
+
// onRowsReordered,
|
|
127
|
+
// onColumnsReordered,
|
|
128
|
+
onContextMenu,
|
|
129
|
+
// canReorderColumns,
|
|
130
|
+
// canReorderRows,
|
|
131
|
+
} = props,
|
|
132
|
+
Repository = model && oneHatData.getRepository(model),
|
|
133
|
+
forceUpdate = useForceUpdate(),
|
|
134
|
+
[isReady, setIsReady] = useState(false),
|
|
135
|
+
[isLoading, setIsLoading] = useState(false),
|
|
136
|
+
onRefresh = () => Repository.load(),
|
|
137
|
+
onColumnsReordered = (targetColumnId, columnIds) => {
|
|
138
|
+
const
|
|
139
|
+
to = columns.findIndex((column) => column.columnId === targetColumnId),
|
|
140
|
+
columnIdxs = columnIds.map((columnId) => columns.findIndex((c) => c.columnId === columnId)),
|
|
141
|
+
reorderedColumns = reorderArray(columns, columnIdxs, to);
|
|
142
|
+
setColumns(reorderedColumns);
|
|
143
|
+
},
|
|
144
|
+
onRowsReordered = () => {},
|
|
145
|
+
onColumnResized = (targetColumnId, newWidth, arr) => {
|
|
146
|
+
const column = _.find(columns, (column) => column.columnId === targetColumnId);
|
|
147
|
+
column.width = newWidth;
|
|
148
|
+
forceUpdate();
|
|
149
|
+
},
|
|
150
|
+
canReorderColumns = (targetColumnId, columnIds, beforeAfter) => {
|
|
151
|
+
// Verify that *all* columns in selection can be reordered
|
|
152
|
+
let canReorder = true;
|
|
153
|
+
_.each(columns, (column) => {
|
|
154
|
+
if (inArray(column.columnId, columnIds) && !column.reorderable) {
|
|
155
|
+
canReorder = false;
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Verify that targetColumn can be reordered
|
|
161
|
+
const targetColumn = _.find(columns, (column) => column.columnId === targetColumnId);
|
|
162
|
+
if (!targetColumn.reorderable) {
|
|
163
|
+
canReorder = false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return canReorder;
|
|
167
|
+
},
|
|
168
|
+
canReorderRows = (targetRowId, rowIds) => {
|
|
169
|
+
return targetRowId !== 'header'; // Prevent reordering rows to be above header
|
|
170
|
+
},
|
|
171
|
+
getCellType = (field) => {
|
|
172
|
+
const
|
|
173
|
+
schema = Repository.schema,
|
|
174
|
+
propertyDefinition = schema.getPropertyDefinition(field);
|
|
175
|
+
switch(propertyDefinition.type) {
|
|
176
|
+
case 'base64':
|
|
177
|
+
propsToPass[type] = 'text';
|
|
178
|
+
break;
|
|
179
|
+
case 'boolean':
|
|
180
|
+
break;
|
|
181
|
+
case 'currency':
|
|
182
|
+
break;
|
|
183
|
+
case 'date':
|
|
184
|
+
propsToPass[type] = 'date';
|
|
185
|
+
break;
|
|
186
|
+
case 'dateTime':
|
|
187
|
+
break;
|
|
188
|
+
case 'file':
|
|
189
|
+
propsToPass[type] = 'text';
|
|
190
|
+
break;
|
|
191
|
+
case 'float':
|
|
192
|
+
break;
|
|
193
|
+
case 'integer':
|
|
194
|
+
break;
|
|
195
|
+
case 'json':
|
|
196
|
+
propsToPass[type] = 'text';
|
|
197
|
+
break;
|
|
198
|
+
case 'oercent':
|
|
199
|
+
break;
|
|
200
|
+
case 'oercentInt':
|
|
201
|
+
break;
|
|
202
|
+
case 'string':
|
|
203
|
+
propsToPass[type] = 'text';
|
|
204
|
+
break;
|
|
205
|
+
case 'time':
|
|
206
|
+
break;
|
|
207
|
+
case 'uuid':
|
|
208
|
+
propsToPass[type] = 'text';
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
propsToPass[type] = 'text';
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
getColumns = () => {
|
|
215
|
+
const columns = _.map(columnsConfig, (columnConfig) => {
|
|
216
|
+
const {
|
|
217
|
+
field,
|
|
218
|
+
resizable = true,
|
|
219
|
+
sortable = true,
|
|
220
|
+
width = 150, // default of ReactGrid
|
|
221
|
+
} = columnConfig;
|
|
222
|
+
return {
|
|
223
|
+
columnId: field,
|
|
224
|
+
reorderable: sortable,
|
|
225
|
+
resizable,
|
|
226
|
+
width,
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
if (!hideNavColumn) {
|
|
230
|
+
columns.push({
|
|
231
|
+
columnId: 'nav',
|
|
232
|
+
reorderable: false,
|
|
233
|
+
resizable: false,
|
|
234
|
+
width: 10,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Try to simulate 'flex' width for a single column
|
|
239
|
+
// const flexColumnConfig = _.find(columnsConfig, (columnConfig) => !!columnConfig.flex);
|
|
240
|
+
// if (flexColumnConfig) {
|
|
241
|
+
// const flexColumn = _.find(columns, (column) => column.columnId === flexColumnConfig.field);
|
|
242
|
+
// const r = ref;
|
|
243
|
+
// debugger;
|
|
244
|
+
// }
|
|
245
|
+
return columns;
|
|
246
|
+
},
|
|
247
|
+
getRows = () => {
|
|
248
|
+
const
|
|
249
|
+
entities = Repository.getEntitiesOnPage(),
|
|
250
|
+
rows = [];
|
|
251
|
+
|
|
252
|
+
if (showHeaders) {
|
|
253
|
+
// Build header row
|
|
254
|
+
const headerCells = [];
|
|
255
|
+
_.each(columns, (column) => {
|
|
256
|
+
// These columns may have been reordered, so match them with columnConfig setting, but user ordering of columns
|
|
257
|
+
const columnConfig = _.find(columnsConfig, (columnConfig) => {
|
|
258
|
+
return columnConfig.field === column.columnId;
|
|
259
|
+
});
|
|
260
|
+
if (!columnConfig) { // e.g rightColumn (nav) cell
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
headerCells.push({
|
|
264
|
+
type: 'header',
|
|
265
|
+
text: columnConfig.text,
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
if (!hideNavColumn) {
|
|
269
|
+
headerCells.push({
|
|
270
|
+
type: 'header',
|
|
271
|
+
text: '',
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
rows.push({ rowId: 'header', cells: headerCells, });
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
_.each(entities, (entity, ix) => {
|
|
278
|
+
// Build the cells for this row, based on previously defined columns
|
|
279
|
+
const cells = [];
|
|
280
|
+
_.each(columns, (column) => {
|
|
281
|
+
// These columns may have been reordered, so match them with columnConfig setting, but user ordering of columns
|
|
282
|
+
const columnConfig = _.find(columnsConfig, (columnConfig) => {
|
|
283
|
+
return columnConfig.field === column.columnId;
|
|
284
|
+
});
|
|
285
|
+
if (!columnConfig) { // e.g rightColumn (nav) cell
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const {
|
|
289
|
+
type = 'text', // specify which Column type to use for this cell (custom or built-in)
|
|
290
|
+
field,
|
|
291
|
+
placeholder,
|
|
292
|
+
validator,
|
|
293
|
+
renderer,
|
|
294
|
+
checkedText,
|
|
295
|
+
uncheckedText,
|
|
296
|
+
format,
|
|
297
|
+
} = columnConfig,
|
|
298
|
+
property = entity.properties[field],
|
|
299
|
+
propsToPass = {
|
|
300
|
+
type,
|
|
301
|
+
},
|
|
302
|
+
propsToCheck = {
|
|
303
|
+
placeholder,
|
|
304
|
+
validator,
|
|
305
|
+
renderer,
|
|
306
|
+
checkedText,
|
|
307
|
+
uncheckedText,
|
|
308
|
+
// date,
|
|
309
|
+
format,
|
|
310
|
+
// text,
|
|
311
|
+
};
|
|
312
|
+
_.each(propsToCheck, (prop, name) => {
|
|
313
|
+
if (!_.isEmpty(prop)) {
|
|
314
|
+
propsToPass[name] = prop;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
// Determine value for this cell
|
|
319
|
+
switch(type) {
|
|
320
|
+
case 'text':
|
|
321
|
+
propsToPass.text = property.displayValue;
|
|
322
|
+
break;
|
|
323
|
+
default:
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
cells.push(propsToPass);
|
|
327
|
+
}); // end each(columns)
|
|
328
|
+
|
|
329
|
+
if (!hideNavColumn) {
|
|
330
|
+
cells.push({
|
|
331
|
+
type: 'text',
|
|
332
|
+
text: '',
|
|
333
|
+
renderer: () => <AngleRight
|
|
334
|
+
color="#aaa"
|
|
335
|
+
variant="ghost"
|
|
336
|
+
alignSelf="center"
|
|
337
|
+
ml={1}
|
|
338
|
+
/>,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
rows.push({
|
|
343
|
+
rowId: entity.id,
|
|
344
|
+
cells,
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
return rows;
|
|
348
|
+
},
|
|
349
|
+
[columns, setColumns] = useState(getColumns());
|
|
350
|
+
|
|
351
|
+
useEffect(() => {
|
|
352
|
+
const
|
|
353
|
+
setTrue = () => setIsLoading(true),
|
|
354
|
+
setFalse = () => setIsLoading(false),
|
|
355
|
+
onChangeFilters = () => {
|
|
356
|
+
if (!Repository.isAutoLoad && Repository.isLoaded && !disableReloadOnChangeFilters) {
|
|
357
|
+
Repository.reload();
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
Repository.on('beforeLoad', setTrue);
|
|
362
|
+
Repository.on('load', setFalse);
|
|
363
|
+
Repository.ons(['changePage', 'changePageSize', 'changeData', 'change'], forceUpdate);
|
|
364
|
+
Repository.on('changeFilters', onChangeFilters);
|
|
365
|
+
|
|
366
|
+
setIsReady(true);
|
|
367
|
+
|
|
368
|
+
return () => {
|
|
369
|
+
Repository.off('beforeLoad', setTrue);
|
|
370
|
+
Repository.off('load', setFalse);
|
|
371
|
+
Repository.offs(['changePage', 'changePageSize', 'changeData', 'change'], forceUpdate);
|
|
372
|
+
Repository.off('changeFilters', onChangeFilters);
|
|
373
|
+
};
|
|
374
|
+
}, [Repository, disableReloadOnChangeFilters, forceUpdate]);
|
|
375
|
+
|
|
376
|
+
if (!Repository) {
|
|
377
|
+
throw Error('No Repository!');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (!isReady) {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const
|
|
385
|
+
propsToPass = {
|
|
386
|
+
enableRangeSelection,
|
|
387
|
+
enableRowSelection,
|
|
388
|
+
enableColumnSelection,
|
|
389
|
+
enableFullWidthHeader,
|
|
390
|
+
enableGroupIdRender,
|
|
391
|
+
stickyTopRows,
|
|
392
|
+
stickyBottomRows,
|
|
393
|
+
stickyLeftColumns,
|
|
394
|
+
stickyRightColumns,
|
|
395
|
+
disableVirtualScrolling,
|
|
396
|
+
},
|
|
397
|
+
propsToCheck = {
|
|
398
|
+
customCellTemplates,
|
|
399
|
+
focusLocation,
|
|
400
|
+
initialFocusLocation,
|
|
401
|
+
highlights,
|
|
402
|
+
enableFillHandle,
|
|
403
|
+
labels,
|
|
404
|
+
horizontalStickyBreakpoint,
|
|
405
|
+
verticalStickyBreakpoint,
|
|
406
|
+
|
|
407
|
+
onCellsChanged,
|
|
408
|
+
onFocusLocationChanged,
|
|
409
|
+
onFocusLocationChanging,
|
|
410
|
+
// onColumnResized,
|
|
411
|
+
// onRowsReordered,
|
|
412
|
+
// onColumnsReordered,
|
|
413
|
+
onContextMenu,
|
|
414
|
+
// canReorderColumns,
|
|
415
|
+
// canReorderRows,
|
|
416
|
+
};
|
|
417
|
+
_.each(propsToCheck, (prop, name) => {
|
|
418
|
+
if (!_.isEmpty(prop)) {
|
|
419
|
+
propsToPass[name] = prop;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
propsToPass.onColumnsReordered = onColumnsReordered;
|
|
424
|
+
propsToPass.onColumnResized = onColumnResized;
|
|
425
|
+
propsToPass.canReorderColumns = canReorderColumns;
|
|
426
|
+
propsToPass.canReorderRows = canReorderRows;
|
|
427
|
+
propsToPass.columns = columns;
|
|
428
|
+
propsToPass.rows = getRows();
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
propsToPass.onContextMenu = (selectedRowIds, selectedColIds, selectionMode, menuOptions) => {
|
|
432
|
+
debugger;
|
|
433
|
+
};
|
|
434
|
+
propsToPass.onCellsChanged = (a,b,c,d,e) => {
|
|
435
|
+
debugger;
|
|
436
|
+
};
|
|
437
|
+
propsToPass.onFocusLocationChanged = (pos) => {
|
|
438
|
+
debugger;
|
|
439
|
+
};
|
|
440
|
+
propsToPass.onFocusLocationChanging = (pos) => {
|
|
441
|
+
return true;
|
|
442
|
+
};
|
|
443
|
+
// special props
|
|
444
|
+
// data,
|
|
445
|
+
// treeData,
|
|
446
|
+
|
|
447
|
+
return <Col
|
|
448
|
+
{...testProps('GridPanelContainer')}
|
|
449
|
+
flex={1}
|
|
450
|
+
w="100%"
|
|
451
|
+
>
|
|
452
|
+
{topToolbar && <Toolbar>{topToolbar}</Toolbar>}
|
|
453
|
+
|
|
454
|
+
{isLoading && <Col flex={1}><Loading /></Col>}
|
|
455
|
+
|
|
456
|
+
{!isLoading && (!Repository.getEntitiesOnPage().length ? <NoRecordsFound text={noneFoundText} onRefresh={onRefresh} /> :
|
|
457
|
+
|
|
458
|
+
<ReactGrid
|
|
459
|
+
{...propsToPass}
|
|
460
|
+
{...gridProps}
|
|
461
|
+
/>)}
|
|
462
|
+
|
|
463
|
+
{bottomToolbar && (bottomToolbar === 'pagination' ?
|
|
464
|
+
<PaginationToolbar Repository={Repository} />:
|
|
465
|
+
<Toolbar>{bottomToolbar}</Toolbar>)}
|
|
466
|
+
</Col>;
|
|
467
|
+
|
|
468
|
+
}
|