@wcstack/state 1.31.0 → 1.32.0

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
@@ -521,7 +521,10 @@ interface WcsStateApi {
521
521
  * ワイルドカードを含むパスにマッチする全要素を配列で取得する。
522
522
  *
523
523
  * @param path - ワイルドカードを含むパス
524
- * @param indexes - 各ワイルドカード階層のインデックス(省略時はループコンテキストから解決)
524
+ * @param indexes - 各ワイルドカード階層のインデックス(前方一致の接頭辞。`[]` は全階層を展開)。
525
+ * 省略時はループ文脈の添字(`[$1..$n]` 相当)のうち path と共有するワイルドカード連鎖の
526
+ * 分が接頭辞として敷かれる(文脈が path より深い分は切り詰め)。共有が無いのに文脈が
527
+ * 添字を持つ場合は throw する — 異なる文脈の添字は流用しない。
525
528
  *
526
529
  * @example
527
530
  * ```ts
@@ -531,6 +534,34 @@ interface WcsStateApi {
531
534
  * ```
532
535
  */
533
536
  $getAll<V = any>(path: string, indexes?: number[]): V[];
537
+ /**
538
+ * ワイルドカードを含むパスにマッチする**全アドレスへ一括で書き込む**(`$getAll` の対称形)。
539
+ *
540
+ * 配列を作り直さずに一括更新するための API。`this.users = this.users.map(...)` は
541
+ * ListIndex・行 getter キャッシュ・差分描画をまとめて作り直すが、`$setAll` は
542
+ * in-place な個別書き込みに分解するのでリストの同一性が保たれる。
543
+ *
544
+ * - `indexes` は `$getAll` と同じ**前方一致の接頭辞**(`[]` で全階層を展開)。省略は不可。
545
+ * - 関数を渡すと **mapper**(`(current, ...indexes) => next`)として要素ごとに評価される。
546
+ * - 配列は既定でブロードキャストされる。1 件ずつ配るには `{ spread: true }` を明示する。
547
+ * - `undefined` を書こうとした要素はスキップされる(クリアは `null`)。
548
+ *
549
+ * @returns 実際に書き込んだ件数(`undefined` でスキップした分を含まない)
550
+ *
551
+ * @example
552
+ * ```ts
553
+ * toggleAll(e: Event) {
554
+ * this.$setAll("users.*.selected", [], (e.target as HTMLInputElement).checked);
555
+ * }
556
+ * invertAll() {
557
+ * this.$setAll("users.*.selected", [], cur => !cur);
558
+ * }
559
+ * ```
560
+ */
561
+ $setAll<V = any>(path: string, indexes: number[], value: V | ((current: V, ...indexes: number[]) => V | undefined)): number;
562
+ $setAll<V = any>(path: string, indexes: number[], values: readonly V[], options: {
563
+ spread: true;
564
+ }): number;
534
565
  /**
535
566
  * 指定パスの更新を手動でトリガーする。
536
567
  * Proxy の set トラップを経由せずに内部状態を変更した場合に使用。