cx 26.4.2 → 26.4.3
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/jsx-dev-runtime.d.ts +1 -0
- package/build/jsx-dev-runtime.d.ts.map +1 -1
- package/build/jsx-dev-runtime.js +1 -0
- package/dist/manifest.js +889 -889
- package/package.json +1 -1
- package/src/charts/BarGraph.scss +31 -31
- package/src/charts/Legend.scss +57 -57
- package/src/charts/LegendEntry.scss +35 -35
- package/src/charts/LineGraph.scss +28 -28
- package/src/charts/helpers/SnapPointFinder.ts +136 -136
- package/src/charts/helpers/ValueAtFinder.ts +72 -72
- package/src/data/createAccessorModelProxy.ts +66 -66
- package/src/jsx-dev-runtime.ts +1 -0
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/Repeater.spec.tsx +181 -181
- package/src/ui/Rescope.ts +50 -50
- package/src/ui/adapter/ArrayAdapter.ts +229 -229
- package/src/ui/exprHelpers.ts +96 -96
- package/src/util/scss/include.scss +69 -69
- package/src/widgets/Button.maps.scss +103 -103
- package/src/widgets/Sandbox.ts +104 -104
- package/src/widgets/form/Calendar.tsx +772 -772
- package/src/widgets/form/ColorField.scss +112 -112
- package/src/widgets/form/DateTimeField.scss +111 -111
- package/src/widgets/form/LookupField.maps.scss +26 -26
- package/src/widgets/form/LookupField.scss +227 -227
- package/src/widgets/form/MonthField.scss +113 -113
- package/src/widgets/form/NumberField.scss +72 -72
- package/src/widgets/form/Select.scss +104 -104
- package/src/widgets/form/TextField.scss +66 -66
- package/src/widgets/grid/Grid.scss +657 -657
- package/src/widgets/grid/variables.scss +47 -47
- package/src/widgets/index.ts +63 -63
- package/src/widgets/nav/MenuItem.scss +150 -150
- package/src/widgets/nav/MenuItem.tsx +525 -525
- package/src/widgets/nav/Tab.ts +122 -122
- package/src/widgets/overlay/Overlay.tsx +1029 -1029
- package/src/widgets/variables.scss +61 -61
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
@forward "colors";
|
|
2
|
-
@use "call-once" as *;
|
|
3
|
-
@use "colors" as *;
|
|
4
|
-
@use "sass:map";
|
|
5
|
-
|
|
6
|
-
$cx-include-all: true !default;
|
|
7
|
-
|
|
8
|
-
$cx-excluded: () !default;
|
|
9
|
-
$cx-used: null !default;
|
|
10
|
-
|
|
11
|
-
$cx-dependencies: () !default;
|
|
12
|
-
|
|
13
|
-
@mixin cx-register-dependencies($deps) {
|
|
14
|
-
$cx-dependencies: map.merge($cx-dependencies, $deps) !global;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
$cx-deps-resolved: false !default;
|
|
18
|
-
|
|
19
|
-
// Recursively add all transitive dependencies of $name into $used
|
|
20
|
-
@function cx-resolve-module-deps($name, $used) {
|
|
21
|
-
$deps: map.get($cx-dependencies, $name);
|
|
22
|
-
@if $deps != null {
|
|
23
|
-
@each $dep in $deps {
|
|
24
|
-
@if map.get($used, $dep) != true {
|
|
25
|
-
$used: map.merge(
|
|
26
|
-
$used,
|
|
27
|
-
(
|
|
28
|
-
$dep: true,
|
|
29
|
-
)
|
|
30
|
-
);
|
|
31
|
-
$used: cx-resolve-module-deps($dep, $used);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
@return $used;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@function cx-should-include($name, $once: true) {
|
|
39
|
-
// Resolve dependencies once, on first call (after all deps are registered)
|
|
40
|
-
@if not $cx-deps-resolved and $cx-used != null {
|
|
41
|
-
@each $module in map.keys($cx-used) {
|
|
42
|
-
$cx-used: cx-resolve-module-deps($module, $cx-used) !global;
|
|
43
|
-
}
|
|
44
|
-
$cx-deps-resolved: true !global;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@return (
|
|
48
|
-
(map.get($cx-excluded, $name) != true) and
|
|
49
|
-
($cx-include-all or ($cx-used != null and map.get($cx-used, $name) == true))
|
|
50
|
-
)
|
|
51
|
-
and ($once != true or cx-call-once($name));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@function cx-included($name) {
|
|
55
|
-
@return cx-called-once($name);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@mixin cx-widgets($names...) {
|
|
59
|
-
$cx-used: () !default !global;
|
|
60
|
-
|
|
61
|
-
@each $name in $names {
|
|
62
|
-
$cx-used: map.merge(
|
|
63
|
-
$cx-used,
|
|
64
|
-
(
|
|
65
|
-
$name: true,
|
|
66
|
-
)
|
|
67
|
-
) !global;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
@forward "colors";
|
|
2
|
+
@use "call-once" as *;
|
|
3
|
+
@use "colors" as *;
|
|
4
|
+
@use "sass:map";
|
|
5
|
+
|
|
6
|
+
$cx-include-all: true !default;
|
|
7
|
+
|
|
8
|
+
$cx-excluded: () !default;
|
|
9
|
+
$cx-used: null !default;
|
|
10
|
+
|
|
11
|
+
$cx-dependencies: () !default;
|
|
12
|
+
|
|
13
|
+
@mixin cx-register-dependencies($deps) {
|
|
14
|
+
$cx-dependencies: map.merge($cx-dependencies, $deps) !global;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
$cx-deps-resolved: false !default;
|
|
18
|
+
|
|
19
|
+
// Recursively add all transitive dependencies of $name into $used
|
|
20
|
+
@function cx-resolve-module-deps($name, $used) {
|
|
21
|
+
$deps: map.get($cx-dependencies, $name);
|
|
22
|
+
@if $deps != null {
|
|
23
|
+
@each $dep in $deps {
|
|
24
|
+
@if map.get($used, $dep) != true {
|
|
25
|
+
$used: map.merge(
|
|
26
|
+
$used,
|
|
27
|
+
(
|
|
28
|
+
$dep: true,
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
$used: cx-resolve-module-deps($dep, $used);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
@return $used;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@function cx-should-include($name, $once: true) {
|
|
39
|
+
// Resolve dependencies once, on first call (after all deps are registered)
|
|
40
|
+
@if not $cx-deps-resolved and $cx-used != null {
|
|
41
|
+
@each $module in map.keys($cx-used) {
|
|
42
|
+
$cx-used: cx-resolve-module-deps($module, $cx-used) !global;
|
|
43
|
+
}
|
|
44
|
+
$cx-deps-resolved: true !global;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@return (
|
|
48
|
+
(map.get($cx-excluded, $name) != true) and
|
|
49
|
+
($cx-include-all or ($cx-used != null and map.get($cx-used, $name) == true))
|
|
50
|
+
)
|
|
51
|
+
and ($once != true or cx-call-once($name));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@function cx-included($name) {
|
|
55
|
+
@return cx-called-once($name);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@mixin cx-widgets($names...) {
|
|
59
|
+
$cx-used: () !default !global;
|
|
60
|
+
|
|
61
|
+
@each $name in $names {
|
|
62
|
+
$cx-used: map.merge(
|
|
63
|
+
$cx-used,
|
|
64
|
+
(
|
|
65
|
+
$name: true,
|
|
66
|
+
)
|
|
67
|
+
) !global;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
@use "sass:map";
|
|
2
|
-
@use "./lists" as *;
|
|
3
|
-
@use "./variables" as *;
|
|
4
|
-
|
|
5
|
-
$cx-button-state-style-map: (
|
|
6
|
-
default: (
|
|
7
|
-
background-color: $cx-default-button-background-color,
|
|
8
|
-
box-shadow: $cx-default-button-box-shadow,
|
|
9
|
-
border-color: $cx-default-button-border-color,
|
|
10
|
-
border-width: $cx-default-button-border-width,
|
|
11
|
-
border-radius: $cx-default-button-border-radius,
|
|
12
|
-
border-style: solid,
|
|
13
|
-
user-select: none,
|
|
14
|
-
color: $cx-default-button-color,
|
|
15
|
-
font-family: $cx-default-button-font-family,
|
|
16
|
-
font-size: $cx-default-button-font-size,
|
|
17
|
-
font-weight: $cx-default-button-font-weight,
|
|
18
|
-
line-height: $cx-default-button-line-height,
|
|
19
|
-
padding: $cx-default-button-padding,
|
|
20
|
-
cursor: pointer,
|
|
21
|
-
-webkit-appearance: none,
|
|
22
|
-
-moz-appearance: none,
|
|
23
|
-
appearance: none,
|
|
24
|
-
white-space: nowrap,
|
|
25
|
-
text-decoration: none,
|
|
26
|
-
),
|
|
27
|
-
hover: (
|
|
28
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
|
|
29
|
-
text-decoration: none,
|
|
30
|
-
),
|
|
31
|
-
focus: (
|
|
32
|
-
outline: none,
|
|
33
|
-
box-shadow: 0 0 1px 1px rgba(77, 144, 254, 0.8),
|
|
34
|
-
),
|
|
35
|
-
hover-focus: (),
|
|
36
|
-
disabled: (
|
|
37
|
-
color: gray,
|
|
38
|
-
box-shadow: none,
|
|
39
|
-
pointer-events: none,
|
|
40
|
-
),
|
|
41
|
-
active: (
|
|
42
|
-
top: 1px,
|
|
43
|
-
box-shadow: none,
|
|
44
|
-
),
|
|
45
|
-
) !default;
|
|
46
|
-
|
|
47
|
-
$cx-button-mods: (
|
|
48
|
-
primary: (
|
|
49
|
-
default: (
|
|
50
|
-
background-color: #1f99f8,
|
|
51
|
-
border-color: #1e88e5,
|
|
52
|
-
color: white,
|
|
53
|
-
),
|
|
54
|
-
disabled: (
|
|
55
|
-
background-color: rgba(31, 153, 248, 0.5),
|
|
56
|
-
border-color: rgba(30, 136, 229, 0.1),
|
|
57
|
-
color: rgba(255, 255, 255, 0.6),
|
|
58
|
-
),
|
|
59
|
-
hover: (
|
|
60
|
-
background-color: #1f99f8,
|
|
61
|
-
),
|
|
62
|
-
),
|
|
63
|
-
danger: (
|
|
64
|
-
default: (
|
|
65
|
-
background-color: #d32f2f,
|
|
66
|
-
border-color: #c62828,
|
|
67
|
-
color: white,
|
|
68
|
-
),
|
|
69
|
-
disabled: (
|
|
70
|
-
background-color: rgba(211, 47, 47, 0.6),
|
|
71
|
-
border-color: rgba(198, 40, 40, 0.1),
|
|
72
|
-
color: rgba(255, 255, 255, 0.5),
|
|
73
|
-
),
|
|
74
|
-
hover: (
|
|
75
|
-
background-color: #d32f2f,
|
|
76
|
-
),
|
|
77
|
-
),
|
|
78
|
-
hollow: (
|
|
79
|
-
default: (
|
|
80
|
-
background-color: transparent,
|
|
81
|
-
border-color: transparent,
|
|
82
|
-
color: inherit,
|
|
83
|
-
box-shadow: none,
|
|
84
|
-
),
|
|
85
|
-
hover: map.merge(
|
|
86
|
-
map.get($cx-list-item, hover),
|
|
87
|
-
(
|
|
88
|
-
box-shadow: none,
|
|
89
|
-
border-color: transparent,
|
|
90
|
-
)
|
|
91
|
-
),
|
|
92
|
-
focus: map.merge(
|
|
93
|
-
map.get($cx-list-item, selected-cursor),
|
|
94
|
-
(
|
|
95
|
-
box-shadow: none,
|
|
96
|
-
border-color: transparent,
|
|
97
|
-
)
|
|
98
|
-
),
|
|
99
|
-
disabled: (
|
|
100
|
-
color: rgba(128, 128, 128, 0.5),
|
|
101
|
-
),
|
|
102
|
-
),
|
|
103
|
-
) !default;
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
@use "./lists" as *;
|
|
3
|
+
@use "./variables" as *;
|
|
4
|
+
|
|
5
|
+
$cx-button-state-style-map: (
|
|
6
|
+
default: (
|
|
7
|
+
background-color: $cx-default-button-background-color,
|
|
8
|
+
box-shadow: $cx-default-button-box-shadow,
|
|
9
|
+
border-color: $cx-default-button-border-color,
|
|
10
|
+
border-width: $cx-default-button-border-width,
|
|
11
|
+
border-radius: $cx-default-button-border-radius,
|
|
12
|
+
border-style: solid,
|
|
13
|
+
user-select: none,
|
|
14
|
+
color: $cx-default-button-color,
|
|
15
|
+
font-family: $cx-default-button-font-family,
|
|
16
|
+
font-size: $cx-default-button-font-size,
|
|
17
|
+
font-weight: $cx-default-button-font-weight,
|
|
18
|
+
line-height: $cx-default-button-line-height,
|
|
19
|
+
padding: $cx-default-button-padding,
|
|
20
|
+
cursor: pointer,
|
|
21
|
+
-webkit-appearance: none,
|
|
22
|
+
-moz-appearance: none,
|
|
23
|
+
appearance: none,
|
|
24
|
+
white-space: nowrap,
|
|
25
|
+
text-decoration: none,
|
|
26
|
+
),
|
|
27
|
+
hover: (
|
|
28
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
|
|
29
|
+
text-decoration: none,
|
|
30
|
+
),
|
|
31
|
+
focus: (
|
|
32
|
+
outline: none,
|
|
33
|
+
box-shadow: 0 0 1px 1px rgba(77, 144, 254, 0.8),
|
|
34
|
+
),
|
|
35
|
+
hover-focus: (),
|
|
36
|
+
disabled: (
|
|
37
|
+
color: gray,
|
|
38
|
+
box-shadow: none,
|
|
39
|
+
pointer-events: none,
|
|
40
|
+
),
|
|
41
|
+
active: (
|
|
42
|
+
top: 1px,
|
|
43
|
+
box-shadow: none,
|
|
44
|
+
),
|
|
45
|
+
) !default;
|
|
46
|
+
|
|
47
|
+
$cx-button-mods: (
|
|
48
|
+
primary: (
|
|
49
|
+
default: (
|
|
50
|
+
background-color: #1f99f8,
|
|
51
|
+
border-color: #1e88e5,
|
|
52
|
+
color: white,
|
|
53
|
+
),
|
|
54
|
+
disabled: (
|
|
55
|
+
background-color: rgba(31, 153, 248, 0.5),
|
|
56
|
+
border-color: rgba(30, 136, 229, 0.1),
|
|
57
|
+
color: rgba(255, 255, 255, 0.6),
|
|
58
|
+
),
|
|
59
|
+
hover: (
|
|
60
|
+
background-color: #1f99f8,
|
|
61
|
+
),
|
|
62
|
+
),
|
|
63
|
+
danger: (
|
|
64
|
+
default: (
|
|
65
|
+
background-color: #d32f2f,
|
|
66
|
+
border-color: #c62828,
|
|
67
|
+
color: white,
|
|
68
|
+
),
|
|
69
|
+
disabled: (
|
|
70
|
+
background-color: rgba(211, 47, 47, 0.6),
|
|
71
|
+
border-color: rgba(198, 40, 40, 0.1),
|
|
72
|
+
color: rgba(255, 255, 255, 0.5),
|
|
73
|
+
),
|
|
74
|
+
hover: (
|
|
75
|
+
background-color: #d32f2f,
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
hollow: (
|
|
79
|
+
default: (
|
|
80
|
+
background-color: transparent,
|
|
81
|
+
border-color: transparent,
|
|
82
|
+
color: inherit,
|
|
83
|
+
box-shadow: none,
|
|
84
|
+
),
|
|
85
|
+
hover: map.merge(
|
|
86
|
+
map.get($cx-list-item, hover),
|
|
87
|
+
(
|
|
88
|
+
box-shadow: none,
|
|
89
|
+
border-color: transparent,
|
|
90
|
+
)
|
|
91
|
+
),
|
|
92
|
+
focus: map.merge(
|
|
93
|
+
map.get($cx-list-item, selected-cursor),
|
|
94
|
+
(
|
|
95
|
+
box-shadow: none,
|
|
96
|
+
border-color: transparent,
|
|
97
|
+
)
|
|
98
|
+
),
|
|
99
|
+
disabled: (
|
|
100
|
+
color: rgba(128, 128, 128, 0.5),
|
|
101
|
+
),
|
|
102
|
+
),
|
|
103
|
+
) !default;
|
package/src/widgets/Sandbox.ts
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { Widget } from "../ui/Widget";
|
|
2
|
-
import { PureContainerBase, PureContainerConfig } from "../ui/PureContainer";
|
|
3
|
-
import { Binding, BindingInput } from "../data/Binding";
|
|
4
|
-
import { ExposedValueView, ExposedValueViewConfig } from "../data/ExposedValueView";
|
|
5
|
-
import { RenderingContext } from "../ui/RenderingContext";
|
|
6
|
-
import { Instance } from "../ui/Instance";
|
|
7
|
-
import { StringProp, WritableProp } from "../ui/Prop";
|
|
8
|
-
import { AccessorChain } from "../data/createAccessorModelProxy";
|
|
9
|
-
|
|
10
|
-
export interface SandboxConfig extends PureContainerConfig {
|
|
11
|
-
/** Binding to the object that holds sandbox data. */
|
|
12
|
-
storage: WritableProp<Record<string, any>>;
|
|
13
|
-
|
|
14
|
-
/** Key used to identify the sandbox instance within the storage. */
|
|
15
|
-
key?: StringProp;
|
|
16
|
-
|
|
17
|
-
/** Alias for `key`. */
|
|
18
|
-
accessKey?: StringProp;
|
|
19
|
-
|
|
20
|
-
/** Alias used to expose sandbox data. Default is `$page`. */
|
|
21
|
-
recordName?: string | AccessorChain<any>;
|
|
22
|
-
|
|
23
|
-
/** Alias for `recordName`. */
|
|
24
|
-
recordAlias?: string | AccessorChain<any>;
|
|
25
|
-
|
|
26
|
-
/** Indicate that parent store data should not be mutated. */
|
|
27
|
-
immutable?: boolean;
|
|
28
|
-
|
|
29
|
-
/** Indicate that sandbox store data should not be mutated. */
|
|
30
|
-
sealed?: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface SandboxInstance extends Instance {
|
|
34
|
-
store: ExposedValueView;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class Sandbox extends PureContainerBase<SandboxConfig, SandboxInstance> {
|
|
38
|
-
declare storage: WritableProp<Record<string, any>>;
|
|
39
|
-
declare key?: StringProp;
|
|
40
|
-
declare recordName?: string;
|
|
41
|
-
declare recordAlias?: string;
|
|
42
|
-
declare accessKey?: StringProp;
|
|
43
|
-
declare immutable?: boolean;
|
|
44
|
-
declare sealed?: boolean;
|
|
45
|
-
declare storageBinding: Binding;
|
|
46
|
-
init(): void {
|
|
47
|
-
if (this.recordAlias) this.recordName = this.recordAlias;
|
|
48
|
-
|
|
49
|
-
if (this.accessKey) this.key = this.accessKey;
|
|
50
|
-
|
|
51
|
-
this.storageBinding = Binding.get(this.storage);
|
|
52
|
-
|
|
53
|
-
super.init();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
initInstance(context: RenderingContext, instance: SandboxInstance): void {
|
|
57
|
-
instance.store = new ExposedValueView({
|
|
58
|
-
store: instance.parentStore,
|
|
59
|
-
containerBinding: this.storageBinding,
|
|
60
|
-
key: null,
|
|
61
|
-
recordName: this.recordName,
|
|
62
|
-
immutable: this.immutable,
|
|
63
|
-
});
|
|
64
|
-
super.initInstance(context, instance);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
applyParentStore(instance: SandboxInstance): void {
|
|
68
|
-
instance.store.setStore(instance.parentStore);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
declareData(...args: Record<string, unknown>[]): void {
|
|
72
|
-
super.declareData(
|
|
73
|
-
{
|
|
74
|
-
storage: undefined,
|
|
75
|
-
key: undefined,
|
|
76
|
-
},
|
|
77
|
-
...args,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
prepareData(context: RenderingContext, instance: SandboxInstance): void {
|
|
82
|
-
var { store, data } = instance;
|
|
83
|
-
if (store.getKey() !== data.key) {
|
|
84
|
-
//when navigating to a page using the same widget tree as the previous page
|
|
85
|
-
//everything needs to be reinstantiated, e.g. user/1 => user/2
|
|
86
|
-
instance.store = new ExposedValueView({
|
|
87
|
-
store: store,
|
|
88
|
-
containerBinding: this.storageBinding,
|
|
89
|
-
key: data.key,
|
|
90
|
-
recordName: this.recordName,
|
|
91
|
-
immutable: this.immutable,
|
|
92
|
-
sealed: this.sealed,
|
|
93
|
-
});
|
|
94
|
-
instance.clearChildrenCache();
|
|
95
|
-
}
|
|
96
|
-
super.prepareData(context, instance);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
Sandbox.prototype.recordName = "$page";
|
|
101
|
-
Sandbox.prototype.immutable = false;
|
|
102
|
-
Sandbox.prototype.sealed = false;
|
|
103
|
-
|
|
104
|
-
Widget.alias("sandbox", Sandbox);
|
|
1
|
+
import { Widget } from "../ui/Widget";
|
|
2
|
+
import { PureContainerBase, PureContainerConfig } from "../ui/PureContainer";
|
|
3
|
+
import { Binding, BindingInput } from "../data/Binding";
|
|
4
|
+
import { ExposedValueView, ExposedValueViewConfig } from "../data/ExposedValueView";
|
|
5
|
+
import { RenderingContext } from "../ui/RenderingContext";
|
|
6
|
+
import { Instance } from "../ui/Instance";
|
|
7
|
+
import { StringProp, WritableProp } from "../ui/Prop";
|
|
8
|
+
import { AccessorChain } from "../data/createAccessorModelProxy";
|
|
9
|
+
|
|
10
|
+
export interface SandboxConfig extends PureContainerConfig {
|
|
11
|
+
/** Binding to the object that holds sandbox data. */
|
|
12
|
+
storage: WritableProp<Record<string, any>>;
|
|
13
|
+
|
|
14
|
+
/** Key used to identify the sandbox instance within the storage. */
|
|
15
|
+
key?: StringProp;
|
|
16
|
+
|
|
17
|
+
/** Alias for `key`. */
|
|
18
|
+
accessKey?: StringProp;
|
|
19
|
+
|
|
20
|
+
/** Alias used to expose sandbox data. Default is `$page`. */
|
|
21
|
+
recordName?: string | AccessorChain<any>;
|
|
22
|
+
|
|
23
|
+
/** Alias for `recordName`. */
|
|
24
|
+
recordAlias?: string | AccessorChain<any>;
|
|
25
|
+
|
|
26
|
+
/** Indicate that parent store data should not be mutated. */
|
|
27
|
+
immutable?: boolean;
|
|
28
|
+
|
|
29
|
+
/** Indicate that sandbox store data should not be mutated. */
|
|
30
|
+
sealed?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface SandboxInstance extends Instance {
|
|
34
|
+
store: ExposedValueView;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class Sandbox extends PureContainerBase<SandboxConfig, SandboxInstance> {
|
|
38
|
+
declare storage: WritableProp<Record<string, any>>;
|
|
39
|
+
declare key?: StringProp;
|
|
40
|
+
declare recordName?: string;
|
|
41
|
+
declare recordAlias?: string;
|
|
42
|
+
declare accessKey?: StringProp;
|
|
43
|
+
declare immutable?: boolean;
|
|
44
|
+
declare sealed?: boolean;
|
|
45
|
+
declare storageBinding: Binding;
|
|
46
|
+
init(): void {
|
|
47
|
+
if (this.recordAlias) this.recordName = this.recordAlias;
|
|
48
|
+
|
|
49
|
+
if (this.accessKey) this.key = this.accessKey;
|
|
50
|
+
|
|
51
|
+
this.storageBinding = Binding.get(this.storage);
|
|
52
|
+
|
|
53
|
+
super.init();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
initInstance(context: RenderingContext, instance: SandboxInstance): void {
|
|
57
|
+
instance.store = new ExposedValueView({
|
|
58
|
+
store: instance.parentStore,
|
|
59
|
+
containerBinding: this.storageBinding,
|
|
60
|
+
key: null,
|
|
61
|
+
recordName: this.recordName,
|
|
62
|
+
immutable: this.immutable,
|
|
63
|
+
});
|
|
64
|
+
super.initInstance(context, instance);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
applyParentStore(instance: SandboxInstance): void {
|
|
68
|
+
instance.store.setStore(instance.parentStore);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declareData(...args: Record<string, unknown>[]): void {
|
|
72
|
+
super.declareData(
|
|
73
|
+
{
|
|
74
|
+
storage: undefined,
|
|
75
|
+
key: undefined,
|
|
76
|
+
},
|
|
77
|
+
...args,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
prepareData(context: RenderingContext, instance: SandboxInstance): void {
|
|
82
|
+
var { store, data } = instance;
|
|
83
|
+
if (store.getKey() !== data.key) {
|
|
84
|
+
//when navigating to a page using the same widget tree as the previous page
|
|
85
|
+
//everything needs to be reinstantiated, e.g. user/1 => user/2
|
|
86
|
+
instance.store = new ExposedValueView({
|
|
87
|
+
store: store,
|
|
88
|
+
containerBinding: this.storageBinding,
|
|
89
|
+
key: data.key,
|
|
90
|
+
recordName: this.recordName,
|
|
91
|
+
immutable: this.immutable,
|
|
92
|
+
sealed: this.sealed,
|
|
93
|
+
});
|
|
94
|
+
instance.clearChildrenCache();
|
|
95
|
+
}
|
|
96
|
+
super.prepareData(context, instance);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Sandbox.prototype.recordName = "$page";
|
|
101
|
+
Sandbox.prototype.immutable = false;
|
|
102
|
+
Sandbox.prototype.sealed = false;
|
|
103
|
+
|
|
104
|
+
Widget.alias("sandbox", Sandbox);
|