cx 26.7.4 → 26.7.5

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.
@@ -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);
@@ -1,112 +1,112 @@
1
- @use "sass:math";
2
- @use "sass:map";
3
- @use "../variables" as *;
4
- @use "../maps" as *;
5
- @use "../../util/call-once.scss" as *;
6
- @use "../../util/scss/add-rules.scss" as *;
7
- @use "../../util/scss/calc.scss" as *;
8
- @use "../../util/scss/clockwise.scss" as *;
9
- @use "../../util/scss/deep-merge.scss" as *;
10
- @use "../../util/scss/besm.scss" as *;
11
- @use "../../util/scss/include.scss" as *;
12
- @use "./Field.scss" as *;
13
- @use "./ColorPicker.scss" as *;
14
-
15
- @mixin cx-colorfield(
16
- $name: "colorfield",
17
- $state-style-map: $cx-std-field-state-style-map,
18
- $placeholder: $cx-input-placeholder,
19
- $empty-text: $cx-empty-text,
20
- $clear-state-style-map: $cx-clear-state-style-map,
21
- $left-icon-state-style-map: $cx-input-left-icon-state-style-map,
22
- $right-icon-state-style-map: $cx-input-right-icon-state-style-map,
23
- $width: $cx-default-input-width,
24
- $icon-size: $cx-default-icon-size,
25
- $besm: $cx-besm
26
- ) {
27
- $block: map.get($besm, block);
28
- $element: map.get($besm, element);
29
- $state: map.get($besm, state);
30
-
31
- .#{$block}#{$name} {
32
- @include cxb-field($besm, $state-style-map, $width: $width, $input: true);
33
- }
34
-
35
- $padding: cx-get-state-rule($state-style-map, default, "padding");
36
-
37
- .#{$element}#{$name}-input {
38
- @include cxe-field-input(
39
- $besm,
40
- $state-style-map,
41
- $placeholder: $placeholder,
42
- $overrides: (
43
- default: (
44
- font-family: $cx-default-colorfield-font-family,
45
- font-size: 11px,
46
- padding: cx-top($padding) cx-calc(cx-top($padding), $cx-default-clear-size, $cx-default-clear-spacing)
47
- cx-bottom($padding)
48
- cx-calc(cx-top($padding), $cx-default-input-left-tool-size, $cx-default-input-left-tool-spacing),
49
- )
50
- )
51
- );
52
- }
53
-
54
- .#{$element}#{$name}-clear {
55
- @include cxe-field-button($besm, $clear-state-style-map);
56
-
57
- .#{$state}focus > & {
58
- @include cx-add-state-rules($clear-state-style-map, focus);
59
- }
60
- .#{$state}error > & {
61
- @include cx-add-state-rules($clear-state-style-map, error);
62
- }
63
- }
64
-
65
- .#{$element}#{$name}-right-icon {
66
- @include cxe-field-button($besm, $right-icon-state-style-map);
67
-
68
- .#{$state}focus > & {
69
- @include cx-add-state-rules($right-icon-state-style-map, focus);
70
- }
71
- .#{$state}error > & {
72
- @include cx-add-state-rules($right-icon-state-style-map, error);
73
- }
74
- }
75
-
76
- .#{$element}#{$name}-left-icon {
77
- box-sizing: border-box;
78
-
79
- @include cx-checker-background();
80
-
81
- @include cxe-field-button(
82
- $besm,
83
- cx-deep-map-merge(
84
- $left-icon-state-style-map,
85
- (
86
- default: (
87
- opacity: 1,
88
- cursor: pointer,
89
- ),
90
- )
91
- )
92
- );
93
-
94
- div {
95
- width: 100%;
96
- height: 100%;
97
- border-radius: inherit;
98
- }
99
- }
100
-
101
- .#{$element}#{$name}-icon {
102
- @include cxe-field-button-icon($besm, $icon-size);
103
- }
104
-
105
- .#{$element}#{$name}-empty-text {
106
- @include cxe-field-empty-text($empty-text);
107
- }
108
- }
109
-
110
- @if (cx-should-include("cx/widgets/ColorField")) {
111
- @include cx-colorfield();
112
- }
1
+ @use "sass:math";
2
+ @use "sass:map";
3
+ @use "../variables" as *;
4
+ @use "../maps" as *;
5
+ @use "../../util/call-once.scss" as *;
6
+ @use "../../util/scss/add-rules.scss" as *;
7
+ @use "../../util/scss/calc.scss" as *;
8
+ @use "../../util/scss/clockwise.scss" as *;
9
+ @use "../../util/scss/deep-merge.scss" as *;
10
+ @use "../../util/scss/besm.scss" as *;
11
+ @use "../../util/scss/include.scss" as *;
12
+ @use "./Field.scss" as *;
13
+ @use "./ColorPicker.scss" as *;
14
+
15
+ @mixin cx-colorfield(
16
+ $name: "colorfield",
17
+ $state-style-map: $cx-std-field-state-style-map,
18
+ $placeholder: $cx-input-placeholder,
19
+ $empty-text: $cx-empty-text,
20
+ $clear-state-style-map: $cx-clear-state-style-map,
21
+ $left-icon-state-style-map: $cx-input-left-icon-state-style-map,
22
+ $right-icon-state-style-map: $cx-input-right-icon-state-style-map,
23
+ $width: $cx-default-input-width,
24
+ $icon-size: $cx-default-icon-size,
25
+ $besm: $cx-besm
26
+ ) {
27
+ $block: map.get($besm, block);
28
+ $element: map.get($besm, element);
29
+ $state: map.get($besm, state);
30
+
31
+ .#{$block}#{$name} {
32
+ @include cxb-field($besm, $state-style-map, $width: $width, $input: true);
33
+ }
34
+
35
+ $padding: cx-get-state-rule($state-style-map, default, "padding");
36
+
37
+ .#{$element}#{$name}-input {
38
+ @include cxe-field-input(
39
+ $besm,
40
+ $state-style-map,
41
+ $placeholder: $placeholder,
42
+ $overrides: (
43
+ default: (
44
+ font-family: $cx-default-colorfield-font-family,
45
+ font-size: 11px,
46
+ padding: cx-top($padding) cx-calc(cx-top($padding), $cx-default-clear-size, $cx-default-clear-spacing)
47
+ cx-bottom($padding)
48
+ cx-calc(cx-top($padding), $cx-default-input-left-tool-size, $cx-default-input-left-tool-spacing),
49
+ )
50
+ )
51
+ );
52
+ }
53
+
54
+ .#{$element}#{$name}-clear {
55
+ @include cxe-field-button($besm, $clear-state-style-map);
56
+
57
+ .#{$state}focus > & {
58
+ @include cx-add-state-rules($clear-state-style-map, focus);
59
+ }
60
+ .#{$state}error > & {
61
+ @include cx-add-state-rules($clear-state-style-map, error);
62
+ }
63
+ }
64
+
65
+ .#{$element}#{$name}-right-icon {
66
+ @include cxe-field-button($besm, $right-icon-state-style-map);
67
+
68
+ .#{$state}focus > & {
69
+ @include cx-add-state-rules($right-icon-state-style-map, focus);
70
+ }
71
+ .#{$state}error > & {
72
+ @include cx-add-state-rules($right-icon-state-style-map, error);
73
+ }
74
+ }
75
+
76
+ .#{$element}#{$name}-left-icon {
77
+ box-sizing: border-box;
78
+
79
+ @include cx-checker-background();
80
+
81
+ @include cxe-field-button(
82
+ $besm,
83
+ cx-deep-map-merge(
84
+ $left-icon-state-style-map,
85
+ (
86
+ default: (
87
+ opacity: 1,
88
+ cursor: pointer,
89
+ ),
90
+ )
91
+ )
92
+ );
93
+
94
+ div {
95
+ width: 100%;
96
+ height: 100%;
97
+ border-radius: inherit;
98
+ }
99
+ }
100
+
101
+ .#{$element}#{$name}-icon {
102
+ @include cxe-field-button-icon($besm, $icon-size);
103
+ }
104
+
105
+ .#{$element}#{$name}-empty-text {
106
+ @include cxe-field-empty-text($empty-text);
107
+ }
108
+ }
109
+
110
+ @if (cx-should-include("cx/widgets/ColorField")) {
111
+ @include cx-colorfield();
112
+ }
@@ -1,111 +1,111 @@
1
- @use "sass:math";
2
- @use "sass:map";
3
- @use "../variables" as *;
4
- @use "../maps" as *;
5
- @use "../../util/scss/add-rules.scss" as *;
6
- @use "../../util/scss/calc.scss" as *;
7
- @use "../../util/scss/clockwise.scss" as *;
8
- @use "../../util/scss/deep-merge.scss" as *;
9
- @use "../../util/scss/besm.scss" as *;
10
- @use "../../util/scss/include.scss" as *;
11
- @use "./Field.scss" as *;
12
-
13
- @mixin cx-datetimefield(
14
- $name: "datetimefield",
15
- $input-state-style-map: $cx-std-field-state-style-map,
16
- $placeholder: $cx-input-placeholder,
17
- $empty-text: $cx-empty-text,
18
- $clear-state-style-map: $cx-clear-state-style-map,
19
- $left-icon-state-style-map: $cx-input-left-icon-state-style-map,
20
- $right-icon-state-style-map: $cx-input-right-icon-state-style-map,
21
- $icon-size: $cx-default-input-icon-size,
22
- $width: $cx-default-input-width,
23
- $besm: $cx-besm
24
- ) {
25
- $block: map.get($besm, block);
26
- $element: map.get($besm, element);
27
- $state: map.get($besm, state);
28
-
29
- .#{$block}#{$name} {
30
- @include cxb-field($besm, $input-state-style-map, $width: $width, $input: true);
31
- }
32
-
33
- $padding: cx-get-state-rule($input-state-style-map, default, "padding");
34
-
35
- .#{$element}#{$name}-input {
36
- @include cxe-field-input(
37
- $besm,
38
- $input-state-style-map,
39
- $placeholder: $placeholder,
40
- $overrides: (
41
- default: (
42
- padding: cx-top($padding) cx-calc(cx-top($padding), $cx-default-clear-size, $cx-default-clear-spacing)
43
- cx-bottom($padding)
44
- cx-calc(cx-top($padding), $cx-default-input-left-tool-size, $cx-default-input-left-tool-spacing),
45
- )
46
- )
47
- );
48
- }
49
-
50
- .#{$element}#{$name}-clear {
51
- @include cxe-field-button($besm, $clear-state-style-map);
52
-
53
- .#{$state}focus > & {
54
- @include cx-add-state-rules($clear-state-style-map, focus);
55
- }
56
- .#{$state}error > & {
57
- @include cx-add-state-rules($clear-state-style-map, error);
58
- }
59
- }
60
-
61
- .#{$element}#{$name}-left-icon {
62
- @include cxe-field-button(
63
- $besm,
64
- cx-deep-map-merge(
65
- $left-icon-state-style-map,
66
- (
67
- default: (
68
- cursor: pointer,
69
- ),
70
- )
71
- )
72
- );
73
-
74
- .#{$state}disabled > & {
75
- @include cx-add-state-rules($input-state-style-map, disabled);
76
- border-width: 0;
77
- }
78
- .#{$state}focus > & {
79
- @include cx-add-state-rules($left-icon-state-style-map, focus);
80
- }
81
- .#{$state}error > & {
82
- @include cx-add-state-rules($left-icon-state-style-map, error);
83
- }
84
- }
85
-
86
- .#{$element}#{$name}-right-icon {
87
- @include cxe-field-button($besm, $right-icon-state-style-map);
88
- .#{$state}disabled > & {
89
- @include cx-add-state-rules($input-state-style-map, disabled);
90
- border-width: 0;
91
- }
92
- .#{$state}focus > & {
93
- @include cx-add-state-rules($right-icon-state-style-map, focus);
94
- }
95
- .#{$state}error > & {
96
- @include cx-add-state-rules($right-icon-state-style-map, error);
97
- }
98
- }
99
-
100
- .#{$element}#{$name}-icon {
101
- @include cxe-field-button-icon($besm, $icon-size);
102
- }
103
-
104
- .#{$element}#{$name}-empty-text {
105
- @include cxe-field-empty-text($empty-text);
106
- }
107
- }
108
-
109
- @if (cx-should-include("cx/widgets/DateTimeField")) {
110
- @include cx-datetimefield();
111
- }
1
+ @use "sass:math";
2
+ @use "sass:map";
3
+ @use "../variables" as *;
4
+ @use "../maps" as *;
5
+ @use "../../util/scss/add-rules.scss" as *;
6
+ @use "../../util/scss/calc.scss" as *;
7
+ @use "../../util/scss/clockwise.scss" as *;
8
+ @use "../../util/scss/deep-merge.scss" as *;
9
+ @use "../../util/scss/besm.scss" as *;
10
+ @use "../../util/scss/include.scss" as *;
11
+ @use "./Field.scss" as *;
12
+
13
+ @mixin cx-datetimefield(
14
+ $name: "datetimefield",
15
+ $input-state-style-map: $cx-std-field-state-style-map,
16
+ $placeholder: $cx-input-placeholder,
17
+ $empty-text: $cx-empty-text,
18
+ $clear-state-style-map: $cx-clear-state-style-map,
19
+ $left-icon-state-style-map: $cx-input-left-icon-state-style-map,
20
+ $right-icon-state-style-map: $cx-input-right-icon-state-style-map,
21
+ $icon-size: $cx-default-input-icon-size,
22
+ $width: $cx-default-input-width,
23
+ $besm: $cx-besm
24
+ ) {
25
+ $block: map.get($besm, block);
26
+ $element: map.get($besm, element);
27
+ $state: map.get($besm, state);
28
+
29
+ .#{$block}#{$name} {
30
+ @include cxb-field($besm, $input-state-style-map, $width: $width, $input: true);
31
+ }
32
+
33
+ $padding: cx-get-state-rule($input-state-style-map, default, "padding");
34
+
35
+ .#{$element}#{$name}-input {
36
+ @include cxe-field-input(
37
+ $besm,
38
+ $input-state-style-map,
39
+ $placeholder: $placeholder,
40
+ $overrides: (
41
+ default: (
42
+ padding: cx-top($padding) cx-calc(cx-top($padding), $cx-default-clear-size, $cx-default-clear-spacing)
43
+ cx-bottom($padding)
44
+ cx-calc(cx-top($padding), $cx-default-input-left-tool-size, $cx-default-input-left-tool-spacing),
45
+ )
46
+ )
47
+ );
48
+ }
49
+
50
+ .#{$element}#{$name}-clear {
51
+ @include cxe-field-button($besm, $clear-state-style-map);
52
+
53
+ .#{$state}focus > & {
54
+ @include cx-add-state-rules($clear-state-style-map, focus);
55
+ }
56
+ .#{$state}error > & {
57
+ @include cx-add-state-rules($clear-state-style-map, error);
58
+ }
59
+ }
60
+
61
+ .#{$element}#{$name}-left-icon {
62
+ @include cxe-field-button(
63
+ $besm,
64
+ cx-deep-map-merge(
65
+ $left-icon-state-style-map,
66
+ (
67
+ default: (
68
+ cursor: pointer,
69
+ ),
70
+ )
71
+ )
72
+ );
73
+
74
+ .#{$state}disabled > & {
75
+ @include cx-add-state-rules($input-state-style-map, disabled);
76
+ border-width: 0;
77
+ }
78
+ .#{$state}focus > & {
79
+ @include cx-add-state-rules($left-icon-state-style-map, focus);
80
+ }
81
+ .#{$state}error > & {
82
+ @include cx-add-state-rules($left-icon-state-style-map, error);
83
+ }
84
+ }
85
+
86
+ .#{$element}#{$name}-right-icon {
87
+ @include cxe-field-button($besm, $right-icon-state-style-map);
88
+ .#{$state}disabled > & {
89
+ @include cx-add-state-rules($input-state-style-map, disabled);
90
+ border-width: 0;
91
+ }
92
+ .#{$state}focus > & {
93
+ @include cx-add-state-rules($right-icon-state-style-map, focus);
94
+ }
95
+ .#{$state}error > & {
96
+ @include cx-add-state-rules($right-icon-state-style-map, error);
97
+ }
98
+ }
99
+
100
+ .#{$element}#{$name}-icon {
101
+ @include cxe-field-button-icon($besm, $icon-size);
102
+ }
103
+
104
+ .#{$element}#{$name}-empty-text {
105
+ @include cxe-field-empty-text($empty-text);
106
+ }
107
+ }
108
+
109
+ @if (cx-should-include("cx/widgets/DateTimeField")) {
110
+ @include cx-datetimefield();
111
+ }