saasufy-components 3.16.1 → 3.17.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
@@ -289,7 +289,7 @@ A form component for inserting data into collections.
289
289
  **Attributes**
290
290
 
291
291
  - `collection-type` (required): Specifies the type of collection to add the resource to when the form is submitted. This should match a `Model` available in your Saasufy service.
292
- - `collection-fields`: A comma-separated list of fields from the `Model` to display as input elements inside the form for the user to fill in. Each field name in this list can optionally be followed by an input element type after a `:` character. For example `collection-fields="qty:number, size:select(small,medium,large)` will create one input element with `type="number"` and one with `type=select` with options `small`, `medium` or `large`. To make a select field optional, you can prefix the list of options with a comma; e.g. `size:select(,small,medium,large)`.
292
+ - `collection-fields`: A comma-separated list of fields from the `Model` to display as input elements inside the form for the user to fill in. Each field name in this list can optionally be followed by an input element type after a `:` character. For example `collection-fields="qty:number, size:select(small,medium,large)` will create one input element with `type="number"` and one with `type=select` with options `small`, `medium` or `large`. To make a select field optional, you can prefix the list of options with a comma; e.g. `size:select(,small,medium,large)`. Supported input types include: `text`, `select`, `number`, `checkbox`, `radio`, `textarea`, `file` and `text-select`.
293
293
  - `model-values`: An optional list of key-value pairs in the format `field1=value1,field2=value2` to add to the newly created resource alongside the values collected from the user via the form. For non-string values, the type should be provided in the format `fieldName:type=value`; supported types are `string`, `number` and `boolean`. Unlike `collection-fields` which are rendered as input elements in the form, `model-values` are not shown to the user.
294
294
  - `submit-button-label`: Text to display on the submit button. If not specified, defaults to `Submit`.
295
295
  - `hide-submit-button`: Adding this attribute will hide the submit button from the form.
@@ -447,7 +447,7 @@ Used for displaying and editing a single field of a model instance in real time.
447
447
  - `list`: If specified, this sets the list attribute of the inner `input` element to provide input suggestions (only works with standard input elements).
448
448
  - `type`: The type of the input component; can be `text`, `number`, `select`, `textarea`, `checkbox` or `file`.
449
449
  - `placeholder`: Can be used to set the placeholder text on the inner input element.
450
- - `consumers`: This allows you to connect this `model-input` 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 `model-input` 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.
450
+ - `consumers`: This allows you to connect this `model-input` 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 `model-input` 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.
451
451
  - `provider-template`: A template string within which the `{{value}}` can be injected before passing to consumers.
452
452
  - `show-error-message`: If this attribute is present, an error message will be displayed above the input if it fails to update the value.
453
453
  - `options`: A comma-separated list of options to provide - This only works if the input type is `select`.
@@ -556,7 +556,7 @@ This component can be configured to provide its data to multiple components (con
556
556
  - `list`: If specified, this sets the list attribute of the inner `input` element to provide input suggestions (only works with standard input elements).
557
557
  - `type`: The type of the input component; can be `text`, `number`, `select`, `textarea` or `checkbox`.
558
558
  - `placeholder`: Can be used to set the placeholder text on the inner input element.
559
- - `consumers`: This allows you to connect this `input-provider` 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.
559
+ - `consumers`: This allows you to connect this `input-provider` 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.
560
560
  - `provider-template`: A template string within which the `{{value}}` can be injected before passing to consumers.
561
561
  - `debounce-delay`: The delay in milliseconds to wait before triggering a change event. This is useful to batch multiple updates together (as is common when user is typing). Default is 800ms.
562
562
  - `options`: A comma-separated list of options to provide - This only works if the input type is `select`.
@@ -616,7 +616,7 @@ The `combineFilters` function produces a combined query string (joined with `%AN
616
616
 
617
617
  **Attributes**
618
618
 
619
- - `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. 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.
619
+ - `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.
620
620
  - `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.
621
621
  - `debounce-delay`: The delay in milliseconds to wait before triggering a change event. This is useful to batch multiple updates together. Default is 0ms.
622
622
 
@@ -656,7 +656,7 @@ The following example shows how to bind an `input-provider` component to an `inp
656
656
 
657
657
  **Attributes**
658
658
 
659
- - `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.
659
+ - `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 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.
660
660
  - `provider-template`: A template string within which the `{{value}}` can be injected before passing to consumers.
661
661
  - `debounce-delay`: The delay in milliseconds to wait before triggering a change event. This is useful to batch multiple updates together. Default is 0ms.
662
662
 
package/model-input.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SocketConsumer } from './socket.js';
2
- import { debouncer, updateConsumerElements } from './utils.js';
2
+ import { debouncer, updateConsumerElements, convertStringToFieldParams } from './utils.js';
3
3
  import AGModel from '/node_modules/ag-model/ag-model.js';
4
4
 
5
5
  class ModelInput extends SocketConsumer {
@@ -21,7 +21,6 @@ class ModelInput extends SocketConsumer {
21
21
 
22
22
  static get observedAttributes() {
23
23
  return [
24
- 'input-id',
25
24
  'list',
26
25
  'socket-instance-property',
27
26
  'type',
@@ -40,7 +39,9 @@ class ModelInput extends SocketConsumer {
40
39
  'value',
41
40
  'hide-error-logs',
42
41
  'autocapitalize',
43
- 'autocorrect'
42
+ 'autocorrect',
43
+ 'input-id',
44
+ 'input-props'
44
45
  ];
45
46
  }
46
47
 
@@ -112,6 +113,7 @@ class ModelInput extends SocketConsumer {
112
113
  let height = this.getAttribute('height');
113
114
  let hideErrorLogs = this.hasAttribute('hide-error-logs');
114
115
  let enableRebound = this.hasAttribute('enable-rebound');
116
+ let inputProps = this.getAttribute('input-props');
115
117
  let hasConsumers = this.hasAttribute('consumers');
116
118
  let writeOnly = type === 'file' && !hasConsumers;
117
119
 
@@ -188,7 +190,7 @@ class ModelInput extends SocketConsumer {
188
190
  }
189
191
  } else if (elementType === 'input') {
190
192
  if (inputList) {
191
- this.inputElement.setAttribute('list', inputList)
193
+ this.inputElement.setAttribute('list', inputList);
192
194
  }
193
195
  this.inputElement.type = type;
194
196
  }
@@ -210,6 +212,15 @@ class ModelInput extends SocketConsumer {
210
212
  if (accept) {
211
213
  this.inputElement.setAttribute('accept', accept);
212
214
  }
215
+ if (inputProps) {
216
+ let {
217
+ fieldNames: attrNames,
218
+ fieldValues: attrValues
219
+ } = convertStringToFieldParams(inputProps);
220
+ for (let attr of attrNames) {
221
+ this.inputElement.setAttribute(attr, attrValues[attr]);
222
+ }
223
+ }
213
224
  let errorMessageContainer = null;
214
225
  if (showErrorMessage) {
215
226
  errorMessageContainer = document.createElement('div');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "3.16.1",
3
+ "version": "3.17.0",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {