lilact 0.26.0 → 0.26.2
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/lilact.development.js +148 -85
- package/dist/lilact.development.js.map +3 -3
- package/dist/lilact.development.min.js +25 -25
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +25 -25
- package/docs/functions/timers.timeoutPromise.html +1 -1
- package/docs/static/lilact.development.js +148 -85
- package/docs/static/lilact.development.js.map +3 -3
- package/docs/static/lilact.development.min.js +25 -25
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +25 -25
- package/docs/variables/accessories.SplitPane.html +1 -1
- package/examples/lilact.development.js +148 -85
- package/examples/lilact.development.js.map +3 -3
- package/examples/lilact.development.min.js +25 -25
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +25 -25
- package/package.json +1 -1
- package/src/accessories.jsx +386 -262
|
@@ -4970,7 +4970,7 @@ var SplitPane = forwardRef(function SplitPane2({
|
|
|
4970
4970
|
max = 0.9,
|
|
4971
4971
|
splitterSize = 8,
|
|
4972
4972
|
onSizeChange,
|
|
4973
|
-
|
|
4973
|
+
resizePolicy = "proportional",
|
|
4974
4974
|
style,
|
|
4975
4975
|
className,
|
|
4976
4976
|
firstPaneStyle,
|
|
@@ -4981,94 +4981,144 @@ var SplitPane = forwardRef(function SplitPane2({
|
|
|
4981
4981
|
}, ref) {
|
|
4982
4982
|
const containerRef = useRef(null);
|
|
4983
4983
|
const sizeRef = useRef({ w: 0, h: 0 });
|
|
4984
|
-
const
|
|
4985
|
-
const
|
|
4986
|
-
const [internalPos, setInternalPos] = useState(
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
mode === "verical" ? sizeRef.current.h : sizeRef.current.w,
|
|
4991
|
-
splitterSize
|
|
4992
|
-
));
|
|
4993
|
-
let posResolved = position2 == null ? internalPos : position2;
|
|
4994
|
-
posResolved = clamp(
|
|
4995
|
-
posResolved,
|
|
4996
|
-
min,
|
|
4997
|
-
max,
|
|
4998
|
-
mode === "verical" ? sizeRef.current.h : sizeRef.current.w,
|
|
4999
|
-
splitterSize
|
|
5000
|
-
);
|
|
4984
|
+
const [internalMode, setInternalMode] = useState(mode === "vertical" ? "vertical" : "horizontal");
|
|
4985
|
+
const internalModeRef = useRef(internalMode);
|
|
4986
|
+
const [internalPos, setInternalPos] = useState(defaultPosition);
|
|
4987
|
+
const internalPosRef = useRef(internalPos);
|
|
4988
|
+
const effectivePosRef = useRef(void 0);
|
|
4989
|
+
const resizePolicyRef = useRef(resizePolicy);
|
|
5001
4990
|
useEffect(() => {
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
min,
|
|
5006
|
-
max,
|
|
5007
|
-
mode === "verical" ? sizeRef.current.h : sizeRef.current.w,
|
|
5008
|
-
splitterSize
|
|
5009
|
-
));
|
|
5010
|
-
}, [position2, min, max]);
|
|
4991
|
+
resizePolicyRef.current = resizePolicy;
|
|
4992
|
+
}, [resizePolicy]);
|
|
4993
|
+
internalModeRef.current = internalMode;
|
|
5011
4994
|
useEffect(() => {
|
|
4995
|
+
internalPosRef.current = internalPos;
|
|
4996
|
+
}, [internalPos]);
|
|
4997
|
+
useLayoutEffect(() => {
|
|
5012
4998
|
setInternalMode(mode === "vertical" ? "vertical" : "horizontal");
|
|
5013
4999
|
}, [mode]);
|
|
5000
|
+
const clampWithSize = (v, modeNow, w2, h2) => {
|
|
5001
|
+
const size = modeNow === "vertical" ? h2 : w2;
|
|
5002
|
+
return clamp(v, min, max, size, splitterSize);
|
|
5003
|
+
};
|
|
5004
|
+
const posResolved = useMemo(() => {
|
|
5005
|
+
const raw = position2 == null ? internalPos : position2;
|
|
5006
|
+
const { w: w2, h: h2 } = sizeRef.current;
|
|
5007
|
+
const hasSize = mode === "vertical" ? h2 > 0 : w2 > 0;
|
|
5008
|
+
if (!hasSize) return raw;
|
|
5009
|
+
return clampWithSize(raw, internalModeRef.current, w2, h2);
|
|
5010
|
+
}, [position2, internalPos, min, max, splitterSize, mode]);
|
|
5011
|
+
useEffect(() => {
|
|
5012
|
+
effectivePosRef.current = posResolved;
|
|
5013
|
+
}, [posResolved]);
|
|
5014
5014
|
const setPosition = (next2) => {
|
|
5015
|
-
const
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5015
|
+
const modeNow = internalModeRef.current;
|
|
5016
|
+
const { w: w2, h: h2 } = sizeRef.current;
|
|
5017
|
+
if (modeNow === "vertical" ? h2 <= 0 : w2 <= 0) {
|
|
5018
|
+
if (position2 == null) setInternalPos(next2);
|
|
5019
|
+
onSizeChange == null ? void 0 : onSizeChange(next2);
|
|
5020
|
+
return;
|
|
5021
|
+
}
|
|
5022
|
+
const clamped = clampWithSize(next2, modeNow, w2, h2);
|
|
5022
5023
|
if (position2 == null) setInternalPos(clamped);
|
|
5024
|
+
effectivePosRef.current = clamped;
|
|
5023
5025
|
onSizeChange == null ? void 0 : onSizeChange(clamped);
|
|
5024
5026
|
};
|
|
5025
5027
|
useImperativeHandle(ref, () => ({
|
|
5026
5028
|
setPosition,
|
|
5027
5029
|
setMode: (nextMode) => setInternalMode(nextMode === "vertical" ? "vertical" : "horizontal"),
|
|
5028
|
-
getPosition: () =>
|
|
5029
|
-
|
|
5030
|
+
getPosition: () => {
|
|
5031
|
+
var _a;
|
|
5032
|
+
return (_a = effectivePosRef.current) != null ? _a : posResolved;
|
|
5033
|
+
},
|
|
5034
|
+
getMode: () => internalModeRef.current
|
|
5030
5035
|
}));
|
|
5036
|
+
const didInitRef = useRef(false);
|
|
5031
5037
|
useLayoutEffect(() => {
|
|
5032
5038
|
const el = containerRef.current;
|
|
5033
5039
|
if (!el) return;
|
|
5034
|
-
const ro = new ResizeObserver(() => {
|
|
5040
|
+
const ro = new ResizeObserver((entries) => {
|
|
5035
5041
|
var _a;
|
|
5036
|
-
const
|
|
5037
|
-
const
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5042
|
+
const rect = el.getBoundingClientRect();
|
|
5043
|
+
const prev2 = sizeRef.current;
|
|
5044
|
+
const nextSize = { w: rect.width, h: rect.height };
|
|
5045
|
+
sizeRef.current = nextSize;
|
|
5046
|
+
const modeNow = internalModeRef.current;
|
|
5047
|
+
const hadSize = modeNow === "vertical" ? prev2.h > 0 : prev2.w > 0;
|
|
5048
|
+
const hasSizeNow = modeNow === "vertical" ? nextSize.h > 0 : nextSize.w > 0;
|
|
5049
|
+
if (!didInitRef.current && hasSizeNow) {
|
|
5050
|
+
didInitRef.current = true;
|
|
5051
|
+
const raw = position2 == null ? internalPosRef.current : position2;
|
|
5052
|
+
const clamped = clampWithSize(raw, modeNow, nextSize.w, nextSize.h);
|
|
5053
|
+
if (position2 == null) setInternalPos(clamped);
|
|
5054
|
+
effectivePosRef.current = clamped;
|
|
5055
|
+
onSizeChange == null ? void 0 : onSizeChange(clamped);
|
|
5056
|
+
return;
|
|
5057
|
+
}
|
|
5058
|
+
if (!hadSize || !hasSizeNow) return;
|
|
5059
|
+
const p2 = (_a = effectivePosRef.current) != null ? _a : posResolved;
|
|
5060
|
+
const rp = resizePolicyRef.current;
|
|
5061
|
+
const s = splitterSize;
|
|
5062
|
+
if (rp === "fixFirst") {
|
|
5063
|
+
if (modeNow === "vertical") {
|
|
5064
|
+
const availOld = prev2.h - s;
|
|
5065
|
+
const availNew = nextSize.h - s;
|
|
5066
|
+
if (availOld > 0 && availNew > 0) {
|
|
5067
|
+
const firstPx = p2 * availOld;
|
|
5068
|
+
const nextP = firstPx / availNew;
|
|
5069
|
+
if (Math.abs(nextP - p2) > EPS) setPosition(nextP);
|
|
5070
|
+
}
|
|
5071
|
+
} else {
|
|
5072
|
+
const availOld = prev2.w - s;
|
|
5073
|
+
const availNew = nextSize.w - s;
|
|
5074
|
+
if (availOld > 0 && availNew > 0) {
|
|
5075
|
+
const firstPx = p2 * availOld;
|
|
5076
|
+
const nextP = firstPx / availNew;
|
|
5077
|
+
if (Math.abs(nextP - p2) > EPS) setPosition(nextP);
|
|
5045
5078
|
}
|
|
5046
|
-
}
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5079
|
+
}
|
|
5080
|
+
} else if (rp === "fixSecond") {
|
|
5081
|
+
if (modeNow === "vertical") {
|
|
5082
|
+
const availOld = prev2.h - s;
|
|
5083
|
+
const availNew = nextSize.h - s;
|
|
5084
|
+
if (availOld > 0 && availNew > 0) {
|
|
5085
|
+
const secondPx = (1 - p2) * availOld;
|
|
5086
|
+
const nextP = 1 - secondPx / availNew;
|
|
5087
|
+
if (Math.abs(nextP - p2) > EPS) setPosition(nextP);
|
|
5088
|
+
}
|
|
5089
|
+
} else {
|
|
5090
|
+
const availOld = prev2.w - s;
|
|
5091
|
+
const availNew = nextSize.w - s;
|
|
5092
|
+
if (availOld > 0 && availNew > 0) {
|
|
5093
|
+
const secondPx = (1 - p2) * availOld;
|
|
5094
|
+
const nextP = 1 - secondPx / availNew;
|
|
5095
|
+
if (Math.abs(nextP - p2) > EPS) setPosition(nextP);
|
|
5051
5096
|
}
|
|
5052
5097
|
}
|
|
5053
5098
|
}
|
|
5054
5099
|
});
|
|
5055
5100
|
ro.observe(el);
|
|
5056
|
-
const rect = el.getBoundingClientRect();
|
|
5057
|
-
sizeRef.current = { w: rect.width, h: rect.height };
|
|
5058
5101
|
return () => ro.disconnect();
|
|
5059
|
-
}, [
|
|
5102
|
+
}, [min, max, splitterSize, onSizeChange, position2]);
|
|
5060
5103
|
const startPosRef = useRef(posResolved);
|
|
5061
5104
|
const [dragging, setDragging] = useState(false);
|
|
5105
|
+
useEffect(() => {
|
|
5106
|
+
if (!dragging) startPosRef.current = posResolved;
|
|
5107
|
+
}, [posResolved, dragging]);
|
|
5062
5108
|
const handleStart = () => {
|
|
5109
|
+
var _a;
|
|
5063
5110
|
setDragging(true);
|
|
5064
|
-
startPosRef.current = posResolved;
|
|
5111
|
+
startPosRef.current = (_a = effectivePosRef.current) != null ? _a : posResolved;
|
|
5065
5112
|
};
|
|
5066
|
-
const handleDelta = (x, y
|
|
5113
|
+
const handleDelta = (x, y) => {
|
|
5114
|
+
const modeNow = internalModeRef.current;
|
|
5067
5115
|
const { w: w2, h: h2 } = sizeRef.current;
|
|
5068
|
-
if (
|
|
5069
|
-
|
|
5116
|
+
if (modeNow === "horizontal") {
|
|
5117
|
+
const denom = w2 > 0 ? w2 : 1;
|
|
5118
|
+
setPosition(startPosRef.current + x / denom);
|
|
5070
5119
|
} else {
|
|
5071
|
-
|
|
5120
|
+
const denom = h2 > 0 ? h2 : 1;
|
|
5121
|
+
setPosition(startPosRef.current + y / denom);
|
|
5072
5122
|
}
|
|
5073
5123
|
};
|
|
5074
5124
|
const handleEnd = () => setDragging(false);
|
|
@@ -5104,22 +5154,26 @@ var SplitPane = forwardRef(function SplitPane2({
|
|
|
5104
5154
|
if (internalMode === "horizontal") {
|
|
5105
5155
|
computedPane1Style.bottom = 0;
|
|
5106
5156
|
computedPane2Style.top = 0;
|
|
5107
|
-
if (
|
|
5108
|
-
|
|
5109
|
-
|
|
5157
|
+
if (resizePolicy === "fixFirst") {
|
|
5158
|
+
const ww = w - splitterSize;
|
|
5159
|
+
const pane1W = ww > 0 ? p * ww : 0;
|
|
5160
|
+
computedPane1Style.width = pane1W;
|
|
5161
|
+
computedPane2Style.left = pane1W + splitterSize;
|
|
5110
5162
|
Object.assign(computedSplitterStyle, {
|
|
5111
5163
|
top: 0,
|
|
5112
5164
|
bottom: 0,
|
|
5113
|
-
left:
|
|
5165
|
+
left: pane1W,
|
|
5114
5166
|
width: splitterSize
|
|
5115
5167
|
});
|
|
5116
|
-
} else if (
|
|
5117
|
-
|
|
5118
|
-
|
|
5168
|
+
} else if (resizePolicy === "fixSecond") {
|
|
5169
|
+
const ww = w - splitterSize;
|
|
5170
|
+
const pane2W = ww > 0 ? (1 - p) * ww : 0;
|
|
5171
|
+
computedPane2Style.width = pane2W;
|
|
5172
|
+
computedPane1Style.right = pane2W + splitterSize;
|
|
5119
5173
|
Object.assign(computedSplitterStyle, {
|
|
5120
5174
|
top: 0,
|
|
5121
5175
|
bottom: 0,
|
|
5122
|
-
|
|
5176
|
+
right: pane2W,
|
|
5123
5177
|
width: splitterSize
|
|
5124
5178
|
});
|
|
5125
5179
|
} else {
|
|
@@ -5135,22 +5189,26 @@ var SplitPane = forwardRef(function SplitPane2({
|
|
|
5135
5189
|
} else {
|
|
5136
5190
|
computedPane1Style.right = 0;
|
|
5137
5191
|
computedPane2Style.left = 0;
|
|
5138
|
-
if (
|
|
5139
|
-
|
|
5140
|
-
|
|
5192
|
+
if (resizePolicy === "fixFirst") {
|
|
5193
|
+
const hh = h - splitterSize;
|
|
5194
|
+
const pane1H = hh > 0 ? p * hh : 0;
|
|
5195
|
+
computedPane1Style.height = pane1H;
|
|
5196
|
+
computedPane2Style.top = pane1H + splitterSize;
|
|
5141
5197
|
Object.assign(computedSplitterStyle, {
|
|
5142
5198
|
left: 0,
|
|
5143
5199
|
right: 0,
|
|
5144
|
-
top:
|
|
5200
|
+
top: pane1H,
|
|
5145
5201
|
height: splitterSize
|
|
5146
5202
|
});
|
|
5147
|
-
} else if (
|
|
5148
|
-
|
|
5149
|
-
|
|
5203
|
+
} else if (resizePolicy === "fixSecond") {
|
|
5204
|
+
const hh = h - splitterSize;
|
|
5205
|
+
const pane2H = hh > 0 ? (1 - p) * hh : 0;
|
|
5206
|
+
computedPane2Style.height = pane2H;
|
|
5207
|
+
computedPane1Style.bottom = pane2H + splitterSize;
|
|
5150
5208
|
Object.assign(computedSplitterStyle, {
|
|
5151
5209
|
left: 0,
|
|
5152
5210
|
right: 0,
|
|
5153
|
-
bottom:
|
|
5211
|
+
bottom: pane2H,
|
|
5154
5212
|
height: splitterSize
|
|
5155
5213
|
});
|
|
5156
5214
|
} else {
|
|
@@ -5170,18 +5228,23 @@ var SplitPane = forwardRef(function SplitPane2({
|
|
|
5170
5228
|
height: "100%",
|
|
5171
5229
|
overflow: "hidden",
|
|
5172
5230
|
...style || {}
|
|
5173
|
-
} }, createComponent("div", { "style": computedPane1Style }, firstChild), createComponent("div", { "style": computedPane2Style }, secondChild), createComponent(DragHandle, { "onStart": handleStart, "onDelta": handleDelta, "onEnd": handleEnd, "style": computedSplitterStyle, "className": "splitter" }, splitterChild));
|
|
5231
|
+
} }, createComponent("div", { "style": computedPane1Style }, firstChild), createComponent("div", { "style": computedPane2Style }, secondChild), createComponent(DragHandle, { "key": internalMode, "onStart": handleStart, "onDelta": handleDelta, "onEnd": handleEnd, "style": computedSplitterStyle, "className": "splitter" }, splitterChild));
|
|
5174
5232
|
});
|
|
5233
|
+
var EPS = 1e-6;
|
|
5175
5234
|
var clamp = function(v, min, max, size, splitterSize) {
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5235
|
+
let _min = min;
|
|
5236
|
+
let _max = max;
|
|
5237
|
+
if (typeof _min === "function") {
|
|
5238
|
+
if (size > 0) _min = _min(size, splitterSize);
|
|
5239
|
+
else _min = 0;
|
|
5240
|
+
}
|
|
5241
|
+
if (typeof _max === "function") {
|
|
5242
|
+
if (size > 0) _max = _max(size, splitterSize);
|
|
5243
|
+
else _max = 1;
|
|
5244
|
+
}
|
|
5245
|
+
_min = Math.max(0, Math.min(_min, 1));
|
|
5246
|
+
_max = Math.max(0, Math.min(_max, 1));
|
|
5247
|
+
return Math.max(_min, Math.min(_max, v));
|
|
5185
5248
|
};
|
|
5186
5249
|
|
|
5187
5250
|
// .tmp/src/vlq.js
|