@aiquants/period-slider 0.16.0 → 0.18.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/CHANGELOG.md +359 -0
- package/README.md +97 -66
- package/dist/DateSelector.d.ts +2 -2
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +2 -2
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +324 -47
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/VirtualDateDropdown.d.ts +19 -1
- package/dist/VirtualDateDropdown.d.ts.map +1 -1
- package/dist/YearSelector.d.ts +4 -2
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2723 -2593
- package/dist/inputValue.d.ts +98 -21
- package/dist/inputValue.d.ts.map +1 -1
- package/dist/optionText.d.ts +1 -1
- package/dist/optionText.d.ts.map +1 -1
- package/dist/selectorMemo.d.ts +14 -0
- package/dist/selectorMemo.d.ts.map +1 -1
- package/dist/selectorStep.d.ts +25 -30
- package/dist/selectorStep.d.ts.map +1 -1
- package/dist/useCommittedRef.d.ts +99 -0
- package/dist/useCommittedRef.d.ts.map +1 -0
- package/dist/usePeriodSlider.d.ts +74 -40
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/dist/useUncontrolledSelection.d.ts +40 -0
- package/dist/useUncontrolledSelection.d.ts.map +1 -0
- package/dist/vernierStep.d.ts +10 -1
- package/dist/vernierStep.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/DateSelector.tsx +34 -67
- package/src/MonthSelector.tsx +24 -57
- package/src/PeriodSlider.tsx +614 -198
- package/src/VirtualDateDropdown.tsx +90 -46
- package/src/YearSelector.tsx +34 -56
- package/src/inputValue.ts +159 -21
- package/src/optionText.ts +3 -5
- package/src/selectorMemo.ts +18 -3
- package/src/selectorStep.ts +46 -58
- package/src/useCommittedRef.ts +236 -0
- package/src/usePeriodSlider.ts +536 -289
- package/src/useUncontrolledSelection.ts +83 -0
- package/src/valueSet.ts +1 -1
- package/src/vernierStep.ts +19 -17
package/dist/inputValue.d.ts
CHANGED
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview How the package reads a raw input value before trusting it: whether it is a usable Date, how a rejection names it, and how a memo comparator keys a Date-typed prop.
|
|
3
|
-
* パッケージが生の入力値を信用する前の読み方 (使える Date
|
|
4
|
-
*
|
|
5
|
-
* Every Date validation
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
2
|
+
* @fileoverview How the package reads a raw input value before trusting it: whether it is a usable Date, whether it is an array, whether a candidate-list input is a list, how a rejection names it, and how a memo comparator keys a Date-typed prop.
|
|
3
|
+
* パッケージが生の入力値を信用する前の読み方 (使える Date かの判定・配列かの判定・候補の一覧の入力が一覧かの判定・拒否メッセージでの値の説明・メモ比較器での Date 型 Props のキー)。
|
|
4
|
+
*
|
|
5
|
+
* Every Date validation, every raw-input array test (tuple and candidate-list validations, and the hand-written memo
|
|
6
|
+
* comparators) and every Date key of a memo comparator reads these rules, and every rejection message describes the value
|
|
7
|
+
* it received or holds with `describeValue` (an array element by element), so "a valid Date" and "an array" each mean one
|
|
8
|
+
* thing everywhere and no message builder can throw. A rejection message reads
|
|
9
|
+
* `<owner>: <path> <requirement> (received: <value>)<remedy>`: the owner is the component, hook or function that rejects;
|
|
10
|
+
* the path names the prop, option, entry point or argument without quotes (`minDate`, `allowedYears[1]`, `stepper.onStep`);
|
|
11
|
+
* the value is describeValue of what was received. Two compared values are named inside one parenthesis instead
|
|
12
|
+
* (`(lower: ..., upper: ...)`, `(minDate: ..., maxDate: ...)`), a value the owner holds reads `(holding ...)`, and a
|
|
13
|
+
* condition without a single value is a sentence. A requirement may state its reason before the parenthesis; a remedy
|
|
14
|
+
* follows the closing parenthesis as `; ...`. No message ends with a full stop. The exceptions are the messages of the
|
|
15
|
+
* `labels` validation and the `locale` check, which keep the format of the `@aiquants/virtualscroll` engine that validates
|
|
16
|
+
* those props (a string JSON-quoted, anything else by its type name). A date or year the package derived itself, such as a
|
|
17
|
+
* resolved bound, is not a received value and is printed as a year, yyyy-MM or yyyy-MM-dd. The module imports nothing, so
|
|
18
|
+
* every other module can read it without an import cycle.
|
|
19
|
+
* パッケージの Date の検証・生の入力値の配列の判定 (タプルと候補の一覧の検証、手書きのメモ比較器)・メモ比較器の Date のキーはすべてこれらの
|
|
20
|
+
* 規則を読み、拒否メッセージは受け取った値・保持している値を `describeValue` で示す (配列は要素ごと)。したがって「有効な Date」と「配列」の意味は
|
|
21
|
+
* それぞれ 1 つに定まり、メッセージを組む段で例外は起きない。拒否メッセージは `<所有者>: <パス> <要件> (received: <値>)<直し方>` の形
|
|
22
|
+
* (所有者は拒否したコンポーネント・フック・関数、パスは引用符を付けない Props・オプション・入口・引数 (`minDate`・`allowedYears[1]`・`stepper.onStep`)、
|
|
23
|
+
* 値は受け取った値の describeValue)。比べる 2 つの値は 1 つの括弧の中に名前付きで並べ (`(lower: ..., upper: ...)`・`(minDate: ..., maxDate: ...)`)、
|
|
24
|
+
* 所有者が保持している値は `(holding ...)`、値が 1 つに定まらない条件は文で示す。要件はその理由を括弧の前に述べてよく、直し方は閉じ括弧の後に
|
|
25
|
+
* `; ...` で続ける。句点で終えない。例外は `labels` の検証と `locale` の検査のメッセージで、それらを検証する
|
|
26
|
+
* `@aiquants/virtualscroll` のエンジンの形 (文字列は JSON の引用符付き、それ以外は型名) を保つ。解決した境界などパッケージ自身が導いた日付・年は
|
|
27
|
+
* 受け取った値ではなく、年・yyyy-MM・yyyy-MM-dd で示す。本モジュールは何も import しないため、どのモジュールからも循環せずに読める。
|
|
16
28
|
*/
|
|
17
29
|
/**
|
|
18
30
|
* Text describing a value whose conversion to a string throws.
|
|
19
31
|
* 文字列への変換が例外を投げる値の説明文。
|
|
20
32
|
*/
|
|
21
33
|
export declare const UNDESCRIBABLE_VALUE = "an object that cannot be converted to a string";
|
|
34
|
+
/**
|
|
35
|
+
* Most entries of an array a rejection message shows; the rest are counted.
|
|
36
|
+
* 拒否メッセージが示す配列の要素の上限 (残りは件数で示す)。
|
|
37
|
+
*
|
|
38
|
+
* The longest array any validator of the package expects is a two-element [start, end] tuple, so three entries show the
|
|
39
|
+
* whole of a tuple with one entry too many, and a candidate list of any size still yields a message of bounded length.
|
|
40
|
+
* パッケージの検証が期待する最長の配列は 2 要素の [開始, 終了] タプルであり、3 要素あれば 1 つ多いタプルの全体が見える。
|
|
41
|
+
* 候補の一覧がどれほど大きくても、メッセージの長さは一定に収まる。
|
|
42
|
+
*/
|
|
43
|
+
export declare const DESCRIBED_ARRAY_ENTRIES = 3;
|
|
22
44
|
/**
|
|
23
45
|
* Type guard telling whether a value is a Date carrying a representable instant; it never throws.
|
|
24
46
|
* 値が表現可能な時刻を保持する Date かどうかを判定する型ガード (例外を投げない)。
|
|
@@ -33,19 +55,74 @@ export declare const UNDESCRIBABLE_VALUE = "an object that cannot be converted t
|
|
|
33
55
|
* @returns True when value is a Date holding a time value that is not NaN / 時刻値が NaN でない Date なら true
|
|
34
56
|
*/
|
|
35
57
|
export declare const isValidDate: (value: unknown) => value is Date;
|
|
58
|
+
/**
|
|
59
|
+
* Type guard telling whether a raw input value is an array; it never throws.
|
|
60
|
+
* 生の入力値が配列かどうかを判定する型ガード (例外を投げない)。
|
|
61
|
+
*
|
|
62
|
+
* It answers as `Array.isArray` does for every value (an array wrapped in a Proxy is an array), except a revoked Proxy,
|
|
63
|
+
* which makes `Array.isArray` itself throw and reads here as not an array. Every raw-input array test of the package - a
|
|
64
|
+
* tuple validation, a candidate-list validation, a memo comparator, `describeValue` - reads this rule, so a value that is
|
|
65
|
+
* not an array is always rejected by the name of the prop or option, never by the TypeError of the test itself.
|
|
66
|
+
* どの値にも `Array.isArray` と同じ答えを返し (Proxy で包んだ配列は配列)、`Array.isArray` 自身が投げる取り消した Proxy だけは配列でないと読む。
|
|
67
|
+
* パッケージの生の入力値の配列の判定 (タプルの検証・候補の一覧の検証・メモ比較器・`describeValue`) はすべてこの規則を読むため、配列でない値は
|
|
68
|
+
* 判定そのものの TypeError ではなく、必ず Props・オプションの名前で拒否される。
|
|
69
|
+
*
|
|
70
|
+
* @param value - Raw input value / 生の入力値
|
|
71
|
+
* @returns True when value is an array / 配列なら true
|
|
72
|
+
*/
|
|
73
|
+
export declare const isArrayValue: (value: unknown) => value is readonly unknown[];
|
|
74
|
+
/**
|
|
75
|
+
* Whether a candidate-list input reads as a list or as omitted - an array or `undefined` - rather than as a value to reject; it never throws.
|
|
76
|
+
* 候補の一覧の入力が一覧または省略 (配列か `undefined`) として読めるかの判定 (拒否すべき値でないか。例外を投げない)。
|
|
77
|
+
*
|
|
78
|
+
* Only `undefined` means omitted, as for every optional input of the package, so `null`, a single Date, a string, an
|
|
79
|
+
* array-like object and a revoked Proxy are supplied values that are not a list: every owner rejects them by name instead
|
|
80
|
+
* of reading them as no candidates or walking them by index. The owner validates the entries by index, and what an empty
|
|
81
|
+
* list means is the owner's own contract (a selector offers nothing, a slider rail stays continuous).
|
|
82
|
+
* 省略は `undefined` だけ (パッケージの任意入力すべてと同じ) であり、`null`・単独の Date・文字列・配列風のオブジェクト・取り消した Proxy は
|
|
83
|
+
* 一覧でない指定値である。どの所有者も、それらを候補なしと読んだり添字で読み進めたりせず、名指しで拒否する。要素は所有者が添字付きで検証し、
|
|
84
|
+
* 空配列の意味は所有者自身の契約 (セレクタは選択肢なし、スライダーのレールは連続) に従う。
|
|
85
|
+
*
|
|
86
|
+
* @param value - Raw candidate-list input / 生の候補の一覧の入力
|
|
87
|
+
* @returns True for `undefined` or an array / `undefined` または配列なら true
|
|
88
|
+
*/
|
|
89
|
+
export declare const isCandidateListInput: (value: unknown) => value is readonly unknown[] | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Asserts that a candidate-list input is a list or omitted, naming the owner and the list otherwise.
|
|
92
|
+
* 候補の一覧の入力が一覧または省略であることの表明 (そうでなければ所有者と一覧を名乗って拒否)。
|
|
93
|
+
*
|
|
94
|
+
* The single copy of the shape message the slider, the state hooks, the three selectors, getSortedAllowedDates and the step functions share.
|
|
95
|
+
* 本体・状態フック・3 セレクタ・getSortedAllowedDates・1 歩の関数が共有する形のメッセージの唯一の写し。
|
|
96
|
+
*
|
|
97
|
+
* @param owner - API named at the head of the message / メッセージの先頭で名乗る API
|
|
98
|
+
* @param label - The list as the message names it (a prop or option, with the vernier row that inherited it) / メッセージが名指す一覧 (Props・オプション名と、それを継いだノギスの行)
|
|
99
|
+
* @param value - Raw candidate-list input / 生の候補の一覧の入力
|
|
100
|
+
* @returns Nothing; returns normally for an array or `undefined` / 戻り値なし (配列か `undefined` なら正常復帰)
|
|
101
|
+
* @throws {RangeError} `<owner>: <label> must be an array of Dates (received: ...)` for any other value, `null` and a revoked Proxy included / それ以外の値 (`null`・取り消した Proxy を含む) なら `<owner>: <label> must be an array of Dates (received: ...)`
|
|
102
|
+
*/
|
|
103
|
+
export declare function assertCandidateListInput(owner: string, label: string, value: unknown): asserts value is readonly unknown[] | undefined;
|
|
36
104
|
/**
|
|
37
105
|
* Describes any value for a rejection message; it never throws.
|
|
38
106
|
* 拒否メッセージ用に任意の値を説明する関数 (例外を投げない)。
|
|
39
107
|
*
|
|
40
108
|
* A string is quoted as JSON, so an empty or blank string, a date-like string and the text "null" stay distinguishable from
|
|
41
|
-
* a Date and from `null`. A valid Date reads as its ISO 8601 instant.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
109
|
+
* a Date and from `null`. A valid Date reads as its ISO 8601 instant. An array (isArrayValue) reads entry by entry with these
|
|
110
|
+
* same rules, as `[e0, e1, e2]`: at most DESCRIBED_ARRAY_ENTRIES entries, the rest counted as `, ... n more`; a hole as
|
|
111
|
+
* `empty`; an entry that is itself an array as `Array(length)`, never descended into, so an array holding itself
|
|
112
|
+
* terminates; an entry whose reading throws as `UNDESCRIBABLE_VALUE` for that entry alone. A Date entry therefore reads the
|
|
113
|
+
* same in every time zone, `[3]` stays distinct from `3`, and a list of any size yields a message of bounded length.
|
|
114
|
+
* Anything else reads as `String(value)`: an Invalid Date as `Invalid Date`, `null` as `null`, a number as its digits, a
|
|
115
|
+
* Symbol as `Symbol(description)`. A value whose conversion to a string throws (an object without a prototype, one that
|
|
116
|
+
* inherits from `Date.prototype` without holding a time value, a Proxy around a Date, a revoked Proxy) and an array whose
|
|
117
|
+
* `length` cannot be read read as `UNDESCRIBABLE_VALUE`, so the RangeError that rejects it is always built.
|
|
45
118
|
* 文字列は JSON の引用符付きで表し、空文字列・空白だけの文字列・日付に見える文字列・文字列の "null" を Date や `null` と区別する。有効な Date は
|
|
46
|
-
* ISO 8601
|
|
47
|
-
* `
|
|
48
|
-
*
|
|
119
|
+
* ISO 8601 の時刻で表す。配列 (isArrayValue) は要素ごとに同じ規則で `[e0, e1, e2]` と表す (示すのは DESCRIBED_ARRAY_ENTRIES 個までで、残りは
|
|
120
|
+
* `, ... n more` と件数で示す。穴は `empty`。配列である要素は `Array(長さ)` とし中へ降りないため、自身を含む配列でも止まる。読み出しが投げる要素は
|
|
121
|
+
* その要素だけを `UNDESCRIBABLE_VALUE` とする)。したがって Date の要素はどのタイムゾーンでも同じ表記になり、`[3]` は `3` と区別され、一覧が
|
|
122
|
+
* どれほど大きくてもメッセージの長さは一定に収まる。それ以外は `String(value)` の形 (Invalid Date は `Invalid Date`、`null` は `null`、数値は
|
|
123
|
+
* その数字、Symbol は `Symbol(説明)`)。文字列への変換が例外を投げる値 (プロトタイプを持たないオブジェクト、時刻値を持たずに `Date.prototype` を
|
|
124
|
+
* 継ぐオブジェクト、Date を包んだ Proxy、取り消した Proxy) と `length` を読めない配列は `UNDESCRIBABLE_VALUE` で表し、それを拒否する RangeError を
|
|
125
|
+
* 必ず組み上げる。
|
|
49
126
|
*
|
|
50
127
|
* @param value - Value to describe / 説明する値
|
|
51
128
|
* @returns Short description of the value / 値の短い説明
|
package/dist/inputValue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputValue.d.ts","sourceRoot":"","sources":["../src/inputValue.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"inputValue.d.ts","sourceRoot":"","sources":["../src/inputValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,mDAAmD,CAAA;AAEnF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAA;AAExC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,IAQrD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,SAAS,OAAO,EAQtE,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,SAAS,OAAO,EAAE,GAAG,SAAuD,CAAA;AAE3I;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,SAAS,OAAO,EAAE,GAAG,SAAS,CAItI;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,MAY9C,CAAA;AA6CD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,KAAG,MAA0D,CAAA;AAEtI;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAAgE,CAAA"}
|
package/dist/optionText.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { PeriodOptionScope, PeriodSliderUnit } from './PeriodSlider.js';
|
|
|
16
16
|
* @param scope - Scope selecting the built-in option set / 組み込みオプション集合を選ぶ区分
|
|
17
17
|
* @param formatLocale - BCP 47 language tag enabling Intl formatting (the `formatLocale` prop, not the UI chrome `locale`) / Intl 書式を有効化する BCP 47 言語タグ (UI クロームの `locale` ではなく `formatLocale` prop)
|
|
18
18
|
* @returns Built-in rendering, or an empty string when date is absent or an Invalid Date / 組み込み描画 (date が未指定・Invalid Date の場合は空文字列)
|
|
19
|
-
* @throws RangeError when unit or scope is not one of the declared values / unit・scope が宣言値以外の場合
|
|
19
|
+
* @throws RangeError when unit or scope is not one of the declared values, unit first, both before the Invalid Date short-circuit (`formatOptionText: unit must be one of "year", "month", "day" (received: ...)` / `formatOptionText: scope must be "period" or "part" (received: ...)`) / unit・scope が宣言値以外の場合 (unit を先に、どちらも無効日付の短絡より先に判定)
|
|
20
20
|
*/
|
|
21
21
|
export declare const formatOptionText: (date: Date, unit: PeriodSliderUnit, scope: PeriodOptionScope, formatLocale?: string) => string;
|
|
22
22
|
//# sourceMappingURL=optionText.d.ts.map
|
package/dist/optionText.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optionText.d.ts","sourceRoot":"","sources":["../src/optionText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"optionText.d.ts","sourceRoot":"","sources":["../src/optionText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAsD,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AA4ElI;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,EAAE,MAAM,gBAAgB,EAAE,OAAO,iBAAiB,EAAE,eAAe,MAAM,KAAG,MAUtH,CAAA"}
|
package/dist/selectorMemo.d.ts
CHANGED
|
@@ -12,6 +12,20 @@ export interface SelectorDateProps {
|
|
|
12
12
|
/** Upper bound / 上限 */
|
|
13
13
|
maxDate?: Date;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Key of a valid Date at a selector's unit: the time of the start of the unit containing it.
|
|
17
|
+
* セレクタの単位での有効な Date のキー (その日付を含む単位の始まりの時刻)。
|
|
18
|
+
*
|
|
19
|
+
* The memo comparators compare the shown date by this key and the uncontrolled selection adopts `initialDate` exactly when it
|
|
20
|
+
* changes (`useUncontrolledSelection`), so a render a comparator skips is a render that would not adopt.
|
|
21
|
+
* メモ比較器は表示する日付をこのキーで比べ、非制御の選択はこのキーが変わったときにだけ `initialDate` を取り込む
|
|
22
|
+
* (`useUncontrolledSelection`)。比較器が省く描画は、取り込みを起こさない描画と一致する。
|
|
23
|
+
*
|
|
24
|
+
* @param date - Date to key / キー化する日付
|
|
25
|
+
* @param unitStart - Start of the selector's unit containing a valid Date, or an Invalid Date where the selector's validation rejects that date / 有効な Date を含むセレクタの単位の始まり (セレクタの検証がその日付を拒む場合は Invalid Date)
|
|
26
|
+
* @returns Time of the unit's start; `NaN` where `unitStart` answers an Invalid Date / 単位の始まりの時刻 (`unitStart` が Invalid Date を返す日付では `NaN`)
|
|
27
|
+
*/
|
|
28
|
+
export declare const selectorUnitKey: (date: Date, unitStart: (date: Date) => Date) => number;
|
|
15
29
|
/**
|
|
16
30
|
* Whether two renders of a selector carry the same Date-typed props at the selector's unit, never judging an unusable one equal.
|
|
17
31
|
* 2 つの描画の Date 型 Props がセレクタの単位で等しいかの判定 (使えない値は等しいとみなさない)。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectorMemo.d.ts","sourceRoot":"","sources":["../src/selectorMemo.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,8BAA8B;IAC9B,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,2CAA2C;IAC3C,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,uBAAuB;IACvB,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,uBAAuB;IACvB,OAAO,CAAC,EAAE,IAAI,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAM,iBAAiB,EAAE,MAAM,iBAAiB,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,KAAG,OAQ7H,CAAA"}
|
|
1
|
+
{"version":3,"file":"selectorMemo.d.ts","sourceRoot":"","sources":["../src/selectorMemo.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,8BAA8B;IAC9B,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,2CAA2C;IAC3C,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,uBAAuB;IACvB,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,uBAAuB;IACvB,OAAO,CAAC,EAAE,IAAI,CAAA;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,KAAG,MAAmC,CAAA;AAEjH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAM,iBAAiB,EAAE,MAAM,iBAAiB,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,KAAG,OAQ7H,CAAA"}
|
package/dist/selectorStep.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export interface ResolveSelectorStepsOptions {
|
|
|
91
91
|
readonly shows: "start" | "end";
|
|
92
92
|
/** Resolution the selection and the set are read at / 選択と集合を読む解像度 */
|
|
93
93
|
readonly unit: PeriodSliderUnit;
|
|
94
|
-
/** Size of one step (default: `unit`): `unit` itself, or "year" for a `unit: "month"` selection (a year row stepping a month-resolution period); a calendar month or year is not a whole number of days, so a day selection only steps by days / 1 歩の大きさ (既定: `unit`)。`unit` そのもの、または `unit: "month"` の選択に対する "year" (年の行で月の期間を動かす)。暦の月・年は日の整数倍ではないため、日の選択は日でしか動かない */
|
|
94
|
+
/** Size of one step (default: `unit`, for an omitted value only; `null` is rejected): `unit` itself, or "year" for a `unit: "month"` selection (a year row stepping a month-resolution period); a calendar month or year is not a whole number of days, so a day selection only steps by days / 1 歩の大きさ (既定: `unit`。省略 (undefined) のときだけで、`null` は拒否)。`unit` そのもの、または `unit: "month"` の選択に対する "year" (年の行で月の期間を動かす)。暦の月・年は日の整数倍ではないため、日の選択は日でしか動かない */
|
|
95
95
|
readonly stepUnit?: PeriodSliderUnit;
|
|
96
96
|
/** Calendar month a year starts in, 0-based, for `unit: "year"` (default: 0) / `unit: "year"` の 1 年が始まる暦月 (0 始まり、既定: 0) */
|
|
97
97
|
readonly yearStartMonth?: number;
|
|
@@ -153,20 +153,25 @@ export type SelectorStepRuleKind = "motion" | "vernierRange" | "vernierPoint";
|
|
|
153
153
|
*/
|
|
154
154
|
export declare const assertSelectorStepRules: (owner: string, path: string, rules: unknown, kind: SelectorStepRuleKind) => void;
|
|
155
155
|
/**
|
|
156
|
-
*
|
|
157
|
-
* `stepper` Props
|
|
156
|
+
* Asserts that a selector's `stepper` prop is well formed and that the selector is controlled, naming the owner and the offending field otherwise.
|
|
157
|
+
* セレクタの `stepper` Props が整っていて、セレクタが制御されていることの表明 (そうでなければ所有者と不備のフィールドを名乗って拒否)。
|
|
158
158
|
*
|
|
159
|
+
* The single copy of both stepper messages of YearSelector, MonthSelector and DateSelector; a selector calls it on every render that supplies `stepper`.
|
|
160
|
+
* YearSelector・MonthSelector・DateSelector の stepper の 2 つのメッセージの唯一の写し。セレクタは `stepper` を渡された描画のたびに呼ぶ。
|
|
161
|
+
*
|
|
162
|
+
* @param owner - Selector named at the head of the message / メッセージの先頭で名乗るセレクタ
|
|
159
163
|
* @param stepper - Value of the `stepper` prop, not undefined / `stepper` Props の値 (undefined ではないこと)
|
|
160
|
-
* @
|
|
164
|
+
* @param isControlled - Whether the selector received `value` / セレクタが `value` を受け取ったか
|
|
165
|
+
* @returns Nothing; returns normally for a well-formed stepper on a controlled selector / 戻り値なし (制御中のセレクタへの整った stepper なら正常復帰)
|
|
166
|
+
* @throws {RangeError} `<owner>: <field> must be <expected> (received: ...)` for the first malformed field among stepper, stepper.onStep, stepper.canStepPrevious, stepper.canStepNext / この順で最初に不備のあるフィールド
|
|
167
|
+
* @throws {RangeError} `<owner>: stepper requires the controlled value; ...` when the selector is uncontrolled / 非制御のセレクタの場合
|
|
161
168
|
*/
|
|
162
|
-
export declare const
|
|
163
|
-
readonly field: string;
|
|
164
|
-
readonly expected: string;
|
|
165
|
-
readonly received: string;
|
|
166
|
-
} | null;
|
|
169
|
+
export declare const assertSelectorStepper: (owner: string, stepper: unknown, isControlled: boolean) => void;
|
|
167
170
|
/**
|
|
168
171
|
* Maps a date onto the integer axis of a unit, failing when the date is not a Date or its unit cannot start inside the Date range.
|
|
172
|
+
* The unit-start rule and its message are encodeInsideDateRange's, the one predicate the slider, the state hooks and the three selectors share.
|
|
169
173
|
* 日付を単位の整数軸へ写す関数 (Date でない場合、その単位の始まりが Date の表現範囲に入らない場合は送出)。
|
|
174
|
+
* 単位の始まりの規則と文言は、本体・状態フック・3 セレクタも共有する唯一の判定 encodeInsideDateRange のもの。
|
|
170
175
|
*
|
|
171
176
|
* @param owner - API name quoted in the error message / エラーメッセージが名指しする API 名
|
|
172
177
|
* @param path - Option path quoted in the error message / エラーメッセージが名指しするオプション経路
|
|
@@ -177,17 +182,6 @@ export declare const findSelectorStepperFault: (stepper: unknown) => {
|
|
|
177
182
|
* @throws RangeError when the value is not a valid Date or its unit starts outside the Date range / 有効な Date でない場合、その単位の始まりが Date の表現範囲外の場合
|
|
178
183
|
*/
|
|
179
184
|
export declare const encodeStepOption: (owner: string, path: string, date: unknown, unit: PeriodSliderUnit, yearStartMonth: number) => number;
|
|
180
|
-
/**
|
|
181
|
-
* Throws unless a value names one of the time units.
|
|
182
|
-
* 値が時間単位のいずれかを名乗る場合を除いて送出する関数。
|
|
183
|
-
*
|
|
184
|
-
* @param owner - API name quoted in the error message / エラーメッセージが名指しする API 名
|
|
185
|
-
* @param path - Option path quoted in the error message / エラーメッセージが名指しするオプション経路
|
|
186
|
-
* @param unit - Value supplied by the caller / 呼び出し側が渡した値
|
|
187
|
-
* @returns Nothing; the function only throws or returns normally / 戻り値なし (正常時は無返却)
|
|
188
|
-
* @throws RangeError when the value is not "year", "month" or "day" / "year"・"month"・"day" でない場合
|
|
189
|
-
*/
|
|
190
|
-
export declare const assertStepUnit: (owner: string, path: string, unit: unknown) => void;
|
|
191
185
|
/**
|
|
192
186
|
* A candidate list's keys on the axis of a unit - validated, ascending and without duplicates - prepared once per list, unit and year start.
|
|
193
187
|
* 候補配列を単位の軸へ写したキー (検証済み・昇順・重複なし) を、配列・単位・年の開始月ごとに 1 度だけ準備する関数。
|
|
@@ -269,7 +263,7 @@ export declare const toStepDates: (stepped: readonly [number, number], encoded:
|
|
|
269
263
|
*
|
|
270
264
|
* @param options - Selection, displayed end, units, selectable set and rules / 選択・示している端・単位・選択可能集合・規則
|
|
271
265
|
* @returns Destination per direction, or null where a direction is unavailable / 向きごとの行き先 (押せない向きは null)
|
|
272
|
-
* @throws RangeError when an option is missing or malformed: a selection that is not two valid Dates in order at `unit` resolution, an unknown `shows`, `unit` or `stepUnit`, a `stepUnit` other than `unit` or a year over months, an invalid `yearStartMonth`, bounds that are invalid or inverted, an invalid `allowedDates` entry, or a malformed rule / オプションが欠落・不正な場合 (`unit` の解像度で順序どおりの有効な 2 つの Date でない選択、未知の `shows`・`unit`・`stepUnit`、`unit` そのものでも月の上の年でもない `stepUnit`、不正な `yearStartMonth
|
|
266
|
+
* @throws RangeError when an option is missing or malformed: a selection that is not two valid Dates in order at `unit` resolution, an unknown `shows`, `unit` or `stepUnit`, a `stepUnit` other than `unit` or a year over months, an invalid `yearStartMonth`, bounds that are invalid or inverted, an `allowedDates` that is supplied but is not an array (`null` included), an invalid `allowedDates` entry, or a malformed rule / オプションが欠落・不正な場合 (`unit` の解像度で順序どおりの有効な 2 つの Date でない選択、未知の `shows`・`unit`・`stepUnit`、`unit` そのものでも月の上の年でもない `stepUnit`、不正な `yearStartMonth`、不正または逆転した境界、配列でない指定値 (`null` を含む) の `allowedDates`、不正な `allowedDates` の要素、整っていない規則)
|
|
273
267
|
*/
|
|
274
268
|
export declare const resolveSelectorSteps: (options: ResolveSelectorStepsOptions) => SelectorStepTargets;
|
|
275
269
|
/**
|
|
@@ -278,16 +272,17 @@ export declare const resolveSelectorSteps: (options: ResolveSelectorStepsOptions
|
|
|
278
272
|
*
|
|
279
273
|
* Availability comes from the destinations of this render: a direction is available iff its destination is not null.
|
|
280
274
|
* A destination is an object (a date pair, a vernier commit) or null, never undefined - the type rejects a source that
|
|
281
|
-
* can yield undefined, so no absence is silently read as either answer. `onStep` reads the
|
|
282
|
-
*
|
|
283
|
-
* on every render - with a new object and a new callback each time - still hands the
|
|
284
|
-
* the selector's memo comparison skips the render unless availability changed
|
|
285
|
-
*
|
|
275
|
+
* can yield undefined, so no absence is silently read as either answer. `onStep` reads the destinations and `onStepTo`
|
|
276
|
+
* of the last committed render through one ref written in the commit phase (useCommittedRef, as the package hooks do),
|
|
277
|
+
* so an owner that recomputes them on every render - with a new object and a new callback each time - still hands the
|
|
278
|
+
* selector the same `onStep`, the selector's memo comparison skips the render unless availability changed, and a render
|
|
279
|
+
* that never commits never supplies the destination a press follows. A press on a direction whose destination
|
|
280
|
+
* disappeared after the last commit does nothing.
|
|
286
281
|
* 押せるかどうかはこの描画の行き先から決まる (行き先が null でない向きだけ押せる)。行き先はオブジェクト (日付の組、ノギスの確定内容) か
|
|
287
|
-
* null で、undefined にはならない (undefined を返し得る出所は型が拒むため、欠落をどちらかの答えへ黙って読み替えない)。`onStep`
|
|
288
|
-
* `onStepTo`
|
|
289
|
-
*
|
|
290
|
-
*
|
|
282
|
+
* null で、undefined にはならない (undefined を返し得る出所は型が拒むため、欠落をどちらかの答えへ黙って読み替えない)。`onStep` は最後に確定した
|
|
283
|
+
* 描画の行き先と `onStepTo` を、確定の段階で写す 1 つの ref (useCommittedRef。パッケージのフックと同じ) から読む。所有者が描画ごとに新しい
|
|
284
|
+
* オブジェクト・新しいコールバックで行き先を作り直しても、セレクタへ渡る `onStep` は同じで、押せるかどうかが変わらない限りセレクタのメモ比較は
|
|
285
|
+
* 描画を省き、確定しない描画の行き先へ送ることもない。最後の確定の後に行き先が消えた向きの押下は何もしない。
|
|
291
286
|
*
|
|
292
287
|
* @param targets - Destination per direction, null where a direction is unavailable / 向きごとの行き先 (押せない向きは null)
|
|
293
288
|
* @param onStepTo - Commits a destination; receives the destination and the pressed direction / 行き先を確定する関数 (行き先と押された向きを受け取る)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectorStep.d.ts","sourceRoot":"","sources":["../src/selectorStep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"selectorStep.d.ts","sourceRoot":"","sources":["../src/selectorStep.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The ref useCommittedRef returns, plus the record a state mirror keeps of the object a returned function last handed to the state it mirrors.
|
|
4
|
+
* useCommittedRef が返す ref と、ステートの写しが持つ「返す関数が最後にそのステートへ渡したオブジェクト」の記録。
|
|
5
|
+
*
|
|
6
|
+
* Only state mirrors use the record. Every hand-off a returned function makes is a plain value, never an updater, and
|
|
7
|
+
* React applies a hook's updates in the order they were queued, so while the record names the state's last queued
|
|
8
|
+
* update, the stored state ends at the recorded object. The one updater a hook's state receives is the hook's record of
|
|
9
|
+
* its own re-placement (recordPlacement), which clears the record first, because that updater may resolve to an earlier
|
|
10
|
+
* hand-off instead of the value it carries.
|
|
11
|
+
* 記録を使うのはステートの写しだけ。返す関数の受け渡しはすべて値そのもので (関数形の更新ではない)、React はフックの更新を積んだ順に
|
|
12
|
+
* 当てるため、記録がステートの最後に積んだ更新を指している間は、保存されるステートが記録したオブジェクトに行き着く。フックのステートが
|
|
13
|
+
* 受け取る更新関数はフック自身の収め直しの記録 (recordPlacement) だけで、それは先に記録を消す (その更新関数は運ぶ値ではなく前の受け渡しへ解け得るため)。
|
|
14
|
+
*/
|
|
15
|
+
export interface CommittedRef<T> extends React.RefObject<T> {
|
|
16
|
+
/**
|
|
17
|
+
* Records the object a returned function is about to pass to the mirrored state's setter.
|
|
18
|
+
* 返す関数が写すステートの設定関数へ渡そうとしているオブジェクトの記録。
|
|
19
|
+
*
|
|
20
|
+
* @param value - The object about to be handed over / これから渡すオブジェクト
|
|
21
|
+
* @returns Nothing / なし
|
|
22
|
+
*/
|
|
23
|
+
hand(value: T): void;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the ref holds the recorded object, so the state's last queued update, or its stored value, already is the held object.
|
|
26
|
+
* ref が記録したオブジェクトを持つか (ステートの最後に積んだ更新、または保存済みの値が、既に保持するオブジェクトそのものか)。
|
|
27
|
+
*/
|
|
28
|
+
readonly holdsHanded: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Drops the record, so the next commit path that settles on the held value hands it over again.
|
|
31
|
+
* 記録を消す関数 (次に保持する値へ落ち着いた確定経路は、もう一度それを渡す)。
|
|
32
|
+
*
|
|
33
|
+
* The hook's record of its own re-placement (recordPlacement) calls it before it queues its updater, because that
|
|
34
|
+
* updater may resolve to a hand-off queued before it rather than to the placed value the mirror holds.
|
|
35
|
+
* フック自身の収め直しの記録 (recordPlacement) が更新関数を積む前に呼ぶ (その更新関数は、写しが持つ置いた値ではなく、前に積まれた受け渡しへ解け得るため)。
|
|
36
|
+
*
|
|
37
|
+
* @returns Nothing / なし
|
|
38
|
+
*/
|
|
39
|
+
forgetHanded(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Drops the record unless it is the state object the running render pass holds; the hook body calls it right after it creates the mirror.
|
|
42
|
+
* 記録が、いま走っている描画の持つステートのオブジェクトでなければ記録を消す関数 (フック本体が写しを作った直後に呼ぶ)。
|
|
43
|
+
*
|
|
44
|
+
* A recorded hand-off stops being the state's last queued update in one way that shows in the next render of the hook:
|
|
45
|
+
* a hand-off made during a render (a returned function called from the host's render body) leaves the queue with that
|
|
46
|
+
* render when React throws the render away, and the restarted render holds an older state. The state this render pass
|
|
47
|
+
* holds is then not the recorded object, so the record is dropped and the next equal value is handed over again. React
|
|
48
|
+
* keeps only the state that discarded render computed, as the queue's last rendered state, which is why every hand-off
|
|
49
|
+
* a returned function makes is a plain value (recordPlacement keeps its one updater from computing on that state). The
|
|
50
|
+
* hook's record of its own re-placement clears the record and never leaves it stale.
|
|
51
|
+
* Until the hook renders again the record stands, so an equal call made between React throwing such a render away and
|
|
52
|
+
* the next render of the hook is skipped, and the value is stored once the restarted render hands it over again. A
|
|
53
|
+
* render that skips the recorded update because of its lower priority drops the record too, which costs one more
|
|
54
|
+
* hand-off of an equal value, at the caller's priority. A hand-off made while handling an event never leaves the queue
|
|
55
|
+
* before it is applied. The write only ever deletes: made in a render that never commits, it can only add a hand-off,
|
|
56
|
+
* never cause one to be skipped.
|
|
57
|
+
* 記録した受け渡しがステートの最後に積んだ更新でなくなる道は 1 つで、次のフックの描画に現れる。描画の中で行った受け渡し (ホストの描画本体から
|
|
58
|
+
* 呼んだ返す関数) は、React がその描画を捨てると描画とともにキューから消え、やり直す描画は古いステートを持つ。このときこの描画が持つステートは
|
|
59
|
+
* 記録したオブジェクトではないため、記録を消し、次の同じ値はもう一度渡す。React が残すのは捨てた描画が求めたステートだけで、キューの最後に
|
|
60
|
+
* 描いたステートとして残る (返す関数の受け渡しを値そのものに限るのはこのためで、recordPlacement は唯一の更新関数にそのステートから計算させない)。
|
|
61
|
+
* フック自身の収め直しの記録は記録を消すため、記録を古くしない。次にフックを描くまでは記録が残るため、React がそうした描画を捨ててから
|
|
62
|
+
* 次にフックを描くまでの同じ値の呼び出しは省かれ、値はやり直した描画がもう一度渡したときに保存される。記録した更新を優先度が低いために
|
|
63
|
+
* 飛ばした描画も記録を消すが、同じ値の受け渡しが呼び出し側の優先度で 1 度増えるだけである。事象の処理中に行った受け渡しは、当てられる前に
|
|
64
|
+
* キューから消えることがない。この書き込みは消すだけで、確定しない描画で行っても受け渡しが増えるだけであり、省く判断は生まない。
|
|
65
|
+
*
|
|
66
|
+
* @param state - The state object this render pass holds (the useState value, before the render derives the re-placed value) / この描画が持つステートのオブジェクト (描画が収め直した値を導く前の useState の値)
|
|
67
|
+
* @returns Nothing / なし
|
|
68
|
+
*/
|
|
69
|
+
forgetHandedUnless(state: T): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Mirrors a value of the committed render into a ref that the functions a hook returns, or a component's own functions that outlive their render, read at event time.
|
|
73
|
+
* 確定した描画の値を、フックの返す関数やコンポーネントの描画より長く生きる自分の関数が事象の時点で読む ref へ写すフック。
|
|
74
|
+
*
|
|
75
|
+
* React runs a component body for renders it discards or leaves suspended (a transition waiting on Suspense, an
|
|
76
|
+
* interrupted concurrent render), so the copy is made in the commit phase, as an insertion effect: React runs it before
|
|
77
|
+
* every layout effect of the commit and also for commits inside a hidden Activity, so a descendant's layout effect and a
|
|
78
|
+
* hidden tree read the commit they belong to. The returned functions may write the ref while handling an event (a setter
|
|
79
|
+
* records the value it handed to the state); a commit copies its render's value only when no such write happened after
|
|
80
|
+
* that render ran, because a time-sliced render can run before an event and commit after it with an older value. The ref
|
|
81
|
+
* object keeps its identity for the life of the component, so a function that reads it keeps its own. While a render is
|
|
82
|
+
* in progress the ref still holds the last committed value, not the value of that render. A state mirror also carries the
|
|
83
|
+
* record of the object a returned function last handed to the state (CommittedRef.hand / holdsHanded), which the hook
|
|
84
|
+
* body clears with CommittedRef.forgetHandedUnless right after this call, and the hook's record of its own re-placement
|
|
85
|
+
* with CommittedRef.forgetHanded.
|
|
86
|
+
* React は捨てる描画や中断したままの描画 (Suspense を待つ移行、割り込まれた並行描画) でも本体を走らせるため、写しは確定の段階で
|
|
87
|
+
* 挿入副作用として行う (確定のどのレイアウト副作用よりも前に、隠れた Activity の中の確定でも走る。子孫のレイアウト副作用も隠れた木も、
|
|
88
|
+
* 自分が属する確定の値を読む)。返す関数は事象の処理中に ref へ書いてよく (設定関数はステートへ渡した値を記録する)、確定はその描画が
|
|
89
|
+
* 走った後に書き込みが無かったときだけ、その描画の値を写す (時間分割した描画は事象の前に走って事象の後に確定することがあり、その値は
|
|
90
|
+
* 書き込みより古い)。ref オブジェクトはコンポーネントの存続中ずっと同じで、それを読む関数の同一性も保たれる。描画の途中の ref は、
|
|
91
|
+
* その描画の値ではなく最後に確定した値を持つ。ステートの写しは、返す関数が最後にステートへ渡したオブジェクトの記録も持ち
|
|
92
|
+
* (CommittedRef.hand / holdsHanded)、フック本体はこの呼び出しの直後に CommittedRef.forgetHandedUnless で、フック自身の収め直しの記録は
|
|
93
|
+
* CommittedRef.forgetHanded でそれを消す。
|
|
94
|
+
*
|
|
95
|
+
* @param value - The value this render holds / この描画が持つ値
|
|
96
|
+
* @returns A ref holding the value of the last committed render (the first render's value until the first commit), or a later value a returned function wrote, with the hand-off record (empty until a returned function hands an object) / 最後に確定した描画の値 (最初の確定までは最初の描画の値)、またはその後に返す関数が書いた値を持つ ref と、受け渡しの記録 (返す関数がオブジェクトを渡すまでは空)
|
|
97
|
+
*/
|
|
98
|
+
export declare function useCommittedRef<T>(value: T): CommittedRef<T>;
|
|
99
|
+
//# sourceMappingURL=useCommittedRef.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCommittedRef.d.ts","sourceRoot":"","sources":["../src/useCommittedRef.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACvD;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;IAEpB;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAE7B;;;;;;;;;OASG;IACH,YAAY,IAAI,IAAI,CAAA;IAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,kBAAkB,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;CACrC;AAoHD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAS5D"}
|