cx 26.0.12 → 26.0.13
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/build/charts/ScatterGraph.d.ts +4 -4
- package/build/charts/ScatterGraph.js +2 -2
- package/build/data/ArrayElementView.spec.d.ts +1 -0
- package/build/data/ArrayElementView.spec.js +81 -0
- package/build/data/Binding.spec.d.ts +1 -0
- package/build/data/Binding.spec.js +61 -0
- package/build/data/Expression.spec.d.ts +1 -0
- package/build/data/Expression.spec.js +196 -0
- package/build/data/Grouper.spec.d.ts +1 -0
- package/build/data/Grouper.spec.js +48 -0
- package/build/data/Ref.spec.d.ts +1 -0
- package/build/data/Ref.spec.js +72 -0
- package/build/data/Selector.d.ts +1 -1
- package/build/data/Store.spec.d.ts +1 -0
- package/build/data/Store.spec.js +19 -0
- package/build/data/StoreRef.spec.d.ts +1 -0
- package/build/data/StoreRef.spec.js +22 -0
- package/build/data/StringTemplate.spec.d.ts +1 -0
- package/build/data/StringTemplate.spec.js +112 -0
- package/build/data/StructuredSelector.spec.d.ts +1 -0
- package/build/data/StructuredSelector.spec.js +102 -0
- package/build/data/View.spec.d.ts +1 -0
- package/build/data/View.spec.js +44 -0
- package/build/data/ZoomIntoPropertyView.spec.d.ts +1 -0
- package/build/data/ZoomIntoPropertyView.spec.js +54 -0
- package/build/data/comparer.spec.d.ts +1 -0
- package/build/data/comparer.spec.js +50 -0
- package/build/data/computable.d.ts +3 -6
- package/build/data/computable.spec.d.ts +1 -0
- package/build/data/computable.spec.js +56 -0
- package/build/data/createAccessorModelProxy.d.ts +5 -3
- package/build/data/createAccessorModelProxy.spec.d.ts +1 -0
- package/build/data/createAccessorModelProxy.spec.js +30 -0
- package/build/data/createStructuredSelector.spec.d.ts +1 -0
- package/build/data/createStructuredSelector.spec.js +42 -0
- package/build/data/diff/diffs.spec.d.ts +1 -0
- package/build/data/diff/diffs.spec.js +45 -0
- package/build/data/getAccessor.spec.d.ts +1 -0
- package/build/data/getAccessor.spec.js +10 -0
- package/build/data/getSelector.spec.d.ts +1 -0
- package/build/data/getSelector.spec.js +36 -0
- package/build/data/ops/append.spec.d.ts +1 -0
- package/build/data/ops/append.spec.js +24 -0
- package/build/data/ops/filter.spec.d.ts +1 -0
- package/build/data/ops/filter.spec.js +25 -0
- package/build/data/ops/findTreeNode.d.ts +1 -1
- package/build/data/ops/findTreeNode.js +1 -1
- package/build/data/ops/findTreeNode.spec.d.ts +1 -0
- package/build/data/ops/findTreeNode.spec.js +20 -0
- package/build/data/ops/findTreePath.d.ts +1 -1
- package/build/data/ops/merge.spec.d.ts +1 -0
- package/build/data/ops/merge.spec.js +23 -0
- package/build/data/ops/removeTreeNodes.d.ts +1 -1
- package/build/data/ops/removeTreeNodes.js +1 -1
- package/build/data/ops/removeTreeNodes.spec.d.ts +1 -0
- package/build/data/ops/removeTreeNodes.spec.js +35 -0
- package/build/data/ops/updateArray.spec.d.ts +1 -0
- package/build/data/ops/updateArray.spec.js +33 -0
- package/build/data/ops/updateTree.d.ts +1 -1
- package/build/data/ops/updateTree.spec.d.ts +1 -0
- package/build/data/ops/updateTree.spec.js +44 -0
- package/build/hooks/invokeCallback.spec.d.ts +1 -0
- package/build/hooks/invokeCallback.spec.js +44 -0
- package/build/hooks/resolveCallback.spec.d.ts +1 -0
- package/build/hooks/resolveCallback.spec.js +35 -0
- package/build/hooks/store.spec.d.ts +1 -0
- package/build/hooks/store.spec.js +48 -0
- package/build/hooks/useTrigger.spec.d.ts +1 -0
- package/build/hooks/useTrigger.spec.js +59 -0
- package/build/jsx-runtime.d.ts +10 -10
- package/build/jsx-runtime.js +6 -0
- package/build/svg/util/Rect.d.ts +1 -1
- package/build/ui/ContentResolver.d.ts +16 -6
- package/build/ui/Controller.d.ts +7 -0
- package/build/ui/Controller.js +2 -1
- package/build/ui/Controller.spec.d.ts +1 -0
- package/build/ui/Controller.spec.js +247 -0
- package/build/ui/Cx.spec.d.ts +1 -0
- package/build/ui/Cx.spec.js +153 -0
- package/build/ui/DataProxy.spec.d.ts +1 -0
- package/build/ui/DataProxy.spec.js +208 -0
- package/build/ui/Instance.d.ts +1 -1
- package/build/ui/Instance.js +10 -10
- package/build/ui/IsolatedScope.spec.d.ts +1 -0
- package/build/ui/IsolatedScope.spec.js +42 -0
- package/build/ui/Prop.d.ts +12 -1
- package/build/ui/PureContainer.spec.d.ts +1 -0
- package/build/ui/PureContainer.spec.js +149 -0
- package/build/ui/Repeater.d.ts +3 -3
- package/build/ui/Repeater.spec.d.ts +1 -0
- package/build/ui/Repeater.spec.js +109 -0
- package/build/ui/Rescope.spec.d.ts +1 -0
- package/build/ui/Rescope.spec.js +134 -0
- package/build/ui/Restate.spec.d.ts +1 -0
- package/build/ui/Restate.spec.js +257 -0
- package/build/ui/Text.d.ts +14 -2
- package/build/ui/Text.js +3 -0
- package/build/ui/adapter/ArrayAdapter.js +4 -1
- package/build/ui/adapter/ArrayAdapter.spec.d.ts +1 -0
- package/build/ui/adapter/ArrayAdapter.spec.js +44 -0
- package/build/ui/adapter/TreeAdapter.spec.d.ts +1 -0
- package/build/ui/adapter/TreeAdapter.spec.js +71 -0
- package/build/ui/app/Url.spec.d.ts +1 -0
- package/build/ui/app/Url.spec.js +43 -0
- package/build/ui/app/startHotAppLoop.js +1 -1
- package/build/ui/createFunctionalComponent.d.ts +14 -1
- package/build/ui/createFunctionalComponent.js +7 -4
- package/build/ui/createFunctionalComponent.spec.d.ts +1 -0
- package/build/ui/createFunctionalComponent.spec.js +272 -0
- package/build/ui/expr.d.ts +3 -1
- package/build/ui/exprHelpers.d.ts +32 -0
- package/build/ui/exprHelpers.js +61 -0
- package/build/ui/index.d.ts +1 -0
- package/build/ui/index.js +1 -0
- package/build/ui/layout/ContentPlaceholder.spec.d.ts +1 -0
- package/build/ui/layout/ContentPlaceholder.spec.js +333 -0
- package/build/ui/layout/FirstVisibleChildLayout.spec.d.ts +1 -0
- package/build/ui/layout/FirstVisibleChildLayout.spec.js +101 -0
- package/build/util/Console.d.ts +1 -0
- package/build/util/Console.js +7 -3
- package/build/util/Format.spec.d.ts +1 -0
- package/build/util/Format.spec.js +58 -0
- package/build/util/TraversalStack.spec.d.ts +1 -0
- package/build/util/TraversalStack.spec.js +43 -0
- package/build/util/date/upperBoundCheck.spec.d.ts +1 -0
- package/build/util/date/upperBoundCheck.spec.js +22 -0
- package/build/util/getSearchQueryPredicate.spec.d.ts +1 -0
- package/build/util/getSearchQueryPredicate.spec.js +33 -0
- package/build/util/isValidIdentifierName.spec.d.ts +1 -0
- package/build/util/isValidIdentifierName.spec.js +28 -0
- package/build/util/routeAppend.spec.d.ts +1 -0
- package/build/util/routeAppend.spec.js +14 -0
- package/build/widgets/AccessorBindings.spec.d.ts +1 -0
- package/build/widgets/AccessorBindings.spec.js +40 -0
- package/build/widgets/Button.d.ts +3 -6
- package/build/widgets/Button.js +1 -1
- package/build/widgets/DocumentTitle.d.ts +2 -0
- package/build/widgets/Heading.d.ts +2 -2
- package/build/widgets/HtmlElement.d.ts +31 -8
- package/build/widgets/HtmlElement.js +7 -9
- package/build/widgets/HtmlElement.spec.d.ts +1 -0
- package/build/widgets/HtmlElement.spec.js +38 -0
- package/build/widgets/Icon.d.ts +3 -13
- package/build/widgets/List.d.ts +4 -0
- package/build/widgets/ReactElementWrapper.d.ts +29 -0
- package/build/widgets/ReactElementWrapper.js +59 -0
- package/build/widgets/drag-drop/DragSource.d.ts +3 -3
- package/build/widgets/drag-drop/DragSource.js +2 -3
- package/build/widgets/drag-drop/DropZone.d.ts +3 -3
- package/build/widgets/drag-drop/DropZone.js +2 -3
- package/build/widgets/form/Checkbox.d.ts +2 -0
- package/build/widgets/form/ColorField.d.ts +2 -0
- package/build/widgets/form/DateTimeField.d.ts +2 -0
- package/build/widgets/form/Field.d.ts +0 -2
- package/build/widgets/form/LabeledContainer.d.ts +9 -8
- package/build/widgets/form/LabeledContainer.js +9 -9
- package/build/widgets/form/LookupField.d.ts +57 -9
- package/build/widgets/form/MonthField.d.ts +2 -0
- package/build/widgets/form/NumberField.d.ts +2 -0
- package/build/widgets/form/Radio.d.ts +2 -0
- package/build/widgets/form/Select.d.ts +2 -0
- package/build/widgets/form/Slider.d.ts +3 -0
- package/build/widgets/form/Switch.d.ts +2 -0
- package/build/widgets/form/TextField.d.ts +34 -0
- package/build/widgets/form/TimeList.d.ts +16 -1
- package/build/widgets/form/TimeList.js +34 -62
- package/build/widgets/form/UploadButton.d.ts +34 -2
- package/build/widgets/form/UploadButton.js +3 -1
- package/build/widgets/form/ValidationGroup.spec.d.ts +1 -0
- package/build/widgets/form/ValidationGroup.spec.js +62 -0
- package/build/widgets/form/Validator.d.ts +33 -2
- package/build/widgets/form/Validator.js +3 -0
- package/build/widgets/grid/Grid.d.ts +9 -9
- package/build/widgets/grid/TreeNode.d.ts +6 -0
- package/build/widgets/index.d.ts +1 -0
- package/build/widgets/index.js +1 -0
- package/build/widgets/nav/MenuItem.d.ts +3 -2
- package/build/widgets/nav/Route.spec.d.ts +1 -0
- package/build/widgets/nav/Route.spec.js +15 -0
- package/build/widgets/nav/Scroller.d.ts +4 -6
- package/build/widgets/nav/Scroller.js +6 -3
- package/build/widgets/nav/Tab.d.ts +2 -2
- package/build/widgets/overlay/ContextMenu.d.ts +3 -3
- package/build/widgets/overlay/Overlay.d.ts +2 -1
- package/build/widgets/overlay/Overlay.js +1 -1
- package/build.js +133 -133
- package/dist/data.js +2 -2
- package/dist/jsx-runtime.js +6 -1
- package/dist/manifest.d.ts +1443 -0
- package/dist/manifest.js +855 -807
- package/dist/ui.js +91 -5
- package/dist/util.js +3 -0
- package/dist/widgets.js +520 -161
- package/package.json +46 -20
- package/src/charts/Chart.ts +108 -108
- package/src/charts/ScatterGraph.tsx +6 -6
- package/src/data/ArrayElementView.ts +90 -90
- package/src/data/AugmentedViewBase.ts +88 -88
- package/src/data/Binding.ts +104 -104
- package/src/data/ExposedRecordView.ts +95 -95
- package/src/data/ExposedValueView.ts +89 -89
- package/src/data/Expression.spec.ts +229 -229
- package/src/data/Expression.ts +233 -233
- package/src/data/Grouper.spec.ts +57 -57
- package/src/data/Grouper.ts +158 -158
- package/src/data/NestedDataView.ts +43 -43
- package/src/data/ReadOnlyDataView.ts +39 -39
- package/src/data/Ref.ts +104 -104
- package/src/data/Selector.ts +10 -10
- package/src/data/Store.ts +52 -52
- package/src/data/StoreProxy.ts +19 -19
- package/src/data/StoreRef.ts +66 -66
- package/src/data/StringTemplate.spec.ts +132 -132
- package/src/data/StringTemplate.ts +93 -93
- package/src/data/StructuredSelector.spec.ts +113 -113
- package/src/data/StructuredSelector.ts +146 -146
- package/src/data/SubscribableView.ts +63 -63
- package/src/data/ZoomIntoPropertyView.spec.ts +64 -64
- package/src/data/ZoomIntoPropertyView.ts +45 -45
- package/src/data/computable.spec.ts +87 -62
- package/src/data/computable.ts +3 -6
- package/src/data/createAccessorModelProxy.spec.tsx +102 -1
- package/src/data/createAccessorModelProxy.ts +9 -3
- package/src/data/createStructuredSelector.ts +62 -62
- package/src/data/getAccessor.spec.ts +11 -11
- package/src/data/getAccessor.ts +74 -74
- package/src/data/getSelector.spec.ts +43 -43
- package/src/data/getSelector.ts +66 -66
- package/src/data/ops/filter.spec.ts +35 -35
- package/src/data/ops/filter.ts +9 -9
- package/src/data/ops/findTreeNode.ts +1 -5
- package/src/data/ops/findTreePath.ts +1 -1
- package/src/data/ops/merge.ts +13 -13
- package/src/data/ops/removeTreeNodes.spec.ts +37 -37
- package/src/data/ops/removeTreeNodes.ts +2 -2
- package/src/data/ops/updateArray.spec.ts +69 -69
- package/src/data/ops/updateArray.ts +31 -31
- package/src/data/ops/updateTree.ts +1 -1
- package/src/data/test-types.ts +7 -7
- package/src/hooks/resolveCallback.spec.tsx +30 -7
- package/src/hooks/useTrigger.ts +26 -26
- package/src/index.scss +6 -6
- package/src/jsx-dev-runtime.ts +4 -4
- package/src/jsx-runtime.spec.tsx +402 -0
- package/src/jsx-runtime.ts +26 -22
- package/src/svg/BoundedObject.ts +101 -101
- package/src/svg/util/Rect.ts +105 -105
- package/src/ui/CSSHelper.ts +17 -17
- package/src/ui/ContentResolver.spec.tsx +172 -19
- package/src/ui/ContentResolver.ts +16 -8
- package/src/ui/Controller.ts +15 -2
- package/src/ui/Culture.ts +159 -159
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/FocusManager.ts +171 -171
- package/src/ui/Instance.ts +866 -868
- package/src/ui/Prop.ts +140 -112
- package/src/ui/RenderingContext.ts +99 -99
- package/src/ui/Repeater.ts +3 -12
- package/src/ui/Rescope.ts +49 -49
- package/src/ui/StructuredInstanceDataAccessor.ts +32 -32
- package/src/ui/Text.ts +21 -2
- package/src/ui/VDOM.ts +34 -34
- package/src/ui/adapter/ArrayAdapter.spec.ts +55 -55
- package/src/ui/adapter/ArrayAdapter.ts +4 -1
- package/src/ui/adapter/TreeAdapter.spec.ts +76 -76
- package/src/ui/adapter/TreeAdapter.ts +185 -185
- package/src/ui/app/History.ts +133 -133
- package/src/ui/app/Url.spec.ts +50 -50
- package/src/ui/app/startHotAppLoop.ts +41 -41
- package/src/ui/createFunctionalComponent.spec.tsx +53 -0
- package/src/ui/createFunctionalComponent.ts +86 -65
- package/src/ui/expr.ts +4 -1
- package/src/ui/exprHelpers.spec.ts +379 -0
- package/src/ui/exprHelpers.ts +78 -0
- package/src/ui/index.ts +47 -46
- package/src/ui/layout/Content.ts +30 -30
- package/src/ui/layout/FirstVisibleChildLayout.spec.tsx +1 -1
- package/src/ui/layout/FirstVisibleChildLayout.ts +60 -60
- package/src/ui/selection/KeySelection.ts +153 -153
- package/src/ui/selection/Selection.ts +128 -128
- package/src/util/Console.ts +13 -11
- package/src/util/Format.ts +267 -267
- package/src/util/addEventListenerWithOptions.ts +41 -41
- package/src/util/browserSupportsPassiveEventHandlers.ts +20 -20
- package/src/util/color/rgbToHsl.ts +35 -35
- package/src/util/getActiveElement.ts +4 -4
- package/src/util/hasKey.ts +18 -18
- package/src/util/index.ts +55 -55
- package/src/util/innerTextTrim.ts +10 -10
- package/src/util/isArray.ts +3 -3
- package/src/util/isDataRecord.ts +5 -5
- package/src/util/isDefined.ts +3 -3
- package/src/util/isString.ts +3 -3
- package/src/widgets/AccessorBindings.spec.tsx +26 -0
- package/src/widgets/Button.tsx +5 -17
- package/src/widgets/DocumentTitle.ts +95 -92
- package/src/widgets/Heading.ts +2 -2
- package/src/widgets/HtmlElement.spec.helpers.tsx +108 -0
- package/src/widgets/HtmlElement.spec.tsx +20 -12
- package/src/widgets/HtmlElement.tsx +77 -23
- package/src/widgets/Icon.ts +3 -17
- package/src/widgets/List.tsx +6 -0
- package/src/widgets/ReactElementWrapper.spec.tsx +452 -0
- package/src/widgets/ReactElementWrapper.tsx +108 -0
- package/src/widgets/Sandbox.ts +103 -103
- package/src/widgets/autoFocus.ts +9 -9
- package/src/widgets/cx.ts +63 -63
- package/src/widgets/drag-drop/DragSource.tsx +3 -4
- package/src/widgets/drag-drop/DropZone.tsx +3 -4
- package/src/widgets/form/Checkbox.tsx +3 -0
- package/src/widgets/form/ColorField.tsx +3 -0
- package/src/widgets/form/DateTimeField.tsx +5 -0
- package/src/widgets/form/Field.tsx +0 -3
- package/src/widgets/form/Label.tsx +1 -0
- package/src/widgets/form/LabeledContainer.ts +22 -26
- package/src/widgets/form/LookupField.spec.tsx +93 -0
- package/src/widgets/form/LookupField.tsx +104 -9
- package/src/widgets/form/MonthField.tsx +5 -0
- package/src/widgets/form/NumberField.tsx +3 -0
- package/src/widgets/form/Radio.tsx +5 -0
- package/src/widgets/form/Select.tsx +5 -0
- package/src/widgets/form/Slider.tsx +4 -0
- package/src/widgets/form/Switch.tsx +3 -0
- package/src/widgets/form/TextField.tsx +62 -0
- package/src/widgets/form/TimeList.tsx +84 -73
- package/src/widgets/form/UploadButton.tsx +53 -2
- package/src/widgets/form/Validator.ts +40 -3
- package/src/widgets/grid/Grid.tsx +9 -12
- package/src/widgets/grid/GridCell.ts +143 -143
- package/src/widgets/grid/TreeNode.tsx +9 -0
- package/src/widgets/icons/calendar.tsx +17 -17
- package/src/widgets/icons/check.tsx +13 -13
- package/src/widgets/icons/clear.tsx +15 -15
- package/src/widgets/icons/close.tsx +20 -20
- package/src/widgets/icons/cx.tsx +38 -38
- package/src/widgets/icons/drop-down.tsx +15 -15
- package/src/widgets/icons/file.tsx +13 -13
- package/src/widgets/icons/folder-open.tsx +15 -15
- package/src/widgets/icons/folder.tsx +13 -13
- package/src/widgets/icons/forward.tsx +22 -22
- package/src/widgets/icons/loading.tsx +24 -24
- package/src/widgets/icons/menu.tsx +17 -17
- package/src/widgets/icons/pixel-picker.tsx +18 -18
- package/src/widgets/icons/search.tsx +13 -13
- package/src/widgets/icons/sort-asc.tsx +14 -14
- package/src/widgets/icons/square.tsx +18 -18
- package/src/widgets/index.ts +1 -0
- package/src/widgets/nav/MenuItem.tsx +3 -2
- package/src/widgets/nav/Route.ts +142 -142
- package/src/widgets/nav/Scroller.tsx +8 -9
- package/src/widgets/nav/Tab.ts +2 -2
- package/src/widgets/overlay/ContextMenu.ts +42 -42
- package/src/widgets/overlay/Dropdown.tsx +762 -762
- package/src/widgets/overlay/MsgBox.tsx +141 -141
- package/src/widgets/overlay/Overlay.tsx +5 -4
- package/src/widgets/overlay/Toast.ts +111 -111
- package/src/widgets/overlay/Window.tsx +299 -299
- package/src/widgets/overlay/alerts.ts +46 -46
- package/src/widgets/overlay/captureMouse.ts +195 -195
- package/src/widgets/overlay/createHotPromiseWindowFactory.ts +72 -72
- package/src/widgets/overlay/index.d.ts +11 -11
- package/src/widgets/overlay/index.ts +11 -11
- package/src/widgets/overlay/tooltip-ops.ts +173 -173
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isValidIdentifierName } from "./isValidIdentifierName";
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
describe("isValidIdentifierName", function () {
|
|
4
|
+
it("names starting with a number are not valid", function () {
|
|
5
|
+
assert(!isValidIdentifierName("1a"));
|
|
6
|
+
assert(!isValidIdentifierName("00"));
|
|
7
|
+
assert(!isValidIdentifierName("0_abc"));
|
|
8
|
+
});
|
|
9
|
+
it("names starting with a dollar sign are valid", function () {
|
|
10
|
+
assert(isValidIdentifierName("$a"));
|
|
11
|
+
assert(isValidIdentifierName("$"));
|
|
12
|
+
});
|
|
13
|
+
it("names starting with an underscore are valid", function () {
|
|
14
|
+
assert(isValidIdentifierName("_a"));
|
|
15
|
+
assert(isValidIdentifierName("_"));
|
|
16
|
+
});
|
|
17
|
+
it("names starting with a letter are valid", function () {
|
|
18
|
+
assert(isValidIdentifierName("a"));
|
|
19
|
+
assert(isValidIdentifierName("abc"));
|
|
20
|
+
assert(isValidIdentifierName("abc0123"));
|
|
21
|
+
});
|
|
22
|
+
it("names with invalid characters are not valid", function () {
|
|
23
|
+
assert(!isValidIdentifierName("a b"));
|
|
24
|
+
assert(!isValidIdentifierName("a-b"));
|
|
25
|
+
assert(!isValidIdentifierName("a.b"));
|
|
26
|
+
assert(!isValidIdentifierName("a!b"));
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { routeAppend } from './routeAppend';
|
|
2
|
+
import assert from 'assert';
|
|
3
|
+
describe('routeAppend', function () {
|
|
4
|
+
it('adds / if necessary', function () {
|
|
5
|
+
assert(routeAppend('x', 'y'), 'x/y');
|
|
6
|
+
});
|
|
7
|
+
it('does not add extra / if not necessary', function () {
|
|
8
|
+
assert(routeAppend('x/', 'y'), 'x/y');
|
|
9
|
+
assert(routeAppend('x', '/y'), 'x/y');
|
|
10
|
+
});
|
|
11
|
+
it('removes extra slash if both parts contain it', function () {
|
|
12
|
+
assert(routeAppend('x/', '/y'), 'x/y');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "cx/jsx-runtime";
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
import { createAccessorModelProxy } from "../data/createAccessorModelProxy";
|
|
4
|
+
import { Store } from "../data/Store";
|
|
5
|
+
import { expr } from "../ui";
|
|
6
|
+
import { createTestRenderer } from "../util/test/createTestRenderer";
|
|
7
|
+
let { $page } = createAccessorModelProxy();
|
|
8
|
+
describe("Accessors", () => {
|
|
9
|
+
it("work as regular bindings", () => {
|
|
10
|
+
let widget = (_jsx("cx", { children: _jsx("div", { text: $page.text }) }));
|
|
11
|
+
let store = new Store({
|
|
12
|
+
data: {
|
|
13
|
+
$page: {
|
|
14
|
+
text: "Test",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const component = createTestRenderer(store, widget);
|
|
19
|
+
let tree = component.toJSON();
|
|
20
|
+
assert(tree && !Array.isArray(tree));
|
|
21
|
+
assert(tree.type === "div");
|
|
22
|
+
assert.deepStrictEqual(tree.children, ["Test"]);
|
|
23
|
+
});
|
|
24
|
+
it("support expressions", () => {
|
|
25
|
+
let widget = (_jsx("cx", { children: _jsx("div", { text: expr($page.a, $page.b, (a, b) => a + b) }) }));
|
|
26
|
+
let store = new Store({
|
|
27
|
+
data: {
|
|
28
|
+
$page: {
|
|
29
|
+
a: 1,
|
|
30
|
+
b: 3,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const component = createTestRenderer(store, widget);
|
|
35
|
+
let tree = component.toJSON();
|
|
36
|
+
assert(tree && !Array.isArray(tree));
|
|
37
|
+
assert(tree.type === "div");
|
|
38
|
+
assert.deepStrictEqual(tree.children, ["4"]);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -3,15 +3,13 @@ import type { RenderingContext } from "../ui/RenderingContext";
|
|
|
3
3
|
import type { Instance, RenderProps } from "../ui/Instance";
|
|
4
4
|
import { BooleanProp, StringProp, Prop } from "../ui/Prop";
|
|
5
5
|
import type { FormRenderingContext } from "./form/ValidationGroup";
|
|
6
|
-
export interface ButtonConfig extends HtmlElementConfig {
|
|
6
|
+
export interface ButtonConfig extends Omit<HtmlElementConfig<"button">, "disabled" | "type" | "form"> {
|
|
7
7
|
/** Confirmation text or configuration object. See MsgBox.yesNo for more details. */
|
|
8
|
-
confirm?: Prop<string | Record<string, unknown
|
|
8
|
+
confirm?: Prop<string | Record<string, unknown> | false>;
|
|
9
9
|
/** If true button appears in pressed state. Useful for implementing toggle buttons. */
|
|
10
10
|
pressed?: BooleanProp;
|
|
11
11
|
/** Name of the icon to be put on the left side of the button. */
|
|
12
12
|
icon?: StringProp;
|
|
13
|
-
/** HTML tag to be used. Default is `button`. */
|
|
14
|
-
tag?: string;
|
|
15
13
|
/** Base CSS class to be applied to the element. Default is 'button'. */
|
|
16
14
|
baseClass?: string;
|
|
17
15
|
/**
|
|
@@ -31,8 +29,7 @@ export interface ButtonConfig extends HtmlElementConfig {
|
|
|
31
29
|
* @param e - Event.
|
|
32
30
|
* @param instance - Cx widget instance that fired the event.
|
|
33
31
|
*/
|
|
34
|
-
onClick?: string | ((e: MouseEvent, instance: Instance) => void);
|
|
35
|
-
onMouseDown?: string | ((e: MouseEvent, instance: Instance) => void);
|
|
32
|
+
onClick?: string | ((e: React.MouseEvent, instance: Instance) => void);
|
|
36
33
|
/** Button type. */
|
|
37
34
|
type?: "submit" | "button";
|
|
38
35
|
/** If set to `true`, the Button will cause its parent Overlay (if one exists) to close. This, however, can be prevented if `onClick` explicitly returns `false`. */
|
package/build/widgets/Button.js
CHANGED
|
@@ -44,7 +44,7 @@ export class Button extends HtmlElement {
|
|
|
44
44
|
super.attachProps(context, instance, props);
|
|
45
45
|
if (!this.focusOnMouseDown) {
|
|
46
46
|
props.onMouseDown = (e) => {
|
|
47
|
-
if (this.onMouseDown && instance.invoke("onMouseDown", e
|
|
47
|
+
if (this.onMouseDown && instance.invoke("onMouseDown", e, instance) === false)
|
|
48
48
|
return;
|
|
49
49
|
preventFocus(e);
|
|
50
50
|
};
|
|
@@ -5,6 +5,8 @@ import { StringProp } from "../ui/Prop";
|
|
|
5
5
|
export interface DocumentTitleConfig extends WidgetConfig {
|
|
6
6
|
/** Text value to be used for the document title. */
|
|
7
7
|
value?: StringProp;
|
|
8
|
+
/** Text value to be used for the document title. */
|
|
9
|
+
text?: StringProp;
|
|
8
10
|
/** Deprecated. Use `action: "append"` instead. */
|
|
9
11
|
append?: boolean;
|
|
10
12
|
/** How to combine the title with existing document title. Default is `append`. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HtmlElement,
|
|
1
|
+
import { HtmlElement, HtmlElementConfigBase, HtmlElementInstance } from "./HtmlElement";
|
|
2
2
|
import { RenderingContext } from "../ui/RenderingContext";
|
|
3
|
-
export interface HeadingConfig extends
|
|
3
|
+
export interface HeadingConfig extends HtmlElementConfigBase {
|
|
4
4
|
/** Name of the HTML element to be rendered. Default is `div`. */
|
|
5
5
|
tag?: string;
|
|
6
6
|
/** Heading level. Allowed values go from 1 to 6. Default is 3. */
|
|
@@ -1,29 +1,51 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type { TooltipInstance } from "./overlay/Tooltip";
|
|
5
|
-
import type { RenderingContext } from "../ui/RenderingContext";
|
|
2
|
+
import type { JSX as ReactJSX } from "react";
|
|
3
|
+
import { ChildNode, StyledContainerBase, StyledContainerConfig } from "../ui/Container";
|
|
6
4
|
import type { RenderProps } from "../ui/Instance";
|
|
7
5
|
import { Instance } from "../ui/Instance";
|
|
6
|
+
import { BooleanProp, ClassProp, NumberProp, Prop, StringProp, StructuredProp } from "../ui/Prop";
|
|
7
|
+
import type { RenderingContext } from "../ui/RenderingContext";
|
|
8
|
+
import type { TooltipInstance } from "./overlay/Tooltip";
|
|
8
9
|
import type { TooltipConfig, TooltipProp } from "./overlay/tooltip-ops";
|
|
9
|
-
import {
|
|
10
|
+
import { TooltipParentInstance } from "./overlay/tooltip-ops";
|
|
10
11
|
export declare let urlAttributes: Record<string, boolean>;
|
|
11
|
-
|
|
12
|
+
type ReactIntrinsicElements = ReactJSX.IntrinsicElements;
|
|
13
|
+
type IsEventHandler<K, T> = K extends `on${string}` ? (NonNullable<T> extends Function ? true : false) : false;
|
|
14
|
+
type CxEventHandler<T> = T extends (event: infer E) => any ? string | ((event: E, instance: Instance) => void) : T extends undefined ? undefined : string | T;
|
|
15
|
+
type TransformHtmlElementProps<T> = {
|
|
16
|
+
[K in keyof T]: K extends "children" ? ChildNode | ChildNode[] : K extends "className" | "class" ? ClassProp : IsEventHandler<K, T[K]> extends true ? CxEventHandler<T[K]> : string extends T[K] ? Prop<T[K]> : NonNullable<T[K]> extends string ? Prop<T[K]> | string : Prop<T[K]>;
|
|
17
|
+
};
|
|
18
|
+
/** Base HtmlElement configuration - core CxJS properties for extension by widgets */
|
|
19
|
+
export interface HtmlElementConfigBase extends StyledContainerConfig {
|
|
12
20
|
id?: StringProp | NumberProp;
|
|
21
|
+
/** HTML tag name */
|
|
22
|
+
tag?: string;
|
|
13
23
|
/** Inner text contents. */
|
|
14
24
|
text?: StringProp | NumberProp;
|
|
15
25
|
/** Inner html contents. */
|
|
26
|
+
innerHtml?: StringProp;
|
|
27
|
+
/** Inner html contents. */
|
|
16
28
|
html?: StringProp;
|
|
17
29
|
/** Tooltip configuration. */
|
|
18
30
|
tooltip?: StringProp | TooltipConfig;
|
|
31
|
+
/** Additional attributes to be applied. */
|
|
32
|
+
attrs?: StructuredProp;
|
|
33
|
+
/** Additional data attributes. */
|
|
34
|
+
data?: StructuredProp;
|
|
35
|
+
autoFocus?: BooleanProp;
|
|
36
|
+
onRef?: string | ((element: HTMLElement | null, instance: Instance) => void);
|
|
19
37
|
}
|
|
38
|
+
/** HtmlElement configuration with tag-specific attributes and events */
|
|
39
|
+
export type HtmlElementConfig<Tag extends keyof ReactIntrinsicElements = "div"> = Omit<HtmlElementConfigBase, "tag"> & TransformHtmlElementProps<ReactIntrinsicElements[Tag]> & {
|
|
40
|
+
tag?: Tag;
|
|
41
|
+
};
|
|
20
42
|
export declare class HtmlElementInstance<E extends HtmlElement<any, any> = HtmlElement<any, any>> extends Instance<E> implements TooltipParentInstance {
|
|
21
43
|
events?: Record<string, (e: React.SyntheticEvent, instance: Instance) => any>;
|
|
22
44
|
tooltips: {
|
|
23
45
|
[key: string]: TooltipInstance;
|
|
24
46
|
};
|
|
25
47
|
}
|
|
26
|
-
export declare class HtmlElement<Config extends
|
|
48
|
+
export declare class HtmlElement<Config extends HtmlElementConfigBase = HtmlElementConfig, InstanceType extends HtmlElementInstance<any> = HtmlElementInstance<any>> extends StyledContainerBase<Config, InstanceType> {
|
|
27
49
|
tag?: string;
|
|
28
50
|
html?: string;
|
|
29
51
|
innerText?: string;
|
|
@@ -35,7 +57,7 @@ export declare class HtmlElement<Config extends HtmlElementConfig = HtmlElementC
|
|
|
35
57
|
urlAttributes?: string[];
|
|
36
58
|
extraProps?: Record<string, unknown>;
|
|
37
59
|
tooltip?: TooltipProp;
|
|
38
|
-
onRef?: (element: HTMLElement | null, instance: Instance) => void;
|
|
60
|
+
onRef?: string | ((element: HTMLElement | null, instance: Instance) => void);
|
|
39
61
|
autoFocus?: boolean | string;
|
|
40
62
|
[key: string]: unknown;
|
|
41
63
|
constructor(config?: Config);
|
|
@@ -46,3 +68,4 @@ export declare class HtmlElement<Config extends HtmlElementConfig = HtmlElementC
|
|
|
46
68
|
attachProps(context: RenderingContext, instance: InstanceType, props: RenderProps): void;
|
|
47
69
|
render(context: RenderingContext, instance: InstanceType, key: string): React.ReactNode;
|
|
48
70
|
}
|
|
71
|
+
export {};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/** @jsxImportSource react */
|
|
3
|
-
import { Widget, VDOM } from "../ui/Widget";
|
|
4
|
-
import { ContainerBase } from "../ui/Container";
|
|
5
|
-
import { tooltipMouseMove, tooltipParentWillUnmount, tooltipMouseLeave, tooltipParentWillReceiveProps, tooltipParentDidMount, tooltipParentDidUpdate, } from "./overlay/tooltip-ops";
|
|
6
2
|
import { Url } from "../ui/app/Url";
|
|
3
|
+
import { StyledContainerBase } from "../ui/Container";
|
|
4
|
+
import { Instance } from "../ui/Instance";
|
|
5
|
+
import { VDOM, Widget } from "../ui/Widget";
|
|
7
6
|
import { debug } from "../util/Debug";
|
|
7
|
+
import { isArray } from "../util/isArray";
|
|
8
|
+
import { isDefined } from "../util/isDefined";
|
|
8
9
|
import { isString } from "../util/isString";
|
|
9
10
|
import { isUndefined } from "../util/isUndefined";
|
|
10
|
-
import { isDefined } from "../util/isDefined";
|
|
11
|
-
import { isArray } from "../util/isArray";
|
|
12
11
|
import { autoFocus } from "./autoFocus";
|
|
13
|
-
import {
|
|
12
|
+
import { tooltipMouseLeave, tooltipMouseMove, tooltipParentDidMount, tooltipParentDidUpdate, tooltipParentWillReceiveProps, tooltipParentWillUnmount, } from "./overlay/tooltip-ops";
|
|
14
13
|
const isDataAttribute = (attr) => (attr.indexOf("data-") === 0 ? attr.substring(5) : false);
|
|
15
14
|
export let urlAttributes = {
|
|
16
15
|
"a.href": true,
|
|
@@ -20,7 +19,7 @@ export let urlAttributes = {
|
|
|
20
19
|
export class HtmlElementInstance extends Instance {
|
|
21
20
|
events;
|
|
22
21
|
}
|
|
23
|
-
export class HtmlElement extends
|
|
22
|
+
export class HtmlElement extends StyledContainerBase {
|
|
24
23
|
constructor(config) {
|
|
25
24
|
super(config);
|
|
26
25
|
if (isUndefined(this.jsxAttributes) && config)
|
|
@@ -181,7 +180,6 @@ export class HtmlElement extends ContainerBase {
|
|
|
181
180
|
}
|
|
182
181
|
}
|
|
183
182
|
HtmlElement.prototype.tag = "div";
|
|
184
|
-
HtmlElement.prototype.styled = true;
|
|
185
183
|
class ContainerComponent extends VDOM.Component {
|
|
186
184
|
el = null;
|
|
187
185
|
constructor(props) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "cx/jsx-runtime";
|
|
2
|
+
import { Store } from "../data/Store";
|
|
3
|
+
import assert from "assert";
|
|
4
|
+
import { createTestRenderer } from "../util/test/createTestRenderer";
|
|
5
|
+
import { bind } from "../ui/bind";
|
|
6
|
+
describe("HtmlElement", () => {
|
|
7
|
+
it("renders textual content provided through the text property", () => {
|
|
8
|
+
let widget = (_jsx("cx", { children: _jsx("div", { text: bind("text") }) }));
|
|
9
|
+
let store = new Store({
|
|
10
|
+
data: {
|
|
11
|
+
text: "Test",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const component = createTestRenderer(store, widget);
|
|
15
|
+
let tree = component.toJSON();
|
|
16
|
+
assert(tree && !Array.isArray(tree), "Expected single element");
|
|
17
|
+
assert.equal(tree.type, "div");
|
|
18
|
+
assert.deepEqual(tree.children, ["Test"]);
|
|
19
|
+
});
|
|
20
|
+
it("allows spread bindings", () => {
|
|
21
|
+
let store = new Store({
|
|
22
|
+
data: {
|
|
23
|
+
title: "title",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const component = createTestRenderer(store, (_jsx("cx", { children: _jsx("a", { href: "#", title: { bind: "title" }, children: "Link" }) })));
|
|
27
|
+
let tree = component.toJSON();
|
|
28
|
+
assert(tree && !Array.isArray(tree), "Expected single element");
|
|
29
|
+
assert.deepEqual(tree, {
|
|
30
|
+
type: "a",
|
|
31
|
+
children: ["Link"],
|
|
32
|
+
props: {
|
|
33
|
+
href: "#",
|
|
34
|
+
title: "title",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
package/build/widgets/Icon.d.ts
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import { Widget, WidgetConfig } from "../ui/Widget";
|
|
1
|
+
import { Widget, WidgetConfig, WidgetStyleConfig } from "../ui/Widget";
|
|
2
2
|
import "./icons/index";
|
|
3
3
|
import { RenderingContext } from "../ui/RenderingContext";
|
|
4
4
|
import { Instance } from "../ui/Instance";
|
|
5
|
-
import { StringProp
|
|
6
|
-
export interface IconConfig extends WidgetConfig {
|
|
5
|
+
import { StringProp } from "../ui/Prop";
|
|
6
|
+
export interface IconConfig extends WidgetConfig, WidgetStyleConfig {
|
|
7
7
|
/** Name under which the icon is registered. */
|
|
8
8
|
name?: StringProp;
|
|
9
|
-
/** Additional CSS classes to be applied to the field.
|
|
10
|
-
* If an object is provided, all keys with a "truthy" value will be added to the CSS class list. */
|
|
11
|
-
className?: ClassProp;
|
|
12
|
-
/** Additional CSS classes to be applied to the field.
|
|
13
|
-
* If an object is provided, all keys with a "truthy" value will be added to the CSS class list. */
|
|
14
|
-
class?: ClassProp;
|
|
15
|
-
/** Style object applied to the wrapper div. Used for setting the dimensions of the field. */
|
|
16
|
-
style?: StyleProp;
|
|
17
|
-
/** Base CSS class to be applied to the element. Default is `icon`. */
|
|
18
|
-
baseClass?: string;
|
|
19
9
|
}
|
|
20
10
|
export declare class Icon extends Widget<IconConfig> {
|
|
21
11
|
declareData(...args: Record<string, unknown>[]): void;
|
package/build/widgets/List.d.ts
CHANGED
|
@@ -12,8 +12,12 @@ export interface ListConfig<T = any> extends StyledContainerConfig {
|
|
|
12
12
|
records?: Prop<T[]>;
|
|
13
13
|
/** Record alias. Default is `$record`. */
|
|
14
14
|
recordName?: RecordAlias;
|
|
15
|
+
/** Record alias. Alias for `recordName`. Default is `$record`. */
|
|
16
|
+
recordAlias?: RecordAlias;
|
|
15
17
|
/** Index alias. Default is `$index`. */
|
|
16
18
|
indexName?: RecordAlias;
|
|
19
|
+
/** Index alias. Alias for `indexName`. Default is `$index`. */
|
|
20
|
+
indexAlias?: RecordAlias;
|
|
17
21
|
/** Style to be applied to each list item. */
|
|
18
22
|
itemStyle?: StyleProp;
|
|
19
23
|
/** CSS class to be applied to each list item. */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ContainerBase, ContainerConfig } from "../ui/Container";
|
|
2
|
+
import { Instance } from "../ui/Instance";
|
|
3
|
+
import { Prop } from "../ui/Prop";
|
|
4
|
+
import type { RenderingContext } from "../ui/RenderingContext";
|
|
5
|
+
type ReactElementWrapperConfigBase = Omit<ContainerConfig, "items">;
|
|
6
|
+
type CxCallback<T> = T extends (...args: infer A) => infer R ? (this: Instance, ...args: A) => R : T;
|
|
7
|
+
type TransformProp<K, V> = K extends keyof ReactElementWrapperConfigBase ? ReactElementWrapperConfigBase[K] : NonNullable<V> extends Function ? CxCallback<V> : Prop<V>;
|
|
8
|
+
type TransformReactElementProps<T> = {
|
|
9
|
+
[K in keyof T]: TransformProp<K, T[K]>;
|
|
10
|
+
};
|
|
11
|
+
/** ReactElementWrapper configuration with component-specific props */
|
|
12
|
+
export type ReactElementWrapperConfig<P> = ReactElementWrapperConfigBase & TransformReactElementProps<P>;
|
|
13
|
+
interface ReactElementWrapperInstance extends Instance {
|
|
14
|
+
events?: Record<string, Function>;
|
|
15
|
+
}
|
|
16
|
+
export declare class ReactElementWrapper<C extends React.ComponentType<any> = React.ComponentType<any>> extends ContainerBase<ReactElementWrapperConfigBase & {
|
|
17
|
+
componentType: C;
|
|
18
|
+
jsxAttributes?: string[];
|
|
19
|
+
}, ReactElementWrapperInstance> {
|
|
20
|
+
componentType: React.ComponentType<any>;
|
|
21
|
+
jsxAttributes?: string[];
|
|
22
|
+
props?: Record<string, unknown>;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
init(): void;
|
|
25
|
+
initInstance(_context: RenderingContext, _instance: ReactElementWrapperInstance): void;
|
|
26
|
+
declareData(...args: Record<string, unknown>[]): void;
|
|
27
|
+
render(context: RenderingContext, instance: ReactElementWrapperInstance, key: string): React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ContainerBase } from "../ui/Container";
|
|
2
|
+
import { VDOM } from "../ui/Widget";
|
|
3
|
+
import { isFunction, isNonEmptyArray } from "../util";
|
|
4
|
+
import { isArray } from "../util/isArray";
|
|
5
|
+
export class ReactElementWrapper extends ContainerBase {
|
|
6
|
+
init() {
|
|
7
|
+
// Collect all props to pass to the React component
|
|
8
|
+
this.props = {};
|
|
9
|
+
if (this.jsxAttributes) {
|
|
10
|
+
for (const attr of this.jsxAttributes) {
|
|
11
|
+
// Skip CxJS reserved attributes and children-related attributes
|
|
12
|
+
if (attr === "componentType" ||
|
|
13
|
+
attr === "visible" ||
|
|
14
|
+
attr === "if" ||
|
|
15
|
+
attr === "controller" ||
|
|
16
|
+
attr === "jsxAttributes" ||
|
|
17
|
+
attr === "layout" ||
|
|
18
|
+
attr === "outerLayout" ||
|
|
19
|
+
attr === "putInto" ||
|
|
20
|
+
attr === "contentFor" ||
|
|
21
|
+
attr === "children" ||
|
|
22
|
+
attr === "items")
|
|
23
|
+
continue;
|
|
24
|
+
this.props[attr] = this[attr];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
super.init();
|
|
28
|
+
}
|
|
29
|
+
initInstance(_context, _instance) {
|
|
30
|
+
let events;
|
|
31
|
+
if (!isNonEmptyArray(this.jsxAttributes))
|
|
32
|
+
return;
|
|
33
|
+
events = {};
|
|
34
|
+
for (let prop of this.jsxAttributes) {
|
|
35
|
+
let f = this[prop];
|
|
36
|
+
if (prop.startsWith("on") && isFunction(f))
|
|
37
|
+
events[prop] = (...args) => f.apply(_instance, args);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
declareData(...args) {
|
|
41
|
+
super.declareData({
|
|
42
|
+
props: { structured: true },
|
|
43
|
+
}, ...args);
|
|
44
|
+
}
|
|
45
|
+
render(context, instance, key) {
|
|
46
|
+
const { data } = instance;
|
|
47
|
+
// Render CxJS children to React elements
|
|
48
|
+
let children = this.renderChildren(context, instance);
|
|
49
|
+
if (children && isArray(children) && children.length === 0)
|
|
50
|
+
children = undefined;
|
|
51
|
+
const props = {
|
|
52
|
+
key,
|
|
53
|
+
...data.props,
|
|
54
|
+
...instance.events,
|
|
55
|
+
children,
|
|
56
|
+
};
|
|
57
|
+
return VDOM.createElement(this.componentType, props);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
|
-
import {
|
|
2
|
+
import { StyledContainerBase, StyledContainerConfig } from "../../ui/Container";
|
|
3
3
|
import { Instance } from "../../ui/Instance";
|
|
4
4
|
import { StringProp, StyleProp, ClassProp, Config } from "../../ui/Prop";
|
|
5
5
|
import { RenderingContext } from "../../ui/RenderingContext";
|
|
6
|
-
export interface DragSourceConfig extends
|
|
6
|
+
export interface DragSourceConfig extends StyledContainerConfig {
|
|
7
7
|
/**
|
|
8
8
|
* Data about the drag source that can be used by drop zones to test if
|
|
9
9
|
* drag source is acceptable and to perform drop operations.
|
|
@@ -35,7 +35,7 @@ export interface DragSourceConfig extends ContainerConfig {
|
|
|
35
35
|
export interface DragSourceInstance extends Instance<DragSource> {
|
|
36
36
|
dragHandles: any[];
|
|
37
37
|
}
|
|
38
|
-
export declare class DragSource extends
|
|
38
|
+
export declare class DragSource extends StyledContainerBase<DragSourceConfig, DragSourceInstance> {
|
|
39
39
|
styled: boolean;
|
|
40
40
|
baseClass: string;
|
|
41
41
|
hideOnDrag: boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource react */
|
|
3
3
|
import { Widget, VDOM } from "../../ui/Widget";
|
|
4
|
-
import {
|
|
4
|
+
import { StyledContainerBase } from "../../ui/Container";
|
|
5
5
|
import { ddMouseDown, ddDetect, ddMouseUp, initiateDragDrop, isDragHandleEvent } from "./ops";
|
|
6
6
|
import { preventFocus } from "../../ui/FocusManager";
|
|
7
7
|
import { parseStyle } from "../../util/parseStyle";
|
|
8
|
-
export class DragSource extends
|
|
8
|
+
export class DragSource extends StyledContainerBase {
|
|
9
9
|
constructor(config) {
|
|
10
10
|
super(config);
|
|
11
11
|
}
|
|
@@ -35,7 +35,6 @@ export class DragSource extends ContainerBase {
|
|
|
35
35
|
return (_jsx(DragSourceComponent, { instance: instance, handled: this.handled || instance.dragHandles.length > 0, children: this.renderChildren(context, instance) }, key));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
DragSource.prototype.styled = true;
|
|
39
38
|
DragSource.prototype.baseClass = "dragsource";
|
|
40
39
|
DragSource.prototype.hideOnDrag = false;
|
|
41
40
|
DragSource.prototype.handled = false;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
|
-
import {
|
|
2
|
+
import { StyledContainerBase, StyledContainerConfig } from "../../ui/Container";
|
|
3
3
|
import { DragEvent } from "./ops";
|
|
4
4
|
import { Instance } from "../../ui/Instance";
|
|
5
5
|
import { StyleProp, ClassProp, StructuredProp } from "../../ui/Prop";
|
|
6
6
|
import { RenderingContext } from "../../ui/RenderingContext";
|
|
7
|
-
export interface DropZoneConfig extends
|
|
7
|
+
export interface DropZoneConfig extends StyledContainerConfig {
|
|
8
8
|
/** CSS styles to be applied when drag cursor is over the drop zone. */
|
|
9
9
|
overStyle?: StyleProp;
|
|
10
10
|
/** CSS styles to be applied when drag cursor is near the drop zone. */
|
|
@@ -74,7 +74,7 @@ export interface DropZoneConfig extends ContainerConfig {
|
|
|
74
74
|
}
|
|
75
75
|
export interface DropZoneInstance extends Instance<DropZone> {
|
|
76
76
|
}
|
|
77
|
-
export declare class DropZone extends
|
|
77
|
+
export declare class DropZone extends StyledContainerBase<DropZoneConfig, DropZoneInstance> {
|
|
78
78
|
styled: boolean;
|
|
79
79
|
nearDistance: number;
|
|
80
80
|
hinflate: number;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource react */
|
|
3
3
|
import { Widget, VDOM } from "../../ui/Widget";
|
|
4
|
-
import {
|
|
4
|
+
import { StyledContainerBase } from "../../ui/Container";
|
|
5
5
|
import { parseStyle } from "../../util/parseStyle";
|
|
6
6
|
import { registerDropZone, DragDropContext } from "./ops";
|
|
7
7
|
import { findScrollableParent } from "../../util/findScrollableParent";
|
|
8
8
|
import { isNumber } from "../../util/isNumber";
|
|
9
9
|
import { getTopLevelBoundingClientRect } from "../../util/getTopLevelBoundingClientRect";
|
|
10
|
-
export class DropZone extends
|
|
10
|
+
export class DropZone extends StyledContainerBase {
|
|
11
11
|
constructor(config) {
|
|
12
12
|
super(config);
|
|
13
13
|
}
|
|
@@ -36,7 +36,6 @@ export class DropZone extends ContainerBase {
|
|
|
36
36
|
return (_jsx(DropZoneComponent, { instance: instance, children: this.renderChildren(context, instance) }, key));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
DropZone.prototype.styled = true;
|
|
40
39
|
DropZone.prototype.nearDistance = 0;
|
|
41
40
|
DropZone.prototype.hinflate = 0;
|
|
42
41
|
DropZone.prototype.vinflate = 0;
|
|
@@ -23,6 +23,8 @@ export interface CheckboxConfig extends FieldConfig {
|
|
|
23
23
|
unfocusable?: boolean;
|
|
24
24
|
/** View mode text. */
|
|
25
25
|
viewText?: StringProp;
|
|
26
|
+
/** Custom validation function. */
|
|
27
|
+
onValidate?: string | ((value: boolean, instance: Instance, validationParams: Record<string, unknown>) => unknown);
|
|
26
28
|
}
|
|
27
29
|
export declare class Checkbox extends Field<CheckboxConfig> {
|
|
28
30
|
baseClass: string;
|
|
@@ -26,6 +26,8 @@ export interface ColorFieldConfig extends FieldConfig {
|
|
|
26
26
|
format?: "rgba" | "hsla" | "hex";
|
|
27
27
|
/** Additional configuration to be passed to the dropdown, such as `style`, `positioning`, etc. */
|
|
28
28
|
dropdownOptions?: Partial<DropdownConfig>;
|
|
29
|
+
/** Custom validation function. */
|
|
30
|
+
onValidate?: string | ((value: string, instance: Instance, validationParams: Record<string, unknown>) => unknown);
|
|
29
31
|
}
|
|
30
32
|
export declare class ColorFieldInstance<F extends ColorField = ColorField> extends FieldInstance<F> implements DropdownWidgetProps {
|
|
31
33
|
lastDropdown?: Instance;
|
|
@@ -59,6 +59,8 @@ export interface DateTimeFieldConfig extends FieldConfig {
|
|
|
59
59
|
showSeconds?: boolean;
|
|
60
60
|
/** Additional configuration to be passed to the dropdown. */
|
|
61
61
|
dropdownOptions?: Partial<DropdownConfig>;
|
|
62
|
+
/** Custom validation function. */
|
|
63
|
+
onValidate?: string | ((value: string | Date, instance: Instance, validationParams: Record<string, unknown>) => unknown);
|
|
62
64
|
}
|
|
63
65
|
export declare class DateTimeField extends Field<DateTimeFieldConfig> {
|
|
64
66
|
showClear?: boolean;
|
|
@@ -61,8 +61,6 @@ export interface FieldConfig extends PureContainerConfig, WidgetStyleConfig {
|
|
|
61
61
|
tabIndex?: StringProp;
|
|
62
62
|
/** Additional content to be displayed next to the field. */
|
|
63
63
|
help?: string | Config;
|
|
64
|
-
/** Custom validation function. */
|
|
65
|
-
onValidate?: string | ((value: unknown, instance: Instance, validationParams: Record<string, unknown>) => unknown);
|
|
66
64
|
/** Validation parameters to be passed to the validation function. */
|
|
67
65
|
validationParams?: Config;
|
|
68
66
|
onValidationException?: string | ((error: unknown, instance: FieldInstance) => void);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import type { Instance } from
|
|
2
|
-
import type { CxChild, RenderingContext } from
|
|
3
|
-
import { Widget } from
|
|
4
|
-
import { FieldGroup, FieldGroupConfig } from
|
|
5
|
-
import { Label } from
|
|
6
|
-
import { StringProp,
|
|
1
|
+
import type { Instance } from "../../ui/Instance";
|
|
2
|
+
import type { CxChild, RenderingContext } from "../../ui/RenderingContext";
|
|
3
|
+
import { Widget } from "../../ui/Widget";
|
|
4
|
+
import { FieldGroup, FieldGroupConfig } from "./FieldGroup";
|
|
5
|
+
import { Label, LabelConfig } from "./Label";
|
|
6
|
+
import { StringProp, BooleanProp, ModProp } from "../../ui/Prop";
|
|
7
|
+
import { Create } from "../../util/Component";
|
|
7
8
|
export interface LabeledContainerConfig extends FieldGroupConfig {
|
|
8
9
|
/** The label. */
|
|
9
|
-
label?: StringProp |
|
|
10
|
+
label?: StringProp | Create<typeof Widget> | LabelConfig;
|
|
10
11
|
/** Set to true to disable the field. */
|
|
11
12
|
disabled?: BooleanProp;
|
|
12
13
|
/** CSS modifier classes. */
|
|
13
|
-
mod?:
|
|
14
|
+
mod?: ModProp;
|
|
14
15
|
/** Set to true to display an asterisk next to the label. */
|
|
15
16
|
asterisk?: BooleanProp;
|
|
16
17
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { isSelector } from
|
|
2
|
-
import { Widget } from
|
|
3
|
-
import { FieldGroup } from
|
|
4
|
-
import { Label } from
|
|
1
|
+
import { isSelector } from "../../data/isSelector";
|
|
2
|
+
import { Widget } from "../../ui/Widget";
|
|
3
|
+
import { FieldGroup } from "./FieldGroup";
|
|
4
|
+
import { Label } from "./Label";
|
|
5
5
|
export class LabeledContainer extends FieldGroup {
|
|
6
6
|
declareData(...args) {
|
|
7
7
|
super.declareData(...args, {
|
|
8
|
-
label: undefined
|
|
8
|
+
label: undefined,
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
init() {
|
|
@@ -15,7 +15,7 @@ export class LabeledContainer extends FieldGroup {
|
|
|
15
15
|
disabled: this.disabled,
|
|
16
16
|
mod: this.mod,
|
|
17
17
|
asterisk: this.asterisk,
|
|
18
|
-
required: true
|
|
18
|
+
required: true,
|
|
19
19
|
};
|
|
20
20
|
if (this.label.isComponentType)
|
|
21
21
|
labelConfig = this.label;
|
|
@@ -29,7 +29,7 @@ export class LabeledContainer extends FieldGroup {
|
|
|
29
29
|
}
|
|
30
30
|
initComponents(context, instance, ...args) {
|
|
31
31
|
return super.initComponents(context, instance, ...args, {
|
|
32
|
-
label: this.label
|
|
32
|
+
label: this.label,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
renderLabel(context, instance, key) {
|
|
@@ -40,9 +40,9 @@ export class LabeledContainer extends FieldGroup {
|
|
|
40
40
|
render(context, instance, key) {
|
|
41
41
|
return {
|
|
42
42
|
label: this.renderLabel(context, instance),
|
|
43
|
-
content: this.renderChildren(context, instance)
|
|
43
|
+
content: this.renderChildren(context, instance),
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
LabeledContainer.prototype.styled = true;
|
|
48
|
-
Widget.alias(
|
|
48
|
+
Widget.alias("labeled-container", LabeledContainer);
|