@onehat/ui 0.3.381 → 0.4.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/package.json +37 -9
- package/src/Components/Accordion/Accordion.js +22 -17
- package/src/Components/Blank.js +1 -3
- package/src/Components/Buttons/BackButton.js +21 -12
- package/src/Components/Buttons/Button.js +65 -13
- package/src/Components/Buttons/CartButtonWithBadge.js +14 -6
- package/src/Components/Buttons/IconButton.js +31 -74
- package/src/Components/Buttons/PlusMinusButton.js +34 -21
- package/src/Components/Buttons/ReloadButton.js +7 -8
- package/src/Components/Buttons/SquareButton.js +41 -55
- package/src/Components/Container/Container.js +55 -16
- package/src/Components/Container/ScreenContainer.js +26 -16
- package/src/Components/Container/Splitter.js +38 -25
- package/src/Components/Editor/Editor.js +3 -2
- package/src/Components/Editor/InlineEditor.js +38 -32
- package/src/Components/Filter/DateRange.js +37 -18
- package/src/Components/Filter/NumberRange.js +87 -83
- package/src/Components/Form/Field/CKEditor/CKEditor.js +4 -4
- package/src/Components/Form/Field/Checkbox/CheckboxGroup.js +9 -6
- package/src/Components/Form/Field/Color.js +95 -86
- package/src/Components/Form/Field/Combo/Combo.js +347 -284
- package/src/Components/Form/Field/Combo/PageSizeCombo.js +4 -7
- package/src/Components/Form/Field/Date.js +276 -312
- package/src/Components/Form/Field/DisplayField.js +11 -5
- package/src/Components/Form/Field/File.js +26 -32
- package/src/Components/Form/Field/FormikForm.js +1018 -0
- package/src/Components/Form/Field/Input.js +91 -41
- package/src/Components/Form/Field/Json.js +25 -21
- package/src/Components/Form/Field/Number.js +70 -51
- package/src/Components/Form/Field/RadioGroup/RadioGroup.js +4 -6
- package/src/Components/Form/Field/Select/PageSizeSelect.js +33 -0
- package/src/Components/Form/Field/Select/Select.js +109 -0
- package/src/Components/Form/Field/Slider.js +38 -30
- package/src/Components/Form/Field/Tag/Tag.js +88 -72
- package/src/Components/Form/Field/Tag/ValueBox.js +25 -20
- package/src/Components/Form/Field/Text.js +21 -12
- package/src/Components/Form/Field/TextArea.js +32 -15
- package/src/Components/Form/Field/Toggle.js +41 -23
- package/src/Components/Form/FieldSet.js +77 -54
- package/src/Components/Form/Form.js +491 -268
- package/src/Components/Form/Label.js +28 -17
- package/src/Components/Gluestack/accordion/index.tsx +394 -0
- package/src/Components/Gluestack/actionsheet/index.tsx +619 -0
- package/src/Components/Gluestack/alert/index.tsx +310 -0
- package/src/Components/Gluestack/alert-dialog/index.tsx +295 -0
- package/src/Components/Gluestack/avatar/index.tsx +190 -0
- package/src/Components/Gluestack/badge/index.tsx +272 -0
- package/src/Components/Gluestack/bottomsheet/index.tsx +294 -0
- package/src/Components/Gluestack/box/index.tsx +19 -0
- package/src/Components/Gluestack/box/index.web.tsx +18 -0
- package/src/Components/Gluestack/box/styles.tsx +10 -0
- package/src/Components/Gluestack/button/index.tsx +494 -0
- package/src/Components/Gluestack/card/index.tsx +23 -0
- package/src/Components/Gluestack/card/index.web.tsx +22 -0
- package/src/Components/Gluestack/card/styles.tsx +20 -0
- package/src/Components/Gluestack/center/index.tsx +22 -0
- package/src/Components/Gluestack/center/index.web.tsx +19 -0
- package/src/Components/Gluestack/center/styles.tsx +8 -0
- package/src/Components/Gluestack/checkbox/index.tsx +305 -0
- package/src/Components/Gluestack/divider/index.tsx +44 -0
- package/src/Components/Gluestack/drawer/index.tsx +354 -0
- package/src/Components/Gluestack/fab/index.tsx +286 -0
- package/src/Components/Gluestack/flat-list/index.tsx +2 -0
- package/src/Components/Gluestack/form-control/index.tsx +527 -0
- package/src/Components/Gluestack/gluestack-ui-provider/config.ts +332 -0
- package/src/Components/Gluestack/gluestack-ui-provider/index.tsx +47 -0
- package/src/Components/Gluestack/gluestack-ui-provider/index.web.tsx +94 -0
- package/src/Components/Gluestack/gluestack-ui-provider/script.ts +19 -0
- package/src/Components/Gluestack/grid/index.tsx +341 -0
- package/src/Components/Gluestack/grid/index.web.tsx +65 -0
- package/src/Components/Gluestack/grid/styles.tsx +15 -0
- package/src/Components/Gluestack/heading/index.tsx +212 -0
- package/src/Components/Gluestack/heading/index.web.tsx +203 -0
- package/src/Components/Gluestack/heading/styles.tsx +43 -0
- package/src/Components/Gluestack/hstack/index.tsx +23 -0
- package/src/Components/Gluestack/hstack/index.web.tsx +22 -0
- package/src/Components/Gluestack/hstack/styles.tsx +25 -0
- package/src/Components/Gluestack/image/index.tsx +52 -0
- package/src/Components/Gluestack/image-background/index.tsx +21 -0
- package/src/Components/Gluestack/index.js +116 -0
- package/src/Components/Gluestack/input/index.tsx +287 -0
- package/src/Components/Gluestack/input-accessory-view/index.tsx +2 -0
- package/src/Components/Gluestack/keyboard-avoiding-view/index.tsx +2 -0
- package/src/Components/Gluestack/link/index.tsx +107 -0
- package/src/Components/Gluestack/menu/index.tsx +210 -0
- package/src/Components/Gluestack/modal/index.tsx +279 -0
- package/src/Components/Gluestack/popover/index.tsx +352 -0
- package/src/Components/Gluestack/portal/index.tsx +13 -0
- package/src/Components/Gluestack/pressable/index.tsx +46 -0
- package/src/Components/Gluestack/progress/index.tsx +164 -0
- package/src/Components/Gluestack/radio/index.tsx +304 -0
- package/src/Components/Gluestack/refresh-control/index.tsx +2 -0
- package/src/Components/Gluestack/safe-area-view/index.tsx +2 -0
- package/src/Components/Gluestack/scroll-view/index.tsx +2 -0
- package/src/Components/Gluestack/section-list/index.tsx +2 -0
- package/src/Components/Gluestack/select/index.tsx +335 -0
- package/src/Components/Gluestack/select/select-actionsheet.tsx +584 -0
- package/src/Components/Gluestack/skeleton/index.tsx +138 -0
- package/src/Components/Gluestack/skeleton/index.web.tsx +103 -0
- package/src/Components/Gluestack/skeleton/styles.tsx +35 -0
- package/src/Components/Gluestack/slider/index.tsx +283 -0
- package/src/Components/Gluestack/spinner/index.tsx +34 -0
- package/src/Components/Gluestack/status-bar/index.tsx +2 -0
- package/src/Components/Gluestack/switch/index.tsx +55 -0
- package/src/Components/Gluestack/table/index.tsx +200 -0
- package/src/Components/Gluestack/table/index.web.tsx +142 -0
- package/src/Components/Gluestack/table/styles.tsx +44 -0
- package/src/Components/Gluestack/text/index.tsx +48 -0
- package/src/Components/Gluestack/text/index.web.tsx +45 -0
- package/src/Components/Gluestack/text/styles.tsx +47 -0
- package/src/Components/Gluestack/textarea/index.tsx +108 -0
- package/src/Components/Gluestack/toast/index.tsx +225 -0
- package/src/Components/Gluestack/tooltip/index.tsx +125 -0
- package/src/Components/Gluestack/utils/use-break-point-value.ts +101 -0
- package/src/Components/Gluestack/view/index.tsx +2 -0
- package/src/Components/Gluestack/virtualized-list/index.tsx +2 -0
- package/src/Components/Gluestack/vstack/index.tsx +24 -0
- package/src/Components/Gluestack/vstack/index.web.tsx +23 -0
- package/src/Components/Gluestack/vstack/styles.tsx +25 -0
- package/src/Components/Grid/Grid.js +192 -135
- package/src/Components/Grid/GridHeaderRow.js +51 -59
- package/src/Components/Grid/GridRow.js +151 -57
- package/src/Components/Grid/HeaderColumnSelectorHandle.js +16 -10
- package/src/Components/Grid/HeaderReorderHandle.js +17 -13
- package/src/Components/Grid/HeaderResizeHandle.js +17 -13
- package/src/Components/Grid/NoRecordsFound.js +15 -18
- package/src/Components/Grid/RowDragHandle.js +9 -13
- package/src/Components/Hoc/Secondary/withSecondaryEditor.js +14 -9
- package/src/Components/Hoc/Secondary/withSecondaryWindowedEditor.js +14 -11
- package/src/Components/Hoc/withAlert.js +150 -200
- package/src/Components/Hoc/withBlank.js +4 -6
- package/src/Components/Hoc/withCollapsible.js +4 -3
- package/src/Components/Hoc/withComponent.js +33 -6
- package/src/Components/Hoc/withContextMenu.js +133 -141
- package/src/Components/Hoc/withData.js +5 -4
- package/src/Components/Hoc/withDnd.js +11 -9
- package/src/Components/Hoc/withDraggable.js +10 -10
- package/src/Components/Hoc/withEditor.js +18 -13
- package/src/Components/Hoc/withEvents.js +4 -6
- package/src/Components/Hoc/withFilters.js +524 -498
- package/src/Components/Hoc/withInlineEditor.js +7 -5
- package/src/Components/Hoc/withModal.js +79 -137
- package/src/Components/Hoc/withMultiSelection.js +4 -2
- package/src/Components/Hoc/withPdfButtons.js +109 -111
- package/src/Components/Hoc/withPresetButtons.js +49 -53
- package/src/Components/Hoc/withSelection.js +6 -5
- package/src/Components/Hoc/withSideEditor.js +12 -6
- package/src/Components/Hoc/withTooltip.js +18 -12
- package/src/Components/Hoc/withValue.js +6 -5
- package/src/Components/Hoc/withWindowedEditor.js +13 -11
- package/src/Components/Icons/AddressBook.js +7 -10
- package/src/Components/Icons/Alt.js +8 -15
- package/src/Components/Icons/AngleLeft.js +7 -14
- package/src/Components/Icons/AngleRight.js +7 -14
- package/src/Components/Icons/AnglesLeft.js +7 -14
- package/src/Components/Icons/AnglesRight.js +7 -14
- package/src/Components/Icons/Asterisk.js +7 -10
- package/src/Components/Icons/Ban.js +9 -14
- package/src/Components/Icons/Bars.js +7 -10
- package/src/Components/Icons/BarsStaggered.js +7 -10
- package/src/Components/Icons/Bell.js +7 -19
- package/src/Components/Icons/BigCircle.js +7 -14
- package/src/Components/Icons/Book.js +7 -10
- package/src/Components/Icons/BookOpen.js +7 -10
- package/src/Components/Icons/Bookmark.js +8 -17
- package/src/Components/Icons/Bug.js +7 -10
- package/src/Components/Icons/Building.js +7 -10
- package/src/Components/Icons/Calendar.js +7 -14
- package/src/Components/Icons/Calendar2.js +7 -14
- package/src/Components/Icons/CalendarDays.js +7 -14
- package/src/Components/Icons/Camera.js +7 -14
- package/src/Components/Icons/CaretDown.js +7 -14
- package/src/Components/Icons/CaretUp.js +7 -14
- package/src/Components/Icons/CartPlus.js +7 -10
- package/src/Components/Icons/CartShopping.js +7 -10
- package/src/Components/Icons/CashRegister.js +7 -10
- package/src/Components/Icons/Certificate.js +7 -10
- package/src/Components/Icons/ChartLine.js +7 -10
- package/src/Components/Icons/ChartPie.js +7 -10
- package/src/Components/Icons/Check.js +7 -10
- package/src/Components/Icons/CheckDouble.js +7 -10
- package/src/Components/Icons/ChevronDown.js +7 -10
- package/src/Components/Icons/ChevronLeft.js +7 -10
- package/src/Components/Icons/ChevronRight.js +7 -10
- package/src/Components/Icons/ChevronUp.js +7 -10
- package/src/Components/Icons/Circle.js +7 -10
- package/src/Components/Icons/CircleArrowRight.js +7 -10
- package/src/Components/Icons/CircleExclamation.js +7 -14
- package/src/Components/Icons/CircleInfo.js +7 -10
- package/src/Components/Icons/CircleQuestion.js +7 -10
- package/src/Components/Icons/CircleXmark.js +7 -10
- package/src/Components/Icons/CircleXmarkRegular.js +7 -10
- package/src/Components/Icons/Clipboard.js +7 -14
- package/src/Components/Icons/ClipboardCheck.js +7 -17
- package/src/Components/Icons/ClipboardList.js +7 -16
- package/src/Components/Icons/Clock.js +7 -10
- package/src/Components/Icons/ClockRegular.js +7 -10
- package/src/Components/Icons/ClockRotateLeft.js +7 -10
- package/src/Components/Icons/Clone.js +7 -10
- package/src/Components/Icons/Collapse.js +7 -14
- package/src/Components/Icons/Comment.js +7 -10
- package/src/Components/Icons/CommentDots.js +7 -10
- package/src/Components/Icons/CommentRegular.js +7 -10
- package/src/Components/Icons/Comments.js +7 -10
- package/src/Components/Icons/CommentsRegular.js +7 -10
- package/src/Components/Icons/Copyright.js +7 -10
- package/src/Components/Icons/Dot.js +10 -15
- package/src/Components/Icons/Download.js +11 -0
- package/src/Components/Icons/Duplicate.js +7 -14
- package/src/Components/Icons/Edit.js +7 -14
- package/src/Components/Icons/EllipsisHorizontal.js +7 -16
- package/src/Components/Icons/EllipsisVertical.js +7 -14
- package/src/Components/Icons/Envelope.js +7 -10
- package/src/Components/Icons/EnvelopeRegular.js +7 -10
- package/src/Components/Icons/Excel.js +7 -10
- package/src/Components/Icons/Exclamation.js +7 -10
- package/src/Components/Icons/Expand.js +7 -10
- package/src/Components/Icons/Eye.js +7 -14
- package/src/Components/Icons/EyeSlash.js +7 -10
- package/src/Components/Icons/File.js +7 -14
- package/src/Components/Icons/FloppyDiskRegular.js +7 -10
- package/src/Components/Icons/Folder.js +7 -10
- package/src/Components/Icons/FolderClosed.js +7 -10
- package/src/Components/Icons/FolderOpen.js +7 -10
- package/src/Components/Icons/FolderTree.js +7 -10
- package/src/Components/Icons/FullWidth.js +10 -25
- package/src/Components/Icons/Gauge.js +7 -17
- package/src/Components/Icons/Gear.js +7 -14
- package/src/Components/Icons/Gears.js +7 -10
- package/src/Components/Icons/Gift.js +7 -10
- package/src/Components/Icons/Grip.js +7 -14
- package/src/Components/Icons/GripLines.js +7 -14
- package/src/Components/Icons/GripLinesVertical.js +7 -14
- package/src/Components/Icons/GripVertical.js +7 -14
- package/src/Components/Icons/Hammer.js +7 -10
- package/src/Components/Icons/Hand.js +7 -10
- package/src/Components/Icons/HighPriority.js +7 -17
- package/src/Components/Icons/House.js +7 -10
- package/src/Components/Icons/Images.js +7 -10
- package/src/Components/Icons/Info.js +7 -10
- package/src/Components/Icons/ItunesNote.js +7 -10
- package/src/Components/Icons/Js.js +7 -16
- package/src/Components/Icons/Leaf.js +7 -10
- package/src/Components/Icons/Link.js +7 -9
- package/src/Components/Icons/List.js +7 -10
- package/src/Components/Icons/ListCheck.js +7 -10
- package/src/Components/Icons/LocationDot.js +7 -10
- package/src/Components/Icons/Loop.js +7 -14
- package/src/Components/Icons/Loop1.js +8 -13
- package/src/Components/Icons/LoopAll.js +8 -13
- package/src/Components/Icons/LowPriority.js +7 -17
- package/src/Components/Icons/MagnifyingGlass.js +7 -10
- package/src/Components/Icons/Maximize.js +7 -10
- package/src/Components/Icons/MedPriority.js +7 -17
- package/src/Components/Icons/Microphone.js +7 -10
- package/src/Components/Icons/Minimize.js +7 -10
- package/src/Components/Icons/Minus.js +7 -14
- package/src/Components/Icons/MobileScreenButton.js +7 -10
- package/src/Components/Icons/MoneyBill.js +7 -10
- package/src/Components/Icons/MoneyBillWave.js +7 -10
- package/src/Components/Icons/Mouth.js +10 -21
- package/src/Components/Icons/Music.js +7 -10
- package/src/Components/Icons/Na.js +7 -14
- package/src/Components/Icons/NoLoop.js +11 -13
- package/src/Components/Icons/NoReorderRows.js +17 -22
- package/src/Components/Icons/ObjectGroupRegular.js +7 -10
- package/src/Components/Icons/Pause.js +7 -10
- package/src/Components/Icons/Pdf.js +7 -10
- package/src/Components/Icons/Pencil.js +7 -14
- package/src/Components/Icons/Phone.js +7 -10
- package/src/Components/Icons/Play.js +7 -10
- package/src/Components/Icons/Plus.js +7 -14
- package/src/Components/Icons/Presentation.js +7 -16
- package/src/Components/Icons/Print.js +7 -14
- package/src/Components/Icons/Question.js +7 -10
- package/src/Components/Icons/Rate-.25x.js +12 -17
- package/src/Components/Icons/Rate-.5x.js +11 -16
- package/src/Components/Icons/Rate-.75x.js +8 -13
- package/src/Components/Icons/Rate-1.25x.js +8 -13
- package/src/Components/Icons/Rate-1.5x.js +8 -13
- package/src/Components/Icons/Rate-1.75x.js +8 -13
- package/src/Components/Icons/Rate-1x.js +11 -16
- package/src/Components/Icons/Rate-2x.js +8 -13
- package/src/Components/Icons/RateIcon-.25x.js +8 -13
- package/src/Components/Icons/RateIcon-.5x.js +11 -16
- package/src/Components/Icons/RateIcon-.75x.js +8 -13
- package/src/Components/Icons/RateIcon-1.25x.js +8 -13
- package/src/Components/Icons/RateIcon-1.5x.js +8 -13
- package/src/Components/Icons/RateIcon-1.75x.js +8 -13
- package/src/Components/Icons/RateIcon-1x.js +8 -13
- package/src/Components/Icons/RateIcon-2x.js +8 -13
- package/src/Components/Icons/RectangleXmark.js +7 -10
- package/src/Components/Icons/RectangleXmarkRegular.js +7 -10
- package/src/Components/Icons/ReorderRows.js +8 -13
- package/src/Components/Icons/RightFromBracket.js +7 -10
- package/src/Components/Icons/RightLeft.js +7 -10
- package/src/Components/Icons/RightToBracket.js +7 -10
- package/src/Components/Icons/Rotate.js +7 -14
- package/src/Components/Icons/RotateLeft.js +7 -10
- package/src/Components/Icons/RotateRight.js +7 -14
- package/src/Components/Icons/ScrewdriverWrench.js +7 -10
- package/src/Components/Icons/Scroll.js +7 -10
- package/src/Components/Icons/Share.js +7 -10
- package/src/Components/Icons/Shop.js +7 -10
- package/src/Components/Icons/SideBySide.js +7 -20
- package/src/Components/Icons/SortDown.js +7 -10
- package/src/Components/Icons/SortDownAlt.js +7 -10
- package/src/Components/Icons/SortUp.js +7 -10
- package/src/Components/Icons/SortUpAlt.js +7 -14
- package/src/Components/Icons/Square.js +7 -10
- package/src/Components/Icons/SquareCheck.js +7 -10
- package/src/Components/Icons/SquareCheckRegular.js +7 -10
- package/src/Components/Icons/SquareMinus.js +7 -14
- package/src/Components/Icons/SquareRegular.js +7 -10
- package/src/Components/Icons/Store.js +7 -10
- package/src/Components/Icons/Table.js +7 -16
- package/src/Components/Icons/ThumbsDown.js +7 -10
- package/src/Components/Icons/ThumbsDownRegular.js +7 -10
- package/src/Components/Icons/ThumbsUp.js +7 -10
- package/src/Components/Icons/ThumbsUpRegular.js +7 -10
- package/src/Components/Icons/Trash.js +7 -14
- package/src/Components/Icons/TrashCan.js +7 -14
- package/src/Components/Icons/TriangleExclamation.js +7 -14
- package/src/Components/Icons/Truck.js +7 -10
- package/src/Components/Icons/TruckFast.js +7 -10
- package/src/Components/Icons/Upload.js +11 -0
- package/src/Components/Icons/UploadDownload.js +11 -11
- package/src/Components/Icons/User.js +7 -10
- package/src/Components/Icons/UserGroup.js +7 -10
- package/src/Components/Icons/UserPlus.js +7 -10
- package/src/Components/Icons/UserSecret.js +7 -10
- package/src/Components/Icons/Video.js +7 -16
- package/src/Components/Icons/X.js +7 -10
- package/src/Components/Icons/Xmark.js +7 -10
- package/src/Components/Layout/CenterBox.js +13 -9
- package/src/Components/Layout/Footer.js +20 -13
- package/src/Components/Messages/ConfirmationMessage.js +30 -13
- package/src/Components/Messages/ErrorMessage.js +29 -23
- package/src/Components/Messages/Loading.js +10 -8
- package/src/Components/Messages/OkMessage.js +30 -13
- package/src/Components/Messages/Unauthorized.js +5 -8
- package/src/Components/Messages/WaitMessage.js +37 -73
- package/src/Components/Panel/AccordionGridPanel.js +6 -6
- package/src/Components/Panel/FormPanel.js +7 -3
- package/src/Components/Panel/Header.js +132 -94
- package/src/Components/Panel/Mask.js +4 -4
- package/src/Components/Panel/Panel.js +55 -72
- package/src/Components/Panel/TabPanel.js +1 -1
- package/src/Components/Picker/Picker.js +10 -9
- package/src/Components/Report/Report.js +17 -14
- package/src/Components/Screens/Manager.js +22 -22
- package/src/Components/Tab/TabBar.js +293 -225
- package/src/Components/Toolbar/FilterToolbar.js +15 -11
- package/src/Components/Toolbar/Pagination.js +51 -46
- package/src/Components/Toolbar/PaginationToolbar.js +25 -19
- package/src/Components/Toolbar/Toolbar.js +26 -13
- package/src/Components/Tooltip/Tooltip.js +35 -0
- package/src/Components/Tree/Tree.js +134 -140
- package/src/Components/Tree/TreeNode.js +75 -36
- package/src/Components/Viewer/Viewer.js +203 -80
- package/src/Components/Window/Editor.js +0 -5
- package/src/Components/Window/UploadsDownloadsWindow.js +40 -22
- package/src/Components/index.js +11 -8
- package/src/Constants/Alert.js +0 -0
- package/src/Constants/AppStates.js +0 -0
- package/src/Constants/Colors.js +13 -0
- package/src/Constants/Commands.js +0 -0
- package/src/Constants/Date.js +0 -0
- package/src/Constants/Dates.js +16 -0
- package/src/Constants/Directions.js +0 -0
- package/src/Constants/Editor.js +0 -0
- package/src/Constants/EditorModes.js +2 -0
- package/src/Constants/File.js +0 -0
- package/src/Constants/Filters.js +0 -0
- package/src/Constants/Grid.js +0 -0
- package/src/Constants/Input.js +1 -0
- package/src/Constants/MimeTypes.js +0 -0
- package/src/Constants/Selection.js +0 -0
- package/src/Constants/Styles.js +119 -108
- package/src/Constants/Tasks.js +3 -0
- package/src/Constants/Tree.js +0 -0
- package/src/Constants/UiModes.js +3 -2
- package/src/Functions/BankersRound.js +0 -0
- package/src/Functions/Cypress/button_functions.js +0 -0
- package/src/Functions/Cypress/crud_functions.js +0 -0
- package/src/Functions/Cypress/dom_functions.js +0 -0
- package/src/Functions/Cypress/grid_functions.js +0 -0
- package/src/Functions/Cypress/navigation_functions.js +0 -0
- package/src/Functions/Cypress/tree_functions.js +0 -0
- package/src/Functions/Cypress/utilities.js +0 -0
- package/src/Functions/PlatformDetector.js +0 -0
- package/src/Functions/Timer.js +0 -0
- package/src/Functions/buildAdditionalButtons.js +5 -5
- package/src/Functions/chunkArray.js +0 -0
- package/src/Functions/colorConversions.js +74 -0
- package/src/Functions/delay.js +0 -0
- package/src/Functions/delayUntil.js +0 -0
- package/src/Functions/deleteSaved.js +0 -0
- package/src/Functions/deleteSecure.js +0 -0
- package/src/Functions/downloadInBackground.js +0 -0
- package/src/Functions/downloadWithFetch.js +0 -0
- package/src/Functions/emptyFn.js +0 -0
- package/src/Functions/getComponentFromType.js +0 -0
- package/src/Functions/getIconButtonFromConfig.js +5 -9
- package/src/Functions/getIsMobile.js +0 -0
- package/src/Functions/getNodeIcon.js +28 -0
- package/src/Functions/getPref.js +0 -0
- package/src/Functions/getSaved.js +0 -0
- package/src/Functions/getSecure.js +0 -0
- package/src/Functions/getTokenHeaders.js +0 -0
- package/src/Functions/gsToHex.js +205 -0
- package/src/Functions/ignoreWanings.js +46 -0
- package/src/Functions/inArray.js +0 -0
- package/src/Functions/isJson.js +0 -0
- package/src/Functions/isSerializable.js +0 -0
- package/src/Functions/isVideo.js +0 -0
- package/src/Functions/jsonValidator.js +0 -0
- package/src/Functions/nbToRgb.js +1 -1
- package/src/Functions/objectToClassName.js +72 -0
- package/src/Functions/parseNotification.js +0 -0
- package/src/Functions/processImage.js +0 -0
- package/src/Functions/registerReactNativeComponents.js +0 -0
- package/src/Functions/registerWebComponents.js +0 -0
- package/src/Functions/setCustomInflector.js +0 -0
- package/src/Functions/setPref.js +0 -0
- package/src/Functions/setProgress.js +0 -0
- package/src/Functions/setSaved.js +0 -0
- package/src/Functions/setSecure.js +0 -0
- package/src/Functions/setThemeOverrides.js +0 -0
- package/src/Functions/setUiSavesRepo.js +0 -0
- package/src/Functions/sleep.js +0 -0
- package/src/Functions/tailwindFunctions.js +384 -0
- package/src/Functions/testProps.js +0 -0
- package/src/Functions/trackEngagementHit.js +0 -0
- package/src/Functions/verifyCompleted.js +0 -0
- package/src/Functions/waitFor.js +2 -2
- package/src/PlatformImports/Web/Attachments.js +32 -38
- package/src/PlatformImports/Web/File.js +38 -31
- package/src/UiGlobals.js +8 -1
- package/src/Components/Grid/ColumnSelectorWindow.js +0 -125
|
@@ -0,0 +1,1018 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef, isValidElement, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
HStack,
|
|
5
|
+
Icon,
|
|
6
|
+
ScrollView,
|
|
7
|
+
Text,
|
|
8
|
+
TextNative,
|
|
9
|
+
VStack,
|
|
10
|
+
VStackNative,
|
|
11
|
+
} from '../../Gluestack';
|
|
12
|
+
import { View, } from 'react-native';
|
|
13
|
+
import {
|
|
14
|
+
EDITOR_TYPE__INLINE,
|
|
15
|
+
EDITOR_TYPE__WINDOWED,
|
|
16
|
+
EDITOR_TYPE__SIDE,
|
|
17
|
+
EDITOR_TYPE__SMART,
|
|
18
|
+
EDITOR_TYPE__PLAIN,
|
|
19
|
+
EDITOR_MODE__VIEW,
|
|
20
|
+
EDITOR_MODE__ADD,
|
|
21
|
+
EDITOR_MODE__EDIT,
|
|
22
|
+
} from '../../../Constants/Editor.js';
|
|
23
|
+
import { Form, Formik, Field } from "formik"; // https://formik.org/docs/overview
|
|
24
|
+
import { useForm, Controller } from 'react-hook-form'; // https://react-hook-form.com/api/
|
|
25
|
+
import * as yup from 'yup'; // https://github.com/jquense/yup#string
|
|
26
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
27
|
+
import useForceUpdate from '../../../Hooks/useForceUpdate.js';
|
|
28
|
+
import UiGlobals from '../../../UiGlobals.js';
|
|
29
|
+
import withAlert from '../../../Hoc/withAlert.js';
|
|
30
|
+
import withComponent from '../../../Hoc/withComponent.js';
|
|
31
|
+
import withEditor from '../../../Hoc/withEditor.js';
|
|
32
|
+
import withPdfButton from '../../../Hoc/withPdfButton.js';
|
|
33
|
+
import inArray from '../../../Functions/inArray.js';
|
|
34
|
+
import getComponentFromType from '../../../Functions/getComponentFromType.js';
|
|
35
|
+
import buildAdditionalButtons from '../../../Functions/buildAdditionalButtons.js';
|
|
36
|
+
import Button from '../../../Buttons/Button.js';
|
|
37
|
+
import IconButton from '../../../Buttons/IconButton.js';
|
|
38
|
+
import AngleLeft from '../../../Icons/AngleLeft.js';
|
|
39
|
+
import Eye from '../../../Icons/Eye.js';
|
|
40
|
+
import Rotate from '../../../Icons/Rotate.js';
|
|
41
|
+
import Pencil from '../../../Icons/Pencil.js';
|
|
42
|
+
import Footer from '../../../Layout/Footer.js';
|
|
43
|
+
import Label from '../../../Form/Label.js';
|
|
44
|
+
import _ from 'lodash';
|
|
45
|
+
|
|
46
|
+
// TODO: memoize field Components
|
|
47
|
+
|
|
48
|
+
// Modes:
|
|
49
|
+
// EDITOR_TYPE__INLINE
|
|
50
|
+
// Form is a single scrollable row, based on columnsConfig and Repository
|
|
51
|
+
//
|
|
52
|
+
// EDITOR_TYPE__WINDOWED
|
|
53
|
+
// EDITOR_TYPE__SIDE
|
|
54
|
+
// Form is a popup or side window, used for editing items in a grid. Integrated with Repository
|
|
55
|
+
//
|
|
56
|
+
// EDITOR_TYPE__SMART
|
|
57
|
+
// Form is a standalone editor
|
|
58
|
+
//
|
|
59
|
+
// EDITOR_TYPE__PLAIN
|
|
60
|
+
// Form is embedded on screen in some other way. Mainly use startingValues, items, validator
|
|
61
|
+
|
|
62
|
+
function FormikForm(props) {
|
|
63
|
+
const
|
|
64
|
+
{
|
|
65
|
+
editorType = EDITOR_TYPE__WINDOWED, // EDITOR_TYPE__INLINE | EDITOR_TYPE__WINDOWED | EDITOR_TYPE__SIDE | EDITOR_TYPE__SMART | EDITOR_TYPE__PLAIN
|
|
66
|
+
startingValues = {},
|
|
67
|
+
items = [], // Columns, FieldSets, Fields, etc to define the form
|
|
68
|
+
ancillaryItems = [], // additional items which are not controllable form elements, but should appear in the form
|
|
69
|
+
columnDefaults = {}, // defaults for each Column defined in items (above)
|
|
70
|
+
columnsConfig, // Which columns are shown in Grid, so the inline editor can match. Used only for EDITOR_TYPE__INLINE
|
|
71
|
+
validator, // custom validator, mainly for EDITOR_TYPE__PLAIN
|
|
72
|
+
footerProps = {},
|
|
73
|
+
buttonGroupProps = {}, // buttons in footer
|
|
74
|
+
checkIsEditingDisabled = true,
|
|
75
|
+
disableLabels = false,
|
|
76
|
+
disableDirtyIcon = false,
|
|
77
|
+
onBack,
|
|
78
|
+
onReset,
|
|
79
|
+
onInit,
|
|
80
|
+
onViewMode,
|
|
81
|
+
submitBtnLabel,
|
|
82
|
+
onSubmit,
|
|
83
|
+
formSetup, // this fn will be executed after the form setup is complete
|
|
84
|
+
additionalEditButtons,
|
|
85
|
+
useAdditionalEditButtons = true,
|
|
86
|
+
additionalFooterButtons,
|
|
87
|
+
|
|
88
|
+
// sizing of outer container
|
|
89
|
+
h,
|
|
90
|
+
maxHeight,
|
|
91
|
+
minHeight = 0,
|
|
92
|
+
w,
|
|
93
|
+
maxWidth,
|
|
94
|
+
flex,
|
|
95
|
+
onLayout, // onLayout handler for main view
|
|
96
|
+
|
|
97
|
+
// withComponent
|
|
98
|
+
self,
|
|
99
|
+
|
|
100
|
+
// withData
|
|
101
|
+
Repository,
|
|
102
|
+
|
|
103
|
+
// withEditor
|
|
104
|
+
isEditorViewOnly = false,
|
|
105
|
+
isSaving = false,
|
|
106
|
+
editorMode,
|
|
107
|
+
onCancel,
|
|
108
|
+
onSave,
|
|
109
|
+
onClose,
|
|
110
|
+
onDelete,
|
|
111
|
+
editorStateRef,
|
|
112
|
+
disableView,
|
|
113
|
+
|
|
114
|
+
// parent container
|
|
115
|
+
selectorId,
|
|
116
|
+
selectorSelected,
|
|
117
|
+
|
|
118
|
+
// withAlert
|
|
119
|
+
alert,
|
|
120
|
+
} = props,
|
|
121
|
+
formRef = useRef(),
|
|
122
|
+
styles = UiGlobals.styles,
|
|
123
|
+
record = props.record?.length === 1 ? props.record[0] : props.record;
|
|
124
|
+
let skipAll = false;
|
|
125
|
+
if (record?.isDestroyed) {
|
|
126
|
+
skipAll = true; // if record is destroyed, skip render, but allow hooks to still be called
|
|
127
|
+
if (self?.parent?.parent?.setIsEditorShown) {
|
|
128
|
+
self.parent.parent.setIsEditorShown(false); // close the editor
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const
|
|
132
|
+
isMultiple = _.isArray(record),
|
|
133
|
+
isSingle = !isMultiple, // for convenience
|
|
134
|
+
isPhantom = !skipAll && !!record?.isPhantom, //
|
|
135
|
+
forceUpdate = useForceUpdate(),
|
|
136
|
+
[previousRecord, setPreviousRecord] = useState(record),
|
|
137
|
+
[containerWidth, setContainerWidth] = useState(),
|
|
138
|
+
initialValues = _.merge(startingValues, (record && !record.isDestroyed ? record.submitValues : {})),
|
|
139
|
+
defaultValues = isMultiple ? getNullFieldValues(initialValues, Repository) : initialValues, // when multiple entities, set all default values to null
|
|
140
|
+
validatorToUse = validator || (isMultiple ? disableRequiredYupFields(Repository?.schema?.model?.validator) : Repository?.schema?.model?.validator) || yup.object(),
|
|
141
|
+
{
|
|
142
|
+
control,
|
|
143
|
+
formState,
|
|
144
|
+
handleSubmit,
|
|
145
|
+
// register,
|
|
146
|
+
// unregister,
|
|
147
|
+
reset,
|
|
148
|
+
// watch,
|
|
149
|
+
// resetField,
|
|
150
|
+
// setError,
|
|
151
|
+
// clearErrors,
|
|
152
|
+
setValue: formSetValue,
|
|
153
|
+
// setFocus,
|
|
154
|
+
getValues: formGetValues,
|
|
155
|
+
// getFieldState,
|
|
156
|
+
trigger,
|
|
157
|
+
} = useForm({
|
|
158
|
+
mode: 'onChange', // onChange | onBlur | onSubmit | onTouched | all
|
|
159
|
+
// reValidateMode: 'onChange', // onChange | onBlur | onSubmit
|
|
160
|
+
defaultValues,
|
|
161
|
+
// values: defaultValues,
|
|
162
|
+
// resetOptions: {
|
|
163
|
+
// keepDirtyValues: false, // user-interacted input will be retained
|
|
164
|
+
// keepErrors: false, // input errors will be retained with value update
|
|
165
|
+
// },
|
|
166
|
+
// criteriaMode: 'firstError', // firstError | all
|
|
167
|
+
// shouldFocusError: false,
|
|
168
|
+
// delayError: 0,
|
|
169
|
+
// shouldUnregister: false,
|
|
170
|
+
// shouldUseNativeValidation: false,
|
|
171
|
+
resolver: yupResolver(validatorToUse),
|
|
172
|
+
context: { isPhantom },
|
|
173
|
+
}),
|
|
174
|
+
buildFromColumnsConfig = () => {
|
|
175
|
+
// For InlineEditor
|
|
176
|
+
// Build the fields that match the current columnsConfig in the grid
|
|
177
|
+
const
|
|
178
|
+
model = Repository.getSchema().model,
|
|
179
|
+
elements = [],
|
|
180
|
+
columnProps = {
|
|
181
|
+
justifyContent: 'center',
|
|
182
|
+
alignItems: 'center',
|
|
183
|
+
borderRightWidth: 1,
|
|
184
|
+
borderRightColor: 'grey-200',
|
|
185
|
+
px: 1,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
if (editorType === EDITOR_TYPE__INLINE) {
|
|
189
|
+
columnProps.minWidth = styles.INLINE_EDITOR_MIN_WIDTH;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
_.each(columnsConfig, (config, ix) => {
|
|
193
|
+
let {
|
|
194
|
+
fieldName,
|
|
195
|
+
isEditable,
|
|
196
|
+
editor,
|
|
197
|
+
renderer,
|
|
198
|
+
w,
|
|
199
|
+
flex,
|
|
200
|
+
useSelectorId = false,
|
|
201
|
+
} = config;
|
|
202
|
+
|
|
203
|
+
if (!isEditable) {
|
|
204
|
+
let renderedValue = renderer ? renderer(record) : record[fieldName];
|
|
205
|
+
if (_.isBoolean(renderedValue)) {
|
|
206
|
+
renderedValue = renderedValue.toString();
|
|
207
|
+
}
|
|
208
|
+
renderedValue += "\n(not editable)";
|
|
209
|
+
elements.push(<Box key={ix} {...columnProps} className={` flex-${flex} w-${w} `}>
|
|
210
|
+
<TextNative numberOfLines={1} ellipsizeMode="head">{renderedValue}</TextNative>
|
|
211
|
+
</Box>);
|
|
212
|
+
} else {
|
|
213
|
+
elements.push(<Controller
|
|
214
|
+
key={'controller-' + ix}
|
|
215
|
+
name={fieldName}
|
|
216
|
+
// rules={rules}
|
|
217
|
+
control={control}
|
|
218
|
+
render={(args) => {
|
|
219
|
+
const {
|
|
220
|
+
field,
|
|
221
|
+
fieldState,
|
|
222
|
+
// formState,
|
|
223
|
+
} = args,
|
|
224
|
+
{
|
|
225
|
+
onChange,
|
|
226
|
+
onBlur,
|
|
227
|
+
name,
|
|
228
|
+
value,
|
|
229
|
+
// ref,
|
|
230
|
+
} = field,
|
|
231
|
+
{
|
|
232
|
+
isTouched,
|
|
233
|
+
isDirty,
|
|
234
|
+
error,
|
|
235
|
+
} = fieldState;
|
|
236
|
+
let _editor = {};
|
|
237
|
+
if (!editor) {
|
|
238
|
+
const propertyDef = fieldName && Repository?.getSchema().getPropertyDefinition(fieldName);
|
|
239
|
+
editor = propertyDef && propertyDef[fieldName].editorType;
|
|
240
|
+
if (_.isPlainObject(editor)) {
|
|
241
|
+
const {
|
|
242
|
+
type,
|
|
243
|
+
onChange: onEditorChange,
|
|
244
|
+
...p
|
|
245
|
+
} = editor;
|
|
246
|
+
_editor = p;
|
|
247
|
+
editor = type;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const Element = getComponentFromType(editor);
|
|
251
|
+
|
|
252
|
+
if (useSelectorId) {
|
|
253
|
+
_editor.selectorId = selectorId;
|
|
254
|
+
_editor.selectorSelected = _editor;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
let element = <Element
|
|
258
|
+
name={name}
|
|
259
|
+
value={value}
|
|
260
|
+
setValue={(newValue) => {
|
|
261
|
+
onChange(newValue);
|
|
262
|
+
if (onEditorChange) {
|
|
263
|
+
onEditorChange(newValue, formSetValue, formGetValues, formState);
|
|
264
|
+
}
|
|
265
|
+
}}
|
|
266
|
+
onBlur={onBlur}
|
|
267
|
+
flex={1}
|
|
268
|
+
{..._editor}
|
|
269
|
+
parent={self}
|
|
270
|
+
reference={fieldName}
|
|
271
|
+
// {...defaults}
|
|
272
|
+
// {...propsToPass}
|
|
273
|
+
/>;
|
|
274
|
+
|
|
275
|
+
// element = <Tooltip key={ix} label={header} placement="bottom">
|
|
276
|
+
// {element}
|
|
277
|
+
// </Tooltip>;
|
|
278
|
+
// if (error) {
|
|
279
|
+
// element = <VStack className="pt-1 flex-1">
|
|
280
|
+
// {element}
|
|
281
|
+
// <Text color="#f00">{error.message}</Text>
|
|
282
|
+
// </VStack>;
|
|
283
|
+
// }
|
|
284
|
+
|
|
285
|
+
const dirtyIcon = isDirty && !disableDirtyIcon ? <Icon
|
|
286
|
+
as={Pencil}
|
|
287
|
+
size="2xs"
|
|
288
|
+
className="text-grey-300 absolute top-[2px] left-[2px]"
|
|
289
|
+
/> : null;
|
|
290
|
+
return <HStack
|
|
291
|
+
key={ix}
|
|
292
|
+
{...columnProps}
|
|
293
|
+
className={` flex-${flex} w-${w} ${error ? "bg-[#fdd]" : "bg-white"} `}
|
|
294
|
+
>{dirtyIcon}{element}</HStack>;
|
|
295
|
+
}}
|
|
296
|
+
/>);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
return <HStack>{elements}</HStack>;
|
|
300
|
+
},
|
|
301
|
+
buildFromItems = () => {
|
|
302
|
+
return _.map(items, (item, ix) => buildFromItem(item, ix, columnDefaults));
|
|
303
|
+
},
|
|
304
|
+
buildFromItem = (item, ix, defaults) => {
|
|
305
|
+
if (!item) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
if (React.isValidElement(item)) {
|
|
309
|
+
return item;
|
|
310
|
+
}
|
|
311
|
+
let {
|
|
312
|
+
type,
|
|
313
|
+
title,
|
|
314
|
+
name,
|
|
315
|
+
isEditable = true,
|
|
316
|
+
label,
|
|
317
|
+
items,
|
|
318
|
+
onChange: onEditorChange,
|
|
319
|
+
useSelectorId = false,
|
|
320
|
+
isHidden = false,
|
|
321
|
+
getDynamicProps,
|
|
322
|
+
getIsRequired,
|
|
323
|
+
...propsToPass
|
|
324
|
+
} = item,
|
|
325
|
+
editorTypeProps = {};
|
|
326
|
+
|
|
327
|
+
if (isHidden) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
if (type === 'DisplayField') {
|
|
331
|
+
isEditable = false;
|
|
332
|
+
}
|
|
333
|
+
const propertyDef = name && Repository?.getSchema().getPropertyDefinition(name);
|
|
334
|
+
if (!useAdditionalEditButtons) {
|
|
335
|
+
item = _.omit(item, 'additionalEditButtons');
|
|
336
|
+
}
|
|
337
|
+
if (propertyDef?.isEditingDisabled && checkIsEditingDisabled) {
|
|
338
|
+
isEditable = false;
|
|
339
|
+
}
|
|
340
|
+
if (!type) {
|
|
341
|
+
if (isEditable) {
|
|
342
|
+
const
|
|
343
|
+
{
|
|
344
|
+
type: t,
|
|
345
|
+
...p
|
|
346
|
+
} = propertyDef?.editorType;
|
|
347
|
+
type = t;
|
|
348
|
+
editorTypeProps = p;
|
|
349
|
+
} else if (propertyDef?.viewerType) {
|
|
350
|
+
const
|
|
351
|
+
{
|
|
352
|
+
type: t,
|
|
353
|
+
...p
|
|
354
|
+
} = propertyDef?.viewerType;
|
|
355
|
+
type = t;
|
|
356
|
+
} else {
|
|
357
|
+
type = 'Text';
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const isCombo = type?.match && type.match(/Combo/);
|
|
361
|
+
if (item.hasOwnProperty('autoLoad')) {
|
|
362
|
+
editorTypeProps.autoLoad = item.autoLoad;
|
|
363
|
+
} else {
|
|
364
|
+
if (isCombo && Repository?.isRemote && !Repository?.isLoaded) {
|
|
365
|
+
editorTypeProps.autoLoad = true;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (isCombo) {
|
|
369
|
+
// editorTypeProps.showEyeButton = true;
|
|
370
|
+
if (_.isNil(propsToPass.showXButton)) {
|
|
371
|
+
editorTypeProps.showXButton = true;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const Element = getComponentFromType(type);
|
|
375
|
+
let children;
|
|
376
|
+
|
|
377
|
+
if (inArray(type, ['Column', 'Row', 'FieldSet'])) {
|
|
378
|
+
if (_.isEmpty(items)) {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
if (type === 'Column') {
|
|
382
|
+
if (containerWidth < styles.FORM_ONE_COLUMN_THRESHOLD) {
|
|
383
|
+
// everything is in one column
|
|
384
|
+
if (propsToPass.hasOwnProperty('flex')) {
|
|
385
|
+
delete propsToPass.flex;
|
|
386
|
+
}
|
|
387
|
+
if (propsToPass.hasOwnProperty('width')) {
|
|
388
|
+
delete propsToPass.width;
|
|
389
|
+
}
|
|
390
|
+
if (propsToPass.hasOwnProperty('w')) {
|
|
391
|
+
delete propsToPass.w;
|
|
392
|
+
}
|
|
393
|
+
propsToPass.w = '100%';
|
|
394
|
+
propsToPass.mb = 1;
|
|
395
|
+
}
|
|
396
|
+
propsToPass.pl = 3;
|
|
397
|
+
}
|
|
398
|
+
if (type === 'Row') {
|
|
399
|
+
propsToPass.w = '100%';
|
|
400
|
+
}
|
|
401
|
+
const itemDefaults = item.defaults;
|
|
402
|
+
children = _.map(items, (item, ix) => {
|
|
403
|
+
return buildFromItem(item, ix, itemDefaults);
|
|
404
|
+
});
|
|
405
|
+
return <Element key={ix} title={title} {...itemDefaults} {...propsToPass} {...editorTypeProps}>{children}</Element>;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (!label && Repository && propertyDef?.title) {
|
|
409
|
+
label = propertyDef.title;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (isEditorViewOnly || !isEditable) {
|
|
413
|
+
let value = null;
|
|
414
|
+
if (record?.properties && record.properties[name]) {
|
|
415
|
+
value = record.properties[name].displayValue;
|
|
416
|
+
}
|
|
417
|
+
if (_.isNil(value) && record && record[name]) {
|
|
418
|
+
value = record[name];
|
|
419
|
+
}
|
|
420
|
+
if (_.isNil(value) && startingValues && startingValues[name]) {
|
|
421
|
+
value = startingValues[name];
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
let element = <Element
|
|
425
|
+
value={value}
|
|
426
|
+
parent={self}
|
|
427
|
+
reference={name}
|
|
428
|
+
{...propsToPass}
|
|
429
|
+
/>;
|
|
430
|
+
if (!disableLabels && label) {
|
|
431
|
+
const labelProps = {};
|
|
432
|
+
if (defaults?.labelWidth) {
|
|
433
|
+
labelProps.w = defaults.labelWidth;
|
|
434
|
+
}
|
|
435
|
+
if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
|
|
436
|
+
element = <><Label {...labelProps}>{label}</Label>{element}</>;
|
|
437
|
+
} else {
|
|
438
|
+
element = <VStack><Label {...labelProps}>{label}</Label>{element}</VStack>;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return <HStack key={ix} className="px-2 pb-1">{element}</HStack>;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
// // These rules are for fields *outside* the model
|
|
447
|
+
// // but which want validation on the form anyway.
|
|
448
|
+
// // The useForm() resolver disables this
|
|
449
|
+
// const
|
|
450
|
+
// rules = {},
|
|
451
|
+
// rulesToCheck = [
|
|
452
|
+
// 'required',
|
|
453
|
+
// 'min',
|
|
454
|
+
// 'max',
|
|
455
|
+
// 'minLength',
|
|
456
|
+
// 'maxLength',
|
|
457
|
+
// 'pattern',
|
|
458
|
+
// 'validate',
|
|
459
|
+
// ];
|
|
460
|
+
// _.each(rulesToCheck, (rule) => {
|
|
461
|
+
// if (item.hasOwnProperty(rule)) {
|
|
462
|
+
// rules[rule] = item[rule];
|
|
463
|
+
// }
|
|
464
|
+
// });
|
|
465
|
+
|
|
466
|
+
return <Controller
|
|
467
|
+
key={'controller-' + ix}
|
|
468
|
+
name={name}
|
|
469
|
+
// rules={rules}
|
|
470
|
+
control={control}
|
|
471
|
+
render={(args) => {
|
|
472
|
+
const {
|
|
473
|
+
field,
|
|
474
|
+
fieldState,
|
|
475
|
+
// formState,
|
|
476
|
+
} = args,
|
|
477
|
+
{
|
|
478
|
+
onChange,
|
|
479
|
+
onBlur,
|
|
480
|
+
name,
|
|
481
|
+
value,
|
|
482
|
+
// ref,
|
|
483
|
+
} = field,
|
|
484
|
+
{
|
|
485
|
+
isTouched,
|
|
486
|
+
isDirty,
|
|
487
|
+
error,
|
|
488
|
+
} = fieldState;
|
|
489
|
+
if (isValidElement(Element)) {
|
|
490
|
+
throw new Error('Should not yet be valid React element. Did you use <Element> instead of () => <Element> when defining it?')
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (useSelectorId) { // This causes the whole form to use selectorId
|
|
494
|
+
editorTypeProps.selectorId = selectorId;
|
|
495
|
+
}
|
|
496
|
+
if (propsToPass.selectorId || editorTypeProps.selectorId) { // editorTypeProps.selectorId causes just this one field to use selectorId
|
|
497
|
+
if (_.isNil(propsToPass.selectorSelected)) {
|
|
498
|
+
editorTypeProps.selectorSelected = record;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
let dynamicProps = {};
|
|
502
|
+
if (getDynamicProps) {
|
|
503
|
+
dynamicProps = getDynamicProps({ fieldState, formSetValue, formGetValues, formState });
|
|
504
|
+
}
|
|
505
|
+
let element = <Element
|
|
506
|
+
name={name}
|
|
507
|
+
value={value}
|
|
508
|
+
onChangeValue={(newValue) => {
|
|
509
|
+
if (newValue === undefined) {
|
|
510
|
+
newValue = null; // React Hook Form doesn't respond well when setting value to undefined
|
|
511
|
+
}
|
|
512
|
+
onChange(newValue);
|
|
513
|
+
if (onEditorChange) {
|
|
514
|
+
onEditorChange(newValue, formSetValue, formGetValues, formState, trigger);
|
|
515
|
+
}
|
|
516
|
+
}}
|
|
517
|
+
onBlur={onBlur}
|
|
518
|
+
flex={1}
|
|
519
|
+
parent={self}
|
|
520
|
+
reference={name}
|
|
521
|
+
{...defaults}
|
|
522
|
+
{...propsToPass}
|
|
523
|
+
{...editorTypeProps}
|
|
524
|
+
{...dynamicProps}
|
|
525
|
+
/>;
|
|
526
|
+
if (editorType !== EDITOR_TYPE__INLINE) {
|
|
527
|
+
let message = null;
|
|
528
|
+
if (error) {
|
|
529
|
+
message = error.message;
|
|
530
|
+
if (label && error.ref?.name) {
|
|
531
|
+
message = message.replace(error.ref.name, label);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (message) {
|
|
535
|
+
message = <Text className="text-[#f00]">{message}</Text>;
|
|
536
|
+
}
|
|
537
|
+
element = <VStack className="pt-1 flex-1">
|
|
538
|
+
{element}
|
|
539
|
+
{message}
|
|
540
|
+
</VStack>;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (item.additionalEditButtons) {
|
|
544
|
+
const buttons = buildAdditionalButtons(item.additionalEditButtons, self, { fieldState, formSetValue, formGetValues, formState });
|
|
545
|
+
if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
|
|
546
|
+
element = <HStack className="flex-1 flex-wrap">
|
|
547
|
+
{element}
|
|
548
|
+
{buttons}
|
|
549
|
+
</HStack>;
|
|
550
|
+
} else {
|
|
551
|
+
element = <VStack className="flex-1 w-full">
|
|
552
|
+
{element}
|
|
553
|
+
<HStack className="flex-1 w-full mt-2 flex-wrap">
|
|
554
|
+
{buttons}
|
|
555
|
+
</HStack>
|
|
556
|
+
</VStack>;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
let isRequired = false,
|
|
561
|
+
requiredIndicator = null;
|
|
562
|
+
if (!isMultiple) { // Don't require fields if editing multiple records
|
|
563
|
+
if (getIsRequired) {
|
|
564
|
+
isRequired = getIsRequired(formGetValues, formState);
|
|
565
|
+
} else if (validatorToUse?.fields && validatorToUse.fields[name]?.exclusiveTests?.required) {
|
|
566
|
+
// submitted validator
|
|
567
|
+
isRequired = true;
|
|
568
|
+
} else if ((propertyDef?.validator?.spec && !propertyDef.validator.spec.optional) ||
|
|
569
|
+
(propertyDef?.requiredIfPhantom && isPhantom) ||
|
|
570
|
+
(propertyDef?.requiredIfNotPhantom && !isPhantom)) {
|
|
571
|
+
// property definition
|
|
572
|
+
isRequired = true;
|
|
573
|
+
}
|
|
574
|
+
if (isRequired) {
|
|
575
|
+
requiredIndicator = <Text className="text-[#f00] text-[30px] pr-1">*</Text>;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (!disableLabels && label && editorType !== EDITOR_TYPE__INLINE) {
|
|
579
|
+
const labelProps = {};
|
|
580
|
+
if (defaults?.labelWidth) {
|
|
581
|
+
labelProps.w = defaults.labelWidth;
|
|
582
|
+
}
|
|
583
|
+
if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
|
|
584
|
+
element = <HStack className="w-full py-1">
|
|
585
|
+
<Label {...labelProps}>{requiredIndicator}{label}</Label>
|
|
586
|
+
{element}
|
|
587
|
+
</HStack>;
|
|
588
|
+
} else {
|
|
589
|
+
element = <VStack className="w-full py-1 mt-3">
|
|
590
|
+
<Label {...labelProps}>{requiredIndicator}{label}</Label>
|
|
591
|
+
{element}
|
|
592
|
+
</VStack>;
|
|
593
|
+
}
|
|
594
|
+
} else if (disableLabels && requiredIndicator) {
|
|
595
|
+
element = <HStack className="w-full py-1">
|
|
596
|
+
{requiredIndicator}
|
|
597
|
+
{element}
|
|
598
|
+
</HStack>;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
const dirtyIcon = isDirty && !disableDirtyIcon ? <Icon
|
|
602
|
+
as={Pencil}
|
|
603
|
+
size="2xs"
|
|
604
|
+
className="text-grey-300 absolute top-[2px] left-[2px]" /> : null;
|
|
605
|
+
return (
|
|
606
|
+
<HStack
|
|
607
|
+
key={ix}
|
|
608
|
+
className={` ${error ? "bg-[#fdd]" : "bg-[null]"} px-2 pb-1 `}>{dirtyIcon}{element}</HStack>
|
|
609
|
+
);
|
|
610
|
+
}}
|
|
611
|
+
/>;
|
|
612
|
+
},
|
|
613
|
+
buildAncillary = () => {
|
|
614
|
+
const components = [];
|
|
615
|
+
if (ancillaryItems.length) {
|
|
616
|
+
_.each(ancillaryItems, (item, ix) => {
|
|
617
|
+
let {
|
|
618
|
+
type,
|
|
619
|
+
title = null,
|
|
620
|
+
description = null,
|
|
621
|
+
selectorId,
|
|
622
|
+
...propsToPass
|
|
623
|
+
} = item;
|
|
624
|
+
if (isMultiple && type !== 'Attachments') {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (!propsToPass.h) {
|
|
628
|
+
propsToPass.h = 400;
|
|
629
|
+
}
|
|
630
|
+
const
|
|
631
|
+
Element = getComponentFromType(type),
|
|
632
|
+
element = <Element
|
|
633
|
+
selectorId={selectorId}
|
|
634
|
+
selectorSelected={selectorSelected || record}
|
|
635
|
+
flex={1}
|
|
636
|
+
uniqueRepository={true}
|
|
637
|
+
parent={self}
|
|
638
|
+
{...propsToPass}
|
|
639
|
+
/>;
|
|
640
|
+
if (title) {
|
|
641
|
+
if (record?.displayValue) {
|
|
642
|
+
title += ' for ' + record.displayValue;
|
|
643
|
+
}
|
|
644
|
+
title = <Text
|
|
645
|
+
className={` ${styles.FORM_ANCILLARY_TITLE_FONTSIZE} font-bold `}
|
|
646
|
+
>{title}</Text>;
|
|
647
|
+
}
|
|
648
|
+
if (description) {
|
|
649
|
+
description = <Text
|
|
650
|
+
className={` ${styles.FORM_ANCILLARY_DESCRIPTION_FONTSIZE} italic-italic `}
|
|
651
|
+
>{description}</Text>;
|
|
652
|
+
}
|
|
653
|
+
components.push(<VStack key={'ancillary-' + ix} className="mx-1 my-3">{title}{description}{element}</VStack>);
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
return components;
|
|
657
|
+
},
|
|
658
|
+
onSubmitError = (errors, e) => {
|
|
659
|
+
if (editorType === EDITOR_TYPE__INLINE) {
|
|
660
|
+
alert(errors.message);
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
doReset = (values) => {
|
|
664
|
+
reset(values);
|
|
665
|
+
if (onReset) {
|
|
666
|
+
onReset(values, formSetValue, formGetValues);
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
onSaveDecorated = async (data, e) => {
|
|
670
|
+
// reset the form after a save
|
|
671
|
+
const result = await onSave(data, e);
|
|
672
|
+
if (result) {
|
|
673
|
+
const values = record.submitValues;
|
|
674
|
+
doReset(values);
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
onSubmitDecorated = async (data, e) => {
|
|
678
|
+
const result = await onSubmit(data, e);
|
|
679
|
+
if (result) {
|
|
680
|
+
const values = record.submitValues;
|
|
681
|
+
doReset(values);
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
onLayoutDecorated = (e) => {
|
|
685
|
+
if (onLayout) {
|
|
686
|
+
onLayout(e);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
setContainerWidth(e.nativeEvent.layout.width);
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
useEffect(() => {
|
|
693
|
+
if (skipAll) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (record === previousRecord) {
|
|
697
|
+
if (onInit) {
|
|
698
|
+
onInit(initialValues, formSetValue, formGetValues);
|
|
699
|
+
}
|
|
700
|
+
} else {
|
|
701
|
+
setPreviousRecord(record);
|
|
702
|
+
doReset(defaultValues);
|
|
703
|
+
}
|
|
704
|
+
if (formSetup) {
|
|
705
|
+
formSetup(formSetValue, formGetValues, formState)
|
|
706
|
+
}
|
|
707
|
+
}, [record]);
|
|
708
|
+
|
|
709
|
+
useEffect(() => {
|
|
710
|
+
if (skipAll) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
if (!Repository) {
|
|
714
|
+
return () => {
|
|
715
|
+
if (!_.isNil(editorStateRef)) {
|
|
716
|
+
editorStateRef.current = null; // clean up the editorStateRef on unmount
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
Repository.ons(['changeData', 'change'], forceUpdate);
|
|
722
|
+
|
|
723
|
+
return () => {
|
|
724
|
+
Repository.offs(['changeData', 'change'], forceUpdate);
|
|
725
|
+
if (!_.isNil(editorStateRef)) {
|
|
726
|
+
editorStateRef.current = null; // clean up the editorStateRef on unmount
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
}, [Repository]);
|
|
730
|
+
|
|
731
|
+
if (skipAll) {
|
|
732
|
+
return null;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// if (Repository && (!record || _.isEmpty(record) || record.isDestroyed)) {
|
|
736
|
+
// return null;
|
|
737
|
+
// }
|
|
738
|
+
|
|
739
|
+
if (!_.isNil(editorStateRef)) {
|
|
740
|
+
editorStateRef.current = formState; // Update state so HOC can know what's going on
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
if (self) {
|
|
744
|
+
self.ref = formRef;
|
|
745
|
+
self.formState = formState;
|
|
746
|
+
self.formSetValue = formSetValue;
|
|
747
|
+
self.formGetValues = formGetValues;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
const sizeProps = {};
|
|
751
|
+
if (!flex && !h && !w) {
|
|
752
|
+
sizeProps.flex = 1;
|
|
753
|
+
} else {
|
|
754
|
+
if (h) {
|
|
755
|
+
sizeProps.h = h;
|
|
756
|
+
}
|
|
757
|
+
if (w) {
|
|
758
|
+
sizeProps.w = w;
|
|
759
|
+
}
|
|
760
|
+
if (flex) {
|
|
761
|
+
sizeProps.flex = flex;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (maxWidth) {
|
|
765
|
+
sizeProps.maxWidth = maxWidth;
|
|
766
|
+
}
|
|
767
|
+
if (maxHeight) {
|
|
768
|
+
sizeProps.maxHeight = maxHeight;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
const formButtons = [];
|
|
772
|
+
let formComponents,
|
|
773
|
+
editor,
|
|
774
|
+
additionalButtons,
|
|
775
|
+
isSaveDisabled = false,
|
|
776
|
+
isSubmitDisabled = false,
|
|
777
|
+
savingProps = {},
|
|
778
|
+
|
|
779
|
+
showDeleteBtn = false,
|
|
780
|
+
showResetBtn = false,
|
|
781
|
+
showCloseBtn = false,
|
|
782
|
+
showCancelBtn = false,
|
|
783
|
+
showSaveBtn = false,
|
|
784
|
+
showSubmitBtn = false;
|
|
785
|
+
|
|
786
|
+
if (containerWidth) { // we need to render this component twice in order to get the container width. Skip this on first render
|
|
787
|
+
|
|
788
|
+
if (isSaving) {
|
|
789
|
+
savingProps.borderTopWidth = 2;
|
|
790
|
+
savingProps.borderTopColor = '#f00';
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
if (editorType === EDITOR_TYPE__INLINE) {
|
|
794
|
+
editor = buildFromColumnsConfig();
|
|
795
|
+
// } else if (editorType === EDITOR_TYPE__PLAIN) {
|
|
796
|
+
// formComponents = buildFromItems();
|
|
797
|
+
// const formAncillaryComponents = buildAncillary();
|
|
798
|
+
// editor = <>
|
|
799
|
+
// <VStack className="p-4">{formComponents}</VStack>
|
|
800
|
+
// <VStack className="pt-4">{formAncillaryComponents}</VStack>
|
|
801
|
+
// </>;
|
|
802
|
+
} else {
|
|
803
|
+
formComponents = buildFromItems();
|
|
804
|
+
const formAncillaryComponents = buildAncillary();
|
|
805
|
+
editor = <>
|
|
806
|
+
{containerWidth >= styles.FORM_ONE_COLUMN_THRESHOLD ? <HStack className="p-4 pl-0">{formComponents}</HStack> : null}
|
|
807
|
+
{containerWidth < styles.FORM_ONE_COLUMN_THRESHOLD ? <VStack className="p-4">{formComponents}</VStack> : null}
|
|
808
|
+
<VStack className="m-2 pt-4 px-2">{formAncillaryComponents}</VStack>
|
|
809
|
+
</>;
|
|
810
|
+
|
|
811
|
+
additionalButtons = buildAdditionalButtons(additionalEditButtons);
|
|
812
|
+
|
|
813
|
+
formButtons.push(<HStack key="buttonsRow" className="px-4 pt-4 items-center justify-end">
|
|
814
|
+
{isSingle && editorMode === EDITOR_MODE__EDIT && onBack &&
|
|
815
|
+
<Button
|
|
816
|
+
key="backBtn"
|
|
817
|
+
onPress={onBack}
|
|
818
|
+
leftIcon={<Icon as={AngleLeft} size="sm" className="text-white" />}
|
|
819
|
+
color="#fff"
|
|
820
|
+
>Back</Button>}
|
|
821
|
+
{isSingle && editorMode === EDITOR_MODE__EDIT && onViewMode && !disableView &&
|
|
822
|
+
<Button
|
|
823
|
+
key="viewBtn"
|
|
824
|
+
onPress={onViewMode}
|
|
825
|
+
leftIcon={<Icon as={Eye} size="sm" className="text-white" />}
|
|
826
|
+
color="#fff"
|
|
827
|
+
>To View</Button>}
|
|
828
|
+
</HStack>);
|
|
829
|
+
if (editorMode === EDITOR_MODE__EDIT && !_.isEmpty(additionalButtons)) {
|
|
830
|
+
formButtons.push(<HStack
|
|
831
|
+
key="additionalButtonsRow"
|
|
832
|
+
className="p-[4px] items-center justify-end flex-wrap"
|
|
833
|
+
>
|
|
834
|
+
{additionalButtons}
|
|
835
|
+
</HStack>)
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
if (!formState.isValid) {
|
|
840
|
+
isSaveDisabled = true;
|
|
841
|
+
isSubmitDisabled = true;
|
|
842
|
+
}
|
|
843
|
+
if (_.isEmpty(formState.dirtyFields) && !isPhantom) {
|
|
844
|
+
isSaveDisabled = true;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
if (editorType === EDITOR_TYPE__INLINE) {
|
|
848
|
+
buttonGroupProps.position = 'fixed';
|
|
849
|
+
buttonGroupProps.left = 10; // TODO: I would prefer to have this be centered, but it's a lot more complex than just making it stick to the left
|
|
850
|
+
footerProps.alignItems = 'flex-start';
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (onDelete && editorMode === EDITOR_MODE__EDIT && isSingle) {
|
|
854
|
+
showDeleteBtn = true;
|
|
855
|
+
}
|
|
856
|
+
if (!isEditorViewOnly) {
|
|
857
|
+
showResetBtn = true;
|
|
858
|
+
}
|
|
859
|
+
if (editorType !== EDITOR_TYPE__SIDE) { // side editor won't show either close or cancel buttons!
|
|
860
|
+
// determine whether we should show the close or cancel button
|
|
861
|
+
if (isEditorViewOnly) {
|
|
862
|
+
showCloseBtn = true;
|
|
863
|
+
} else {
|
|
864
|
+
const formIsDirty = formState.isDirty;
|
|
865
|
+
// console.log('formIsDirty', formIsDirty);
|
|
866
|
+
// console.log('isPhantom', isPhantom);
|
|
867
|
+
if (formIsDirty || isPhantom) {
|
|
868
|
+
if (isSingle && onCancel) {
|
|
869
|
+
showCancelBtn = true;
|
|
870
|
+
}
|
|
871
|
+
} else {
|
|
872
|
+
if (onClose) {
|
|
873
|
+
showCloseBtn = true;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (!isEditorViewOnly && onSave) {
|
|
879
|
+
showSaveBtn = true;
|
|
880
|
+
}
|
|
881
|
+
if (!!onSubmit) {
|
|
882
|
+
showSubmitBtn = true;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
return <VStackNative
|
|
887
|
+
{...sizeProps}
|
|
888
|
+
onLayout={onLayoutDecorated}
|
|
889
|
+
ref={formRef}
|
|
890
|
+
>
|
|
891
|
+
{!!containerWidth && <>
|
|
892
|
+
{editorType === EDITOR_TYPE__INLINE &&
|
|
893
|
+
<ScrollView
|
|
894
|
+
horizontal={true}
|
|
895
|
+
className="flex-1 bg-white py-1 border-t-[3px] border-b-[5px] border-t-primary-100 border-b-primary-100">{editor}</ScrollView>}
|
|
896
|
+
{editorType !== EDITOR_TYPE__INLINE &&
|
|
897
|
+
<ScrollView _web={{ minHeight, }} className="w-full pb-1">
|
|
898
|
+
{formButtons}
|
|
899
|
+
{editor}
|
|
900
|
+
</ScrollView>}
|
|
901
|
+
|
|
902
|
+
<Footer className="justify-end" {...footerProps} {...savingProps}>
|
|
903
|
+
{onDelete && editorMode === EDITOR_MODE__EDIT && isSingle &&
|
|
904
|
+
|
|
905
|
+
<HStack className="flex-1 justify-start">
|
|
906
|
+
<Button
|
|
907
|
+
key="deleteBtn"
|
|
908
|
+
onPress={onDelete}
|
|
909
|
+
bg="warning"
|
|
910
|
+
_hover={{
|
|
911
|
+
bg: 'warningHover',
|
|
912
|
+
}}
|
|
913
|
+
color="#fff"
|
|
914
|
+
>Delete</Button>
|
|
915
|
+
</HStack>}
|
|
916
|
+
|
|
917
|
+
{showResetBtn &&
|
|
918
|
+
<IconButton
|
|
919
|
+
key="resetBtn"
|
|
920
|
+
onPress={() => doReset()}
|
|
921
|
+
icon={Rotate}
|
|
922
|
+
_icon={{
|
|
923
|
+
color: !formState.isDirty ? 'grey-400' : '#000',
|
|
924
|
+
}}
|
|
925
|
+
isDisabled={!formState.isDirty}
|
|
926
|
+
mr={2}
|
|
927
|
+
/>}
|
|
928
|
+
|
|
929
|
+
{showCancelBtn &&
|
|
930
|
+
<Button
|
|
931
|
+
key="cancelBtn"
|
|
932
|
+
variant="outline"
|
|
933
|
+
onPress={onCancel}
|
|
934
|
+
color="#fff"
|
|
935
|
+
>Cancel</Button>}
|
|
936
|
+
|
|
937
|
+
{showCloseBtn &&
|
|
938
|
+
<Button
|
|
939
|
+
key="closeBtn"
|
|
940
|
+
variant="outline"
|
|
941
|
+
onPress={onClose}
|
|
942
|
+
color="#fff"
|
|
943
|
+
>Close</Button>}
|
|
944
|
+
|
|
945
|
+
{showSaveBtn &&
|
|
946
|
+
<Button
|
|
947
|
+
key="saveBtn"
|
|
948
|
+
onPress={(e) => handleSubmit(onSaveDecorated, onSubmitError)(e)}
|
|
949
|
+
isDisabled={isSaveDisabled}
|
|
950
|
+
color="#fff"
|
|
951
|
+
>{editorMode === EDITOR_MODE__ADD ? 'Add' : 'Save'}</Button>}
|
|
952
|
+
|
|
953
|
+
{showSubmitBtn &&
|
|
954
|
+
<Button
|
|
955
|
+
key="submitBtn"
|
|
956
|
+
onPress={(e) => handleSubmit(onSubmitDecorated, onSubmitError)(e)}
|
|
957
|
+
isDisabled={isSubmitDisabled}
|
|
958
|
+
color="#fff"
|
|
959
|
+
>{submitBtnLabel || 'Submit'}</Button>}
|
|
960
|
+
|
|
961
|
+
{additionalFooterButtons && _.map(additionalFooterButtons, (props) => {
|
|
962
|
+
return <Button
|
|
963
|
+
{...props}
|
|
964
|
+
onPress={(e) => handleSubmit(props.onPress, onSubmitError)(e)}
|
|
965
|
+
>{props.text}</Button>;
|
|
966
|
+
})}
|
|
967
|
+
</Footer>
|
|
968
|
+
</>}
|
|
969
|
+
</VStackNative>;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// helper fns
|
|
973
|
+
function disableRequiredYupFields(validator) {
|
|
974
|
+
// based on https://github.com/jquense/yup/issues/1466#issuecomment-944386480
|
|
975
|
+
if (!validator) {
|
|
976
|
+
return null;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
const nextSchema = validator.clone();
|
|
980
|
+
return nextSchema.withMutation((next) => {
|
|
981
|
+
if (typeof next.fields === 'object' && next.fields != null) {
|
|
982
|
+
for (const key in next.fields) {
|
|
983
|
+
const nestedField = next.fields[key];
|
|
984
|
+
|
|
985
|
+
let nestedFieldNext = nestedField.notRequired();
|
|
986
|
+
|
|
987
|
+
if (Array.isArray(nestedField.conditions) && nestedField.conditions.length > 0) {
|
|
988
|
+
// Next is done to disable required() inside a condition
|
|
989
|
+
// https://github.com/jquense/yup/issues/1002
|
|
990
|
+
nestedFieldNext = nestedFieldNext.when('whatever', (unused, schema) => {
|
|
991
|
+
return schema.notRequired();
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
next.fields[key] = nestedFieldNext;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
function getNullFieldValues(initialValues, Repository) {
|
|
1001
|
+
const ret = {};
|
|
1002
|
+
if (Repository) {
|
|
1003
|
+
const properties = Repository.getSchema().model.properties;
|
|
1004
|
+
_.each(properties, (propertyDef) => {
|
|
1005
|
+
ret[propertyDef.name] = null;
|
|
1006
|
+
});
|
|
1007
|
+
} else {
|
|
1008
|
+
// takes a JSON object of fieldValues and sets them all to null
|
|
1009
|
+
_.each(initialValues, (value, field) => {
|
|
1010
|
+
ret[field] = null;
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
return ret;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
export const FormEditor = withComponent(withAlert(withEditor(withPdfButton(FormikForm))));
|
|
1017
|
+
|
|
1018
|
+
export default withComponent(withAlert(withPdfButton(FormikForm)));
|