wacom 20.0.3 → 20.0.6

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.
@@ -805,14 +805,47 @@ class CoreService {
805
805
  this.linkIds[name].push(...reset());
806
806
  });
807
807
  }
808
- // Angular Signals
808
+ // Angular Signals //
809
+ /**
810
+ * Converts a plain object into a signal-wrapped object.
811
+ * Optionally wraps specific fields of the object as individual signals,
812
+ * and merges them into the returned signal for fine-grained reactivity.
813
+ *
814
+ * @template Document - The type of the object being wrapped.
815
+ * @param {Document} document - The plain object to wrap into a signal.
816
+ * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] -
817
+ * Optional map where each key is a field name and the value is a function
818
+ * to extract the initial value for that field. These fields will be wrapped
819
+ * as separate signals and embedded in the returned object.
820
+ *
821
+ * @returns {Signal<Document>} A signal-wrapped object, possibly containing
822
+ * nested field signals for more granular control.
823
+ *
824
+ * @example
825
+ * const user = { _id: '1', name: 'Alice', score: 42 };
826
+ * const sig = toSignal(user, { score: (u) => u.score });
827
+ * console.log(sig().name); // 'Alice'
828
+ * console.log(sig().score()); // 42 — field is now a signal
829
+ */
830
+ toSignal(document, signalFields = {}) {
831
+ if (Object.keys(signalFields).length) {
832
+ const fields = {};
833
+ for (const key in signalFields) {
834
+ fields[key] = signal(signalFields[key](document));
835
+ }
836
+ return signal({ ...document, ...fields });
837
+ }
838
+ else {
839
+ return signal(document);
840
+ }
841
+ }
809
842
  /**
810
843
  * Converts an array of objects into an array of Angular signals.
811
844
  * Optionally wraps specific fields of each object as individual signals.
812
845
  *
813
846
  * @template Document - The type of each object in the array.
814
847
  * @param {Document[]} arr - Array of plain objects to convert into signals.
815
- * @param {Record<string, (doc: Document) => unknown>} [updatableFields={}] -
848
+ * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] -
816
849
  * Optional map where keys are field names and values are functions that extract the initial value
817
850
  * from the object. These fields will be turned into separate signals.
818
851
  *
@@ -825,43 +858,36 @@ class CoreService {
825
858
  * score: (u) => u.score,
826
859
  * });
827
860
  */
828
- toSignalsArray(arr, updatableFields = {}) {
829
- return arr.map((obj) => {
830
- if (Object.keys(updatableFields).length) {
831
- const signalFields = {};
832
- for (const key in updatableFields) {
833
- signalFields[key] = signal(updatableFields[key](obj));
834
- }
835
- return signal({ ...obj, ...signalFields });
836
- }
837
- else {
838
- return signal(obj);
839
- }
840
- });
861
+ toSignalsArray(arr, signalFields = {}) {
862
+ return arr.map((obj) => this.toSignal(obj, signalFields));
841
863
  }
842
864
  /**
843
865
  * Adds a new object to the signals array.
844
866
  * Optionally wraps specific fields of the object as individual signals before wrapping the whole object.
845
867
  *
846
868
  * @template Document - The type of the object being added.
847
- * @param {WritableSignal<Document>[]} signals - The signals array to append to.
848
- * @param {Document} item - The object to wrap and push as a writable signal.
849
- * @param {Record<string, (doc: Document) => unknown>} [updatableFields={}] -
869
+ * @param {Signal<Document>[]} signals - The signals array to append to.
870
+ * @param {Document} item - The object to wrap and push as a signal.
871
+ * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] -
850
872
  * Optional map of fields to be wrapped as signals within the object.
851
873
  *
852
874
  * @returns {void}
853
875
  */
854
- pushSignal(signals, item, updatableFields = {}) {
855
- if (Object.keys(updatableFields).length) {
856
- const fieldSignals = {};
857
- for (const key in updatableFields) {
858
- fieldSignals[key] = signal(updatableFields[key](item));
859
- }
860
- signals.push(signal({ ...item, ...fieldSignals }));
861
- }
862
- else {
863
- signals.push(signal(item));
864
- }
876
+ pushSignal(signals, item, signalFields = {}) {
877
+ signals.push(this.toSignal(item, signalFields));
878
+ }
879
+ /**
880
+ * Removes the first signal from the array whose object's field matches the provided value.
881
+ * @template Document
882
+ * @param {WritableSignal<Document>[]} signals - The signals array to modify.
883
+ * @param {unknown} value - The value to match.
884
+ * @param {string} [field='_id'] - The object field to match against.
885
+ * @returns {void}
886
+ */
887
+ removeSignalByField(signals, value, field = '_id') {
888
+ const idx = signals.findIndex((sig) => sig()[field] === value);
889
+ if (idx > -1)
890
+ signals.splice(idx, 1);
865
891
  }
866
892
  /**
867
893
  * Returns a generic trackBy function for *ngFor, tracking by the specified object field.
@@ -897,19 +923,6 @@ class CoreService {
897
923
  if (sig)
898
924
  sig.update(updater);
899
925
  }
900
- /**
901
- * Removes the first signal from the array whose object's field matches the provided value.
902
- * @template Document
903
- * @param {WritableSignal<Document>[]} signals - The signals array to modify.
904
- * @param {unknown} value - The value to match.
905
- * @param {string} [field='_id'] - The object field to match against.
906
- * @returns {void}
907
- */
908
- removeSignalByField(signals, value, field = '_id') {
909
- const idx = signals.findIndex((sig) => sig()[field] === value);
910
- if (idx > -1)
911
- signals.splice(idx, 1);
912
- }
913
926
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: CoreService, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
914
927
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: CoreService, providedIn: 'root' });
915
928
  }
@@ -2375,6 +2388,7 @@ class CrudService extends BaseService {
2375
2388
  constructor(_config) {
2376
2389
  super();
2377
2390
  this._config = _config;
2391
+ this._config.signalFields = this._config.signalFields || {};
2378
2392
  this._url += this._config.name;
2379
2393
  this.loaded = this.__core.onComplete(this._config.name + '_loaded');
2380
2394
  if (this._config.unauthorized) {