@startinblox/core 0.19.15-beta.1 → 0.19.15-beta.3

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.
Files changed (2) hide show
  1. package/dist/index.js +38 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51073,8 +51073,12 @@ const WidgetMixin = {
51073
51073
  return [];
51074
51074
  let fields = [];
51075
51075
  for (const prop2 of resource.properties) {
51076
- if (!prop2.startsWith("@") && !(prop2 === "permissions") && await resource[prop2])
51077
- fields.push(prop2);
51076
+ if (!prop2.startsWith("@") && !(prop2 === "permissions")) {
51077
+ if (!this.isAlias(prop2) && await resource[prop2])
51078
+ fields.push(prop2);
51079
+ else if (this.isAlias(prop2))
51080
+ fields.push(prop2);
51081
+ }
51078
51082
  }
51079
51083
  return fields;
51080
51084
  },
@@ -51123,9 +51127,21 @@ const WidgetMixin = {
51123
51127
  let foundSets = this.fields.match(this.getSetRegexp(field));
51124
51128
  return foundSets ? foundSets.length > 0 : false;
51125
51129
  },
51130
+ /**
51131
+ * Return true if "field" is a string
51132
+ * @param field - string
51133
+ */
51126
51134
  isString(field) {
51127
51135
  return field.startsWith("'") || field.startsWith('"');
51128
51136
  },
51137
+ /**
51138
+ * Return true if "field" is an alias (contains " as ")
51139
+ * @param field - string
51140
+ */
51141
+ isAlias(field) {
51142
+ const aliasRegex = /^[\w@.]+\s+as\s+[\w@.]+$/;
51143
+ return aliasRegex.test(field);
51144
+ },
51129
51145
  /**
51130
51146
  * Return the value of "resource" for predicate "field"
51131
51147
  * @param field - string
@@ -51161,6 +51177,10 @@ const WidgetMixin = {
51161
51177
  if (this.element.hasAttribute("value-" + field)) {
51162
51178
  return this.element.getAttribute("value-" + field);
51163
51179
  }
51180
+ if (this.isAlias(field)) {
51181
+ const alias = field.split(" as ");
51182
+ return await this.fetchValue(alias[0], resource);
51183
+ }
51164
51184
  let resourceValue = await this.fetchValue(field, resource);
51165
51185
  if (resourceValue === void 0 || resourceValue === "" || resourceValue === null)
51166
51186
  return this.element.hasAttribute("default-" + field) ? this.element.getAttribute("default-" + field) : "";
@@ -51188,6 +51208,8 @@ const WidgetMixin = {
51188
51208
  * @param isSet - boolean
51189
51209
  */
51190
51210
  getWidget(field, isSet2 = false) {
51211
+ if (this.isAlias(field))
51212
+ field = field.split(" as ")[1];
51191
51213
  const widget = this.element.getAttribute("widget-" + field);
51192
51214
  if (widget)
51193
51215
  return this.widgetFromTagName(widget);
@@ -51225,6 +51247,8 @@ const WidgetMixin = {
51225
51247
  */
51226
51248
  widgetAttributes(field, resource) {
51227
51249
  const attrs2 = { name: field };
51250
+ if (this.isAlias(field))
51251
+ field = field.split(" as ")[1];
51228
51252
  const escapedField = this.getEscapedField(field);
51229
51253
  const multipleAttributes = [
51230
51254
  "fields",
@@ -51316,8 +51340,18 @@ const WidgetMixin = {
51316
51340
  }
51317
51341
  if (value === null || value === void 0)
51318
51342
  attributes.value = "";
51319
- if (widgetMeta.type === WidgetType.USER && value["@id"]) {
51320
- attributes["data-src"] = value["@id"];
51343
+ if (widgetMeta.type === WidgetType.USER) {
51344
+ if (value["@id"]) {
51345
+ attributes["data-src"] = value["@id"];
51346
+ } else {
51347
+ try {
51348
+ let isUrl = new URL(value);
51349
+ if (isUrl)
51350
+ attributes["data-src"] = value;
51351
+ } catch (e) {
51352
+ }
51353
+ attributes["value"] = value;
51354
+ }
51321
51355
  } else {
51322
51356
  attributes["value"] = value;
51323
51357
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.19.15-beta.1",
3
+ "version": "0.19.15-beta.3",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",