native-document 1.0.129 → 1.0.131
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/components.js +2 -1
- package/dist/native-document.components.min.js +922 -549
- package/dist/native-document.dev.js +11 -0
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/components/$traits/HasItems.js +0 -39
- package/src/components/BaseComponent.js +1 -1
- package/src/components/avatar/Avatar.js +26 -24
- package/src/components/avatar/AvatarGroup.js +39 -0
- package/src/components/avatar/index.js +3 -1
- package/src/components/badge/Badge.js +44 -24
- package/src/components/button/Button.js +29 -31
- package/src/components/divider/Divider.js +21 -6
- package/src/components/layouts/HStack.js +27 -0
- package/src/components/layouts/Stack.js +75 -0
- package/src/components/layouts/VStack.js +26 -0
- package/src/components/layouts/ZStack.js +36 -0
- package/src/components/layouts/index.js +19 -0
- package/src/components/menu/Menu.js +51 -5
- package/src/components/menu/MenuDivider.js +6 -7
- package/src/components/menu/MenuGroup.js +4 -4
- package/src/components/menu/MenuItem.js +3 -3
- package/src/components/menu/MenuLink.js +3 -3
- package/src/components/menu/index.js +3 -1
- package/src/components/progress/Progress.js +33 -10
- package/src/components/skeleton/Skeleton.js +45 -6
- package/src/components/spacer/Spacer.js +13 -0
- package/src/components/spacer/index.js +5 -0
- package/src/components/spinner/Spinner.js +31 -16
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import BaseComponent from "../BaseComponent";
|
|
2
2
|
import EventEmitter from "../../../src/core/utils/EventEmitter";
|
|
3
3
|
import {Validator} from "../../../index";
|
|
4
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
4
5
|
|
|
5
|
-
export default function Progress(
|
|
6
|
+
export default function Progress(props = {}) {
|
|
6
7
|
if (!(this instanceof Progress)) {
|
|
7
|
-
return new Progress(
|
|
8
|
+
return new Progress(props);
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
BaseComponent.call(this, props);
|
|
12
|
+
|
|
10
13
|
this.$description = {
|
|
11
14
|
value: null,
|
|
12
15
|
type: null,
|
|
@@ -22,7 +25,8 @@ export default function Progress(config = {}) {
|
|
|
22
25
|
striped: null,
|
|
23
26
|
animated: null,
|
|
24
27
|
render: null,
|
|
25
|
-
|
|
28
|
+
borderRadiusType: null,
|
|
29
|
+
props
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -30,13 +34,32 @@ BaseComponent.extends(Progress, EventEmitter);
|
|
|
30
34
|
|
|
31
35
|
Progress.defaultTemplate = null;
|
|
32
36
|
|
|
33
|
-
Progress.use = function(template) {
|
|
37
|
+
Progress.use = function(template) {
|
|
38
|
+
Progress.defaultTemplate = template.progress;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
Progress.preset = function(name, callback) {
|
|
42
|
+
if (Progress.prototype[name] || Progress[name]) {
|
|
43
|
+
DebugManager.warn(`Warning: the ${name} method already exists in Progress.`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
Progress[name] = (props) => callback(new Progress(props));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Progress.presets = function(presets) {
|
|
50
|
+
for (const name in presets) {
|
|
51
|
+
Progress.preset(name, presets[name]);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
34
55
|
|
|
35
56
|
Progress.prototype.model = function(observable) {
|
|
36
57
|
this.$description.value = observable;
|
|
37
58
|
return this;
|
|
38
59
|
};
|
|
39
60
|
|
|
61
|
+
Progress.prototype.bind = Progress.prototype.model;
|
|
62
|
+
|
|
40
63
|
Progress.prototype.setCurrentStep = function(step) {
|
|
41
64
|
this.$description.value?.set(step);
|
|
42
65
|
this.emit('change', step);
|
|
@@ -51,12 +74,7 @@ Progress.prototype.value = function() {
|
|
|
51
74
|
};
|
|
52
75
|
|
|
53
76
|
Progress.prototype.setValue = function(newValue) {
|
|
54
|
-
|
|
55
|
-
if(Validator.isObservable(value)) {
|
|
56
|
-
value.set(newValue);
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
this.$description.value = newValue;
|
|
77
|
+
this.setCurrentStep(newValue);
|
|
60
78
|
return this;
|
|
61
79
|
};
|
|
62
80
|
|
|
@@ -82,6 +100,11 @@ Progress.prototype.line = function() {
|
|
|
82
100
|
return this.type('line');
|
|
83
101
|
};
|
|
84
102
|
|
|
103
|
+
Progress.prototype.pill = function() {
|
|
104
|
+
this.$description.borderRadiusType = 'pill';
|
|
105
|
+
return this;
|
|
106
|
+
};
|
|
107
|
+
|
|
85
108
|
// Variant
|
|
86
109
|
Progress.prototype.variant = function(name) {
|
|
87
110
|
this.$description.variant = name;
|
|
@@ -1,22 +1,47 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
1
3
|
|
|
2
|
-
export default function Skeleton(
|
|
4
|
+
export default function Skeleton(props = {}) {
|
|
3
5
|
if (!(this instanceof Skeleton)) {
|
|
4
|
-
return new Skeleton(
|
|
6
|
+
return new Skeleton(props);
|
|
5
7
|
}
|
|
8
|
+
|
|
9
|
+
BaseComponent.call(this, props);
|
|
10
|
+
|
|
6
11
|
this.$description = {
|
|
7
|
-
type,
|
|
12
|
+
type: 'rect',
|
|
13
|
+
variant: 'pulse',
|
|
14
|
+
borderRadiusType: 'rounded',
|
|
8
15
|
lines: null,
|
|
9
16
|
width: null,
|
|
10
17
|
height: null,
|
|
11
18
|
loading: null,
|
|
12
19
|
repeat: null,
|
|
13
|
-
|
|
20
|
+
props
|
|
14
21
|
};
|
|
15
22
|
}
|
|
16
23
|
|
|
24
|
+
BaseComponent.extends(Skeleton);
|
|
25
|
+
|
|
17
26
|
Skeleton.defaultTemplate = null;
|
|
18
27
|
|
|
19
|
-
Skeleton.use = function(template) {
|
|
28
|
+
Skeleton.use = function(template) {
|
|
29
|
+
Skeleton.defaultTemplate = template.skeleton;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
Skeleton.preset = function(name, callback) {
|
|
33
|
+
if (Skeleton.prototype[name] || Skeleton[name]) {
|
|
34
|
+
DebugManager.warn(`Warning: the ${name} method already exists in Skeleton.`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
Skeleton[name] = (props) => callback(new Skeleton(props));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Skeleton.presets = function(presets) {
|
|
41
|
+
for (const name in presets) {
|
|
42
|
+
Skeleton.preset(name, presets[name]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
20
45
|
|
|
21
46
|
Skeleton.prototype.type = function(type) {
|
|
22
47
|
this.$description.type = type;
|
|
@@ -39,6 +64,21 @@ Skeleton.prototype.image = function() {
|
|
|
39
64
|
return this.type('image');
|
|
40
65
|
};
|
|
41
66
|
|
|
67
|
+
Skeleton.prototype.rounded = function() {
|
|
68
|
+
this.$description.borderRadiusType = 'rounded';
|
|
69
|
+
return this;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
Skeleton.prototype.pill = function() {
|
|
73
|
+
this.$description.borderRadiusType = 'pill';
|
|
74
|
+
return this;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Skeleton.prototype.smooth = function() {
|
|
78
|
+
this.$description.borderRadiusType = 'smooth';
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
81
|
+
|
|
42
82
|
Skeleton.prototype.width = function(width) {
|
|
43
83
|
this.$description.width = width;
|
|
44
84
|
return this;
|
|
@@ -63,7 +103,6 @@ Skeleton.prototype.wave = function() {
|
|
|
63
103
|
Skeleton.prototype.pulse = function() {
|
|
64
104
|
return this.variant('pulse');
|
|
65
105
|
};
|
|
66
|
-
Skeleton.prototype.rounded = function() {};
|
|
67
106
|
|
|
68
107
|
Skeleton.prototype.loading = function(isLoading) {
|
|
69
108
|
this.$description.loading = isLoading;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
|
|
3
|
+
export function Spacer(props = {}) {
|
|
4
|
+
if (!(this instanceof Spacer)) {
|
|
5
|
+
return new Spacer(props);
|
|
6
|
+
}
|
|
7
|
+
BaseComponent.call(this, props);
|
|
8
|
+
this.$description = {
|
|
9
|
+
type: 'spacer',
|
|
10
|
+
props
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
BaseComponent.extends(Spacer);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import BaseComponent from "../BaseComponent";
|
|
2
|
+
import DebugManager from "../../core/utils/debug-manager";
|
|
1
3
|
|
|
2
|
-
export default function Spinner(
|
|
4
|
+
export default function Spinner(props = {}) {
|
|
3
5
|
if (!(this instanceof Spinner)) {
|
|
4
|
-
return new Spinner(
|
|
6
|
+
return new Spinner(props);
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
this.$description = {
|
|
8
10
|
type: 'circle',
|
|
9
|
-
variant:
|
|
11
|
+
variant: 'primary',
|
|
10
12
|
color: null,
|
|
11
13
|
size: 'small',
|
|
12
14
|
label: null,
|
|
@@ -15,13 +17,29 @@ export default function Spinner(config = {}) {
|
|
|
15
17
|
backdrop: null,
|
|
16
18
|
render: null,
|
|
17
19
|
loading: null,
|
|
18
|
-
speed:
|
|
19
|
-
|
|
20
|
+
speed: 'normal',
|
|
21
|
+
props
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
Spinner.use = function(template) {};
|
|
24
25
|
Spinner.defaultTemplate = null;
|
|
26
|
+
Spinner.use = function(template) {
|
|
27
|
+
Spinner.defaultTemplate = template.spinner;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Spinner.preset = function(name, callback) {
|
|
31
|
+
if (Spinner.prototype[name] || Spinner[name]) {
|
|
32
|
+
DebugManager.warn(`Warning: the ${name} method already exists in Spinner.`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
Spinner[name] = (props) => callback(new Spinner(props));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Spinner.presets = function(presets) {
|
|
39
|
+
for (const name in presets) {
|
|
40
|
+
Spinner.preset(name, presets[name]);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
25
43
|
|
|
26
44
|
Spinner.prototype.type = function(type) {
|
|
27
45
|
this.$description.type = type;
|
|
@@ -144,17 +162,14 @@ Spinner.prototype.fast = function() {
|
|
|
144
162
|
return this.speed('fast');
|
|
145
163
|
};
|
|
146
164
|
Spinner.prototype.loading = function(isLoading) {
|
|
147
|
-
this.$description.loading = isLoading;
|
|
165
|
+
this.$description.loading = BaseComponent.obs(isLoading);
|
|
148
166
|
return this;
|
|
149
167
|
};
|
|
168
|
+
Spinner.prototype.bind = Spinner.prototype.loading;
|
|
150
169
|
|
|
151
|
-
Spinner.prototype.show = function() {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Spinner.prototype.render = function(renderFn) {
|
|
155
|
-
this.$description.render = renderFn;
|
|
156
|
-
return this;
|
|
170
|
+
Spinner.prototype.show = function() {
|
|
171
|
+
this.$description.loading?.set(true);
|
|
157
172
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
173
|
+
Spinner.prototype.hide = function() {
|
|
174
|
+
this.$description.loading?.set(false);
|
|
175
|
+
};
|