saasufy-components 3.15.1 → 3.16.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 +44 -1
- package/collection-browser.js +7 -1
- package/input-transformer.js +48 -0
- package/overlay-modal.js +1 -0
- package/package.json +1 -1
- package/styles.css +13 -0
- package/utils.js +2 -0
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ Components for Saasufy
|
|
|
19
19
|
### User input
|
|
20
20
|
- [input-provider](#input-provider)
|
|
21
21
|
- [input-combiner](#input-combiner)
|
|
22
|
+
- [input-transformer](#input-transformer)
|
|
22
23
|
|
|
23
24
|
### Authentication
|
|
24
25
|
- [log-in-form](#log-in-form)
|
|
@@ -67,6 +68,7 @@ To use components, you just need to include them into your `.html` file inside y
|
|
|
67
68
|
<script src="https://saasufy.com/node_modules/saasufy-components/model-viewer.js" type="module" defer></script>
|
|
68
69
|
<script src="https://saasufy.com/node_modules/saasufy-components/input-provider.js" type="module" defer></script>
|
|
69
70
|
<script src="https://saasufy.com/node_modules/saasufy-components/input-combiner.js" type="module" defer></script>
|
|
71
|
+
<script src="https://saasufy.com/node_modules/saasufy-components/input-transformer.js" type="module" defer></script>
|
|
70
72
|
<script src="https://saasufy.com/node_modules/saasufy-components/log-in-form.js" type="module" defer></script>
|
|
71
73
|
<script src="https://saasufy.com/node_modules/saasufy-components/log-out.js" type="module" defer></script>
|
|
72
74
|
<script src="https://saasufy.com/node_modules/saasufy-components/oauth-link.js" type="module" defer></script>
|
|
@@ -315,7 +317,8 @@ OR (with confirmation step)
|
|
|
315
317
|
**Attributes**
|
|
316
318
|
|
|
317
319
|
- `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.
|
|
318
|
-
- `
|
|
320
|
+
- `onclick` (required): The logic to execute to delete the item. Should be either `deleteItem()` or `confirmDeleteItem()`.
|
|
321
|
+
- `confirm-message`: The confirmation message to show the user when this component's `confirmDeleteItem()` function is invoked.
|
|
319
322
|
|
|
320
323
|
If `confirmDeleteItem()` is used, then the parent `collection-browser` must have a `confirm-modal` element slotted into it as shown here:
|
|
321
324
|
|
|
@@ -608,6 +611,46 @@ The `combineFilters` function produces a combined query string (joined with `%AN
|
|
|
608
611
|
- `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.
|
|
609
612
|
- `debounce-delay`: The delay in milliseconds to wait before triggering a change event. This is useful to batch multiple updates together. Default is 0ms.
|
|
610
613
|
|
|
614
|
+
### input-transformer
|
|
615
|
+
|
|
616
|
+
A component which can be used to transform data from an `input-provider` component and pass the transformed data to other components (or HTML elements) via custom attributes.
|
|
617
|
+
This component can be configured to provide its data to multiple components (consumers) via custom attributes.
|
|
618
|
+
|
|
619
|
+
**Import**
|
|
620
|
+
|
|
621
|
+
```html
|
|
622
|
+
<script src="https://saasufy.com/node_modules/saasufy-components/input-transformer.js" type="module" defer></script>
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
**Example usage**
|
|
626
|
+
|
|
627
|
+
The following example shows how to bind an `input-provider` component to an `input-transformer`.
|
|
628
|
+
|
|
629
|
+
```html
|
|
630
|
+
<input-provider
|
|
631
|
+
class="dollar-input"
|
|
632
|
+
name="count"
|
|
633
|
+
type="text"
|
|
634
|
+
consumers=".cents-transformer"
|
|
635
|
+
value=""
|
|
636
|
+
placeholder="Dollars"
|
|
637
|
+
></input-provider>
|
|
638
|
+
|
|
639
|
+
<input-transformer
|
|
640
|
+
class="cents-transformer"
|
|
641
|
+
consumers=".cents-container"
|
|
642
|
+
provider-template="{{Number(value) * 100}}"
|
|
643
|
+
></input-transformer>
|
|
644
|
+
|
|
645
|
+
<div class="cents-container"></div>
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
**Attributes**
|
|
649
|
+
|
|
650
|
+
- `consumers`: This allows you to connect this `input-transformer` to other elements on your page. It takes a list of selectors with optional attributes to target. 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.
|
|
651
|
+
- `provider-template`: A template string within which the `{{value}}` can be injected before passing to consumers.
|
|
652
|
+
- `debounce-delay`: The delay in milliseconds to wait before triggering a change event. This is useful to batch multiple updates together. Default is 0ms.
|
|
653
|
+
|
|
611
654
|
### log-in-form
|
|
612
655
|
|
|
613
656
|
A form component which allows end-users to authenticate themselves into your app using the Saasufy blockchain or any Capitalisk-based blockchain.
|
package/collection-browser.js
CHANGED
|
@@ -139,8 +139,14 @@ class CollectionBrowser extends SocketConsumer {
|
|
|
139
139
|
let currentPageElements = this.shadowRoot.querySelector('slot[name="page-number"]').assignedElements();
|
|
140
140
|
let pageNumber = Math.floor(this.collection.meta.pageOffset / this.collection.meta.pageSize + 1);
|
|
141
141
|
for (let element of currentPageElements) {
|
|
142
|
-
if (element.nodeName === 'INPUT') {
|
|
142
|
+
if (element.nodeName === 'INPUT' || element.nodeName === 'MODEL-INPUT') {
|
|
143
143
|
element.value = pageNumber;
|
|
144
|
+
} else if (
|
|
145
|
+
element.nodeName === 'INPUT-PROVIDER' ||
|
|
146
|
+
element.nodeName === 'INPUT-COMBINER' ||
|
|
147
|
+
element.nodeName === 'INPUT-TRANSFORMER'
|
|
148
|
+
) {
|
|
149
|
+
element.setAttribute('value', pageNumber);
|
|
144
150
|
} else {
|
|
145
151
|
element.innerHTML = pageNumber;
|
|
146
152
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { debouncer, updateConsumerElements } from './utils.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_DEBOUNCE_DELAY = 0;
|
|
4
|
+
|
|
5
|
+
class InputTransformer extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.isReady = false;
|
|
9
|
+
this.debounce = debouncer();
|
|
10
|
+
}
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
this.isReady = true;
|
|
13
|
+
this.render();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static get observedAttributes() {
|
|
17
|
+
return [
|
|
18
|
+
'consumers',
|
|
19
|
+
'debounce-delay',
|
|
20
|
+
'provider-template',
|
|
21
|
+
'value'
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
26
|
+
this.render();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
if (!this.hasAttribute('value')) return;
|
|
31
|
+
|
|
32
|
+
let value = this.getAttribute('value') || '';
|
|
33
|
+
let debounceDelay = this.getAttribute('debounce-delay');
|
|
34
|
+
debounceDelay = debounceDelay ? Number(debounceDelay) : DEFAULT_DEBOUNCE_DELAY;
|
|
35
|
+
|
|
36
|
+
if (!this.isReady) return;
|
|
37
|
+
|
|
38
|
+
let consumers = this.getAttribute('consumers');
|
|
39
|
+
if (!consumers) return;
|
|
40
|
+
|
|
41
|
+
this.debounce(async () => {
|
|
42
|
+
let providerTemplate = this.getAttribute('provider-template') || '{{value}}';
|
|
43
|
+
updateConsumerElements(consumers, value, providerTemplate);
|
|
44
|
+
}, debounceDelay);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
window.customElements.define('input-transformer', InputTransformer);
|
package/overlay-modal.js
CHANGED
package/package.json
CHANGED
package/styles.css
CHANGED
|
@@ -178,6 +178,19 @@ collection-browser > [slot=next-page] {
|
|
|
178
178
|
width: auto;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
.confirm-modal-content {
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
align-items: center;
|
|
185
|
+
gap: 20px;
|
|
186
|
+
padding: 20px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.confirm-modal-buttons-container {
|
|
190
|
+
display: flex;
|
|
191
|
+
gap: 5px;
|
|
192
|
+
}
|
|
193
|
+
|
|
181
194
|
.container-vertical {
|
|
182
195
|
display: flex;
|
|
183
196
|
flex-direction: column;
|
package/utils.js
CHANGED
|
@@ -320,6 +320,8 @@ export function updateConsumerElements(consumers, value, template, sourceElement
|
|
|
320
320
|
}
|
|
321
321
|
} else if (element.nodeName === 'MODEL-INPUT') {
|
|
322
322
|
element.value = value;
|
|
323
|
+
} else if (element.nodeName === 'INPUT-TRANSFORMER') {
|
|
324
|
+
element.setAttribute('value', value);
|
|
323
325
|
} else if (element.nodeName === 'INPUT-COMBINER') {
|
|
324
326
|
element.setAttribute(
|
|
325
327
|
'value',
|