@startinblox/core 0.18.2 → 0.18.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.
@@ -60,8 +60,10 @@ export const SolidFormSearch = {
60
60
  const name = (widget.component || widget).name;
61
61
  if (name == null) return;
62
62
  let value = widget.component ? widget.component.getValue() : widget.value;
63
+ let keep = value;
63
64
  try {
64
65
  value = JSON.parse(value);
66
+ if (!value && keep === '""') value = keep;
65
67
  } catch {}
66
68
  // Add another filter value in the values array
67
69
  value = {
@@ -67,8 +67,8 @@ const orThrow = (throwOn, ret) => {
67
67
  */
68
68
  const matchValue = async (val, query, throwOn) => {
69
69
  const subject = await val;
70
- if (subject == null && query.value === '' && query.type !== 'string') return orThrow(throwOn, true); // filter not set and subject not existing -> ignore filter only if type is not string
71
- if (subject == null) return orThrow(throwOn, false); // return false; // property does not exist on resource
70
+ if (subject == null && query.value === "" && query.type !== 'string') return orThrow(throwOn, true);
71
+ if (subject == null && query.value !== "" && query.type !== 'string') return orThrow(throwOn, false); // return false;
72
72
  if (query.list) {
73
73
  // Filter on a container
74
74
  if (query.value.length === 0) return orThrow(throwOn, true);
@@ -84,7 +84,7 @@ const matchValue = async (val, query, throwOn) => {
84
84
  }
85
85
  return orThrow(throwOn, false);
86
86
  }
87
- if (subject.isContainer?.()) {
87
+ if (subject && subject.isContainer?.()) {
88
88
  let ret = Promise.resolve(query.value === ''); // if no query, return a match
89
89
  for (const value of subject['ldp:contains']) {
90
90
  ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result
@@ -140,6 +140,7 @@ const matchFilter = async (resource, filter, query, fieldsAttr, searchForm, filt
140
140
  await Promise.all((fields || []).map(field => matchFilter(resource, field, query, fieldsAttr, searchForm, filterId, true // stop searching when 1 filter is true (= OR)
141
141
  )));
142
142
  } catch (e) {
143
+ // console.log("Exception raised when subject is null", query, e);
143
144
  return true;
144
145
  }
145
146
  throw false;
@@ -161,6 +162,7 @@ const matchFilters = async (resource, filters, filterNames, fields, searchForm,
161
162
  await Promise.all(filterNames.map(filter => matchFilter(resource, filter, filters[filter], fields, searchForm, filterId, false // stop searching when 1 filter is false (= AND)
162
163
  )));
163
164
  } catch (e) {
165
+ // console.log("Exception raised when subject is null", e, filters);
164
166
  return false;
165
167
  }
166
168
  return true;
@@ -137,10 +137,10 @@ function fuzzyCompare(subject, search) {
137
137
  const compare = {
138
138
  string(subject, query) {
139
139
  // Exact match on empty string between query and subject
140
- if (query === '' && subject.toString() === '') return false;
140
+ if (query === '""' && (subject === null || !subject)) return true;
141
141
  // Else if query is empty and subject is something else, return true
142
142
  else if (query === '') return true;
143
- if (subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;
143
+ if (subject && subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;
144
144
  return fuzzyCompare(subject, query);
145
145
  },
146
146
  boolean(subject, query) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.18.2",
3
+ "version": "0.18.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",