@aiquants/resize-panels 1.9.0 → 2.0.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/README.md +129 -22
- package/dist/GlobalDebugOverlay-Cf3GOn2A.cjs +1 -0
- package/dist/{GlobalDebugOverlay-Do70T2l6.js → GlobalDebugOverlay-DQtUdNeF.js} +28 -28
- package/dist/debugOverlayStore-D7FT6zPE.js +135 -0
- package/dist/debugOverlayStore-DY09saU8.cjs +1 -0
- package/dist/index-DZ0itiBD.js +1299 -0
- package/dist/index-DqATP_BA.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -29
- package/dist/index.js +25 -13
- package/dist/src/GlobalDebugOverlay.d.ts.map +1 -0
- package/dist/src/Panel.d.ts +46 -0
- package/dist/src/Panel.d.ts.map +1 -0
- package/dist/src/PanelDebugInfo.d.ts +34 -0
- package/dist/src/PanelDebugInfo.d.ts.map +1 -0
- package/dist/src/PanelGroup.d.ts.map +1 -0
- package/dist/src/PanelResizeHandle.d.ts.map +1 -0
- package/dist/src/allocateLayout.d.ts +60 -0
- package/dist/src/allocateLayout.d.ts.map +1 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/{debugOverlayStore.d.ts → src/debugOverlayStore.d.ts} +10 -2
- package/dist/src/debugOverlayStore.d.ts.map +1 -0
- package/dist/src/hooks.d.ts +48 -0
- package/dist/src/hooks.d.ts.map +1 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/reducer.d.ts +49 -0
- package/dist/src/reducer.d.ts.map +1 -0
- package/dist/src/roundHalfToEven.d.ts.map +1 -0
- package/dist/{types.d.ts → src/types.d.ts} +164 -60
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/simple-logger.d.ts.map +1 -0
- package/dist/src/utils.d.ts +164 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/styles/resize-panels.standalone.css +1 -1
- package/dist/tests/support/dom-harness.d.ts +89 -0
- package/dist/tests/support/dom-harness.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/GlobalDebugOverlay.tsx +3 -3
- package/src/Panel.tsx +203 -541
- package/src/PanelDebugInfo.tsx +52 -106
- package/src/PanelGroup.tsx +27 -42
- package/src/PanelResizeHandle.tsx +470 -509
- package/src/allocateLayout.ts +412 -0
- package/src/debugOverlayStore.ts +19 -15
- package/src/hooks.ts +187 -779
- package/src/index.ts +12 -3
- package/src/reducer.ts +364 -1126
- package/src/types.ts +149 -63
- package/src/utils.ts +205 -164
- package/dist/GlobalDebugOverlay-sEQN6exo.cjs +0 -1
- package/dist/GlobalDebugOverlay.d.ts.map +0 -1
- package/dist/Panel.d.ts +0 -7
- package/dist/Panel.d.ts.map +0 -1
- package/dist/PanelDebugInfo.d.ts +0 -26
- package/dist/PanelDebugInfo.d.ts.map +0 -1
- package/dist/PanelGroup.d.ts.map +0 -1
- package/dist/PanelResizeHandle.d.ts.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/debugOverlayStore-Cntyxboe.js +0 -141
- package/dist/debugOverlayStore-Dkl-fHoa.cjs +0 -1
- package/dist/debugOverlayStore.d.ts.map +0 -1
- package/dist/hooks.d.ts +0 -45
- package/dist/hooks.d.ts.map +0 -1
- package/dist/index-B6YGX2DH.js +0 -2009
- package/dist/index-DssZUxGw.cjs +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/reducer.d.ts +0 -39
- package/dist/reducer.d.ts.map +0 -1
- package/dist/roundHalfToEven.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/simple-logger.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -61
- package/dist/utils.d.ts.map +0 -1
- /package/dist/{GlobalDebugOverlay.d.ts → src/GlobalDebugOverlay.d.ts} +0 -0
- /package/dist/{PanelGroup.d.ts → src/PanelGroup.d.ts} +0 -0
- /package/dist/{PanelResizeHandle.d.ts → src/PanelResizeHandle.d.ts} +0 -0
- /package/dist/{context.d.ts → src/context.d.ts} +0 -0
- /package/dist/{roundHalfToEven.d.ts → src/roundHalfToEven.d.ts} +0 -0
- /package/dist/{utils → src/utils}/simple-logger.d.ts +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Shared jsdom harness for panel group component tests.
|
|
3
|
+
* パネルグループのコンポーネントテスト用 jsdom 共通ハーネス。
|
|
4
|
+
*
|
|
5
|
+
* jsdom does not lay out flex containers, so the harness supplies the one measurement the package reads
|
|
6
|
+
* from the DOM — the group's box — and lets the assertions work on the allocator's state and on the inline
|
|
7
|
+
* styles the components render from it.
|
|
8
|
+
* jsdom はフレックスレイアウトを行わないため、パッケージが DOM から読む唯一の計測値 (グループの矩形) を
|
|
9
|
+
* ハーネスが与え、検証は配分器の状態とそこから描画されるインラインスタイルに対して行う。
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Observer stub that re-invokes its callback on demand.
|
|
13
|
+
* 任意のタイミングでコールバックを再実行できる ResizeObserver スタブ。
|
|
14
|
+
*/
|
|
15
|
+
declare class ManualResizeObserver implements ResizeObserver {
|
|
16
|
+
static instances: ManualResizeObserver[];
|
|
17
|
+
readonly callback: ResizeObserverCallback;
|
|
18
|
+
readonly targets: Element[];
|
|
19
|
+
disconnected: boolean;
|
|
20
|
+
constructor(callback: ResizeObserverCallback);
|
|
21
|
+
/**
|
|
22
|
+
* Build the observation a browser would deliver for one target.
|
|
23
|
+
* ブラウザが 1 つの対象について届ける観測結果を組み立てる処理。
|
|
24
|
+
*/
|
|
25
|
+
entriesFor: (target: Element) => ResizeObserverEntry[];
|
|
26
|
+
observe: (target: Element) => void;
|
|
27
|
+
unobserve: () => void;
|
|
28
|
+
disconnect: () => void;
|
|
29
|
+
takeRecords: () => ResizeObserverEntry[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Give an element a fixed box so `getContainerSize` can measure it.
|
|
33
|
+
* `getContainerSize` が計測できるよう、要素へ固定の矩形を与える処理。
|
|
34
|
+
*
|
|
35
|
+
* @param element - Element to measure / 計測対象の要素
|
|
36
|
+
* @param width - Border-box width in pixels / 境界領域の幅 (px)
|
|
37
|
+
* @param height - Border-box height in pixels / 境界領域の高さ (px)
|
|
38
|
+
*/
|
|
39
|
+
export declare const setElementBox: (element: HTMLElement, width: number, height: number) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Install the observer stub and clear the instances collected by a previous test.
|
|
42
|
+
* オブザーバースタブを導入し、直前のテストで収集したインスタンスを破棄する処理。
|
|
43
|
+
*
|
|
44
|
+
* @returns Accessor for the observers created during the test / テスト中に生成されたオブザーバーへのアクセサ
|
|
45
|
+
*/
|
|
46
|
+
export declare const installResizeObserver: () => {
|
|
47
|
+
readonly instances: ManualResizeObserver[];
|
|
48
|
+
/**
|
|
49
|
+
* Re-run every live observer callback, as the browser would after a layout change.
|
|
50
|
+
* レイアウト変化後にブラウザが行うのと同様、生存中の全オブザーバーのコールバックを再実行する処理。
|
|
51
|
+
*/
|
|
52
|
+
flush: () => void;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Resize the group element and notify the observers, as a real container resize would.
|
|
56
|
+
* グループ要素をリサイズしてオブザーバーへ通知する (実際のコンテナリサイズ相当) 処理。
|
|
57
|
+
*
|
|
58
|
+
* @param group - Group element to resize / リサイズするグループ要素
|
|
59
|
+
* @param observers - Observer accessor returned by `installResizeObserver` / オブザーバーアクセサ
|
|
60
|
+
* @param width - New border-box width in pixels / 新しい境界領域の幅 (px)
|
|
61
|
+
* @param height - New border-box height in pixels / 新しい境界領域の高さ (px)
|
|
62
|
+
*/
|
|
63
|
+
export declare const resizeGroup: (group: HTMLElement, observers: ReturnType<typeof installResizeObserver>, width: number, height: number) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Read the panel elements of one group in DOM order.
|
|
66
|
+
* 1 つのグループに属するパネル要素を DOM 順で取得する処理。
|
|
67
|
+
*
|
|
68
|
+
* @param group - Group element / グループ要素
|
|
69
|
+
* @returns Panel elements that are direct children of the group / グループ直下のパネル要素
|
|
70
|
+
*/
|
|
71
|
+
export declare const getPanelElements: (group: HTMLElement) => HTMLElement[];
|
|
72
|
+
/**
|
|
73
|
+
* Read the allocated sizes the panels published through their data attributes.
|
|
74
|
+
* パネルが data 属性で公開している配分済みサイズを読み取る処理。
|
|
75
|
+
*
|
|
76
|
+
* @param group - Group element / グループ要素
|
|
77
|
+
* @returns Allocated sizes in DOM order / DOM 順の配分済みサイズ
|
|
78
|
+
*/
|
|
79
|
+
export declare const getPanelSizes: (group: HTMLElement) => number[];
|
|
80
|
+
/**
|
|
81
|
+
* Read the flex basis each panel rendered, in pixels.
|
|
82
|
+
* 各パネルが描画した flex basis をピクセルで読み取る処理。
|
|
83
|
+
*
|
|
84
|
+
* @param group - Group element / グループ要素
|
|
85
|
+
* @returns Rendered flex basis values in DOM order / DOM 順の flex basis 値 (px)
|
|
86
|
+
*/
|
|
87
|
+
export declare const getRenderedBases: (group: HTMLElement) => number[];
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=dom-harness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-harness.d.ts","sourceRoot":"","sources":["../../../tests/support/dom-harness.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH;;;GAGG;AACH,cAAM,oBAAqB,YAAW,cAAc;IAChD,MAAM,CAAC,SAAS,EAAE,oBAAoB,EAAE,CAAK;IAE7C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAA;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,CAAK;IAChC,YAAY,UAAQ;gBAER,QAAQ,EAAE,sBAAsB;IAK5C;;;OAGG;IACH,UAAU,GAAI,QAAQ,OAAO,KAAG,mBAAmB,EAAE,CAepD;IAED,OAAO,GAAI,QAAQ,OAAO,KAAG,IAAI,CAGhC;IAED,SAAS,QAAO,IAAI,CAAM;IAE1B,UAAU,QAAO,IAAI,CAEpB;IAED,WAAW,QAAO,mBAAmB,EAAE,CAAM;CAChD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,WAAW,EAAE,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,IASnF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;IAO1B;;;OAGG;;CAcV,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,WAAW,EAAE,WAAW,UAAU,CAAC,OAAO,qBAAqB,CAAC,EAAE,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,IAGpI,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,WAAW,KAAG,WAAW,EAA8H,CAAA;AAE/L;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,WAAW,KAAG,MAAM,EAA6E,CAAA;AAEtI;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,WAAW,KAAG,MAAM,EAQtD,CAAA"}
|
package/package.json
CHANGED
|
@@ -225,7 +225,7 @@ export const GlobalDebugOverlay = () => {
|
|
|
225
225
|
const measuredPixel = panel.measuredPixelSize ?? panel.size
|
|
226
226
|
const statePixel = panel.size
|
|
227
227
|
const statePixelLabel = formatNumericValue(statePixel, "px")
|
|
228
|
-
const statePercentage =
|
|
228
|
+
const statePercentage = axisSize > 0 ? (panel.size / axisSize) * 100 : undefined
|
|
229
229
|
const measuredPercentage = panel.measuredPercentageSize !== undefined ? panel.measuredPercentageSize : axisSize > 0 ? (measuredPixel / axisSize) * 100 : undefined
|
|
230
230
|
const isHidden = panel.collapsed || measuredPixel <= PANEL_SNAP_THRESHOLD
|
|
231
231
|
const statusLabel = panel.collapsed ? "collapsed" : isHidden ? "hidden" : "visible"
|
|
@@ -253,14 +253,14 @@ export const GlobalDebugOverlay = () => {
|
|
|
253
253
|
<span>{measuredPixelLabel}</span>
|
|
254
254
|
<span>percentage (state):</span>
|
|
255
255
|
<span>{percentageLabel}</span>
|
|
256
|
+
<span>preference:</span>
|
|
257
|
+
<span>{panel.sizeUnit === "pixels" ? formatNumericValue(panel.preferredPixelSize, "px") : formatNumericValue(panel.preferredPercentageSize, "%")}</span>
|
|
256
258
|
<span>percentage (measured):</span>
|
|
257
259
|
<span>{measuredPercentageLabel}</span>
|
|
258
260
|
<span>unit:</span>
|
|
259
261
|
<span>{panel.sizeUnit}</span>
|
|
260
262
|
<span>min:</span>
|
|
261
263
|
<span>{panel.minSize !== undefined ? JSON.stringify(panel.minSize) : "—"}</span>
|
|
262
|
-
<span>auto min:</span>
|
|
263
|
-
<span>{panel.autoMinSize !== undefined ? JSON.stringify(panel.autoMinSize) : "—"}</span>
|
|
264
264
|
<span>max:</span>
|
|
265
265
|
<span>{panel.maxSize !== undefined ? JSON.stringify(panel.maxSize) : "—"}</span>
|
|
266
266
|
<span>priority:</span>
|