lilact 0.16.1 → 0.16.3
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/bin/copy-demo.js +1 -1
- package/dist/lilact.development.js +132 -122
- package/dist/lilact.development.js.map +3 -3
- package/dist/lilact.development.min.js +23 -23
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +23 -23
- package/docs/classes/accessories.ErrorBoundary.html +8 -8
- package/docs/classes/accessories.Suspense.html +7 -7
- package/docs/classes/components.Component.html +11 -11
- package/docs/classes/components.HTMLComponent.html +11 -11
- package/docs/classes/components.RootComponent.html +11 -11
- package/docs/functions/accessories.DragHandle.html +2 -2
- package/docs/functions/components.createComponent.html +1 -1
- package/docs/functions/components.createRoot.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +1 -1
- package/docs/static/demos/pane.jsx +2 -1
- package/docs/static/lilact.development.js +132 -122
- package/docs/static/lilact.development.js.map +3 -3
- package/docs/static/lilact.development.min.js +23 -23
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +23 -23
- package/docs/variables/accessories.SplitPane.html +2 -2
- package/{root → examples}/demos/pane.jsx +2 -1
- package/{root → examples}/lilact.development.js +132 -122
- package/examples/lilact.development.js.map +7 -0
- package/examples/lilact.development.min.js +107 -0
- package/examples/lilact.development.min.js.map +7 -0
- package/examples/lilact.production.min.js +106 -0
- package/package.json +3 -3
- package/scripts/build.mjs +29 -0
- package/scripts/copy-dist-to-examples.mjs +42 -0
- package/scripts/esbuild-preprocessor-plugin.cjs +29 -4
- package/scripts/preprocess.mjs +29 -1
- package/src/accessories.jsx +236 -246
- package/src/components.jsx +19 -7
- package/typedoc.json +1 -1
- package/root/lilact.development.js.map +0 -7
- package/root/lilact.development.min.js +0 -107
- package/root/lilact.development.min.js.map +0 -7
- package/root/lilact.production.min.js +0 -106
- package/scripts/copy-dist-to-root.mjs +0 -13
- /package/{root → examples}/demos/actionstate.jsx +0 -0
- /package/{root → examples}/demos/capture.jsx +0 -0
- /package/{root → examples}/demos/context.jsx +0 -0
- /package/{root → examples}/demos/css-transition.jsx +0 -0
- /package/{root → examples}/demos/error-boundary.jsx +0 -0
- /package/{root → examples}/demos/error-callback.jsx +0 -0
- /package/{root → examples}/demos/error-component-stack.jsx +0 -0
- /package/{root → examples}/demos/error-init.jsx +0 -0
- /package/{root → examples}/demos/error-parser.jsx +0 -0
- /package/{root → examples}/demos/form-elements.jsx +0 -0
- /package/{root → examples}/demos/forwardref.jsx +0 -0
- /package/{root → examples}/demos/lazy.jsx +0 -0
- /package/{root → examples}/demos/modal.jsx +0 -0
- /package/{root → examples}/demos/proptypes.jsx +0 -0
- /package/{root → examples}/demos/reducer.jsx +0 -0
- /package/{root → examples}/demos/redux.jsx +0 -0
- /package/{root → examples}/demos/router.jsx +0 -0
- /package/{root → examples}/demos/stopwatch.jsx +0 -0
- /package/{root → examples}/demos/suspense.jsx +0 -0
- /package/{root → examples}/demos/switch-transition.jsx +0 -0
- /package/{root → examples}/demos/transition.jsx +0 -0
- /package/{root → examples}/demos/usedefered.jsx +0 -0
- /package/{root → examples}/demos/usetransition.jsx +0 -0
- /package/{root → examples}/icon.png +0 -0
- /package/{root → examples}/index.html +0 -0
- /package/{root → examples}/prismjs/LICENSE.md +0 -0
- /package/{root → examples}/prismjs/prism-jsx.min.js +0 -0
- /package/{root → examples}/prismjs/prism.min.css +0 -0
- /package/{root → examples}/prismjs/prism.min.js +0 -0
package/bin/copy-demo.js
CHANGED
|
@@ -19,7 +19,7 @@ function copyDirRecursive(src, dest) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const typedocOut = process.env.TYPEDOC_OUT || 'docs';
|
|
22
|
-
const from = path.resolve(__dirname, '..', '
|
|
22
|
+
const from = path.resolve(__dirname, '..', 'examples');
|
|
23
23
|
const to = path.resolve(__dirname, '..', typedocOut, 'static');
|
|
24
24
|
|
|
25
25
|
copyDirRecursive(from, to);
|
|
@@ -2431,7 +2431,7 @@ var ComponentCore = class {
|
|
|
2431
2431
|
}
|
|
2432
2432
|
}
|
|
2433
2433
|
updateElementProps(patch, force = false) {
|
|
2434
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2434
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2435
2435
|
if (this.entity === "input") {
|
|
2436
2436
|
if (!(patch == null ? void 0 : patch.type)) patch.type = "text";
|
|
2437
2437
|
if (patch.type !== this.element.type) {
|
|
@@ -2473,18 +2473,29 @@ var ComponentCore = class {
|
|
|
2473
2473
|
(_d = this.event_detachers) != null ? _d : this.event_detachers = {};
|
|
2474
2474
|
(_f = (_e = this.event_detachers)[al]) == null ? void 0 : _f.call(_e);
|
|
2475
2475
|
this.event_detachers[al] = lilact_default.addWrappedEventListener(this.element, alc.substring(2), patch[a], { capture: true });
|
|
2476
|
-
} else if (
|
|
2477
|
-
if (typeof patch
|
|
2478
|
-
this.element.style = patch
|
|
2476
|
+
} else if (a === "style") {
|
|
2477
|
+
if (typeof patch.style === "string") {
|
|
2478
|
+
this.element.style = patch.style;
|
|
2479
2479
|
} else {
|
|
2480
|
-
|
|
2480
|
+
if ((_g = this.props) == null ? void 0 : _g.style) {
|
|
2481
|
+
if (typeof this.props.style === "string") {
|
|
2482
|
+
this.element.style = "";
|
|
2483
|
+
} else {
|
|
2484
|
+
for (let p in this.props.style) {
|
|
2485
|
+
if (!patch.style.hasOwnProperty(p)) {
|
|
2486
|
+
this.element.style[p] = "";
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
for (const x in patch.style) {
|
|
2481
2492
|
if (length_css_attributes_set.has(x)) {
|
|
2482
|
-
if (isFinite(patch[
|
|
2483
|
-
patch[
|
|
2493
|
+
if (isFinite(patch.style[x])) {
|
|
2494
|
+
patch.style[x] += "px";
|
|
2484
2495
|
}
|
|
2485
2496
|
}
|
|
2486
2497
|
}
|
|
2487
|
-
Object.assign(this.element.style, patch
|
|
2498
|
+
Object.assign(this.element.style, patch.style);
|
|
2488
2499
|
}
|
|
2489
2500
|
} else if (boolean_html_attributes_set.has(a)) {
|
|
2490
2501
|
this.element[a] = toBool(patch[a]);
|
|
@@ -4510,8 +4521,8 @@ function Spinner({
|
|
|
4510
4521
|
animation: "ddSpinnerSpin 0.9s linear infinite",
|
|
4511
4522
|
boxSizing: "border-box"
|
|
4512
4523
|
} }), createComponent("style", {}, `
|
|
4513
|
-
|
|
4514
|
-
|
|
4524
|
+
@keyframes ddSpinnerSpin { to { transform: rotate(360deg); } }
|
|
4525
|
+
`));
|
|
4515
4526
|
}
|
|
4516
4527
|
var ErrorBoundary = class extends Component {
|
|
4517
4528
|
constructor() {
|
|
@@ -4697,14 +4708,9 @@ function DragHandle({
|
|
|
4697
4708
|
}, [endDrag]);
|
|
4698
4709
|
return createComponent("div", { "role": "button", "tabIndex": 0, "style": { ...style, touchAction: "none" }, "className": cx2(className, isDragging ? "dragging" : ""), "onPointerDown": onPointerDown, "onPointerMove": onPointerMove, "onPointerUp": onPointerUp, "onPointerCancel": onPointerCancel }, children);
|
|
4699
4710
|
}
|
|
4700
|
-
var clamp = (n, min, max) => {
|
|
4701
|
-
if (!Number.isFinite(n)) return n;
|
|
4702
|
-
return Math.min(max, Math.max(min, n));
|
|
4703
|
-
};
|
|
4704
4711
|
var SplitPane = forwardRef(function SplitPane2({
|
|
4705
4712
|
mode = "horizontal",
|
|
4706
4713
|
position: position2,
|
|
4707
|
-
// controlled: number | undefined/null
|
|
4708
4714
|
defaultPosition = 0.5,
|
|
4709
4715
|
min = 0.1,
|
|
4710
4716
|
max = 0.9,
|
|
@@ -4712,135 +4718,139 @@ var SplitPane = forwardRef(function SplitPane2({
|
|
|
4712
4718
|
onSizeChange,
|
|
4713
4719
|
style,
|
|
4714
4720
|
className,
|
|
4715
|
-
|
|
4716
|
-
|
|
4721
|
+
firstPaneStyle,
|
|
4722
|
+
secondPaneStyle,
|
|
4717
4723
|
splitterStyle,
|
|
4718
4724
|
children
|
|
4719
4725
|
}, ref) {
|
|
4720
|
-
|
|
4721
|
-
const
|
|
4722
|
-
const
|
|
4723
|
-
const
|
|
4724
|
-
const rightChild = (_b = panes[1]) != null ? _b : null;
|
|
4725
|
-
const isControlled = position2 != null;
|
|
4726
|
-
const [internalMode, setInternalMode] = useState(mode);
|
|
4727
|
-
const [posUncontrolled, setPosUncontrolled] = useState(
|
|
4728
|
-
() => clamp(
|
|
4729
|
-
position2 != null ? position2 : defaultPosition,
|
|
4730
|
-
min,
|
|
4731
|
-
max
|
|
4732
|
-
)
|
|
4733
|
-
);
|
|
4726
|
+
const initialMode = mode === "vertical" ? "vertical" : "horizontal";
|
|
4727
|
+
const [internalMode, setInternalMode] = useState(initialMode);
|
|
4728
|
+
const [internalPos, setInternalPos] = useState(clamp(defaultPosition, min, max));
|
|
4729
|
+
const posResolved = position2 == null ? internalPos : clamp(position2, min, max);
|
|
4734
4730
|
useEffect(() => {
|
|
4735
|
-
if (
|
|
4731
|
+
if (position2 == null) return;
|
|
4732
|
+
setInternalPos(clamp(position2, min, max));
|
|
4733
|
+
}, [position2, min, max]);
|
|
4734
|
+
useEffect(() => {
|
|
4735
|
+
setInternalMode(mode === "vertical" ? "vertical" : "horizontal");
|
|
4736
4736
|
}, [mode]);
|
|
4737
|
-
useLayoutEffect(() => {
|
|
4738
|
-
if (isControlled) return;
|
|
4739
|
-
setPosUncontrolled((p) => clamp(p, min, max));
|
|
4740
|
-
}, [min, max, isControlled]);
|
|
4741
|
-
const posResolved = isControlled ? clamp(position2, min, max) : posUncontrolled;
|
|
4742
4737
|
const setPosition = (next2) => {
|
|
4743
4738
|
const clamped = clamp(next2, min, max);
|
|
4744
|
-
if (
|
|
4739
|
+
if (position2 == null) setInternalPos(clamped);
|
|
4745
4740
|
onSizeChange == null ? void 0 : onSizeChange(clamped);
|
|
4746
4741
|
};
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4742
|
+
useImperativeHandle(ref, () => ({
|
|
4743
|
+
setPosition,
|
|
4744
|
+
setMode: (nextMode) => setInternalMode(nextMode === "vertical" ? "vertical" : "horizontal"),
|
|
4745
|
+
getPosition: () => posResolved,
|
|
4746
|
+
getMode: () => internalMode
|
|
4747
|
+
}));
|
|
4748
|
+
const containerRef = useRef(null);
|
|
4749
|
+
const sizeRef = useRef({ w: 0, h: 0 });
|
|
4750
|
+
useLayoutEffect(() => {
|
|
4750
4751
|
const el = containerRef.current;
|
|
4751
4752
|
if (!el) return;
|
|
4753
|
+
const ro = new ResizeObserver(() => {
|
|
4754
|
+
const rect2 = el.getBoundingClientRect();
|
|
4755
|
+
sizeRef.current = { w: rect2.width, h: rect2.height };
|
|
4756
|
+
});
|
|
4757
|
+
ro.observe(el);
|
|
4752
4758
|
const rect = el.getBoundingClientRect();
|
|
4759
|
+
sizeRef.current = { w: rect.width, h: rect.height };
|
|
4760
|
+
return () => ro.disconnect();
|
|
4761
|
+
}, []);
|
|
4762
|
+
const startPosRef = useRef(posResolved);
|
|
4763
|
+
const [dragging, setDragging] = useState(false);
|
|
4764
|
+
const handleStart = () => {
|
|
4765
|
+
setDragging(true);
|
|
4766
|
+
startPosRef.current = posResolved;
|
|
4767
|
+
};
|
|
4768
|
+
const handleDelta = (x, y, _data) => {
|
|
4769
|
+
const { w, h } = sizeRef.current;
|
|
4753
4770
|
if (internalMode === "horizontal") {
|
|
4754
|
-
|
|
4755
|
-
if (!Number.isFinite(usable) || usable <= 0) return;
|
|
4756
|
-
const raw = (clientX - rect.left) / usable;
|
|
4757
|
-
if (!Number.isFinite(raw)) return;
|
|
4758
|
-
setPosition(raw);
|
|
4771
|
+
setPosition(startPosRef.current + x / (w || 1));
|
|
4759
4772
|
} else {
|
|
4760
|
-
|
|
4761
|
-
if (!Number.isFinite(usable) || usable <= 0) return;
|
|
4762
|
-
const raw = (clientY - rect.top) / usable;
|
|
4763
|
-
if (!Number.isFinite(raw)) return;
|
|
4764
|
-
setPosition(raw);
|
|
4773
|
+
setPosition(startPosRef.current + y / (h || 1));
|
|
4765
4774
|
}
|
|
4766
4775
|
};
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
const onPointerDown = (e) => {
|
|
4789
|
-
var _a2, _b2;
|
|
4790
|
-
if (e.button != null && e.button !== 0) return;
|
|
4791
|
-
e.preventDefault();
|
|
4792
|
-
draggingRef.current = true;
|
|
4793
|
-
pointerIdRef.current = e.pointerId;
|
|
4794
|
-
try {
|
|
4795
|
-
(_b2 = (_a2 = e.currentTarget).setPointerCapture) == null ? void 0 : _b2.call(_a2, e.pointerId);
|
|
4796
|
-
} catch (e2) {
|
|
4797
|
-
}
|
|
4798
|
-
updateFromClient(e.clientX, e.clientY);
|
|
4776
|
+
const handleEnd = () => setDragging(false);
|
|
4777
|
+
const arr = Children.toArray(children);
|
|
4778
|
+
const firstChild = arr[0];
|
|
4779
|
+
const secondChild = arr[1];
|
|
4780
|
+
const p = posResolved;
|
|
4781
|
+
const pane1StyleAbs = internalMode === "horizontal" ? {
|
|
4782
|
+
position: "absolute",
|
|
4783
|
+
top: 0,
|
|
4784
|
+
bottom: 0,
|
|
4785
|
+
left: 0,
|
|
4786
|
+
width: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
4787
|
+
overflow: "auto",
|
|
4788
|
+
...firstPaneStyle || {}
|
|
4789
|
+
} : {
|
|
4790
|
+
position: "absolute",
|
|
4791
|
+
left: 0,
|
|
4792
|
+
right: 0,
|
|
4793
|
+
top: 0,
|
|
4794
|
+
height: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
4795
|
+
overflow: "auto",
|
|
4796
|
+
...firstPaneStyle || {}
|
|
4799
4797
|
};
|
|
4800
|
-
const
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4798
|
+
const pane2StyleAbs = internalMode === "horizontal" ? {
|
|
4799
|
+
position: "absolute",
|
|
4800
|
+
top: 0,
|
|
4801
|
+
bottom: 0,
|
|
4802
|
+
left: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
|
|
4803
|
+
right: 0,
|
|
4804
|
+
overflow: "auto",
|
|
4805
|
+
...secondPaneStyle || {}
|
|
4806
|
+
} : {
|
|
4807
|
+
position: "absolute",
|
|
4808
|
+
left: 0,
|
|
4809
|
+
right: 0,
|
|
4810
|
+
top: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
|
|
4811
|
+
bottom: 0,
|
|
4812
|
+
overflow: "auto",
|
|
4813
|
+
...secondPaneStyle || {}
|
|
4814
4814
|
};
|
|
4815
|
-
const
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
}
|
|
4820
|
-
const
|
|
4821
|
-
|
|
4822
|
-
|
|
4815
|
+
const splitterBase = {
|
|
4816
|
+
background: "rgba(0,0,0,0.08)",
|
|
4817
|
+
boxShadow: "inset 0 0 2px rgba(0,0,0,0.25)",
|
|
4818
|
+
zIndex: 10
|
|
4819
|
+
};
|
|
4820
|
+
const splitterAbsStyle = internalMode === "horizontal" ? {
|
|
4821
|
+
position: "absolute",
|
|
4822
|
+
top: 0,
|
|
4823
|
+
bottom: 0,
|
|
4824
|
+
left: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
4825
|
+
width: splitterSize,
|
|
4823
4826
|
height: "100%",
|
|
4824
|
-
|
|
4827
|
+
cursor: dragging ? "col-resize" : "col-resize",
|
|
4825
4828
|
touchAction: "none",
|
|
4826
|
-
|
|
4827
|
-
|
|
4829
|
+
pointerEvents: "auto",
|
|
4830
|
+
...splitterBase,
|
|
4831
|
+
...splitterStyle || {}
|
|
4832
|
+
} : {
|
|
4833
|
+
position: "absolute",
|
|
4834
|
+
left: 0,
|
|
4835
|
+
right: 0,
|
|
4836
|
+
top: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
4837
|
+
height: splitterSize,
|
|
4838
|
+
width: "100%",
|
|
4839
|
+
cursor: dragging ? "row-resize" : "row-resize",
|
|
4840
|
+
touchAction: "none",
|
|
4841
|
+
pointerEvents: "auto",
|
|
4842
|
+
...splitterBase,
|
|
4843
|
+
...splitterStyle || {}
|
|
4828
4844
|
};
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
getPosition: () => posResolved,
|
|
4837
|
-
getMode: () => internalMode
|
|
4838
|
-
}));
|
|
4839
|
-
return createComponent("div", { "ref": containerRef, "className": className, "style": rootStyle }, createComponent("div", { "style": leftPaneComputed }, leftChild), createComponent("div", { "role": "separator", "aria-orientation": internalMode === "horizontal" ? "vertical" : "horizontal", "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": posResolved, "tabIndex": 0, "onPointerDown": onPointerDown, "onPointerCancel": () => {
|
|
4840
|
-
draggingRef.current = false;
|
|
4841
|
-
pointerIdRef.current = null;
|
|
4842
|
-
}, "onKeyDown": onKeyDown, "style": splitterComputed }, createComponent("div", { "style": dividerVisualStyle })), createComponent("div", { "style": rightPaneComputed }, rightChild));
|
|
4845
|
+
return createComponent("div", { "ref": containerRef, "className": className, "style": {
|
|
4846
|
+
position: "relative",
|
|
4847
|
+
width: "100%",
|
|
4848
|
+
height: "100%",
|
|
4849
|
+
overflow: "hidden",
|
|
4850
|
+
...style || {}
|
|
4851
|
+
} }, createComponent("div", { "style": pane1StyleAbs }, firstChild), createComponent("div", { "style": pane2StyleAbs }, secondChild), createComponent(DragHandle, { "onStart": handleStart, "onDelta": handleDelta, "onEnd": handleEnd, "style": splitterAbsStyle, "className": "splitter" }));
|
|
4843
4852
|
});
|
|
4853
|
+
var clamp = (v, min, max) => Math.max(min, Math.min(max, v));
|
|
4844
4854
|
|
|
4845
4855
|
// .tmp/src/vlq.js
|
|
4846
4856
|
var char_to_integer = {};
|