solid-ctrl-flow 2.0.1 → 2.1.1

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/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { JSX } from 'solid-js';
4
4
  import { MemoOptions } from 'solid-js';
5
5
  import { Owner } from 'solid-js';
6
6
  import { ParentProps } from 'solid-js';
7
+ import { splitProps } from 'solid-js';
7
8
 
8
9
  /** Like a {@link Match} but gets the value from the closest {@link On} ancestor */
9
10
  export declare function Case(props: ParentProps<{
@@ -154,22 +155,27 @@ export declare namespace Slot {
154
155
  */
155
156
  const remove: <T extends Slot>(list: T[], v: T) => T | undefined;
156
157
  /**
157
- * Removes an element from a slotted list
158
+ * Removes an element from a slotted list.
159
+ * The function returns `undefined` ONLY if the index is out of range (A {@link Slot} can't be `undefined`)
158
160
  * @param list The list from which to remove the element
159
161
  * @param i The index at which to remove the element
160
162
  * @returns The removed element
161
163
  */
162
164
  export function removeAt<T extends Slot>(list: T[], i: number): T | undefined;
165
+ /**
166
+ * Restores the indexes of a slotted list.
167
+ * This function is useful after a sort, filter, or any other operation that changes the order of the elements in the list without taking care of {@link Slot}s
168
+ * @param list The list to restore
169
+ */
170
+ export function restore(list: Slot[]): void;
163
171
  }
164
172
 
165
173
  /**
166
- * Executes {@link splitProps} and memoizes the first of the two returned objects using {@link memoProps}.
167
- * Unlike {@link splitProps}, this doesn't support multiple key-sets out of the box
174
+ * Executes {@link splitProps} and memoizes every returned object but the last one using {@link memoProps}
168
175
  * @param obj Object to split and partially memoize
169
- * @param keys The keys of the properties to memoize and to include in the first of the two objects
170
- * @param equals The comparator function to use on the newly created memos
176
+ * @param keys The lists of the keys to split from {@link obj}
171
177
  */
172
- export declare function splitAndMemoProps<T extends Record<any, any>, K extends readonly (keyof T)[]>(obj: T, keys: K, equals?: Equals): [Pick<T, Extract<K, readonly (keyof T)[]>[number]>, Omit<T, K[number]>];
178
+ export declare const splitAndMemoProps: typeof splitProps;
173
179
 
174
180
  /** Standard parameters to pass to an {@link Enfold} */
175
181
  declare type Standard<T> = ParentProps<{
package/dist/index.mjs CHANGED
@@ -6,11 +6,12 @@ function memoProps(obj, keys = Reflect.ownKeys(obj), equals = false) {
6
6
  Object.defineProperty(out, elm, { enumerable: true, get: createMemo(() => obj[elm], void 0, { equals }) });
7
7
  return out;
8
8
  }
9
- function splitAndMemoProps(obj, keys, equals) {
10
- const out = splitProps(obj, keys);
11
- out[0] = memoProps(out[0], keys, equals);
9
+ const splitAndMemoProps = (obj, ...keys) => {
10
+ const out = splitProps(obj, ...keys);
11
+ for (var i = 0; i < keys.length; i++)
12
+ out[i] = memoProps(out[i], keys[i]);
12
13
  return out;
13
- }
14
+ };
14
15
  function untrackCall(f, ...args) {
15
16
  return untrack(() => f.apply(this, args));
16
17
  }
@@ -64,6 +65,11 @@ var Slot;
64
65
  return out;
65
66
  }
66
67
  Slot2.removeAt = removeAt;
68
+ function restore(list) {
69
+ for (var i = 0; i < list.length; i++)
70
+ list[i].slot = i;
71
+ }
72
+ Slot2.restore = restore;
67
73
  })(Slot || (Slot = {}));
68
74
  function createExtractor(name = "extractor") {
69
75
  const ctx2 = createContext(void 0, {
package/dist/index.umd.js CHANGED
@@ -8,11 +8,12 @@
8
8
  Object.defineProperty(out, elm, { enumerable: true, get: solidJs.createMemo(() => obj[elm], void 0, { equals }) });
9
9
  return out;
10
10
  }
11
- function splitAndMemoProps(obj, keys, equals) {
12
- const out = solidJs.splitProps(obj, keys);
13
- out[0] = memoProps(out[0], keys, equals);
11
+ const splitAndMemoProps = (obj, ...keys) => {
12
+ const out = solidJs.splitProps(obj, ...keys);
13
+ for (var i = 0; i < keys.length; i++)
14
+ out[i] = memoProps(out[i], keys[i]);
14
15
  return out;
15
- }
16
+ };
16
17
  function untrackCall(f, ...args) {
17
18
  return solidJs.untrack(() => f.apply(this, args));
18
19
  }
@@ -66,6 +67,11 @@
66
67
  return out;
67
68
  }
68
69
  Slot2.removeAt = removeAt;
70
+ function restore(list) {
71
+ for (var i = 0; i < list.length; i++)
72
+ list[i].slot = i;
73
+ }
74
+ Slot2.restore = restore;
69
75
  })(exports2.Slot || (exports2.Slot = {}));
70
76
  function createExtractor(name = "extractor") {
71
77
  const ctx2 = solidJs.createContext(void 0, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",