saasufy-components 5.6.0 → 5.8.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/input-provider.js CHANGED
@@ -134,13 +134,18 @@ class InputProvider extends HTMLElement {
134
134
  this.inputElement = document.createElement(elementType);
135
135
  if (type === 'select') {
136
136
  if (options) {
137
- let optionElements = options
138
- .split(',')
139
- .map((option) => {
140
- if (option === placeholder) {
141
- return `<option value="" selected class="select-default-option">${option}</option>`;
137
+ let {
138
+ fieldNames: optionNames,
139
+ fieldValues: optionValues
140
+ } = convertStringToFieldParams(options);
141
+
142
+ let optionElements = optionNames
143
+ .map((optionName) => {
144
+ let optionValue = optionValues[optionName] || optionName;
145
+ if (optionName === placeholder) {
146
+ return `<option value="" selected class="select-default-option">${optionName}</option>`;
142
147
  }
143
- return `<option value="${option}">${option}</option>`;
148
+ return `<option value="${optionValue}">${optionName}</option>`;
144
149
  })
145
150
  .join('');
146
151
  this.inputElement.innerHTML = optionElements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "5.6.0",
3
+ "version": "5.8.0",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/utils.js CHANGED
@@ -205,6 +205,16 @@ export function computeId(...parts) {
205
205
  return `${idHex.slice(0, 8)}-${idHex.slice(8, 12)}-${third}-${fourth}-${idHex.slice(20, 32)}`;
206
206
  }
207
207
 
208
+ export function toDate(timestamp) {
209
+ let date = new Date(timestamp);
210
+ let year = date.getFullYear();
211
+ let month = date.toLocaleString('default', { month: 'long' });
212
+ let day = date.getDate();
213
+ let hour = date.getHours();
214
+ let minutes = date.getMinutes();
215
+ return `${month} ${day}, ${year} at ${hour}:${minutes.toString().padStart(2, '0')}`;
216
+ }
217
+
208
218
  let templateFormatters = {
209
219
  url: (value) => String(value).toLowerCase().replace(/ /g, '-'),
210
220
  lowerCase: (value) => String(value).toLowerCase(),
@@ -217,15 +227,7 @@ let templateFormatters = {
217
227
  fallback: (...args) => {
218
228
  return args.filter(arg => arg)[0];
219
229
  },
220
- date: (timestamp) => {
221
- let date = new Date(timestamp);
222
- let year = date.getFullYear();
223
- let month = date.toLocaleString('default', { month: 'long' });
224
- let day = date.getDate();
225
- let hour = date.getHours();
226
- let minutes = date.getMinutes();
227
- return `${month} ${day}, ${year} at ${hour}:${minutes.toString().padStart(2, '0')}`;
228
- },
230
+ date: (timestamp) => toDate(timestamp),
229
231
  joinFields: (list, field, sep) => {
230
232
  return list.map(item => item[field]).join(sep);
231
233
  },