solid-ui 3.0.5-test.7 → 3.0.5

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/dist/solid-ui.js CHANGED
@@ -4913,6 +4913,8 @@ function basicField(dom, container, already, subject, form, doc, callbackFunctio
4913
4913
  field.style = inputStyle;
4914
4914
  rhs.appendChild(field);
4915
4915
  field.setAttribute('type', params.type ? params.type : 'text');
4916
+ var fieldType = (field.getAttribute('type') || '').toLowerCase();
4917
+ var deferWhileFocused = fieldType === 'date' || fieldType === 'datetime-local';
4916
4918
  var size = kb.anyJS(form, src_ns.ui('size')) || styleConstants.textInputSize || 20;
4917
4919
  field.setAttribute('size', size);
4918
4920
  var maxLength = kb.any(form, src_ns.ui('maxLength'));
@@ -4951,9 +4953,18 @@ function basicField(dom, container, already, subject, form, doc, callbackFunctio
4951
4953
  }
4952
4954
  }, true);
4953
4955
  field.addEventListener('change', function (_e) {
4956
+ if (deferWhileFocused && dom.activeElement === field) {
4957
+ if (field.dataset) {
4958
+ field.dataset.deferredChange = 'true';
4959
+ }
4960
+ return;
4961
+ }
4954
4962
  // i.e. lose focus with changed data
4955
4963
  if (params.pattern && !field.value.match(params.pattern)) return;
4956
- field.disabled = true; // See if this stops getting two dates from fumbling e.g the chrome datepicker.
4964
+ var disabledForSave = !deferWhileFocused;
4965
+ if (disabledForSave) {
4966
+ field.disabled = true; // See if this stops getting two dates from fumbling, e.g., the chrome datepicker.
4967
+ }
4957
4968
  field.setAttribute('style', inputStyle + 'color: gray;'); // pending
4958
4969
  var ds = kb.statementsMatching(subject, property); // remove any multiple values
4959
4970
  var result;
@@ -5021,7 +5032,9 @@ function basicField(dom, container, already, subject, form, doc, callbackFunctio
5021
5032
  updateMany(ds, is, function (uri, ok, body) {
5022
5033
  // kb.updater.update(ds, is, function (uri, ok, body) {
5023
5034
  if (ok) {
5024
- field.disabled = false;
5035
+ if (disabledForSave) {
5036
+ field.disabled = false;
5037
+ }
5025
5038
  field.setAttribute('style', inputStyle);
5026
5039
  } else {
5027
5040
  box.appendChild(errorMessageBlock(dom, body));
@@ -5029,6 +5042,15 @@ function basicField(dom, container, already, subject, form, doc, callbackFunctio
5029
5042
  callbackFunction(ok, body);
5030
5043
  });
5031
5044
  }, true);
5045
+ field.addEventListener('blur', function (_e) {
5046
+ if (deferWhileFocused && field.dataset && field.dataset.deferredChange === 'true') {
5047
+ delete field.dataset.deferredChange;
5048
+ var event = new Event('change', {
5049
+ bubbles: true
5050
+ });
5051
+ field.dispatchEvent(event);
5052
+ }
5053
+ }, true);
5032
5054
  return box;
5033
5055
  }
5034
5056
  ;// ./src/widgets/forms/autocomplete/language.ts
@@ -11478,6 +11500,8 @@ var AccessGroups = /*#__PURE__*/function () {
11478
11500
  thing,
11479
11501
  _this$_store,
11480
11502
  message,
11503
+ detectedTypes,
11504
+ typeDetails,
11481
11505
  error,
11482
11506
  _args4 = arguments,
11483
11507
  _t2;
@@ -11511,7 +11535,9 @@ var AccessGroups = /*#__PURE__*/function () {
11511
11535
  _context4.next = 6;
11512
11536
  break;
11513
11537
  }
11514
- error = " Error: Drop fails to drop appropriate thing! ".concat(uri);
11538
+ detectedTypes = Object.keys(this.store.findTypeURIs(thing));
11539
+ typeDetails = detectedTypes.length > 0 ? "Detected RDF types: ".concat(detectedTypes.join(', ')) : 'No RDF type was detected for this URI.';
11540
+ error = "Error: Failed to add access target: ".concat(uri, " is not a recognized ACL target type.") + " Expected one of: vcard:WebID, vcard:Group, foaf:Person, foaf:Agent, solid:AppProvider, solid:AppProviderClass, or recognized ACL classes." + ' Hint: try dropping a WebID profile URI, a vcard:Group URI, or a web app origin.' + typeDetails;
11515
11541
  src_debug/* error */.z3(error);
11516
11542
  return _context4.abrupt("return", Promise.reject(new Error(error)));
11517
11543
  case 6:
@@ -19018,8 +19044,8 @@ function notepad(dom, padDoc, subject, me, options) {
19018
19044
  }
19019
19045
  }
19020
19046
  /* @@ TODO want to look into this, it seems upstream should be a boolean and default to false ?
19021
- *
19022
- */
19047
+ *
19048
+ */
19023
19049
  var complain = function complain(message) {
19024
19050
  var upstream = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19025
19051
  (0,src_debug/* log */.Rm)(message);
@@ -19031,6 +19057,7 @@ function notepad(dom, padDoc, subject, me, options) {
19031
19057
  // @@ TODO need to refactor so that we don't have to type cast
19032
19058
  var clearStatus = function clearStatus(_upsteam) {
19033
19059
  if (options.statusArea) {
19060
+ ;
19034
19061
  options.statusArea.innerHTML = '';
19035
19062
  }
19036
19063
  };
@@ -19062,7 +19089,7 @@ function notepad(dom, padDoc, subject, me, options) {
19062
19089
  var next = kb.any(chunk, PAD('next'));
19063
19090
  if (prev.sameTerm(subject) && next.sameTerm(subject)) {
19064
19091
  // Last one
19065
- (0,src_debug/* log */.Rm)('You can\'t delete the only line.');
19092
+ (0,src_debug/* log */.Rm)("You can't delete the only line.");
19066
19093
  return;
19067
19094
  }
19068
19095
  var del = kb.statementsMatching(chunk, undefined, undefined, padDoc).concat(kb.statementsMatching(undefined, undefined, chunk, padDoc));
@@ -19104,10 +19131,10 @@ function notepad(dom, padDoc, subject, me, options) {
19104
19131
  }, 1000);
19105
19132
  } else {
19106
19133
  (0,src_debug/* log */.Rm)(' removePart FAILED ' + chunk + ': ' + errorMessage);
19107
- (0,src_debug/* log */.Rm)(' removePart was deleteing :\'' + del);
19134
+ (0,src_debug/* log */.Rm)(" removePart was deleting :'" + del);
19108
19135
  setPartStyle(part, 'color: black; background-color: #fdd;'); // failed
19109
19136
  var res = response ? response.status : ' [no response field] ';
19110
- complain('Error ' + res + ' saving changes: ' + errorMessage["true"]); // upstream,
19137
+ complain('Error ' + res + ' saving changes: ' + String(errorMessage)); // upstream,
19111
19138
  // updater.requestDownstreamAction(padDoc, reloadAndSync);
19112
19139
  }
19113
19140
  });
@@ -19124,7 +19151,7 @@ function notepad(dom, padDoc, subject, me, options) {
19124
19151
  }
19125
19152
  updater.update(del, ins, function (uri, ok, errorBody) {
19126
19153
  if (!ok) {
19127
- (0,src_debug/* log */.Rm)('Indent change FAILED \'' + newIndent + '\' for ' + padDoc + ': ' + errorBody);
19154
+ (0,src_debug/* log */.Rm)("Indent change FAILED '" + newIndent + "' for " + padDoc + ': ' + errorBody);
19128
19155
  setPartStyle(part, 'color: black; background-color: #fdd;'); // failed
19129
19156
  updater.requestDownstreamAction(padDoc, reloadAndSync);
19130
19157
  } else {
@@ -19133,6 +19160,7 @@ function notepad(dom, padDoc, subject, me, options) {
19133
19160
  });
19134
19161
  };
19135
19162
  var addListeners = function addListeners(part, chunk) {
19163
+ var inputDebounceTimer = null;
19136
19164
  part.addEventListener('keydown', function (event) {
19137
19165
  if (!updater) {
19138
19166
  throw new Error('no updater');
@@ -19141,8 +19169,8 @@ function notepad(dom, padDoc, subject, me, options) {
19141
19169
  // up 38; down 40; left 37; right 39 tab 9; shift 16; escape 27
19142
19170
  switch (event.keyCode) {
19143
19171
  case 13:
19144
- // Return
19145
19172
  {
19173
+ // Return
19146
19174
  var before = event.shiftKey;
19147
19175
  (0,src_debug/* log */.Rm)('enter'); // Shift-return inserts before -- only way to add to top of pad.
19148
19176
  if (before) {
@@ -19189,8 +19217,8 @@ function notepad(dom, padDoc, subject, me, options) {
19189
19217
  }
19190
19218
  break;
19191
19219
  case 9:
19192
- // Tab
19193
19220
  {
19221
+ // Tab
19194
19222
  var delta = event.shiftKey ? -1 : 1;
19195
19223
  changeIndent(part, chunk, delta);
19196
19224
  event.preventDefault(); // default is to highlight next field
@@ -19233,7 +19261,8 @@ function notepad(dom, padDoc, subject, me, options) {
19233
19261
  // DEBUGGING ONLY
19234
19262
  if (part.lastSent) {
19235
19263
  if (old !== part.lastSent) {
19236
- throw new Error('Out of order, last sent expected \'' + old + '\' but found \'' + part.lastSent + '\'');
19264
+ // Non-fatal: log a warning instead of throwing, to avoid crashing the pad UI.
19265
+ console.warn("Out of order, last sent expected '" + old + "' but found '" + part.lastSent + "'");
19237
19266
  }
19238
19267
  }
19239
19268
  part.lastSent = newOne;
@@ -19253,7 +19282,7 @@ function notepad(dom, padDoc, subject, me, options) {
19253
19282
  updater.update(del, ins, function (uri, ok, errorBody, xhr) {
19254
19283
  if (!ok) {
19255
19284
  // alert("clash " + errorBody);
19256
- (0,src_debug/* log */.Rm)(' patch FAILED ' + xhr.status + ' for \'' + old + '\' -> \'' + newOne + '\': ' + errorBody);
19285
+ (0,src_debug/* log */.Rm)(' patch FAILED ' + xhr.status + " for '" + old + "' -> '" + newOne + "': " + errorBody);
19257
19286
  if (xhr.status === 409) {
19258
19287
  // Conflict - @@ we assume someone else
19259
19288
  setPartStyle(part, 'color: black; background-color: #fdd;');
@@ -19264,15 +19293,28 @@ function notepad(dom, padDoc, subject, me, options) {
19264
19293
  }, 1000);
19265
19294
  } else {
19266
19295
  setPartStyle(part, 'color: black; background-color: #fdd;'); // failed pink
19267
- part.state = 0;
19268
- complain(' Error ' + xhr.status + ' sending data: ' + errorBody, true);
19269
- beep(1.0, 128); // Other
19270
- // @@@ Do soemthing more serious with other errors eg auth, etc
19296
+ var status = xhr === null || xhr === void 0 ? void 0 : xhr.status;
19297
+ if (!status || status === 502 || status === 503) {
19298
+ // Transient server error – retry after a short delay
19299
+ part.lastSent = undefined;
19300
+ part.state = 0;
19301
+ setTimeout(function () {
19302
+ if (part.state === 0 || part.state === undefined) {
19303
+ part.state = 1;
19304
+ _updateStore(part);
19305
+ }
19306
+ }, 2000);
19307
+ } else {
19308
+ part.state = 0;
19309
+ complain(' Error ' + status + ' sending data: ' + errorBody, true);
19310
+ beep(1.0, 128); // Other
19311
+ // @@@ Do something more serious with other errors eg auth, etc
19312
+ }
19271
19313
  }
19272
19314
  } else {
19273
19315
  clearStatus(true); // upstream
19274
19316
  setPartStyle(part); // synced
19275
- (0,src_debug/* log */.Rm)(' Patch ok \'' + old + '\' -> \'' + newOne + '\' ');
19317
+ (0,src_debug/* log */.Rm)(" Patch ok '" + old + "' -> '" + newOne + "' ");
19276
19318
  if (part.state === 4) {
19277
19319
  // delete me
19278
19320
  part.state = 3;
@@ -19292,7 +19334,7 @@ function notepad(dom, padDoc, subject, me, options) {
19292
19334
  part.addEventListener('input', function inputChangeListener(_event) {
19293
19335
  // debug.log("input changed "+part.value);
19294
19336
  setPartStyle(part, undefined, true); // grey out - not synced
19295
- (0,src_debug/* log */.Rm)('Input event state ' + part.state + ' value \'' + part.value + '\'');
19337
+ (0,src_debug/* log */.Rm)('Input event state ' + part.state + " value '" + part.value + "'");
19296
19338
  switch (part.state) {
19297
19339
  case 3:
19298
19340
  // being deleted
@@ -19308,8 +19350,15 @@ function notepad(dom, padDoc, subject, me, options) {
19308
19350
  return;
19309
19351
  case 0:
19310
19352
  case undefined:
19311
- part.state = 1; // being upadted
19312
- _updateStore(part);
19353
+ // Debounce: wait for a pause in typing before sending PATCH
19354
+ if (inputDebounceTimer !== null) clearTimeout(inputDebounceTimer);
19355
+ inputDebounceTimer = setTimeout(function () {
19356
+ inputDebounceTimer = null;
19357
+ if (part.state === 0 || part.state === undefined) {
19358
+ part.state = 1; // being updated
19359
+ _updateStore(part);
19360
+ }
19361
+ }, 400);
19313
19362
  }
19314
19363
  }); // listener
19315
19364
  }; // addlisteners
@@ -19339,13 +19388,13 @@ function notepad(dom, padDoc, subject, me, options) {
19339
19388
  addListeners(part, chunk);
19340
19389
  } else {
19341
19390
  setPartStyle(part, 'color: #222; background-color: #fff');
19342
- (0,src_debug/* log */.Rm)('Note can\'t add listeners - not logged in');
19391
+ (0,src_debug/* log */.Rm)("Note can't add listeners - not logged in");
19343
19392
  }
19344
19393
  return part;
19345
19394
  };
19346
19395
 
19347
19396
  /* @@ TODO we need to look at indent, it can be a Number or an Object this doesn't seem correct.
19348
- */
19397
+ */
19349
19398
  var _newChunk = function newChunk(ele, before) {
19350
19399
  // element of chunk being split
19351
19400
  var kb = pad_store;
@@ -19470,6 +19519,7 @@ function notepad(dom, padDoc, subject, me, options) {
19470
19519
  var msg = 'Pad: Inconsistent data - NEXT pointers: ' + kb.each(subject, PAD('next')).length;
19471
19520
  (0,src_debug/* log */.Rm)(msg);
19472
19521
  if (options.statusArea) {
19522
+ ;
19473
19523
  options.statusArea.textContent += msg;
19474
19524
  }
19475
19525
  return;