saasufy-components 9.6.0 → 10.0.0

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 CHANGED
@@ -345,7 +345,7 @@ A Saasufy component which integrates with data from Saasufy is known as a `socke
345
345
  - `url` (required): Specifies the URL for the Saasufy service to use as the data store for all components which are placed inside it.
346
346
  - `auth-token-name`: Allows you to specify a custom key for your token - This will be used as the key in localStorage. You generally do not need to set this attribute. It is intended for situations were an app has multiple `socket-provider` elements connecting different services with different/separate authentication flows.
347
347
  - `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.
348
- - `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.
348
+ - `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. Nested properties can be set like this: `autoReconnectOptions.initialDelay:number=2000,autoReconnectOptions.randomness:number=1000,autoReconnectOptions.multiplier:number=1.5,autoReconnectOptions.maxDelay:number=20000`.
349
349
  - `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.
350
350
  - `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.
351
351
 
@@ -541,6 +541,7 @@ OR (with confirmation step)
541
541
  - `model-id` (required): Specifies the ID of the resource to delete from the parent collection when this component is activated. This can be achieved by invoking either the `deleteItem()` or `confirmDeleteItem()` function from inside an event handler. The example above shows how to achieve deletion via the `onclick` event. You can either invoke `deleteItem()` to delete the resource immediately or you can invoke `confirmDeleteItem()` to require additional confirmation prior to deletion.
542
542
  - `onclick` (required): The logic to execute to delete the item. Should be either `deleteItem()` or `confirmDeleteItem()`.
543
543
  - `confirm-message`: The confirmation message to show the user when this component's `confirmDeleteItem()` function is invoked.
544
+ - `confirm-heading`: The heading to show in the confirmation modal's title bar when this component's `confirmDeleteItem()` function is invoked.
544
545
  - `model-field`: If specified, this attribute can be used to delete a single field of a model instance, instead of the whole instance.
545
546
 
546
547
  If `confirmDeleteItem()` is used, then the parent `collection-viewer` must have a `confirm-modal` element slotted into it as shown here:
@@ -563,7 +564,7 @@ If `confirmDeleteItem()` is used, then the parent `collection-viewer` must have
563
564
  <div slot="viewport" class="chat-viewport"></div>
564
565
 
565
566
  <!-- The confirm-modal element must be specified here with slot="modal" to prompt the user for confirmation -->
566
- <confirm-modal slot="modal" title="Delete confirmation" message="" confirm-button-label="Delete"></confirm-modal>
567
+ <confirm-modal slot="modal" heading="Delete confirmation" message="" confirm-button-label="Delete"></confirm-modal>
567
568
  </collection-viewer>
568
569
  ```
569
570
 
@@ -1173,16 +1174,17 @@ A modal component to prompt the user for confirmation before performing sensitiv
1173
1174
  <div slot="viewport"></div>
1174
1175
 
1175
1176
  <!-- The confirm-modal element must be specified here with slot="modal" to prompt the user for confirmation -->
1176
- <confirm-modal slot="modal" title="Delete confirmation" message="" confirm-button-label="Delete"></confirm-modal>
1177
+ <confirm-modal slot="modal" heading="Delete confirmation" message="" confirm-button-label="Delete"></confirm-modal>
1177
1178
  </collection-viewer>
1178
1179
  ```
1179
1180
 
1180
1181
  **Attributes**
1181
1182
 
1182
- - `title`: The text to show in the modal's title bar.
1183
+ - `heading`: The text to show in the modal's title bar.
1183
1184
  - `message`: The text to show as the modal's main content.
1184
1185
  - `confirm-button-label`: The text to use as the confirm button label.
1185
1186
  - `cancel-button-label`: The text to use as the cancel button label.
1187
+ - `auto-focus`: Which button to focus when the modal is shown; either `confirm` (or its alias `delete`) or `cancel`. If not specified, no button will be focused.
1186
1188
 
1187
1189
  ### overlay-modal
1188
1190
 
@@ -27,14 +27,14 @@ class CollectionDeleter extends HTMLElement {
27
27
 
28
28
  showConfirmModal(deleteField) {
29
29
  let message = this.getAttribute('confirm-message');
30
- let title = this.getAttribute('confirm-title');
30
+ let heading = this.getAttribute('confirm-heading');
31
31
  let confirmButtonLabel = this.getAttribute('confirm-button-label');
32
32
  let cancelButtonLabel = this.getAttribute('cancel-button-label');
33
33
  this.dispatchEvent(
34
34
  new CustomEvent('showModal', {
35
35
  detail: {
36
36
  message,
37
- title,
37
+ heading,
38
38
  confirmButtonLabel,
39
39
  cancelButtonLabel,
40
40
  callback: () => {
package/confirm-modal.js CHANGED
@@ -3,7 +3,7 @@ import './overlay-modal.js';
3
3
  class ConfirmModal extends HTMLElement {
4
4
  constructor() {
5
5
  super();
6
- this.hidden = true;
6
+ this.isHidden = true;
7
7
  this.isReady = false;
8
8
  }
9
9
 
@@ -13,7 +13,7 @@ class ConfirmModal extends HTMLElement {
13
13
  }
14
14
 
15
15
  static get observedAttributes() {
16
- return [ 'message', 'title', 'confirm-button-label', 'cancel-button-label' ];
16
+ return [ 'message', 'heading', 'confirm-button-label', 'cancel-button-label' ];
17
17
  }
18
18
 
19
19
  attributeChangedCallback(name, oldValue, newValue) {
@@ -27,12 +27,12 @@ class ConfirmModal extends HTMLElement {
27
27
  overlayModal.removeAttribute('style');
28
28
  }
29
29
  this.confirmCallback = confirmCallback;
30
- this.hidden = false;
30
+ this.isHidden = false;
31
31
  if (typeof options === 'string') {
32
32
  this.setAttribute('message', options);
33
33
  } else {
34
- if (options.title != null) {
35
- this.setAttribute('title', options.title);
34
+ if (options.heading != null) {
35
+ this.setAttribute('heading', options.heading);
36
36
  }
37
37
  if (options.confirmButtonLabel != null) {
38
38
  this.setAttribute('confirm-button-label', options.confirmButtonLabel);
@@ -44,17 +44,30 @@ class ConfirmModal extends HTMLElement {
44
44
  this.setAttribute('message', options.message);
45
45
  }
46
46
  }
47
+ this.applyAutoFocus();
48
+ }
49
+
50
+ applyAutoFocus() {
51
+ let autoFocus = this.getAttribute('auto-focus');
52
+ let selector;
53
+ if (autoFocus === 'confirm' || autoFocus === 'delete') {
54
+ selector = '.modal-confirm-button';
55
+ } else if (autoFocus === 'cancel') {
56
+ selector = '.modal-cancel-button';
57
+ }
58
+ if (!selector) return;
59
+ this.querySelector(selector)?.focus({ preventScroll: true });
47
60
  }
48
61
 
49
62
  render() {
50
63
  let message = this.getAttribute('message') || '';
51
- let title = this.getAttribute('title') || '';
64
+ let heading = this.getAttribute('heading') || '';
52
65
  let confirmButtonLabel = this.getAttribute('confirm-button-label') || 'Confirm';
53
66
  let cancelButtonLabel = this.getAttribute('cancel-button-label') || 'Cancel';
54
67
 
55
68
  this.innerHTML = `
56
- <overlay-modal${this.hidden ? ' style="display: none;"' : ''}>
57
- <div slot="title">${title}</div>
69
+ <overlay-modal${this.isHidden ? ' style="display: none;"' : ''}>
70
+ <div slot="title">${heading}</div>
58
71
  <div class="confirm-modal-content" slot="content">
59
72
  <div>${message}</div>
60
73
  <div class="confirm-modal-buttons-container">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "9.6.0",
3
+ "version": "10.0.0",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {