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/dist/data.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isString,
|
|
3
3
|
isObject,
|
|
4
|
+
hasStringAtKey,
|
|
5
|
+
hasValueAtKey,
|
|
4
6
|
isFunction,
|
|
5
7
|
Format,
|
|
6
8
|
isValidIdentifierName,
|
|
@@ -9,18 +11,17 @@ import {
|
|
|
9
11
|
isArray,
|
|
10
12
|
isDefined,
|
|
11
13
|
SubscriberList,
|
|
14
|
+
hasKey,
|
|
15
|
+
hasFunctionAtKey,
|
|
12
16
|
isUndefined,
|
|
13
17
|
expandFatArrows,
|
|
14
18
|
} from "cx/util";
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
function createAccessorModelProxy(chain) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var lastOp = null;
|
|
22
|
-
var proxy = new Proxy(emptyFn, {
|
|
23
|
-
get: function get(_, name) {
|
|
20
|
+
const emptyFn = () => {};
|
|
21
|
+
function createAccessorModelProxy(chain = "") {
|
|
22
|
+
let lastOp = null;
|
|
23
|
+
const proxy = new Proxy(emptyFn, {
|
|
24
|
+
get: (_, name) => {
|
|
24
25
|
if (typeof name !== "string") return proxy;
|
|
25
26
|
switch (name) {
|
|
26
27
|
case "isAccessorChain":
|
|
@@ -31,15 +32,15 @@ function createAccessorModelProxy(chain) {
|
|
|
31
32
|
lastOp = name;
|
|
32
33
|
return proxy;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
+
let newChain = chain;
|
|
35
36
|
if (newChain.length > 0) newChain += ".";
|
|
36
37
|
newChain += name;
|
|
37
38
|
return createAccessorModelProxy(newChain);
|
|
38
39
|
},
|
|
39
|
-
apply
|
|
40
|
+
apply() {
|
|
40
41
|
switch (lastOp) {
|
|
41
42
|
case "nameOf":
|
|
42
|
-
|
|
43
|
+
const lastDotIndex = chain.lastIndexOf(".");
|
|
43
44
|
return lastDotIndex > 0 ? chain.substring(lastDotIndex + 1) : chain;
|
|
44
45
|
default:
|
|
45
46
|
return chain;
|
|
@@ -52,36 +53,38 @@ function isAccessorChain(value) {
|
|
|
52
53
|
return value != null && !!value.isAccessorChain;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
let bindingCache = {};
|
|
57
|
+
class Binding {
|
|
58
|
+
path;
|
|
59
|
+
parts;
|
|
60
|
+
value;
|
|
61
|
+
constructor(path) {
|
|
58
62
|
this.path = path;
|
|
59
63
|
this.parts = path.split(".");
|
|
60
|
-
|
|
61
|
-
for (
|
|
64
|
+
let body = "return x";
|
|
65
|
+
for (let i = 0; i < this.parts.length; i++) body += '?.["' + this.parts[i] + '"]';
|
|
62
66
|
this.value = new Function("x", body);
|
|
63
67
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var cv = this.value(state);
|
|
68
|
+
set(state, value) {
|
|
69
|
+
const cv = this.value(state);
|
|
67
70
|
if (cv === value) return state;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const ns = Object.assign({}, state);
|
|
72
|
+
let o = ns;
|
|
73
|
+
for (let i = 0; i < this.parts.length; i++) {
|
|
74
|
+
const part = this.parts[i];
|
|
75
|
+
const no = i === this.parts.length - 1 ? value : Object.assign({}, o[part]);
|
|
73
76
|
o[part] = no;
|
|
74
77
|
o = no;
|
|
75
78
|
}
|
|
76
79
|
return ns;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
for (
|
|
80
|
+
}
|
|
81
|
+
delete(state) {
|
|
82
|
+
const ns = Object.assign({}, state);
|
|
83
|
+
let o = ns;
|
|
84
|
+
let part;
|
|
85
|
+
for (let i = 0; i < this.parts.length - 1; i++) {
|
|
83
86
|
part = this.parts[i];
|
|
84
|
-
|
|
87
|
+
const no = Object.assign({}, o[part]);
|
|
85
88
|
o[part] = no;
|
|
86
89
|
o = no;
|
|
87
90
|
}
|
|
@@ -89,119 +92,72 @@ var Binding = /*#__PURE__*/ (function () {
|
|
|
89
92
|
if (!o.hasOwnProperty(part)) return state;
|
|
90
93
|
delete o[part];
|
|
91
94
|
return ns;
|
|
92
|
-
}
|
|
93
|
-
|
|
95
|
+
}
|
|
96
|
+
static get(path) {
|
|
94
97
|
if (isString(path)) {
|
|
95
|
-
|
|
98
|
+
let b = bindingCache[path];
|
|
96
99
|
if (b) return b;
|
|
97
100
|
b = new Binding(path);
|
|
98
101
|
bindingCache[path] = b;
|
|
99
102
|
return b;
|
|
100
103
|
}
|
|
101
|
-
if (
|
|
104
|
+
if (isBindingObject(path)) return this.get(path.bind);
|
|
102
105
|
if (path instanceof Binding) return path;
|
|
103
106
|
if (isAccessorChain(path)) return this.get(path.toString());
|
|
104
107
|
throw new Error("Invalid binding definition provided.");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
})();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
108
110
|
function isBinding(value) {
|
|
109
|
-
if (isObject(value)
|
|
110
|
-
|
|
111
|
+
if (isObject(value)) {
|
|
112
|
+
if (hasStringAtKey(value, "bind")) return true;
|
|
113
|
+
if (hasValueAtKey(value, "isAccessorChain", true)) return true;
|
|
114
|
+
}
|
|
111
115
|
return value instanceof Binding;
|
|
112
116
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
116
|
-
var o = [null];
|
|
117
|
-
o.push.apply(o, e);
|
|
118
|
-
var p = new (t.bind.apply(t, o))();
|
|
119
|
-
return p;
|
|
120
|
-
}
|
|
121
|
-
function _extends() {
|
|
122
|
-
return (
|
|
123
|
-
(_extends = Object.assign
|
|
124
|
-
? Object.assign.bind()
|
|
125
|
-
: function (n) {
|
|
126
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
127
|
-
var t = arguments[e];
|
|
128
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
129
|
-
}
|
|
130
|
-
return n;
|
|
131
|
-
}),
|
|
132
|
-
_extends.apply(null, arguments)
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
function _inheritsLoose(t, o) {
|
|
136
|
-
(t.prototype = Object.create(o.prototype)), (t.prototype.constructor = t), _setPrototypeOf(t, o);
|
|
137
|
-
}
|
|
138
|
-
function _isNativeReflectConstruct() {
|
|
139
|
-
try {
|
|
140
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
141
|
-
} catch (t) {}
|
|
142
|
-
return (_isNativeReflectConstruct = function () {
|
|
143
|
-
return !!t;
|
|
144
|
-
})();
|
|
145
|
-
}
|
|
146
|
-
function _setPrototypeOf(t, e) {
|
|
147
|
-
return (
|
|
148
|
-
(_setPrototypeOf = Object.setPrototypeOf
|
|
149
|
-
? Object.setPrototypeOf.bind()
|
|
150
|
-
: function (t, e) {
|
|
151
|
-
return (t.__proto__ = e), t;
|
|
152
|
-
}),
|
|
153
|
-
_setPrototypeOf(t, e)
|
|
154
|
-
);
|
|
117
|
+
function isBindingObject(value) {
|
|
118
|
+
return isObject(value) && hasStringAtKey(value, "bind");
|
|
155
119
|
}
|
|
156
120
|
|
|
157
|
-
function computable() {
|
|
158
|
-
|
|
159
|
-
if (arguments.length == 0)
|
|
121
|
+
function computable(...selectorsAndCompute) {
|
|
122
|
+
if (selectorsAndCompute.length == 0)
|
|
160
123
|
throw new Error("computable requires at least a compute function to be passed in arguments.");
|
|
161
|
-
|
|
124
|
+
let compute = selectorsAndCompute[selectorsAndCompute.length - 1];
|
|
162
125
|
if (typeof compute != "function") throw new Error("Last argument to the computable function should be a function.");
|
|
163
|
-
|
|
126
|
+
let inputs = [],
|
|
164
127
|
a;
|
|
165
|
-
for (
|
|
166
|
-
a =
|
|
128
|
+
for (let i = 0; i + 1 < selectorsAndCompute.length; i++) {
|
|
129
|
+
a = selectorsAndCompute[i];
|
|
167
130
|
if (isString(a) || isAccessorChain(a)) inputs.push(Binding.get(a.toString()).value);
|
|
168
131
|
else if (a.memoize) inputs.push(a.memoize());
|
|
169
132
|
else if (isFunction(a)) inputs.push(a);
|
|
170
|
-
else throw new Error(
|
|
133
|
+
else throw new Error(`Invalid selector type '${typeof a}' received.`);
|
|
171
134
|
}
|
|
172
135
|
function memoize(warmupData) {
|
|
173
|
-
|
|
174
|
-
lastArgs =
|
|
175
|
-
warmupData &&
|
|
176
|
-
inputs.map(function (s) {
|
|
177
|
-
return s(warmupData);
|
|
178
|
-
});
|
|
136
|
+
let lastValue,
|
|
137
|
+
lastArgs = warmupData && inputs.map((s) => s(warmupData));
|
|
179
138
|
return function (data) {
|
|
180
|
-
|
|
139
|
+
let dirty = false;
|
|
181
140
|
if (!lastArgs) {
|
|
182
141
|
lastArgs = Array.from({
|
|
183
142
|
length: inputs.length,
|
|
184
143
|
});
|
|
185
144
|
dirty = true;
|
|
186
145
|
}
|
|
187
|
-
for (
|
|
188
|
-
|
|
189
|
-
if (v === lastArgs[
|
|
190
|
-
lastArgs[
|
|
146
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
147
|
+
let v = inputs[i](data);
|
|
148
|
+
if (v === lastArgs[i]) continue;
|
|
149
|
+
lastArgs[i] = v;
|
|
191
150
|
dirty = true;
|
|
192
151
|
}
|
|
193
152
|
if (dirty) lastValue = compute.apply(null, lastArgs);
|
|
194
153
|
return lastValue;
|
|
195
154
|
};
|
|
196
155
|
}
|
|
197
|
-
|
|
198
|
-
|
|
156
|
+
let selector = (data) =>
|
|
157
|
+
compute.apply(
|
|
199
158
|
null,
|
|
200
|
-
inputs.map(
|
|
201
|
-
return s(data);
|
|
202
|
-
}),
|
|
159
|
+
inputs.map((s) => s(data)),
|
|
203
160
|
);
|
|
204
|
-
};
|
|
205
161
|
selector.memoize = memoize;
|
|
206
162
|
return selector;
|
|
207
163
|
}
|
|
@@ -212,56 +168,53 @@ function computable() {
|
|
|
212
168
|
Expression.registerHelper('_', _);
|
|
213
169
|
let e = Expression.compile('_.min({data})');
|
|
214
170
|
*/
|
|
215
|
-
|
|
216
|
-
var helpers = {},
|
|
171
|
+
let helpers = {},
|
|
217
172
|
helperNames = [],
|
|
218
173
|
helperValues = [],
|
|
219
174
|
expFatArrows = null;
|
|
220
175
|
function getExpr(expr) {
|
|
221
176
|
if (expr.memoize) return expr;
|
|
222
177
|
function memoize() {
|
|
223
|
-
|
|
178
|
+
let lastValue,
|
|
224
179
|
lastRunBindings = {},
|
|
225
180
|
lastRunResults = {},
|
|
226
181
|
getters = {},
|
|
227
182
|
currentData,
|
|
228
183
|
len = -1;
|
|
229
|
-
|
|
230
|
-
|
|
184
|
+
let get = function (bindingWithFormat) {
|
|
185
|
+
let getter = getters[bindingWithFormat];
|
|
231
186
|
if (!getter) {
|
|
232
|
-
|
|
187
|
+
let binding = bindingWithFormat,
|
|
233
188
|
format;
|
|
234
|
-
|
|
189
|
+
let colonIndex = bindingWithFormat.indexOf(":");
|
|
235
190
|
if (colonIndex != -1) {
|
|
236
191
|
format = Format.parse(bindingWithFormat.substring(colonIndex + 1));
|
|
237
192
|
binding = bindingWithFormat.substring(0, colonIndex);
|
|
238
193
|
} else {
|
|
239
|
-
|
|
194
|
+
let nullSeparatorIndex = bindingWithFormat.indexOf(":");
|
|
240
195
|
if (nullSeparatorIndex != -1) {
|
|
241
196
|
format = Format.parse(bindingWithFormat.substring(nullSeparatorIndex));
|
|
242
197
|
binding = bindingWithFormat.substring(0, nullSeparatorIndex - 1);
|
|
243
198
|
}
|
|
244
199
|
}
|
|
245
|
-
|
|
246
|
-
getter =
|
|
247
|
-
|
|
200
|
+
let b = Binding.get(binding);
|
|
201
|
+
getter = (data) => {
|
|
202
|
+
let value = b.value(data);
|
|
248
203
|
lastRunBindings[len] = b.value;
|
|
249
204
|
lastRunResults[len] = value;
|
|
250
205
|
len++;
|
|
251
206
|
return value;
|
|
252
207
|
};
|
|
253
208
|
if (format) {
|
|
254
|
-
|
|
255
|
-
getter =
|
|
256
|
-
return format(valueGetter(data));
|
|
257
|
-
};
|
|
209
|
+
let valueGetter = getter;
|
|
210
|
+
getter = (data) => format(valueGetter(data));
|
|
258
211
|
}
|
|
259
212
|
getters[bindingWithFormat] = getter;
|
|
260
213
|
}
|
|
261
214
|
return getter(currentData);
|
|
262
215
|
};
|
|
263
216
|
return function (data) {
|
|
264
|
-
|
|
217
|
+
let i = 0;
|
|
265
218
|
for (; i < len; i++) if (lastRunBindings[i](data) !== lastRunResults[i]) break;
|
|
266
219
|
if (i !== len) {
|
|
267
220
|
len = 0;
|
|
@@ -271,26 +224,26 @@ function getExpr(expr) {
|
|
|
271
224
|
return lastValue;
|
|
272
225
|
};
|
|
273
226
|
}
|
|
274
|
-
|
|
227
|
+
let result = memoize();
|
|
275
228
|
result.memoize = memoize;
|
|
276
229
|
return result;
|
|
277
230
|
}
|
|
278
231
|
function expression(str) {
|
|
279
232
|
if (isFunction(str)) return getExpr(str);
|
|
280
|
-
|
|
281
|
-
|
|
233
|
+
let cache = getExpressionCache();
|
|
234
|
+
let r = cache[str];
|
|
282
235
|
if (r) return r;
|
|
283
|
-
|
|
284
|
-
|
|
236
|
+
let quote = false;
|
|
237
|
+
let termStart = -1,
|
|
285
238
|
curlyBrackets = 0,
|
|
286
239
|
percentExpression;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
for (
|
|
293
|
-
|
|
240
|
+
let fb = ["return ("];
|
|
241
|
+
let args = {};
|
|
242
|
+
let formats = [];
|
|
243
|
+
let subExprCount = 0;
|
|
244
|
+
let invalidNameCount = 0;
|
|
245
|
+
for (let i = 0; i < str.length; i++) {
|
|
246
|
+
let c = str[i];
|
|
294
247
|
switch (c) {
|
|
295
248
|
case "{":
|
|
296
249
|
if (curlyBrackets > 0 && !quote) curlyBrackets++;
|
|
@@ -305,27 +258,27 @@ function expression(str) {
|
|
|
305
258
|
if (termStart >= 0) {
|
|
306
259
|
if (quote) continue;
|
|
307
260
|
if (--curlyBrackets == 0) {
|
|
308
|
-
|
|
309
|
-
|
|
261
|
+
let term = str.substring(termStart, i);
|
|
262
|
+
let formatStart = 0;
|
|
310
263
|
if (term[0] == "[") formatStart = term.indexOf("]");
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
264
|
+
let colon = term.indexOf(":", formatStart > 0 ? formatStart : 0);
|
|
265
|
+
let binding = colon == -1 ? term : term.substring(0, colon);
|
|
266
|
+
let format = colon == -1 ? null : term.substring(colon + 1);
|
|
314
267
|
if (colon == -1) {
|
|
315
|
-
|
|
268
|
+
let nullSepIndex = binding.indexOf("|", formatStart);
|
|
316
269
|
if (nullSepIndex != -1) {
|
|
317
270
|
format = binding.substring(nullSepIndex);
|
|
318
271
|
binding = binding.substring(0, nullSepIndex);
|
|
319
272
|
}
|
|
320
273
|
}
|
|
321
|
-
|
|
274
|
+
let argName = binding.replace(/\./g, "_");
|
|
322
275
|
if (!isValidIdentifierName(argName)) argName = "inv" + ++invalidNameCount;
|
|
323
276
|
if (percentExpression || (binding[0] == "[" && binding[binding.length - 1] == "]")) {
|
|
324
|
-
argName =
|
|
277
|
+
argName = `expr${++subExprCount}`;
|
|
325
278
|
args[argName] = expression(percentExpression ? binding : binding.substring(1, binding.length - 1));
|
|
326
279
|
} else args[argName] = binding;
|
|
327
280
|
if (format) {
|
|
328
|
-
|
|
281
|
+
let formatter = "fmt" + formats.length;
|
|
329
282
|
fb.push(formatter, "(", argName, ", ", quoteStr(format), ")");
|
|
330
283
|
formats.push(Format.parse(format));
|
|
331
284
|
} else fb.push(argName);
|
|
@@ -337,8 +290,8 @@ function expression(str) {
|
|
|
337
290
|
case "'":
|
|
338
291
|
if (!quote) quote = c;
|
|
339
292
|
else if (quote == c) {
|
|
340
|
-
|
|
341
|
-
|
|
293
|
+
let at = i - 1;
|
|
294
|
+
let slashCount = 0;
|
|
342
295
|
while (at >= 0 && str[at] === "\\") {
|
|
343
296
|
slashCount++;
|
|
344
297
|
at--;
|
|
@@ -353,51 +306,35 @@ function expression(str) {
|
|
|
353
306
|
}
|
|
354
307
|
}
|
|
355
308
|
fb.push(")");
|
|
356
|
-
|
|
309
|
+
let body = fb.join("");
|
|
357
310
|
if (expFatArrows) body = expFatArrows(body);
|
|
358
|
-
|
|
359
311
|
//console.log(body);
|
|
360
|
-
|
|
312
|
+
let keys = Object.keys(args);
|
|
361
313
|
try {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
return "fmt" + i;
|
|
368
|
-
}),
|
|
369
|
-
helperNames,
|
|
370
|
-
keys,
|
|
371
|
-
[body],
|
|
372
|
-
),
|
|
373
|
-
)).bind.apply(_Function, [Format, Format.value].concat(formats, helperValues));
|
|
374
|
-
var selector = computable.apply(
|
|
375
|
-
void 0,
|
|
376
|
-
keys
|
|
377
|
-
.map(function (k) {
|
|
378
|
-
return args[k];
|
|
379
|
-
})
|
|
380
|
-
.concat([compute]),
|
|
314
|
+
let compute = new Function("fmt", ...formats.map((f, i) => "fmt" + i), ...helperNames, ...keys, body).bind(
|
|
315
|
+
Format,
|
|
316
|
+
Format.value,
|
|
317
|
+
...formats,
|
|
318
|
+
...helperValues,
|
|
381
319
|
);
|
|
320
|
+
let selector = computable(...keys.map((k) => args[k]), compute);
|
|
382
321
|
cache[str] = selector;
|
|
383
322
|
return selector;
|
|
384
323
|
} catch (err) {
|
|
385
|
-
throw new Error(
|
|
324
|
+
throw new Error(`Failed to parse expression: '${str}'. ${err}`);
|
|
386
325
|
}
|
|
387
326
|
}
|
|
388
|
-
|
|
389
|
-
get: function
|
|
327
|
+
const Expression = {
|
|
328
|
+
get: function (str) {
|
|
390
329
|
return expression(str);
|
|
391
330
|
},
|
|
392
|
-
compile: function
|
|
331
|
+
compile: function (str) {
|
|
393
332
|
return this.get(str).memoize();
|
|
394
333
|
},
|
|
395
|
-
registerHelper: function
|
|
334
|
+
registerHelper: function (name, helper) {
|
|
396
335
|
helpers[name] = helper;
|
|
397
336
|
helperNames = Object.keys(helpers);
|
|
398
|
-
helperValues = helperNames.map(
|
|
399
|
-
return helpers[n];
|
|
400
|
-
});
|
|
337
|
+
helperValues = helperNames.map((n) => helpers[n]);
|
|
401
338
|
},
|
|
402
339
|
};
|
|
403
340
|
function plugFatArrowExpansion(impl) {
|
|
@@ -406,10 +343,8 @@ function plugFatArrowExpansion(impl) {
|
|
|
406
343
|
function invalidateExpressionCache() {
|
|
407
344
|
expCache = {};
|
|
408
345
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
return expCache;
|
|
412
|
-
};
|
|
346
|
+
let expCache = {};
|
|
347
|
+
let getExpressionCache = () => expCache;
|
|
413
348
|
function setGetExpressionCacheCallback(callback) {
|
|
414
349
|
getExpressionCache = callback;
|
|
415
350
|
}
|
|
@@ -418,16 +353,16 @@ function plus(str) {
|
|
|
418
353
|
return str.length ? str + " + " : str;
|
|
419
354
|
}
|
|
420
355
|
function stringTemplate(str) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (
|
|
424
|
-
expr = "";
|
|
425
|
-
|
|
356
|
+
let tplCache = getTplCache();
|
|
357
|
+
let cached = tplCache[str];
|
|
358
|
+
if (cached) return cached;
|
|
359
|
+
let expr = "";
|
|
360
|
+
let termStart = -1,
|
|
426
361
|
quoteStart = 0,
|
|
427
362
|
term,
|
|
428
363
|
bracketsOpen = 0,
|
|
429
|
-
percentSign;
|
|
430
|
-
for (
|
|
364
|
+
percentSign = false;
|
|
365
|
+
for (let i = 0; i < str.length; i++) {
|
|
431
366
|
switch (str[i]) {
|
|
432
367
|
case "{":
|
|
433
368
|
if (termStart < 0) {
|
|
@@ -449,7 +384,7 @@ function stringTemplate(str) {
|
|
|
449
384
|
if (--bracketsOpen == 0) {
|
|
450
385
|
term = str.substring(termStart, i);
|
|
451
386
|
if (term.indexOf(":") == -1) {
|
|
452
|
-
|
|
387
|
+
let nullSepIndex = term.indexOf("|");
|
|
453
388
|
if (nullSepIndex == -1) term += ":s";
|
|
454
389
|
else term = term.substring(0, nullSepIndex) + ":s" + term.substring(nullSepIndex);
|
|
455
390
|
}
|
|
@@ -469,24 +404,19 @@ function stringTemplate(str) {
|
|
|
469
404
|
if (quoteStart < str.length || expr.length == 0) expr = plus(expr) + quoteStr(str.substring(quoteStart));
|
|
470
405
|
return (tplCache[str] = expression(expr));
|
|
471
406
|
}
|
|
472
|
-
|
|
473
|
-
get: function
|
|
407
|
+
const StringTemplate = {
|
|
408
|
+
get: function (str) {
|
|
474
409
|
return stringTemplate(str);
|
|
475
410
|
},
|
|
476
|
-
compile: function
|
|
411
|
+
compile: function (str) {
|
|
477
412
|
return stringTemplate(str).memoize();
|
|
478
413
|
},
|
|
479
|
-
format: function format
|
|
480
|
-
|
|
481
|
-
args[_key - 1] = arguments[_key];
|
|
482
|
-
}
|
|
483
|
-
return stringTemplate(_format)(args);
|
|
414
|
+
format: function (format, ...args) {
|
|
415
|
+
return stringTemplate(format)(args);
|
|
484
416
|
},
|
|
485
417
|
};
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return tplCache;
|
|
489
|
-
};
|
|
418
|
+
let tplCache = {};
|
|
419
|
+
let getTplCache = () => tplCache;
|
|
490
420
|
function invalidateStringTemplateCache() {
|
|
491
421
|
tplCache = {};
|
|
492
422
|
}
|
|
@@ -494,301 +424,278 @@ function setGetStringTemplateCacheCallback(callback) {
|
|
|
494
424
|
getTplCache = callback;
|
|
495
425
|
}
|
|
496
426
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
_inheritsLoose(Ref, _Component);
|
|
506
|
-
var _proto = Ref.prototype;
|
|
507
|
-
_proto.get = function get() {
|
|
427
|
+
class Ref extends Component {
|
|
428
|
+
constructor(config) {
|
|
429
|
+
super(config);
|
|
430
|
+
this.get = this.get.bind(this);
|
|
431
|
+
if (this.set) this.set = this.set.bind(this);
|
|
432
|
+
}
|
|
433
|
+
get() {
|
|
508
434
|
throw new Error("Ref's get method is not implemented.");
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
435
|
+
}
|
|
436
|
+
set(value) {
|
|
437
|
+
throw new Error("Ref's set method is not implemented.");
|
|
438
|
+
}
|
|
439
|
+
delete() {
|
|
440
|
+
throw new Error("Ref's delete method is not implemented.");
|
|
441
|
+
}
|
|
442
|
+
init(value) {
|
|
443
|
+
if (value === undefined) return; // Component.init() compatibility
|
|
444
|
+
if (this.get() === undefined) return this.set(value);
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
toggle() {
|
|
448
|
+
return this.set(!this.get());
|
|
449
|
+
}
|
|
450
|
+
update(cb, ...args) {
|
|
451
|
+
return this.set(cb(this.get(), ...args));
|
|
452
|
+
}
|
|
453
|
+
as(config) {
|
|
523
454
|
return Ref.create(config, {
|
|
524
455
|
get: this.get,
|
|
525
456
|
set: this.set,
|
|
526
457
|
});
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
var binding = Binding.get(path);
|
|
458
|
+
}
|
|
459
|
+
ref(path) {
|
|
460
|
+
let binding = Binding.get(path);
|
|
531
461
|
return Ref.create({
|
|
532
|
-
get:
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
var data = _this2.get();
|
|
537
|
-
var newData = binding.set(data, value);
|
|
462
|
+
get: () => binding.value(this.get()),
|
|
463
|
+
set: (value) => {
|
|
464
|
+
let data = this.get();
|
|
465
|
+
let newData = binding.set(data, value);
|
|
538
466
|
if (data === newData) return false;
|
|
539
|
-
return
|
|
467
|
+
return this.set(newData);
|
|
540
468
|
},
|
|
541
469
|
});
|
|
542
|
-
}
|
|
543
|
-
|
|
470
|
+
}
|
|
544
471
|
//allows the function to be passed as a selector, e.g. to computable or addTrigger
|
|
545
|
-
|
|
472
|
+
memoize() {
|
|
546
473
|
return this.get;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
})(Component);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
550
476
|
Ref.prototype.isRef = true;
|
|
551
477
|
Ref.factory = function (alias, config, more) {
|
|
552
478
|
if (isFunction(alias)) {
|
|
553
|
-
|
|
479
|
+
let cfg = {
|
|
480
|
+
...config,
|
|
481
|
+
...more,
|
|
482
|
+
};
|
|
554
483
|
if (cfg.store) Object.assign(cfg, cfg.store.getMethods());
|
|
555
|
-
|
|
484
|
+
let result = alias(cfg);
|
|
556
485
|
if (result instanceof Ref) return result;
|
|
557
|
-
return this.create(
|
|
486
|
+
return this.create({
|
|
487
|
+
...config,
|
|
488
|
+
...more,
|
|
489
|
+
...result,
|
|
490
|
+
});
|
|
558
491
|
}
|
|
559
|
-
return this.create(
|
|
492
|
+
return this.create({
|
|
493
|
+
...config,
|
|
494
|
+
...more,
|
|
495
|
+
});
|
|
560
496
|
};
|
|
561
497
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
_inheritsLoose(StoreRef, _Ref);
|
|
570
|
-
var _proto = StoreRef.prototype;
|
|
571
|
-
_proto.get = function get() {
|
|
498
|
+
class StoreRef extends Ref {
|
|
499
|
+
constructor(config) {
|
|
500
|
+
super(config);
|
|
501
|
+
if (isAccessorChain(this.path)) this.path = this.path.toString();
|
|
502
|
+
}
|
|
503
|
+
get() {
|
|
572
504
|
return this.store.get(this.path);
|
|
573
|
-
}
|
|
574
|
-
|
|
505
|
+
}
|
|
506
|
+
set(value) {
|
|
575
507
|
return this.store.set(this.path, value);
|
|
576
|
-
}
|
|
577
|
-
|
|
508
|
+
}
|
|
509
|
+
init(value) {
|
|
510
|
+
if (value === undefined) return;
|
|
578
511
|
return this.store.init(this.path, value);
|
|
579
|
-
}
|
|
580
|
-
|
|
512
|
+
}
|
|
513
|
+
toggle() {
|
|
581
514
|
return this.store.toggle(this.path);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
return this.store
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
args[_key] = arguments[_key];
|
|
590
|
-
}
|
|
591
|
-
return (_this$store = this.store).update.apply(_this$store, [this.path].concat(args));
|
|
592
|
-
};
|
|
593
|
-
|
|
515
|
+
}
|
|
516
|
+
delete() {
|
|
517
|
+
return this.store.delete(this.path);
|
|
518
|
+
}
|
|
519
|
+
update(cb, ...args) {
|
|
520
|
+
return this.store.update(this.path, cb, ...args);
|
|
521
|
+
}
|
|
594
522
|
//allows the function to be passed as a selector, e.g. to computable or addTrigger
|
|
595
|
-
|
|
523
|
+
memoize() {
|
|
596
524
|
return this.get;
|
|
597
|
-
}
|
|
598
|
-
|
|
525
|
+
}
|
|
526
|
+
ref(path) {
|
|
599
527
|
return new StoreRef({
|
|
600
|
-
path: this.path
|
|
528
|
+
path: `${this.path}.${path}`,
|
|
601
529
|
store: this.store,
|
|
602
530
|
});
|
|
603
|
-
}
|
|
604
|
-
|
|
531
|
+
}
|
|
532
|
+
as(config) {
|
|
605
533
|
return StoreRef.create(config, {
|
|
606
534
|
path: this.path,
|
|
607
535
|
store: this.store,
|
|
608
536
|
get: this.get,
|
|
609
537
|
set: this.set,
|
|
610
538
|
});
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
})(Ref);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
614
541
|
|
|
615
|
-
|
|
616
|
-
|
|
542
|
+
class View {
|
|
543
|
+
cache;
|
|
544
|
+
notificationsSuspended = 0;
|
|
545
|
+
dirty = false;
|
|
546
|
+
constructor(config) {
|
|
617
547
|
Object.assign(this, config);
|
|
618
548
|
this.cache = {
|
|
619
549
|
version: -1,
|
|
620
550
|
};
|
|
621
551
|
if (this.store) this.setStore(this.store);
|
|
622
552
|
}
|
|
623
|
-
|
|
624
|
-
_proto.getData = function getData() {
|
|
553
|
+
getData() {
|
|
625
554
|
throw new Error("abstract method");
|
|
626
|
-
}
|
|
627
|
-
|
|
555
|
+
}
|
|
556
|
+
init(path, value) {
|
|
628
557
|
if (typeof path == "object" && path != null) {
|
|
629
|
-
|
|
630
|
-
for (
|
|
558
|
+
let changed = false;
|
|
559
|
+
for (let key in path)
|
|
631
560
|
if (path.hasOwnProperty(key) && this.get(key) === undefined && this.setItem(key, path[key])) changed = true;
|
|
632
561
|
return changed;
|
|
633
562
|
}
|
|
634
|
-
|
|
563
|
+
let binding = Binding.get(path);
|
|
635
564
|
if (this.get(binding.path) === undefined) return this.setItem(binding.path, value);
|
|
636
565
|
return false;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
if (
|
|
640
|
-
|
|
641
|
-
for (
|
|
566
|
+
}
|
|
567
|
+
set(path, value) {
|
|
568
|
+
if (typeof path == "object" && path != null) {
|
|
569
|
+
let changed = false;
|
|
570
|
+
for (let key in path) if (path.hasOwnProperty(key) && this.setItem(key, path[key])) changed = true;
|
|
642
571
|
return changed;
|
|
643
572
|
}
|
|
644
|
-
|
|
573
|
+
let binding = Binding.get(path);
|
|
645
574
|
return this.setItem(binding.path, value);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
this.set(to, value);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
_this["delete"](from);
|
|
575
|
+
}
|
|
576
|
+
copy(from, to) {
|
|
577
|
+
let value = this.get(from);
|
|
578
|
+
return this.set(to, value);
|
|
579
|
+
}
|
|
580
|
+
move(from, to) {
|
|
581
|
+
return this.batch(() => {
|
|
582
|
+
this.copy(from, to);
|
|
583
|
+
this.delete(from);
|
|
656
584
|
});
|
|
657
|
-
}
|
|
658
|
-
|
|
585
|
+
}
|
|
659
586
|
//protected
|
|
660
|
-
|
|
587
|
+
setItem(path, value) {
|
|
661
588
|
if (this.store) return this.store.setItem(path, value);
|
|
662
589
|
throw new Error("abstract method");
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
var _this2 = this;
|
|
590
|
+
}
|
|
591
|
+
delete(path) {
|
|
666
592
|
if (arguments.length > 1) path = Array.from(arguments);
|
|
667
|
-
if (isArray(path))
|
|
668
|
-
|
|
669
|
-
.map(function (arg) {
|
|
670
|
-
return _this2["delete"](arg);
|
|
671
|
-
})
|
|
672
|
-
.some(Boolean);
|
|
673
|
-
var binding = Binding.get(path);
|
|
593
|
+
if (isArray(path)) return path.map((arg) => this.delete(arg)).some(Boolean);
|
|
594
|
+
let binding = Binding.get(path);
|
|
674
595
|
return this.deleteItem(binding.path);
|
|
675
|
-
}
|
|
676
|
-
|
|
596
|
+
}
|
|
677
597
|
//protected
|
|
678
|
-
|
|
598
|
+
deleteItem(path) {
|
|
679
599
|
if (this.store) return this.store.deleteItem(path);
|
|
680
600
|
throw new Error("abstract method");
|
|
681
|
-
}
|
|
682
|
-
|
|
601
|
+
}
|
|
602
|
+
clear() {
|
|
683
603
|
if (this.store) return this.store.clear();
|
|
684
604
|
throw new Error("abstract method");
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
|
|
605
|
+
}
|
|
606
|
+
get(path, ...args) {
|
|
607
|
+
let storeData = this.getData();
|
|
688
608
|
if (arguments.length > 1) path = Array.from(arguments);
|
|
689
|
-
if (isArray(path))
|
|
690
|
-
return path.map(function (arg) {
|
|
691
|
-
return Binding.get(arg).value(storeData);
|
|
692
|
-
});
|
|
609
|
+
if (isArray(path)) return path.map((arg) => Binding.get(arg).value(storeData));
|
|
693
610
|
return Binding.get(path).value(storeData);
|
|
694
|
-
}
|
|
695
|
-
|
|
611
|
+
}
|
|
612
|
+
toggle(path) {
|
|
696
613
|
return this.set(path, !this.get(path));
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
700
|
-
args[_key - 2] = arguments[_key];
|
|
701
|
-
}
|
|
614
|
+
}
|
|
615
|
+
update(path, updateFn, ...args) {
|
|
702
616
|
if (arguments.length == 1 && isFunction(path))
|
|
703
|
-
return this.load(path.apply(null, [this.getData(), updateFn]
|
|
704
|
-
return this.set(path, updateFn.apply(null, [this.get(path)]
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
|
|
617
|
+
return this.load(path.apply(null, [this.getData(), updateFn, ...args]));
|
|
618
|
+
return this.set(path, updateFn.apply(null, [this.get(path), ...args]));
|
|
619
|
+
}
|
|
620
|
+
mutate(path, updateFn, ...args) {
|
|
621
|
+
throw new Error(
|
|
622
|
+
"Mutate requires Immer. Please install 'immer' and 'cx-immer' packages and enable store mutation by calling enableImmerMutate().",
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
batch(callback) {
|
|
626
|
+
let dirty = this.silently(callback);
|
|
708
627
|
if (dirty) this.notify();
|
|
709
628
|
return dirty;
|
|
710
|
-
}
|
|
711
|
-
|
|
629
|
+
}
|
|
630
|
+
silently(callback) {
|
|
712
631
|
if (this.store) return this.store.silently(callback);
|
|
713
632
|
throw new Error("abstract method");
|
|
714
|
-
}
|
|
715
|
-
|
|
633
|
+
}
|
|
634
|
+
notify(path) {
|
|
716
635
|
if (this.notificationsSuspended) this.dirty = true;
|
|
717
636
|
else this.doNotify(path);
|
|
718
|
-
}
|
|
719
|
-
|
|
637
|
+
}
|
|
638
|
+
doNotify(path) {
|
|
720
639
|
if (this.store) return this.store.notify(path);
|
|
721
640
|
throw new Error("abstract method");
|
|
722
|
-
}
|
|
723
|
-
|
|
641
|
+
}
|
|
642
|
+
subscribe(callback) {
|
|
724
643
|
if (this.store) return this.store.subscribe(callback);
|
|
725
644
|
throw new Error("abstract method");
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
return this.
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
};
|
|
732
|
-
_proto.dispatch = function dispatch(action) {
|
|
645
|
+
}
|
|
646
|
+
load(data) {
|
|
647
|
+
return this.set(data);
|
|
648
|
+
}
|
|
649
|
+
dispatch(action) {
|
|
733
650
|
if (this.store) return this.store.dispatch(action);
|
|
734
651
|
throw new Error("The underlying store doesn't support dispatch.");
|
|
735
|
-
}
|
|
736
|
-
|
|
652
|
+
}
|
|
653
|
+
getMeta() {
|
|
737
654
|
return this.meta;
|
|
738
|
-
}
|
|
739
|
-
|
|
655
|
+
}
|
|
656
|
+
setStore(store) {
|
|
740
657
|
this.store = store;
|
|
741
658
|
this.meta = store.getMeta();
|
|
742
|
-
}
|
|
743
|
-
|
|
659
|
+
}
|
|
660
|
+
ref(path, defaultValue) {
|
|
744
661
|
if (isDefined(defaultValue)) this.init(path, defaultValue);
|
|
745
662
|
return StoreRef.create({
|
|
746
663
|
store: this,
|
|
747
|
-
path
|
|
664
|
+
path,
|
|
748
665
|
});
|
|
749
|
-
}
|
|
750
|
-
|
|
666
|
+
}
|
|
667
|
+
getMethods() {
|
|
751
668
|
return {
|
|
752
669
|
getData: this.getData.bind(this),
|
|
753
670
|
set: this.set.bind(this),
|
|
754
671
|
get: this.get.bind(this),
|
|
755
672
|
update: this.update.bind(this),
|
|
756
|
-
delete: this
|
|
673
|
+
delete: this.delete.bind(this),
|
|
757
674
|
toggle: this.toggle.bind(this),
|
|
758
675
|
init: this.init.bind(this),
|
|
759
676
|
ref: this.ref.bind(this),
|
|
760
|
-
mutate: this.
|
|
677
|
+
mutate: this.mutate.bind(this),
|
|
761
678
|
};
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
})();
|
|
679
|
+
}
|
|
680
|
+
}
|
|
765
681
|
View.prototype.sealed = false; //indicate that data should be copied before virtual items are added
|
|
766
682
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
)
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
_this = _View.call(this, config) || this;
|
|
778
|
-
_this.subscribers = new SubscriberList();
|
|
779
|
-
_this.changes = [];
|
|
780
|
-
return _this;
|
|
781
|
-
}
|
|
782
|
-
_inheritsLoose(SubscribableView, _View);
|
|
783
|
-
var _proto = SubscribableView.prototype;
|
|
784
|
-
_proto.subscribe = function subscribe(callback) {
|
|
683
|
+
class SubscribableView extends View {
|
|
684
|
+
subscribers;
|
|
685
|
+
changes;
|
|
686
|
+
scheduled;
|
|
687
|
+
constructor(config) {
|
|
688
|
+
super(config);
|
|
689
|
+
this.subscribers = new SubscriberList();
|
|
690
|
+
this.changes = [];
|
|
691
|
+
}
|
|
692
|
+
subscribe(callback) {
|
|
785
693
|
return this.subscribers.subscribe(callback);
|
|
786
|
-
}
|
|
787
|
-
|
|
694
|
+
}
|
|
695
|
+
unsubscribeAll() {
|
|
788
696
|
this.subscribers.clear();
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
var _this2 = this;
|
|
697
|
+
}
|
|
698
|
+
doNotify(path) {
|
|
792
699
|
if (this.notificationsSuspended) return;
|
|
793
700
|
if (!this.async) {
|
|
794
701
|
this.subscribers.notify([path]);
|
|
@@ -796,18 +703,18 @@ var SubscribableView = /*#__PURE__*/ (function (_View) {
|
|
|
796
703
|
this.changes.push(path || "");
|
|
797
704
|
if (!this.scheduled) {
|
|
798
705
|
this.scheduled = true;
|
|
799
|
-
setTimeout(
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
706
|
+
setTimeout(() => {
|
|
707
|
+
this.scheduled = false;
|
|
708
|
+
let changes = this.changes;
|
|
709
|
+
this.changes = [];
|
|
710
|
+
this.subscribers.notify(changes);
|
|
804
711
|
}, 0);
|
|
805
712
|
}
|
|
806
713
|
}
|
|
807
|
-
}
|
|
808
|
-
|
|
714
|
+
}
|
|
715
|
+
silently(callback) {
|
|
809
716
|
this.notificationsSuspended = (this.notificationsSuspended || 0) + 1;
|
|
810
|
-
|
|
717
|
+
let wasDirty = this.dirty,
|
|
811
718
|
dirty;
|
|
812
719
|
this.dirty = false;
|
|
813
720
|
try {
|
|
@@ -818,31 +725,24 @@ var SubscribableView = /*#__PURE__*/ (function (_View) {
|
|
|
818
725
|
this.dirty = wasDirty;
|
|
819
726
|
}
|
|
820
727
|
return dirty;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
})(View);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
824
730
|
SubscribableView.prototype.async = false;
|
|
825
731
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
_this = _SubscribableView.call(this, config) || this;
|
|
833
|
-
_this.data = config.data || {};
|
|
834
|
-
_this.meta = {
|
|
732
|
+
class Store extends SubscribableView {
|
|
733
|
+
data;
|
|
734
|
+
constructor(config = {}) {
|
|
735
|
+
super(config);
|
|
736
|
+
this.data = config.data ?? {};
|
|
737
|
+
this.meta = {
|
|
835
738
|
version: 0,
|
|
836
739
|
};
|
|
837
|
-
return _this;
|
|
838
740
|
}
|
|
839
|
-
|
|
840
|
-
var _proto = Store.prototype;
|
|
841
|
-
_proto.getData = function getData() {
|
|
741
|
+
getData() {
|
|
842
742
|
return this.data;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
|
|
743
|
+
}
|
|
744
|
+
setItem(path, value) {
|
|
745
|
+
let next = Binding.get(path).set(this.data, value);
|
|
846
746
|
if (next != this.data) {
|
|
847
747
|
this.data = next;
|
|
848
748
|
this.meta.version++;
|
|
@@ -850,9 +750,9 @@ var Store = /*#__PURE__*/ (function (_SubscribableView) {
|
|
|
850
750
|
return true;
|
|
851
751
|
}
|
|
852
752
|
return false;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
|
|
753
|
+
}
|
|
754
|
+
deleteItem(path) {
|
|
755
|
+
let next = Binding.get(path).delete(this.data);
|
|
856
756
|
if (next != this.data) {
|
|
857
757
|
this.data = next;
|
|
858
758
|
this.meta.version++;
|
|
@@ -860,23 +760,25 @@ var Store = /*#__PURE__*/ (function (_SubscribableView) {
|
|
|
860
760
|
return true;
|
|
861
761
|
}
|
|
862
762
|
return false;
|
|
863
|
-
}
|
|
864
|
-
|
|
763
|
+
}
|
|
764
|
+
clear() {
|
|
865
765
|
this.data = {};
|
|
866
766
|
this.meta.version++;
|
|
867
767
|
this.notify();
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
})(SubscribableView);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
871
770
|
Store.prototype.async = false;
|
|
872
771
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
772
|
+
class ExposedRecordView extends View {
|
|
773
|
+
itemIndex;
|
|
774
|
+
immutable;
|
|
775
|
+
collectionBinding;
|
|
776
|
+
recordName;
|
|
777
|
+
indexName;
|
|
778
|
+
constructor(config) {
|
|
779
|
+
super(config);
|
|
876
780
|
}
|
|
877
|
-
|
|
878
|
-
var _proto = ExposedRecordView.prototype;
|
|
879
|
-
_proto.getData = function getData() {
|
|
781
|
+
getData() {
|
|
880
782
|
if (
|
|
881
783
|
this.sealed &&
|
|
882
784
|
this.meta.version === this.cache.version &&
|
|
@@ -889,65 +791,63 @@ var ExposedRecordView = /*#__PURE__*/ (function (_View) {
|
|
|
889
791
|
this.cache.itemIndex = this.itemIndex;
|
|
890
792
|
this.meta = this.store.meta;
|
|
891
793
|
return this.cache.result;
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
794
|
+
}
|
|
795
|
+
embed(data) {
|
|
796
|
+
const collection = this.collectionBinding.value(data);
|
|
797
|
+
const record = collection[this.itemIndex];
|
|
798
|
+
const copy =
|
|
799
|
+
this.sealed || this.immutable || this.store.sealed
|
|
800
|
+
? {
|
|
801
|
+
...data,
|
|
802
|
+
}
|
|
803
|
+
: data;
|
|
897
804
|
copy[this.recordName] = record;
|
|
898
805
|
if (this.indexName) copy[this.indexName] = this.itemIndex;
|
|
899
806
|
return copy;
|
|
900
|
-
}
|
|
901
|
-
|
|
807
|
+
}
|
|
808
|
+
setIndex(index) {
|
|
902
809
|
this.itemIndex = index;
|
|
903
|
-
}
|
|
904
|
-
|
|
810
|
+
}
|
|
811
|
+
setItem(path, value) {
|
|
905
812
|
if (path == this.recordName || path.indexOf(this.recordName + ".") == 0) {
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
813
|
+
const storeData = this.store.getData();
|
|
814
|
+
const collection = this.collectionBinding.value(storeData);
|
|
815
|
+
const data = this.embed(storeData);
|
|
816
|
+
const d = Binding.get(path).set(data, value);
|
|
910
817
|
if (d === data) return false;
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
collection.slice(0, this.itemIndex),
|
|
914
|
-
[record],
|
|
915
|
-
collection.slice(this.itemIndex + 1),
|
|
916
|
-
);
|
|
818
|
+
const record = d[this.recordName];
|
|
819
|
+
const newCollection = [...collection.slice(0, this.itemIndex), record, ...collection.slice(this.itemIndex + 1)];
|
|
917
820
|
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
918
821
|
}
|
|
919
822
|
return this.store.setItem(path, value);
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
|
|
823
|
+
}
|
|
824
|
+
deleteItem(path) {
|
|
825
|
+
let storeData, collection, newCollection;
|
|
923
826
|
if (path == this.recordName) {
|
|
924
827
|
storeData = this.store.getData();
|
|
925
828
|
collection = this.collectionBinding.value(storeData);
|
|
926
|
-
newCollection = [
|
|
829
|
+
newCollection = [...collection.slice(0, this.itemIndex), ...collection.slice(this.itemIndex + 1)];
|
|
927
830
|
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
928
831
|
} else if (path.indexOf(this.recordName + ".") == 0) {
|
|
929
832
|
storeData = this.store.getData();
|
|
930
833
|
collection = this.collectionBinding.value(storeData);
|
|
931
|
-
|
|
932
|
-
|
|
834
|
+
const data = this.embed(storeData);
|
|
835
|
+
const d = Binding.get(path).delete(data);
|
|
933
836
|
if (d === data) return false;
|
|
934
|
-
|
|
935
|
-
newCollection = [
|
|
837
|
+
const record = d[this.recordName];
|
|
838
|
+
newCollection = [...collection.slice(0, this.itemIndex), record, ...collection.slice(this.itemIndex + 1)];
|
|
936
839
|
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
937
840
|
}
|
|
938
841
|
return this.store.deleteItem(path);
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
})(View);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
942
844
|
ExposedRecordView.prototype.immutable = false;
|
|
943
845
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
846
|
+
class ExposedValueView extends View {
|
|
847
|
+
constructor(config) {
|
|
848
|
+
super(config);
|
|
947
849
|
}
|
|
948
|
-
|
|
949
|
-
var _proto = ExposedValueView.prototype;
|
|
950
|
-
_proto.getData = function getData() {
|
|
850
|
+
getData() {
|
|
951
851
|
if (
|
|
952
852
|
this.sealed &&
|
|
953
853
|
this.meta.version === this.cache.version &&
|
|
@@ -955,23 +855,28 @@ var ExposedValueView = /*#__PURE__*/ (function (_View) {
|
|
|
955
855
|
this.meta == this.store.meta
|
|
956
856
|
)
|
|
957
857
|
return this.cache.result;
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
858
|
+
let data = this.store.getData();
|
|
859
|
+
let container = this.containerBinding.value(data) || {};
|
|
860
|
+
let record = container[this.key];
|
|
961
861
|
this.cache.version = this.meta.version;
|
|
962
862
|
this.cache.key = this.key;
|
|
963
|
-
this.cache.result =
|
|
863
|
+
this.cache.result =
|
|
864
|
+
this.sealed || this.immutable || this.store.sealed
|
|
865
|
+
? {
|
|
866
|
+
...data,
|
|
867
|
+
}
|
|
868
|
+
: data;
|
|
964
869
|
this.cache.result[this.recordName] = record;
|
|
965
870
|
this.meta = this.store.meta;
|
|
966
871
|
return this.cache.result;
|
|
967
|
-
}
|
|
968
|
-
|
|
872
|
+
}
|
|
873
|
+
setKey(key) {
|
|
969
874
|
this.key = key;
|
|
970
|
-
}
|
|
971
|
-
|
|
875
|
+
}
|
|
876
|
+
getKey() {
|
|
972
877
|
return this.key;
|
|
973
|
-
}
|
|
974
|
-
|
|
878
|
+
}
|
|
879
|
+
setItem(path, value) {
|
|
975
880
|
if (path == this.recordName || path.indexOf(this.recordName + ".") == 0) {
|
|
976
881
|
var data = this.getData();
|
|
977
882
|
var d = Binding.get(path).set(data, value);
|
|
@@ -983,8 +888,8 @@ var ExposedValueView = /*#__PURE__*/ (function (_View) {
|
|
|
983
888
|
return this.store.setItem(this.containerBinding.path, newContainer);
|
|
984
889
|
}
|
|
985
890
|
return this.store.setItem(path, value);
|
|
986
|
-
}
|
|
987
|
-
|
|
891
|
+
}
|
|
892
|
+
deleteItem(path) {
|
|
988
893
|
var data, container, newContainer;
|
|
989
894
|
if (path == this.recordName) {
|
|
990
895
|
data = this.getData();
|
|
@@ -995,7 +900,7 @@ var ExposedValueView = /*#__PURE__*/ (function (_View) {
|
|
|
995
900
|
this.store.set(this.containerBinding.path, newContainer);
|
|
996
901
|
} else if (path.indexOf(this.recordName + ".") == 0) {
|
|
997
902
|
data = this.getData();
|
|
998
|
-
var d = Binding.get(path)
|
|
903
|
+
var d = Binding.get(path).delete(data);
|
|
999
904
|
if (d === data) return false;
|
|
1000
905
|
container = this.containerBinding.value(d);
|
|
1001
906
|
var record = d[this.recordName];
|
|
@@ -1004,21 +909,18 @@ var ExposedValueView = /*#__PURE__*/ (function (_View) {
|
|
|
1004
909
|
return this.store.setItem(this.containerBinding.path, newContainer);
|
|
1005
910
|
}
|
|
1006
911
|
return this.store.deleteItem(path);
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
})(View);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
1010
914
|
ExposedValueView.prototype.immutable = false;
|
|
1011
915
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
916
|
+
class ReadOnlyDataView extends View {
|
|
917
|
+
constructor(config) {
|
|
918
|
+
super(config);
|
|
1015
919
|
}
|
|
1016
|
-
|
|
1017
|
-
var _proto = ReadOnlyDataView.prototype;
|
|
1018
|
-
_proto.getData = function getData() {
|
|
920
|
+
getData() {
|
|
1019
921
|
if (this.sealed && this.meta.version === this.cache.version && this.cache.data === this.data)
|
|
1020
922
|
return this.cache.result;
|
|
1021
|
-
|
|
923
|
+
let data = this.store.getData();
|
|
1022
924
|
this.cache.result =
|
|
1023
925
|
this.sealed || this.immutable || this.store.sealed
|
|
1024
926
|
? Object.assign({}, data, this.getAdditionalData(data))
|
|
@@ -1026,158 +928,156 @@ var ReadOnlyDataView = /*#__PURE__*/ (function (_View) {
|
|
|
1026
928
|
this.cache.version = this.meta.version;
|
|
1027
929
|
this.cache.data = this.data;
|
|
1028
930
|
return this.cache.result;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
931
|
+
}
|
|
932
|
+
getAdditionalData(data) {
|
|
1031
933
|
return this.data;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
934
|
+
}
|
|
935
|
+
setData(data) {
|
|
1034
936
|
this.data = data;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
})(View);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
1038
939
|
ReadOnlyDataView.prototype.immutable = false;
|
|
1039
940
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
941
|
+
class AugmentedViewBase extends View {
|
|
942
|
+
constructor(config) {
|
|
943
|
+
super(config);
|
|
1043
944
|
}
|
|
1044
|
-
|
|
1045
|
-
var _proto = AugmentedViewBase.prototype;
|
|
1046
|
-
_proto.getData = function getData() {
|
|
945
|
+
getData() {
|
|
1047
946
|
if (this.sealed && this.meta.version === this.cache.version && this.meta === this.store.meta)
|
|
1048
947
|
return this.cache.result;
|
|
1049
|
-
|
|
1050
|
-
|
|
948
|
+
let parentStoreData = this.store.getData();
|
|
949
|
+
let result = this.getBaseData(parentStoreData);
|
|
1051
950
|
this.embedAugmentData(result, parentStoreData);
|
|
1052
951
|
this.cache.result = result;
|
|
1053
952
|
this.cache.parentStoreData = parentStoreData;
|
|
1054
953
|
this.cache.version = this.meta.version;
|
|
1055
954
|
this.meta = this.store.meta;
|
|
1056
955
|
return this.cache.result;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
if (this.sealed || this.immutable || this.store.sealed)
|
|
956
|
+
}
|
|
957
|
+
getBaseData(parentStoreData) {
|
|
958
|
+
if (this.sealed || this.immutable || this.store.sealed)
|
|
959
|
+
return {
|
|
960
|
+
...parentStoreData,
|
|
961
|
+
};
|
|
1060
962
|
return parentStoreData;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
963
|
+
}
|
|
964
|
+
embedAugmentData(result, parentStoreData) {
|
|
1063
965
|
throw new Error("abstract");
|
|
1064
|
-
}
|
|
1065
|
-
|
|
966
|
+
}
|
|
967
|
+
isExtraKey(key) {
|
|
1066
968
|
throw new Error("abstract");
|
|
1067
|
-
}
|
|
1068
|
-
|
|
969
|
+
}
|
|
1069
970
|
// Stores which need to support nested aliases should override this method
|
|
1070
|
-
|
|
1071
|
-
|
|
971
|
+
getExtraKeyBinding(key) {
|
|
972
|
+
let binding = Binding.get(key);
|
|
1072
973
|
return this.isExtraKey(binding.parts[0]) ? Binding.get(binding.parts[0]) : null;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
974
|
+
}
|
|
975
|
+
setExtraKeyValue(key, value) {
|
|
1075
976
|
throw new Error("abstract");
|
|
1076
|
-
}
|
|
1077
|
-
|
|
977
|
+
}
|
|
978
|
+
deleteExtraKeyValue(key) {
|
|
1078
979
|
throw new Error("abstract");
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
|
|
980
|
+
}
|
|
981
|
+
setItem(path, value) {
|
|
982
|
+
let extraKeyBinding = this.getExtraKeyBinding(path);
|
|
1082
983
|
if (extraKeyBinding) {
|
|
1083
|
-
|
|
1084
|
-
|
|
984
|
+
let binding = Binding.get(path);
|
|
985
|
+
let newValue = value;
|
|
1085
986
|
if (binding.parts.length > extraKeyBinding.parts.length) {
|
|
1086
|
-
|
|
987
|
+
let data = {};
|
|
1087
988
|
this.embedAugmentData(data, this.store.getData());
|
|
1088
|
-
|
|
1089
|
-
data =
|
|
989
|
+
let binding = Binding.get(path);
|
|
990
|
+
data = binding.set(data, value);
|
|
1090
991
|
newValue = extraKeyBinding.value(data);
|
|
1091
992
|
}
|
|
1092
993
|
return this.setExtraKeyValue(extraKeyBinding.path, newValue);
|
|
1093
994
|
}
|
|
1094
|
-
return
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
995
|
+
return super.setItem(path, value);
|
|
996
|
+
}
|
|
997
|
+
deleteItem(path) {
|
|
998
|
+
let extraKeyBinding = this.getExtraKeyBinding(path);
|
|
1098
999
|
if (extraKeyBinding) {
|
|
1099
1000
|
if (path == extraKeyBinding.path) return this.deleteExtraKeyValue(extraKeyBinding.path);
|
|
1100
|
-
|
|
1001
|
+
let data = {};
|
|
1101
1002
|
this.embedAugmentData(data, this.store.getData());
|
|
1102
|
-
|
|
1103
|
-
data = binding
|
|
1104
|
-
|
|
1003
|
+
let binding = Binding.get(path);
|
|
1004
|
+
data = binding.delete(data);
|
|
1005
|
+
let newValue = extraKeyBinding.value(data);
|
|
1105
1006
|
return this.setExtraKeyValue(extraKeyBinding.path, newValue);
|
|
1106
1007
|
}
|
|
1107
|
-
return
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
})(View);
|
|
1008
|
+
return super.deleteItem(path);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1111
1011
|
AugmentedViewBase.prototype.immutable = false;
|
|
1112
1012
|
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1013
|
+
class NestedDataView extends AugmentedViewBase {
|
|
1014
|
+
constructor(config) {
|
|
1015
|
+
super(config);
|
|
1116
1016
|
}
|
|
1117
|
-
|
|
1118
|
-
var _proto = NestedDataView.prototype;
|
|
1119
|
-
_proto.embedAugmentData = function embedAugmentData(result, parentStoreData) {
|
|
1017
|
+
embedAugmentData(result, parentStoreData) {
|
|
1120
1018
|
if (this.nestedData) {
|
|
1121
|
-
|
|
1122
|
-
for (
|
|
1019
|
+
let nested = this.nestedData.getSelector()(parentStoreData);
|
|
1020
|
+
for (let key in nested) result[key] = nested[key];
|
|
1123
1021
|
}
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
return this.nestedData && this.nestedData.containsKey(key);
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
this.nestedData
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
}
|
|
1022
|
+
}
|
|
1023
|
+
isExtraKey(key) {
|
|
1024
|
+
return !!this.nestedData && this.nestedData.containsKey(key);
|
|
1025
|
+
}
|
|
1026
|
+
setExtraKeyValue(key, value) {
|
|
1027
|
+
if (!this.nestedData) throw new Error("Internal error. This should not happen.");
|
|
1028
|
+
return this.nestedData.setItem(key, value);
|
|
1029
|
+
}
|
|
1030
|
+
deleteExtraKeyValue(key) {
|
|
1031
|
+
return this.setExtraKeyValue(key, undefined);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1136
1034
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
_proto.getBaseData = function getBaseData(parentStoreData) {
|
|
1144
|
-
var x = this.binding.value(parentStoreData);
|
|
1035
|
+
class ZoomIntoPropertyView extends NestedDataView {
|
|
1036
|
+
constructor(config) {
|
|
1037
|
+
super(config);
|
|
1038
|
+
}
|
|
1039
|
+
getBaseData(parentStoreData) {
|
|
1040
|
+
let x = this.binding.value(parentStoreData);
|
|
1145
1041
|
if (x != null && typeof x != "object") throw new Error("Zoomed value must be an object.");
|
|
1146
|
-
return
|
|
1147
|
-
|
|
1148
|
-
|
|
1042
|
+
return {
|
|
1043
|
+
...x,
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
embedAugmentData(result, parentStoreData) {
|
|
1149
1047
|
result[this.rootName] = parentStoreData;
|
|
1150
|
-
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
if (path.indexOf(this.rootName + ".") == 0)
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
}
|
|
1048
|
+
super.embedAugmentData(result, parentStoreData);
|
|
1049
|
+
}
|
|
1050
|
+
setItem(path, value) {
|
|
1051
|
+
if (path.indexOf(this.rootName + ".") == 0)
|
|
1052
|
+
return this.store.setItem(path.substring(this.rootName.length + 1), value);
|
|
1053
|
+
if (this.isExtraKey(Binding.get(path).parts[0])) return super.setItem(path, value);
|
|
1054
|
+
return super.setItem(this.binding.path + "." + path, value);
|
|
1055
|
+
}
|
|
1056
|
+
deleteItem(path) {
|
|
1057
|
+
if (path.indexOf(this.rootName + ".") == 0) return this.store.deleteItem(path.substring(this.rootName.length + 1));
|
|
1058
|
+
if (this.isExtraKey(Binding.get(path).parts[0])) return super.deleteItem(path);
|
|
1059
|
+
return super.deleteItem(this.binding.path + "." + path);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1164
1062
|
ZoomIntoPropertyView.prototype.rootName = "$root";
|
|
1165
1063
|
|
|
1166
1064
|
function createStructuredSelector(selector, constants) {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1065
|
+
let keys = Object.keys(selector);
|
|
1066
|
+
constants = constants ?? {};
|
|
1067
|
+
if (keys.length == 0) {
|
|
1068
|
+
let result = () => constants;
|
|
1069
|
+
result.memoize = () => result;
|
|
1070
|
+
return result;
|
|
1071
|
+
}
|
|
1172
1072
|
function memoize() {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
keys.forEach(
|
|
1073
|
+
let lastResult = Object.assign({}, constants);
|
|
1074
|
+
let memoizedSelectors = {};
|
|
1075
|
+
keys.forEach((key) => {
|
|
1176
1076
|
memoizedSelectors[key] = selector[key].memoize ? selector[key].memoize() : selector[key];
|
|
1177
1077
|
lastResult[key] = undefined;
|
|
1178
1078
|
});
|
|
1179
1079
|
return function (data) {
|
|
1180
|
-
|
|
1080
|
+
let result = lastResult,
|
|
1181
1081
|
k,
|
|
1182
1082
|
v,
|
|
1183
1083
|
i;
|
|
@@ -1193,15 +1093,15 @@ function createStructuredSelector(selector, constants) {
|
|
|
1193
1093
|
return (lastResult = result);
|
|
1194
1094
|
};
|
|
1195
1095
|
}
|
|
1196
|
-
function evaluate(data) {
|
|
1197
|
-
|
|
1198
|
-
for (
|
|
1096
|
+
let result = function evaluate(data) {
|
|
1097
|
+
let result = Object.assign({}, constants);
|
|
1098
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1199
1099
|
result[keys[i]] = selector[keys[i]](data);
|
|
1200
1100
|
}
|
|
1201
1101
|
return result;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
return
|
|
1102
|
+
};
|
|
1103
|
+
result.memoize = memoize;
|
|
1104
|
+
return result;
|
|
1205
1105
|
}
|
|
1206
1106
|
|
|
1207
1107
|
function isSelector(config) {
|
|
@@ -1222,47 +1122,46 @@ function isSelector(config) {
|
|
|
1222
1122
|
return false;
|
|
1223
1123
|
}
|
|
1224
1124
|
|
|
1225
|
-
var undefinedF =
|
|
1226
|
-
|
|
1227
|
-
};
|
|
1228
|
-
var nullF = function nullF() {
|
|
1229
|
-
return null;
|
|
1230
|
-
};
|
|
1125
|
+
var undefinedF = () => undefined;
|
|
1126
|
+
var nullF = () => null;
|
|
1231
1127
|
function getSelector(config) {
|
|
1232
1128
|
if (config === undefined) return undefinedF;
|
|
1233
1129
|
if (config === null) return nullF;
|
|
1234
1130
|
switch (typeof config) {
|
|
1235
1131
|
case "object":
|
|
1236
1132
|
if (isArray(config)) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
});
|
|
1240
|
-
return function (data) {
|
|
1241
|
-
return _selectors.map(function (elementSelector) {
|
|
1242
|
-
return elementSelector(data);
|
|
1243
|
-
});
|
|
1244
|
-
};
|
|
1133
|
+
let selectors = config.map((x) => getSelector(x));
|
|
1134
|
+
return (data) => selectors.map((elementSelector) => elementSelector(data));
|
|
1245
1135
|
}
|
|
1246
|
-
|
|
1247
1136
|
//toString converts accessor chains to binding paths
|
|
1248
|
-
if (config.bind) return Binding.get(config.bind.toString()).value;
|
|
1249
|
-
if (
|
|
1250
|
-
if (config.expr)
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1137
|
+
if (hasKey(config, "bind") && config.bind != null) return Binding.get(config.bind.toString()).value;
|
|
1138
|
+
if (hasStringAtKey(config, "tpl")) return StringTemplate.get(config.tpl);
|
|
1139
|
+
if (hasKey(config, "expr") && (isString(config.expr) || isFunction(config.expr)))
|
|
1140
|
+
return Expression.get(config.expr);
|
|
1141
|
+
if (hasFunctionAtKey(config, "get")) return config.get;
|
|
1142
|
+
let selectors = {};
|
|
1143
|
+
let constants = {};
|
|
1144
|
+
let obj = config;
|
|
1145
|
+
for (let key in obj) {
|
|
1146
|
+
switch (typeof obj[key]) {
|
|
1147
|
+
case "bigint":
|
|
1148
|
+
case "boolean":
|
|
1149
|
+
case "number":
|
|
1150
|
+
case "string":
|
|
1151
|
+
constants[key] = obj[key];
|
|
1152
|
+
break;
|
|
1153
|
+
default:
|
|
1154
|
+
if (isSelector(obj[key])) selectors[key] = getSelector(obj[key]);
|
|
1155
|
+
else constants[key] = obj[key];
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1257
1158
|
}
|
|
1258
1159
|
return createStructuredSelector(selectors, constants);
|
|
1259
1160
|
case "function":
|
|
1260
1161
|
if (isAccessorChain(config)) return Binding.get(config.toString()).value;
|
|
1261
1162
|
return config;
|
|
1262
1163
|
default:
|
|
1263
|
-
return
|
|
1264
|
-
return config;
|
|
1265
|
-
};
|
|
1164
|
+
return () => config;
|
|
1266
1165
|
}
|
|
1267
1166
|
}
|
|
1268
1167
|
|
|
@@ -1271,7 +1170,7 @@ function defaultValue(pv) {
|
|
|
1271
1170
|
return pv;
|
|
1272
1171
|
}
|
|
1273
1172
|
function getSelectorConfig(props, values, nameMap) {
|
|
1274
|
-
|
|
1173
|
+
let functions = {},
|
|
1275
1174
|
structures = {},
|
|
1276
1175
|
defaultValues = {},
|
|
1277
1176
|
constants,
|
|
@@ -1305,7 +1204,7 @@ function getSelectorConfig(props, values, nameMap) {
|
|
|
1305
1204
|
} else if (pv && typeof pv == "object" && pv.structured) {
|
|
1306
1205
|
if (isArray(v)) functions[p] = getSelector(v);
|
|
1307
1206
|
else {
|
|
1308
|
-
|
|
1207
|
+
let s = getSelectorConfig(v, v, {});
|
|
1309
1208
|
structures[p] = s;
|
|
1310
1209
|
Object.assign(defaultValues, s.defaultValues);
|
|
1311
1210
|
}
|
|
@@ -1316,7 +1215,7 @@ function getSelectorConfig(props, values, nameMap) {
|
|
|
1316
1215
|
}
|
|
1317
1216
|
} else if (isFunction(v)) {
|
|
1318
1217
|
if (isAccessorChain(v)) {
|
|
1319
|
-
|
|
1218
|
+
let path = v.toString();
|
|
1320
1219
|
nameMap[p] = path;
|
|
1321
1220
|
functions[p] = Binding.get(path).value;
|
|
1322
1221
|
} else functions[p] = v;
|
|
@@ -1332,216 +1231,195 @@ function getSelectorConfig(props, values, nameMap) {
|
|
|
1332
1231
|
}
|
|
1333
1232
|
}
|
|
1334
1233
|
return {
|
|
1335
|
-
functions
|
|
1336
|
-
structures
|
|
1337
|
-
defaultValues
|
|
1338
|
-
constants
|
|
1339
|
-
constant
|
|
1234
|
+
functions,
|
|
1235
|
+
structures,
|
|
1236
|
+
defaultValues,
|
|
1237
|
+
constants,
|
|
1238
|
+
constant,
|
|
1340
1239
|
};
|
|
1341
1240
|
}
|
|
1342
|
-
function createSelector(
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
constants = _ref.constants;
|
|
1346
|
-
_ref.defaultValues;
|
|
1347
|
-
var selector = {};
|
|
1348
|
-
for (var n in functions) {
|
|
1241
|
+
function createSelector({ functions, structures, constants, defaultValues }) {
|
|
1242
|
+
let selector = {};
|
|
1243
|
+
for (let n in functions) {
|
|
1349
1244
|
selector[n] = functions[n];
|
|
1350
1245
|
}
|
|
1351
|
-
for (
|
|
1246
|
+
for (let n in structures) selector[n] = createSelector(structures[n]);
|
|
1352
1247
|
return createStructuredSelector(selector, constants);
|
|
1353
1248
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1249
|
+
class StructuredSelector {
|
|
1250
|
+
nameMap;
|
|
1251
|
+
config;
|
|
1252
|
+
constructor({ props, values }) {
|
|
1358
1253
|
this.nameMap = {};
|
|
1359
1254
|
this.config = getSelectorConfig(props, values, this.nameMap);
|
|
1360
1255
|
}
|
|
1361
|
-
|
|
1362
|
-
_proto.init = function init(store) {
|
|
1256
|
+
init(store) {
|
|
1363
1257
|
store.init(this.config.defaultValues);
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
memoize = true;
|
|
1368
|
-
}
|
|
1369
|
-
var selector = createSelector(this.config);
|
|
1258
|
+
}
|
|
1259
|
+
create(memoize = true) {
|
|
1260
|
+
let selector = createSelector(this.config);
|
|
1370
1261
|
if (memoize && selector.memoize) return selector.memoize();
|
|
1371
1262
|
return selector;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1263
|
+
}
|
|
1264
|
+
createStoreSelector() {
|
|
1374
1265
|
if (this.config.constant) {
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
return result;
|
|
1266
|
+
let result = {
|
|
1267
|
+
...this.config.constants,
|
|
1378
1268
|
};
|
|
1269
|
+
return () => result;
|
|
1379
1270
|
}
|
|
1380
|
-
|
|
1381
|
-
return
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
};
|
|
1385
|
-
return StructuredSelector;
|
|
1386
|
-
})();
|
|
1271
|
+
let selector = this.create();
|
|
1272
|
+
return (store) => selector(store.getData());
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1387
1275
|
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
AggregateFunction.sum = function sum() {
|
|
1276
|
+
class AggregateFunction {
|
|
1277
|
+
static sum() {
|
|
1391
1278
|
return new Sum();
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1279
|
+
}
|
|
1280
|
+
static avg() {
|
|
1394
1281
|
return new Avg();
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1282
|
+
}
|
|
1283
|
+
static count() {
|
|
1397
1284
|
return new Count();
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1285
|
+
}
|
|
1286
|
+
static distinct() {
|
|
1400
1287
|
return new Distinct();
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1288
|
+
}
|
|
1289
|
+
static min() {
|
|
1403
1290
|
return new Min();
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1291
|
+
}
|
|
1292
|
+
static max() {
|
|
1406
1293
|
return new Max();
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1294
|
+
}
|
|
1295
|
+
static last() {
|
|
1409
1296
|
return new LastValue();
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
class Sum {
|
|
1300
|
+
result = 0;
|
|
1301
|
+
empty = true;
|
|
1302
|
+
invalid;
|
|
1303
|
+
process(value) {
|
|
1417
1304
|
this.empty = false;
|
|
1418
1305
|
if (!isNaN(value)) this.result += value;
|
|
1419
1306
|
else this.invalid = true;
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1307
|
+
}
|
|
1308
|
+
getResult() {
|
|
1422
1309
|
if (this.invalid) return null;
|
|
1423
1310
|
return this.result;
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
})();
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1427
1313
|
Sum.prototype.result = 0;
|
|
1428
1314
|
Sum.prototype.empty = true;
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
}
|
|
1315
|
+
class Avg {
|
|
1316
|
+
result = 0;
|
|
1317
|
+
count = 0;
|
|
1318
|
+
empty = true;
|
|
1319
|
+
invalid;
|
|
1320
|
+
process(value, count = 1) {
|
|
1436
1321
|
this.empty = false;
|
|
1437
1322
|
if (!isNaN(value) && !isNaN(count)) {
|
|
1438
1323
|
this.result += value * count;
|
|
1439
1324
|
this.count += count;
|
|
1440
1325
|
} else this.invalid = true;
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1326
|
+
}
|
|
1327
|
+
getResult() {
|
|
1443
1328
|
if (this.empty || this.invalid || this.count == 0) return null;
|
|
1444
1329
|
return this.result / this.count;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
})();
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1448
1332
|
Avg.prototype.result = 0;
|
|
1449
1333
|
Avg.prototype.count = 0;
|
|
1450
1334
|
Avg.prototype.empty = true;
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
_proto3.process = function process(value) {
|
|
1335
|
+
class Count {
|
|
1336
|
+
result = 0;
|
|
1337
|
+
process(value) {
|
|
1455
1338
|
if (value != null) this.result++;
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1339
|
+
}
|
|
1340
|
+
getResult() {
|
|
1458
1341
|
return this.result;
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
})();
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1462
1344
|
Count.prototype.result = 0;
|
|
1463
|
-
|
|
1464
|
-
|
|
1345
|
+
class Distinct {
|
|
1346
|
+
values = {};
|
|
1347
|
+
empty = true;
|
|
1348
|
+
result = 0;
|
|
1349
|
+
invalid;
|
|
1350
|
+
constructor() {
|
|
1465
1351
|
this.values = {};
|
|
1466
1352
|
}
|
|
1467
|
-
|
|
1468
|
-
_proto4.process = function process(value) {
|
|
1353
|
+
process(value) {
|
|
1469
1354
|
if (value == null || this.values[value]) return;
|
|
1470
1355
|
this.values[value] = true;
|
|
1471
1356
|
this.empty = false;
|
|
1472
1357
|
this.result++;
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1358
|
+
}
|
|
1359
|
+
getResult() {
|
|
1475
1360
|
if (this.empty || this.invalid) return null;
|
|
1476
1361
|
return this.result;
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
})();
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1480
1364
|
Distinct.prototype.result = 0;
|
|
1481
1365
|
Distinct.prototype.empty = true;
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1366
|
+
class Max {
|
|
1367
|
+
result = 0;
|
|
1368
|
+
empty = true;
|
|
1369
|
+
invalid;
|
|
1370
|
+
process(value) {
|
|
1486
1371
|
if (!isNaN(value)) {
|
|
1487
1372
|
if (this.empty) this.result = value;
|
|
1488
1373
|
else if (value > this.result) this.result = value;
|
|
1489
1374
|
this.empty = false;
|
|
1490
1375
|
} else if (value != null) this.invalid = true;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1376
|
+
}
|
|
1377
|
+
getResult() {
|
|
1493
1378
|
if (this.empty || this.invalid) return null;
|
|
1494
1379
|
return this.result;
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
})();
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1498
1382
|
Max.prototype.result = 0;
|
|
1499
1383
|
Max.prototype.empty = true;
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1384
|
+
class Min {
|
|
1385
|
+
result = 0;
|
|
1386
|
+
empty = true;
|
|
1387
|
+
invalid;
|
|
1388
|
+
process(value) {
|
|
1504
1389
|
if (!isNaN(value)) {
|
|
1505
1390
|
if (this.empty) this.result = value;
|
|
1506
1391
|
else if (value < this.result) this.result = value;
|
|
1507
1392
|
this.empty = false;
|
|
1508
1393
|
} else if (value != null) this.invalid = true;
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1394
|
+
}
|
|
1395
|
+
getResult() {
|
|
1511
1396
|
if (this.empty || this.invalid) return null;
|
|
1512
1397
|
return this.result;
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
})();
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1516
1400
|
Min.prototype.result = 0;
|
|
1517
1401
|
Min.prototype.empty = true;
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
_proto7.process = function process(value) {
|
|
1402
|
+
class LastValue {
|
|
1403
|
+
result = null;
|
|
1404
|
+
process(value) {
|
|
1522
1405
|
this.result = value;
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1406
|
+
}
|
|
1407
|
+
getResult() {
|
|
1525
1408
|
return this.result;
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
})();
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1529
1411
|
LastValue.prototype.result = null;
|
|
1530
1412
|
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
function Grouper(key, aggregates, dataGetter, nameGetter) {
|
|
1542
|
-
this.keys = Object.keys(key).map(function (keyField) {
|
|
1543
|
-
var isSimpleField = keyField.indexOf(".") === -1;
|
|
1544
|
-
var keySetter;
|
|
1413
|
+
class Grouper {
|
|
1414
|
+
keys;
|
|
1415
|
+
nameGetter;
|
|
1416
|
+
dataGetter;
|
|
1417
|
+
aggregates;
|
|
1418
|
+
groups;
|
|
1419
|
+
constructor(key, aggregates, dataGetter, nameGetter) {
|
|
1420
|
+
this.keys = Object.keys(key).map((keyField) => {
|
|
1421
|
+
let isSimpleField = keyField.indexOf(".") === -1;
|
|
1422
|
+
let keySetter;
|
|
1545
1423
|
if (isSimpleField) {
|
|
1546
1424
|
// use simple field setter wherever possible
|
|
1547
1425
|
keySetter = function set(result, value) {
|
|
@@ -1550,49 +1428,41 @@ var Grouper = /*#__PURE__*/ (function () {
|
|
|
1550
1428
|
};
|
|
1551
1429
|
} else {
|
|
1552
1430
|
// for complex paths, use deep setter
|
|
1553
|
-
|
|
1554
|
-
keySetter =
|
|
1555
|
-
return binding.set(result, value);
|
|
1556
|
-
};
|
|
1431
|
+
let binding = Binding.get(keyField);
|
|
1432
|
+
keySetter = (result, value) => binding.set(result, value);
|
|
1557
1433
|
}
|
|
1558
1434
|
return {
|
|
1559
1435
|
name: keyField,
|
|
1560
|
-
keySetter
|
|
1436
|
+
keySetter,
|
|
1561
1437
|
value: getSelector(key[keyField]),
|
|
1562
1438
|
};
|
|
1563
1439
|
});
|
|
1564
1440
|
if (nameGetter) this.nameGetter = getSelector(nameGetter);
|
|
1565
|
-
this.dataGetter =
|
|
1566
|
-
dataGetter ||
|
|
1567
|
-
function (x) {
|
|
1568
|
-
return x;
|
|
1569
|
-
};
|
|
1441
|
+
this.dataGetter = dataGetter || ((x) => x);
|
|
1570
1442
|
this.aggregates =
|
|
1571
1443
|
aggregates &&
|
|
1572
|
-
transformValues(aggregates,
|
|
1573
|
-
|
|
1574
|
-
if (!AggregateFunction[prop.type]) throw new Error("Unknown aggregate function '" + prop.type + "'.");
|
|
1444
|
+
transformValues(aggregates, (prop) => {
|
|
1445
|
+
if (!(prop.type in AggregateFunction)) throw new Error(`Unknown aggregate function '${prop.type}'.`);
|
|
1575
1446
|
return {
|
|
1576
1447
|
value: getSelector(prop.value),
|
|
1577
|
-
weight: getSelector(
|
|
1448
|
+
weight: getSelector(prop.weight ?? 1),
|
|
1578
1449
|
type: prop.type,
|
|
1579
1450
|
};
|
|
1580
1451
|
});
|
|
1581
1452
|
this.reset();
|
|
1582
1453
|
}
|
|
1583
|
-
|
|
1584
|
-
_proto.reset = function reset() {
|
|
1454
|
+
reset() {
|
|
1585
1455
|
this.groups = this.initGroup(this.keys.length == 0);
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1456
|
+
}
|
|
1457
|
+
initGroup(leaf) {
|
|
1588
1458
|
if (!leaf) return {};
|
|
1589
1459
|
return {
|
|
1590
1460
|
records: [],
|
|
1591
1461
|
indexes: [],
|
|
1592
1462
|
aggregates:
|
|
1593
1463
|
this.aggregates &&
|
|
1594
|
-
transformValues(this.aggregates,
|
|
1595
|
-
|
|
1464
|
+
transformValues(this.aggregates, (prop) => {
|
|
1465
|
+
let f = AggregateFunction[prop.type];
|
|
1596
1466
|
return {
|
|
1597
1467
|
processor: f(),
|
|
1598
1468
|
value: prop.value,
|
|
@@ -1600,15 +1470,13 @@ var Grouper = /*#__PURE__*/ (function () {
|
|
|
1600
1470
|
};
|
|
1601
1471
|
}),
|
|
1602
1472
|
};
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
for (var i = 0; i < key.length; i++) {
|
|
1611
|
-
var sg = g[key[i]];
|
|
1473
|
+
}
|
|
1474
|
+
process(record, index) {
|
|
1475
|
+
let data = this.dataGetter(record);
|
|
1476
|
+
let key = this.keys.map((k) => k.value(data));
|
|
1477
|
+
let g = this.groups;
|
|
1478
|
+
for (let i = 0; i < key.length; i++) {
|
|
1479
|
+
let sg = g[key[i]];
|
|
1612
1480
|
if (!sg) {
|
|
1613
1481
|
sg = g[key[i]] = this.initGroup(i + 1 == key.length);
|
|
1614
1482
|
if (this.nameGetter) sg.name = this.nameGetter(data);
|
|
@@ -1618,24 +1486,19 @@ var Grouper = /*#__PURE__*/ (function () {
|
|
|
1618
1486
|
g.records.push(record);
|
|
1619
1487
|
g.indexes.push(index);
|
|
1620
1488
|
if (g.aggregates) {
|
|
1621
|
-
for (
|
|
1489
|
+
for (let k in g.aggregates)
|
|
1622
1490
|
g.aggregates[k].processor.process(g.aggregates[k].value(data), g.aggregates[k].weight(data));
|
|
1623
1491
|
}
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
var _this = this;
|
|
1492
|
+
}
|
|
1493
|
+
processAll(records, indexes) {
|
|
1627
1494
|
if (indexes) {
|
|
1628
|
-
for (
|
|
1629
|
-
} else
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
});
|
|
1633
|
-
};
|
|
1634
|
-
_proto.report = function report(g, path, level, results) {
|
|
1635
|
-
var _this2 = this;
|
|
1495
|
+
for (let i = 0; i < records.length; i++) this.process(records[i], indexes[i]);
|
|
1496
|
+
} else records.forEach((r, i) => this.process(r, i));
|
|
1497
|
+
}
|
|
1498
|
+
report(g, path, level, results) {
|
|
1636
1499
|
if (level == this.keys.length) {
|
|
1637
|
-
|
|
1638
|
-
this.keys.forEach(
|
|
1500
|
+
let key = {};
|
|
1501
|
+
this.keys.forEach((k, i) => {
|
|
1639
1502
|
key = k.keySetter(key, path[i]);
|
|
1640
1503
|
});
|
|
1641
1504
|
results.push({
|
|
@@ -1643,38 +1506,29 @@ var Grouper = /*#__PURE__*/ (function () {
|
|
|
1643
1506
|
name: g.name,
|
|
1644
1507
|
records: g.records,
|
|
1645
1508
|
indexes: g.indexes,
|
|
1646
|
-
aggregates: resolveKeyPaths(
|
|
1647
|
-
transformValues(g.aggregates, function (p) {
|
|
1648
|
-
return p.processor.getResult();
|
|
1649
|
-
}),
|
|
1650
|
-
),
|
|
1509
|
+
aggregates: resolveKeyPaths(transformValues(g.aggregates, (p) => p.processor.getResult())),
|
|
1651
1510
|
});
|
|
1652
1511
|
} else {
|
|
1653
|
-
Object.keys(g).forEach(
|
|
1654
|
-
return _this2.report(g[k], [].concat(path, [k]), level + 1, results);
|
|
1655
|
-
});
|
|
1512
|
+
Object.keys(g).forEach((k) => this.report(g[k], [...path, k], level + 1, results));
|
|
1656
1513
|
}
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1514
|
+
}
|
|
1515
|
+
getResults() {
|
|
1516
|
+
let g = this.groups;
|
|
1517
|
+
let results = [];
|
|
1661
1518
|
this.report(g, [], 0, results);
|
|
1662
1519
|
return results;
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
})();
|
|
1666
|
-
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1667
1522
|
// transform object values using a function
|
|
1668
1523
|
function transformValues(o, f) {
|
|
1669
|
-
|
|
1670
|
-
for (
|
|
1524
|
+
let res = {};
|
|
1525
|
+
for (let k in o) res[k] = f(o[k], k);
|
|
1671
1526
|
return res;
|
|
1672
1527
|
}
|
|
1673
|
-
|
|
1674
1528
|
// transform keys like 'a.b.c' into nested objects
|
|
1675
1529
|
function resolveKeyPaths(o) {
|
|
1676
|
-
|
|
1677
|
-
for (
|
|
1530
|
+
let res = {};
|
|
1531
|
+
for (let k in o) {
|
|
1678
1532
|
if (k.indexOf(".") > 0) res = Binding.get(k).set(res, o[k]);
|
|
1679
1533
|
else res[k] = o[k];
|
|
1680
1534
|
}
|
|
@@ -1692,40 +1546,27 @@ function defaultCompare(av, bv) {
|
|
|
1692
1546
|
}
|
|
1693
1547
|
|
|
1694
1548
|
function getComparer(sorters, dataAccessor, comparer) {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
? getSelector(s.value)
|
|
1698
|
-
: s.field
|
|
1699
|
-
? function (x) {
|
|
1700
|
-
return x[s.field];
|
|
1701
|
-
}
|
|
1702
|
-
: function () {
|
|
1703
|
-
return null;
|
|
1704
|
-
};
|
|
1549
|
+
let resolvedSorters = (sorters || []).map((s) => {
|
|
1550
|
+
let selector = isDefined(s.value) ? getSelector(s.value) : s.field ? (x) => x[s.field] : () => null;
|
|
1705
1551
|
return {
|
|
1706
|
-
getter: dataAccessor
|
|
1707
|
-
? function (x) {
|
|
1708
|
-
return selector(dataAccessor(x));
|
|
1709
|
-
}
|
|
1710
|
-
: selector,
|
|
1552
|
+
getter: dataAccessor ? (x) => selector(dataAccessor(x)) : selector,
|
|
1711
1553
|
factor: s.direction && s.direction[0].toLowerCase() == "d" ? -1 : 1,
|
|
1712
1554
|
compare: s.comparer || s.compare || comparer || defaultCompare,
|
|
1713
1555
|
};
|
|
1714
1556
|
});
|
|
1715
1557
|
return function (a, b) {
|
|
1716
|
-
|
|
1717
|
-
for (
|
|
1558
|
+
let d, av, bv;
|
|
1559
|
+
for (let i = 0; i < resolvedSorters.length; i++) {
|
|
1718
1560
|
d = resolvedSorters[i];
|
|
1719
1561
|
av = d.getter(a);
|
|
1720
1562
|
bv = d.getter(b);
|
|
1721
|
-
|
|
1722
1563
|
// show nulls always on the bottom
|
|
1723
1564
|
if (av == null) {
|
|
1724
1565
|
if (bv == null) continue;
|
|
1725
1566
|
else return 1;
|
|
1726
1567
|
}
|
|
1727
1568
|
if (bv == null) return -1;
|
|
1728
|
-
|
|
1569
|
+
let r = d.compare(av, bv);
|
|
1729
1570
|
if (r == 0) continue;
|
|
1730
1571
|
return d.factor * r;
|
|
1731
1572
|
}
|
|
@@ -1733,26 +1574,22 @@ function getComparer(sorters, dataAccessor, comparer) {
|
|
|
1733
1574
|
};
|
|
1734
1575
|
}
|
|
1735
1576
|
function indexSorter(sorters, dataAccessor, compare) {
|
|
1736
|
-
|
|
1577
|
+
let cmp = getComparer(sorters, dataAccessor, compare);
|
|
1737
1578
|
return function (data) {
|
|
1738
|
-
|
|
1579
|
+
let result = Array.from(
|
|
1739
1580
|
{
|
|
1740
1581
|
length: data.length,
|
|
1741
1582
|
},
|
|
1742
|
-
|
|
1743
|
-
return k;
|
|
1744
|
-
},
|
|
1583
|
+
(v, k) => k,
|
|
1745
1584
|
);
|
|
1746
|
-
result.sort(
|
|
1747
|
-
return cmp(data[ia], data[ib]);
|
|
1748
|
-
});
|
|
1585
|
+
result.sort((ia, ib) => cmp(data[ia], data[ib]));
|
|
1749
1586
|
return result;
|
|
1750
1587
|
};
|
|
1751
1588
|
}
|
|
1752
1589
|
function sorter(sorters, dataAccessor, compare) {
|
|
1753
|
-
|
|
1590
|
+
let cmp = getComparer(sorters, dataAccessor, compare);
|
|
1754
1591
|
return function (data) {
|
|
1755
|
-
|
|
1592
|
+
let result = [...data];
|
|
1756
1593
|
result.sort(cmp);
|
|
1757
1594
|
return result;
|
|
1758
1595
|
};
|
|
@@ -1762,43 +1599,46 @@ function enableFatArrowExpansion() {
|
|
|
1762
1599
|
plugFatArrowExpansion(expandFatArrows);
|
|
1763
1600
|
}
|
|
1764
1601
|
|
|
1765
|
-
function append(array) {
|
|
1766
|
-
|
|
1767
|
-
items[_key - 1] = arguments[_key];
|
|
1768
|
-
}
|
|
1769
|
-
if (items.length == 0) return array;
|
|
1602
|
+
function append(array, ...items) {
|
|
1603
|
+
if (items.length === 0) return array ?? [];
|
|
1770
1604
|
if (!array) return items;
|
|
1771
|
-
return [
|
|
1605
|
+
return [...array, ...items];
|
|
1772
1606
|
}
|
|
1773
1607
|
|
|
1774
1608
|
function merge(item, data) {
|
|
1775
|
-
|
|
1776
|
-
if (data)
|
|
1609
|
+
let result = item;
|
|
1610
|
+
if (data) {
|
|
1611
|
+
for (const key in data) {
|
|
1612
|
+
result = Binding.get(key).set(result, data[key]);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1777
1615
|
return result;
|
|
1778
1616
|
}
|
|
1779
1617
|
|
|
1780
1618
|
function filter(array, callback) {
|
|
1781
1619
|
if (array == null) return array;
|
|
1782
|
-
|
|
1783
|
-
if (result.length
|
|
1620
|
+
const result = array.filter(callback);
|
|
1621
|
+
if (result.length === array.length) return array;
|
|
1784
1622
|
return result;
|
|
1785
1623
|
}
|
|
1786
1624
|
|
|
1787
1625
|
function updateArray(array, updateCallback, itemFilter, removeFilter) {
|
|
1788
1626
|
if (!array) return array;
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
for (
|
|
1792
|
-
|
|
1627
|
+
const newArray = [];
|
|
1628
|
+
let dirty = false;
|
|
1629
|
+
for (let index = 0; index < array.length; index++) {
|
|
1630
|
+
const item = array[index];
|
|
1793
1631
|
if (removeFilter && removeFilter(item, index)) {
|
|
1794
1632
|
dirty = true;
|
|
1795
1633
|
continue;
|
|
1796
1634
|
}
|
|
1797
1635
|
if (!itemFilter || itemFilter(item, index)) {
|
|
1798
|
-
|
|
1636
|
+
const newItem = updateCallback(item, index);
|
|
1799
1637
|
newArray.push(newItem);
|
|
1800
1638
|
if (newItem !== item) dirty = true;
|
|
1801
|
-
} else
|
|
1639
|
+
} else {
|
|
1640
|
+
newArray.push(item);
|
|
1641
|
+
}
|
|
1802
1642
|
}
|
|
1803
1643
|
return dirty ? newArray : array;
|
|
1804
1644
|
}
|
|
@@ -1806,14 +1646,16 @@ function updateArray(array, updateCallback, itemFilter, removeFilter) {
|
|
|
1806
1646
|
function updateTree(array, updateCallback, itemFilter, childrenField, removeFilter) {
|
|
1807
1647
|
return updateArray(
|
|
1808
1648
|
array,
|
|
1809
|
-
|
|
1810
|
-
var _extends2;
|
|
1649
|
+
(item) => {
|
|
1811
1650
|
if (!itemFilter || itemFilter(item)) item = updateCallback(item);
|
|
1812
|
-
|
|
1651
|
+
const children = item[childrenField];
|
|
1813
1652
|
if (!Array.isArray(children)) return item;
|
|
1814
|
-
|
|
1653
|
+
const updatedChildren = updateTree(children, updateCallback, itemFilter, childrenField, removeFilter);
|
|
1815
1654
|
if (updatedChildren != children)
|
|
1816
|
-
return
|
|
1655
|
+
return {
|
|
1656
|
+
...item,
|
|
1657
|
+
[childrenField]: updatedChildren,
|
|
1658
|
+
};
|
|
1817
1659
|
return item;
|
|
1818
1660
|
},
|
|
1819
1661
|
null,
|
|
@@ -1821,271 +1663,223 @@ function updateTree(array, updateCallback, itemFilter, childrenField, removeFilt
|
|
|
1821
1663
|
);
|
|
1822
1664
|
}
|
|
1823
1665
|
|
|
1824
|
-
function removeTreeNodes(array, criteria, childrenField) {
|
|
1825
|
-
if (childrenField === void 0) {
|
|
1826
|
-
childrenField = "$children";
|
|
1827
|
-
}
|
|
1666
|
+
function removeTreeNodes(array, criteria, childrenField = "$children") {
|
|
1828
1667
|
return updateTree(
|
|
1829
1668
|
array,
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
return false;
|
|
1833
|
-
},
|
|
1669
|
+
(x) => x,
|
|
1670
|
+
() => false,
|
|
1834
1671
|
childrenField,
|
|
1835
1672
|
criteria,
|
|
1836
1673
|
);
|
|
1837
1674
|
}
|
|
1838
1675
|
|
|
1839
|
-
function findTreeNode(array, criteria, childrenField) {
|
|
1840
|
-
if (childrenField === void 0) {
|
|
1841
|
-
childrenField = "$children";
|
|
1842
|
-
}
|
|
1676
|
+
function findTreeNode(array, criteria, childrenField = "$children") {
|
|
1843
1677
|
if (!Array.isArray(array)) return false;
|
|
1844
|
-
for (
|
|
1845
|
-
if (criteria(
|
|
1846
|
-
|
|
1847
|
-
|
|
1678
|
+
for (const node of array) {
|
|
1679
|
+
if (criteria(node)) return node;
|
|
1680
|
+
const children = node[childrenField];
|
|
1681
|
+
const found = findTreeNode(children, criteria, childrenField);
|
|
1682
|
+
if (found) return found;
|
|
1848
1683
|
}
|
|
1849
1684
|
return false;
|
|
1850
1685
|
}
|
|
1851
1686
|
|
|
1852
1687
|
function moveElement(array, sourceIndex, targetIndex) {
|
|
1853
|
-
if (
|
|
1854
|
-
|
|
1855
|
-
|
|
1688
|
+
if (sourceIndex === targetIndex) return array;
|
|
1689
|
+
const result = [...array];
|
|
1690
|
+
const element = result[sourceIndex];
|
|
1856
1691
|
if (sourceIndex < targetIndex) {
|
|
1857
|
-
for (
|
|
1692
|
+
for (let i = sourceIndex; i < targetIndex - 1; i++) {
|
|
1693
|
+
result[i] = result[i + 1];
|
|
1694
|
+
}
|
|
1695
|
+
result[targetIndex - 1] = result[targetIndex];
|
|
1858
1696
|
targetIndex--;
|
|
1859
1697
|
} else {
|
|
1860
|
-
for (
|
|
1698
|
+
for (let i = sourceIndex; i > targetIndex; i--) {
|
|
1699
|
+
result[i] = result[i - 1];
|
|
1700
|
+
}
|
|
1861
1701
|
}
|
|
1862
|
-
|
|
1863
|
-
return
|
|
1702
|
+
result[targetIndex] = element;
|
|
1703
|
+
return result;
|
|
1864
1704
|
}
|
|
1865
1705
|
|
|
1866
|
-
function insertElement(array, index) {
|
|
1867
|
-
|
|
1868
|
-
args[_key - 2] = arguments[_key];
|
|
1869
|
-
}
|
|
1870
|
-
return [].concat(array.slice(0, index), args, array.slice(index));
|
|
1706
|
+
function insertElement(array, index, ...elements) {
|
|
1707
|
+
return [...array.slice(0, index), ...elements, ...array.slice(index)];
|
|
1871
1708
|
}
|
|
1872
1709
|
|
|
1873
|
-
function findTreePath(array, criteria, childrenField, currentPath) {
|
|
1874
|
-
if (childrenField === void 0) {
|
|
1875
|
-
childrenField = "$children";
|
|
1876
|
-
}
|
|
1877
|
-
if (currentPath === void 0) {
|
|
1878
|
-
currentPath = [];
|
|
1879
|
-
}
|
|
1710
|
+
function findTreePath(array, criteria, childrenField = "$children", currentPath = []) {
|
|
1880
1711
|
if (!Array.isArray(array)) return false;
|
|
1881
|
-
for (
|
|
1882
|
-
currentPath.push(
|
|
1883
|
-
if (criteria(
|
|
1884
|
-
|
|
1712
|
+
for (const node of array) {
|
|
1713
|
+
currentPath.push(node);
|
|
1714
|
+
if (criteria(node)) return [...currentPath];
|
|
1715
|
+
const children = node[childrenField];
|
|
1716
|
+
const childPath = findTreePath(children, criteria, childrenField, currentPath);
|
|
1885
1717
|
if (childPath) return childPath;
|
|
1886
1718
|
currentPath.pop();
|
|
1887
1719
|
}
|
|
1888
1720
|
return false;
|
|
1889
1721
|
}
|
|
1890
1722
|
|
|
1891
|
-
function diffArrays(oldArray, newArray, keyFn) {
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
else
|
|
1723
|
+
function diffArrays(oldArray, newArray, keyFn = (e) => e) {
|
|
1724
|
+
const map = new Map();
|
|
1725
|
+
oldArray.forEach((item) => {
|
|
1726
|
+
const key = keyFn(item);
|
|
1727
|
+
map.set(key, item);
|
|
1728
|
+
});
|
|
1729
|
+
const added = [];
|
|
1730
|
+
const changed = [];
|
|
1731
|
+
const unchanged = [];
|
|
1732
|
+
newArray.forEach((item) => {
|
|
1733
|
+
const key = keyFn(item);
|
|
1734
|
+
const oldItem = map.get(key);
|
|
1735
|
+
if (isUndefined(oldItem)) {
|
|
1736
|
+
added.push(item);
|
|
1737
|
+
} else {
|
|
1738
|
+
map.delete(key);
|
|
1739
|
+
if (item === oldItem) {
|
|
1740
|
+
unchanged.push(item);
|
|
1741
|
+
} else {
|
|
1910
1742
|
changed.push({
|
|
1911
|
-
before:
|
|
1912
|
-
after:
|
|
1743
|
+
before: oldItem,
|
|
1744
|
+
after: item,
|
|
1913
1745
|
});
|
|
1746
|
+
}
|
|
1914
1747
|
}
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1748
|
+
});
|
|
1749
|
+
const removed = Array.from(map.values());
|
|
1917
1750
|
return {
|
|
1918
|
-
added
|
|
1919
|
-
changed
|
|
1920
|
-
unchanged
|
|
1921
|
-
removed
|
|
1751
|
+
added,
|
|
1752
|
+
changed,
|
|
1753
|
+
unchanged,
|
|
1754
|
+
removed,
|
|
1922
1755
|
};
|
|
1923
1756
|
}
|
|
1924
1757
|
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
};
|
|
1937
|
-
_proto.insert = function insert(index) {
|
|
1938
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1939
|
-
args[_key2 - 1] = arguments[_key2];
|
|
1940
|
-
}
|
|
1941
|
-
this.update.apply(this, [insertElement].concat(args));
|
|
1942
|
-
};
|
|
1943
|
-
_proto.filter = function filter(predicate) {
|
|
1944
|
-
this.update(function (array) {
|
|
1945
|
-
return array.filter(function (a) {
|
|
1946
|
-
return predicate(a);
|
|
1947
|
-
});
|
|
1948
|
-
});
|
|
1949
|
-
};
|
|
1950
|
-
_proto.move = function move(fromIndex, toIndex) {
|
|
1758
|
+
class ArrayRef extends Ref {
|
|
1759
|
+
append(...args) {
|
|
1760
|
+
this.update(append, ...args);
|
|
1761
|
+
}
|
|
1762
|
+
insert(index, ...args) {
|
|
1763
|
+
this.update(insertElement, ...args);
|
|
1764
|
+
}
|
|
1765
|
+
filter(predicate) {
|
|
1766
|
+
this.update((array) => array.filter((a) => predicate(a)));
|
|
1767
|
+
}
|
|
1768
|
+
move(fromIndex, toIndex) {
|
|
1951
1769
|
this.update(moveElement, fromIndex, toIndex);
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1770
|
+
}
|
|
1771
|
+
clear() {
|
|
1954
1772
|
this.set([]);
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1773
|
+
}
|
|
1774
|
+
sort(compare) {
|
|
1775
|
+
let data = this.get();
|
|
1958
1776
|
if (!data) return;
|
|
1959
|
-
|
|
1777
|
+
let x = [...data];
|
|
1960
1778
|
x.sort(compare);
|
|
1961
1779
|
this.set(x);
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
})(Ref);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1965
1782
|
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
}) || this;
|
|
1973
|
-
Object.defineProperty(_this, "store", {
|
|
1783
|
+
class StoreProxy extends View {
|
|
1784
|
+
constructor(getStore) {
|
|
1785
|
+
super({
|
|
1786
|
+
store: getStore(),
|
|
1787
|
+
});
|
|
1788
|
+
Object.defineProperty(this, "store", {
|
|
1974
1789
|
get: getStore,
|
|
1975
1790
|
});
|
|
1976
|
-
return _this;
|
|
1977
1791
|
}
|
|
1978
|
-
|
|
1979
|
-
var _proto = StoreProxy.prototype;
|
|
1980
|
-
_proto.getData = function getData() {
|
|
1792
|
+
getData() {
|
|
1981
1793
|
return this.store.getData();
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
})(View);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1985
1796
|
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
_this.lengthAlias = Binding.get(_this.lengthAlias);
|
|
1797
|
+
class ArrayElementView extends AugmentedViewBase {
|
|
1798
|
+
constructor(config) {
|
|
1799
|
+
super(config);
|
|
1800
|
+
this.hasNestedAliases =
|
|
1801
|
+
this.recordAlias.indexOf(".") >= 0 || this.indexAlias.indexOf(".") >= 0 || this.lengthAlias.indexOf(".") >= 0;
|
|
1802
|
+
this.recordBinding = Binding.get(this.recordAlias);
|
|
1803
|
+
if (this.hasNestedAliases) {
|
|
1804
|
+
this.indexBinding = Binding.get(this.indexAlias);
|
|
1805
|
+
this.lengthBinding = Binding.get(this.lengthAlias);
|
|
1996
1806
|
}
|
|
1997
|
-
return _this;
|
|
1998
1807
|
}
|
|
1999
|
-
|
|
2000
|
-
var _proto = ArrayElementView.prototype;
|
|
2001
|
-
_proto.getExtraKeyBinding = function getExtraKeyBinding(key) {
|
|
1808
|
+
getExtraKeyBinding(key) {
|
|
2002
1809
|
if (!key.startsWith(this.recordAlias)) return null;
|
|
2003
1810
|
if (key.length == this.recordAlias.length || key[this.recordAlias.length] == ".") return this.recordBinding;
|
|
2004
1811
|
return null;
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
if (key != this.recordAlias) throw new Error(
|
|
2008
|
-
|
|
1812
|
+
}
|
|
1813
|
+
deleteExtraKeyValue(key) {
|
|
1814
|
+
if (key != this.recordAlias) throw new Error(`Field ${key} cannot be deleted.`);
|
|
1815
|
+
const array = this.arrayAccessor.get(this.store.getData());
|
|
2009
1816
|
if (!array) return false;
|
|
2010
|
-
|
|
1817
|
+
const newArray = [...array.slice(0, this.itemIndex), ...array.slice(this.itemIndex + 1)];
|
|
2011
1818
|
return this.arrayAccessor.set(newArray, this.store);
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
if (key != this.recordAlias) throw new Error(
|
|
2015
|
-
|
|
1819
|
+
}
|
|
1820
|
+
setExtraKeyValue(key, value) {
|
|
1821
|
+
if (key != this.recordAlias) throw new Error(`Field ${key} is read-only.`);
|
|
1822
|
+
const array = this.arrayAccessor.get(this.store.getData());
|
|
2016
1823
|
if (!array || value === array[this.itemIndex]) return false;
|
|
2017
|
-
|
|
1824
|
+
const newArray = [...array.slice(0, this.itemIndex), value, ...array.slice(this.itemIndex + 1)];
|
|
2018
1825
|
return this.arrayAccessor.set(newArray, this.store);
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
|
|
1826
|
+
}
|
|
1827
|
+
embedAugmentData(result, parentStoreData) {
|
|
1828
|
+
let array = this.arrayAccessor.get(parentStoreData);
|
|
2022
1829
|
if (!isArray(array)) return;
|
|
2023
1830
|
if (!this.hasNestedAliases) {
|
|
2024
1831
|
result[this.recordAlias] = array[this.itemIndex];
|
|
2025
1832
|
result[this.indexAlias] = this.itemIndex;
|
|
2026
1833
|
result[this.lengthAlias] = array.length;
|
|
2027
1834
|
} else {
|
|
2028
|
-
|
|
1835
|
+
let copy = result;
|
|
2029
1836
|
copy = this.recordBinding.set(copy, array[this.itemIndex]);
|
|
2030
1837
|
copy = this.indexBinding.set(copy, this.itemIndex);
|
|
2031
|
-
copy = this.
|
|
1838
|
+
copy = this.lengthBinding.set(copy, array.length);
|
|
2032
1839
|
result[this.recordBinding.parts[0]] = copy[this.recordBinding.parts[0]];
|
|
2033
1840
|
result[this.indexBinding.parts[0]] = copy[this.indexBinding.parts[0]];
|
|
2034
|
-
result[this.
|
|
1841
|
+
result[this.lengthBinding.parts[0]] = copy[this.lengthBinding.parts[0]];
|
|
2035
1842
|
}
|
|
2036
|
-
}
|
|
2037
|
-
|
|
1843
|
+
}
|
|
1844
|
+
setIndex(itemIndex) {
|
|
2038
1845
|
this.itemIndex = itemIndex;
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
})(AugmentedViewBase);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
2042
1848
|
ArrayElementView.prototype.recordAlias = "$record";
|
|
2043
1849
|
ArrayElementView.prototype.indexAlias = "$index";
|
|
2044
1850
|
ArrayElementView.prototype.lengthAlias = "$length";
|
|
2045
1851
|
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
Refs offer simplicity, bindings have better performance with more arguments.
|
|
2049
|
-
Accessor works as a common interface which works with both patterns.
|
|
2050
|
-
*/
|
|
2051
|
-
|
|
2052
|
-
function getAccessor(accessor, options) {
|
|
2053
|
-
if (accessor == null) return null;
|
|
1852
|
+
function getAccessor(accessor) {
|
|
1853
|
+
if (accessor == null) return undefined;
|
|
2054
1854
|
if (isObject(accessor)) {
|
|
2055
|
-
if (
|
|
1855
|
+
if ("isAccessor" in accessor || "isRef" in accessor) return accessor;
|
|
2056
1856
|
if (isBinding(accessor)) {
|
|
2057
|
-
|
|
1857
|
+
let binding = Binding.get(accessor);
|
|
2058
1858
|
return {
|
|
2059
1859
|
get: binding.value,
|
|
2060
|
-
set:
|
|
2061
|
-
return store.set(binding.path, v);
|
|
2062
|
-
},
|
|
1860
|
+
set: (v, store) => store.set(binding.path, v),
|
|
2063
1861
|
isAccessor: true,
|
|
2064
1862
|
};
|
|
2065
1863
|
}
|
|
2066
1864
|
}
|
|
2067
1865
|
if (isAccessorChain(accessor)) {
|
|
2068
|
-
|
|
1866
|
+
let binding = Binding.get(accessor);
|
|
2069
1867
|
return {
|
|
2070
|
-
get:
|
|
2071
|
-
set:
|
|
2072
|
-
return store.set(_binding.path, v);
|
|
2073
|
-
},
|
|
1868
|
+
get: binding.value,
|
|
1869
|
+
set: (v, store) => store.set(binding.path, v),
|
|
2074
1870
|
isAccessor: true,
|
|
2075
1871
|
};
|
|
2076
1872
|
}
|
|
2077
1873
|
if (isSelector(accessor)) {
|
|
2078
|
-
|
|
1874
|
+
let selector = getSelector(accessor);
|
|
2079
1875
|
if (accessor && accessor.set)
|
|
2080
1876
|
return {
|
|
2081
1877
|
get: selector,
|
|
2082
1878
|
isAccessor: true,
|
|
2083
|
-
bindInstance
|
|
1879
|
+
bindInstance(instance) {
|
|
2084
1880
|
return {
|
|
2085
1881
|
get: selector,
|
|
2086
|
-
set:
|
|
2087
|
-
return accessor.set(value, instance);
|
|
2088
|
-
},
|
|
1882
|
+
set: (value) => accessor.set(value, instance),
|
|
2089
1883
|
isAccessor: true,
|
|
2090
1884
|
};
|
|
2091
1885
|
},
|
|
@@ -2096,9 +1890,7 @@ function getAccessor(accessor, options) {
|
|
|
2096
1890
|
};
|
|
2097
1891
|
}
|
|
2098
1892
|
return {
|
|
2099
|
-
get:
|
|
2100
|
-
return accessor;
|
|
2101
|
-
},
|
|
1893
|
+
get: () => accessor,
|
|
2102
1894
|
};
|
|
2103
1895
|
}
|
|
2104
1896
|
|
|
@@ -2122,6 +1914,7 @@ export {
|
|
|
2122
1914
|
View,
|
|
2123
1915
|
ZoomIntoPropertyView,
|
|
2124
1916
|
append,
|
|
1917
|
+
bindingCache,
|
|
2125
1918
|
computable,
|
|
2126
1919
|
createAccessorModelProxy,
|
|
2127
1920
|
defaultCompare,
|
|
@@ -2140,6 +1933,7 @@ export {
|
|
|
2140
1933
|
invalidateStringTemplateCache,
|
|
2141
1934
|
isAccessorChain,
|
|
2142
1935
|
isBinding,
|
|
1936
|
+
isBindingObject,
|
|
2143
1937
|
isSelector,
|
|
2144
1938
|
merge,
|
|
2145
1939
|
moveElement,
|