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.
@@ -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(config = {}) {
6
+ export default function Progress(props = {}) {
6
7
  if (!(this instanceof Progress)) {
7
- return new Progress(config);
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
- ...config
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
- const value = this.$description.value;
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(type = 'rect', config = {}) {
4
+ export default function Skeleton(props = {}) {
3
5
  if (!(this instanceof Skeleton)) {
4
- return new Skeleton(config);
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
- ...config
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);
@@ -0,0 +1,5 @@
1
+ import Spacer from './spacer';
2
+
3
+ export {
4
+ Spacer,
5
+ }
@@ -1,12 +1,14 @@
1
+ import BaseComponent from "../BaseComponent";
2
+ import DebugManager from "../../core/utils/debug-manager";
1
3
 
2
- export default function Spinner(config = {}) {
4
+ export default function Spinner(props = {}) {
3
5
  if (!(this instanceof Spinner)) {
4
- return new Spinner(config);
6
+ return new Spinner(props);
5
7
  }
6
8
 
7
9
  this.$description = {
8
10
  type: 'circle',
9
- variant: null,
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: null,
19
- ...config
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
- Spinner.prototype.hide = function() {};
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
- Spinner.prototype.$build = function() {};
160
- Spinner.prototype.toNdElement = function() {};
173
+ Spinner.prototype.hide = function() {
174
+ this.$description.loading?.set(false);
175
+ };