cx 25.11.1 → 26.0.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/.mocharc.json +5 -0
- package/build.js +129 -0
- package/dist/charts.css +250 -250
- package/dist/charts.js +2421 -3102
- package/dist/data.js +857 -1063
- package/dist/hooks.js +48 -59
- package/dist/jsx-runtime.js +24 -0
- package/dist/manifest.js +925 -919
- package/dist/svg.js +266 -432
- package/dist/ui.js +1933 -2388
- package/dist/util.js +587 -557
- package/dist/widgets.css +6 -6
- package/dist/widgets.js +7542 -9910
- package/package.json +39 -5
- package/src/charts/Bar.scss +5 -3
- package/src/charts/Bar.ts +114 -0
- package/src/charts/BarGraph.scss +4 -3
- package/src/charts/BarGraph.tsx +145 -0
- package/src/charts/BubbleGraph.scss +5 -3
- package/src/charts/BubbleGraph.tsx +165 -0
- package/src/charts/Chart.ts +108 -0
- package/src/charts/ColorMap.ts +150 -0
- package/src/charts/Column.scss +5 -3
- package/src/charts/Column.ts +124 -0
- package/src/charts/ColumnBarBase.tsx +284 -0
- package/src/charts/ColumnBarGraphBase.tsx +229 -0
- package/src/charts/ColumnGraph.scss +5 -3
- package/src/charts/ColumnGraph.tsx +153 -0
- package/src/charts/Grid.ts +5 -0
- package/src/charts/Gridlines.scss +5 -3
- package/src/charts/Gridlines.tsx +88 -0
- package/src/charts/Legend.scss +5 -3
- package/src/charts/Legend.tsx +270 -0
- package/src/charts/LegendEntry.scss +5 -3
- package/src/charts/LegendEntry.tsx +197 -0
- package/src/charts/LineGraph.scss +4 -3
- package/src/charts/LineGraph.tsx +441 -0
- package/src/charts/Marker.scss +5 -3
- package/src/charts/Marker.tsx +483 -0
- package/src/charts/MarkerLine.scss +5 -3
- package/src/charts/MarkerLine.tsx +214 -0
- package/src/charts/MouseTracker.tsx +112 -0
- package/src/charts/Pie.ts +8 -0
- package/src/charts/PieChart.scss +5 -3
- package/src/charts/PieChart.tsx +717 -0
- package/src/charts/PieLabel.tsx +106 -0
- package/src/charts/PieLabelsContainer.ts +68 -0
- package/src/charts/Range.scss +4 -3
- package/src/charts/Range.tsx +318 -0
- package/src/charts/RangeMarker.scss +5 -3
- package/src/charts/RangeMarker.tsx +233 -0
- package/src/charts/ScatterGraph.scss +5 -3
- package/src/charts/ScatterGraph.tsx +245 -0
- package/src/charts/Swimlane.scss +5 -3
- package/src/charts/Swimlane.tsx +195 -0
- package/src/charts/Swimlanes.scss +5 -3
- package/src/charts/Swimlanes.tsx +179 -0
- package/src/charts/axis/Axis.tsx +444 -0
- package/src/charts/axis/CategoryAxis.scss +5 -3
- package/src/charts/axis/CategoryAxis.tsx +313 -0
- package/src/charts/axis/NumericAxis.scss +5 -3
- package/src/charts/axis/NumericAxis.tsx +437 -0
- package/src/charts/axis/Stack.ts +61 -0
- package/src/charts/axis/TimeAxis.scss +4 -3
- package/src/charts/axis/TimeAxis.tsx +718 -0
- package/src/charts/axis/index.ts +4 -0
- package/src/charts/helpers/MinMaxFinder.ts +66 -0
- package/src/charts/helpers/PointReducer.ts +135 -0
- package/src/charts/helpers/SnapPointFinder.ts +136 -0
- package/src/charts/helpers/ValueAtFinder.ts +72 -0
- package/src/charts/helpers/index.ts +4 -0
- package/src/charts/palette.scss +7 -5
- package/src/charts/shapes.tsx +86 -0
- package/src/charts/variables.scss +2 -1
- package/src/core.d.ts +182 -310
- package/src/data/AggregateFunction.ts +171 -0
- package/src/data/ArrayElementView.spec.ts +88 -0
- package/src/data/ArrayElementView.ts +90 -0
- package/src/data/ArrayRef.ts +35 -0
- package/src/data/AugmentedViewBase.ts +88 -0
- package/src/data/Binding.ts +104 -0
- package/src/data/ExposedRecordView.ts +95 -0
- package/src/data/ExposedValueView.ts +89 -0
- package/src/data/Expression.spec.ts +229 -0
- package/src/data/Expression.ts +233 -0
- package/src/data/Grouper.ts +158 -0
- package/src/data/NestedDataView.ts +43 -0
- package/src/data/ReadOnlyDataView.ts +39 -0
- package/src/data/Ref.spec.ts +79 -0
- package/src/data/Ref.ts +104 -0
- package/src/data/Selector.ts +10 -0
- package/src/data/Store.spec.ts +22 -0
- package/src/data/Store.ts +52 -0
- package/src/data/StoreProxy.ts +19 -0
- package/src/data/StoreRef.spec.ts +24 -0
- package/src/data/StoreRef.ts +66 -0
- package/src/data/StringTemplate.spec.ts +132 -0
- package/src/data/StringTemplate.ts +93 -0
- package/src/data/StructuredSelector.spec.ts +113 -0
- package/src/data/StructuredSelector.ts +146 -0
- package/src/data/SubscribableView.ts +63 -0
- package/src/data/View.ts +289 -0
- package/src/data/ZoomIntoPropertyView.spec.ts +64 -0
- package/src/data/ZoomIntoPropertyView.ts +45 -0
- package/src/data/comparer.ts +78 -0
- package/src/data/computable.spec.ts +62 -0
- package/src/data/computable.ts +72 -0
- package/src/data/createAccessorModelProxy.ts +60 -0
- package/src/data/createStructuredSelector.spec.ts +45 -0
- package/src/data/createStructuredSelector.ts +62 -0
- package/src/data/defaultCompare.ts +15 -0
- package/src/data/diff/diffArrays.ts +49 -0
- package/src/data/diff/diffs.spec.ts +49 -0
- package/src/data/diff/index.ts +1 -0
- package/src/data/enableFatArrowExpansion.ts +6 -0
- package/src/data/getAccessor.spec.ts +11 -0
- package/src/data/getAccessor.ts +74 -0
- package/src/data/getSelector.spec.ts +43 -0
- package/src/data/getSelector.ts +66 -0
- package/src/data/index.ts +30 -0
- package/src/data/isSelector.ts +26 -0
- package/src/data/ops/append.spec.ts +28 -0
- package/src/data/ops/append.ts +5 -0
- package/src/data/ops/filter.spec.ts +35 -0
- package/src/data/ops/filter.ts +9 -0
- package/src/data/ops/findTreeNode.spec.ts +23 -0
- package/src/data/ops/findTreeNode.ts +18 -0
- package/src/data/ops/findTreePath.ts +23 -0
- package/src/data/ops/insertElement.ts +3 -0
- package/src/data/ops/merge.spec.ts +27 -0
- package/src/data/ops/merge.ts +13 -0
- package/src/data/ops/moveElement.ts +21 -0
- package/src/data/ops/removeTreeNodes.spec.ts +37 -0
- package/src/data/ops/removeTreeNodes.ts +15 -0
- package/src/data/ops/updateArray.spec.ts +69 -0
- package/src/data/ops/updateArray.ts +31 -0
- package/src/data/ops/updateTree.spec.ts +54 -0
- package/src/data/ops/updateTree.ts +23 -0
- package/src/data/test-types.ts +7 -0
- package/src/hooks/createLocalStorageRef.ts +21 -0
- package/src/hooks/invokeCallback.spec.tsx +59 -0
- package/src/hooks/invokeCallback.ts +8 -0
- package/src/hooks/resolveCallback.spec.tsx +48 -0
- package/src/hooks/resolveCallback.ts +16 -0
- package/src/hooks/store.spec.tsx +67 -0
- package/src/hooks/store.ts +46 -0
- package/src/hooks/useEffect.ts +14 -0
- package/src/hooks/useInterval.ts +8 -0
- package/src/hooks/useState.ts +20 -0
- package/src/hooks/useTrigger.spec.tsx +99 -0
- package/src/hooks/useTrigger.ts +26 -0
- package/src/index.scss +6 -6
- package/src/jsx-runtime.ts +72 -0
- package/src/locale/de-de.ts +76 -0
- package/src/locale/en-us.ts +75 -0
- package/src/locale/es-es.ts +76 -0
- package/src/locale/fr-fr.ts +76 -0
- package/src/locale/nl-nl.ts +76 -0
- package/src/locale/pt-pt.ts +76 -0
- package/src/locale/sr-latn-ba.ts +76 -0
- package/src/svg/BoundedObject.ts +101 -0
- package/src/svg/ClipRect.tsx +29 -0
- package/src/svg/Ellipse.tsx +69 -0
- package/src/svg/Line.tsx +58 -0
- package/src/svg/NonOverlappingRect.ts +26 -0
- package/src/svg/NonOverlappingRectGroup.ts +49 -0
- package/src/svg/Rectangle.tsx +91 -0
- package/src/svg/Svg.scss +5 -4
- package/src/svg/Svg.tsx +241 -0
- package/src/svg/Text.tsx +134 -0
- package/src/svg/TextualBoundedObject.ts +35 -0
- package/src/svg/util/Rect.ts +105 -0
- package/src/ui/CSS.ts +87 -0
- package/src/ui/CSSHelper.ts +17 -0
- package/src/ui/Container.tsx +216 -0
- package/src/ui/ContentResolver.spec.tsx +430 -0
- package/src/ui/ContentResolver.ts +124 -0
- package/src/ui/Controller.spec.tsx +566 -0
- package/src/ui/Controller.ts +189 -0
- package/src/ui/Culture.ts +159 -0
- package/src/ui/Cx.spec.tsx +208 -0
- package/src/ui/Cx.tsx +386 -0
- package/src/ui/DataProxy.spec.tsx +337 -0
- package/src/ui/DataProxy.ts +55 -0
- package/src/ui/DetachedScope.tsx +159 -0
- package/src/ui/FocusManager.ts +171 -0
- package/src/ui/Format.ts +108 -0
- package/src/ui/HoverSync.tsx +189 -0
- package/src/ui/Instance.ts +868 -0
- package/src/ui/IsolatedScope.spec.tsx +55 -0
- package/src/ui/IsolatedScope.ts +50 -0
- package/src/ui/Localization.ts +70 -0
- package/src/ui/Prop.ts +112 -0
- package/src/ui/PureContainer.spec.tsx +230 -0
- package/src/ui/PureContainer.tsx +19 -0
- package/src/ui/RenderingContext.ts +99 -0
- package/src/ui/Repeater.spec.tsx +141 -0
- package/src/ui/Repeater.ts +203 -0
- package/src/ui/Rescope.spec.tsx +199 -0
- package/src/ui/Rescope.ts +49 -0
- package/src/ui/ResizeManager.ts +31 -0
- package/src/ui/Restate.spec.tsx +418 -0
- package/src/ui/Restate.tsx +217 -0
- package/src/ui/StaticText.ts +11 -0
- package/src/ui/StructuredInstanceDataAccessor.ts +32 -0
- package/src/ui/Text.ts +30 -0
- package/src/ui/VDOM.ts +34 -0
- package/src/ui/Widget.spec.tsx +53 -0
- package/src/ui/Widget.tsx +308 -0
- package/src/ui/ZIndexManager.ts +11 -0
- package/src/ui/adapter/ArrayAdapter.spec.ts +55 -0
- package/src/ui/adapter/ArrayAdapter.ts +226 -0
- package/src/ui/adapter/DataAdapter.ts +52 -0
- package/src/ui/adapter/GroupAdapter.ts +235 -0
- package/src/ui/adapter/TreeAdapter.spec.ts +76 -0
- package/src/ui/adapter/TreeAdapter.ts +185 -0
- package/src/ui/app/History.ts +133 -0
- package/src/ui/app/Url.spec.ts +50 -0
- package/src/ui/app/Url.ts +102 -0
- package/src/ui/app/startAppLoop.tsx +74 -0
- package/src/ui/app/startHotAppLoop.ts +40 -0
- package/src/ui/batchUpdates.ts +77 -0
- package/src/ui/bind.ts +10 -0
- package/src/ui/createFunctionalComponent.spec.tsx +399 -0
- package/src/ui/createFunctionalComponent.ts +65 -0
- package/src/ui/expr.ts +44 -0
- package/src/ui/flattenProps.ts +21 -0
- package/src/ui/index.ts +45 -0
- package/src/ui/keyboardShortcuts.ts +40 -0
- package/src/ui/layout/Content.ts +30 -0
- package/src/ui/layout/ContentPlaceholder.spec.tsx +587 -0
- package/src/ui/layout/ContentPlaceholder.ts +133 -0
- package/src/ui/layout/FirstVisibleChildLayout.spec.tsx +195 -0
- package/src/ui/layout/FirstVisibleChildLayout.ts +60 -0
- package/src/ui/layout/LabelsLeftLayout.scss +6 -4
- package/src/ui/layout/LabelsLeftLayout.tsx +76 -0
- package/src/ui/layout/LabelsTopLayout.scss +5 -4
- package/src/ui/layout/LabelsTopLayout.tsx +156 -0
- package/src/ui/layout/UseParentLayout.ts +8 -0
- package/src/ui/layout/exploreChildren.ts +38 -0
- package/src/ui/selection/KeySelection.ts +165 -0
- package/src/ui/selection/PropertySelection.ts +87 -0
- package/src/ui/selection/Selection.ts +118 -0
- package/src/ui/tpl.ts +5 -0
- package/src/util/Component.spec.ts +381 -0
- package/src/util/Component.ts +296 -0
- package/src/util/Console.ts +11 -0
- package/src/util/DOM.ts +88 -0
- package/src/util/Debug.ts +71 -0
- package/src/util/Format.spec.ts +69 -0
- package/src/util/Format.ts +267 -0
- package/src/util/GlobalCacheIdentifier.ts +11 -0
- package/src/util/KeyCode.ts +21 -0
- package/src/util/SubscriberList.ts +87 -0
- package/src/util/Timing.ts +59 -0
- package/src/util/TraversalStack.spec.ts +54 -0
- package/src/util/TraversalStack.ts +48 -0
- package/src/util/addEventListenerWithOptions.ts +41 -0
- package/src/util/browserSupportsPassiveEventHandlers.ts +20 -0
- package/src/util/calculateNaturalElementHeight.ts +22 -0
- package/src/util/capitalize.ts +4 -0
- package/src/util/coalesce.ts +6 -0
- package/src/util/color/hslToRgb.ts +34 -0
- package/src/util/color/parseColor.ts +173 -0
- package/src/util/color/rgbToHex.ts +15 -0
- package/src/util/color/rgbToHsl.ts +36 -0
- package/src/util/date/dateDiff.ts +9 -0
- package/src/util/date/diff.ts +13 -0
- package/src/util/date/encodeDate.ts +8 -0
- package/src/util/date/encodeDateWithTimezoneOffset.ts +19 -0
- package/src/util/date/lowerBoundCheck.ts +13 -0
- package/src/util/date/maxDate.ts +14 -0
- package/src/util/date/minDate.ts +14 -0
- package/src/util/date/monthStart.ts +8 -0
- package/src/util/date/parseDateInvariant.ts +20 -0
- package/src/util/date/sameDate.ts +11 -0
- package/src/util/date/upperBoundCheck.ts +13 -0
- package/src/util/date/zeroTime.ts +9 -0
- package/src/util/debounce.ts +26 -0
- package/src/util/dummyCallback.ts +1 -0
- package/src/util/escapeSpecialRegexCharacters.ts +8 -0
- package/src/util/eventCallbacks.ts +12 -0
- package/src/util/expandFatArrows.ts +118 -0
- package/src/util/findScrollableParent.ts +15 -0
- package/src/util/getActiveElement.ts +4 -0
- package/src/util/getParentFrameBoundingClientRect.ts +13 -0
- package/src/util/getScrollerBoundingClientRect.ts +12 -0
- package/src/util/getSearchQueryPredicate.ts +58 -0
- package/src/util/getTopLevelBoundingClientRect.ts +7 -0
- package/src/util/getVendorPrefix.ts +33 -0
- package/src/util/hasKey.ts +18 -0
- package/src/util/index.ts +55 -0
- package/src/util/innerTextTrim.ts +10 -0
- package/src/util/isArray.ts +3 -0
- package/src/util/isDataRecord.ts +5 -0
- package/src/util/isDefined.ts +3 -0
- package/src/util/isDigit.ts +8 -0
- package/src/util/isFunction.ts +3 -0
- package/src/util/isNonEmptyArray.ts +3 -0
- package/src/util/isNumber.ts +3 -0
- package/src/util/isObject.ts +3 -0
- package/src/util/isPromise.ts +6 -0
- package/src/util/isString.ts +3 -0
- package/src/util/isTextInputElement.ts +3 -0
- package/src/util/isTouchDevice.ts +7 -0
- package/src/util/isTouchEvent.ts +64 -0
- package/src/util/isUndefined.ts +3 -0
- package/src/util/isValidIdentifierName.ts +5 -0
- package/src/util/onIdleCallback.ts +10 -0
- package/src/util/parseStyle.ts +29 -0
- package/src/util/quote.ts +6 -0
- package/src/util/reverseSlice.ts +10 -0
- package/src/util/routeAppend.ts +16 -0
- package/src/util/scrollElementIntoView.ts +40 -0
- package/src/util/scss/add-rules.scss +7 -5
- package/src/util/scss/calc.scss +12 -8
- package/src/util/scss/call-once.scss +5 -3
- package/src/util/scss/clockwise.scss +20 -18
- package/src/util/scss/colors.scss +4 -2
- package/src/util/scss/deep-get.scss +3 -1
- package/src/util/scss/deep-merge.scss +6 -3
- package/src/util/scss/include.scss +6 -5
- package/src/util/shallowEquals.ts +43 -0
- package/src/util/test/createTestRenderer.tsx +12 -0
- package/src/util/throttle.ts +21 -0
- package/src/util/validatedDebounce.ts +23 -0
- package/src/widgets/AccessorBindings.spec.tsx +5 -7
- package/src/widgets/Button.scss +6 -4
- package/src/widgets/Button.tsx +201 -0
- package/src/widgets/Button.variables.scss +13 -10
- package/src/widgets/CxCredit.scss +6 -4
- package/src/widgets/CxCredit.tsx +46 -0
- package/src/widgets/DocumentTitle.ts +92 -0
- package/src/widgets/FlexBox.scss +7 -5
- package/src/widgets/FlexBox.tsx +169 -0
- package/src/widgets/Heading.scss +6 -4
- package/src/widgets/Heading.ts +43 -0
- package/src/widgets/HighlightedSearchText.scss +6 -4
- package/src/widgets/HighlightedSearchText.tsx +54 -0
- package/src/widgets/HtmlElement.spec.tsx +79 -0
- package/src/widgets/HtmlElement.tsx +349 -0
- package/src/widgets/Icon.scss +6 -4
- package/src/widgets/Icon.ts +78 -0
- package/src/widgets/List.scss +6 -4
- package/src/widgets/List.tsx +787 -0
- package/src/widgets/ProgressBar.scss +5 -4
- package/src/widgets/ProgressBar.tsx +66 -0
- package/src/widgets/Resizer.scss +5 -4
- package/src/widgets/Resizer.tsx +200 -0
- package/src/widgets/Sandbox.ts +103 -0
- package/src/widgets/Section.scss +5 -4
- package/src/widgets/Section.tsx +187 -0
- package/src/widgets/autoFocus.ts +9 -0
- package/src/widgets/cx.ts +63 -0
- package/src/widgets/drag-drop/DragClone.scss +6 -4
- package/src/widgets/drag-drop/DragHandle.scss +6 -4
- package/src/widgets/drag-drop/DragHandle.tsx +47 -0
- package/src/widgets/drag-drop/DragSource.scss +6 -4
- package/src/widgets/drag-drop/DragSource.tsx +238 -0
- package/src/widgets/drag-drop/DropZone.scss +6 -4
- package/src/widgets/drag-drop/DropZone.tsx +354 -0
- package/src/widgets/drag-drop/ops.tsx +422 -0
- package/src/widgets/drag-drop/variables.scss +4 -1
- package/src/widgets/enableAllInternalDependencies.ts +11 -0
- package/src/widgets/form/Calendar.scss +8 -5
- package/src/widgets/form/Calendar.tsx +760 -0
- package/src/widgets/form/Checkbox.scss +5 -3
- package/src/widgets/form/Checkbox.tsx +285 -0
- package/src/widgets/form/ColorField.scss +5 -3
- package/src/widgets/form/ColorField.tsx +491 -0
- package/src/widgets/form/ColorPicker.scss +5 -3
- package/src/widgets/form/ColorPicker.tsx +544 -0
- package/src/widgets/form/DateField.ts +21 -0
- package/src/widgets/form/DateTimeField.scss +5 -3
- package/src/widgets/form/DateTimeField.tsx +723 -0
- package/src/widgets/form/DateTimePicker.scss +6 -4
- package/src/widgets/form/DateTimePicker.tsx +431 -0
- package/src/widgets/form/Field.scss +4 -2
- package/src/widgets/form/Field.tsx +611 -0
- package/src/widgets/form/FieldGroup.ts +10 -0
- package/src/widgets/form/FieldIcon.ts +61 -0
- package/src/widgets/form/HelpText.scss +5 -4
- package/src/widgets/form/HelpText.ts +15 -0
- package/src/widgets/form/Label.scss +5 -4
- package/src/widgets/form/Label.tsx +116 -0
- package/src/widgets/form/LabeledContainer.ts +81 -0
- package/src/widgets/form/LookupField.scss +5 -3
- package/src/widgets/form/LookupField.tsx +1326 -0
- package/src/widgets/form/MonthField.scss +4 -3
- package/src/widgets/form/MonthField.tsx +665 -0
- package/src/widgets/form/MonthPicker.scss +8 -5
- package/src/widgets/form/MonthPicker.tsx +822 -0
- package/src/widgets/form/NumberField.scss +5 -3
- package/src/widgets/form/NumberField.tsx +540 -0
- package/src/widgets/form/Radio.scss +5 -3
- package/src/widgets/form/Radio.tsx +245 -0
- package/src/widgets/form/Select.scss +6 -4
- package/src/widgets/form/Select.tsx +322 -0
- package/src/widgets/form/Slider.scss +6 -3
- package/src/widgets/form/Slider.tsx +461 -0
- package/src/widgets/form/Switch.scss +5 -3
- package/src/widgets/form/Switch.tsx +174 -0
- package/src/widgets/form/TextArea.scss +6 -4
- package/src/widgets/form/TextArea.tsx +229 -0
- package/src/widgets/form/TextField.scss +6 -4
- package/src/widgets/form/TextField.tsx +345 -0
- package/src/widgets/form/TimeField.ts +10 -0
- package/src/widgets/form/TimeList.tsx +94 -0
- package/src/widgets/form/UploadButton.scss +5 -3
- package/src/widgets/form/UploadButton.tsx +256 -0
- package/src/widgets/form/ValidationError.scss +4 -3
- package/src/widgets/form/ValidationError.tsx +72 -0
- package/src/widgets/form/ValidationGroup.spec.tsx +147 -0
- package/src/widgets/form/ValidationGroup.ts +141 -0
- package/src/widgets/form/Validator.ts +23 -0
- package/src/widgets/form/Wheel.scss +9 -7
- package/src/widgets/form/Wheel.tsx +315 -0
- package/src/widgets/form/variables.scss +3 -1
- package/src/widgets/grid/Grid.scss +6 -4
- package/src/widgets/grid/Grid.tsx +4247 -0
- package/src/widgets/grid/GridCell.ts +143 -0
- package/src/widgets/grid/GridCellEditor.tsx +52 -0
- package/src/widgets/grid/GridRow.ts +302 -0
- package/src/widgets/grid/GridRowLine.ts +49 -0
- package/src/widgets/grid/Pagination.scss +5 -3
- package/src/widgets/grid/Pagination.tsx +126 -0
- package/src/widgets/grid/TreeNode.scss +6 -4
- package/src/widgets/grid/TreeNode.tsx +145 -0
- package/src/widgets/grid/createGridCellEditor.tsx +18 -0
- package/src/widgets/grid/index.ts +17 -0
- package/src/widgets/grid/variables.scss +8 -4
- package/src/widgets/icons/calendar.tsx +17 -0
- package/src/widgets/icons/check.tsx +13 -0
- package/src/widgets/icons/clear.tsx +15 -0
- package/src/widgets/icons/close.tsx +20 -0
- package/src/widgets/icons/cx.tsx +38 -0
- package/src/widgets/icons/drop-down.tsx +15 -0
- package/src/widgets/icons/file.tsx +13 -0
- package/src/widgets/icons/folder-open.tsx +15 -0
- package/src/widgets/icons/folder.tsx +13 -0
- package/src/widgets/icons/forward.tsx +22 -0
- package/src/widgets/icons/loading.tsx +24 -0
- package/src/widgets/icons/menu.tsx +17 -0
- package/src/widgets/icons/pixel-picker.tsx +18 -0
- package/src/widgets/icons/registry.ts +57 -0
- package/src/widgets/icons/search.tsx +13 -0
- package/src/widgets/icons/sort-asc.tsx +14 -0
- package/src/widgets/icons/square.tsx +18 -0
- package/src/widgets/nav/Link.scss +5 -3
- package/src/widgets/nav/Link.ts +12 -0
- package/src/widgets/nav/LinkButton.ts +176 -0
- package/src/widgets/nav/Menu.scss +7 -5
- package/src/widgets/nav/Menu.tsx +489 -0
- package/src/widgets/nav/Menu.variables.scss +3 -1
- package/src/widgets/nav/MenuItem.scss +6 -4
- package/src/widgets/nav/MenuItem.tsx +523 -0
- package/src/widgets/nav/MenuSpacer.ts +19 -0
- package/src/widgets/nav/RedirectRoute.ts +50 -0
- package/src/widgets/nav/Route.spec.tsx +24 -0
- package/src/widgets/nav/Route.ts +142 -0
- package/src/widgets/nav/Scroller.scss +5 -3
- package/src/widgets/nav/Scroller.tsx +253 -0
- package/src/widgets/nav/Submenu.ts +6 -0
- package/src/widgets/nav/Tab.scss +5 -4
- package/src/widgets/nav/Tab.ts +120 -0
- package/src/widgets/nav/cover.scss +5 -4
- package/src/widgets/nav/variables.scss +3 -1
- package/src/widgets/overlay/ContextMenu.ts +42 -0
- package/src/widgets/overlay/Dropdown.scss +11 -9
- package/src/widgets/overlay/Dropdown.tsx +762 -0
- package/src/widgets/overlay/FlyweightTooltipTracker.ts +57 -0
- package/src/widgets/overlay/MsgBox.tsx +141 -0
- package/src/widgets/overlay/Overlay.scss +5 -3
- package/src/widgets/overlay/Overlay.tsx +942 -0
- package/src/widgets/overlay/Toast.scss +8 -7
- package/src/widgets/overlay/Toast.ts +111 -0
- package/src/widgets/overlay/Tooltip.scss +6 -4
- package/src/widgets/overlay/Tooltip.tsx +393 -0
- package/src/widgets/overlay/Window.scss +6 -4
- package/src/widgets/overlay/Window.tsx +299 -0
- package/src/widgets/overlay/alerts.ts +46 -0
- package/src/widgets/overlay/captureMouse.ts +195 -0
- package/src/widgets/overlay/createHotPromiseWindowFactory.ts +72 -0
- package/src/widgets/overlay/index.d.ts +11 -11
- package/src/widgets/overlay/index.ts +11 -0
- package/src/widgets/overlay/tooltip-ops.ts +173 -0
- package/src/widgets/overlay/variables.scss +3 -1
- package/src/widgets/variables.scss +3 -1
- package/tsconfig.compile.json +4 -0
- package/tsconfig.json +34 -0
- package/tsconfig.mocha.json +14 -0
- package/charts.d.ts +0 -1
- package/charts.js +0 -1
- package/data.d.ts +0 -1
- package/data.js +0 -1
- package/hooks.d.ts +0 -1
- package/hooks.js +0 -1
- package/index.js +0 -17
- package/locale/de-de.js +0 -75
- package/locale/en-us.js +0 -75
- package/locale/es-es.js +0 -75
- package/locale/fr-fr.js +0 -75
- package/locale/nl-nl.js +0 -75
- package/locale/pt-pt.js +0 -75
- package/locale/sr-latn-ba.js +0 -75
- package/manifest.js +0 -1
- package/src/charts/Bar.d.ts +0 -28
- package/src/charts/Bar.js +0 -90
- package/src/charts/BarGraph.d.ts +0 -15
- package/src/charts/BarGraph.js +0 -112
- package/src/charts/BubbleGraph.js +0 -93
- package/src/charts/Chart.d.ts +0 -12
- package/src/charts/Chart.js +0 -75
- package/src/charts/ColorMap.d.ts +0 -21
- package/src/charts/ColorMap.js +0 -97
- package/src/charts/Column.d.ts +0 -29
- package/src/charts/Column.js +0 -88
- package/src/charts/ColumnBarBase.d.ts +0 -64
- package/src/charts/ColumnBarBase.js +0 -176
- package/src/charts/ColumnBarGraphBase.d.ts +0 -73
- package/src/charts/ColumnBarGraphBase.js +0 -114
- package/src/charts/ColumnGraph.d.ts +0 -18
- package/src/charts/ColumnGraph.js +0 -120
- package/src/charts/Grid.js +0 -5
- package/src/charts/Gridlines.d.ts +0 -25
- package/src/charts/Gridlines.js +0 -49
- package/src/charts/Legend.d.ts +0 -45
- package/src/charts/Legend.js +0 -187
- package/src/charts/LegendEntry.d.ts +0 -54
- package/src/charts/LegendEntry.js +0 -128
- package/src/charts/LineGraph.d.ts +0 -101
- package/src/charts/LineGraph.js +0 -300
- package/src/charts/Marker.d.ts +0 -110
- package/src/charts/Marker.js +0 -311
- package/src/charts/MarkerLine.d.ts +0 -56
- package/src/charts/MarkerLine.js +0 -128
- package/src/charts/MouseTracker.d.ts +0 -17
- package/src/charts/MouseTracker.js +0 -81
- package/src/charts/Pie.js +0 -8
- package/src/charts/PieChart.d.ts +0 -92
- package/src/charts/PieChart.js +0 -530
- package/src/charts/PieLabel.d.ts +0 -26
- package/src/charts/PieLabel.js +0 -71
- package/src/charts/PieLabelsContainer.d.ts +0 -6
- package/src/charts/PieLabelsContainer.js +0 -55
- package/src/charts/Range.d.ts +0 -75
- package/src/charts/Range.js +0 -206
- package/src/charts/RangeMarker.d.ts +0 -35
- package/src/charts/RangeMarker.js +0 -159
- package/src/charts/ScatterGraph.d.ts +0 -64
- package/src/charts/ScatterGraph.js +0 -164
- package/src/charts/Swimlane.d.ts +0 -24
- package/src/charts/Swimlane.js +0 -140
- package/src/charts/Swimlanes.d.ts +0 -41
- package/src/charts/Swimlanes.js +0 -114
- package/src/charts/axis/Axis.d.ts +0 -113
- package/src/charts/axis/Axis.js +0 -288
- package/src/charts/axis/CategoryAxis.d.ts +0 -30
- package/src/charts/axis/CategoryAxis.js +0 -241
- package/src/charts/axis/NumericAxis.d.ts +0 -46
- package/src/charts/axis/NumericAxis.js +0 -351
- package/src/charts/axis/Stack.d.ts +0 -11
- package/src/charts/axis/Stack.js +0 -55
- package/src/charts/axis/TimeAxis.d.ts +0 -31
- package/src/charts/axis/TimeAxis.js +0 -611
- package/src/charts/axis/index.d.ts +0 -4
- package/src/charts/axis/index.js +0 -4
- package/src/charts/helpers/MinMaxFinder.d.ts +0 -22
- package/src/charts/helpers/MinMaxFinder.js +0 -36
- package/src/charts/helpers/PointReducer.d.ts +0 -24
- package/src/charts/helpers/PointReducer.js +0 -61
- package/src/charts/helpers/SnapPointFinder.d.ts +0 -30
- package/src/charts/helpers/SnapPointFinder.js +0 -69
- package/src/charts/helpers/ValueAtFinder.d.ts +0 -16
- package/src/charts/helpers/ValueAtFinder.js +0 -46
- package/src/charts/helpers/index.d.ts +0 -4
- package/src/charts/helpers/index.js +0 -4
- package/src/charts/index.d.ts +0 -27
- package/src/charts/shapes.d.ts +0 -23
- package/src/charts/shapes.js +0 -79
- package/src/data/AggregateFunction.d.ts +0 -20
- package/src/data/AggregateFunction.js +0 -145
- package/src/data/ArrayElementView.d.ts +0 -13
- package/src/data/ArrayElementView.js +0 -64
- package/src/data/ArrayElementView.spec.js +0 -88
- package/src/data/ArrayRef.d.ts +0 -15
- package/src/data/ArrayRef.js +0 -35
- package/src/data/AugmentedViewBase.d.ts +0 -18
- package/src/data/AugmentedViewBase.js +0 -77
- package/src/data/Binding.d.ts +0 -19
- package/src/data/Binding.js +0 -76
- package/src/data/ExposedRecordView.d.ts +0 -14
- package/src/data/ExposedRecordView.js +0 -75
- package/src/data/ExposedValueView.d.ts +0 -19
- package/src/data/ExposedValueView.js +0 -73
- package/src/data/Expression.d.ts +0 -17
- package/src/data/Expression.js +0 -229
- package/src/data/Expression.spec.js +0 -229
- package/src/data/Grouper.d.ts +0 -21
- package/src/data/Grouper.js +0 -144
- package/src/data/NestedDataView.d.ts +0 -19
- package/src/data/NestedDataView.js +0 -22
- package/src/data/ReadOnlyDataView.d.ts +0 -14
- package/src/data/ReadOnlyDataView.js +0 -27
- package/src/data/Ref.d.ts +0 -24
- package/src/data/Ref.js +0 -79
- package/src/data/Ref.spec.js +0 -79
- package/src/data/Store.d.ts +0 -14
- package/src/data/Store.js +0 -46
- package/src/data/Store.spec.js +0 -22
- package/src/data/StoreProxy.d.ts +0 -5
- package/src/data/StoreProxy.js +0 -17
- package/src/data/StoreRef.js +0 -54
- package/src/data/StoreRef.spec.js +0 -24
- package/src/data/StringTemplate.d.ts +0 -15
- package/src/data/StringTemplate.js +0 -92
- package/src/data/StringTemplate.spec.js +0 -132
- package/src/data/StructuredDataAccessor.d.ts +0 -7
- package/src/data/StructuredSelector.d.ts +0 -17
- package/src/data/StructuredSelector.js +0 -132
- package/src/data/StructuredSelector.spec.js +0 -113
- package/src/data/SubscribableView.d.ts +0 -11
- package/src/data/SubscribableView.js +0 -54
- package/src/data/View.d.ts +0 -155
- package/src/data/View.js +0 -182
- package/src/data/ZoomIntoPropertyView.d.ts +0 -11
- package/src/data/ZoomIntoPropertyView.js +0 -33
- package/src/data/ZoomIntoPropertyView.spec.js +0 -65
- package/src/data/comparer.d.ts +0 -7
- package/src/data/comparer.js +0 -54
- package/src/data/computable.d.ts +0 -125
- package/src/data/computable.js +0 -56
- package/src/data/computable.spec.js +0 -55
- package/src/data/createAccessorModelProxy.d.ts +0 -6
- package/src/data/createAccessorModelProxy.js +0 -43
- package/src/data/createStructuredSelector.d.ts +0 -3
- package/src/data/createStructuredSelector.js +0 -43
- package/src/data/createStructuredSelector.spec.js +0 -46
- package/src/data/defaultCompare.d.ts +0 -1
- package/src/data/defaultCompare.js +0 -15
- package/src/data/diff/diffArrays.d.ts +0 -15
- package/src/data/diff/diffArrays.js +0 -41
- package/src/data/diff/diffs.spec.js +0 -49
- package/src/data/diff/index.d.ts +0 -1
- package/src/data/diff/index.js +0 -1
- package/src/data/enableFatArrowExpansion.d.ts +0 -1
- package/src/data/enableFatArrowExpansion.js +0 -6
- package/src/data/getAccessor.d.ts +0 -9
- package/src/data/getAccessor.js +0 -61
- package/src/data/getAccessor.spec.js +0 -11
- package/src/data/getSelector.d.ts +0 -3
- package/src/data/getSelector.js +0 -49
- package/src/data/getSelector.spec.js +0 -43
- package/src/data/index.d.ts +0 -30
- package/src/data/index.js +0 -29
- package/src/data/isSelector.d.ts +0 -1
- package/src/data/isSelector.js +0 -26
- package/src/data/ops/append.d.ts +0 -1
- package/src/data/ops/append.js +0 -7
- package/src/data/ops/append.spec.js +0 -28
- package/src/data/ops/filter.d.ts +0 -1
- package/src/data/ops/filter.js +0 -8
- package/src/data/ops/filter.spec.js +0 -29
- package/src/data/ops/findTreeNode.d.ts +0 -1
- package/src/data/ops/findTreeNode.js +0 -15
- package/src/data/ops/findTreeNode.spec.js +0 -24
- package/src/data/ops/findTreePath.d.ts +0 -6
- package/src/data/ops/findTreePath.js +0 -16
- package/src/data/ops/index.d.ts +0 -10
- package/src/data/ops/insertElement.d.ts +0 -1
- package/src/data/ops/insertElement.js +0 -3
- package/src/data/ops/merge.d.ts +0 -3
- package/src/data/ops/merge.js +0 -9
- package/src/data/ops/merge.spec.js +0 -27
- package/src/data/ops/moveElement.d.ts +0 -1
- package/src/data/ops/moveElement.js +0 -14
- package/src/data/ops/removeTreeNodes.d.ts +0 -5
- package/src/data/ops/removeTreeNodes.js +0 -5
- package/src/data/ops/removeTreeNodes.spec.js +0 -28
- package/src/data/ops/updateArray.d.ts +0 -6
- package/src/data/ops/updateArray.js +0 -24
- package/src/data/ops/updateArray.spec.js +0 -38
- package/src/data/ops/updateTree.d.ts +0 -7
- package/src/data/ops/updateTree.js +0 -25
- package/src/data/ops/updateTree.spec.js +0 -36
- package/src/hooks/createLocalStorageRef.d.ts +0 -3
- package/src/hooks/createLocalStorageRef.js +0 -20
- package/src/hooks/index.js +0 -8
- package/src/hooks/invokeCallback.d.ts +0 -5
- package/src/hooks/invokeCallback.js +0 -7
- package/src/hooks/invokeCallback.spec.js +0 -53
- package/src/hooks/resolveCallback.d.ts +0 -3
- package/src/hooks/resolveCallback.js +0 -12
- package/src/hooks/resolveCallback.spec.js +0 -54
- package/src/hooks/store.d.ts +0 -8
- package/src/hooks/store.js +0 -32
- package/src/hooks/store.spec.js +0 -73
- package/src/hooks/useEffect.d.ts +0 -3
- package/src/hooks/useEffect.js +0 -15
- package/src/hooks/useInterval.d.ts +0 -1
- package/src/hooks/useInterval.js +0 -8
- package/src/hooks/useState.d.ts +0 -3
- package/src/hooks/useState.js +0 -16
- package/src/hooks/useTrigger.d.ts +0 -5
- package/src/hooks/useTrigger.js +0 -20
- package/src/hooks/useTrigger.spec.js +0 -102
- package/src/svg/BoundedObject.d.ts +0 -23
- package/src/svg/BoundedObject.js +0 -59
- package/src/svg/ClipRect.d.ts +0 -5
- package/src/svg/ClipRect.js +0 -23
- package/src/svg/Ellipse.d.ts +0 -24
- package/src/svg/Ellipse.js +0 -37
- package/src/svg/Line.d.ts +0 -21
- package/src/svg/Line.js +0 -33
- package/src/svg/NonOverlappingRect.d.ts +0 -5
- package/src/svg/NonOverlappingRect.js +0 -15
- package/src/svg/NonOverlappingRectGroup.d.ts +0 -3
- package/src/svg/NonOverlappingRectGroup.js +0 -37
- package/src/svg/Rectangle.d.ts +0 -37
- package/src/svg/Rectangle.js +0 -42
- package/src/svg/Svg.d.ts +0 -32
- package/src/svg/Svg.js +0 -177
- package/src/svg/Text.d.ts +0 -40
- package/src/svg/Text.js +0 -78
- package/src/svg/TextualBoundedObject.d.ts +0 -7
- package/src/svg/TextualBoundedObject.js +0 -28
- package/src/svg/index.d.ts +0 -11
- package/src/svg/util/Rect.d.ts +0 -41
- package/src/svg/util/Rect.js +0 -109
- package/src/svg/util/index.js +0 -1
- package/src/ui/CSS.d.ts +0 -20
- package/src/ui/CSS.js +0 -79
- package/src/ui/CSSHelper.d.ts +0 -11
- package/src/ui/CSSHelper.js +0 -18
- package/src/ui/Container.d.ts +0 -18
- package/src/ui/Container.js +0 -154
- package/src/ui/ContentResolver.d.ts +0 -12
- package/src/ui/ContentResolver.js +0 -78
- package/src/ui/Controller.d.ts +0 -182
- package/src/ui/Controller.js +0 -114
- package/src/ui/Controller.spec.js +0 -415
- package/src/ui/Culture.d.ts +0 -57
- package/src/ui/Culture.js +0 -139
- package/src/ui/Cx.d.ts +0 -18
- package/src/ui/Cx.js +0 -325
- package/src/ui/Cx.spec.js +0 -194
- package/src/ui/DataProxy.d.ts +0 -12
- package/src/ui/DataProxy.js +0 -31
- package/src/ui/DataProxy.spec.js +0 -338
- package/src/ui/DetachedScope.d.ts +0 -21
- package/src/ui/DetachedScope.js +0 -98
- package/src/ui/FocusManager.d.ts +0 -29
- package/src/ui/FocusManager.js +0 -171
- package/src/ui/Format.d.ts +0 -3
- package/src/ui/Format.js +0 -108
- package/src/ui/HoverSync.d.ts +0 -13
- package/src/ui/HoverSync.js +0 -147
- package/src/ui/Instance.d.ts +0 -72
- package/src/ui/Instance.js +0 -620
- package/src/ui/IsolatedScope.d.ts +0 -16
- package/src/ui/IsolatedScope.js +0 -30
- package/src/ui/IsolatedScope.spec.js +0 -62
- package/src/ui/Localization.d.ts +0 -17
- package/src/ui/Localization.js +0 -70
- package/src/ui/PureContainer.d.ts +0 -16
- package/src/ui/PureContainer.js +0 -7
- package/src/ui/RenderingContext.d.ts +0 -9
- package/src/ui/RenderingContext.js +0 -88
- package/src/ui/Repeater.d.ts +0 -61
- package/src/ui/Repeater.js +0 -109
- package/src/ui/Repeater.spec.js +0 -143
- package/src/ui/Rescope.d.ts +0 -10
- package/src/ui/Rescope.js +0 -35
- package/src/ui/Rescope.spec.js +0 -195
- package/src/ui/ResizeManager.d.ts +0 -10
- package/src/ui/ResizeManager.js +0 -31
- package/src/ui/Restate.d.ts +0 -21
- package/src/ui/Restate.js +0 -167
- package/src/ui/Restate.spec.js +0 -422
- package/src/ui/StaticText.d.ts +0 -8
- package/src/ui/StaticText.js +0 -9
- package/src/ui/StructuredInstanceDataAccessor.d.ts +0 -16
- package/src/ui/StructuredInstanceDataAccessor.js +0 -26
- package/src/ui/Text.d.ts +0 -10
- package/src/ui/Text.js +0 -25
- package/src/ui/VDOM.d.ts +0 -12
- package/src/ui/VDOM.js +0 -2
- package/src/ui/Widget.d.ts +0 -14
- package/src/ui/Widget.js +0 -184
- package/src/ui/ZIndexManager.d.ts +0 -7
- package/src/ui/ZIndexManager.js +0 -11
- package/src/ui/adapter/ArrayAdapter.d.ts +0 -17
- package/src/ui/adapter/ArrayAdapter.js +0 -152
- package/src/ui/adapter/ArrayAdapter.spec.js +0 -55
- package/src/ui/adapter/DataAdapter.d.ts +0 -31
- package/src/ui/adapter/DataAdapter.js +0 -15
- package/src/ui/adapter/GroupAdapter.d.ts +0 -23
- package/src/ui/adapter/GroupAdapter.js +0 -143
- package/src/ui/adapter/TreeAdapter.d.ts +0 -24
- package/src/ui/adapter/TreeAdapter.js +0 -101
- package/src/ui/adapter/TreeAdapter.spec.js +0 -67
- package/src/ui/adapter/index.js +0 -4
- package/src/ui/app/History.d.ts +0 -17
- package/src/ui/app/History.js +0 -114
- package/src/ui/app/Url.d.ts +0 -21
- package/src/ui/app/Url.js +0 -103
- package/src/ui/app/Url.spec.js +0 -51
- package/src/ui/app/index.d.ts +0 -4
- package/src/ui/app/startAppLoop.d.ts +0 -4
- package/src/ui/app/startAppLoop.js +0 -58
- package/src/ui/app/startHotAppLoop.d.ts +0 -7
- package/src/ui/app/startHotAppLoop.js +0 -25
- package/src/ui/batchUpdates.d.ts +0 -11
- package/src/ui/batchUpdates.js +0 -67
- package/src/ui/bind.d.ts +0 -4
- package/src/ui/bind.js +0 -7
- package/src/ui/createFunctionalComponent.d.ts +0 -1
- package/src/ui/createFunctionalComponent.js +0 -63
- package/src/ui/createFunctionalComponent.spec.js +0 -400
- package/src/ui/expr.d.ts +0 -24
- package/src/ui/expr.js +0 -17
- package/src/ui/flattenProps.js +0 -21
- package/src/ui/index.d.ts +0 -42
- package/src/ui/index.js +0 -44
- package/src/ui/keyboardShortcuts.d.ts +0 -5
- package/src/ui/keyboardShortcuts.js +0 -31
- package/src/ui/layout/Content.d.ts +0 -14
- package/src/ui/layout/Content.js +0 -16
- package/src/ui/layout/ContentPlaceholder.d.ts +0 -19
- package/src/ui/layout/ContentPlaceholder.js +0 -105
- package/src/ui/layout/ContentPlaceholder.spec.js +0 -579
- package/src/ui/layout/FirstVisibleChildLayout.d.ts +0 -4
- package/src/ui/layout/FirstVisibleChildLayout.js +0 -66
- package/src/ui/layout/FirstVisibleChildLayout.spec.js +0 -196
- package/src/ui/layout/LabelsLeftLayout.d.ts +0 -11
- package/src/ui/layout/LabelsLeftLayout.js +0 -59
- package/src/ui/layout/LabelsTopLayout.d.ts +0 -15
- package/src/ui/layout/LabelsTopLayout.js +0 -135
- package/src/ui/layout/UseParentLayout.d.ts +0 -4
- package/src/ui/layout/UseParentLayout.js +0 -6
- package/src/ui/layout/exploreChildren.d.ts +0 -12
- package/src/ui/layout/exploreChildren.js +0 -27
- package/src/ui/layout/index.js +0 -10
- package/src/ui/selection/KeySelection.d.ts +0 -17
- package/src/ui/selection/KeySelection.js +0 -129
- package/src/ui/selection/PropertySelection.d.ts +0 -17
- package/src/ui/selection/PropertySelection.js +0 -55
- package/src/ui/selection/Selection.d.ts +0 -27
- package/src/ui/selection/Selection.js +0 -93
- package/src/ui/selection/index.js +0 -3
- package/src/ui/tpl.d.ts +0 -3
- package/src/ui/tpl.js +0 -5
- package/src/util/Component.d.ts +0 -42
- package/src/util/Component.js +0 -108
- package/src/util/Console.d.ts +0 -4
- package/src/util/Console.js +0 -11
- package/src/util/DOM.d.ts +0 -33
- package/src/util/DOM.js +0 -72
- package/src/util/Debug.d.ts +0 -11
- package/src/util/Debug.js +0 -45
- package/src/util/Format.d.ts +0 -18
- package/src/util/Format.js +0 -270
- package/src/util/Format.spec.js +0 -69
- package/src/util/GlobalCacheIdentifier.js +0 -11
- package/src/util/GlobalCacheldentifier.d.ts +0 -7
- package/src/util/KeyCode.d.ts +0 -21
- package/src/util/KeyCode.js +0 -21
- package/src/util/SubscriberList.d.ts +0 -42
- package/src/util/SubscriberList.js +0 -58
- package/src/util/Timing.d.ts +0 -14
- package/src/util/Timing.js +0 -58
- package/src/util/TraversalStack.js +0 -43
- package/src/util/TraversalStack.spec.js +0 -47
- package/src/util/addEventListenerWithOptions.d.ts +0 -6
- package/src/util/addEventListenerWithOptions.js +0 -9
- package/src/util/browserSupportsPassiveEventHandlers.d.ts +0 -5
- package/src/util/browserSupportsPassiveEventHandlers.js +0 -18
- package/src/util/calculateNaturalElementHeight.d.ts +0 -1
- package/src/util/calculateNaturalElementHeight.js +0 -22
- package/src/util/capitalize.d.ts +0 -1
- package/src/util/capitalize.js +0 -4
- package/src/util/coalesce.d.ts +0 -1
- package/src/util/coalesce.js +0 -6
- package/src/util/color/hslToRgb.d.ts +0 -9
- package/src/util/color/hslToRgb.js +0 -27
- package/src/util/color/index.d.ts +0 -4
- package/src/util/color/parseColor.d.ts +0 -60
- package/src/util/color/parseColor.js +0 -119
- package/src/util/color/rgbToHex.d.ts +0 -9
- package/src/util/color/rgbToHex.js +0 -8
- package/src/util/color/rgbToHsl.d.ts +0 -9
- package/src/util/color/rgbToHsl.js +0 -28
- package/src/util/date/dateDiff.d.ts +0 -8
- package/src/util/date/dateDiff.js +0 -3
- package/src/util/date/diff.d.ts +0 -8
- package/src/util/date/diff.js +0 -7
- package/src/util/date/encodeDate.d.ts +0 -1
- package/src/util/date/encodeDate.js +0 -8
- package/src/util/date/encodeDateWithTimezoneOffset.d.ts +0 -1
- package/src/util/date/encodeDateWithTimezoneOffset.js +0 -19
- package/src/util/date/index.js +0 -11
- package/src/util/date/lowerBoundCheck.d.ts +0 -8
- package/src/util/date/lowerBoundCheck.js +0 -6
- package/src/util/date/maxDate.d.ts +0 -6
- package/src/util/date/maxDate.js +0 -9
- package/src/util/date/minDate.d.ts +0 -6
- package/src/util/date/minDate.js +0 -9
- package/src/util/date/monthStart.d.ts +0 -6
- package/src/util/date/monthStart.js +0 -3
- package/src/util/date/parseDateInvariant.d.ts +0 -3
- package/src/util/date/parseDateInvariant.js +0 -20
- package/src/util/date/sameDate.d.ts +0 -7
- package/src/util/date/sameDate.js +0 -5
- package/src/util/date/upperBoundCheck.d.ts +0 -8
- package/src/util/date/upperBoundCheck.js +0 -6
- package/src/util/date/zeroTime.d.ts +0 -7
- package/src/util/date/zeroTime.js +0 -3
- package/src/util/debounce.d.ts +0 -9
- package/src/util/debounce.js +0 -18
- package/src/util/dummyCallback.d.ts +0 -1
- package/src/util/dummyCallback.js +0 -1
- package/src/util/escapeSpecialRegexCharacters.d.ts +0 -7
- package/src/util/escapeSpecialRegexCharacters.js +0 -3
- package/src/util/eventCallbacks.d.ts +0 -5
- package/src/util/eventCallbacks.js +0 -2
- package/src/util/expandFatArrows.d.ts +0 -1
- package/src/util/expandFatArrows.js +0 -118
- package/src/util/findScrollableParent.d.ts +0 -1
- package/src/util/findScrollableParent.js +0 -16
- package/src/util/getActiveElement.d.ts +0 -1
- package/src/util/getActiveElement.js +0 -4
- package/src/util/getParentFrameBoundingClientRect.d.ts +0 -1
- package/src/util/getParentFrameBoundingClientRect.js +0 -21
- package/src/util/getScrollerBoundingClientRect.d.ts +0 -1
- package/src/util/getScrollerBoundingClientRect.js +0 -22
- package/src/util/getSearchQueryPredicate.d.ts +0 -1
- package/src/util/getSearchQueryPredicate.js +0 -59
- package/src/util/getTopLevelBoundingClientRect.d.ts +0 -1
- package/src/util/getTopLevelBoundingClientRect.js +0 -14
- package/src/util/getVendorPrefix.d.ts +0 -1
- package/src/util/getVendorPrefix.js +0 -26
- package/src/util/index.d.ts +0 -51
- package/src/util/index.js +0 -54
- package/src/util/innerTextTrim.d.ts +0 -7
- package/src/util/innerTextTrim.js +0 -5
- package/src/util/isArray.d.ts +0 -1
- package/src/util/isArray.js +0 -3
- package/src/util/isDefined.d.ts +0 -1
- package/src/util/isDefined.js +0 -3
- package/src/util/isDigit.d.ts +0 -7
- package/src/util/isDigit.js +0 -3
- package/src/util/isFunction.d.ts +0 -1
- package/src/util/isFunction.js +0 -3
- package/src/util/isNonEmptyArray.d.ts +0 -1
- package/src/util/isNonEmptyArray.js +0 -3
- package/src/util/isNumber.d.ts +0 -1
- package/src/util/isNumber.js +0 -3
- package/src/util/isObject.d.ts +0 -1
- package/src/util/isObject.js +0 -3
- package/src/util/isPromise.d.ts +0 -1
- package/src/util/isPromise.js +0 -6
- package/src/util/isString.d.ts +0 -1
- package/src/util/isString.js +0 -3
- package/src/util/isTextInputElement.d.ts +0 -1
- package/src/util/isTextInputElement.js +0 -3
- package/src/util/isTouchDevice.d.ts +0 -2
- package/src/util/isTouchDevice.js +0 -7
- package/src/util/isTouchEvent.d.ts +0 -4
- package/src/util/isTouchEvent.js +0 -64
- package/src/util/isUndefined.d.ts +0 -1
- package/src/util/isUndefined.js +0 -3
- package/src/util/isValidIdentifierName.d.ts +0 -1
- package/src/util/isValidIdentifierName.js +0 -5
- package/src/util/onIdleCallback.d.ts +0 -1
- package/src/util/onIdleCallback.js +0 -14
- package/src/util/parseStyle.d.ts +0 -4
- package/src/util/parseStyle.js +0 -27
- package/src/util/quote.d.ts +0 -3
- package/src/util/quote.js +0 -4
- package/src/util/reverseSlice.d.ts +0 -1
- package/src/util/reverseSlice.js +0 -10
- package/src/util/routeAppend.d.ts +0 -1
- package/src/util/routeAppend.js +0 -16
- package/src/util/scrollElementIntoView.d.ts +0 -7
- package/src/util/scrollElementIntoView.js +0 -34
- package/src/util/shallowEquals.d.ts +0 -1
- package/src/util/shallowEquals.js +0 -43
- package/src/util/throttle.d.ts +0 -9
- package/src/util/throttle.js +0 -14
- package/src/util/validatedDebounce.js +0 -19
- package/src/widgets/Button.d.ts +0 -58
- package/src/widgets/Button.js +0 -118
- package/src/widgets/CxCredit.d.ts +0 -12
- package/src/widgets/CxCredit.js +0 -32
- package/src/widgets/DocumentTitle.d.ts +0 -11
- package/src/widgets/DocumentTitle.js +0 -69
- package/src/widgets/FlexBox.d.ts +0 -69
- package/src/widgets/FlexBox.js +0 -93
- package/src/widgets/Heading.d.ts +0 -16
- package/src/widgets/Heading.js +0 -33
- package/src/widgets/HighlightedSearchText.d.ts +0 -9
- package/src/widgets/HighlightedSearchText.js +0 -36
- package/src/widgets/HtmlElement.d.ts +0 -30
- package/src/widgets/HtmlElement.js +0 -275
- package/src/widgets/HtmlElement.spec.js +0 -57
- package/src/widgets/Icon.d.ts +0 -34
- package/src/widgets/Icon.js +0 -50
- package/src/widgets/List.d.ts +0 -96
- package/src/widgets/List.js +0 -594
- package/src/widgets/ProgressBar.d.ts +0 -17
- package/src/widgets/ProgressBar.js +0 -46
- package/src/widgets/Resizer.d.ts +0 -27
- package/src/widgets/Resizer.js +0 -151
- package/src/widgets/Sandbox.d.ts +0 -18
- package/src/widgets/Sandbox.js +0 -65
- package/src/widgets/Section.d.ts +0 -52
- package/src/widgets/Section.js +0 -139
- package/src/widgets/autoFocus.d.ts +0 -1
- package/src/widgets/autoFocus.js +0 -9
- package/src/widgets/cx.d.ts +0 -2
- package/src/widgets/cx.js +0 -72
- package/src/widgets/drag-drop/DragHandle.d.ts +0 -10
- package/src/widgets/drag-drop/DragHandle.js +0 -37
- package/src/widgets/drag-drop/DragSource.d.ts +0 -45
- package/src/widgets/drag-drop/DragSource.js +0 -160
- package/src/widgets/drag-drop/DropZone.d.ts +0 -98
- package/src/widgets/drag-drop/DropZone.js +0 -214
- package/src/widgets/drag-drop/index.js +0 -4
- package/src/widgets/drag-drop/ops.d.ts +0 -57
- package/src/widgets/drag-drop/ops.js +0 -344
- package/src/widgets/enableAllInternalDependencies.d.ts +0 -1
- package/src/widgets/enableAllInternalDependencies.js +0 -11
- package/src/widgets/form/Calendar.d.ts +0 -86
- package/src/widgets/form/Calendar.js +0 -618
- package/src/widgets/form/Checkbox.d.ts +0 -43
- package/src/widgets/form/Checkbox.js +0 -203
- package/src/widgets/form/ColorField.d.ts +0 -44
- package/src/widgets/form/ColorField.js +0 -397
- package/src/widgets/form/ColorPicker.d.ts +0 -23
- package/src/widgets/form/ColorPicker.js +0 -485
- package/src/widgets/form/DateField.d.ts +0 -6
- package/src/widgets/form/DateField.js +0 -12
- package/src/widgets/form/DateTimeField.d.ts +0 -89
- package/src/widgets/form/DateTimeField.js +0 -576
- package/src/widgets/form/DateTimePicker.js +0 -392
- package/src/widgets/form/Field.d.ts +0 -112
- package/src/widgets/form/Field.js +0 -446
- package/src/widgets/form/FieldGroup.d.ts +0 -6
- package/src/widgets/form/FieldGroup.js +0 -6
- package/src/widgets/form/FieldIcon.js +0 -42
- package/src/widgets/form/HelpText.d.ts +0 -10
- package/src/widgets/form/HelpText.js +0 -9
- package/src/widgets/form/Label.d.ts +0 -23
- package/src/widgets/form/Label.js +0 -89
- package/src/widgets/form/LabeledContainer.d.ts +0 -9
- package/src/widgets/form/LabeledContainer.js +0 -59
- package/src/widgets/form/LookupField.d.ts +0 -179
- package/src/widgets/form/LookupField.js +0 -1135
- package/src/widgets/form/MonthField.d.ts +0 -104
- package/src/widgets/form/MonthField.js +0 -524
- package/src/widgets/form/MonthPicker.d.ts +0 -97
- package/src/widgets/form/MonthPicker.js +0 -687
- package/src/widgets/form/NumberField.d.ts +0 -96
- package/src/widgets/form/NumberField.js +0 -459
- package/src/widgets/form/Radio.d.ts +0 -37
- package/src/widgets/form/Radio.js +0 -188
- package/src/widgets/form/Select.d.ts +0 -69
- package/src/widgets/form/Select.js +0 -269
- package/src/widgets/form/Slider.d.ts +0 -65
- package/src/widgets/form/Slider.js +0 -351
- package/src/widgets/form/Switch.d.ts +0 -38
- package/src/widgets/form/Switch.js +0 -118
- package/src/widgets/form/TextArea.d.ts +0 -17
- package/src/widgets/form/TextArea.js +0 -195
- package/src/widgets/form/TextField.d.ts +0 -78
- package/src/widgets/form/TextField.js +0 -290
- package/src/widgets/form/TimeField.d.ts +0 -6
- package/src/widgets/form/TimeField.js +0 -11
- package/src/widgets/form/TimeList.js +0 -84
- package/src/widgets/form/UploadButton.d.ts +0 -34
- package/src/widgets/form/UploadButton.js +0 -213
- package/src/widgets/form/ValidationError.d.ts +0 -10
- package/src/widgets/form/ValidationError.js +0 -44
- package/src/widgets/form/ValidationGroup.d.ts +0 -41
- package/src/widgets/form/ValidationGroup.js +0 -68
- package/src/widgets/form/ValidationGroup.spec.js +0 -148
- package/src/widgets/form/Validator.d.ts +0 -8
- package/src/widgets/form/Validator.js +0 -21
- package/src/widgets/form/Wheel.js +0 -261
- package/src/widgets/form/index.d.ts +0 -26
- package/src/widgets/grid/Grid.d.ts +0 -445
- package/src/widgets/grid/Grid.js +0 -3431
- package/src/widgets/grid/GridCell.d.ts +0 -38
- package/src/widgets/grid/GridCell.js +0 -71
- package/src/widgets/grid/GridCellEditor.js +0 -41
- package/src/widgets/grid/GridRow.js +0 -228
- package/src/widgets/grid/GridRowLine.js +0 -24
- package/src/widgets/grid/Pagination.d.ts +0 -14
- package/src/widgets/grid/Pagination.js +0 -95
- package/src/widgets/grid/TreeNode.d.ts +0 -23
- package/src/widgets/grid/TreeNode.js +0 -102
- package/src/widgets/grid/index.d.ts +0 -4
- package/src/widgets/grid/index.js +0 -15
- package/src/widgets/icons/calendar.js +0 -16
- package/src/widgets/icons/check.js +0 -12
- package/src/widgets/icons/clear.js +0 -14
- package/src/widgets/icons/close.js +0 -19
- package/src/widgets/icons/cx.js +0 -37
- package/src/widgets/icons/drop-down.js +0 -14
- package/src/widgets/icons/file.js +0 -12
- package/src/widgets/icons/folder-open.js +0 -14
- package/src/widgets/icons/folder.js +0 -12
- package/src/widgets/icons/forward.js +0 -21
- package/src/widgets/icons/loading.js +0 -23
- package/src/widgets/icons/menu.js +0 -16
- package/src/widgets/icons/pixel-picker.js +0 -17
- package/src/widgets/icons/registry.js +0 -54
- package/src/widgets/icons/search.js +0 -12
- package/src/widgets/icons/sort-asc.js +0 -13
- package/src/widgets/icons/square.js +0 -17
- package/src/widgets/nav/Link.d.ts +0 -26
- package/src/widgets/nav/Link.js +0 -8
- package/src/widgets/nav/LinkButton.d.ts +0 -34
- package/src/widgets/nav/LinkButton.js +0 -128
- package/src/widgets/nav/Menu.d.ts +0 -27
- package/src/widgets/nav/Menu.js +0 -406
- package/src/widgets/nav/MenuItem.d.ts +0 -31
- package/src/widgets/nav/MenuItem.js +0 -445
- package/src/widgets/nav/MenuSpacer.d.ts +0 -5
- package/src/widgets/nav/MenuSpacer.js +0 -13
- package/src/widgets/nav/RedirectRoute.d.ts +0 -9
- package/src/widgets/nav/RedirectRoute.js +0 -41
- package/src/widgets/nav/Route.d.ts +0 -21
- package/src/widgets/nav/Route.js +0 -102
- package/src/widgets/nav/Route.spec.js +0 -27
- package/src/widgets/nav/Scroller.d.ts +0 -17
- package/src/widgets/nav/Scroller.js +0 -214
- package/src/widgets/nav/Submenu.d.ts +0 -6
- package/src/widgets/nav/Submenu.js +0 -6
- package/src/widgets/nav/Tab.d.ts +0 -33
- package/src/widgets/nav/Tab.js +0 -82
- package/src/widgets/nav/index.js +0 -10
- package/src/widgets/overlay/ContextMenu.d.ts +0 -10
- package/src/widgets/overlay/ContextMenu.js +0 -29
- package/src/widgets/overlay/Dropdown.d.ts +0 -32
- package/src/widgets/overlay/Dropdown.js +0 -612
- package/src/widgets/overlay/FlyweightTooltipTracker.d.ts +0 -8
- package/src/widgets/overlay/FlyweightTooltipTracker.js +0 -39
- package/src/widgets/overlay/MsgBox.d.ts +0 -17
- package/src/widgets/overlay/MsgBox.js +0 -116
- package/src/widgets/overlay/Overlay.d.ts +0 -73
- package/src/widgets/overlay/Overlay.js +0 -747
- package/src/widgets/overlay/Toast.d.ts +0 -30
- package/src/widgets/overlay/Toast.js +0 -93
- package/src/widgets/overlay/Tooltip.d.ts +0 -50
- package/src/widgets/overlay/Tooltip.js +0 -308
- package/src/widgets/overlay/Window.d.ts +0 -42
- package/src/widgets/overlay/Window.js +0 -202
- package/src/widgets/overlay/alerts.d.ts +0 -7
- package/src/widgets/overlay/alerts.js +0 -39
- package/src/widgets/overlay/captureMouse.d.ts +0 -54
- package/src/widgets/overlay/captureMouse.js +0 -124
- package/src/widgets/overlay/createHotPromiseWindowFactory.d.ts +0 -18
- package/src/widgets/overlay/createHotPromiseWindowFactory.js +0 -56
- package/src/widgets/overlay/index.js +0 -11
- package/src/widgets/overlay/tooltip-ops.d.ts +0 -11
- package/src/widgets/overlay/tooltip-ops.js +0 -29
- package/svg.d.ts +0 -1
- package/svg.js +0 -1
- package/ui.d.ts +0 -1
- package/ui.js +0 -1
- package/util.d.ts +0 -1
- package/util.js +0 -1
- package/widgets.d.ts +0 -1
- package/widgets.js +0 -1
- /package/src/charts/{index.js → index.ts} +0 -0
- /package/src/data/{Binding.spec.js → Binding.spec.ts} +0 -0
- /package/src/data/{Grouper.spec.js → Grouper.spec.ts} +0 -0
- /package/src/data/{View.spec.js → View.spec.ts} +0 -0
- /package/src/data/{comparer.spec.js → comparer.spec.ts} +0 -0
- /package/src/data/ops/{index.js → index.ts} +0 -0
- /package/src/hooks/{index.d.ts → index.ts} +0 -0
- /package/src/{index.js → index.ts} +0 -0
- /package/src/svg/{index.js → index.ts} +0 -0
- /package/src/svg/util/{index.d.ts → index.ts} +0 -0
- /package/src/ui/adapter/{index.d.ts → index.ts} +0 -0
- /package/src/ui/app/{index.js → index.ts} +0 -0
- /package/src/ui/layout/{index.d.ts → index.ts} +0 -0
- /package/src/ui/selection/{index.d.ts → index.ts} +0 -0
- /package/src/util/color/{index.js → index.ts} +0 -0
- /package/src/util/date/{index.d.ts → index.ts} +0 -0
- /package/src/util/date/{upperBoundCheck.spec.js → upperBoundCheck.spec.ts} +0 -0
- /package/src/util/{getSearchQueryPredicate.spec.js → getSearchQueryPredicate.spec.ts} +0 -0
- /package/src/util/{isValidIdentifierName.spec.js → isValidIdentifierName.spec.ts} +0 -0
- /package/src/util/{routeAppend.spec.js → routeAppend.spec.ts} +0 -0
- /package/src/widgets/drag-drop/{index.d.ts → index.ts} +0 -0
- /package/src/widgets/form/{index.js → index.ts} +0 -0
- /package/src/widgets/icons/{index.js → index.ts} +0 -0
- /package/src/widgets/{index.js → index.ts} +0 -0
- /package/src/widgets/nav/{index.d.ts → index.ts} +0 -0
package/src/widgets/grid/Grid.js
DELETED
|
@@ -1,3431 +0,0 @@
|
|
|
1
|
-
import { Widget, VDOM, getContent } from "../../ui/Widget";
|
|
2
|
-
import { PureContainer } from "../../ui/PureContainer";
|
|
3
|
-
import { getSelector } from "../../data/getSelector";
|
|
4
|
-
import { isSelector } from "../../data/isSelector";
|
|
5
|
-
import { Format } from "../../ui/Format";
|
|
6
|
-
import { Selection } from "../../ui/selection/Selection";
|
|
7
|
-
import { DataAdapter } from "../../ui/adapter/DataAdapter";
|
|
8
|
-
import { GroupAdapter } from "../../ui/adapter/GroupAdapter";
|
|
9
|
-
import { ResizeManager } from "../../ui/ResizeManager";
|
|
10
|
-
import { KeyCode } from "../../util/KeyCode";
|
|
11
|
-
import { scrollElementIntoView } from "../../util/scrollElementIntoView";
|
|
12
|
-
import { findScrollableParent } from "../../util/findScrollableParent";
|
|
13
|
-
import { FocusManager, oneFocusOut, offFocusOut } from "../../ui/FocusManager";
|
|
14
|
-
import DropDownIcon from "../icons/sort-asc";
|
|
15
|
-
import { ddMouseDown, ddDetect, initiateDragDrop, registerDropZone } from "../drag-drop/ops";
|
|
16
|
-
import { GridRow, GridRowComponent } from "./GridRow";
|
|
17
|
-
import { Localization } from "../../ui/Localization";
|
|
18
|
-
import { SubscriberList } from "../../util/SubscriberList";
|
|
19
|
-
import { RenderingContext } from "../../ui/RenderingContext";
|
|
20
|
-
import { isNonEmptyArray } from "../../util/isNonEmptyArray";
|
|
21
|
-
import { isObject } from "../../util/isObject";
|
|
22
|
-
import { isString } from "../../util/isString";
|
|
23
|
-
import { isDefined } from "../../util/isDefined";
|
|
24
|
-
import { isArray } from "../../util/isArray";
|
|
25
|
-
import { isNumber } from "../../util/isNumber";
|
|
26
|
-
import { debounce } from "../../util/debounce";
|
|
27
|
-
import { shallowEquals } from "../../util/shallowEquals";
|
|
28
|
-
import { InstanceCache } from "../../ui/Instance";
|
|
29
|
-
import { Cx } from "../../ui/Cx";
|
|
30
|
-
import { Console } from "../../util/Console";
|
|
31
|
-
import { getTopLevelBoundingClientRect } from "../../util/getTopLevelBoundingClientRect";
|
|
32
|
-
import { getParentFrameBoundingClientRect } from "../../util/getParentFrameBoundingClientRect";
|
|
33
|
-
import { ValidationGroup } from "../form/ValidationGroup";
|
|
34
|
-
import { closest } from "../../util/DOM";
|
|
35
|
-
import { captureMouse2, getCursorPos } from "../overlay/captureMouse";
|
|
36
|
-
import { getAccessor } from "../../data/getAccessor";
|
|
37
|
-
import { getActiveElement } from "../../util/getActiveElement";
|
|
38
|
-
import { GridCellEditor } from "./GridCellEditor";
|
|
39
|
-
import { batchUpdates } from "../../ui/batchUpdates";
|
|
40
|
-
import { parseStyle } from "cx/src/util/parseStyle";
|
|
41
|
-
import { StaticText } from "../../ui/StaticText";
|
|
42
|
-
import { unfocusElement } from "../../ui/FocusManager";
|
|
43
|
-
import { tooltipMouseMove, tooltipMouseLeave } from "../overlay/tooltip-ops";
|
|
44
|
-
import { Container } from "../../ui/Container";
|
|
45
|
-
import { findFirstChild } from "../../util/DOM";
|
|
46
|
-
import { Binding } from "../../data/Binding";
|
|
47
|
-
|
|
48
|
-
export class Grid extends Container {
|
|
49
|
-
declareData(...args) {
|
|
50
|
-
let selection = this.selection.configureWidget(this);
|
|
51
|
-
|
|
52
|
-
super.declareData(
|
|
53
|
-
...args,
|
|
54
|
-
{
|
|
55
|
-
records: undefined,
|
|
56
|
-
sorters: undefined,
|
|
57
|
-
preSorters: undefined,
|
|
58
|
-
scrollable: undefined,
|
|
59
|
-
sortField: undefined,
|
|
60
|
-
sortDirection: undefined,
|
|
61
|
-
emptyText: undefined,
|
|
62
|
-
dragSource: { structured: true },
|
|
63
|
-
dropZone: { structured: true },
|
|
64
|
-
filterParams: { structured: true },
|
|
65
|
-
groupingParams: { structured: true },
|
|
66
|
-
scrollResetParams: { structured: true },
|
|
67
|
-
page: undefined,
|
|
68
|
-
totalRecordCount: undefined,
|
|
69
|
-
tabIndex: undefined,
|
|
70
|
-
columnParams: { structured: true },
|
|
71
|
-
},
|
|
72
|
-
selection,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
init() {
|
|
77
|
-
if (this.recordAlias) this.recordName = this.recordAlias;
|
|
78
|
-
|
|
79
|
-
if (this.indexAlias) this.indexName = this.indexAlias;
|
|
80
|
-
|
|
81
|
-
if (this.infinite) {
|
|
82
|
-
this.buffered = true;
|
|
83
|
-
this.remoteSort = true;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (this.buffered) this.scrollable = true;
|
|
87
|
-
|
|
88
|
-
this.recordsAccessor = getAccessor(this.records);
|
|
89
|
-
|
|
90
|
-
this.selection = Selection.create(this.selection, {
|
|
91
|
-
records: this.records,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
if (!this.selection.isDummy || this.onRowClick || this.onRowDoubleClick) this.selectable = true;
|
|
95
|
-
if (this.focusable == null) this.focusable = !this.selection.isDummy || this.cellEditable;
|
|
96
|
-
|
|
97
|
-
super.init();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
initState(context, instance) {
|
|
101
|
-
instance.state = {
|
|
102
|
-
colWidth: {},
|
|
103
|
-
lockedColWidth: {},
|
|
104
|
-
dimensionsVersion: 0,
|
|
105
|
-
disableDefaultSort: false,
|
|
106
|
-
};
|
|
107
|
-
instance.v = 0;
|
|
108
|
-
if (this.infinite)
|
|
109
|
-
instance.buffer = {
|
|
110
|
-
records: [],
|
|
111
|
-
totalRecordCount: 0,
|
|
112
|
-
page: 1,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
applyParentStore(instance) {
|
|
117
|
-
super.applyParentStore(instance);
|
|
118
|
-
|
|
119
|
-
// force prepareData to execute again and propagate the store change to the records
|
|
120
|
-
if (instance.cached) delete instance.cached.rawData;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
createRowTemplate(context, columnParams, instance, groupingData) {
|
|
124
|
-
var row = this.row || {};
|
|
125
|
-
let columns = this.columns;
|
|
126
|
-
if (this.onGetColumns) {
|
|
127
|
-
let result = instance.invoke("onGetColumns", columnParams, instance);
|
|
128
|
-
if (isArray(result)) columns = result;
|
|
129
|
-
else row = result;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (columns)
|
|
133
|
-
row.line1 = {
|
|
134
|
-
columns,
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
row.hasSortableColumns = false;
|
|
138
|
-
row.hasResizableColumns = false;
|
|
139
|
-
row.hasMergedCells = false;
|
|
140
|
-
row.mergedColumns = [];
|
|
141
|
-
|
|
142
|
-
let aggregates = {};
|
|
143
|
-
let showFooter = false;
|
|
144
|
-
let lines = [];
|
|
145
|
-
for (let i = 0; i < 10; i++) {
|
|
146
|
-
let l = row["line" + i];
|
|
147
|
-
if (l) {
|
|
148
|
-
if (isArray(l.columns))
|
|
149
|
-
for (let c = 0; c < l.columns.length; c++)
|
|
150
|
-
l.columns[c].uniqueColumnId = `l${i}-${l.columns[c].key || c}`;
|
|
151
|
-
lines.push(l);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
row.header = PureContainer.create({
|
|
156
|
-
items: GridColumnHeaderLine.create(lines),
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
row.header.items.forEach((line) => {
|
|
160
|
-
line.items.forEach((c, index) => {
|
|
161
|
-
if (c.sortable) row.hasSortableColumns = true;
|
|
162
|
-
|
|
163
|
-
if (c.mergeCells) {
|
|
164
|
-
if (row.header.items.length > 1)
|
|
165
|
-
Console.warn("Merged columns are only supported in grids in which rows have only one line of cells.");
|
|
166
|
-
else {
|
|
167
|
-
row.hasMergedCells = true;
|
|
168
|
-
row.mergedColumns.push({ uniqueColumnId: c.uniqueColumnId, index, mode: c.mergeCells });
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
c.resizable ||
|
|
174
|
-
(c.header && c.header.resizable) ||
|
|
175
|
-
(c.header1 && c.header1.resizable) ||
|
|
176
|
-
(c.header2 && c.header2.resizable) ||
|
|
177
|
-
(c.header3 && c.header3.resizable)
|
|
178
|
-
)
|
|
179
|
-
row.hasResizableColumns = true;
|
|
180
|
-
|
|
181
|
-
if (c.aggregate && c.aggregateAlias && (c.aggregateField || isDefined(c.aggregateValue))) {
|
|
182
|
-
aggregates[c.aggregateAlias] = {
|
|
183
|
-
value: isDefined(c.aggregateValue)
|
|
184
|
-
? c.aggregateValue
|
|
185
|
-
: isDefined(c.value)
|
|
186
|
-
? c.value
|
|
187
|
-
: c.aggregateField
|
|
188
|
-
? { bind: this.recordName + "." + c.aggregateField }
|
|
189
|
-
: null,
|
|
190
|
-
weight:
|
|
191
|
-
c.weight != null
|
|
192
|
-
? c.weight
|
|
193
|
-
: c.weightField && {
|
|
194
|
-
bind: this.recordName + "." + c.weightField,
|
|
195
|
-
},
|
|
196
|
-
type: c.aggregate,
|
|
197
|
-
};
|
|
198
|
-
} else if (c.footer && !showFooter) {
|
|
199
|
-
showFooter = true;
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
//add default footer if some columns have aggregates and grouping is not defined
|
|
205
|
-
if (!groupingData && (Object.keys(aggregates).length > 0 || this.fixedFooter || showFooter))
|
|
206
|
-
groupingData = [
|
|
207
|
-
{
|
|
208
|
-
key: {},
|
|
209
|
-
showFooter: true,
|
|
210
|
-
},
|
|
211
|
-
];
|
|
212
|
-
|
|
213
|
-
let { grouping, showHeader } = this.resolveGrouping(groupingData);
|
|
214
|
-
|
|
215
|
-
this.showHeader = showHeader;
|
|
216
|
-
|
|
217
|
-
if (this.fixedFooter && isNonEmptyArray(grouping)) {
|
|
218
|
-
grouping[0].showFooter = true;
|
|
219
|
-
if (grouping[0].key && Object.keys(grouping[0].key).length > 0)
|
|
220
|
-
Console.warn(
|
|
221
|
-
"First grouping level in grids with a fixed footer must group all data. The key field should be omitted.",
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
instance.dataAdapter = DataAdapter.create(
|
|
226
|
-
{
|
|
227
|
-
type: (this.dataAdapter && this.dataAdapter.type) || GroupAdapter,
|
|
228
|
-
recordsAccessor: this.recordsAccessor,
|
|
229
|
-
keyField: this.keyField,
|
|
230
|
-
aggregates: aggregates,
|
|
231
|
-
recordName: this.recordName,
|
|
232
|
-
indexName: this.indexName,
|
|
233
|
-
sortOptions: this.sortOptions,
|
|
234
|
-
groupings: grouping,
|
|
235
|
-
preserveOrder: this.preserveGroupOrder,
|
|
236
|
-
},
|
|
237
|
-
this.dataAdapter,
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
instance.dataAdapter.initInstance(context, instance);
|
|
241
|
-
|
|
242
|
-
return Widget.create(GridRow, {
|
|
243
|
-
class: this.CSS.element(this.baseClass, "data"),
|
|
244
|
-
className: this.rowClass,
|
|
245
|
-
style: this.rowStyle,
|
|
246
|
-
recordName: this.recordName,
|
|
247
|
-
hoverId: this.rowHoverId,
|
|
248
|
-
...row,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
prepareData(context, instance) {
|
|
253
|
-
let { data, state, cached, row } = instance;
|
|
254
|
-
|
|
255
|
-
let grouping = this.grouping;
|
|
256
|
-
|
|
257
|
-
if (this.onGetGrouping) {
|
|
258
|
-
if (!cached.data || cached.data.groupingParams !== data.groupingParams)
|
|
259
|
-
grouping = instance.invoke("onGetGrouping", data.groupingParams, instance);
|
|
260
|
-
else grouping = cached.grouping;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
let groupingChanged = instance.cache("grouping", grouping);
|
|
264
|
-
|
|
265
|
-
if (instance.cache("columnParams", data.columnParams) || groupingChanged || !row) {
|
|
266
|
-
row = instance.row = this.createRowTemplate(context, data.columnParams, instance, grouping);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
data.version = ++instance.v;
|
|
270
|
-
|
|
271
|
-
if (!this.infinite) data.totalRecordCount = isArray(data.records) ? data.records.length : 0;
|
|
272
|
-
else {
|
|
273
|
-
if (isNumber(data.totalRecordCount)) instance.buffer.totalRecordCount = data.totalRecordCount;
|
|
274
|
-
else data.totalRecordCount = instance.buffer.totalRecordCount;
|
|
275
|
-
|
|
276
|
-
if (isDefined(data.records)) instance.buffer.records = data.records;
|
|
277
|
-
else data.records = instance.buffer.records;
|
|
278
|
-
|
|
279
|
-
if (isNumber(data.page)) instance.buffer.page = data.page;
|
|
280
|
-
else data.page = instance.buffer.page;
|
|
281
|
-
|
|
282
|
-
data.offset = (data.page - 1) * this.pageSize;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (!isArray(data.records)) data.records = [];
|
|
286
|
-
|
|
287
|
-
if (state.sorters && !isDefined(this.sorters)) data.sorters = state.sorters;
|
|
288
|
-
|
|
289
|
-
let sortField = null;
|
|
290
|
-
|
|
291
|
-
if (isDefined(this.sortField) && isDefined(this.sortDirection)) {
|
|
292
|
-
let sorter = {
|
|
293
|
-
field: data.sortField,
|
|
294
|
-
direction: data.sortDirection,
|
|
295
|
-
};
|
|
296
|
-
sortField = data.sortField;
|
|
297
|
-
data.sorters = [sorter];
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
let skipDefaultSorting = this.clearableSort && instance.state.disableDefaultSort;
|
|
301
|
-
if (!skipDefaultSorting && !isNonEmptyArray(data.sorters) && this.defaultSortField) {
|
|
302
|
-
let sorter = {
|
|
303
|
-
field: this.defaultSortField,
|
|
304
|
-
direction: this.defaultSortDirection || "ASC",
|
|
305
|
-
};
|
|
306
|
-
sortField = this.defaultSortField;
|
|
307
|
-
data.sorters = [sorter];
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (sortField) {
|
|
311
|
-
for (let l = 1; l < 10; l++) {
|
|
312
|
-
let line = instance.row[`line${l}`];
|
|
313
|
-
let sortColumn = line && line.columns && line.columns.find((c) => c.field == sortField);
|
|
314
|
-
if (sortColumn) {
|
|
315
|
-
data.sorters[0].value = sortColumn.sortValue || sortColumn.value;
|
|
316
|
-
data.sorters[0].comparer = sortColumn.comparer;
|
|
317
|
-
data.sorters[0].sortOptions = sortColumn.sortOptions;
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
let headerMode = this.headerMode;
|
|
324
|
-
|
|
325
|
-
if (this.headerMode == null) {
|
|
326
|
-
if (this.scrollable || row.hasSortableColumns || row.hasResizableColumns) headerMode = "default";
|
|
327
|
-
else headerMode = "plain";
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
let border = this.border;
|
|
331
|
-
|
|
332
|
-
if (this.showBorder || (border == null && this.scrollable)) border = true;
|
|
333
|
-
|
|
334
|
-
let dragMode = false;
|
|
335
|
-
if (data.dragSource) dragMode = data.dragSource.mode || "move";
|
|
336
|
-
|
|
337
|
-
let dropMode = data.dropZone && data.dropZone.mode;
|
|
338
|
-
|
|
339
|
-
if (this.onDrop && !dropMode) dropMode = "preview";
|
|
340
|
-
|
|
341
|
-
data.dropMode = dropMode;
|
|
342
|
-
|
|
343
|
-
data.stateMods = {
|
|
344
|
-
selectable: this.selectable,
|
|
345
|
-
"cell-editable": this.cellEditable,
|
|
346
|
-
scrollable: data.scrollable,
|
|
347
|
-
buffered: this.buffered,
|
|
348
|
-
["header-" + headerMode]: true,
|
|
349
|
-
border: border,
|
|
350
|
-
vlines: this.vlines,
|
|
351
|
-
["drag-" + dragMode]: dragMode,
|
|
352
|
-
["drop-" + dropMode]: dropMode,
|
|
353
|
-
resizable: row.hasResizableColumns,
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
super.prepareData(context, instance);
|
|
357
|
-
|
|
358
|
-
instance.records = this.mapRecords(context, instance);
|
|
359
|
-
|
|
360
|
-
//tree adapters can have additional (child) records, filtering also affects actual record count
|
|
361
|
-
if (instance.records && !this.infinite) {
|
|
362
|
-
//apply record count after filtering
|
|
363
|
-
data.totalRecordCount = instance.records.length;
|
|
364
|
-
|
|
365
|
-
//recheck if there are any actual records
|
|
366
|
-
//when grouping is enabled group header/footer are always in
|
|
367
|
-
if (instance.records.length < 5) {
|
|
368
|
-
data.empty = true;
|
|
369
|
-
for (let i = 0; i < instance.records.length; i++)
|
|
370
|
-
if (instance.records[i].type == "data") {
|
|
371
|
-
data.empty = false;
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
} else data.empty = data.totalRecordCount == 0;
|
|
375
|
-
} else data.empty = data.totalRecordCount == 0;
|
|
376
|
-
|
|
377
|
-
if (this.onCreateIsRecordSelectable) {
|
|
378
|
-
instance.isRecordSelectable = instance.invoke("onCreateIsRecordSelectable", null, instance);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (this.onCreateIsRecordDraggable) {
|
|
382
|
-
instance.isRecordDraggable = instance.invoke("onCreateIsRecordDraggable", null, instance);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (this.onTrackMappedRecords) {
|
|
386
|
-
instance.invoke("onTrackMappedRecords", instance.records, instance);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
initInstance(context, instance) {
|
|
391
|
-
instance.fixedHeaderResizeEvent = new SubscriberList();
|
|
392
|
-
super.initInstance(context, instance);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
explore(context, instance) {
|
|
396
|
-
context.push("parentPositionChangeEvent", instance.fixedHeaderResizeEvent);
|
|
397
|
-
|
|
398
|
-
instance.hoverSync = context.hoverSync;
|
|
399
|
-
|
|
400
|
-
super.explore(context, instance);
|
|
401
|
-
|
|
402
|
-
instance.header = instance.getChild(context, instance.row.header, "header");
|
|
403
|
-
instance.header.scheduleExploreIfVisible(context);
|
|
404
|
-
|
|
405
|
-
let { store } = instance;
|
|
406
|
-
instance.isSelected = this.selection.getIsSelectedDelegate(store);
|
|
407
|
-
|
|
408
|
-
//do not process rows in buffered mode or cached mode if nothing has changed;
|
|
409
|
-
if (!this.buffered && (!this.cached || instance.shouldUpdate)) {
|
|
410
|
-
for (let i = 0; i < instance.records.length; i++) {
|
|
411
|
-
let record = instance.records[i];
|
|
412
|
-
if (record.type == "data") {
|
|
413
|
-
let row = (record.row = instance.getChild(context, instance.row, record.key, record.store));
|
|
414
|
-
row.selected = instance.isSelected(record.data, record.index);
|
|
415
|
-
let changed = false;
|
|
416
|
-
if (row.cache("selected", row.selected)) changed = true;
|
|
417
|
-
if (row.cache("recordData", record.data)) changed = true;
|
|
418
|
-
if (this.cached && !changed && !row.childStateDirty) row.shouldUpdate = false;
|
|
419
|
-
else row.scheduleExploreIfVisible(context);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
exploreCleanup(context, instance) {
|
|
426
|
-
context.pop("parentPositionChangeEvent");
|
|
427
|
-
let fixedColumnCount = 0,
|
|
428
|
-
visibleColumns = [];
|
|
429
|
-
instance.header.children.forEach((line) => {
|
|
430
|
-
line.children.forEach((col) => {
|
|
431
|
-
if (col.data.fixed) fixedColumnCount++;
|
|
432
|
-
visibleColumns.push(col.widget);
|
|
433
|
-
});
|
|
434
|
-
});
|
|
435
|
-
instance.visibleColumns = visibleColumns;
|
|
436
|
-
instance.hasFixedColumns = fixedColumnCount > 0;
|
|
437
|
-
instance.fixedColumnCount = fixedColumnCount;
|
|
438
|
-
if (fixedColumnCount > 0) {
|
|
439
|
-
instance.data.classNames += ` ${instance.widget.CSS.state("fixed-columns")}`;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
resolveGrouping(grouping) {
|
|
444
|
-
if (grouping) {
|
|
445
|
-
if (!isArray(grouping)) {
|
|
446
|
-
if (isString(grouping) || isObject(grouping)) grouping = [grouping];
|
|
447
|
-
else throw new Error("Dynamic grouping should be an array of grouping objects.");
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
grouping = grouping.map((g, i) => {
|
|
451
|
-
let group;
|
|
452
|
-
if (isString(g))
|
|
453
|
-
group = {
|
|
454
|
-
key: {
|
|
455
|
-
[g]: {
|
|
456
|
-
bind: this.recordName + "." + g,
|
|
457
|
-
},
|
|
458
|
-
},
|
|
459
|
-
showHeader: !this.scrollable && i == grouping.length - 1,
|
|
460
|
-
showFooter: true,
|
|
461
|
-
caption: { bind: `$group.${g}` },
|
|
462
|
-
text: { bind: `${this.recordName}.${g}` },
|
|
463
|
-
};
|
|
464
|
-
else
|
|
465
|
-
group = {
|
|
466
|
-
...g,
|
|
467
|
-
};
|
|
468
|
-
if (group.caption) group.caption = getSelector(group.caption);
|
|
469
|
-
return group;
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
let showHeader = !isArray(grouping) || !grouping.some((g) => g.showHeader);
|
|
474
|
-
|
|
475
|
-
return { showHeader, grouping };
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
groupBy(groupingData, options) {
|
|
479
|
-
let { grouping, showHeader } = this.resolveGrouping(groupingData);
|
|
480
|
-
this.grouping = grouping;
|
|
481
|
-
if (options?.autoConfigure) this.showHeader = showHeader;
|
|
482
|
-
this.update();
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
render(context, instance, key) {
|
|
486
|
-
let { data, hasFixedColumns } = instance;
|
|
487
|
-
|
|
488
|
-
let fixedHeader =
|
|
489
|
-
data.scrollable && this.showHeader && this.renderHeader(context, instance, "header", true, false);
|
|
490
|
-
|
|
491
|
-
let fixedColumnsFixedHeader =
|
|
492
|
-
data.scrollable &&
|
|
493
|
-
this.showHeader &&
|
|
494
|
-
hasFixedColumns &&
|
|
495
|
-
this.renderHeader(context, instance, "header", true, true);
|
|
496
|
-
|
|
497
|
-
if (!this.buffered) this.renderRows(context, instance);
|
|
498
|
-
|
|
499
|
-
if (this.fixedFooter) this.renderFixedFooter(context, instance);
|
|
500
|
-
|
|
501
|
-
let header = this.showHeader && this.renderHeader(context, instance, "header", false, false);
|
|
502
|
-
|
|
503
|
-
let fixedColumnsHeader =
|
|
504
|
-
this.showHeader && hasFixedColumns && this.renderHeader(context, instance, "header", false, true);
|
|
505
|
-
|
|
506
|
-
return (
|
|
507
|
-
<GridComponent
|
|
508
|
-
key={key}
|
|
509
|
-
instance={instance}
|
|
510
|
-
data={instance.data}
|
|
511
|
-
shouldUpdate={instance.shouldUpdate}
|
|
512
|
-
header={header}
|
|
513
|
-
fixedColumnsHeader={fixedColumnsHeader}
|
|
514
|
-
fixedColumnsFixedHeader={fixedColumnsFixedHeader}
|
|
515
|
-
fixedHeader={fixedHeader}
|
|
516
|
-
fixedFooter={instance.fixedFooterVDOM}
|
|
517
|
-
fixedColumnsFixedFooter={instance.fixedColumnsFixedFooterVDOM}
|
|
518
|
-
>
|
|
519
|
-
{this.renderChildren(context, instance)}
|
|
520
|
-
</GridComponent>
|
|
521
|
-
);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
renderResizer(instance, hdinst, header, colIndex, forPreviousColumn) {
|
|
525
|
-
let { widget } = instance;
|
|
526
|
-
|
|
527
|
-
let { CSS, baseClass } = widget;
|
|
528
|
-
|
|
529
|
-
let hdwidget = hdinst.widget;
|
|
530
|
-
|
|
531
|
-
let resizerClassName = "col-resizer";
|
|
532
|
-
if (forPreviousColumn) resizerClassName += "-prev-col";
|
|
533
|
-
|
|
534
|
-
return (
|
|
535
|
-
<div
|
|
536
|
-
className={CSS.element(baseClass, resizerClassName)}
|
|
537
|
-
onClick={(e) => {
|
|
538
|
-
e.stopPropagation();
|
|
539
|
-
}}
|
|
540
|
-
data-unique-col-id={hdwidget.uniqueColumnId}
|
|
541
|
-
onMouseDown={(e) => {
|
|
542
|
-
if (e.buttons != 1) return;
|
|
543
|
-
let resizeOverlayEl = document.createElement("div");
|
|
544
|
-
|
|
545
|
-
let gridEl =
|
|
546
|
-
e.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
|
|
547
|
-
let uniqueColId = e.currentTarget.dataset.uniqueColId;
|
|
548
|
-
|
|
549
|
-
// if we use fixed columns, rhs resizer of the last fixed column is within regular columns header tbody
|
|
550
|
-
let headerCell = findFirstChild(
|
|
551
|
-
gridEl,
|
|
552
|
-
(el) => el.tagName == "TH" && el.dataset && el.dataset.uniqueColId == uniqueColId,
|
|
553
|
-
);
|
|
554
|
-
|
|
555
|
-
let initialWidth = headerCell.offsetWidth;
|
|
556
|
-
let initialPosition = getCursorPos(e);
|
|
557
|
-
resizeOverlayEl.className = CSS.element(baseClass, "resize-overlay");
|
|
558
|
-
resizeOverlayEl.style.width = `${initialWidth}px`;
|
|
559
|
-
resizeOverlayEl.style.left = `${
|
|
560
|
-
headerCell.getBoundingClientRect().left - gridEl.getBoundingClientRect().left
|
|
561
|
-
}px`;
|
|
562
|
-
gridEl.appendChild(resizeOverlayEl);
|
|
563
|
-
captureMouse2(e, {
|
|
564
|
-
onMouseMove: (e) => {
|
|
565
|
-
let cursor = getCursorPos(e);
|
|
566
|
-
let width = Math.max(30, Math.round(initialWidth + cursor.clientX - initialPosition.clientX));
|
|
567
|
-
resizeOverlayEl.style.width = `${width}px`;
|
|
568
|
-
},
|
|
569
|
-
onMouseUp: (e) => {
|
|
570
|
-
if (!resizeOverlayEl) return; //dblclick
|
|
571
|
-
let width = resizeOverlayEl.offsetWidth;
|
|
572
|
-
hdinst.assignedWidth = width;
|
|
573
|
-
gridEl.removeChild(resizeOverlayEl);
|
|
574
|
-
resizeOverlayEl = null;
|
|
575
|
-
if (widget.onColumnResize) instance.invoke("onColumnResize", { width, column: hdwidget }, hdinst);
|
|
576
|
-
header.set("width", width);
|
|
577
|
-
instance.setState({
|
|
578
|
-
dimensionsVersion: instance.state.dimensionsVersion + 1,
|
|
579
|
-
colWidth: {
|
|
580
|
-
...instance.state.colWidth,
|
|
581
|
-
[hdwidget.uniqueColumnId]: width,
|
|
582
|
-
},
|
|
583
|
-
});
|
|
584
|
-
},
|
|
585
|
-
onDblClick: () => {
|
|
586
|
-
let table = gridEl.querySelector("table");
|
|
587
|
-
let parentEl = table.parentElement;
|
|
588
|
-
let tableClone = table.cloneNode(true);
|
|
589
|
-
tableClone.childNodes.forEach((tbody) => {
|
|
590
|
-
tbody.childNodes.forEach((tr) => {
|
|
591
|
-
tr.childNodes.forEach((td, index) => {
|
|
592
|
-
if (index == colIndex) {
|
|
593
|
-
td.style.maxWidth = null;
|
|
594
|
-
td.style.minWidth = null;
|
|
595
|
-
td.style.width = "auto";
|
|
596
|
-
} else {
|
|
597
|
-
td.style.display = "none";
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
});
|
|
601
|
-
});
|
|
602
|
-
tableClone.style.position = "absolute";
|
|
603
|
-
tableClone.style.visibility = "hidden";
|
|
604
|
-
tableClone.style.top = 0;
|
|
605
|
-
tableClone.style.left = 0;
|
|
606
|
-
tableClone.style.width = "auto";
|
|
607
|
-
parentEl.appendChild(tableClone);
|
|
608
|
-
let width = tableClone.offsetWidth;
|
|
609
|
-
parentEl.removeChild(tableClone);
|
|
610
|
-
header.set("width", width);
|
|
611
|
-
instance.setState({
|
|
612
|
-
dimensionsVersion: instance.state.dimensionsVersion + 1,
|
|
613
|
-
colWidth: {
|
|
614
|
-
...instance.state.colWidth,
|
|
615
|
-
[hdwidget.uniqueColumnId]: width,
|
|
616
|
-
},
|
|
617
|
-
});
|
|
618
|
-
},
|
|
619
|
-
});
|
|
620
|
-
}}
|
|
621
|
-
/>
|
|
622
|
-
);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
renderHeader(context, instance, key, fixed, fixedColumns) {
|
|
626
|
-
let { data, widget, header } = instance;
|
|
627
|
-
|
|
628
|
-
let { CSS, baseClass } = widget;
|
|
629
|
-
|
|
630
|
-
let headerRows = [];
|
|
631
|
-
|
|
632
|
-
if (!header) return null;
|
|
633
|
-
|
|
634
|
-
let skip = {};
|
|
635
|
-
let lineIndex = 0;
|
|
636
|
-
|
|
637
|
-
header.children.forEach((line) => {
|
|
638
|
-
let empty = [true, true, true];
|
|
639
|
-
let result = [[], [], []];
|
|
640
|
-
|
|
641
|
-
line.children.forEach((hdinst, colIndex) => {
|
|
642
|
-
let hdwidget = hdinst.widget;
|
|
643
|
-
for (let l = 0; l < 3; l++) {
|
|
644
|
-
let colKey = `${lineIndex + l}-${colIndex}`;
|
|
645
|
-
|
|
646
|
-
if (skip[colKey]) continue;
|
|
647
|
-
|
|
648
|
-
if (Boolean(hdinst.data.fixed) != fixedColumns) continue;
|
|
649
|
-
|
|
650
|
-
let header = hdinst.components[`header${l + 1}`];
|
|
651
|
-
let colSpan,
|
|
652
|
-
rowSpan,
|
|
653
|
-
style,
|
|
654
|
-
cls,
|
|
655
|
-
mods = [],
|
|
656
|
-
content,
|
|
657
|
-
sortIcon,
|
|
658
|
-
tool;
|
|
659
|
-
|
|
660
|
-
let resizer = null,
|
|
661
|
-
prevColumnResizer = null;
|
|
662
|
-
|
|
663
|
-
if (header) {
|
|
664
|
-
empty[l] = false;
|
|
665
|
-
|
|
666
|
-
if (header.widget.align) mods.push("aligned-" + header.widget.align);
|
|
667
|
-
else if (hdwidget.align) mods.push("aligned-" + hdwidget.align);
|
|
668
|
-
|
|
669
|
-
if (hdwidget.sortable && header.widget.allowSorting) {
|
|
670
|
-
mods.push("sortable");
|
|
671
|
-
if (data.sorters && data.sorters[0].field == (hdwidget.sortField || hdwidget.field)) {
|
|
672
|
-
mods.push("sorted-" + data.sorters[0].direction.toLowerCase());
|
|
673
|
-
sortIcon = <DropDownIcon className={CSS.element(baseClass, "column-sort-icon")} />;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
let uniqueColumnId = header.data.colSpan > 1 ? null : hdwidget.uniqueColumnId;
|
|
678
|
-
|
|
679
|
-
style = header.data.style;
|
|
680
|
-
let customWidth =
|
|
681
|
-
header.data.width ||
|
|
682
|
-
instance.state.colWidth[uniqueColumnId] ||
|
|
683
|
-
header.data.defaultWidth ||
|
|
684
|
-
instance.state.lockedColWidth[uniqueColumnId];
|
|
685
|
-
if (customWidth) {
|
|
686
|
-
if (instance.state.colWidth[uniqueColumnId] != customWidth)
|
|
687
|
-
instance.state.colWidth[uniqueColumnId] = customWidth;
|
|
688
|
-
let s = `${customWidth}px`;
|
|
689
|
-
style = {
|
|
690
|
-
...style,
|
|
691
|
-
width: s,
|
|
692
|
-
minWidth: s,
|
|
693
|
-
maxWidth: s,
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
if (header.data.classNames) cls = header.data.classNames;
|
|
698
|
-
|
|
699
|
-
content = header.render(context);
|
|
700
|
-
|
|
701
|
-
if (header.components && header.components.tool) {
|
|
702
|
-
tool = (
|
|
703
|
-
<div className={CSS.element(baseClass, "col-header-tool")}>
|
|
704
|
-
{getContent(header.components.tool.render(context))}
|
|
705
|
-
</div>
|
|
706
|
-
);
|
|
707
|
-
mods.push("tool");
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
if (header.data.colSpan > 1 || header.data.rowSpan > 1) {
|
|
711
|
-
colSpan = header.data.colSpan;
|
|
712
|
-
rowSpan = header.data.rowSpan;
|
|
713
|
-
|
|
714
|
-
for (let r = 0; r < header.data.rowSpan; r++)
|
|
715
|
-
for (let c = 0; c < header.data.colSpan; c++)
|
|
716
|
-
skip[`${lineIndex + l + r}-${colIndex + c}`] = true;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
if ((hdwidget.resizable || header.data.resizable) && header.data.colSpan < 2) {
|
|
720
|
-
resizer = this.renderResizer(instance, hdinst, header, colIndex);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
if (colIndex > 0) {
|
|
724
|
-
let hdinstPrev = line.children[colIndex - 1];
|
|
725
|
-
let prevLine = 3;
|
|
726
|
-
let headerPrev;
|
|
727
|
-
while (!headerPrev && prevLine >= 0) {
|
|
728
|
-
headerPrev = hdinstPrev.components[`header${prevLine + 1}`];
|
|
729
|
-
prevLine--;
|
|
730
|
-
}
|
|
731
|
-
if (
|
|
732
|
-
(hdinstPrev.widget.resizable || headerPrev?.data?.resizable) &&
|
|
733
|
-
headerPrev?.data?.colSpan < 2
|
|
734
|
-
) {
|
|
735
|
-
prevColumnResizer = this.renderResizer(instance, hdinstPrev, headerPrev, colIndex - 1, true);
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
cls = CSS.element(baseClass, "col-header", mods) + (cls ? " " + cls : "");
|
|
741
|
-
|
|
742
|
-
let onContextMenu;
|
|
743
|
-
|
|
744
|
-
if (this.onColumnContextMenu) onContextMenu = (e) => instance.invoke("onColumnContextMenu", e, hdinst);
|
|
745
|
-
|
|
746
|
-
result[l].push(
|
|
747
|
-
<th
|
|
748
|
-
key={colIndex}
|
|
749
|
-
colSpan={colSpan}
|
|
750
|
-
rowSpan={rowSpan}
|
|
751
|
-
className={cls}
|
|
752
|
-
style={style}
|
|
753
|
-
onMouseDown={ddMouseDown}
|
|
754
|
-
onMouseMove={(e) => this.onHeaderMouseMove(e, hdwidget, hdinst, instance, l)}
|
|
755
|
-
onMouseLeave={(e) => this.onHeaderMouseLeave(e, hdinst, l)}
|
|
756
|
-
onClick={(e) => this.onHeaderClick(e, hdwidget, instance, l)}
|
|
757
|
-
onContextMenu={onContextMenu}
|
|
758
|
-
data-unique-col-id={colSpan > 1 ? null : hdwidget.uniqueColumnId}
|
|
759
|
-
>
|
|
760
|
-
{getContent(content)}
|
|
761
|
-
{sortIcon}
|
|
762
|
-
{tool}
|
|
763
|
-
{prevColumnResizer}
|
|
764
|
-
{resizer}
|
|
765
|
-
</th>,
|
|
766
|
-
);
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
result = result.filter((_, i) => !empty[i]);
|
|
771
|
-
lineIndex += result.length;
|
|
772
|
-
|
|
773
|
-
if (result[0]) {
|
|
774
|
-
if (fixed && !fixedColumns) {
|
|
775
|
-
result[0].push(
|
|
776
|
-
<th key="dummy" rowSpan={result.length} className={CSS.element(baseClass, "col-header")} />,
|
|
777
|
-
);
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
headerRows.push(...result.map((h, i) => <tr key={`${lineIndex}-${i}`}>{h}</tr>));
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
|
|
784
|
-
if (headerRows.length == 0) return null;
|
|
785
|
-
|
|
786
|
-
return (
|
|
787
|
-
<tbody key={"h" + key} className={CSS.element(baseClass, "header")}>
|
|
788
|
-
{headerRows}
|
|
789
|
-
</tbody>
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
onHeaderMouseMove(e, column, columnInstance, gridInstance, headerLine) {
|
|
794
|
-
let { baseClass, CSS } = gridInstance.widget;
|
|
795
|
-
if (columnInstance.data.fixed) return;
|
|
796
|
-
let headerInstance = columnInstance.components[`header${headerLine + 1}`];
|
|
797
|
-
if (!headerInstance) return;
|
|
798
|
-
let { store, data } = headerInstance;
|
|
799
|
-
if (headerInstance.widget?.tooltip) {
|
|
800
|
-
tooltipMouseMove(e, headerInstance, headerInstance.widget.tooltip);
|
|
801
|
-
}
|
|
802
|
-
if (data.draggable && !data.fixed && ddDetect(e) && e.buttons == 1) {
|
|
803
|
-
initiateDragDrop(
|
|
804
|
-
e,
|
|
805
|
-
{
|
|
806
|
-
sourceEl: e.currentTarget,
|
|
807
|
-
source: {
|
|
808
|
-
type: "grid-column",
|
|
809
|
-
store,
|
|
810
|
-
column,
|
|
811
|
-
columnInstance,
|
|
812
|
-
headerInstance,
|
|
813
|
-
gridInstance,
|
|
814
|
-
headerLine,
|
|
815
|
-
},
|
|
816
|
-
clone: {
|
|
817
|
-
store: store,
|
|
818
|
-
matchCursorOffset: true,
|
|
819
|
-
matchWidth: true,
|
|
820
|
-
widget: () => <div className={CSS.element(baseClass, "col-header-drag-clone")}>{data.text}</div>,
|
|
821
|
-
},
|
|
822
|
-
},
|
|
823
|
-
() => {},
|
|
824
|
-
);
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
onHeaderMouseLeave(e, columnInstance, headerLine) {
|
|
829
|
-
let headerInstance = columnInstance.components[`header${headerLine + 1}`];
|
|
830
|
-
if (!headerInstance) return;
|
|
831
|
-
if (headerInstance.widget?.tooltip) {
|
|
832
|
-
tooltipMouseLeave(e, headerInstance, headerInstance.widget.tooltip);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
onHeaderClick(e, column, instance, headerLine) {
|
|
837
|
-
e.preventDefault();
|
|
838
|
-
e.stopPropagation();
|
|
839
|
-
|
|
840
|
-
let { data } = instance;
|
|
841
|
-
let header = column.components[`header${headerLine + 1}`];
|
|
842
|
-
|
|
843
|
-
let field = column.sortField || column.field;
|
|
844
|
-
let value = column.sortValue || column.value;
|
|
845
|
-
let comparer = column.comparer;
|
|
846
|
-
let sortOptions = column.sortOptions;
|
|
847
|
-
|
|
848
|
-
if (header && header.allowSorting && column.sortable && (field || value || data.sortField)) {
|
|
849
|
-
let direction = column.primarySortDirection ?? "ASC";
|
|
850
|
-
if (
|
|
851
|
-
isNonEmptyArray(data.sorters) &&
|
|
852
|
-
((!!data.sorters[0].field && data.sorters[0].field == (field || data.sortField)) ||
|
|
853
|
-
(!!value && data.sorters[0].value == value))
|
|
854
|
-
) {
|
|
855
|
-
if (data.sorters[0].direction == "ASC" && (!this.clearableSort || direction == "ASC")) direction = "DESC";
|
|
856
|
-
else if (data.sorters[0].direction == "DESC" && (!this.clearableSort || direction == "DESC"))
|
|
857
|
-
direction = "ASC";
|
|
858
|
-
else {
|
|
859
|
-
direction = null;
|
|
860
|
-
instance.state.disableDefaultSort = true;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
let sorters = direction
|
|
865
|
-
? [
|
|
866
|
-
{
|
|
867
|
-
field,
|
|
868
|
-
direction,
|
|
869
|
-
value,
|
|
870
|
-
comparer,
|
|
871
|
-
sortOptions,
|
|
872
|
-
},
|
|
873
|
-
]
|
|
874
|
-
: null;
|
|
875
|
-
|
|
876
|
-
if (sorters == null) field = null;
|
|
877
|
-
|
|
878
|
-
instance.set("sorters", sorters);
|
|
879
|
-
instance.set("sortField", field);
|
|
880
|
-
instance.set("sortDirection", direction);
|
|
881
|
-
|
|
882
|
-
if (!this.remoteSort || this.infinite) instance.setState({ sorters });
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
renderGroupHeader(context, instance, g, level, group, i, store, fixedColumns) {
|
|
887
|
-
let { CSS, baseClass } = this;
|
|
888
|
-
let data = store.getData();
|
|
889
|
-
if (g.caption) {
|
|
890
|
-
let caption = g.caption(data);
|
|
891
|
-
return (
|
|
892
|
-
<tbody
|
|
893
|
-
key={`g-${level}-${group.$key}`}
|
|
894
|
-
className={CSS.element(baseClass, "group-caption", ["level-" + level])}
|
|
895
|
-
data-group-key={group.$key}
|
|
896
|
-
data-group-element={`group-caption-${level}`}
|
|
897
|
-
>
|
|
898
|
-
<tr>
|
|
899
|
-
<td colSpan={1000}>{caption}</td>
|
|
900
|
-
</tr>
|
|
901
|
-
</tbody>
|
|
902
|
-
);
|
|
903
|
-
} else if (g.showCaption) {
|
|
904
|
-
let skip = 0;
|
|
905
|
-
|
|
906
|
-
let { header } = instance;
|
|
907
|
-
|
|
908
|
-
let lines = [];
|
|
909
|
-
header.children.forEach((line, lineIndex) => {
|
|
910
|
-
let empty = true;
|
|
911
|
-
|
|
912
|
-
let cells = line.children.map((ci, i) => {
|
|
913
|
-
if (--skip >= 0) return null;
|
|
914
|
-
|
|
915
|
-
if (Boolean(ci.data.fixed) != fixedColumns) return null;
|
|
916
|
-
|
|
917
|
-
let v,
|
|
918
|
-
c = ci.widget,
|
|
919
|
-
colSpan,
|
|
920
|
-
pad,
|
|
921
|
-
cls = "",
|
|
922
|
-
style = null;
|
|
923
|
-
if (c.caption) {
|
|
924
|
-
if (c.caption.children)
|
|
925
|
-
v = <Cx widget={c.caption.children} store={store} parentInstance={instance} subscribe />;
|
|
926
|
-
else {
|
|
927
|
-
v = c.caption.value(data);
|
|
928
|
-
let fmt = c.caption.format(data);
|
|
929
|
-
if (fmt) v = Format.value(v, fmt);
|
|
930
|
-
}
|
|
931
|
-
pad = c.caption.pad;
|
|
932
|
-
colSpan = c.caption.colSpan;
|
|
933
|
-
empty = false;
|
|
934
|
-
cls = CSS.expand(c.caption.class(data)) || "";
|
|
935
|
-
style = parseStyle(c.caption.style(data));
|
|
936
|
-
if (c.caption.expand) {
|
|
937
|
-
colSpan = 1;
|
|
938
|
-
for (
|
|
939
|
-
let ind = i + 1;
|
|
940
|
-
ind < line.children.length &&
|
|
941
|
-
!line.children[ind].widget.caption &&
|
|
942
|
-
!line.children[ind].widget.aggregate;
|
|
943
|
-
ind++
|
|
944
|
-
)
|
|
945
|
-
colSpan++;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
if (colSpan > 1) skip = colSpan - 1;
|
|
949
|
-
} else if (c.aggregate && c.aggregateAliasGetter && c.caption !== false) {
|
|
950
|
-
empty = false;
|
|
951
|
-
v = c.aggregateAliasGetter(group);
|
|
952
|
-
if (isString(ci.data.format)) v = Format.value(v, ci.data.format);
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
if (cls) cls += " ";
|
|
956
|
-
if (c.align) cls += CSS.state("aligned-" + c.align);
|
|
957
|
-
|
|
958
|
-
if (pad !== false) cls += (cls ? " " : "") + CSS.state("pad");
|
|
959
|
-
|
|
960
|
-
return (
|
|
961
|
-
<td key={i} className={cls} colSpan={colSpan} style={style}>
|
|
962
|
-
{v}
|
|
963
|
-
</td>
|
|
964
|
-
);
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
if (empty) return;
|
|
968
|
-
|
|
969
|
-
lines.push(<tr key={lineIndex}>{cells}</tr>);
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
if (lines.length == 0) return null;
|
|
973
|
-
|
|
974
|
-
return (
|
|
975
|
-
<tbody
|
|
976
|
-
key={"c" + group.$key}
|
|
977
|
-
className={CSS.element(baseClass, "group-caption", ["level-" + level])}
|
|
978
|
-
data-group-key={group.$key}
|
|
979
|
-
data-group-element={`group-caption-${level}`}
|
|
980
|
-
>
|
|
981
|
-
{lines}
|
|
982
|
-
</tbody>
|
|
983
|
-
);
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
renderGroupFooter(context, instance, g, level, group, i, store, fixed, fixedColumns) {
|
|
988
|
-
let { CSS, baseClass } = this;
|
|
989
|
-
let data = store.getData();
|
|
990
|
-
let skip = 0;
|
|
991
|
-
|
|
992
|
-
let { header, state } = instance;
|
|
993
|
-
let rowStyle = {};
|
|
994
|
-
|
|
995
|
-
let lines = [];
|
|
996
|
-
header.children.forEach((line, lineIndex) => {
|
|
997
|
-
let empty = true;
|
|
998
|
-
|
|
999
|
-
let cells = line.children.map((ci, i) => {
|
|
1000
|
-
if (--skip >= 0) return null;
|
|
1001
|
-
|
|
1002
|
-
if (Boolean(ci.data.fixed) != fixedColumns) return null;
|
|
1003
|
-
|
|
1004
|
-
let v,
|
|
1005
|
-
c = ci.widget,
|
|
1006
|
-
colSpan = 1,
|
|
1007
|
-
pad,
|
|
1008
|
-
cls = "",
|
|
1009
|
-
style = null;
|
|
1010
|
-
if (c.footer) {
|
|
1011
|
-
v = c.footer.value(data);
|
|
1012
|
-
let fmt = c.footer.format(data);
|
|
1013
|
-
if (fmt) v = Format.value(v, fmt);
|
|
1014
|
-
pad = c.footer.pad;
|
|
1015
|
-
colSpan = c.footer.colSpan;
|
|
1016
|
-
empty = false;
|
|
1017
|
-
cls = CSS.expand(c.footer.class(data)) || "";
|
|
1018
|
-
style = parseStyle(c.footer.style(data));
|
|
1019
|
-
if (c.footer.expand) {
|
|
1020
|
-
colSpan = 1;
|
|
1021
|
-
for (
|
|
1022
|
-
let ind = i + 1;
|
|
1023
|
-
ind < line.children.length &&
|
|
1024
|
-
!line.children[ind].widget.footer &&
|
|
1025
|
-
!line.children[ind].widget.aggregate;
|
|
1026
|
-
ind++
|
|
1027
|
-
)
|
|
1028
|
-
colSpan++;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
if (colSpan > 1) skip = colSpan - 1;
|
|
1032
|
-
} else if (c.aggregate && c.aggregateAliasGetter && c.footer !== false) {
|
|
1033
|
-
empty = false;
|
|
1034
|
-
v = c.aggregateAliasGetter(group);
|
|
1035
|
-
if (isString(ci.data.format)) v = Format.value(v, ci.data.format);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
if (cls) cls += " ";
|
|
1039
|
-
if (c.align) cls += CSS.state("aligned-" + c.align);
|
|
1040
|
-
|
|
1041
|
-
if (pad !== false) cls += (cls ? " " : "") + CSS.state("pad");
|
|
1042
|
-
|
|
1043
|
-
// apply column width to footers too, but only if colSpan == 1,
|
|
1044
|
-
// otherwise set 1px so that the footer is not participating in the layout
|
|
1045
|
-
|
|
1046
|
-
let maxWidth = 1;
|
|
1047
|
-
if (colSpan == 1) maxWidth = state.colWidth[c.uniqueColumnId];
|
|
1048
|
-
style = {
|
|
1049
|
-
...style,
|
|
1050
|
-
maxWidth,
|
|
1051
|
-
};
|
|
1052
|
-
|
|
1053
|
-
return (
|
|
1054
|
-
<td key={i} className={cls} colSpan={colSpan} style={style}>
|
|
1055
|
-
{v}
|
|
1056
|
-
</td>
|
|
1057
|
-
);
|
|
1058
|
-
});
|
|
1059
|
-
|
|
1060
|
-
if (empty) return;
|
|
1061
|
-
|
|
1062
|
-
if (fixed && !fixedColumns)
|
|
1063
|
-
cells.push(<td key="dummy" className={CSS.element(baseClass, "fixed-footer-corner")} />);
|
|
1064
|
-
|
|
1065
|
-
lines.push(<tr key={lineIndex}>{cells}</tr>);
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
|
-
if (lines.length == 0) return null;
|
|
1069
|
-
|
|
1070
|
-
return (
|
|
1071
|
-
<tbody
|
|
1072
|
-
key={"f" + i}
|
|
1073
|
-
style={rowStyle}
|
|
1074
|
-
className={CSS.element(baseClass, "group-footer", ["level-" + level])}
|
|
1075
|
-
data-group-key={group.$key}
|
|
1076
|
-
data-group-element={`group-footer-${level}`}
|
|
1077
|
-
>
|
|
1078
|
-
{lines}
|
|
1079
|
-
</tbody>
|
|
1080
|
-
);
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
renderRows(context, instance) {
|
|
1084
|
-
let { records, hasFixedColumns } = instance;
|
|
1085
|
-
|
|
1086
|
-
if (!isArray(records)) return null;
|
|
1087
|
-
|
|
1088
|
-
let record, g;
|
|
1089
|
-
|
|
1090
|
-
for (let i = 0; i < records.length; i++) {
|
|
1091
|
-
record = records[i];
|
|
1092
|
-
if (record.type == "data") record.vdom = record.row.render(context, record.key);
|
|
1093
|
-
|
|
1094
|
-
if (record.type == "group-header") {
|
|
1095
|
-
record.vdom = [];
|
|
1096
|
-
record.fixedVdom = [];
|
|
1097
|
-
g = record.grouping;
|
|
1098
|
-
if (g.caption || g.showCaption)
|
|
1099
|
-
record.vdom.push(
|
|
1100
|
-
this.renderGroupHeader(
|
|
1101
|
-
context,
|
|
1102
|
-
instance,
|
|
1103
|
-
g,
|
|
1104
|
-
record.level,
|
|
1105
|
-
record.group,
|
|
1106
|
-
record.key + "-caption",
|
|
1107
|
-
record.store,
|
|
1108
|
-
false,
|
|
1109
|
-
),
|
|
1110
|
-
);
|
|
1111
|
-
|
|
1112
|
-
if (hasFixedColumns)
|
|
1113
|
-
record.fixedVdom.push(
|
|
1114
|
-
this.renderGroupHeader(
|
|
1115
|
-
context,
|
|
1116
|
-
instance,
|
|
1117
|
-
g,
|
|
1118
|
-
record.level,
|
|
1119
|
-
record.group,
|
|
1120
|
-
record.key + "-caption",
|
|
1121
|
-
record.store,
|
|
1122
|
-
true,
|
|
1123
|
-
),
|
|
1124
|
-
);
|
|
1125
|
-
|
|
1126
|
-
if (g.showHeader) {
|
|
1127
|
-
record.vdom.push(this.renderHeader(context, instance, record.key + "-header", false, false));
|
|
1128
|
-
if (hasFixedColumns)
|
|
1129
|
-
record.fixedVdom.push(this.renderHeader(context, instance, record.key + "-header", false, true));
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
if (record.type == "group-footer") {
|
|
1134
|
-
g = record.grouping;
|
|
1135
|
-
if (g.showFooter) {
|
|
1136
|
-
record.vdom = this.renderGroupFooter(
|
|
1137
|
-
context,
|
|
1138
|
-
instance,
|
|
1139
|
-
g,
|
|
1140
|
-
record.level,
|
|
1141
|
-
record.group,
|
|
1142
|
-
record.key + "-footer",
|
|
1143
|
-
record.store,
|
|
1144
|
-
false,
|
|
1145
|
-
false,
|
|
1146
|
-
);
|
|
1147
|
-
if (hasFixedColumns)
|
|
1148
|
-
record.fixedVdom = this.renderGroupFooter(
|
|
1149
|
-
context,
|
|
1150
|
-
instance,
|
|
1151
|
-
g,
|
|
1152
|
-
record.level,
|
|
1153
|
-
record.group,
|
|
1154
|
-
record.key + "-footer",
|
|
1155
|
-
record.store,
|
|
1156
|
-
false,
|
|
1157
|
-
true,
|
|
1158
|
-
);
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
renderFixedFooter(context, instance) {
|
|
1165
|
-
let { records, hasFixedColumns, data } = instance;
|
|
1166
|
-
|
|
1167
|
-
instance.fixedFooterVDOM = null;
|
|
1168
|
-
instance.fixedColumnsFixedFooterVDOM = null;
|
|
1169
|
-
|
|
1170
|
-
if (data.empty || !isNonEmptyArray(records)) return;
|
|
1171
|
-
|
|
1172
|
-
//all type of records are allowed here because the footer can be based on pre-computed data
|
|
1173
|
-
//it doesn't make sense to show the footer if the grid is empty though
|
|
1174
|
-
let record = records[records.length - 1];
|
|
1175
|
-
|
|
1176
|
-
instance.fixedFooterOverlap = true;
|
|
1177
|
-
instance.fixedFooterIsGroupFooter = record.type == "group-footer";
|
|
1178
|
-
|
|
1179
|
-
instance.fixedFooterVDOM = this.renderGroupFooter(
|
|
1180
|
-
context,
|
|
1181
|
-
instance,
|
|
1182
|
-
record.grouping,
|
|
1183
|
-
record.level || 1,
|
|
1184
|
-
record.group || { $key: "fixed-footer" },
|
|
1185
|
-
record.key + "-footer",
|
|
1186
|
-
record.store,
|
|
1187
|
-
true,
|
|
1188
|
-
false,
|
|
1189
|
-
);
|
|
1190
|
-
|
|
1191
|
-
if (hasFixedColumns)
|
|
1192
|
-
instance.fixedColumnsFixedFooterVDOM = this.renderGroupFooter(
|
|
1193
|
-
context,
|
|
1194
|
-
instance,
|
|
1195
|
-
record.grouping,
|
|
1196
|
-
record.level,
|
|
1197
|
-
record.group || { $key: "fixed-footer" },
|
|
1198
|
-
record.key + "-footer",
|
|
1199
|
-
record.store,
|
|
1200
|
-
true,
|
|
1201
|
-
true,
|
|
1202
|
-
);
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
mapRecords(context, instance) {
|
|
1206
|
-
let { data, store, dataAdapter } = instance;
|
|
1207
|
-
|
|
1208
|
-
let filter = null;
|
|
1209
|
-
if (this.onCreateFilter) filter = instance.invoke("onCreateFilter", data.filterParams, instance);
|
|
1210
|
-
|
|
1211
|
-
let sorters = !this.remoteSort && data.sorters;
|
|
1212
|
-
|
|
1213
|
-
//apply pre-sorters only if some sorting is applied
|
|
1214
|
-
if (isNonEmptyArray(data.sorters) && isNonEmptyArray(data.preSorters)) {
|
|
1215
|
-
sorters = [...data.preSorters, ...data.sorters];
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
dataAdapter.setFilter(filter);
|
|
1219
|
-
dataAdapter.sort(sorters);
|
|
1220
|
-
|
|
1221
|
-
//if no filtering or sorting applied, let the component maps records on demand
|
|
1222
|
-
if (
|
|
1223
|
-
this.buffered &&
|
|
1224
|
-
!this.fixedFooter &&
|
|
1225
|
-
!filter &&
|
|
1226
|
-
!isNonEmptyArray(sorters) &&
|
|
1227
|
-
!dataAdapter.isTreeAdapter &&
|
|
1228
|
-
!instance.dataAdapter.groupings
|
|
1229
|
-
)
|
|
1230
|
-
return null;
|
|
1231
|
-
|
|
1232
|
-
return dataAdapter.getRecords(context, instance, data.records, store);
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
mapRecord(context, instance, data, index) {
|
|
1236
|
-
return instance.dataAdapter.mapRecord(context, instance, data, instance.store, this.recordsAccessor, index);
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
Grid.prototype.baseClass = "grid";
|
|
1241
|
-
Grid.prototype.showHeader = true;
|
|
1242
|
-
Grid.prototype.showFooter = false;
|
|
1243
|
-
Grid.prototype.recordName = "$record";
|
|
1244
|
-
Grid.prototype.indexName = "$index";
|
|
1245
|
-
Grid.prototype.remoteSort = false;
|
|
1246
|
-
Grid.prototype.lockColumnWidths = false;
|
|
1247
|
-
Grid.prototype.lockColumnWidthsRequiredRowCount = 3;
|
|
1248
|
-
Grid.prototype.focused = false;
|
|
1249
|
-
Grid.prototype.emptyText = false;
|
|
1250
|
-
Grid.prototype.showBorder = false; // show border override for material theme
|
|
1251
|
-
Grid.prototype.cached = false;
|
|
1252
|
-
Grid.prototype.buffered = false;
|
|
1253
|
-
Grid.prototype.bufferStep = 15;
|
|
1254
|
-
Grid.prototype.bufferSize = 60;
|
|
1255
|
-
Grid.prototype.pageSize = 100;
|
|
1256
|
-
Grid.prototype.infinite = false;
|
|
1257
|
-
Grid.prototype.styled = true;
|
|
1258
|
-
Grid.prototype.scrollSelectionIntoView = false;
|
|
1259
|
-
Grid.prototype.clearableSort = false;
|
|
1260
|
-
Grid.prototype.cellEditable = false;
|
|
1261
|
-
Grid.prototype.preciseMeasurements = false;
|
|
1262
|
-
Grid.prototype.hoverChannel = "default";
|
|
1263
|
-
Grid.prototype.focusable = null; // automatically resolved
|
|
1264
|
-
Grid.prototype.allowsFileDrops = false;
|
|
1265
|
-
Grid.prototype.preserveGroupOrder = false;
|
|
1266
|
-
|
|
1267
|
-
Widget.alias("grid", Grid);
|
|
1268
|
-
Localization.registerPrototype("cx/widgets/Grid", Grid);
|
|
1269
|
-
|
|
1270
|
-
class GridComponent extends VDOM.Component {
|
|
1271
|
-
constructor(props) {
|
|
1272
|
-
super(props);
|
|
1273
|
-
this.dom = {};
|
|
1274
|
-
let { widget } = props.instance;
|
|
1275
|
-
|
|
1276
|
-
let end = Math.min(widget.bufferSize, props.data.totalRecordCount);
|
|
1277
|
-
|
|
1278
|
-
this.state = {
|
|
1279
|
-
cursor: widget.focused && widget.selectable ? 0 : -1,
|
|
1280
|
-
cursorCellIndex: 0,
|
|
1281
|
-
focused: widget.focused,
|
|
1282
|
-
dropInsertionIndex: null,
|
|
1283
|
-
dropNextToTheRowAbove: null,
|
|
1284
|
-
start: 0,
|
|
1285
|
-
end: end,
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
|
-
this.syncBuffering = false;
|
|
1289
|
-
|
|
1290
|
-
if (widget.infinite) {
|
|
1291
|
-
this.start = 0;
|
|
1292
|
-
this.end = end;
|
|
1293
|
-
this.loadingStartPage = 0;
|
|
1294
|
-
this.loadingEndPage = 0;
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
this.scrollerRef = (el) => {
|
|
1298
|
-
this.dom.scroller = el;
|
|
1299
|
-
};
|
|
1300
|
-
|
|
1301
|
-
this.fixedScrollerRef = (el) => {
|
|
1302
|
-
this.dom.fixedScroller = el;
|
|
1303
|
-
};
|
|
1304
|
-
|
|
1305
|
-
this.gridRef = (el) => {
|
|
1306
|
-
this.dom.el = el;
|
|
1307
|
-
};
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
getBufferStartEnd() {
|
|
1311
|
-
//{start, end};
|
|
1312
|
-
return this.syncBuffering ? this : this.state;
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
renderCellEditor(key, CSS, baseClass, instance, column) {
|
|
1316
|
-
//add an inner div with fixed height in order to help IE absolutely position the contents inside
|
|
1317
|
-
return (
|
|
1318
|
-
<td key={key} className={CSS.element(baseClass, "cell-editor")}>
|
|
1319
|
-
<Cx parentInstance={instance} subscribe>
|
|
1320
|
-
<GridCellEditor
|
|
1321
|
-
className={CSS.element(baseClass, "cell-editor-wrap")}
|
|
1322
|
-
style={
|
|
1323
|
-
this.rowHeight > 0
|
|
1324
|
-
? {
|
|
1325
|
-
height: this.rowHeight + 1,
|
|
1326
|
-
}
|
|
1327
|
-
: null
|
|
1328
|
-
}
|
|
1329
|
-
>
|
|
1330
|
-
<ValidationGroup
|
|
1331
|
-
valid={{
|
|
1332
|
-
get: () => this.cellEditorValid,
|
|
1333
|
-
set: (value) => {
|
|
1334
|
-
this.cellEditorValid = value;
|
|
1335
|
-
},
|
|
1336
|
-
}}
|
|
1337
|
-
>
|
|
1338
|
-
{column.editor}
|
|
1339
|
-
</ValidationGroup>
|
|
1340
|
-
</GridCellEditor>
|
|
1341
|
-
</Cx>
|
|
1342
|
-
</td>
|
|
1343
|
-
);
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
createRowRenderer(cellWrap) {
|
|
1347
|
-
let { instance, data } = this.props;
|
|
1348
|
-
let { widget, isRecordSelectable, visibleColumns, isRecordDraggable, row } = instance;
|
|
1349
|
-
let { CSS, baseClass } = widget;
|
|
1350
|
-
let { dragSource } = data;
|
|
1351
|
-
let { dragged, cursor, cursorCellIndex, cellEdit, dropInsertionIndex, dropTarget } = this.state;
|
|
1352
|
-
let { colWidth, dimensionsVersion } = instance.state;
|
|
1353
|
-
let { hasMergedCells } = row;
|
|
1354
|
-
|
|
1355
|
-
return (record, index, standalone, fixed) => {
|
|
1356
|
-
let { store, key, row } = record;
|
|
1357
|
-
let isDragged = dragged && (row.selected || record == dragged);
|
|
1358
|
-
let mod = {
|
|
1359
|
-
selected: row.selected,
|
|
1360
|
-
dragged: isDragged,
|
|
1361
|
-
cursor: widget.selectable && index == cursor,
|
|
1362
|
-
over: dropTarget == "row" && dropInsertionIndex === index,
|
|
1363
|
-
alternate: index % 2 == 1,
|
|
1364
|
-
};
|
|
1365
|
-
|
|
1366
|
-
if (isRecordSelectable) {
|
|
1367
|
-
let selectable = isRecordSelectable(record.data, {});
|
|
1368
|
-
mod["selectable"] = selectable;
|
|
1369
|
-
mod["non-selectable"] = !selectable;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
let draggable =
|
|
1373
|
-
dragSource &&
|
|
1374
|
-
(!row.dragHandles || row.dragHandles.length == 0) &&
|
|
1375
|
-
(!isRecordDraggable || isRecordDraggable(record.data));
|
|
1376
|
-
mod["draggable"] = draggable;
|
|
1377
|
-
mod["non-draggable"] = !draggable;
|
|
1378
|
-
|
|
1379
|
-
let wrap = (children) => {
|
|
1380
|
-
let skipCells = {};
|
|
1381
|
-
return (
|
|
1382
|
-
<GridRowComponent
|
|
1383
|
-
key={key}
|
|
1384
|
-
className={CSS.state(mod)}
|
|
1385
|
-
store={store}
|
|
1386
|
-
dragSource={dragSource}
|
|
1387
|
-
instance={row}
|
|
1388
|
-
grid={instance}
|
|
1389
|
-
record={record}
|
|
1390
|
-
parent={this}
|
|
1391
|
-
cursorIndex={index}
|
|
1392
|
-
selected={row.selected}
|
|
1393
|
-
isBeingDragged={dragged}
|
|
1394
|
-
isDraggedOver={mod.over}
|
|
1395
|
-
cursor={mod.cursor}
|
|
1396
|
-
cursorCellIndex={index == cursor && cursorCellIndex}
|
|
1397
|
-
cellEdit={index == cursor && cursorCellIndex != null && cellEdit}
|
|
1398
|
-
shouldUpdate={row.shouldUpdate}
|
|
1399
|
-
dimensionsVersion={dimensionsVersion}
|
|
1400
|
-
fixed={fixed}
|
|
1401
|
-
useTrTag={hasMergedCells}
|
|
1402
|
-
>
|
|
1403
|
-
{children.content.map(({ key, data, content }, line) => {
|
|
1404
|
-
let cells = content.map(
|
|
1405
|
-
({ key, data, content, uniqueColumnId, merged, mergeRowSpan }, cellIndex) => {
|
|
1406
|
-
if (Boolean(data.fixed) !== fixed) return null;
|
|
1407
|
-
if (merged) return null;
|
|
1408
|
-
let cellected =
|
|
1409
|
-
index == cursor && cellIndex == cursorCellIndex && widget.cellEditable && line == 0;
|
|
1410
|
-
let className = cellected
|
|
1411
|
-
? CSS.expand(data.classNames, CSS.state("cellected"))
|
|
1412
|
-
: data.classNames;
|
|
1413
|
-
if (cellected && cellEdit) {
|
|
1414
|
-
let column = visibleColumns[cursorCellIndex];
|
|
1415
|
-
if (column && column.editor && data.editable)
|
|
1416
|
-
return this.renderCellEditor(key, CSS, baseClass, row, column);
|
|
1417
|
-
}
|
|
1418
|
-
let width = colWidth[uniqueColumnId];
|
|
1419
|
-
let style = data.style;
|
|
1420
|
-
if (width) {
|
|
1421
|
-
style = {
|
|
1422
|
-
...style,
|
|
1423
|
-
maxWidth: `${width}px`,
|
|
1424
|
-
};
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
if (skipCells[`${line}-${cellIndex}`]) return null;
|
|
1428
|
-
|
|
1429
|
-
if (data.colSpan > 1 || data.rowSpan > 1) {
|
|
1430
|
-
for (let r = line; r < line + (data.rowSpan ?? 1); r++)
|
|
1431
|
-
for (let c = cellIndex; c < cellIndex + (data.colSpan ?? 1); c++)
|
|
1432
|
-
skipCells[`${r}-${c}`] = true;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
if (cellWrap) content = cellWrap(content);
|
|
1436
|
-
|
|
1437
|
-
return (
|
|
1438
|
-
<td
|
|
1439
|
-
key={key}
|
|
1440
|
-
className={className}
|
|
1441
|
-
style={style}
|
|
1442
|
-
colSpan={data.colSpan}
|
|
1443
|
-
rowSpan={mergeRowSpan ?? data.rowSpan}
|
|
1444
|
-
>
|
|
1445
|
-
{content}
|
|
1446
|
-
</td>
|
|
1447
|
-
);
|
|
1448
|
-
},
|
|
1449
|
-
);
|
|
1450
|
-
if (hasMergedCells) return cells;
|
|
1451
|
-
return (
|
|
1452
|
-
<tr key={key} className={data.classNames} style={data.style}>
|
|
1453
|
-
{cells}
|
|
1454
|
-
</tr>
|
|
1455
|
-
);
|
|
1456
|
-
})}
|
|
1457
|
-
</GridRowComponent>
|
|
1458
|
-
);
|
|
1459
|
-
};
|
|
1460
|
-
|
|
1461
|
-
if (!standalone) return wrap(record.vdom);
|
|
1462
|
-
|
|
1463
|
-
return (
|
|
1464
|
-
<Cx
|
|
1465
|
-
key={key}
|
|
1466
|
-
instance={record.row}
|
|
1467
|
-
parentInstance={instance}
|
|
1468
|
-
options={{ name: "grid-row" }}
|
|
1469
|
-
contentFactory={(x) =>
|
|
1470
|
-
wrap({
|
|
1471
|
-
content: Array.isArray(x.children) ? x.children : x.children != null ? [x.children] : [],
|
|
1472
|
-
data: {},
|
|
1473
|
-
})
|
|
1474
|
-
}
|
|
1475
|
-
params={{
|
|
1476
|
-
...mod,
|
|
1477
|
-
dimensionsVersion: dimensionsVersion,
|
|
1478
|
-
cursorIndex: index,
|
|
1479
|
-
data: record.data,
|
|
1480
|
-
cursorCellIndex: index == cursor && cursorCellIndex,
|
|
1481
|
-
cellEdit: index == cursor && cursorCellIndex != null && cellEdit,
|
|
1482
|
-
}}
|
|
1483
|
-
/>
|
|
1484
|
-
);
|
|
1485
|
-
};
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
render() {
|
|
1489
|
-
let { instance, data, fixedFooter, fixedColumnsFixedFooter } = this.props;
|
|
1490
|
-
let { widget, hasFixedColumns } = instance;
|
|
1491
|
-
let { CSS, baseClass } = widget;
|
|
1492
|
-
let { start, end } = this.getBufferStartEnd();
|
|
1493
|
-
|
|
1494
|
-
let cellWrap = false;
|
|
1495
|
-
|
|
1496
|
-
if (widget.cellEditable && (widget.hasResizableColumns || hasFixedColumns)) {
|
|
1497
|
-
cellWrap = (children) => <div className="cxe-grid-cell-clip">{children}</div>;
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
let children = [],
|
|
1501
|
-
fixedChildren = [];
|
|
1502
|
-
|
|
1503
|
-
let renderRow = this.createRowRenderer(cellWrap);
|
|
1504
|
-
|
|
1505
|
-
let addRow = (record, index, standalone) => {
|
|
1506
|
-
children.push(renderRow(record, index, standalone, false));
|
|
1507
|
-
if (hasFixedColumns) fixedChildren.push(renderRow(record, index, standalone, true));
|
|
1508
|
-
|
|
1509
|
-
//avoid re-rendering on cursor change
|
|
1510
|
-
record.row.shouldUpdate = false;
|
|
1511
|
-
};
|
|
1512
|
-
|
|
1513
|
-
if (widget.buffered) {
|
|
1514
|
-
let context = new RenderingContext();
|
|
1515
|
-
let dummyDataClass = CSS.element(baseClass, "data", { dummy: true });
|
|
1516
|
-
if (!instance.recordInstanceCache) instance.recordInstanceCache = new InstanceCache(instance);
|
|
1517
|
-
instance.recordInstanceCache.mark();
|
|
1518
|
-
this.getRecordsSlice(start, end).forEach((r, i) => {
|
|
1519
|
-
if (r == null) {
|
|
1520
|
-
addRow(
|
|
1521
|
-
{
|
|
1522
|
-
key: "dummy-" + start + i,
|
|
1523
|
-
row: {
|
|
1524
|
-
data: { classNames: dummyDataClass },
|
|
1525
|
-
widget: instance.row,
|
|
1526
|
-
},
|
|
1527
|
-
vdom: {
|
|
1528
|
-
content: [
|
|
1529
|
-
{
|
|
1530
|
-
key: 0,
|
|
1531
|
-
data: {},
|
|
1532
|
-
content: [
|
|
1533
|
-
{
|
|
1534
|
-
key: 0,
|
|
1535
|
-
data: {
|
|
1536
|
-
colSpan: 1000,
|
|
1537
|
-
style: {
|
|
1538
|
-
height: `${this.rowHeight}px`,
|
|
1539
|
-
},
|
|
1540
|
-
},
|
|
1541
|
-
},
|
|
1542
|
-
],
|
|
1543
|
-
},
|
|
1544
|
-
],
|
|
1545
|
-
},
|
|
1546
|
-
},
|
|
1547
|
-
start + i,
|
|
1548
|
-
);
|
|
1549
|
-
} else {
|
|
1550
|
-
let record = instance.records
|
|
1551
|
-
? r
|
|
1552
|
-
: widget.mapRecord(context, instance, r, widget.infinite ? start + i - data.offset : start + i);
|
|
1553
|
-
let row = (record.row = instance.recordInstanceCache.getChild(instance.row, record.store, record.key));
|
|
1554
|
-
instance.recordInstanceCache.addChild(row);
|
|
1555
|
-
row.detached = true;
|
|
1556
|
-
row.selected = instance.isSelected(record.data, record.index);
|
|
1557
|
-
|
|
1558
|
-
if (record.type == "data") {
|
|
1559
|
-
addRow(record, start + i, true);
|
|
1560
|
-
} else if (record.type == "group-header") {
|
|
1561
|
-
let g = record.grouping;
|
|
1562
|
-
if (g.caption || g.showCaption) {
|
|
1563
|
-
children.push(
|
|
1564
|
-
widget.renderGroupHeader(
|
|
1565
|
-
null,
|
|
1566
|
-
instance,
|
|
1567
|
-
g,
|
|
1568
|
-
record.level,
|
|
1569
|
-
record.group,
|
|
1570
|
-
record.key + "-caption",
|
|
1571
|
-
record.store,
|
|
1572
|
-
false,
|
|
1573
|
-
),
|
|
1574
|
-
);
|
|
1575
|
-
|
|
1576
|
-
if (hasFixedColumns)
|
|
1577
|
-
fixedChildren.push(
|
|
1578
|
-
widget.renderGroupHeader(
|
|
1579
|
-
null,
|
|
1580
|
-
instance,
|
|
1581
|
-
g,
|
|
1582
|
-
record.level,
|
|
1583
|
-
record.group,
|
|
1584
|
-
record.key + "-caption",
|
|
1585
|
-
record.store,
|
|
1586
|
-
true,
|
|
1587
|
-
),
|
|
1588
|
-
);
|
|
1589
|
-
}
|
|
1590
|
-
} else if (record.type == "group-footer") {
|
|
1591
|
-
let g = record.grouping;
|
|
1592
|
-
if (g.showFooter && (!widget.fixedFooter || start + i != instance.records.length - 1)) {
|
|
1593
|
-
children.push(
|
|
1594
|
-
widget.renderGroupFooter(
|
|
1595
|
-
null,
|
|
1596
|
-
instance,
|
|
1597
|
-
g,
|
|
1598
|
-
record.level,
|
|
1599
|
-
record.group,
|
|
1600
|
-
record.key + "-footer",
|
|
1601
|
-
record.store,
|
|
1602
|
-
false,
|
|
1603
|
-
false,
|
|
1604
|
-
),
|
|
1605
|
-
);
|
|
1606
|
-
|
|
1607
|
-
if (hasFixedColumns)
|
|
1608
|
-
fixedChildren.push(
|
|
1609
|
-
widget.renderGroupFooter(
|
|
1610
|
-
null,
|
|
1611
|
-
instance,
|
|
1612
|
-
g,
|
|
1613
|
-
record.level,
|
|
1614
|
-
record.group,
|
|
1615
|
-
record.key + "-footer",
|
|
1616
|
-
record.store,
|
|
1617
|
-
false,
|
|
1618
|
-
true,
|
|
1619
|
-
),
|
|
1620
|
-
);
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
});
|
|
1625
|
-
instance.recordInstanceCache.sweep();
|
|
1626
|
-
} else {
|
|
1627
|
-
let { row } = instance;
|
|
1628
|
-
let { hasMergedCells, mergedColumns } = row;
|
|
1629
|
-
if (hasMergedCells) {
|
|
1630
|
-
// merge adjacent cells with the same value in columns that are marked as merged
|
|
1631
|
-
let rowSpan = {};
|
|
1632
|
-
let getCellRenderInfo = (vdom, cellIndex) => vdom.content[0]?.content[cellIndex];
|
|
1633
|
-
for (let index = instance.records.length - 1; index >= 0; index--) {
|
|
1634
|
-
let row = instance.records[index];
|
|
1635
|
-
let prevRow = instance.records[index - 1];
|
|
1636
|
-
if (row.type == "data") {
|
|
1637
|
-
let stopMerge = false;
|
|
1638
|
-
for (let mi = 0; mi < mergedColumns.length; mi++) {
|
|
1639
|
-
let mergedCol = mergedColumns[mi];
|
|
1640
|
-
let cellInfo = getCellRenderInfo(row.vdom, mergedCol.index);
|
|
1641
|
-
cellInfo.merged = false;
|
|
1642
|
-
delete cellInfo.mergeRowSpan;
|
|
1643
|
-
if (prevRow?.type == "data") {
|
|
1644
|
-
let shouldMerge = false;
|
|
1645
|
-
switch (mergedCol.mode) {
|
|
1646
|
-
case "always":
|
|
1647
|
-
shouldMerge = true;
|
|
1648
|
-
break;
|
|
1649
|
-
case "same-value":
|
|
1650
|
-
let prevCellInfo = getCellRenderInfo(prevRow.vdom, mergedCol.index);
|
|
1651
|
-
shouldMerge = !stopMerge && cellInfo.data.value === prevCellInfo.data.value;
|
|
1652
|
-
break;
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
if (shouldMerge) {
|
|
1656
|
-
cellInfo.merged = true;
|
|
1657
|
-
rowSpan[mergedCol.uniqueColumnId] = (rowSpan[mergedCol.uniqueColumnId] ?? 1) + 1;
|
|
1658
|
-
} else {
|
|
1659
|
-
if (mergedCol.mode == "same-value") stopMerge = true;
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
if (!cellInfo.merged && rowSpan[mergedCol.uniqueColumnId] > 1) {
|
|
1663
|
-
cellInfo.mergeRowSpan = rowSpan[mergedCol.uniqueColumnId];
|
|
1664
|
-
rowSpan[mergedCol.uniqueColumnId] = 1;
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
} else rowSpan = {};
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
instance.records.forEach((record, i) => {
|
|
1672
|
-
if (record.type == "data") addRow(record, i, false);
|
|
1673
|
-
else {
|
|
1674
|
-
children.push(record.vdom);
|
|
1675
|
-
if (hasFixedColumns) fixedChildren.push(record.fixedVdom);
|
|
1676
|
-
}
|
|
1677
|
-
});
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
if (this.state.dropTarget == "grid" && this.state.dropInsertionIndex != null) {
|
|
1681
|
-
let dragInsertionRow = (
|
|
1682
|
-
<tbody key="dropzone">
|
|
1683
|
-
<tr>
|
|
1684
|
-
<td
|
|
1685
|
-
className={CSS.element(baseClass, "dropzone")}
|
|
1686
|
-
colSpan={1000}
|
|
1687
|
-
style={{
|
|
1688
|
-
height: data.dropMode == "insertion" ? 0 : this.state.dropItemHeight,
|
|
1689
|
-
}}
|
|
1690
|
-
/>
|
|
1691
|
-
</tr>
|
|
1692
|
-
</tbody>
|
|
1693
|
-
);
|
|
1694
|
-
|
|
1695
|
-
let dataRecordClass = CSS.element(baseClass, "data");
|
|
1696
|
-
|
|
1697
|
-
let isDataRecord = widget.buffered
|
|
1698
|
-
? (item) => item?.props?.instance?.data?.class == dataRecordClass
|
|
1699
|
-
: (item) => item?.props?.record?.type;
|
|
1700
|
-
|
|
1701
|
-
let index = 0;
|
|
1702
|
-
while (index < children.length && !isDataRecord(children[index])) index++;
|
|
1703
|
-
|
|
1704
|
-
let count = 0;
|
|
1705
|
-
while (index < children.length && count < this.state.dropInsertionIndex) {
|
|
1706
|
-
if (isDataRecord(children[index])) count++;
|
|
1707
|
-
index++;
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
let savedIndexPos = index;
|
|
1711
|
-
|
|
1712
|
-
if (!this.state.dropNextToTheRowAbove)
|
|
1713
|
-
while (index < children.length && !isDataRecord(children[index])) index++;
|
|
1714
|
-
|
|
1715
|
-
// do not allow insertion after the last group footer
|
|
1716
|
-
if (savedIndexPos < index && index == children.length) index = savedIndexPos;
|
|
1717
|
-
|
|
1718
|
-
children.splice(index, 0, dragInsertionRow);
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
let content = [],
|
|
1722
|
-
fixedColumnsContent = [];
|
|
1723
|
-
|
|
1724
|
-
//instance.records holds the record count after filtering
|
|
1725
|
-
if (data.emptyText && data.empty) {
|
|
1726
|
-
children = [
|
|
1727
|
-
<tbody key="empty" className={CSS.element(baseClass, "empty-text")}>
|
|
1728
|
-
<tr>
|
|
1729
|
-
<td colSpan={1000}>{data.emptyText}</td>
|
|
1730
|
-
</tr>
|
|
1731
|
-
</tbody>,
|
|
1732
|
-
];
|
|
1733
|
-
} else if (widget.fixedFooter && (widget.buffered || !instance.fixedFooterIsGroupFooter)) {
|
|
1734
|
-
//add fixed footer content for buffered grids
|
|
1735
|
-
if (fixedFooter || fixedColumnsFixedFooter) {
|
|
1736
|
-
children.push(fixedFooter);
|
|
1737
|
-
if (hasFixedColumns) fixedChildren.push(fixedColumnsFixedFooter);
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
|
|
1741
|
-
let shouldRenderFixedFooter = widget.scrollable && (fixedFooter || fixedColumnsFixedFooter);
|
|
1742
|
-
|
|
1743
|
-
if (hasFixedColumns) {
|
|
1744
|
-
fixedColumnsContent.push(
|
|
1745
|
-
<div
|
|
1746
|
-
key="fixedscroller"
|
|
1747
|
-
ref={this.fixedScrollerRef}
|
|
1748
|
-
className={CSS.element(baseClass, "fixed-scroll-area", {
|
|
1749
|
-
"fixed-header": !!this.props.header,
|
|
1750
|
-
"fixed-footer": shouldRenderFixedFooter,
|
|
1751
|
-
})}
|
|
1752
|
-
>
|
|
1753
|
-
<div className={CSS.element(baseClass, "fixed-table-wrapper")}>
|
|
1754
|
-
<table
|
|
1755
|
-
ref={(el) => {
|
|
1756
|
-
this.dom.fixedTable = el;
|
|
1757
|
-
}}
|
|
1758
|
-
>
|
|
1759
|
-
{this.props.fixedColumnsHeader}
|
|
1760
|
-
{fixedChildren}
|
|
1761
|
-
</table>
|
|
1762
|
-
</div>
|
|
1763
|
-
</div>,
|
|
1764
|
-
);
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
content.push(
|
|
1768
|
-
<div
|
|
1769
|
-
key="scroller"
|
|
1770
|
-
ref={this.scrollerRef}
|
|
1771
|
-
onScroll={this.onScroll.bind(this)}
|
|
1772
|
-
className={CSS.element(baseClass, "scroll-area", {
|
|
1773
|
-
"fixed-header": !!this.props.header,
|
|
1774
|
-
"fixed-footer": shouldRenderFixedFooter,
|
|
1775
|
-
})}
|
|
1776
|
-
>
|
|
1777
|
-
<div className={CSS.element(baseClass, "table-wrapper")}>
|
|
1778
|
-
<table
|
|
1779
|
-
ref={(el) => {
|
|
1780
|
-
this.dom.table = el;
|
|
1781
|
-
if (this.props.instance.widget.onRef) this.props.instance.invoke("onRef", el, this.props.instance);
|
|
1782
|
-
}}
|
|
1783
|
-
>
|
|
1784
|
-
{this.props.header}
|
|
1785
|
-
{children}
|
|
1786
|
-
</table>
|
|
1787
|
-
</div>
|
|
1788
|
-
</div>,
|
|
1789
|
-
);
|
|
1790
|
-
|
|
1791
|
-
if (this.props.fixedHeader)
|
|
1792
|
-
content.push(
|
|
1793
|
-
<div
|
|
1794
|
-
key="fh"
|
|
1795
|
-
ref={(el) => {
|
|
1796
|
-
this.dom.fixedHeader = el;
|
|
1797
|
-
}}
|
|
1798
|
-
className={CSS.element(baseClass, "fixed-header")}
|
|
1799
|
-
style={{
|
|
1800
|
-
display: this.scrollWidth > 0 ? "block" : "none",
|
|
1801
|
-
}}
|
|
1802
|
-
>
|
|
1803
|
-
<table>{this.props.fixedHeader}</table>
|
|
1804
|
-
</div>,
|
|
1805
|
-
);
|
|
1806
|
-
|
|
1807
|
-
if (this.props.fixedColumnsFixedHeader)
|
|
1808
|
-
fixedColumnsContent.push(
|
|
1809
|
-
<div
|
|
1810
|
-
key="fcfh"
|
|
1811
|
-
ref={(el) => {
|
|
1812
|
-
this.dom.fixedColumnsFixedHeader = el;
|
|
1813
|
-
}}
|
|
1814
|
-
className={CSS.element(baseClass, "fixed-fixed-header")}
|
|
1815
|
-
style={{
|
|
1816
|
-
display: this.scrollWidth > 0 ? "block" : "none",
|
|
1817
|
-
}}
|
|
1818
|
-
>
|
|
1819
|
-
<table>{this.props.fixedColumnsFixedHeader}</table>
|
|
1820
|
-
</div>,
|
|
1821
|
-
);
|
|
1822
|
-
|
|
1823
|
-
if (shouldRenderFixedFooter) {
|
|
1824
|
-
content.push(
|
|
1825
|
-
<div
|
|
1826
|
-
key="ff"
|
|
1827
|
-
ref={(el) => {
|
|
1828
|
-
this.dom.fixedFooter = el;
|
|
1829
|
-
}}
|
|
1830
|
-
className={CSS.element(baseClass, "fixed-footer")}
|
|
1831
|
-
>
|
|
1832
|
-
<table>{fixedFooter}</table>
|
|
1833
|
-
</div>,
|
|
1834
|
-
);
|
|
1835
|
-
|
|
1836
|
-
if (hasFixedColumns)
|
|
1837
|
-
fixedColumnsContent.push(
|
|
1838
|
-
<div
|
|
1839
|
-
key="fcff"
|
|
1840
|
-
ref={(el) => {
|
|
1841
|
-
this.dom.fixedColumnsFixedFooter = el;
|
|
1842
|
-
}}
|
|
1843
|
-
className={CSS.element(baseClass, "fixed-fixed-footer")}
|
|
1844
|
-
>
|
|
1845
|
-
<table>{fixedColumnsFixedFooter}</table>
|
|
1846
|
-
</div>,
|
|
1847
|
-
);
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
let columnInsertionMarker = null;
|
|
1851
|
-
if (this.state.dropTarget == "column") {
|
|
1852
|
-
columnInsertionMarker = (
|
|
1853
|
-
<div
|
|
1854
|
-
className={CSS.element(baseClass, "col-insertion-marker")}
|
|
1855
|
-
style={{
|
|
1856
|
-
left: this.state.colDropInsertionLeft,
|
|
1857
|
-
}}
|
|
1858
|
-
/>
|
|
1859
|
-
);
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
return (
|
|
1863
|
-
<div
|
|
1864
|
-
className={data.classNames}
|
|
1865
|
-
style={{ ...data.style, counterReset: `cx-row-number ${start}` }}
|
|
1866
|
-
tabIndex={widget.focusable ? data.tabIndex || 0 : null}
|
|
1867
|
-
ref={this.gridRef}
|
|
1868
|
-
onKeyDown={this.handleKeyDown.bind(this)}
|
|
1869
|
-
onFocus={this.onFocus.bind(this)}
|
|
1870
|
-
onBlur={this.onBlur.bind(this)}
|
|
1871
|
-
onDragEnter={this.onFileDragEnter.bind(this)}
|
|
1872
|
-
onDragOver={this.onFileDragOver.bind(this)}
|
|
1873
|
-
onDragLeave={this.onFileDragLeave.bind(this)}
|
|
1874
|
-
onDrop={this.onFileDrop.bind(this)}
|
|
1875
|
-
>
|
|
1876
|
-
{fixedColumnsContent}
|
|
1877
|
-
{content}
|
|
1878
|
-
{columnInsertionMarker}
|
|
1879
|
-
{this.props.children}
|
|
1880
|
-
</div>
|
|
1881
|
-
);
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
getRecordsSlice(start, end) {
|
|
1885
|
-
let { data, instance } = this.props;
|
|
1886
|
-
let { widget } = instance;
|
|
1887
|
-
if (!widget.infinite) {
|
|
1888
|
-
let source = instance.records || data.records;
|
|
1889
|
-
return source.slice(start, end);
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
let { offset, records } = data;
|
|
1893
|
-
let result = [];
|
|
1894
|
-
for (let i = start; i < Math.min(end, data.totalRecordCount); i++) {
|
|
1895
|
-
if (i >= offset && i < offset + records.length) result.push(records[i - offset]);
|
|
1896
|
-
else result.push(null);
|
|
1897
|
-
}
|
|
1898
|
-
|
|
1899
|
-
return result;
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
|
-
ensureData(visibleStart, visibleEnd) {
|
|
1903
|
-
if (this.loading) return;
|
|
1904
|
-
|
|
1905
|
-
let { instance } = this.props;
|
|
1906
|
-
let { widget } = instance;
|
|
1907
|
-
let { pageSize } = widget;
|
|
1908
|
-
|
|
1909
|
-
let startPage = Math.trunc(visibleStart / pageSize) + 1,
|
|
1910
|
-
endPage = Math.trunc((visibleEnd - 1) / pageSize) + 1;
|
|
1911
|
-
|
|
1912
|
-
//debouncing restricts excessive page loading on fast scrolling as rendering data is
|
|
1913
|
-
//useless because visible region is scrolled away before data appears
|
|
1914
|
-
//the user should spent some time on the page before loading it
|
|
1915
|
-
|
|
1916
|
-
if (!this.loadPageRange)
|
|
1917
|
-
this.loadPageRange = debounce((startPage, endPage) => {
|
|
1918
|
-
let { data } = this.props;
|
|
1919
|
-
let { records, offset } = data;
|
|
1920
|
-
let promises = [];
|
|
1921
|
-
|
|
1922
|
-
for (let page = startPage; page <= endPage; page++) {
|
|
1923
|
-
let s = (page - 1) * pageSize,
|
|
1924
|
-
e = s + pageSize;
|
|
1925
|
-
if (s >= offset && e <= offset + records.length) {
|
|
1926
|
-
promises.push(Promise.resolve(records.slice(s - offset, e - offset)));
|
|
1927
|
-
} else {
|
|
1928
|
-
let result = instance.invoke(
|
|
1929
|
-
"onFetchRecords",
|
|
1930
|
-
{
|
|
1931
|
-
page,
|
|
1932
|
-
pageSize,
|
|
1933
|
-
sorters: data.sorters,
|
|
1934
|
-
sortField: data.sortField,
|
|
1935
|
-
sortDirection: data.sortDirection,
|
|
1936
|
-
filterParams: data.filterParams,
|
|
1937
|
-
state: this.prevFetchRecordsState,
|
|
1938
|
-
},
|
|
1939
|
-
instance,
|
|
1940
|
-
);
|
|
1941
|
-
promises.push(Promise.resolve(result));
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
this.loading = true;
|
|
1946
|
-
|
|
1947
|
-
Promise.all(promises)
|
|
1948
|
-
.then((pageRecords) => {
|
|
1949
|
-
this.loading = false;
|
|
1950
|
-
let records = [];
|
|
1951
|
-
let totalRecordCount;
|
|
1952
|
-
let lastPage;
|
|
1953
|
-
|
|
1954
|
-
pageRecords.forEach((page) => {
|
|
1955
|
-
if (Array.isArray(page)) {
|
|
1956
|
-
records.push(...page);
|
|
1957
|
-
} else {
|
|
1958
|
-
if (!Array.isArray(page.records))
|
|
1959
|
-
throw new Error(
|
|
1960
|
-
"onFetchRecords should return an array of records or an object with results inside records property.",
|
|
1961
|
-
);
|
|
1962
|
-
totalRecordCount = page.totalRecordCount;
|
|
1963
|
-
lastPage = page.lastPage;
|
|
1964
|
-
this.prevFetchRecordsState = page.state;
|
|
1965
|
-
records.push(...page.records);
|
|
1966
|
-
}
|
|
1967
|
-
});
|
|
1968
|
-
|
|
1969
|
-
let { data } = this.props;
|
|
1970
|
-
|
|
1971
|
-
if (!isNumber(totalRecordCount)) {
|
|
1972
|
-
totalRecordCount = (startPage - 1) * pageSize + records.length;
|
|
1973
|
-
if (!lastPage && records.length == (endPage - startPage + 1) * pageSize) totalRecordCount++;
|
|
1974
|
-
if (data.totalRecordCount > totalRecordCount) totalRecordCount = data.totalRecordCount;
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
instance.buffer.totalRecordCount = data.totalRecordCount = totalRecordCount;
|
|
1978
|
-
instance.buffer.records = data.records = records;
|
|
1979
|
-
instance.buffer.page = data.page = startPage;
|
|
1980
|
-
data.offset = (startPage - 1) * pageSize;
|
|
1981
|
-
|
|
1982
|
-
instance.store.silently(() => {
|
|
1983
|
-
instance.set("records", records);
|
|
1984
|
-
instance.set("page", startPage);
|
|
1985
|
-
instance.set("totalRecordCount", totalRecordCount);
|
|
1986
|
-
});
|
|
1987
|
-
|
|
1988
|
-
let stateChanges = {
|
|
1989
|
-
startPage,
|
|
1990
|
-
endPage,
|
|
1991
|
-
};
|
|
1992
|
-
|
|
1993
|
-
if (this.state.end == 0) stateChanges.end = Math.min(widget.bufferSize, totalRecordCount);
|
|
1994
|
-
|
|
1995
|
-
this.setState(stateChanges, () => {
|
|
1996
|
-
this.loadingStartPage = startPage;
|
|
1997
|
-
this.loadingEndPage = endPage;
|
|
1998
|
-
this.onScroll();
|
|
1999
|
-
});
|
|
2000
|
-
})
|
|
2001
|
-
.catch((error) => {
|
|
2002
|
-
this.loading = false;
|
|
2003
|
-
if (widget.onLoadingError) instance.invoke(error, "onLoadingError", instance);
|
|
2004
|
-
});
|
|
2005
|
-
}, 30);
|
|
2006
|
-
|
|
2007
|
-
if (startPage < this.loadingStartPage || endPage > this.loadingEndPage) {
|
|
2008
|
-
this.loadingStartPage = startPage;
|
|
2009
|
-
this.loadingEndPage = endPage;
|
|
2010
|
-
this.loadPageRange(startPage, endPage);
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
onScroll() {
|
|
2015
|
-
//check if unmounted
|
|
2016
|
-
if (!this.dom.scroller) return;
|
|
2017
|
-
|
|
2018
|
-
if (this.dom.fixedHeader) {
|
|
2019
|
-
this.dom.fixedHeader.scrollLeft = this.dom.scroller.scrollLeft;
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
if (this.dom.fixedFooter) {
|
|
2023
|
-
this.dom.fixedFooter.scrollLeft = this.dom.scroller.scrollLeft;
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
|
-
if (this.dom.fixedScroller) {
|
|
2027
|
-
this.dom.fixedScroller.scrollTop = this.dom.scroller.scrollTop;
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
let { instance, data } = this.props;
|
|
2031
|
-
let { widget } = instance;
|
|
2032
|
-
if (widget.buffered && !this.pending) {
|
|
2033
|
-
let start = 0;
|
|
2034
|
-
if (widget.measureRowHeights && instance.records)
|
|
2035
|
-
start = Math.max(0, this.estimateStart(instance.records, this.dom.scroller.scrollTop) - widget.bufferStep);
|
|
2036
|
-
else if (this.rowHeight > 0)
|
|
2037
|
-
start = Math.round(this.dom.scroller.scrollTop / this.rowHeight - widget.bufferStep);
|
|
2038
|
-
|
|
2039
|
-
start = Math.round(start / widget.bufferStep) * widget.bufferStep;
|
|
2040
|
-
start = Math.max(0, Math.min(start, data.totalRecordCount - widget.bufferSize));
|
|
2041
|
-
let end = Math.min(data.totalRecordCount, start + widget.bufferSize);
|
|
2042
|
-
|
|
2043
|
-
if (widget.infinite) {
|
|
2044
|
-
this.ensureData(start, end);
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
if (this.syncBuffering) {
|
|
2048
|
-
this.start = start;
|
|
2049
|
-
this.end = end;
|
|
2050
|
-
} else if (this.state.end != end) {
|
|
2051
|
-
this.pending = true;
|
|
2052
|
-
this.setState({ start, end }, () => {
|
|
2053
|
-
this.pending = false;
|
|
2054
|
-
});
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
onFixedColumnsWheel(e) {
|
|
2060
|
-
this.dom.scroller.scrollTop += e.deltaY;
|
|
2061
|
-
e.preventDefault();
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
shouldComponentUpdate(props, state) {
|
|
2065
|
-
return props.shouldUpdate !== false || state !== this.state;
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
componentDidMount() {
|
|
2069
|
-
this.componentDidUpdate();
|
|
2070
|
-
let { instance } = this.props;
|
|
2071
|
-
let { widget } = instance;
|
|
2072
|
-
if (widget.scrollable) {
|
|
2073
|
-
//update fixed header/footer on resize
|
|
2074
|
-
this.offResize = ResizeManager.trackElement(this.dom.scroller, () => {
|
|
2075
|
-
requestAnimationFrame(() => {
|
|
2076
|
-
//ignore changes if the element is not visible on the page
|
|
2077
|
-
if (!this.dom.scroller?.offsetWidth) return;
|
|
2078
|
-
this.componentDidUpdate();
|
|
2079
|
-
instance.setState({
|
|
2080
|
-
dimensionsVersion: instance.state.dimensionsVersion + 1,
|
|
2081
|
-
lockedColWidth: {},
|
|
2082
|
-
});
|
|
2083
|
-
});
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
if (widget.pipeKeyDown) instance.invoke("pipeKeyDown", this.handleKeyDown.bind(this), instance);
|
|
2087
|
-
this.unregisterDropZone = registerDropZone(this);
|
|
2088
|
-
if (widget.infinite) this.ensureData(0, 0);
|
|
2089
|
-
if (this.dom.fixedScroller) {
|
|
2090
|
-
this.onFixedColumnsWheel = this.onFixedColumnsWheel.bind(this);
|
|
2091
|
-
this.dom.fixedScroller.addEventListener("wheel", this.onFixedColumnsWheel, { passive: false });
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
|
|
2095
|
-
onDragStart(e) {
|
|
2096
|
-
let { instance } = this.props;
|
|
2097
|
-
let { widget } = instance;
|
|
2098
|
-
if (widget.onDragStart) instance.invoke("onDragStart", e, instance);
|
|
2099
|
-
}
|
|
2100
|
-
|
|
2101
|
-
onDrop(e) {
|
|
2102
|
-
try {
|
|
2103
|
-
let { instance } = this.props;
|
|
2104
|
-
let { widget } = instance;
|
|
2105
|
-
let { start } = this.getBufferStartEnd();
|
|
2106
|
-
let { dropInsertionIndex, dropTarget, dropNextToTheRowAbove } = this.state;
|
|
2107
|
-
if (dropTarget == "grid" && widget.onDrop && dropInsertionIndex != null) {
|
|
2108
|
-
e.target = {
|
|
2109
|
-
insertionIndex: start + dropInsertionIndex,
|
|
2110
|
-
recordBefore: this.getDataRecordAt(start + dropInsertionIndex - 1),
|
|
2111
|
-
recordAfter: this.getDataRecordAt(start + dropInsertionIndex),
|
|
2112
|
-
dropNextToTheRowAbove,
|
|
2113
|
-
};
|
|
2114
|
-
instance.invoke("onDrop", e, instance);
|
|
2115
|
-
} else if (dropTarget == "row") {
|
|
2116
|
-
e.target = {
|
|
2117
|
-
index: start + dropInsertionIndex,
|
|
2118
|
-
record: this.getDataRecordAt(start + dropInsertionIndex),
|
|
2119
|
-
};
|
|
2120
|
-
instance.invoke("onRowDrop", e, instance);
|
|
2121
|
-
} else if (dropTarget == "column" && widget.onColumnDrop) {
|
|
2122
|
-
e.target = {
|
|
2123
|
-
index: this.state.colDropInsertionIndex,
|
|
2124
|
-
grid: widget,
|
|
2125
|
-
instance,
|
|
2126
|
-
};
|
|
2127
|
-
instance.invoke("onColumnDrop", e, instance);
|
|
2128
|
-
}
|
|
2129
|
-
} catch (err) {
|
|
2130
|
-
console.error("Grid drop operation failed. Please fix this error:", err);
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
|
-
//in some cases drop operation is not followed by leave
|
|
2134
|
-
this.onDragLeave(e);
|
|
2135
|
-
}
|
|
2136
|
-
|
|
2137
|
-
onDropTest(e) {
|
|
2138
|
-
let { instance } = this.props;
|
|
2139
|
-
let { widget } = instance;
|
|
2140
|
-
let grid = widget.onDropTest && instance.invoke("onDropTest", e, instance);
|
|
2141
|
-
let row = widget.onRowDropTest && instance.invoke("onRowDropTest", e, instance);
|
|
2142
|
-
let column = widget.onColumnDropTest && instance.invoke("onColumnDropTest", e, instance);
|
|
2143
|
-
return (grid || row || column) && { grid, row, column };
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
onDragEnd(e) {
|
|
2147
|
-
this.setState({
|
|
2148
|
-
dropTarget: null,
|
|
2149
|
-
dropInsertionIndex: null,
|
|
2150
|
-
colDropInsertionIndex: null,
|
|
2151
|
-
colDropInsertionLeft: null,
|
|
2152
|
-
});
|
|
2153
|
-
let { instance } = this.props;
|
|
2154
|
-
let { widget } = instance;
|
|
2155
|
-
if (widget.onDragEnd) instance.invoke("onDragEnd", e, instance);
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
|
-
onDragMeasure(e, { test: { grid, row, column } }) {
|
|
2159
|
-
//columns can be dropped anywhere, while rows only in the scrollable area
|
|
2160
|
-
let r = getTopLevelBoundingClientRect(column ? this.dom.el : this.dom.scroller);
|
|
2161
|
-
let { clientX, clientY } = e.cursor;
|
|
2162
|
-
|
|
2163
|
-
if (clientX < r.left || clientX >= r.right || clientY < r.top || clientY >= r.bottom) return false;
|
|
2164
|
-
|
|
2165
|
-
return {
|
|
2166
|
-
over: 1000,
|
|
2167
|
-
};
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
onColumnDragOver(ev) {
|
|
2171
|
-
let headerTBody = this.dom.table.firstChild;
|
|
2172
|
-
let positions = [];
|
|
2173
|
-
let bounds;
|
|
2174
|
-
|
|
2175
|
-
let exists = {};
|
|
2176
|
-
|
|
2177
|
-
for (let r = 0; r < headerTBody.children.length; r++) {
|
|
2178
|
-
let cells = headerTBody.children[r].children;
|
|
2179
|
-
for (let c = 0; c < cells.length; c++) {
|
|
2180
|
-
bounds = cells[c].getBoundingClientRect();
|
|
2181
|
-
let key = bounds.left.toFixed(0);
|
|
2182
|
-
if (exists[key]) continue;
|
|
2183
|
-
positions.push(bounds.left);
|
|
2184
|
-
exists[key] = true;
|
|
2185
|
-
}
|
|
2186
|
-
if (r == 0) positions.push(bounds.right);
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
//due to the order of enumeration it's possible that positions are out of order
|
|
2190
|
-
positions.sort((a, b) => a - b);
|
|
2191
|
-
let index = 0;
|
|
2192
|
-
while (index + 1 < positions.length && ev.cursor.clientX > positions[index + 1]) index++;
|
|
2193
|
-
|
|
2194
|
-
let { fixedColumnCount } = this.props.instance;
|
|
2195
|
-
|
|
2196
|
-
this.setState({
|
|
2197
|
-
colDropInsertionIndex: fixedColumnCount + index,
|
|
2198
|
-
colDropInsertionLeft:
|
|
2199
|
-
positions[index] - positions[0] - this.dom.scroller.scrollLeft + this.dom.scroller.offsetLeft,
|
|
2200
|
-
dropTarget: "column",
|
|
2201
|
-
});
|
|
2202
|
-
}
|
|
2203
|
-
|
|
2204
|
-
onDragOver(ev, { test: { grid, row, column } }) {
|
|
2205
|
-
if (column) this.onColumnDragOver(ev);
|
|
2206
|
-
|
|
2207
|
-
if (!grid && !row) return;
|
|
2208
|
-
|
|
2209
|
-
let { instance } = this.props;
|
|
2210
|
-
let { widget, data } = instance;
|
|
2211
|
-
let { CSS, baseClass } = widget;
|
|
2212
|
-
let rowClass = CSS.element(baseClass, "data");
|
|
2213
|
-
let nodes = Array.from(this.dom.table.children).filter(
|
|
2214
|
-
(node) => node.className && node.className.indexOf(rowClass) != -1,
|
|
2215
|
-
);
|
|
2216
|
-
let { start } = this.getBufferStartEnd();
|
|
2217
|
-
|
|
2218
|
-
let s = 0,
|
|
2219
|
-
e = nodes.length,
|
|
2220
|
-
m,
|
|
2221
|
-
b;
|
|
2222
|
-
let parentOffset = getParentFrameBoundingClientRect(this.dom.scroller);
|
|
2223
|
-
let cy = ev.cursor.clientY - parentOffset.top;
|
|
2224
|
-
|
|
2225
|
-
let rowOverIndex = null;
|
|
2226
|
-
let nextToTheRowAbove = false;
|
|
2227
|
-
|
|
2228
|
-
while (s < e) {
|
|
2229
|
-
m = Math.floor((s + e) / 2);
|
|
2230
|
-
b = nodes[m].getBoundingClientRect();
|
|
2231
|
-
|
|
2232
|
-
//dragged items might be invisible and have no client bounds
|
|
2233
|
-
if (b.top == 0 && b.bottom == 0) {
|
|
2234
|
-
//it's important to go all the way in one direction otherwise infinite loop might occur
|
|
2235
|
-
while (m > s && b.top == 0 && b.bottom == 0) {
|
|
2236
|
-
m--;
|
|
2237
|
-
b = nodes[m].getBoundingClientRect();
|
|
2238
|
-
}
|
|
2239
|
-
while (m + 1 < e && b.top == 0 && b.bottom == 0) {
|
|
2240
|
-
m = m + 1;
|
|
2241
|
-
b = nodes[m].getBoundingClientRect();
|
|
2242
|
-
}
|
|
2243
|
-
if (b.top == 0 && b.bottom == 0) {
|
|
2244
|
-
s = e = m;
|
|
2245
|
-
break;
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
|
-
if (cy < b.top) e = m;
|
|
2250
|
-
else if (cy > b.bottom) s = m + 1;
|
|
2251
|
-
else {
|
|
2252
|
-
//hovering over a row here
|
|
2253
|
-
if (row) {
|
|
2254
|
-
let confirmed = !grid;
|
|
2255
|
-
if (!confirmed) {
|
|
2256
|
-
let insertionZone = (b.bottom - b.top) / 4;
|
|
2257
|
-
confirmed = cy > b.top + insertionZone && cy < b.bottom - insertionZone;
|
|
2258
|
-
}
|
|
2259
|
-
if (confirmed) {
|
|
2260
|
-
rowOverIndex = m;
|
|
2261
|
-
break;
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
|
|
2265
|
-
if (cy > (b.bottom + b.top) / 2) {
|
|
2266
|
-
s = e = m + 1;
|
|
2267
|
-
nextToTheRowAbove = true;
|
|
2268
|
-
} else s = e = m;
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
|
|
2272
|
-
let cancel = false;
|
|
2273
|
-
|
|
2274
|
-
if (rowOverIndex != null) {
|
|
2275
|
-
let evt = {
|
|
2276
|
-
...ev,
|
|
2277
|
-
target: {
|
|
2278
|
-
record: this.getRecordAt(rowOverIndex),
|
|
2279
|
-
index: start + rowOverIndex,
|
|
2280
|
-
},
|
|
2281
|
-
};
|
|
2282
|
-
if (widget.onRowDragOver && instance.invoke("onRowDragOver", evt, instance) === false) cancel = true;
|
|
2283
|
-
else if (rowOverIndex != this.state.dropInsertionIndex || this.state.dropTarget != "row") {
|
|
2284
|
-
this.setState({
|
|
2285
|
-
dropInsertionIndex: rowOverIndex,
|
|
2286
|
-
dropNextToTheRowAbove: false,
|
|
2287
|
-
dropItemHeight: ev.source.height - 1,
|
|
2288
|
-
dropTarget: "row",
|
|
2289
|
-
});
|
|
2290
|
-
}
|
|
2291
|
-
} else if (grid) {
|
|
2292
|
-
let evt = {
|
|
2293
|
-
...ev,
|
|
2294
|
-
target: {
|
|
2295
|
-
recordBefore: this.getRecordAt(s - 1),
|
|
2296
|
-
recordAfter: this.getRecordAt(s),
|
|
2297
|
-
insertionIndex: start + s,
|
|
2298
|
-
totalRecordCount: data.totalRecordCount,
|
|
2299
|
-
},
|
|
2300
|
-
};
|
|
2301
|
-
if (widget.onDragOver && instance.invoke("onDragOver", evt, instance) === false) cancel = true;
|
|
2302
|
-
else if (s != this.state.dropInsertionIndex || this.state.dropTarget != "grid") {
|
|
2303
|
-
this.setState({
|
|
2304
|
-
dropInsertionIndex: s,
|
|
2305
|
-
dropNextToTheRowAbove: nextToTheRowAbove,
|
|
2306
|
-
dropItemHeight: ev.source.height - 1,
|
|
2307
|
-
dropTarget: "grid",
|
|
2308
|
-
});
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
|
-
if (cancel) {
|
|
2312
|
-
this.setState({
|
|
2313
|
-
dropInsertionIndex: null,
|
|
2314
|
-
dropNextToTheRowAbove: null,
|
|
2315
|
-
dropTarget: null,
|
|
2316
|
-
});
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
|
-
onDragLeave(e) {
|
|
2321
|
-
this.setState({
|
|
2322
|
-
dropInsertionIndex: null,
|
|
2323
|
-
dropNextToTheRowAbove: null,
|
|
2324
|
-
dropTarget: null,
|
|
2325
|
-
});
|
|
2326
|
-
}
|
|
2327
|
-
|
|
2328
|
-
onGetHScrollParent() {
|
|
2329
|
-
let { widget } = this.props.instance;
|
|
2330
|
-
if (widget.scrollable) return this.dom.scroller;
|
|
2331
|
-
return findScrollableParent(this.dom.table, true);
|
|
2332
|
-
}
|
|
2333
|
-
|
|
2334
|
-
onGetVScrollParent({ test: { grid, row, column } }) {
|
|
2335
|
-
if (column && !grid && !row) return null;
|
|
2336
|
-
let { widget } = this.props.instance;
|
|
2337
|
-
if (widget.scrollable) return this.dom.scroller;
|
|
2338
|
-
return findScrollableParent(this.dom.table);
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
|
-
UNSAFE_componentWillReceiveProps(props) {
|
|
2342
|
-
let { data, widget } = props.instance;
|
|
2343
|
-
if (this.state.cursor >= data.totalRecordCount)
|
|
2344
|
-
this.setState({
|
|
2345
|
-
cursor: data.totalRecordCount - 1,
|
|
2346
|
-
});
|
|
2347
|
-
else if (widget.selectable && this.state.focused && this.state.cursor < 0)
|
|
2348
|
-
this.setState({
|
|
2349
|
-
cursor: 0,
|
|
2350
|
-
});
|
|
2351
|
-
}
|
|
2352
|
-
|
|
2353
|
-
componentWillUnmount() {
|
|
2354
|
-
let { instance } = this.props;
|
|
2355
|
-
let { widget } = instance;
|
|
2356
|
-
if (this.offResize) this.offResize();
|
|
2357
|
-
|
|
2358
|
-
offFocusOut(this);
|
|
2359
|
-
|
|
2360
|
-
if (this.unregisterDropZone) this.unregisterDropZone();
|
|
2361
|
-
|
|
2362
|
-
if (widget.pipeKeyDown) instance.invoke("pipeKeyDown", null, instance);
|
|
2363
|
-
|
|
2364
|
-
if (this.dom.fixedScroller) {
|
|
2365
|
-
this.dom.fixedScroller.removeEventListener("wheel", this.onFixedColumnsWheel);
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
|
|
2369
|
-
estimateHeight(records, start, end, breakCondition) {
|
|
2370
|
-
let avgDataRowHeight = this.heightStats.estimate("data");
|
|
2371
|
-
let totalHeight = 0;
|
|
2372
|
-
for (let i = start; i < end; i++) {
|
|
2373
|
-
let record = records[i];
|
|
2374
|
-
switch (record.type) {
|
|
2375
|
-
case "data":
|
|
2376
|
-
if (record.key in this.rowHeights) totalHeight += this.rowHeights[record.key];
|
|
2377
|
-
else totalHeight += avgDataRowHeight;
|
|
2378
|
-
break;
|
|
2379
|
-
|
|
2380
|
-
case "group-header":
|
|
2381
|
-
if (record.grouping.showCaption) {
|
|
2382
|
-
let captionKey = "group-caption-" + record.level;
|
|
2383
|
-
if (`${captionKey}-${record.group.$key}` in this.rowHeights)
|
|
2384
|
-
totalHeight += this.rowHeights[`${captionKey}-${record.group.$key}`];
|
|
2385
|
-
else totalHeight += this.heightStats.estimate(captionKey) || avgDataRowHeight;
|
|
2386
|
-
}
|
|
2387
|
-
break;
|
|
2388
|
-
|
|
2389
|
-
case "group-footer":
|
|
2390
|
-
if (record.grouping.showFooter) {
|
|
2391
|
-
let captionKey = "group-footer-" + record.level;
|
|
2392
|
-
if (`${captionKey}-${record.group.$key}` in this.rowHeights)
|
|
2393
|
-
totalHeight += this.rowHeights[`${captionKey}-${record.group.$key}`];
|
|
2394
|
-
else totalHeight += this.heightStats.estimate(captionKey) || avgDataRowHeight;
|
|
2395
|
-
}
|
|
2396
|
-
break;
|
|
2397
|
-
|
|
2398
|
-
default:
|
|
2399
|
-
Console.warn("UNPROCESSED RECORD TYPE", record);
|
|
2400
|
-
break;
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
|
-
if (breakCondition && breakCondition(i, totalHeight) === false) break;
|
|
2404
|
-
}
|
|
2405
|
-
return totalHeight;
|
|
2406
|
-
}
|
|
2407
|
-
|
|
2408
|
-
estimateStart(records, height) {
|
|
2409
|
-
let start = 0;
|
|
2410
|
-
if (height == 0) return 0;
|
|
2411
|
-
this.estimateHeight(records, 0, records.length, (index, h) => {
|
|
2412
|
-
start = index;
|
|
2413
|
-
return h < height;
|
|
2414
|
-
});
|
|
2415
|
-
return start;
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
componentDidUpdate() {
|
|
2419
|
-
let { instance, data } = this.props;
|
|
2420
|
-
let { widget, fixedFooterOverlap } = instance;
|
|
2421
|
-
|
|
2422
|
-
if (
|
|
2423
|
-
widget.lockColumnWidths &&
|
|
2424
|
-
isArray(data.records) &&
|
|
2425
|
-
data.records.length >= widget.lockColumnWidthsRequiredRowCount
|
|
2426
|
-
) {
|
|
2427
|
-
let headerTBody = this.dom.table.firstChild;
|
|
2428
|
-
for (let r = 0; r < headerTBody.children.length; r++) {
|
|
2429
|
-
let sr = headerTBody.children[r];
|
|
2430
|
-
for (let c = 0; c < sr.children.length; c++) {
|
|
2431
|
-
let cell = sr.children[c];
|
|
2432
|
-
cell.style.width = cell.style.minWidth = cell.style.maxWidth = `${sr.children[c].offsetWidth}px`;
|
|
2433
|
-
cell.style.boxSizing = "border-box";
|
|
2434
|
-
if (cell.dataset.uniqueColId)
|
|
2435
|
-
instance.state.lockedColWidth[cell.dataset.uniqueColId] = sr.children[c].offsetWidth;
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
if (widget.scrollable) {
|
|
2441
|
-
this.scrollWidth = this.dom.scroller.offsetWidth - this.dom.scroller.clientWidth;
|
|
2442
|
-
|
|
2443
|
-
let resized = false,
|
|
2444
|
-
headerHeight = 0,
|
|
2445
|
-
footerHeight = 0,
|
|
2446
|
-
rowHeight = 0;
|
|
2447
|
-
|
|
2448
|
-
if (this.dom.fixedTable) syncHeaderHeights(this.dom.table.firstChild, this.dom.fixedTable.firstChild);
|
|
2449
|
-
|
|
2450
|
-
if (this.dom.fixedHeader) {
|
|
2451
|
-
let fixedHeaderTBody = this.dom.fixedHeader.firstChild.firstChild;
|
|
2452
|
-
|
|
2453
|
-
resized = widget.preciseMeasurements
|
|
2454
|
-
? copyCellSizePrecise(this.dom.table.firstChild, fixedHeaderTBody)
|
|
2455
|
-
: copyCellSize(this.dom.table.firstChild, fixedHeaderTBody);
|
|
2456
|
-
|
|
2457
|
-
let scrollColumnEl = fixedHeaderTBody.firstChild.lastChild;
|
|
2458
|
-
if (scrollColumnEl) scrollColumnEl.style.minWidth = scrollColumnEl.style.maxWidth = this.scrollWidth + "px";
|
|
2459
|
-
|
|
2460
|
-
this.dom.fixedHeader.style.display = "block";
|
|
2461
|
-
headerHeight = this.dom.fixedHeader.offsetHeight;
|
|
2462
|
-
this.dom.scroller.style.marginTop = `${headerHeight}px`;
|
|
2463
|
-
if (this.dom.fixedScroller) this.dom.fixedScroller.style.marginTop = `${headerHeight}px`;
|
|
2464
|
-
else if (this.dom.fixedHeader.style.left != null) this.dom.fixedHeader.style.left = null;
|
|
2465
|
-
} else {
|
|
2466
|
-
this.dom.scroller.style.marginTop = 0;
|
|
2467
|
-
if (this.dom.fixedScroller) this.dom.fixedScroller.style.marginTop = 0;
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2470
|
-
if (this.dom.fixedColumnsFixedHeader) {
|
|
2471
|
-
let fixedColumnsWidth = `${this.dom.fixedScroller.offsetWidth}px`;
|
|
2472
|
-
this.dom.fixedColumnsFixedHeader.style.right = "auto";
|
|
2473
|
-
this.dom.fixedColumnsFixedHeader.style.width = fixedColumnsWidth;
|
|
2474
|
-
if (this.dom.fixedHeader) this.dom.fixedHeader.style.left = fixedColumnsWidth;
|
|
2475
|
-
|
|
2476
|
-
this.dom.fixedColumnsFixedHeader.style.display = "block";
|
|
2477
|
-
|
|
2478
|
-
let fixedHeaderTBody = this.dom.fixedColumnsFixedHeader.firstChild.firstChild;
|
|
2479
|
-
|
|
2480
|
-
if (this.dom.fixedTable.firstChild) {
|
|
2481
|
-
resized = copyCellSize(this.dom.fixedTable.firstChild, fixedHeaderTBody);
|
|
2482
|
-
}
|
|
2483
|
-
}
|
|
2484
|
-
|
|
2485
|
-
if (this.dom.fixedFooter || this.dom.fixedColumnsFixedFooter) {
|
|
2486
|
-
if (this.dom.fixedColumnsFixedFooter) {
|
|
2487
|
-
let fixedColumnsWidth = `${this.dom.fixedScroller.offsetWidth}px`;
|
|
2488
|
-
this.dom.fixedColumnsFixedFooter.style.right = "auto";
|
|
2489
|
-
this.dom.fixedColumnsFixedFooter.style.width = fixedColumnsWidth;
|
|
2490
|
-
|
|
2491
|
-
let dstTableBody = this.dom.fixedColumnsFixedFooter.firstChild.firstChild;
|
|
2492
|
-
if (dstTableBody) {
|
|
2493
|
-
let srcTableBody = this.dom.fixedTable.lastChild;
|
|
2494
|
-
copyCellSize(srcTableBody, dstTableBody, fixedFooterOverlap);
|
|
2495
|
-
this.dom.fixedColumnsFixedFooter.style.display = "block";
|
|
2496
|
-
footerHeight = this.dom.fixedFooter.offsetHeight;
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
|
-
if (this.dom.fixedFooter) {
|
|
2501
|
-
let dstTableBody = this.dom.fixedFooter.firstChild.firstChild;
|
|
2502
|
-
|
|
2503
|
-
if (dstTableBody) {
|
|
2504
|
-
let srcTableBody = this.dom.table.lastChild;
|
|
2505
|
-
|
|
2506
|
-
copyCellSize(srcTableBody, dstTableBody, fixedFooterOverlap);
|
|
2507
|
-
|
|
2508
|
-
let scrollColumnEl = dstTableBody.firstChild.lastChild;
|
|
2509
|
-
if (scrollColumnEl)
|
|
2510
|
-
scrollColumnEl.style.minWidth = scrollColumnEl.style.maxWidth = this.scrollWidth + "px";
|
|
2511
|
-
|
|
2512
|
-
this.dom.fixedFooter.style.display = "block";
|
|
2513
|
-
footerHeight = this.dom.fixedFooter.offsetHeight;
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2516
|
-
if (this.dom.fixedScroller) this.dom.fixedFooter.style.left = `${this.dom.fixedScroller.offsetWidth}px`;
|
|
2517
|
-
else if (this.dom.fixedFooter.style.left != null) this.dom.fixedFooter.style.left = null;
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
this.dom.scroller.style.marginBottom = `${footerHeight}px`;
|
|
2521
|
-
if (this.dom.fixedScroller) this.dom.fixedScroller.style.marginBottom = `${footerHeight}px`;
|
|
2522
|
-
} else {
|
|
2523
|
-
this.dom.scroller.style.marginBottom = 0;
|
|
2524
|
-
if (this.dom.fixedScroller) this.dom.fixedScroller.style.marginBottom = 0;
|
|
2525
|
-
}
|
|
2526
|
-
|
|
2527
|
-
let scrollOverlap = fixedFooterOverlap ? footerHeight : 0;
|
|
2528
|
-
|
|
2529
|
-
if (widget.buffered) {
|
|
2530
|
-
let { start, end } = this.getBufferStartEnd();
|
|
2531
|
-
let remaining = 0,
|
|
2532
|
-
count = Math.min(data.totalRecordCount, end - start);
|
|
2533
|
-
|
|
2534
|
-
if (widget.measureRowHeights) {
|
|
2535
|
-
if (!this.rowHeights) this.rowHeights = {};
|
|
2536
|
-
if (!this.heightStats) this.heightStats = new AvgHeight();
|
|
2537
|
-
for (let i = 0; i < this.dom.table.children.length; i++) {
|
|
2538
|
-
let body = this.dom.table.children[i];
|
|
2539
|
-
if (body.dataset.recordKey != null) {
|
|
2540
|
-
if (!(body.dataset.recordKey in this.rowHeights)) this.heightStats.add("data", body.offsetHeight);
|
|
2541
|
-
this.rowHeights[body.dataset.recordKey] = body.offsetHeight;
|
|
2542
|
-
} else if (body.dataset.groupKey) {
|
|
2543
|
-
let key = body.dataset.groupElement + "-" + body.dataset.groupKey;
|
|
2544
|
-
this.rowHeights[key] = body.offsetHeight;
|
|
2545
|
-
if (!(body.dataset.recordKey in this.rowHeights))
|
|
2546
|
-
this.heightStats.add(body.dataset.groupElement, body.offsetHeight);
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
}
|
|
2550
|
-
|
|
2551
|
-
if (count > 0) {
|
|
2552
|
-
//do not change row height while a drag-drop operation is in place
|
|
2553
|
-
rowHeight = this.state.dragged
|
|
2554
|
-
? this.rowHeight
|
|
2555
|
-
: Math.round((this.dom.table.offsetHeight - headerHeight) / count);
|
|
2556
|
-
// if (this.rowHeight && this.rowHeight != rowHeight) {
|
|
2557
|
-
// console.warn("ROW-HEIGHT-CHANGE", this.rowHeight, rowHeight);
|
|
2558
|
-
// }
|
|
2559
|
-
remaining = Math.max(0, data.totalRecordCount - end);
|
|
2560
|
-
}
|
|
2561
|
-
|
|
2562
|
-
let upperMargin = 0,
|
|
2563
|
-
lowerMargin = 0;
|
|
2564
|
-
if (widget.measureRowHeights && instance.records) {
|
|
2565
|
-
upperMargin = this.estimateHeight(instance.records, 0, start);
|
|
2566
|
-
lowerMargin = this.estimateHeight(instance.records, end, instance.records.length);
|
|
2567
|
-
} else {
|
|
2568
|
-
upperMargin = start * rowHeight;
|
|
2569
|
-
lowerMargin = remaining * rowHeight;
|
|
2570
|
-
}
|
|
2571
|
-
|
|
2572
|
-
//console.log(upperMargin, start * rowHeight, this.rowHeights, this.heightStats);
|
|
2573
|
-
|
|
2574
|
-
this.dom.table.style.marginTop = `${(-headerHeight + upperMargin).toFixed(0)}px`;
|
|
2575
|
-
this.dom.table.style.marginBottom = `${(lowerMargin - scrollOverlap).toFixed(0)}px`;
|
|
2576
|
-
} else {
|
|
2577
|
-
this.dom.table.style.marginTop = `${-headerHeight}px`;
|
|
2578
|
-
this.dom.table.style.marginBottom = `${-scrollOverlap}px`;
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2581
|
-
if (this.dom.fixedTable) {
|
|
2582
|
-
this.dom.fixedTable.style.marginTop = this.dom.table.style.marginTop;
|
|
2583
|
-
this.dom.fixedTable.style.marginBottom = this.dom.table.style.marginBottom;
|
|
2584
|
-
}
|
|
2585
|
-
|
|
2586
|
-
this.rowHeight = rowHeight;
|
|
2587
|
-
|
|
2588
|
-
let sortersChanged = widget.infinite && !shallowEquals(data.sorters, this.lastSorters);
|
|
2589
|
-
|
|
2590
|
-
if (data.empty && !widget.infinite) {
|
|
2591
|
-
this.dom.scroller.scrollTop = 0;
|
|
2592
|
-
}
|
|
2593
|
-
|
|
2594
|
-
if (
|
|
2595
|
-
sortersChanged ||
|
|
2596
|
-
data.filterParams !== this.lastScrollFilterParams ||
|
|
2597
|
-
data.scrollResetParams !== this.lastScrollResetParams
|
|
2598
|
-
) {
|
|
2599
|
-
this.dom.scroller.scrollTop = 0;
|
|
2600
|
-
this.lastScrollFilterParams = data.filterParams;
|
|
2601
|
-
this.lastScrollResetParams = data.scrollResetParams;
|
|
2602
|
-
this.lastSorters = data.sorters;
|
|
2603
|
-
if (widget.infinite) {
|
|
2604
|
-
this.loadingStartPage = 0;
|
|
2605
|
-
this.loadingEndPage = 0;
|
|
2606
|
-
instance.buffer.records = data.records = [];
|
|
2607
|
-
instance.buffer.totalRecordCount = 0;
|
|
2608
|
-
instance.buffer.page = 1;
|
|
2609
|
-
this.prevFetchRecordsState = null;
|
|
2610
|
-
this.loading = false;
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
|
|
2614
|
-
if (widget.scrollSelectionIntoView && !widget.buffered) {
|
|
2615
|
-
let { CSS, baseClass } = widget;
|
|
2616
|
-
let selectedRowSelector = `.${CSS.element(baseClass, "data")}.${CSS.state("selected")}`;
|
|
2617
|
-
let firstSelectedRow = this.dom.table.querySelector(selectedRowSelector);
|
|
2618
|
-
if (firstSelectedRow != this.selectedEl) {
|
|
2619
|
-
firstSelectedRow && scrollElementIntoView(firstSelectedRow);
|
|
2620
|
-
this.selectedEl = firstSelectedRow;
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
|
|
2624
|
-
setTimeout(this.onScroll.bind(this), 0);
|
|
2625
|
-
|
|
2626
|
-
if (resized) instance.fixedHeaderResizeEvent.notify();
|
|
2627
|
-
}
|
|
2628
|
-
}
|
|
2629
|
-
|
|
2630
|
-
moveCursor(
|
|
2631
|
-
index,
|
|
2632
|
-
{ focused, hover, scrollIntoView, select, selectRange, selectOptions, cellIndex, cellEdit, cancelEdit } = {},
|
|
2633
|
-
) {
|
|
2634
|
-
let { widget, visibleColumns } = this.props.instance;
|
|
2635
|
-
if (!widget.selectable && !widget.cellEditable) return;
|
|
2636
|
-
|
|
2637
|
-
let newState = {};
|
|
2638
|
-
|
|
2639
|
-
if (cellEdit != null && cellEdit != this.state.cellEdit) {
|
|
2640
|
-
newState.cellEdit = cellEdit;
|
|
2641
|
-
if (
|
|
2642
|
-
cellEdit &&
|
|
2643
|
-
(!visibleColumns[this.state.cursorCellIndex] || !visibleColumns[this.state.cursorCellIndex].editor)
|
|
2644
|
-
)
|
|
2645
|
-
newState.cellEdit = false;
|
|
2646
|
-
}
|
|
2647
|
-
|
|
2648
|
-
if (cellIndex != null && cellIndex != this.state.cursorCellIndex) {
|
|
2649
|
-
newState.cursorCellIndex = cellIndex;
|
|
2650
|
-
newState.cellEdit = false;
|
|
2651
|
-
}
|
|
2652
|
-
|
|
2653
|
-
if (widget.focused) focused = true;
|
|
2654
|
-
|
|
2655
|
-
if (focused != null && this.state.focused != focused) {
|
|
2656
|
-
newState.focused = focused;
|
|
2657
|
-
newState.cellEdit = false;
|
|
2658
|
-
}
|
|
2659
|
-
|
|
2660
|
-
if (index != this.state.cursor) {
|
|
2661
|
-
newState.cursor = index;
|
|
2662
|
-
newState.cellEdit = false;
|
|
2663
|
-
}
|
|
2664
|
-
|
|
2665
|
-
batchUpdates(() => {
|
|
2666
|
-
if (select) {
|
|
2667
|
-
let start = selectRange && this.state.selectionStart >= 0 ? this.state.selectionStart : index;
|
|
2668
|
-
if (start < 0) start = index;
|
|
2669
|
-
this.selectRange(start, index, selectOptions);
|
|
2670
|
-
if (!selectRange) newState.selectionStart = index;
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
if (Object.keys(newState).length > 0) {
|
|
2674
|
-
let prevState = this.state;
|
|
2675
|
-
let wasCellEditing = prevState.focused && prevState.cellEdit;
|
|
2676
|
-
let futureState = { ...this.state, ...newState };
|
|
2677
|
-
|
|
2678
|
-
if (!futureState.cellEdit && wasCellEditing) {
|
|
2679
|
-
// If cell editing is in progress, moving the cursor may cause that the cell editor to unmount before
|
|
2680
|
-
// the blur event which may cause data loss for components which do not have reactOn=change set, e.g. NumberField.
|
|
2681
|
-
unfocusElement(null, false);
|
|
2682
|
-
let record = this.getRecordAt(prevState.cursor);
|
|
2683
|
-
if ((!this.cellEditorValid || cancelEdit) && this.cellEditUndoData)
|
|
2684
|
-
record.store.set(widget.recordName, this.cellEditUndoData);
|
|
2685
|
-
else {
|
|
2686
|
-
let newData = record.store.get(widget.recordName); //record.data might be stale at this point
|
|
2687
|
-
if (widget.onCellEdited && newData != this.cellEditUndoData) {
|
|
2688
|
-
this.props.instance.invoke(
|
|
2689
|
-
"onCellEdited",
|
|
2690
|
-
{
|
|
2691
|
-
column: visibleColumns[prevState.cursorCellIndex],
|
|
2692
|
-
newData,
|
|
2693
|
-
oldData: this.cellEditUndoData,
|
|
2694
|
-
field: visibleColumns[prevState.cursorCellIndex].field,
|
|
2695
|
-
},
|
|
2696
|
-
record,
|
|
2697
|
-
);
|
|
2698
|
-
this.cellEditUndoData = newData;
|
|
2699
|
-
}
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
|
|
2703
|
-
if (futureState.cellEdit && !wasCellEditing) {
|
|
2704
|
-
let record = this.getRecordAt(futureState.cursor);
|
|
2705
|
-
let cellEditUndoData = record.data;
|
|
2706
|
-
|
|
2707
|
-
if (
|
|
2708
|
-
widget.onBeforeCellEdit &&
|
|
2709
|
-
this.props.instance.invoke(
|
|
2710
|
-
"onBeforeCellEdit",
|
|
2711
|
-
{
|
|
2712
|
-
column: visibleColumns[futureState.cursorCellIndex],
|
|
2713
|
-
data: cellEditUndoData,
|
|
2714
|
-
field: visibleColumns[futureState.cursorCellIndex].field,
|
|
2715
|
-
},
|
|
2716
|
-
record,
|
|
2717
|
-
) === false
|
|
2718
|
-
)
|
|
2719
|
-
return;
|
|
2720
|
-
|
|
2721
|
-
this.cellEditUndoData = cellEditUndoData;
|
|
2722
|
-
}
|
|
2723
|
-
|
|
2724
|
-
this.setState(newState, () => {
|
|
2725
|
-
if (this.state.focused && !this.state.cellEdit && wasCellEditing) FocusManager.focus(this.dom.el);
|
|
2726
|
-
|
|
2727
|
-
if (scrollIntoView) {
|
|
2728
|
-
let record = this.getRecordAt(index);
|
|
2729
|
-
|
|
2730
|
-
let item = record && this.dom.table.querySelector(`tbody[data-record-key="${record.key}"]`);
|
|
2731
|
-
|
|
2732
|
-
let hscroll = false;
|
|
2733
|
-
if (item) {
|
|
2734
|
-
if (widget.cellEditable)
|
|
2735
|
-
if (this.state.cursorCellIndex >= this.props.instance.fixedColumnCount) {
|
|
2736
|
-
hscroll = true;
|
|
2737
|
-
item =
|
|
2738
|
-
item.firstChild.children[
|
|
2739
|
-
this.state.cursorCellIndex - this.props.instance.fixedColumnCount
|
|
2740
|
-
];
|
|
2741
|
-
} else {
|
|
2742
|
-
let fixedItem = this.dom.fixedTable.querySelector(`tbody[data-record-key="${record.key}"]`);
|
|
2743
|
-
let cell = fixedItem && fixedItem.firstChild.children[this.state.cursorCellIndex];
|
|
2744
|
-
if (cell) scrollElementIntoView(cell, false, true, 10);
|
|
2745
|
-
}
|
|
2746
|
-
|
|
2747
|
-
scrollElementIntoView(item, true, hscroll, widget.cellEditable ? 10 : 0);
|
|
2748
|
-
}
|
|
2749
|
-
}
|
|
2750
|
-
});
|
|
2751
|
-
}
|
|
2752
|
-
});
|
|
2753
|
-
}
|
|
2754
|
-
|
|
2755
|
-
showCursor(focused) {
|
|
2756
|
-
let { records, isSelected } = this.props.instance;
|
|
2757
|
-
let cursor = this.state.cursor;
|
|
2758
|
-
if (cursor == -1) {
|
|
2759
|
-
if (records) {
|
|
2760
|
-
cursor = records.findIndex((x) => isSelected(x.data, x.index));
|
|
2761
|
-
//if there are no selected records, find the first data record (skip group header)
|
|
2762
|
-
if (cursor == -1) cursor = records.findIndex((x) => x.type == "data");
|
|
2763
|
-
} else cursor = 0;
|
|
2764
|
-
}
|
|
2765
|
-
this.moveCursor(cursor, { focused: true, scrollIntoView: false });
|
|
2766
|
-
}
|
|
2767
|
-
|
|
2768
|
-
onFocus() {
|
|
2769
|
-
FocusManager.nudge();
|
|
2770
|
-
|
|
2771
|
-
//focus moved within the grid
|
|
2772
|
-
if (this.state.focused) {
|
|
2773
|
-
if (this.state.cellEdit && this.dom.el == getActiveElement())
|
|
2774
|
-
this.moveCursor(this.state.cursor, {
|
|
2775
|
-
cellEdit: false,
|
|
2776
|
-
});
|
|
2777
|
-
return;
|
|
2778
|
-
}
|
|
2779
|
-
|
|
2780
|
-
let { widget } = this.props.instance;
|
|
2781
|
-
|
|
2782
|
-
//the cursor will be set if focus in originating from a mouse event
|
|
2783
|
-
setTimeout(() => {
|
|
2784
|
-
this.showCursor(true);
|
|
2785
|
-
}, 0);
|
|
2786
|
-
|
|
2787
|
-
if (!widget.focused) {
|
|
2788
|
-
if (this.dom.el) {
|
|
2789
|
-
//if an inner element is focused first (autoFocus), this.dom.el might be undefined
|
|
2790
|
-
oneFocusOut(this, this.dom.el, () => {
|
|
2791
|
-
this.moveCursor(-1, { focused: false });
|
|
2792
|
-
});
|
|
2793
|
-
}
|
|
2794
|
-
}
|
|
2795
|
-
|
|
2796
|
-
this.setState({
|
|
2797
|
-
focused: true,
|
|
2798
|
-
});
|
|
2799
|
-
}
|
|
2800
|
-
|
|
2801
|
-
onBlur() {
|
|
2802
|
-
FocusManager.nudge();
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2805
|
-
selectRange(from, to, options) {
|
|
2806
|
-
let { instance, data } = this.props;
|
|
2807
|
-
let { records, widget } = instance;
|
|
2808
|
-
|
|
2809
|
-
if (from > to) {
|
|
2810
|
-
let tmp = from;
|
|
2811
|
-
from = to;
|
|
2812
|
-
to = tmp;
|
|
2813
|
-
}
|
|
2814
|
-
|
|
2815
|
-
options = {
|
|
2816
|
-
...options,
|
|
2817
|
-
range: from < to,
|
|
2818
|
-
};
|
|
2819
|
-
|
|
2820
|
-
let selection = [],
|
|
2821
|
-
indexes = [];
|
|
2822
|
-
|
|
2823
|
-
for (let cursor = from; cursor <= to; cursor++) {
|
|
2824
|
-
let record;
|
|
2825
|
-
if (records) record = records[cursor];
|
|
2826
|
-
else {
|
|
2827
|
-
let offset = widget.infinite ? data.offset : 0;
|
|
2828
|
-
let r = data.records[cursor - offset];
|
|
2829
|
-
if (r) record = widget.mapRecord(null, instance, r, cursor - offset);
|
|
2830
|
-
}
|
|
2831
|
-
if (record && record.type == "data") {
|
|
2832
|
-
if (instance.isRecordSelectable && !instance.isRecordSelectable(record.data, options)) continue;
|
|
2833
|
-
selection.push(record.data);
|
|
2834
|
-
indexes.push(record.index);
|
|
2835
|
-
}
|
|
2836
|
-
}
|
|
2837
|
-
|
|
2838
|
-
widget.selection.selectMultiple(instance.store, selection, indexes, options);
|
|
2839
|
-
}
|
|
2840
|
-
|
|
2841
|
-
getDataRecordAt(index) {
|
|
2842
|
-
let { records } = this.props.instance;
|
|
2843
|
-
if (!records) return this.getRecordAt(index);
|
|
2844
|
-
let dataRecords = records.filter((r) => r.type == "data");
|
|
2845
|
-
return dataRecords[index];
|
|
2846
|
-
}
|
|
2847
|
-
|
|
2848
|
-
getRecordAt(cursor) {
|
|
2849
|
-
let { instance, data } = this.props;
|
|
2850
|
-
let { records, widget } = instance;
|
|
2851
|
-
|
|
2852
|
-
if (records) return records[cursor];
|
|
2853
|
-
|
|
2854
|
-
let offset = widget.infinite ? data.offset : 0;
|
|
2855
|
-
let r = data.records[cursor - offset];
|
|
2856
|
-
if (r) return widget.mapRecord(null, instance, r, cursor - offset);
|
|
2857
|
-
|
|
2858
|
-
return null;
|
|
2859
|
-
}
|
|
2860
|
-
|
|
2861
|
-
getRecordInstanceAt(cursor) {
|
|
2862
|
-
let record = this.getRecordAt(cursor);
|
|
2863
|
-
if (!record) return null;
|
|
2864
|
-
let { instance } = this.props;
|
|
2865
|
-
if (instance.recordInstanceCache)
|
|
2866
|
-
return instance.recordInstanceCache.getChild(instance.row, record.store, record.key);
|
|
2867
|
-
|
|
2868
|
-
//different signature
|
|
2869
|
-
return instance.getChild(null, instance.row, record.key, record.store);
|
|
2870
|
-
}
|
|
2871
|
-
|
|
2872
|
-
handleKeyDown(e) {
|
|
2873
|
-
let { instance, data } = this.props;
|
|
2874
|
-
let { widget } = instance;
|
|
2875
|
-
|
|
2876
|
-
if (widget.onKeyDown && instance.invoke("onKeyDown", e, instance) === false) return;
|
|
2877
|
-
|
|
2878
|
-
let recordInstance = this.getRecordInstanceAt(this.state.cursor);
|
|
2879
|
-
if (recordInstance && widget.onRowKeyDown && instance.invoke("onRowKeyDown", e, recordInstance) === false) return;
|
|
2880
|
-
|
|
2881
|
-
if (widget.onCellKeyDown && widget.cellEditable && this.state.cursorCellIndex != -1) {
|
|
2882
|
-
if (
|
|
2883
|
-
instance.invoke("onCellKeyDown", e, instance, {
|
|
2884
|
-
cellIndex: this.state.cursorCellIndex,
|
|
2885
|
-
record: recordInstance,
|
|
2886
|
-
}) === false
|
|
2887
|
-
)
|
|
2888
|
-
return;
|
|
2889
|
-
}
|
|
2890
|
-
|
|
2891
|
-
switch (e.keyCode) {
|
|
2892
|
-
case KeyCode.enter:
|
|
2893
|
-
this.moveCursor(this.state.cursor, {
|
|
2894
|
-
select: true,
|
|
2895
|
-
selectOptions: {
|
|
2896
|
-
toggle: e.ctrlKey && !e.shiftKey,
|
|
2897
|
-
add: e.ctrlKey && e.shiftKey,
|
|
2898
|
-
},
|
|
2899
|
-
selectRange: e.shiftKey,
|
|
2900
|
-
cellEdit: widget.cellEditable && !this.state.cellEdit,
|
|
2901
|
-
focused: true,
|
|
2902
|
-
});
|
|
2903
|
-
e.stopPropagation();
|
|
2904
|
-
e.preventDefault();
|
|
2905
|
-
break;
|
|
2906
|
-
|
|
2907
|
-
case KeyCode.esc:
|
|
2908
|
-
if (this.state.cellEdit) {
|
|
2909
|
-
this.moveCursor(this.state.cursor, {
|
|
2910
|
-
cellEdit: false,
|
|
2911
|
-
focused: true,
|
|
2912
|
-
cancelEdit: true,
|
|
2913
|
-
});
|
|
2914
|
-
e.stopPropagation();
|
|
2915
|
-
e.preventDefault();
|
|
2916
|
-
}
|
|
2917
|
-
break;
|
|
2918
|
-
|
|
2919
|
-
case KeyCode.tab:
|
|
2920
|
-
if (widget.cellEditable) {
|
|
2921
|
-
e.stopPropagation();
|
|
2922
|
-
e.preventDefault();
|
|
2923
|
-
let direction = e.shiftKey ? -1 : +1;
|
|
2924
|
-
let cursor = this.state.cursor;
|
|
2925
|
-
let cellIndex = (this.state.cursorCellIndex + direction) % instance.row.line1.columns.length;
|
|
2926
|
-
if (cellIndex == -1) {
|
|
2927
|
-
cellIndex += instance.row.line1.columns.length;
|
|
2928
|
-
cursor--;
|
|
2929
|
-
} else if (cellIndex == 0 && direction > 0) cursor++;
|
|
2930
|
-
for (; ; cursor += direction) {
|
|
2931
|
-
let record = this.getRecordAt(cursor);
|
|
2932
|
-
if (!record) break;
|
|
2933
|
-
if (record.type != "data") continue;
|
|
2934
|
-
this.moveCursor(cursor, {
|
|
2935
|
-
focused: true,
|
|
2936
|
-
cellIndex,
|
|
2937
|
-
scrollIntoView: true,
|
|
2938
|
-
cellEdit: false,
|
|
2939
|
-
});
|
|
2940
|
-
break;
|
|
2941
|
-
}
|
|
2942
|
-
}
|
|
2943
|
-
break;
|
|
2944
|
-
|
|
2945
|
-
case KeyCode.down:
|
|
2946
|
-
for (let cursor = this.state.cursor + 1; ; cursor++) {
|
|
2947
|
-
let record = this.getRecordAt(cursor);
|
|
2948
|
-
if (!record) break;
|
|
2949
|
-
if (record.type != "data") continue;
|
|
2950
|
-
this.moveCursor(cursor, {
|
|
2951
|
-
focused: true,
|
|
2952
|
-
scrollIntoView: true,
|
|
2953
|
-
select: e.shiftKey,
|
|
2954
|
-
selectRange: e.shiftKey,
|
|
2955
|
-
});
|
|
2956
|
-
break;
|
|
2957
|
-
}
|
|
2958
|
-
e.stopPropagation();
|
|
2959
|
-
e.preventDefault();
|
|
2960
|
-
break;
|
|
2961
|
-
|
|
2962
|
-
case KeyCode.up:
|
|
2963
|
-
for (let cursor = this.state.cursor - 1; cursor >= 0; cursor--) {
|
|
2964
|
-
let record = this.getRecordAt(cursor);
|
|
2965
|
-
if (!record) break;
|
|
2966
|
-
if (record.type != "data") continue;
|
|
2967
|
-
this.moveCursor(cursor, {
|
|
2968
|
-
focused: true,
|
|
2969
|
-
scrollIntoView: true,
|
|
2970
|
-
select: e.shiftKey,
|
|
2971
|
-
selectRange: e.shiftKey,
|
|
2972
|
-
});
|
|
2973
|
-
break;
|
|
2974
|
-
}
|
|
2975
|
-
e.stopPropagation();
|
|
2976
|
-
e.preventDefault();
|
|
2977
|
-
break;
|
|
2978
|
-
|
|
2979
|
-
case KeyCode.right:
|
|
2980
|
-
if (widget.cellEditable) {
|
|
2981
|
-
if (this.state.cursorCellIndex + 1 < instance.row.line1.columns.length) {
|
|
2982
|
-
this.moveCursor(this.state.cursor, {
|
|
2983
|
-
focused: true,
|
|
2984
|
-
cellIndex: this.state.cursorCellIndex + 1,
|
|
2985
|
-
scrollIntoView: true,
|
|
2986
|
-
});
|
|
2987
|
-
}
|
|
2988
|
-
e.stopPropagation();
|
|
2989
|
-
e.preventDefault();
|
|
2990
|
-
}
|
|
2991
|
-
break;
|
|
2992
|
-
|
|
2993
|
-
case KeyCode.left:
|
|
2994
|
-
if (widget.cellEditable) {
|
|
2995
|
-
if (this.state.cursorCellIndex > 0) {
|
|
2996
|
-
this.moveCursor(this.state.cursor, {
|
|
2997
|
-
focused: true,
|
|
2998
|
-
cellIndex: this.state.cursorCellIndex - 1,
|
|
2999
|
-
scrollIntoView: true,
|
|
3000
|
-
});
|
|
3001
|
-
}
|
|
3002
|
-
e.stopPropagation();
|
|
3003
|
-
e.preventDefault();
|
|
3004
|
-
}
|
|
3005
|
-
break;
|
|
3006
|
-
|
|
3007
|
-
case KeyCode.a:
|
|
3008
|
-
if (!e.ctrlKey || !widget.selection.multiple) return;
|
|
3009
|
-
|
|
3010
|
-
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
|
|
3011
|
-
|
|
3012
|
-
this.selectRange(0, data.totalRecordCount);
|
|
3013
|
-
|
|
3014
|
-
e.stopPropagation();
|
|
3015
|
-
e.preventDefault();
|
|
3016
|
-
break;
|
|
3017
|
-
}
|
|
3018
|
-
}
|
|
3019
|
-
|
|
3020
|
-
beginDragDrop(e, record) {
|
|
3021
|
-
let { instance, data } = this.props;
|
|
3022
|
-
let { widget, store } = instance;
|
|
3023
|
-
let { isRecordDraggable } = instance;
|
|
3024
|
-
|
|
3025
|
-
if (isRecordDraggable && !isRecordDraggable(record.data)) return;
|
|
3026
|
-
|
|
3027
|
-
//get a fresh isSelected delegate
|
|
3028
|
-
let isSelected = widget.selection.getIsSelectedDelegate(store);
|
|
3029
|
-
|
|
3030
|
-
let selected = [];
|
|
3031
|
-
|
|
3032
|
-
let add = (rec, data, index, force) => {
|
|
3033
|
-
if (!data || !(force || isSelected(data, index)) || (isRecordDraggable && !isRecordDraggable(data))) return;
|
|
3034
|
-
let mappedRecord = rec ? { ...rec } : widget.mapRecord(null, instance, data, index);
|
|
3035
|
-
let row = (mappedRecord.row = instance.getDetachedChild(
|
|
3036
|
-
instance.row,
|
|
3037
|
-
"DD:" + mappedRecord.key,
|
|
3038
|
-
mappedRecord.store,
|
|
3039
|
-
));
|
|
3040
|
-
row.selected = true;
|
|
3041
|
-
selected.push(mappedRecord);
|
|
3042
|
-
};
|
|
3043
|
-
|
|
3044
|
-
if (!record.selected) {
|
|
3045
|
-
if (instance.records) instance.records.forEach((r) => add(r, r.data, r.index));
|
|
3046
|
-
else this.getRecordsSlice(0, data.totalRecordCount).forEach((r, index) => add(null, r, index));
|
|
3047
|
-
}
|
|
3048
|
-
|
|
3049
|
-
if (selected.length == 0) add(record, record.data, record.index, true);
|
|
3050
|
-
|
|
3051
|
-
let renderRow = this.createRowRenderer(false);
|
|
3052
|
-
|
|
3053
|
-
let contents = selected.map((record, i) => ({
|
|
3054
|
-
type: StaticText,
|
|
3055
|
-
text: renderRow(record, i, true, false),
|
|
3056
|
-
}));
|
|
3057
|
-
|
|
3058
|
-
initiateDragDrop(
|
|
3059
|
-
e,
|
|
3060
|
-
{
|
|
3061
|
-
sourceEl: closest(e.currentTarget, (a) => a.tagName == "TBODY"),
|
|
3062
|
-
source: {
|
|
3063
|
-
data: data.dragSource.data,
|
|
3064
|
-
store: store,
|
|
3065
|
-
record: record,
|
|
3066
|
-
records: selected,
|
|
3067
|
-
},
|
|
3068
|
-
clone: {
|
|
3069
|
-
store: record.store,
|
|
3070
|
-
matchCursorOffset: true,
|
|
3071
|
-
matchWidth: true,
|
|
3072
|
-
widget: (
|
|
3073
|
-
<cx>
|
|
3074
|
-
<div className={data.classNames}>
|
|
3075
|
-
<table>{contents}</table>
|
|
3076
|
-
</div>
|
|
3077
|
-
</cx>
|
|
3078
|
-
),
|
|
3079
|
-
},
|
|
3080
|
-
},
|
|
3081
|
-
() => {
|
|
3082
|
-
this.setState({
|
|
3083
|
-
dragged: false,
|
|
3084
|
-
});
|
|
3085
|
-
},
|
|
3086
|
-
);
|
|
3087
|
-
|
|
3088
|
-
this.setState({
|
|
3089
|
-
dragged: record,
|
|
3090
|
-
});
|
|
3091
|
-
}
|
|
3092
|
-
|
|
3093
|
-
onFileDragEnter(ev) {
|
|
3094
|
-
if (!this.props.instance.widget.allowsFileDrops) return;
|
|
3095
|
-
let event = getDragDropEvent(ev);
|
|
3096
|
-
var test = this.onDropTest(event);
|
|
3097
|
-
if (test) {
|
|
3098
|
-
ev.preventDefault();
|
|
3099
|
-
ev.stopPropagation();
|
|
3100
|
-
this.onDragStart(ev);
|
|
3101
|
-
}
|
|
3102
|
-
}
|
|
3103
|
-
onFileDragOver(ev) {
|
|
3104
|
-
if (!this.props.instance.widget.allowsFileDrops) return;
|
|
3105
|
-
let event = getDragDropEvent(ev);
|
|
3106
|
-
var test = this.onDropTest(event);
|
|
3107
|
-
if (test) {
|
|
3108
|
-
ev.preventDefault();
|
|
3109
|
-
ev.stopPropagation();
|
|
3110
|
-
this.onDragOver(event, { test });
|
|
3111
|
-
}
|
|
3112
|
-
}
|
|
3113
|
-
onFileDragLeave(ev) {
|
|
3114
|
-
if (!this.props.instance.widget.allowsFileDrops) return;
|
|
3115
|
-
if (ev.target != this.dom.el) {
|
|
3116
|
-
//The dragleave event fires when the cursor leave any of the child elements.
|
|
3117
|
-
//We need to be sure that the cursor left the top element too.
|
|
3118
|
-
let el = document.elementFromPoint(ev.clientX, ev.clientY);
|
|
3119
|
-
if (el == this.dom.el || this.dom.el.contains(el)) return;
|
|
3120
|
-
}
|
|
3121
|
-
let event = getDragDropEvent(ev);
|
|
3122
|
-
var test = this.onDropTest(event);
|
|
3123
|
-
if (test) {
|
|
3124
|
-
this.onDragLeave(event);
|
|
3125
|
-
}
|
|
3126
|
-
}
|
|
3127
|
-
onFileDrop(ev) {
|
|
3128
|
-
if (!this.props.instance.widget.allowsFileDrops) return;
|
|
3129
|
-
let event = getDragDropEvent(ev);
|
|
3130
|
-
var test = this.onDropTest(event);
|
|
3131
|
-
if (test) {
|
|
3132
|
-
ev.preventDefault();
|
|
3133
|
-
ev.stopPropagation();
|
|
3134
|
-
this.onDrop(event);
|
|
3135
|
-
}
|
|
3136
|
-
}
|
|
3137
|
-
}
|
|
3138
|
-
|
|
3139
|
-
class GridColumnHeaderLine extends PureContainer {
|
|
3140
|
-
declareData() {
|
|
3141
|
-
return super.declareData(...arguments, {
|
|
3142
|
-
showHeader: undefined,
|
|
3143
|
-
});
|
|
3144
|
-
}
|
|
3145
|
-
|
|
3146
|
-
init() {
|
|
3147
|
-
this.items = Widget.create(GridColumnHeader, this.columns || []);
|
|
3148
|
-
this.visible = this.showHeader;
|
|
3149
|
-
this.style = this.headerStyle;
|
|
3150
|
-
this.className = this.headerClass;
|
|
3151
|
-
this.class = null;
|
|
3152
|
-
super.init();
|
|
3153
|
-
}
|
|
3154
|
-
|
|
3155
|
-
render(context, instance, key) {
|
|
3156
|
-
let { data } = instance;
|
|
3157
|
-
return (
|
|
3158
|
-
<tr key={key} className={data.classNames} style={data.style}>
|
|
3159
|
-
{this.renderChildren(context, instance)}
|
|
3160
|
-
</tr>
|
|
3161
|
-
);
|
|
3162
|
-
}
|
|
3163
|
-
}
|
|
3164
|
-
|
|
3165
|
-
GridColumnHeaderLine.prototype.isPureContainer = false;
|
|
3166
|
-
GridColumnHeaderLine.prototype.styled = true;
|
|
3167
|
-
GridColumnHeaderLine.prototype.showHeader = true;
|
|
3168
|
-
GridColumnHeaderLine.autoInit = true;
|
|
3169
|
-
|
|
3170
|
-
class GridColumnHeader extends Widget {
|
|
3171
|
-
declareData() {
|
|
3172
|
-
return super.declareData(...arguments, {
|
|
3173
|
-
format: undefined,
|
|
3174
|
-
width: undefined,
|
|
3175
|
-
defaultWidth: undefined,
|
|
3176
|
-
fixed: undefined,
|
|
3177
|
-
});
|
|
3178
|
-
}
|
|
3179
|
-
|
|
3180
|
-
init() {
|
|
3181
|
-
delete this.style;
|
|
3182
|
-
delete this.className;
|
|
3183
|
-
delete this.class;
|
|
3184
|
-
|
|
3185
|
-
if (this.header) this.header1 = this.header;
|
|
3186
|
-
|
|
3187
|
-
if (this.header1 || this.resizable || this.width || this.defaultWidth || this.sortable || this.draggable) {
|
|
3188
|
-
if (!isObject(this.header1))
|
|
3189
|
-
this.header1 = {
|
|
3190
|
-
text: this.header1 || "",
|
|
3191
|
-
};
|
|
3192
|
-
|
|
3193
|
-
if (this.resizable) this.header1.resizable = this.resizable;
|
|
3194
|
-
|
|
3195
|
-
if (this.width) this.header1.width = this.width;
|
|
3196
|
-
|
|
3197
|
-
if (this.defaultWidth) this.header1.defaultWidth = this.defaultWidth;
|
|
3198
|
-
|
|
3199
|
-
if (this.draggable) this.header1.draggable = this.draggable;
|
|
3200
|
-
}
|
|
3201
|
-
|
|
3202
|
-
if (this.header2 && isSelector(this.header2))
|
|
3203
|
-
this.header2 = {
|
|
3204
|
-
text: this.header2,
|
|
3205
|
-
};
|
|
3206
|
-
|
|
3207
|
-
if (this.header3 && isSelector(this.header3))
|
|
3208
|
-
this.header3 = {
|
|
3209
|
-
text: this.header3,
|
|
3210
|
-
};
|
|
3211
|
-
|
|
3212
|
-
if (!this.aggregateField && this.field) this.aggregateField = this.field;
|
|
3213
|
-
|
|
3214
|
-
if (!this.aggregateAlias) this.aggregateAlias = this.aggregateField;
|
|
3215
|
-
if (this.aggregateAlias) this.aggregateAliasGetter = Binding.get(this.aggregateAlias).value;
|
|
3216
|
-
|
|
3217
|
-
if (this.footer && isSelector(this.footer))
|
|
3218
|
-
this.footer = {
|
|
3219
|
-
value: this.footer,
|
|
3220
|
-
pad: this.pad,
|
|
3221
|
-
colSpan: this.colSpan,
|
|
3222
|
-
};
|
|
3223
|
-
|
|
3224
|
-
if (this.footer) {
|
|
3225
|
-
this.footer.value = getSelector(this.footer.value);
|
|
3226
|
-
this.footer.class = getSelector(this.footer.class);
|
|
3227
|
-
this.footer.style = getSelector(this.footer.style);
|
|
3228
|
-
this.footer.format = getSelector(this.footer.format);
|
|
3229
|
-
}
|
|
3230
|
-
|
|
3231
|
-
if (this.caption && isSelector(this.caption))
|
|
3232
|
-
this.caption = {
|
|
3233
|
-
value: this.caption,
|
|
3234
|
-
pad: this.pad,
|
|
3235
|
-
format: this.format,
|
|
3236
|
-
};
|
|
3237
|
-
|
|
3238
|
-
if (this.caption) {
|
|
3239
|
-
let children = this.caption.children || this.caption.items;
|
|
3240
|
-
if (children) {
|
|
3241
|
-
delete this.caption.items;
|
|
3242
|
-
this.caption.children = Widget.create(children);
|
|
3243
|
-
} else {
|
|
3244
|
-
this.caption.value = getSelector(this.caption.value);
|
|
3245
|
-
this.caption.format = getSelector(this.caption.format);
|
|
3246
|
-
}
|
|
3247
|
-
this.caption.class = getSelector(this.caption.class);
|
|
3248
|
-
this.caption.style = getSelector(this.caption.style);
|
|
3249
|
-
}
|
|
3250
|
-
|
|
3251
|
-
super.init();
|
|
3252
|
-
}
|
|
3253
|
-
|
|
3254
|
-
initComponents() {
|
|
3255
|
-
return super.initComponents({
|
|
3256
|
-
header1: this.header1 && GridColumnHeaderCell.create(this.header1),
|
|
3257
|
-
header2: this.header2 && GridColumnHeaderCell.create(this.header2),
|
|
3258
|
-
header3: this.header3 && GridColumnHeaderCell.create(this.header3),
|
|
3259
|
-
});
|
|
3260
|
-
}
|
|
3261
|
-
|
|
3262
|
-
render() {
|
|
3263
|
-
return null;
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
|
|
3267
|
-
GridColumnHeader.autoInit = true;
|
|
3268
|
-
|
|
3269
|
-
class GridColumnHeaderCell extends PureContainer {
|
|
3270
|
-
declareData() {
|
|
3271
|
-
return super.declareData(...arguments, {
|
|
3272
|
-
text: undefined,
|
|
3273
|
-
colSpan: undefined,
|
|
3274
|
-
rowSpan: undefined,
|
|
3275
|
-
width: undefined,
|
|
3276
|
-
defaultWidth: undefined,
|
|
3277
|
-
resizable: undefined,
|
|
3278
|
-
fixed: undefined,
|
|
3279
|
-
draggable: undefined,
|
|
3280
|
-
});
|
|
3281
|
-
}
|
|
3282
|
-
|
|
3283
|
-
initComponents() {
|
|
3284
|
-
return super.initComponents(...arguments, {
|
|
3285
|
-
tool: this.tool && Widget.create(this.tool),
|
|
3286
|
-
});
|
|
3287
|
-
}
|
|
3288
|
-
|
|
3289
|
-
render(context, instance, key) {
|
|
3290
|
-
let { data } = instance;
|
|
3291
|
-
return data.text || super.render(context, instance, key);
|
|
3292
|
-
}
|
|
3293
|
-
}
|
|
3294
|
-
|
|
3295
|
-
GridColumnHeaderCell.prototype.colSpan = 1;
|
|
3296
|
-
GridColumnHeaderCell.prototype.rowSpan = 1;
|
|
3297
|
-
GridColumnHeaderCell.prototype.allowSorting = true;
|
|
3298
|
-
GridColumnHeaderCell.prototype.styled = true;
|
|
3299
|
-
GridColumnHeaderCell.prototype.fixed = false;
|
|
3300
|
-
|
|
3301
|
-
// function initGrouping(grouping) {
|
|
3302
|
-
// grouping.forEach((g) => {
|
|
3303
|
-
// if (g.caption) g.caption = getSelector(g.caption);
|
|
3304
|
-
// });
|
|
3305
|
-
// }
|
|
3306
|
-
|
|
3307
|
-
function copyCellSize(srcTableBody, dstTableBody, applyHeight = true) {
|
|
3308
|
-
if (!srcTableBody || !dstTableBody) return false;
|
|
3309
|
-
|
|
3310
|
-
let changed = false;
|
|
3311
|
-
for (let r = 0; r < dstTableBody.children.length && r < srcTableBody.children.length; r++) {
|
|
3312
|
-
let sr = srcTableBody.children[r];
|
|
3313
|
-
let dr = dstTableBody.children[r];
|
|
3314
|
-
for (let c = 0; c < dr.children.length && c < sr.children.length; c++) {
|
|
3315
|
-
let dc = dr.children[c];
|
|
3316
|
-
let ws = `${sr.children[c].offsetWidth}px`;
|
|
3317
|
-
if (!changed && dc.style.width != ws) changed = true;
|
|
3318
|
-
dc.style.width = dc.style.minWidth = dc.style.maxWidth = ws;
|
|
3319
|
-
if (applyHeight) dc.style.height = `${sr.children[c].offsetHeight}px`;
|
|
3320
|
-
}
|
|
3321
|
-
}
|
|
3322
|
-
return changed;
|
|
3323
|
-
}
|
|
3324
|
-
|
|
3325
|
-
function copyCellSizePrecise(srcTableBody, dstTableBody, applyHeight = true) {
|
|
3326
|
-
if (!srcTableBody || !dstTableBody) return false;
|
|
3327
|
-
let changed = false;
|
|
3328
|
-
for (let r = 0; r < dstTableBody.children.length && r < srcTableBody.children.length; r++) {
|
|
3329
|
-
let sr = srcTableBody.children[r];
|
|
3330
|
-
let dr = dstTableBody.children[r];
|
|
3331
|
-
for (let c = 0; c < dr.children.length && c < sr.children.length; c++) {
|
|
3332
|
-
let dc = dr.children[c];
|
|
3333
|
-
let bounds = sr.children[c].getBoundingClientRect();
|
|
3334
|
-
let ws = `${bounds.width}px`;
|
|
3335
|
-
if (!changed && dc.style.width != ws) changed = true;
|
|
3336
|
-
dc.style.width = dc.style.minWidth = dc.style.maxWidth = ws;
|
|
3337
|
-
if (applyHeight) dc.style.height = `${bounds.height}px`;
|
|
3338
|
-
}
|
|
3339
|
-
}
|
|
3340
|
-
return changed;
|
|
3341
|
-
}
|
|
3342
|
-
|
|
3343
|
-
function syncHeaderHeights(header1, header2) {
|
|
3344
|
-
/**
|
|
3345
|
-
* In the first pass measure all row heights.
|
|
3346
|
-
* In the second pass apply those heights.
|
|
3347
|
-
* Use getBoundingClientRect() for sub-pixel accuracy.
|
|
3348
|
-
*/
|
|
3349
|
-
|
|
3350
|
-
if (!header1 || !header2) return;
|
|
3351
|
-
const rowCount = Math.max(header1.children.length, header2.children.length);
|
|
3352
|
-
let rowHeight = [];
|
|
3353
|
-
for (let r = 0; r < rowCount; r++) {
|
|
3354
|
-
rowHeight.push(0);
|
|
3355
|
-
let tr1 = header1.children[r];
|
|
3356
|
-
let tr2 = header2.children[r];
|
|
3357
|
-
if (tr1) {
|
|
3358
|
-
for (let i = 0; i < tr1.children.length; i++) {
|
|
3359
|
-
let td = tr1.children[i];
|
|
3360
|
-
let h = td.getBoundingClientRect().height;
|
|
3361
|
-
if (td.rowSpan == 1 && h > rowHeight[r]) {
|
|
3362
|
-
rowHeight[r] = h;
|
|
3363
|
-
break;
|
|
3364
|
-
}
|
|
3365
|
-
}
|
|
3366
|
-
}
|
|
3367
|
-
if (tr2) {
|
|
3368
|
-
for (let i = 0; i < tr2.children.length; i++) {
|
|
3369
|
-
let td = tr2.children[i];
|
|
3370
|
-
let h = td.getBoundingClientRect().height;
|
|
3371
|
-
if (td.rowSpan == 1 && h > rowHeight[r]) {
|
|
3372
|
-
rowHeight[r] = h;
|
|
3373
|
-
break;
|
|
3374
|
-
}
|
|
3375
|
-
}
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
|
|
3379
|
-
for (let r = 0; r < rowCount; r++) {
|
|
3380
|
-
let tr1 = header1.children[r];
|
|
3381
|
-
let tr2 = header2.children[r];
|
|
3382
|
-
if (tr1) {
|
|
3383
|
-
for (let i = 0; i < tr1.children.length; i++) {
|
|
3384
|
-
let td = tr1.children[i];
|
|
3385
|
-
let h = 0;
|
|
3386
|
-
for (let x = 0; x < td.rowSpan; x++) h += rowHeight[r + x];
|
|
3387
|
-
td.style.height = `${h}px`;
|
|
3388
|
-
}
|
|
3389
|
-
}
|
|
3390
|
-
if (tr2) {
|
|
3391
|
-
for (let i = 0; i < tr2.children.length; i++) {
|
|
3392
|
-
let td = tr2.children[i];
|
|
3393
|
-
let h = 0;
|
|
3394
|
-
for (let x = 0; x < td.rowSpan; x++) h += rowHeight[r + x];
|
|
3395
|
-
td.style.height = `${h}px`;
|
|
3396
|
-
}
|
|
3397
|
-
}
|
|
3398
|
-
}
|
|
3399
|
-
}
|
|
3400
|
-
|
|
3401
|
-
class AvgHeight {
|
|
3402
|
-
constructor() {
|
|
3403
|
-
this.groups = {};
|
|
3404
|
-
}
|
|
3405
|
-
|
|
3406
|
-
add(group, height) {
|
|
3407
|
-
let g = this.groups[group];
|
|
3408
|
-
if (!g) g = this.groups[group] = { sum: 0, count: 0 };
|
|
3409
|
-
g.sum += height;
|
|
3410
|
-
g.count++;
|
|
3411
|
-
}
|
|
3412
|
-
|
|
3413
|
-
estimate(group) {
|
|
3414
|
-
let g = this.groups[group];
|
|
3415
|
-
if (!g || g.count == 0) return null;
|
|
3416
|
-
return Math.round(g.sum / g.count);
|
|
3417
|
-
}
|
|
3418
|
-
}
|
|
3419
|
-
|
|
3420
|
-
function getDragDropEvent(ev) {
|
|
3421
|
-
return {
|
|
3422
|
-
event: ev,
|
|
3423
|
-
cursor: getCursorPos(ev),
|
|
3424
|
-
dataTransfer: ev.dataTransfer,
|
|
3425
|
-
source: {
|
|
3426
|
-
width: 32,
|
|
3427
|
-
height: 32,
|
|
3428
|
-
margin: [],
|
|
3429
|
-
},
|
|
3430
|
-
};
|
|
3431
|
-
}
|