saasufy-components 5.1.1 → 5.2.1
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/README.md +10 -1
- package/app-router.js +2 -0
- package/collection-adder-form.js +2 -0
- package/collection-reducer.js +2 -0
- package/collection-viewer.js +2 -0
- package/conditional-group.js +3 -1
- package/if-group.js +3 -1
- package/input-combiner.js +3 -1
- package/input-provider.js +2 -0
- package/input-transformer.js +2 -0
- package/log-in-form.js +2 -0
- package/model-input.js +2 -0
- package/model-text.js +2 -0
- package/model-viewer.js +2 -0
- package/package.json +1 -1
- package/socket.js +2 -0
- package/switch-group.js +3 -1
package/README.md
CHANGED
|
@@ -219,6 +219,7 @@ So for example, if your `index.html` file is served up from the URL `http://mywe
|
|
|
219
219
|
- `debounce-delay`: The number of milliseconds to wait before changing the route. This can help to avoid multiple renders if the route changes rapidly (e.g. when doing hard redirects). Defaults to 100ms.
|
|
220
220
|
- `target-page`: A convenience attribute which can be used to programmatically change the `location.hash` in the address bar.
|
|
221
221
|
- `force-render-paths`: An optional list of comma-separated paths to force a page render/re-render, regardless of whether or not the page has changed.
|
|
222
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
222
223
|
|
|
223
224
|
**Attributes of slotted page templates**
|
|
224
225
|
|
|
@@ -255,6 +256,7 @@ A Saasufy component which integrates with data from Saasufy is known as a `socke
|
|
|
255
256
|
- `disable-tab-sync`: By default, the socket provider synchronizes socket auth state across multiple tabs via localStorage. If this attribute is set, then the socket auth state will not sync automatically and a manual page refresh may be necessary to update to the latest auth state.
|
|
256
257
|
- `socket-options`: Can be used to set options on the inner `socket`. Must be in the format `option1:type1=value1,option2:type2=value2`; the type of each option can be string, boolean or number. If not specified, the default type is string.
|
|
257
258
|
- `disconnect-on-deauth`: If this attribute is set, the underlying socket will be disconnected if the socket becomes unauthenticated. This means that components will not receive real-time updates until the user's next interaction (which will cause the socket to reconnect). If this attribute is not set, the socket will attempt to reconnect immediately after losing authentication.
|
|
259
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
258
260
|
|
|
259
261
|
### collection-viewer
|
|
260
262
|
|
|
@@ -321,6 +323,7 @@ In addition to the slots shown above, the `collection-viewer` also supports the
|
|
|
321
323
|
- `type-alias`: Allows you to provide an alternative name for your `Model` to use when injecting values inside the template. This is useful for situations where you may have multiple `collection-viewer` elements and/or `model-viewer` elements of the same type nested inside each other and want to avoid `Model` name clashes in the nested template definitions. For example, if the `type-alias` in the snippet above was set to `SubChat`, then `{{Chat.message}}` would become `{{SubChat.message}}`.
|
|
322
324
|
- `hide-error-logs`: A flag which, when present, suppresses error logs from being printed to the console.
|
|
323
325
|
- `max-show-loader`: If this attribute is present, your slotted `loader` element will be shown as often as possible; this includes situations where the collection is merely refreshing itself. It is disabled by default.
|
|
326
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
324
327
|
|
|
325
328
|
### collection-adder
|
|
326
329
|
|
|
@@ -392,6 +395,7 @@ This component is similar to the `collection-adder` component except that it req
|
|
|
392
395
|
- `success-message`: A message to show the user if the resource has been successfully added to the collection after submitting the form.
|
|
393
396
|
- `trim-spaces`: If this attribute exists on the element, then leading and trailing spaces will be trimmed from each input element's value before submitting the form.
|
|
394
397
|
- `auto-reset-hidden-inputs`: If this attribute exists, then `hidden` input elements which are inside the `collection-adder-form` will be cleared along with other input fields. By default, `hidden` input elements are not cleared when the form is reset.
|
|
398
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
395
399
|
|
|
396
400
|
**Attributes of slotted input, select, textarea... elements**
|
|
397
401
|
|
|
@@ -513,6 +517,7 @@ In the example above, the name of the first element can be accessed with `{{Cate
|
|
|
513
517
|
- `collection-get-count`: If this attribute is present, the component will get the record count of the target view. The count can be rendered into the template by prefixing the model name with a dollar sign and accessing the `count` property like this: `{{$MyModelName.count}}`.
|
|
514
518
|
- `type-alias`: Allows you to provide an alternative name for your `Model` to use when injecting values inside the template. This is useful for situations where you may have multiple `collection-viewer` elements and/or `model-viewer` elements of the same type nested inside each other and want to avoid `Model` name clashes in the nested template definitions. For example, if the `type-alias` in the snippet above was set to `SubChat`, then `{{Chat.message}}` would become `{{SubChat.message}}`.
|
|
515
519
|
- `hide-error-logs`: A flag which, when present, suppresses error logs from being printed to the console.
|
|
520
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
516
521
|
|
|
517
522
|
### model-input
|
|
518
523
|
|
|
@@ -563,6 +568,7 @@ Used for displaying and editing a single field of a model instance in real time.
|
|
|
563
568
|
- `input-id`: Can be used to set an `id` attribute on the inner `input` element.
|
|
564
569
|
- `input-props`: Can be used to set additional attributes on the inner `input` element. Must be in the format `attr1=value1,attr2=value2`.
|
|
565
570
|
- `ignore-invalid-selection`: Can be used with a `model-input` component of type `select` to prevent the `error` class from being added if the selected value is not among the available options.
|
|
571
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
566
572
|
|
|
567
573
|
### model-text
|
|
568
574
|
|
|
@@ -593,6 +599,7 @@ Used to displaying a field of a model instance in real time.
|
|
|
593
599
|
- `slice-to`: Optional attribute which can be set to a number to trim strings down to a maximum number of characters when reading. This is useful when dealing with potentially very long field values. Note that it may affect caching if the same field is being referenced in multiple parts of the application at the same time within the same `socket-provider`.
|
|
594
600
|
- `default-value`: A default value to show the user if the underlying model field's value is null or undefined.
|
|
595
601
|
- `hide-error-logs`: By default, this component will log errors to the console. If set, this attribute will suppress such errors from showing up on the console.
|
|
602
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
596
603
|
|
|
597
604
|
### model-viewer
|
|
598
605
|
|
|
@@ -632,6 +639,7 @@ Used for rendering a single model resource using a template. This is the single-
|
|
|
632
639
|
- `type-alias`: Allows you to provide an alternative name for your `Model` to use when injecting values inside the template. This is useful for situations where you may have multiple `model-viewer` elements and/or `model-viewer` elements of the same type nested inside each other and want to avoid `Model` name clashes in the nested template definitions. For example, if the `type-alias` in the snippet above was set to `MyProduct`, then `{{Product.name}}` would become `{{MyProduct.name}}`.
|
|
633
640
|
- `fields-slice-to`: Optional attribute which can be used to trim strings down to a maximum number of characters when reading. The format is `fieldName1=number1,fieldName2=number2`. This is useful when dealing with potentially very long field values. Note that it may affect caching if the same field is being referenced in multiple parts of the application at the same time within the same `socket-provider`.
|
|
634
641
|
- `hide-error-logs`: A flag which, when present, suppresses error logs from being printed to the console.
|
|
642
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
635
643
|
|
|
636
644
|
### input-provider
|
|
637
645
|
|
|
@@ -726,7 +734,7 @@ The `combineFilters` function produces a combined query string (joined with `%AN
|
|
|
726
734
|
|
|
727
735
|
- `consumers`: This allows you to connect this `input-combiner` to other elements on your page. It takes a list of selectors with optional attributes to target in the format `element-selector:attribute-name`. For example `.my-input:value` will find all elements with a `my-input` class and update their `value` attributes with the value of the `input-provider` component in real-time. You can specify multiple selectors separated by commas such as `.my-input,my-div`; in this case, because attribute names are not specified, values will be injected into the `value` attribute (for input elements) or into the `innerHTML` property (for other kinds of elements). The default attribute/property depends on the element type.
|
|
728
736
|
- `provider-template`: A template string within which the `{{value}}` can be injected before passing to consumers. In the case of the `input-combiner`, the value is an object wherein each key represents the unique label associated with different `input-provider` components.
|
|
729
|
-
- `debounce-delay`: The delay in milliseconds to wait before triggering a change event. This is useful to batch multiple updates together. Default is
|
|
737
|
+
- `debounce-delay`: The delay in milliseconds to wait before triggering a change event. This is useful to batch multiple updates together. Default is 500ms.
|
|
730
738
|
|
|
731
739
|
### input-transformer
|
|
732
740
|
|
|
@@ -804,6 +812,7 @@ The change in the location hash can then be detected by an `app-router` to switc
|
|
|
804
812
|
- `secure` (required): Should be `true` or `false` depending on whether or not the node is exposed over HTTP/WS or HTTPS/WSS.
|
|
805
813
|
- `auth-timeout`: The maximum number of milliseconds to wait for authentication to complete. Defaults to 10000 (10 seconds).
|
|
806
814
|
- `success-location-hash`: If authentication is successful, the browser's `location.hash` will be set to this value. It can be used to redirect the user to their dashboard, for example.
|
|
815
|
+
- `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
|
|
807
816
|
|
|
808
817
|
### log-out
|
|
809
818
|
|
package/app-router.js
CHANGED
|
@@ -65,6 +65,8 @@ export class AppRouter extends SocketConsumer {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
68
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
69
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
68
70
|
if (name === 'debounce-delay') {
|
|
69
71
|
if (newValue) {
|
|
70
72
|
this.debounceDelay = Number(newValue);
|
package/collection-adder-form.js
CHANGED
|
@@ -37,6 +37,8 @@ class CollectionAdderForm extends SocketConsumer {
|
|
|
37
37
|
|
|
38
38
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
39
39
|
if (!this.isReady) return;
|
|
40
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
41
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
40
42
|
this.render();
|
|
41
43
|
}
|
|
42
44
|
|
package/collection-reducer.js
CHANGED
|
@@ -83,6 +83,8 @@ class CollectionReducer extends SocketConsumer {
|
|
|
83
83
|
|
|
84
84
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
85
85
|
if (!this.isReady) return;
|
|
86
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
87
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
86
88
|
if (this.collection && name === 'collection-page-offset') {
|
|
87
89
|
let newOffset = Number(newValue);
|
|
88
90
|
if (newOffset !== this.collection.meta.pageOffset) {
|
package/collection-viewer.js
CHANGED
|
@@ -132,6 +132,8 @@ class CollectionViewer extends SocketConsumer {
|
|
|
132
132
|
|
|
133
133
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
134
134
|
if (!this.isReady) return;
|
|
135
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
136
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
135
137
|
if (name === 'collection-page-offset') {
|
|
136
138
|
if (this.collection) {
|
|
137
139
|
let newOffset = Number(newValue);
|
package/conditional-group.js
CHANGED
|
@@ -11,8 +11,10 @@ class ConditionalGroup extends HTMLElement {
|
|
|
11
11
|
];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
attributeChangedCallback() {
|
|
14
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
15
15
|
if (!this.isReady) return;
|
|
16
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
17
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
16
18
|
this.render();
|
|
17
19
|
}
|
|
18
20
|
|
package/if-group.js
CHANGED
|
@@ -45,8 +45,10 @@ class IfGroup extends HTMLElement {
|
|
|
45
45
|
];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
attributeChangedCallback() {
|
|
48
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
49
49
|
if (!this.isReady) return;
|
|
50
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
51
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
50
52
|
this.processTemplates();
|
|
51
53
|
}
|
|
52
54
|
|
package/input-combiner.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { debouncer, updateConsumerElements } from './utils.js';
|
|
2
2
|
|
|
3
|
-
const DEFAULT_DEBOUNCE_DELAY =
|
|
3
|
+
const DEFAULT_DEBOUNCE_DELAY = 500;
|
|
4
4
|
|
|
5
5
|
class InputCombiner extends HTMLElement {
|
|
6
6
|
constructor() {
|
|
@@ -24,6 +24,8 @@ class InputCombiner extends HTMLElement {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
27
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
28
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
27
29
|
this.render();
|
|
28
30
|
}
|
|
29
31
|
|
package/input-provider.js
CHANGED
|
@@ -42,6 +42,8 @@ class InputProvider extends HTMLElement {
|
|
|
42
42
|
|
|
43
43
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
44
44
|
if (!this.isReady) return;
|
|
45
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
46
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
45
47
|
if (name === 'value') {
|
|
46
48
|
this.value = newValue;
|
|
47
49
|
} else {
|
package/input-transformer.js
CHANGED
package/log-in-form.js
CHANGED
|
@@ -29,6 +29,8 @@ class LogInForm extends SocketConsumer {
|
|
|
29
29
|
|
|
30
30
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
31
31
|
if (!this.isReady) return;
|
|
32
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
33
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
32
34
|
this.render();
|
|
33
35
|
}
|
|
34
36
|
|
package/model-input.js
CHANGED
|
@@ -54,6 +54,8 @@ class ModelInput extends SocketConsumer {
|
|
|
54
54
|
|
|
55
55
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
56
56
|
if (!this.isReady) return;
|
|
57
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
58
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
57
59
|
if (name === 'value') {
|
|
58
60
|
this.value = newValue;
|
|
59
61
|
} else {
|
package/model-text.js
CHANGED
|
@@ -32,6 +32,8 @@ class ModelText extends SocketConsumer {
|
|
|
32
32
|
|
|
33
33
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
34
34
|
if (!this.isReady) return;
|
|
35
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
36
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
35
37
|
this.destroy();
|
|
36
38
|
this.render();
|
|
37
39
|
}
|
package/model-viewer.js
CHANGED
|
@@ -42,6 +42,8 @@ class ModelViewer extends SocketConsumer {
|
|
|
42
42
|
|
|
43
43
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
44
44
|
if (!this.isReady) return;
|
|
45
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
46
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
45
47
|
this.render();
|
|
46
48
|
}
|
|
47
49
|
|
package/package.json
CHANGED
package/socket.js
CHANGED
|
@@ -48,6 +48,8 @@ export class SocketProvider extends HTMLElement {
|
|
|
48
48
|
|
|
49
49
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
50
50
|
if (!this.isReady) return;
|
|
51
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
52
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
51
53
|
this.getSocket();
|
|
52
54
|
}
|
|
53
55
|
|
package/switch-group.js
CHANGED
|
@@ -58,8 +58,10 @@ class SwitchGroup extends HTMLElement {
|
|
|
58
58
|
];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
attributeChangedCallback() {
|
|
61
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
62
62
|
if (!this.isReady) return;
|
|
63
|
+
let greedyRefresh = this.hasAttribute('greedy-refresh');
|
|
64
|
+
if (!greedyRefresh && oldValue === newValue) return;
|
|
63
65
|
this.processTemplates();
|
|
64
66
|
}
|
|
65
67
|
|