native-document 1.0.246 → 1.0.248

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.246",
3
+ "version": "1.0.248",
4
4
  "description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
5
5
  "author": "AfroCodeur <https://github.com/afrocodeur>",
6
6
  "license": "MIT",
@@ -0,0 +1,60 @@
1
+ import { $ } from '../../../../core/data/Observable';
2
+ import Field from '../Field';
3
+
4
+
5
+ export default function AddressSearchField(name, props = {}) {
6
+ if(!(this instanceof AddressSearchField)) {
7
+ return new AddressSearchField(name, props);
8
+ }
9
+
10
+ Field.call(this, name, 'input', props);
11
+
12
+ Object.assign(this.$description, {
13
+ renderSuggestion: null
14
+ });
15
+
16
+ }
17
+
18
+ AddressSearchField.defaultTemplate = null;
19
+
20
+ AddressSearchField.prototype = Object.create(Field.prototype);
21
+ AddressSearchField.prototype.constructor = AddressSearchField;
22
+
23
+ /**
24
+ * Registers the render template for AddressSearchField.
25
+ * @param {(description: {
26
+ * value: Observable<string>,
27
+ * placeholder: string|null,
28
+ * debounceMs: number,
29
+ * disabled: Observable<boolean>|null,
30
+ * loading: Observable<boolean>|null,
31
+ * props: GlobalAttributes,
32
+ * }, instance: AddressSearchField) => NdChild} template
33
+ */
34
+ AddressSearchField.use = function(template) {
35
+ AddressSearchField.defaultTemplate = template;
36
+ };
37
+
38
+
39
+ /**
40
+ * @param {Observable} $loading
41
+ * @return {this}
42
+ */
43
+ AddressSearchField.prototype.loading = function($loading){
44
+ this.$description.loading = $loading;
45
+ return this;
46
+ };
47
+
48
+ /**
49
+ * @param {(sugesstion: *) => {}} callback
50
+ * @return {AddressSearchField}
51
+ */
52
+ AddressSearchField.prototype.onSuggestions = function(callback){
53
+ this.$description.callback = callback;
54
+ return this;
55
+ };
56
+
57
+ AddressSearchField.prototype.renderSuggestion = function(renderFn){
58
+ this.$description.renderSuggestion = renderFn;
59
+ return this;
60
+ };
@@ -63,4 +63,13 @@ SearchField.prototype.constructor = SearchField;
63
63
  SearchField.prototype.debounce = function(ms) {
64
64
  this.$description.debounce = ms;
65
65
  return this;
66
- };
66
+ };
67
+
68
+ /**
69
+ * @param {Observable} $loading
70
+ * @return {this}
71
+ */
72
+ SearchField.prototype.loading = function($loading){
73
+ this.$description.loading = $loading;
74
+ return this;
75
+ };
@@ -50,6 +50,7 @@ export default function ListGroup(label, props = {}) {
50
50
  selectByClick: $(false),
51
51
  loopOnKeyboard: $(false),
52
52
  hideIfEmpty: null,
53
+ showTitleWhen: null,
53
54
  props,
54
55
  };
55
56
  }
@@ -134,10 +135,19 @@ ListGroup.prototype.data = function(data) {
134
135
  this.$description.data = data;
135
136
  return this;
136
137
  };
138
+
137
139
  /**
138
140
  * @return {this}
139
141
  */
140
142
  ListGroup.prototype.hideIfEmpty = function() {
141
143
  this.$description.hideIfEmpty = true;
142
144
  return this;
145
+ };
146
+
147
+ /**
148
+ * @param {Observable} $observable
149
+ */
150
+ ListGroup.prototype.showTitleWhen = function($observable) {
151
+ this.$description.showTitleWhen = $observable;
152
+ return this;
143
153
  };
@@ -51,6 +51,7 @@ export interface ListGroupInterface {
51
51
  on(event: string, handler: (...args: unknown[]) => void): this;
52
52
  emit(event: string, ...args: unknown[]): void;
53
53
  hasListeners(event: string): boolean;
54
+ showTitleWhen(observable: ObservableItem<boolean>): boolean;
54
55
  }
55
56
 
56
57
  export declare function ListGroup(label: ValidChild, props?: GlobalAttributes): ListGroupInterface;
@@ -0,0 +1,15 @@
1
+ import BaseComponent from '../../BaseComponent';
2
+
3
+
4
+ export default function AddressMapPicker() {
5
+ if(!(this instanceof AddressMapPicker)) {
6
+ return new AddressMapPicker();
7
+ }
8
+
9
+ this.$description = {
10
+
11
+ };
12
+
13
+ };
14
+
15
+ BaseComponent.extends(AddressMapPicker);
@@ -646,6 +646,28 @@ ObservableItem.prototype.clone = function() {
646
646
  return new ObservableItem(clonedValue);
647
647
  };
648
648
 
649
+ /**
650
+ * @param {ObservableItem} targetObservable
651
+ * @return {(function())|*}
652
+ */
653
+ ObservableItem.prototype.sync = function(targetObservable) {
654
+ if(this === targetObservable) {
655
+ return () => {};
656
+ }
657
+
658
+ const updateTargetObservable = (newValue) => targetObservable.set(newValue);
659
+ const updateCurrentObservable = (newValue) => this.set(newValue);
660
+
661
+ this.subscribe(updateTargetObservable);
662
+ targetObservable.subscribe(updateCurrentObservable);
663
+
664
+
665
+ return () => {
666
+ this.unsubscribe(updateTargetObservable);
667
+ targetObservable.unsubscribe(updateCurrentObservable);
668
+ };
669
+ };
670
+
649
671
 
650
672
  ObservableItem.prototype.fnSet = function(value) {
651
673
  return () => this.set(value);
@@ -46,7 +46,7 @@ function buildContent($desc) {
46
46
  const content = [];
47
47
 
48
48
  if($desc.loading) {
49
- content.push(ShowIf($desc.loading, Spinner({ class: 'btn-spinner' })));
49
+ content.push(ShowIf($desc.loading, Spinner({ class: 'btn-spinner' }).size($desc.size)));
50
50
  }
51
51
 
52
52
  if($desc.icon && isIconBefore($desc.iconPosition)) {
@@ -272,9 +272,12 @@
272
272
  &.is-large { width: var(--btn-height-large); }
273
273
  }
274
274
  }
275
- .btn.is-loading:not(.is-outline) .spinner,
276
- .btn.is-loading:not(.is-ghost) .spinner {
277
- --spinner-color: white !important;
275
+ .btn.is-loading .spinner{
276
+ --spinner-color: white;
277
+ }
278
+ .btn.is-loading.is-outline .spinner,
279
+ .btn.is-loading.is-ghost .spinner {
280
+ --spinner-color: var(--gray-lite-2);
278
281
  }
279
282
 
280
283
  .btn-icon {
@@ -63,5 +63,9 @@ function buildGroupHeader($desc, instance) {
63
63
  header.nd.onStopClick(() => $desc.collapsed.toggle());
64
64
  }
65
65
 
66
+ if($desc.showTitleWhen) {
67
+ return ShowIf($desc.showTitleWhen, header);
68
+ }
69
+
66
70
  return header;
67
71
  }
@@ -57,6 +57,6 @@
57
57
 
58
58
  .list-group-items {
59
59
  .list-item {
60
- padding-left: calc(var(--list-group-items-indent) + 14px);
60
+ padding-left: calc(var(--list-group-items-indent) + 5px);
61
61
  }
62
62
  }
@@ -1,9 +1,9 @@
1
1
  :root {
2
2
  --spinner-size-extra-small: 16px;
3
- --spinner-size-small: 24px;
4
- --spinner-size-medium: 36px;
5
- --spinner-size-large: 48px;
6
- --spinner-size-extra-large: 64px;
3
+ --spinner-size-small: 20px;
4
+ --spinner-size-medium: 32px;
5
+ --spinner-size-large: 45px;
6
+ --spinner-size-extra-large: 60px;
7
7
 
8
8
  --spinner-speed-slow: 1.2s;
9
9
  --spinner-speed-normal: 0.8s;