@ethlete/core 4.29.1 → 4.29.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ethlete/core
2
2
 
3
+ ## 4.29.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6b05b76`](https://github.com/ethlete-io/ethdk/commit/6b05b7603cfd0038dda1336c7c0acf590556a4fa) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix `controlValueSignal` not reporting the initial value if the passed control is a required input
8
+
9
+ ## 4.29.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`11dc4d3`](https://github.com/ethlete-io/ethdk/commit/11dc4d32d6ae7f3681c50029d3c7e2468cbec3a0) Thanks [@TomTomB](https://github.com/TomTomB)! - Raise an error if signal utils detect a non html element being used as an element
14
+
3
15
  ## 4.29.1
4
16
 
5
17
  ### Patch Changes
@@ -1699,12 +1699,19 @@ const buildElementSignal = (el) => {
1699
1699
  else {
1700
1700
  mElSignal = signal([coerceElement(el)]);
1701
1701
  }
1702
- const elSig = toSignal(toObservable(mElSignal).pipe(startWith(null), pairwise(), map(([previousElements, currentElements]) => ({
1703
- previousElements: previousElements ?? [],
1704
- currentElements: currentElements ?? [],
1705
- currentElement: currentElements?.[0] ?? null,
1706
- previousElement: previousElements?.[0] ?? null,
1707
- }))), { initialValue: { currentElement: null, previousElement: null, previousElements: [], currentElements: [] } });
1702
+ const elSig = toSignal(toObservable(mElSignal).pipe(startWith(null), pairwise(), map(([previousElements, currentElements]) => {
1703
+ const previousEl = previousElements?.[0] ?? null;
1704
+ const currentEl = currentElements?.[0] ?? null;
1705
+ if (currentEl && !(currentEl instanceof HTMLElement)) {
1706
+ console.error('Received an element that is not an HTMLElement. You are probably using viewChild or contentChild on a component without the read option set to ElementRef. This will cause issues. Received:', currentEl);
1707
+ }
1708
+ return {
1709
+ previousElements: previousElements ?? [],
1710
+ currentElements: currentElements ?? [],
1711
+ currentElement: currentEl,
1712
+ previousElement: previousEl,
1713
+ };
1714
+ })), { initialValue: { currentElement: null, previousElement: null, previousElements: [], currentElements: [] } });
1708
1715
  return computed(() => elSig(), {
1709
1716
  equal: (a, b) => a.currentElement === b.currentElement &&
1710
1717
  a.previousElement === b.previousElement &&
@@ -2188,14 +2195,14 @@ const controlValueSignal = (control, options) => {
2188
2195
  let initialValue = null;
2189
2196
  const getRawValueSafe = (ctrl) => {
2190
2197
  try {
2191
- return ctrl?.getRawValue() ?? null;
2198
+ return isSignal(ctrl) ? (ctrl()?.getRawValue() ?? null) : (ctrl?.getRawValue() ?? null);
2192
2199
  }
2193
2200
  catch {
2194
2201
  // Ignore errors. This can happen if the passed control is a required input and is not yet initialized.
2195
2202
  return null;
2196
2203
  }
2197
2204
  };
2198
- initialValue = isSignal(control) ? getRawValueSafe(control()) : getRawValueSafe(control);
2205
+ initialValue = getRawValueSafe(control);
2199
2206
  const controlStream = isSignal(control)
2200
2207
  ? toObservable(control)
2201
2208
  : of(control);
@@ -2205,7 +2212,7 @@ const controlValueSignal = (control, options) => {
2205
2212
  const vcsObs = options?.debounceTime
2206
2213
  ? ctrl.valueChanges.pipe(debounceTime(options.debounceTime))
2207
2214
  : ctrl.valueChanges;
2208
- return vcsObs.pipe(map(() => getRawValueSafe(ctrl)));
2215
+ return vcsObs.pipe(startWith(ctrl.getRawValue()), map(() => ctrl.getRawValue()));
2209
2216
  }));
2210
2217
  const obs = !options?.debounceFirst ? merge(of(initialValue), controlObs) : controlObs;
2211
2218
  return toSignal(obs.pipe(distinctUntilChanged((a, b) => equal(a, b))), {